Beispiel #1
0
 /**
  * Imports a list of folders which are to be deleted
  *
  * @param long          $flags
  * @param mixed         $sourcekeys array with sourcekeys
  *
  * @access public
  * @return
  */
 function ImportFolderDeletion($flags, $sourcekeys)
 {
     foreach ($sourcekeys as $sourcekey) {
         $this->importer->ImportFolderDeletion(SyncFolder::GetObject(bin2hex($sourcekey)));
     }
     return 0;
 }
 /**
  * Synchronizes a change
  *
  * @access public
  * @return array
  */
 public function Synchronize()
 {
     $progress = array();
     // Get one of our stored changes and send it to the importer, store the new state if
     // it succeeds
     if ($this->folderid == false) {
         if ($this->step < count($this->changes)) {
             $change = $this->changes[$this->step];
             switch ($change["type"]) {
                 case "change":
                     $folder = $this->backend->GetFolder($change["id"]);
                     $stat = $this->backend->StatFolder($change["id"]);
                     if (!$folder) {
                         return;
                     }
                     if ($this->flags & BACKEND_DISCARD_DATA || $this->importer->ImportFolderChange($folder)) {
                         $this->updateState("change", $stat);
                     }
                     break;
                 case "delete":
                     if ($this->flags & BACKEND_DISCARD_DATA || $this->importer->ImportFolderDeletion(SyncFolder::GetObject($change["id"]))) {
                         $this->updateState("delete", $change);
                     }
                     break;
             }
             $this->step++;
             $progress = array();
             $progress["steps"] = count($this->changes);
             $progress["progress"] = $this->step;
             return $progress;
         } else {
             return false;
         }
     } else {
         if ($this->step < count($this->changes)) {
             $change = $this->changes[$this->step];
             switch ($change["type"]) {
                 case "change":
                     // Note: because 'parseMessage' and 'statMessage' are two seperate
                     // calls, we have a chance that the message has changed between both
                     // calls. This may cause our algorithm to 'double see' changes.
                     $stat = $this->backend->StatMessage($this->folderid, $change["id"]);
                     $message = $this->backend->GetMessage($this->folderid, $change["id"], $this->contentparameters);
                     // copy the flag to the message
                     $message->flags = isset($change["flags"]) ? $change["flags"] : 0;
                     if ($stat && $message) {
                         if ($this->flags & BACKEND_DISCARD_DATA || $this->importer->ImportMessageChange($change["id"], $message) == true) {
                             $this->updateState("change", $stat);
                         }
                     }
                     break;
                 case "delete":
                     if ($this->flags & BACKEND_DISCARD_DATA || $this->importer->ImportMessageDeletion($change["id"]) == true) {
                         $this->updateState("delete", $change);
                     }
                     break;
                 case "flags":
                     if ($this->flags & BACKEND_DISCARD_DATA || $this->importer->ImportMessageReadFlag($change["id"], $change["flags"]) == true) {
                         $this->updateState("flags", $change);
                     }
                     break;
                 case "move":
                     if ($this->flags & BACKEND_DISCARD_DATA || $this->importer->ImportMessageMove($change["id"], $change["parent"]) == true) {
                         $this->updateState("move", $change);
                     }
                     break;
             }
             $this->step++;
             $progress = array();
             $progress["steps"] = count($this->changes);
             $progress["progress"] = $this->step;
             return $progress;
         } else {
             return false;
         }
     }
 }