Commit f4bccba4 authored by skummer's avatar skummer

ZP-148

- added: a method to DeviceManager to remove previously ignored objects from the device data 
- changed: StreamImporter->ImportMessageDeletion() excludes a previously ignored object from the device data
- changed: the DeviceManager should always be present when using the StreamImporter. If not, it should be loaded anyway

git-svn-id: https://z-push.org/svn/z-push/trunk@1373 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 18e2ed76
...@@ -431,6 +431,23 @@ class DeviceManager { ...@@ -431,6 +431,23 @@ class DeviceManager {
return false; return false;
} }
/**
* Removes device information about a broken message as it is been removed from the mobile.
*
* @param string $id message id
*
* @access public
* @return boolean
*/
public function RemoveBrokenMessage($id) {
$folderid = $this->getLatestFolder();
if ($this->device->RemoveIgnoredMessage($folderid, $id)) {
ZLog::Write(LOGLEVEL_INFO, sprintf("DeviceManager->RemoveBrokenMessage('%s', '%s'): cleared data about previously ignored message", $folderid, $id));
return true;
}
return false;
}
/** /**
* Amount of items to me synchronized * Amount of items to me synchronized
* *
......
...@@ -46,6 +46,7 @@ class ImportChangesStream implements IImportChanges { ...@@ -46,6 +46,7 @@ class ImportChangesStream implements IImportChanges {
private $objclass; private $objclass;
private $seenObjects; private $seenObjects;
private $importedMsgs; private $importedMsgs;
private $checkForIgnoredMessages;
/** /**
* Constructor of the StreamImporter * Constructor of the StreamImporter
...@@ -61,6 +62,7 @@ class ImportChangesStream implements IImportChanges { ...@@ -61,6 +62,7 @@ class ImportChangesStream implements IImportChanges {
$this->classAsString = (is_object($class))?get_class($class):''; $this->classAsString = (is_object($class))?get_class($class):'';
$this->seenObjects = array(); $this->seenObjects = array();
$this->importedMsgs = 0; $this->importedMsgs = 0;
$this->checkForIgnoredMessages = true;
} }
/** /**
...@@ -94,9 +96,15 @@ class ImportChangesStream implements IImportChanges { ...@@ -94,9 +96,15 @@ class ImportChangesStream implements IImportChanges {
$this->seenObjects[] = $id; $this->seenObjects[] = $id;
// checks if the next message may cause a loop or is broken // checks if the next message may cause a loop or is broken
if (ZPush::GetDeviceManager(false) && ZPush::GetDeviceManager()->DoNotStreamMessage($id, $message)) { if (ZPush::GetDeviceManager()->DoNotStreamMessage($id, $message)) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesStream->ImportMessageChange('%s'): message ignored and requested to be removed from mobile", $id)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesStream->ImportMessageChange('%s'): message ignored and requested to be removed from mobile", $id));
return $this->ImportMessageDeletion($id);
// this is an internal operation & should not trigger an update in the device manager
$this->checkForIgnoredMessages = false;
$stat = $this->ImportMessageDeletion($id);
$this->checkForIgnoredMessages = true;
return $stat;
} }
if ($message->flags === false || $message->flags === SYNC_NEWMESSAGE) if ($message->flags === false || $message->flags === SYNC_NEWMESSAGE)
...@@ -133,6 +141,10 @@ class ImportChangesStream implements IImportChanges { ...@@ -133,6 +141,10 @@ class ImportChangesStream implements IImportChanges {
* @return boolean * @return boolean
*/ */
public function ImportMessageDeletion($id) { public function ImportMessageDeletion($id) {
if ($this->checkForIgnoredMessages) {
ZPush::GetDeviceManager()->RemoveBrokenMessage($id);
}
$this->importedMsgs++; $this->importedMsgs++;
$this->encoder->startTag(SYNC_REMOVE); $this->encoder->startTag(SYNC_REMOVE);
$this->encoder->startTag(SYNC_SERVERENTRYID); $this->encoder->startTag(SYNC_SERVERENTRYID);
......
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