Commit a2aa1591 authored by Sebastian Kummer's avatar Sebastian Kummer

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.
parent a0773223
...@@ -443,6 +443,27 @@ class DeviceManager { ...@@ -443,6 +443,27 @@ class DeviceManager {
return false; return false;
} }
/**
* Returns a list of all synchronized folders. If type is false, all types are returned.
* If only certain folders are required, set the AS type here.
*
* @param array $type A list of AS foldertypes, if empty, returns all
*
* @access public
* @return array
*/
public function GetSynchronizedFolderIds($types = array()) {
$synched = array();
foreach($this->device->GetAllFolderIds() as $folderid) {
if ($this->device->GetFolderUUID($folderid)) {
if (empty($types) || in_array($this->device->GetFolderType($folderid), $types)) {
$synched[] = $folderid;
}
}
}
return $synched;
}
/** /**
* Checks if the message should be streamed to a mobile * Checks if the message should be streamed to a mobile
* Should always be called before a message is sent to the mobile * Should always be called before a message is sent to the mobile
......
...@@ -84,10 +84,25 @@ class ImportChangesStream implements IImportChanges { ...@@ -84,10 +84,25 @@ 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) && !($this->classAsString == "SyncNote" && Request::GetDeviceType() == "WindowsOutlook")) { if(!($message instanceof $this->classAsString)) {
return false; return false;
} }
// Acacia ZO-42: to sync Notes to Outlook we sync them as Tasks
if ( ZPush::GetDeviceManager()->IsOutlookClient() && $this->classAsString == "SyncNote") {
$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)) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Object '%s' discarded! Object already sent in this request.", $id)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("Object '%s' discarded! Object already sent in this request.", $id));
......
...@@ -102,6 +102,11 @@ class Ping extends RequestProcessor { ...@@ -102,6 +102,11 @@ class Ping extends RequestProcessor {
// cache requested (pingable) folderids // cache requested (pingable) folderids
$pingable = array(); $pingable = array();
// Acacia ZO-42: Outlook does never request Ping for Notes folder, so we add them manually if they are synched
if (self::$deviceManager->IsOutlookClient()) {
$pingable = self::$deviceManager->GetSynchronizedFolderIds(array(SYNC_FOLDER_TYPE_NOTE, SYNC_FOLDER_TYPE_USER_NOTE));
}
while(self::$decoder->getElementStartTag(SYNC_PING_FOLDER)) { while(self::$decoder->getElementStartTag(SYNC_PING_FOLDER)) {
WBXMLDecoder::ResetInWhile("pingFolder"); WBXMLDecoder::ResetInWhile("pingFolder");
while(WBXMLDecoder::InWhile("pingFolder")) { while(WBXMLDecoder::InWhile("pingFolder")) {
......
...@@ -446,27 +446,27 @@ class Sync extends RequestProcessor { ...@@ -446,27 +446,27 @@ 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)) {
ZLog::Write(LOGLEVEL_DEBUG, "--------------ContentClass:". $spa->GetContentClass(). " foldertype:".$foldertype); $message = ZPush::getSyncObjectFromFolderClass($spa->GetContentClass());
$message = ZPush::getSyncObjectFromFolderClass(($foldertype)?$foldertype:$spa->GetContentClass());
// Acacia sends notes as Tasks // Acacia ZO-42: OL sends Notes as Tasks
if ($spa->GetContentClass() == "Notes" && Request::GetDeviceType() == "WindowsOutlook") { 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 = new SyncTask();
} $message->Decode(self::$decoder);
$message->Decode(self::$decoder);
// Acacia: transform the SyncTask into a SyncNote
if ($spa->GetContentClass() == "Notes" && Request::GetDeviceType() == "WindowsOutlook") {
$note = new SyncNote(); $note = new SyncNote();
if (isset($message->asbody)) if (isset($message->asbody))
$note->asbody = $message->asbody; $note->asbody = $message->asbody;
if (isset($message->categories)) if (isset($message->categories))
$note->categories = $message->categories; $note->categories = $message->categories;
$note->subject = $message->subject; if (isset($message->subject))
$note->subject = $message->subject;
// TODO color of the note // TODO color of the note
$message = $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