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:  * Connector class for exporting ActiveSync messages to the wbxml output stream.
  4:  * Contains code written by the Z-Push project. Original file header preserved
  5:  * below.
  6:  *
  7:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
  8:  *
  9:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
 10:  * @package ActiveSync
 11:  */
 12: 
 13: /**
 14:  * File      :   streamimporter.php
 15:  * Project   :   Z-Push
 16:  * Descr     :   Stream import classes
 17:  *
 18:  * Created   :   01.10.2007
 19:  *
 20:  * © Zarafa Deutschland GmbH, www.zarafaserver.de
 21:  * This file is distributed under GPL-2.0.
 22:  * Consult COPYING file for details
 23:  */
 24: class Horde_ActiveSync_Connector_Exporter
 25: {
 26:     /**
 27:      * The wbxml encoder
 28:      *
 29:      * @var Horde_ActiveSync_Wbxml_Encoder
 30:      */
 31:     protected $_encoder;
 32: 
 33:     /**
 34:      * The collection class for what we are exporting
 35:      *
 36:      * @var string
 37:      */
 38:     protected $_class;
 39: 
 40:     /**
 41:      * Local cache of object ids we have already dealt with.
 42:      *
 43:      * @var array
 44:      */
 45:     protected $_seenObjects = array();
 46: 
 47:     /**
 48:      * Array of object ids that have changed.
 49:      * Used when exporting folder structure changes since they are not streamed
 50:      * from this object.
 51:      *
 52:      * @var array
 53:      */
 54:     public $changed = array();
 55: 
 56:     /**
 57:      * Array of folder ids that have been deleted on the server.
 58:      *
 59:      * @var array
 60:      */
 61:     public $deleted = array();
 62: 
 63:     /**
 64:      * Tracks the total number of folder changes
 65:      *
 66:      * @var integer
 67:      */
 68:     public $count = 0;
 69: 
 70:     /**
 71:      * Const'r
 72:      *
 73:      * @param Horde_ActiveSync_Wbxml_Encoder $encoder The encoder
 74:      * @param string $class                           The collection class
 75:      *
 76:      * @return Horde_ActiveSync_Connector_Exporter
 77:      */
 78:     public function __construct($encoder = null, $class = null)
 79:     {
 80:         $this->_encoder = $encoder;
 81:         $this->_class = $class;
 82:     }
 83: 
 84:     /**
 85:      * Send a message change over the wbxml stream
 86:      *
 87:      * @param string $id                              The uid of the message
 88:      * @param Horde_ActiveSync_Message_Base $message  The message object
 89:      *
 90:      * @return boolean
 91:      */
 92:     public function messageChange($id, $message)
 93:     {
 94:         /* Just ignore any messages that are not from this collection */
 95:         if ($message->getClass() != $this->_class) {
 96:             return true;
 97:         }
 98: 
 99:         /* Prevent sending the same object twice in one request */
100:         if (in_array($id, $this->_seenObjects)) {
101:             return true;
102:         }
103: 
104:         /* Remember this message */
105:         $this->_seenObjects[] = $id;
106: 
107:         /* Specify if this is an ADD or a MODIFY change? */
108:         if ($message->flags === false || $message->flags === Horde_ActiveSync::FLAG_NEWMESSAGE) {
109:             $this->_encoder->startTag(Horde_ActiveSync::SYNC_ADD);
110:         } else {
111:             $this->_encoder->startTag(Horde_ActiveSync::SYNC_MODIFY);
112:         }
113: 
114:         /* Send the message */
115:         $this->_encoder->startTag(Horde_ActiveSync::SYNC_SERVERENTRYID);
116:         $this->_encoder->content($id);
117:         $this->_encoder->endTag();
118:         $this->_encoder->startTag(Horde_ActiveSync::SYNC_DATA);
119:         $message->encodeStream($this->_encoder);
120:         $this->_encoder->endTag();
121:         $this->_encoder->endTag();
122: 
123:         return true;
124:     }
125: 
126:     /**
127:      * Stream a message deletion to the PIM
128:      *
129:      * @param string $id  The uid of the message we are deleting.
130:      *
131:      * @return boolean
132:      */
133:     public function messageDeletion($id)
134:     {
135:         $this->_encoder->startTag(Horde_ActiveSync::SYNC_REMOVE);
136:         $this->_encoder->startTag(Horde_ActiveSync::SYNC_SERVERENTRYID);
137:         $this->_encoder->content($id);
138:         $this->_encoder->endTag();
139:         $this->_encoder->endTag();
140: 
141:         return true;
142:     }
143: 
144:     /**
145:      * Change a message's READ flag.
146:      *
147:      * @param string $id      The uid
148:      * @param integer $flags  The flag
149:      *
150:      * @return boolean
151:      */
152:     public function messageReadFlag($id, $flags)
153:     {
154:         /* This only applies to mail folders */
155:         if ($this->_class != "syncmail") {
156:             return true;
157:         }
158: 
159:         /* Encode and stream */
160:         $this->_encoder->startTag(Horde_ActiveSync::SYNC_MODIFY);
161:         $this->_encoder->startTag(Horde_ActiveSync::SYNC_SERVERENTRYID);
162:         $this->_encoder->content($id);
163:         $this->_encoder->endTag();
164:         $this->_encoder->startTag(Horde_ActiveSync::SYNC_DATA);
165:         $this->_encoder->startTag(SYNC_POOMMAIL_READ);
166:         $this->_encoder->content($flags);
167:         $this->_encoder->endTag();
168:         $this->_encoder->endTag();
169:         $this->_encoder->endTag();
170: 
171:         return true;
172:     }
173: 
174:     /**
175:      * Move a message to a different folder.
176:      * @TODO
177:      * @param Horde_ActiveSync_Message_Base $message  The message
178:      *
179:      * @return boolean
180:      */
181:     function messageMove($message)
182:     {
183:         return true;
184:     }
185: 
186:     /**
187:      * Add a folder change to the cache. (used during FolderSync Requests).
188:      *
189:      * @param Horde_ActiveSync_Message_Folder $folder
190:      *
191:      * @return boolean
192:      */
193:     public function folderChange($folder)
194:     {
195:         array_push($this->changed, $folder);
196:         $this->count++;
197: 
198:         return true;
199:     }
200: 
201:     /**
202:      * Add a folder deletion to the cache (used during FolderSync Requests).
203:      *
204:      * @param string $id  The folder id
205:      *
206:      * @return boolean
207:      */
208:     public function folderDeletion($id)
209:     {
210:         array_push($this->deleted, $id);
211:         $this->count++;
212: 
213:         return true;
214:     }
215: }
API documentation generated by ApiGen