Bug 494394 - No way for the user to refresh a calendar
authorMilan Crha <mcrha@redhat.com>
Mon, 30 Nov 2009 06:59:39 +0000 (12:29 +0530)
committerChenthill Palanisamy <pchenthill@novell.com>
Mon, 30 Nov 2009 06:59:39 +0000 (12:29 +0530)
15 files changed:
addressbook/libedata-book/e-data-book-factory.c
calendar/backends/caldav/e-cal-backend-caldav.c
calendar/backends/http/e-cal-backend-http.c
calendar/backends/weather/e-cal-backend-weather.c
calendar/libecal/e-cal-util.h
calendar/libecal/e-cal.c
calendar/libecal/e-cal.h
calendar/libedata-cal/e-cal-backend-sync.c
calendar/libedata-cal/e-cal-backend-sync.h
calendar/libedata-cal/e-cal-backend.c
calendar/libedata-cal/e-cal-backend.h
calendar/libedata-cal/e-data-cal-factory.c
calendar/libedata-cal/e-data-cal.c
calendar/libedata-cal/e-data-cal.h
calendar/libedata-cal/e-data-cal.xml

index d5e891f..4c1ce58 100644 (file)
@@ -317,8 +317,10 @@ impl_BookFactory_getBook(EDataBookFactory *factory, const gchar *IN_source, DBus
                if (backend_factory)
                        backend = e_book_backend_factory_new_backend (backend_factory);
 
-               if (backend)
+               if (backend) {
                        g_hash_table_insert (priv->backends, g_strdup (uri), backend);
+                       e_book_backend_set_mode (backend, priv->mode);
+               }
        }
 
        if (!backend) {
@@ -333,7 +335,6 @@ impl_BookFactory_getBook(EDataBookFactory *factory, const gchar *IN_source, DBus
 
        path = construct_book_factory_path ();
        book = e_data_book_new (backend, source);
-       e_book_backend_set_mode (backend, priv->mode);
        g_hash_table_insert (priv->books, g_strdup (path), book);
        e_book_backend_add_client (backend, book);
        dbus_g_connection_register_g_object (connection, path, G_OBJECT (book));
index 372e7ea..e36bad1 100644 (file)
@@ -2110,11 +2110,13 @@ caldav_get_static_capabilities (ECalBackendSync  *backend,
 
        if (priv && priv->is_google)
                *capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
-                                         CAL_STATIC_CAPABILITY_NO_THISANDPRIOR);
+                                         CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
+                                         CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
        else
                *capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
                                          CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
-                                         CAL_STATIC_CAPABILITY_NO_THISANDPRIOR);
+                                         CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
+                                         CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
 
        return GNOME_Evolution_Calendar_Success;
 }
@@ -2380,6 +2382,36 @@ caldav_do_open (ECalBackendSync *backend,
 }
 
 static ECalBackendSyncStatus
+caldav_refresh (ECalBackendSync *backend, EDataCal *cal)
+{
+       ECalBackendCalDAV        *cbdav;
+       ECalBackendCalDAVPrivate *priv;
+       ECalBackendSyncStatus     status;
+       gboolean                  online;
+
+       cbdav = E_CAL_BACKEND_CALDAV (backend);
+       priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
+
+       g_mutex_lock (priv->busy_lock);
+
+       if (!priv->loaded
+           || priv->slave_cmd != SLAVE_SHOULD_SLEEP
+           || check_state (cbdav, &online) != GNOME_Evolution_Calendar_Success
+           || !online) {
+               g_mutex_unlock (priv->busy_lock);
+               return GNOME_Evolution_Calendar_Success;
+       }
+
+       priv->slave_cmd = SLAVE_SHOULD_WORK;
+
+       /* wake it up */
+       g_cond_signal (priv->cond);
+       g_mutex_unlock (priv->busy_lock);
+
+       return GNOME_Evolution_Calendar_Success;
+}
+
+static ECalBackendSyncStatus
 caldav_remove (ECalBackendSync *backend,
               EDataCal        *cal)
 {
@@ -4596,6 +4628,7 @@ e_cal_backend_caldav_class_init (ECalBackendCalDAVClass *class)
        sync_class->get_static_capabilities_sync = caldav_get_static_capabilities;
 
        sync_class->open_sync                    = caldav_do_open;
+       sync_class->refresh_sync                 = caldav_refresh;
        sync_class->remove_sync                  = caldav_remove;
 
        sync_class->create_object_sync = caldav_create_object;
index c42ccb4..0bb92ab 100644 (file)
@@ -208,7 +208,10 @@ e_cal_backend_http_get_alarm_email_address (ECalBackendSync *backend, EDataCal *
 static ECalBackendSyncStatus
 e_cal_backend_http_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
 {
-       *capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS);
+       *capabilities = g_strdup (
+               CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
+               CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED
+               );
 
        return GNOME_Evolution_Calendar_Success;
 }
@@ -284,7 +287,7 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
        icalcomponent *icalcomp, *subcomp;
        icalcomponent_kind kind;
        const gchar *newuri;
-       SoupURI *uri_parsed;
+       SoupURI *uri_parsed;
        GHashTable *old_cache;
        GSList *comps_in_cache;
 
@@ -688,6 +691,29 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
 }
 
 static ECalBackendSyncStatus
+e_cal_backend_http_refresh (ECalBackendSync *backend, EDataCal *cal)
+{
+       ECalBackendHttp *cbhttp;
+       ECalBackendHttpPrivate *priv;
+
+       cbhttp = E_CAL_BACKEND_HTTP (backend);
+       priv = cbhttp->priv;
+
+       if (!priv->opened ||
+           priv->is_loading)
+               return GNOME_Evolution_Calendar_Success;
+
+       if (priv->reload_timeout_id)
+               g_source_remove (priv->reload_timeout_id);
+       priv->reload_timeout_id = 0;
+
+       /* wait a second, then start reloading */
+       priv->reload_timeout_id = g_timeout_add (1000, (GSourceFunc) reload_cb, cbhttp);
+
+       return GNOME_Evolution_Calendar_Success;
+}
+
+static ECalBackendSyncStatus
 e_cal_backend_http_remove (ECalBackendSync *backend, EDataCal *cal)
 {
        ECalBackendHttp *cbhttp;
@@ -740,34 +766,39 @@ e_cal_backend_http_set_mode (ECalBackend *backend, CalMode mode)
        ECalBackendHttpPrivate *priv;
        GNOME_Evolution_Calendar_CalMode set_mode;
        gboolean loaded;
+
        cbhttp = E_CAL_BACKEND_HTTP (backend);
        priv = cbhttp->priv;
 
        loaded = e_cal_backend_http_is_loaded (backend);
 
-       switch (mode) {
-               case CAL_MODE_LOCAL:
-                       priv->mode = mode;
-                       set_mode = cal_mode_to_corba (mode);
-                       if (loaded && priv->reload_timeout_id) {
-                               g_source_remove (priv->reload_timeout_id);
-                               priv->reload_timeout_id = 0;
-                       }
-                       break;
-               case CAL_MODE_REMOTE:
-               case CAL_MODE_ANY:
-                       priv->mode = mode;
-                       set_mode = cal_mode_to_corba (mode);
-                       if (loaded)
-                               g_idle_add ((GSourceFunc) begin_retrieval_cb, backend);
-                       break;
-
-                       priv->mode = CAL_MODE_REMOTE;
-                       set_mode = GNOME_Evolution_Calendar_MODE_REMOTE;
-                       break;
-               default:
-                       set_mode = GNOME_Evolution_Calendar_MODE_ANY;
-                       break;
+       if (priv->mode != mode) {
+               switch (mode) {
+                       case CAL_MODE_LOCAL:
+                               priv->mode = mode;
+                               set_mode = cal_mode_to_corba (mode);
+                               if (loaded && priv->reload_timeout_id) {
+                                       g_source_remove (priv->reload_timeout_id);
+                                       priv->reload_timeout_id = 0;
+                               }
+                               break;
+                       case CAL_MODE_REMOTE:
+                       case CAL_MODE_ANY:
+                               priv->mode = mode;
+                               set_mode = cal_mode_to_corba (mode);
+                               if (loaded)
+                                       g_idle_add ((GSourceFunc) begin_retrieval_cb, backend);
+                               break;
+
+                               priv->mode = CAL_MODE_REMOTE;
+                               set_mode = GNOME_Evolution_Calendar_MODE_REMOTE;
+                               break;
+                       default:
+                               set_mode = GNOME_Evolution_Calendar_MODE_ANY;
+                               break;
+               }
+       } else {
+               set_mode = cal_mode_to_corba (priv->mode);
        }
 
        if (loaded) {
@@ -1356,6 +1387,7 @@ e_cal_backend_http_class_init (ECalBackendHttpClass *class)
        sync_class->get_ldap_attribute_sync = e_cal_backend_http_get_ldap_attribute;
        sync_class->get_static_capabilities_sync = e_cal_backend_http_get_static_capabilities;
        sync_class->open_sync = e_cal_backend_http_open;
+       sync_class->refresh_sync = e_cal_backend_http_refresh;
        sync_class->remove_sync = e_cal_backend_http_remove;
        sync_class->create_object_sync = e_cal_backend_http_create_object;
        sync_class->modify_object_sync = e_cal_backend_http_modify_object;
index 6b8aa06..f16f949 100644 (file)
@@ -458,7 +458,8 @@ e_cal_backend_weather_get_static_capabilities (ECalBackendSync *backend, EDataCa
                                  CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS  ","
                                  CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT  ","
                                  CAL_STATIC_CAPABILITY_NO_THISANDFUTURE  ","
-                                 CAL_STATIC_CAPABILITY_NO_THISANDPRIOR);
+                                 CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
+                                 CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
 
        return GNOME_Evolution_Calendar_Success;
 }
@@ -508,6 +509,29 @@ e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean on
 }
 
 static ECalBackendSyncStatus
+e_cal_backend_weather_refresh (ECalBackendSync *backend, EDataCal *cal)
+{
+       ECalBackendWeather *cbw;
+       ECalBackendWeatherPrivate *priv;
+
+       cbw = E_CAL_BACKEND_WEATHER (backend);
+       priv = cbw->priv;
+
+       if (!priv->opened ||
+           priv->is_loading)
+               return GNOME_Evolution_Calendar_Success;
+
+       if (priv->reload_timeout_id)
+               g_source_remove (priv->reload_timeout_id);
+       priv->reload_timeout_id = 0;
+
+       /* wait a second, then start reloading */
+       priv->reload_timeout_id = g_timeout_add (1000, (GSourceFunc) reload_cb, cbw);
+
+       return GNOME_Evolution_Calendar_Success;
+}
+
+static ECalBackendSyncStatus
 e_cal_backend_weather_remove (ECalBackendSync *backend, EDataCal *cal)
 {
        ECalBackendWeather *cbw;
@@ -785,25 +809,29 @@ e_cal_backend_weather_set_mode (ECalBackend *backend, CalMode mode)
 
        loaded = e_cal_backend_weather_is_loaded (backend);
 
-       switch (mode) {
-               case CAL_MODE_LOCAL:
-               case CAL_MODE_REMOTE:
-                       priv->mode = mode;
-                       set_mode = cal_mode_to_corba (mode);
-                       if (loaded && priv->reload_timeout_id) {
-                               g_source_remove (priv->reload_timeout_id);
-                               priv->reload_timeout_id = 0;
-                       }
-                       break;
-               case CAL_MODE_ANY:
-                       priv->mode = mode;
-                       set_mode = cal_mode_to_corba (mode);
-                       if (loaded && !priv->begin_retrival_id)
-                               priv->begin_retrival_id = g_idle_add ((GSourceFunc) begin_retrieval_cb, backend);
-                       break;
-               default:
-                       set_mode = GNOME_Evolution_Calendar_MODE_ANY;
-                       break;
+       if (priv->mode != mode) {
+               switch (mode) {
+                       case CAL_MODE_LOCAL:
+                       case CAL_MODE_REMOTE:
+                               priv->mode = mode;
+                               set_mode = cal_mode_to_corba (mode);
+                               if (loaded && priv->reload_timeout_id) {
+                                       g_source_remove (priv->reload_timeout_id);
+                                       priv->reload_timeout_id = 0;
+                               }
+                               break;
+                       case CAL_MODE_ANY:
+                               priv->mode = mode;
+                               set_mode = cal_mode_to_corba (mode);
+                               if (loaded && !priv->begin_retrival_id)
+                                       priv->begin_retrival_id = g_idle_add ((GSourceFunc) begin_retrieval_cb, backend);
+                               break;
+                       default:
+                               set_mode = GNOME_Evolution_Calendar_MODE_ANY;
+                               break;
+               }
+       } else {
+               set_mode = cal_mode_to_corba (priv->mode);
        }
 
        if (loaded) {
@@ -939,6 +967,7 @@ e_cal_backend_weather_class_init (ECalBackendWeatherClass *class)
        sync_class->get_ldap_attribute_sync = e_cal_backend_weather_get_ldap_attribute;
        sync_class->get_static_capabilities_sync = e_cal_backend_weather_get_static_capabilities;
        sync_class->open_sync = e_cal_backend_weather_open;
+       sync_class->refresh_sync = e_cal_backend_weather_refresh;
        sync_class->remove_sync = e_cal_backend_weather_remove;
        sync_class->discard_alarm_sync = e_cal_backend_weather_discard_alarm;
        sync_class->receive_objects_sync = e_cal_backend_weather_receive_objects;
index 9af0cfb..773c70a 100644 (file)
@@ -127,6 +127,7 @@ gboolean e_cal_util_event_dates_match (icalcomponent *icalcomp1, icalcomponent *
 #define CAL_STATIC_CAPABILITY_NO_ORGANIZER              "no-organizer"
 #define CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY          "delegate-to-many"
 #define CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING     "has-unaccepted-meeting"
+#define CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED         "refresh-supported"
 
 /* Recurrent events. Management for instances */
 icalcomponent *e_cal_util_construct_instance (icalcomponent *icalcomp,
index 60950db..247c18f 100644 (file)
@@ -1278,6 +1278,34 @@ e_cal_open_async (ECal *ecal, gboolean only_if_exists)
 }
 
 /**
+ * e_cal_refresh:
+ * @ecal: A calendar client.
+ * @error: Placeholder for error information.
+ *
+ * Invokes refresh on a calendar. See @e_cal_get_refresh_supported.
+ *
+ * Return value: TRUE if calendar supports refresh and it was invoked, FALSE otherwise.
+ **/
+gboolean
+e_cal_refresh (ECal *ecal, GError **error)
+{
+       ECalPrivate *priv;
+
+       e_return_error_if_fail (E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+       priv = ecal->priv;
+       e_return_error_if_fail (priv->proxy, E_CALENDAR_STATUS_REPOSITORY_OFFLINE);
+
+       LOCK_CONN ();
+       if (!org_gnome_evolution_dataserver_calendar_Cal_refresh (priv->proxy, error)) {
+               UNLOCK_CONN ();
+               E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+       }
+       UNLOCK_CONN ();
+
+       return TRUE;
+}
+
+/**
  * e_cal_remove:
  * @ecal: A calendar client.
  * @error: Placeholder for error information.
@@ -1769,6 +1797,23 @@ e_cal_get_organizer_must_accept (ECal *ecal)
 }
 
 /**
+ * e_cal_get_refresh_supported:
+ * @ecal: A calendar client.
+ *
+ * Checks whether a calendar supports explicit refreshing (see @e_cal_refresh).
+ *
+ * Return value: TRUE if the calendar supports refreshing, FALSE otherwise.
+ */
+gboolean
+e_cal_get_refresh_supported (ECal *ecal)
+{
+       g_return_val_if_fail (ecal != NULL, FALSE);
+       g_return_val_if_fail (E_IS_CAL (ecal), FALSE);
+
+       return check_capability (ecal, CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
+}
+
+/**
  * e_cal_set_mode:
  * @ecal: A calendar client.
  * @mode: Mode to switch to.
index 73f1dce..e088899 100644 (file)
@@ -110,6 +110,7 @@ void e_cal_set_auth_func (ECal *ecal, ECalAuthFunc func, gpointer data);
 
 gboolean e_cal_open (ECal *ecal, gboolean only_if_exists, GError **error);
 void e_cal_open_async (ECal *ecal, gboolean only_if_exists);
+gboolean e_cal_refresh (ECal *ecal, GError **error);
 gboolean e_cal_remove (ECal *ecal, GError **error);
 
 GList *e_cal_uri_list (ECal *ecal, CalMode mode);
@@ -130,6 +131,7 @@ gboolean e_cal_get_organizer_must_attend (ECal *ecal);
 gboolean e_cal_get_save_schedules (ECal *ecal);
 gboolean e_cal_get_static_capability (ECal *ecal, const gchar *cap);
 gboolean e_cal_get_organizer_must_accept (ECal *ecal);
+gboolean e_cal_get_refresh_supported (ECal *ecal);
 
 gboolean e_cal_set_mode (ECal *ecal, CalMode mode);
 
index a503ab0..57ab76a 100644 (file)
@@ -211,6 +211,29 @@ e_cal_backend_sync_remove  (ECalBackendSync *backend, EDataCal *cal)
 }
 
 /**
+ * e_cal_backend_sync_refresh:
+ * @backend: An ECalBackendSync object.
+ * @cal: An EDataCal object.
+ *
+ * Calls the refresh method on the given backend.
+ *
+ * Return value: Status code.
+ */
+ECalBackendSyncStatus
+e_cal_backend_sync_refresh  (ECalBackendSync *backend, EDataCal *cal)
+{
+       ECalBackendSyncStatus status;
+
+       g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
+       g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->refresh_sync != NULL,
+                             GNOME_Evolution_Calendar_UnsupportedMethod);
+
+       LOCK_WRAPPER (refresh_sync, (backend, cal));
+
+       return status;
+}
+
+/**
  * e_cal_backend_sync_create_object:
  * @backend: An ECalBackendSync object.
  * @cal: An EDataCal object.
@@ -710,6 +733,16 @@ _e_cal_backend_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext c
 }
 
 static void
+_e_cal_backend_refresh (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
+{
+       ECalBackendSyncStatus status;
+
+       status = e_cal_backend_sync_refresh (E_CAL_BACKEND_SYNC (backend), cal);
+
+       e_data_cal_notify_refresh (cal, context, status);
+}
+
+static void
 _e_cal_backend_remove (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
        ECalBackendSyncStatus status;
@@ -1072,6 +1105,7 @@ e_cal_backend_sync_class_init (ECalBackendSyncClass *klass)
        backend_class->get_ldap_attribute = _e_cal_backend_get_ldap_attribute;
        backend_class->get_static_capabilities = _e_cal_backend_get_static_capabilities;
        backend_class->open = _e_cal_backend_open;
+       backend_class->refresh = _e_cal_backend_refresh;
        backend_class->remove = _e_cal_backend_remove;
        backend_class->create_object = _e_cal_backend_create_object;
        backend_class->modify_object = _e_cal_backend_modify_object;
index bf2a0f6..e5b13a9 100644 (file)
@@ -39,6 +39,7 @@ struct _ECalBackendSyncClass {
        ECalBackendSyncStatus (*get_static_capabilities_sync)  (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities);
 
        ECalBackendSyncStatus (*open_sync)  (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password);
+       ECalBackendSyncStatus (*refresh_sync)  (ECalBackendSync *backend, EDataCal *cal);
        ECalBackendSyncStatus (*remove_sync)  (ECalBackendSync *backend, EDataCal *cal);
 
        ECalBackendSyncStatus (*create_object_sync)  (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid);
@@ -98,8 +99,10 @@ ECalBackendSyncStatus e_cal_backend_sync_open                    (ECalBackendSyn
                                                                  gboolean         only_if_exists,
                                                                  const gchar *username,
                                                                  const gchar *password);
+ECalBackendSyncStatus e_cal_backend_sync_refresh                  (ECalBackendSync  *backend,
+                                                                 EDataCal             *cal);
 ECalBackendSyncStatus e_cal_backend_sync_remove                  (ECalBackendSync  *backend,
-                                                              EDataCal             *cal);
+                                                                 EDataCal             *cal);
 ECalBackendSyncStatus e_cal_backend_sync_create_object           (ECalBackendSync  *backend,
                                                                  EDataCal             *cal,
                                                                  gchar           **calobj,
index 4e523c1..cc2d36c 100644 (file)
@@ -636,6 +636,23 @@ e_cal_backend_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext co
 }
 
 /**
+ * e_cal_backend_refresh:
+ * @backend: A calendar backend.
+ * @cal: An #EDataCal object.
+ *
+ * Refreshes the calendar being accessed by the given backend.
+ */
+void
+e_cal_backend_refresh (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
+{
+       g_return_if_fail (backend != NULL);
+       g_return_if_fail (E_IS_CAL_BACKEND (backend));
+
+       g_assert (CLASS (backend)->refresh != NULL);
+       (* CLASS (backend)->refresh) (backend, cal, context);
+}
+
+/**
  * e_cal_backend_remove:
  * @backend: A calendar backend.
  * @cal: An #EDataCal object.
index be67b5e..a10077e 100644 (file)
@@ -76,6 +76,7 @@ struct _ECalBackendClass {
        void (* get_static_capabilities) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 
        void (* open) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists, const gchar *username, const gchar *password);
+       void (* refresh) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
        void (* remove) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 
        /* Object related virtual methods */
@@ -134,6 +135,7 @@ void e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal, ESer
 void e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 
 void e_cal_backend_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists, const gchar *username, const gchar *password);
+void e_cal_backend_refresh (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 void e_cal_backend_remove (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 
 void e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj);
index 0f078cc..814942d 100644 (file)
@@ -403,6 +403,8 @@ impl_CalFactory_getCal (EDataCalFactory             *factory,
 
                /* Track the backend */
                g_hash_table_insert (priv->backends, g_strdup (uid_type_string), backend);
+
+               e_cal_backend_set_mode (backend, priv->mode);
        } else if (!e_source_equal (source, e_cal_backend_get_source (backend))) {
                /* source changed, update it in a backend */
                update_source_in_backend (backend, source);
@@ -410,7 +412,6 @@ impl_CalFactory_getCal (EDataCalFactory             *factory,
 
        calendar = e_data_cal_new (backend, source);
        e_cal_backend_add_client (backend, calendar);
-       e_cal_backend_set_mode (backend, priv->mode);
 
        path = construct_cal_factory_path ();
        dbus_g_connection_register_g_object (connection, path, G_OBJECT (calendar));
index 5797da0..10dcf37 100644 (file)
@@ -43,6 +43,7 @@ DBusGConnection *connection;
 static void impl_Cal_get_uri (EDataCal *cal, DBusGMethodInvocation *context);
 static void impl_Cal_open (EDataCal *cal, gboolean only_if_exists, gchar *username, gchar *password, DBusGMethodInvocation *context);
 static gboolean impl_Cal_close (EDataCal *cal, GError **error);
+static void impl_Cal_refresh (EDataCal *cal, DBusGMethodInvocation *context);
 static void impl_Cal_remove (EDataCal *cal, DBusGMethodInvocation *context);
 static void impl_Cal_isReadOnly (EDataCal *cal, DBusGMethodInvocation *context);
 static void impl_Cal_getCalAddress (EDataCal *cal, DBusGMethodInvocation *context);
@@ -200,6 +201,13 @@ impl_Cal_close (EDataCal *cal, GError **error)
        return TRUE;
 }
 
+/* EDataCal::refresh method */
+static void
+impl_Cal_refresh (EDataCal *cal, DBusGMethodInvocation *context)
+{
+       e_cal_backend_refresh (cal->priv->backend, cal, context);
+}
+
 /* EDataCal::remove method */
 static void
 impl_Cal_remove (EDataCal *cal, DBusGMethodInvocation *context)
@@ -557,6 +565,23 @@ e_data_cal_notify_open (EDataCal *cal, EServerMethodContext context, EDataCalCal
 }
 
 /**
+ * e_data_cal_notify_refresh:
+ * @cal: A calendar client interface.
+ * @status: Status code.
+ *
+ * Notifies listeners of the completion of the refresh method call.
+ */
+void
+e_data_cal_notify_refresh (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
+{
+       DBusGMethodInvocation *method = context;
+       if (status != Success)
+               dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot refresh calendar")));
+       else
+               dbus_g_method_return (method);
+}
+
+/**
  * e_data_cal_notify_remove:
  * @cal: A calendar client interface.
  * @status: Status code.
index bae69e0..4cd5f1a 100644 (file)
@@ -72,6 +72,7 @@ void e_data_cal_notify_static_capabilities (EDataCal *cal, EServerMethodContext
                                            const gchar *capabilities);
 
 void e_data_cal_notify_open   (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
+void e_data_cal_notify_refresh(EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
 void e_data_cal_notify_remove (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
 
 void e_data_cal_notify_object_created  (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
index 8b60530..d2f5087 100644 (file)
                        <arg name="password" type="s" direction="in"/>
                </method>
 
+               <method name="refresh">
+                       <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_refresh"/>
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+               </method>               
+
                <method name="close">
                        <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_close"/>
                </method>