[evolution-data-server] Bug 494394 - No way for the user to refresh a calendar
- From: Chenthill Palanisamy <pchen src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 494394 - No way for the user to refresh a calendar
- Date: Mon, 30 Nov 2009 07:05:26 +0000 (UTC)
commit 523d5a9d3116e242ad2f8cd4d140c4c278933246
Author: Milan Crha <mcrha redhat com>
Date: Mon Nov 30 12:29:39 2009 +0530
Bug 494394 - No way for the user to refresh a calendar
addressbook/libedata-book/e-data-book-factory.c | 5 +-
calendar/backends/caldav/e-cal-backend-caldav.c | 37 +++++++++-
calendar/backends/http/e-cal-backend-http.c | 82 ++++++++++++++------
calendar/backends/weather/e-cal-backend-weather.c | 69 ++++++++++++-----
calendar/libecal/e-cal-util.h | 1 +
calendar/libecal/e-cal.c | 45 +++++++++++
calendar/libecal/e-cal.h | 2 +
calendar/libedata-cal/e-cal-backend-sync.c | 34 +++++++++
calendar/libedata-cal/e-cal-backend-sync.h | 5 +-
calendar/libedata-cal/e-cal-backend.c | 17 ++++
calendar/libedata-cal/e-cal-backend.h | 2 +
calendar/libedata-cal/e-data-cal-factory.c | 3 +-
calendar/libedata-cal/e-data-cal.c | 25 ++++++
calendar/libedata-cal/e-data-cal.h | 1 +
calendar/libedata-cal/e-data-cal.xml | 5 +
15 files changed, 282 insertions(+), 51 deletions(-)
---
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index d5e891f..4c1ce58 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -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));
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 372e7ea..e36bad1 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -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;
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index c42ccb4..0bb92ab 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -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;
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index 6b8aa06..f16f949 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -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;
diff --git a/calendar/libecal/e-cal-util.h b/calendar/libecal/e-cal-util.h
index 9af0cfb..773c70a 100644
--- a/calendar/libecal/e-cal-util.h
+++ b/calendar/libecal/e-cal-util.h
@@ -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,
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 60950db..247c18f 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -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.
diff --git a/calendar/libecal/e-cal.h b/calendar/libecal/e-cal.h
index 73f1dce..e088899 100644
--- a/calendar/libecal/e-cal.h
+++ b/calendar/libecal/e-cal.h
@@ -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);
diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c
index a503ab0..57ab76a 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.c
+++ b/calendar/libedata-cal/e-cal-backend-sync.c
@@ -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;
diff --git a/calendar/libedata-cal/e-cal-backend-sync.h b/calendar/libedata-cal/e-cal-backend-sync.h
index bf2a0f6..e5b13a9 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.h
+++ b/calendar/libedata-cal/e-cal-backend-sync.h
@@ -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,
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 4e523c1..cc2d36c 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -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.
diff --git a/calendar/libedata-cal/e-cal-backend.h b/calendar/libedata-cal/e-cal-backend.h
index be67b5e..a10077e 100644
--- a/calendar/libedata-cal/e-cal-backend.h
+++ b/calendar/libedata-cal/e-cal-backend.h
@@ -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);
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 0f078cc..814942d 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -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));
diff --git a/calendar/libedata-cal/e-data-cal.c b/calendar/libedata-cal/e-data-cal.c
index 5797da0..10dcf37 100644
--- a/calendar/libedata-cal/e-data-cal.c
+++ b/calendar/libedata-cal/e-data-cal.c
@@ -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.
diff --git a/calendar/libedata-cal/e-data-cal.h b/calendar/libedata-cal/e-data-cal.h
index bae69e0..4cd5f1a 100644
--- a/calendar/libedata-cal/e-data-cal.h
+++ b/calendar/libedata-cal/e-data-cal.h
@@ -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,
diff --git a/calendar/libedata-cal/e-data-cal.xml b/calendar/libedata-cal/e-data-cal.xml
index 8b60530..d2f5087 100644
--- a/calendar/libedata-cal/e-data-cal.xml
+++ b/calendar/libedata-cal/e-data-cal.xml
@@ -32,6 +32,11 @@
<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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]