/** * UnLinks all states from a folder id * Old states are removed assisting the StateMachine to get rid of old data. * The UUID is then removed from the device * * @param ASDevice $device * @param string $folderid * @param boolean $removeFromDevice indicates if the device should be * notified that the state was removed * @param boolean $retrieveUUIDFromDevice indicates if the UUID should be retrieved from * device. If not true this parameter will be used as UUID. * * @access public * @return boolean */ public static function UnLinkState(&$device, $folderid, $removeFromDevice = true, $retrieveUUIDFromDevice = true) { if ($retrieveUUIDFromDevice === true) { $savedUuid = $device->GetFolderUUID($folderid); } else { $savedUuid = $retrieveUUIDFromDevice; } if ($savedUuid) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("StateManager::UnLinkState('%s'): saved state '%s' will be deleted.", $folderid, $savedUuid)); ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::DEFTYPE, $savedUuid, self::FIXEDHIERARCHYCOUNTER * 2); ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::FOLDERDATA, $savedUuid); // CPO ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::FAILSAVE, $savedUuid, self::FIXEDHIERARCHYCOUNTER * 2); ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, $savedUuid, self::FIXEDHIERARCHYCOUNTER * 2); // remove all messages which could not be synched before $device->RemoveIgnoredMessage($folderid, false); if ($folderid === false && $savedUuid !== false) { ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::HIERARCHY, $savedUuid, self::FIXEDHIERARCHYCOUNTER * 2); } } // delete this id from the uuid cache if ($removeFromDevice) { return $device->SetFolderUUID(false, $folderid); } else { return true; } }