Add some methods to get bulk device info and last sync times
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 24 Apr 2010 22:42:36 +0000 (18:42 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 24 Apr 2010 22:42:36 +0000 (18:42 -0400)
framework/ActiveSync/lib/Horde/ActiveSync/State/Base.php
framework/ActiveSync/lib/Horde/ActiveSync/State/File.php
framework/ActiveSync/lib/Horde/ActiveSync/State/History.php

index 57baec1..5949ba3 100644 (file)
@@ -565,4 +565,22 @@ abstract class Horde_ActiveSync_State_Base
      */
     abstract public function setHeartbeatInterval($heartbeat);
 
+    /**
+     * List all devices that we know about.
+     *
+     * @return array  An array of device hashes
+     * @throws Horde_ActiveSync_Exception
+     */
+    abstract public function listDevices();
+
+    /**
+     * Get the last time a particular device issued a SYNC request.
+     *
+     * @param string $devId  The device id
+     *
+     * @return integer  The timestamp of the last sync, regardless of collection
+     * @throws Horde_ActiveSync_Exception
+     */
+    abstract public function getLastSyncTimestamp($devId);
+
 }
\ No newline at end of file
index 7475a74..13a48c9 100644 (file)
@@ -592,6 +592,24 @@ class Horde_ActiveSync_State_File extends Horde_ActiveSync_State_Base
         $this->_gc($syncKey, true);
     }
 
+    public function listDevices()
+    {
+       throw new Horde_ActiveSync_Exception('Not Implemented');
+    }
+
+    /**
+     * Get the last time a particular device issued a SYNC request.
+     *
+     * @param string $devId  The device id
+     *
+     * @return integer  The timestamp of the last sync, regardless of collection
+     * @throws Horde_ActiveSync_Exception
+     */
+    public function getLastSyncTimestamp($devId)
+    {
+        throw new Horde_ActiveSync_Exception('Not Implemented');
+    }
+
     /**
      * Garbage collector - clean up from previous sync
      * requests.
index bdb96de..4803685 100644 (file)
@@ -478,7 +478,6 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base
     public function deviceExists($devId)
     {
         $query = 'SELECT COUNT(*) FROM ' . $this->_syncDeviceTable . ' WHERE device_id = ?';
-
         try {
             return $this->_db->selectValue($query, array($devId));
         } catch (Horde_Db_Exception $e) {
@@ -487,6 +486,40 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base
     }
 
     /**
+     * List all devices that we know about.
+     *
+     * @return array  An array of device hashes
+     * @throws Horde_ActiveSync_Exception
+     */
+    public function listDevices()
+    {
+        $sql = 'SELECT * from ' . $this->_syncDeviceTable;
+        try {
+            return $this->_db->selectAll($sql);
+        } catch (Horde_Db_Exception $e) {
+            throw new Horde_ActiveSync_Exception($e);
+        }
+    }
+
+    /**
+     * Get the last time a particular device issued a SYNC request.
+     *
+     * @param string $devId  The device id
+     *
+     * @return integer  The timestamp of the last sync, regardless of collection
+     * @throws Horde_ActiveSync_Exception
+     */
+    public function getLastSyncTimestamp($devId)
+    {
+        $sql = 'SELECT sync_time FROM ' . $this->_syncStateTable . ' WHERE sync_devid = ?';
+        try {
+            return $this->_db->selectValue($sql, array($devId));
+        } catch (Horde_Db_Exception $e) {
+            throw new Horde_ActiveSync_Exception($e);
+        }
+    }
+
+    /**
      * Load a specific collection's ping state. Ping state must already have
      * been loaded.
      *