Projects
Kolab:16:Enterprise
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 50
View file
kolab-syncroton.spec
Changed
@@ -36,7 +36,7 @@ %global _ap_sysconfdir %{_sysconfdir}/%{httpd_name} Name: kolab-syncroton -Version: 2.3.23 +Version: 2.4.0 Release: 1%{?dist} Summary: ActiveSync for Kolab Groupware @@ -44,7 +44,7 @@ License: LGPLv2 URL: http://www.syncroton.org -Source0: https://mirror.kolabenterprise.com/pub/releases/%{name}-%{version}.tar.gz +Source0: %{name}-%{version}.tar.gz Source1: kolab-syncroton.logrotate Source2: plesk.kolab_syncroton.inc.php @@ -68,6 +68,7 @@ %endif %endif +Requires: roundcubemail Requires: logrotate %if 0%{?rhel} < 8 Requires: php-kolabformat @@ -171,7 +172,7 @@ fi /usr/share/roundcubemail/bin/updatedb.sh \ - --dir /usr/share/doc/kolab-syncroton-%{version}/SQL/ \ + --dir /usr/share/doc/kolab-syncroton/SQL/ \ --package syncroton \ >/dev/null 2>&1 || : @@ -192,6 +193,9 @@ %attr(0770,%{httpd_user},%{httpd_group}) %{_var}/log/%{name} %changelog +* Wed May 10 2023 Christian Mollekopf <mollekopf@apheleia-it.ch> - 2.4.0-1 +- Release version 2.4.0 + * Fri Feb 04 2022 Jeroen van Meeuwen <vanmeeuwen@apheleia-it.ch> - 2.3.22-1 - Release version 2.3.22
View file
debian.changelog
Changed
@@ -1,3 +1,9 @@ +kolab-syncroton (2.4.0-0~kolab1) unstable; urgency=low + + * Release version 2.4.0 + + -- Christian Mollekopf <mollekopf@apheleia-it.ch> Wed, 10 May 2023 15:13:40 +0200 + kolab-syncroton (2.3.23-0~kolab1) unstable; urgency=low * Release version 2.3.23
View file
kolab-syncroton-2.4.0.tar.gz/docs/SQL/mysql/2023100500.sql
Added
@@ -0,0 +1,2 @@ + +ALTER TABLE `syncroton_synckey` ADD `client_id_map` longblob DEFAULT NULL;
View file
kolab-syncroton-2.3.23.tar.gz/lib/ext/Syncroton/Command/Settings.php -> kolab-syncroton-2.4.0.tar.gz/lib/ext/Syncroton/Command/Settings.php
Changed
@@ -110,6 +110,7 @@ // Out-of-Office if (!empty($this->_OofGet)) { + $OofGet = null; try { $OofGet = $this->_deviceBackend->getOOF($this->_OofGet); } catch (Exception $e) {
View file
kolab-syncroton-2.3.23.tar.gz/lib/ext/Syncroton/Command/Sync.php -> kolab-syncroton-2.4.0.tar.gz/lib/ext/Syncroton/Command/Sync.php
Changed
@@ -243,7 +243,12 @@ continue; } - // check for invalid sycnkey + $syncKeyReused = $this->_syncStateBackend->haveNext($this->_device, $collectionData->folder, $collectionData->syncKey); + if ($syncKeyReused) { + if ($this->_logger instanceof Zend_Log) + $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " already known synckey {$collectionData->syncKey} provided"); + } + // check for invalid synckey 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"); @@ -301,6 +306,11 @@ if ($this->_logger instanceof Zend_Log) $this->_logger->info(__METHOD__ . '::' . __LINE__ . " found " . count($adds) . " entries to be added to server"); + $clientIdMap = ; + if ($syncKeyReused && $collectionData->syncState->clientIdMap) { + $clientIdMap = Zend_Json::decode($collectionData->syncState->clientIdMap); + } + foreach ($adds as $add) { if ($this->_logger instanceof Zend_Log) $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " add entry with clientId " . (string) $add->ClientId); @@ -309,20 +319,35 @@ if ($this->_logger instanceof Zend_Log) $this->_logger->info(__METHOD__ . '::' . __LINE__ . " adding entry as new"); - $serverId = $dataController->createEntry($collectionData->collectionId, new $dataClass($add->ApplicationData)); - - $clientModifications'added'$serverId = array( - 'clientId' => (string)$add->ClientId, - 'serverId' => $serverId, - 'status' => self::STATUS_SUCCESS, - 'contentState' => $this->_contentStateBackend->create(new Syncroton_Model_Content(array( - 'device_id' => $this->_device, - 'folder_id' => $collectionData->folder, - 'contentid' => $serverId, - 'creation_time' => $this->_syncTimeStamp, - 'creation_synckey' => $collectionData->syncKey + 1 - ))) - ); + $clientId = (string)$add->ClientId; + // If the sync key was reused, but we don't have a $clientId mapping, + // this means the client sent a new item with the same sync_key. + if ($syncKeyReused && array_key_exists($clientId, $clientIdMap)) { + // We don't normally store the clientId, so if a command with Add's is resent, + // we have to look-up the corresponding serverId using a cached clientId => serverId mapping, + // otherwise we would duplicate all added items on resend. + $serverId = $clientIdMap$clientId; + $clientModifications'added'$serverId = array( + 'clientId' => (string)$add->ClientId, + 'serverId' => $serverId, + 'status' => self::STATUS_SUCCESS, + 'contentState' => null + ); + } else { + $serverId = $dataController->createEntry($collectionData->collectionId, new $dataClass($add->ApplicationData)); + $clientModifications'added'$serverId = array( + 'clientId' => (string)$add->ClientId, + 'serverId' => $serverId, + 'status' => self::STATUS_SUCCESS, + 'contentState' => $this->_contentStateBackend->create(new Syncroton_Model_Content(array( + 'device_id' => $this->_device, + 'folder_id' => $collectionData->folder, + 'contentid' => $serverId, + 'creation_time' => $this->_syncTimeStamp, + 'creation_synckey' => $collectionData->syncKey + 1 + ))) + ); + } } catch (Exception $e) { if ($this->_logger instanceof Zend_Log) @@ -336,7 +361,7 @@ } // handle changes, but only if not first sync - if($collectionData->syncKey > 1 && $collectionData->hasClientChanges()) { + if(!$syncKeyReused && $collectionData->syncKey > 1 && $collectionData->hasClientChanges()) { $changes = $collectionData->getClientChanges(); if ($this->_logger instanceof Zend_Log) @@ -367,7 +392,7 @@ } // handle deletes, but only if not first sync - if($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"); @@ -670,8 +695,8 @@ if ($this->_logger instanceof Zend_Log) $this->_logger->info(__METHOD__ . '::' . __LINE__ . " skipped added entry: " . $serverId); unset($serverModifications'added'$id); - } } + } // entries to be deleted $serverModifications'deleted' = array_diff($allClientEntries, $allServerEntries); @@ -731,7 +756,7 @@ 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 is the add failed + // we have no serverId if the add failed if(isset($entryData'serverId')) { $add->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ServerId', $entryData'serverId')); } @@ -990,50 +1015,65 @@ $collectionData->syncState->pendingdata = null; } - - if (!empty($clientModifications'added')) { - if ($this->_logger instanceof Zend_Log) - $this->_logger->info(__METHOD__ . '::' . __LINE__ . " remove previous synckey as client added new entries"); - $keepPreviousSyncKey = false; - } else { - $keepPreviousSyncKey = true; - } - $collectionData->syncState->lastsync = clone $this->_syncTimeStamp; // increment sync timestamp by 1 second $collectionData->syncState->lastsync->modify('+1 sec'); - - try { - $transactionId = Syncroton_Registry::getTransactionManager()->startTransaction(Syncroton_Registry::getDatabase()); - - // store new synckey - $this->_syncStateBackend->create($collectionData->syncState, $keepPreviousSyncKey); - - // store contentstates for new entries added to client - foreach($newContentStates as $state) { - $this->_contentStateBackend->create($state); - } - - // remove contentstates for entries to be deleted on client - foreach($deletedContentStates as $state) { - $this->_contentStateBackend->delete($state); + if (!empty($clientModifications'added')) { + // Store a client id mapping in case we encounter a reused sync_key in a future request. + $newClientIdMap = ; + foreach($clientModifications'added' as $entryData) { + $newClientIdMap$entryData'clientId' = $entryData'serverId'; } - - Syncroton_Registry::getTransactionManager()->commitTransaction($transactionId); - } catch (Zend_Db_Statement_Exception $zdse) { - // something went wrong - // maybe another parallel request added a new synckey - // we must remove data added from client - if (!empty($clientModifications'added')) { - foreach ($clientModifications'added' as $added) { - $this->_contentStateBackend->delete($added'contentState'); - $dataController->deleteEntry($collectionData->collectionId, $added'serverId', array()); + $collectionData->syncState->clientIdMap = Zend_Json::encode($newClientIdMap); + } + + //Retry in case of deadlock + $retries = 0; + while (True) { + try { + $transactionId = Syncroton_Registry::getTransactionManager()->startTransaction(Syncroton_Registry::getDatabase()); + // store new synckey + $this->_syncStateBackend->create($collectionData->syncState, true); + + // store contentstates for new entries added to client + foreach($newContentStates as $state) { + $this->_contentStateBackend->create($state); + } + + // remove contentstates for entries to be deleted on client + foreach($deletedContentStates as $state) { + $this->_contentStateBackend->delete($state); + } + + Syncroton_Registry::getTransactionManager()->commitTransaction($transactionId); + break; + } catch (Exception $zdse) { + $retries++; + if ($retries > 5) { + if ($this->_logger instanceof Zend_Log) + $this->_logger->warn(__METHOD__ . '::' . __LINE__ . ' exception while storing new synckey. Aborting after 5 retries.'); + + // something went wrong + // maybe another parallel request added a new synckey + // we must remove data added from client + if (!empty($clientModifications'added')) { + foreach ($clientModifications'added' as $added) { + $this->_contentStateBackend->delete($added'contentState'); + $dataController->deleteEntry($collectionData->collectionId, $added'serverId', array()); + } + } + + Syncroton_Registry::getTransactionManager()->rollBack();
View file
kolab-syncroton-2.3.23.tar.gz/lib/ext/Syncroton/Exception/Status/Settings.php -> kolab-syncroton-2.4.0.tar.gz/lib/ext/Syncroton/Exception/Status/Settings.php
Changed
@@ -32,11 +32,11 @@ * @var array */ protected $_errorMessages = array( - self::PROTOCOL_ERROR => "Protocol error"; - self::ACCESS_DENIED => "Access denied"; - self::SERVICE_UNAVAILABLE => "Server unavailable"; - self::INVALID_ARGUMENTS => "Invalid arguments"; - self::CONFLICTING_ARGUMENTS => "Conflicting arguments"; - self::DENIED_BY_POLICY => "Denied by policy. Disabled by administrator"; + self::PROTOCOL_ERROR => "Protocol error", + self::ACCESS_DENIED => "Access denied", + self::SERVICE_UNAVAILABLE => "Server unavailable", + self::INVALID_ARGUMENTS => "Invalid arguments", + self::CONFLICTING_ARGUMENTS => "Conflicting arguments", + self::DENIED_BY_POLICY => "Denied by policy. Disabled by administrator", ); }
View file
kolab-syncroton-2.3.23.tar.gz/lib/ext/Syncroton/Model/ISyncState.php -> kolab-syncroton-2.4.0.tar.gz/lib/ext/Syncroton/Model/ISyncState.php
Changed
@@ -19,6 +19,7 @@ * @property string counter * @property DateTime lastsync * @property string pendingdata + * @property string client_id_map */ interface Syncroton_Model_ISyncState {
View file
kolab-syncroton-2.3.23.tar.gz/lib/ext/Syncroton/Wbxml/Encoder.php -> kolab-syncroton-2.4.0.tar.gz/lib/ext/Syncroton/Wbxml/Encoder.php
Changed
@@ -20,27 +20,6 @@ class Syncroton_Wbxml_Encoder extends Syncroton_Wbxml_Abstract { /** - * stack of dtd objects - * - * @var array - */ - protected $_dtdStack = array(); - - /** - * stack of stream resources - * - * @var array - */ - protected $_streamStack = array(); - - /** - * stack of levels when to pop data from the other stacks - * - * @var array - */ - protected $_popStack = array(); - - /** * count level of tags * * @var string @@ -48,27 +27,6 @@ protected $_level = 0; /** - * when to take data next time from the different stacks - * - * @var unknown_type - */ - protected $_nextStackPop = NULL; - - /** - * collect data trough different calls to _handleCharacters - * - * @var string - */ - protected $_currentTagData = NULL; - - /** - * the current tag as read by the parser - * - * @var string - */ - protected $_currentTag = NULL; - - /** * the constructor * * @param resource $_stream @@ -151,67 +109,66 @@ { $_dom->formatOutput = false; - $tempStream = tmpfile(); - - $meta_data = stream_get_meta_data($tempStream); - $filename = $meta_data"uri"; - $_dom->save($filename); - rewind($tempStream); - $this->_initialize($_dom); - - $parser = xml_parser_create_ns($this->_charSet, ';'); - xml_set_object($parser, $this); - xml_set_element_handler($parser, '_handleStartTag', '_handleEndTag'); - xml_set_character_data_handler($parser, '_handleCharacters'); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - - while (!feof($tempStream)) { - if (!xml_parse($parser, fread($tempStream, 1048576), feof($tempStream))) { - // uncomment to write xml document to file - #rewind($tempStream); - #$xmlStream = fopen(tempnam(sys_get_temp_dir(), "xmlerrors"), 'r+'); - #stream_copy_to_stream($tempStream, $xmlStream); - #fclose($xmlStream); - - throw new Syncroton_Wbxml_Exception(sprintf('XML error: %s at line %d', - xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser) - )); + $this->_traverseDom($_dom); + } + + private function getAttributes($node) + { + $attributes = array(); + if ($node->attributes) { + for ($i = 0; $i < $node->attributes->length; ++$i) { + $attributes$node->attributes->item($i)->name = $node->attributes->item($i)->value; } } + return $attributes; + } - fclose($tempStream); - xml_parser_free($parser); + private function writeNode($node, $withContent = false, $data = null) { + if($this->_codePage->getNameSpace() != $node->namespaceURI) { + $this->_switchCodePage($node->namespaceURI); + } + $this->_writeTag($node->localName, $this->getAttributes($node), $withContent, $data); } - /** - * get's called by xml parser when tag starts - * - * @param resource $_parser - * @param string $_tag current tag prefixed with namespace - * @param array $_attributes list of tag attributes - */ - protected function _handleStartTag($_parser, $_tag, $_attributes) + protected function _traverseDom($_dom) { - $this->_level++; - $this->_currentTagData = null; - - // write data for previous tag happens whith <tag1><tag2> - if($this->_currentTag !== NULL) { - $this->_writeTag($this->_currentTag, $this->_attributes, true); + if ($_dom->childNodes->length == 0) { + return false; } - - list($nameSpace, $this->_currentTag) = explode(';', $_tag); - - if($this->_codePage->getNameSpace() != $nameSpace) { - $this->_switchCodePage($nameSpace); + // print(str_pad("", $this->_level, " ") . "traversing {$_dom->nodeName}" . "\n"); + $this->_level++; + $prevNode = $_dom; + $foundElementNode = false; + foreach ($_dom->childNodes as $node) { + if ($node->nodeType == XML_ELEMENT_NODE) { + $foundElementNode = true; + if ($prevNode && $this->_level > 1) { + // print(str_pad("", $this->_level, " ") . "{$node->nodeName} creating parent {$prevNode->nodeName}" . "\n"); + $this->writeNode($prevNode, true); + $prevNode = null; + } + if (!$this->_traverseDom($node)) { + // print(str_pad("", $this->_level, " ") . "{$node->nodeName} content {$node->nodeValue}" . "\n"); + $data = $node->nodeValue; + if (strlen($data) == 0) { + $this->writeNode($node); + } else { + $this->writeNode($node, true, $data); + $this->_writeByte(Syncroton_Wbxml_Abstract::END); + // print("Closing tag after writing tag\n"); + } + } else { + $this->_writeByte(Syncroton_Wbxml_Abstract::END); + // print("Closing tag\n"); + } + } } + $this->_level--; - $this->_attributes = $_attributes; - + return $foundElementNode; } - + /** * strip uri: from nameSpace * @@ -224,73 +181,6 @@ } /** - * get's called by xml parser when tag ends - * - * @param resource $_parser - * @param string $_tag current tag prefixed with namespace - */ - protected function _handleEndTag($_parser, $_tag) - { - #echo "$_tag Level: $this->_level == $this->_nextStackPop \n"; - - if($this->_nextStackPop !== NULL && $this->_nextStackPop == $this->_level) { - #echo "TAG: $_tag\n"; - $this->_writeByte(Syncroton_Wbxml_Abstract::END); - - $subStream = $this->_stream; - $subStreamLength = ftell($subStream); - - $this->_dtd = array_pop($this->_dtdStack); - $this->_stream = array_pop($this->_streamStack); - $this->_nextStackPop = array_pop($this->_popStack); - $this->_codePage = $this->_dtd->getCurrentCodePage(); - - rewind($subStream); - #while (!feof($subStream)) {$buffer = fgets($subStream, 4096);echo $buffer;}
View file
kolab-syncroton-2.3.23.tar.gz/lib/kolab_sync.php -> kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync.php
Changed
@@ -48,7 +48,7 @@ public $task = null; const CHARSET = 'UTF-8'; - const VERSION = "2.3.22"; + const VERSION = "2.4.0"; /** @@ -301,7 +301,8 @@ // parse $host $a_host = parse_url($host); $port = null; - if ($a_host'host') { + $ssl = null; + if (!empty($a_host'host')) { $host = $a_host'host'; $ssl = (isset($a_host'scheme') && in_array($a_host'scheme', array('ssl','imaps','tls'))) ? $a_host'scheme' : null; if (!empty($a_host'port')) {
View file
kolab-syncroton-2.3.23.tar.gz/lib/kolab_sync_backend.php -> kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_backend.php
Changed
@@ -176,7 +176,7 @@ } // Activesync folder identifier (serverId) - $folder_type = $typedata$folder ?: 'mail'; + $folder_type = ($typedata$folder ?? null) ?: 'mail'; $folder_id = self::folder_id($folder, $folder_type); $folders_list$folder_id = $this->folder_data($folder, $folder_type); @@ -417,10 +417,7 @@ public function device_get($id) { $devices_list = $this->devices_list(); - - $result = $devices_list$id; - - return $result; + return $devices_list$id ?? null; } /** @@ -670,7 +667,7 @@ continue; } - $type = $foldertypes$folder ?: 'mail'; + $type = ($foldertypes$folder ?? null) ?: 'mail'; if ($type == 'mail' && isset($special_folders$folder)) { $type = $special_folders$folder; }
View file
kolab-syncroton-2.3.23.tar.gz/lib/kolab_sync_backend_common.php -> kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_backend_common.php
Changed
@@ -151,6 +151,10 @@ $result = $this->db->query('DELETE FROM `' . $this->table_name .'` WHERE `id` = ?', array($id)); + if ($this->db->is_error($result)) { + throw new Exception('Failed to delete instance of ' . $this->interface_name); + } + return (bool) $this->db->affected_rows($result); } @@ -175,8 +179,11 @@ $set = $this->db->quote_identifier($key) . ' = ?'; } - $this->db->query('UPDATE `' . $this->table_name . '` SET ' . implode(', ', $set) + $result = $this->db->query('UPDATE `' . $this->table_name . '` SET ' . implode(', ', $set) . ' WHERE `id` = ' . $this->db->quote($object->id), array_values($data)); + if ($this->db->is_error($result)) { + throw new Exception('Failed to update instance of ' . $this->interface_name); + } return $object; }
View file
kolab-syncroton-2.3.23.tar.gz/lib/kolab_sync_backend_state.php -> kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_backend_state.php
Changed
@@ -180,21 +180,27 @@ $where'folder_id' = $this->db->quote_identifier('folder_id') . ' = ' . $this->db->quote($folder_id); $where'is_deleted' = $this->db->quote_identifier('is_deleted') . ' = 1'; - // found more recent synckey => the last sync response got not received by the client + // found more recent synckey => the last sync response was not received by the client if ($next > $sync_key) { - $where'synckey' = $this->db->quote_identifier('creation_synckey') . ' = ' . $this->db->quote($state->counter); - // undelete entries marked as deleted in syncroton_content table - $this->db->query("UPDATE `syncroton_content` SET `is_deleted` = 0 WHERE " . implode(' AND ', $where)); - - // remove entries added during latest sync in syncroton_content table - unset($where'is_deleted'); - $where'synckey' = $this->db->quote_identifier('creation_synckey') . ' > ' . $this->db->quote($state->counter); - - $this->db->query("DELETE FROM `syncroton_content` WHERE " . implode(' AND ', $where)); + // We store the clientIdMap with the "next" sync state, so we need to copy it back. + $state->clientIdMap = $states$next->clientIdMap; } else { // finaly delete all entries marked for removal in syncroton_content table - $this->db->query("DELETE FROM `syncroton_content` WHERE " . implode(' AND ', $where)); + $retryCounter = 0; + while(True) { + $result = $this->db->query("DELETE FROM `syncroton_content` WHERE " . implode(' AND ', $where)); + if ($this->db->is_error($result)) { + $retryCounter++; + if ($retryCounter > 5) { + throw new Exception('Failed to delete entries in sync_key check'); + } + } else { + break; + } + //Give the other transactions some time before we try again + sleep(1); + } } // remove all other synckeys @@ -204,4 +210,18 @@ return $state; } + + public function haveNext($deviceid, $folderid, $sync_key) + { + $device_id = $deviceid instanceof Syncroton_Model_IDevice ? $deviceid->id : $deviceid; + $folder_id = $folderid instanceof Syncroton_Model_IFolder ? $folderid->id : $folderid; + + $where'device_id' = $this->db->quote_identifier('device_id') . ' = ' . $this->db->quote($device_id); + $where'type' = $this->db->quote_identifier('type') . ' = ' . $this->db->quote($folder_id); + $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)); + return $this->db->num_rows($select) > 0; + } + }
View file
kolab-syncroton-2.3.23.tar.gz/lib/kolab_sync_data.php -> kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_data.php
Changed
@@ -1011,7 +1011,7 @@ } // convert categories into tags, save them after creating an object - if (isset($this->tag_categories) && $this->tag_categories) { + if (!empty($data'categories') && isset($this->tag_categories) && $this->tag_categories) { $tags = $data'categories'; unset($data'categories'); } @@ -1462,16 +1462,17 @@ * @param int $type Result data type (to which the body will be converted, if specified). * One or array of Syncroton_Model_EmailBody constants. * - * @return string Body value + * @return string|null Body value */ protected function getBody($body, $type = null) { + $data = null; if ($body && $body->data) { $data = $body->data; } if (!$data || empty($type)) { - return; + return null; } $type = (array) $type; @@ -1813,17 +1814,20 @@ // handle exceptions from recurrence if (!empty($data->exceptions)) { foreach ($data->exceptions as $exception) { + $date = clone $exception->exceptionStartTime; + if ($timezone) { + $date->setTimezone($timezone); + } + if ($exception->deleted) { - $date = clone $exception->exceptionStartTime; - if ($timezone) { - $date->setTimezone($timezone); - } $date->setTime(0, 0, 0); $rrule'EXDATE' = $date; } else { $ex = $this->toKolab($exception, $folderid, null, $timezone); + $ex'recurrence_date' = $date; + if ($data->allDayEvent) { $ex'allday' = 1; }
View file
kolab-syncroton-2.3.23.tar.gz/lib/kolab_sync_data_calendar.php -> kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_data_calendar.php
Changed
@@ -236,17 +236,15 @@ break; case 'sensitivity': - if (empty($value)) { - continue; + if (!empty($value)) { + $value = intval($this->sensitivityMap$value); } - $value = intval($this->sensitivityMap$value); break; case 'free_busy': - if (empty($value)) { - continue; + if (!empty($value)) { + $value = $this->busyStatusMap$value; } - $value = $this->busyStatusMap$value; break; case 'description': @@ -495,7 +493,8 @@ else if (isset($data->attendees)) { $statusMap = array_flip($this->attendeeStatusMap); foreach ($data->attendees as $attendee) { - if ($attendee->email && $attendee->email == $organizer_email) { + if (!empty($organizer_email) && $attendee->email && !strcasecmp($attendee->email, $organizer_email)) { + // skip the organizer continue; } @@ -540,22 +539,23 @@ } } - // Make sure the event has the organizer set - if (!$organizer_email && ($identity = kolab_sync::get_instance()->user->get_identity())) { - $attendees = array( - 'role' => 'ORGANIZER', - 'name' => $identity'name', - 'email' => $identity'email', - ); + if (!$is_exception) { + // Make sure the event has the organizer set + if (!$organizer_email && ($identity = kolab_sync::get_instance()->user->get_identity())) { + $attendees = array( + 'role' => 'ORGANIZER', + 'name' => $identity'name', + 'email' => $identity'email', + ); + } + + // recurrence (and exceptions) + $event'recurrence' = $this->recurrence_to_kolab($data, $folderid, $timezone); } $event'attendees' = $attendees; $event'categories' = $categories; - - // recurrence (and exceptions) - if (!$is_exception) { - $event'recurrence' = $this->recurrence_to_kolab($data, $folderid, $timezone); - } + $event'exceptions' = isset($event'recurrence''EXCEPTIONS') ? $event'recurrence''EXCEPTIONS' : array(); // Bump SEQUENCE number on update (Outlook only). // It's been confirmed that any change of the event that has attendees specified @@ -807,14 +807,13 @@ */ protected function update_attendee_status(&$event, $status) { - $organizer = null; - $emails = $this->user_emails(); + $emails = $this->user_emails(); foreach ((array) $event'attendees' as $i => $attendee) { - if ($attendee'role' == 'ORGANIZER') { - $organizer = $attendee; - } - else if ($attendee'email' && in_array_nocase($attendee'email', $emails)) { + if (!empty($attendee'email') + && (empty($attendee'role') || $attendee'role' != 'ORGANIZER') + && in_array_nocase($attendee'email', $emails) + ) { $event'attendees'$i'status' = $status; $event'attendees'$i'rsvp' = false; $event_attendee = $attendee; @@ -822,8 +821,14 @@ } if (!$event_attendee) { - $this->logger->warn('MeetingResponse on an event where the user is not an attendee. UID: ' . $event'uid'); - throw new Syncroton_Exception_Status_MeetingResponse(Syncroton_Exception_Status_MeetingResponse::MEETING_ERROR); + // Add the user to the attendees list + $event'attendees' = array( + 'role' => 'OPT-PARTICIPANT', + 'name' => '', + 'email' => $emails0, + 'status' => $status, + 'rsvp' => false, + ); } }
View file
kolab-syncroton-2.3.23.tar.gz/lib/kolab_sync_data_email.php -> kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_data_email.php
Changed
@@ -283,6 +283,7 @@ // In Sync examples there's one in which bodyPreferences is not defined // in such case Truncated=1 and there's no body sent to the client // only it's estimated size + $isTruncated = 0; if (empty($prefs)) { $messageBody = ''; $real_length = $headers->size;
View file
kolab-syncroton-2.3.23.tar.gz/lib/kolab_sync_data_tasks.php -> kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_data_tasks.php
Changed
@@ -140,7 +140,9 @@ break; case 'sensitivity': - $value = intval($this->sensitivityMap$value); + if (!empty($value)) { + $value = intval($this->sensitivityMap$value); + } break; case 'priority': @@ -156,7 +158,9 @@ } // convert kolab tags into categories - $result'categories' = $this->getKolabTags($task'uid', $result'categories'); + if (!empty($result'categories')) { + $result'categories' = $this->getKolabTags($task'uid', $result'categories'); + } // Recurrence $this->recurrence_from_kolab($collection, $task, $result, 'Task'); @@ -222,7 +226,7 @@ case 'sensitivity': $map = array_flip($this->sensitivityMap); - $value = $map$value; + $value = $map$value ?? 'none' ?? self::SENSITIVITY_NORMAL; break; case 'description': @@ -245,9 +249,13 @@ $task'status' = 'COMPLETED'; $task'complete' = 100; } - else if (isset($data->complete) && ($task'status' == 'COMPLETED' || $task'complete' == 100)) { - $task'status' = ''; - $task'complete' = 0; + else if (isset($data->complete)) { + if ((!empty($task'status') && $task'status' == 'COMPLETED') + || (!empty($task'complete') && $task'complete' == 100) + ) { + $task'status' = ''; + $task'complete' = 0; + } } // recurrence
View file
kolab-syncroton-2.4.0.tar.gz/tests/wbxml.php
Added
@@ -0,0 +1,888 @@ +<?php + +class message extends PHPUnit\Framework\TestCase +{ + //function testDecode() + //{ + // //TODO input some wbxml document + // // + // $dom = new DOMDocument(); + // $dom->loadXML($lastSyncCollection'lastXML'); + // // + // try { + // $decoder = new Syncroton_Wbxml_Decoder($dom); + // $requestBody = $decoder->decode(); + // if ($this->_logger instanceof Zend_Log) { + // $requestBody->formatOutput = true; + // $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " xml request:\n" . $requestBody->saveXML()); + // } + // } catch(Syncroton_Wbxml_Exception_UnexpectedEndOfFile $e) { + // $requestBody = NULL; + // } + // //TODO validate output + //} + + + + public function testEncode() + { + $outputStream = fopen("php://temp", 'r+'); + + $encoder = new Syncroton_Wbxml_Encoder($outputStream, 'UTF-8', 3); + + $xml = <<<EOF + <?xml version="1.0" encoding="utf-8"?> + <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> + <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks"> + <Collections> + <Collection> + <SyncKey>2</SyncKey> + <CollectionId>tasksId</CollectionId> + <Commands> + <Add> + <ClientId>clientId2</ClientId> + <ApplicationData> + <Subject xmlns="uri:Tasks">task2</Subject> + <Complete xmlns="uri:Tasks">0</Complete> + <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate> + <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate> + </ApplicationData> + </Add> + <Add> + <ClientId>clientId3</ClientId> + <ApplicationData> + <Subject xmlns="uri:Tasks">task3</Subject> + <Complete xmlns="uri:Tasks">0</Complete> + <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate> + <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate> + </ApplicationData> + </Add> + </Commands> + </Collection> + </Collections> + <WindowSize>16</WindowSize> + </Sync> + EOF; + + + $dom = new DOMDocument(); + $dom->loadXML($xml); + + $encoder->encode($dom); + + rewind($outputStream); + $output = stream_get_contents($outputStream); + // print("----"); + // print(var_export($output, true)); + // print("----"); + $this->assertEquals( + base64_decode('AwFqAEVcT0sDMgABUgN0YXNrc0lkAAFWR0wDY2xpZW50SWQyAAFdAAlgA3Rhc2syAAFKAzAAAUwDMjAyMC0xMS0wNFQwMDowMDowMC4wMDBaAAFNAzIwMjAtMTEtMDNUMjM6MDA6MDAuMDAwWgABAQEAAEdMA2NsaWVudElkMwABXQAJYAN0YXNrMwABSgMwAAFMAzIwMjAtMTEtMDRUMDA6MDA6MDAuMDAwWgABTQMyMDIwLTExLTAzVDIzOjAwOjAwLjAwMFoAAQEBAQEBAABVAzE2AAEB'), + $output + ); + } + + public function testEncodeFolderSync() + { + $outputStream = fopen("php://temp", 'r+'); + + $encoder = new Syncroton_Wbxml_Encoder($outputStream, 'UTF-8', 3); + + $xml = <<<EOF + <?xml version="1.0" encoding="utf-8"?> + <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> + <FolderSync xmlns="uri:FolderHierarchy" xmlns:Syncroton="uri:Syncroton" xmlns:Internal="uri:Internal"> + <Status>1</Status> + <SyncKey>1</SyncKey> + <Changes> + <Count>18</Count> + <Add> + <ServerId>2685b302b79f58d2753199545e3cb8be</ServerId> + <ParentId>0</ParentId> + <DisplayName>Test2</DisplayName> + <Type>13</Type> + </Add> + <Add> + <ServerId>9770b083c68e8584f396d15a116d6608</ServerId> + <ParentId>0</ParentId> + <DisplayName>DavidCalendar</DisplayName> + <Type>13</Type> + </Add> + <Add> + <ServerId>0f66388806743c514b8063bf0dc87486</ServerId> + <ParentId>0</ParentId> + <DisplayName>SergeyCalendar</DisplayName> + <Type>13</Type> + </Add> + <Add> + <ServerId>cca1b81c734abbcd669bea90d23e08ae</ServerId> + <ParentId>0</ParentId> + <DisplayName>Calendar</DisplayName> + <Type>8</Type> + </Add> + <Add> + <ServerId>ab1ddb4ef8e8f8fcc2c9f5a7f9062452</ServerId> + <ParentId>0</ParentId> + <DisplayName>PubCal</DisplayName> + <Type>13</Type> + </Add> + <Add> + <ServerId>d98bd8721371544ed095841ead941893</ServerId> + <ParentId>0</ParentId> + <DisplayName>(david) Test2</DisplayName> + <Type>13</Type> + </Add> + <Add> + <ServerId>9e7b9656ef61d4af2fb2fdcabe600079</ServerId> + <ParentId>0</ParentId> + <DisplayName>(david) DavidCalendar</DisplayName> + <Type>13</Type> + </Add> + <Add> + <ServerId>384cf2d877c39a622fdc2a16898052e2</ServerId> + <ParentId>0</ParentId> + <DisplayName>(david) Calendar</DisplayName> + <Type>13</Type> + </Add> + <Add> + <ServerId>Contacts::Syncroton</ServerId> + <ParentId>0</ParentId> + <DisplayName>Contacts</DisplayName> + <Type>9</Type> + </Add> + <Add> + <ServerId>1bb8c55fe84d52c6968db2571f7dc124</ServerId> + <ParentId>0</ParentId> + <DisplayName>Archive</DisplayName> + <Type>12</Type> + </Add> + <Add> + <ServerId>b51abe73e9e98fe200a4afe409050502</ServerId> + <ParentId>38b950ebd62cd9a66929c89615d0fc04</ParentId> + <DisplayName>Spam</DisplayName> + <Type>12</Type> + </Add> + <Add> + <ServerId>cf529c792fc87d1f207435b3921bb02e</ServerId> + <ParentId>0</ParentId> + <DisplayName>Sent</DisplayName> + <Type>5</Type> + </Add> + <Add> + <ServerId>715ed9ea29b8a5377a69c1f758037c65</ServerId> + <ParentId>0</ParentId> + <DisplayName>Spam</DisplayName> + <Type>12</Type> + </Add> + <Add> + <ServerId>db0d959a3aeb21757f8849a830947a7a</ServerId> + <ParentId>0</ParentId> + <DisplayName>Trash</DisplayName> + <Type>4</Type> + </Add> + <Add> + <ServerId>5ac9ec2e1a9d99e2e10cabe4abf26729</ServerId> + <ParentId>0</ParentId> + <DisplayName>Drafts</DisplayName> + <Type>3</Type> + </Add> + <Add> + <ServerId>38b950ebd62cd9a66929c89615d0fc04</ServerId> + <ParentId>0</ParentId> + <DisplayName>INBOX</DisplayName> + <Type>2</Type> + </Add> + <Add> + <ServerId>fc56f4c7ffe0aefa622db9f8d9186c4a</ServerId> + <ParentId>0</ParentId> + <DisplayName>Notes</DisplayName> + <Type>10</Type> + </Add>
View file
kolab-syncroton.dsc
Changed
@@ -2,7 +2,7 @@ Source: kolab-syncroton Binary: kolab-syncroton Architecture: all -Version: 2.3.23-1~kolab1 +Version: 2.4.0-1~kolab1 Maintainer: Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> Uploaders: Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> Homepage: http://www.kolab.org/ @@ -12,5 +12,5 @@ Package-List: kolab-syncroton deb utils extra Files: - 00000000000000000000000000000000 0 kolab-syncroton-2.3.23.tar.gz + 00000000000000000000000000000000 0 kolab-syncroton-2.4.0.tar.gz 00000000000000000000000000000000 0 debian.tar.gz
View file
plesk.kolab_syncroton.inc.php
Changed
@@ -118,8 +118,6 @@ $config'activesync_multifolder_blacklist_note' = null; $config'activesync_multifolder_blacklist_task' = null; -$config'activesync_protected_folders' = array('windowsoutlook' => array('INBOX', 'Sent', 'Trash')); - // Enables adding sender name in the From: header of send email // when a device uses email address only (e.g. iOS devices) $config'activesync_fix_from' = true;
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
.