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) {
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));
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;
}
}
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)
{
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;
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;
}
icalcomponent *icalcomp, *subcomp;
icalcomponent_kind kind;
const gchar *newuri;
- SoupURI *uri_parsed;
+ SoupURI *uri_parsed;
GHashTable *old_cache;
GSList *comps_in_cache;
}
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;
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) {
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;
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;
}
}
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;
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) {
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;
#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,
}
/**
+ * 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.
}
/**
+ * 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.
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);
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);
}
/**
+ * 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.
}
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;
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;
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);
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,
}
/**
+ * 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.
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 */
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);
/* 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);
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));
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);
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)
}
/**
+ * 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.
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,
<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>