/**
  * Private helper method
  *
  * @param   &peer.mail.MimePart[] parts
  * @param   array p structure parts as retrieved from cclient lib
  * @param   string id default '' part id
  */
 protected function _recurseparts(&$parts, $p, $id = '')
 {
     static $types = array('text', 'multipart', 'message', 'application', 'audio', 'image', 'video', 'unknown');
     for ($i = 0, $s = sizeof($p); $i < $s; $i++) {
         $pid = sprintf('%s%d', $id, $i + 1);
         if (empty($p[$i]->parts)) {
             $part = new MimePart(NULL, NULL, $this->_lookupattr(@$p[$i]->parameters, 'CHARSET'), $this->_lookupattr(@$p[$i]->dparameters, 'NAME'));
         } else {
             $part = new MultiPart();
         }
         $part->setContentType($types[$p[$i]->type] . '/' . strtolower($p[$i]->subtype));
         $part->setDisposition($p[$i]->ifdisposition ? MIME_DISPOSITION_ATTACHMENT : MIME_DISPOSITION_INLINE);
         if (FALSE !== ($f = $this->_lookupattr($p[$i]->dparameters, 'FILENAME'))) {
             $part->setFilename($f);
         }
         $part->id = $pid;
         // We can retrieve the body here since the message has been read anyway
         if (!empty($p[$i]->parts)) {
             if ($p[$i]->ifsubtype) {
                 switch ($p[$i]->subtype) {
                     case 'MIXED':
                         $pid = substr($pid, 0, -2);
                         break;
                     default:
                         // Nothing
                 }
             }
             // Recurse through parts
             $this->_recurseparts($part->parts, $p[$i]->parts, $pid . '.');
             // Multipart -> part.0 are the headers
             $part->parts[0]->setHeaderString($this->folder->getMessagePart($this->uid, $pid . '.0'));
         } else {
             $part->body = $this->folder->getMessagePart($this->uid, $pid);
         }
         $part->folder = $this->folder;
         $parts[] = $part;
     }
 }