..also comment out the defines for constants used in commands that are not yet implemented.
define("SYNC_MOVE_STATUS","Move:Status");
define("SYNC_MOVE_DSTMSGID","Move:DstMsgId");
-// GetItemEstimate
-define("SYNC_GETITEMESTIMATE_GETITEMESTIMATE","GetItemEstimate:GetItemEstimate");
-define("SYNC_GETITEMESTIMATE_VERSION","GetItemEstimate:Version");
-define("SYNC_GETITEMESTIMATE_FOLDERS","GetItemEstimate:Folders");
-define("SYNC_GETITEMESTIMATE_FOLDER","GetItemEstimate:Folder");
-define("SYNC_GETITEMESTIMATE_FOLDERTYPE","GetItemEstimate:FolderType");
-define("SYNC_GETITEMESTIMATE_FOLDERID","GetItemEstimate:FolderId");
-define("SYNC_GETITEMESTIMATE_DATETIME","GetItemEstimate:DateTime");
-define("SYNC_GETITEMESTIMATE_ESTIMATE","GetItemEstimate:Estimate");
-define("SYNC_GETITEMESTIMATE_RESPONSE","GetItemEstimate:Response");
-define("SYNC_GETITEMESTIMATE_STATUS","GetItemEstimate:Status");
-
-// FolderHierarchy
-define("SYNC_FOLDERHIERARCHY_FOLDERS","FolderHierarchy:Folders");
-define("SYNC_FOLDERHIERARCHY_FOLDER","FolderHierarchy:Folder");
-define("SYNC_FOLDERHIERARCHY_DISPLAYNAME","FolderHierarchy:DisplayName");
-define("SYNC_FOLDERHIERARCHY_SERVERENTRYID","FolderHierarchy:ServerEntryId");
-define("SYNC_FOLDERHIERARCHY_PARENTID","FolderHierarchy:ParentId");
-define("SYNC_FOLDERHIERARCHY_TYPE","FolderHierarchy:Type");
-define("SYNC_FOLDERHIERARCHY_RESPONSE","FolderHierarchy:Response");
-define("SYNC_FOLDERHIERARCHY_STATUS","FolderHierarchy:Status");
-define("SYNC_FOLDERHIERARCHY_CONTENTCLASS","FolderHierarchy:ContentClass");
-define("SYNC_FOLDERHIERARCHY_CHANGES","FolderHierarchy:Changes");
-define("SYNC_FOLDERHIERARCHY_ADD","FolderHierarchy:Add");
-define("SYNC_FOLDERHIERARCHY_REMOVE","FolderHierarchy:Remove");
-define("SYNC_FOLDERHIERARCHY_UPDATE","FolderHierarchy:Update");
-define("SYNC_FOLDERHIERARCHY_SYNCKEY","FolderHierarchy:SyncKey");
-define("SYNC_FOLDERHIERARCHY_FOLDERCREATE","FolderHierarchy:FolderCreate");
-define("SYNC_FOLDERHIERARCHY_FOLDERDELETE","FolderHierarchy:FolderDelete");
-define("SYNC_FOLDERHIERARCHY_FOLDERUPDATE","FolderHierarchy:FolderUpdate");
-define("SYNC_FOLDERHIERARCHY_FOLDERSYNC","FolderHierarchy:FolderSync");
-define("SYNC_FOLDERHIERARCHY_COUNT","FolderHierarchy:Count");
-define("SYNC_FOLDERHIERARCHY_VERSION","FolderHierarchy:Version");
-
// MeetingResponse
define("SYNC_MEETINGRESPONSE_CALENDARID","MeetingResponse:CalendarId");
define("SYNC_MEETINGRESPONSE_FOLDERID","MeetingResponse:FolderId");
define("SYNC_VALIDATECERT_CHECKCRL","ValidateCert:CheckCRL");
define("SYNC_VALIDATECERT_STATUS","ValidateCert:Status");
-// Ping
-define("SYNC_PING_PING","Ping:Ping");
-define("SYNC_PING_STATUS","Ping:Status");
-define("SYNC_PING_LIFETIME", "Ping:LifeTime");
-define("SYNC_PING_FOLDERS", "Ping:Folders");
-define("SYNC_PING_FOLDER", "Ping:Folder");
-define("SYNC_PING_SERVERENTRYID", "Ping:ServerEntryId");
-define("SYNC_PING_FOLDERTYPE", "Ping:FolderType");
-
-//Provision
-define("SYNC_PROVISION_PROVISION", "Provision:Provision");
-define("SYNC_PROVISION_POLICIES", "Provision:Policies");
-define("SYNC_PROVISION_POLICY", "Provision:Policy");
-define("SYNC_PROVISION_POLICYTYPE", "Provision:PolicyType");
-define("SYNC_PROVISION_POLICYKEY", "Provision:PolicyKey");
-define("SYNC_PROVISION_DATA", "Provision:Data");
-define("SYNC_PROVISION_STATUS", "Provision:Status");
-define("SYNC_PROVISION_REMOTEWIPE", "Provision:RemoteWipe");
-define("SYNC_PROVISION_EASPROVISIONDOC", "Provision:EASProvisionDoc");
-
//Search
define("SYNC_SEARCH_SEARCH", "Search:Search");
define("SYNC_SEARCH_STORE", "Search:Store");
define("SYNC_GAL_MOBILEPHONE", "GAL:MobilePhone");
define("SYNC_GAL_EMAILADDRESS", "GAL:EmailAddress");
-// Other constants
-define("SYNC_FOLDER_TYPE_OTHER", 1);
-define("SYNC_FOLDER_TYPE_INBOX", 2);
-define("SYNC_FOLDER_TYPE_DRAFTS", 3);
-define("SYNC_FOLDER_TYPE_WASTEBASKET", 4);
-define("SYNC_FOLDER_TYPE_SENTMAIL", 5);
-define("SYNC_FOLDER_TYPE_OUTBOX", 6);
-define("SYNC_FOLDER_TYPE_TASK", 7);
-define("SYNC_FOLDER_TYPE_APPOINTMENT", 8);
-define("SYNC_FOLDER_TYPE_CONTACT", 9);
-define("SYNC_FOLDER_TYPE_NOTE", 10);
-define("SYNC_FOLDER_TYPE_JOURNAL", 11);
-define("SYNC_FOLDER_TYPE_USER_MAIL", 12);
-define("SYNC_FOLDER_TYPE_USER_APPOINTMENT", 13);
-define("SYNC_FOLDER_TYPE_USER_CONTACT", 14);
-define("SYNC_FOLDER_TYPE_USER_TASK", 15);
-define("SYNC_FOLDER_TYPE_USER_JOURNAL", 16);
-define("SYNC_FOLDER_TYPE_USER_NOTE", 17);
-define("SYNC_FOLDER_TYPE_UNKNOWN", 18);
-define("SYNC_FOLDER_TYPE_RECIPIENT_CACHE", 19);
-define("SYNC_FOLDER_TYPE_DUMMY", "__dummy.Folder.Id__");
-
/**
* Main ActiveSync class. Entry point for performing all ActiveSync operations
*
const TRUNCATION_SEVEN = 7;
const TRUNCATION_ALL = 9;
- /* Request related constants */
+ /* Request related constants that are used in multiple places */
+ /* FOLDERHIERARCHY */
+ const FOLDERHIERARCHY_FOLDERS = 'FolderHierarchy:Folders';
+ const FOLDERHIERARCHY_FOLDER = 'FolderHierarchy:Folder';
+ const FOLDERHIERARCHY_DISPLAYNAME = 'FolderHierarchy:DisplayName';
+ const FOLDERHIERARCHY_SERVERENTRYID = 'FolderHierarchy:ServerEntryId';
+ const FOLDERHIERARCHY_PARENTID = 'FolderHierarchy:ParentId';
+ const FOLDERHIERARCHY_TYPE = 'FolderHierarchy:Type';
+ const FOLDERHIERARCHY_RESPONSE = 'FolderHierarchy:Response';
+ const FOLDERHIERARCHY_STATUS = 'FolderHierarchy:Status';
+ const FOLDERHIERARCHY_CONTENTCLASS = 'FolderHierarchy:ContentClass';
+ const FOLDERHIERARCHY_CHANGES = 'FolderHierarchy:Changes';
+ const FOLDERHIERARCHY_ADD = 'FolderHierarchy:Add';
+ const FOLDERHIERARCHY_REMOVE = 'FolderHierarchy:Remove';
+ const FOLDERHIERARCHY_UPDATE = 'FolderHierarchy:Update';
+ const FOLDERHIERARCHY_SYNCKEY = 'FolderHierarchy:SyncKey';
+ const FOLDERHIERARCHY_FOLDERCREATE = 'FolderHierarchy:FolderCreate';
+ const FOLDERHIERARCHY_FOLDERDELETE = 'FolderHierarchy:FolderDelete';
+ const FOLDERHIERARCHY_FOLDERUPDATE = 'FolderHierarchy:FolderUpdate';
+ const FOLDERHIERARCHY_FOLDERSYNC = 'FolderHierarchy:FolderSync';
+ const FOLDERHIERARCHY_COUNT = 'FolderHierarchy:Count';
+ const FOLDERHIERARCHY_VERSION = 'FolderHierarchy:Version';
+
/* SYNC */
const SYNC_SYNCHRONIZE = 'Synchronize';
const SYNC_REPLIES = 'Replies';
const SYNC_MIMESUPPORT = 'MIMESupport';
const SYNC_MIMETRUNCATION = 'MIMETruncation';
+ /* PROVISION */
+ const PROVISION_PROVISION = 'Provision:Provision';
+ const PROVISION_POLICIES = 'Provision:Policies';
+ const PROVISION_POLICY = 'Provision:Policy';
+ const PROVISION_POLICYTYPE = 'Provision:PolicyType';
+ const PROVISION_POLICYKEY = 'Provision:PolicyKey';
+ const PROVISION_DATA = 'Provision:Data';
+ const PROVISION_STATUS = 'Provision:Status';
+ const PROVISION_REMOTEWIPE = 'Provision:RemoteWipe';
+ const PROVISION_EASPROVISIONDOC = 'Provision:EASProvisionDoc';
+
/* Flags */
const FLAG_NEWMESSAGE = 'NewMessage';
+ /* Folder types */
+ // Other constants
+ const FOLDER_TYPE_OTHER = 1;
+ const FOLDER_TYPE_INBOX = 2;
+ const FOLDER_TYPE_DRAFTS = 3;
+ const FOLDER_TYPE_WASTEBASKET = 4;
+ const FOLDER_TYPE_SENTMAIL = 5;
+ const FOLDER_TYPE_OUTBOX = 6;
+ const FOLDER_TYPE_TASK = 7;
+ const FOLDER_TYPE_APPOINTMENT = 8;
+ const FOLDER_TYPE_CONTACT = 9;
+ const FOLDER_TYPE_NOTE = 10;
+ const FOLDER_TYPE_JOURNAL = 11;
+ const FOLDER_TYPE_USER_MAIL = 12;
+ const FOLDER_TYPE_USER_APPOINTMENT = 13;
+ const FOLDER_TYPE_USER_CONTACT = 14;
+ const FOLDER_TYPE_USER_TASK = 15;
+ const FOLDER_TYPE_USER_JOURNAL = 16;
+ const FOLDER_TYPE_USER_NOTE = 17;
+ const FOLDER_TYPE_UNKNOWN = 18;
+ const FOLDER_TYPE_RECIPIENT_CACHE = 19;
+ const FOLDER_TYPE_DUMMY = '__dummy.Folder.Id__';
+
/**
* Logger
*
$this->_stateMachine->setFolderData($devid, $folders);
$this->_encoder->StartWBXML();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERS);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_FOLDERS);
foreach ($folders as $folder) {
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDER);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_FOLDER);
$folder->encodeStream($this->_encoder);
$this->_encoder->endTag();
}
$create = $update = $delete = false;
- if ($el[Horde_ActiveSync_Wbxml::EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERCREATE) {
+ if ($el[Horde_ActiveSync_Wbxml::EN_TAG] == self::FOLDERHIERARCHY_FOLDERCREATE) {
$create = true;
- } elseif ($el[Horde_ActiveSync_Wbxml::EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERUPDATE) {
+ } elseif ($el[Horde_ActiveSync_Wbxml::EN_TAG] == self::FOLDERHIERARCHY_FOLDERUPDATE) {
$update = true;
- } elseif ($el[Horde_ActiveSync_Wbxml::EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERDELETE) {
+ } elseif ($el[Horde_ActiveSync_Wbxml::EN_TAG] == self::FOLDERHIERARCHY_FOLDERDELETE) {
$delete = true;
}
}
// SyncKey
- if (!$this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) {
+ if (!$this->_decoder->getElementStartTag(self::FOLDERHIERARCHY_SYNCKEY)) {
return false;
}
$synckey = $this->_decoder->getElementContent();
// ServerID
$serverid = false;
- if ($this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID)) {
+ if ($this->_decoder->getElementStartTag(self::FOLDERHIERARCHY_SERVERENTRYID)) {
$serverid = $this->_decoder->getElementContent();
if (!$this->_decoder->getElementEndTag()) {
return false;
if (!$delete) {
// Parent
$parentid = false;
- if ($this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_PARENTID)) {
+ if ($this->_decoder->getElementStartTag(self::FOLDERHIERARCHY_PARENTID)) {
$parentid = $this->_decoder->getElementContent();
if (!$this->_decoder->getElementEndTag()) {
return false;
}
// Displayname
- if (!$this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_DISPLAYNAME)) {
+ if (!$this->_decoder->getElementStartTag(self::FOLDERHIERARCHY_DISPLAYNAME)) {
return false;
}
$displayname = $this->_decoder->getElementContent();
// Type
$type = false;
- if ($this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_TYPE)) {
+ if ($this->_decoder->getElementStartTag(self::FOLDERHIERARCHY_TYPE)) {
$type = $this->_decoder->getElementContent();
if (!$this->_decoder->getElementEndTag()) {
return false;
// add folder id to the seen folders
$seenfolders[] = $serverid;
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERCREATE);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_FOLDERCREATE);
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_STATUS);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_STATUS);
$this->_encoder->content(1);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_SYNCKEY);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_SYNCKEY);
$this->_encoder->content($newsynckey);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_SERVERENTRYID);
$this->_encoder->content($serverid);
$this->_encoder->endTag();
$this->_encoder->endTag();
} elseif ($update) {
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERUPDATE);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_FOLDERUPDATE);
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_STATUS);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_STATUS);
$this->_encoder->content(1);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_SYNCKEY);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_SYNCKEY);
$this->_encoder->content($newsynckey);
$this->_encoder->endTag();
$this->_encoder->endTag();
} elseif ($delete) {
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERDELETE);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_FOLDERDELETE);
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_STATUS);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_STATUS);
$this->_encoder->content($deletedstat);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_SYNCKEY);
+ $this->_encoder->startTag(self::FOLDERHIERARCHY_SYNCKEY);
$this->_encoder->content($newsynckey);
$this->_encoder->endTag();
public function ImportMessageChange($id, $message)
{
/* do nothing if it is in a dummy folder */
- if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) {
+ if ($this->_folderId == Horde_ActiveSync::FOLDER_TYPE_DUMMY) {
return false;
}
public function ImportMessageDeletion($id)
{
/* Do nothing if it is in a dummy folder */
- if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) {
+ if ($this->_folderId == Horde_ActiveSync::FOLDER_TYPE_DUMMY) {
return true;
}
public function ImportMessageReadFlag($id, $flags)
{
/* Do nothing if it is a dummy folder */
- if ($this->_folderId == SYNC_FOLDER_TYPE_DUMMY) {
+ if ($this->_folderId == Horde_ActiveSync::FOLDER_TYPE_DUMMY) {
return true;
}
public function ImportFolderChange($id, $parent, $displayname, $type)
{
/* do nothing if it is a dummy folder */
- if ($parent == SYNC_FOLDER_TYPE_DUMMY) {
+ if ($parent == Horde_ActiveSync::FOLDER_TYPE_DUMMY) {
return false;
}
public function ImportFolderDeletion($id, $parent)
{
/* Do nothing if it is a dummy folder */
- if ($parent == SYNC_FOLDER_TYPE_DUMMY) {
+ if ($parent == Horde_ActiveSync::FOLDER_TYPE_DUMMY) {
return false;
}
switch ($id) {
case self::APPOINTMENTS_FOLDER:
- $folder->type = SYNC_FOLDER_TYPE_APPOINTMENT;
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT;
break;
case self::CONTACTS_FOLDER:
- $folder->type = SYNC_FOLDER_TYPE_CONTACT;
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_CONTACT;
break;
case self::TASKS_FOLDER:
- $folder->type = SYNC_FOLDER_TYPE_TASK;
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_TASK;
break;
default:
return false;
public function __construct($params = array())
{
$mapping = array (
- SYNC_FOLDERHIERARCHY_SERVERENTRYID => array (Horde_ActiveSync_Message_Base::KEY_ATTRIBUTE => 'serverid'),
- SYNC_FOLDERHIERARCHY_PARENTID => array (Horde_ActiveSync_Message_Base::KEY_ATTRIBUTE => 'parentid'),
- SYNC_FOLDERHIERARCHY_DISPLAYNAME => array (Horde_ActiveSync_Message_Base::KEY_ATTRIBUTE => 'displayname'),
- SYNC_FOLDERHIERARCHY_TYPE => array (Horde_ActiveSync_Message_Base::KEY_ATTRIBUTE => 'type')
+ Horde_ActiveSync::FOLDERHIERARCHY_SERVERENTRYID => array (Horde_ActiveSync_Message_Base::KEY_ATTRIBUTE => 'serverid'),
+ Horde_ActiveSync::FOLDERHIERARCHY_PARENTID => array (Horde_ActiveSync_Message_Base::KEY_ATTRIBUTE => 'parentid'),
+ Horde_ActiveSync::FOLDERHIERARCHY_DISPLAYNAME => array (Horde_ActiveSync_Message_Base::KEY_ATTRIBUTE => 'displayname'),
+ Horde_ActiveSync::FOLDERHIERARCHY_TYPE => array (Horde_ActiveSync_Message_Base::KEY_ATTRIBUTE => 'type')
);
parent::__construct($mapping, $params);
$map = array();
/* Start parsing input */
- if (!$this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC)) {
+ if (!$this->_decoder->getElementStartTag(Horde_ActiveSync::FOLDERHIERARCHY_FOLDERSYNC)) {
$this->_logger->err('[Horde_ActiveSync::handleFolderSync] No input to parse');
$this->_statusCode = self::STATUS_PROTOERR;
$this->_handleError();
}
/* Get the current synckey from PIM */
- if (!$this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) {
+ if (!$this->_decoder->getElementStartTag(Horde_ActiveSync::FOLDERHIERARCHY_SYNCKEY)) {
$this->_logger->err('[Horde_ActiveSync::handleFolderSync] No input to parse');
$this->_statusCode = self::STATUS_PROTOERR;
$this->_handleError();
$this->_logger->debug('[Horde_ActiveSync::handleFolderSync] newSyncKey: ' . $newsynckey);
/* Deal with folder hierarchy changes */
- if ($this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_CHANGES)) {
+ if ($this->_decoder->getElementStartTag(Horde_ActiveSync::FOLDERHIERARCHY_CHANGES)) {
// Ignore <Count> if present
- if ($this->_decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_COUNT)) {
+ if ($this->_decoder->getElementStartTag(Horde_ActiveSync::FOLDERHIERARCHY_COUNT)) {
$this->_decoder->getElementContent();
if (!$this->_decoder->getElementEndTag()) {
$this->_statusCode = self::STATUS_PROTOERR;
// Output our WBXML reply now
$this->_encoder->StartWBXML();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_FOLDERSYNC);
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_STATUS);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_STATUS);
$this->_encoder->content($this->_statusCode);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_SYNCKEY);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_SYNCKEY);
$this->_encoder->content($newsynckey);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_CHANGES);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_CHANGES);
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_COUNT);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_COUNT);
$this->_encoder->content($connector->count);
$this->_encoder->endTag();
if (count($connector->changed) > 0) {
foreach ($connector->changed as $folder) {
if (isset($folder->serverid) && in_array($folder->serverid, $seenfolders)) {
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_UPDATE);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_UPDATE);
} else {
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_ADD);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_ADD);
}
$folder->encodeStream($this->_encoder);
$this->_encoder->endTag();
if (count($connector->deleted) > 0) {
foreach ($connector->deleted as $folder) {
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_REMOVE);
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_REMOVE);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_SERVERENTRYID);
$this->_encoder->content($folder);
$this->_encoder->endTag();
$this->_encoder->endTag();
private function _handleError()
{
$this->_encoder->StartWBXML();
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC);
- $this->_encoder->startTag(SYNC_FOLDERHIERARCHY_STATUS);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_FOLDERSYNC);
+ $this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_STATUS);
$this->_encoder->content($this->_statusCode);
$this->_encoder->endTag();
$this->_encoder->endTag();
const STATUS_NOTPRIMED = 3;
const STATUS_KEYMISM = 4;
+ /* Request tag constants */
+ const GETITEMESTIMATE = 'GetItemEstimate:GetItemEstimate';
+ const VERSION = 'GetItemEstimate:Version';
+ const FOLDERS = 'GetItemEstimate:Folders';
+ const FOLDER = 'GetItemEstimate:Folder';
+ const FOLDERTYPE = 'GetItemEstimate:FolderType';
+ const FOLDERID = 'GetItemEstimate:FolderId';
+ const DATETIME = 'GetItemEstimate:DateTime';
+ const ESTIMATE = 'GetItemEstimate:Estimate';
+ const RESPONSE = 'GetItemEstimate:Response';
+ const STATUS = 'GetItemEstimate:Status';
+
/**
* Handle the request
*
$status = array();
$collections = array();
- if (!$this->_decoder->getElementStartTag(SYNC_GETITEMESTIMATE_GETITEMESTIMATE) ||
- !$this->_decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERS)) {
+ if (!$this->_decoder->getElementStartTag(self::GETITEMESTIMATE) ||
+ !$this->_decoder->getElementStartTag(self::FOLDERS)) {
// Not sure why the protocol doesn't have a status for this...
return false;
}
/* Obtain all the collections we are getting estimates for */
- while ($this->_decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDER)) {
+ while ($this->_decoder->getElementStartTag(self::FOLDER)) {
/* Status - Assume success */
$cStatus = self::STATUS_SUCCESS;
/* Collection Class */
- if (!$this->_decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERTYPE)) {
+ if (!$this->_decoder->getElementStartTag(self::FOLDERTYPE)) {
return false;
}
$class = $this->_decoder->getElementContent();
}
/* Collection Id */
- if ($this->_decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERID)) {
+ if ($this->_decoder->getElementStartTag(self::FOLDERID)) {
$collectionid = $this->_decoder->getElementContent();
if (!$this->_decoder->getElementEndTag()) {
return false;
$this->_encoder->startWBXML();
/* Start getting the actual esitmates and outputting the results */
- $this->_encoder->startTag(SYNC_GETITEMESTIMATE_GETITEMESTIMATE);
+ $this->_encoder->startTag(self::GETITEMESTIMATE);
foreach ($collections as $collection) {
- $this->_encoder->startTag(SYNC_GETITEMESTIMATE_RESPONSE);
- $this->_encoder->startTag(SYNC_GETITEMESTIMATE_STATUS);
+ $this->_encoder->startTag(self::RESPONSE);
+ $this->_encoder->startTag(self::STATUS);
$this->_encoder->content($status[$collection['id']]);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_GETITEMESTIMATE_FOLDER);
- $this->_encoder->startTag(SYNC_GETITEMESTIMATE_FOLDERTYPE);
+ $this->_encoder->startTag(self::FOLDER);
+ $this->_encoder->startTag(self::FOLDERTYPE);
$this->_encoder->content($collection['class']);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_GETITEMESTIMATE_FOLDERID);
+ $this->_encoder->startTag(self::FOLDERID);
$this->_encoder->content($collection['id']);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_GETITEMESTIMATE_ESTIMATE);
+ $this->_encoder->startTag(self::ESTIMATE);
$importer = new Horde_ActiveSync_Connector_NullImporter();
$state = $this->_driver->getStateObject($collection);
const STATUS_FOLDERSYNCREQD = 7;
const STATUS_SERVERERROR = 8;
+ // Ping
+ const PING = 'Ping:Ping';
+ const STATUS = 'Ping:Status';
+ const LIFETIME = 'Ping:LifeTime';
+ const FOLDERS = 'Ping:Folders';
+ const FOLDER = 'Ping:Folder';
+ const SERVERENTRYID = 'Ping:ServerEntryId';
+ const FOLDERTYPE = 'Ping:FolderType';
+
/**
* Handle a PING command from the PIM. Ping is sent periodically by the PIM
* to tell the server what folders we are interested in monitoring for
$lifetime = $state->getPingLifetime();
/* Build the $collections array if we receive request from PIM */
- if ($this->_decoder->getElementStartTag(SYNC_PING_PING)) {
- if ($this->_decoder->getElementStartTag(SYNC_PING_LIFETIME)) {
+ if ($this->_decoder->getElementStartTag(self::PING)) {
+ if ($this->_decoder->getElementStartTag(self::LIFETIME)) {
$lifetime = $this->_decoder->getElementContent();
$state->setPingLifetime($lifetime);
$this->_decoder->getElementEndTag();
}
- if ($this->_decoder->getElementStartTag(SYNC_PING_FOLDERS)) {
+ if ($this->_decoder->getElementStartTag(self::FOLDERS)) {
$collections = array();
- while ($this->_decoder->getElementStartTag(SYNC_PING_FOLDER)) {
+ while ($this->_decoder->getElementStartTag(self::FOLDER)) {
$collection = array();
- if ($this->_decoder->getElementStartTag(SYNC_PING_SERVERENTRYID)) {
+ if ($this->_decoder->getElementStartTag(self::SERVERENTRYID)) {
$collection['id'] = $this->_decoder->getElementContent();
$this->_decoder->getElementEndTag();
}
- if ($this->_decoder->getElementStartTag(SYNC_PING_FOLDERTYPE)) {
+ if ($this->_decoder->getElementStartTag(self::FOLDERTYPE)) {
$collection['class'] = $this->_decoder->getElementContent();
$this->_decoder->getElementEndTag();
}
//check the remote wipe status
if ($this->_provisioning === true) {
$rwstatus = $state->getDeviceRWStatus($this->_devId);
- if ($rwstatus == SYNC_PROVISION_RWSTATUS_PENDING || $rwstatus == SYNC_PROVISION_RWSTATUS_WIPED) {
+ if ($rwstatus == Horde_ActiveSync::PROVISION_RWSTATUS_PENDING || $rwstatus == Horde_ActiveSync::PROVISION_RWSTATUS_WIPED) {
$this->_statusCode = self::STATUS_FOLDERSYNCREQD;
break;
}
$this->_logger->info('[' . $this->_devId . '] Sending response for PING.');
$this->_encoder->StartWBXML();
- $this->_encoder->startTag(SYNC_PING_PING);
+ $this->_encoder->startTag(self::PING);
- $this->_encoder->startTag(SYNC_PING_STATUS);
+ $this->_encoder->startTag(self::STATUS);
$this->_encoder->content($this->_statusCode);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_PING_FOLDERS);
+ $this->_encoder->startTag(self::FOLDERS);
foreach ($collections as $collection) {
if (isset($changes[$collection['id']])) {
- $this->_encoder->startTag(SYNC_PING_FOLDER);
+ $this->_encoder->startTag(self::FOLDER);
$this->_encoder->content($collection['id']);
$this->_encoder->endTag();
}
/* Start by assuming we are in stage 2 */
$phase2 = true;
- if (!$this->_decoder->getElementStartTag(SYNC_PROVISION_PROVISION)) {
+ if (!$this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_PROVISION)) {
return $this->_globalError(self::STATUS_PROTERROR);
}
/* Handle android remote wipe */
- if ($this->_decoder->getElementStartTag(SYNC_PROVISION_REMOTEWIPE)) {
- if (!$this->_decoder->getElementStartTag(SYNC_PROVISION_STATUS)) {
+ if ($this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_REMOTEWIPE)) {
+ if (!$this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_STATUS)) {
return $this->_globalError(self::STATUS_PROTERROR);
}
// TODO: Look at $status here...
/* Need to send *something* in the policytype field even if wiping */
$policytype = self::POLICYTYPE_XML;
} else {
- if (!$this->_decoder->getElementStartTag(SYNC_PROVISION_POLICIES) ||
- !$this->_decoder->getElementStartTag(SYNC_PROVISION_POLICY) ||
- !$this->_decoder->getElementStartTag(SYNC_PROVISION_POLICYTYPE)) {
+ if (!$this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_POLICIES) ||
+ !$this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_POLICY) ||
+ !$this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_POLICYTYPE)) {
return $this->_globalError(self::STATUS_PROTERROR);
}
}
/* POLICYKEY is only sent by client in phase 3 */
- if ($this->_decoder->getElementStartTag(SYNC_PROVISION_POLICYKEY)) {
+ if ($this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_POLICYKEY)) {
$policykey = $this->_decoder->getElementContent();
$this->_logger->debug('PHASE 3 policykey sent from PIM: ' . $policykey);
if (!$this->_decoder->getElementEndTag() ||
- !$this->_decoder->getElementStartTag(SYNC_PROVISION_STATUS)) {
+ !$this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_STATUS)) {
return $this->_globalError(self::STATUS_PROTERROR);
}
}
/* Handle remote wipe for other devices */
- if ($this->_decoder->getElementStartTag(SYNC_PROVISION_REMOTEWIPE)) {
- if (!$this->_decoder->getElementStartTag(SYNC_PROVISION_STATUS)) {
+ if ($this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_REMOTEWIPE)) {
+ if (!$this->_decoder->getElementStartTag(Horde_ActiveSync::PROVISION_STATUS)) {
return $this->_globalError(self::STATUS_PROTERROR);
}
// @TODO: look at status here??
$state->setPolicyKey($this->_devId, $policykey);
}
- $this->_encoder->startTag(SYNC_PROVISION_PROVISION);
- $this->_encoder->startTag(SYNC_PROVISION_STATUS);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_PROVISION);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_STATUS);
$this->_encoder->content($status);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_PROVISION_POLICIES);
- $this->_encoder->startTag(SYNC_PROVISION_POLICY);
- $this->_encoder->startTag(SYNC_PROVISION_POLICYTYPE);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_POLICIES);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_POLICY);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_POLICYTYPE);
$this->_encoder->content($policytype);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_PROVISION_STATUS);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_STATUS);
$this->_encoder->content($policyStatus);
$this->_encoder->endTag();
- $this->_encoder->startTag(SYNC_PROVISION_POLICYKEY);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_POLICYKEY);
$this->_encoder->content($policykey);
$this->_encoder->endTag();
/* Send security policies - configure this/move to it's own method...*/
if ($phase2 && $status == self::STATUS_SUCCESS && $policyStatus == self::STATUS_SUCCESS) {
- $this->_encoder->startTag(SYNC_PROVISION_DATA);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_DATA);
if ($policytype == self::POLICYTYPE_XML) {
$this->_encoder->content($this->_driver->getCurrentPolicy(self::POLICYTYPE_XML));
} else {
//wipe data if status is pending or wiped
if ($rwstatus == self::RWSTATUS_PENDING || $rwstatus == self::RWSTATUS_WIPED) {
- $this->_encoder->startTag(SYNC_PROVISION_REMOTEWIPE, false, true);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_REMOTEWIPE, false, true);
$state->setDeviceRWStatus($this->_devId, self::RWSTATUS_WIPED);
}
private function _globalError($status)
{
$this->_encoder->StartWBXML();
- $this->_encoder->startTag(SYNC_PROVISION_PROVISION);
- $this->_encoder->startTag(SYNC_PROVISION_STATUS);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_PROVISION);
+ $this->_encoder->startTag(Horde_ActiveSync::PROVISION_STATUS);
$this->_encoder->content($status);
$this->_encoder->endTag();
$this->_encoder->endTag();
$unique_folders = array ();
foreach ($folders as $folder) {
// don't save folder-ids for emails
- if ($folder->type == SYNC_FOLDER_TYPE_INBOX) {
+ if ($folder->type == Horde_ActiveSync::FOLDER_TYPE_INBOX) {
continue;
}
// Treo does initial sync for calendar and contacts too, so we need to fake
// these folders if they are not supported by the backend
- if (!array_key_exists(SYNC_FOLDER_TYPE_APPOINTMENT, $unique_folders)) {
- $unique_folders[SYNC_FOLDER_TYPE_APPOINTMENT] = SYNC_FOLDER_TYPE_DUMMY;
+ if (!array_key_exists(Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT, $unique_folders)) {
+ $unique_folders[Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT] = Horde_ActiveSync::FOLDER_TYPE_DUMMY;
}
- if (!array_key_exists(SYNC_FOLDER_TYPE_CONTACT, $unique_folders)) {
- $unique_folders[SYNC_FOLDER_TYPE_CONTACT] = SYNC_FOLDER_TYPE_DUMMY;
+ if (!array_key_exists(Horde_ActiveSync::FOLDER_TYPE_CONTACT, $unique_folders)) {
+ $unique_folders[Horde_ActiveSync::FOLDER_TYPE_CONTACT] = Horde_ActiveSync::FOLDER_TYPE_DUMMY;
}
if (!file_put_contents($this->_stateDir . '/' . $this->_backend->getUser() . '/compat-' . $devId, serialize($unique_folders))) {
if (file_exists($filename)) {
$arr = unserialize(file_get_contents($filename));
if ($class == "Calendar") {
- return $arr[SYNC_FOLDER_TYPE_APPOINTMENT];
+ return $arr[Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT];
}
if ($class == "Contacts") {
- return $arr[SYNC_FOLDER_TYPE_CONTACT];
+ return $arr[Horde_ActiveSync::FOLDER_TYPE_CONTACT];
}
}
$this->_logger->debug('[' . $this->_devId . ']' . count($syncState) . ' messages in state.');
/* do nothing if it is a dummy folder */
- if ($folderId != SYNC_FOLDER_TYPE_DUMMY) {
+ if ($folderId != Horde_ActiveSync::FOLDER_TYPE_DUMMY) {
// on ping: check if backend supports alternative PING mechanism & use it
if ($this->_collection['class'] === false && $flags == BACKEND_DISCARD_DATA && $this->_backend->AlterPing()) {
//@TODO - look at the passing of syncstate here - should probably pass self??
$unique_folders = array ();
foreach ($folders as $folder) {
// don't save folder-ids for emails
- if ($folder->type == SYNC_FOLDER_TYPE_INBOX) {
+ if ($folder->type == Horde_ActiveSync::FOLDER_TYPE_INBOX) {
continue;
}
// Treo does initial sync for calendar and contacts too, so we need to fake
// these folders if they are not supported by the backend
- if (!array_key_exists(SYNC_FOLDER_TYPE_APPOINTMENT, $unique_folders)) {
- $unique_folders[SYNC_FOLDER_TYPE_APPOINTMENT] = SYNC_FOLDER_TYPE_DUMMY;
+ if (!array_key_exists(Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT, $unique_folders)) {
+ $unique_folders[Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT] = Horde_ActiveSync::FOLDER_TYPE_DUMMY;
}
- if (!array_key_exists(SYNC_FOLDER_TYPE_CONTACT, $unique_folders)) {
- $unique_folders[SYNC_FOLDER_TYPE_CONTACT] = SYNC_FOLDER_TYPE_DUMMY;
+ if (!array_key_exists(Horde_ActiveSync::FOLDER_TYPE_CONTACT, $unique_folders)) {
+ $unique_folders[Horde_ActiveSync::FOLDER_TYPE_CONTACT] = Horde_ActiveSync::FOLDER_TYPE_DUMMY;
}
/* Storage to SQL? */
//
// if (file_exists($filename)) {
// $arr = unserialize(file_get_contents($filename));
// if ($class == "Calendar") {
-// return $arr[SYNC_FOLDER_TYPE_APPOINTMENT];
+// return $arr[Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT];
// }
// if ($class == "Contacts") {
-// return $arr[SYNC_FOLDER_TYPE_CONTACT];
+// return $arr[Horde_ActiveSync::FOLDER_TYPE_CONTACT];
// }
// }
//
$this->_logger->debug('Initializing message diff engine');
//do nothing if it is a dummy folder
- if ($folderId != SYNC_FOLDER_TYPE_DUMMY) {
+ if ($folderId != Horde_ActiveSync::FOLDER_TYPE_DUMMY) {
/* First, need to see if we have exising changes left over
* from a previous sync that resulted in a MORE_AVAILABLE */
if (!$empty($this->_changes)) {