From 901af9df5086279fcefeeee84932e43fc10ce54e Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sun, 25 Apr 2010 13:24:41 -0400 Subject: [PATCH] initial work on supporting the SUPPORTED tag in SYNC requests. This is needed to avoid deleting field values when the PIM doesn't support/send a particular value when editing an entry on the PIM. This commit just adds support for persisting the SUPPORTED (non-ghosted) fields. --- .../ActiveSync/lib/Horde/ActiveSync/Request/Sync.php | 13 +++++++++++-- .../ActiveSync/lib/Horde/ActiveSync/State/History.php | 19 ++++++++++++++----- horde/scripts/sql/horde_activesync.sql | 1 + 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php index 85ac80772..aeb7ca3b9 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php @@ -98,7 +98,8 @@ class Horde_ActiveSync_Request_Sync extends Horde_ActiveSync_Request_Base exit; } while (1) { - $el = $this->_decoder->getElement(); + $el = $this->_decoder->getElementContent(); + $collection['supported'][] = $el; if ($el[Horde_ActiveSync_Wbxml::EN_TYPE] == Horde_ActiveSync_Wbxml::EN_TYPE_ENDTAG) { break; } @@ -186,7 +187,15 @@ class Horde_ActiveSync_Request_Sync extends Horde_ActiveSync_Request_Base if ($this->_statusCode == self::STATUS_SUCCESS) { /* Initialize the state */ $state = &$this->_driver->getStateObject($collection); - $state->getDeviceInfo($devId); + $device = $state->getDeviceInfo($devId); + if (!empty($collection['supported'])) { + /* Initial sync and we have SUPPORTED data - save it */ + if (empty($device->supported)) { + $device->supported = array(); + } + $device->supported[$collection['class']] = $collection['supported']; + $state->setDeviceInfo($devId, $device); + } try { $state->loadState($collection['synckey'], 'sync'); } catch (Horde_ActiveSync_Exception $e) { diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php b/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php index 2e139f9a9..7d4f4b067 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php @@ -403,7 +403,7 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base } $this->_devId = $devId; - $query = 'SELECT device_type, device_agent, device_ping, device_policykey, device_rwstatus, device_user FROM ' + $query = 'SELECT device_type, device_agent, device_ping, device_policykey, device_rwstatus, device_user, device_supported FROM ' . $this->_syncDeviceTable . ' WHERE device_id = ?'; try { $result = $this->_db->selectOne($query, array($devId)); @@ -417,7 +417,8 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base $this->_deviceInfo->deviceType = $result['device_type']; $this->_deviceInfo->userAgent = $result['device_agent']; $this->_deviceInfo->id = $devId; - $this->deviceInfo->user = $result['device_user']; + $this->_deviceInfo->user = $result['device_user']; + $this->_deviceInfo->supported = unserilize($result['device_supported']); if ($result['device_ping']) { $this->_pingState = unserialize($result['device_ping']); } else { @@ -455,10 +456,18 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base $this->_db->execute($query, array($devId)); $query = 'INSERT INTO ' . $this->_syncDeviceTable - . '(device_type, device_agent, device_ping, device_policykey, device_rwstatus, device_id, device_user)' - . ' VALUES(?, ?, ?, ?, ?, ?, ?)'; + . '(device_type, device_agent, device_ping, device_policykey, device_rwstatus, device_id, device_user, device_supported)' + . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?)'; + + $values = array($data->deviceType, + $data->userAgent, + '', + $data->policykey, + $data->rwstatus, + $devId, + $data->user, + (!empty($data->supported) ? $data->supported : '')); - $values = array($data->deviceType, $data->userAgent, '', $data->policykey, $data->rwstatus, $devId, $data->user); $this->_devId = $devId; return $this->_db->insert($query, $values); diff --git a/horde/scripts/sql/horde_activesync.sql b/horde/scripts/sql/horde_activesync.sql index ca837d292..92546b59a 100644 --- a/horde/scripts/sql/horde_activesync.sql +++ b/horde/scripts/sql/horde_activesync.sql @@ -27,6 +27,7 @@ CREATE TABLE horde_activesync_device ( device_type VARCHAR(255) NOT NULL, device_agent VARCHAR(255) NOT NULL, device_ping TEXT, + device_supported TEXT, device_policykey BIGINT DEFAULT 0, device_rwstatus INTEGER, device_folders TEXT, -- 2.11.0