Return the number of bytes corresponding to the requested trunction
constant. This applies to MIMETRUNCATION only.
/** * Helper method to handle incoming OPTIONS nodes. * * @param array $collection The current collection array. */ public function _parseSyncOptions(&$collection) { $options = array(); $haveElement = false; // These can be sent in any order. while (1) { if ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_FILTERTYPE)) { $options['filtertype'] = $this->_decoder->getElementContent(); $haveElement = true; if (!$this->_decoder->getElementEndTag()) { $this->_statusCode = self::STATUS_PROTERROR; $this->_handleError($collection); exit; } } // EAS > 12.1 the Collection Class can be part of OPTIONS. if ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_FOLDERTYPE)) { $haveElement = true; $options['class'] = $this->_decoder->getElementContent(); if (!$this->_decoder->getElementEndTag()) { $this->_statusCode = self::STATUS_PROTERROR; $this->_handleError($collection); exit; } } if ($this->_decoder->getElementStartTag(Horde_ActiveSync::AIRSYNCBASE_BODYPREFERENCE)) { $this->_bodyPrefs($options); } if ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_CONFLICT)) { $haveElement = true; $options['conflict'] = $this->_decoder->getElementContent(); if (!$this->_decoder->getElementEndTag()) { $this->_statusCode = self::STATUS_PROTERROR; $this->_handleError; exit; } } if ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_MIMESUPPORT)) { $haveElement = true; $this->_mimeSupport($options); } // SYNC_MIMETRUNCATION is used when no SYNC_BODYPREFS element is sent. if ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_MIMETRUNCATION)) { $haveElement = true; $options['mimetruncation'] = Horde_ActiveSync::getMIMETruncSize($this->_decoder->getElementContent()); if (!$this->_decoder->getElementEndTag()) { $this->_statusCode = self::STATUS_PROTERROR; $this->_handleError($collection); exit; } } // SYNC_TRUNCATION only applies to the body of non-email collections // or the BODY element of an Email in EAS 2.5. if ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_TRUNCATION)) { $haveElement = true; $options['truncation'] = Horde_ActiveSync::getTruncSize($this->_decoder->getElementContent()); if (!$this->_decoder->getElementEndTag()) { $this->_statusCode = self::STATUS_PROTERROR; $this->_handleError($collection); exit; } } // @todo This seems to no longer be supported by the specs? Probably // a leftover from EAS 1 or 2.0. Remove in H6. if ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_RTFTRUNCATION)) { $haveElement = true; $options['rtftruncation'] = $this->_decoder->getElementContent(); if (!$this->_decoder->getElementEndTag()) { $this->_statusCode = self::STATUS_PROTERROR; $this->_handleError($collection); exit; } } if ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_MAXITEMS)) { $haveElement = true; $options['maxitems'] = $this->_decoder->getElementContent(); if (!$this->_decoder->getElementEndTag()) { $this->_statusCode = self::STATUS_PROTERROR; $this->_handleError($collection); exit; } } // EAS 14.1 if ($this->_device->version >= Horde_ActiveSync::VERSION_FOURTEENONE) { if ($this->_decoder->getElementStartTag(Horde_ActiveSync::RM_SUPPORT)) { $haveElement = true; $this->_rightsManagement($options); } if ($this->_decoder->getElementStartTag(Horde_ActiveSync::AIRSYNCBASE_BODYPARTPREFERENCE)) { $haveElement = true; $this->_bodyPartPrefs($options); } } $e = $this->_decoder->peek(); if ($e[Horde_ActiveSync_Wbxml::EN_TYPE] == Horde_ActiveSync_Wbxml::EN_TYPE_ENDTAG) { $this->_decoder->getElementEndTag(); break; } elseif (!$haveElement) { $depth = 0; while (1) { $e = $this->_decoder->getElement(); if ($e === false) { $this->_logger->err(sprintf('[%s] Unexpected end of stream.', $this->_procid)); $this->_statusCode = self::STATUS_PROTERROR; $this->_handleError($collection); exit; } elseif ($e[Horde_ActiveSync_Wbxml::EN_TYPE] == Horde_ActiveSync_Wbxml::EN_TYPE_STARTTAG) { $depth = $this->_decoder->isEmptyElement($e) ? $depth : $depth + 1; } elseif ($e[Horde_ActiveSync_Wbxml::EN_TYPE] == Horde_ActiveSync_Wbxml::EN_TYPE_ENDTAG) { $depth--; } if ($depth == 0) { break; } } } } // Default to no filter as per the specs. if (!isset($options['filtertype'])) { $options['filtertype'] = '0'; } if (!empty($options['class']) && $options['class'] == 'SMS') { return; } $collection = array_merge($collection, $options); }