Commit 964cd004 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-886 Added softdelete flag to ImportMessageDeletion() of:

- IImportChanges
- ImportChangesCombined
- ImportChangesICS
- StreamImporter (puts correct tag on the stream!)
- ChangesMemoryWrapper.

Released under the Affero GNU General Public License (AGPL) version 3.
parent d664cb41
......@@ -98,19 +98,20 @@ class ImportChangesCombined implements IImportChanges {
}
/**
* Imports a deletion. This may conflict if the local object has been modified
* Imports a deletion. This may conflict if the local object has been modified.
*
* @param string $id
* @param boolean $asSoftDelete (opt) if true, the deletion is exported as "SoftDelete", else as "Remove" - default: false
*
* @access public
* @return boolean
*/
public function ImportMessageDeletion($id) {
public function ImportMessageDeletion($id, $asSoftDelete = false) {
if (!$this->icc) {
ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->ImportMessageDeletion() icc not configured");
return false;
}
return $this->icc->ImportMessageDeletion($id);
return $this->icc->ImportMessageDeletion($id, $asSoftDelete);
}
/**
......
......@@ -408,15 +408,15 @@ class ImportChangesICS implements IImportChanges {
}
/**
* Imports a deletion. This may conflict if the local object has been modified
* Imports a deletion. This may conflict if the local object has been modified.
*
* @param string $id
* @param boolean $asSoftDelete (opt) if true, the deletion is exported as "SoftDelete", else as "Remove" - default: false
*
* @access public
* @return boolean
* @throws StatusException
*/
public function ImportMessageDeletion($id) {
public function ImportMessageDeletion($id, $asSoftDelete = false) {
list(,$sk) = MAPIUtils::SplitMessageId($id);
// check if the message is in the current syncinterval
if (!$this->isMessageInSyncInterval($sk))
......
......@@ -179,6 +179,7 @@ class PHPWrapper {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("PHPWrapper->ImportMessageDeletion(): Received %d remove requests from ICS", $amount));
}
foreach($sourcekeys as $sourcekey) {
// TODO if we would know that ICS is removing the message because it's outside the sync interval, we couls send a $asSoftDelete = true to the importer. Could they pass that via $flags?
$this->importer->ImportMessageDeletion($this->prefix.bin2hex($sourcekey));
ZLog::Write(LOGLEVEL_DEBUG, sprintf("PHPWrapper->ImportMessageDeletion(): delete for :'%s'", $this->prefix.bin2hex($sourcekey)));
}
......
......@@ -45,6 +45,7 @@
class ChangesMemoryWrapper extends HierarchyCache implements IImportChanges, IExportChanges {
const CHANGE = 1;
const DELETION = 2;
const SOFTDELETION = 3;
private $changes;
private $step;
......@@ -150,13 +151,19 @@ class ChangesMemoryWrapper extends HierarchyCache implements IImportChanges, IEx
/**
* Imports a message deletion, which is imported into memory
*
* @param string $id id of message which is deleted
* @param string $id
* @param boolean $asSoftDelete (opt) if true, the deletion is exported as "SoftDelete", else as "Remove" - default: false
*
* @access public
* @return boolean
*/
public function ImportMessageDeletion($id) {
public function ImportMessageDeletion($id, $asSoftDelete = false) {
if ($asSoftDelete === true) {
$this->changes[] = array(self::SOFTDELETION, $id);
}
else {
$this->changes[] = array(self::DELETION, $id);
}
return true;
}
......@@ -181,7 +188,7 @@ class ChangesMemoryWrapper extends HierarchyCache implements IImportChanges, IEx
* @return boolean
*/
public function IsDeleted($id) {
return (array_search(array(self::DELETION, $id), $this->changes) === false) ? false:true;
return !((array_search(array(self::DELETION, $id), $this->changes) === false) && (array_search(array(self::SOFTDELETION, $id), $this->changes) === false));
}
/**
......
......@@ -140,20 +140,26 @@ class ImportChangesStream implements IImportChanges {
}
/**
* Imports a deletion
* Imports a deletion.
*
* @param string $id
* @param boolean $asSoftDelete (opt) if true, the deletion is exported as "SoftDelete", else as "Remove" - default: false
*
* @access public
* @return boolean
*/
public function ImportMessageDeletion($id) {
public function ImportMessageDeletion($id, $asSoftDelete = false) {
if ($this->checkForIgnoredMessages) {
ZPush::GetDeviceManager()->RemoveBrokenMessage($id);
}
$this->importedMsgs++;
if ($asSoftDelete) {
$this->encoder->startTag(SYNC_SOFTDELETE);
}
else {
$this->encoder->startTag(SYNC_REMOVE);
}
$this->encoder->startTag(SYNC_SERVERENTRYID);
$this->encoder->content($id);
$this->encoder->endTag();
......
......@@ -119,16 +119,15 @@ class ImportChangesDiff extends DiffState implements IImportChanges {
}
/**
* Imports a deletion. This may conflict if the local object has been modified
* Imports a deletion. This may conflict if the local object has been modified.
*
* @param string $id
* @param SyncObject $message
* @param boolean $asSoftDelete (opt) if true, the deletion is exported as "SoftDelete", else as "Remove" - default: false
*
* @access public
* @return boolean
* @throws StatusException
*/
public function ImportMessageDeletion($id) {
public function ImportMessageDeletion($id, $asSoftDelete = false) {
//do nothing if it is in a dummy folder
if ($this->folderid == SYNC_FOLDER_TYPE_DUMMY)
throw new StatusException(sprintf("ImportChangesDiff->ImportMessageDeletion('%s'): can not be done on a dummy folder", $id), SYNC_STATUS_SYNCCANNOTBECOMPLETED);
......
......@@ -75,15 +75,15 @@ interface IImportChanges extends IChanges {
public function ImportMessageChange($id, $message);
/**
* Imports a deletion. This may conflict if the local object has been modified
* Imports a deletion. This may conflict if the local object has been modified.
*
* @param string $id
* @param boolean $asSoftDelete (opt) if true, the deletion is exported as "SoftDelete", else as "Remove" - default: false
*
* @access public
* @return boolean
* @throws StatusException
*/
public function ImportMessageDeletion($id);
public function ImportMessageDeletion($id, $asSoftDelete = false);
/**
* Imports a change in 'read' flag
......
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