initial work on supporting the SUPPORTED tag in SYNC requests.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 25 Apr 2010 17:24:41 +0000 (13:24 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 25 Apr 2010 17:24:41 +0000 (13:24 -0400)
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.

framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php
framework/ActiveSync/lib/Horde/ActiveSync/State/History.php
horde/scripts/sql/horde_activesync.sql

index 85ac807..aeb7ca3 100644 (file)
@@ -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) {
index 2e139f9..7d4f4b0 100644 (file)
@@ -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);
index ca837d2..92546b5 100644 (file)
@@ -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,