Overview

Packages

  • ActiveSync
  • None

Classes

  • Horde_ActiveSync
  • Horde_ActiveSync_Connector_Exporter
  • Horde_ActiveSync_Connector_Importer
  • Horde_ActiveSync_Driver_Base
  • Horde_ActiveSync_Exception
  • Horde_ActiveSync_Exception_InvalidRequest
  • Horde_ActiveSync_Exception_StateGone
  • Horde_ActiveSync_Message_Base
  • Horde_ActiveSync_Request_Base
  • Horde_ActiveSync_Request_FolderCreate
  • Horde_ActiveSync_Request_FolderSync
  • Horde_ActiveSync_Request_GetHierarchy
  • Horde_ActiveSync_Request_GetItemEstimate
  • Horde_ActiveSync_Request_MeetingResponse
  • Horde_ActiveSync_Request_MoveItems
  • Horde_ActiveSync_Request_Notify
  • Horde_ActiveSync_Request_Ping
  • Horde_ActiveSync_Request_Provision
  • Horde_ActiveSync_Request_Search
  • Horde_ActiveSync_Request_SendMail
  • Horde_ActiveSync_Request_SmartForward
  • Horde_ActiveSync_Request_SmartReply
  • Horde_ActiveSync_Request_Sync
  • Horde_ActiveSync_State_File
  • Horde_ActiveSync_Sync
  • Horde_ActiveSync_Wbxml
  • Horde_ActiveSync_Wbxml_Decoder
  • Horde_ActiveSync_Wbxml_Encoder
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * ActiveSync Handler for GetItemEstimate requests
  4:  *
  5:  * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  8:  * @package ActiveSync
  9:  */
 10: /**
 11:  * Zarafa Deutschland GmbH, www.zarafaserver.de
 12:  * This file is distributed under GPL-2.0.
 13:  * Consult COPYING file for details
 14:  */
 15: class Horde_ActiveSync_Request_GetItemEstimate extends Horde_ActiveSync_Request_Base
 16: {
 17:     /** Status Codes **/
 18:     const STATUS_SUCCESS = 1;
 19:     const STATUS_INVALIDCOL = 2;
 20:     const STATUS_NOTPRIMED = 3;
 21:     const STATUS_KEYMISM = 4;
 22: 
 23:     /* Request tag constants */
 24:     const GETITEMESTIMATE = 'GetItemEstimate:GetItemEstimate';
 25:     const VERSION = 'GetItemEstimate:Version';
 26:     const FOLDERS = 'GetItemEstimate:Folders';
 27:     const FOLDER = 'GetItemEstimate:Folder';
 28:     const FOLDERTYPE = 'GetItemEstimate:FolderType';
 29:     const FOLDERID = 'GetItemEstimate:FolderId';
 30:     const DATETIME = 'GetItemEstimate:DateTime';
 31:     const ESTIMATE = 'GetItemEstimate:Estimate';
 32:     const RESPONSE = 'GetItemEstimate:Response';
 33:     const STATUS = 'GetItemEstimate:Status';
 34: 
 35:     /**
 36:      * Handle the request
 37:      *
 38:      * @return boolean
 39:      * @throws Horde_ActiveSync_Exception
 40:      */
 41:     public function handle()
 42:     {
 43:         parent::handle();
 44:         $this->_logger->info('[' . $this->_device->id . '] Beginning GETITEMESTIMATE');
 45: 
 46:         /* Check policy */
 47:         if (!$this->checkPolicyKey($this->_activeSync->getPolicyKey())) {
 48:             return false;
 49:         }
 50: 
 51:         $status = array();
 52:         $collections = array();
 53:         if (!$this->_decoder->getElementStartTag(self::GETITEMESTIMATE) ||
 54:             !$this->_decoder->getElementStartTag(self::FOLDERS)) {
 55: 
 56:             // Not sure why the protocol doesn't have a status for this...
 57:             return false;
 58:         }
 59: 
 60:         /* Obtain all the collections we are getting estimates for */
 61:         while ($this->_decoder->getElementStartTag(self::FOLDER)) {
 62: 
 63:             /* Status - Assume success */
 64:             $cStatus = self::STATUS_SUCCESS;
 65: 
 66:             /* Collection Class */
 67:             if (!$this->_decoder->getElementStartTag(self::FOLDERTYPE)) {
 68:                 return false;
 69:             }
 70:             $class = $this->_decoder->getElementContent();
 71:             if (!$this->_decoder->getElementEndTag()) {
 72:                 return false;
 73:             }
 74: 
 75:             /* Collection Id */
 76:             if ($this->_decoder->getElementStartTag(self::FOLDERID)) {
 77:                 $collectionid = $this->_decoder->getElementContent();
 78:                 if (!$this->_decoder->getElementEndTag()) {
 79:                     return false;
 80:                 }
 81:             }
 82: 
 83:             /* Filter Type */
 84:             if (!$this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_FILTERTYPE)) {
 85:                 return false;
 86:             }
 87:             $filtertype = $this->_decoder->getElementContent();
 88:             if (!$this->_decoder->getElementEndTag()) {
 89:                 return false;
 90:             }
 91: 
 92:             /* Sync Key */
 93:             if (!$this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_SYNCKEY)) {
 94:                 return false;
 95:             }
 96:             $synckey = $this->_decoder->getElementContent();
 97:             if (empty($synckey)) {
 98:                 $cStatus = self::STATUS_NOTPRIMED;
 99:             }
100:             if (!$this->_decoder->getElementEndTag()) {
101:                 return false;
102:             }
103: 
104:             /* End the FOLDER element */
105:             if (!$this->_decoder->getElementEndTag()) {
106:                 return false;
107:             }
108: 
109:             /* Build the collection array */
110:             $collection = array();
111:             $collection['synckey'] = $synckey;
112:             $collection['class'] = $class;
113:             $collection['filtertype'] = $filtertype;
114: 
115:             /* compatibility mode - get id from state */
116:             if (!isset($collectionid)) {
117:                 $collectionid = $this->_state>getFolderData($this->_device->id, $collection['class']);
118:             }
119:             $collection['id'] = $collectionid;
120:             $status[$collection['id']] = $cStatus;
121: 
122:             array_push($collections, $collection);
123:         }
124: 
125:         $this->_encoder->startWBXML();
126: 
127:         /* Start getting the actual esitmates and outputting the results */
128:         $this->_encoder->startTag(self::GETITEMESTIMATE);
129:         foreach ($collections as $collection) {
130:             $this->_state->init($collection);
131:             try {
132:                 $this->_state->loadState($collection['synckey']);
133:             } catch (Horde_ActiveSync_Exception $e) {
134:                 $status[$collection['id']] = self::STATUS_KEYMISM;
135:             }
136:             $this->_encoder->startTag(self::RESPONSE);
137:             $this->_encoder->startTag(self::STATUS);
138:             $this->_encoder->content($status[$collection['id']]);
139:             $this->_encoder->endTag();
140:             $this->_encoder->startTag(self::FOLDER);
141:             $this->_encoder->startTag(self::FOLDERTYPE);
142:             $this->_encoder->content($collection['class']);
143:             $this->_encoder->endTag();
144:             $this->_encoder->startTag(self::FOLDERID);
145:             $this->_encoder->content($collection['id']);
146:             $this->_encoder->endTag();
147:             $this->_encoder->startTag(self::ESTIMATE);
148:             $sync = $this->_driver->getSyncObject();
149:             $sync->init($this->_state, null, $collection);
150:             $this->_encoder->content($sync->GetChangeCount());
151:             $this->_encoder->endTag();
152:             $this->_encoder->endTag();
153:             $this->_encoder->endTag();
154:         }
155:         $this->_encoder->endTag();
156: 
157:         return true;
158:     }
159: 
160: }
161: 
API documentation generated by ApiGen