Projects
Kolab:16:Testing
kolab-syncroton
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 64
View file
kolab-syncroton.spec
Changed
@@ -43,7 +43,7 @@ %global upstream_version 2.4.2 Name: kolab-syncroton -Version: 2.4.2.36 +Version: 2.4.2.37 Release: 1%{?dist} Summary: ActiveSync for Kolab Groupware @@ -205,16 +205,22 @@ -%if 0%{?plesk} > 0 && 0%{?rhel} == 7 -php="/opt/plesk/php/7.4/bin/php" +%if 0%{?plesk} > 0 && 0%{?rhel} <= 8 +for version in 8.2 8.1 8.0 7.4; do + php="/opt/plesk/php/$version/bin/php" %else -php="/usr/bin/php" +for version in 1; do + php="/usr/bin/php" %endif -${php} /usr/share/roundcubemail/bin/updatedb.sh \ - --dir /usr/share/doc/kolab-syncroton/SQL/ \ - --package syncroton \ - >/dev/null 2>&1 || : + if -f "$php" ; then + ${php} /usr/share/roundcubemail/bin/updatedb.sh \ + --dir /usr/share/doc/kolab-syncroton/SQL/ \ + --package syncroton \ + >/dev/null 2>&1 || : + break + fi +done exit 0
View file
debian.changelog
Changed
@@ -1,4 +1,4 @@ -kolab-syncroton (2.4.2.36-0~kolab1) unstable; urgency=low +kolab-syncroton (2.4.2.37-0~kolab1) unstable; urgency=low * Release version 2.4.2
View file
kolab-syncroton-2.4.2.tar.gz/bin/analyzelogs.php
Changed
@@ -1,5 +1,6 @@ #!/usr/bin/env php <?php + /* +--------------------------------------------------------------------------+ | Kolab Sync (ActiveSync for Kolab) |
View file
kolab-syncroton-2.4.2.tar.gz/bin/delete-device.php
Changed
@@ -1,5 +1,6 @@ #!/usr/bin/env php <?php + /* +--------------------------------------------------------------------------+ | Kolab Sync (ActiveSync for Kolab) |
View file
kolab-syncroton-2.4.2.tar.gz/bin/inspect.php
Changed
@@ -1,5 +1,6 @@ #!/usr/bin/env php <?php + /* +--------------------------------------------------------------------------+ | Kolab Sync (ActiveSync for Kolab) | @@ -154,6 +155,7 @@ $device_id = $data"id"; $result$device_id'deviceid' = $deviceid; + $result$device_id'device_id' = $device_id; $result$device_id'devicetype' = $data"devicetype"; $select = $db->limitquery( @@ -200,6 +202,7 @@ } $result$device_id'folders'$folder'id''name' = $folder'displayname'; + $result$device_id'folders'$folder'id''folderid' = $folder'folderid'; $result$device_id'folders'$folder'id''class' = $folder'class'; $result$device_id'folders'$folder'id''lastfiltertype' = $folder'lastfiltertype' ?? null; @@ -243,7 +246,7 @@ if (!$value) { return "No filter"; } - switch($value) { + switch ($value) { case 0: return "No filter"; case 1: return "1 day"; case 2: return "3 days"; @@ -284,13 +287,15 @@ } println(""); -foreach ($result as $deviceId => $values) { - println("Device: $deviceId"); +foreach ($result as $deviceId => $values) { + $device_id = $values'deviceid'; + println("Device: $device_id ($deviceId)"); println(" Last folder sync: " . $values'FolderSync''lastsync'); println(" Folder sync count: " . $values'FolderSync''counter'); println(" Folders:"); foreach ($values'folders' ?? as $folderId => $folder) { - println(" " . $folder'name' . " ($folderId)"); + $folder_id = $folder'folderid'; + println(" " . $folder'name' . " $folder_id ($folderId)"); $messageCount = $folder'contentCount'; $totalCount = $folder'imapMessagecount' ?? "unknown"; $modseq = $folder'modseq' ?? "none";
View file
kolab-syncroton-2.4.2.tar.gz/bin/resync.php
Changed
@@ -1,5 +1,6 @@ #!/usr/bin/php <?php + /* +--------------------------------------------------------------------------+ | Kolab Sync (ActiveSync for Kolab) | @@ -101,16 +102,17 @@ // TODO: Support not only top-level folders $select = $db->query( - "SELECT `id`, `displayname`, `folderid` FROM `syncroton_folder`" + "SELECT syncroton_folder.id, `displayname`, `folderid`, `deviceid` FROM `syncroton_folder`" + . " JOIN `syncroton_device` ON syncroton_device.id = syncroton_folder.device_id" . " WHERE `device_id` IN (" . $db->array2list($devices) . ")" . " AND `parentid` = '0' AND `displayname` = " . $db->quote($opts'folder') ); while ($record = $db->fetch_assoc($select)) { if (!empty($opts'dry-run')) { - print("DRY-RUN {$record'displayname'} ({$record'id'}:{$record'folderid'})\n"); + print("DRY-RUN {$record'displayname'} {$record'deviceid'} ({$record'id'}:{$record'folderid'})\n"); } else { $db->query("UPDATE `syncroton_folder` SET `resync` = 1 WHERE id = ?", $record'id'); - print("{$record'displayname'} ({$record'id'}:{$record'folderid'})\n"); + print("{$record'displayname'} {$record'deviceid'} ({$record'id'}:{$record'folderid'})\n"); } }
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/ABackend.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/Content.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/Device.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/Folder.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -51,7 +52,7 @@ * (non-PHPdoc) * @see Syncroton_Backend_IFolder::getFolderState() */ - public function getFolderState($deviceId, $class) + public function getFolderState($deviceId, $class, $syncKey) { $deviceId = $deviceId instanceof Syncroton_Model_IDevice ? $deviceId->id : $deviceId; @@ -133,4 +134,9 @@ return parent::_toCamelCase($string, $ucFirst); } } + + public function exists($deviceid, $folderid); + { + return false; // not implemented + } }
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/IBackend.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/IContent.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/IDevice.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/IFolder.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -52,4 +53,14 @@ * @return bool True if folders hierarchy changed, False otherwise */ public function hasHierarchyChanges($device); + + /** + * Check if the folder already exists + * + * @param Syncroton_Model_Device|string $deviceid Device object or identifier + * @param string $folderid Folder identifier + * + * @return bool true if it exists + */ + public function exists($deviceid, $folderid); }
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/ISyncState.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/Policy.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/SyncState.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/AutoDiscover.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/FolderCreate.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -63,7 +64,7 @@ return; } - switch($folder->type) { + switch ($folder->type) { case Syncroton_Command_FolderSync::FOLDERTYPE_CALENDAR_USER_CREATED: $folder->class = Syncroton_Data_Factory::CLASS_CALENDAR; break;
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/FolderDelete.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/FolderSync.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -68,6 +69,11 @@ protected $_syncKey; /** + * @var bool + */ + protected $_syncKeyReused = false; + + /** * Parse FolderSync request */ public function handle() @@ -91,11 +97,19 @@ $this->_syncStateBackend->resetState($this->_device, 'FolderSync'); return; + } else { + // The synckey that is sent to us should already be existing, because we create it at the end, + // however, the next one shouldn't + if ($this->_syncStateBackend->haveNext($this->_device, 'FolderSync', $syncKey)) { + $this->_syncKeyReused = true; + if ($this->_logger instanceof Zend_Log) { + $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " already known synckey $syncKey provided"); + } + } } - if (!($this->_syncState = $this->_syncStateBackend->validate($this->_device, 'FolderSync', $syncKey)) instanceof Syncroton_Model_SyncState) { if ($this->_logger instanceof Zend_Log) { - $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " invalidating sync state"); + $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " invalid synckey $syncKey provided, invalidating sync state"); } $this->_syncStateBackend->resetState($this->_device, 'FolderSync'); } @@ -130,7 +144,7 @@ $updates = ; $deletes = ; - foreach($this->_classes as $class) { + foreach ($this->_classes as $class) { try { $dataController = Syncroton_Data_Factory::factory($class, $this->_device, $this->_syncTimeStamp); } catch (Exception $e) { @@ -242,6 +256,11 @@ // but because the folder is still existing and subscribed on the backend it should // "immediately" be added again (and re-synced). $forceDeleteIds = array_keys(array_filter($clientFolders, function ($f) { return !empty($f->resync); })); + if (!empty($forceDeleteIds)) { + if ($this->_logger instanceof Zend_Log) { + $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " forcing resync of: " . var_export($forceDeleteIds, true)); + } + } $serverFoldersIds = array_diff($serverFoldersIds, $forceDeleteIds); // calculate deleted entries @@ -253,53 +272,53 @@ $folderSync->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Status', self::STATUS_SUCCESS)); + $newSyncKey = $this->_syncState->counter; $count = count($adds) + count($updates) + count($deletes); - if($count > 0) { - $this->_syncState->counter++; - $this->_syncState->lastsync = $this->_syncTimeStamp; + if ($count > 0) { + $newSyncKey++; } // create xml output - $folderSync->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'SyncKey', $this->_syncState->counter)); + $folderSync->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'SyncKey', $newSyncKey)); $changes = $folderSync->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Changes')); $changes->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Count', $count)); - foreach($adds as $folder) { + foreach ($adds as $folder) { $add = $changes->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Add')); $folder->appendXML($add, $this->_device); - // store folder in backend - if (empty($folder->id)) { - try { + if (!$this->_syncKeyReused && empty($folder->id)) { + // The folder could exist in the backend if we e.g. delete the same name and then recreate, + // or disable/reenable for syncing. + if (!$this->_folderBackend->exists($this->_device->id, $folder->serverId)) { $this->_folderBackend->create($folder); - } catch(Exception $zdse) { - //This can happen if we rerun a previous sync-key - $this->_folderBackend->update($folder); } } } - foreach($updates as $folder) { + foreach ($updates as $folder) { $update = $changes->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Update')); $folder->appendXML($update, $this->_device); - $this->_folderBackend->update($folder); } - foreach($deletes as $folder) { + foreach ($deletes as $folder) { $delete = $changes->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Delete')); $delete->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'ServerId', $folder->serverId)); $this->_folderBackend->delete($folder); } - // Only create this syncstate if it isn't already existing (which happens if we a sync key is re-sent) - if (!$this->_syncStateBackend->haveNext($this->_device, 'FolderSync', $this->_syncState->counter - 1)) { - // Keep previous sync states in case a sync key is re-sent - $this->_syncStateBackend->create($this->_syncState, true); + if ($this->_syncState->counter != $newSyncKey) { + $this->_syncState->counter = $newSyncKey; + $this->_syncState->lastsync = $this->_syncTimeStamp; + // Keep previous sync states in case a sync key is re-sent. + // We always insert because deleteOtherStates is executed from _syncStateBackend->validate, + // which means we remove and re-insert the latest state on key resend. + $this->_syncStateBackend->create($this->_syncState, true); // @phpstan-ignore-line } return $this->_outputDom;
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/FolderUpdate.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/GetAttachment.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/GetItemEstimate.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -59,7 +60,7 @@ $collectionData'folder' = $this->_folderBackend->getFolder($this->_device, $collectionData'collectionId'); $collectionData'folder'->lastfiltertype = $collectionData'filterType'; - if($collectionData'syncKey' === 0) { + if ($collectionData'syncKey' === 0) { $collectionData'syncState' = new Syncroton_Model_SyncState( 'device_id' => $this->_device, 'counter' => 0, @@ -92,7 +93,7 @@ { $itemEstimate = $this->_outputDom->documentElement; - foreach($this->_collections as $collectionData) { + foreach ($this->_collections as $collectionData) { $response = $itemEstimate->appendChild($this->_outputDom->createElementNS('uri:ItemEstimate', 'Response')); // invalid collectionid provided @@ -131,7 +132,7 @@ $response->appendChild($this->_outputDom->createElementNS('uri:ItemEstimate', 'Status', self::STATUS_SUCCESS)); $collection = $response->appendChild($this->_outputDom->createElementNS('uri:ItemEstimate', 'Collection')); $collection->appendChild($this->_outputDom->createElementNS('uri:ItemEstimate', 'CollectionId', $collectionData'collectionId')); - if($collectionData'syncState'->counter === 0) { + if ($collectionData'syncState'->counter === 0) { // this is the first sync. in most cases there are data on the server. $count = count($dataController->getServerEntries($collectionData'collectionId', $collectionData'filterType')); } else {
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/ICommand.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/ItemOperations.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/MeetingResponse.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Options.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Ping.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -52,7 +53,7 @@ $xml = simplexml_import_dom($this->_requestBody); $xml->registerXPathNamespace('Ping', 'Ping'); - if(isset($xml->HeartbeatInterval)) { + if (isset($xml->HeartbeatInterval)) { $this->_device->pinglifetime = (int)$xml->HeartbeatInterval; } @@ -279,10 +280,10 @@ $ping = $this->_outputDom->documentElement; $ping->appendChild($this->_outputDom->createElementNS('uri:Ping', 'Status', $status)); - if($status === self::STATUS_CHANGES_FOUND) { + if ($status === self::STATUS_CHANGES_FOUND) { $folders = $ping->appendChild($this->_outputDom->createElementNS('uri:Ping', 'Folders')); - foreach($this->_foldersWithChanges as $changedFolder) { + foreach ($this->_foldersWithChanges as $changedFolder) { $folder = $folders->appendChild($this->_outputDom->createElementNS('uri:Ping', 'Folder', $changedFolder->serverId)); if ($this->_logger instanceof Zend_Log) { $this->_logger->info(__METHOD__ . '::' . __LINE__ . " DeviceId: " . $this->_device->deviceid . " changes in folder: " . $changedFolder->serverId);
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Provision.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Search.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/SendMail.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Settings.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/SmartForward.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/SmartReply.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Sync.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -222,7 +223,7 @@ } // initial synckey - if($collectionData->syncKey === 0) { + if ($collectionData->syncKey === 0) { if ($this->_logger instanceof Zend_Log) { $this->_logger->info(__METHOD__ . '::' . __LINE__ . " initial client synckey 0 provided"); } @@ -250,7 +251,7 @@ } } // check for invalid synckey - if(($collectionData->syncState = $this->_syncStateBackend->validate($this->_device, $collectionData->folder, $collectionData->syncKey)) === false) { + if (($collectionData->syncState = $this->_syncStateBackend->validate($this->_device, $collectionData->folder, $collectionData->syncKey)) === false) { if ($this->_logger instanceof Zend_Log) { $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " invalid synckey {$collectionData->syncKey} provided"); } @@ -266,7 +267,7 @@ $dataController = Syncroton_Data_Factory::factory($collectionData->folder->class, $this->_device, $this->_syncTimeStamp); - switch($collectionData->folder->class) { + switch ($collectionData->folder->class) { case Syncroton_Data_Factory::CLASS_CALENDAR: $dataClass = 'Syncroton_Model_Event'; break; @@ -301,7 +302,7 @@ ; // handle incoming data - if($collectionData->hasClientAdds()) { + if ($collectionData->hasClientAdds()) { $adds = $collectionData->getClientAdds(); if ($this->_logger instanceof Zend_Log) { @@ -366,7 +367,7 @@ } // handle changes, but only if not first sync - if(!$syncKeyReused && $collectionData->syncKey > 1 && $collectionData->hasClientChanges()) { + if (!$syncKeyReused && $collectionData->syncKey > 1 && $collectionData->hasClientChanges()) { $changes = $collectionData->getClientChanges(); if ($this->_logger instanceof Zend_Log) { @@ -399,7 +400,7 @@ } // handle deletes, but only if not first sync - if(!$syncKeyReused && $collectionData->hasClientDeletes()) { + if (!$syncKeyReused && $collectionData->hasClientDeletes()) { $deletes = $collectionData->getClientDeletes(); if ($this->_logger instanceof Zend_Log) { $this->_logger->info(__METHOD__ . '::' . __LINE__ . " found " . count($deletes) . " entries to be deleted on server"); @@ -415,7 +416,7 @@ try { $dataController->deleteEntry($collectionData->collectionId, $serverId, $collectionData); - } catch(Syncroton_Exception_NotFound $e) { + } catch (Syncroton_Exception_NotFound $e) { if ($this->_logger instanceof Zend_Log) { $this->_logger->crit(__METHOD__ . '::' . __LINE__ . ' tried to delete entry ' . $serverId . ' but entry was not found'); } @@ -441,7 +442,7 @@ } // handle fetches, but only if not first sync - if($collectionData->syncKey > 1 && $collectionData->hasClientFetches()) { + if ($collectionData->syncKey > 1 && $collectionData->hasClientFetches()) { // the default value for GetChanges is 1. If the phone don't want the changes it must set GetChanges to 0 // some prevoius versions of iOS did not set GetChanges to 0 for fetches. Let's enforce getChanges to false here. $collectionData->getChanges = false; @@ -514,9 +515,9 @@ $serverModifications'added' = array_unique(array_merge($serverModifications'added', $serverDiff)); // @todo still needed? - foreach($serverModifications'added' as $id => $serverId) { + foreach ($serverModifications'added' as $id => $serverId) { // skip entries added by client during this sync session - if(isset($clientModifications'added'$serverId) && !isset($clientModifications'forceAdd'$serverId)) { + if (isset($clientModifications'added'$serverId) && !isset($clientModifications'forceAdd'$serverId)) { if ($this->_logger instanceof Zend_Log) { $this->_logger->info(__METHOD__ . '::' . __LINE__ . " skipped added entry: " . $serverId); } @@ -530,9 +531,9 @@ // entries changed since last sync $serverModifications'changed' = array_merge($allChangedEntries, $clientModifications'forceChange'); - foreach($serverModifications'changed' as $id => $serverId) { + foreach ($serverModifications'changed' as $id => $serverId) { // skip entry, if it got changed by client during current sync - if(isset($clientModifications'changed'$serverId) && !isset($clientModifications'forceChange'$serverId)) { + if (isset($clientModifications'changed'$serverId) && !isset($clientModifications'forceChange'$serverId)) { if ($this->_logger instanceof Zend_Log) { $this->_logger->info(__METHOD__ . '::' . __LINE__ . " skipped changed entry: " . $serverId); } @@ -592,7 +593,7 @@ $now = new DateTime('now', new DateTimeZone('UTC')); - foreach($this->_collections as $collectionData) { + foreach ($this->_collections as $collectionData) { // continue immediately if folder does not exist if (! ($collectionData->folder instanceof Syncroton_Model_IFolder)) { break 2; @@ -659,7 +660,7 @@ $dataController = Syncroton_Data_Factory::factory($collectionData->folder->class, $this->_device, $this->_syncTimeStamp); // countinue immediately if there are any changes available - if($dataController->hasChanges($this->_contentStateBackend, $collectionData->folder, $collectionData->syncState)) { + if ($dataController->hasChanges($this->_contentStateBackend, $collectionData->folder, $collectionData->syncState)) { break 2; } } @@ -753,7 +754,7 @@ if ($collectionData->getChanges === true) { // continue sync session? - if(is_array($collectionData->syncState->pendingdata)) { + if (is_array($collectionData->syncState->pendingdata)) { $serverModifications = $collectionData->syncState->pendingdata; if ($this->_logger instanceof Zend_Log) { $this->_logger->info(__METHOD__ . '::' . __LINE__ . " restored from sync state."); @@ -805,12 +806,12 @@ } // send reponse for newly added entries - if(!empty($clientModifications'added')) { - foreach($clientModifications'added' as $entryData) { + if (!empty($clientModifications'added')) { + foreach ($clientModifications'added' as $entryData) { $add = $responses->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Add')); $add->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ClientId', $entryData'clientId')); // we have no serverId if the add failed - if(isset($entryData'serverId')) { + if (isset($entryData'serverId')) { $add->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ServerId', $entryData'serverId')); } $add->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Status', $entryData'status')); @@ -818,8 +819,8 @@ } // send reponse for changed entries - if(!empty($clientModifications'changed')) { - foreach($clientModifications'changed' as $serverId => $status) { + if (!empty($clientModifications'changed')) { + foreach ($clientModifications'changed' as $serverId => $status) { if ($status !== Syncroton_Command_Sync::STATUS_SUCCESS) { $change = $responses->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Change')); $change->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ServerId', $serverId)); @@ -829,19 +830,19 @@ } // send response for to be fetched entries - if(!empty($collectionData->toBeFetched)) { + if (!empty($collectionData->toBeFetched)) { // unset all truncation settings as entries are not allowed to be truncated during fetch $fetchCollectionData = clone $collectionData; // unset truncationSize if (isset($fetchCollectionData->options'bodyPreferences') && is_array($fetchCollectionData->options'bodyPreferences')) { - foreach($fetchCollectionData->options'bodyPreferences' as $key => $bodyPreference) { + foreach ($fetchCollectionData->options'bodyPreferences' as $key => $bodyPreference) { unset($fetchCollectionData->options'bodyPreferences'$key'truncationSize'); } } $fetchCollectionData->options'mimeTruncation' = Syncroton_Command_Sync::TRUNCATE_NOTHING; - foreach($collectionData->toBeFetched as $serverId) { + foreach ($collectionData->toBeFetched as $serverId) { $fetch = $responses->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Fetch')); $fetch->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ServerId', $serverId)); @@ -873,8 +874,8 @@ $commands = $this->_outputDom->createElementNS('uri:AirSync', 'Commands'); - foreach($serverModifications'added' as $id => $serverId) { - if($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) { + foreach ($serverModifications'added' as $id => $serverId) { + if ($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) { break; } @@ -926,8 +927,8 @@ /** * process entries changed on server side */ - foreach($serverModifications'changed' as $id => $serverId) { - if($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) { + foreach ($serverModifications'changed' as $id => $serverId) { + if ($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) { break; }
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Wbxml.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/AData.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Calendar.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Contacts.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Email.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Factory.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/IData.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/IDataCalendar.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/IDataEmail.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/IDataSearch.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Notes.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Tasks.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/AccessDenied.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/DeadlockDetected.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/MemoryExhausted.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/NotFound.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/PolicyKeyMissing.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/ProvisioningNeeded.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/Autodiscover.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/FolderCreate.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/FolderDelete.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/FolderSync.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/FolderUpdate.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/GetItemEstimate.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/ItemOperations.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/MeetingResponse.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/MoveItems.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/Settings.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/Sync.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/UnexpectedValue.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/AEntry.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -70,7 +71,7 @@ */ public function setFromArray(array $properties) { - foreach($properties as $key => $value) { + foreach ($properties as $key => $value) { try { $this->$key = $value; //echo __LINE__ . PHP_EOL; } catch (InvalidArgumentException $iae) {
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/AXMLEntry.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -47,9 +48,9 @@ { $this->_addXMLNamespaces($domParrent); - foreach($this->_elements as $elementName => $value) { + foreach ($this->_elements as $elementName => $value) { // skip empty values - if($value === null || $value === '' || (is_array($value) && empty($value))) { + if ($value === null || $value === '' || (is_array($value) && empty($value))) { continue; } @@ -69,7 +70,7 @@ if (isset($elementProperties'childElement')) { $element = $domParrent->ownerDocument->createElementNS($nameSpace, ucfirst($elementName)); - foreach($value as $subValue) { + foreach ($value as $subValue) { $subElement = $domParrent->ownerDocument->createElementNS($nameSpace, ucfirst($elementProperties'childElement')); $this->_appendXMLElement($device, $subElement, $elementProperties, $subValue); $element->appendChild($subElement); @@ -102,7 +103,7 @@ { $properties = ; - foreach($this->_properties as $namespace => $namespaceProperties) { + foreach ($this->_properties as $namespace => $namespaceProperties) { if ($selectedNamespace !== null && $namespace != $selectedNamespace) { continue; } @@ -255,7 +256,7 @@ */ protected function _getElementProperties($element) { - foreach($this->_properties as $namespace => $namespaceProperties) { + foreach ($this->_properties as $namespace => $namespaceProperties) { if (array_key_exists($element, $namespaceProperties)) { return $namespace, $namespaceProperties$element; }
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Account.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Contact.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Content.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Device.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/DeviceInformation.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Email.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailAttachment.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailBody.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailFlag.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailMeetingRequest.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailRecurrence.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Event.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EventAttendee.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EventException.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EventRecurrence.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/FileReference.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/GAL.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/GALPicture.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IContent.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IEntry.php
Changed
@@ -1,4 +1,5 @@ <?php + /* * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IFolder.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IPolicy.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/ISyncState.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IXMLEntry.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/MeetingResponse.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Note.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Policy.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SendMail.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SmartForward.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SmartReply.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/StoreRequest.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/StoreResponseResult.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SyncCollection.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SyncState.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Task.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/TaskRecurrence.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Registry.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Zend Framework *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Server.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -66,13 +67,16 @@ } if ($this->_request->getMethod() != "OPTIONS" && empty($this->_userId)) { - $this->_logger->warn(__METHOD__ . '::' . __LINE__ . ' Not authenticated'); + // Outlook on ios/android sends unauthenticated requests for Ping/FolderSync/Settings + // (which doesn't seem to make much sense), so we handle this case silently, + // even though it should normally be a warning. + $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' Not authenticated'); header('WWW-Authenticate: Basic realm="ActiveSync for Kolab"'); header('HTTP/1.1 401 Unauthorized'); exit; } - switch($this->_request->getMethod()) { + switch ($this->_request->getMethod()) { case 'OPTIONS': $this->_handleOptions(); break; @@ -138,7 +142,7 @@ if ($this->_logger instanceof Zend_Log) { $this->_logDomDocument($requestBody, 'request', __METHOD__, __LINE__); } - } catch(Syncroton_Wbxml_Exception_UnexpectedEndOfFile $e) { + } catch (Syncroton_Wbxml_Exception_UnexpectedEndOfFile $e) { if ($this->_logger instanceof Zend_Log) { $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " unexpected end of file."); }
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/TransactionManager.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/TransactionManagerInterface.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Abstract.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -111,7 +112,7 @@ */ public function getDPI($_uInt = 0) { - if(!defined('Syncroton_Wbxml_Abstract::DPI_' . $_uInt)) { + if (!defined('Syncroton_Wbxml_Abstract::DPI_' . $_uInt)) { throw new Syncroton_Wbxml_Exception('unknown wellknown identifier: ' . $_uInt); } @@ -142,7 +143,7 @@ { $byte = fread($this->_stream, 1); - if($byte === false) { + if ($byte === false) { throw new Syncroton_Wbxml_Exception("failed reading one byte"); } @@ -204,7 +205,7 @@ do { $byte = ($remainder & 127); $remainder >>= 7; - if($multibyte === null) { + if ($multibyte === null) { $multibyte = chr($byte); } else { $multibyte = chr($byte | 128) . $multibyte; @@ -240,7 +241,7 @@ $this->_writeMultibyteUInt($length); $writenBytes = stream_copy_to_stream($stream, $this->_stream); - if($writenBytes !== $length) { + if ($writenBytes !== $length) { throw new Syncroton_Wbxml_Exception('blow'); }
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Decoder.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -54,10 +55,10 @@ */ public function __construct($_stream, $_dpi = null) { - if(!is_resource($_stream) || get_resource_type($_stream) != 'stream') { + if (!is_resource($_stream) || get_resource_type($_stream) != 'stream') { throw new Syncroton_Wbxml_Exception('$_stream must be a stream'); } - if($_dpi !== null) { + if ($_dpi !== null) { $this->_dpi = $_dpi; } @@ -65,7 +66,7 @@ $this->_version = $this->_getByte(); - if(feof($this->_stream)) { + if (feof($this->_stream)) { throw new Syncroton_Wbxml_Exception_UnexpectedEndOfFile(); } @@ -77,7 +78,7 @@ // resolve DPI as we have read the stringtable now // this->_dpi contains the string table index - if($this->_dpiType === Syncroton_Wbxml_Abstract::DPI_STRINGTABLE) { + if ($this->_dpiType === Syncroton_Wbxml_Abstract::DPI_STRINGTABLE) { $this->_dpi = $this->_stringTable$this->_dpi; } @@ -120,7 +121,7 @@ while (!feof($this->_stream)) { $byte = $this->_getByte(); - switch($byte) { + switch ($byte) { case Syncroton_Wbxml_Abstract::END: $node = $node->parentNode; $openTags--; @@ -128,7 +129,7 @@ case Syncroton_Wbxml_Abstract::OPAQUE: $length = $this->_getMultibyteUInt(); - if($length > 0) { + if ($length > 0) { $opaque = $this->_getOpaque($length); try { // let see if we can decode it. maybe the opaque data is wbxml encoded content @@ -141,8 +142,8 @@ fclose($opaqueDataStream); - foreach($dom->childNodes as $newNode) { - if($newNode instanceof DOMElement) { + foreach ($dom->childNodes as $newNode) { + if ($newNode instanceof DOMElement) { $newNode = $this->_dom->importNode($newNode, true); $node->appendChild($newNode); } @@ -240,7 +241,7 @@ { $uInt = $this->_getMultibyteUInt(); - if($uInt == 0) { + if ($uInt == 0) { // get identifier from stringtable $this->_dpiType = Syncroton_Wbxml_Abstract::DPI_STRINGTABLE; // string table identifier, can be resolved only after reading string table @@ -260,7 +261,7 @@ { $uInt = $this->_getMultibyteUInt(); - switch($uInt) { + switch ($uInt) { case 106: $this->_charSet = 'UTF-8'; break; @@ -279,21 +280,21 @@ { $length = $this->_getMultibyteUInt(); - if($length > 0) { + if ($length > 0) { $rawStringTable = $this->_getOpaque($length); $index = null; $string = null; - for($i = 0; $i < strlen($rawStringTable); $i++) { - if($index === null) { + for ($i = 0; $i < strlen($rawStringTable); $i++) { + if ($index === null) { $index = $i; } - if(ord($rawStringTable$i) != 0) { + if (ord($rawStringTable$i) != 0) { $string .= $rawStringTable$i; } // either the string has ended or we reached a \0 - if($i + 1 == strlen($rawStringTable) || ord($rawStringTable$i) == 0) { + if ($i + 1 == strlen($rawStringTable) || ord($rawStringTable$i) == 0) { $this->_stringTable$index = $string; $index = null; $string = null;
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/Abstract.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -87,7 +88,7 @@ */ public function getIdentity($_tag) { - if(!isset($this->_tags$_tag)) { + if (!isset($this->_tags$_tag)) { //var_dump($this->_tags); throw new Syncroton_Wbxml_Exception("tag $_tag not found"); } @@ -105,7 +106,7 @@ { $tag = array_search($_identity, $this->_tags); - if($tag === false) { + if ($tag === false) { throw new Syncroton_Wbxml_Exception("identity $_identity not found"); }
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage0.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage1.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage10.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage11.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage12.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage13.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage14.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage15.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage16.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage17.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage18.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage19.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage2.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage20.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage21.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage22.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage23.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage24.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage254.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage3.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage4.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage5.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage6.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage7.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage8.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage9.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/Exception/CodePageNotFound.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/Factory.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Encoder.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton * @@ -54,7 +55,7 @@ // the WBXML version $this->_writeByte($this->_version); - if($this->_codePage->getDPI() === null) { + if ($this->_codePage->getDPI() === null) { // the document public identifier $this->_writeMultibyteUInt(1); } else { @@ -68,7 +69,7 @@ // write the charSet $this->_writeCharSet($this->_charSet); - if($this->_codePage->getDPI() === null) { + if ($this->_codePage->getDPI() === null) { // the length of the string table $this->_writeMultibyteUInt(0); } else { @@ -87,7 +88,7 @@ */ protected function _writeCharSet($_charSet) { - switch(strtoupper($_charSet)) { + switch (strtoupper($_charSet)) { case 'UTF-8': $this->_writeMultibyteUInt(106); break; @@ -123,7 +124,7 @@ private function writeNode($node, $withContent = false, $data = null) { - if($this->_codePage->getNameSpace() != $node->namespaceURI) { + if ($this->_codePage->getNameSpace() != $node->namespaceURI) { $this->_switchCodePage($node->namespaceURI); } $this->_writeTag($node->localName, $this->getAttributes($node), $withContent, $data); @@ -189,7 +190,7 @@ */ protected function _writeTag($_tag, $_attributes = null, $_hasContent = false, $_data = null) { - if($_hasContent == false && $_data !== null) { + if ($_hasContent == false && $_data !== null) { throw new Syncroton_Wbxml_Exception('$_hasContent can not be false, when $_data !== NULL'); } @@ -203,18 +204,18 @@ $encoding = 'termstring'; } - if(!empty($_attributes)) { + if (!empty($_attributes)) { $identity |= 0x80; } - if($_hasContent == true) { + if ($_hasContent == true) { $identity |= 0x40; } $this->_writeByte($identity); // handle the data - if($_data !== null) { + if ($_data !== null) { if ($encoding == 'opaque') { $this->_writeOpaqueString(base64_decode($_data)); } else { @@ -231,7 +232,7 @@ protected function _switchCodePage($_nameSpace) { $codePageName = $this->_stripNameSpace($_nameSpace); - if(!defined('Syncroton_Wbxml_Dtd_ActiveSync::CODEPAGE_' . strtoupper($codePageName))) { + if (!defined('Syncroton_Wbxml_Dtd_ActiveSync::CODEPAGE_' . strtoupper($codePageName))) { throw new Syncroton_Wbxml_Exception('codepage ' . $codePageName . ' not found'); } // switch to another codepage
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Exception.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Exception/UnexpectedEndOfFile.php
Changed
@@ -1,4 +1,5 @@ <?php + /** * Syncroton *
View file
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync.php
Changed
@@ -149,7 +149,8 @@ Syncroton_Registry::set(Syncroton_Registry::LOGGERBACKEND, $this->logger); Syncroton_Registry::set(Syncroton_Registry::DATABASE, $this->get_dbh()); Syncroton_Registry::set(Syncroton_Registry::TRANSACTIONMANAGER, kolab_sync_transaction_manager::getInstance()); - // The unauthenticated OPTIONS request doesn't require these backends and we can't instantiate them without credentials for the underlying storage backend + // The unauthenticated OPTIONS request doesn't require these backends and we can't + // instantiate them without credentials for the underlying storage backend if (!empty($userid)) { Syncroton_Registry::set(Syncroton_Registry::DEVICEBACKEND, new kolab_sync_backend_device()); Syncroton_Registry::set(Syncroton_Registry::FOLDERBACKEND, new kolab_sync_backend_folder()); @@ -385,8 +386,10 @@ /** * Initializes and returns the storage backend object + * + * @param bool $init Reset the driver internal state */ - public static function storage() + public static function storage($init = false) { $class = 'kolab_sync_storage'; $self = self::get_instance(); @@ -395,6 +398,15 @@ $class .= '_' . strtolower($name); } + if ($init) { + // Reset storage driver internal state + $reflection = new ReflectionClass($class); + $property = $reflection->getProperty('instance'); + $property->setAccessible(true); + $property->setValue($class::get_instance(), null); + $property->setAccessible(false); + } + return $class::get_instance(); }
View file
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_backend_folder.php
Changed
@@ -103,6 +103,26 @@ } /** + * Check if the folder already exists + * + * @param Syncroton_Model_Device|string $deviceid Device object or identifier + * @param string $folderid Folder identifier + * + * @return bool true if it exists + */ + public function exists($deviceid, $folderid) + { + $device_id = $deviceid instanceof Syncroton_Model_IDevice ? $deviceid->id : $deviceid; + + $where = $this->db->quote_identifier('device_id') . ' = ' . $this->db->quote($device_id); + $where = $this->db->quote_identifier('folderid') . ' = ' . $this->db->quote($folderid); + + $select = $this->db->query('SELECT 1 FROM `' . $this->table_name . '` WHERE ' . implode(' AND ', $where)); + $folder = $this->db->fetch_assoc($select); + return !empty($folder); + } + + /** * Find out if the folder hierarchy changed since the last FolderSync * * @param Syncroton_Model_Device $device Device object
View file
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_backend_state.php
Changed
@@ -115,6 +115,10 @@ $select = $this->db->limitquery("SELECT * FROM `{$this->table_name}` WHERE " . implode(' AND ', $where) . " ORDER BY `counter` DESC", 0, 1); + if ($err = $this->db->is_error($select)) { + throw new Exception("Query failed while fetching sync state: {$err}"); + } + $state = $this->db->fetch_assoc($select); if (empty($state)) { @@ -164,6 +168,10 @@ $select = $this->db->query("SELECT * FROM `{$this->table_name}` WHERE " . implode(' AND ', $where)); + if ($err = $this->db->is_error($select)) { + throw new Exception("Query failed while validating sync state: {$err}"); + } + while ($row = $this->db->fetch_assoc($select)) { $states$row'counter' = $this->get_object($row); } @@ -223,6 +231,9 @@ $where'counter' = $this->db->quote_identifier('counter') . ' > ' . $this->db->quote($sync_key); $select = $this->db->query("SELECT id FROM `{$this->table_name}` WHERE " . implode(' AND ', $where)); + if ($err = $this->db->is_error($select)) { + throw new Exception("Query failed while checking for sync state: {$err}"); + } return $this->db->num_rows($select) > 0; } }
View file
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_data.php
Changed
@@ -1175,7 +1175,7 @@ $r = $data'recurrence'; // required fields - switch($r'FREQ') { + switch ($r'FREQ') { case 'DAILY': $recurrence'type' = self::RECUR_TYPE_DAILY; break;
View file
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_data_contacts.php
Changed
@@ -272,7 +272,8 @@ $emails = ; for ($x = 0; $x < 3; $x++) { $key = 'email' . ($x + 1) . 'Address'; - if ($value = $data->$key) { + $value = $data->$key ?? null; + if ($value) { // Android sends email address as: Lars Kneschke <l.kneschke@metaways.de> if (preg_match('/(.*)<(.+@^@+)>/', $value, $matches)) { $value = trim($matches2);
View file
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_storage.php
Changed
@@ -56,7 +56,7 @@ protected $folders = ; protected $root_meta; protected $relations = ; - public $relationSupport = true; + protected $relationSupport = self::MODEL_TASKS, self::MODEL_NOTES, self::MODEL_EMAIL; protected $tag_rts = ; private $modseq = ; @@ -109,7 +109,7 @@ $this->storage->set_options( // @TODO: there can be Roundcube plugins defining additional headers, // we maybe would need to add them here - 'fetch_headers' => 'X-KOLAB-TYPE X-KOLAB-MIME-VERSION', + 'fetch_headers' => 'X-KOLAB-TYPE X-KOLAB-MIME-VERSION MESSAGE-ID', 'skip_deleted' => true, 'threading' => false, ); @@ -694,7 +694,7 @@ return $uid; } - $useTags = $this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES); + $useTags = in_array($type, $this->relationSupport); // convert categories into tags, save them after creating an object if ($useTags && !empty($data'categories')) { @@ -752,7 +752,7 @@ return $this->storage->delete_message($uid, $foldername); } - $useTags = $this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES); + $useTags = in_array($type, $this->relationSupport); $folder = $this->getFolder($folderid, $deviceid, $type); @@ -795,14 +795,14 @@ } // Categories (Tags) change - if (isset($params'categories') && $this->relationSupport) { - $message = new rcube_message($uid, $foldername); + if (isset($params'categories') && in_array($type, $this->relationSupport)) { + $headers = $this->storage->fetch_headers($foldername, $uid, false); - if (empty($message->headers)) { + if (empty($headers) || empty($headers$uid)) { throw new Syncroton_Exception_Status_Sync(Syncroton_Exception_Status_Sync::SYNC_SERVER_ERROR); } - $this->setCategories($message, $params'categories'); + $this->setCategories($headers$uid, $params'categories'); } return $uid; @@ -810,7 +810,7 @@ $folder = $this->getFolder($folderid, $deviceid, $type); - $useTags = $this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES); + $useTags = in_array($type, $this->relationSupport); // convert categories into tags, save them after updating an object if ($useTags && array_key_exists('categories', $data)) { @@ -836,16 +836,16 @@ /** * Returns list of categories assigned to an object * - * @param object|string $object UID or rcube_message object - * @param array $categories Addition tag names to merge with + * @param rcube_message_header|string $object UID or mail message headers + * @param array $categories Addition tag names to merge with * * @return array List of categories */ - public function getCategories($object, $categories = ) + protected function getCategories($object, $categories = ) { if (is_object($object)) { // support only messages with message-id - if (!($msg_id = $object->headers->get('message-id', false))) { + if (!($msg_id = $object->get('message-id', false))) { return ; } @@ -952,8 +952,10 @@ $message = new rcube_message($uid, $foldername); if (!empty($message->headers)) { - if ($this->relationSupport) { - $message->headers->others'categories' = $this->getCategories($message); + if (in_array($type, $this->relationSupport)) { + $message->headers->folder = $foldername; + $message->headers->uid = $uid; + $message->headers->others'categories' = $this->getCategories($message->headers); } return $message; @@ -974,7 +976,7 @@ throw new Syncroton_Exception_Status(Syncroton_Exception_Status::SERVER_ERROR); } - $useTags = $this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES); + $useTags = in_array($type, $this->relationSupport); if ($useTags) { $result'categories' = $this->getCategories($uid, $result'categories' ?? ); @@ -1071,10 +1073,10 @@ /** * Set categories to an object * - * @param object|string $object UID or rcube_message object - * @param array $categories List of Category names + * @param rcube_message_header|string $object UID or mail message headers + * @param array $categories List of Category names */ - public function setCategories($object, $categories) + protected function setCategories($object, $categories) { if (!is_object($object)) { $config = kolab_storage_config::get_instance(); @@ -1084,7 +1086,7 @@ $config = kolab_storage_config::get_instance(); $delta = Syncroton_Registry::getPingTimeout(); - $uri = kolab_storage_config::get_message_uri($object->headers, $object->folder); + $uri = kolab_storage_config::get_message_uri($object, $object->folder); // for all tag objects... foreach ($config->get_tags() as $relation) { @@ -1250,7 +1252,7 @@ } // get members of modified relations - if ($this->relationSupport) { + if (in_array($type, $this->relationSupport)) { $changed_msgs = $this->getChangesByRelations($folderid, $device_key, $type, $filter); // handle relation changes if (!empty($changed_msgs)) { @@ -1258,7 +1260,7 @@ switch ($result_type) { case kolab_sync_data::RESULT_COUNT: - $result += count($members); + $result += count($members); // @phpstan-ignore-line break; case kolab_sync_data::RESULT_UID: @@ -1319,7 +1321,7 @@ // there's a PHP Warning from kolab_storage if $filter isn't an array if (empty($filter)) { $filter = ; - } elseif ($this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES)) { + } elseif (in_array($type, $this->relationSupport)) { $changed_objects = $this->getChangesByRelations($folderid, $device_key, $type, $filter); } @@ -1376,7 +1378,7 @@ // need a precise result here $count = $folder->count($tag_filter); if ($count !== null) { - $result += (int) $count; + $result += (int) $count; // @phpstan-ignore-line } break; @@ -1942,7 +1944,7 @@ $rcube = rcube::get_instance(); $db = $rcube->get_dbh(); $this->relations$folderid$synctime = $relations; - $data = rcube_charset::clean(json_encode($relations)); + $data = gzdeflate(json_encode($relations)); $result = $db->insert_or_update( 'syncroton_relations_state', @@ -2001,11 +2003,15 @@ } if ($row) { - // Don't use $row'synctime' for the internal cache. + // Don't use $row'synctime' for the internal cache, and use $synctime instead. // The synctime of the found row is usually earlier than the requested synctime. - // Note: We use internal cache because there's a call to both hasChanges() and + // Note: We use the internal cache because there's a call to both hasChanges() and // getChangedEntries() in Sync. It's needed until we add some caching on a higher level. - $this->relations$folderid$synctime = json_decode($row'data', true); + $data = $row'data'; + $inflated = gzinflate($data); + // Inflation may fail for backward compatiblity + $data = $inflated ? $inflated : $data; + $this->relations$folderid$synctime = json_decode($data, true); // Cleanup: remove all records older than the current one. // We must use the row's synctime, otherwise we would delete the record we just loaded
View file
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_storage_kolab4.php
Changed
@@ -29,7 +29,8 @@ class kolab_sync_storage_kolab4 extends kolab_sync_storage { protected $davStorage = null; - public $relationSupport = false; + protected $tagStorage = null; + protected $relationSupport = self::MODEL_EMAIL; /** * This implements the 'singleton' design pattern @@ -66,6 +67,7 @@ // Inject user+password to the URL, there's no other way to pass it to the DAV client $url = str_replace('://', '://' . rawurlencode($sync->username) . ':' . rawurlencode($sync->password) . '@', $url); + $this->tagStorage = new kolab_storage_tags(); $this->davStorage = new kolab_storage_dav($url); // DAV $this->storage = $sync->get_storage(); // IMAP @@ -465,6 +467,35 @@ } /** + * Returns list of categories assigned to an object + * + * @param rcube_message_header|string $object UID or mail message headers + * @param array $categories Addition tag names to merge with + * + * @return array List of categories + */ + protected function getCategories($object, $categories = ) + { + $tags = $this->tagStorage->get_tags_for($object); + + // merge result with old categories + if (!empty($categories)) { + $tags = array_unique(array_merge($tags, (array) $categories)); + } + + return $tags; + } + + /** + * Detect changes of tag objects data and assigned messages + */ + protected function getChangesByRelations($folderid, $device_key, $type, $filter) + { + // This is not needed with Kolab4 that uses METADATA/ANNOTATE and immutable tags + return ; + } + + /** * Gets kolab_storage_folder object from Activesync folder ID. * * @param string $folderid Folder identifier @@ -568,4 +599,15 @@ } return parent::getExtraData($folderid, $deviceid); } + + /** + * Set categories to an object + * + * @param rcube_message_header|string $object UID or mail message headers + * @param array $categories List of Category names + */ + protected function setCategories($object, $categories) + { + $this->tagStorage->set_tags_for($object, $categories); + } }
View file
kolab-syncroton-2.4.2.tar.gz/tests/Sync/FoldersTest.php
Changed
@@ -5,17 +5,16 @@ /** * Cleanup folders */ - public function setUp(): void + protected function foldersCleanup(): void { // Note: We essentially assume the test account is in an initial state, extra folders may break tests // Anyway, we first remove folders that might have been created during tests in this file - $this->deleteTestFolder('Test Folder', 'mail'); $this->deleteTestFolder('NewFolder', 'mail'); $this->deleteTestFolder('NewFolder2', 'mail'); + $this->deleteTestFolder('Test Folder', 'mail'); $this->deleteTestFolder('Test Folder New', 'mail'); $this->deleteTestFolder('Test Contacts Folder', 'contact'); $this->deleteTestFolder('Test Contacts New', 'contact'); - parent::setUp(); } /** @@ -23,6 +22,8 @@ */ public function testFolderSyncBasic() { + $this->foldersCleanup(); + $request = <<<EOF <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> @@ -63,13 +64,12 @@ // No changes on second sync $this->assertSame(strval(0), $xpath->query("//ns:FolderSync/ns:Changes/ns:Count")->item(0)->nodeValue); - //Clear the creation_synckey (that's the migration scenario) //Shouldn't trigger a change $rcube = \rcube::get_instance(); $db = $rcube->get_dbh(); $result = $db->query( - "UPDATE `syncroton_folder` SET `creation_synckey` = null", + "UPDATE `syncroton_folder` SET `creation_synckey` = 0", ); $request = <<<EOF @@ -84,7 +84,6 @@ $this->assertEquals(200, $response->getStatusCode()); $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - $this->printDom($dom); $this->assertSame('1', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue); $this->assertSame('1', $xpath->query("//ns:FolderSync/ns:SyncKey")->item(0)->nodeValue); // No changes on second sync @@ -114,14 +113,11 @@ $this->assertSame('9', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue); } - /** * Test synckey reuse */ public function testSyncKeyResend() { - $this->deleteTestFolder('NewFolder', 'mail'); - $this->deleteTestFolder('NewFolder2', 'mail'); $request = <<<EOF <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> @@ -216,6 +212,48 @@ $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); $this->assertSame('9', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue); + } + + /** + * This test recreates a previously deleted folder. + * Currently similar to disabling/reenabling a folder for sync, but should perhaps be tested separately + * + * @depends testSyncKeyResend + */ + public function testRecreatePreviousFolder() + { + $this->deleteTestFolder('NewFolder', 'mail'); + $this->deleteTestFolder('NewFolder2', 'mail'); + $request = <<<EOF + <?xml version="1.0" encoding="utf-8"?> + <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> + <FolderSync xmlns="uri:FolderHierarchy"> + <SyncKey>0</SyncKey> + </FolderSync> + EOF; + $response = $this->request($request, 'FolderSync'); + $this->assertEquals(200, $response->getStatusCode()); + $dom = $this->fromWbxml($response->getBody()); + $xpath = $this->xpath($dom); + $this->assertSame('1', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue); + + //Now change something + $this->createTestFolder("NewFolder", "mail"); + $request = <<<EOF + <?xml version="1.0" encoding="utf-8"?> + <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> + <FolderSync xmlns="uri:FolderHierarchy"> + <SyncKey>1</SyncKey> + </FolderSync> + EOF; + + $response = $this->request($request, 'FolderSync'); + $this->assertEquals(200, $response->getStatusCode()); + $dom = $this->fromWbxml($response->getBody()); + $xpath = $this->xpath($dom); + $this->assertSame('1', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue); + $this->assertSame('2', $xpath->query("//ns:FolderSync/ns:SyncKey")->item(0)->nodeValue); + $this->assertSame(strval(1), $xpath->query("//ns:FolderSync/ns:Changes/ns:Count")->item(0)->nodeValue); // Cleanup for the other tests $this->deleteTestFolder('NewFolder', 'mail'); @@ -227,6 +265,8 @@ */ public function testFolderSync() { + $this->foldersCleanup(); + $this->resetDevice(); $request = <<<EOF <?xml version="1.0" encoding="utf-8"?>
View file
kolab-syncroton-2.4.2.tar.gz/tests/Sync/MoveItemsTest.php
Changed
@@ -205,8 +205,7 @@ // Test with multi-folder support enabled self::$deviceType = 'iphone'; - // @phpstan-ignore-next-line - $davFolder = $this->isStorageDriver('kolab') ? 'Contacts' : 'Addressbook'; + $davFolder = 'Contacts'; $this->emptyTestFolder($davFolder, 'contact'); $this->deleteTestFolder($folderName = 'Test Contacts Folder', 'contact'); $this->appendObject($davFolder, 'contact.vcard1', 'contact');
View file
kolab-syncroton-2.4.2.tar.gz/tests/Sync/PingTest.php
Changed
@@ -2,7 +2,6 @@ class PingTest extends Tests\SyncTestCase { - /** * Test Ping command */ @@ -28,7 +27,6 @@ $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - $this->printDom($dom); //Initially we know no folders $this->assertSame('7', $xpath->query("//ns:Ping/ns:Status")->item(0)->nodeValue); @@ -65,8 +63,7 @@ $this->assertEquals(200, $response->getStatusCode()); $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - // $this->printDom($dom); - //Initially we know no folders + // Initially we know no folders $this->assertSame('2', $xpath->query("//ns:Ping/ns:Status")->item(0)->nodeValue); } @@ -95,7 +92,6 @@ $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - // $this->printDom($dom); $this->assertSame('7', $xpath->query("//ns:Ping/ns:Status")->item(0)->nodeValue); }
View file
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/ContactsTest.php
Changed
@@ -9,7 +9,7 @@ */ public function testSync() { - $davFolder = $this->isStorageDriver('kolab') ? 'Contacts' : 'Addressbook'; + $davFolder = 'Contacts'; $this->emptyTestFolder($davFolder, 'contact'); $this->deleteTestFolder('Test Contacts Folder', 'contact'); // from other test files $this->registerDevice();
View file
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/EmailITipTest.php
Changed
@@ -69,8 +69,6 @@ $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - // print($dom->saveXML()); - $root = "//ns:Sync/ns:Collections/ns:Collection"; $this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue); $this->assertSame(strval(++$syncKey), $xpath->query("{$root}/ns:SyncKey")->item(0)->nodeValue);
View file
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/EmailTest.php
Changed
@@ -148,6 +148,7 @@ $this->assertSame(strval(++$syncKey), $xpath->query("{$root}/ns:SyncKey")->item(0)->nodeValue); $this->assertSame($folderId, $xpath->query("{$root}/ns:CollectionId")->item(0)->nodeValue); $this->assertSame(1, $xpath->query("{$root}/ns:Commands/ns:Add")->count()); + $this->assertSame('0', $xpath->query("{$root}/ns:Commands/ns:Add/ns:ApplicationData/Email:Read")->item(0)->nodeValue); // Note: We assume messages are in IMAP default order, it may change in future $root .= "/ns:Commands/ns:Add"; @@ -238,7 +239,6 @@ $this->assertEquals(200, $response->getStatusCode()); $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - // print($dom->saveXML()); $root = "//ns:Sync/ns:Collections/ns:Collection"; $this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue); @@ -247,10 +247,10 @@ $this->assertSame(0, $xpath->query("{$root}/ns:Commands/ns:Add")->count()); $this->assertSame(2, $xpath->query("{$root}/ns:Commands/ns:Change")->count()); $this->assertSame(2, $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->count()); - $this->assertSame('0', $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->item(0)->nodeValue); - $this->assertSame('0', $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->item(1)->nodeValue); - + $this->assertSame('1', $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->item(0)->nodeValue); + $this->assertSame('1', $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->item(1)->nodeValue); $this->assertSame(0, $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/AirSyncBase:Body")->count()); + return $syncKey; } @@ -293,7 +293,6 @@ $this->assertEquals(200, $response->getStatusCode()); $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - // print($dom->saveXML()); $root = "//ns:Sync/ns:Collections/ns:Collection"; $this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue); @@ -349,7 +348,6 @@ $this->assertEquals(200, $response->getStatusCode()); $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - // print($dom->saveXML()); $root = "//ns:Sync/ns:Collections/ns:Collection"; $this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue); @@ -404,7 +402,6 @@ $this->assertEquals(200, $response->getStatusCode()); $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - // print($dom->saveXML()); $root = "//ns:Sync/ns:Collections/ns:Collection"; $this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue); @@ -422,7 +419,6 @@ return $syncKey; } - /** * Test a sync key that doesn't exist yet. * @depends testDeleteFromClient @@ -460,7 +456,6 @@ $this->assertEquals(200, $response->getStatusCode()); $dom = $this->fromWbxml($response->getBody()); $xpath = $this->xpath($dom); - // print($dom->saveXML()); $root = "//ns:Sync/ns:Collections/ns:Collection"; $this->assertSame('3', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue); @@ -469,5 +464,4 @@ //We have to start over after this. The sync state was removed. return 0; } - }
View file
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/InconsistencyTest.php
Changed
@@ -124,15 +124,11 @@ $this->assertSame($folderId, $xpath->query("{$root}/ns:CollectionId")->item(0)->nodeValue); $this->assertSame(1, $xpath->query("{$root}/ns:Commands/ns:Add")->count()); - - //Assert that we have all content parts back - $sync = \kolab_sync::get_instance(); - $device = $sync->storage()->device_get(self::$deviceId); - + // Assert that we have all content parts back $result = $db->query( "SELECT `contentid` FROM `syncroton_content`" - . " WHERE `device_id` = ?", - $device'ID' + . " WHERE `device_id` IN (SELECT `id` FROM `syncroton_device` WHERE `deviceid` = ?)", + self::$deviceId ); $data = ; while ($state = $db->fetch_assoc($result)) { @@ -142,5 +138,4 @@ return $syncKey; } - }
View file
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/RelationsTest.php
Changed
@@ -55,7 +55,7 @@ $db = \rcube::get_instance()->get_dbh(); $result = $db->query( "SELECT `data`, `synctime` FROM `syncroton_relations_state`" - . " WHERE `device_id` = ? AND `folder_id` = ?" + . " WHERE `device_id` IN (SELECT `id` FROM `syncroton_device` WHERE `deviceid` = ?) AND `folder_id` = ?" . " ORDER BY `synctime` DESC", $device_id, $folderId @@ -73,12 +73,13 @@ public function testRelationsSync() { $sync = \kolab_sync::get_instance(); - if (!$sync->storage()->relationSupport) { - $this->markTestSkipped('No relation support'); - } $this->emptyTestFolder('INBOX', 'mail'); - $this->emptyTestFolder('Configuration', 'configuration'); + if ($this->isStorageDriver('kolab4')) { + $sync->get_storage()->set_metadata(\kolab_storage_tags::METADATA_ROOT, \kolab_storage_tags::METADATA_TAGS_KEY => null); + } else { + $this->emptyTestFolder('Configuration', 'configuration'); + } $this->registerDevice(); // Test INBOX @@ -103,10 +104,8 @@ $sync = \kolab_sync::get_instance(); - $device = $sync->storage()->device_get(self::$deviceId); - - //Add a tag - $sync->storage()->updateItem($folderId, $device'ID', \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1'); + // Add a tag + $sync->storage(true)->updateItem($folderId, self::$deviceId, \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1'); sleep(1); $response = $this->syncRequest($syncKey, $folderId, 10); @@ -123,8 +122,8 @@ $this->assertSame(1, $xpath->query("{$root}/ns:ApplicationData/Email:Categories")->count()); $this->assertSame("test1", $xpath->query("{$root}/ns:ApplicationData/Email:Categories")->item(0)->nodeValue); - //Add a second tag - $sync->storage()->updateItem($folderId, $device'ID', \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1', 'test2'); + // Add a second tag + $sync->storage(true)->updateItem($folderId, self::$deviceId, \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1', 'test2'); sleep(1); // Necessary to make sure we pick up on the tag. $response = $this->syncRequest($syncKey, $folderId, 10); @@ -163,7 +162,9 @@ $this->assertSame("test1test2", $xpath->query("{$root}/ns:ApplicationData/Email:Categories")->item(0)->nodeValue); // Assert the db state - $this->assertSame(2, count($this->getRelationsState($device'ID', $folderId))); + if ($this->isStorageDriver('kolab')) { + $this->assertSame(2, count($this->getRelationsState(self::$deviceId, $folderId))); + } // Make sure we have a new timestamp after the first iteration. // This way we can potentially catch errors when we end up using the same or a different timestamp. sleep(1); @@ -171,7 +172,7 @@ $syncKey += ($retries + 1); // Reset to no tags - $sync->storage()->updateItem($folderId, $device'ID', \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => ); + $sync->storage(true)->updateItem($folderId, self::$deviceId, \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => ); sleep(1); // Necessary to make sure we pick up on the tag. $response = $this->syncRequest($syncKey, $folderId, 10); @@ -190,9 +191,10 @@ //FIXME this currently fails because we omit the empty categories element // $this->assertSame("", $xpath->query("{$root}/ns:ApplicationData/Email:Categories")->item(0)->nodeValue); - // Assert the db state - $this->assertSame(2, count($this->getRelationsState($device'ID', $folderId))); + if ($this->isStorageDriver('kolab')) { + $this->assertSame(2, count($this->getRelationsState(self::$deviceId, $folderId))); + } $response = $this->syncRequest($syncKey, $folderId, 10); $this->assertEquals(200, $response->getStatusCode()); @@ -208,10 +210,9 @@ // Setup with a tag and an initial sync completed $folderId = '38b950ebd62cd9a66929c89615d0fc04'; $sync = \kolab_sync::get_instance(); - $device = $sync->storage()->device_get(self::$deviceId); $uid1 = $this->appendMail('INBOX', 'mail.sync1'); - $sync->storage()->updateItem($folderId, $device'ID', \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1'); + $sync->storage(true)->updateItem($folderId, self::$deviceId, \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1'); sleep(1); $response = $this->syncRequest(0, $folderId, 10); @@ -219,14 +220,15 @@ $response = $this->syncRequest(1, $folderId, 10); $this->assertEquals(200, $response->getStatusCode()); - - $this->assertSame(2, count($this->getRelationsState($device'ID', $folderId))); + if ($this->isStorageDriver('kolab')) { + $this->assertSame(2, count($this->getRelationsState(self::$deviceId, $folderId))); + } // Make sure the timestamp changes sleep(1); // Pings should not change the number of relation states - for ($i=0; $i < 2; $i++) { + for ($i = 0; $i < 2; $i++) { $request = <<<EOF <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> @@ -244,7 +246,9 @@ $response = $this->request($request, 'Ping'); $this->assertEquals(200, $response->getStatusCode()); - $this->assertSame(1, count($this->getRelationsState($device'ID', $folderId))); + if ($this->isStorageDriver('kolab')) { + $this->assertSame(1, count($this->getRelationsState(self::$deviceId, $folderId))); + } } // This simulates a specific case where we had: @@ -273,7 +277,8 @@ $response = $this->request($request, 'Ping'); $this->assertEquals(200, $response->getStatusCode()); - $this->assertSame(1, count($this->getRelationsState($device'ID', $folderId))); - + if ($this->isStorageDriver('kolab')) { + $this->assertSame(1, count($this->getRelationsState(self::$deviceId, $folderId))); + } } }
View file
kolab-syncroton-2.4.2.tar.gz/tests/SyncTestCase.php
Changed
@@ -43,7 +43,7 @@ return; } - self::$deviceId = 'test' . time(); + self::$deviceId = 'test' . str_replace('.', '', microtime(true)); $db->query('DELETE FROM syncroton_device'); $db->query('DELETE FROM syncroton_synckey'); @@ -379,6 +379,19 @@ } } + protected function resetDevice() + { + $sync = \kolab_sync::get_instance(); + + if (self::$deviceId) { + $storage = $sync->storage(); + $storage->device_delete(self::$deviceId); + } + + $db = $sync->get_dbh(); + $db->query('DELETE FROM syncroton_device'); + } + /** * Convert XML into WBXML binary content */
View file
kolab-syncroton.dsc
Changed
@@ -2,7 +2,7 @@ Source: kolab-syncroton Binary: kolab-syncroton Architecture: all -Version: 1:2.4.2.36-1~kolab1 +Version: 1:2.4.2.37-1~kolab1 Maintainer: Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> Uploaders: Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> Homepage: http://www.kolab.org/
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.