From: Michael J. Rubinsky Date: Wed, 31 Mar 2010 21:43:53 +0000 (-0400) Subject: Refactor the Exporter/Streamer/Importer/HierarchyCache mess.... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f44355dda4a0b1a323a0cd3411b67c0a3ac3d1ed;p=horde.git Refactor the Exporter/Streamer/Importer/HierarchyCache mess.... Rename a bunch of classes and combine a few to better reflect what is happening here. As a bonus, cleans up the main directory of the package a bit. --- diff --git a/framework/ActiveSync/lib/Horde/ActiveSync.php b/framework/ActiveSync/lib/Horde/ActiveSync.php index 3a919b95d..dd6599157 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync.php @@ -1549,6 +1549,7 @@ class Horde_ActiveSync $device->userAgent = $this->_request->getHeader('User-Agent'); $device->deviceType = !empty($get['DeviceType']) ? $get['DeviceType'] : ''; $device->policykey = 0; + $device->rwstatus = 0; $state->setDeviceInfo($devId, $device); } diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Connector/Exporter.php b/framework/ActiveSync/lib/Horde/ActiveSync/Connector/Exporter.php new file mode 100644 index 000000000..89e77caba --- /dev/null +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Connector/Exporter.php @@ -0,0 +1,154 @@ +_encoder = $encoder; + $this->_type = $class; + $this->_seenObjects = array(); + } + + /** + * + * @param $id + * @param $message + * @return unknown_type + */ + public function messageChange($id, $message) + { + if ($message->getClass() != $this->_type) { + return true; // ignore other types + } + + // prevent sending the same object twice in one request + if (in_array($id, $this->_seenObjects)) { + return true; + } + + $this->_seenObjects[] = $id; + if ($message->flags === false || $message->flags === SYNC_NEWMESSAGE) { + $this->_encoder->startTag(SYNC_ADD); + } else { + $this->_encoder->startTag(SYNC_MODIFY); + } + + $this->_encoder->startTag(SYNC_SERVERENTRYID); + $this->_encoder->content($id); + $this->_encoder->endTag(); + $this->_encoder->startTag(SYNC_DATA); + $message->encodeStream($this->_encoder); + $this->_encoder->endTag(); + $this->_encoder->endTag(); + + return true; + } + + /** + * + * @param $id + * @return unknown_type + */ + public function messageDeletion($id) + { + $this->_encoder->startTag(SYNC_REMOVE); + $this->_encoder->startTag(SYNC_SERVERENTRYID); + $this->_encoder->content($id); + $this->_encoder->endTag(); + $this->_encoder->endTag(); + + return true; + } + + /** + * + * @param $id + * @param $flags + * @return unknown_type + */ + public function messageReadFlag($id, $flags) + { + if ($this->_type != "syncmail") { + return true; + } + $this->_encoder->startTag(SYNC_MODIFY); + $this->_encoder->startTag(SYNC_SERVERENTRYID); + $this->_encoder->content($id); + $this->_encoder->endTag(); + $this->_encoder->startTag(SYNC_DATA); + $this->_encoder->startTag(SYNC_POOMMAIL_READ); + $this->_encoder->content($flags); + $this->_encoder->endTag(); + $this->_encoder->endTag(); + $this->_encoder->endTag(); + + return true; + } + + /** + * + * @param $message + * @return unknown_type + */ + function messageMove($message) + { + return true; + } + + /** + * + * @param $folder + * @return + */ + public function FolderChange($folder) + { + array_push($this->changed, $folder); + $this->count++; + + return true; + } + + /** + * + * @param $id + * @return + */ + public function FolderDeletion($id) + { + array_push($this->deleted, $id); + $this->count++; + + return true; + } +} \ No newline at end of file diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Connector/Importer.php b/framework/ActiveSync/lib/Horde/ActiveSync/Connector/Importer.php new file mode 100644 index 000000000..15212e9ad --- /dev/null +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Connector/Importer.php @@ -0,0 +1,262 @@ + + */ + protected $_flags; + + /** + * The server specific folder id + * + * @var string + */ + protected $_folderId; + + protected $_logger; + + /** + * Const'r + * + * @param Horde_ActiveSync_Driver_Base $backend + * @param Horde_ActiveSync_StateMachine_Base $stateMachine + * @param $syncKey + * @param $flags + */ + public function __construct(Horde_ActiveSync_Driver_Base $backend) + { + $this->_backend = $backend; + } + + public function init(Horde_ActiveSync_State_Base &$stateMachine, + $folderId, $syncKey, $flags = 0) + { + $this->_stateMachine = &$stateMachine; + $this->_syncKey = $syncKey; + $this->_flags = $flags; + $this->_folderId = $folderId; + } + + public function setLogger($logger) + { + $this->_logger = $logger; + } + + /** + * + * @param mixed $id A server message id or + * false if a new message + * @param Horde_ActiveSync_Message_Base $message A message object + * + * @return mixed The server message id or false + */ + public function ImportMessageChange($id, $message) + { + //do nothing if it is in a dummy folder + if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) { + return false; + } + + if ($id) { + // See if there's a conflict + $conflict = $this->_isConflict('change', $this->_folderId, $id); + + // Update client state if this is an update + $change = array(); + $change['id'] = $id; + $change['mod'] = 0; // dummy, will be updated later if the change succeeds + $change['parent'] = $this->_folderId; + $change['flags'] = (isset($message->read)) ? $message->read : 0; + $this->_stateMachine->updateState('change', $change); + + if ($conflict && $this->_flags == SYNC_CONFLICT_OVERWRITE_PIM) { + return true; + } + } + + $stat = $this->_backend->ChangeMessage($this->_folderId, $id, $message); + // @TODO: Isn't this an error? + if (!is_array($stat)) { + return $stat; + } + + // Record the state of the message + $this->_stateMachine->updateState('change', $stat); + + return $stat['id']; + } + + /** + * Import a deletion. This may conflict if the local object has been + * modified. + * + * @param string $id Server message id + */ + public function ImportMessageDeletion($id) + { + //do nothing if it is in a dummy folder + if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) { + return true; + } + + // See if there's a conflict + $conflict = $this->_isConflict('delete', $this->_folderId, $id); + + // Update client state + $change = array(); + $change['id'] = $id; + $this->_stateMachine->updateState('delete', $change); + + // If there is a conflict, and the server 'wins', then return OK without + // performing the change this will cause the exporter to 'see' the + // overriding item as a change, and send it back to the PIM + if ($conflict && $this->_flags == SYNC_CONFLICT_OVERWRITE_PIM) { + return true; + } + + $this->_backend->DeleteMessage($this->_folderId, $id); + + return true; + } + + /** + * Import a change in 'read' flags .. This can never conflict + * + * @param string $id Server message id + * @param ?? $flags The read flags to set + */ + public function ImportMessageReadFlag($id, $flags) + { + //do nothing if it is a dummy folder + if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) { + return true; + } + + // Update client state + $change = array(); + $change['id'] = $id; + $change['flags'] = $flags; + $this->_stateMachine->updateState('flags', $change); + $this->_backend->SetReadFlag($this->_folderId, $id, $flags); + + return true; + } + + /** + * Not supported/todo? + * + * @param $id + * @param $newfolder + * @return + */ + public function ImportMessageMove($id, $newfolder) + { + return true; + } + + /** + * + * @param $id + * @param $parent + * @param $displayname + * @param $type + * @return unknown_type + */ + public function ImportFolderChange($id, $parent, $displayname, $type) + { + //do nothing if it is a dummy folder + if ($parent == SYNC_FOLDER_TYPE_DUMMY) { + return false; + } + + if ($id) { + $change = array(); + $change['id'] = $id; + $change['mod'] = $displayname; + $change['parent'] = $parent; + $change['flags'] = 0; + $this->_stateMachine->updateState('change', $change); + } + + // @TODO: ChangeFolder did not exist in ZPush's code?? + $stat = $this->_backend->ChangeFolder($parent, $id, $displayname, $type); + if ($stat) { + $this->_stateMachine->updateState('change', $stat); + } + + return $stat['id']; + } + + /** + * + * @param $id + * @param $parent + * @return unknown_type + */ + public function ImportFolderDeletion($id, $parent) + { + //do nothing if it is a dummy folder + if ($parent == SYNC_FOLDER_TYPE_DUMMY) { + return false; + } + + $change = array(); + $change['id'] = $id; + + $this->_stateMachine->updateState('delete', $change); + $this->_backend->DeleteFolder($parent, $id); + + return true; + } + + /** + * Returns TRUE if the given ID conflicts with the given operation. + * This is only true in the following situations: + * + * Changed here and changed there + * Changed here and deleted there + * Deleted here and changed there + * + * Any other combination of operations can be done + * (e.g. change flags & move or move & delete) + */ + protected function _isConflict($type, $folderid, $id) + { + $stat = $this->_backend->StatMessage($folderid, $id); + if (!$stat) { + // Message is gone + if ($type == 'change') { + return true; + } else { + return false; // all other remote changes still result in a delete (no conflict) + } + } + + return $this->_stateMachine->isConflict($stat, $type); + } + +} diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Connector/NullImporter.php b/framework/ActiveSync/lib/Horde/ActiveSync/Connector/NullImporter.php new file mode 100644 index 000000000..2d8f1d3e2 --- /dev/null +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Connector/NullImporter.php @@ -0,0 +1,11 @@ +setLogger($this->_logger); + $importer = new Horde_ActiveSync_Connector_Importer($this); return $importer; } diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/HierarchyCache.php b/framework/ActiveSync/lib/Horde/ActiveSync/HierarchyCache.php deleted file mode 100644 index 123b543bf..000000000 --- a/framework/ActiveSync/lib/Horde/ActiveSync/HierarchyCache.php +++ /dev/null @@ -1,47 +0,0 @@ -changed = array(); - $this->deleted = array(); - $this->count = 0; - - return true; - } - - public function FolderChange($folder) - { - array_push($this->changed, $folder); - $this->count++; - - return true; - } - - public function FolderDeletion($id) - { - array_push($this->deleted, $id); - $this->count++; - - return true; - } -} \ No newline at end of file diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Importer.php b/framework/ActiveSync/lib/Horde/ActiveSync/Importer.php deleted file mode 100644 index 913c2ce46..000000000 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Importer.php +++ /dev/null @@ -1,261 +0,0 @@ - - */ - protected $_flags; - - /** - * The server specific folder id - * - * @var string - */ - protected $_folderId; - - protected $_logger; - - /** - * Const'r - * - * @param Horde_ActiveSync_Driver_Base $backend - * @param Horde_ActiveSync_StateMachine_Base $stateMachine - * @param $syncKey - * @param $flags - */ - public function __construct(Horde_ActiveSync_Driver_Base $backend) - { - $this->_backend = $backend; - } - - public function init(Horde_ActiveSync_State_Base &$stateMachine, - $folderId, $syncKey, $flags = 0) - { - $this->_stateMachine = &$stateMachine; - $this->_syncKey = $syncKey; - $this->_flags = $flags; - $this->_folderId = $folderId; - } - - public function setLogger($logger) - { - $this->_logger = $logger; - } - - /** - * - * @param mixed $id A server message id or - * false if a new message - * @param Horde_ActiveSync_Message_Base $message A message object - * - * @return mixed The server message id or false - */ - public function ImportMessageChange($id, $message) - { - //do nothing if it is in a dummy folder - if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) { - return false; - } - - if ($id) { - // See if there's a conflict - $conflict = $this->_isConflict('change', $this->_folderId, $id); - - // Update client state if this is an update - $change = array(); - $change['id'] = $id; - $change['mod'] = 0; // dummy, will be updated later if the change succeeds - $change['parent'] = $this->_folderId; - $change['flags'] = (isset($message->read)) ? $message->read : 0; - $this->_stateMachine->updateState('change', $change); - - if ($conflict && $this->_flags == SYNC_CONFLICT_OVERWRITE_PIM) { - return true; - } - } - - $stat = $this->_backend->ChangeMessage($this->_folderId, $id, $message); - // @TODO: Isn't this an error? - if (!is_array($stat)) { - return $stat; - } - - // Record the state of the message - $this->_stateMachine->updateState('change', $stat); - - return $stat['id']; - } - - /** - * Import a deletion. This may conflict if the local object has been - * modified. - * - * @param string $id Server message id - */ - public function ImportMessageDeletion($id) - { - //do nothing if it is in a dummy folder - if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) { - return true; - } - - // See if there's a conflict - $conflict = $this->_isConflict('delete', $this->_folderId, $id); - - // Update client state - $change = array(); - $change['id'] = $id; - $this->_stateMachine->updateState('delete', $change); - - // If there is a conflict, and the server 'wins', then return OK without - // performing the change this will cause the exporter to 'see' the - // overriding item as a change, and send it back to the PIM - if ($conflict && $this->_flags == SYNC_CONFLICT_OVERWRITE_PIM) { - return true; - } - - $this->_backend->DeleteMessage($this->_folderId, $id); - - return true; - } - - /** - * Import a change in 'read' flags .. This can never conflict - * - * @param string $id Server message id - * @param ?? $flags The read flags to set - */ - public function ImportMessageReadFlag($id, $flags) - { - //do nothing if it is a dummy folder - if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) { - return true; - } - - // Update client state - $change = array(); - $change['id'] = $id; - $change['flags'] = $flags; - $this->_stateMachine->updateState('flags', $change); - $this->_backend->SetReadFlag($this->_folderId, $id, $flags); - - return true; - } - - /** - * Not supported/todo? - * - * @param $id - * @param $newfolder - * @return - */ - public function ImportMessageMove($id, $newfolder) - { - return true; - } - - /** - * - * @param $id - * @param $parent - * @param $displayname - * @param $type - * @return unknown_type - */ - public function ImportFolderChange($id, $parent, $displayname, $type) - { - //do nothing if it is a dummy folder - if ($parent == SYNC_FOLDER_TYPE_DUMMY) { - return false; - } - - if ($id) { - $change = array(); - $change['id'] = $id; - $change['mod'] = $displayname; - $change['parent'] = $parent; - $change['flags'] = 0; - $this->_stateMachine->updateState('change', $change); - } - - // @TODO: ChangeFolder did not exist in ZPush's code?? - $stat = $this->_backend->ChangeFolder($parent, $id, $displayname, $type); - if ($stat) { - $this->_stateMachine->updateState('change', $stat); - } - - return $stat['id']; - } - - /** - * - * @param $id - * @param $parent - * @return unknown_type - */ - public function ImportFolderDeletion($id, $parent) - { - //do nothing if it is a dummy folder - if ($parent == SYNC_FOLDER_TYPE_DUMMY) { - return false; - } - - $change = array(); - $change['id'] = $id; - - $this->_stateMachine->updateState('delete', $change); - $this->_backend->DeleteFolder($parent, $id); - - return true; - } - - /** - * Returns TRUE if the given ID conflicts with the given operation. - * This is only true in the following situations: - * - * Changed here and changed there - * Changed here and deleted there - * Deleted here and changed there - * - * Any other combination of operations can be done - * (e.g. change flags & move or move & delete) - */ - protected function _isConflict($type, $folderid, $id) - { - $stat = $this->_backend->StatMessage($folderid, $id); - if (!$stat) { - // Message is gone - if ($type == 'change') { - return true; - } else { - return false; // all other remote changes still result in a delete (no conflict) - } - } - - return $this->_stateMachine->isConflict($stat, $type); - } -} \ No newline at end of file diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/FolderSync.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/FolderSync.php index 3f08993e6..92ad9f845 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/FolderSync.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Request/FolderSync.php @@ -146,12 +146,12 @@ class Horde_ActiveSync_Request_FolderSync extends Horde_ActiveSync_Request_Base // this is not done when sync'ing messages - we let the exporter write // directly to WBXML. // TODO: Combine all these import caches into a single Class - $importer = new Horde_ActiveSync_HierarchyCache(); - $exporter = $this->_driver->GetSyncObject(); - $exporter->init($state, $importer, array('synckey' => $synckey)); + $connector = new Horde_ActiveSync_Connector_Exporter(); + $sync = $this->_driver->GetSyncObject(); + $sync->init($state, $connector, array('synckey' => $synckey)); /* Perform the actual sync operation */ - while(is_array($exporter->syncronize())); + while(is_array($sync->syncronize())); // Output our WBXML reply now $this->_encoder->StartWBXML(); @@ -169,11 +169,11 @@ class Horde_ActiveSync_Request_FolderSync extends Horde_ActiveSync_Request_Base $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_CHANGES); $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_COUNT); - $this->_encoder->content($importer->count); + $this->_encoder->content($connector->count); $this->_encoder->endTag(); - if (count($importer->changed) > 0) { - foreach ($importer->changed as $folder) { + if (count($connector->changed) > 0) { + foreach ($connector->changed as $folder) { if (isset($folder->serverid) && in_array($folder->serverid, $seenfolders)) { $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_UPDATE); } else { @@ -184,8 +184,8 @@ class Horde_ActiveSync_Request_FolderSync extends Horde_ActiveSync_Request_Base } } - if (count($importer->deleted) > 0) { - foreach ($importer->deleted as $folder) { + if (count($connector->deleted) > 0) { + foreach ($connector->deleted as $folder) { $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_REMOVE); $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID); $this->_encoder->content($folder); diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/GetItemEstimate.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/GetItemEstimate.php index e8bc880de..c407bbfb1 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/GetItemEstimate.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Request/GetItemEstimate.php @@ -130,7 +130,7 @@ class Horde_ActiveSync_Request_GetItemEstimate extends Horde_ActiveSync_Request_ $this->_encoder->endTag(); $this->_encoder->startTag(SYNC_GETITEMESTIMATE_ESTIMATE); - $importer = new Horde_ActiveSync_ContentsCache(); + $importer = new Horde_ActiveSync_Connector_NullImporter(); $state = $this->_driver->getStateObject($collection); $state->loadState($collection['synckey']); $exporter = $this->_driver->getSyncObject(); diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php index f44357824..0e0883fc6 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php @@ -435,10 +435,10 @@ class Horde_ActiveSync_Request_Sync extends Horde_ActiveSync_Request_Base /* Send server changes to PIM */ if (isset($collection['getchanges'])) { $filtertype = isset($collection['filtertype']) ? $collection['filtertype'] : false; - $streamer = new Horde_ActiveSync_Streamer($this->_encoder, $collection['class']); - $exporter = $this->_driver->getSyncObject(); - $exporter->init($state, $streamer, $collection); - $changecount = $exporter->getChangeCount(); + $exporter = new Horde_ActiveSync_Connector_Exporter($this->_encoder, $collection['class']); + $sync = $this->_driver->getSyncObject(); + $sync->init($state, $exporter, $collection); + $changecount = $sync->getChangeCount(); if (!empty($collection['windowsize']) && $changecount > $collection['windowsize']) { $this->_encoder->startTag(SYNC_MOREAVAILABLE, false, true); } @@ -449,7 +449,7 @@ class Horde_ActiveSync_Request_Sync extends Horde_ActiveSync_Request_Base // Stream the changes to the PDA $n = 0; while (1) { - $progress = $exporter->syncronize(); + $progress = $sync->syncronize(); if (!is_array($progress)) { break; } @@ -467,7 +467,7 @@ class Horde_ActiveSync_Request_Sync extends Horde_ActiveSync_Request_Base /* Save the sync state for the next time */ if (isset($collection['newsynckey'])) { - if (!empty($exporter) || !empty($importer) || !empty($streamer) || $collection['synckey'] == 0) { + if (!empty($sync) || !empty($importer) || !empty($exporter) || $collection['synckey'] == 0) { $state->setNewSyncKey($collection['newsynckey']); $state->save(); } else { diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Streamer.php b/framework/ActiveSync/lib/Horde/ActiveSync/Streamer.php deleted file mode 100644 index 19f3cca3e..000000000 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Streamer.php +++ /dev/null @@ -1,124 +0,0 @@ -_encoder = &$encoder; - $this->_type = $class; - $this->_seenObjects = array(); - } - - /** - * - * @param $id - * @param $message - * @return unknown_type - */ - public function messageChange($id, $message) - { - if ($message->getClass() != $this->_type) { - return true; // ignore other types - } - - // prevent sending the same object twice in one request - if (in_array($id, $this->_seenObjects)) { - return true; - } - - $this->_seenObjects[] = $id; - if ($message->flags === false || $message->flags === SYNC_NEWMESSAGE) { - $this->_encoder->startTag(SYNC_ADD); - } else { - $this->_encoder->startTag(SYNC_MODIFY); - } - - $this->_encoder->startTag(SYNC_SERVERENTRYID); - $this->_encoder->content($id); - $this->_encoder->endTag(); - $this->_encoder->startTag(SYNC_DATA); - $message->encodeStream($this->_encoder); - $this->_encoder->endTag(); - $this->_encoder->endTag(); - - return true; - } - - /** - * - * @param $id - * @return unknown_type - */ - public function messageDeletion($id) - { - $this->_encoder->startTag(SYNC_REMOVE); - $this->_encoder->startTag(SYNC_SERVERENTRYID); - $this->_encoder->content($id); - $this->_encoder->endTag(); - $this->_encoder->endTag(); - - return true; - } - - /** - * - * @param $id - * @param $flags - * @return unknown_type - */ - public function messageReadFlag($id, $flags) - { - if ($this->_type != "syncmail") { - return true; - } - $this->_encoder->startTag(SYNC_MODIFY); - $this->_encoder->startTag(SYNC_SERVERENTRYID); - $this->_encoder->content($id); - $this->_encoder->endTag(); - $this->_encoder->startTag(SYNC_DATA); - $this->_encoder->startTag(SYNC_POOMMAIL_READ); - $this->_encoder->content($flags); - $this->_encoder->endTag(); - $this->_encoder->endTag(); - $this->_encoder->endTag(); - - return true; - } - - /** - * - * @param $message - * @return unknown_type - */ - function messageMove($message) - { - return true; - } -} \ No newline at end of file diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Sync.php b/framework/ActiveSync/lib/Horde/ActiveSync/Sync.php index 8a77e2a28..78dab1b2e 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Sync.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Sync.php @@ -102,9 +102,9 @@ class Horde_ActiveSync_Sync /** * The change streamer * - * @var Horde_ActiveSync_Streamer + * @var Horde_ActiveSync_Connector_Exporter */ - protected $_streamer; + protected $_exporter; protected $_logger; @@ -119,11 +119,11 @@ class Horde_ActiveSync_Sync } public function init(Horde_ActiveSync_State_Base &$stateMachine, - $streamer, + $exporter, $collection = array()) { $this->_stateMachine = &$stateMachine; - $this->_streamer = $streamer; + $this->_exporter = $exporter; $this->_folderId = !empty($collection['id']) ? $collection['id'] : false; $this->_changes = $stateMachine->getChanges(); $this->_syncKey = $collection['synckey']; @@ -158,12 +158,12 @@ class Horde_ActiveSync_Sync return; } - if ($flags & BACKEND_DISCARD_DATA || $this->_streamer->FolderChange($folder)) { + if ($flags & BACKEND_DISCARD_DATA || $this->_exporter->FolderChange($folder)) { $this->_stateMachine->updateState('change', $stat); } break; case 'delete': - if ($flags & BACKEND_DISCARD_DATA || $this->_streamer->FolderDeletion($change['id'])) { + if ($flags & BACKEND_DISCARD_DATA || $this->_exporter->FolderDeletion($change['id'])) { $this->_stateMachine->updateState('delete', $change); } break; @@ -198,26 +198,26 @@ class Horde_ActiveSync_Sync $message->flags = (isset($change['flags'])) ? $change['flags'] : 0; if ($stat && $message) { - if ($flags & BACKEND_DISCARD_DATA || $this->_streamer->messageChange($change['id'], $message) == true) { + if ($flags & BACKEND_DISCARD_DATA || $this->_exporter->messageChange($change['id'], $message) == true) { $this->_stateMachine->updateState('change', $stat); } } break; case 'delete': - if ($flags & BACKEND_DISCARD_DATA || $this->_streamer->messageDeletion($change['id']) == true) { + if ($flags & BACKEND_DISCARD_DATA || $this->_exporter->messageDeletion($change['id']) == true) { $this->_stateMachine->updateState('delete', $change); } break; case 'flags': - if ($flags & BACKEND_DISCARD_DATA || $this->_streamer->messageReadFlag($change['id'], $change['flags']) == true) { + if ($flags & BACKEND_DISCARD_DATA || $this->_exporter->messageReadFlag($change['id'], $change['flags']) == true) { $this->_stateMachine->updateState('flags', $change); } break; case 'move': - if ($flags & BACKEND_DISCARD_DATA || $this->_streamer->messageMove($change['id'], $change['parent']) == true) { + if ($flags & BACKEND_DISCARD_DATA || $this->_exporter->messageMove($change['id'], $change['parent']) == true) { $this->_stateMachine->updateState('move', $change); } break; diff --git a/framework/ActiveSync/package.xml b/framework/ActiveSync/package.xml index 35841acda..3bd4fc150 100644 --- a/framework/ActiveSync/package.xml +++ b/framework/ActiveSync/package.xml @@ -31,6 +31,11 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + + + @@ -67,14 +72,9 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - @@ -97,6 +97,9 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + @@ -118,15 +121,10 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - - + diff --git a/framework/ActiveSync/test/Horde/ActiveSync/HordeDriverTest.php b/framework/ActiveSync/test/Horde/ActiveSync/HordeDriverTest.php index 49512c2b1..96ee5bd88 100644 --- a/framework/ActiveSync/test/Horde/ActiveSync/HordeDriverTest.php +++ b/framework/ActiveSync/test/Horde/ActiveSync/HordeDriverTest.php @@ -193,6 +193,7 @@ class Horde_ActiveSync_HordeDriverTest extends Horde_Test_Case } /** * Test ChangeMessage: + * * This tests converting the contact streamer object to a hash suitable for * passing to the contacts/import method. Because it only returns the UID * for the newly added/edited entry, we can't check the results here. The