Index: horde-webmailer/debian/horde-webmailer/usr/share/horde3/kronolith/lib/api.php =================================================================== --- horde-webmailer.orig/debian/horde-webmailer/usr/share/horde3/kronolith/lib/api.php 2008-10-15 16:01:34.000000000 +0200 +++ horde-webmailer/debian/horde-webmailer/usr/share/horde3/kronolith/lib/api.php 2008-10-15 16:01:34.000000000 +0200 @@ -126,6 +126,11 @@ 'type' => 'boolean', ); +$_services['synchronize'] = array( + 'args' => array(), + 'type' => 'boolean' +); + /** * Returns a list of available permissions. * @@ -1433,3 +1438,35 @@ return PEAR::raiseError('Unknown calendar specification'); } } + +/** + * Synchronizes kronolith with the IMAP backend + * + * @return boolean False if something went wrong + */ +function _kronolith_synchronize() +{ + require_once dirname(__FILE__) . '/base.php'; + global $kronolith_driver; + + $calendar = Kronolith::getDefaultCalendar(); + + if (!array_key_exists($calendar, + Kronolith::listCalendars(false, PERMS_READ))) { + return False; + } + + $kronolith_driver->open($calendar); + + if (get_class ($kronolith_driver) == 'Kronolith_Driver_kolab' && + get_class ($kronolith_driver->_wrapper) == 'Kronolith_Driver_kolab_wrapper_new') { + + $kronolith_driver->_wrapper->synchronize (true); + + if (get_class ($kronolith_driver->_wrapper->_store) == 'Kolab_IMAP') { + $kronolith_driver->_wrapper->_store->_synchronize (); + } + } + + return True; +} Index: horde-webmailer/debian/horde-webmailer/usr/share/horde3/mnemo/lib/api.php =================================================================== --- horde-webmailer.orig/debian/horde-webmailer/usr/share/horde3/mnemo/lib/api.php 2008-10-15 16:01:08.000000000 +0200 +++ horde-webmailer/debian/horde-webmailer/usr/share/horde3/mnemo/lib/api.php 2008-10-15 16:01:34.000000000 +0200 @@ -70,6 +70,11 @@ 'type' => 'boolean' ); +$_services['synchronize'] = array( + 'args' => array(), + 'type' => 'boolean' +); + /** * Returns a list of available permissions. * @@ -475,3 +480,35 @@ return PEAR::raiseError(sprintf(_("Unsupported Content-Type: %s"),$contentType)); } } + +/** + * Synchronizes mnemo with the IMAP backend + * + * @return boolean False if something went wrong + */ +function _mnemo_synchronize() +{ + require_once dirname(__FILE__) . '/base.php'; + + /* Make sure we have a valid notepad. */ + if (empty($notepad)) { + $notepad = Mnemo::getDefaultNotepad(); + } + + if (!array_key_exists($notepad, + Mnemo::listNotepads(false, PERMS_READ))) { + return False; + } + + $storage = &Mnemo_Driver::singleton($notepad); + if (get_class ($storage) == 'Mnemo_Driver_kolab' && + get_class ($storage->_wrapper) == 'Mnemo_Driver_kolab_wrapper_new') { + + $storage->_wrapper->connect (); + if (get_class ($storage->_wrapper->_store) == 'Kolab_IMAP') { + $storage->_wrapper->_store->_synchronize (); + } + } + + return True; +} Index: horde-webmailer/debian/horde-webmailer/usr/share/horde3/nag/lib/api.php =================================================================== --- horde-webmailer.orig/debian/horde-webmailer/usr/share/horde3/nag/lib/api.php 2008-10-15 16:01:02.000000000 +0200 +++ horde-webmailer/debian/horde-webmailer/usr/share/horde3/nag/lib/api.php 2008-10-15 16:01:34.000000000 +0200 @@ -113,6 +113,11 @@ 'type' => '{urn:horde}hashHash' ); +$_services['synchronize'] = array( + 'args' => array(), + 'type' => 'boolean' +); + /** * Returns a list of available permissions. * @@ -1352,3 +1357,32 @@ return $alarm_list; } + +/** + * Synchronizes nag with the IMAP backend + * + * @return boolean False if something went wrong + */ +function _nag_synchronize() +{ + require_once dirname(__FILE__) . '/base.php'; + + $tasklist = Nag::getDefaultTasklist(PERMS_READ); + + if (!array_key_exists($tasklist, + Nag::listTasklists(false, PERMS_READ))) { + return False; + } + + $storage = &Nag_Driver::singleton($tasklist); + if (get_class ($storage) == 'Nag_Driver_kolab' && + get_class ($storage->_wrapper) == 'Nag_Driver_kolab_wrapper_new') { + + $storage->_wrapper->connect (); + if (get_class ($storage->_wrapper->_store) == 'Kolab_IMAP') { + $storage->_wrapper->_store->_synchronize (); + } + } + + return True; +} Index: horde-webmailer/debian/horde-webmailer/usr/share/horde3/turba/lib/api.php =================================================================== --- horde-webmailer.orig/debian/horde-webmailer/usr/share/horde3/turba/lib/api.php 2008-10-15 16:01:08.000000000 +0200 +++ horde-webmailer/debian/horde-webmailer/usr/share/horde3/turba/lib/api.php 2008-10-15 16:01:34.000000000 +0200 @@ -182,6 +182,11 @@ 'type' => 'boolean' ); +$_services['synchronize'] = array( + 'args' => array(), + 'type' => 'boolean' +); + /** * Removes user data. * @@ -1886,3 +1891,49 @@ return; } + +/** + * Synchronizes turba with the IMAP backend + * + * @return boolean False if something went wrong + */ +function _turba_synchronize() +{ + global $prefs, $cfgSources; + require_once dirname(__FILE__) . '/base.php'; + + /* Get default address book from user preferences. */ + if (empty($sources)) { + $sources = @unserialize($prefs->getValue('sync_books')); + } elseif (!is_array($sources)) { + $sources = array($sources); + } + if (empty($sources)) { + $sources = array(Turba::getDefaultAddressbook()); + } + if (empty($sources)) { + return False; + } + + foreach ($sources as $source) { + if (empty($source) || !isset($cfgSources[$source])) { + continue; + } + + $driver = &Turba_Driver::singleton($source); + if (is_a($driver, 'PEAR_Error')) { + continue; + } + if (get_class ($driver) == 'Turba_Driver_share' && + get_class ($driver->_driver) == 'Turba_Driver_kolab' && + get_class ($driver->_driver->_wrapper) == 'Turba_Driver_kolab_wrapper_new') { + + $driver->_driver->_wrapper->connect (); + if (get_class ($driver->_driver->_wrapper->_store) == 'Kolab_IMAP') { + $driver->_driver->_wrapper->_store->_synchronize (); + } + } + } + + return True; +} Index: horde-webmailer/debian/horde-webmailer/usr/share/horde3/lib/SyncML/Command/Alert.php =================================================================== --- horde-webmailer.orig/debian/horde-webmailer/usr/share/horde3/lib/SyncML/Command/Alert.php 2008-10-15 16:01:01.000000000 +0200 +++ horde-webmailer/debian/horde-webmailer/usr/share/horde3/lib/SyncML/Command/Alert.php 2008-10-15 16:18:26.000000000 +0200 @@ -287,6 +287,17 @@ 'Creating SyncML_Sync object for database ' . $this->_targetLocURI . '; sync type ' . $synctype, __FILE__, __LINE__, PEAR_LOG_DEBUG); + /* Synchronize databases with the IMAP backend */ + $databases = array ('kronolith', 'turba', 'nag', 'mnemo'); + foreach($databases as $app) { + $GLOBALS['registry']->callByPackage($app, 'synchronize'); + } + if ($serverAnchorNext == time ()) { + // make sure that the timestamps of the synchronized items in + // the database are different from serverAnchorNext + sleep (1); + } + $serverAnchorNext = $GLOBALS['backend']->getCurrentTimeStamp(); $sync = new SyncML_Sync($synctype, $this->_targetLocURI, $this->_sourceLocURI,