Changeset 814bafc in github


Ignore:
Timestamp:
Dec 27, 2010 9:50:21 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
a63b36a
Parents:
dd944d9
Message:
  • Add handling of multifolder METADATA/ANNOTATION responses
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r1c7b94b5 r814bafc  
    44- Show the same message only once (#1487641) 
    55- Fix namespaces handling (#1487649) 
     6- Add handling of multifolder METADATA/ANNOTATION responses 
    67 
    78RELEASE 0.5-RC 
  • program/include/rcube_imap_generic.php

    r7f1da48 r814bafc  
    28072807            $this->escape($mailbox), $optlist)); 
    28082808 
    2809         if ($code == self::ERROR_OK && preg_match('/^\* METADATA /i', $response)) { 
    2810             // Parse server response (remove "* METADATA ") 
    2811             $response = substr($response, 11); 
    2812             $ret_mbox = $this->tokenizeResponse($response, 1); 
    2813             $data     = $this->tokenizeResponse($response); 
     2809        if ($code == self::ERROR_OK) { 
     2810            $result = array(); 
     2811            $data   = $this->tokenizeResponse($response); 
    28142812 
    28152813            // The METADATA response can contain multiple entries in a single 
     
    28172815            if (!empty($data) && ($size = count($data))) { 
    28182816                for ($i=0; $i<$size; $i++) { 
    2819                     if (is_array($data[$i])) { 
     2817                    if (isset($mbox) && is_array($data[$i])) { 
    28202818                        $size_sub = count($data[$i]); 
    28212819                        for ($x=0; $x<$size_sub; $x++) { 
    2822                             $data[$data[$i][$x]] = $data[$i][++$x]; 
     2820                            $result[$mbox][$data[$i][$x]] = $data[$i][++$x]; 
    28232821                        } 
    28242822                        unset($data[$i]); 
    28252823                    } 
    2826                     else if ($data[$i] == '*' && $data[$i+1] == 'METADATA') { 
    2827                         unset($data[$i]);   // "*" 
    2828                         unset($data[++$i]); // "METADATA" 
    2829                         unset($data[++$i]); // Mailbox 
    2830                     } 
    2831                     else { 
    2832                         $data[$data[$i]] = $data[++$i]; 
     2824                    else if ($data[$i] == '*') { 
     2825                        if ($data[$i+1] == 'METADATA') { 
     2826                            $mbox = $data[$i+2]; 
     2827                            unset($data[$i]);   // "*" 
     2828                            unset($data[++$i]); // "METADATA" 
     2829                            unset($data[++$i]); // Mailbox 
     2830                        } 
     2831                        // get rid of other untagged responses 
     2832                        else { 
     2833                            unset($mbox); 
     2834                            unset($data[$i]); 
     2835                        } 
     2836                    } 
     2837                    else if (isset($mbox)) { 
     2838                        $result[$mbox][$data[$i]] = $data[++$i]; 
    28332839                        unset($data[$i]); 
    28342840                        unset($data[$i-1]); 
    28352841                    } 
    2836                 } 
    2837             } 
    2838  
    2839             return $data; 
     2842                    else { 
     2843                        unset($data[$i]); 
     2844                    } 
     2845                } 
     2846            } 
     2847 
     2848            return $result; 
    28402849        } 
    28412850 
     
    29412950            $this->escape($mailbox), $entries, $attribs)); 
    29422951 
    2943         if ($code == self::ERROR_OK && preg_match('/^\* ANNOTATION /i', $response)) { 
    2944             // Parse server response (remove "* ANNOTATION ") 
    2945             $response = substr($response, 13); 
    2946             $ret_mbox = $this->tokenizeResponse($response, 1); 
    2947             $data     = $this->tokenizeResponse($response); 
    2948             $res      = array(); 
     2952        if ($code == self::ERROR_OK) { 
     2953            $result = array(); 
     2954            $data   = $this->tokenizeResponse($response); 
    29492955 
    29502956            // Here we returns only data compatible with METADATA result format 
    29512957            if (!empty($data) && ($size = count($data))) { 
    29522958                for ($i=0; $i<$size; $i++) { 
    2953                     $entry = $data[$i++]; 
    2954                     if (is_array($entry)) { 
     2959                    $entry = $data[$i]; 
     2960                    if (isset($mbox) && is_array($entry)) { 
    29552961                        $attribs = $entry; 
    29562962                        $entry   = $last_entry; 
    29572963                    } 
    2958                     else 
    2959                         $attribs = $data[$i++]; 
     2964                    else if ($entry == '*') { 
     2965                        if ($data[$i+1] == 'ANNOTATION') { 
     2966                            $mbox = $data[$i+2]; 
     2967                            unset($data[$i]);   // "*" 
     2968                            unset($data[++$i]); // "ANNOTATION" 
     2969                            unset($data[++$i]); // Mailbox 
     2970                        } 
     2971                        // get rid of other untagged responses 
     2972                        else { 
     2973                            unset($mbox); 
     2974                            unset($data[$i]); 
     2975                        } 
     2976                        continue; 
     2977                    } 
     2978                    else if (isset($mbox)) { 
     2979                        $attribs = $data[++$i]; 
     2980                    } 
     2981                    else { 
     2982                        unset($data[$i]); 
     2983                        continue; 
     2984                    } 
    29602985 
    29612986                    if (!empty($attribs)) { 
     
    29642989                            $value = $attribs[$x++]; 
    29652990                            if ($attr == 'value.priv') { 
    2966                                 $res['/private' . $entry] = $value; 
     2991                                $result[$mbox]['/private' . $entry] = $value; 
    29672992                            } 
    29682993                            else if ($attr == 'value.shared') { 
    2969                                 $res['/shared' . $entry] = $value; 
     2994                                $result[$mbox]['/shared' . $entry] = $value; 
    29702995                            } 
    29712996                        } 
    29722997                    } 
    29732998                    $last_entry = $entry; 
    2974                     unset($data[$i-1]); 
    2975                     unset($data[$i-2]); 
    2976                 } 
    2977             } 
    2978  
    2979             return $res; 
     2999                    unset($data[$i]); 
     3000                } 
     3001            } 
     3002 
     3003            return $result; 
    29803004        } 
    29813005 
Note: See TracChangeset for help on using the changeset viewer.