Commit dc33ea48 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #10 in ZO/z-push from feature/ZO-42-notes-synchronization to develop

* commit 'ac1e300d':
  ZP-54 Outlook does send Notes folders, but as Tasks. States have to be loaded for these cases as well. Removed GetSynchedFolderIds from DeviceManager. Changed order in checks to get a bit more performance.
  ZP-42 Undo change from additional contact prototyping.
  ZP-54 Rewrite SyncNote as SyncTask when sending and read SyncTask and convert to SyncNote for saving. Add Note folders manually to pingable folders for Outlook.
  ZO-42 First prototype. (cherry picked from commit 9f395cf9)
parents d979598c ac1e300d
...@@ -84,8 +84,24 @@ class ImportChangesStream implements IImportChanges { ...@@ -84,8 +84,24 @@ class ImportChangesStream implements IImportChanges {
*/ */
public function ImportMessageChange($id, $message) { public function ImportMessageChange($id, $message) {
// ignore other SyncObjects // ignore other SyncObjects
if(!($message instanceof $this->classAsString)) if(!($message instanceof $this->classAsString)) {
return false; return false;
}
// Acacia ZO-42: to sync Notes to Outlook we sync them as Tasks
if ($this->classAsString == "SyncNote" && ZPush::GetDeviceManager()->IsOutlookClient()) {
$task = new SyncTask();
$task->flags = $message->flags;
if (isset($message->asbody))
$task->asbody = $message->asbody;
if (isset($message->categories))
$task->categories = $message->categories;
if (isset($message->subject))
$task->subject = $message->subject;
// TODO color of the note
$message = $task;
}
// prevent sending the same object twice in one request // prevent sending the same object twice in one request
if (in_array($id, $this->seenObjects)) { if (in_array($id, $this->seenObjects)) {
......
...@@ -137,11 +137,10 @@ class Ping extends RequestProcessor { ...@@ -137,11 +137,10 @@ class Ping extends RequestProcessor {
$fakechanges[$folderid] = 1; $fakechanges[$folderid] = 1;
$foundchanges = true; $foundchanges = true;
} }
else if ($class == $spa->GetContentClass()) { else if ($this->isClassValid($class, $spa)) {
$pingable[] = $folderid; $pingable[] = $folderid;
ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): using saved sync state for '%s' id '%s'", $spa->GetContentClass(), $folderid)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): using saved sync state for '%s' id '%s'", $spa->GetContentClass(), $folderid));
} }
} }
if(!self::$decoder->getElementEndTag()) if(!self::$decoder->getElementEndTag())
return false; return false;
...@@ -272,4 +271,23 @@ class Ping extends RequestProcessor { ...@@ -272,4 +271,23 @@ class Ping extends RequestProcessor {
} }
return true; return true;
} }
/**
* Checks if a sent folder class is valid for that SyncParameters object.
*
* @param string $class
* @param SycnParameters $spa
*
* @access public
* @return boolean
*/
private function isClassValid($class, $spa) {
if ($class == $spa->GetContentClass() ||
// Acacia ZO-42: Notes are synched as Tasks
(self::$deviceManager->IsOutlookClient() && $class == "Tasks" && $spa->GetContentClass() == "Notes")
) {
return true;
}
return false;
}
} }
...@@ -452,7 +452,26 @@ class Sync extends RequestProcessor { ...@@ -452,7 +452,26 @@ class Sync extends RequestProcessor {
// Get the SyncMessage if sent // Get the SyncMessage if sent
if(($el = self::$decoder->getElementStartTag(SYNC_DATA)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) { if(($el = self::$decoder->getElementStartTag(SYNC_DATA)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) {
$message = ZPush::getSyncObjectFromFolderClass($spa->GetContentClass()); $message = ZPush::getSyncObjectFromFolderClass($spa->GetContentClass());
$message->Decode(self::$decoder);
// Acacia ZO-42: OL sends Notes as Tasks
if ($spa->GetContentClass() == "Notes" && self::$deviceManager->IsOutlookClient()) {
ZLog::Write(LOGLEVEL_DEBUG, "HandleSync(): Outlook sends Notes as Tasks, read as Tasks and convert it into a SyncNote object.");
$message = new SyncTask();
$message->Decode(self::$decoder);
$note = new SyncNote();
if (isset($message->asbody))
$note->asbody = $message->asbody;
if (isset($message->categories))
$note->categories = $message->categories;
if (isset($message->subject))
$note->subject = $message->subject;
// TODO color of the note
$message = $note;
}
else {
$message->Decode(self::$decoder);
}
// set Ghosted fields // set Ghosted fields
$message->emptySupported(self::$deviceManager->GetSupportedFields($spa->GetFolderId())); $message->emptySupported(self::$deviceManager->GetSupportedFields($spa->GetFolderId()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment