This request is superseded by
request 3329
(Show diff)
Overview
Request 3328 (superseded)
New release 2.4.2.35
- Created by mollekopf 6 months ago
- In state superseded
- Supersedes 3327
- Superseded by 3329
-
Open review for
Admin
-
Open review for
vanmeeuwen
-
Open review for
mollekopf
-
Open review for
kolab-developers
kolab-syncroton.spec
Changed
x
1
2
%global upstream_version 2.4.2
3
4
Name: kolab-syncroton
5
-Version: 2.4.2.39
6
+Version: 2.4.2.34
7
Release: 1%{?dist}
8
Summary: ActiveSync for Kolab Groupware
9
10
11
12
13
14
-%if 0%{?plesk} > 0 && 0%{?rhel} <= 8
15
-for version in 8.2 8.1 8.0 7.4; do
16
- php="/opt/plesk/php/$version/bin/php"
17
+%if 0%{?plesk} > 0 && 0%{?rhel} == 7
18
+php="/opt/plesk/php/7.4/bin/php"
19
%else
20
-for version in 1; do
21
- php="/usr/bin/php"
22
+php="/usr/bin/php"
23
%endif
24
25
- if -f "$php" ; then
26
- ${php} /usr/share/roundcubemail/bin/updatedb.sh \
27
- --dir /usr/share/doc/kolab-syncroton/SQL/ \
28
- --package syncroton \
29
- >/dev/null 2>&1 || :
30
- break
31
- fi
32
-done
33
+${php} /usr/share/roundcubemail/bin/updatedb.sh \
34
+ --dir /usr/share/doc/kolab-syncroton/SQL/ \
35
+ --package syncroton \
36
+ >/dev/null 2>&1 || :
37
38
exit 0
39
40
debian.changelog
Changed
7
1
2
-kolab-syncroton (2.4.2.39-0~kolab1) unstable; urgency=low
3
+kolab-syncroton (2.4.2.34-0~kolab1) unstable; urgency=low
4
5
* Release version 2.4.2
6
7
kolab-syncroton-2.4.2.tar.gz/bin/analyzelogs.php
Changed
8
1
2
#!/usr/bin/env php
3
<?php
4
-
5
/*
6
+--------------------------------------------------------------------------+
7
| Kolab Sync (ActiveSync for Kolab) |
8
kolab-syncroton-2.4.2.tar.gz/bin/delete-device.php
Changed
8
1
2
#!/usr/bin/env php
3
<?php
4
-
5
/*
6
+--------------------------------------------------------------------------+
7
| Kolab Sync (ActiveSync for Kolab) |
8
kolab-syncroton-2.4.2.tar.gz/bin/inspect.php
Changed
52
1
2
#!/usr/bin/env php
3
<?php
4
-
5
/*
6
+--------------------------------------------------------------------------+
7
| Kolab Sync (ActiveSync for Kolab) |
8
9
$device_id = $data"id";
10
11
$result$device_id'deviceid' = $deviceid;
12
- $result$device_id'device_id' = $device_id;
13
$result$device_id'devicetype' = $data"devicetype";
14
15
$select = $db->limitquery(
16
17
}
18
19
$result$device_id'folders'$folder'id''name' = $folder'displayname';
20
- $result$device_id'folders'$folder'id''folderid' = $folder'folderid';
21
$result$device_id'folders'$folder'id''class' = $folder'class';
22
$result$device_id'folders'$folder'id''lastfiltertype' = $folder'lastfiltertype' ?? null;
23
24
25
if (!$value) {
26
return "No filter";
27
}
28
- switch ($value) {
29
+ switch($value) {
30
case 0: return "No filter";
31
case 1: return "1 day";
32
case 2: return "3 days";
33
34
}
35
36
println("");
37
-foreach ($result as $deviceId => $values) {
38
- $device_id = $values'deviceid';
39
- println("Device: $device_id ($deviceId)");
40
+foreach ($result as $deviceId => $values) {
41
+ println("Device: $deviceId");
42
println(" Last folder sync: " . $values'FolderSync''lastsync');
43
println(" Folder sync count: " . $values'FolderSync''counter');
44
println(" Folders:");
45
foreach ($values'folders' ?? as $folderId => $folder) {
46
- $folder_id = $folder'folderid';
47
- println(" " . $folder'name' . " $folder_id ($folderId)");
48
+ println(" " . $folder'name' . " ($folderId)");
49
$messageCount = $folder'contentCount';
50
$totalCount = $folder'imapMessagecount' ?? "unknown";
51
$modseq = $folder'modseq' ?? "none";
52
kolab-syncroton-2.4.2.tar.gz/bin/resync.php
Changed
29
1
2
#!/usr/bin/php
3
<?php
4
-
5
/*
6
+--------------------------------------------------------------------------+
7
| Kolab Sync (ActiveSync for Kolab) |
8
9
// TODO: Support not only top-level folders
10
11
$select = $db->query(
12
- "SELECT syncroton_folder.id, `displayname`, `folderid`, `deviceid` FROM `syncroton_folder`"
13
- . " JOIN `syncroton_device` ON syncroton_device.id = syncroton_folder.device_id"
14
+ "SELECT `id`, `displayname`, `folderid` FROM `syncroton_folder`"
15
. " WHERE `device_id` IN (" . $db->array2list($devices) . ")"
16
. " AND `parentid` = '0' AND `displayname` = " . $db->quote($opts'folder')
17
);
18
19
while ($record = $db->fetch_assoc($select)) {
20
if (!empty($opts'dry-run')) {
21
- print("DRY-RUN {$record'displayname'} {$record'deviceid'} ({$record'id'}:{$record'folderid'})\n");
22
+ print("DRY-RUN {$record'displayname'} ({$record'id'}:{$record'folderid'})\n");
23
} else {
24
$db->query("UPDATE `syncroton_folder` SET `resync` = 1 WHERE id = ?", $record'id');
25
- print("{$record'displayname'} {$record'deviceid'} ({$record'id'}:{$record'folderid'})\n");
26
+ print("{$record'displayname'} ({$record'id'}:{$record'folderid'})\n");
27
}
28
}
29
kolab-syncroton-2.4.2.tar.gz/docs/SQL/mysql.initial.sql
Changed
9
1
2
`creation_synckey` int(11) NOT NULL DEFAULT '0',
3
`lastfiltertype` int(11) DEFAULT NULL,
4
`supportedfields` longblob DEFAULT NULL,
5
- `resync` tinyint(1) DEFAULT NULL,
6
PRIMARY KEY (`id`),
7
UNIQUE KEY `device_id--class--folderid` (`device_id`(40),`class`(40),`folderid`(40)),
8
KEY `folderstates::device_id--devices::id` (`device_id`),
9
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/ABackend.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/Content.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/Device.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/Folder.php
Changed
28
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
* (non-PHPdoc)
9
* @see Syncroton_Backend_IFolder::getFolderState()
10
*/
11
- public function getFolderState($deviceId, $class, $syncKey)
12
+ public function getFolderState($deviceId, $class)
13
{
14
$deviceId = $deviceId instanceof Syncroton_Model_IDevice ? $deviceId->id : $deviceId;
15
16
17
$this->_db->delete($this->_tablePrefix . $this->_tableName, $where);
18
}
19
20
- public function exists($deviceid, $folderid)
21
- {
22
- return false; // not implemented
23
- }
24
-
25
/**
26
* (non-PHPdoc)
27
* @see Syncroton_Backend_IFolder::hasHierarchyChanges()
28
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/IBackend.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/IContent.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/IDevice.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/IFolder.php
Changed
22
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
* @return bool True if folders hierarchy changed, False otherwise
9
*/
10
public function hasHierarchyChanges($device);
11
-
12
- /**
13
- * Check if the folder already exists
14
- *
15
- * @param Syncroton_Model_Device|string $deviceid Device object or identifier
16
- * @param string $folderid Folder identifier
17
- *
18
- * @return bool true if it exists
19
- */
20
- public function exists($deviceid, $folderid);
21
}
22
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/ISyncState.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/Policy.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Backend/SyncState.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/AutoDiscover.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/FolderCreate.php
Changed
16
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
return;
9
}
10
11
- switch ($folder->type) {
12
+ switch($folder->type) {
13
case Syncroton_Command_FolderSync::FOLDERTYPE_CALENDAR_USER_CREATED:
14
$folder->class = Syncroton_Data_Factory::CLASS_CALENDAR;
15
break;
16
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/FolderDelete.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/FolderSync.php
Changed
134
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
protected $_syncKey;
9
10
/**
11
- * @var bool
12
- */
13
- protected $_syncKeyReused = false;
14
-
15
- /**
16
* Parse FolderSync request
17
*/
18
public function handle()
19
20
$this->_syncStateBackend->resetState($this->_device, 'FolderSync');
21
22
return;
23
- } else {
24
- // The synckey that is sent to us should already be existing, because we create it at the end,
25
- // however, the next one shouldn't
26
- if ($this->_syncStateBackend->haveNext($this->_device, 'FolderSync', $syncKey)) {
27
- $this->_syncKeyReused = true;
28
- if ($this->_logger instanceof Zend_Log) {
29
- $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " already known synckey $syncKey provided");
30
- }
31
- }
32
}
33
+
34
if (!($this->_syncState = $this->_syncStateBackend->validate($this->_device, 'FolderSync', $syncKey)) instanceof Syncroton_Model_SyncState) {
35
if ($this->_logger instanceof Zend_Log) {
36
- $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " invalid synckey $syncKey provided, invalidating sync state");
37
+ $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " invalidating sync state");
38
}
39
$this->_syncStateBackend->resetState($this->_device, 'FolderSync');
40
}
41
42
$updates = ;
43
$deletes = ;
44
45
- foreach ($this->_classes as $class) {
46
+ foreach($this->_classes as $class) {
47
try {
48
$dataController = Syncroton_Data_Factory::factory($class, $this->_device, $this->_syncTimeStamp);
49
} catch (Exception $e) {
50
51
// but because the folder is still existing and subscribed on the backend it should
52
// "immediately" be added again (and re-synced).
53
$forceDeleteIds = array_keys(array_filter($clientFolders, function ($f) { return !empty($f->resync); }));
54
- if (!empty($forceDeleteIds)) {
55
- if ($this->_logger instanceof Zend_Log) {
56
- $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " forcing resync of: " . var_export($forceDeleteIds, true));
57
- }
58
- }
59
$serverFoldersIds = array_diff($serverFoldersIds, $forceDeleteIds);
60
61
// calculate deleted entries
62
63
64
$folderSync->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Status', self::STATUS_SUCCESS));
65
66
- $newSyncKey = $this->_syncState->counter;
67
$count = count($adds) + count($updates) + count($deletes);
68
- if ($count > 0) {
69
- $newSyncKey++;
70
+ if($count > 0) {
71
+ $this->_syncState->counter++;
72
+ $this->_syncState->lastsync = $this->_syncTimeStamp;
73
}
74
75
// create xml output
76
- $folderSync->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'SyncKey', $newSyncKey));
77
+ $folderSync->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'SyncKey', $this->_syncState->counter));
78
79
$changes = $folderSync->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Changes'));
80
$changes->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Count', $count));
81
82
- foreach ($adds as $folder) {
83
+ foreach($adds as $folder) {
84
$add = $changes->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Add'));
85
86
$folder->appendXML($add, $this->_device);
87
88
- if (!$this->_syncKeyReused && empty($folder->id)) {
89
- // The folder could exist in the backend if we e.g. delete the same name and then recreate,
90
- // or disable/reenable for syncing.
91
- if (!$this->_folderBackend->exists($this->_device->id, $folder->serverId)) {
92
+ // store folder in backend
93
+ if (empty($folder->id)) {
94
+ try {
95
$this->_folderBackend->create($folder);
96
+ } catch(Exception $zdse) {
97
+ //This can happen if we rerun a previous sync-key
98
+ $this->_folderBackend->update($folder);
99
}
100
}
101
}
102
103
- foreach ($updates as $folder) {
104
+ foreach($updates as $folder) {
105
$update = $changes->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Update'));
106
107
$folder->appendXML($update, $this->_device);
108
+
109
$this->_folderBackend->update($folder);
110
}
111
112
- foreach ($deletes as $folder) {
113
+ foreach($deletes as $folder) {
114
$delete = $changes->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'Delete'));
115
$delete->appendChild($this->_outputDom->createElementNS('uri:FolderHierarchy', 'ServerId', $folder->serverId));
116
117
$this->_folderBackend->delete($folder);
118
}
119
120
- if ($this->_syncState->counter != $newSyncKey) {
121
- $this->_syncState->counter = $newSyncKey;
122
- $this->_syncState->lastsync = $this->_syncTimeStamp;
123
- // Keep previous sync states in case a sync key is re-sent.
124
- // We always insert because deleteOtherStates is executed from _syncStateBackend->validate,
125
- // which means we remove and re-insert the latest state on key resend.
126
- $this->_syncStateBackend->create($this->_syncState, true); // @phpstan-ignore-line
127
+ // Only create this syncstate if it isn't already existing (which happens if we a sync key is re-sent)
128
+ if (!$this->_syncStateBackend->haveNext($this->_device, 'FolderSync', $this->_syncState->counter - 1)) {
129
+ // Keep previous sync states in case a sync key is re-sent
130
+ $this->_syncStateBackend->create($this->_syncState, true);
131
}
132
133
return $this->_outputDom;
134
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/FolderUpdate.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/GetAttachment.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/GetItemEstimate.php
Changed
34
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
$collectionData'folder' = $this->_folderBackend->getFolder($this->_device, $collectionData'collectionId');
9
$collectionData'folder'->lastfiltertype = $collectionData'filterType';
10
11
- if ($collectionData'syncKey' === 0) {
12
+ if($collectionData'syncKey' === 0) {
13
$collectionData'syncState' = new Syncroton_Model_SyncState(
14
'device_id' => $this->_device,
15
'counter' => 0,
16
17
{
18
$itemEstimate = $this->_outputDom->documentElement;
19
20
- foreach ($this->_collections as $collectionData) {
21
+ foreach($this->_collections as $collectionData) {
22
$response = $itemEstimate->appendChild($this->_outputDom->createElementNS('uri:ItemEstimate', 'Response'));
23
24
// invalid collectionid provided
25
26
$response->appendChild($this->_outputDom->createElementNS('uri:ItemEstimate', 'Status', self::STATUS_SUCCESS));
27
$collection = $response->appendChild($this->_outputDom->createElementNS('uri:ItemEstimate', 'Collection'));
28
$collection->appendChild($this->_outputDom->createElementNS('uri:ItemEstimate', 'CollectionId', $collectionData'collectionId'));
29
- if ($collectionData'syncState'->counter === 0) {
30
+ if($collectionData'syncState'->counter === 0) {
31
// this is the first sync. in most cases there are data on the server.
32
$count = count($dataController->getServerEntries($collectionData'collectionId', $collectionData'filterType'));
33
} else {
34
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/ICommand.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/ItemOperations.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/MeetingResponse.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Options.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Ping.php
Changed
51
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
$xml = simplexml_import_dom($this->_requestBody);
9
$xml->registerXPathNamespace('Ping', 'Ping');
10
11
- if (isset($xml->HeartbeatInterval)) {
12
+ if(isset($xml->HeartbeatInterval)) {
13
$this->_device->pinglifetime = (int)$xml->HeartbeatInterval;
14
}
15
16
17
$folders = ;
18
foreach ($xml->Folders->Folder as $folderXml) {
19
try {
20
- if (empty((string)$folderXml->Id)) {
21
- // Ignore empty folder ids
22
- continue;
23
- }
24
// does the folder exist?
25
$folder = $this->_folderBackend->getFolder($this->_device, (string)$folderXml->Id);
26
27
28
$now = new DateTime('now', new DateTimeZone('UTC'));
29
30
foreach ($folders as $folderId) {
31
- if (empty($folderId)) {
32
- // Ignore empty folder ids
33
- continue;
34
- }
35
try {
36
/** @var Syncroton_Model_Folder $folder */
37
$folder = $this->_folderBackend->get($folderId);
38
39
40
$ping = $this->_outputDom->documentElement;
41
$ping->appendChild($this->_outputDom->createElementNS('uri:Ping', 'Status', $status));
42
- if ($status === self::STATUS_CHANGES_FOUND) {
43
+ if($status === self::STATUS_CHANGES_FOUND) {
44
$folders = $ping->appendChild($this->_outputDom->createElementNS('uri:Ping', 'Folders'));
45
46
- foreach ($this->_foldersWithChanges as $changedFolder) {
47
+ foreach($this->_foldersWithChanges as $changedFolder) {
48
$folder = $folders->appendChild($this->_outputDom->createElementNS('uri:Ping', 'Folder', $changedFolder->serverId));
49
if ($this->_logger instanceof Zend_Log) {
50
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " DeviceId: " . $this->_device->deviceid . " changes in folder: " . $changedFolder->serverId);
51
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Provision.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Search.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/SendMail.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Settings.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/SmartForward.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/SmartReply.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Sync.php
Changed
244
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
}
9
10
// initial synckey
11
- if ($collectionData->syncKey === 0) {
12
+ if($collectionData->syncKey === 0) {
13
if ($this->_logger instanceof Zend_Log) {
14
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " initial client synckey 0 provided");
15
}
16
17
}
18
}
19
// check for invalid synckey
20
- if (($collectionData->syncState = $this->_syncStateBackend->validate($this->_device, $collectionData->folder, $collectionData->syncKey)) === false) {
21
+ if(($collectionData->syncState = $this->_syncStateBackend->validate($this->_device, $collectionData->folder, $collectionData->syncKey)) === false) {
22
if ($this->_logger instanceof Zend_Log) {
23
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " invalid synckey {$collectionData->syncKey} provided");
24
}
25
26
27
$dataController = Syncroton_Data_Factory::factory($collectionData->folder->class, $this->_device, $this->_syncTimeStamp);
28
29
- switch ($collectionData->folder->class) {
30
+ switch($collectionData->folder->class) {
31
case Syncroton_Data_Factory::CLASS_CALENDAR:
32
$dataClass = 'Syncroton_Model_Event';
33
break;
34
35
;
36
37
// handle incoming data
38
- if ($collectionData->hasClientAdds()) {
39
+ if($collectionData->hasClientAdds()) {
40
$adds = $collectionData->getClientAdds();
41
42
if ($this->_logger instanceof Zend_Log) {
43
44
}
45
46
// handle changes, but only if not first sync
47
- if (!$syncKeyReused && $collectionData->syncKey > 1 && $collectionData->hasClientChanges()) {
48
+ if(!$syncKeyReused && $collectionData->syncKey > 1 && $collectionData->hasClientChanges()) {
49
$changes = $collectionData->getClientChanges();
50
51
if ($this->_logger instanceof Zend_Log) {
52
53
}
54
55
// handle deletes, but only if not first sync
56
- if (!$syncKeyReused && $collectionData->hasClientDeletes()) {
57
+ if(!$syncKeyReused && $collectionData->hasClientDeletes()) {
58
$deletes = $collectionData->getClientDeletes();
59
if ($this->_logger instanceof Zend_Log) {
60
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " found " . count($deletes) . " entries to be deleted on server");
61
62
try {
63
$dataController->deleteEntry($collectionData->collectionId, $serverId, $collectionData);
64
65
- } catch (Syncroton_Exception_NotFound $e) {
66
+ } catch(Syncroton_Exception_NotFound $e) {
67
if ($this->_logger instanceof Zend_Log) {
68
$this->_logger->crit(__METHOD__ . '::' . __LINE__ . ' tried to delete entry ' . $serverId . ' but entry was not found');
69
}
70
71
}
72
73
// handle fetches, but only if not first sync
74
- if ($collectionData->syncKey > 1 && $collectionData->hasClientFetches()) {
75
+ if($collectionData->syncKey > 1 && $collectionData->hasClientFetches()) {
76
// the default value for GetChanges is 1. If the phone don't want the changes it must set GetChanges to 0
77
// some prevoius versions of iOS did not set GetChanges to 0 for fetches. Let's enforce getChanges to false here.
78
$collectionData->getChanges = false;
79
80
$serverModifications'added' = array_unique(array_merge($serverModifications'added', $serverDiff));
81
82
// @todo still needed?
83
- foreach ($serverModifications'added' as $id => $serverId) {
84
+ foreach($serverModifications'added' as $id => $serverId) {
85
// skip entries added by client during this sync session
86
- if (isset($clientModifications'added'$serverId) && !isset($clientModifications'forceAdd'$serverId)) {
87
+ if(isset($clientModifications'added'$serverId) && !isset($clientModifications'forceAdd'$serverId)) {
88
if ($this->_logger instanceof Zend_Log) {
89
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " skipped added entry: " . $serverId);
90
}
91
92
// entries changed since last sync
93
$serverModifications'changed' = array_merge($allChangedEntries, $clientModifications'forceChange');
94
95
- foreach ($serverModifications'changed' as $id => $serverId) {
96
+ foreach($serverModifications'changed' as $id => $serverId) {
97
// skip entry, if it got changed by client during current sync
98
- if (isset($clientModifications'changed'$serverId) && !isset($clientModifications'forceChange'$serverId)) {
99
+ if(isset($clientModifications'changed'$serverId) && !isset($clientModifications'forceChange'$serverId)) {
100
if ($this->_logger instanceof Zend_Log) {
101
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " skipped changed entry: " . $serverId);
102
}
103
104
105
$now = new DateTime('now', new DateTimeZone('UTC'));
106
107
- foreach ($this->_collections as $collectionData) {
108
+ foreach($this->_collections as $collectionData) {
109
// continue immediately if folder does not exist
110
if (! ($collectionData->folder instanceof Syncroton_Model_IFolder)) {
111
break 2;
112
113
$dataController = Syncroton_Data_Factory::factory($collectionData->folder->class, $this->_device, $this->_syncTimeStamp);
114
115
// countinue immediately if there are any changes available
116
- if ($dataController->hasChanges($this->_contentStateBackend, $collectionData->folder, $collectionData->syncState)) {
117
+ if($dataController->hasChanges($this->_contentStateBackend, $collectionData->folder, $collectionData->syncState)) {
118
break 2;
119
}
120
}
121
122
123
if ($collectionData->getChanges === true) {
124
// continue sync session?
125
- if (is_array($collectionData->syncState->pendingdata)) {
126
+ if(is_array($collectionData->syncState->pendingdata)) {
127
$serverModifications = $collectionData->syncState->pendingdata;
128
if ($this->_logger instanceof Zend_Log) {
129
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " restored from sync state.");
130
131
}
132
133
// send reponse for newly added entries
134
- if (!empty($clientModifications'added')) {
135
- foreach ($clientModifications'added' as $entryData) {
136
+ if(!empty($clientModifications'added')) {
137
+ foreach($clientModifications'added' as $entryData) {
138
$add = $responses->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Add'));
139
$add->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ClientId', $entryData'clientId'));
140
// we have no serverId if the add failed
141
- if (isset($entryData'serverId')) {
142
+ if(isset($entryData'serverId')) {
143
$add->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ServerId', $entryData'serverId'));
144
}
145
$add->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Status', $entryData'status'));
146
147
}
148
149
// send reponse for changed entries
150
- if (!empty($clientModifications'changed')) {
151
- foreach ($clientModifications'changed' as $serverId => $status) {
152
+ if(!empty($clientModifications'changed')) {
153
+ foreach($clientModifications'changed' as $serverId => $status) {
154
if ($status !== Syncroton_Command_Sync::STATUS_SUCCESS) {
155
$change = $responses->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Change'));
156
$change->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ServerId', $serverId));
157
158
}
159
160
// send response for to be fetched entries
161
- if (!empty($collectionData->toBeFetched)) {
162
+ if(!empty($collectionData->toBeFetched)) {
163
// unset all truncation settings as entries are not allowed to be truncated during fetch
164
$fetchCollectionData = clone $collectionData;
165
166
// unset truncationSize
167
if (isset($fetchCollectionData->options'bodyPreferences') && is_array($fetchCollectionData->options'bodyPreferences')) {
168
- foreach ($fetchCollectionData->options'bodyPreferences' as $key => $bodyPreference) {
169
+ foreach($fetchCollectionData->options'bodyPreferences' as $key => $bodyPreference) {
170
unset($fetchCollectionData->options'bodyPreferences'$key'truncationSize');
171
}
172
}
173
$fetchCollectionData->options'mimeTruncation' = Syncroton_Command_Sync::TRUNCATE_NOTHING;
174
175
- foreach ($collectionData->toBeFetched as $serverId) {
176
+ foreach($collectionData->toBeFetched as $serverId) {
177
$fetch = $responses->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Fetch'));
178
$fetch->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'ServerId', $serverId));
179
180
181
182
$commands = $this->_outputDom->createElementNS('uri:AirSync', 'Commands');
183
184
- foreach ($serverModifications'added' as $id => $serverId) {
185
- if ($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) {
186
+ foreach($serverModifications'added' as $id => $serverId) {
187
+ if($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) {
188
break;
189
}
190
191
192
/**
193
* process entries changed on server side
194
*/
195
- foreach ($serverModifications'changed' as $id => $serverId) {
196
- if ($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) {
197
+ foreach($serverModifications'changed' as $id => $serverId) {
198
+ if($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) {
199
break;
200
}
201
202
203
unset($serverModifications'changed'$id);
204
}
205
206
- foreach ($serverModifications'deleted' as $id => $serverId) {
207
- if ($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) {
208
+ foreach($serverModifications'deleted' as $id => $serverId) {
209
+ if($collectionChanges == $collectionData->windowSize || $totalChanges + $collectionChanges >= $this->_globalWindowSize) {
210
break;
211
}
212
213
214
if (!empty($clientModifications'added')) {
215
// Store a client id mapping in case we encounter a reused sync_key in a future request.
216
$newClientIdMap = ;
217
- foreach ($clientModifications'added' as $entryData) {
218
+ foreach($clientModifications'added' as $entryData) {
219
// No serverId if we failed to add
220
if ($entryData'status' == self::STATUS_SUCCESS) {
221
$newClientIdMap$entryData'clientId' = $entryData'serverId';
222
223
$this->_syncStateBackend->create($collectionData->syncState, true); // @phpstan-ignore-line
224
225
// store contentstates for new entries added to client
226
- foreach ($newContentStates as $state) {
227
+ foreach($newContentStates as $state) {
228
try {
229
//This can happen if we rerun a previous sync-key
230
$state = $this->_contentStateBackend->getContentState($state->device_id, $state->folder_id, $state->contentid);
231
$this->_contentStateBackend->update($state);
232
- } catch (Exception $zdse) {
233
+ } catch(Exception $zdse) {
234
$this->_contentStateBackend->create($state);
235
}
236
}
237
238
// remove contentstates for entries to be deleted on client
239
- foreach ($deletedContentStates as $state) {
240
+ foreach($deletedContentStates as $state) {
241
$this->_contentStateBackend->delete($state);
242
}
243
244
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Command/Wbxml.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/AData.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Calendar.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Contacts.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Email.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Factory.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/IData.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/IDataCalendar.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/IDataEmail.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/IDataSearch.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Notes.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Data/Tasks.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/AccessDenied.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/DeadlockDetected.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/MemoryExhausted.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/NotFound.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/PolicyKeyMissing.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/ProvisioningNeeded.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/Autodiscover.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/FolderCreate.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/FolderDelete.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/FolderSync.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/FolderUpdate.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/GetItemEstimate.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/ItemOperations.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/MeetingResponse.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/MoveItems.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/Settings.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/Status/Sync.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Exception/UnexpectedValue.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/AEntry.php
Changed
16
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
*/
9
public function setFromArray(array $properties)
10
{
11
- foreach ($properties as $key => $value) {
12
+ foreach($properties as $key => $value) {
13
try {
14
$this->$key = $value; //echo __LINE__ . PHP_EOL;
15
} catch (InvalidArgumentException $iae) {
16
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/AXMLEntry.php
Changed
46
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
{
9
$this->_addXMLNamespaces($domParrent);
10
11
- foreach ($this->_elements as $elementName => $value) {
12
+ foreach($this->_elements as $elementName => $value) {
13
// skip empty values
14
- if ($value === null || $value === '' || (is_array($value) && empty($value))) {
15
+ if($value === null || $value === '' || (is_array($value) && empty($value))) {
16
continue;
17
}
18
19
20
21
if (isset($elementProperties'childElement')) {
22
$element = $domParrent->ownerDocument->createElementNS($nameSpace, ucfirst($elementName));
23
- foreach ($value as $subValue) {
24
+ foreach($value as $subValue) {
25
$subElement = $domParrent->ownerDocument->createElementNS($nameSpace, ucfirst($elementProperties'childElement'));
26
$this->_appendXMLElement($device, $subElement, $elementProperties, $subValue);
27
$element->appendChild($subElement);
28
29
{
30
$properties = ;
31
32
- foreach ($this->_properties as $namespace => $namespaceProperties) {
33
+ foreach($this->_properties as $namespace => $namespaceProperties) {
34
if ($selectedNamespace !== null && $namespace != $selectedNamespace) {
35
continue;
36
}
37
38
*/
39
protected function _getElementProperties($element)
40
{
41
- foreach ($this->_properties as $namespace => $namespaceProperties) {
42
+ foreach($this->_properties as $namespace => $namespaceProperties) {
43
if (array_key_exists($element, $namespaceProperties)) {
44
return $namespace, $namespaceProperties$element;
45
}
46
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Account.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Contact.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Content.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Device.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/DeviceInformation.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Email.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailAttachment.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailBody.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailFlag.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailMeetingRequest.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EmailRecurrence.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Event.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EventAttendee.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EventException.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/EventRecurrence.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/FileReference.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/GAL.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/GALPicture.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IContent.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IEntry.php
Changed
7
1
2
<?php
3
-
4
/*
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IFolder.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IPolicy.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/ISyncState.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/IXMLEntry.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/MeetingResponse.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Note.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Policy.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SendMail.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SmartForward.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SmartReply.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/StoreRequest.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/StoreResponseResult.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SyncCollection.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/SyncState.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/Task.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Model/TaskRecurrence.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Registry.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Zend Framework
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Server.php
Changed
35
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
}
9
10
if ($this->_request->getMethod() != "OPTIONS" && empty($this->_userId)) {
11
- // Outlook on ios/android sends unauthenticated requests for Ping/FolderSync/Settings
12
- // (which doesn't seem to make much sense), so we handle this case silently,
13
- // even though it should normally be a warning.
14
- $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' Not authenticated');
15
+ $this->_logger->warn(__METHOD__ . '::' . __LINE__ . ' Not authenticated');
16
header('WWW-Authenticate: Basic realm="ActiveSync for Kolab"');
17
header('HTTP/1.1 401 Unauthorized');
18
exit;
19
}
20
21
- switch ($this->_request->getMethod()) {
22
+ switch($this->_request->getMethod()) {
23
case 'OPTIONS':
24
$this->_handleOptions();
25
break;
26
27
if ($this->_logger instanceof Zend_Log) {
28
$this->_logDomDocument($requestBody, 'request', __METHOD__, __LINE__);
29
}
30
- } catch (Syncroton_Wbxml_Exception_UnexpectedEndOfFile $e) {
31
+ } catch(Syncroton_Wbxml_Exception_UnexpectedEndOfFile $e) {
32
if ($this->_logger instanceof Zend_Log) {
33
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " unexpected end of file.");
34
}
35
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/TransactionManager.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/TransactionManagerInterface.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Abstract.php
Changed
43
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
*/
9
public function getDPI($_uInt = 0)
10
{
11
- if (!defined('Syncroton_Wbxml_Abstract::DPI_' . $_uInt)) {
12
+ if(!defined('Syncroton_Wbxml_Abstract::DPI_' . $_uInt)) {
13
throw new Syncroton_Wbxml_Exception('unknown wellknown identifier: ' . $_uInt);
14
}
15
16
17
{
18
$byte = fread($this->_stream, 1);
19
20
- if ($byte === false) {
21
+ if($byte === false) {
22
throw new Syncroton_Wbxml_Exception("failed reading one byte");
23
}
24
25
26
do {
27
$byte = ($remainder & 127);
28
$remainder >>= 7;
29
- if ($multibyte === null) {
30
+ if($multibyte === null) {
31
$multibyte = chr($byte);
32
} else {
33
$multibyte = chr($byte | 128) . $multibyte;
34
35
$this->_writeMultibyteUInt($length);
36
$writenBytes = stream_copy_to_stream($stream, $this->_stream);
37
38
- if ($writenBytes !== $length) {
39
+ if($writenBytes !== $length) {
40
throw new Syncroton_Wbxml_Exception('blow');
41
}
42
43
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Decoder.php
Changed
112
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
*/
9
public function __construct($_stream, $_dpi = null)
10
{
11
- if (!is_resource($_stream) || get_resource_type($_stream) != 'stream') {
12
+ if(!is_resource($_stream) || get_resource_type($_stream) != 'stream') {
13
throw new Syncroton_Wbxml_Exception('$_stream must be a stream');
14
}
15
- if ($_dpi !== null) {
16
+ if($_dpi !== null) {
17
$this->_dpi = $_dpi;
18
}
19
20
21
22
$this->_version = $this->_getByte();
23
24
- if (feof($this->_stream)) {
25
+ if(feof($this->_stream)) {
26
throw new Syncroton_Wbxml_Exception_UnexpectedEndOfFile();
27
}
28
29
30
31
// resolve DPI as we have read the stringtable now
32
// this->_dpi contains the string table index
33
- if ($this->_dpiType === Syncroton_Wbxml_Abstract::DPI_STRINGTABLE) {
34
+ if($this->_dpiType === Syncroton_Wbxml_Abstract::DPI_STRINGTABLE) {
35
$this->_dpi = $this->_stringTable$this->_dpi;
36
}
37
38
39
while (!feof($this->_stream)) {
40
$byte = $this->_getByte();
41
42
- switch ($byte) {
43
+ switch($byte) {
44
case Syncroton_Wbxml_Abstract::END:
45
$node = $node->parentNode;
46
$openTags--;
47
48
49
case Syncroton_Wbxml_Abstract::OPAQUE:
50
$length = $this->_getMultibyteUInt();
51
- if ($length > 0) {
52
+ if($length > 0) {
53
$opaque = $this->_getOpaque($length);
54
try {
55
// let see if we can decode it. maybe the opaque data is wbxml encoded content
56
57
58
fclose($opaqueDataStream);
59
60
- foreach ($dom->childNodes as $newNode) {
61
- if ($newNode instanceof DOMElement) {
62
+ foreach($dom->childNodes as $newNode) {
63
+ if($newNode instanceof DOMElement) {
64
$newNode = $this->_dom->importNode($newNode, true);
65
$node->appendChild($newNode);
66
}
67
68
{
69
$uInt = $this->_getMultibyteUInt();
70
71
- if ($uInt == 0) {
72
+ if($uInt == 0) {
73
// get identifier from stringtable
74
$this->_dpiType = Syncroton_Wbxml_Abstract::DPI_STRINGTABLE;
75
// string table identifier, can be resolved only after reading string table
76
77
{
78
$uInt = $this->_getMultibyteUInt();
79
80
- switch ($uInt) {
81
+ switch($uInt) {
82
case 106:
83
$this->_charSet = 'UTF-8';
84
break;
85
86
{
87
$length = $this->_getMultibyteUInt();
88
89
- if ($length > 0) {
90
+ if($length > 0) {
91
$rawStringTable = $this->_getOpaque($length);
92
$index = null;
93
$string = null;
94
95
- for ($i = 0; $i < strlen($rawStringTable); $i++) {
96
- if ($index === null) {
97
+ for($i = 0; $i < strlen($rawStringTable); $i++) {
98
+ if($index === null) {
99
$index = $i;
100
}
101
- if (ord($rawStringTable$i) != 0) {
102
+ if(ord($rawStringTable$i) != 0) {
103
$string .= $rawStringTable$i;
104
}
105
106
// either the string has ended or we reached a \0
107
- if ($i + 1 == strlen($rawStringTable) || ord($rawStringTable$i) == 0) {
108
+ if($i + 1 == strlen($rawStringTable) || ord($rawStringTable$i) == 0) {
109
$this->_stringTable$index = $string;
110
$index = null;
111
$string = null;
112
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/Abstract.php
Changed
25
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
*/
9
public function getIdentity($_tag)
10
{
11
- if (!isset($this->_tags$_tag)) {
12
+ if(!isset($this->_tags$_tag)) {
13
//var_dump($this->_tags);
14
throw new Syncroton_Wbxml_Exception("tag $_tag not found");
15
}
16
17
{
18
$tag = array_search($_identity, $this->_tags);
19
20
- if ($tag === false) {
21
+ if($tag === false) {
22
throw new Syncroton_Wbxml_Exception("identity $_identity not found");
23
}
24
25
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage0.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage1.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage10.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage11.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage12.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage13.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage14.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage15.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage16.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage17.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage18.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage19.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage2.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage20.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage21.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage22.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage23.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage24.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage254.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage3.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage4.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage5.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage6.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage7.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage8.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage9.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/Exception/CodePageNotFound.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Dtd/Factory.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Encoder.php
Changed
83
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
8
// the WBXML version
9
$this->_writeByte($this->_version);
10
11
- if ($this->_codePage->getDPI() === null) {
12
+ if($this->_codePage->getDPI() === null) {
13
// the document public identifier
14
$this->_writeMultibyteUInt(1);
15
} else {
16
17
// write the charSet
18
$this->_writeCharSet($this->_charSet);
19
20
- if ($this->_codePage->getDPI() === null) {
21
+ if($this->_codePage->getDPI() === null) {
22
// the length of the string table
23
$this->_writeMultibyteUInt(0);
24
} else {
25
26
*/
27
protected function _writeCharSet($_charSet)
28
{
29
- switch (strtoupper($_charSet)) {
30
+ switch(strtoupper($_charSet)) {
31
case 'UTF-8':
32
$this->_writeMultibyteUInt(106);
33
break;
34
35
36
private function writeNode($node, $withContent = false, $data = null)
37
{
38
- if ($this->_codePage->getNameSpace() != $node->namespaceURI) {
39
+ if($this->_codePage->getNameSpace() != $node->namespaceURI) {
40
$this->_switchCodePage($node->namespaceURI);
41
}
42
$this->_writeTag($node->localName, $this->getAttributes($node), $withContent, $data);
43
44
*/
45
protected function _writeTag($_tag, $_attributes = null, $_hasContent = false, $_data = null)
46
{
47
- if ($_hasContent == false && $_data !== null) {
48
+ if($_hasContent == false && $_data !== null) {
49
throw new Syncroton_Wbxml_Exception('$_hasContent can not be false, when $_data !== NULL');
50
}
51
52
53
$encoding = 'termstring';
54
}
55
56
- if (!empty($_attributes)) {
57
+ if(!empty($_attributes)) {
58
$identity |= 0x80;
59
}
60
61
- if ($_hasContent == true) {
62
+ if($_hasContent == true) {
63
$identity |= 0x40;
64
}
65
66
$this->_writeByte($identity);
67
68
// handle the data
69
- if ($_data !== null) {
70
+ if($_data !== null) {
71
if ($encoding == 'opaque') {
72
$this->_writeOpaqueString(base64_decode($_data));
73
} else {
74
75
protected function _switchCodePage($_nameSpace)
76
{
77
$codePageName = $this->_stripNameSpace($_nameSpace);
78
- if (!defined('Syncroton_Wbxml_Dtd_ActiveSync::CODEPAGE_' . strtoupper($codePageName))) {
79
+ if(!defined('Syncroton_Wbxml_Dtd_ActiveSync::CODEPAGE_' . strtoupper($codePageName))) {
80
throw new Syncroton_Wbxml_Exception('codepage ' . $codePageName . ' not found');
81
}
82
// switch to another codepage
83
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Exception.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/ext/Syncroton/Wbxml/Exception/UnexpectedEndOfFile.php
Changed
7
1
2
<?php
3
-
4
/**
5
* Syncroton
6
*
7
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync.php
Changed
39
1
2
Syncroton_Registry::set(Syncroton_Registry::LOGGERBACKEND, $this->logger);
3
Syncroton_Registry::set(Syncroton_Registry::DATABASE, $this->get_dbh());
4
Syncroton_Registry::set(Syncroton_Registry::TRANSACTIONMANAGER, kolab_sync_transaction_manager::getInstance());
5
- // The unauthenticated OPTIONS request doesn't require these backends and we can't
6
- // instantiate them without credentials for the underlying storage backend
7
+ // The unauthenticated OPTIONS request doesn't require these backends and we can't instantiate them without credentials for the underlying storage backend
8
if (!empty($userid)) {
9
Syncroton_Registry::set(Syncroton_Registry::DEVICEBACKEND, new kolab_sync_backend_device());
10
Syncroton_Registry::set(Syncroton_Registry::FOLDERBACKEND, new kolab_sync_backend_folder());
11
12
13
/**
14
* Initializes and returns the storage backend object
15
- *
16
- * @param bool $init Reset the driver internal state
17
*/
18
- public static function storage($init = false)
19
+ public static function storage()
20
{
21
$class = 'kolab_sync_storage';
22
$self = self::get_instance();
23
24
$class .= '_' . strtolower($name);
25
}
26
27
- if ($init) {
28
- // Reset storage driver internal state
29
- $reflection = new ReflectionClass($class);
30
- $property = $reflection->getProperty('instance');
31
- $property->setAccessible(true);
32
- $property->setValue($class::get_instance(), null);
33
- $property->setAccessible(false);
34
- }
35
-
36
return $class::get_instance();
37
}
38
39
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_backend_folder.php
Changed
28
1
2
}
3
4
/**
5
- * Check if the folder already exists
6
- *
7
- * @param Syncroton_Model_Device|string $deviceid Device object or identifier
8
- * @param string $folderid Folder identifier
9
- *
10
- * @return bool true if it exists
11
- */
12
- public function exists($deviceid, $folderid)
13
- {
14
- $device_id = $deviceid instanceof Syncroton_Model_IDevice ? $deviceid->id : $deviceid;
15
-
16
- $where = $this->db->quote_identifier('device_id') . ' = ' . $this->db->quote($device_id);
17
- $where = $this->db->quote_identifier('folderid') . ' = ' . $this->db->quote($folderid);
18
-
19
- $select = $this->db->query('SELECT 1 FROM `' . $this->table_name . '` WHERE ' . implode(' AND ', $where));
20
- $folder = $this->db->fetch_assoc($select);
21
- return !empty($folder);
22
- }
23
-
24
- /**
25
* Find out if the folder hierarchy changed since the last FolderSync
26
*
27
* @param Syncroton_Model_Device $device Device object
28
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_backend_state.php
Changed
33
1
2
$select = $this->db->limitquery("SELECT * FROM `{$this->table_name}` WHERE " . implode(' AND ', $where)
3
. " ORDER BY `counter` DESC", 0, 1);
4
5
- if ($err = $this->db->is_error($select)) {
6
- throw new Exception("Query failed while fetching sync state: {$err}");
7
- }
8
-
9
$state = $this->db->fetch_assoc($select);
10
11
if (empty($state)) {
12
13
14
$select = $this->db->query("SELECT * FROM `{$this->table_name}` WHERE " . implode(' AND ', $where));
15
16
- if ($err = $this->db->is_error($select)) {
17
- throw new Exception("Query failed while validating sync state: {$err}");
18
- }
19
-
20
while ($row = $this->db->fetch_assoc($select)) {
21
$states$row'counter' = $this->get_object($row);
22
}
23
24
$where'counter' = $this->db->quote_identifier('counter') . ' > ' . $this->db->quote($sync_key);
25
26
$select = $this->db->query("SELECT id FROM `{$this->table_name}` WHERE " . implode(' AND ', $where));
27
- if ($err = $this->db->is_error($select)) {
28
- throw new Exception("Query failed while checking for sync state: {$err}");
29
- }
30
return $this->db->num_rows($select) > 0;
31
}
32
}
33
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_data.php
Changed
10
1
2
$r = $data'recurrence';
3
4
// required fields
5
- switch ($r'FREQ') {
6
+ switch($r'FREQ') {
7
case 'DAILY':
8
$recurrence'type' = self::RECUR_TYPE_DAILY;
9
break;
10
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_data_contacts.php
Changed
11
1
2
$emails = ;
3
for ($x = 0; $x < 3; $x++) {
4
$key = 'email' . ($x + 1) . 'Address';
5
- $value = $data->$key ?? null;
6
- if ($value) {
7
+ if ($value = $data->$key) {
8
// Android sends email address as: Lars Kneschke <l.kneschke@metaways.de>
9
if (preg_match('/(.*)<(.+@^@+)>/', $value, $matches)) {
10
$value = trim($matches2);
11
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_data_email.php
Changed
18
1
2
*/
3
public function getFileReference($fileReference)
4
{
5
+ $folderid, $uid, $part_id = explode('::', $fileReference);
6
+
7
$message = $this->getObject($fileReference);
8
9
if (!$message) {
10
throw new Syncroton_Exception_NotFound("Message $fileReference not found");
11
}
12
13
- $folderid, $uid, $part_id = explode('::', $fileReference);
14
-
15
$part = $message->mime_parts$part_id;
16
$body = $message->get_part_body($part_id);
17
18
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_storage.php
Changed
242
1
2
protected $folders = ;
3
protected $root_meta;
4
protected $relations = ;
5
- protected $relationSupport = self::MODEL_TASKS, self::MODEL_NOTES, self::MODEL_EMAIL;
6
+ public $relationSupport = true;
7
protected $tag_rts = ;
8
private $modseq = ;
9
10
11
$this->storage->set_options(
12
// @TODO: there can be Roundcube plugins defining additional headers,
13
// we maybe would need to add them here
14
- 'fetch_headers' => 'X-KOLAB-TYPE X-KOLAB-MIME-VERSION MESSAGE-ID',
15
+ 'fetch_headers' => 'X-KOLAB-TYPE X-KOLAB-MIME-VERSION',
16
'skip_deleted' => true,
17
'threading' => false,
18
);
19
20
return $uid;
21
}
22
23
- $useTags = in_array($type, $this->relationSupport);
24
+ $useTags = $this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES);
25
26
// convert categories into tags, save them after creating an object
27
if ($useTags && !empty($data'categories')) {
28
29
return $this->storage->delete_message($uid, $foldername);
30
}
31
32
- $useTags = in_array($type, $this->relationSupport);
33
+ $useTags = $this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES);
34
35
$folder = $this->getFolder($folderid, $deviceid, $type);
36
37
38
}
39
40
// Categories (Tags) change
41
- if (isset($params'categories') && in_array($type, $this->relationSupport)) {
42
- $headers = $this->storage->fetch_headers($foldername, $uid, false);
43
+ if (isset($params'categories') && $this->relationSupport) {
44
+ $message = new rcube_message($uid, $foldername);
45
46
- if (empty($headers) || empty($headers$uid)) {
47
+ if (empty($message->headers)) {
48
throw new Syncroton_Exception_Status_Sync(Syncroton_Exception_Status_Sync::SYNC_SERVER_ERROR);
49
}
50
51
- $this->setCategories($headers$uid, $params'categories');
52
+ $this->setCategories($message, $params'categories');
53
}
54
55
return $uid;
56
57
58
$folder = $this->getFolder($folderid, $deviceid, $type);
59
60
- $useTags = in_array($type, $this->relationSupport);
61
+ $useTags = $this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES);
62
63
// convert categories into tags, save them after updating an object
64
if ($useTags && array_key_exists('categories', $data)) {
65
66
/**
67
* Returns list of categories assigned to an object
68
*
69
- * @param rcube_message_header|string $object UID or mail message headers
70
- * @param array $categories Addition tag names to merge with
71
+ * @param object|string $object UID or rcube_message object
72
+ * @param array $categories Addition tag names to merge with
73
*
74
* @return array List of categories
75
*/
76
- protected function getCategories($object, $categories = )
77
+ public function getCategories($object, $categories = )
78
{
79
if (is_object($object)) {
80
// support only messages with message-id
81
- if (!($msg_id = $object->get('message-id', false))) {
82
+ if (!($msg_id = $object->headers->get('message-id', false))) {
83
return ;
84
}
85
86
87
$message = new rcube_message($uid, $foldername);
88
89
if (!empty($message->headers)) {
90
- if (in_array($type, $this->relationSupport)) {
91
- $message->headers->folder = $foldername;
92
- $message->headers->uid = $uid;
93
- $message->headers->others'categories' = $this->getCategories($message->headers);
94
+ if ($this->relationSupport) {
95
+ $message->headers->others'categories' = $this->getCategories($message);
96
}
97
98
return $message;
99
100
throw new Syncroton_Exception_Status(Syncroton_Exception_Status::SERVER_ERROR);
101
}
102
103
- $useTags = in_array($type, $this->relationSupport);
104
+ $useTags = $this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES);
105
106
if ($useTags) {
107
$result'categories' = $this->getCategories($uid, $result'categories' ?? );
108
109
/**
110
* Set categories to an object
111
*
112
- * @param rcube_message_header|string $object UID or mail message headers
113
- * @param array $categories List of Category names
114
+ * @param object|string $object UID or rcube_message object
115
+ * @param array $categories List of Category names
116
*/
117
- protected function setCategories($object, $categories)
118
+ public function setCategories($object, $categories)
119
{
120
if (!is_object($object)) {
121
$config = kolab_storage_config::get_instance();
122
123
124
$config = kolab_storage_config::get_instance();
125
$delta = Syncroton_Registry::getPingTimeout();
126
- $uri = kolab_storage_config::get_message_uri($object, $object->folder);
127
+ $uri = kolab_storage_config::get_message_uri($object->headers, $object->folder);
128
129
// for all tag objects...
130
foreach ($config->get_tags() as $relation) {
131
132
}
133
134
// get members of modified relations
135
- if (in_array($type, $this->relationSupport)) {
136
+ if ($this->relationSupport) {
137
$changed_msgs = $this->getChangesByRelations($folderid, $device_key, $type, $filter);
138
// handle relation changes
139
if (!empty($changed_msgs)) {
140
141
142
switch ($result_type) {
143
case kolab_sync_data::RESULT_COUNT:
144
- $result += count($members); // @phpstan-ignore-line
145
+ $result += count($members);
146
break;
147
148
case kolab_sync_data::RESULT_UID:
149
150
// there's a PHP Warning from kolab_storage if $filter isn't an array
151
if (empty($filter)) {
152
$filter = ;
153
- } elseif (in_array($type, $this->relationSupport)) {
154
+ } elseif ($this->relationSupport && ($type == self::MODEL_TASKS || $type == self::MODEL_NOTES)) {
155
$changed_objects = $this->getChangesByRelations($folderid, $device_key, $type, $filter);
156
}
157
158
159
// need a precise result here
160
$count = $folder->count($tag_filter);
161
if ($count !== null) {
162
- $result += (int) $count; // @phpstan-ignore-line
163
+ $result += (int) $count;
164
}
165
166
break;
167
168
169
// Protect against inserting the same values twice (this code can be executed twice in the same request)
170
if (!isset($this->relations$folderid$synctime)) {
171
- $rcube = rcube::get_instance();
172
- $db = $rcube->get_dbh();
173
+ $rcube = rcube::get_instance();
174
+ $db = $rcube->get_dbh();
175
$this->relations$folderid$synctime = $relations;
176
- $data = gzdeflate(json_encode($relations));
177
-
178
- if ($data === false) {
179
- throw new Exception("Failed to compress relation data");
180
- }
181
+ $data = rcube_charset::clean(json_encode($relations));
182
183
$result = $db->insert_or_update(
184
'syncroton_relations_state',
185
186
{
187
$synctime = $synctime->format('Y-m-d H:i:s');
188
189
- // If we had a collision before
190
+ //If we had a collision before
191
if (isset($this->relations$folderid$synctime . "-1")) {
192
return $this->relations$folderid$synctime . "-1";
193
}
194
-
195
if (!isset($this->relations$folderid$synctime)) {
196
$rcube = rcube::get_instance();
197
- $db = $rcube->get_dbh();
198
+ $db = $rcube->get_dbh();
199
200
$db->limitquery(
201
"SELECT `data`, `synctime` FROM `syncroton_relations_state`"
202
203
$synctime
204
);
205
206
- $row = $db->fetch_assoc();
207
- if (!$row) {
208
- // Only if we don't have a timestamp that is older than synctime do we return the next best.
209
- // We MUST return an entry if there are any, because otherwise we will keep INSERTing new entries in,
210
- // relations_state_set
211
- $db->limitquery(
212
- "SELECT `data`, `synctime` FROM `syncroton_relations_state`"
213
- . " WHERE `device_id` = ? AND `folder_id` = ?"
214
- . " ORDER BY `synctime` ASC",
215
- 0,
216
- 1,
217
- $device_key,
218
- $folderid,
219
- $synctime
220
- );
221
- $row = $db->fetch_assoc();
222
- }
223
-
224
- if ($row) {
225
- // Don't use $row'synctime' for the internal cache, and use $synctime instead.
226
+ if ($row = $db->fetch_assoc()) {
227
+ // Don't use $row'synctime' for the internal cache.
228
// The synctime of the found row is usually earlier than the requested synctime.
229
- // Note: We use the internal cache because there's a call to both hasChanges() and
230
+ // Note: We use internal cache because there's a call to both hasChanges() and
231
// getChangedEntries() in Sync. It's needed until we add some caching on a higher level.
232
- $data = $row'data';
233
- // Support data in both compressed and uncompressed format
234
- if (strlen($data) && $data0 != '{' && $data0 != '') {
235
- $data = gzinflate($data);
236
- }
237
- $this->relations$folderid$synctime = json_decode($data, true);
238
+ $this->relations$folderid$synctime = json_decode($row'data', true);
239
240
// Cleanup: remove all records older than the current one.
241
// We must use the row's synctime, otherwise we would delete the record we just loaded
242
kolab-syncroton-2.4.2.tar.gz/lib/kolab_sync_storage_kolab4.php
Changed
71
1
2
class kolab_sync_storage_kolab4 extends kolab_sync_storage
3
{
4
protected $davStorage = null;
5
- protected $tagStorage = null;
6
- protected $relationSupport = self::MODEL_EMAIL;
7
+ public $relationSupport = false;
8
9
/**
10
* This implements the 'singleton' design pattern
11
12
// Inject user+password to the URL, there's no other way to pass it to the DAV client
13
$url = str_replace('://', '://' . rawurlencode($sync->username) . ':' . rawurlencode($sync->password) . '@', $url);
14
15
- $this->tagStorage = new kolab_storage_tags();
16
$this->davStorage = new kolab_storage_dav($url); // DAV
17
$this->storage = $sync->get_storage(); // IMAP
18
19
20
}
21
22
/**
23
- * Returns list of categories assigned to an object
24
- *
25
- * @param rcube_message_header|string $object UID or mail message headers
26
- * @param array $categories Addition tag names to merge with
27
- *
28
- * @return array List of categories
29
- */
30
- protected function getCategories($object, $categories = )
31
- {
32
- $tags = $this->tagStorage->get_tags_for($object);
33
-
34
- // merge result with old categories
35
- if (!empty($categories)) {
36
- $tags = array_unique(array_merge($tags, (array) $categories));
37
- }
38
-
39
- return $tags;
40
- }
41
-
42
- /**
43
- * Detect changes of tag objects data and assigned messages
44
- */
45
- protected function getChangesByRelations($folderid, $device_key, $type, $filter)
46
- {
47
- // This is not needed with Kolab4 that uses METADATA/ANNOTATE and immutable tags
48
- return ;
49
- }
50
-
51
- /**
52
* Gets kolab_storage_folder object from Activesync folder ID.
53
*
54
* @param string $folderid Folder identifier
55
56
}
57
return parent::getExtraData($folderid, $deviceid);
58
}
59
-
60
- /**
61
- * Set categories to an object
62
- *
63
- * @param rcube_message_header|string $object UID or mail message headers
64
- * @param array $categories List of Category names
65
- */
66
- protected function setCategories($object, $categories)
67
- {
68
- $this->tagStorage->set_tags_for($object, $categories);
69
- }
70
}
71
kolab-syncroton-2.4.2.tar.gz/tests/Sync/FoldersTest.php
Changed
126
1
2
/**
3
* Cleanup folders
4
*/
5
- protected function foldersCleanup(): void
6
+ public function setUp(): void
7
{
8
// Note: We essentially assume the test account is in an initial state, extra folders may break tests
9
// Anyway, we first remove folders that might have been created during tests in this file
10
+ $this->deleteTestFolder('Test Folder', 'mail');
11
$this->deleteTestFolder('NewFolder', 'mail');
12
$this->deleteTestFolder('NewFolder2', 'mail');
13
- $this->deleteTestFolder('Test Folder', 'mail');
14
$this->deleteTestFolder('Test Folder New', 'mail');
15
$this->deleteTestFolder('Test Contacts Folder', 'contact');
16
$this->deleteTestFolder('Test Contacts New', 'contact');
17
+ parent::setUp();
18
}
19
20
/**
21
22
*/
23
public function testFolderSyncBasic()
24
{
25
- $this->foldersCleanup();
26
-
27
$request = <<<EOF
28
<?xml version="1.0" encoding="utf-8"?>
29
<!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
30
31
// No changes on second sync
32
$this->assertSame(strval(0), $xpath->query("//ns:FolderSync/ns:Changes/ns:Count")->item(0)->nodeValue);
33
34
+
35
//Clear the creation_synckey (that's the migration scenario)
36
//Shouldn't trigger a change
37
$rcube = \rcube::get_instance();
38
$db = $rcube->get_dbh();
39
$result = $db->query(
40
- "UPDATE `syncroton_folder` SET `creation_synckey` = 0",
41
+ "UPDATE `syncroton_folder` SET `creation_synckey` = null",
42
);
43
44
$request = <<<EOF
45
46
$this->assertEquals(200, $response->getStatusCode());
47
$dom = $this->fromWbxml($response->getBody());
48
$xpath = $this->xpath($dom);
49
+ $this->printDom($dom);
50
$this->assertSame('1', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue);
51
$this->assertSame('1', $xpath->query("//ns:FolderSync/ns:SyncKey")->item(0)->nodeValue);
52
// No changes on second sync
53
54
$this->assertSame('9', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue);
55
}
56
57
+
58
/**
59
* Test synckey reuse
60
*/
61
public function testSyncKeyResend()
62
{
63
+ $this->deleteTestFolder('NewFolder', 'mail');
64
+ $this->deleteTestFolder('NewFolder2', 'mail');
65
$request = <<<EOF
66
<?xml version="1.0" encoding="utf-8"?>
67
<!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
68
69
$dom = $this->fromWbxml($response->getBody());
70
$xpath = $this->xpath($dom);
71
$this->assertSame('9', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue);
72
- }
73
-
74
- /**
75
- * This test recreates a previously deleted folder.
76
- * Currently similar to disabling/reenabling a folder for sync, but should perhaps be tested separately
77
- *
78
- * @depends testSyncKeyResend
79
- */
80
- public function testRecreatePreviousFolder()
81
- {
82
- $this->deleteTestFolder('NewFolder', 'mail');
83
- $this->deleteTestFolder('NewFolder2', 'mail');
84
- $request = <<<EOF
85
- <?xml version="1.0" encoding="utf-8"?>
86
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
87
- <FolderSync xmlns="uri:FolderHierarchy">
88
- <SyncKey>0</SyncKey>
89
- </FolderSync>
90
- EOF;
91
- $response = $this->request($request, 'FolderSync');
92
- $this->assertEquals(200, $response->getStatusCode());
93
- $dom = $this->fromWbxml($response->getBody());
94
- $xpath = $this->xpath($dom);
95
- $this->assertSame('1', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue);
96
-
97
- //Now change something
98
- $this->createTestFolder("NewFolder", "mail");
99
- $request = <<<EOF
100
- <?xml version="1.0" encoding="utf-8"?>
101
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
102
- <FolderSync xmlns="uri:FolderHierarchy">
103
- <SyncKey>1</SyncKey>
104
- </FolderSync>
105
- EOF;
106
-
107
- $response = $this->request($request, 'FolderSync');
108
- $this->assertEquals(200, $response->getStatusCode());
109
- $dom = $this->fromWbxml($response->getBody());
110
- $xpath = $this->xpath($dom);
111
- $this->assertSame('1', $xpath->query("//ns:FolderSync/ns:Status")->item(0)->nodeValue);
112
- $this->assertSame('2', $xpath->query("//ns:FolderSync/ns:SyncKey")->item(0)->nodeValue);
113
- $this->assertSame(strval(1), $xpath->query("//ns:FolderSync/ns:Changes/ns:Count")->item(0)->nodeValue);
114
115
// Cleanup for the other tests
116
$this->deleteTestFolder('NewFolder', 'mail');
117
118
*/
119
public function testFolderSync()
120
{
121
- $this->foldersCleanup();
122
- $this->resetDevice();
123
124
$request = <<<EOF
125
<?xml version="1.0" encoding="utf-8"?>
126
kolab-syncroton-2.4.2.tar.gz/tests/Sync/MoveItemsTest.php
Changed
11
1
2
// Test with multi-folder support enabled
3
self::$deviceType = 'iphone';
4
5
- $davFolder = 'Contacts';
6
+ // @phpstan-ignore-next-line
7
+ $davFolder = $this->isStorageDriver('kolab') ? 'Contacts' : 'Addressbook';
8
$this->emptyTestFolder($davFolder, 'contact');
9
$this->deleteTestFolder($folderName = 'Test Contacts Folder', 'contact');
10
$this->appendObject($davFolder, 'contact.vcard1', 'contact');
11
kolab-syncroton-2.4.2.tar.gz/tests/Sync/PingTest.php
Changed
35
1
2
3
class PingTest extends Tests\SyncTestCase
4
{
5
+
6
/**
7
* Test Ping command
8
*/
9
10
11
$dom = $this->fromWbxml($response->getBody());
12
$xpath = $this->xpath($dom);
13
+ $this->printDom($dom);
14
15
//Initially we know no folders
16
$this->assertSame('7', $xpath->query("//ns:Ping/ns:Status")->item(0)->nodeValue);
17
18
$this->assertEquals(200, $response->getStatusCode());
19
$dom = $this->fromWbxml($response->getBody());
20
$xpath = $this->xpath($dom);
21
- // Initially we know no folders
22
+ // $this->printDom($dom);
23
+ //Initially we know no folders
24
$this->assertSame('2', $xpath->query("//ns:Ping/ns:Status")->item(0)->nodeValue);
25
}
26
27
28
29
$dom = $this->fromWbxml($response->getBody());
30
$xpath = $this->xpath($dom);
31
+ // $this->printDom($dom);
32
33
$this->assertSame('7', $xpath->query("//ns:Ping/ns:Status")->item(0)->nodeValue);
34
}
35
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/ContactsTest.php
Changed
10
1
2
*/
3
public function testSync()
4
{
5
- $davFolder = 'Contacts';
6
+ $davFolder = $this->isStorageDriver('kolab') ? 'Contacts' : 'Addressbook';
7
$this->emptyTestFolder($davFolder, 'contact');
8
$this->deleteTestFolder('Test Contacts Folder', 'contact'); // from other test files
9
$this->registerDevice();
10
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/EmailITipTest.php
Changed
10
1
2
$dom = $this->fromWbxml($response->getBody());
3
$xpath = $this->xpath($dom);
4
5
+ // print($dom->saveXML());
6
+
7
$root = "//ns:Sync/ns:Collections/ns:Collection";
8
$this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue);
9
$this->assertSame(strval(++$syncKey), $xpath->query("{$root}/ns:SyncKey")->item(0)->nodeValue);
10
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/EmailTest.php
Changed
77
1
2
$this->assertSame(strval(++$syncKey), $xpath->query("{$root}/ns:SyncKey")->item(0)->nodeValue);
3
$this->assertSame($folderId, $xpath->query("{$root}/ns:CollectionId")->item(0)->nodeValue);
4
$this->assertSame(1, $xpath->query("{$root}/ns:Commands/ns:Add")->count());
5
- $this->assertSame('0', $xpath->query("{$root}/ns:Commands/ns:Add/ns:ApplicationData/Email:Read")->item(0)->nodeValue);
6
7
// Note: We assume messages are in IMAP default order, it may change in future
8
$root .= "/ns:Commands/ns:Add";
9
10
$this->assertEquals(200, $response->getStatusCode());
11
$dom = $this->fromWbxml($response->getBody());
12
$xpath = $this->xpath($dom);
13
+ // print($dom->saveXML());
14
15
$root = "//ns:Sync/ns:Collections/ns:Collection";
16
$this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue);
17
18
$this->assertSame(0, $xpath->query("{$root}/ns:Commands/ns:Add")->count());
19
$this->assertSame(2, $xpath->query("{$root}/ns:Commands/ns:Change")->count());
20
$this->assertSame(2, $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->count());
21
- $this->assertSame('1', $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->item(0)->nodeValue);
22
- $this->assertSame('1', $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->item(1)->nodeValue);
23
- $this->assertSame(0, $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/AirSyncBase:Body")->count());
24
+ $this->assertSame('0', $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->item(0)->nodeValue);
25
+ $this->assertSame('0', $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/Email:Read")->item(1)->nodeValue);
26
27
+ $this->assertSame(0, $xpath->query("{$root}/ns:Commands/ns:Change/ns:ApplicationData/AirSyncBase:Body")->count());
28
return $syncKey;
29
}
30
31
32
$this->assertEquals(200, $response->getStatusCode());
33
$dom = $this->fromWbxml($response->getBody());
34
$xpath = $this->xpath($dom);
35
+ // print($dom->saveXML());
36
37
$root = "//ns:Sync/ns:Collections/ns:Collection";
38
$this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue);
39
40
$this->assertEquals(200, $response->getStatusCode());
41
$dom = $this->fromWbxml($response->getBody());
42
$xpath = $this->xpath($dom);
43
+ // print($dom->saveXML());
44
45
$root = "//ns:Sync/ns:Collections/ns:Collection";
46
$this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue);
47
48
$this->assertEquals(200, $response->getStatusCode());
49
$dom = $this->fromWbxml($response->getBody());
50
$xpath = $this->xpath($dom);
51
+ // print($dom->saveXML());
52
53
$root = "//ns:Sync/ns:Collections/ns:Collection";
54
$this->assertSame('1', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue);
55
56
return $syncKey;
57
}
58
59
+
60
/**
61
* Test a sync key that doesn't exist yet.
62
* @depends testDeleteFromClient
63
64
$this->assertEquals(200, $response->getStatusCode());
65
$dom = $this->fromWbxml($response->getBody());
66
$xpath = $this->xpath($dom);
67
+ // print($dom->saveXML());
68
69
$root = "//ns:Sync/ns:Collections/ns:Collection";
70
$this->assertSame('3', $xpath->query("{$root}/ns:Status")->item(0)->nodeValue);
71
72
//We have to start over after this. The sync state was removed.
73
return 0;
74
}
75
+
76
}
77
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/InconsistencyTest.php
Changed
26
1
2
$this->assertSame($folderId, $xpath->query("{$root}/ns:CollectionId")->item(0)->nodeValue);
3
$this->assertSame(1, $xpath->query("{$root}/ns:Commands/ns:Add")->count());
4
5
- // Assert that we have all content parts back
6
+
7
+ //Assert that we have all content parts back
8
+ $sync = \kolab_sync::get_instance();
9
+ $device = $sync->storage()->device_get(self::$deviceId);
10
+
11
$result = $db->query(
12
"SELECT `contentid` FROM `syncroton_content`"
13
- . " WHERE `device_id` IN (SELECT `id` FROM `syncroton_device` WHERE `deviceid` = ?)",
14
- self::$deviceId
15
+ . " WHERE `device_id` = ?",
16
+ $device'ID'
17
);
18
$data = ;
19
while ($state = $db->fetch_assoc($result)) {
20
21
22
return $syncKey;
23
}
24
+
25
}
26
kolab-syncroton-2.4.2.tar.gz/tests/Sync/Sync/RelationsTest.php
Changed
203
1
2
return $this->request($request, 'Sync');
3
}
4
5
- private function getRelationsState($device_id, $folderId)
6
- {
7
- $db = \rcube::get_instance()->get_dbh();
8
- $result = $db->query(
9
- "SELECT `data`, `synctime` FROM `syncroton_relations_state`"
10
- . " WHERE `device_id` IN (SELECT `id` FROM `syncroton_device` WHERE `deviceid` = ?) AND `folder_id` = ?"
11
- . " ORDER BY `synctime` DESC",
12
- $device_id,
13
- $folderId
14
- );
15
- $data = ;
16
- while ($state = $db->fetch_assoc($result)) {
17
- $data = $state;
18
- }
19
- return $data;
20
- }
21
-
22
/**
23
* Test Sync command
24
*/
25
public function testRelationsSync()
26
{
27
$sync = \kolab_sync::get_instance();
28
+ if (!$sync->storage()->relationSupport) {
29
+ $this->markTestSkipped('No relation support');
30
+ }
31
32
$this->emptyTestFolder('INBOX', 'mail');
33
- if ($this->isStorageDriver('kolab4')) {
34
- $sync->get_storage()->set_metadata(\kolab_storage_tags::METADATA_ROOT, \kolab_storage_tags::METADATA_TAGS_KEY => null);
35
- } else {
36
- $this->emptyTestFolder('Configuration', 'configuration');
37
- }
38
+ $this->emptyTestFolder('Configuration', 'configuration');
39
$this->registerDevice();
40
41
// Test INBOX
42
43
44
$sync = \kolab_sync::get_instance();
45
46
- // Add a tag
47
- $sync->storage(true)->updateItem($folderId, self::$deviceId, \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1');
48
+ $device = $sync->storage()->device_get(self::$deviceId);
49
+
50
+ //Add a tag
51
+ $sync->storage()->updateItem($folderId, $device'ID', \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1');
52
sleep(1);
53
54
$response = $this->syncRequest($syncKey, $folderId, 10);
55
56
$this->assertSame(1, $xpath->query("{$root}/ns:ApplicationData/Email:Categories")->count());
57
$this->assertSame("test1", $xpath->query("{$root}/ns:ApplicationData/Email:Categories")->item(0)->nodeValue);
58
59
- // Add a second tag
60
- $sync->storage(true)->updateItem($folderId, self::$deviceId, \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1', 'test2');
61
+ //Add a second tag
62
+ $sync->storage()->updateItem($folderId, $device'ID', \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1', 'test2');
63
sleep(1); // Necessary to make sure we pick up on the tag.
64
65
$response = $this->syncRequest($syncKey, $folderId, 10);
66
67
$this->assertSame("test1test2", $xpath->query("{$root}/ns:ApplicationData/Email:Categories")->item(0)->nodeValue);
68
69
// Assert the db state
70
- if ($this->isStorageDriver('kolab')) {
71
- $this->assertSame(2, count($this->getRelationsState(self::$deviceId, $folderId)));
72
+ $rcube = \rcube::get_instance();
73
+ $db = $rcube->get_dbh();
74
+ $result = $db->query(
75
+ "SELECT `data`, `synctime` FROM `syncroton_relations_state`"
76
+ . " WHERE `device_id` = ? AND `folder_id` = ?"
77
+ . " ORDER BY `synctime` DESC",
78
+ $device'ID',
79
+ $folderId
80
+ );
81
+ $data = ;
82
+ while ($state = $db->fetch_assoc($result)) {
83
+ $data = $state;
84
}
85
+ $this->assertSame(2, count($data));
86
// Make sure we have a new timestamp after the first iteration.
87
// This way we can potentially catch errors when we end up using the same or a different timestamp.
88
sleep(1);
89
90
$syncKey += ($retries + 1);
91
92
// Reset to no tags
93
- $sync->storage(true)->updateItem($folderId, self::$deviceId, \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => );
94
+ $sync->storage()->updateItem($folderId, $device'ID', \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => );
95
sleep(1); // Necessary to make sure we pick up on the tag.
96
97
$response = $this->syncRequest($syncKey, $folderId, 10);
98
99
//FIXME this currently fails because we omit the empty categories element
100
// $this->assertSame("", $xpath->query("{$root}/ns:ApplicationData/Email:Categories")->item(0)->nodeValue);
101
102
+
103
// Assert the db state
104
- if ($this->isStorageDriver('kolab')) {
105
- $this->assertSame(2, count($this->getRelationsState(self::$deviceId, $folderId)));
106
+ $result = $db->query(
107
+ "SELECT `data`, `synctime` FROM `syncroton_relations_state`"
108
+ . " WHERE `device_id` = ? AND `folder_id` = ?"
109
+ . " ORDER BY `synctime` DESC",
110
+ $device'ID',
111
+ $folderId
112
+ );
113
+ $data = ;
114
+ while ($state = $db->fetch_assoc($result)) {
115
+ $data = $state;
116
}
117
+ $this->assertSame(2, count($data));
118
119
$response = $this->syncRequest($syncKey, $folderId, 10);
120
$this->assertEquals(200, $response->getStatusCode());
121
122
123
return $syncKey;
124
}
125
-
126
- public function testPing()
127
- {
128
- // Setup with a tag and an initial sync completed
129
- $folderId = '38b950ebd62cd9a66929c89615d0fc04';
130
- $sync = \kolab_sync::get_instance();
131
-
132
- $uid1 = $this->appendMail('INBOX', 'mail.sync1');
133
- $sync->storage(true)->updateItem($folderId, self::$deviceId, \kolab_sync_storage::MODEL_EMAIL, $uid1, null, 'categories' => 'test1');
134
- sleep(1);
135
-
136
- $response = $this->syncRequest(0, $folderId, 10);
137
- $this->assertEquals(200, $response->getStatusCode());
138
- $response = $this->syncRequest(1, $folderId, 10);
139
- $this->assertEquals(200, $response->getStatusCode());
140
-
141
- if ($this->isStorageDriver('kolab')) {
142
- $this->assertSame(2, count($this->getRelationsState(self::$deviceId, $folderId)));
143
- }
144
-
145
- // Make sure the timestamp changes
146
- sleep(1);
147
-
148
- // Pings should not change the number of relation states
149
- for ($i = 0; $i < 2; $i++) {
150
- $request = <<<EOF
151
- <?xml version="1.0" encoding="utf-8"?>
152
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
153
- <Ping xmlns="uri:Ping">
154
- <HeartbeatInterval>0</HeartbeatInterval>
155
- <Folders>
156
- <Folder>
157
- <Id>$folderId</Id>
158
- <Class>Email</Class>
159
- </Folder>
160
- </Folders>
161
- </Ping>
162
- EOF;
163
-
164
- $response = $this->request($request, 'Ping');
165
-
166
- $this->assertEquals(200, $response->getStatusCode());
167
- if ($this->isStorageDriver('kolab')) {
168
- $this->assertSame(1, count($this->getRelationsState(self::$deviceId, $folderId)));
169
- }
170
- }
171
-
172
- // This simulates a specific case where we had:
173
- // * An old lastsync timestamp (because the folders were not actively synchronized)
174
- // * The folder was still included in the ping command
175
- // => This resulted in the relations code never finding a relation, and thus not cleaning up, but it still inserted new entries
176
- $db = \rcube::get_instance()->get_dbh();
177
- $result = $db->query(
178
- "UPDATE `syncroton_synckey` SET `lastsync` = '2023-06-23 13:15:03'"
179
- );
180
-
181
- $request = <<<EOF
182
- <?xml version="1.0" encoding="utf-8"?>
183
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
184
- <Ping xmlns="uri:Ping">
185
- <HeartbeatInterval>0</HeartbeatInterval>
186
- <Folders>
187
- <Folder>
188
- <Id>$folderId</Id>
189
- <Class>Email</Class>
190
- </Folder>
191
- </Folders>
192
- </Ping>
193
- EOF;
194
-
195
- $response = $this->request($request, 'Ping');
196
-
197
- $this->assertEquals(200, $response->getStatusCode());
198
- if ($this->isStorageDriver('kolab')) {
199
- $this->assertSame(1, count($this->getRelationsState(self::$deviceId, $folderId)));
200
- }
201
- }
202
}
203
kolab-syncroton-2.4.2.tar.gz/tests/SyncTestCase.php
Changed
30
1
2
return;
3
}
4
5
- self::$deviceId = 'test' . str_replace('.', '', microtime(true));
6
+ self::$deviceId = 'test' . time();
7
8
$db->query('DELETE FROM syncroton_device');
9
$db->query('DELETE FROM syncroton_synckey');
10
11
}
12
}
13
14
- protected function resetDevice()
15
- {
16
- $sync = \kolab_sync::get_instance();
17
-
18
- if (self::$deviceId) {
19
- $storage = $sync->storage();
20
- $storage->device_delete(self::$deviceId);
21
- }
22
-
23
- $db = $sync->get_dbh();
24
- $db->query('DELETE FROM syncroton_device');
25
- }
26
-
27
/**
28
* Convert XML into WBXML binary content
29
*/
30
kolab-syncroton.dsc
Changed
10
1
2
Source: kolab-syncroton
3
Binary: kolab-syncroton
4
Architecture: all
5
-Version: 1:2.4.2.39-1~kolab1
6
+Version: 1:2.4.2.34-1~kolab1
7
Maintainer: Jeroen van Meeuwen <vanmeeuwen@kolabsys.com>
8
Uploaders: Jeroen van Meeuwen <vanmeeuwen@kolabsys.com>
9
Homepage: http://www.kolab.org/
10
Refresh
kolab-syncroton
x86_64
x86_64
x86_64
x86_64
x86_64
ppc64le
x86_64
x86_64
x86_64
x86_64
x86_64
x86_64
x86_64
x86_64
x86_64
ppc64le
x86_64
x86_64
x86_64
x86_64
x86_64
x86_64
x86_64
x86_64
Refresh
Login required, please
login
in order to comment
Request History
mollekopf created request 6 months ago
New release 2.4.2.35
mollekopf superseded request 6 months ago
superseded by 3329