Make sure we have the APIs needed for each folder class
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 10 Apr 2010 17:22:09 +0000 (13:22 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 10 Apr 2010 17:22:09 +0000 (13:22 -0400)
framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde.php
framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde/Connector/Registry.php
framework/ActiveSync/test/Horde/ActiveSync/HordeDriverTest.php

index 48040ca..5b1b942 100644 (file)
@@ -126,10 +126,21 @@ class Horde_ActiveSync_Driver_Horde extends Horde_ActiveSync_Driver_Base
     public function getFolderList()
     {
         $this->_logger->debug('Horde::getFolderList()');
+        /* Make sure we have the APIs needed for each folder class */
+        $supported = $this->_connector->horde_listApis();
         $folders = array();
-        $folders[] = $this->StatFolder(self::APPOINTMENTS_FOLDER);
-        $folders[] = $this->StatFolder(self::CONTACTS_FOLDER);
-        $folders[] = $this->StatFolder(self::TASKS_FOLDER);
+
+        if (array_search('calendar', $supported)){
+            $folders[] = $this->StatFolder(self::APPOINTMENTS_FOLDER);
+        }
+
+        if (array_search('contacts', $supported)){
+            $folders[] = $this->StatFolder(self::CONTACTS_FOLDER);
+        }
+
+        if (array_search('tasks', $supported)){
+            $folders[] = $this->StatFolder(self::TASKS_FOLDER);
+        }
 
         return $folders;
     }
index 13c2656..2a4cd89 100644 (file)
@@ -214,4 +214,19 @@ class Horde_ActiveSync_Driver_Horde_Connector_Registry
         return $result;
     }
 
+    public function tasks_listTasks()
+    {
+        return $this->_registry->tasks->listTasks();
+    }
+
+    public function horde_listApis()
+    {
+        return $this->_registry->horde->listAPIs();
+    }
+
+    public function horde_getPref($app, $pref)
+    {
+        return $this->_registry->horde->getPref($app, $pref);
+    }
+
 }
\ No newline at end of file
index 96ee5bd..6922d55 100644 (file)
@@ -244,7 +244,7 @@ class Horde_ActiveSync_HordeDriverTest extends Horde_Test_Case
     {
         $registry = $this->getMockSkipConstructor('Horde_Registry');
         $state = $this->getMockSkipConstructor('Horde_ActiveSync_State_File');
-        $connector = new Horde_ActiveSync_MockConnector(array('fixture' => array()));
+        $connector = new Horde_ActiveSync_MockConnector(array('fixture' => array('horde_listApis' => array('horde', 'contacts', 'calendar', 'tasks'))));
         $driver = new Horde_ActiveSync_Driver_Horde(array('connector' => $connector,
                                                           'state_basic' => $state));
         $results = $driver->getFolderList();