@@ -121,7 +121,7 @@ |
||
121 | 121 | $status = SYNC_FSSTATUS_SYNCKEYERROR; |
122 | 122 | } |
123 | 123 | catch (StatusException $stex) { |
124 | - $status = $stex->getCode(); |
|
124 | + $status = $stex->getCode(); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // set $newsynckey in case of an error |
@@ -18,37 +18,37 @@ discard block |
||
18 | 18 | * @access public |
19 | 19 | * @return boolean |
20 | 20 | */ |
21 | - public function Handle ($commandCode) { |
|
21 | + public function Handle($commandCode) { |
|
22 | 22 | $el = self::$decoder->getElement(); |
23 | 23 | |
24 | - if($el[EN_TYPE] != EN_TYPE_STARTTAG) |
|
24 | + if ($el[EN_TYPE] != EN_TYPE_STARTTAG) |
|
25 | 25 | return false; |
26 | 26 | |
27 | 27 | $create = $update = $delete = false; |
28 | - if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERCREATE) |
|
28 | + if ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERCREATE) |
|
29 | 29 | $create = true; |
30 | - else if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERUPDATE) |
|
30 | + else if ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERUPDATE) |
|
31 | 31 | $update = true; |
32 | - else if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERDELETE) |
|
32 | + else if ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERDELETE) |
|
33 | 33 | $delete = true; |
34 | 34 | |
35 | - if(!$create && !$update && !$delete) |
|
35 | + if (!$create && !$update && !$delete) |
|
36 | 36 | return false; |
37 | 37 | |
38 | 38 | // SyncKey |
39 | - if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) |
|
39 | + if (!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) |
|
40 | 40 | return false; |
41 | 41 | $synckey = self::$decoder->getElementContent(); |
42 | - if(!self::$decoder->getElementEndTag()) |
|
42 | + if (!self::$decoder->getElementEndTag()) |
|
43 | 43 | return false; |
44 | 44 | |
45 | 45 | // ServerID |
46 | 46 | $serverid = false; |
47 | 47 | $backendid = false; |
48 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID)) { |
|
48 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID)) { |
|
49 | 49 | $serverid = self::$decoder->getElementContent(); |
50 | 50 | $backendid = self::$deviceManager->GetBackendIdForFolderId($serverid); |
51 | - if(!self::$decoder->getElementEndTag()) |
|
51 | + if (!self::$decoder->getElementEndTag()) |
|
52 | 52 | return false; |
53 | 53 | } |
54 | 54 | |
@@ -58,31 +58,31 @@ discard block |
||
58 | 58 | |
59 | 59 | // when creating or updating more information is necessary |
60 | 60 | if (!$delete) { |
61 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_PARENTID)) { |
|
61 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_PARENTID)) { |
|
62 | 62 | $parentid = self::$decoder->getElementContent(); |
63 | 63 | $parentBackendId = self::$deviceManager->GetBackendIdForFolderId($parentid); |
64 | - if(!self::$decoder->getElementEndTag()) |
|
64 | + if (!self::$decoder->getElementEndTag()) |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
68 | 68 | // Displayname |
69 | - if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_DISPLAYNAME)) |
|
69 | + if (!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_DISPLAYNAME)) |
|
70 | 70 | return false; |
71 | 71 | $displayname = self::$decoder->getElementContent(); |
72 | - if(!self::$decoder->getElementEndTag()) |
|
72 | + if (!self::$decoder->getElementEndTag()) |
|
73 | 73 | return false; |
74 | 74 | |
75 | 75 | // Type |
76 | 76 | $type = false; |
77 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_TYPE)) { |
|
77 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_TYPE)) { |
|
78 | 78 | $type = self::$decoder->getElementContent(); |
79 | - if(!self::$decoder->getElementEndTag()) |
|
79 | + if (!self::$decoder->getElementEndTag()) |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | 84 | // endtag foldercreate, folderupdate, folderdelete |
85 | - if(!self::$decoder->getElementEndTag()) |
|
85 | + if (!self::$decoder->getElementEndTag()) |
|
86 | 86 | return false; |
87 | 87 | |
88 | 88 | $status = SYNC_FSSTATUS_SUCCESS; |
@@ -21,26 +21,31 @@ discard block |
||
21 | 21 | public function Handle ($commandCode) { |
22 | 22 | $el = self::$decoder->getElement(); |
23 | 23 | |
24 | - if($el[EN_TYPE] != EN_TYPE_STARTTAG) |
|
25 | - return false; |
|
24 | + if($el[EN_TYPE] != EN_TYPE_STARTTAG) { |
|
25 | + return false; |
|
26 | + } |
|
26 | 27 | |
27 | 28 | $create = $update = $delete = false; |
28 | - if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERCREATE) |
|
29 | - $create = true; |
|
30 | - else if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERUPDATE) |
|
31 | - $update = true; |
|
32 | - else if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERDELETE) |
|
33 | - $delete = true; |
|
29 | + if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERCREATE) { |
|
30 | + $create = true; |
|
31 | + } else if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERUPDATE) { |
|
32 | + $update = true; |
|
33 | + } else if($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERDELETE) { |
|
34 | + $delete = true; |
|
35 | + } |
|
34 | 36 | |
35 | - if(!$create && !$update && !$delete) |
|
36 | - return false; |
|
37 | + if(!$create && !$update && !$delete) { |
|
38 | + return false; |
|
39 | + } |
|
37 | 40 | |
38 | 41 | // SyncKey |
39 | - if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) |
|
40 | - return false; |
|
42 | + if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) { |
|
43 | + return false; |
|
44 | + } |
|
41 | 45 | $synckey = self::$decoder->getElementContent(); |
42 | - if(!self::$decoder->getElementEndTag()) |
|
43 | - return false; |
|
46 | + if(!self::$decoder->getElementEndTag()) { |
|
47 | + return false; |
|
48 | + } |
|
44 | 49 | |
45 | 50 | // ServerID |
46 | 51 | $serverid = false; |
@@ -48,8 +53,9 @@ discard block |
||
48 | 53 | if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID)) { |
49 | 54 | $serverid = self::$decoder->getElementContent(); |
50 | 55 | $backendid = self::$deviceManager->GetBackendIdForFolderId($serverid); |
51 | - if(!self::$decoder->getElementEndTag()) |
|
52 | - return false; |
|
56 | + if(!self::$decoder->getElementEndTag()) { |
|
57 | + return false; |
|
58 | + } |
|
53 | 59 | } |
54 | 60 | |
55 | 61 | // Parent |
@@ -61,29 +67,34 @@ discard block |
||
61 | 67 | if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_PARENTID)) { |
62 | 68 | $parentid = self::$decoder->getElementContent(); |
63 | 69 | $parentBackendId = self::$deviceManager->GetBackendIdForFolderId($parentid); |
64 | - if(!self::$decoder->getElementEndTag()) |
|
65 | - return false; |
|
70 | + if(!self::$decoder->getElementEndTag()) { |
|
71 | + return false; |
|
72 | + } |
|
66 | 73 | } |
67 | 74 | |
68 | 75 | // Displayname |
69 | - if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_DISPLAYNAME)) |
|
70 | - return false; |
|
76 | + if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_DISPLAYNAME)) { |
|
77 | + return false; |
|
78 | + } |
|
71 | 79 | $displayname = self::$decoder->getElementContent(); |
72 | - if(!self::$decoder->getElementEndTag()) |
|
73 | - return false; |
|
80 | + if(!self::$decoder->getElementEndTag()) { |
|
81 | + return false; |
|
82 | + } |
|
74 | 83 | |
75 | 84 | // Type |
76 | 85 | $type = false; |
77 | 86 | if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_TYPE)) { |
78 | 87 | $type = self::$decoder->getElementContent(); |
79 | - if(!self::$decoder->getElementEndTag()) |
|
80 | - return false; |
|
88 | + if(!self::$decoder->getElementEndTag()) { |
|
89 | + return false; |
|
90 | + } |
|
81 | 91 | } |
82 | 92 | } |
83 | 93 | |
84 | 94 | // endtag foldercreate, folderupdate, folderdelete |
85 | - if(!self::$decoder->getElementEndTag()) |
|
86 | - return false; |
|
95 | + if(!self::$decoder->getElementEndTag()) { |
|
96 | + return false; |
|
97 | + } |
|
87 | 98 | |
88 | 99 | $status = SYNC_FSSTATUS_SUCCESS; |
89 | 100 | // Get state of hierarchy |
@@ -104,29 +115,31 @@ discard block |
||
104 | 115 | self::$backend->Setup(false); |
105 | 116 | |
106 | 117 | // there are unprocessed changes in the hierarchy, trigger resync |
107 | - if ($changesMem->GetChangeCount() > 0) |
|
108 | - throw new StatusException("HandleFolderChange() can not proceed as there are unprocessed hierarchy changes", SYNC_FSSTATUS_SERVERERROR); |
|
118 | + if ($changesMem->GetChangeCount() > 0) { |
|
119 | + throw new StatusException("HandleFolderChange() can not proceed as there are unprocessed hierarchy changes", SYNC_FSSTATUS_SERVERERROR); |
|
120 | + } |
|
109 | 121 | |
110 | 122 | // any additional folders can not be modified - with exception if they are of type SYNC_FOLDER_TYPE_UNKNOWN (ZP-907) |
111 | - if (self::$deviceManager->GetFolderTypeFromCacheById($serverid) != SYNC_FOLDER_TYPE_UNKNOWN && $serverid !== false && ZPush::GetAdditionalSyncFolderStore($backendid)) |
|
112 | - throw new StatusException("HandleFolderChange() can not change additional folders which are configured", SYNC_FSSTATUS_SYSTEMFOLDER); |
|
123 | + if (self::$deviceManager->GetFolderTypeFromCacheById($serverid) != SYNC_FOLDER_TYPE_UNKNOWN && $serverid !== false && ZPush::GetAdditionalSyncFolderStore($backendid)) { |
|
124 | + throw new StatusException("HandleFolderChange() can not change additional folders which are configured", SYNC_FSSTATUS_SYSTEMFOLDER); |
|
125 | + } |
|
113 | 126 | |
114 | 127 | // switch user store if this this happens inside an additional folder |
115 | 128 | // if this is an additional folder the backend has to be setup correctly |
116 | 129 | // backend should also not be switched when type is SYNC_FOLDER_TYPE_UNKNOWN (ZP-1220) |
117 | - if (self::$deviceManager->GetFolderTypeFromCacheById($serverid) != SYNC_FOLDER_TYPE_UNKNOWN && !self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore((($parentBackendId != false) ? $parentBackendId : $backendid)))) |
|
118 | - throw new StatusException(sprintf("HandleFolderChange() could not Setup() the backend for folder id '%s'", (($parentBackendId != false) ? $parentBackendId : $backendid)), SYNC_FSSTATUS_SERVERERROR); |
|
119 | - } |
|
120 | - catch (StateNotFoundException $snfex) { |
|
130 | + if (self::$deviceManager->GetFolderTypeFromCacheById($serverid) != SYNC_FOLDER_TYPE_UNKNOWN && !self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore((($parentBackendId != false) ? $parentBackendId : $backendid)))) { |
|
131 | + throw new StatusException(sprintf("HandleFolderChange() could not Setup() the backend for folder id '%s'", (($parentBackendId != false) ? $parentBackendId : $backendid)), SYNC_FSSTATUS_SERVERERROR); |
|
132 | + } |
|
133 | + } catch (StateNotFoundException $snfex) { |
|
121 | 134 | $status = SYNC_FSSTATUS_SYNCKEYERROR; |
122 | - } |
|
123 | - catch (StatusException $stex) { |
|
135 | + } catch (StatusException $stex) { |
|
124 | 136 | $status = $stex->getCode(); |
125 | 137 | } |
126 | 138 | |
127 | 139 | // set $newsynckey in case of an error |
128 | - if (!isset($newsynckey)) |
|
129 | - $newsynckey = $synckey; |
|
140 | + if (!isset($newsynckey)) { |
|
141 | + $newsynckey = $synckey; |
|
142 | + } |
|
130 | 143 | |
131 | 144 | if ($status == SYNC_FSSTATUS_SUCCESS) { |
132 | 145 | try { |
@@ -154,13 +167,11 @@ discard block |
||
154 | 167 | if (!$delete) { |
155 | 168 | // when creating, $folder->serverid is false, and the returned id is already mapped by the backend |
156 | 169 | $folder = $changesMem->ImportFolderChange($folder); |
157 | - } |
|
158 | - else { |
|
170 | + } else { |
|
159 | 171 | // delete folder |
160 | 172 | $changesMem->ImportFolderDeletion($folder); |
161 | 173 | } |
162 | - } |
|
163 | - catch (StatusException $stex) { |
|
174 | + } catch (StatusException $stex) { |
|
164 | 175 | $status = $stex->getCode(); |
165 | 176 | } |
166 | 177 | } |
@@ -185,9 +196,7 @@ discard block |
||
185 | 196 | } |
186 | 197 | } |
187 | 198 | self::$encoder->endTag(); |
188 | - } |
|
189 | - |
|
190 | - elseif ($update) { |
|
199 | + } elseif ($update) { |
|
191 | 200 | self::$encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERUPDATE); |
192 | 201 | { |
193 | 202 | { |
@@ -201,9 +210,7 @@ discard block |
||
201 | 210 | } |
202 | 211 | } |
203 | 212 | self::$encoder->endTag(); |
204 | - } |
|
205 | - |
|
206 | - elseif ($delete) { |
|
213 | + } elseif ($delete) { |
|
207 | 214 | self::$encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERDELETE); |
208 | 215 | { |
209 | 216 | { |
@@ -19,13 +19,13 @@ |
||
19 | 19 | */ |
20 | 20 | public function Handle($commandCode) { |
21 | 21 | // Parse input |
22 | - if(!self::$decoder->getElementStartTag(SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS)) |
|
22 | + if (!self::$decoder->getElementStartTag(SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS)) |
|
23 | 23 | return false; |
24 | 24 | |
25 | 25 | $resolveRecipients = new SyncResolveRecipients(); |
26 | 26 | $resolveRecipients->Decode(self::$decoder); |
27 | 27 | |
28 | - if(!self::$decoder->getElementEndTag()) |
|
28 | + if (!self::$decoder->getElementEndTag()) |
|
29 | 29 | return false; // SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS |
30 | 30 | |
31 | 31 | $resolveRecipients = self::$backend->ResolveRecipients($resolveRecipients); |
@@ -19,14 +19,17 @@ |
||
19 | 19 | */ |
20 | 20 | public function Handle($commandCode) { |
21 | 21 | // Parse input |
22 | - if(!self::$decoder->getElementStartTag(SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS)) |
|
23 | - return false; |
|
22 | + if(!self::$decoder->getElementStartTag(SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS)) { |
|
23 | + return false; |
|
24 | + } |
|
24 | 25 | |
25 | 26 | $resolveRecipients = new SyncResolveRecipients(); |
26 | 27 | $resolveRecipients->Decode(self::$decoder); |
27 | 28 | |
28 | - if(!self::$decoder->getElementEndTag()) |
|
29 | - return false; // SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS |
|
29 | + if(!self::$decoder->getElementEndTag()) { |
|
30 | + return false; |
|
31 | + } |
|
32 | + // SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS |
|
30 | 33 | |
31 | 34 | $resolveRecipients = self::$backend->ResolveRecipients($resolveRecipients); |
32 | 35 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | // the hierarchyCache should now fully be initialized - check for changes in the additional folders |
64 | 64 | $changesMem->Config(ZPush::GetAdditionalSyncFolders(false), ChangesMemoryWrapper::SYNCHRONIZING); |
65 | 65 | |
66 | - // reset to default store in backend |
|
66 | + // reset to default store in backend |
|
67 | 67 | self::$backend->Setup(false); |
68 | 68 | |
69 | 69 | // process incoming changes |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | catch (StatusException $stex) { |
120 | - $status = $stex->getCode(); |
|
120 | + $status = $stex->getCode(); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 |
@@ -17,21 +17,21 @@ discard block |
||
17 | 17 | * @access public |
18 | 18 | * @return boolean |
19 | 19 | */ |
20 | - public function Handle ($commandCode) { |
|
20 | + public function Handle($commandCode) { |
|
21 | 21 | // Parse input |
22 | - if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC)) |
|
22 | + if (!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC)) |
|
23 | 23 | return false; |
24 | 24 | |
25 | - if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) |
|
25 | + if (!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) |
|
26 | 26 | return false; |
27 | 27 | |
28 | 28 | $synckey = self::$decoder->getElementContent(); |
29 | 29 | |
30 | - if(!self::$decoder->getElementEndTag()) |
|
30 | + if (!self::$decoder->getElementEndTag()) |
|
31 | 31 | return false; |
32 | 32 | |
33 | 33 | // every FolderSync with SyncKey 0 should return the supported AS version & command headers |
34 | - if($synckey == "0") { |
|
34 | + if ($synckey == "0") { |
|
35 | 35 | self::$specialHeaders = array(); |
36 | 36 | self::$specialHeaders[] = ZPush::GetSupportedProtocolVersions(); |
37 | 37 | self::$specialHeaders[] = ZPush::GetSupportedCommands(); |
@@ -67,25 +67,25 @@ discard block |
||
67 | 67 | self::$backend->Setup(false); |
68 | 68 | |
69 | 69 | // process incoming changes |
70 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_CHANGES)) { |
|
70 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_CHANGES)) { |
|
71 | 71 | // Ignore <Count> if present |
72 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_COUNT)) { |
|
72 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_COUNT)) { |
|
73 | 73 | self::$decoder->getElementContent(); |
74 | - if(!self::$decoder->getElementEndTag()) |
|
74 | + if (!self::$decoder->getElementEndTag()) |
|
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
78 | 78 | // Process the changes (either <Add>, <Modify>, or <Remove>) |
79 | 79 | $element = self::$decoder->getElement(); |
80 | 80 | |
81 | - if($element[EN_TYPE] != EN_TYPE_STARTTAG) |
|
81 | + if ($element[EN_TYPE] != EN_TYPE_STARTTAG) |
|
82 | 82 | return false; |
83 | 83 | |
84 | 84 | $importer = false; |
85 | 85 | WBXMLDecoder::ResetInWhile("folderSyncIncomingChange"); |
86 | - while(WBXMLDecoder::InWhile("folderSyncIncomingChange")) { |
|
86 | + while (WBXMLDecoder::InWhile("folderSyncIncomingChange")) { |
|
87 | 87 | $folder = new SyncFolder(); |
88 | - if(!$folder->Decode(self::$decoder)) |
|
88 | + if (!$folder->Decode(self::$decoder)) |
|
89 | 89 | break; |
90 | 90 | |
91 | 91 | // add the backendId to the SyncFolder object |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | if ($status == SYNC_FSSTATUS_SUCCESS) { |
104 | - switch($element[EN_TAG]) { |
|
104 | + switch ($element[EN_TAG]) { |
|
105 | 105 | case SYNC_ADD: |
106 | 106 | case SYNC_MODIFY: |
107 | 107 | $serverid = $changesMem->ImportFolderChange($folder); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - if(!self::$decoder->getElementEndTag()) |
|
124 | + if (!self::$decoder->getElementEndTag()) |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | // no incoming changes |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - if(!self::$decoder->getElementEndTag()) |
|
136 | + if (!self::$decoder->getElementEndTag()) |
|
137 | 137 | return false; |
138 | 138 | |
139 | 139 | // We have processed incoming foldersync requests, now send the PIM |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | $totalChanges = $exporter->GetChangeCount(); |
162 | 162 | $exported = 0; |
163 | 163 | $partial = false; |
164 | - while(is_array($exporter->Synchronize())) { |
|
164 | + while (is_array($exporter->Synchronize())) { |
|
165 | 165 | $exported++; |
166 | 166 | |
167 | - if (time() % 4 ) { |
|
167 | + if (time() % 4) { |
|
168 | 168 | self::$topCollector->AnnounceInformation(sprintf("Exported %d from %d folders", $exported, $totalChanges)); |
169 | 169 | } |
170 | 170 | |
171 | 171 | // if partial sync is allowed, stop if this takes too long |
172 | 172 | if (USE_PARTIAL_FOLDERSYNC && Request::IsRequestTimeoutReached()) { |
173 | - ZLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): Exporting folders is too slow. In %d seconds only %d from %d changes were processed.",(time() - $_SERVER["REQUEST_TIME"]), $exported, $totalChanges)); |
|
173 | + ZLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): Exporting folders is too slow. In %d seconds only %d from %d changes were processed.", (time() - $_SERVER["REQUEST_TIME"]), $exported, $totalChanges)); |
|
174 | 174 | self::$topCollector->AnnounceInformation(sprintf("Partial export of %d out of %d folders", $exported, $totalChanges), true); |
175 | 175 | self::$deviceManager->SetFolderSyncComplete(false); |
176 | 176 | $partial = true; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // get the new state from the backend |
191 | - $newsyncstate = (isset($exporter))?$exporter->GetState():""; |
|
191 | + $newsyncstate = (isset($exporter)) ? $exporter->GetState() : ""; |
|
192 | 192 | } |
193 | 193 | catch (StatusException $stex) { |
194 | 194 | if ($stex->getCode() == SYNC_FSSTATUS_CODEUNKNOWN) |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | self::$encoder->startTag(SYNC_FOLDERHIERARCHY_COUNT); |
219 | 219 | self::$encoder->content($changeCount); |
220 | 220 | self::$encoder->endTag(); |
221 | - while($changesMem->Synchronize()); |
|
221 | + while ($changesMem->Synchronize()); |
|
222 | 222 | } |
223 | 223 | self::$encoder->endTag(); |
224 | - self::$topCollector->AnnounceInformation(sprintf("Outgoing %d folders",$changeCount), true); |
|
224 | + self::$topCollector->AnnounceInformation(sprintf("Outgoing %d folders", $changeCount), true); |
|
225 | 225 | |
226 | 226 | if ($changeCount == 0) { |
227 | 227 | self::$deviceManager->CheckFolderData(); |
@@ -19,16 +19,19 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function Handle ($commandCode) { |
21 | 21 | // Parse input |
22 | - if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC)) |
|
23 | - return false; |
|
22 | + if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC)) { |
|
23 | + return false; |
|
24 | + } |
|
24 | 25 | |
25 | - if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) |
|
26 | - return false; |
|
26 | + if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) { |
|
27 | + return false; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | $synckey = self::$decoder->getElementContent(); |
29 | 31 | |
30 | - if(!self::$decoder->getElementEndTag()) |
|
31 | - return false; |
|
32 | + if(!self::$decoder->getElementEndTag()) { |
|
33 | + return false; |
|
34 | + } |
|
32 | 35 | |
33 | 36 | // every FolderSync with SyncKey 0 should return the supported AS version & command headers |
34 | 37 | if($synckey == "0") { |
@@ -47,11 +50,9 @@ discard block |
||
47 | 50 | |
48 | 51 | // there are no SyncParameters for the hierarchy, but we use it to save the latest synckeys |
49 | 52 | $spa = self::$deviceManager->GetStateManager()->GetSynchedFolderState(false); |
50 | - } |
|
51 | - catch (StateNotFoundException $snfex) { |
|
53 | + } catch (StateNotFoundException $snfex) { |
|
52 | 54 | $status = SYNC_FSSTATUS_SYNCKEYERROR; |
53 | - } |
|
54 | - catch (StateInvalidException $sive) { |
|
55 | + } catch (StateInvalidException $sive) { |
|
55 | 56 | $status = SYNC_FSSTATUS_SYNCKEYERROR; |
56 | 57 | } |
57 | 58 | |
@@ -71,22 +72,25 @@ discard block |
||
71 | 72 | // Ignore <Count> if present |
72 | 73 | if(self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_COUNT)) { |
73 | 74 | self::$decoder->getElementContent(); |
74 | - if(!self::$decoder->getElementEndTag()) |
|
75 | - return false; |
|
75 | + if(!self::$decoder->getElementEndTag()) { |
|
76 | + return false; |
|
77 | + } |
|
76 | 78 | } |
77 | 79 | |
78 | 80 | // Process the changes (either <Add>, <Modify>, or <Remove>) |
79 | 81 | $element = self::$decoder->getElement(); |
80 | 82 | |
81 | - if($element[EN_TYPE] != EN_TYPE_STARTTAG) |
|
82 | - return false; |
|
83 | + if($element[EN_TYPE] != EN_TYPE_STARTTAG) { |
|
84 | + return false; |
|
85 | + } |
|
83 | 86 | |
84 | 87 | $importer = false; |
85 | 88 | WBXMLDecoder::ResetInWhile("folderSyncIncomingChange"); |
86 | 89 | while(WBXMLDecoder::InWhile("folderSyncIncomingChange")) { |
87 | 90 | $folder = new SyncFolder(); |
88 | - if(!$folder->Decode(self::$decoder)) |
|
89 | - break; |
|
91 | + if(!$folder->Decode(self::$decoder)) { |
|
92 | + break; |
|
93 | + } |
|
90 | 94 | |
91 | 95 | // add the backendId to the SyncFolder object |
92 | 96 | $folder->BackendId = self::$deviceManager->GetBackendIdForFolderId($folder->serverid); |
@@ -110,19 +114,18 @@ discard block |
||
110 | 114 | $serverid = $changesMem->ImportFolderDeletion($folder); |
111 | 115 | break; |
112 | 116 | } |
113 | - } |
|
114 | - else { |
|
117 | + } else { |
|
115 | 118 | ZLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): ignoring incoming folderchange for folder '%s' as status indicates problem.", $folder->displayname)); |
116 | 119 | self::$topCollector->AnnounceInformation("Incoming change ignored", true); |
117 | 120 | } |
118 | - } |
|
119 | - catch (StatusException $stex) { |
|
121 | + } catch (StatusException $stex) { |
|
120 | 122 | $status = $stex->getCode(); |
121 | 123 | } |
122 | 124 | } |
123 | 125 | |
124 | - if(!self::$decoder->getElementEndTag()) |
|
125 | - return false; |
|
126 | + if(!self::$decoder->getElementEndTag()) { |
|
127 | + return false; |
|
128 | + } |
|
126 | 129 | } |
127 | 130 | // no incoming changes |
128 | 131 | else { |
@@ -133,8 +136,9 @@ discard block |
||
133 | 136 | } |
134 | 137 | } |
135 | 138 | |
136 | - if(!self::$decoder->getElementEndTag()) |
|
137 | - return false; |
|
139 | + if(!self::$decoder->getElementEndTag()) { |
|
140 | + return false; |
|
141 | + } |
|
138 | 142 | |
139 | 143 | // We have processed incoming foldersync requests, now send the PIM |
140 | 144 | // our changes |
@@ -147,8 +151,9 @@ discard block |
||
147 | 151 | if ($status == SYNC_FSSTATUS_SUCCESS) { |
148 | 152 | try { |
149 | 153 | // do nothing if this is an invalid device id (like the 'validate' Androids internal client sends) |
150 | - if (!Request::IsValidDeviceID()) |
|
151 | - throw new StatusException(sprintf("Request::IsValidDeviceID() indicated that '%s' is not a valid device id", Request::GetDeviceID()), SYNC_FSSTATUS_SERVERERROR); |
|
154 | + if (!Request::IsValidDeviceID()) { |
|
155 | + throw new StatusException(sprintf("Request::IsValidDeviceID() indicated that '%s' is not a valid device id", Request::GetDeviceID()), SYNC_FSSTATUS_SERVERERROR); |
|
156 | + } |
|
152 | 157 | |
153 | 158 | // Changes from backend are sent to the MemImporter and processed for the HierarchyCache. |
154 | 159 | // The state which is saved is from the backend, as the MemImporter is only a proxy. |
@@ -189,12 +194,12 @@ discard block |
||
189 | 194 | |
190 | 195 | // get the new state from the backend |
191 | 196 | $newsyncstate = (isset($exporter))?$exporter->GetState():""; |
192 | - } |
|
193 | - catch (StatusException $stex) { |
|
194 | - if ($stex->getCode() == SYNC_FSSTATUS_CODEUNKNOWN) |
|
195 | - $status = SYNC_FSSTATUS_SYNCKEYERROR; |
|
196 | - else |
|
197 | - $status = $stex->getCode(); |
|
197 | + } catch (StatusException $stex) { |
|
198 | + if ($stex->getCode() == SYNC_FSSTATUS_CODEUNKNOWN) { |
|
199 | + $status = SYNC_FSSTATUS_SYNCKEYERROR; |
|
200 | + } else { |
|
201 | + $status = $stex->getCode(); |
|
202 | + } |
|
198 | 203 | } |
199 | 204 | } |
200 | 205 |
@@ -376,7 +376,7 @@ |
||
376 | 376 | self::$backend->EmptyFolder($operation['backendfolderid'], $operation['deletesubfolders']); |
377 | 377 | } |
378 | 378 | catch (StatusException $stex) { |
379 | - $status = $stex->getCode(); |
|
379 | + $status = $stex->getCode(); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | self::$encoder->startTag(SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS); |
@@ -20,38 +20,38 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function Handle($commandCode) { |
22 | 22 | // Parse input |
23 | - if(!self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_ITEMOPERATIONS)) |
|
23 | + if (!self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_ITEMOPERATIONS)) |
|
24 | 24 | return false; |
25 | 25 | |
26 | 26 | $itemoperations = array(); |
27 | 27 | //ItemOperations can either be Fetch, EmptyFolderContents or Move |
28 | 28 | WBXMLDecoder::ResetInWhile("itemOperationsActions"); |
29 | - while(WBXMLDecoder::InWhile("itemOperationsActions")) { |
|
29 | + while (WBXMLDecoder::InWhile("itemOperationsActions")) { |
|
30 | 30 | //TODO check if multiple item operations are possible in one request |
31 | 31 | $el = self::$decoder->getElement(); |
32 | 32 | |
33 | - if($el[EN_TYPE] != EN_TYPE_STARTTAG) |
|
33 | + if ($el[EN_TYPE] != EN_TYPE_STARTTAG) |
|
34 | 34 | return false; |
35 | 35 | |
36 | 36 | $fetch = $efc = $move = false; |
37 | 37 | $operation = array(); |
38 | - if($el[EN_TAG] == SYNC_ITEMOPERATIONS_FETCH) { |
|
38 | + if ($el[EN_TAG] == SYNC_ITEMOPERATIONS_FETCH) { |
|
39 | 39 | $fetch = true; |
40 | 40 | $operation['operation'] = SYNC_ITEMOPERATIONS_FETCH; |
41 | 41 | self::$topCollector->AnnounceInformation("Fetch", true); |
42 | 42 | } |
43 | - else if($el[EN_TAG] == SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS) { |
|
43 | + else if ($el[EN_TAG] == SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS) { |
|
44 | 44 | $efc = true; |
45 | 45 | $operation['operation'] = SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS; |
46 | 46 | self::$topCollector->AnnounceInformation("Empty Folder", true); |
47 | 47 | } |
48 | - else if($el[EN_TAG] == SYNC_ITEMOPERATIONS_MOVE) { |
|
48 | + else if ($el[EN_TAG] == SYNC_ITEMOPERATIONS_MOVE) { |
|
49 | 49 | $move = true; |
50 | 50 | $operation['operation'] = SYNC_ITEMOPERATIONS_MOVE; |
51 | 51 | self::$topCollector->AnnounceInformation("Move", true); |
52 | 52 | } |
53 | 53 | |
54 | - if(!$fetch && !$efc && !$move) { |
|
54 | + if (!$fetch && !$efc && !$move) { |
|
55 | 55 | ZLog::Write(LOGLEVEL_DEBUG, "Unknown item operation:".print_r($el, 1)); |
56 | 56 | self::$topCollector->AnnounceInformation("Unknown operation", true); |
57 | 57 | return false; |
@@ -59,42 +59,42 @@ discard block |
||
59 | 59 | |
60 | 60 | // process operation |
61 | 61 | WBXMLDecoder::ResetInWhile("itemOperationsOperation"); |
62 | - while(WBXMLDecoder::InWhile("itemOperationsOperation")) { |
|
62 | + while (WBXMLDecoder::InWhile("itemOperationsOperation")) { |
|
63 | 63 | if ($fetch) { |
64 | 64 | // Save all OPTIONS into a ContentParameters object |
65 | 65 | $operation["cpo"] = new ContentParameters(); |
66 | 66 | |
67 | - if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_STORE)) { |
|
67 | + if (self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_STORE)) { |
|
68 | 68 | $operation['store'] = self::$decoder->getElementContent(); |
69 | - if(!self::$decoder->getElementEndTag()) |
|
70 | - return false;//SYNC_ITEMOPERATIONS_STORE |
|
69 | + if (!self::$decoder->getElementEndTag()) |
|
70 | + return false; //SYNC_ITEMOPERATIONS_STORE |
|
71 | 71 | } |
72 | 72 | |
73 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_LONGID)) { |
|
73 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_LONGID)) { |
|
74 | 74 | $operation['longid'] = self::$decoder->getElementContent(); |
75 | - if(!self::$decoder->getElementEndTag()) |
|
76 | - return false;//SYNC_SEARCH_LONGID |
|
75 | + if (!self::$decoder->getElementEndTag()) |
|
76 | + return false; //SYNC_SEARCH_LONGID |
|
77 | 77 | } |
78 | 78 | |
79 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
|
79 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
|
80 | 80 | $operation['folderid'] = self::$decoder->getElementContent(); |
81 | - if(!self::$decoder->getElementEndTag()) |
|
82 | - return false;//SYNC_FOLDERID |
|
81 | + if (!self::$decoder->getElementEndTag()) |
|
82 | + return false; //SYNC_FOLDERID |
|
83 | 83 | } |
84 | 84 | |
85 | - if(self::$decoder->getElementStartTag(SYNC_SERVERENTRYID)) { |
|
85 | + if (self::$decoder->getElementStartTag(SYNC_SERVERENTRYID)) { |
|
86 | 86 | $operation['serverid'] = self::$decoder->getElementContent(); |
87 | - if(!self::$decoder->getElementEndTag()) |
|
88 | - return false;//SYNC_SERVERENTRYID |
|
87 | + if (!self::$decoder->getElementEndTag()) |
|
88 | + return false; //SYNC_SERVERENTRYID |
|
89 | 89 | } |
90 | 90 | |
91 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_FILEREFERENCE)) { |
|
91 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_FILEREFERENCE)) { |
|
92 | 92 | $operation['filereference'] = self::$decoder->getElementContent(); |
93 | - if(!self::$decoder->getElementEndTag()) |
|
94 | - return false;//SYNC_AIRSYNCBASE_FILEREFERENCE |
|
93 | + if (!self::$decoder->getElementEndTag()) |
|
94 | + return false; //SYNC_AIRSYNCBASE_FILEREFERENCE |
|
95 | 95 | } |
96 | 96 | |
97 | - if(($el = self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_OPTIONS)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
97 | + if (($el = self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_OPTIONS)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
98 | 98 | //TODO other options |
99 | 99 | //schema |
100 | 100 | //range |
@@ -104,36 +104,36 @@ discard block |
||
104 | 104 | //rm:RightsManagementSupport |
105 | 105 | |
106 | 106 | WBXMLDecoder::ResetInWhile("itemOperationsOptions"); |
107 | - while(WBXMLDecoder::InWhile("itemOperationsOptions")) { |
|
107 | + while (WBXMLDecoder::InWhile("itemOperationsOptions")) { |
|
108 | 108 | while (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODYPREFERENCE)) { |
109 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TYPE)) { |
|
109 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TYPE)) { |
|
110 | 110 | $bptype = self::$decoder->getElementContent(); |
111 | 111 | $operation["cpo"]->BodyPreference($bptype); |
112 | - if(!self::$decoder->getElementEndTag()) { |
|
112 | + if (!self::$decoder->getElementEndTag()) { |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
|
117 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
|
118 | 118 | $operation["cpo"]->BodyPreference($bptype)->SetTruncationSize(self::$decoder->getElementContent()); |
119 | - if(!self::$decoder->getElementEndTag()) |
|
119 | + if (!self::$decoder->getElementEndTag()) |
|
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | |
123 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
|
123 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
|
124 | 124 | $operation["cpo"]->BodyPreference($bptype)->SetAllOrNone(self::$decoder->getElementContent()); |
125 | - if(!self::$decoder->getElementEndTag()) |
|
125 | + if (!self::$decoder->getElementEndTag()) |
|
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
129 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
|
129 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
|
130 | 130 | $operation["cpo"]->BodyPreference($bptype)->SetPreview(self::$decoder->getElementContent()); |
131 | - if(!self::$decoder->getElementEndTag()) |
|
131 | + if (!self::$decoder->getElementEndTag()) |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
135 | - if(!self::$decoder->getElementEndTag()) |
|
136 | - return false;//SYNC_AIRSYNCBASE_BODYPREFERENCE |
|
135 | + if (!self::$decoder->getElementEndTag()) |
|
136 | + return false; //SYNC_AIRSYNCBASE_BODYPREFERENCE |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODYPARTPREFERENCE)) { |
@@ -147,19 +147,19 @@ discard block |
||
147 | 147 | |
148 | 148 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
149 | 149 | $operation["cpo"]->BodyPartPreference($bpptype)->SetTruncationSize(self::$decoder->getElementContent()); |
150 | - if(!self::$decoder->getElementEndTag()) |
|
150 | + if (!self::$decoder->getElementEndTag()) |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | 154 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
155 | 155 | $operation["cpo"]->BodyPartPreference($bpptype)->SetAllOrNone(self::$decoder->getElementContent()); |
156 | - if(!self::$decoder->getElementEndTag()) |
|
156 | + if (!self::$decoder->getElementEndTag()) |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
160 | 160 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
161 | 161 | $operation["cpo"]->BodyPartPreference($bpptype)->SetPreview(self::$decoder->getElementContent()); |
162 | - if(!self::$decoder->getElementEndTag()) |
|
162 | + if (!self::$decoder->getElementEndTag()) |
|
163 | 163 | return false; |
164 | 164 | } |
165 | 165 | |
@@ -167,41 +167,41 @@ discard block |
||
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | |
170 | - if(self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
|
170 | + if (self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
|
171 | 171 | $operation["cpo"]->SetMimeSupport(self::$decoder->getElementContent()); |
172 | - if(!self::$decoder->getElementEndTag()) |
|
172 | + if (!self::$decoder->getElementEndTag()) |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
176 | - if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_RANGE)) { |
|
176 | + if (self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_RANGE)) { |
|
177 | 177 | $operation["range"] = self::$decoder->getElementContent(); |
178 | - if(!self::$decoder->getElementEndTag()) |
|
178 | + if (!self::$decoder->getElementEndTag()) |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_SCHEMA)) { |
|
182 | + if (self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_SCHEMA)) { |
|
183 | 183 | // read schema tags |
184 | 184 | WBXMLDecoder::ResetInWhile("itemOperationsSchema"); |
185 | - while(WBXMLDecoder::InWhile("itemOperationsSchema")) { |
|
185 | + while (WBXMLDecoder::InWhile("itemOperationsSchema")) { |
|
186 | 186 | // TODO save elements |
187 | 187 | $el = self::$decoder->getElement(); |
188 | 188 | $e = self::$decoder->peek(); |
189 | - if($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
189 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
190 | 190 | self::$decoder->getElementEndTag(); |
191 | 191 | break; |
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - if(self::$decoder->getElementStartTag(SYNC_RIGHTSMANAGEMENT_SUPPORT)) { |
|
196 | + if (self::$decoder->getElementStartTag(SYNC_RIGHTSMANAGEMENT_SUPPORT)) { |
|
197 | 197 | $operation["cpo"]->SetRmSupport(self::$decoder->getElementContent()); |
198 | - if(!self::$decoder->getElementEndTag()) |
|
198 | + if (!self::$decoder->getElementEndTag()) |
|
199 | 199 | return false; |
200 | 200 | } |
201 | 201 | |
202 | 202 | //break if it reached the endtag |
203 | 203 | $e = self::$decoder->peek(); |
204 | - if($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
204 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
205 | 205 | self::$decoder->getElementEndTag(); |
206 | 206 | break; |
207 | 207 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $operation["cpo"]->SetRemoveRmProtection(true); |
213 | 213 | if (($rrmp = self::$decoder->getElementContent()) !== false) { |
214 | 214 | $operation["cpo"]->SetRemoveRmProtection($rrmp); |
215 | - if(!self::$decoder->getElementEndTag()) { |
|
215 | + if (!self::$decoder->getElementEndTag()) { |
|
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | } |
@@ -220,17 +220,17 @@ discard block |
||
220 | 220 | } // end if fetch |
221 | 221 | |
222 | 222 | if ($efc) { |
223 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
|
223 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
|
224 | 224 | $operation['folderid'] = self::$decoder->getElementContent(); |
225 | - if(!self::$decoder->getElementEndTag()) |
|
226 | - return false;//SYNC_FOLDERID |
|
225 | + if (!self::$decoder->getElementEndTag()) |
|
226 | + return false; //SYNC_FOLDERID |
|
227 | 227 | } |
228 | - if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_OPTIONS)) { |
|
229 | - if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_DELETESUBFOLDERS)) { |
|
228 | + if (self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_OPTIONS)) { |
|
229 | + if (self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_DELETESUBFOLDERS)) { |
|
230 | 230 | $operation['deletesubfolders'] = true; |
231 | 231 | if (($dsf = self::$decoder->getElementContent()) !== false) { |
232 | 232 | $operation['deletesubfolders'] = (bool)$dsf; |
233 | - if(!self::$decoder->getElementEndTag()) |
|
233 | + if (!self::$decoder->getElementEndTag()) |
|
234 | 234 | return false; |
235 | 235 | } |
236 | 236 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | //break if it reached the endtag SYNC_ITEMOPERATIONS_FETCH or SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS or SYNC_ITEMOPERATIONS_MOVE |
244 | 244 | $e = self::$decoder->peek(); |
245 | - if($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
245 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
246 | 246 | self::$decoder->getElementEndTag(); |
247 | 247 | break; |
248 | 248 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $itemoperations[] = $operation; |
257 | 257 | //break if it reached the endtag |
258 | 258 | $e = self::$decoder->peek(); |
259 | - if($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
259 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
260 | 260 | self::$decoder->getElementEndTag(); //SYNC_ITEMOPERATIONS_ITEMOPERATIONS |
261 | 261 | break; |
262 | 262 | } |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | |
271 | 271 | self::$encoder->startTag(SYNC_ITEMOPERATIONS_STATUS); |
272 | 272 | self::$encoder->content($status); |
273 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_STATUS |
|
273 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_STATUS |
|
274 | 274 | |
275 | 275 | // Stop here if something went wrong |
276 | 276 | if ($status != SYNC_ITEMOPERATIONSSTATUS_SUCCESS) { |
277 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_ITEMOPERATIONS |
|
277 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_ITEMOPERATIONS |
|
278 | 278 | return true; |
279 | 279 | } |
280 | 280 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | |
321 | 321 | self::$encoder->startTag(SYNC_ITEMOPERATIONS_STATUS); |
322 | 322 | self::$encoder->content($status); |
323 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_STATUS |
|
323 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_STATUS |
|
324 | 324 | |
325 | 325 | if (isset($operation['folderid']) && isset($operation['serverid'])) { |
326 | 326 | self::$encoder->startTag(SYNC_FOLDERID); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_PROPERTIES |
366 | 366 | } |
367 | 367 | |
368 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_FETCH |
|
368 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_FETCH |
|
369 | 369 | } |
370 | 370 | // empty folder contents operation |
371 | 371 | else if ($operation['operation'] == SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS) { |
@@ -383,14 +383,14 @@ discard block |
||
383 | 383 | |
384 | 384 | self::$encoder->startTag(SYNC_ITEMOPERATIONS_STATUS); |
385 | 385 | self::$encoder->content($status); |
386 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_STATUS |
|
386 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_STATUS |
|
387 | 387 | |
388 | 388 | if (isset($operation['folderid'])) { |
389 | 389 | self::$encoder->startTag(SYNC_FOLDERID); |
390 | 390 | self::$encoder->content($operation['folderid']); |
391 | 391 | self::$encoder->endTag(); // end SYNC_FOLDERID |
392 | 392 | } |
393 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS |
|
393 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS |
|
394 | 394 | } |
395 | 395 | // TODO implement ItemOperations Move |
396 | 396 | // move operation |
@@ -401,13 +401,13 @@ discard block |
||
401 | 401 | self::$encoder->startTag(SYNC_ITEMOPERATIONS_MOVE); |
402 | 402 | self::$encoder->startTag(SYNC_ITEMOPERATIONS_STATUS); |
403 | 403 | self::$encoder->content(SYNC_ITEMOPERATIONSSTATUS_SERVERERROR); |
404 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_STATUS |
|
405 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_MOVE |
|
404 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_STATUS |
|
405 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_MOVE |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | } |
409 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_RESPONSE |
|
410 | - self::$encoder->endTag();//SYNC_ITEMOPERATIONS_ITEMOPERATIONS |
|
409 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_RESPONSE |
|
410 | + self::$encoder->endTag(); //SYNC_ITEMOPERATIONS_ITEMOPERATIONS |
|
411 | 411 | |
412 | 412 | return true; |
413 | 413 | } |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function Handle($commandCode) { |
22 | 22 | // Parse input |
23 | - if(!self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_ITEMOPERATIONS)) |
|
24 | - return false; |
|
23 | + if(!self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_ITEMOPERATIONS)) { |
|
24 | + return false; |
|
25 | + } |
|
25 | 26 | |
26 | 27 | $itemoperations = array(); |
27 | 28 | //ItemOperations can either be Fetch, EmptyFolderContents or Move |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | //TODO check if multiple item operations are possible in one request |
31 | 32 | $el = self::$decoder->getElement(); |
32 | 33 | |
33 | - if($el[EN_TYPE] != EN_TYPE_STARTTAG) |
|
34 | - return false; |
|
34 | + if($el[EN_TYPE] != EN_TYPE_STARTTAG) { |
|
35 | + return false; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | $fetch = $efc = $move = false; |
37 | 39 | $operation = array(); |
@@ -39,13 +41,11 @@ discard block |
||
39 | 41 | $fetch = true; |
40 | 42 | $operation['operation'] = SYNC_ITEMOPERATIONS_FETCH; |
41 | 43 | self::$topCollector->AnnounceInformation("Fetch", true); |
42 | - } |
|
43 | - else if($el[EN_TAG] == SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS) { |
|
44 | + } else if($el[EN_TAG] == SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS) { |
|
44 | 45 | $efc = true; |
45 | 46 | $operation['operation'] = SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS; |
46 | 47 | self::$topCollector->AnnounceInformation("Empty Folder", true); |
47 | - } |
|
48 | - else if($el[EN_TAG] == SYNC_ITEMOPERATIONS_MOVE) { |
|
48 | + } else if($el[EN_TAG] == SYNC_ITEMOPERATIONS_MOVE) { |
|
49 | 49 | $move = true; |
50 | 50 | $operation['operation'] = SYNC_ITEMOPERATIONS_MOVE; |
51 | 51 | self::$topCollector->AnnounceInformation("Move", true); |
@@ -66,32 +66,42 @@ discard block |
||
66 | 66 | |
67 | 67 | if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_STORE)) { |
68 | 68 | $operation['store'] = self::$decoder->getElementContent(); |
69 | - if(!self::$decoder->getElementEndTag()) |
|
70 | - return false;//SYNC_ITEMOPERATIONS_STORE |
|
69 | + if(!self::$decoder->getElementEndTag()) { |
|
70 | + return false; |
|
71 | + } |
|
72 | + //SYNC_ITEMOPERATIONS_STORE |
|
71 | 73 | } |
72 | 74 | |
73 | 75 | if(self::$decoder->getElementStartTag(SYNC_SEARCH_LONGID)) { |
74 | 76 | $operation['longid'] = self::$decoder->getElementContent(); |
75 | - if(!self::$decoder->getElementEndTag()) |
|
76 | - return false;//SYNC_SEARCH_LONGID |
|
77 | + if(!self::$decoder->getElementEndTag()) { |
|
78 | + return false; |
|
79 | + } |
|
80 | + //SYNC_SEARCH_LONGID |
|
77 | 81 | } |
78 | 82 | |
79 | 83 | if(self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
80 | 84 | $operation['folderid'] = self::$decoder->getElementContent(); |
81 | - if(!self::$decoder->getElementEndTag()) |
|
82 | - return false;//SYNC_FOLDERID |
|
85 | + if(!self::$decoder->getElementEndTag()) { |
|
86 | + return false; |
|
87 | + } |
|
88 | + //SYNC_FOLDERID |
|
83 | 89 | } |
84 | 90 | |
85 | 91 | if(self::$decoder->getElementStartTag(SYNC_SERVERENTRYID)) { |
86 | 92 | $operation['serverid'] = self::$decoder->getElementContent(); |
87 | - if(!self::$decoder->getElementEndTag()) |
|
88 | - return false;//SYNC_SERVERENTRYID |
|
93 | + if(!self::$decoder->getElementEndTag()) { |
|
94 | + return false; |
|
95 | + } |
|
96 | + //SYNC_SERVERENTRYID |
|
89 | 97 | } |
90 | 98 | |
91 | 99 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_FILEREFERENCE)) { |
92 | 100 | $operation['filereference'] = self::$decoder->getElementContent(); |
93 | - if(!self::$decoder->getElementEndTag()) |
|
94 | - return false;//SYNC_AIRSYNCBASE_FILEREFERENCE |
|
101 | + if(!self::$decoder->getElementEndTag()) { |
|
102 | + return false; |
|
103 | + } |
|
104 | + //SYNC_AIRSYNCBASE_FILEREFERENCE |
|
95 | 105 | } |
96 | 106 | |
97 | 107 | if(($el = self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_OPTIONS)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
@@ -116,24 +126,29 @@ discard block |
||
116 | 126 | |
117 | 127 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
118 | 128 | $operation["cpo"]->BodyPreference($bptype)->SetTruncationSize(self::$decoder->getElementContent()); |
119 | - if(!self::$decoder->getElementEndTag()) |
|
120 | - return false; |
|
129 | + if(!self::$decoder->getElementEndTag()) { |
|
130 | + return false; |
|
131 | + } |
|
121 | 132 | } |
122 | 133 | |
123 | 134 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
124 | 135 | $operation["cpo"]->BodyPreference($bptype)->SetAllOrNone(self::$decoder->getElementContent()); |
125 | - if(!self::$decoder->getElementEndTag()) |
|
126 | - return false; |
|
136 | + if(!self::$decoder->getElementEndTag()) { |
|
137 | + return false; |
|
138 | + } |
|
127 | 139 | } |
128 | 140 | |
129 | 141 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
130 | 142 | $operation["cpo"]->BodyPreference($bptype)->SetPreview(self::$decoder->getElementContent()); |
131 | - if(!self::$decoder->getElementEndTag()) |
|
132 | - return false; |
|
143 | + if(!self::$decoder->getElementEndTag()) { |
|
144 | + return false; |
|
145 | + } |
|
133 | 146 | } |
134 | 147 | |
135 | - if(!self::$decoder->getElementEndTag()) |
|
136 | - return false;//SYNC_AIRSYNCBASE_BODYPREFERENCE |
|
148 | + if(!self::$decoder->getElementEndTag()) { |
|
149 | + return false; |
|
150 | + } |
|
151 | + //SYNC_AIRSYNCBASE_BODYPREFERENCE |
|
137 | 152 | } |
138 | 153 | |
139 | 154 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODYPARTPREFERENCE)) { |
@@ -147,36 +162,42 @@ discard block |
||
147 | 162 | |
148 | 163 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
149 | 164 | $operation["cpo"]->BodyPartPreference($bpptype)->SetTruncationSize(self::$decoder->getElementContent()); |
150 | - if(!self::$decoder->getElementEndTag()) |
|
151 | - return false; |
|
165 | + if(!self::$decoder->getElementEndTag()) { |
|
166 | + return false; |
|
167 | + } |
|
152 | 168 | } |
153 | 169 | |
154 | 170 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
155 | 171 | $operation["cpo"]->BodyPartPreference($bpptype)->SetAllOrNone(self::$decoder->getElementContent()); |
156 | - if(!self::$decoder->getElementEndTag()) |
|
157 | - return false; |
|
172 | + if(!self::$decoder->getElementEndTag()) { |
|
173 | + return false; |
|
174 | + } |
|
158 | 175 | } |
159 | 176 | |
160 | 177 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
161 | 178 | $operation["cpo"]->BodyPartPreference($bpptype)->SetPreview(self::$decoder->getElementContent()); |
162 | - if(!self::$decoder->getElementEndTag()) |
|
163 | - return false; |
|
179 | + if(!self::$decoder->getElementEndTag()) { |
|
180 | + return false; |
|
181 | + } |
|
164 | 182 | } |
165 | 183 | |
166 | - if (!self::$decoder->getElementEndTag()) |
|
167 | - return false; |
|
184 | + if (!self::$decoder->getElementEndTag()) { |
|
185 | + return false; |
|
186 | + } |
|
168 | 187 | } |
169 | 188 | |
170 | 189 | if(self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
171 | 190 | $operation["cpo"]->SetMimeSupport(self::$decoder->getElementContent()); |
172 | - if(!self::$decoder->getElementEndTag()) |
|
173 | - return false; |
|
191 | + if(!self::$decoder->getElementEndTag()) { |
|
192 | + return false; |
|
193 | + } |
|
174 | 194 | } |
175 | 195 | |
176 | 196 | if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_RANGE)) { |
177 | 197 | $operation["range"] = self::$decoder->getElementContent(); |
178 | - if(!self::$decoder->getElementEndTag()) |
|
179 | - return false; |
|
198 | + if(!self::$decoder->getElementEndTag()) { |
|
199 | + return false; |
|
200 | + } |
|
180 | 201 | } |
181 | 202 | |
182 | 203 | if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_SCHEMA)) { |
@@ -195,8 +216,9 @@ discard block |
||
195 | 216 | |
196 | 217 | if(self::$decoder->getElementStartTag(SYNC_RIGHTSMANAGEMENT_SUPPORT)) { |
197 | 218 | $operation["cpo"]->SetRmSupport(self::$decoder->getElementContent()); |
198 | - if(!self::$decoder->getElementEndTag()) |
|
199 | - return false; |
|
219 | + if(!self::$decoder->getElementEndTag()) { |
|
220 | + return false; |
|
221 | + } |
|
200 | 222 | } |
201 | 223 | |
202 | 224 | //break if it reached the endtag |
@@ -222,16 +244,19 @@ discard block |
||
222 | 244 | if ($efc) { |
223 | 245 | if(self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
224 | 246 | $operation['folderid'] = self::$decoder->getElementContent(); |
225 | - if(!self::$decoder->getElementEndTag()) |
|
226 | - return false;//SYNC_FOLDERID |
|
247 | + if(!self::$decoder->getElementEndTag()) { |
|
248 | + return false; |
|
249 | + } |
|
250 | + //SYNC_FOLDERID |
|
227 | 251 | } |
228 | 252 | if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_OPTIONS)) { |
229 | 253 | if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_DELETESUBFOLDERS)) { |
230 | 254 | $operation['deletesubfolders'] = true; |
231 | 255 | if (($dsf = self::$decoder->getElementContent()) !== false) { |
232 | 256 | $operation['deletesubfolders'] = (bool)$dsf; |
233 | - if(!self::$decoder->getElementEndTag()) |
|
234 | - return false; |
|
257 | + if(!self::$decoder->getElementEndTag()) { |
|
258 | + return false; |
|
259 | + } |
|
235 | 260 | } |
236 | 261 | } |
237 | 262 | self::$decoder->getElementEndTag(); |
@@ -292,25 +317,21 @@ discard block |
||
292 | 317 | try { |
293 | 318 | self::$topCollector->AnnounceInformation("Get attachment data from backend with file reference"); |
294 | 319 | $data = self::$backend->GetAttachmentData($operation['filereference']); |
295 | - } |
|
296 | - catch (StatusException $stex) { |
|
320 | + } catch (StatusException $stex) { |
|
297 | 321 | $status = $stex->getCode(); |
298 | 322 | } |
299 | 323 | |
300 | - } |
|
301 | - else { |
|
324 | + } else { |
|
302 | 325 | try { |
303 | 326 | if (isset($operation['folderid']) && isset($operation['serverid'])) { |
304 | 327 | self::$topCollector->AnnounceInformation("Fetching data from backend with item and folder id"); |
305 | 328 | $data = self::$backend->Fetch($operation['backendfolderid'], $operation['serverid'], $operation["cpo"]); |
306 | - } |
|
307 | - else if (isset($operation['longid'])) { |
|
329 | + } else if (isset($operation['longid'])) { |
|
308 | 330 | self::$topCollector->AnnounceInformation("Fetching data from backend with long id"); |
309 | 331 | $tmp = explode(":", $operation['longid']); |
310 | 332 | $data = self::$backend->Fetch(self::$deviceManager->GetBackendIdForFolderId($tmp[0]), $tmp[1], $operation["cpo"]); |
311 | 333 | } |
312 | - } |
|
313 | - catch (StatusException $stex) { |
|
334 | + } catch (StatusException $stex) { |
|
314 | 335 | // the only option to return is that we could not retrieve it |
315 | 336 | $status = SYNC_ITEMOPERATIONSSTATUS_CONVERSIONFAILED; |
316 | 337 | } |
@@ -374,8 +395,7 @@ discard block |
||
374 | 395 | |
375 | 396 | // send request to backend |
376 | 397 | self::$backend->EmptyFolder($operation['backendfolderid'], $operation['deletesubfolders']); |
377 | - } |
|
378 | - catch (StatusException $stex) { |
|
398 | + } catch (StatusException $stex) { |
|
379 | 399 | $status = $stex->getCode(); |
380 | 400 | } |
381 | 401 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function Handle($commandCode) { |
21 | 21 | $attname = Request::GetGETAttachmentName(); |
22 | - if(!$attname) |
|
22 | + if (!$attname) |
|
23 | 23 | return false; |
24 | 24 | |
25 | 25 | try { |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | fclose($stream); |
38 | 38 | if ($l === false) |
39 | 39 | throw new FatalException("HandleGetAttachment(): fpassthru === false !!!"); |
40 | - self::$topCollector->AnnounceInformation(sprintf("Streamed %d KB attachment", round($l/1024)), true); |
|
41 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment with %d KB sent to mobile", round($l/1024))); |
|
40 | + self::$topCollector->AnnounceInformation(sprintf("Streamed %d KB attachment", round($l / 1024)), true); |
|
41 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment with %d KB sent to mobile", round($l / 1024))); |
|
42 | 42 | } |
43 | 43 | catch (StatusException $s) { |
44 | 44 | // StatusException already logged so we just need to pass it upwards to send a HTTP error |
@@ -19,8 +19,9 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function Handle($commandCode) { |
21 | 21 | $attname = Request::GetGETAttachmentName(); |
22 | - if(!$attname) |
|
23 | - return false; |
|
22 | + if(!$attname) { |
|
23 | + return false; |
|
24 | + } |
|
24 | 25 | |
25 | 26 | try { |
26 | 27 | $attachment = self::$backend->GetAttachmentData($attname); |
@@ -28,19 +29,20 @@ discard block |
||
28 | 29 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment stream from backend: %s", $stream)); |
29 | 30 | |
30 | 31 | // need to check for a resource here, as eg. feof('Error') === false and causing infinite loop in while! |
31 | - if (!is_resource($stream)) |
|
32 | - throw new StatusException(sprintf("HandleGetAttachment(): No stream resource returned by backend for attachment: %s", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT); |
|
32 | + if (!is_resource($stream)) { |
|
33 | + throw new StatusException(sprintf("HandleGetAttachment(): No stream resource returned by backend for attachment: %s", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | header("Content-Type: application/octet-stream"); |
35 | 37 | self::$topCollector->AnnounceInformation("Starting attachment streaming", true); |
36 | 38 | $l = fpassthru($stream); |
37 | 39 | fclose($stream); |
38 | - if ($l === false) |
|
39 | - throw new FatalException("HandleGetAttachment(): fpassthru === false !!!"); |
|
40 | + if ($l === false) { |
|
41 | + throw new FatalException("HandleGetAttachment(): fpassthru === false !!!"); |
|
42 | + } |
|
40 | 43 | self::$topCollector->AnnounceInformation(sprintf("Streamed %d KB attachment", round($l/1024)), true); |
41 | 44 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment with %d KB sent to mobile", round($l/1024))); |
42 | - } |
|
43 | - catch (StatusException $s) { |
|
45 | + } catch (StatusException $s) { |
|
44 | 46 | // StatusException already logged so we just need to pass it upwards to send a HTTP error |
45 | 47 | throw new HTTPReturnCodeException($s->getMessage(), HTTP_CODE_500, null, LOGLEVEL_DEBUG); |
46 | 48 | } |
@@ -138,7 +138,7 @@ |
||
138 | 138 | |
139 | 139 | //In AS 14 request only collectionid is sent, without class |
140 | 140 | if (! $spa->HasContentClass() && $spa->HasFolderId()) { |
141 | - try { |
|
141 | + try { |
|
142 | 142 | $spa->SetContentClass(self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId())); |
143 | 143 | } |
144 | 144 | catch (NoHierarchyCacheAvailableException $nhca) { |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | public function Handle($commandCode) { |
23 | 23 | $sc = new SyncCollections(); |
24 | 24 | |
25 | - if(!self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_GETITEMESTIMATE)) |
|
25 | + if (!self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_GETITEMESTIMATE)) |
|
26 | 26 | return false; |
27 | 27 | |
28 | - if(!self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERS)) |
|
28 | + if (!self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERS)) |
|
29 | 29 | return false; |
30 | 30 | |
31 | - while(self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDER)) { |
|
31 | + while (self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDER)) { |
|
32 | 32 | $spa = new SyncParameters(); |
33 | 33 | $spastatus = false; |
34 | 34 | |
35 | 35 | // read the folder properties |
36 | 36 | WBXMLDecoder::ResetInWhile("getItemEstimateFolders"); |
37 | - while(WBXMLDecoder::InWhile("getItemEstimateFolders")) { |
|
38 | - if(self::$decoder->getElementStartTag(SYNC_SYNCKEY)) { |
|
37 | + while (WBXMLDecoder::InWhile("getItemEstimateFolders")) { |
|
38 | + if (self::$decoder->getElementStartTag(SYNC_SYNCKEY)) { |
|
39 | 39 | try { |
40 | 40 | $spa->SetSyncKey(self::$decoder->getElementContent()); |
41 | 41 | } |
@@ -43,51 +43,51 @@ discard block |
||
43 | 43 | $spastatus = SYNC_GETITEMESTSTATUS_SYNCSTATENOTPRIMED; |
44 | 44 | } |
45 | 45 | |
46 | - if(!self::$decoder->getElementEndTag()) |
|
46 | + if (!self::$decoder->getElementEndTag()) |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | - elseif(self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERID)) { |
|
50 | + elseif (self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERID)) { |
|
51 | 51 | $fid = self::$decoder->getElementContent(); |
52 | 52 | $spa->SetFolderId($fid); |
53 | 53 | $spa->SetBackendFolderId(self::$deviceManager->GetBackendIdForFolderId($fid)); |
54 | 54 | |
55 | - if(!self::$decoder->getElementEndTag()) |
|
55 | + if (!self::$decoder->getElementEndTag()) |
|
56 | 56 | return false; |
57 | 57 | } |
58 | 58 | |
59 | 59 | // conversation mode requested |
60 | - elseif(self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) { |
|
60 | + elseif (self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) { |
|
61 | 61 | $spa->SetConversationMode(true); |
62 | - if(($conversationmode = self::$decoder->getElementContent()) !== false) { |
|
62 | + if (($conversationmode = self::$decoder->getElementContent()) !== false) { |
|
63 | 63 | $spa->SetConversationMode((bool)$conversationmode); |
64 | - if(!self::$decoder->getElementEndTag()) |
|
64 | + if (!self::$decoder->getElementEndTag()) |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | 69 | // get items estimate does not necessarily send the folder type |
70 | - elseif(self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERTYPE)) { |
|
70 | + elseif (self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERTYPE)) { |
|
71 | 71 | $spa->SetContentClass(self::$decoder->getElementContent()); |
72 | 72 | |
73 | - if(!self::$decoder->getElementEndTag()) |
|
73 | + if (!self::$decoder->getElementEndTag()) |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | |
77 | 77 | //TODO AS 2.5 and filtertype not set |
78 | - elseif(self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
|
78 | + elseif (self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
|
79 | 79 | $spa->SetFilterType(self::$decoder->getElementContent()); |
80 | 80 | |
81 | - if(!self::$decoder->getElementEndTag()) |
|
81 | + if (!self::$decoder->getElementEndTag()) |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | - while(self::$decoder->getElementStartTag(SYNC_OPTIONS)) { |
|
85 | + while (self::$decoder->getElementStartTag(SYNC_OPTIONS)) { |
|
86 | 86 | WBXMLDecoder::ResetInWhile("getItemEstimateOptions"); |
87 | - while(WBXMLDecoder::InWhile("getItemEstimateOptions")) { |
|
87 | + while (WBXMLDecoder::InWhile("getItemEstimateOptions")) { |
|
88 | 88 | $firstOption = true; |
89 | 89 | // foldertype definition |
90 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
|
90 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
|
91 | 91 | $foldertype = self::$decoder->getElementContent(); |
92 | 92 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetItemEstimate(): specified options block with foldertype '%s'", $foldertype)); |
93 | 93 | |
@@ -97,31 +97,31 @@ discard block |
||
97 | 97 | // set to synchronize all changes. The mobile could overwrite this value |
98 | 98 | $spa->SetFilterType(SYNC_FILTERTYPE_ALL); |
99 | 99 | |
100 | - if(!self::$decoder->getElementEndTag()) |
|
100 | + if (!self::$decoder->getElementEndTag()) |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | // if no foldertype is defined, use default cpo |
104 | - else if ($firstOption){ |
|
104 | + else if ($firstOption) { |
|
105 | 105 | $spa->UseCPO(); |
106 | 106 | // set to synchronize all changes. The mobile could overwrite this value |
107 | 107 | $spa->SetFilterType(SYNC_FILTERTYPE_ALL); |
108 | 108 | } |
109 | 109 | $firstOption = false; |
110 | 110 | |
111 | - if(self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
|
111 | + if (self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
|
112 | 112 | $spa->SetFilterType(self::$decoder->getElementContent()); |
113 | - if(!self::$decoder->getElementEndTag()) |
|
113 | + if (!self::$decoder->getElementEndTag()) |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
117 | - if(self::$decoder->getElementStartTag(SYNC_MAXITEMS)) { |
|
117 | + if (self::$decoder->getElementStartTag(SYNC_MAXITEMS)) { |
|
118 | 118 | $spa->SetWindowSize($maxitems = self::$decoder->getElementContent()); |
119 | - if(!self::$decoder->getElementEndTag()) |
|
119 | + if (!self::$decoder->getElementEndTag()) |
|
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | |
123 | 123 | $e = self::$decoder->peek(); |
124 | - if($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
124 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
125 | 125 | self::$decoder->getElementEndTag(); |
126 | 126 | break; |
127 | 127 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | $e = self::$decoder->peek(); |
132 | - if($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
132 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
133 | 133 | self::$decoder->getElementEndTag(); //SYNC_GETITEMESTIMATE_FOLDER |
134 | 134 | break; |
135 | 135 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // Process folder data |
138 | 138 | |
139 | 139 | //In AS 14 request only collectionid is sent, without class |
140 | - if (! $spa->HasContentClass() && $spa->HasFolderId()) { |
|
140 | + if (!$spa->HasContentClass() && $spa->HasFolderId()) { |
|
141 | 141 | try { |
142 | 142 | $spa->SetContentClass(self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId())); |
143 | 143 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | // compatibility mode AS 1.0 - get folderid which was sent during GetHierarchy() |
150 | - if (! $spa->HasFolderId() && $spa->HasContentClass()) { |
|
150 | + if (!$spa->HasFolderId() && $spa->HasContentClass()) { |
|
151 | 151 | $spa->SetFolderId(self::$deviceManager->GetFolderIdFromCacheByClass($spa->GetContentClass())); |
152 | 152 | } |
153 | 153 | |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_COLLECTIONINVALID); |
178 | 178 | } |
179 | 179 | |
180 | - self::$topCollector->AnnounceInformation("StateNotFoundException ". $sc->GetParameter($spa, "status"), true); |
|
180 | + self::$topCollector->AnnounceInformation("StateNotFoundException ".$sc->GetParameter($spa, "status"), true); |
|
181 | 181 | } |
182 | 182 | catch (StatusException $stex) { |
183 | 183 | if ($stex->getCode() == SYNC_GETITEMESTSTATUS_COLLECTIONINVALID) |
184 | 184 | $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_COLLECTIONINVALID); |
185 | 185 | else |
186 | 186 | $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_SYNCSTATENOTPRIMED); |
187 | - self::$topCollector->AnnounceInformation("StatusException ". $sc->GetParameter($spa, "status"), true); |
|
187 | + self::$topCollector->AnnounceInformation("StatusException ".$sc->GetParameter($spa, "status"), true); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | 191 | } |
192 | - if(!self::$decoder->getElementEndTag()) |
|
192 | + if (!self::$decoder->getElementEndTag()) |
|
193 | 193 | return false; //SYNC_GETITEMESTIMATE_FOLDERS |
194 | 194 | |
195 | - if(!self::$decoder->getElementEndTag()) |
|
195 | + if (!self::$decoder->getElementEndTag()) |
|
196 | 196 | return false; //SYNC_GETITEMESTIMATE_GETITEMESTIMATE |
197 | 197 | |
198 | 198 | self::$encoder->startWBXML(); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | $changes = $sc->GetChangedFolderIds(); |
211 | 211 | |
212 | - foreach($sc as $folderid => $spa) { |
|
212 | + foreach ($sc as $folderid => $spa) { |
|
213 | 213 | self::$encoder->startTag(SYNC_GETITEMESTIMATE_RESPONSE); |
214 | 214 | { |
215 | 215 | if ($sc->GetParameter($spa, "status")) |
@@ -22,11 +22,13 @@ discard block |
||
22 | 22 | public function Handle($commandCode) { |
23 | 23 | $sc = new SyncCollections(); |
24 | 24 | |
25 | - if(!self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_GETITEMESTIMATE)) |
|
26 | - return false; |
|
25 | + if(!self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_GETITEMESTIMATE)) { |
|
26 | + return false; |
|
27 | + } |
|
27 | 28 | |
28 | - if(!self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERS)) |
|
29 | - return false; |
|
29 | + if(!self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERS)) { |
|
30 | + return false; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | while(self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDER)) { |
32 | 34 | $spa = new SyncParameters(); |
@@ -38,22 +40,21 @@ discard block |
||
38 | 40 | if(self::$decoder->getElementStartTag(SYNC_SYNCKEY)) { |
39 | 41 | try { |
40 | 42 | $spa->SetSyncKey(self::$decoder->getElementContent()); |
41 | - } |
|
42 | - catch (StateInvalidException $siex) { |
|
43 | + } catch (StateInvalidException $siex) { |
|
43 | 44 | $spastatus = SYNC_GETITEMESTSTATUS_SYNCSTATENOTPRIMED; |
44 | 45 | } |
45 | 46 | |
46 | - if(!self::$decoder->getElementEndTag()) |
|
47 | - return false; |
|
48 | - } |
|
49 | - |
|
50 | - elseif(self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERID)) { |
|
47 | + if(!self::$decoder->getElementEndTag()) { |
|
48 | + return false; |
|
49 | + } |
|
50 | + } elseif(self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERID)) { |
|
51 | 51 | $fid = self::$decoder->getElementContent(); |
52 | 52 | $spa->SetFolderId($fid); |
53 | 53 | $spa->SetBackendFolderId(self::$deviceManager->GetBackendIdForFolderId($fid)); |
54 | 54 | |
55 | - if(!self::$decoder->getElementEndTag()) |
|
56 | - return false; |
|
55 | + if(!self::$decoder->getElementEndTag()) { |
|
56 | + return false; |
|
57 | + } |
|
57 | 58 | } |
58 | 59 | |
59 | 60 | // conversation mode requested |
@@ -61,8 +62,9 @@ discard block |
||
61 | 62 | $spa->SetConversationMode(true); |
62 | 63 | if(($conversationmode = self::$decoder->getElementContent()) !== false) { |
63 | 64 | $spa->SetConversationMode((bool)$conversationmode); |
64 | - if(!self::$decoder->getElementEndTag()) |
|
65 | - return false; |
|
65 | + if(!self::$decoder->getElementEndTag()) { |
|
66 | + return false; |
|
67 | + } |
|
66 | 68 | } |
67 | 69 | } |
68 | 70 | |
@@ -70,16 +72,18 @@ discard block |
||
70 | 72 | elseif(self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERTYPE)) { |
71 | 73 | $spa->SetContentClass(self::$decoder->getElementContent()); |
72 | 74 | |
73 | - if(!self::$decoder->getElementEndTag()) |
|
74 | - return false; |
|
75 | + if(!self::$decoder->getElementEndTag()) { |
|
76 | + return false; |
|
77 | + } |
|
75 | 78 | } |
76 | 79 | |
77 | 80 | //TODO AS 2.5 and filtertype not set |
78 | 81 | elseif(self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
79 | 82 | $spa->SetFilterType(self::$decoder->getElementContent()); |
80 | 83 | |
81 | - if(!self::$decoder->getElementEndTag()) |
|
82 | - return false; |
|
84 | + if(!self::$decoder->getElementEndTag()) { |
|
85 | + return false; |
|
86 | + } |
|
83 | 87 | } |
84 | 88 | |
85 | 89 | while(self::$decoder->getElementStartTag(SYNC_OPTIONS)) { |
@@ -97,8 +101,9 @@ discard block |
||
97 | 101 | // set to synchronize all changes. The mobile could overwrite this value |
98 | 102 | $spa->SetFilterType(SYNC_FILTERTYPE_ALL); |
99 | 103 | |
100 | - if(!self::$decoder->getElementEndTag()) |
|
101 | - return false; |
|
104 | + if(!self::$decoder->getElementEndTag()) { |
|
105 | + return false; |
|
106 | + } |
|
102 | 107 | } |
103 | 108 | // if no foldertype is defined, use default cpo |
104 | 109 | else if ($firstOption){ |
@@ -110,14 +115,16 @@ discard block |
||
110 | 115 | |
111 | 116 | if(self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
112 | 117 | $spa->SetFilterType(self::$decoder->getElementContent()); |
113 | - if(!self::$decoder->getElementEndTag()) |
|
114 | - return false; |
|
118 | + if(!self::$decoder->getElementEndTag()) { |
|
119 | + return false; |
|
120 | + } |
|
115 | 121 | } |
116 | 122 | |
117 | 123 | if(self::$decoder->getElementStartTag(SYNC_MAXITEMS)) { |
118 | 124 | $spa->SetWindowSize($maxitems = self::$decoder->getElementContent()); |
119 | - if(!self::$decoder->getElementEndTag()) |
|
120 | - return false; |
|
125 | + if(!self::$decoder->getElementEndTag()) { |
|
126 | + return false; |
|
127 | + } |
|
121 | 128 | } |
122 | 129 | |
123 | 130 | $e = self::$decoder->peek(); |
@@ -140,8 +147,7 @@ discard block |
||
140 | 147 | if (! $spa->HasContentClass() && $spa->HasFolderId()) { |
141 | 148 | try { |
142 | 149 | $spa->SetContentClass(self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId())); |
143 | - } |
|
144 | - catch (NoHierarchyCacheAvailableException $nhca) { |
|
150 | + } catch (NoHierarchyCacheAvailableException $nhca) { |
|
145 | 151 | $spastatus = SYNC_GETITEMESTSTATUS_COLLECTIONINVALID; |
146 | 152 | } |
147 | 153 | } |
@@ -156,44 +162,46 @@ discard block |
||
156 | 162 | if ($spastatus) { |
157 | 163 | // the CPO has a folder id now, so we can set the status |
158 | 164 | $sc->AddParameter($spa, "status", $spastatus); |
159 | - } |
|
160 | - else { |
|
165 | + } else { |
|
161 | 166 | try { |
162 | 167 | $sc->AddParameter($spa, "state", self::$deviceManager->GetStateManager()->GetSyncState($spa->GetSyncKey())); |
163 | 168 | |
164 | 169 | // if this is an additional folder the backend has to be setup correctly |
165 | - if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
166 | - throw new StatusException(sprintf("HandleGetItemEstimate() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_GETITEMESTSTATUS_COLLECTIONINVALID); |
|
167 | - } |
|
168 | - catch (StateNotFoundException $snfex) { |
|
170 | + if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) { |
|
171 | + throw new StatusException(sprintf("HandleGetItemEstimate() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_GETITEMESTSTATUS_COLLECTIONINVALID); |
|
172 | + } |
|
173 | + } catch (StateNotFoundException $snfex) { |
|
169 | 174 | // ok, the key is invalid. Question is, if the hierarchycache is still ok |
170 | 175 | //if not, we have to issue SYNC_GETITEMESTSTATUS_COLLECTIONINVALID which triggers a FolderSync |
171 | 176 | try { |
172 | 177 | self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId()); |
173 | 178 | // we got here, so the HierarchyCache is ok |
174 | 179 | $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_SYNCKKEYINVALID); |
175 | - } |
|
176 | - catch (NoHierarchyCacheAvailableException $nhca) { |
|
180 | + } catch (NoHierarchyCacheAvailableException $nhca) { |
|
177 | 181 | $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_COLLECTIONINVALID); |
178 | 182 | } |
179 | 183 | |
180 | 184 | self::$topCollector->AnnounceInformation("StateNotFoundException ". $sc->GetParameter($spa, "status"), true); |
181 | - } |
|
182 | - catch (StatusException $stex) { |
|
183 | - if ($stex->getCode() == SYNC_GETITEMESTSTATUS_COLLECTIONINVALID) |
|
184 | - $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_COLLECTIONINVALID); |
|
185 | - else |
|
186 | - $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_SYNCSTATENOTPRIMED); |
|
185 | + } catch (StatusException $stex) { |
|
186 | + if ($stex->getCode() == SYNC_GETITEMESTSTATUS_COLLECTIONINVALID) { |
|
187 | + $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_COLLECTIONINVALID); |
|
188 | + } else { |
|
189 | + $sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_SYNCSTATENOTPRIMED); |
|
190 | + } |
|
187 | 191 | self::$topCollector->AnnounceInformation("StatusException ". $sc->GetParameter($spa, "status"), true); |
188 | 192 | } |
189 | 193 | } |
190 | 194 | |
191 | 195 | } |
192 | - if(!self::$decoder->getElementEndTag()) |
|
193 | - return false; //SYNC_GETITEMESTIMATE_FOLDERS |
|
196 | + if(!self::$decoder->getElementEndTag()) { |
|
197 | + return false; |
|
198 | + } |
|
199 | + //SYNC_GETITEMESTIMATE_FOLDERS |
|
194 | 200 | |
195 | - if(!self::$decoder->getElementEndTag()) |
|
196 | - return false; //SYNC_GETITEMESTIMATE_GETITEMESTIMATE |
|
201 | + if(!self::$decoder->getElementEndTag()) { |
|
202 | + return false; |
|
203 | + } |
|
204 | + //SYNC_GETITEMESTIMATE_GETITEMESTIMATE |
|
197 | 205 | |
198 | 206 | self::$encoder->startWBXML(); |
199 | 207 | self::$encoder->startTag(SYNC_GETITEMESTIMATE_GETITEMESTIMATE); |
@@ -203,8 +211,7 @@ discard block |
||
203 | 211 | |
204 | 212 | try { |
205 | 213 | $sc->CountChanges(); |
206 | - } |
|
207 | - catch (StatusException $ste) { |
|
214 | + } catch (StatusException $ste) { |
|
208 | 215 | $status = SYNC_GETITEMESTSTATUS_COLLECTIONINVALID; |
209 | 216 | } |
210 | 217 | $changes = $sc->GetChangedFolderIds(); |
@@ -212,8 +219,9 @@ discard block |
||
212 | 219 | foreach($sc as $folderid => $spa) { |
213 | 220 | self::$encoder->startTag(SYNC_GETITEMESTIMATE_RESPONSE); |
214 | 221 | { |
215 | - if ($sc->GetParameter($spa, "status")) |
|
216 | - $status = $sc->GetParameter($spa, "status"); |
|
222 | + if ($sc->GetParameter($spa, "status")) { |
|
223 | + $status = $sc->GetParameter($spa, "status"); |
|
224 | + } |
|
217 | 225 | |
218 | 226 | self::$encoder->startTag(SYNC_GETITEMESTIMATE_STATUS); |
219 | 227 | self::$encoder->content($status); |
@@ -234,20 +242,23 @@ discard block |
||
234 | 242 | self::$encoder->content($changes[$folderid]); |
235 | 243 | self::$encoder->endTag(); |
236 | 244 | |
237 | - if ($changes[$folderid] > 0) |
|
238 | - self::$topCollector->AnnounceInformation(sprintf("%s %d changes", $spa->GetContentClass(), $changes[$folderid]), true); |
|
245 | + if ($changes[$folderid] > 0) { |
|
246 | + self::$topCollector->AnnounceInformation(sprintf("%s %d changes", $spa->GetContentClass(), $changes[$folderid]), true); |
|
247 | + } |
|
239 | 248 | |
240 | 249 | // update the device data to mark folders as complete when syncing with WM |
241 | - if ($changes[$folderid] == 0) |
|
242 | - self::$deviceManager->SetFolderSyncStatus($folderid, DeviceManager::FLD_SYNC_COMPLETED); |
|
250 | + if ($changes[$folderid] == 0) { |
|
251 | + self::$deviceManager->SetFolderSyncStatus($folderid, DeviceManager::FLD_SYNC_COMPLETED); |
|
252 | + } |
|
243 | 253 | } |
244 | 254 | } |
245 | 255 | self::$encoder->endTag(); |
246 | 256 | } |
247 | 257 | self::$encoder->endTag(); |
248 | 258 | } |
249 | - if (array_sum($changes) == 0) |
|
250 | - self::$topCollector->AnnounceInformation("No changes found", true); |
|
259 | + if (array_sum($changes) == 0) { |
|
260 | + self::$topCollector->AnnounceInformation("No changes found", true); |
|
261 | + } |
|
251 | 262 | } |
252 | 263 | self::$encoder->endTag(); |
253 | 264 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | self::$userIsAuthenticated = false; |
38 | 38 | |
39 | 39 | // when a certificate is sent, allow authentication only as the certificate owner |
40 | - if(defined("CERTIFICATE_OWNER_PARAMETER") && isset($_SERVER[CERTIFICATE_OWNER_PARAMETER]) && strtolower($_SERVER[CERTIFICATE_OWNER_PARAMETER]) != strtolower(Request::GetAuthUser())) |
|
40 | + if (defined("CERTIFICATE_OWNER_PARAMETER") && isset($_SERVER[CERTIFICATE_OWNER_PARAMETER]) && strtolower($_SERVER[CERTIFICATE_OWNER_PARAMETER]) != strtolower(Request::GetAuthUser())) |
|
41 | 41 | throw new AuthenticationRequiredException(sprintf("Access denied. Access is allowed only for the certificate owner '%s'", $_SERVER[CERTIFICATE_OWNER_PARAMETER])); |
42 | 42 | |
43 | 43 | if (Request::GetImpersonatedUser() && strcasecmp(Request::GetAuthUser(), Request::GetImpersonatedUser()) !== 0) { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | $backend = ZPush::GetBackend(); |
48 | - if($backend->Logon(Request::GetAuthUser(), Request::GetAuthDomain(), Request::GetAuthPassword()) == false) |
|
48 | + if ($backend->Logon(Request::GetAuthUser(), Request::GetAuthDomain(), Request::GetAuthPassword()) == false) |
|
49 | 49 | throw new AuthenticationRequiredException("Access denied. Username or password incorrect"); |
50 | 50 | |
51 | 51 | // mark this request as "authenticated" |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | } |
100 | 100 | catch (Exception $ex) { |
101 | 101 | // Log 10 KB of the WBXML data |
102 | - ZLog::Write(LOGLEVEL_FATAL, "WBXML 10K debug data: " . Request::GetInputAsBase64(10240), false); |
|
102 | + ZLog::Write(LOGLEVEL_FATAL, "WBXML 10K debug data: ".Request::GetInputAsBase64(10240), false); |
|
103 | 103 | throw $ex; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // also log WBXML in happy case |
107 | 107 | if (ZLog::IsWbxmlDebugEnabled()) { |
108 | 108 | // Log 4 KB in the happy case |
109 | - ZLog::Write(LOGLEVEL_WBXML, "WBXML-IN : ". Request::GetInputAsBase64(4096), false); |
|
109 | + ZLog::Write(LOGLEVEL_WBXML, "WBXML-IN : ".Request::GetInputAsBase64(4096), false); |
|
110 | 110 | } |
111 | 111 | return true; |
112 | 112 | } |
@@ -37,16 +37,18 @@ discard block |
||
37 | 37 | self::$userIsAuthenticated = false; |
38 | 38 | |
39 | 39 | // when a certificate is sent, allow authentication only as the certificate owner |
40 | - if(defined("CERTIFICATE_OWNER_PARAMETER") && isset($_SERVER[CERTIFICATE_OWNER_PARAMETER]) && strtolower($_SERVER[CERTIFICATE_OWNER_PARAMETER]) != strtolower(Request::GetAuthUser())) |
|
41 | - throw new AuthenticationRequiredException(sprintf("Access denied. Access is allowed only for the certificate owner '%s'", $_SERVER[CERTIFICATE_OWNER_PARAMETER])); |
|
40 | + if(defined("CERTIFICATE_OWNER_PARAMETER") && isset($_SERVER[CERTIFICATE_OWNER_PARAMETER]) && strtolower($_SERVER[CERTIFICATE_OWNER_PARAMETER]) != strtolower(Request::GetAuthUser())) { |
|
41 | + throw new AuthenticationRequiredException(sprintf("Access denied. Access is allowed only for the certificate owner '%s'", $_SERVER[CERTIFICATE_OWNER_PARAMETER])); |
|
42 | + } |
|
42 | 43 | |
43 | 44 | if (Request::GetImpersonatedUser() && strcasecmp(Request::GetAuthUser(), Request::GetImpersonatedUser()) !== 0) { |
44 | 45 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("RequestProcessor->Authenticate(): Impersonation active - authenticating: '%s' - impersonating '%s'", Request::GetAuthUser(), Request::GetImpersonatedUser())); |
45 | 46 | } |
46 | 47 | |
47 | 48 | $backend = ZPush::GetBackend(); |
48 | - if($backend->Logon(Request::GetAuthUser(), Request::GetAuthDomain(), Request::GetAuthPassword()) == false) |
|
49 | - throw new AuthenticationRequiredException("Access denied. Username or password incorrect"); |
|
49 | + if($backend->Logon(Request::GetAuthUser(), Request::GetAuthDomain(), Request::GetAuthPassword()) == false) { |
|
50 | + throw new AuthenticationRequiredException("Access denied. Username or password incorrect"); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | // mark this request as "authenticated" |
52 | 54 | self::$userIsAuthenticated = true; |
@@ -59,8 +61,9 @@ discard block |
||
59 | 61 | * @return boolean |
60 | 62 | */ |
61 | 63 | static public function isUserAuthenticated() { |
62 | - if (!isset(self::$userIsAuthenticated)) |
|
63 | - return false; |
|
64 | + if (!isset(self::$userIsAuthenticated)) { |
|
65 | + return false; |
|
66 | + } |
|
64 | 67 | return self::$userIsAuthenticated; |
65 | 68 | } |
66 | 69 | |
@@ -75,8 +78,9 @@ discard block |
||
75 | 78 | self::$deviceManager = ZPush::GetDeviceManager(false); |
76 | 79 | self::$topCollector = ZPush::GetTopCollector(); |
77 | 80 | |
78 | - if (!ZPush::CommandNeedsPlainInput(Request::GetCommandCode())) |
|
79 | - self::$decoder = new WBXMLDecoder(Request::GetInputStream()); |
|
81 | + if (!ZPush::CommandNeedsPlainInput(Request::GetCommandCode())) { |
|
82 | + self::$decoder = new WBXMLDecoder(Request::GetInputStream()); |
|
83 | + } |
|
80 | 84 | |
81 | 85 | self::$encoder = new WBXMLEncoder(Request::GetOutputStream(), Request::GetGETAcceptMultipart()); |
82 | 86 | self::$waitTime = 0; |
@@ -96,8 +100,7 @@ discard block |
||
96 | 100 | if (!$handler->Handle(Request::GetCommandCode())) { |
97 | 101 | throw new WBXMLException(sprintf("Unknown error in %s->Handle()", get_class($handler))); |
98 | 102 | } |
99 | - } |
|
100 | - catch (Exception $ex) { |
|
103 | + } catch (Exception $ex) { |
|
101 | 104 | // Log 10 KB of the WBXML data |
102 | 105 | ZLog::Write(LOGLEVEL_FATAL, "WBXML 10K debug data: " . Request::GetInputAsBase64(10240), false); |
103 | 106 | throw $ex; |
@@ -118,8 +121,9 @@ discard block |
||
118 | 121 | * @return array |
119 | 122 | */ |
120 | 123 | static public function GetSpecialHeaders() { |
121 | - if (!isset(self::$specialHeaders) || !is_array(self::$specialHeaders)) |
|
122 | - return array(); |
|
124 | + if (!isset(self::$specialHeaders) || !is_array(self::$specialHeaders)) { |
|
125 | + return array(); |
|
126 | + } |
|
123 | 127 | |
124 | 128 | return self::$specialHeaders; |
125 | 129 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $sc->AddParameter($spa, "state", $this->importer->GetState()); |
524 | 524 | } |
525 | 525 | catch (StatusException $stex) { |
526 | - $status = $stex->getCode(); |
|
526 | + $status = $stex->getCode(); |
|
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
@@ -612,9 +612,9 @@ discard block |
||
612 | 612 | $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
613 | 613 | } |
614 | 614 | catch (StatusException $stex) { |
615 | - $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
|
616 | - self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
|
617 | - $this->saveMultiFolderInfo("exception", "StatusException"); |
|
615 | + $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
|
616 | + self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
|
617 | + $this->saveMultiFolderInfo("exception", "StatusException"); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | // update a few values |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | throw new StatusException(sprintf("HandleSync() could not get an exporter for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
817 | 817 | } |
818 | 818 | catch (StatusException $stex) { |
819 | - $status = $stex->getCode(); |
|
819 | + $status = $stex->getCode(); |
|
820 | 820 | } |
821 | 821 | try { |
822 | 822 | // Stream the messages directly to the PDA |
@@ -1294,9 +1294,9 @@ discard block |
||
1294 | 1294 | $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
1295 | 1295 | } |
1296 | 1296 | catch (StatusException $stex) { |
1297 | - $status = $stex->getCode(); |
|
1298 | - self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
|
1299 | - $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
|
1297 | + $status = $stex->getCode(); |
|
1298 | + self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
|
1299 | + $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
|
1300 | 1300 | |
1301 | 1301 | } |
1302 | 1302 | } |
@@ -1344,7 +1344,7 @@ discard block |
||
1344 | 1344 | } |
1345 | 1345 | } |
1346 | 1346 | catch (StatusException $stex) { |
1347 | - $status = $stex->getCode(); |
|
1347 | + $status = $stex->getCode(); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | return $status; |
@@ -1473,7 +1473,7 @@ discard block |
||
1473 | 1473 | } |
1474 | 1474 | } |
1475 | 1475 | catch (StatusException $stex) { |
1476 | - $actiondata["statusids"][$clientid] = $stex->getCode(); |
|
1476 | + $actiondata["statusids"][$clientid] = $stex->getCode(); |
|
1477 | 1477 | } |
1478 | 1478 | break; |
1479 | 1479 | case SYNC_REMOVE: |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | // check if the hierarchySync was fully completed |
41 | 41 | if (USE_PARTIAL_FOLDERSYNC) { |
42 | - if (self::$deviceManager->GetFolderSyncComplete() === false) { |
|
42 | + if (self::$deviceManager->GetFolderSyncComplete() === false) { |
|
43 | 43 | ZLog::Write(LOGLEVEL_INFO, "Request->HandleSync(): Sync request aborted, as exporting of folders has not yet completed"); |
44 | 44 | self::$topCollector->AnnounceInformation("Aborted due incomplete folder sync", true); |
45 | 45 | $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | // Start Synchronize |
52 | - if(self::$decoder->getElementStartTag(SYNC_SYNCHRONIZE)) { |
|
52 | + if (self::$decoder->getElementStartTag(SYNC_SYNCHRONIZE)) { |
|
53 | 53 | |
54 | 54 | // AS 1.0 sends version information in WBXML |
55 | - if(self::$decoder->getElementStartTag(SYNC_VERSION)) { |
|
55 | + if (self::$decoder->getElementStartTag(SYNC_VERSION)) { |
|
56 | 56 | $sync_version = self::$decoder->getElementContent(); |
57 | 57 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("WBXML sync version: '%s'", $sync_version)); |
58 | - if(!self::$decoder->getElementEndTag()) |
|
58 | + if (!self::$decoder->getElementEndTag()) |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | // Check if Folders tag is empty (<Folders/>) and only sync if there are |
65 | 65 | // some folders in the request. See ZP-172 |
66 | 66 | $startTag = self::$decoder->getElementStartTag(SYNC_FOLDERS); |
67 | - if(isset($startTag[EN_FLAGS]) && $startTag[EN_FLAGS]) { |
|
68 | - while(self::$decoder->getElementStartTag(SYNC_FOLDER)) { |
|
67 | + if (isset($startTag[EN_FLAGS]) && $startTag[EN_FLAGS]) { |
|
68 | + while (self::$decoder->getElementStartTag(SYNC_FOLDER)) { |
|
69 | 69 | $actiondata = array(); |
70 | 70 | $actiondata["requested"] = true; |
71 | 71 | $actiondata["clientids"] = array(); |
@@ -83,19 +83,19 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | //for AS versions < 2.5 |
86 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
|
86 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
|
87 | 87 | $class = self::$decoder->getElementContent(); |
88 | 88 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Sync folder: '%s'", $class)); |
89 | 89 | |
90 | - if(!self::$decoder->getElementEndTag()) |
|
90 | + if (!self::$decoder->getElementEndTag()) |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | 94 | // SyncKey |
95 | - if(self::$decoder->getElementStartTag(SYNC_SYNCKEY)) { |
|
95 | + if (self::$decoder->getElementStartTag(SYNC_SYNCKEY)) { |
|
96 | 96 | $synckey = "0"; |
97 | 97 | if (($synckey = self::$decoder->getElementContent()) !== false) { |
98 | - if(!self::$decoder->getElementEndTag()) { |
|
98 | + if (!self::$decoder->getElementEndTag()) { |
|
99 | 99 | return false; |
100 | 100 | } |
101 | 101 | } |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | return false; |
105 | 105 | |
106 | 106 | // FolderId |
107 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
|
107 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
|
108 | 108 | $folderid = self::$decoder->getElementContent(); |
109 | 109 | |
110 | - if(!self::$decoder->getElementEndTag()) |
|
110 | + if (!self::$decoder->getElementEndTag()) |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | |
114 | 114 | // compatibility mode AS 1.0 - get folderid which was sent during GetHierarchy() |
115 | - if (! $folderid && $class) { |
|
115 | + if (!$folderid && $class) { |
|
116 | 116 | $folderid = self::$deviceManager->GetFolderIdFromCacheByClass($class); |
117 | 117 | } |
118 | 118 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | // TODO remove resync of folders |
124 | 124 | // this forces a resync of all states |
125 | - if (! $spa instanceof SyncParameters) |
|
125 | + if (!$spa instanceof SyncParameters) |
|
126 | 126 | throw new StateInvalidException("Saved state are not of type SyncParameters"); |
127 | 127 | |
128 | 128 | // new/resync requested |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $spa->SetContentClass($class); |
156 | 156 | |
157 | 157 | // Get class for as versions >= 12.0 |
158 | - if (! $spa->HasContentClass()) { |
|
158 | + if (!$spa->HasContentClass()) { |
|
159 | 159 | try { |
160 | 160 | $spa->SetContentClass(self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId())); |
161 | 161 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("GetFolderClassFromCacheByID from Device Manager: '%s' for id:'%s'", $spa->GetContentClass(), $spa->GetFolderId())); |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | ZLog::Write(LOGLEVEL_WARN, "Not possible to determine class of request. Request did not contain class and apparently there is an issue with the HierarchyCache."); |
177 | 177 | |
178 | 178 | // SUPPORTED properties |
179 | - if(($se = self::$decoder->getElementStartTag(SYNC_SUPPORTED)) !== false) { |
|
179 | + if (($se = self::$decoder->getElementStartTag(SYNC_SUPPORTED)) !== false) { |
|
180 | 180 | // ZP-481: LG phones send an empty supported tag, so only read the contents if available here |
181 | 181 | // if <Supported/> is received, it's as no supported fields would have been sent at all. |
182 | 182 | // unsure if this is the correct approach, or if in this case some default list should be used |
183 | 183 | if ($se[EN_FLAGS] & EN_FLAGS_CONTENT) { |
184 | 184 | $supfields = array(); |
185 | 185 | WBXMLDecoder::ResetInWhile("syncSupported"); |
186 | - while(WBXMLDecoder::InWhile("syncSupported")) { |
|
186 | + while (WBXMLDecoder::InWhile("syncSupported")) { |
|
187 | 187 | $el = self::$decoder->getElement(); |
188 | 188 | |
189 | - if($el[EN_TYPE] == EN_TYPE_ENDTAG) |
|
189 | + if ($el[EN_TYPE] == EN_TYPE_ENDTAG) |
|
190 | 190 | break; |
191 | 191 | else |
192 | 192 | $supfields[] = $el[EN_TAG]; |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | } |
197 | 197 | |
198 | 198 | // Deletes as moves can be an empty tag as well as have value |
199 | - if(self::$decoder->getElementStartTag(SYNC_DELETESASMOVES)) { |
|
199 | + if (self::$decoder->getElementStartTag(SYNC_DELETESASMOVES)) { |
|
200 | 200 | $spa->SetDeletesAsMoves(true); |
201 | 201 | if (($dam = self::$decoder->getElementContent()) !== false) { |
202 | 202 | $spa->SetDeletesAsMoves((bool)$dam); |
203 | - if(!self::$decoder->getElementEndTag()) { |
|
203 | + if (!self::$decoder->getElementEndTag()) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | // Get changes can be an empty tag as well as have value |
210 | 210 | // code block partly contributed by dw2412 |
211 | - if($starttag = self::$decoder->getElementStartTag(SYNC_GETCHANGES)) { |
|
211 | + if ($starttag = self::$decoder->getElementStartTag(SYNC_GETCHANGES)) { |
|
212 | 212 | $sc->AddParameter($spa, "getchanges", true); |
213 | 213 | if (($gc = self::$decoder->getElementContent()) !== false) { |
214 | 214 | $sc->AddParameter($spa, "getchanges", $gc); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | - if(self::$decoder->getElementStartTag(SYNC_WINDOWSIZE)) { |
|
224 | + if (self::$decoder->getElementStartTag(SYNC_WINDOWSIZE)) { |
|
225 | 225 | $ws = self::$decoder->getElementContent(); |
226 | 226 | // normalize windowsize - see ZP-477 |
227 | 227 | if ($ws == 0 || $ws > WINDOW_SIZE_MAX) |
@@ -232,16 +232,16 @@ discard block |
||
232 | 232 | // also announce the currently requested window size to the DeviceManager |
233 | 233 | self::$deviceManager->SetWindowSize($spa->GetFolderId(), $spa->GetWindowSize()); |
234 | 234 | |
235 | - if(!self::$decoder->getElementEndTag()) |
|
235 | + if (!self::$decoder->getElementEndTag()) |
|
236 | 236 | return false; |
237 | 237 | } |
238 | 238 | |
239 | 239 | // conversation mode requested |
240 | - if(self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) { |
|
240 | + if (self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) { |
|
241 | 241 | $spa->SetConversationMode(true); |
242 | - if(($conversationmode = self::$decoder->getElementContent()) !== false) { |
|
242 | + if (($conversationmode = self::$decoder->getElementContent()) !== false) { |
|
243 | 243 | $spa->SetConversationMode((bool)$conversationmode); |
244 | - if(!self::$decoder->getElementEndTag()) |
|
244 | + if (!self::$decoder->getElementEndTag()) |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | } |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | // save the current filtertype because it might have been changed on the mobile |
256 | 256 | $currentFilterType = $spa->GetFilterType(); |
257 | 257 | |
258 | - while(self::$decoder->getElementStartTag(SYNC_OPTIONS)) { |
|
258 | + while (self::$decoder->getElementStartTag(SYNC_OPTIONS)) { |
|
259 | 259 | $firstOption = true; |
260 | 260 | WBXMLDecoder::ResetInWhile("syncOptions"); |
261 | - while(WBXMLDecoder::InWhile("syncOptions")) { |
|
261 | + while (WBXMLDecoder::InWhile("syncOptions")) { |
|
262 | 262 | // foldertype definition |
263 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
|
263 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
|
264 | 264 | $foldertype = self::$decoder->getElementContent(); |
265 | 265 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): specified options block with foldertype '%s'", $foldertype)); |
266 | 266 | |
@@ -273,11 +273,11 @@ discard block |
||
273 | 273 | // set to synchronize all changes. The mobile could overwrite this value |
274 | 274 | $spa->SetFilterType(SYNC_FILTERTYPE_ALL); |
275 | 275 | |
276 | - if(!self::$decoder->getElementEndTag()) |
|
276 | + if (!self::$decoder->getElementEndTag()) |
|
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | // if no foldertype is defined, use default cpo |
280 | - else if ($firstOption){ |
|
280 | + else if ($firstOption) { |
|
281 | 281 | $spa->UseCPO(); |
282 | 282 | // save the current filtertype because it might have been changed on the mobile |
283 | 283 | $currentFilterType = $spa->GetFilterType(); |
@@ -286,68 +286,68 @@ discard block |
||
286 | 286 | } |
287 | 287 | $firstOption = false; |
288 | 288 | |
289 | - if(self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
|
289 | + if (self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
|
290 | 290 | $spa->SetFilterType(self::$decoder->getElementContent()); |
291 | - if(!self::$decoder->getElementEndTag()) |
|
291 | + if (!self::$decoder->getElementEndTag()) |
|
292 | 292 | return false; |
293 | 293 | } |
294 | - if(self::$decoder->getElementStartTag(SYNC_TRUNCATION)) { |
|
294 | + if (self::$decoder->getElementStartTag(SYNC_TRUNCATION)) { |
|
295 | 295 | $spa->SetTruncation(self::$decoder->getElementContent()); |
296 | - if(!self::$decoder->getElementEndTag()) |
|
296 | + if (!self::$decoder->getElementEndTag()) |
|
297 | 297 | return false; |
298 | 298 | } |
299 | - if(self::$decoder->getElementStartTag(SYNC_RTFTRUNCATION)) { |
|
299 | + if (self::$decoder->getElementStartTag(SYNC_RTFTRUNCATION)) { |
|
300 | 300 | $spa->SetRTFTruncation(self::$decoder->getElementContent()); |
301 | - if(!self::$decoder->getElementEndTag()) |
|
301 | + if (!self::$decoder->getElementEndTag()) |
|
302 | 302 | return false; |
303 | 303 | } |
304 | 304 | |
305 | - if(self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
|
305 | + if (self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
|
306 | 306 | $spa->SetMimeSupport(self::$decoder->getElementContent()); |
307 | - if(!self::$decoder->getElementEndTag()) |
|
307 | + if (!self::$decoder->getElementEndTag()) |
|
308 | 308 | return false; |
309 | 309 | } |
310 | 310 | |
311 | - if(self::$decoder->getElementStartTag(SYNC_MIMETRUNCATION)) { |
|
311 | + if (self::$decoder->getElementStartTag(SYNC_MIMETRUNCATION)) { |
|
312 | 312 | $spa->SetMimeTruncation(self::$decoder->getElementContent()); |
313 | - if(!self::$decoder->getElementEndTag()) |
|
313 | + if (!self::$decoder->getElementEndTag()) |
|
314 | 314 | return false; |
315 | 315 | } |
316 | 316 | |
317 | - if(self::$decoder->getElementStartTag(SYNC_CONFLICT)) { |
|
317 | + if (self::$decoder->getElementStartTag(SYNC_CONFLICT)) { |
|
318 | 318 | $spa->SetConflict(self::$decoder->getElementContent()); |
319 | - if(!self::$decoder->getElementEndTag()) |
|
319 | + if (!self::$decoder->getElementEndTag()) |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | 323 | while (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODYPREFERENCE)) { |
324 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TYPE)) { |
|
324 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TYPE)) { |
|
325 | 325 | $bptype = self::$decoder->getElementContent(); |
326 | 326 | $spa->BodyPreference($bptype); |
327 | - if(!self::$decoder->getElementEndTag()) { |
|
327 | + if (!self::$decoder->getElementEndTag()) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
|
332 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
|
333 | 333 | $spa->BodyPreference($bptype)->SetTruncationSize(self::$decoder->getElementContent()); |
334 | - if(!self::$decoder->getElementEndTag()) |
|
334 | + if (!self::$decoder->getElementEndTag()) |
|
335 | 335 | return false; |
336 | 336 | } |
337 | 337 | |
338 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
|
338 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
|
339 | 339 | $spa->BodyPreference($bptype)->SetAllOrNone(self::$decoder->getElementContent()); |
340 | - if(!self::$decoder->getElementEndTag()) |
|
340 | + if (!self::$decoder->getElementEndTag()) |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | |
344 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
|
344 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
|
345 | 345 | $spa->BodyPreference($bptype)->SetPreview(self::$decoder->getElementContent()); |
346 | - if(!self::$decoder->getElementEndTag()) |
|
346 | + if (!self::$decoder->getElementEndTag()) |
|
347 | 347 | return false; |
348 | 348 | } |
349 | 349 | |
350 | - if(!self::$decoder->getElementEndTag()) |
|
350 | + if (!self::$decoder->getElementEndTag()) |
|
351 | 351 | return false; |
352 | 352 | } |
353 | 353 | |
@@ -362,19 +362,19 @@ discard block |
||
362 | 362 | |
363 | 363 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
364 | 364 | $spa->BodyPartPreference($bpptype)->SetTruncationSize(self::$decoder->getElementContent()); |
365 | - if(!self::$decoder->getElementEndTag()) |
|
365 | + if (!self::$decoder->getElementEndTag()) |
|
366 | 366 | return false; |
367 | 367 | } |
368 | 368 | |
369 | 369 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
370 | 370 | $spa->BodyPartPreference($bpptype)->SetAllOrNone(self::$decoder->getElementContent()); |
371 | - if(!self::$decoder->getElementEndTag()) |
|
371 | + if (!self::$decoder->getElementEndTag()) |
|
372 | 372 | return false; |
373 | 373 | } |
374 | 374 | |
375 | 375 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
376 | 376 | $spa->BodyPartPreference($bpptype)->SetPreview(self::$decoder->getElementContent()); |
377 | - if(!self::$decoder->getElementEndTag()) |
|
377 | + if (!self::$decoder->getElementEndTag()) |
|
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | } |
390 | 390 | |
391 | 391 | $e = self::$decoder->peek(); |
392 | - if($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
392 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
393 | 393 | self::$decoder->getElementEndTag(); |
394 | 394 | break; |
395 | 395 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | ZLog::Write(LOGLEVEL_DEBUG, "HierarchyCache is also not available. Triggering HierarchySync to device"); |
416 | 416 | } |
417 | 417 | |
418 | - if(($el = self::$decoder->getElementStartTag(SYNC_PERFORM)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
418 | + if (($el = self::$decoder->getElementStartTag(SYNC_PERFORM)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
419 | 419 | // We can not proceed here as the content class is unknown |
420 | 420 | if ($status != SYNC_STATUS_SUCCESS) { |
421 | 421 | ZLog::Write(LOGLEVEL_WARN, "Ignoring all incoming actions as global status indicates problem."); |
@@ -430,11 +430,11 @@ discard block |
||
430 | 430 | |
431 | 431 | $nchanges = 0; |
432 | 432 | WBXMLDecoder::ResetInWhile("syncActions"); |
433 | - while(WBXMLDecoder::InWhile("syncActions")) { |
|
433 | + while (WBXMLDecoder::InWhile("syncActions")) { |
|
434 | 434 | // ADD, MODIFY, REMOVE or FETCH |
435 | 435 | $element = self::$decoder->getElement(); |
436 | 436 | |
437 | - if($element[EN_TYPE] != EN_TYPE_STARTTAG) { |
|
437 | + if ($element[EN_TYPE] != EN_TYPE_STARTTAG) { |
|
438 | 438 | self::$decoder->ungetElement($element); |
439 | 439 | break; |
440 | 440 | } |
@@ -443,49 +443,49 @@ discard block |
||
443 | 443 | $nchanges++; |
444 | 444 | |
445 | 445 | // Foldertype sent when syncing SMS |
446 | - if(self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
|
446 | + if (self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
|
447 | 447 | $foldertype = self::$decoder->getElementContent(); |
448 | 448 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): incoming data with foldertype '%s'", $foldertype)); |
449 | 449 | |
450 | - if(!self::$decoder->getElementEndTag()) |
|
450 | + if (!self::$decoder->getElementEndTag()) |
|
451 | 451 | return false; |
452 | 452 | } |
453 | 453 | else |
454 | 454 | $foldertype = false; |
455 | 455 | |
456 | 456 | $serverid = false; |
457 | - if(self::$decoder->getElementStartTag(SYNC_SERVERENTRYID)) { |
|
457 | + if (self::$decoder->getElementStartTag(SYNC_SERVERENTRYID)) { |
|
458 | 458 | if (($serverid = self::$decoder->getElementContent()) !== false) { |
459 | - if(!self::$decoder->getElementEndTag()) { // end serverid |
|
459 | + if (!self::$decoder->getElementEndTag()) { // end serverid |
|
460 | 460 | return false; |
461 | 461 | } |
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | - if(self::$decoder->getElementStartTag(SYNC_CLIENTENTRYID)) { |
|
465 | + if (self::$decoder->getElementStartTag(SYNC_CLIENTENTRYID)) { |
|
466 | 466 | $clientid = self::$decoder->getElementContent(); |
467 | 467 | |
468 | - if(!self::$decoder->getElementEndTag()) // end clientid |
|
468 | + if (!self::$decoder->getElementEndTag()) // end clientid |
|
469 | 469 | return false; |
470 | 470 | } |
471 | 471 | else |
472 | 472 | $clientid = false; |
473 | 473 | |
474 | 474 | // Get the SyncMessage if sent |
475 | - if(($el = self::$decoder->getElementStartTag(SYNC_DATA)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
475 | + if (($el = self::$decoder->getElementStartTag(SYNC_DATA)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
476 | 476 | $message = ZPush::getSyncObjectFromFolderClass($spa->GetContentClass()); |
477 | 477 | $message->Decode(self::$decoder); |
478 | 478 | |
479 | 479 | // set Ghosted fields |
480 | 480 | $message->emptySupported(self::$deviceManager->GetSupportedFields($spa->GetFolderId())); |
481 | 481 | |
482 | - if(!self::$decoder->getElementEndTag()) // end applicationdata |
|
482 | + if (!self::$decoder->getElementEndTag()) // end applicationdata |
|
483 | 483 | return false; |
484 | 484 | } |
485 | 485 | else |
486 | 486 | $message = false; |
487 | 487 | |
488 | - switch($element[EN_TAG]) { |
|
488 | + switch ($element[EN_TAG]) { |
|
489 | 489 | case SYNC_FETCH: |
490 | 490 | array_push($actiondata["fetchids"], $serverid); |
491 | 491 | break; |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | else |
508 | 508 | self::$topCollector->AnnounceInformation(sprintf("Incoming %d", $nchanges)); |
509 | 509 | |
510 | - if(!self::$decoder->getElementEndTag()) // end add/change/delete/move |
|
510 | + if (!self::$decoder->getElementEndTag()) // end add/change/delete/move |
|
511 | 511 | return false; |
512 | 512 | } |
513 | 513 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
530 | - if(!self::$decoder->getElementEndTag()) // end PERFORM |
|
530 | + if (!self::$decoder->getElementEndTag()) // end PERFORM |
|
531 | 531 | return false; |
532 | 532 | } |
533 | 533 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | // save actiondata |
542 | 542 | $sc->AddParameter($spa, "actiondata", $actiondata); |
543 | 543 | |
544 | - if(!self::$decoder->getElementEndTag()) // end collection |
|
544 | + if (!self::$decoder->getElementEndTag()) // end collection |
|
545 | 545 | return false; |
546 | 546 | |
547 | 547 | // AS14 does not send GetChanges anymore. We should do it if there were no incoming changes |
@@ -549,19 +549,19 @@ discard block |
||
549 | 549 | $sc->AddParameter($spa, "getchanges", true); |
550 | 550 | } // END FOLDER |
551 | 551 | |
552 | - if(!$wbxmlproblem && !self::$decoder->getElementEndTag()) // end collections |
|
552 | + if (!$wbxmlproblem && !self::$decoder->getElementEndTag()) // end collections |
|
553 | 553 | return false; |
554 | 554 | } // end FOLDERS |
555 | 555 | |
556 | 556 | if (self::$decoder->getElementStartTag(SYNC_HEARTBEATINTERVAL)) { |
557 | 557 | $hbinterval = self::$decoder->getElementContent(); |
558 | - if(!self::$decoder->getElementEndTag()) // SYNC_HEARTBEATINTERVAL |
|
558 | + if (!self::$decoder->getElementEndTag()) // SYNC_HEARTBEATINTERVAL |
|
559 | 559 | return false; |
560 | 560 | } |
561 | 561 | |
562 | 562 | if (self::$decoder->getElementStartTag(SYNC_WAIT)) { |
563 | 563 | $wait = self::$decoder->getElementContent(); |
564 | - if(!self::$decoder->getElementEndTag()) // SYNC_WAIT |
|
564 | + if (!self::$decoder->getElementEndTag()) // SYNC_WAIT |
|
565 | 565 | return false; |
566 | 566 | |
567 | 567 | // internally the heartbeat interval and the wait time are the same |
@@ -571,17 +571,17 @@ discard block |
||
571 | 571 | |
572 | 572 | if (self::$decoder->getElementStartTag(SYNC_WINDOWSIZE)) { |
573 | 573 | $sc->SetGlobalWindowSize(self::$decoder->getElementContent()); |
574 | - ZLog::Write(LOGLEVEL_DEBUG, "Sync(): Global WindowSize requested: ". $sc->GetGlobalWindowSize()); |
|
575 | - if(!self::$decoder->getElementEndTag()) // SYNC_WINDOWSIZE |
|
574 | + ZLog::Write(LOGLEVEL_DEBUG, "Sync(): Global WindowSize requested: ".$sc->GetGlobalWindowSize()); |
|
575 | + if (!self::$decoder->getElementEndTag()) // SYNC_WINDOWSIZE |
|
576 | 576 | return false; |
577 | 577 | } |
578 | 578 | |
579 | - if(self::$decoder->getElementStartTag(SYNC_PARTIAL)) |
|
579 | + if (self::$decoder->getElementStartTag(SYNC_PARTIAL)) |
|
580 | 580 | $partial = true; |
581 | 581 | else |
582 | 582 | $partial = false; |
583 | 583 | |
584 | - if(!$wbxmlproblem && !self::$decoder->getElementEndTag()) // end sync |
|
584 | + if (!$wbxmlproblem && !self::$decoder->getElementEndTag()) // end sync |
|
585 | 585 | return false; |
586 | 586 | } |
587 | 587 | // we did not receive a SYNCHRONIZE block - assume empty sync |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | } |
600 | 600 | |
601 | 601 | // Partial & Empty Syncs need saved data to proceed with synchronization |
602 | - if ($status == SYNC_STATUS_SUCCESS && ($emptysync === true || $partial === true) ) { |
|
602 | + if ($status == SYNC_STATUS_SUCCESS && ($emptysync === true || $partial === true)) { |
|
603 | 603 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): Partial or Empty sync requested. Retrieving data of synchronized folders.")); |
604 | 604 | |
605 | 605 | // Load all collections - do not overwrite existing (received!), load states, check permissions and only load confirmed states! |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | } |
619 | 619 | |
620 | 620 | // update a few values |
621 | - foreach($sc as $folderid => $spa) { |
|
621 | + foreach ($sc as $folderid => $spa) { |
|
622 | 622 | // manually set getchanges parameter for this collection if it is synchronized |
623 | 623 | if ($spa->HasSyncKey()) { |
624 | 624 | $actiondata = $sc->GetParameter($spa, "actiondata"); |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | |
653 | 653 | // states are lazy loaded - we have to make sure that they are there! |
654 | 654 | $loadstatus = SYNC_STATUS_SUCCESS; |
655 | - foreach($sc as $folderid => $spa) { |
|
655 | + foreach ($sc as $folderid => $spa) { |
|
656 | 656 | // some androids do heartbeat on the OUTBOX folder, with weird results - ZP-362 |
657 | 657 | // we do not load the state so we will never get relevant changes on the OUTBOX folder |
658 | 658 | if (self::$deviceManager->GetFolderTypeFromCacheById($folderid) == SYNC_FOLDER_TYPE_OUTBOX) { |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | if (!$foundchanges && $status == SYNC_STATUS_SUCCESS) { |
694 | 694 | // if there were changes to the SPA or CPOs we need to save this before we terminate |
695 | 695 | // only save if the state was not modified by some other request, if so, return state invalid status |
696 | - foreach($sc as $folderid => $spa) { |
|
696 | + foreach ($sc as $folderid => $spa) { |
|
697 | 697 | if (self::$deviceManager->CheckHearbeatStateIntegrity($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter())) { |
698 | 698 | $status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID; |
699 | 699 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | } |
742 | 742 | |
743 | 743 | // Loop through requested folders |
744 | - foreach($sc as $folderid => $spa) { |
|
744 | + foreach ($sc as $folderid => $spa) { |
|
745 | 745 | // get actiondata |
746 | 746 | $actiondata = $sc->GetParameter($spa, "actiondata"); |
747 | 747 | |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | continue; |
751 | 751 | } |
752 | 752 | |
753 | - if (! $sc->GetParameter($spa, "requested")) { |
|
753 | + if (!$sc->GetParameter($spa, "requested")) { |
|
754 | 754 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): partial sync for folder class '%s' with id '%s'", $spa->GetContentClass(), $spa->GetFolderId())); |
755 | 755 | // reload state and initialize StateMachine correctly |
756 | 756 | $sc->AddParameter($spa, "state", null); |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | $setupExporter = true; |
766 | 766 | |
767 | 767 | // TODO we could check against $sc->GetChangedFolderIds() on heartbeat so we do not need to configure all exporter again |
768 | - if($status == SYNC_STATUS_SUCCESS && ($sc->GetParameter($spa, "getchanges") || ! $spa->HasSyncKey())) { |
|
768 | + if ($status == SYNC_STATUS_SUCCESS && ($sc->GetParameter($spa, "getchanges") || !$spa->HasSyncKey())) { |
|
769 | 769 | |
770 | 770 | // no need to run the exporter if the globalwindowsize is already full - if collection already has a synckey (ZP-1215) |
771 | 771 | if ($sc->GetGlobalWindowSize() == $this->globallyExportedItems && $spa->HasSyncKey()) { |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | elseif ($setupExporter && self::$backend->HasFolderStats()) { |
793 | 793 | // check if the folder stats changed -> if not, don't setup the exporter, there are no changes! |
794 | 794 | $newFolderStat = self::$backend->GetFolderStat(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()), $spa->GetBackendFolderId()); |
795 | - if ($newFolderStat !== false && ! $spa->IsExporterRunRequired($newFolderStat, true)) { |
|
795 | + if ($newFolderStat !== false && !$spa->IsExporterRunRequired($newFolderStat, true)) { |
|
796 | 796 | $changecount = 0; |
797 | 797 | $setupExporter = false; |
798 | 798 | } |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | //make sure the states are loaded |
804 | 804 | $status = $this->loadStates($sc, $spa, $actiondata); |
805 | 805 | |
806 | - if($status == SYNC_STATUS_SUCCESS) { |
|
806 | + if ($status == SYNC_STATUS_SUCCESS) { |
|
807 | 807 | try { |
808 | 808 | // if this is an additional folder the backend has to be setup correctly |
809 | 809 | if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | $status = $stex->getCode(); |
838 | 838 | } |
839 | 839 | |
840 | - if (! $spa->HasSyncKey()) { |
|
840 | + if (!$spa->HasSyncKey()) { |
|
841 | 841 | self::$topCollector->AnnounceInformation(sprintf("Exporter registered. %d objects queued.", $changecount), $this->singleFolder); |
842 | 842 | $this->saveMultiFolderInfo("queued", $changecount); |
843 | 843 | // update folder status as initialized |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | if (!empty($actiondata["modifyids"]) || |
861 | 861 | !empty($actiondata["clientids"]) || |
862 | 862 | !empty($actiondata["removeids"]) || |
863 | - (! $spa->HasSyncKey() && $status == SYNC_STATUS_SUCCESS)) { |
|
863 | + (!$spa->HasSyncKey() && $status == SYNC_STATUS_SUCCESS)) { |
|
864 | 864 | $spa->SetNewSyncKey(self::$deviceManager->GetStateManager()->GetNewSyncKey($spa->GetSyncKey())); |
865 | 865 | } |
866 | 866 | // get a new synckey only if we did not reach the global limit yet |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | } |
879 | 879 | |
880 | 880 | // Fir AS 14.0+ omit output for folder, if there were no incoming or outgoing changes and no Fetch |
881 | - if (Request::GetProtocolVersion() >= 14.0 && ! $spa->HasNewSyncKey() && $changecount == 0 && empty($actiondata["fetchids"]) && $status == SYNC_STATUS_SUCCESS && |
|
882 | - ! $spa->HasConfirmationChanged() && ($newFolderStat === false || ! $spa->IsExporterRunRequired($newFolderStat))) { |
|
881 | + if (Request::GetProtocolVersion() >= 14.0 && !$spa->HasNewSyncKey() && $changecount == 0 && empty($actiondata["fetchids"]) && $status == SYNC_STATUS_SUCCESS && |
|
882 | + !$spa->HasConfirmationChanged() && ($newFolderStat === false || !$spa->IsExporterRunRequired($newFolderStat))) { |
|
883 | 883 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync: No changes found for %s folder id '%s'. Omitting output.", $spa->GetContentClass(), $spa->GetFolderId())); |
884 | 884 | continue; |
885 | 885 | } |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | $this->sendFolderStartTag(); |
979 | 979 | self::$encoder->startTag(SYNC_FOLDER); |
980 | 980 | |
981 | - if($spa->HasContentClass()) { |
|
981 | + if ($spa->HasContentClass()) { |
|
982 | 982 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Folder type: %s", $spa->GetContentClass())); |
983 | 983 | // AS 12.0 devices require content class |
984 | 984 | if (Request::GetProtocolVersion() < 12.1) { |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | } |
990 | 990 | |
991 | 991 | self::$encoder->startTag(SYNC_SYNCKEY); |
992 | - if($status == SYNC_STATUS_SUCCESS && $spa->HasNewSyncKey()) |
|
992 | + if ($status == SYNC_STATUS_SUCCESS && $spa->HasNewSyncKey()) |
|
993 | 993 | self::$encoder->content($spa->GetNewSyncKey()); |
994 | 994 | else |
995 | 995 | self::$encoder->content($spa->GetSyncKey()); |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | self::$deviceManager->AnnounceProcessStatus($spa->GetFolderId(), $status); |
1009 | 1009 | |
1010 | 1010 | // Output IDs and status for incoming items & requests |
1011 | - if($status == SYNC_STATUS_SUCCESS && ( |
|
1011 | + if ($status == SYNC_STATUS_SUCCESS && ( |
|
1012 | 1012 | !empty($actiondata["clientids"]) || |
1013 | 1013 | !empty($actiondata["modifyids"]) || |
1014 | 1014 | !empty($actiondata["removeids"]) || |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | |
1017 | 1017 | self::$encoder->startTag(SYNC_REPLIES); |
1018 | 1018 | // output result of all new incoming items |
1019 | - foreach($actiondata["clientids"] as $clientid => $serverid) { |
|
1019 | + foreach ($actiondata["clientids"] as $clientid => $serverid) { |
|
1020 | 1020 | self::$encoder->startTag(SYNC_ADD); |
1021 | 1021 | self::$encoder->startTag(SYNC_CLIENTENTRYID); |
1022 | 1022 | self::$encoder->content($clientid); |
@@ -1027,13 +1027,13 @@ discard block |
||
1027 | 1027 | self::$encoder->endTag(); |
1028 | 1028 | } |
1029 | 1029 | self::$encoder->startTag(SYNC_STATUS); |
1030 | - self::$encoder->content((isset($actiondata["statusids"][$clientid])?$actiondata["statusids"][$clientid]:SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR)); |
|
1030 | + self::$encoder->content((isset($actiondata["statusids"][$clientid]) ? $actiondata["statusids"][$clientid] : SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR)); |
|
1031 | 1031 | self::$encoder->endTag(); |
1032 | 1032 | self::$encoder->endTag(); |
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | // loop through modify operations which were not a success, send status |
1036 | - foreach($actiondata["modifyids"] as $serverid) { |
|
1036 | + foreach ($actiondata["modifyids"] as $serverid) { |
|
1037 | 1037 | if (isset($actiondata["statusids"][$serverid]) && $actiondata["statusids"][$serverid] !== SYNC_STATUS_SUCCESS) { |
1038 | 1038 | self::$encoder->startTag(SYNC_MODIFY); |
1039 | 1039 | self::$encoder->startTag(SYNC_SERVERENTRYID); |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | // loop through remove operations which were not a success, send status |
1050 | - foreach($actiondata["removeids"] as $serverid) { |
|
1050 | + foreach ($actiondata["removeids"] as $serverid) { |
|
1051 | 1051 | if (isset($actiondata["statusids"][$serverid]) && $actiondata["statusids"][$serverid] !== SYNC_STATUS_SUCCESS) { |
1052 | 1052 | self::$encoder->startTag(SYNC_REMOVE); |
1053 | 1053 | self::$encoder->startTag(SYNC_SERVERENTRYID); |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | $this->saveMultiFolderInfo("fetching", count($actiondata["fetchids"])); |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - foreach($actiondata["fetchids"] as $id) { |
|
1068 | + foreach ($actiondata["fetchids"] as $id) { |
|
1069 | 1069 | $data = false; |
1070 | 1070 | try { |
1071 | 1071 | $fetchstatus = SYNC_STATUS_SUCCESS; |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | self::$encoder->content($fetchstatus); |
1096 | 1096 | self::$encoder->endTag(); |
1097 | 1097 | |
1098 | - if($data !== false && $status == SYNC_STATUS_SUCCESS) { |
|
1098 | + if ($data !== false && $status == SYNC_STATUS_SUCCESS) { |
|
1099 | 1099 | self::$encoder->startTag(SYNC_DATA); |
1100 | 1100 | $data->Encode(self::$encoder); |
1101 | 1101 | self::$encoder->endTag(); |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | self::$encoder->endTag(); |
1109 | 1109 | } |
1110 | 1110 | |
1111 | - if($sc->GetParameter($spa, "getchanges") && $spa->HasFolderId() && $spa->HasContentClass() && $spa->HasSyncKey()) { |
|
1111 | + if ($sc->GetParameter($spa, "getchanges") && $spa->HasFolderId() && $spa->HasContentClass() && $spa->HasSyncKey()) { |
|
1112 | 1112 | $moreAvailableSent = false; |
1113 | 1113 | $windowSize = self::$deviceManager->GetWindowSize($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter(), $changecount); |
1114 | 1114 | |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | } |
1121 | 1121 | // send <MoreAvailable/> if there are more changes than fit in the folder windowsize |
1122 | 1122 | // or there is a move state (another sync should be done afterwards) |
1123 | - if($changecount > $windowSize) { |
|
1123 | + if ($changecount > $windowSize) { |
|
1124 | 1124 | self::$encoder->startTag(SYNC_MOREAVAILABLE, false, true); |
1125 | 1125 | $moreAvailableSent = true; |
1126 | 1126 | $spa->DelFolderStat(); |
@@ -1128,22 +1128,22 @@ discard block |
||
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | // Stream outgoing changes |
1131 | - if($status == SYNC_STATUS_SUCCESS && $sc->GetParameter($spa, "getchanges") == true && $windowSize > 0 && !!$exporter) { |
|
1132 | - self::$topCollector->AnnounceInformation(sprintf("Streaming data of %d objects", (($changecount > $windowSize)?$windowSize:$changecount))); |
|
1131 | + if ($status == SYNC_STATUS_SUCCESS && $sc->GetParameter($spa, "getchanges") == true && $windowSize > 0 && !!$exporter) { |
|
1132 | + self::$topCollector->AnnounceInformation(sprintf("Streaming data of %d objects", (($changecount > $windowSize) ? $windowSize : $changecount))); |
|
1133 | 1133 | |
1134 | 1134 | // Output message changes per folder |
1135 | 1135 | self::$encoder->startTag(SYNC_PERFORM); |
1136 | 1136 | |
1137 | 1137 | $n = 0; |
1138 | 1138 | WBXMLDecoder::ResetInWhile("syncSynchronize"); |
1139 | - while(WBXMLDecoder::InWhile("syncSynchronize")) { |
|
1139 | + while (WBXMLDecoder::InWhile("syncSynchronize")) { |
|
1140 | 1140 | try { |
1141 | 1141 | $progress = $exporter->Synchronize(); |
1142 | - if(!is_array($progress)) |
|
1142 | + if (!is_array($progress)) |
|
1143 | 1143 | break; |
1144 | 1144 | $n++; |
1145 | 1145 | if ($n % 10 == 0) |
1146 | - self::$topCollector->AnnounceInformation(sprintf("Streamed data of %d objects out of %d", $n, (($changecount > $windowSize)?$windowSize:$changecount))); |
|
1146 | + self::$topCollector->AnnounceInformation(sprintf("Streamed data of %d objects out of %d", $n, (($changecount > $windowSize) ? $windowSize : $changecount))); |
|
1147 | 1147 | } |
1148 | 1148 | catch (SyncObjectBrokenException $mbe) { |
1149 | 1149 | $brokenSO = $mbe->GetSyncObject(); |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | } |
1169 | 1169 | } |
1170 | 1170 | |
1171 | - if($n >= $windowSize || Request::IsRequestTimeoutReached() || Request::IsRequestMemoryLimitReached()) { |
|
1171 | + if ($n >= $windowSize || Request::IsRequestTimeoutReached() || Request::IsRequestMemoryLimitReached()) { |
|
1172 | 1172 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): Exported maxItems of messages: %d / %d", $n, $changecount)); |
1173 | 1173 | break; |
1174 | 1174 | } |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | } |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - self::$topCollector->AnnounceInformation(sprintf("Outgoing %d objects%s", $n, ($n >= $windowSize)?" of ".$changecount:""), $this->singleFolder); |
|
1196 | + self::$topCollector->AnnounceInformation(sprintf("Outgoing %d objects%s", $n, ($n >= $windowSize) ? " of ".$changecount : ""), $this->singleFolder); |
|
1197 | 1197 | $this->saveMultiFolderInfo("outgoing", $n); |
1198 | 1198 | $this->saveMultiFolderInfo("queued", $changecount); |
1199 | 1199 | |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | self::$encoder->endTag(); |
1226 | 1226 | |
1227 | 1227 | // Save the sync state for the next time |
1228 | - if($spa->HasNewSyncKey()) { |
|
1228 | + if ($spa->HasNewSyncKey()) { |
|
1229 | 1229 | self::$topCollector->AnnounceInformation("Saving state"); |
1230 | 1230 | |
1231 | 1231 | try { |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | $state = $sc->GetParameter($spa, "state"); |
1239 | 1239 | |
1240 | 1240 | // if a new request without state information (hierarchy) save an empty state |
1241 | - else if (! $spa->HasSyncKey()) |
|
1241 | + else if (!$spa->HasSyncKey()) |
|
1242 | 1242 | $state = ""; |
1243 | 1243 | } |
1244 | 1244 | catch (StatusException $stex) { |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | $status = SYNC_STATUS_SUCCESS; |
1275 | 1275 | |
1276 | 1276 | if ($sc->GetParameter($spa, "state") == null) { |
1277 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("Sync->loadStates(): loading states for folder '%s'",$spa->GetFolderId())); |
|
1277 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("Sync->loadStates(): loading states for folder '%s'", $spa->GetFolderId())); |
|
1278 | 1278 | |
1279 | 1279 | try { |
1280 | 1280 | $sc->AddParameter($spa, "state", self::$deviceManager->GetStateManager()->GetSyncState($spa->GetSyncKey())); |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | } |
1409 | 1409 | |
1410 | 1410 | if (!$ignoreMessage) { |
1411 | - switch($todo) { |
|
1411 | + switch ($todo) { |
|
1412 | 1412 | case SYNC_MODIFY: |
1413 | 1413 | self::$topCollector->AnnounceInformation(sprintf("Saving modified message %d", $messageCount)); |
1414 | 1414 | try { |
@@ -1425,7 +1425,7 @@ discard block |
||
1425 | 1425 | $actiondata["statusids"][$serverid] = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR; |
1426 | 1426 | } |
1427 | 1427 | else { |
1428 | - if(isset($message->read)) { |
|
1428 | + if (isset($message->read)) { |
|
1429 | 1429 | // Currently, 'read' is only sent by the PDA when it is ONLY setting the read flag. |
1430 | 1430 | $this->importer->ImportMessageReadFlag($serverid, $message->read); |
1431 | 1431 | } |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | |
1436 | 1436 | // email todoflags - some devices send todos flags together with read flags, |
1437 | 1437 | // so they have to be handled separately |
1438 | - if (isset($message->flag)){ |
|
1438 | + if (isset($message->flag)) { |
|
1439 | 1439 | $this->importer->ImportMessageChange($serverid, $message); |
1440 | 1440 | } |
1441 | 1441 | |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | ZLog::Write(LOGLEVEL_DEBUG, "SMS sync are not supported. Ignoring message."); |
1459 | 1459 | // TODO we should create the SMS |
1460 | 1460 | // return a fake serverid which we can identify later |
1461 | - $actiondata["clientids"][$clientid] = self::ZPUSHIGNORESMS . $clientid; |
|
1461 | + $actiondata["clientids"][$clientid] = self::ZPUSHIGNORESMS.$clientid; |
|
1462 | 1462 | $actiondata["statusids"][$clientid] = SYNC_STATUS_SUCCESS; |
1463 | 1463 | } |
1464 | 1464 | // check incoming message without logging WARN messages about errors |
@@ -1488,10 +1488,10 @@ discard block |
||
1488 | 1488 | } |
1489 | 1489 | else { |
1490 | 1490 | // if message deletions are to be moved, move them |
1491 | - if($spa->GetDeletesAsMoves()) { |
|
1491 | + if ($spa->GetDeletesAsMoves()) { |
|
1492 | 1492 | $folderid = self::$backend->GetWasteBasket(); |
1493 | 1493 | |
1494 | - if($folderid) { |
|
1494 | + if ($folderid) { |
|
1495 | 1495 | $actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS; |
1496 | 1496 | $this->importer->ImportMessageMove($serverid, $folderid); |
1497 | 1497 | break; |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | } |
1506 | 1506 | } |
1507 | 1507 | catch (StatusException $stex) { |
1508 | - if($stex->getCode() != SYNC_MOVEITEMSSTATUS_SUCCESS) { |
|
1508 | + if ($stex->getCode() != SYNC_MOVEITEMSSTATUS_SUCCESS) { |
|
1509 | 1509 | $actiondata["statusids"][$serverid] = SYNC_STATUS_OBJECTNOTFOUND; |
1510 | 1510 | } |
1511 | 1511 | } |
@@ -1545,9 +1545,9 @@ discard block |
||
1545 | 1545 | * @return string |
1546 | 1546 | */ |
1547 | 1547 | private function getMultiFolderInfoLine($amountOfFolders) { |
1548 | - $s = $amountOfFolders . " folders"; |
|
1548 | + $s = $amountOfFolders." folders"; |
|
1549 | 1549 | if (isset($this->multiFolderInfo["incoming"])) { |
1550 | - $s .= ": ". $this->multiFolderInfo["incoming"] ." saved"; |
|
1550 | + $s .= ": ".$this->multiFolderInfo["incoming"]." saved"; |
|
1551 | 1551 | } |
1552 | 1552 | if (isset($this->multiFolderInfo["outgoing"]) && isset($this->multiFolderInfo["queued"]) && $this->multiFolderInfo["outgoing"] > 0) { |
1553 | 1553 | $s .= sprintf(": Streamed %d out of %d", $this->multiFolderInfo["outgoing"], $this->multiFolderInfo["queued"]); |
@@ -1557,10 +1557,10 @@ discard block |
||
1557 | 1557 | } |
1558 | 1558 | else { |
1559 | 1559 | if (isset($this->multiFolderInfo["outgoing"])) { |
1560 | - $s .= "/".$this->multiFolderInfo["outgoing"] ." streamed"; |
|
1560 | + $s .= "/".$this->multiFolderInfo["outgoing"]." streamed"; |
|
1561 | 1561 | } |
1562 | 1562 | if (isset($this->multiFolderInfo["queued"])) { |
1563 | - $s .= "/".$this->multiFolderInfo["queued"] ." queued"; |
|
1563 | + $s .= "/".$this->multiFolderInfo["queued"]." queued"; |
|
1564 | 1564 | } |
1565 | 1565 | } |
1566 | 1566 | if (isset($this->multiFolderInfo["exception"])) { |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | ZLog::Write(LOGLEVEL_INFO, "Request->HandleSync(): Sync request aborted, as exporting of folders has not yet completed"); |
44 | 44 | self::$topCollector->AnnounceInformation("Aborted due incomplete folder sync", true); |
45 | 45 | $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
46 | + } else { |
|
47 | + ZLog::Write(LOGLEVEL_INFO, "Request->HandleSync(): FolderSync marked as complete"); |
|
46 | 48 | } |
47 | - else |
|
48 | - ZLog::Write(LOGLEVEL_INFO, "Request->HandleSync(): FolderSync marked as complete"); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // Start Synchronize |
@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | if(self::$decoder->getElementStartTag(SYNC_VERSION)) { |
56 | 56 | $sync_version = self::$decoder->getElementContent(); |
57 | 57 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("WBXML sync version: '%s'", $sync_version)); |
58 | - if(!self::$decoder->getElementEndTag()) |
|
59 | - return false; |
|
58 | + if(!self::$decoder->getElementEndTag()) { |
|
59 | + return false; |
|
60 | + } |
|
60 | 61 | } |
61 | 62 | |
62 | 63 | // Syncing specified folders |
@@ -87,8 +88,9 @@ discard block |
||
87 | 88 | $class = self::$decoder->getElementContent(); |
88 | 89 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Sync folder: '%s'", $class)); |
89 | 90 | |
90 | - if(!self::$decoder->getElementEndTag()) |
|
91 | - return false; |
|
91 | + if(!self::$decoder->getElementEndTag()) { |
|
92 | + return false; |
|
93 | + } |
|
92 | 94 | } |
93 | 95 | |
94 | 96 | // SyncKey |
@@ -99,16 +101,17 @@ discard block |
||
99 | 101 | return false; |
100 | 102 | } |
101 | 103 | } |
104 | + } else { |
|
105 | + return false; |
|
102 | 106 | } |
103 | - else |
|
104 | - return false; |
|
105 | 107 | |
106 | 108 | // FolderId |
107 | 109 | if(self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
108 | 110 | $folderid = self::$decoder->getElementContent(); |
109 | 111 | |
110 | - if(!self::$decoder->getElementEndTag()) |
|
111 | - return false; |
|
112 | + if(!self::$decoder->getElementEndTag()) { |
|
113 | + return false; |
|
114 | + } |
|
112 | 115 | } |
113 | 116 | |
114 | 117 | // compatibility mode AS 1.0 - get folderid which was sent during GetHierarchy() |
@@ -122,24 +125,23 @@ discard block |
||
122 | 125 | |
123 | 126 | // TODO remove resync of folders |
124 | 127 | // this forces a resync of all states |
125 | - if (! $spa instanceof SyncParameters) |
|
126 | - throw new StateInvalidException("Saved state are not of type SyncParameters"); |
|
128 | + if (! $spa instanceof SyncParameters) { |
|
129 | + throw new StateInvalidException("Saved state are not of type SyncParameters"); |
|
130 | + } |
|
127 | 131 | |
128 | 132 | // new/resync requested |
129 | 133 | if ($synckey == "0") { |
130 | 134 | $spa->RemoveSyncKey(); |
131 | 135 | $spa->DelFolderStat(); |
132 | 136 | $spa->SetMoveState(false); |
133 | - } |
|
134 | - else if ($synckey !== false) { |
|
137 | + } else if ($synckey !== false) { |
|
135 | 138 | if ($synckey !== $spa->GetSyncKey() && $synckey !== $spa->GetNewSyncKey()) { |
136 | 139 | ZLog::Write(LOGLEVEL_DEBUG, "HandleSync(): Synckey does not match latest saved for this folder or there is a move state, removing folderstat to force Exporter setup"); |
137 | 140 | $spa->DelFolderStat(); |
138 | 141 | } |
139 | 142 | $spa->SetSyncKey($synckey); |
140 | 143 | } |
141 | - } |
|
142 | - catch (StateInvalidException $stie) { |
|
144 | + } catch (StateInvalidException $stie) { |
|
143 | 145 | $spa = new SyncParameters(); |
144 | 146 | $status = SYNC_STATUS_INVALIDSYNCKEY; |
145 | 147 | self::$topCollector->AnnounceInformation("State invalid - Resync folder", $this->singleFolder); |
@@ -151,16 +153,16 @@ discard block |
||
151 | 153 | $spa->SetFolderId($folderid); |
152 | 154 | $spa->SetBackendFolderId(self::$deviceManager->GetBackendIdForFolderId($folderid)); |
153 | 155 | |
154 | - if ($class !== false) |
|
155 | - $spa->SetContentClass($class); |
|
156 | + if ($class !== false) { |
|
157 | + $spa->SetContentClass($class); |
|
158 | + } |
|
156 | 159 | |
157 | 160 | // Get class for as versions >= 12.0 |
158 | 161 | if (! $spa->HasContentClass()) { |
159 | 162 | try { |
160 | 163 | $spa->SetContentClass(self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId())); |
161 | 164 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("GetFolderClassFromCacheByID from Device Manager: '%s' for id:'%s'", $spa->GetContentClass(), $spa->GetFolderId())); |
162 | - } |
|
163 | - catch (NoHierarchyCacheAvailableException $nhca) { |
|
165 | + } catch (NoHierarchyCacheAvailableException $nhca) { |
|
164 | 166 | $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
165 | 167 | self::$deviceManager->ForceFullResync(); |
166 | 168 | } |
@@ -170,10 +172,11 @@ discard block |
||
170 | 172 | $sc->AddCollection($spa); |
171 | 173 | $sc->AddParameter($spa, "requested", true); |
172 | 174 | |
173 | - if ($spa->HasContentClass()) |
|
174 | - self::$topCollector->AnnounceInformation(sprintf("%s request", $spa->GetContentClass()), $this->singleFolder); |
|
175 | - else |
|
176 | - ZLog::Write(LOGLEVEL_WARN, "Not possible to determine class of request. Request did not contain class and apparently there is an issue with the HierarchyCache."); |
|
175 | + if ($spa->HasContentClass()) { |
|
176 | + self::$topCollector->AnnounceInformation(sprintf("%s request", $spa->GetContentClass()), $this->singleFolder); |
|
177 | + } else { |
|
178 | + ZLog::Write(LOGLEVEL_WARN, "Not possible to determine class of request. Request did not contain class and apparently there is an issue with the HierarchyCache."); |
|
179 | + } |
|
177 | 180 | |
178 | 181 | // SUPPORTED properties |
179 | 182 | if(($se = self::$decoder->getElementStartTag(SYNC_SUPPORTED)) !== false) { |
@@ -186,10 +189,11 @@ discard block |
||
186 | 189 | while(WBXMLDecoder::InWhile("syncSupported")) { |
187 | 190 | $el = self::$decoder->getElement(); |
188 | 191 | |
189 | - if($el[EN_TYPE] == EN_TYPE_ENDTAG) |
|
190 | - break; |
|
191 | - else |
|
192 | - $supfields[] = $el[EN_TAG]; |
|
192 | + if($el[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
193 | + break; |
|
194 | + } else { |
|
195 | + $supfields[] = $el[EN_TAG]; |
|
196 | + } |
|
193 | 197 | } |
194 | 198 | self::$deviceManager->SetSupportedFields($spa->GetFolderId(), $supfields); |
195 | 199 | } |
@@ -224,16 +228,18 @@ discard block |
||
224 | 228 | if(self::$decoder->getElementStartTag(SYNC_WINDOWSIZE)) { |
225 | 229 | $ws = self::$decoder->getElementContent(); |
226 | 230 | // normalize windowsize - see ZP-477 |
227 | - if ($ws == 0 || $ws > WINDOW_SIZE_MAX) |
|
228 | - $ws = WINDOW_SIZE_MAX; |
|
231 | + if ($ws == 0 || $ws > WINDOW_SIZE_MAX) { |
|
232 | + $ws = WINDOW_SIZE_MAX; |
|
233 | + } |
|
229 | 234 | |
230 | 235 | $spa->SetWindowSize($ws); |
231 | 236 | |
232 | 237 | // also announce the currently requested window size to the DeviceManager |
233 | 238 | self::$deviceManager->SetWindowSize($spa->GetFolderId(), $spa->GetWindowSize()); |
234 | 239 | |
235 | - if(!self::$decoder->getElementEndTag()) |
|
236 | - return false; |
|
240 | + if(!self::$decoder->getElementEndTag()) { |
|
241 | + return false; |
|
242 | + } |
|
237 | 243 | } |
238 | 244 | |
239 | 245 | // conversation mode requested |
@@ -241,8 +247,9 @@ discard block |
||
241 | 247 | $spa->SetConversationMode(true); |
242 | 248 | if(($conversationmode = self::$decoder->getElementContent()) !== false) { |
243 | 249 | $spa->SetConversationMode((bool)$conversationmode); |
244 | - if(!self::$decoder->getElementEndTag()) |
|
245 | - return false; |
|
250 | + if(!self::$decoder->getElementEndTag()) { |
|
251 | + return false; |
|
252 | + } |
|
246 | 253 | } |
247 | 254 | } |
248 | 255 | |
@@ -273,8 +280,9 @@ discard block |
||
273 | 280 | // set to synchronize all changes. The mobile could overwrite this value |
274 | 281 | $spa->SetFilterType(SYNC_FILTERTYPE_ALL); |
275 | 282 | |
276 | - if(!self::$decoder->getElementEndTag()) |
|
277 | - return false; |
|
283 | + if(!self::$decoder->getElementEndTag()) { |
|
284 | + return false; |
|
285 | + } |
|
278 | 286 | } |
279 | 287 | // if no foldertype is defined, use default cpo |
280 | 288 | else if ($firstOption){ |
@@ -288,36 +296,42 @@ discard block |
||
288 | 296 | |
289 | 297 | if(self::$decoder->getElementStartTag(SYNC_FILTERTYPE)) { |
290 | 298 | $spa->SetFilterType(self::$decoder->getElementContent()); |
291 | - if(!self::$decoder->getElementEndTag()) |
|
292 | - return false; |
|
299 | + if(!self::$decoder->getElementEndTag()) { |
|
300 | + return false; |
|
301 | + } |
|
293 | 302 | } |
294 | 303 | if(self::$decoder->getElementStartTag(SYNC_TRUNCATION)) { |
295 | 304 | $spa->SetTruncation(self::$decoder->getElementContent()); |
296 | - if(!self::$decoder->getElementEndTag()) |
|
297 | - return false; |
|
305 | + if(!self::$decoder->getElementEndTag()) { |
|
306 | + return false; |
|
307 | + } |
|
298 | 308 | } |
299 | 309 | if(self::$decoder->getElementStartTag(SYNC_RTFTRUNCATION)) { |
300 | 310 | $spa->SetRTFTruncation(self::$decoder->getElementContent()); |
301 | - if(!self::$decoder->getElementEndTag()) |
|
302 | - return false; |
|
311 | + if(!self::$decoder->getElementEndTag()) { |
|
312 | + return false; |
|
313 | + } |
|
303 | 314 | } |
304 | 315 | |
305 | 316 | if(self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
306 | 317 | $spa->SetMimeSupport(self::$decoder->getElementContent()); |
307 | - if(!self::$decoder->getElementEndTag()) |
|
308 | - return false; |
|
318 | + if(!self::$decoder->getElementEndTag()) { |
|
319 | + return false; |
|
320 | + } |
|
309 | 321 | } |
310 | 322 | |
311 | 323 | if(self::$decoder->getElementStartTag(SYNC_MIMETRUNCATION)) { |
312 | 324 | $spa->SetMimeTruncation(self::$decoder->getElementContent()); |
313 | - if(!self::$decoder->getElementEndTag()) |
|
314 | - return false; |
|
325 | + if(!self::$decoder->getElementEndTag()) { |
|
326 | + return false; |
|
327 | + } |
|
315 | 328 | } |
316 | 329 | |
317 | 330 | if(self::$decoder->getElementStartTag(SYNC_CONFLICT)) { |
318 | 331 | $spa->SetConflict(self::$decoder->getElementContent()); |
319 | - if(!self::$decoder->getElementEndTag()) |
|
320 | - return false; |
|
332 | + if(!self::$decoder->getElementEndTag()) { |
|
333 | + return false; |
|
334 | + } |
|
321 | 335 | } |
322 | 336 | |
323 | 337 | while (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODYPREFERENCE)) { |
@@ -331,24 +345,28 @@ discard block |
||
331 | 345 | |
332 | 346 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
333 | 347 | $spa->BodyPreference($bptype)->SetTruncationSize(self::$decoder->getElementContent()); |
334 | - if(!self::$decoder->getElementEndTag()) |
|
335 | - return false; |
|
348 | + if(!self::$decoder->getElementEndTag()) { |
|
349 | + return false; |
|
350 | + } |
|
336 | 351 | } |
337 | 352 | |
338 | 353 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
339 | 354 | $spa->BodyPreference($bptype)->SetAllOrNone(self::$decoder->getElementContent()); |
340 | - if(!self::$decoder->getElementEndTag()) |
|
341 | - return false; |
|
355 | + if(!self::$decoder->getElementEndTag()) { |
|
356 | + return false; |
|
357 | + } |
|
342 | 358 | } |
343 | 359 | |
344 | 360 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
345 | 361 | $spa->BodyPreference($bptype)->SetPreview(self::$decoder->getElementContent()); |
346 | - if(!self::$decoder->getElementEndTag()) |
|
347 | - return false; |
|
362 | + if(!self::$decoder->getElementEndTag()) { |
|
363 | + return false; |
|
364 | + } |
|
348 | 365 | } |
349 | 366 | |
350 | - if(!self::$decoder->getElementEndTag()) |
|
351 | - return false; |
|
367 | + if(!self::$decoder->getElementEndTag()) { |
|
368 | + return false; |
|
369 | + } |
|
352 | 370 | } |
353 | 371 | |
354 | 372 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODYPARTPREFERENCE)) { |
@@ -362,30 +380,35 @@ discard block |
||
362 | 380 | |
363 | 381 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
364 | 382 | $spa->BodyPartPreference($bpptype)->SetTruncationSize(self::$decoder->getElementContent()); |
365 | - if(!self::$decoder->getElementEndTag()) |
|
366 | - return false; |
|
383 | + if(!self::$decoder->getElementEndTag()) { |
|
384 | + return false; |
|
385 | + } |
|
367 | 386 | } |
368 | 387 | |
369 | 388 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
370 | 389 | $spa->BodyPartPreference($bpptype)->SetAllOrNone(self::$decoder->getElementContent()); |
371 | - if(!self::$decoder->getElementEndTag()) |
|
372 | - return false; |
|
390 | + if(!self::$decoder->getElementEndTag()) { |
|
391 | + return false; |
|
392 | + } |
|
373 | 393 | } |
374 | 394 | |
375 | 395 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
376 | 396 | $spa->BodyPartPreference($bpptype)->SetPreview(self::$decoder->getElementContent()); |
377 | - if(!self::$decoder->getElementEndTag()) |
|
378 | - return false; |
|
397 | + if(!self::$decoder->getElementEndTag()) { |
|
398 | + return false; |
|
399 | + } |
|
379 | 400 | } |
380 | 401 | |
381 | - if (!self::$decoder->getElementEndTag()) |
|
382 | - return false; |
|
402 | + if (!self::$decoder->getElementEndTag()) { |
|
403 | + return false; |
|
404 | + } |
|
383 | 405 | } |
384 | 406 | |
385 | 407 | if (self::$decoder->getElementStartTag(SYNC_RIGHTSMANAGEMENT_SUPPORT)) { |
386 | 408 | $spa->SetRmSupport(self::$decoder->getElementContent()); |
387 | - if (!self::$decoder->getElementEndTag()) |
|
388 | - return false; |
|
409 | + if (!self::$decoder->getElementEndTag()) { |
|
410 | + return false; |
|
411 | + } |
|
389 | 412 | } |
390 | 413 | |
391 | 414 | $e = self::$decoder->peek(); |
@@ -439,19 +462,21 @@ discard block |
||
439 | 462 | break; |
440 | 463 | } |
441 | 464 | |
442 | - if ($status == SYNC_STATUS_SUCCESS) |
|
443 | - $nchanges++; |
|
465 | + if ($status == SYNC_STATUS_SUCCESS) { |
|
466 | + $nchanges++; |
|
467 | + } |
|
444 | 468 | |
445 | 469 | // Foldertype sent when syncing SMS |
446 | 470 | if(self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
447 | 471 | $foldertype = self::$decoder->getElementContent(); |
448 | 472 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): incoming data with foldertype '%s'", $foldertype)); |
449 | 473 | |
450 | - if(!self::$decoder->getElementEndTag()) |
|
451 | - return false; |
|
474 | + if(!self::$decoder->getElementEndTag()) { |
|
475 | + return false; |
|
476 | + } |
|
477 | + } else { |
|
478 | + $foldertype = false; |
|
452 | 479 | } |
453 | - else |
|
454 | - $foldertype = false; |
|
455 | 480 | |
456 | 481 | $serverid = false; |
457 | 482 | if(self::$decoder->getElementStartTag(SYNC_SERVERENTRYID)) { |
@@ -465,11 +490,13 @@ discard block |
||
465 | 490 | if(self::$decoder->getElementStartTag(SYNC_CLIENTENTRYID)) { |
466 | 491 | $clientid = self::$decoder->getElementContent(); |
467 | 492 | |
468 | - if(!self::$decoder->getElementEndTag()) // end clientid |
|
493 | + if(!self::$decoder->getElementEndTag()) { |
|
494 | + // end clientid |
|
469 | 495 | return false; |
496 | + } |
|
497 | + } else { |
|
498 | + $clientid = false; |
|
470 | 499 | } |
471 | - else |
|
472 | - $clientid = false; |
|
473 | 500 | |
474 | 501 | // Get the SyncMessage if sent |
475 | 502 | if(($el = self::$decoder->getElementStartTag(SYNC_DATA)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
@@ -479,11 +506,13 @@ discard block |
||
479 | 506 | // set Ghosted fields |
480 | 507 | $message->emptySupported(self::$deviceManager->GetSupportedFields($spa->GetFolderId())); |
481 | 508 | |
482 | - if(!self::$decoder->getElementEndTag()) // end applicationdata |
|
509 | + if(!self::$decoder->getElementEndTag()) { |
|
510 | + // end applicationdata |
|
483 | 511 | return false; |
512 | + } |
|
513 | + } else { |
|
514 | + $message = false; |
|
484 | 515 | } |
485 | - else |
|
486 | - $message = false; |
|
487 | 516 | |
488 | 517 | switch($element[EN_TAG]) { |
489 | 518 | case SYNC_FETCH: |
@@ -491,24 +520,29 @@ discard block |
||
491 | 520 | break; |
492 | 521 | default: |
493 | 522 | // get the importer |
494 | - if ($this->importer == false) |
|
495 | - $status = $this->getImporter($sc, $spa, $actiondata); |
|
523 | + if ($this->importer == false) { |
|
524 | + $status = $this->getImporter($sc, $spa, $actiondata); |
|
525 | + } |
|
496 | 526 | |
497 | - if ($status == SYNC_STATUS_SUCCESS) |
|
498 | - $this->importMessage($spa, $actiondata, $element[EN_TAG], $message, $clientid, $serverid, $foldertype, $nchanges); |
|
499 | - else |
|
500 | - ZLog::Write(LOGLEVEL_WARN, "Ignored incoming change, global status indicates problem."); |
|
527 | + if ($status == SYNC_STATUS_SUCCESS) { |
|
528 | + $this->importMessage($spa, $actiondata, $element[EN_TAG], $message, $clientid, $serverid, $foldertype, $nchanges); |
|
529 | + } else { |
|
530 | + ZLog::Write(LOGLEVEL_WARN, "Ignored incoming change, global status indicates problem."); |
|
531 | + } |
|
501 | 532 | |
502 | 533 | break; |
503 | 534 | } |
504 | 535 | |
505 | - if ($actiondata["fetchids"]) |
|
506 | - self::$topCollector->AnnounceInformation(sprintf("Fetching %d", $nchanges)); |
|
507 | - else |
|
508 | - self::$topCollector->AnnounceInformation(sprintf("Incoming %d", $nchanges)); |
|
536 | + if ($actiondata["fetchids"]) { |
|
537 | + self::$topCollector->AnnounceInformation(sprintf("Fetching %d", $nchanges)); |
|
538 | + } else { |
|
539 | + self::$topCollector->AnnounceInformation(sprintf("Incoming %d", $nchanges)); |
|
540 | + } |
|
509 | 541 | |
510 | - if(!self::$decoder->getElementEndTag()) // end add/change/delete/move |
|
542 | + if(!self::$decoder->getElementEndTag()) { |
|
543 | + // end add/change/delete/move |
|
511 | 544 | return false; |
545 | + } |
|
512 | 546 | } |
513 | 547 | |
514 | 548 | if ($status == SYNC_STATUS_SUCCESS && $this->importer !== false) { |
@@ -521,14 +555,15 @@ discard block |
||
521 | 555 | try { |
522 | 556 | // Save the updated state, which is used for the exporter later |
523 | 557 | $sc->AddParameter($spa, "state", $this->importer->GetState()); |
524 | - } |
|
525 | - catch (StatusException $stex) { |
|
558 | + } catch (StatusException $stex) { |
|
526 | 559 | $status = $stex->getCode(); |
527 | 560 | } |
528 | 561 | } |
529 | 562 | |
530 | - if(!self::$decoder->getElementEndTag()) // end PERFORM |
|
563 | + if(!self::$decoder->getElementEndTag()) { |
|
564 | + // end PERFORM |
|
531 | 565 | return false; |
566 | + } |
|
532 | 567 | } |
533 | 568 | |
534 | 569 | // save the failsave state |
@@ -541,28 +576,37 @@ discard block |
||
541 | 576 | // save actiondata |
542 | 577 | $sc->AddParameter($spa, "actiondata", $actiondata); |
543 | 578 | |
544 | - if(!self::$decoder->getElementEndTag()) // end collection |
|
579 | + if(!self::$decoder->getElementEndTag()) { |
|
580 | + // end collection |
|
545 | 581 | return false; |
582 | + } |
|
546 | 583 | |
547 | 584 | // AS14 does not send GetChanges anymore. We should do it if there were no incoming changes |
548 | - if (!isset($performaction) && !$sc->GetParameter($spa, "getchanges") && $spa->HasSyncKey()) |
|
549 | - $sc->AddParameter($spa, "getchanges", true); |
|
585 | + if (!isset($performaction) && !$sc->GetParameter($spa, "getchanges") && $spa->HasSyncKey()) { |
|
586 | + $sc->AddParameter($spa, "getchanges", true); |
|
587 | + } |
|
550 | 588 | } // END FOLDER |
551 | 589 | |
552 | - if(!$wbxmlproblem && !self::$decoder->getElementEndTag()) // end collections |
|
590 | + if(!$wbxmlproblem && !self::$decoder->getElementEndTag()) { |
|
591 | + // end collections |
|
553 | 592 | return false; |
593 | + } |
|
554 | 594 | } // end FOLDERS |
555 | 595 | |
556 | 596 | if (self::$decoder->getElementStartTag(SYNC_HEARTBEATINTERVAL)) { |
557 | 597 | $hbinterval = self::$decoder->getElementContent(); |
558 | - if(!self::$decoder->getElementEndTag()) // SYNC_HEARTBEATINTERVAL |
|
598 | + if(!self::$decoder->getElementEndTag()) { |
|
599 | + // SYNC_HEARTBEATINTERVAL |
|
559 | 600 | return false; |
601 | + } |
|
560 | 602 | } |
561 | 603 | |
562 | 604 | if (self::$decoder->getElementStartTag(SYNC_WAIT)) { |
563 | 605 | $wait = self::$decoder->getElementContent(); |
564 | - if(!self::$decoder->getElementEndTag()) // SYNC_WAIT |
|
606 | + if(!self::$decoder->getElementEndTag()) { |
|
607 | + // SYNC_WAIT |
|
565 | 608 | return false; |
609 | + } |
|
566 | 610 | |
567 | 611 | // internally the heartbeat interval and the wait time are the same |
568 | 612 | // heartbeat is in seconds, wait in minutes |
@@ -572,17 +616,22 @@ discard block |
||
572 | 616 | if (self::$decoder->getElementStartTag(SYNC_WINDOWSIZE)) { |
573 | 617 | $sc->SetGlobalWindowSize(self::$decoder->getElementContent()); |
574 | 618 | ZLog::Write(LOGLEVEL_DEBUG, "Sync(): Global WindowSize requested: ". $sc->GetGlobalWindowSize()); |
575 | - if(!self::$decoder->getElementEndTag()) // SYNC_WINDOWSIZE |
|
619 | + if(!self::$decoder->getElementEndTag()) { |
|
620 | + // SYNC_WINDOWSIZE |
|
576 | 621 | return false; |
622 | + } |
|
577 | 623 | } |
578 | 624 | |
579 | - if(self::$decoder->getElementStartTag(SYNC_PARTIAL)) |
|
580 | - $partial = true; |
|
581 | - else |
|
582 | - $partial = false; |
|
625 | + if(self::$decoder->getElementStartTag(SYNC_PARTIAL)) { |
|
626 | + $partial = true; |
|
627 | + } else { |
|
628 | + $partial = false; |
|
629 | + } |
|
583 | 630 | |
584 | - if(!$wbxmlproblem && !self::$decoder->getElementEndTag()) // end sync |
|
631 | + if(!$wbxmlproblem && !self::$decoder->getElementEndTag()) { |
|
632 | + // end sync |
|
585 | 633 | return false; |
634 | + } |
|
586 | 635 | } |
587 | 636 | // we did not receive a SYNCHRONIZE block - assume empty sync |
588 | 637 | else { |
@@ -605,13 +654,11 @@ discard block |
||
605 | 654 | // Load all collections - do not overwrite existing (received!), load states, check permissions and only load confirmed states! |
606 | 655 | try { |
607 | 656 | $sc->LoadAllCollections(false, true, true, true, true); |
608 | - } |
|
609 | - catch (StateInvalidException $siex) { |
|
657 | + } catch (StateInvalidException $siex) { |
|
610 | 658 | $status = SYNC_STATUS_INVALIDSYNCKEY; |
611 | 659 | self::$topCollector->AnnounceInformation("StateNotFoundException", $this->singleFolder); |
612 | 660 | $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
613 | - } |
|
614 | - catch (StatusException $stex) { |
|
661 | + } catch (StatusException $stex) { |
|
615 | 662 | $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
616 | 663 | self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
617 | 664 | $this->saveMultiFolderInfo("exception", "StatusException"); |
@@ -631,10 +678,10 @@ discard block |
||
631 | 678 | self::$deviceManager->SetWindowSize($folderid, $spa->GetWindowSize()); |
632 | 679 | } |
633 | 680 | } |
634 | - if (!$sc->HasCollections()) |
|
635 | - $status = SYNC_STATUS_SYNCREQUESTINCOMPLETE; |
|
636 | - } |
|
637 | - else if (isset($hbinterval)) { |
|
681 | + if (!$sc->HasCollections()) { |
|
682 | + $status = SYNC_STATUS_SYNCREQUESTINCOMPLETE; |
|
683 | + } |
|
684 | + } else if (isset($hbinterval)) { |
|
638 | 685 | // load the hierarchy data - there are no permissions to verify so we just set it to false |
639 | 686 | if (!$sc->LoadCollection(false, true, false)) { |
640 | 687 | $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
@@ -647,8 +694,9 @@ discard block |
||
647 | 694 | if ($status == SYNC_STATUS_SUCCESS && isset($hbinterval)) { |
648 | 695 | $interval = (defined('PING_INTERVAL') && PING_INTERVAL > 0) ? PING_INTERVAL : 30; |
649 | 696 | |
650 | - if (isset($hbinterval)) |
|
651 | - $sc->SetLifetime($hbinterval); |
|
697 | + if (isset($hbinterval)) { |
|
698 | + $sc->SetLifetime($hbinterval); |
|
699 | + } |
|
652 | 700 | |
653 | 701 | // states are lazy loaded - we have to make sure that they are there! |
654 | 702 | $loadstatus = SYNC_STATUS_SUCCESS; |
@@ -663,8 +711,9 @@ discard block |
||
663 | 711 | $fad = array(); |
664 | 712 | // if loading the states fails, we do not enter heartbeat, but we keep $status on SYNC_STATUS_SUCCESS |
665 | 713 | // so when the changes are exported the correct folder gets an SYNC_STATUS_INVALIDSYNCKEY |
666 | - if ($loadstatus == SYNC_STATUS_SUCCESS) |
|
667 | - $loadstatus = $this->loadStates($sc, $spa, $fad); |
|
714 | + if ($loadstatus == SYNC_STATUS_SUCCESS) { |
|
715 | + $loadstatus = $this->loadStates($sc, $spa, $fad); |
|
716 | + } |
|
668 | 717 | } |
669 | 718 | |
670 | 719 | if ($loadstatus == SYNC_STATUS_SUCCESS) { |
@@ -674,12 +723,10 @@ discard block |
||
674 | 723 | // always check for changes |
675 | 724 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): Entering Heartbeat mode")); |
676 | 725 | $foundchanges = $sc->CheckForChanges($sc->GetLifetime(), $interval); |
677 | - } |
|
678 | - catch (StatusException $stex) { |
|
726 | + } catch (StatusException $stex) { |
|
679 | 727 | if ($stex->getCode() == SyncCollections::OBSOLETE_CONNECTION) { |
680 | 728 | $status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID; |
681 | - } |
|
682 | - else { |
|
729 | + } else { |
|
683 | 730 | $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
684 | 731 | self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
685 | 732 | $this->saveMultiFolderInfo("exception", "StatusException"); |
@@ -696,8 +743,7 @@ discard block |
||
696 | 743 | foreach($sc as $folderid => $spa) { |
697 | 744 | if (self::$deviceManager->CheckHearbeatStateIntegrity($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter())) { |
698 | 745 | $status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID; |
699 | - } |
|
700 | - else { |
|
746 | + } else { |
|
701 | 747 | $sc->SaveCollection($spa); |
702 | 748 | } |
703 | 749 | } |
@@ -717,9 +763,9 @@ discard block |
||
717 | 763 | if ($changecount > 0 && $sc->WaitedForChanges() && self::$deviceManager->CheckHearbeatStateIntegrity($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter())) { |
718 | 764 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): heartbeat: found %d changes in '%s' which was already synchronized. Heartbeat aborted!", $changecount, $folderid)); |
719 | 765 | $status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID; |
766 | + } else { |
|
767 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): heartbeat: found %d changes in '%s'", $changecount, $folderid)); |
|
720 | 768 | } |
721 | - else |
|
722 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): heartbeat: found %d changes in '%s'", $changecount, $folderid)); |
|
723 | 769 | } |
724 | 770 | } |
725 | 771 | } |
@@ -806,16 +852,17 @@ discard block |
||
806 | 852 | if($status == SYNC_STATUS_SUCCESS) { |
807 | 853 | try { |
808 | 854 | // if this is an additional folder the backend has to be setup correctly |
809 | - if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
810 | - throw new StatusException(sprintf("HandleSync() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
|
855 | + if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) { |
|
856 | + throw new StatusException(sprintf("HandleSync() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
|
857 | + } |
|
811 | 858 | |
812 | 859 | // Use the state from the importer, as changes may have already happened |
813 | 860 | $exporter = self::$backend->GetExporter($spa->GetBackendFolderId()); |
814 | 861 | |
815 | - if ($exporter === false) |
|
816 | - throw new StatusException(sprintf("HandleSync() could not get an exporter for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
|
817 | - } |
|
818 | - catch (StatusException $stex) { |
|
862 | + if ($exporter === false) { |
|
863 | + throw new StatusException(sprintf("HandleSync() could not get an exporter for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
|
864 | + } |
|
865 | + } catch (StatusException $stex) { |
|
819 | 866 | $status = $stex->getCode(); |
820 | 867 | } |
821 | 868 | try { |
@@ -829,12 +876,12 @@ discard block |
||
829 | 876 | |
830 | 877 | $changecount = $exporter->GetChangeCount(); |
831 | 878 | } |
832 | - } |
|
833 | - catch (StatusException $stex) { |
|
834 | - if ($stex->getCode() === SYNC_FSSTATUS_CODEUNKNOWN && $spa->HasSyncKey()) |
|
835 | - $status = SYNC_STATUS_INVALIDSYNCKEY; |
|
836 | - else |
|
837 | - $status = $stex->getCode(); |
|
879 | + } catch (StatusException $stex) { |
|
880 | + if ($stex->getCode() === SYNC_FSSTATUS_CODEUNKNOWN && $spa->HasSyncKey()) { |
|
881 | + $status = SYNC_STATUS_INVALIDSYNCKEY; |
|
882 | + } else { |
|
883 | + $status = $stex->getCode(); |
|
884 | + } |
|
838 | 885 | } |
839 | 886 | |
840 | 887 | if (! $spa->HasSyncKey()) { |
@@ -846,8 +893,7 @@ discard block |
||
846 | 893 | if ($changecount > 0) { |
847 | 894 | self::$deviceManager->SetFolderSyncStatus($folderid, DeviceManager::FLD_SYNC_INITIALIZED); |
848 | 895 | } |
849 | - } |
|
850 | - else if ($status != SYNC_STATUS_SUCCESS) { |
|
896 | + } else if ($status != SYNC_STATUS_SUCCESS) { |
|
851 | 897 | self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
852 | 898 | $this->saveMultiFolderInfo("exception", "StatusException"); |
853 | 899 | } |
@@ -902,8 +948,9 @@ discard block |
||
902 | 948 | } // END foreach collection |
903 | 949 | |
904 | 950 | //SYNC_FOLDERS - only if the starttag was sent |
905 | - if ($this->startFolderTagSent) |
|
906 | - self::$encoder->endTag(); |
|
951 | + if ($this->startFolderTagSent) { |
|
952 | + self::$encoder->endTag(); |
|
953 | + } |
|
907 | 954 | |
908 | 955 | // Check if there was any response - in case of an empty sync request, we shouldn't send an empty answer (ZP-1241) |
909 | 956 | if (!$this->startTagsSent && $emptysync === true) { |
@@ -914,8 +961,9 @@ discard block |
||
914 | 961 | } |
915 | 962 | |
916 | 963 | //SYNC_SYNCHRONIZE - only if the starttag was sent |
917 | - if ($this->startTagsSent) |
|
918 | - self::$encoder->endTag(); |
|
964 | + if ($this->startTagsSent) { |
|
965 | + self::$encoder->endTag(); |
|
966 | + } |
|
919 | 967 | |
920 | 968 | // final top announcement for a multi-folder sync |
921 | 969 | if ($sc->GetCollectionCount() > 1) { |
@@ -989,10 +1037,11 @@ discard block |
||
989 | 1037 | } |
990 | 1038 | |
991 | 1039 | self::$encoder->startTag(SYNC_SYNCKEY); |
992 | - if($status == SYNC_STATUS_SUCCESS && $spa->HasNewSyncKey()) |
|
993 | - self::$encoder->content($spa->GetNewSyncKey()); |
|
994 | - else |
|
995 | - self::$encoder->content($spa->GetSyncKey()); |
|
1040 | + if($status == SYNC_STATUS_SUCCESS && $spa->HasNewSyncKey()) { |
|
1041 | + self::$encoder->content($spa->GetNewSyncKey()); |
|
1042 | + } else { |
|
1043 | + self::$encoder->content($spa->GetSyncKey()); |
|
1044 | + } |
|
996 | 1045 | self::$encoder->endTag(); |
997 | 1046 | |
998 | 1047 | self::$encoder->startTag(SYNC_FOLDERID); |
@@ -1004,8 +1053,9 @@ discard block |
||
1004 | 1053 | self::$encoder->endTag(); |
1005 | 1054 | |
1006 | 1055 | // announce failing status to the process loop detection |
1007 | - if ($status !== SYNC_STATUS_SUCCESS) |
|
1008 | - self::$deviceManager->AnnounceProcessStatus($spa->GetFolderId(), $status); |
|
1056 | + if ($status !== SYNC_STATUS_SUCCESS) { |
|
1057 | + self::$deviceManager->AnnounceProcessStatus($spa->GetFolderId(), $status); |
|
1058 | + } |
|
1009 | 1059 | |
1010 | 1060 | // Output IDs and status for incoming items & requests |
1011 | 1061 | if($status == SYNC_STATUS_SUCCESS && ( |
@@ -1071,8 +1121,9 @@ discard block |
||
1071 | 1121 | $fetchstatus = SYNC_STATUS_SUCCESS; |
1072 | 1122 | |
1073 | 1123 | // if this is an additional folder the backend has to be setup correctly |
1074 | - if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
1075 | - throw new StatusException(sprintf("HandleSync(): could not Setup() the backend to fetch in folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_OBJECTNOTFOUND); |
|
1124 | + if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) { |
|
1125 | + throw new StatusException(sprintf("HandleSync(): could not Setup() the backend to fetch in folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_OBJECTNOTFOUND); |
|
1126 | + } |
|
1076 | 1127 | |
1077 | 1128 | $data = self::$backend->Fetch($spa->GetBackendFolderId(), $id, $spa->GetCPO()); |
1078 | 1129 | |
@@ -1081,8 +1132,7 @@ discard block |
||
1081 | 1132 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): message not to be streamed as requested by DeviceManager, id = %s", $id)); |
1082 | 1133 | $fetchstatus = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR; |
1083 | 1134 | } |
1084 | - } |
|
1085 | - catch (StatusException $stex) { |
|
1135 | + } catch (StatusException $stex) { |
|
1086 | 1136 | $fetchstatus = $stex->getCode(); |
1087 | 1137 | } |
1088 | 1138 | |
@@ -1099,9 +1149,9 @@ discard block |
||
1099 | 1149 | self::$encoder->startTag(SYNC_DATA); |
1100 | 1150 | $data->Encode(self::$encoder); |
1101 | 1151 | self::$encoder->endTag(); |
1152 | + } else { |
|
1153 | + ZLog::Write(LOGLEVEL_WARN, sprintf("Unable to Fetch '%s'", $id)); |
|
1102 | 1154 | } |
1103 | - else |
|
1104 | - ZLog::Write(LOGLEVEL_WARN, sprintf("Unable to Fetch '%s'", $id)); |
|
1105 | 1155 | self::$encoder->endTag(); |
1106 | 1156 | |
1107 | 1157 | } |
@@ -1139,18 +1189,18 @@ discard block |
||
1139 | 1189 | while(WBXMLDecoder::InWhile("syncSynchronize")) { |
1140 | 1190 | try { |
1141 | 1191 | $progress = $exporter->Synchronize(); |
1142 | - if(!is_array($progress)) |
|
1143 | - break; |
|
1192 | + if(!is_array($progress)) { |
|
1193 | + break; |
|
1194 | + } |
|
1144 | 1195 | $n++; |
1145 | - if ($n % 10 == 0) |
|
1146 | - self::$topCollector->AnnounceInformation(sprintf("Streamed data of %d objects out of %d", $n, (($changecount > $windowSize)?$windowSize:$changecount))); |
|
1147 | - } |
|
1148 | - catch (SyncObjectBrokenException $mbe) { |
|
1196 | + if ($n % 10 == 0) { |
|
1197 | + self::$topCollector->AnnounceInformation(sprintf("Streamed data of %d objects out of %d", $n, (($changecount > $windowSize)?$windowSize:$changecount))); |
|
1198 | + } |
|
1199 | + } catch (SyncObjectBrokenException $mbe) { |
|
1149 | 1200 | $brokenSO = $mbe->GetSyncObject(); |
1150 | 1201 | if (!$brokenSO) { |
1151 | 1202 | ZLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): Caught SyncObjectBrokenException but broken SyncObject not available. This should be fixed in the backend.")); |
1152 | - } |
|
1153 | - else { |
|
1203 | + } else { |
|
1154 | 1204 | if (!isset($brokenSO->id)) { |
1155 | 1205 | $brokenSO->id = "Unknown ID"; |
1156 | 1206 | ZLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): Caught SyncObjectBrokenException but no ID of object set. This should be fixed in the backend.")); |
@@ -1212,14 +1262,13 @@ discard block |
||
1212 | 1262 | $newFolderStatAfterExport = self::$backend->GetFolderStat(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()), $spa->GetBackendFolderId()); |
1213 | 1263 | if ($newFolderStat === $newFolderStatAfterExport) { |
1214 | 1264 | $this->setFolderStat($spa, $newFolderStat); |
1215 | - } |
|
1216 | - else { |
|
1265 | + } else { |
|
1217 | 1266 | ZLog::Write(LOGLEVEL_DEBUG, "Sync() Folderstat differs after export, force another exporter run."); |
1218 | 1267 | } |
1219 | 1268 | } |
1269 | + } else { |
|
1270 | + self::$deviceManager->SetFolderSyncStatus($spa->GetFolderId(), DeviceManager::FLD_SYNC_INPROGRESS); |
|
1220 | 1271 | } |
1221 | - else |
|
1222 | - self::$deviceManager->SetFolderSyncStatus($spa->GetFolderId(), DeviceManager::FLD_SYNC_INPROGRESS); |
|
1223 | 1272 | } |
1224 | 1273 | |
1225 | 1274 | self::$encoder->endTag(); |
@@ -1234,27 +1283,30 @@ discard block |
||
1234 | 1283 | } |
1235 | 1284 | |
1236 | 1285 | // nothing exported, but possibly imported - get the importer state |
1237 | - else if ($sc->GetParameter($spa, "state") !== null) |
|
1238 | - $state = $sc->GetParameter($spa, "state"); |
|
1286 | + else if ($sc->GetParameter($spa, "state") !== null) { |
|
1287 | + $state = $sc->GetParameter($spa, "state"); |
|
1288 | + } |
|
1239 | 1289 | |
1240 | 1290 | // if a new request without state information (hierarchy) save an empty state |
1241 | - else if (! $spa->HasSyncKey()) |
|
1242 | - $state = ""; |
|
1243 | - } |
|
1244 | - catch (StatusException $stex) { |
|
1291 | + else if (! $spa->HasSyncKey()) { |
|
1292 | + $state = ""; |
|
1293 | + } |
|
1294 | + } catch (StatusException $stex) { |
|
1245 | 1295 | $status = $stex->getCode(); |
1246 | 1296 | } |
1247 | 1297 | |
1248 | 1298 | |
1249 | - if (isset($state) && $status == SYNC_STATUS_SUCCESS) |
|
1250 | - self::$deviceManager->GetStateManager()->SetSyncState($spa->GetNewSyncKey(), $state, $spa->GetFolderId()); |
|
1251 | - else |
|
1252 | - ZLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): error saving '%s' - no state information available", $spa->GetNewSyncKey())); |
|
1299 | + if (isset($state) && $status == SYNC_STATUS_SUCCESS) { |
|
1300 | + self::$deviceManager->GetStateManager()->SetSyncState($spa->GetNewSyncKey(), $state, $spa->GetFolderId()); |
|
1301 | + } else { |
|
1302 | + ZLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): error saving '%s' - no state information available", $spa->GetNewSyncKey())); |
|
1303 | + } |
|
1253 | 1304 | } |
1254 | 1305 | |
1255 | 1306 | // save SyncParameters |
1256 | - if ($status == SYNC_STATUS_SUCCESS && empty($actiondata["fetchids"])) |
|
1257 | - $sc->SaveCollection($spa); |
|
1307 | + if ($status == SYNC_STATUS_SUCCESS && empty($actiondata["fetchids"])) { |
|
1308 | + $sc->SaveCollection($spa); |
|
1309 | + } |
|
1258 | 1310 | |
1259 | 1311 | return $status; |
1260 | 1312 | } |
@@ -1285,15 +1337,14 @@ discard block |
||
1285 | 1337 | } |
1286 | 1338 | |
1287 | 1339 | // if this is an additional folder the backend has to be setup correctly |
1288 | - if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
1289 | - throw new StatusException(sprintf("HandleSync() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
|
1290 | - } |
|
1291 | - catch (StateNotFoundException $snfex) { |
|
1340 | + if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) { |
|
1341 | + throw new StatusException(sprintf("HandleSync() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
|
1342 | + } |
|
1343 | + } catch (StateNotFoundException $snfex) { |
|
1292 | 1344 | $status = SYNC_STATUS_INVALIDSYNCKEY; |
1293 | 1345 | self::$topCollector->AnnounceInformation("StateNotFoundException", $this->singleFolder); |
1294 | 1346 | $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
1295 | - } |
|
1296 | - catch (StatusException $stex) { |
|
1347 | + } catch (StatusException $stex) { |
|
1297 | 1348 | $status = $stex->getCode(); |
1298 | 1349 | self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
1299 | 1350 | $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
@@ -1328,22 +1379,22 @@ discard block |
||
1328 | 1379 | $this->importer = self::$backend->GetImporter($spa->GetBackendFolderId()); |
1329 | 1380 | |
1330 | 1381 | // if something goes wrong, ask the mobile to resync the hierarchy |
1331 | - if ($this->importer === false) |
|
1332 | - throw new StatusException(sprintf("Sync->getImporter(): no importer for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
|
1382 | + if ($this->importer === false) { |
|
1383 | + throw new StatusException(sprintf("Sync->getImporter(): no importer for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
|
1384 | + } |
|
1333 | 1385 | |
1334 | 1386 | // if there is a valid state obtained after importing changes in a previous loop, we use that state |
1335 | 1387 | if (isset($actiondata["failstate"]) && isset($actiondata["failstate"]["failedsyncstate"])) { |
1336 | 1388 | $this->importer->Config($actiondata["failstate"]["failedsyncstate"], $spa->GetConflict()); |
1389 | + } else { |
|
1390 | + $this->importer->Config($sc->GetParameter($spa, "state"), $spa->GetConflict()); |
|
1337 | 1391 | } |
1338 | - else |
|
1339 | - $this->importer->Config($sc->GetParameter($spa, "state"), $spa->GetConflict()); |
|
1340 | 1392 | |
1341 | 1393 | // the CPO is also needed by the importer to check if imported changes are inside the sync window - see ZP-258 |
1342 | 1394 | $this->importer->ConfigContentParameters($spa->GetCPO()); |
1343 | 1395 | $this->importer->LoadConflicts($spa->GetCPO(), $sc->GetParameter($spa, "state")); |
1344 | 1396 | } |
1345 | - } |
|
1346 | - catch (StatusException $stex) { |
|
1397 | + } catch (StatusException $stex) { |
|
1347 | 1398 | $status = $stex->getCode(); |
1348 | 1399 | } |
1349 | 1400 | |
@@ -1369,8 +1420,9 @@ discard block |
||
1369 | 1420 | */ |
1370 | 1421 | private function importMessage($spa, &$actiondata, $todo, $message, $clientid, $serverid, $foldertype, $messageCount) { |
1371 | 1422 | // the importer needs to be available! |
1372 | - if ($this->importer == false) |
|
1373 | - throw new StatusException("Sync->importMessage(): importer not available", SYNC_STATUS_SERVERERROR); |
|
1423 | + if ($this->importer == false) { |
|
1424 | + throw new StatusException("Sync->importMessage(): importer not available", SYNC_STATUS_SERVERERROR); |
|
1425 | + } |
|
1374 | 1426 | |
1375 | 1427 | // mark this state as used, e.g. for HeartBeat |
1376 | 1428 | self::$deviceManager->SetHeartbeatStateIntegrity($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter()); |
@@ -1423,13 +1475,11 @@ discard block |
||
1423 | 1475 | // check incoming message without logging WARN messages about errors |
1424 | 1476 | else if (!($message instanceof SyncObject) || !$message->Check(true)) { |
1425 | 1477 | $actiondata["statusids"][$serverid] = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR; |
1426 | - } |
|
1427 | - else { |
|
1478 | + } else { |
|
1428 | 1479 | if(isset($message->read)) { |
1429 | 1480 | // Currently, 'read' is only sent by the PDA when it is ONLY setting the read flag. |
1430 | 1481 | $this->importer->ImportMessageReadFlag($serverid, $message->read); |
1431 | - } |
|
1432 | - elseif (!isset($message->flag)) { |
|
1482 | + } elseif (!isset($message->flag)) { |
|
1433 | 1483 | $this->importer->ImportMessageChange($serverid, $message); |
1434 | 1484 | } |
1435 | 1485 | |
@@ -1441,8 +1491,7 @@ discard block |
||
1441 | 1491 | |
1442 | 1492 | $actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS; |
1443 | 1493 | } |
1444 | - } |
|
1445 | - catch (StatusException $stex) { |
|
1494 | + } catch (StatusException $stex) { |
|
1446 | 1495 | $actiondata["statusids"][$serverid] = $stex->getCode(); |
1447 | 1496 | } |
1448 | 1497 | |
@@ -1465,14 +1514,12 @@ discard block |
||
1465 | 1514 | else if (!($message instanceof SyncObject) || !$message->Check(true)) { |
1466 | 1515 | $actiondata["clientids"][$clientid] = false; |
1467 | 1516 | $actiondata["statusids"][$clientid] = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR; |
1468 | - } |
|
1469 | - else { |
|
1517 | + } else { |
|
1470 | 1518 | $actiondata["clientids"][$clientid] = false; |
1471 | 1519 | $actiondata["clientids"][$clientid] = $this->importer->ImportMessageChange(false, $message); |
1472 | 1520 | $actiondata["statusids"][$clientid] = SYNC_STATUS_SUCCESS; |
1473 | 1521 | } |
1474 | - } |
|
1475 | - catch (StatusException $stex) { |
|
1522 | + } catch (StatusException $stex) { |
|
1476 | 1523 | $actiondata["statusids"][$clientid] = $stex->getCode(); |
1477 | 1524 | } |
1478 | 1525 | break; |
@@ -1485,8 +1532,7 @@ discard block |
||
1485 | 1532 | ZLog::Write(LOGLEVEL_DEBUG, "SMS sync are not supported. Ignoring message."); |
1486 | 1533 | // TODO we should delete the SMS |
1487 | 1534 | $actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS; |
1488 | - } |
|
1489 | - else { |
|
1535 | + } else { |
|
1490 | 1536 | // if message deletions are to be moved, move them |
1491 | 1537 | if($spa->GetDeletesAsMoves()) { |
1492 | 1538 | $folderid = self::$backend->GetWasteBasket(); |
@@ -1495,16 +1541,15 @@ discard block |
||
1495 | 1541 | $actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS; |
1496 | 1542 | $this->importer->ImportMessageMove($serverid, $folderid); |
1497 | 1543 | break; |
1544 | + } else { |
|
1545 | + ZLog::Write(LOGLEVEL_WARN, "Message should be moved to WasteBasket, but the Backend did not return a destination ID. Message is hard deleted now!"); |
|
1498 | 1546 | } |
1499 | - else |
|
1500 | - ZLog::Write(LOGLEVEL_WARN, "Message should be moved to WasteBasket, but the Backend did not return a destination ID. Message is hard deleted now!"); |
|
1501 | 1547 | } |
1502 | 1548 | |
1503 | 1549 | $this->importer->ImportMessageDeletion($serverid); |
1504 | 1550 | $actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS; |
1505 | 1551 | } |
1506 | - } |
|
1507 | - catch (StatusException $stex) { |
|
1552 | + } catch (StatusException $stex) { |
|
1508 | 1553 | if($stex->getCode() != SYNC_MOVEITEMSSTATUS_SUCCESS) { |
1509 | 1554 | $actiondata["statusids"][$serverid] = SYNC_STATUS_OBJECTNOTFOUND; |
1510 | 1555 | } |
@@ -1551,11 +1596,9 @@ discard block |
||
1551 | 1596 | } |
1552 | 1597 | if (isset($this->multiFolderInfo["outgoing"]) && isset($this->multiFolderInfo["queued"]) && $this->multiFolderInfo["outgoing"] > 0) { |
1553 | 1598 | $s .= sprintf(": Streamed %d out of %d", $this->multiFolderInfo["outgoing"], $this->multiFolderInfo["queued"]); |
1554 | - } |
|
1555 | - else if (!isset($this->multiFolderInfo["outgoing"]) && !isset($this->multiFolderInfo["queued"])) { |
|
1599 | + } else if (!isset($this->multiFolderInfo["outgoing"]) && !isset($this->multiFolderInfo["queued"])) { |
|
1556 | 1600 | $s .= ": no changes"; |
1557 | - } |
|
1558 | - else { |
|
1601 | + } else { |
|
1559 | 1602 | if (isset($this->multiFolderInfo["outgoing"])) { |
1560 | 1603 | $s .= "/".$this->multiFolderInfo["outgoing"] ." streamed"; |
1561 | 1604 | } |
@@ -116,7 +116,7 @@ |
||
116 | 116 | $searchvalue = self::$decoder->getElementContent(); |
117 | 117 | $cpo->SetSearchValueLess($searchvalue); |
118 | 118 | if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
119 | - return false; |
|
119 | + return false; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_LESSTHAN |
@@ -22,26 +22,26 @@ discard block |
||
22 | 22 | $searchpicture = false; |
23 | 23 | $cpo = new ContentParameters(); |
24 | 24 | |
25 | - if(!self::$decoder->getElementStartTag(SYNC_SEARCH_SEARCH)) |
|
25 | + if (!self::$decoder->getElementStartTag(SYNC_SEARCH_SEARCH)) |
|
26 | 26 | return false; |
27 | 27 | |
28 | 28 | // TODO check: possible to search in other stores? |
29 | - if(!self::$decoder->getElementStartTag(SYNC_SEARCH_STORE)) |
|
29 | + if (!self::$decoder->getElementStartTag(SYNC_SEARCH_STORE)) |
|
30 | 30 | return false; |
31 | 31 | |
32 | - if(!self::$decoder->getElementStartTag(SYNC_SEARCH_NAME)) |
|
32 | + if (!self::$decoder->getElementStartTag(SYNC_SEARCH_NAME)) |
|
33 | 33 | return false; |
34 | 34 | $searchname = strtoupper(self::$decoder->getElementContent()); |
35 | - if(!self::$decoder->getElementEndTag()) |
|
35 | + if (!self::$decoder->getElementEndTag()) |
|
36 | 36 | return false; |
37 | 37 | |
38 | - if(!self::$decoder->getElementStartTag(SYNC_SEARCH_QUERY)) |
|
38 | + if (!self::$decoder->getElementStartTag(SYNC_SEARCH_QUERY)) |
|
39 | 39 | return false; |
40 | 40 | |
41 | 41 | // check if it is a content of an element (= GAL search) |
42 | 42 | // or a starttag (= mailbox or documentlibrary search) |
43 | 43 | $searchquery = self::$decoder->getElementContent(); |
44 | - if($searchquery && !self::$decoder->getElementEndTag()) |
|
44 | + if ($searchquery && !self::$decoder->getElementEndTag()) |
|
45 | 45 | return false; |
46 | 46 | |
47 | 47 | if ($searchquery === false) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | if (self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
51 | 51 | $searchfolderid = self::$decoder->getElementContent(); |
52 | 52 | $cpo->SetSearchFolderid($searchfolderid); |
53 | - if(!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
53 | + if (!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
54 | 54 | return false; |
55 | 55 | } |
56 | 56 | |
@@ -58,176 +58,176 @@ discard block |
||
58 | 58 | if (self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
59 | 59 | $searchclass = self::$decoder->getElementContent(); |
60 | 60 | $cpo->SetSearchClass($searchclass); |
61 | - if(!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
61 | + if (!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
62 | 62 | return false; |
63 | 63 | } |
64 | 64 | |
65 | 65 | if (self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
66 | 66 | $searchfolderid = self::$decoder->getElementContent(); |
67 | 67 | $cpo->SetSearchFolderid($searchfolderid); |
68 | - if(!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
68 | + if (!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
72 | 72 | if (self::$decoder->getElementStartTag(SYNC_SEARCH_FREETEXT)) { |
73 | 73 | $searchfreetext = self::$decoder->getElementContent(); |
74 | 74 | $cpo->SetSearchFreeText($searchfreetext); |
75 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_FREETEXT |
|
75 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_FREETEXT |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | |
79 | 79 | //TODO - review |
80 | 80 | if (self::$decoder->getElementStartTag(SYNC_SEARCH_GREATERTHAN)) { |
81 | - if(self::$decoder->getElementStartTag(SYNC_POOMMAIL_DATERECEIVED)) { |
|
81 | + if (self::$decoder->getElementStartTag(SYNC_POOMMAIL_DATERECEIVED)) { |
|
82 | 82 | $datereceivedgreater = true; |
83 | 83 | if (($dam = self::$decoder->getElementContent()) !== false) { |
84 | 84 | $datereceivedgreater = true; |
85 | - if(!self::$decoder->getElementEndTag()) { |
|
85 | + if (!self::$decoder->getElementEndTag()) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | $cpo->SetSearchDateReceivedGreater($datereceivedgreater); |
90 | 90 | } |
91 | 91 | |
92 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
|
92 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
|
93 | 93 | $searchvalue = self::$decoder->getElementContent(); |
94 | 94 | $cpo->SetSearchValueGreater($searchvalue); |
95 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
95 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_GREATERTHAN |
|
99 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_GREATERTHAN |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
103 | 103 | if (self::$decoder->getElementStartTag(SYNC_SEARCH_LESSTHAN)) { |
104 | - if(self::$decoder->getElementStartTag(SYNC_POOMMAIL_DATERECEIVED)) { |
|
104 | + if (self::$decoder->getElementStartTag(SYNC_POOMMAIL_DATERECEIVED)) { |
|
105 | 105 | $datereceivedless = true; |
106 | 106 | if (($dam = self::$decoder->getElementContent()) !== false) { |
107 | 107 | $datereceivedless = true; |
108 | - if(!self::$decoder->getElementEndTag()) { |
|
108 | + if (!self::$decoder->getElementEndTag()) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | } |
112 | 112 | $cpo->SetSearchDateReceivedLess($datereceivedless); |
113 | 113 | } |
114 | 114 | |
115 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
|
115 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
|
116 | 116 | $searchvalue = self::$decoder->getElementContent(); |
117 | 117 | $cpo->SetSearchValueLess($searchvalue); |
118 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
118 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
122 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_LESSTHAN |
|
122 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_LESSTHAN |
|
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | |
126 | 126 | if (self::$decoder->getElementStartTag(SYNC_SEARCH_FREETEXT)) { |
127 | 127 | $searchfreetext = self::$decoder->getElementContent(); |
128 | 128 | $cpo->SetSearchFreeText($searchfreetext); |
129 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_FREETEXT |
|
129 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_FREETEXT |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_AND |
|
133 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_AND |
|
134 | 134 | return false; |
135 | 135 | } |
136 | 136 | elseif (self::$decoder->getElementStartTag(SYNC_SEARCH_EQUALTO)) { |
137 | 137 | // linkid can be an empty tag as well as have value |
138 | - if(self::$decoder->getElementStartTag(SYNC_DOCUMENTLIBRARY_LINKID)) { |
|
138 | + if (self::$decoder->getElementStartTag(SYNC_DOCUMENTLIBRARY_LINKID)) { |
|
139 | 139 | if (($linkId = self::$decoder->getElementContent()) !== false) { |
140 | 140 | $cpo->SetLinkId($linkId); |
141 | - if(!self::$decoder->getElementEndTag()) { // SYNC_DOCUMENTLIBRARY_LINKID |
|
141 | + if (!self::$decoder->getElementEndTag()) { // SYNC_DOCUMENTLIBRARY_LINKID |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
|
147 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
|
148 | 148 | $searchvalue = self::$decoder->getElementContent(); |
149 | 149 | $cpo->SetSearchValueEqualTo($searchvalue); |
150 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
150 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_EQUALTO |
|
154 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_EQUALTO |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | |
158 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_QUERY |
|
158 | + if (!self::$decoder->getElementEndTag()) // SYNC_SEARCH_QUERY |
|
159 | 159 | return false; |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_OPTIONS)) { |
|
163 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_OPTIONS)) { |
|
164 | 164 | WBXMLDecoder::ResetInWhile("searchOptions"); |
165 | - while(WBXMLDecoder::InWhile("searchOptions")) { |
|
166 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_RANGE)) { |
|
165 | + while (WBXMLDecoder::InWhile("searchOptions")) { |
|
166 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_RANGE)) { |
|
167 | 167 | $searchrange = self::$decoder->getElementContent(); |
168 | 168 | $cpo->SetSearchRange($searchrange); |
169 | - if(!self::$decoder->getElementEndTag()) |
|
169 | + if (!self::$decoder->getElementEndTag()) |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | 173 | |
174 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_REBUILDRESULTS)) { |
|
174 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_REBUILDRESULTS)) { |
|
175 | 175 | $rebuildresults = true; |
176 | 176 | if (($dam = self::$decoder->getElementContent()) !== false) { |
177 | 177 | $rebuildresults = true; |
178 | - if(!self::$decoder->getElementEndTag()) { |
|
178 | + if (!self::$decoder->getElementEndTag()) { |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | } |
182 | 182 | $cpo->SetSearchRebuildResults($rebuildresults); |
183 | 183 | } |
184 | 184 | |
185 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_DEEPTRAVERSAL)) { |
|
185 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_DEEPTRAVERSAL)) { |
|
186 | 186 | $deeptraversal = true; |
187 | 187 | if (($dam = self::$decoder->getElementContent()) !== false) { |
188 | 188 | $deeptraversal = true; |
189 | - if(!self::$decoder->getElementEndTag()) { |
|
189 | + if (!self::$decoder->getElementEndTag()) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | } |
193 | 193 | $cpo->SetSearchDeepTraversal($deeptraversal); |
194 | 194 | } |
195 | 195 | |
196 | - if(self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
|
196 | + if (self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
|
197 | 197 | $cpo->SetMimeSupport(self::$decoder->getElementContent()); |
198 | - if(!self::$decoder->getElementEndTag()) |
|
198 | + if (!self::$decoder->getElementEndTag()) |
|
199 | 199 | return false; |
200 | 200 | } |
201 | 201 | |
202 | 202 | //TODO body preferences |
203 | 203 | while (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODYPREFERENCE)) { |
204 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TYPE)) { |
|
204 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TYPE)) { |
|
205 | 205 | $bptype = self::$decoder->getElementContent(); |
206 | 206 | $cpo->BodyPreference($bptype); |
207 | - if(!self::$decoder->getElementEndTag()) { |
|
207 | + if (!self::$decoder->getElementEndTag()) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
|
212 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
|
213 | 213 | $cpo->BodyPreference($bptype)->SetTruncationSize(self::$decoder->getElementContent()); |
214 | - if(!self::$decoder->getElementEndTag()) |
|
214 | + if (!self::$decoder->getElementEndTag()) |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
218 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
|
218 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
|
219 | 219 | $cpo->BodyPreference($bptype)->SetAllOrNone(self::$decoder->getElementContent()); |
220 | - if(!self::$decoder->getElementEndTag()) |
|
220 | + if (!self::$decoder->getElementEndTag()) |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | |
224 | - if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
|
224 | + if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
|
225 | 225 | $cpo->BodyPreference($bptype)->SetPreview(self::$decoder->getElementContent()); |
226 | - if(!self::$decoder->getElementEndTag()) |
|
226 | + if (!self::$decoder->getElementEndTag()) |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
230 | - if(!self::$decoder->getElementEndTag()) |
|
230 | + if (!self::$decoder->getElementEndTag()) |
|
231 | 231 | return false; |
232 | 232 | } |
233 | 233 | |
@@ -242,19 +242,19 @@ discard block |
||
242 | 242 | |
243 | 243 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
244 | 244 | $cpo->BodyPartPreference($bpptype)->SetTruncationSize(self::$decoder->getElementContent()); |
245 | - if(!self::$decoder->getElementEndTag()) |
|
245 | + if (!self::$decoder->getElementEndTag()) |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | |
249 | 249 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
250 | 250 | $cpo->BodyPartPreference($bpptype)->SetAllOrNone(self::$decoder->getElementContent()); |
251 | - if(!self::$decoder->getElementEndTag()) |
|
251 | + if (!self::$decoder->getElementEndTag()) |
|
252 | 252 | return false; |
253 | 253 | } |
254 | 254 | |
255 | 255 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
256 | 256 | $cpo->BodyPartPreference($bpptype)->SetPreview(self::$decoder->getElementContent()); |
257 | - if(!self::$decoder->getElementEndTag()) |
|
257 | + if (!self::$decoder->getElementEndTag()) |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | |
@@ -262,45 +262,45 @@ discard block |
||
262 | 262 | return false; |
263 | 263 | } |
264 | 264 | |
265 | - if(self::$decoder->getElementStartTag(SYNC_RIGHTSMANAGEMENT_SUPPORT)) { |
|
265 | + if (self::$decoder->getElementStartTag(SYNC_RIGHTSMANAGEMENT_SUPPORT)) { |
|
266 | 266 | $cpo->SetRmSupport(self::$decoder->getElementContent()); |
267 | - if(!self::$decoder->getElementEndTag()) |
|
267 | + if (!self::$decoder->getElementEndTag()) |
|
268 | 268 | return false; |
269 | 269 | } |
270 | 270 | |
271 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_PICTURE)) { // TODO - do something with maxsize and maxpictures in the backend |
|
271 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_PICTURE)) { // TODO - do something with maxsize and maxpictures in the backend |
|
272 | 272 | $searchpicture = new SyncResolveRecipientsPicture(); |
273 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_MAXSIZE)) { |
|
273 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_MAXSIZE)) { |
|
274 | 274 | $searchpicture->maxsize = self::$decoder->getElementContent(); |
275 | - if(!self::$decoder->getElementEndTag()) |
|
275 | + if (!self::$decoder->getElementEndTag()) |
|
276 | 276 | return false; |
277 | 277 | } |
278 | 278 | |
279 | - if(self::$decoder->getElementStartTag(SYNC_SEARCH_MAXPICTURES)) { |
|
279 | + if (self::$decoder->getElementStartTag(SYNC_SEARCH_MAXPICTURES)) { |
|
280 | 280 | $searchpicture->maxpictures = self::$decoder->getElementContent(); |
281 | - if(!self::$decoder->getElementEndTag()) |
|
281 | + if (!self::$decoder->getElementEndTag()) |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
285 | 285 | // iOs devices send empty picture tag: <Search:Picture/> |
286 | 286 | if (($sp = self::$decoder->getElementContent()) !== false) { |
287 | - if(!self::$decoder->getElementEndTag()) { |
|
287 | + if (!self::$decoder->getElementEndTag()) { |
|
288 | 288 | return false; |
289 | 289 | } |
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | 293 | $e = self::$decoder->peek(); |
294 | - if($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
294 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
295 | 295 | self::$decoder->getElementEndTag(); |
296 | 296 | break; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | } |
300 | - if(!self::$decoder->getElementEndTag()) //store |
|
300 | + if (!self::$decoder->getElementEndTag()) //store |
|
301 | 301 | return false; |
302 | 302 | |
303 | - if(!self::$decoder->getElementEndTag()) //search |
|
303 | + if (!self::$decoder->getElementEndTag()) //search |
|
304 | 304 | return false; |
305 | 305 | |
306 | 306 | // get SearchProvider |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | } |
335 | 335 | $searchprovider->Disconnect(); |
336 | 336 | |
337 | - self::$topCollector->AnnounceInformation(sprintf("'%s' search found %d results", $searchname, (isset($rows['searchtotal']) ? $rows['searchtotal'] : 0) ), true); |
|
337 | + self::$topCollector->AnnounceInformation(sprintf("'%s' search found %d results", $searchname, (isset($rows['searchtotal']) ? $rows['searchtotal'] : 0)), true); |
|
338 | 338 | |
339 | 339 | self::$encoder->startWBXML(); |
340 | 340 | self::$encoder->startTag(SYNC_SEARCH_SEARCH); |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | self::$encoder->startTag(SYNC_SEARCH_PROPERTIES); |
367 | 367 | |
368 | 368 | self::$encoder->startTag(SYNC_GAL_DISPLAYNAME); |
369 | - self::$encoder->content((isset($u[SYNC_GAL_DISPLAYNAME]))?$u[SYNC_GAL_DISPLAYNAME]:"No name"); |
|
369 | + self::$encoder->content((isset($u[SYNC_GAL_DISPLAYNAME])) ? $u[SYNC_GAL_DISPLAYNAME] : "No name"); |
|
370 | 370 | self::$encoder->endTag(); |
371 | 371 | |
372 | 372 | if (isset($u[SYNC_GAL_PHONE])) { |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | |
402 | 402 | // Always send the firstname, even empty. Nokia needs this to display the entry |
403 | 403 | self::$encoder->startTag(SYNC_GAL_FIRSTNAME); |
404 | - self::$encoder->content((isset($u[SYNC_GAL_FIRSTNAME]))?$u[SYNC_GAL_FIRSTNAME]:""); |
|
404 | + self::$encoder->content((isset($u[SYNC_GAL_FIRSTNAME])) ? $u[SYNC_GAL_FIRSTNAME] : ""); |
|
405 | 405 | self::$encoder->endTag(); |
406 | 406 | |
407 | 407 | self::$encoder->startTag(SYNC_GAL_LASTNAME); |
408 | - self::$encoder->content((isset($u[SYNC_GAL_LASTNAME]))?$u[SYNC_GAL_LASTNAME]:"No name"); |
|
408 | + self::$encoder->content((isset($u[SYNC_GAL_LASTNAME])) ? $u[SYNC_GAL_LASTNAME] : "No name"); |
|
409 | 409 | self::$encoder->endTag(); |
410 | 410 | |
411 | 411 | if (isset($u[SYNC_GAL_HOMEPHONE])) { |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | } |
422 | 422 | |
423 | 423 | self::$encoder->startTag(SYNC_GAL_EMAILADDRESS); |
424 | - self::$encoder->content((isset($u[SYNC_GAL_EMAILADDRESS]))?$u[SYNC_GAL_EMAILADDRESS]:""); |
|
424 | + self::$encoder->content((isset($u[SYNC_GAL_EMAILADDRESS])) ? $u[SYNC_GAL_EMAILADDRESS] : ""); |
|
425 | 425 | self::$encoder->endTag(); |
426 | 426 | |
427 | 427 | |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | self::$encoder->endTag(); // SYNC_GAL_PICTURE |
438 | 438 | } |
439 | 439 | |
440 | - self::$encoder->endTag();//result |
|
441 | - self::$encoder->endTag();//properties |
|
440 | + self::$encoder->endTag(); //result |
|
441 | + self::$encoder->endTag(); //properties |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | } |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | $message = self::$backend->Fetch(false, $u['longid'], $cpo); |
463 | 463 | $message->Encode(self::$encoder); |
464 | 464 | |
465 | - self::$encoder->endTag();//result |
|
466 | - self::$encoder->endTag();//properties |
|
465 | + self::$encoder->endTag(); //result |
|
466 | + self::$encoder->endTag(); //properties |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | // it seems that android 4 requires range and searchtotal |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | self::$encoder->endTag(); |
480 | 480 | } |
481 | 481 | |
482 | - self::$encoder->endTag();//store |
|
483 | - self::$encoder->endTag();//response |
|
482 | + self::$encoder->endTag(); //store |
|
483 | + self::$encoder->endTag(); //response |
|
484 | 484 | } |
485 | - self::$encoder->endTag();//search |
|
485 | + self::$encoder->endTag(); //search |
|
486 | 486 | |
487 | 487 | return true; |
488 | 488 | } |
@@ -22,27 +22,33 @@ discard block |
||
22 | 22 | $searchpicture = false; |
23 | 23 | $cpo = new ContentParameters(); |
24 | 24 | |
25 | - if(!self::$decoder->getElementStartTag(SYNC_SEARCH_SEARCH)) |
|
26 | - return false; |
|
25 | + if(!self::$decoder->getElementStartTag(SYNC_SEARCH_SEARCH)) { |
|
26 | + return false; |
|
27 | + } |
|
27 | 28 | |
28 | 29 | // TODO check: possible to search in other stores? |
29 | - if(!self::$decoder->getElementStartTag(SYNC_SEARCH_STORE)) |
|
30 | - return false; |
|
30 | + if(!self::$decoder->getElementStartTag(SYNC_SEARCH_STORE)) { |
|
31 | + return false; |
|
32 | + } |
|
31 | 33 | |
32 | - if(!self::$decoder->getElementStartTag(SYNC_SEARCH_NAME)) |
|
33 | - return false; |
|
34 | + if(!self::$decoder->getElementStartTag(SYNC_SEARCH_NAME)) { |
|
35 | + return false; |
|
36 | + } |
|
34 | 37 | $searchname = strtoupper(self::$decoder->getElementContent()); |
35 | - if(!self::$decoder->getElementEndTag()) |
|
36 | - return false; |
|
38 | + if(!self::$decoder->getElementEndTag()) { |
|
39 | + return false; |
|
40 | + } |
|
37 | 41 | |
38 | - if(!self::$decoder->getElementStartTag(SYNC_SEARCH_QUERY)) |
|
39 | - return false; |
|
42 | + if(!self::$decoder->getElementStartTag(SYNC_SEARCH_QUERY)) { |
|
43 | + return false; |
|
44 | + } |
|
40 | 45 | |
41 | 46 | // check if it is a content of an element (= GAL search) |
42 | 47 | // or a starttag (= mailbox or documentlibrary search) |
43 | 48 | $searchquery = self::$decoder->getElementContent(); |
44 | - if($searchquery && !self::$decoder->getElementEndTag()) |
|
45 | - return false; |
|
49 | + if($searchquery && !self::$decoder->getElementEndTag()) { |
|
50 | + return false; |
|
51 | + } |
|
46 | 52 | |
47 | 53 | if ($searchquery === false) { |
48 | 54 | $cpo->SetSearchName($searchname); |
@@ -50,30 +56,38 @@ discard block |
||
50 | 56 | if (self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
51 | 57 | $searchfolderid = self::$decoder->getElementContent(); |
52 | 58 | $cpo->SetSearchFolderid($searchfolderid); |
53 | - if(!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
59 | + if(!self::$decoder->getElementEndTag()) { |
|
60 | + // SYNC_FOLDERTYPE |
|
54 | 61 | return false; |
62 | + } |
|
55 | 63 | } |
56 | 64 | |
57 | 65 | |
58 | 66 | if (self::$decoder->getElementStartTag(SYNC_FOLDERTYPE)) { |
59 | 67 | $searchclass = self::$decoder->getElementContent(); |
60 | 68 | $cpo->SetSearchClass($searchclass); |
61 | - if(!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
69 | + if(!self::$decoder->getElementEndTag()) { |
|
70 | + // SYNC_FOLDERTYPE |
|
62 | 71 | return false; |
72 | + } |
|
63 | 73 | } |
64 | 74 | |
65 | 75 | if (self::$decoder->getElementStartTag(SYNC_FOLDERID)) { |
66 | 76 | $searchfolderid = self::$decoder->getElementContent(); |
67 | 77 | $cpo->SetSearchFolderid($searchfolderid); |
68 | - if(!self::$decoder->getElementEndTag()) // SYNC_FOLDERTYPE |
|
78 | + if(!self::$decoder->getElementEndTag()) { |
|
79 | + // SYNC_FOLDERTYPE |
|
69 | 80 | return false; |
81 | + } |
|
70 | 82 | } |
71 | 83 | |
72 | 84 | if (self::$decoder->getElementStartTag(SYNC_SEARCH_FREETEXT)) { |
73 | 85 | $searchfreetext = self::$decoder->getElementContent(); |
74 | 86 | $cpo->SetSearchFreeText($searchfreetext); |
75 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_FREETEXT |
|
87 | + if(!self::$decoder->getElementEndTag()) { |
|
88 | + // SYNC_SEARCH_FREETEXT |
|
76 | 89 | return false; |
90 | + } |
|
77 | 91 | } |
78 | 92 | |
79 | 93 | //TODO - review |
@@ -92,12 +106,16 @@ discard block |
||
92 | 106 | if(self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
93 | 107 | $searchvalue = self::$decoder->getElementContent(); |
94 | 108 | $cpo->SetSearchValueGreater($searchvalue); |
95 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
109 | + if(!self::$decoder->getElementEndTag()) { |
|
110 | + // SYNC_SEARCH_VALUE |
|
96 | 111 | return false; |
112 | + } |
|
97 | 113 | } |
98 | 114 | |
99 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_GREATERTHAN |
|
115 | + if(!self::$decoder->getElementEndTag()) { |
|
116 | + // SYNC_SEARCH_GREATERTHAN |
|
100 | 117 | return false; |
118 | + } |
|
101 | 119 | } |
102 | 120 | |
103 | 121 | if (self::$decoder->getElementStartTag(SYNC_SEARCH_LESSTHAN)) { |
@@ -115,25 +133,32 @@ discard block |
||
115 | 133 | if(self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
116 | 134 | $searchvalue = self::$decoder->getElementContent(); |
117 | 135 | $cpo->SetSearchValueLess($searchvalue); |
118 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
136 | + if(!self::$decoder->getElementEndTag()) { |
|
137 | + // SYNC_SEARCH_VALUE |
|
119 | 138 | return false; |
139 | + } |
|
120 | 140 | } |
121 | 141 | |
122 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_LESSTHAN |
|
142 | + if(!self::$decoder->getElementEndTag()) { |
|
143 | + // SYNC_SEARCH_LESSTHAN |
|
123 | 144 | return false; |
145 | + } |
|
124 | 146 | } |
125 | 147 | |
126 | 148 | if (self::$decoder->getElementStartTag(SYNC_SEARCH_FREETEXT)) { |
127 | 149 | $searchfreetext = self::$decoder->getElementContent(); |
128 | 150 | $cpo->SetSearchFreeText($searchfreetext); |
129 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_FREETEXT |
|
151 | + if(!self::$decoder->getElementEndTag()) { |
|
152 | + // SYNC_SEARCH_FREETEXT |
|
130 | 153 | return false; |
154 | + } |
|
131 | 155 | } |
132 | 156 | |
133 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_AND |
|
157 | + if(!self::$decoder->getElementEndTag()) { |
|
158 | + // SYNC_SEARCH_AND |
|
134 | 159 | return false; |
135 | - } |
|
136 | - elseif (self::$decoder->getElementStartTag(SYNC_SEARCH_EQUALTO)) { |
|
160 | + } |
|
161 | + } elseif (self::$decoder->getElementStartTag(SYNC_SEARCH_EQUALTO)) { |
|
137 | 162 | // linkid can be an empty tag as well as have value |
138 | 163 | if(self::$decoder->getElementStartTag(SYNC_DOCUMENTLIBRARY_LINKID)) { |
139 | 164 | if (($linkId = self::$decoder->getElementContent()) !== false) { |
@@ -147,16 +172,22 @@ discard block |
||
147 | 172 | if(self::$decoder->getElementStartTag(SYNC_SEARCH_VALUE)) { |
148 | 173 | $searchvalue = self::$decoder->getElementContent(); |
149 | 174 | $cpo->SetSearchValueEqualTo($searchvalue); |
150 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_VALUE |
|
175 | + if(!self::$decoder->getElementEndTag()) { |
|
176 | + // SYNC_SEARCH_VALUE |
|
151 | 177 | return false; |
178 | + } |
|
152 | 179 | } |
153 | 180 | |
154 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_EQUALTO |
|
181 | + if(!self::$decoder->getElementEndTag()) { |
|
182 | + // SYNC_SEARCH_EQUALTO |
|
155 | 183 | return false; |
184 | + } |
|
156 | 185 | } |
157 | 186 | |
158 | - if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_QUERY |
|
187 | + if(!self::$decoder->getElementEndTag()) { |
|
188 | + // SYNC_SEARCH_QUERY |
|
159 | 189 | return false; |
190 | + } |
|
160 | 191 | |
161 | 192 | } |
162 | 193 | |
@@ -166,8 +197,9 @@ discard block |
||
166 | 197 | if(self::$decoder->getElementStartTag(SYNC_SEARCH_RANGE)) { |
167 | 198 | $searchrange = self::$decoder->getElementContent(); |
168 | 199 | $cpo->SetSearchRange($searchrange); |
169 | - if(!self::$decoder->getElementEndTag()) |
|
170 | - return false; |
|
200 | + if(!self::$decoder->getElementEndTag()) { |
|
201 | + return false; |
|
202 | + } |
|
171 | 203 | } |
172 | 204 | |
173 | 205 | |
@@ -195,8 +227,9 @@ discard block |
||
195 | 227 | |
196 | 228 | if(self::$decoder->getElementStartTag(SYNC_MIMESUPPORT)) { |
197 | 229 | $cpo->SetMimeSupport(self::$decoder->getElementContent()); |
198 | - if(!self::$decoder->getElementEndTag()) |
|
199 | - return false; |
|
230 | + if(!self::$decoder->getElementEndTag()) { |
|
231 | + return false; |
|
232 | + } |
|
200 | 233 | } |
201 | 234 | |
202 | 235 | //TODO body preferences |
@@ -211,24 +244,28 @@ discard block |
||
211 | 244 | |
212 | 245 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
213 | 246 | $cpo->BodyPreference($bptype)->SetTruncationSize(self::$decoder->getElementContent()); |
214 | - if(!self::$decoder->getElementEndTag()) |
|
215 | - return false; |
|
247 | + if(!self::$decoder->getElementEndTag()) { |
|
248 | + return false; |
|
249 | + } |
|
216 | 250 | } |
217 | 251 | |
218 | 252 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
219 | 253 | $cpo->BodyPreference($bptype)->SetAllOrNone(self::$decoder->getElementContent()); |
220 | - if(!self::$decoder->getElementEndTag()) |
|
221 | - return false; |
|
254 | + if(!self::$decoder->getElementEndTag()) { |
|
255 | + return false; |
|
256 | + } |
|
222 | 257 | } |
223 | 258 | |
224 | 259 | if(self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
225 | 260 | $cpo->BodyPreference($bptype)->SetPreview(self::$decoder->getElementContent()); |
226 | - if(!self::$decoder->getElementEndTag()) |
|
227 | - return false; |
|
261 | + if(!self::$decoder->getElementEndTag()) { |
|
262 | + return false; |
|
263 | + } |
|
228 | 264 | } |
229 | 265 | |
230 | - if(!self::$decoder->getElementEndTag()) |
|
231 | - return false; |
|
266 | + if(!self::$decoder->getElementEndTag()) { |
|
267 | + return false; |
|
268 | + } |
|
232 | 269 | } |
233 | 270 | |
234 | 271 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODYPARTPREFERENCE)) { |
@@ -242,44 +279,51 @@ discard block |
||
242 | 279 | |
243 | 280 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TRUNCATIONSIZE)) { |
244 | 281 | $cpo->BodyPartPreference($bpptype)->SetTruncationSize(self::$decoder->getElementContent()); |
245 | - if(!self::$decoder->getElementEndTag()) |
|
246 | - return false; |
|
282 | + if(!self::$decoder->getElementEndTag()) { |
|
283 | + return false; |
|
284 | + } |
|
247 | 285 | } |
248 | 286 | |
249 | 287 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) { |
250 | 288 | $cpo->BodyPartPreference($bpptype)->SetAllOrNone(self::$decoder->getElementContent()); |
251 | - if(!self::$decoder->getElementEndTag()) |
|
252 | - return false; |
|
289 | + if(!self::$decoder->getElementEndTag()) { |
|
290 | + return false; |
|
291 | + } |
|
253 | 292 | } |
254 | 293 | |
255 | 294 | if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) { |
256 | 295 | $cpo->BodyPartPreference($bpptype)->SetPreview(self::$decoder->getElementContent()); |
257 | - if(!self::$decoder->getElementEndTag()) |
|
258 | - return false; |
|
296 | + if(!self::$decoder->getElementEndTag()) { |
|
297 | + return false; |
|
298 | + } |
|
259 | 299 | } |
260 | 300 | |
261 | - if (!self::$decoder->getElementEndTag()) |
|
262 | - return false; |
|
301 | + if (!self::$decoder->getElementEndTag()) { |
|
302 | + return false; |
|
303 | + } |
|
263 | 304 | } |
264 | 305 | |
265 | 306 | if(self::$decoder->getElementStartTag(SYNC_RIGHTSMANAGEMENT_SUPPORT)) { |
266 | 307 | $cpo->SetRmSupport(self::$decoder->getElementContent()); |
267 | - if(!self::$decoder->getElementEndTag()) |
|
268 | - return false; |
|
308 | + if(!self::$decoder->getElementEndTag()) { |
|
309 | + return false; |
|
310 | + } |
|
269 | 311 | } |
270 | 312 | |
271 | 313 | if(self::$decoder->getElementStartTag(SYNC_SEARCH_PICTURE)) { // TODO - do something with maxsize and maxpictures in the backend |
272 | 314 | $searchpicture = new SyncResolveRecipientsPicture(); |
273 | 315 | if(self::$decoder->getElementStartTag(SYNC_SEARCH_MAXSIZE)) { |
274 | 316 | $searchpicture->maxsize = self::$decoder->getElementContent(); |
275 | - if(!self::$decoder->getElementEndTag()) |
|
276 | - return false; |
|
317 | + if(!self::$decoder->getElementEndTag()) { |
|
318 | + return false; |
|
319 | + } |
|
277 | 320 | } |
278 | 321 | |
279 | 322 | if(self::$decoder->getElementStartTag(SYNC_SEARCH_MAXPICTURES)) { |
280 | 323 | $searchpicture->maxpictures = self::$decoder->getElementContent(); |
281 | - if(!self::$decoder->getElementEndTag()) |
|
282 | - return false; |
|
324 | + if(!self::$decoder->getElementEndTag()) { |
|
325 | + return false; |
|
326 | + } |
|
283 | 327 | } |
284 | 328 | |
285 | 329 | // iOs devices send empty picture tag: <Search:Picture/> |
@@ -297,11 +341,15 @@ discard block |
||
297 | 341 | } |
298 | 342 | } |
299 | 343 | } |
300 | - if(!self::$decoder->getElementEndTag()) //store |
|
344 | + if(!self::$decoder->getElementEndTag()) { |
|
345 | + //store |
|
301 | 346 | return false; |
347 | + } |
|
302 | 348 | |
303 | - if(!self::$decoder->getElementEndTag()) //search |
|
349 | + if(!self::$decoder->getElementEndTag()) { |
|
350 | + //search |
|
304 | 351 | return false; |
352 | + } |
|
305 | 353 | |
306 | 354 | // get SearchProvider |
307 | 355 | $searchprovider = ZPush::GetBackend()->GetSearchProvider(); |
@@ -315,18 +363,15 @@ discard block |
||
315 | 363 | if ($searchname == ISearchProvider::SEARCH_GAL) { |
316 | 364 | //get search results from the searchprovider |
317 | 365 | $rows = $searchprovider->GetGALSearchResults($searchquery, $searchrange, $searchpicture); |
318 | - } |
|
319 | - elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) { |
|
366 | + } elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) { |
|
320 | 367 | $backendFolderId = self::$deviceManager->GetBackendIdForFolderId($cpo->GetSearchFolderid()); |
321 | 368 | $cpo->SetSearchFolderid($backendFolderId); |
322 | 369 | $rows = $searchprovider->GetMailboxSearchResults($cpo); |
323 | 370 | } |
324 | - } |
|
325 | - catch (StatusException $stex) { |
|
371 | + } catch (StatusException $stex) { |
|
326 | 372 | $storestatus = $stex->getCode(); |
327 | 373 | } |
328 | - } |
|
329 | - else { |
|
374 | + } else { |
|
330 | 375 | $rows = array('searchtotal' => 0); |
331 | 376 | $status = SYNC_SEARCHSTATUS_SERVERERROR; |
332 | 377 | ZLog::Write(LOGLEVEL_WARN, sprintf("Searchtype '%s' is not supported.", $searchname)); |
@@ -441,8 +486,7 @@ discard block |
||
441 | 486 | self::$encoder->endTag();//properties |
442 | 487 | } |
443 | 488 | } |
444 | - } |
|
445 | - elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) { |
|
489 | + } elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) { |
|
446 | 490 | foreach ($rows as $u) { |
447 | 491 | // TODO: unclear if any clients *require* the folder id where the message is located (it's not available anymore) |
448 | 492 | //$folderid = self::$deviceManager->GetFolderIdForBackendId($u['folderid']); |