diff options
Diffstat (limited to 'calendar/gui')
80 files changed, 1806 insertions, 1480 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 0a404d429c..09cc0559b0 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -209,7 +209,6 @@ libevolution_calendar_la_LIBADD = \ $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ $(top_builddir)/widgets/menus/libmenus.la \ $(top_builddir)/shell/libeshell.la \ - $(top_builddir)/calendar/common/libevolution-calendarprivate.la \ $(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la \ $(top_builddir)/calendar/importers/libevolution-calendar-importers.la \ $(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \ diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am index 5296f95f19..c15181ad9c 100644 --- a/calendar/gui/alarm-notify/Makefile.am +++ b/calendar/gui/alarm-notify/Makefile.am @@ -44,7 +44,6 @@ evolution_alarm_notify_SOURCES = \ evolution_alarm_notify_LDADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(top_builddir)/calendar/common/libevolution-calendarprivate.la \ $(CAMEL_LIBS) \ $(EVOLUTION_CALENDAR_LIBS) \ $(CANBERRA_LIBS) \ diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index 96e8a177aa..28b10ff602 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -26,16 +26,16 @@ #include <string.h> #include <camel/camel.h> +#include <libecal/e-cal-client.h> #include <libedataserver/e-url.h> #include <libedataserver/e-data-server-util.h> #include <libedataserverui/e-passwords.h> -#include <libecal/e-cal.h> +#include <libedataserverui/e-client-utils.h> #include "alarm.h" #include "alarm-notify.h" #include "alarm-queue.h" #include "config-data.h" -#include "common/authentication.h" #define APPLICATION_ID "org.gnome.EvolutionAlarmNotify" @@ -43,8 +43,8 @@ struct _AlarmNotifyPrivate { /* Mapping from EUri's to LoadedClient structures */ /* FIXME do we need per source type uri hashes? or perhaps we just need to hash based on source */ - GHashTable *uri_client_hash[E_CAL_SOURCE_TYPE_LAST]; - ESourceList *source_lists[E_CAL_SOURCE_TYPE_LAST]; + GHashTable *uri_client_hash[E_CAL_CLIENT_SOURCE_TYPE_LAST]; + ESourceList *source_lists[E_CAL_CLIENT_SOURCE_TYPE_LAST]; ESourceList *selected_calendars; GMutex *mutex; }; @@ -97,7 +97,7 @@ alarm_notify_list_changed_cb (ESourceList *source_list, AlarmNotify *an) { GSList *groups, *sources, *p, *q; - ECalSourceType source_type = E_CAL_SOURCE_TYPE_LAST; + ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST; ProcessRemovalsData prd; GList *l; gint i; @@ -106,13 +106,13 @@ alarm_notify_list_changed_cb (ESourceList *source_list, source_list, alarm_notify_list_changed_cb, an); /* Figure out the source type */ - for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) { + for (i = 0; i < E_CAL_CLIENT_SOURCE_TYPE_LAST; i++) { if (source_list == an->priv->source_lists[i]) { source_type = i; break; } } - if (source_type == E_CAL_SOURCE_TYPE_LAST) + if (source_type == E_CAL_CLIENT_SOURCE_TYPE_LAST) return; /* process the additions */ @@ -156,12 +156,12 @@ alarm_notify_list_changed_cb (ESourceList *source_list, static void alarm_notify_load_calendars (AlarmNotify *an, - ECalSourceType source_type) + ECalClientSourceType source_type) { ESourceList *source_list; GSList *groups, *sources, *p, *q; - if (!e_cal_get_sources (&source_list, source_type, NULL)) { + if (!e_cal_client_get_sources (&source_list, source_type, NULL)) { debug (("Cannont get sources")); an->priv->source_lists[source_type] = NULL; @@ -198,7 +198,7 @@ alarm_notify_load_calendars (AlarmNotify *an, static void alarm_notify_dequeue_client (gpointer key, - ECal *client) + ECalClient *client) { alarm_queue_remove_client (client, TRUE); } @@ -211,7 +211,7 @@ alarm_notify_finalize (GObject *object) priv = ALARM_NOTIFY (object)->priv; - for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++) { + for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) { g_hash_table_foreach ( priv->uri_client_hash[ii], (GHFunc) alarm_notify_dequeue_client, NULL); @@ -279,7 +279,7 @@ alarm_notify_init (AlarmNotify *an) an->priv->selected_calendars = config_data_get_calendars ( "/apps/evolution/calendar/sources"); - for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++) + for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) an->priv->uri_client_hash[ii] = g_hash_table_new_full ( g_str_hash, g_str_equal, (GDestroyNotify) g_free, @@ -287,7 +287,7 @@ alarm_notify_init (AlarmNotify *an) alarm_queue_init (an); - for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++) + for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) alarm_notify_load_calendars (an, ii); } @@ -313,22 +313,30 @@ alarm_notify_new (void) } static void -cal_opened_cb (ECal *client, const GError *error, gpointer user_data) +client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { AlarmNotifyPrivate *priv; AlarmNotify *an = ALARM_NOTIFY (user_data); + EClient *client = NULL; + GError *error = NULL; + + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; priv = an->priv; - debug (("%s - Calendar Status %d%s%s%s", e_cal_get_uri (client), error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : "")); + debug (("%s - Calendar Status %d%s%s%s", e_client_get_uri (client), error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : "")); + + if (!error) { + ECalClient *cal_client = E_CAL_CLIENT (client); + + g_hash_table_insert (priv->uri_client_hash[e_cal_client_get_source_type (cal_client)], g_strdup (e_client_get_uri (client)), cal_client); + /* to resolve floating DATE-TIME properly */ + e_cal_client_set_default_timezone (cal_client, config_data_get_timezone ()); - if (!error) - alarm_queue_add_client (client); - else { - g_hash_table_remove (priv->uri_client_hash[e_cal_get_source_type (client)], - e_cal_get_uri (client)); - g_signal_handlers_disconnect_matched (G_OBJECT (client), G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, an); + alarm_queue_add_client (cal_client); + } else { + g_error_free (error); } } @@ -344,10 +352,9 @@ cal_opened_cb (ECal *client, const GError *error, gpointer user_data) * that it can be loaded in the future when the alarm daemon starts up. **/ void -alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource *source, gboolean load_afterwards) +alarm_notify_add_calendar (AlarmNotify *an, ECalClientSourceType source_type, ESource *source, gboolean load_afterwards) { AlarmNotifyPrivate *priv; - ECal *client; EUri *e_uri; gchar *str_uri; gchar *pass_key; @@ -390,16 +397,16 @@ alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource } } - client = e_auth_new_cal_from_source (source, source_type); + debug (("%s - Calendar Open Async... %p", str_uri, source)); - if (client) { - debug (("%s - Calendar Open Async... %p", str_uri, client)); - g_hash_table_insert (priv->uri_client_hash[source_type], g_strdup (str_uri), client); - g_signal_connect (G_OBJECT (client), "cal_opened_ex", G_CALLBACK (cal_opened_cb), an); - /* to resolve floating DATE-TIME properly */ - e_cal_set_default_timezone (client, config_data_get_timezone (), NULL); - e_cal_open_async (client, FALSE); - } + e_client_utils_open_new (source, + source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ? E_CLIENT_SOURCE_TYPE_EVENTS : + source_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS ? E_CLIENT_SOURCE_TYPE_TASKS : + source_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS ? E_CLIENT_SOURCE_TYPE_MEMOS : + E_CLIENT_SOURCE_TYPE_LAST, + TRUE, NULL, + e_client_utils_authenticate_handler, NULL, + client_opened_cb, an); g_free (str_uri); g_free (pass_key); @@ -407,17 +414,17 @@ alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource } void -alarm_notify_remove_calendar (AlarmNotify *an, ECalSourceType source_type, const gchar *str_uri) +alarm_notify_remove_calendar (AlarmNotify *an, ECalClientSourceType source_type, const gchar *str_uri) { AlarmNotifyPrivate *priv; - ECal *client; + ECalClient *cal_client; priv = an->priv; - client = g_hash_table_lookup (priv->uri_client_hash[source_type], str_uri); - if (client) { - debug (("Removing Client %p", client)); - alarm_queue_remove_client (client, FALSE); + cal_client = g_hash_table_lookup (priv->uri_client_hash[source_type], str_uri); + if (cal_client) { + debug (("Removing Client %p", cal_client)); + alarm_queue_remove_client (cal_client, FALSE); g_hash_table_remove (priv->uri_client_hash[source_type], str_uri); } } diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h index de7e0398a6..51837d21d5 100644 --- a/calendar/gui/alarm-notify/alarm-notify.h +++ b/calendar/gui/alarm-notify/alarm-notify.h @@ -27,7 +27,8 @@ #define ALARM_NOTIFY_H #include <gtk/gtk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> +#include <libedataserverui/e-client-utils.h> /* Standard GObject macros */ #define TYPE_ALARM_NOTIFY \ @@ -66,11 +67,11 @@ struct _AlarmNotifyClass { GType alarm_notify_get_type (void); AlarmNotify * alarm_notify_new (void); void alarm_notify_add_calendar (AlarmNotify *an, - ECalSourceType source_type, + ECalClientSourceType source_type, ESource *source, gboolean load_afterwards); void alarm_notify_remove_calendar (AlarmNotify *an, - ECalSourceType source_type, + ECalClientSourceType source_type, const gchar *str_uri); ESourceList * alarm_notify_get_selected_calendars (AlarmNotify *an); diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index e8e5485e45..fde985f8be 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -34,6 +34,7 @@ #include <canberra-gtk.h> #endif +#include <libecal/e-cal-client-view.h> #include <libecal/e-cal-time-util.h> #include <libecal/e-cal-component.h> @@ -69,10 +70,10 @@ static AlarmNotify *an; /* Structure that stores a client we are monitoring */ typedef struct { /* Monitored client */ - ECal *client; + ECalClient *cal_client; - /* The live query to the calendar */ - ECalView *query; + /* The live view to the calendar */ + ECalClientView *view; /* Hash table of component UID -> CompQueuedAlarms. If an element is * present here, then it means its cqa->queued_alarms contains at least @@ -142,17 +143,17 @@ static void popup_notification (time_t trigger, gpointer alarm_id, gboolean use_description); #endif -static void query_objects_changed_cb (ECal *client, - GList *objects, +static void query_objects_modified_cb (ECalClientView *view, + const GSList *objects, gpointer data); -static void query_objects_removed_cb (ECal *client, - GList *objects, +static void query_objects_removed_cb (ECalClientView *view, + const GSList *uids, gpointer data); static void update_cqa (CompQueuedAlarms *cqa, ECalComponent *comp); static void update_qa (ECalComponentAlarms *alarms, QueuedAlarm *qa); static void tray_list_remove_cqa (CompQueuedAlarms *cqa); -static void on_dialog_objs_removed_cb (ECal *client, GList *objects, gpointer data); +static void on_dialog_objs_removed_cb (ECalClientView *view, const GSList *uids, gpointer data); /* Alarm queue engine */ @@ -299,9 +300,9 @@ midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data) /* Looks up a client in the client alarms hash table */ static ClientAlarms * -lookup_client (ECal *client) +lookup_client (ECalClient *cal_client) { - return g_hash_table_lookup (client_alarms_hash, client); + return g_hash_table_lookup (client_alarms_hash, cal_client); } /* Looks up a queued alarm based on its alarm ID */ @@ -347,10 +348,21 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, cqa->queued_alarms = g_slist_delete_link (cqa->queued_alarms, l); if (remove_alarm) { - cqa->expecting_update = TRUE; - e_cal_discard_alarm (cqa->parent_client->client, cqa->alarms->comp, - qa->instance->auid, NULL); - cqa->expecting_update = FALSE; + GError *error = NULL; + ECalComponentId *id = e_cal_component_get_id (cqa->alarms->comp); + if (id) { + cqa->expecting_update = TRUE; + e_cal_client_discard_alarm_sync (cqa->parent_client->cal_client, id->uid, id->rid, + qa->instance->auid, NULL, &error); + cqa->expecting_update = FALSE; + + if (error) { + if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED)) + g_debug ("%s: Failed to discard alarm: %s", G_STRFUNC, error->message); + g_error_free (error); + } + e_cal_component_free_id (id); + } } g_free (qa); @@ -425,7 +437,7 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) cqa = data; comp = cqa->alarms->comp; - config_data_set_last_notification_time (cqa->parent_client->client, trigger); + config_data_set_last_notification_time (cqa->parent_client->cal_client, trigger); debug (("Setting Last notification time to %s", e_ctime (&trigger))); qa = lookup_queued_alarm (cqa, alarm_id); @@ -543,6 +555,7 @@ static void load_alarms (ClientAlarms *ca, time_t start, time_t end) { gchar *str_query, *iso_start, *iso_end; + GError *error = NULL; debug (("...")); @@ -563,31 +576,36 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) g_free (iso_end); /* create the live query */ - if (ca->query) { + if (ca->view) { debug (("Disconnecting old queries")); g_signal_handlers_disconnect_matched ( - ca->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->query); - ca->query = NULL; + ca->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); + g_object_unref (ca->view); + ca->view = NULL; } - /* FIXME: handle errors */ - if (!e_cal_get_query (ca->client, str_query, &ca->query, NULL)) { - g_warning (G_STRLOC ": Could not get query for client"); + if (!e_cal_client_get_view_sync (ca->cal_client, str_query, &ca->view, NULL, &error)) { + g_debug ("%s: Could not get query for client: %s", error ? error->message : "Unknown error", G_STRFUNC); + if (error) + g_error_free (error); } else { debug (("Setting Call backs")); g_signal_connect ( - ca->query, "objects_added", - G_CALLBACK (query_objects_changed_cb), ca); + ca->view, "objects-added", + G_CALLBACK (query_objects_modified_cb), ca); g_signal_connect ( - ca->query, "objects_modified", - G_CALLBACK (query_objects_changed_cb), ca); + ca->view, "objects-modified", + G_CALLBACK (query_objects_modified_cb), ca); g_signal_connect ( - ca->query, "objects_removed", + ca->view, "objects-removed", G_CALLBACK (query_objects_removed_cb), ca); - e_cal_view_start (ca->query); + e_cal_client_view_start (ca->view, &error); + if (error) { + g_debug ("%s: Failed to start view: %s", G_STRFUNC, error->message); + g_error_free (error); + } } g_free (str_query); @@ -609,7 +627,7 @@ load_alarms_for_today (ClientAlarms *ca) * half-open; we do not want to display the "last" displayed alarm * twice, once when it occurs and once when the alarm daemon restarts. */ - from = config_data_get_last_notification_time (ca->client) + 1; + from = config_data_get_last_notification_time (ca->cal_client) + 1; if (from <= 0) from = MAX (from, day_start); @@ -618,20 +636,6 @@ load_alarms_for_today (ClientAlarms *ca) load_alarms (ca, from, day_end); } -/* Called when a calendar client finished loading; we load its alarms */ -static void -cal_opened_cb (ECal *client, const GError *error, gpointer data) -{ - ClientAlarms *ca; - - ca = data; - - if (error) - return; - - load_alarms_for_today (ca); -} - /* Looks up a component's queued alarm structure in a client alarms structure */ static CompQueuedAlarms * lookup_comp_queued_alarms (ClientAlarms *ca, const ECalComponentId *id) @@ -693,35 +697,71 @@ remove_comp (ClientAlarms *ca, ECalComponentId *id) */ struct _query_msg { Message header; - GList *objects; + GSList *objects; gpointer data; }; -static GList * -duplicate_ical (GList *in_list) +static GSList * +duplicate_ical (const GSList *in_list) { - GList *l, *out_list = NULL; + const GSList *l; + GSList *out_list = NULL; for (l = in_list; l; l = l->next) { - out_list = g_list_prepend (out_list, icalcomponent_new_clone (l->data)); + out_list = g_slist_prepend (out_list, icalcomponent_new_clone (l->data)); } - return g_list_reverse (out_list); + return g_slist_reverse (out_list); } -static GList * -duplicate_ecal (GList *in_list) +static GSList * +duplicate_ecal (const GSList *in_list) { - GList *l, *out_list = NULL; + const GSList *l; + GSList *out_list = NULL; for (l = in_list; l; l = l->next) { ECalComponentId *id, *old; old = l->data; id = g_new0 (ECalComponentId, 1); id->uid = g_strdup (old->uid); id->rid = g_strdup (old->rid); - out_list = g_list_prepend (out_list, id); + out_list = g_slist_prepend (out_list, id); + } + + return g_slist_reverse (out_list); +} + +static gboolean +get_alarms_for_object (ECalClient *cal_client, const ECalComponentId *id, time_t start, time_t end, ECalComponentAlarms **alarms) +{ + icalcomponent *icalcomp; + ECalComponent *comp; + ECalComponentAlarmAction omit[] = {-1}; + + g_return_val_if_fail (cal_client != NULL, FALSE); + g_return_val_if_fail (id != NULL, FALSE); + g_return_val_if_fail (alarms != NULL, FALSE); + g_return_val_if_fail (start >= 0 && end >= 0, FALSE); + g_return_val_if_fail (start <= end, FALSE); + + if (!e_cal_client_get_object_sync (cal_client, id->uid, id->rid, &icalcomp, NULL, NULL)) + return FALSE; + + if (!icalcomp) + return FALSE; + + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { + icalcomponent_free (icalcomp); + g_object_unref (comp); + return FALSE; } - return g_list_reverse (out_list); + *alarms = e_cal_util_generate_alarms_for_comp (comp, start, end, omit, e_cal_client_resolve_tzid_cb, + cal_client, e_cal_client_get_default_timezone (cal_client)); + + g_object_unref (comp); + + return TRUE; } static void @@ -733,13 +773,13 @@ query_objects_changed_async (struct _query_msg *msg) gboolean found; icaltimezone *zone; CompQueuedAlarms *cqa; - GList *l; - GList *objects; + GSList *l; + GSList *objects; ca = msg->data; objects = msg->objects; - from = config_data_get_last_notification_time (ca->client); + from = config_data_get_last_notification_time (ca->cal_client); if (from == -1) from = time (NULL); else @@ -757,10 +797,10 @@ query_objects_changed_async (struct _query_msg *msg) e_cal_component_set_icalcomponent (comp, l->data); id = e_cal_component_get_id (comp); - found = e_cal_get_alarms_for_object (ca->client, id, from, day_end, &alarms); + found = get_alarms_for_object (ca->cal_client, id, from, day_end, &alarms); if (!found) { - debug (("No Alarm found for client %p", ca->client)); + debug (("No Alarm found for client %p", ca->cal_client)); tray_list_remove_cqa (lookup_comp_queued_alarms (ca, id)); remove_comp (ca, id); g_hash_table_remove (ca->uid_alarms_hash, id); @@ -826,13 +866,13 @@ query_objects_changed_async (struct _query_msg *msg) g_object_unref (comp); comp = NULL; } - g_list_free (objects); + g_slist_free (objects); g_slice_free (struct _query_msg, msg); } static void -query_objects_changed_cb (ECal *client, GList *objects, gpointer data) +query_objects_modified_cb (ECalClientView *view, const GSList *objects, gpointer data) { struct _query_msg *msg; @@ -851,13 +891,13 @@ static void query_objects_removed_async (struct _query_msg *msg) { ClientAlarms *ca; - GList *l; - GList *objects; + GSList *l; + GSList *objects; ca = msg->data; objects = msg->objects; - debug (("Removing %d objects", g_list_length (objects))); + debug (("Removing %d objects", g_slist_length (objects))); for (l = objects; l != NULL; l = l->next) { /* If the alarm is already triggered remove it. */ @@ -867,19 +907,19 @@ query_objects_removed_async (struct _query_msg *msg) e_cal_component_free_id (l->data); } - g_list_free (objects); + g_slist_free (objects); g_slice_free (struct _query_msg, msg); } static void -query_objects_removed_cb (ECal *client, GList *objects, gpointer data) +query_objects_removed_cb (ECalClientView *view, const GSList *uids, gpointer data) { struct _query_msg *msg; msg = g_slice_new0 (struct _query_msg); msg->header.func = (MessageFunc) query_objects_removed_async; - msg->objects = duplicate_ecal (objects); + msg->objects = duplicate_ecal (uids); msg->data = data; message_push ((Message *) msg); @@ -919,7 +959,7 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, gint snooze_mins) /* Launches a component editor for a component */ static void -edit_component (ECal *client, ECalComponent *comp) +edit_component (ECalClient *cal_client, ECalComponent *comp) { ESource *source; gchar *command_line; @@ -931,19 +971,19 @@ edit_component (ECal *client, ECalComponent *comp) /* XXX Don't we have a function to construct these URIs? * How are other apps expected to know this stuff? */ - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (cal_client)); source_uid = e_source_peek_uid (source); e_cal_component_get_uid (comp, &comp_uid); - switch (e_cal_get_source_type (client)) { - case E_CAL_SOURCE_TYPE_EVENT: + switch (e_cal_client_get_source_type (cal_client)) { + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: scheme = "calendar:"; break; - case E_CAL_SOURCE_TYPE_TODO: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: scheme = "task:"; break; - case E_CAL_SOURCE_TYPE_JOURNAL: + case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: scheme = "memo:"; break; default: @@ -973,8 +1013,8 @@ typedef struct { CompQueuedAlarms *cqa; gpointer alarm_id; ECalComponent *comp; - ECal *client; - ECalView *query; + ECalClient *cal_client; + ECalClientView *view; GdkPixbuf *image; GtkTreeIter iter; } TrayIconData; @@ -999,13 +1039,13 @@ free_tray_icon_data (TrayIconData *tray_data) tray_data->location = NULL; } - g_object_unref (tray_data->client); - tray_data->client = NULL; + g_object_unref (tray_data->cal_client); + tray_data->cal_client = NULL; - g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC, + g_signal_handlers_disconnect_matched (tray_data->view, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_dialog_objs_removed_cb, NULL); - g_object_unref (tray_data->query); - tray_data->query = NULL; + g_object_unref (tray_data->view); + tray_data->view = NULL; g_object_unref (tray_data->comp); tray_data->comp = NULL; @@ -1020,44 +1060,47 @@ free_tray_icon_data (TrayIconData *tray_data) static void on_dialog_objs_removed_async (struct _query_msg *msg) { - const gchar *our_uid; - GList *l; TrayIconData *tray_data; - GList *objects; + GSList *l, *objects; + ECalComponentId *our_id; debug (("...")); tray_data = msg->data; objects = msg->objects; - e_cal_component_get_uid (tray_data->comp, &our_uid); - g_return_if_fail (our_uid && *our_uid); + our_id = e_cal_component_get_id (tray_data->comp); + g_return_if_fail (our_id); for (l = objects; l != NULL; l = l->next) { - const gchar *uid = l->data; + ECalComponentId *id = l->data; - if (!uid) + if (!id) continue; - if (!strcmp (uid, our_uid)) { + if (g_strcmp0 (id->uid, our_id->uid) == 0&& g_strcmp0 (id->rid, our_id->rid) == 0) { tray_data->cqa = NULL; tray_data->alarm_id = NULL; tray_icons_list = g_list_remove (tray_icons_list, tray_data); tray_data = NULL; } + + e_cal_component_free_id (id); } + e_cal_component_free_id (our_id); + g_slist_free (objects); g_slice_free (struct _query_msg, msg); } static void -on_dialog_objs_removed_cb (ECal *client, GList *objects, gpointer data) +on_dialog_objs_removed_cb (ECalClientView *view, const GSList *uids, gpointer data) { struct _query_msg *msg; msg = g_slice_new0 (struct _query_msg); msg->header.func = (MessageFunc) on_dialog_objs_removed_async; - msg->objects = objects; + msg->objects = duplicate_ecal (uids); msg->data = data; message_push ((Message *) msg); @@ -1219,7 +1262,7 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data) debug (("Received from dialog")); - g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC, + g_signal_handlers_disconnect_matched (tray_data->view, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_dialog_objs_removed_cb, NULL); switch (result) { @@ -1254,7 +1297,7 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data) break; case ALARM_NOTIFY_EDIT: - edit_component (tray_data->client, tray_data->comp); + edit_component (tray_data->cal_client, tray_data->comp); break; @@ -1530,11 +1573,11 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, tray_data->cqa = cqa; tray_data->alarm_id = alarm_id; tray_data->comp = g_object_ref (e_cal_component_clone (comp)); - tray_data->client = cqa->parent_client->client; - tray_data->query = g_object_ref (cqa->parent_client->query); + tray_data->cal_client = cqa->parent_client->cal_client; + tray_data->view = g_object_ref (cqa->parent_client->view); tray_data->blink_state = FALSE; tray_data->snooze_set = FALSE; - g_object_ref (tray_data->client); + g_object_ref (tray_data->cal_client); /* Task to add tray_data to the global tray_icon_list */ tray_list_add_new (tray_data); @@ -1558,7 +1601,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, g_free (time_str); g_free (str); - g_signal_connect (G_OBJECT (tray_data->query), "objects_removed", + g_signal_connect (G_OBJECT (tray_data->view), "objects_removed", G_CALLBACK (on_dialog_objs_removed_cb), tray_data); /* FIXME: We should remove this check */ @@ -1731,8 +1774,7 @@ mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) debug (("...")); - if (!e_cal_get_static_capability (cqa->parent_client->client, - CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)) + if (!e_client_check_capability (E_CLIENT (cqa->parent_client->cal_client), CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)) return; dialog = gtk_dialog_new_with_buttons (_("Warning"), @@ -1932,20 +1974,20 @@ free_client_alarms_cb (gpointer key, gpointer value, gpointer user_data) if (ca) { remove_client_alarms (ca); - if (ca->client) { + if (ca->cal_client) { debug (("Disconnecting Client")); - g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched (ca->cal_client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->client); + g_object_unref (ca->cal_client); } - if (ca->query) { + if (ca->view) { debug (("Disconnecting Query")); - g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched (ca->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->query); + g_object_unref (ca->view); } g_hash_table_destroy (ca->uid_alarms_hash); @@ -2016,52 +2058,46 @@ hash_ids (gpointer a) struct _alarm_client_msg { Message header; - ECal *client; + ECalClient *cal_client; }; static void alarm_queue_add_async (struct _alarm_client_msg *msg) { ClientAlarms *ca; - ECal *client = msg->client; + ECalClient *cal_client = msg->cal_client; g_return_if_fail (alarm_queue_inited); - g_return_if_fail (client != NULL); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (cal_client != NULL); + g_return_if_fail (E_IS_CAL_CLIENT (cal_client)); - ca = lookup_client (client); + ca = lookup_client (cal_client); if (ca) { /* We already have it. Unref the passed one*/ - g_object_unref (client); + g_object_unref (cal_client); return; } - debug (("client=%p", client)); + debug (("client=%p", cal_client)); ca = g_new (ClientAlarms, 1); - ca->client = client; - ca->query = NULL; + ca->cal_client = cal_client; + ca->view = NULL; - g_hash_table_insert (client_alarms_hash, client, ca); + g_hash_table_insert (client_alarms_hash, cal_client, ca); ca->uid_alarms_hash = g_hash_table_new ( (GHashFunc) hash_ids, (GEqualFunc) compare_ids); - if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) { - load_alarms_for_today (ca); - } else { - g_signal_connect (client, "cal_opened_ex", - G_CALLBACK (cal_opened_cb), - ca); - } + load_alarms_for_today (ca); g_slice_free (struct _alarm_client_msg, msg); } /** * alarm_queue_add_client: - * @client: A calendar client. + * @cal_client: A calendar client. * * Adds a calendar client to the alarm queueing system. Alarm trigger * notifications will be presented at the appropriate times. The client should @@ -2074,13 +2110,13 @@ alarm_queue_add_async (struct _alarm_client_msg *msg) * queueing system when it is no longer wanted. **/ void -alarm_queue_add_client (ECal *client) +alarm_queue_add_client (ECalClient *cal_client) { struct _alarm_client_msg *msg; msg = g_slice_new0 (struct _alarm_client_msg); msg->header.func = (MessageFunc) alarm_queue_add_async; - msg->client = g_object_ref (client); + msg->cal_client = g_object_ref (cal_client); message_push ((Message *) msg); } @@ -2137,35 +2173,35 @@ static void alarm_queue_remove_async (struct _alarm_client_msg *msg) { ClientAlarms *ca; - ECal *client = msg->client; + ECalClient *cal_client = msg->cal_client; g_return_if_fail (alarm_queue_inited); - g_return_if_fail (client != NULL); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (cal_client != NULL); + g_return_if_fail (E_IS_CAL_CLIENT (cal_client)); - ca = lookup_client (client); + ca = lookup_client (cal_client); g_return_if_fail (ca != NULL); debug (("...")); remove_client_alarms (ca); /* Clean up */ - if (ca->client) { + if (ca->cal_client) { debug (("Disconnecting Client")); - g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched (ca->cal_client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->client); - ca->client = NULL; + g_object_unref (ca->cal_client); + ca->cal_client = NULL; } - if (ca->query) { + if (ca->view) { debug (("Disconnecting Query")); - g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched (ca->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->query); - ca->query = NULL; + g_object_unref (ca->view); + ca->view = NULL; } g_hash_table_destroy (ca->uid_alarms_hash); @@ -2173,7 +2209,7 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg) g_free (ca); - g_hash_table_remove (client_alarms_hash, client); + g_hash_table_remove (client_alarms_hash, cal_client); g_slice_free (struct _alarm_client_msg, msg); } @@ -2181,18 +2217,18 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg) /** alarm_queue_remove_client * * asynchronously remove client from alarm queue. - * @client: Client to remove. + * @cal_client: Client to remove. * @immediately: Indicates whether use thread or do it right now. */ void -alarm_queue_remove_client (ECal *client, gboolean immediately) +alarm_queue_remove_client (ECalClient *cal_client, gboolean immediately) { struct _alarm_client_msg *msg; msg = g_slice_new0 (struct _alarm_client_msg); msg->header.func = (MessageFunc) alarm_queue_remove_async; - msg->client = client; + msg->cal_client = cal_client; if (immediately) { alarm_queue_remove_async (msg); @@ -2220,7 +2256,7 @@ update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp) debug (("Generating alarms between %s and %s", e_ctime (&from), e_ctime (&to))); alarms = e_cal_util_generate_alarms_for_comp (newcomp, from, to, omit, - e_cal_resolve_tzid_cb, cqa->parent_client->client, zone); + e_cal_client_resolve_tzid_cb, cqa->parent_client->cal_client, zone); /* Update auids in Queued Alarms*/ for (qa_list = cqa->queued_alarms; qa_list; qa_list = qa_list->next) { diff --git a/calendar/gui/alarm-notify/alarm-queue.h b/calendar/gui/alarm-notify/alarm-queue.h index c594e12a6b..e43027bd60 100644 --- a/calendar/gui/alarm-notify/alarm-queue.h +++ b/calendar/gui/alarm-notify/alarm-queue.h @@ -26,12 +26,12 @@ #ifndef ALARM_QUEUE_H #define ALARM_QUEUE_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> void alarm_queue_init (gpointer); void alarm_queue_done (void); -void alarm_queue_add_client (ECal *client); -void alarm_queue_remove_client (ECal *client, gboolean immediately); +void alarm_queue_add_client (ECalClient *cal_client); +void alarm_queue_remove_client (ECalClient *cal_client, gboolean immediately); #endif diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c index 41207d48fb..b5e6faa923 100644 --- a/calendar/gui/alarm-notify/config-data.c +++ b/calendar/gui/alarm-notify/config-data.c @@ -259,7 +259,7 @@ config_data_get_notify_with_tray (void) * triggered while it was not running. **/ void -config_data_set_last_notification_time (ECal *cal, time_t t) +config_data_set_last_notification_time (ECalClient *cal, time_t t) { GConfClient *client; time_t current_t, now = time (NULL); @@ -267,7 +267,7 @@ config_data_set_last_notification_time (ECal *cal, time_t t) g_return_if_fail (t != -1); if (cal) { - ESource *source = e_cal_get_source (cal); + ESource *source = e_client_get_source (E_CLIENT (cal)); if (source) { GTimeVal tmval = {0}; gchar *as_text; @@ -301,13 +301,13 @@ config_data_set_last_notification_time (ECal *cal, time_t t) * Return value: The last saved value, or -1 if no value had been saved before. **/ time_t -config_data_get_last_notification_time (ECal *cal) +config_data_get_last_notification_time (ECalClient *cal) { GConfValue *value; GConfClient *client; if (cal) { - ESource *source = e_cal_get_source (cal); + ESource *source = e_client_get_source (E_CLIENT (cal)); if (source) { const gchar *last_notified; diff --git a/calendar/gui/alarm-notify/config-data.h b/calendar/gui/alarm-notify/config-data.h index 85b2593a8b..1023609d6a 100644 --- a/calendar/gui/alarm-notify/config-data.h +++ b/calendar/gui/alarm-notify/config-data.h @@ -27,7 +27,7 @@ #define CONFIG_DATA_H #include <libical/ical.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <gconf/gconf-client.h> #include <libedataserver/e-source-list.h> @@ -37,10 +37,10 @@ gboolean config_data_get_24_hour_format (void); gboolean config_data_get_notify_with_tray (void); void config_data_set_last_notification_time - (ECal *cal, + (ECalClient *cal, time_t t); time_t config_data_get_last_notification_time - (ECal *cal); + (ECalClient *cal); void config_data_save_blessed_program (const gchar *program); gboolean config_data_is_blessed_program (const gchar *program); diff --git a/calendar/gui/cal-editor-utils.c b/calendar/gui/cal-editor-utils.c index c49e648883..4ddc3899b9 100644 --- a/calendar/gui/cal-editor-utils.c +++ b/calendar/gui/cal-editor-utils.c @@ -32,7 +32,7 @@ /** * open_component_editor: - * @client: Already opened #ECal, where to store the component + * @client: Already opened #ECalClient, where to store the component * @comp: #ECalComponent component to be stored * @is_new: Whether the @comp is a new component or an existing * @error: #GError for possible error reporting @@ -45,7 +45,7 @@ **/ void open_component_editor (EShell *shell, - ECal *client, + ECalClient *client, ECalComponent *comp, gboolean is_new, GError **error) @@ -55,7 +55,7 @@ open_component_editor (EShell *shell, CompEditor *editor = NULL; g_return_if_fail (E_IS_SHELL (shell)); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); g_return_if_fail (E_IS_CAL_COMPONENT (comp)); id = e_cal_component_get_id (comp); @@ -99,10 +99,7 @@ open_component_editor (EShell *shell, break; default: if (error) - *error = g_error_new ( - E_CALENDAR_ERROR, - E_CALENDAR_STATUS_INVALID_OBJECT, - "%s", _("Invalid object")); + *error = e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL); break; } diff --git a/calendar/gui/cal-editor-utils.h b/calendar/gui/cal-editor-utils.h index 00f24a5b33..26b2104ea4 100644 --- a/calendar/gui/cal-editor-utils.h +++ b/calendar/gui/cal-editor-utils.h @@ -20,14 +20,14 @@ #ifndef CAL_EDITOR_UTILS_H #define CAL_EDITOR_UTILS_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-component.h> #include <shell/e-shell.h> G_BEGIN_DECLS void open_component_editor (EShell *shell, - ECal *client, + ECalClient *client, ECalComponent *comp, gboolean is_new, GError **error); diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index f905af4d40..61e92efae4 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -29,7 +29,7 @@ #define _CALENDAR_CONFIG_H_ #include <gdk/gdk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <gconf/gconf-client.h> #include <e-util/e-util-enums.h> diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index fbf9e7dc82..a6095d0bcc 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -32,8 +32,8 @@ #include "comp-util.h" #include "dialogs/delete-comp.h" #include <libecal/e-cal-component.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-categories-config.h" -#include "common/authentication.h" #include "gnome-cal.h" #include "shell/e-shell-window.h" @@ -90,7 +90,7 @@ e_cal_component_compare_tzid (const gchar *tzid1, const gchar *tzid2) /** * cal_comp_util_compare_event_timezones: * @comp: A calendar component object. - * @client: A #ECal. + * @client: A #ECalClient. * * Checks if the component uses the given timezone for both the start and * the end time, or if the UTC offsets of the start and end times are the same @@ -101,7 +101,7 @@ e_cal_component_compare_tzid (const gchar *tzid1, const gchar *tzid2) **/ gboolean cal_comp_util_compare_event_timezones (ECalComponent *comp, - ECal *client, + ECalClient *client, icaltimezone *zone) { ECalComponentDateTime start_datetime, end_datetime; @@ -151,8 +151,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, /* If the TZIDs differ, we have to compare the UTC offsets of the start and end times, using their own timezones and the given timezone. */ - if (!e_cal_get_timezone (client, start_datetime.tzid, - &start_zone, NULL)) + if (!e_cal_client_get_timezone_sync (client, start_datetime.tzid, + &start_zone, NULL, NULL)) goto out; if (start_datetime.value) { @@ -166,8 +166,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, goto out; } - if (!e_cal_get_timezone (client, end_datetime.tzid, - &end_zone, NULL)) + if (!e_cal_client_get_timezone_sync (client, end_datetime.tzid, + &end_zone, NULL, NULL)) goto out; if (end_datetime.value) { @@ -211,7 +211,7 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, * user cancelled the deletion. **/ gboolean -cal_comp_is_on_server (ECalComponent *comp, ECal *client) +cal_comp_is_on_server (ECalComponent *comp, ECalClient *client) { const gchar *uid; gchar *rid = NULL; @@ -221,7 +221,7 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client) g_return_val_if_fail (comp != NULL, FALSE); g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE); g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (E_IS_CAL (client), FALSE); + g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE); /* See if the component is on the server. If it is not, then it likely * means that the appointment is new, only in the day view, and we @@ -234,19 +234,18 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client) /* TODO We should not be checking for this here. But since * e_cal_util_construct_instance does not create the instances * of all day events, so we default to old behaviour. */ - if (e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) { + if (e_cal_client_check_recurrences_no_master (client)) { rid = e_cal_component_get_recurid_as_string (comp); } - if (e_cal_get_object (client, uid, rid, &icalcomp, &error)) { + if (e_cal_client_get_object_sync (client, uid, rid, &icalcomp, NULL, &error)) { icalcomponent_free (icalcomp); g_free (rid); return TRUE; } - if (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND) + if (!g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) g_warning (G_STRLOC ": %s", error->message); g_clear_error (&error); @@ -261,7 +260,7 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client) * icalcomponent, not the ECalComponent. **/ gboolean -is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client) +is_icalcomp_on_the_server (icalcomponent *icalcomp, ECalClient *client) { gboolean on_server; ECalComponent *comp; @@ -288,7 +287,7 @@ is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client) * Return value: A newly-created calendar component. **/ ECalComponent * -cal_comp_event_new_with_defaults (ECal *client, +cal_comp_event_new_with_defaults (ECalClient *client, gboolean all_day, gboolean use_default_reminder, gint default_reminder_interval, @@ -300,7 +299,7 @@ cal_comp_event_new_with_defaults (ECal *client, icalproperty *icalprop; ECalComponentAlarmTrigger trigger; - if (!e_cal_get_default_object (client, &icalcomp, NULL)) + if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT); comp = e_cal_component_new (); @@ -358,7 +357,7 @@ cal_comp_event_new_with_defaults (ECal *client, } ECalComponent * -cal_comp_event_new_with_current_time (ECal *client, +cal_comp_event_new_with_current_time (ECalClient *client, gboolean all_day, icaltimezone *zone, gboolean use_default_reminder, @@ -398,12 +397,12 @@ cal_comp_event_new_with_current_time (ECal *client, } ECalComponent * -cal_comp_task_new_with_defaults (ECal *client) +cal_comp_task_new_with_defaults (ECalClient *client) { ECalComponent *comp; icalcomponent *icalcomp; - if (!e_cal_get_default_object (client, &icalcomp, NULL)) + if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) icalcomp = icalcomponent_new (ICAL_VTODO_COMPONENT); comp = e_cal_component_new (); @@ -417,12 +416,12 @@ cal_comp_task_new_with_defaults (ECal *client) } ECalComponent * -cal_comp_memo_new_with_defaults (ECal *client) +cal_comp_memo_new_with_defaults (ECalClient *client) { ECalComponent *comp; icalcomponent *icalcomp; - if (!e_cal_get_default_object (client, &icalcomp, NULL)) + if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) icalcomp = icalcomponent_new (ICAL_VJOURNAL_COMPONENT); comp = e_cal_component_new (); @@ -613,7 +612,7 @@ cal_comp_selection_get_string_list (GtkSelectionData *selection_data) } static void -datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) +datetime_to_zone (ECalClient *client, ECalComponentDateTime *date, const gchar *tzid) { icaltimezone *from, *to; @@ -625,16 +624,21 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) from = icaltimezone_get_builtin_timezone_from_tzid (date->tzid); if (!from) { - if (!e_cal_get_timezone (client, date->tzid, &from, NULL)) + GError *error = NULL; + + if (!e_cal_client_get_timezone_sync (client, date->tzid, &from, NULL, &error)) g_warning ( - "%s: Could not get timezone from server: %s", - G_STRFUNC, date->tzid ? date->tzid : ""); + "%s: Could not get timezone '%s' from server: %s", + G_STRFUNC, date->tzid ? date->tzid : "", error ? error->message : "Unknown error"); + + if (error) + g_error_free (error); } to = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (!to) { /* do not check failure here, maybe the zone is not available there */ - e_cal_get_timezone (client, tzid, &to, NULL); + e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL); } icaltimezone_convert_time (date->value, from, to); @@ -643,14 +647,14 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) /** * cal_comp_set_dtstart_with_oldzone: - * @client: ECal structure, to retrieve timezone from, when required. + * @client: ECalClient structure, to retrieve timezone from, when required. * @comp: Component, where make the change. * @pdate: Value, to change to. * * Changes 'dtstart' of the component, but converts time to the old timezone. **/ void -cal_comp_set_dtstart_with_oldzone (ECal *client, +cal_comp_set_dtstart_with_oldzone (ECalClient *client, ECalComponent *comp, const ECalComponentDateTime *pdate) { @@ -671,14 +675,14 @@ cal_comp_set_dtstart_with_oldzone (ECal *client, /** * cal_comp_set_dtend_with_oldzone: - * @client: ECal structure, to retrieve timezone from, when required. + * @client: ECalClient structure, to retrieve timezone from, when required. * @comp: Component, where make the change. * @pdate: Value, to change to. * * Changes 'dtend' of the component, but converts time to the old timezone. **/ void -cal_comp_set_dtend_with_oldzone (ECal *client, +cal_comp_set_dtend_with_oldzone (ECalClient *client, ECalComponent *comp, const ECalComponentDateTime *pdate) { @@ -699,18 +703,21 @@ cal_comp_set_dtend_with_oldzone (ECal *client, void comp_util_sanitize_recurrence_master (ECalComponent *comp, - ECal *client) + ECalClient *client) { ECalComponent *master = NULL; icalcomponent *icalcomp = NULL; ECalComponentRange rid; ECalComponentDateTime sdt; const gchar *uid; + GError *error = NULL; /* Get the master component */ e_cal_component_get_uid (comp, &uid); - if (!e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) { - g_warning ("Unable to get the master component \n"); + if (!e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, &error)) { + g_warning ("Unable to get the master component: %s", error ? error->message : "Unknown error"); + if (error) + g_error_free (error); return; } diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h index c99e1d0c3f..1f69ddb107 100644 --- a/calendar/gui/comp-util.h +++ b/calendar/gui/comp-util.h @@ -27,7 +27,7 @@ #include <gtk/gtk.h> #include <libecal/e-cal-component.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <e-util/e-util-enums.h> struct _EShell; @@ -38,41 +38,41 @@ void cal_comp_util_add_exdate (ECalComponent *comp, time_t t, icaltimezone *zone and DTEND, or if the UTC offsets of the start and end times are the same as in the given zone. */ gboolean cal_comp_util_compare_event_timezones (ECalComponent *comp, - ECal *client, + ECalClient *client, icaltimezone *zone); /* Returns the number of icons owned by the ECalComponent */ gint cal_comp_util_get_n_icons (ECalComponent *comp, GSList **pixbufs); gboolean cal_comp_is_on_server (ECalComponent *comp, - ECal *client); -gboolean is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client); + ECalClient *client); +gboolean is_icalcomp_on_the_server (icalcomponent *icalcomp, ECalClient *client); ECalComponent * cal_comp_event_new_with_defaults - (ECal *client, + (ECalClient *client, gboolean all_day, gboolean use_default_reminder, gint default_reminder_interval, EDurationType default_reminder_units); ECalComponent * cal_comp_event_new_with_current_time - (ECal *client, + (ECalClient *client, gboolean all_day, icaltimezone *zone, gboolean use_default_reminder, gint default_reminder_interval, EDurationType default_reminder_units); -ECalComponent *cal_comp_task_new_with_defaults (ECal *client); -ECalComponent *cal_comp_memo_new_with_defaults (ECal *client); +ECalComponent *cal_comp_task_new_with_defaults (ECalClient *client); +ECalComponent *cal_comp_memo_new_with_defaults (ECalClient *client); void cal_comp_update_time_by_active_window (ECalComponent *comp, struct _EShell *shell); void cal_comp_selection_set_string_list (GtkSelectionData *data, GSList *str_list); GSList *cal_comp_selection_get_string_list (GtkSelectionData *data); -void cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate); -void cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate); +void cal_comp_set_dtstart_with_oldzone (ECalClient *client, ECalComponent *comp, const ECalComponentDateTime *pdate); +void cal_comp_set_dtend_with_oldzone (ECalClient *client, ECalComponent *comp, const ECalComponentDateTime *pdate); -void comp_util_sanitize_recurrence_master (ECalComponent *comp, ECal *client); +void comp_util_sanitize_recurrence_master (ECalComponent *comp, ECalClient *client); gchar *icalcomp_suggest_filename (icalcomponent *icalcomp, const gchar *default_name); diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c index 6b234f6cce..564c4dd1f4 100644 --- a/calendar/gui/dialogs/alarm-dialog.c +++ b/calendar/gui/dialogs/alarm-dialog.c @@ -54,7 +54,7 @@ typedef struct { ECalComponentAlarm *alarm; /* The client */ - ECal *ecal; + ECalClient *cal_client; /* Toplevel */ GtkWidget *toplevel; @@ -209,16 +209,16 @@ alarm_to_dialog (Dialog *dialog) for (i = 0; valid && action_map[i] != -1; i++) { gtk_list_store_set ( GTK_LIST_STORE (model), &iter, - 1, !e_cal_get_static_capability (dialog->ecal, action_map_cap[i]), + 1, !e_client_check_capability (E_CLIENT (dialog->cal_client), action_map_cap[i]), -1); valid = gtk_tree_model_iter_next (model, &iter); } /* Set a default address if possible */ - if (!e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS) - && !e_cal_component_alarm_has_attendees (dialog->alarm) - && e_cal_get_alarm_email_address (dialog->ecal, &email, NULL)) { + if (!e_client_check_capability (E_CLIENT (dialog->cal_client), CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS) + && !e_cal_component_alarm_has_attendees (dialog->alarm) + && e_client_get_backend_property_sync (E_CLIENT (dialog->cal_client), CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS, &email, NULL, NULL)) { ECalComponentAttendee *a; GSList attendee_list; @@ -235,7 +235,7 @@ alarm_to_dialog (Dialog *dialog) } /* If we can repeat */ - repeat = !e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT); + repeat = !e_client_check_capability (E_CLIENT (dialog->cal_client), CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT); gtk_widget_set_sensitive (dialog->repeat_toggle, repeat); /* if we are editing a exiting alarm */ @@ -880,27 +880,6 @@ get_widgets (Dialog *dialog) && dialog->palarm_args); } -#if 0 -/* Callback used when the alarm options button is clicked */ -static void -show_options (Dialog *dialog) -{ - gboolean repeat; - gchar *email; - - e_cal_component_alarm_set_action (dialog->alarm, - e_dialog_combo_box_get (dialog->action_combo, action_map)); - - repeat = !e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT); - - if (e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS) - || e_cal_get_alarm_email_address (dialog->ecal, &email, NULL)) { - if (!alarm_options_dialog_run (dialog->toplevel, dialog->alarm, email, repeat)) - g_message (G_STRLOC ": not create the alarm options dialog"); - } -} -#endif - static void addressbook_clicked_cb (GtkWidget *widget, Dialog *dialog) { @@ -1202,7 +1181,7 @@ init_widgets (Dialog *dialog) } gboolean -alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm) +alarm_dialog_run (GtkWidget *parent, ECalClient *cal_client, ECalComponentAlarm *alarm) { Dialog dialog; GtkWidget *container; @@ -1211,7 +1190,7 @@ alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm) g_return_val_if_fail (alarm != NULL, FALSE); dialog.alarm = alarm; - dialog.ecal = ecal; + dialog.cal_client = cal_client; dialog.builder = gtk_builder_new (); e_load_ui_builder_definition (dialog.builder, "alarm-dialog.ui"); diff --git a/calendar/gui/dialogs/alarm-dialog.h b/calendar/gui/dialogs/alarm-dialog.h index b5560f9ff4..d99d47f15f 100644 --- a/calendar/gui/dialogs/alarm-dialog.h +++ b/calendar/gui/dialogs/alarm-dialog.h @@ -30,12 +30,12 @@ #ifndef ALARM_DIALOG_H #define ALARM_DIALOG_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-component.h> G_BEGIN_DECLS -gboolean alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm); +gboolean alarm_dialog_run (GtkWidget *parent, ECalClient *cal_client, ECalComponentAlarm *alarm); G_END_DECLS diff --git a/calendar/gui/dialogs/alarm-list-dialog.c b/calendar/gui/dialogs/alarm-list-dialog.c index 1990e076df..3e854da751 100644 --- a/calendar/gui/dialogs/alarm-list-dialog.c +++ b/calendar/gui/dialogs/alarm-list-dialog.c @@ -48,7 +48,7 @@ typedef struct { GtkBuilder *builder; /* The client */ - ECal *ecal; + ECalClient *cal_client; /* The list store */ EAlarmList *list_store; @@ -94,18 +94,13 @@ sensitize_buttons (Dialog *dialog) GtkTreeSelection *selection; GtkTreeIter iter; gboolean have_selected, read_only = FALSE; - GError *error = NULL; - if (!e_cal_is_read_only (dialog->ecal, &read_only, &error)) { - if (error->code != E_CALENDAR_STATUS_BUSY) - read_only = TRUE; - g_error_free (error); - } + read_only = e_client_is_readonly (E_CLIENT (dialog->cal_client)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list)); have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter); - if ((e_cal_get_one_alarm_only (dialog->ecal) && have_selected) || read_only) + if ((e_cal_client_check_one_alarm_only (dialog->cal_client) && have_selected) || read_only) gtk_widget_set_sensitive (dialog->add, FALSE); else gtk_widget_set_sensitive (dialog->add, TRUE); @@ -133,7 +128,7 @@ add_clicked_cb (GtkButton *button, gpointer data) icalproperty_set_x_name (icalprop, "X-EVOLUTION-NEEDS-DESCRIPTION"); icalcomponent_add_property (icalcomp, icalprop); - if (alarm_dialog_run (dialog->toplevel, dialog->ecal, alarm)) { + if (alarm_dialog_run (dialog->toplevel, dialog->cal_client, alarm)) { e_alarm_list_append (dialog->list_store, &iter, alarm); gtk_tree_selection_select_iter (gtk_tree_view_get_selection (view), &iter); } else { @@ -165,7 +160,7 @@ edit_clicked_cb (GtkButton *button, gpointer data) alarm = (ECalComponentAlarm *) e_alarm_list_get_alarm (dialog->list_store, &iter); path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->list_store), &iter); - if (alarm_dialog_run (dialog->toplevel, dialog->ecal, alarm)) { + if (alarm_dialog_run (dialog->toplevel, dialog->cal_client, alarm)) { gtk_tree_selection_select_iter (gtk_tree_view_get_selection (view), &iter); gtk_tree_model_row_changed (GTK_TREE_MODEL (dialog->list_store), path, &iter); } @@ -216,7 +211,7 @@ selection_changed_cb (GtkTreeSelection *selection, gpointer data) } void -alarm_list_dialog_set_client (GtkWidget *dlg_box, ECal *client) +alarm_list_dialog_set_client (GtkWidget *dlg_box, ECalClient *cal_client) { Dialog *dialog; @@ -224,7 +219,7 @@ alarm_list_dialog_set_client (GtkWidget *dlg_box, ECal *client) dialog = g_object_get_data (G_OBJECT (dlg_box), "dialog"); if (dialog) { - dialog->ecal = client; + dialog->cal_client = cal_client; sensitize_buttons (dialog); } } @@ -267,13 +262,13 @@ init_widgets (Dialog *dialog) } gboolean -alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store) +alarm_list_dialog_run (GtkWidget *parent, ECalClient *cal_client, EAlarmList *list_store) { Dialog dialog; GtkWidget *container; gint response_id; - dialog.ecal = ecal; + dialog.cal_client = cal_client; dialog.list_store = list_store; dialog.builder = gtk_builder_new (); @@ -313,12 +308,12 @@ alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store) } GtkWidget * -alarm_list_dialog_peek (ECal *ecal, EAlarmList *list_store) +alarm_list_dialog_peek (ECalClient *cal_client, EAlarmList *list_store) { Dialog *dialog; dialog = (Dialog *) g_new (Dialog, 1); - dialog->ecal = ecal; + dialog->cal_client = cal_client; dialog->list_store = list_store; dialog->builder = gtk_builder_new (); diff --git a/calendar/gui/dialogs/alarm-list-dialog.h b/calendar/gui/dialogs/alarm-list-dialog.h index 7d58fcb0af..163582c556 100644 --- a/calendar/gui/dialogs/alarm-list-dialog.h +++ b/calendar/gui/dialogs/alarm-list-dialog.h @@ -30,15 +30,15 @@ #ifndef ALARM_LIST_DIALOG_H #define ALARM_LIST_DIALOG_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-component.h> #include "../e-alarm-list.h" G_BEGIN_DECLS -gboolean alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store); -GtkWidget *alarm_list_dialog_peek (ECal *ecal, EAlarmList *list_store); -void alarm_list_dialog_set_client (GtkWidget *dlg_box, ECal *client); +gboolean alarm_list_dialog_run (GtkWidget *parent, ECalClient *cal_client, EAlarmList *list_store); +GtkWidget *alarm_list_dialog_peek (ECalClient *cal_client, EAlarmList *list_store); +void alarm_list_dialog_set_client (GtkWidget *dlg_box, ECalClient *cal_client); G_END_DECLS diff --git a/calendar/gui/dialogs/calendar-setup.c b/calendar/gui/dialogs/calendar-setup.c index 5981076ee6..231cd0dd34 100644 --- a/calendar/gui/dialogs/calendar-setup.c +++ b/calendar/gui/dialogs/calendar-setup.c @@ -32,7 +32,7 @@ #include <libedataserver/e-source-list.h> #include <shell/e-shell.h> #include <glib/gi18n.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include "calendar-setup.h" #include "../e-cal-config.h" @@ -55,7 +55,7 @@ struct _CalendarSourceDialog { /* Source group we're creating/editing a source in */ ESourceGroup *source_group; - ECalSourceType source_type; + ECalClientSourceType source_type; }; static gboolean @@ -272,11 +272,11 @@ eccp_general_offline (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidg else { g_object_get (parent, "n-rows", &row, NULL); - if (sdialog->source_type == E_CAL_SOURCE_TYPE_EVENT) + if (sdialog->source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS) offline_setting = gtk_check_button_new_with_mnemonic (_("Cop_y calendar contents locally for offline operation")); - else if (sdialog->source_type == E_CAL_SOURCE_TYPE_TODO) + else if (sdialog->source_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS) offline_setting = gtk_check_button_new_with_mnemonic (_("Cop_y task list contents locally for offline operation")); - else if (sdialog->source_type == E_CAL_SOURCE_TYPE_JOURNAL) + else if (sdialog->source_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS) offline_setting = gtk_check_button_new_with_mnemonic (_("Cop_y memo list contents locally for offline operation")); gtk_widget_show (offline_setting); @@ -469,7 +469,7 @@ calendar_setup_edit_calendar (GtkWindow *parent, ESource *source, ESourceGroup * e_source_set_absolute_uri (sdialog->source, NULL); e_source_set_group (sdialog->source, sdialog->source_group); - sdialog->source_type = E_CAL_SOURCE_TYPE_EVENT; + sdialog->source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties"); for (i = 0; eccp_items[i].path; i++) items = g_slist_prepend (items, &eccp_items[i]); @@ -477,7 +477,7 @@ calendar_setup_edit_calendar (GtkWindow *parent, ESource *source, ESourceGroup * e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog); target = e_cal_config_target_new_source (ec, sdialog->source); - target->source_type = E_CAL_SOURCE_TYPE_EVENT; + target->source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; e_config_set_target ((EConfig *) ec, (EConfigTarget *) target); sdialog->window = e_config_create_window ((EConfig *)ec, NULL, source ? _("Calendar Properties") : _("New Calendar")); @@ -525,7 +525,7 @@ calendar_setup_edit_task_list (GtkWindow *parent, ESource *source) e_source_set_absolute_uri (sdialog->source, NULL); e_source_set_group (sdialog->source, sdialog->source_group); - sdialog->source_type = E_CAL_SOURCE_TYPE_TODO; + sdialog->source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS; sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties"); for (i = 0; ectp_items[i].path; i++) items = g_slist_prepend (items, &ectp_items[i]); @@ -533,7 +533,7 @@ calendar_setup_edit_task_list (GtkWindow *parent, ESource *source) e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog); target = e_cal_config_target_new_source (ec, sdialog->source); - target->source_type = E_CAL_SOURCE_TYPE_TODO; + target->source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS; e_config_set_target ((EConfig *) ec, (EConfigTarget *) target); sdialog->window = e_config_create_window ((EConfig *)ec, NULL, source ? _("Task List Properties") : _("New Task List")); @@ -581,7 +581,7 @@ calendar_setup_edit_memo_list (GtkWindow *parent, ESource *source) e_source_set_absolute_uri (sdialog->source, NULL); e_source_set_group (sdialog->source, sdialog->source_group); - sdialog->source_type = E_CAL_SOURCE_TYPE_JOURNAL; + sdialog->source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS; sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties"); for (i = 0; ecmp_items[i].path; i++) items = g_slist_prepend (items, &ecmp_items[i]); @@ -589,7 +589,7 @@ calendar_setup_edit_memo_list (GtkWindow *parent, ESource *source) e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog); target = e_cal_config_target_new_source (ec, sdialog->source); - target->source_type = E_CAL_SOURCE_TYPE_JOURNAL; + target->source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS; e_config_set_target ((EConfig *) ec, (EConfigTarget *) target); sdialog->window = e_config_create_window ((EConfig *)ec, NULL, source ? _("Memo List Properties") : _("New Memo List")); diff --git a/calendar/gui/dialogs/cancel-comp.c b/calendar/gui/dialogs/cancel-comp.c index 4482d4d7ab..86663eda97 100644 --- a/calendar/gui/dialogs/cancel-comp.c +++ b/calendar/gui/dialogs/cancel-comp.c @@ -66,14 +66,14 @@ is_past_event (ECalComponent *comp) **/ gboolean cancel_component_dialog (GtkWindow *parent, - ECal *client, + ECalClient *cal_client, ECalComponent *comp, gboolean deleting) { ECalComponentVType vtype; const gchar *id; - if (deleting && e_cal_get_save_schedules (client)) + if (deleting && e_cal_client_check_save_schedules (cal_client)) return TRUE; vtype = e_cal_component_get_vtype (comp); diff --git a/calendar/gui/dialogs/cancel-comp.h b/calendar/gui/dialogs/cancel-comp.h index db455b06d7..3514cf19f5 100644 --- a/calendar/gui/dialogs/cancel-comp.h +++ b/calendar/gui/dialogs/cancel-comp.h @@ -26,9 +26,9 @@ #ifndef CANCEL_COMP_H #define CANCEL_COMP_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-component.h> -gboolean cancel_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean deleting); +gboolean cancel_component_dialog (GtkWindow *parent, ECalClient *cal_client, ECalComponent *comp, gboolean deleting); #endif diff --git a/calendar/gui/dialogs/comp-editor-page.h b/calendar/gui/dialogs/comp-editor-page.h index 2b9f7a4467..a33d83810d 100644 --- a/calendar/gui/dialogs/comp-editor-page.h +++ b/calendar/gui/dialogs/comp-editor-page.h @@ -28,7 +28,7 @@ #include <time.h> #include <gtk/gtk.h> #include <libecal/e-cal-component.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <calendar/gui/e-meeting-attendee.h> diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index cc794ae3f5..21ac86e9c3 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -43,6 +43,9 @@ #include <e-util/gconf-bridge.h> #include <shell/e-shell.h> +#include <libecal/e-cal-client.h> +#include <libecal/e-cal-client-view.h> + #include "../print.h" #include "../comp-util.h" #include "save-comp.h" @@ -75,13 +78,14 @@ struct _CompEditorPrivate { GtkWindowGroup *window_group; /* Client to use */ - ECal *client; + ECalClient *cal_client; /* Source client (where comp lives currently) */ - ECal *source_client; + ECalClient *source_client; /* View to listen for changes */ - ECalView *view; + ECalClientView *view; + GCancellable *view_cancellable; /* Calendar object/uid we are editing; this is an internal copy */ ECalComponent *comp; @@ -198,8 +202,8 @@ static void page_dates_changed_cb (CompEditor *editor, CompEditorPageDates *dates, CompEditorPage *page); -static void obj_modified_cb (ECal *client, GList *objs, CompEditor *editor); -static void obj_removed_cb (ECal *client, GList *uids, CompEditor *editor); +static void obj_modified_cb (ECalClientView *view, const GSList *objs, CompEditor *editor); +static void obj_removed_cb (ECalClientView *view, const GSList *uids, CompEditor *editor); G_DEFINE_TYPE_WITH_CODE ( CompEditor, comp_editor, GTK_TYPE_WINDOW, @@ -303,7 +307,7 @@ get_attachment_list (CompEditor *editor) view = E_ATTACHMENT_VIEW (editor->priv->attachment_view); store = e_attachment_view_get_store (view); - local_store = e_cal_get_local_attachment_store (editor->priv->client); + local_store = e_cal_client_get_local_attachment_store (editor->priv->cal_client); e_cal_component_get_uid (editor->priv->comp, &comp_uid); path = g_build_path ("/", local_store, comp_uid, NULL); destination = g_file_new_for_path (path); @@ -344,6 +348,40 @@ commit_all_fields (CompEditor *editor) } static void +changes_view_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + CompEditor *editor = user_data; + ECalClientView *view = NULL; + GError *error = NULL; + + g_return_if_fail (editor != NULL); + + if (!e_cal_client_get_view_finish (E_CAL_CLIENT (source_object), result, &view, &error)) + view = NULL; + + if (view) { + editor->priv->view = view; + g_signal_connect ( + view, "objects_modified", + G_CALLBACK (obj_modified_cb), editor); + g_signal_connect ( + view, "objects_removed", + G_CALLBACK (obj_removed_cb), editor); + + e_cal_client_view_start (view, &error); + + if (error) { + g_debug ("%s: Failed to stat view: %s", G_STRFUNC, error->message); + g_error_free (error); + } + } else if (error) { + if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) + g_debug ("%s: Failed to get view: %s", G_STRFUNC, error->message); + g_error_free (error); + } +} + +static void listen_for_changes (CompEditor *editor) { CompEditorPrivate *priv; @@ -352,6 +390,12 @@ listen_for_changes (CompEditor *editor) priv = editor->priv; /* Discard change listener */ + if (priv->view_cancellable) { + g_cancellable_cancel (priv->view_cancellable); + g_object_unref (priv->view_cancellable); + priv->view_cancellable = NULL; + } + if (priv->view) { g_signal_handlers_disconnect_matched (G_OBJECT (priv->view), G_SIGNAL_MATCH_DATA, @@ -369,21 +413,11 @@ listen_for_changes (CompEditor *editor) if (uid) { gchar *query; + priv->view_cancellable = g_cancellable_new (); query = g_strdup_printf ("(uid? \"%s\")", uid); - e_cal_get_query (priv->source_client, query, &priv->view, NULL); + e_cal_client_get_view (priv->source_client, query, priv->view_cancellable, changes_view_ready_cb, editor); g_free (query); } - - if (priv->view) { - g_signal_connect ( - priv->view, "objects_modified", - G_CALLBACK (obj_modified_cb), editor); - g_signal_connect ( - priv->view, "objects_removed", - G_CALLBACK (obj_removed_cb), editor); - - e_cal_view_start (priv->view); - } } static void @@ -391,8 +425,14 @@ send_timezone (gpointer key, gpointer value, gpointer user_data) { icaltimezone *zone = value; CompEditor *editor = user_data; + GError *error = NULL; + + e_cal_client_add_timezone_sync (editor->priv->cal_client, zone, NULL, &error); - e_cal_add_timezone (editor->priv->client, zone, NULL); + if (error) { + g_debug ("%s: Failed to add timezone: %s", G_STRFUNC, error->message); + g_error_free (error); + } } static gboolean @@ -448,8 +488,8 @@ save_comp (CompEditor *editor) /* If we are not the organizer, we don't update the sequence number */ if (!e_cal_component_has_organizer (clone) || - itip_organizer_is_user (clone, priv->client) || - itip_sentby_is_user (clone, priv->client)) + itip_organizer_is_user (clone, priv->cal_client) || + itip_sentby_is_user (clone, priv->cal_client)) e_cal_component_commit_sequence (clone); else e_cal_component_abort_sequence (clone); @@ -472,10 +512,14 @@ save_comp (CompEditor *editor) priv->comp, get_attachment_list (editor)); icalcomp = e_cal_component_get_icalcomponent (priv->comp); /* send the component to the server */ - if (!cal_comp_is_on_server (priv->comp, priv->client)) { - result = e_cal_create_object (priv->client, icalcomp, NULL, &error); - if (result) + if (!cal_comp_is_on_server (priv->comp, priv->cal_client)) { + gchar *uid = NULL; + result = e_cal_client_create_object_sync (priv->cal_client, icalcomp, &uid, NULL, &error); + if (result) { + icalcomponent_set_uid (icalcomp, uid); + g_free (uid); g_signal_emit_by_name (editor, "object_created"); + } } else { gboolean has_recurrences; @@ -484,7 +528,7 @@ save_comp (CompEditor *editor) if (has_recurrences && priv->mod == CALOBJ_MOD_ALL) comp_util_sanitize_recurrence_master ( - priv->comp, priv->client); + priv->comp, priv->cal_client); if (priv->mod == CALOBJ_MOD_THIS) { e_cal_component_set_rdate_list (priv->comp, NULL); @@ -492,13 +536,13 @@ save_comp (CompEditor *editor) e_cal_component_set_exdate_list (priv->comp, NULL); e_cal_component_set_exrule_list (priv->comp, NULL); } - result = e_cal_modify_object (priv->client, icalcomp, priv->mod, &error); + result = e_cal_client_modify_object_sync (priv->cal_client, icalcomp, priv->mod, NULL, &error); if (priv->mod == CALOBJ_MOD_THIS) { if (result && ((flags & COMP_EDITOR_DELEGATE) || !e_cal_component_has_organizer (clone) || - itip_organizer_is_user (clone, priv->client) || - itip_sentby_is_user (clone, priv->client))) + itip_organizer_is_user (clone, priv->cal_client) || + itip_sentby_is_user (clone, priv->cal_client))) e_cal_component_commit_sequence (clone); else e_cal_component_abort_sequence (clone); @@ -550,25 +594,31 @@ save_comp (CompEditor *editor) return FALSE; } else { if (priv->source_client && - !e_source_equal (e_cal_get_source (priv->client), - e_cal_get_source (priv->source_client)) && + !e_source_equal (e_client_get_source (E_CLIENT (priv->cal_client)), + e_client_get_source (E_CLIENT (priv->source_client))) && cal_comp_is_on_server (priv->comp, priv->source_client)) { /* Comp found a new home. Remove it from old one. */ + GError *error = NULL; if (e_cal_component_is_instance (priv->comp) || e_cal_component_has_recurrences (priv->comp)) - e_cal_remove_object_with_mod ( + e_cal_client_remove_object_sync ( priv->source_client, orig_uid_copy, - NULL, CALOBJ_MOD_ALL, NULL); + NULL, CALOBJ_MOD_ALL, NULL, &error); else - e_cal_remove_object ( + e_cal_client_remove_object_sync ( priv->source_client, - orig_uid_copy, NULL); + orig_uid_copy, NULL, CALOBJ_MOD_THIS, NULL, &error); + + if (error) { + g_debug ("%s: Failed to remove object: %s", G_STRFUNC, error->message); + g_error_free (error); + } /* Let priv->source_client point to new home, * so we can move it again this session. */ g_object_unref (priv->source_client); - priv->source_client = g_object_ref (priv->client); + priv->source_client = g_object_ref (priv->cal_client); listen_for_changes (editor); } @@ -608,9 +658,9 @@ save_comp_with_send (CompEditor *editor) if (!save_comp (editor)) return FALSE; - delegated = delegate && !e_cal_get_save_schedules (priv->client); + delegated = delegate && !e_cal_client_check_save_schedules (priv->cal_client); if (delegated || (send && send_component_dialog ( - (GtkWindow *) editor, priv->client, priv->comp, + (GtkWindow *) editor, priv->cal_client, priv->comp, !priv->existing_org, &strip_alarms, !priv->existing_org ? NULL : &only_new_attendees))) { if (delegated) @@ -622,8 +672,8 @@ save_comp_with_send (CompEditor *editor) (only_new_attendees ? COMP_EDITOR_SEND_TO_NEW_ATTENDEES_ONLY : 0)); - if ((itip_organizer_is_user (priv->comp, priv->client) || - itip_sentby_is_user (priv->comp, priv->client))) { + if ((itip_organizer_is_user (priv->comp, priv->cal_client) || + itip_sentby_is_user (priv->comp, priv->cal_client))) { if (e_cal_component_get_vtype (priv->comp) == E_CAL_COMPONENT_JOURNAL) return comp_editor_send_comp ( editor, E_CAL_COMPONENT_METHOD_PUBLISH, @@ -768,7 +818,7 @@ action_print_cb (GtkAction *action, use_24_hour_format = comp_editor_get_use_24_hour_format (editor); print_comp ( - comp, priv->client, zone, use_24_hour_format, + comp, priv->cal_client, zone, use_24_hour_format, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); g_object_unref (comp); @@ -798,14 +848,14 @@ action_print_preview_cb (GtkAction *action, use_24_hour_format = comp_editor_get_use_24_hour_format (editor); print_comp ( - comp, priv->client, zone, use_24_hour_format, + comp, priv->cal_client, zone, use_24_hour_format, GTK_PRINT_OPERATION_ACTION_PREVIEW); g_object_unref (comp); } static gboolean -remove_event_dialog (ECal *client, +remove_event_dialog (ECalClient *client, ECalComponent *comp, GtkWindow *parent) { @@ -833,7 +883,7 @@ action_save_cb (GtkAction *action, EAttachmentView *view; ECalComponentText text; gboolean delegated = FALSE; - gboolean read_only, correct = FALSE; + gboolean correct = FALSE; ECalComponent *comp; view = E_ATTACHMENT_VIEW (priv->attachment_view); @@ -860,12 +910,12 @@ action_save_cb (GtkAction *action, return; } - if (!e_cal_is_read_only (priv->client, &read_only, NULL) || read_only) { + if (e_client_is_readonly (E_CLIENT (priv->cal_client))) { e_alert_submit ( E_ALERT_SINK (editor), "calendar:prompt-read-only-cal-editor", e_source_peek_name ( - e_cal_get_source (priv->client)), + e_client_get_source (E_CLIENT (priv->cal_client))), NULL); return; } @@ -873,7 +923,7 @@ action_save_cb (GtkAction *action, commit_all_fields (editor); if (e_cal_component_has_recurrences (priv->comp)) { if (!recur_component_dialog ( - priv->client, priv->comp, &priv->mod, + priv->cal_client, priv->comp, &priv->mod, GTK_WINDOW (editor), delegated)) return; } else if (e_cal_component_is_instance (priv->comp)) @@ -888,7 +938,7 @@ action_save_cb (GtkAction *action, if (!text.value) if (!send_component_prompt_subject ( - (GtkWindow *) editor, priv->client, priv->comp)) + (GtkWindow *) editor, priv->cal_client, priv->comp)) return; if (save_comp_with_send (editor)) { @@ -899,7 +949,7 @@ action_save_cb (GtkAction *action, delegate = flags & COMP_EDITOR_DELEGATE; if (delegate && !remove_event_dialog ( - priv->client, priv->comp, GTK_WINDOW (editor))) { + priv->cal_client, priv->comp, GTK_WINDOW (editor))) { const gchar *uid = NULL; GError *error = NULL; @@ -909,12 +959,10 @@ action_save_cb (GtkAction *action, e_cal_component_has_recurrences (priv->comp)) { gchar *rid; rid = e_cal_component_get_recurid_as_string (priv->comp); - e_cal_remove_object_with_mod ( - priv->client, uid, rid, - priv->mod, &error); + e_cal_client_remove_object_sync (priv->cal_client, uid, rid, priv->mod, NULL, &error); g_free (rid); } else - e_cal_remove_object (priv->client, uid, &error); + e_cal_client_remove_object_sync (priv->cal_client, uid, NULL, CALOBJ_MOD_THIS, NULL, &error); g_clear_error (&error); } @@ -1470,9 +1518,9 @@ comp_editor_dispose (GObject *object) priv->window_group = NULL; } - if (priv->client) { - g_object_unref (priv->client); - priv->client = NULL; + if (priv->cal_client) { + g_object_unref (priv->cal_client); + priv->cal_client = NULL; } if (priv->source_client) { @@ -1480,6 +1528,12 @@ comp_editor_dispose (GObject *object) priv->source_client = NULL; } + if (priv->view_cancellable) { + g_cancellable_cancel (priv->view_cancellable); + g_object_unref (priv->view_cancellable); + priv->view_cancellable = NULL; + } + if (priv->view) { g_signal_handlers_disconnect_matched (G_OBJECT (priv->view), G_SIGNAL_MATCH_DATA, @@ -1690,7 +1744,7 @@ comp_editor_class_init (CompEditorClass *class) "client", NULL, NULL, - E_TYPE_CAL, + E_TYPE_CAL_CLIENT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); @@ -2074,7 +2128,7 @@ static gboolean prompt_and_save_changes (CompEditor *editor, gboolean send) { CompEditorPrivate *priv; - gboolean read_only, correct = FALSE; + gboolean correct = FALSE; ECalComponent *comp; ECalComponentText text; @@ -2085,12 +2139,12 @@ prompt_and_save_changes (CompEditor *editor, gboolean send) switch (save_component_dialog (GTK_WINDOW (editor), priv->comp)) { case GTK_RESPONSE_YES: /* Save */ - if (!e_cal_is_read_only (priv->client, &read_only, NULL) || read_only) { + if (e_client_is_readonly (E_CLIENT (priv->cal_client))) { e_alert_submit ( E_ALERT_SINK (editor), "calendar:prompt-read-only-cal-editor", e_source_peek_name ( - e_cal_get_source (priv->client)), + e_client_get_source (E_CLIENT (priv->cal_client))), NULL); /* don't discard changes when selected readonly calendar */ return FALSE; @@ -2105,12 +2159,12 @@ prompt_and_save_changes (CompEditor *editor, gboolean send) if (!text.value) if (!send_component_prompt_subject ( - (GtkWindow *) editor, priv->client, priv->comp)) + (GtkWindow *) editor, priv->cal_client, priv->comp)) return FALSE; if (e_cal_component_is_instance (priv->comp)) if (!recur_component_dialog ( - priv->client, priv->comp, &priv->mod, + priv->cal_client, priv->comp, &priv->mod, GTK_WINDOW (editor), FALSE)) return FALSE; @@ -2815,27 +2869,27 @@ comp_editor_show_page (CompEditor *editor, CompEditorPage *page) /** * comp_editor_set_client: * @editor: A component editor - * @client: The calendar client to use + * @cal_client: The calendar client to use * * Sets the calendar client used by the editor to update components **/ void comp_editor_set_client (CompEditor *editor, - ECal *client) + ECalClient *cal_client) { g_return_if_fail (IS_COMP_EDITOR (editor)); - g_return_if_fail (client == NULL || E_IS_CAL (client)); + g_return_if_fail (cal_client == NULL || E_IS_CAL_CLIENT (cal_client)); - if (client != NULL) - g_object_ref (client); + if (cal_client != NULL) + g_object_ref (cal_client); - if (editor->priv->client != NULL) - g_object_unref (editor->priv->client); + if (editor->priv->cal_client != NULL) + g_object_unref (editor->priv->cal_client); - editor->priv->client = client; + editor->priv->cal_client = cal_client; - if (editor->priv->source_client == NULL && client != NULL) - editor->priv->source_client = g_object_ref (client); + if (editor->priv->source_client == NULL && cal_client != NULL) + editor->priv->source_client = g_object_ref (cal_client); g_object_notify (G_OBJECT (editor), "client"); } @@ -2848,12 +2902,12 @@ comp_editor_set_client (CompEditor *editor, * * Return value: The calendar client of the editor **/ -ECal * +ECalClient * comp_editor_get_client (CompEditor *editor) { g_return_val_if_fail (IS_COMP_EDITOR (editor), NULL); - return editor->priv->client; + return editor->priv->cal_client; } static void @@ -3046,7 +3100,7 @@ set_attendees_for_delegation (ECalComponent *comp, } static void -get_users_from_memo_comp (ECalComponent *comp, GList **users) +get_users_from_memo_comp (ECalComponent *comp, GSList **users) { icalcomponent *icalcomp; icalproperty *icalprop; @@ -3072,7 +3126,7 @@ get_users_from_memo_comp (ECalComponent *comp, GList **users) iter = emails; while (*iter) { - *users = g_list_append (*users, g_strdup (*iter)); + *users = g_slist_append (*users, g_strdup (*iter)); iter++; } g_strfreev (emails); @@ -3088,7 +3142,7 @@ real_send_comp (CompEditor *editor, CompEditorFlags flags; ECalComponent *send_comp = NULL; gchar *address = NULL; - GList *users = NULL; + GSList *users = NULL; g_return_val_if_fail (IS_COMP_EDITOR (editor), FALSE); @@ -3101,7 +3155,7 @@ real_send_comp (CompEditor *editor, const gchar *uid = NULL; e_cal_component_get_uid (priv->comp, &uid); - if (e_cal_get_object (priv->client, uid, NULL, &icalcomp, NULL) && icalcomp) { + if (e_cal_client_get_object_sync (priv->cal_client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); @@ -3122,17 +3176,17 @@ real_send_comp (CompEditor *editor, /* The user updates the delegated status to the Organizer, * so remove all other attendees. */ if (flags & COMP_EDITOR_DELEGATE) { - address = itip_get_comp_attendee (send_comp, priv->client); + address = itip_get_comp_attendee (send_comp, priv->cal_client); if (address) set_attendees_for_delegation (send_comp, address, method); } if (!e_cal_component_has_attachments (priv->comp) || - e_cal_get_static_capability (priv->client, + e_client_check_capability (E_CLIENT (priv->cal_client), CAL_STATIC_CAPABILITY_CREATE_MESSAGES)) { if (itip_send_comp ( - method, send_comp, priv->client, + method, send_comp, priv->cal_client, NULL, NULL, users, strip_alarms, priv->flags & COMP_EDITOR_SEND_TO_NEW_ATTENDEES_ONLY)) { g_object_unref (send_comp); @@ -3162,7 +3216,7 @@ real_send_comp (CompEditor *editor, } if (itip_send_comp ( - method, send_comp, priv->client, + method, send_comp, priv->cal_client, NULL, mime_attach_list, users, strip_alarms, priv->flags & COMP_EDITOR_SEND_TO_NEW_ATTENDEES_ONLY)) { gboolean saved = save_comp (editor); @@ -3279,10 +3333,10 @@ comp_editor_delete_comp (CompEditor *editor) e_cal_component_get_uid (priv->comp, &uid); if (e_cal_component_is_instance (priv->comp) || e_cal_component_has_recurrences (priv->comp)) - e_cal_remove_object_with_mod (priv->client, uid, NULL, - CALOBJ_MOD_ALL, NULL); + e_cal_client_remove_object_sync (priv->cal_client, uid, NULL, + CALOBJ_MOD_ALL, NULL, NULL); else - e_cal_remove_object (priv->client, uid, NULL); + e_cal_client_remove_object_sync (priv->cal_client, uid, NULL, CALOBJ_MOD_THIS, NULL, NULL); close_dialog (editor); } @@ -3428,8 +3482,8 @@ page_dates_changed_cb (CompEditor *editor, } static void -obj_modified_cb (ECal *client, - GList *objects, +obj_modified_cb (ECalClientView *view, + const GSList *objects, CompEditor *editor) { CompEditorPrivate *priv; @@ -3465,8 +3519,8 @@ obj_modified_cb (ECal *client, } static void -obj_removed_cb (ECal *client, - GList *uids, +obj_removed_cb (ECalClientView *view, + const GSList *uids, CompEditor *editor) { CompEditorPrivate *priv = editor->priv; diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h index 591300ffd2..3f1ddbb673 100644 --- a/calendar/gui/dialogs/comp-editor.h +++ b/calendar/gui/dialogs/comp-editor.h @@ -26,7 +26,7 @@ #define COMP_EDITOR_H #include <gtk/gtk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include "../itip-utils.h" #include "comp-editor-page.h" #include <shell/e-shell.h> @@ -165,8 +165,8 @@ void comp_editor_remove_page (CompEditor *editor, void comp_editor_show_page (CompEditor *editor, CompEditorPage *page); void comp_editor_set_client (CompEditor *editor, - ECal *client); -ECal * comp_editor_get_client (CompEditor *editor); + ECalClient *cal_client); +ECalClient * comp_editor_get_client (CompEditor *editor); void comp_editor_edit_comp (CompEditor *ee, ECalComponent *comp); ECalComponent * comp_editor_get_comp (CompEditor *editor); diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c index 547a91069c..7b75624a56 100644 --- a/calendar/gui/dialogs/copy-source-dialog.c +++ b/calendar/gui/dialogs/copy-source-dialog.c @@ -27,33 +27,35 @@ #endif #include <glib/gi18n.h> +#include <libedataserverui/e-client-utils.h> + #include "copy-source-dialog.h" #include "select-source-dialog.h" -#include "common/authentication.h" typedef struct { GtkWindow *parent; ESource *orig_source; - ECalSourceType obj_type; + EClientSourceType obj_type; ESource *selected_source; + ECalClient *source_client, *dest_client; } CopySourceDialogData; static void -show_error (CopySourceDialogData *csdd, const gchar *msg) +show_error (CopySourceDialogData *csdd, const gchar *msg, const GError *error) { GtkWidget *dialog; dialog = gtk_message_dialog_new ( csdd->parent, 0, GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, "%s", msg); + GTK_BUTTONS_CLOSE, error ? "%s\n%s" : "%s", msg, error ? error->message : ""); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } struct ForeachTzidData { - ECal *source_client; - ECal *dest_client; + ECalClient *source_client; + ECalClient *dest_client; }; static void @@ -71,61 +73,70 @@ add_timezone_to_cal_cb (icalparameter *param, gpointer data) if (!tzid || !*tzid) return; - if (e_cal_get_timezone (ftd->source_client, tzid, &tz, NULL) && tz) - e_cal_add_timezone (ftd->dest_client, tz, NULL); + if (e_cal_client_get_timezone_sync (ftd->source_client, tzid, &tz, NULL, NULL) && tz) + e_cal_client_add_timezone_sync (ftd->dest_client, tz, NULL, NULL); } -static gboolean -copy_source (CopySourceDialogData *csdd) +static void +free_copy_data (CopySourceDialogData *csdd) { - ECal *source_client, *dest_client; - gboolean read_only = TRUE; - GList *obj_list = NULL; - gboolean result = FALSE; - - if (!csdd->selected_source) - return FALSE; - - /* open the source */ - source_client = e_auth_new_cal_from_source (csdd->orig_source, csdd->obj_type); - if (!e_cal_open (source_client, TRUE, NULL)) { - show_error (csdd, _("Could not open source")); - g_object_unref (source_client); - return FALSE; - } + if (!csdd) + return; - /* open the destination */ - dest_client = e_auth_new_cal_from_source (csdd->selected_source, csdd->obj_type); - if (!e_cal_open (dest_client, FALSE, NULL)) { - show_error (csdd, _("Could not open destination")); - g_object_unref (dest_client); - g_object_unref (source_client); - return FALSE; + if (csdd->orig_source) + g_object_unref (csdd->orig_source); + if (csdd->selected_source) + g_object_unref (csdd->selected_source); + if (csdd->source_client) + g_object_unref (csdd->source_client); + if (csdd->dest_client) + g_object_unref (csdd->dest_client); + g_free (csdd); +} + +static void +dest_source_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + CopySourceDialogData *csdd = user_data; + EClient *client = NULL; + GError *error = NULL; + + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; + + if (!client) { + show_error (csdd, _("Could not open destination"), error); + if (error) + g_error_free (error); + free_copy_data (csdd); + return; } + csdd->dest_client = E_CAL_CLIENT (client); + + e_client_utils_open_new (csdd->selected_source, csdd->obj_type, FALSE, NULL, + e_client_utils_authenticate_handler, csdd->parent, + dest_source_opened_cb, csdd); + /* check if the destination is read only */ - e_cal_is_read_only (dest_client, &read_only, NULL); - if (read_only) { - show_error (csdd, _("Destination is read only")); + if (e_client_is_readonly (E_CLIENT (csdd->dest_client))) { + show_error (csdd, _("Destination is read only"), NULL); } else { - if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) { - GList *l; + GSList *obj_list = NULL; + if (e_cal_client_get_object_list_sync (csdd->source_client, "#t", &obj_list, NULL, NULL)) { + GSList *l; icalcomponent *icalcomp; struct ForeachTzidData ftd; - ftd.source_client = source_client; - ftd.dest_client = dest_client; + ftd.source_client = csdd->source_client; + ftd.dest_client = csdd->dest_client; for (l = obj_list; l != NULL; l = l->next) { /* FIXME: process recurrences */ /* FIXME: process errors */ - if (e_cal_get_object ( - dest_client, - icalcomponent_get_uid (l->data), - NULL, &icalcomp, NULL)) { - e_cal_modify_object ( - dest_client, l->data, - CALOBJ_MOD_ALL, NULL); + if (e_cal_client_get_object_sync (csdd->dest_client, icalcomponent_get_uid (l->data), NULL, + &icalcomp, NULL, NULL)) { + e_cal_client_modify_object_sync (csdd->dest_client, l->data, CALOBJ_MOD_ALL, NULL, NULL); icalcomponent_free (icalcomp); } else { gchar *uid = NULL; @@ -139,11 +150,11 @@ copy_source (CopySourceDialogData *csdd) icalcomp, add_timezone_to_cal_cb, &ftd); - if (e_cal_create_object (dest_client, icalcomp, &uid, &error)) { + if (e_cal_client_create_object_sync (csdd->dest_client, icalcomp, &uid, NULL, &error)) { g_free (uid); } else { if (error) { - show_error (csdd, error->message); + show_error (csdd, _("Cannot create object"), error); g_error_free (error); } break; @@ -151,15 +162,57 @@ copy_source (CopySourceDialogData *csdd) } } - e_cal_free_object_list (obj_list); + e_cal_client_free_icalcomp_slist (obj_list); } } - /* free memory */ - g_object_unref (dest_client); - g_object_unref (source_client); + free_copy_data (csdd); +} + +static void +orig_source_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + CopySourceDialogData *csdd = user_data; + EClient *client = NULL; + GError *error = NULL; + + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; + + if (!client) { + show_error (csdd, _("Could not open source"), error); + if (error) + g_error_free (error); + free_copy_data (csdd); + return; + } + + csdd->source_client = E_CAL_CLIENT (client); + + e_client_utils_open_new (csdd->selected_source, csdd->obj_type, FALSE, NULL, + e_client_utils_authenticate_handler, csdd->parent, + dest_source_opened_cb, csdd); +} + +static void +copy_source (const CopySourceDialogData *const_csdd) +{ + CopySourceDialogData *csdd; + + if (!const_csdd->selected_source) + return; - return result; + g_return_if_fail (const_csdd->obj_type != E_CLIENT_SOURCE_TYPE_LAST); + + csdd = g_new0 (CopySourceDialogData, 1); + csdd->parent = const_csdd->parent; + csdd->orig_source = g_object_ref (const_csdd->orig_source); + csdd->obj_type = const_csdd->obj_type; + csdd->selected_source = g_object_ref (const_csdd->selected_source); + + e_client_utils_open_new (csdd->orig_source, csdd->obj_type, FALSE, NULL, + e_client_utils_authenticate_handler, csdd->parent, + orig_source_opened_cb, csdd); } /** @@ -168,26 +221,29 @@ copy_source (CopySourceDialogData *csdd) * Implements the Copy command for sources, allowing the user to select a target * source to copy to. */ -gboolean -copy_source_dialog (GtkWindow *parent, ESource *source, ECalSourceType obj_type) +void +copy_source_dialog (GtkWindow *parent, ESource *source, ECalClientSourceType obj_type) { CopySourceDialogData csdd; - gboolean result = FALSE; - g_return_val_if_fail (E_IS_SOURCE (source), FALSE); + g_return_if_fail (E_IS_SOURCE (source)); + g_return_if_fail (obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS || + obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS || + obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS); csdd.parent = parent; csdd.orig_source = source; csdd.selected_source = NULL; - csdd.obj_type = obj_type; + csdd.obj_type = obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ? E_CLIENT_SOURCE_TYPE_EVENTS : + obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS ? E_CLIENT_SOURCE_TYPE_TASKS : + obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS ? E_CLIENT_SOURCE_TYPE_MEMOS : + E_CLIENT_SOURCE_TYPE_LAST; csdd.selected_source = select_source_dialog (parent, obj_type, source); if (csdd.selected_source) { - result = copy_source (&csdd); + copy_source (&csdd); /* free memory */ g_object_unref (csdd.selected_source); } - - return result; } diff --git a/calendar/gui/dialogs/copy-source-dialog.h b/calendar/gui/dialogs/copy-source-dialog.h index 4c6f5b19c8..d9475f742c 100644 --- a/calendar/gui/dialogs/copy-source-dialog.h +++ b/calendar/gui/dialogs/copy-source-dialog.h @@ -28,9 +28,9 @@ #include <gtk/gtk.h> #include <libedataserver/e-source.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-util.h> -gboolean copy_source_dialog (GtkWindow *parent, ESource *source, ECalSourceType type); +void copy_source_dialog (GtkWindow *parent, ESource *source, ECalClientSourceType type); #endif diff --git a/calendar/gui/dialogs/delete-error.c b/calendar/gui/dialogs/delete-error.c index 9b9d22ae4c..cd461c7858 100644 --- a/calendar/gui/dialogs/delete-error.c +++ b/calendar/gui/dialogs/delete-error.c @@ -45,11 +45,11 @@ delete_error_dialog (const GError *error, ECalComponentVType vtype) const gchar *str; const gchar *icon_name = NULL; - if (!error) + if (!error || error->domain != E_CLIENT_ERROR) return; switch (error->code) { - case E_CALENDAR_STATUS_DBUS_EXCEPTION: + case E_CLIENT_ERROR_DBUS_ERROR: switch (vtype) { case E_CAL_COMPONENT_EVENT: /* Translators: The '%s' is replaced with a detailed error message */ @@ -69,7 +69,7 @@ delete_error_dialog (const GError *error, ECalComponentVType vtype) break; } break; - case E_CALENDAR_STATUS_PERMISSION_DENIED: + case E_CLIENT_ERROR_PERMISSION_DENIED: switch (vtype) { case E_CAL_COMPONENT_EVENT: str = _("The event could not be deleted because permission was denied"); @@ -85,7 +85,7 @@ delete_error_dialog (const GError *error, ECalComponentVType vtype) break; } break; - case E_CALENDAR_STATUS_OTHER_ERROR: + case E_CLIENT_ERROR_OTHER_ERROR: switch (vtype) { case E_CAL_COMPONENT_EVENT: /* Translators: The '%s' is replaced with a detailed error message */ @@ -105,8 +105,6 @@ delete_error_dialog (const GError *error, ECalComponentVType vtype) break; } break; - case E_CALENDAR_STATUS_OK: - case E_CALENDAR_STATUS_OBJECT_NOT_FOUND: default: /* If not found, we don't care - its gone anyhow */ return; diff --git a/calendar/gui/dialogs/delete-error.h b/calendar/gui/dialogs/delete-error.h index 480edcbd42..91e38c146f 100644 --- a/calendar/gui/dialogs/delete-error.h +++ b/calendar/gui/dialogs/delete-error.h @@ -26,7 +26,7 @@ #ifndef DELETE_ERROR_H #define DELETE_ERROR_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-component.h> void delete_error_dialog (const GError *error, ECalComponentVType vtype); diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index 64d3b67891..f4c798bfd1 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -286,7 +286,7 @@ event_editor_constructor (GType type, GtkActionGroup *action_group; GtkWidget *content_area; EShell *shell; - ECal *client; + ECalClient *client; gboolean is_meeting; GtkWidget *alarm_page; GtkWidget *attendee_page; @@ -363,8 +363,7 @@ event_editor_constructor (GType type, if (is_meeting) { - if (e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS)) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS)) event_page_show_options (priv->event_page); comp_editor_set_group_item (editor, TRUE); @@ -604,7 +603,7 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) ECalComponentOrganizer organizer; gboolean delegate; ECalComponentDateTime dtstart, dtend; - ECal *client; + ECalClient *client; GSList *attendees = NULL; priv = EVENT_EDITOR (editor)->priv; @@ -645,8 +644,8 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) gtk_action_set_visible (action, TRUE); } - if (!(delegate && e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY))) { + if (!(delegate && e_client_check_capability ( + E_CLIENT (client), CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY))) { event_page_remove_all_attendees (priv->event_page); for (l = attendees; l != NULL; l = l->next) { @@ -685,7 +684,7 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) if (ia != NULL) e_meeting_attendee_set_edit_level ( ia, E_MEETING_ATTENDEE_EDIT_STATUS); - } else if (e_cal_get_organizer_must_attend (client)) { + } else if (e_cal_client_check_organizer_must_attend (client)) { EMeetingAttendee *ia; ia = e_meeting_store_find_attendee ( @@ -726,7 +725,7 @@ event_editor_send_comp (CompEditor *editor, comp = event_page_get_cancel_comp (priv->event_page); if (comp != NULL) { - ECal *client; + ECalClient *client; gboolean result; client = e_meeting_store_get_client (priv->model); @@ -748,7 +747,7 @@ event_editor_send_comp (CompEditor *editor, /** * event_editor_new: - * @client: a ECal + * @client: a ECalClient * * Creates a new event editor dialog. * @@ -756,11 +755,11 @@ event_editor_send_comp (CompEditor *editor, * editor could not be created. **/ CompEditor * -event_editor_new (ECal *client, +event_editor_new (ECalClient *client, EShell *shell, CompEditorFlags flags) { - g_return_val_if_fail (E_IS_CAL (client), NULL); + g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL); g_return_val_if_fail (E_IS_SHELL (shell), NULL); return g_object_new ( diff --git a/calendar/gui/dialogs/event-editor.h b/calendar/gui/dialogs/event-editor.h index abb8f0e659..eaa2c49057 100644 --- a/calendar/gui/dialogs/event-editor.h +++ b/calendar/gui/dialogs/event-editor.h @@ -65,7 +65,7 @@ struct _EventEditorClass { }; GType event_editor_get_type (void); -CompEditor * event_editor_new (ECal *client, +CompEditor * event_editor_new (ECalClient *client, EShell *shell, CompEditorFlags flags); void event_editor_show_meeting (EventEditor *ee); diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index b6d7c2630b..68210d1090 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -35,8 +35,8 @@ #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> #include <libedataserverui/e-category-completion.h> +#include <libedataserverui/e-client-utils.h> #include <libedataserverui/e-source-combo-box.h> -#include "common/authentication.h" #include "misc/e-dateedit.h" #include "misc/e-send-options.h" #include "misc/e-buffer-tagger.h" @@ -604,7 +604,7 @@ create_alarm_image_button (const gchar *image_text, static void sensitize_widgets (EventPage *epage) { - ECal *client; + ECalClient *client; EShell *shell; CompEditor *editor; CompEditorFlags flags; @@ -623,8 +623,7 @@ sensitize_widgets (EventPage *epage) if (flags & COMP_EDITOR_MEETING) sens = flags & COMP_EDITOR_USER_ORG; - if (!e_cal_is_read_only (client, &read_only, NULL)) - read_only = TRUE; + read_only = e_client_is_readonly (E_CLIENT (client)); delegate = flags & COMP_EDITOR_DELEGATE; @@ -724,7 +723,7 @@ update_time (EventPage *epage, ECalComponentDateTime *end_date) { CompEditor *editor; - ECal *client; + ECalClient *client; GtkAction *action; struct icaltimetype *start_tt, *end_tt, implied_tt; icaltimezone *start_zone = NULL, *def_zone = NULL; @@ -734,15 +733,20 @@ update_time (EventPage *epage, editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); client = comp_editor_get_client (editor); - /* Note that if we are creating a new event, the timezones may not be - on the server, so we try to get the builtin timezone with the TZID - first. */ - start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid); - if (!start_zone) { - /* FIXME: Handle error better. */ - if (!e_cal_get_timezone (client, start_date->tzid, &start_zone, NULL)) { - g_warning ("Couldn't get timezone from server: %s", - start_date->tzid ? start_date->tzid : ""); + if (start_date->tzid) { + /* Note that if we are creating a new event, the timezones may not be + on the server, so we try to get the builtin timezone with the TZID + first. */ + start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid); + if (!start_zone) { + /* FIXME: Handle error better. */ + GError *error = NULL; + if (!e_cal_client_get_timezone_sync (client, start_date->tzid, &start_zone, NULL, &error)) { + g_warning ("Couldn't get timezone '%s' from server: %s", + start_date->tzid ? start_date->tzid : "", error ? error->message : "Unknown error"); + if (error) + g_error_free (error); + } } } @@ -1068,7 +1072,7 @@ static gboolean event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { - ECal *client; + ECalClient *client; CompEditor *editor; CompEditorFlags flags; EventPage *epage; @@ -1135,7 +1139,7 @@ event_page_fill_widgets (CompEditorPage *page, e_cal_component_free_text_list (l); e_buffer_tagger_update_tags (GTK_TEXT_VIEW (priv->description)); - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); set_subscriber_info_string (epage, backend_addr); if (priv->is_meeting) { @@ -1156,13 +1160,13 @@ event_page_fill_widgets (CompEditorPage *page, gchar *string; if (itip_organizer_is_user (comp, client) || itip_sentby_is_user (comp, client)) { - if (e_cal_get_static_capability ( - client, + if (e_client_check_capability ( + E_CLIENT (client), CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) priv->user_org = TRUE; } else { - if (e_cal_get_static_capability ( - client, + if (e_client_check_capability ( + E_CLIENT (client), CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) gtk_widget_set_sensitive (priv->invite, FALSE); gtk_widget_set_sensitive (priv->add, FALSE); @@ -1171,7 +1175,7 @@ event_page_fill_widgets (CompEditorPage *page, priv->user_org = FALSE; } - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (flags & COMP_EDITOR_DELEGATE)) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (flags & COMP_EDITOR_DELEGATE)) string = g_strdup (backend_addr); else if ( organizer.cn != NULL) string = g_strdup_printf ("%s <%s>", organizer.cn, strip); @@ -1224,7 +1228,7 @@ event_page_fill_widgets (CompEditorPage *page, backend_mailto = mailto = NULL; } - if (client && e_cal_get_organizer_must_accept (client)) + if (client && e_cal_client_check_organizer_must_accept (client)) e_meeting_attendee_set_status ( attendee, ICAL_PARTSTAT_NEEDSACTION); else @@ -1277,7 +1281,7 @@ event_page_fill_widgets (CompEditorPage *page, break; } - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_TRANSPARENCY)) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_TRANSPARENCY)) enable_busy_time_menu (epage, FALSE); else enable_busy_time_menu (epage, TRUE); @@ -1318,7 +1322,7 @@ event_page_fill_widgets (CompEditorPage *page, /* Source */ e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_selector), - e_cal_get_source (client)); + e_client_get_source (E_CLIENT (client))); e_cal_component_get_uid (comp, &uid); if (!(flags & COMP_EDITOR_DELEGATE) @@ -1337,7 +1341,7 @@ event_page_fill_component (CompEditorPage *page, { CompEditor *editor; CompEditorFlags flags; - ECal *client; + ECalClient *client; EventPage *epage; EventPagePrivate *priv; ECalComponentClassification classification; @@ -1622,7 +1626,7 @@ event_page_fill_component (CompEditorPage *page, gchar *name; gchar *mailto; - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); /* Find the identity for the organizer or sentby field */ if (!get_current_identity (epage, &name, &mailto)) { @@ -2172,7 +2176,7 @@ attendee_added_cb (EMeetingListView *emlv, EventPagePrivate *priv = epage->priv; CompEditor *editor; CompEditorFlags flags; - ECal *client; + ECalClient *client; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); client = comp_editor_get_client (editor); @@ -2186,7 +2190,7 @@ attendee_added_cb (EMeetingListView *emlv, /* do not remove here, it did EMeetingListView already */ e_meeting_attendee_set_delfrom (ia, g_strdup_printf ("MAILTO:%s", priv->user_add ? priv->user_add : "")); - if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) { + if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) { EMeetingAttendee *delegator; gtk_widget_set_sensitive (priv->invite, FALSE); @@ -2822,7 +2826,7 @@ event_page_send_options_clicked_cb (EventPage *epage) CompEditor *editor; GtkWidget *toplevel; ESource *source; - ECal *client; + ECalClient *client; priv = epage->priv; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); @@ -2836,7 +2840,7 @@ event_page_send_options_clicked_cb (EventPage *epage) priv->sod->data->initialized = TRUE; } - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)) { + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)) { e_send_options_set_need_general_options (priv->sod, FALSE); } @@ -2850,25 +2854,28 @@ source_changed_cb (ESourceComboBox *source_combo_box, EventPage *epage) EventPagePrivate *priv = epage->priv; CompEditor *editor; ESource *source; - ECal *client; + ECalClient *client; + GError *error = NULL; if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (epage))) return; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); source = e_source_combo_box_get_active (source_combo_box); - client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT); + client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &error); if (client) { icaltimezone *zone; zone = e_meeting_store_get_timezone (epage->priv->meeting_store); - e_cal_set_default_timezone (client, zone, NULL); + e_cal_client_set_default_timezone (client, zone); + + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); } - if (!client || !e_cal_open (client, FALSE, NULL)) { + if (!client || !e_client_open_sync (E_CLIENT (client), FALSE, NULL, &error)) { GtkWidget *dialog; - ECal *old_client; + ECalClient *old_client; old_client = comp_editor_get_client (editor); @@ -2877,17 +2884,21 @@ source_changed_cb (ESourceComboBox *source_combo_box, EventPage *epage) e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_selector), - e_cal_get_source (old_client)); + e_client_get_source (E_CLIENT (old_client))); dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - _("Unable to open the calendar '%s'."), - e_source_peek_name (source)); + _("Unable to open the calendar '%s': %s"), + e_source_peek_name (source), + error ? error->message : _("Unknown error")); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); + + if (error) + g_error_free (error); } else { comp_editor_set_client (editor, client); - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_meeting) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_meeting) event_page_show_options (epage); else event_page_hide_options (epage); @@ -2895,7 +2906,7 @@ source_changed_cb (ESourceComboBox *source_combo_box, EventPage *epage) if (client) { gchar *backend_addr = NULL; - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); if (priv->is_meeting) event_page_select_organizer (epage, backend_addr); @@ -2914,12 +2925,12 @@ static void set_subscriber_info_string (EventPage *epage, const gchar *backend_address) { CompEditor *editor; - ECal *client; + ECalClient *client; ESource *source; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); client = comp_editor_get_client (editor); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); if (e_source_get_property (source, "subscriber")) { g_free (epage->priv->subscriber_info_text); @@ -3033,7 +3044,7 @@ alarm_custom_clicked_cb (GtkWidget *widget, GtkTreeIter iter; gboolean valid_iter; GtkWidget *toplevel; - ECal *client; + ECalClient *client; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); client = comp_editor_get_client (editor); @@ -3084,7 +3095,7 @@ init_widgets (EventPage *epage) GtkAction *action; GtkTreeSelection *selection; gboolean active; - ECal *client; + ECalClient *client; GtkTreeIter iter; GtkListStore *store; @@ -3328,7 +3339,7 @@ event_page_select_organizer (EventPage *epage, const gchar *backend_address) { EventPagePrivate *priv = epage->priv; CompEditor *editor; - ECal *client; + ECalClient *client; const gchar *default_address; gboolean subscribed_cal = FALSE; ESource *source = NULL; @@ -3339,7 +3350,7 @@ event_page_select_organizer (EventPage *epage, const gchar *backend_address) client = comp_editor_get_client (editor); if (client) - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); if (source) user_addr = e_source_get_property (source, "subscriber"); diff --git a/calendar/gui/dialogs/goto-dialog.c b/calendar/gui/dialogs/goto-dialog.c index bc20baa7c2..3ef0db31bf 100644 --- a/calendar/gui/dialogs/goto-dialog.c +++ b/calendar/gui/dialogs/goto-dialog.c @@ -89,7 +89,7 @@ ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data) { GoToDialog *dlg = user_data; ECalModel *model; - ECal *client; + ECalClient *client; model = gnome_calendar_get_model (dlg->gcal); client = e_cal_model_get_default_client (model); diff --git a/calendar/gui/dialogs/memo-editor.c b/calendar/gui/dialogs/memo-editor.c index 2f64910cab..e7dd1e7f93 100644 --- a/calendar/gui/dialogs/memo-editor.c +++ b/calendar/gui/dialogs/memo-editor.c @@ -158,7 +158,7 @@ memo_editor_init (MemoEditor *me) /** * memo_editor_new: - * @client: an ECal + * @client: an #ECalClient * * Creates a new event editor dialog. * @@ -166,11 +166,11 @@ memo_editor_init (MemoEditor *me) * editor could not be created. **/ CompEditor * -memo_editor_new (ECal *client, +memo_editor_new (ECalClient *client, EShell *shell, CompEditorFlags flags) { - g_return_val_if_fail (E_IS_CAL (client), NULL); + g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL); g_return_val_if_fail (E_IS_SHELL (shell), NULL); return g_object_new ( diff --git a/calendar/gui/dialogs/memo-editor.h b/calendar/gui/dialogs/memo-editor.h index cd4bc194ac..a5d32c07eb 100644 --- a/calendar/gui/dialogs/memo-editor.h +++ b/calendar/gui/dialogs/memo-editor.h @@ -67,7 +67,7 @@ struct _MemoEditorClass { }; GType memo_editor_get_type (void); -CompEditor * memo_editor_new (ECal *client, +CompEditor * memo_editor_new (ECalClient *client, EShell *shell, CompEditorFlags flags); diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c index e055072959..d720e91b1d 100644 --- a/calendar/gui/dialogs/memo-page.c +++ b/calendar/gui/dialogs/memo-page.c @@ -34,6 +34,7 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> #include <libedataserverui/e-category-completion.h> +#include <libedataserverui/e-client-utils.h> #include <libedataserverui/e-source-combo-box.h> #include <libedataserverui/e-name-selector.h> #include <libedataserverui/e-name-selector-entry.h> @@ -48,7 +49,6 @@ #include "e-util/e-dialog-widgets.h" #include "e-util/e-util-private.h" -#include "common/authentication.h" #include "../calendar-config.h" #include "comp-editor.h" #include "comp-editor-util.h" @@ -242,7 +242,7 @@ memo_page_fill_widgets (CompEditorPage *page, MemoPagePrivate *priv; CompEditor *editor; CompEditorFlags flags; - ECal *client; + ECalClient *client; ECalComponentClassification cl; ECalComponentText text; ECalComponentDateTime d; @@ -297,7 +297,7 @@ memo_page_fill_widgets (CompEditorPage *page, e_cal_component_get_categories (comp, &categories); e_dialog_editable_set (priv->categories, categories); - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); set_subscriber_info_string (mpage, backend_addr); if (e_cal_component_has_organizer (comp)) { @@ -333,7 +333,7 @@ memo_page_fill_widgets (CompEditorPage *page, /* Source */ e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_selector), - e_cal_get_source (client)); + e_client_get_source (E_CLIENT (client))); if (priv->to_entry && (flags & COMP_EDITOR_IS_SHARED) && !(flags & COMP_EDITOR_NEW_ITEM)) gtk_entry_set_text (GTK_ENTRY (priv->to_entry), get_recipients (comp)); @@ -403,7 +403,7 @@ sensitize_widgets (MemoPage *mpage) CompEditor *editor; CompEditorFlags flags; MemoPagePrivate *priv; - ECal *client; + ECalClient *client; priv = mpage->priv; @@ -411,8 +411,7 @@ sensitize_widgets (MemoPage *mpage) client = comp_editor_get_client (editor); flags = comp_editor_get_flags (editor); - if (!e_cal_is_read_only (client, &read_only, NULL)) - read_only = TRUE; + read_only = e_client_is_readonly (E_CLIENT (client)); if (flags & COMP_EDITOR_IS_SHARED) sens = flags & COMP_EDITOR_USER_ORG; @@ -511,53 +510,51 @@ fill_comp_with_recipients (ENameSelector *name_selector, ECalComponent *comp) /* check if the contact is contact list which is not expanded yet */ /* we expand it by getting the list again from the server forming the query */ if (contact && e_contact_get (contact , E_CONTACT_IS_LIST)) { - EBook *book = NULL; + EBookClient *book_client = NULL; ENameSelectorDialog *dialog; ENameSelectorModel *model; EContactStore *c_store; - GList *books, *l; + GSList *clients, *l; gchar *uri = e_contact_get (contact, E_CONTACT_BOOK_URI); dialog = e_name_selector_peek_dialog (name_selector); model = e_name_selector_dialog_peek_model (dialog); c_store = e_name_selector_model_peek_contact_store (model); - books = e_contact_store_get_books (c_store); + clients = e_contact_store_get_clients (c_store); - for (l = books; l; l = l->next) { - EBook *b = l->data; - if (g_str_equal (uri, e_book_get_uri (b))) { - book = b; + for (l = clients; l; l = l->next) { + EBookClient *b = l->data; + if (g_str_equal (uri, e_client_get_uri (E_CLIENT (b)))) { + book_client = b; break; } } - if (book) { - GList *contacts = NULL; + if (book_client) { + GSList *contacts = NULL; EContact *n_con = NULL; - gchar *qu; - EBookQuery *query; + gchar *query; - qu = g_strdup_printf ("(is \"full_name\" \"%s\")", + query = g_strdup_printf ("(is \"full_name\" \"%s\")", (gchar *) e_contact_get (contact, E_CONTACT_FULL_NAME)); - query = e_book_query_from_string (qu); - if (!e_book_get_contacts (book, query, &contacts, NULL)) { + if (!e_book_client_get_contacts_sync (book_client, query, &contacts, NULL, NULL)) { g_warning ("Could not get contact from the book \n"); } else { des = e_destination_new (); n_con = contacts->data; e_destination_set_contact (des, n_con, 0); + e_destination_set_client (des, book_client); list_dests = e_destination_list_get_dests (des); - g_list_foreach (contacts, (GFunc) g_object_unref, NULL); - g_list_free (contacts); + g_slist_foreach (contacts, (GFunc) g_object_unref, NULL); + g_slist_free (contacts); } - e_book_query_unref (query); - g_free (qu); + g_free (query); } - g_list_free (books); + g_slist_free (clients); } else { card_dest.next = NULL; card_dest.prev = NULL; @@ -611,7 +608,7 @@ memo_page_fill_component (CompEditorPage *page, MemoPagePrivate *priv; CompEditor *editor; CompEditorFlags flags; - ECal *client; + ECalClient *client; ECalComponentClassification classification; ECalComponentDateTime start_date; struct icaltimetype start_tt; @@ -724,7 +721,7 @@ memo_page_fill_component (CompEditorPage *page, gchar *name; gchar *mailto; - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); /* Find the identity for the organizer or sentby field */ if (!get_current_identity (mpage, &name, &mailto)) { @@ -888,7 +885,8 @@ source_changed_cb (ESourceComboBox *source_combo_box, CompEditor *editor; CompEditorFlags flags; ESource *source; - ECal *client; + ECalClient *client; + GError *error = NULL; if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (mpage))) return; @@ -897,11 +895,14 @@ source_changed_cb (ESourceComboBox *source_combo_box, flags = comp_editor_get_flags (editor); source = e_source_combo_box_get_active (source_combo_box); - client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL); + client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, &error); - if (!client || !e_cal_open (client, FALSE, NULL)) { + if (client) + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + + if (!client || !e_client_open_sync (E_CLIENT (client), FALSE, NULL, &error)) { GtkWidget *dialog; - ECal *old_client; + ECalClient *old_client; old_client = comp_editor_get_client (editor); @@ -910,21 +911,25 @@ source_changed_cb (ESourceComboBox *source_combo_box, e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_selector), - e_cal_get_source (old_client)); + e_client_get_source (E_CLIENT (old_client))); dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - _("Unable to open memos in '%s'."), - e_source_peek_name (source)); + _("Unable to open memos in '%s': %s"), + e_source_peek_name (source), + error ? error->message : _("Unknown error")); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); + + if (error) + g_error_free (error); } else { comp_editor_set_client (editor, client); if (client) { gchar *backend_addr = NULL; - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); if (flags & COMP_EDITOR_IS_SHARED) memo_page_select_organizer (mpage, backend_addr); @@ -942,12 +947,12 @@ set_subscriber_info_string (MemoPage *mpage, const gchar *backend_address) { CompEditor *editor; - ECal *client; + ECalClient *client; ESource *source; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (mpage)); client = comp_editor_get_client (editor); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); if (e_source_get_property (source, "subscriber")) { g_free (mpage->priv->subscriber_info_text); @@ -1097,7 +1102,7 @@ memo_page_select_organizer (MemoPage *mpage, const gchar *backend_address) MemoPagePrivate *priv; CompEditor *editor; CompEditorFlags flags; - ECal *client; + ECalClient *client; const gchar *default_address; gboolean subscribed_cal = FALSE; ESource *source = NULL; @@ -1110,7 +1115,7 @@ memo_page_select_organizer (MemoPage *mpage, const gchar *backend_address) flags = comp_editor_get_flags (editor); if (client) - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); if (source) user_addr = e_source_get_property (source, "subscriber"); diff --git a/calendar/gui/dialogs/recur-comp.c b/calendar/gui/dialogs/recur-comp.c index 7793647723..3514c03dbf 100644 --- a/calendar/gui/dialogs/recur-comp.c +++ b/calendar/gui/dialogs/recur-comp.c @@ -32,7 +32,7 @@ gboolean -recur_component_dialog (ECal *client, +recur_component_dialog (ECalClient *client, ECalComponent *comp, CalObjModType *mod, GtkWindow *parent, gboolean delegated) @@ -90,13 +90,13 @@ recur_component_dialog (ECal *client, rb_this = gtk_radio_button_new_with_label (NULL, _("This Instance Only")); gtk_container_add (GTK_CONTAINER (vbox), rb_this); - if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) { + if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) { rb_prior = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This and Prior Instances")); gtk_container_add (GTK_CONTAINER (vbox), rb_prior); } else rb_prior = NULL; - if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) { + if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) { rb_future = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This and Future Instances")); gtk_container_add (GTK_CONTAINER (vbox), rb_future); } else diff --git a/calendar/gui/dialogs/recur-comp.h b/calendar/gui/dialogs/recur-comp.h index 47236ef8cd..7087daa166 100644 --- a/calendar/gui/dialogs/recur-comp.h +++ b/calendar/gui/dialogs/recur-comp.h @@ -26,11 +26,11 @@ #define RECUR_COMP_H #include <gtk/gtk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-component.h> #include <libecal/e-cal-util.h> -gboolean recur_component_dialog (ECal *client, +gboolean recur_component_dialog (ECalClient *client, ECalComponent *comp, CalObjModType *mod, GtkWindow *parent, diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index 8d2701fab2..bf8f1c191c 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -212,7 +212,7 @@ preview_recur (RecurrencePage *rpage) { RecurrencePagePrivate *priv = rpage->priv; CompEditor *editor; - ECal *client; + ECalClient *client; ECalComponent *comp; ECalComponentDateTime cdt; GSList *l; @@ -236,8 +236,8 @@ preview_recur (RecurrencePage *rpage) e_cal_component_get_dtstart (priv->comp, &cdt); if (cdt.tzid != NULL) { - /* FIXME Will e_cal_get_timezone really not return builtin zones? */ - if (!e_cal_get_timezone (client, cdt.tzid, &zone, NULL)) + /* FIXME Will e_cal_client_get_timezone_sync really not return builtin zones? */ + if (!e_cal_client_get_timezone_sync (client, cdt.tzid, &zone, NULL, NULL)) zone = icaltimezone_get_builtin_timezone_from_tzid (cdt.tzid); } e_cal_component_set_dtstart (comp, &cdt); @@ -586,7 +586,7 @@ sensitize_buttons (RecurrencePage *rpage) gboolean read_only, sensitize = TRUE; gint selected_rows; icalcomponent *icalcomp; - ECal *client; + ECalClient *client; const gchar *uid; if (priv->comp == NULL) @@ -602,27 +602,26 @@ sensitize_buttons (RecurrencePage *rpage) selected_rows = gtk_tree_selection_count_selected_rows ( gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->exception_list))); - if (!e_cal_is_read_only (client, &read_only, NULL)) - read_only = TRUE; + read_only = e_client_is_readonly (E_CLIENT (client)); if (!read_only) { e_cal_component_get_uid (priv->comp, &uid); - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR) && e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) { + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR) && e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL)) { read_only = TRUE; icalcomponent_free (icalcomp); } if (!read_only) { - GList *list; + GSList *list = NULL; /* see if we have detached instances */ - if (e_cal_get_objects_for_uid (client, uid, &list, NULL)) { - if (list && g_list_length (list) > 1) + if (e_cal_client_get_objects_for_uid_sync (client, uid, &list, NULL, NULL)) { + if (list && g_slist_length (list) > 1) read_only = TRUE; - g_list_foreach (list, (GFunc) g_object_unref, NULL); - g_list_free (list); + g_slist_foreach (list, (GFunc) g_object_unref, NULL); + g_slist_free (list); } } } @@ -1485,7 +1484,7 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r) { RecurrencePagePrivate *priv = rpage->priv; CompEditor *editor; - ECal *client; + ECalClient *client; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage)); client = comp_editor_get_client (editor); @@ -1512,9 +1511,16 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r) to_zone = e_meeting_store_get_timezone (priv->meeting_store); else if (dt.tzid == NULL) to_zone = icaltimezone_get_utc_timezone (); - else + else { + GError *error = NULL; /* FIXME Error checking? */ - e_cal_get_timezone (client, dt.tzid, &to_zone, NULL); + e_cal_client_get_timezone_sync (client, dt.tzid, &to_zone, NULL, &error); + + if (error) { + g_debug ("%s: Failed to get timezone: %s", G_STRFUNC, error->message); + g_error_free (error); + } + } from_zone = icaltimezone_get_utc_timezone (); icaltimezone_convert_time (&r->until, from_zone, to_zone); @@ -2069,7 +2075,7 @@ type_toggled_cb (GtkToggleButton *toggle, { RecurrencePagePrivate *priv = rpage->priv; CompEditor *editor; - ECal *client; + ECalClient *client; gboolean read_only; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage)); @@ -2079,8 +2085,7 @@ type_toggled_cb (GtkToggleButton *toggle, sensitize_buttons (rpage); /* enable/disable the 'Add' button */ - if (!e_cal_is_read_only (client, &read_only, NULL)) - read_only = TRUE; + read_only = e_client_is_readonly (E_CLIENT (client)); if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->recurs)) || read_only) gtk_widget_set_sensitive (priv->exception_add, FALSE); diff --git a/calendar/gui/dialogs/schedule-page.c b/calendar/gui/dialogs/schedule-page.c index 26ea1cdf5c..c4191e68dc 100644 --- a/calendar/gui/dialogs/schedule-page.c +++ b/calendar/gui/dialogs/schedule-page.c @@ -68,16 +68,12 @@ sensitize_widgets (SchedulePage *spage) { SchedulePagePrivate *priv = spage->priv; CompEditor *editor; - ECal *client; - gboolean read_only; + ECalClient *client; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (spage)); client = comp_editor_get_client (editor); - if (!e_cal_is_read_only (client, &read_only, NULL)) - read_only = TRUE; - - e_meeting_time_selector_set_read_only (priv->sel, read_only); + e_meeting_time_selector_set_read_only (priv->sel, e_client_is_readonly (E_CLIENT (client))); } /* Set date/time */ @@ -90,30 +86,43 @@ update_time (SchedulePage *spage, CompEditor *editor; struct icaltimetype start_tt, end_tt; icaltimezone *start_zone = NULL, *end_zone = NULL; - ECal *client; + ECalClient *client; gboolean all_day; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (spage)); client = comp_editor_get_client (editor); - /* Note that if we are creating a new event, the timezones may not be - on the server, so we try to get the builtin timezone with the TZID - first. */ - start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid); - if (!start_zone) { - if (!e_cal_get_timezone (client, start_date->tzid, &start_zone, NULL)) { - /* FIXME: Handle error better. */ - g_warning ("Couldn't get timezone from server: %s", - start_date->tzid ? start_date->tzid : ""); + if (start_date->tzid) { + /* Note that if we are creating a new event, the timezones may not be + on the server, so we try to get the builtin timezone with the TZID + first. */ + start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid); + if (!start_zone) { + GError *error = NULL; + + if (!e_cal_client_get_timezone_sync (client, start_date->tzid, &start_zone, NULL, &error)) { + /* FIXME: Handle error better. */ + g_warning ("Couldn't get timezone '%s' from server: %s", + start_date->tzid ? start_date->tzid : "", + error ? error->message : "Unknown error"); + if (error) + g_error_free (error); + } } } - end_zone = icaltimezone_get_builtin_timezone_from_tzid (end_date->tzid); - if (!end_zone) { - if (!e_cal_get_timezone (client, end_date->tzid, &end_zone, NULL)) { - /* FIXME: Handle error better. */ - g_warning ("Couldn't get timezone from server: %s", - end_date->tzid ? end_date->tzid : ""); + if (end_date->tzid) { + end_zone = icaltimezone_get_builtin_timezone_from_tzid (end_date->tzid); + if (!end_zone) { + GError *error = NULL; + if (!e_cal_client_get_timezone_sync (client, end_date->tzid, &end_zone, NULL, &error)) { + /* FIXME: Handle error better. */ + g_warning ("Couldn't get timezone '%s' from server: %s", + end_date->tzid ? end_date->tzid : "", + error ? error->message : "Unknown error"); + if (error) + g_error_free (error); + } } } diff --git a/calendar/gui/dialogs/select-source-dialog.c b/calendar/gui/dialogs/select-source-dialog.c index 79905d5f01..4ae9f0a0d8 100644 --- a/calendar/gui/dialogs/select-source-dialog.c +++ b/calendar/gui/dialogs/select-source-dialog.c @@ -35,7 +35,7 @@ * Implements dialog for allowing user to select a destination source. */ ESource * -select_source_dialog (GtkWindow *parent, ECalSourceType obj_type, ESource *except_source) +select_source_dialog (GtkWindow *parent, ECalClientSourceType obj_type, ESource *except_source) { GtkWidget *dialog; ESourceList *source_list; @@ -44,11 +44,11 @@ select_source_dialog (GtkWindow *parent, ECalSourceType obj_type, ESource *excep GConfClient *conf_client; const gchar *icon_name = NULL; - if (obj_type == E_CAL_SOURCE_TYPE_EVENT) + if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS) gconf_key = "/apps/evolution/calendar/sources"; - else if (obj_type == E_CAL_SOURCE_TYPE_TODO) + else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS) gconf_key = "/apps/evolution/tasks/sources"; - else if (obj_type == E_CAL_SOURCE_TYPE_JOURNAL) + else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS) gconf_key = "/apps/evolution/memos/sources"; else return NULL; @@ -59,11 +59,11 @@ select_source_dialog (GtkWindow *parent, ECalSourceType obj_type, ESource *excep /* create the dialog */ dialog = e_source_selector_dialog_new (parent, source_list); - if (obj_type == E_CAL_SOURCE_TYPE_EVENT) + if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS) icon_name = "x-office-calendar"; - else if (obj_type == E_CAL_SOURCE_TYPE_TODO) + else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS) icon_name = "stock_todo"; - else if (obj_type == E_CAL_SOURCE_TYPE_JOURNAL) + else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS) icon_name = "stock_journal"; if (icon_name) diff --git a/calendar/gui/dialogs/select-source-dialog.h b/calendar/gui/dialogs/select-source-dialog.h index 902ac3fc03..6d64fb825a 100644 --- a/calendar/gui/dialogs/select-source-dialog.h +++ b/calendar/gui/dialogs/select-source-dialog.h @@ -28,8 +28,8 @@ #include <gtk/gtk.h> #include <libedataserver/e-source.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> -ESource *select_source_dialog (GtkWindow *parent, ECalSourceType type, ESource *except_source); +ESource *select_source_dialog (GtkWindow *parent, ECalClientSourceType type, ESource *except_source); #endif diff --git a/calendar/gui/dialogs/send-comp.c b/calendar/gui/dialogs/send-comp.c index 070fb6b735..d67d9fb626 100644 --- a/calendar/gui/dialogs/send-comp.c +++ b/calendar/gui/dialogs/send-comp.c @@ -133,7 +133,7 @@ add_checkbox (GtkBox *where, const gchar *caption) * Return value: TRUE if the user clicked Yes, FALSE otherwise. **/ gboolean -send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean new, gboolean *strip_alarms, gboolean *only_new_attendees) +send_component_dialog (GtkWindow *parent, ECalClient *client, ECalComponent *comp, gboolean new, gboolean *strip_alarms, gboolean *only_new_attendees) { ECalComponentVType vtype; const gchar *id; @@ -144,7 +144,7 @@ send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gbo if (strip_alarms) *strip_alarms = TRUE; - if (e_cal_get_save_schedules (client) || !component_has_recipients (comp)) + if (e_cal_client_check_save_schedules (client) || !component_has_recipients (comp)) return FALSE; vtype = e_cal_component_get_vtype (comp); @@ -206,7 +206,7 @@ send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gbo } gboolean -send_component_prompt_subject (GtkWindow *parent, ECal *client, ECalComponent *comp) +send_component_prompt_subject (GtkWindow *parent, ECalClient *client, ECalComponent *comp) { ECalComponentVType vtype; const gchar *id; diff --git a/calendar/gui/dialogs/send-comp.h b/calendar/gui/dialogs/send-comp.h index 83f356b142..91584a7f4b 100644 --- a/calendar/gui/dialogs/send-comp.h +++ b/calendar/gui/dialogs/send-comp.h @@ -25,10 +25,10 @@ #define SEND_COMP_H #include <gtk/gtk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-component.h> -gboolean send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean new, gboolean *strip_alarms, gboolean *only_new_attendees); -gboolean send_component_prompt_subject (GtkWindow *parent, ECal *client, ECalComponent *comp); +gboolean send_component_dialog (GtkWindow *parent, ECalClient *client, ECalComponent *comp, gboolean new, gboolean *strip_alarms, gboolean *only_new_attendees); +gboolean send_component_prompt_subject (GtkWindow *parent, ECalClient *client, ECalComponent *comp); #endif diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c index 7f72dd3e38..bc828cf431 100644 --- a/calendar/gui/dialogs/task-details-page.c +++ b/calendar/gui/dialogs/task-details-page.c @@ -149,14 +149,13 @@ sensitize_widgets (TaskDetailsPage *tdpage) TaskDetailsPagePrivate *priv = tdpage->priv; CompEditor *editor; GtkWidget *entry; - ECal *client; + ECalClient *client; gboolean read_only; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage)); client = comp_editor_get_client (editor); - if (!e_cal_is_read_only (client, &read_only, NULL)) - read_only = TRUE; + read_only = e_client_is_readonly (E_CLIENT (client)); gtk_widget_set_sensitive (priv->status_combo, !read_only); gtk_widget_set_sensitive (priv->priority_combo, !read_only); diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index f24db192b2..1e859cb293 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -148,7 +148,7 @@ task_editor_constructor (GType type, CompEditorFlags flags; TaskEditorPrivate *priv; GtkActionGroup *action_group; - ECal *client; + ECalClient *client; gboolean is_assigned; /* Chain up to parent's constructor() method. */ @@ -168,8 +168,7 @@ task_editor_constructor (GType type, gtk_action_group_set_visible (action_group, is_assigned); if (is_assigned) { - if (e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS)) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS)) task_page_show_options (priv->task_page); comp_editor_set_group_item (editor, TRUE); } @@ -380,7 +379,7 @@ task_editor_edit_comp (CompEditor *editor, ECalComponent *comp) { TaskEditorPrivate *priv; ECalComponentOrganizer organizer; - ECal *client; + ECalClient *client; GSList *attendees = NULL; priv = TASK_EDITOR_GET_PRIVATE (editor); @@ -429,7 +428,7 @@ task_editor_edit_comp (CompEditor *editor, ECalComponent *comp) if (ia != NULL) e_meeting_attendee_set_edit_level (ia, E_MEETING_ATTENDEE_EDIT_STATUS); - } else if (e_cal_get_organizer_must_attend (client)) { + } else if (e_cal_client_check_organizer_must_attend (client)) { EMeetingAttendee *ia; ia = e_meeting_store_find_attendee (priv->model, organizer.value, &row); @@ -466,7 +465,7 @@ task_editor_send_comp (CompEditor *editor, comp = task_page_get_cancel_comp (priv->task_page); if (comp != NULL) { - ECal *client; + ECalClient *client; gboolean result; client = e_meeting_store_get_client (priv->model); @@ -488,7 +487,7 @@ task_editor_send_comp (CompEditor *editor, /** * task_editor_new: - * @client: a ECal + * @client: a ECalClient * * Creates a new event editor dialog. * @@ -496,11 +495,11 @@ task_editor_send_comp (CompEditor *editor, * editor could not be created. **/ CompEditor * -task_editor_new (ECal *client, +task_editor_new (ECalClient *client, EShell *shell, CompEditorFlags flags) { - g_return_val_if_fail (E_IS_CAL (client), NULL); + g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL); g_return_val_if_fail (E_IS_SHELL (shell), NULL); return g_object_new ( diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h index f026acae0c..0808cd547d 100644 --- a/calendar/gui/dialogs/task-editor.h +++ b/calendar/gui/dialogs/task-editor.h @@ -65,7 +65,7 @@ struct _TaskEditorClass { }; GType task_editor_get_type (void); -CompEditor * task_editor_new (ECal *client, +CompEditor * task_editor_new (ECalClient *client, EShell *shell, CompEditorFlags flags); void task_editor_show_assignment (TaskEditor *te); diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index bb18780250..12902ff6d4 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -34,11 +34,11 @@ #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> #include <libedataserverui/e-category-completion.h> +#include <libedataserverui/e-client-utils.h> #include <libedataserverui/e-source-combo-box.h> #include <misc/e-dateedit.h> #include "misc/e-buffer-tagger.h" #include <e-util/e-dialog-utils.h> -#include "common/authentication.h" #include "../e-timezone-entry.h" #include "comp-editor.h" #include "comp-editor-util.h" @@ -111,7 +111,7 @@ struct _TaskPagePrivate { GtkWidget *attendees_label; /* ListView stuff */ - ECal *client; + ECalClient *client; EMeetingStore *meeting_store; EMeetingListView *list_view; gint row; @@ -264,7 +264,7 @@ sensitize_widgets (TaskPage *tpage) TaskPagePrivate *priv = tpage->priv; CompEditor *editor; CompEditorFlags flags; - ECal *client; + ECalClient *client; GtkActionGroup *action_group; GtkAction *action; gboolean read_only, sens = TRUE, sensitize; @@ -273,8 +273,7 @@ sensitize_widgets (TaskPage *tpage) client = comp_editor_get_client (editor); flags = comp_editor_get_flags (editor); - if (!e_cal_is_read_only (client, &read_only, NULL)) - read_only = TRUE; + read_only = e_client_is_readonly (E_CLIENT (client)); if (flags & COMP_EDITOR_IS_ASSIGNED) sens = flags & COMP_EDITOR_USER_ORG; @@ -473,7 +472,7 @@ task_page_fill_widgets (CompEditorPage *page, CompEditor *editor; CompEditorFlags flags; GtkAction *action; - ECal *client; + ECalClient *client; GSList *l; icalcomponent *icalcomp; const gchar *categories, *uid; @@ -555,10 +554,13 @@ task_page_fill_widgets (CompEditorPage *page, on the server, so we try to get the builtin timezone with the TZID first. */ if (!zone && d.tzid) { - if (!e_cal_get_timezone (client, d.tzid, &zone, NULL)) + GError *error = NULL; + if (!e_cal_client_get_timezone_sync (client, d.tzid, &zone, NULL, &error)) /* FIXME: Handle error better. */ - g_warning ("Couldn't get timezone from server: %s", - d.tzid ? d.tzid : ""); + g_warning ("Couldn't get timezone '%s' from server: %s", + d.tzid ? d.tzid : "", error ? error->message : "Unknown error"); + if (error) + g_error_free (error); } e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->timezone), @@ -611,7 +613,7 @@ task_page_fill_widgets (CompEditorPage *page, comp_editor_set_classification (editor, cl); e_cal_component_get_uid (comp, &uid); - if (e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) { + if (e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL)) { icalcomponent_free (icalcomp); task_page_hide_options (tpage); } @@ -623,9 +625,9 @@ task_page_fill_widgets (CompEditorPage *page, /* Source */ e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_selector), - e_cal_get_source (client)); + e_client_get_source (E_CLIENT (client))); - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); set_subscriber_info_string (tpage, backend_addr); if (priv->is_assignment) { @@ -646,14 +648,10 @@ task_page_fill_widgets (CompEditorPage *page, gchar *string; if (itip_organizer_is_user (comp, client) || itip_sentby_is_user (comp, client)) { - if (e_cal_get_static_capability ( - client, - CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) priv->user_org = TRUE; } else { - if (e_cal_get_static_capability ( - client, - CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) gtk_widget_set_sensitive (priv->invite, FALSE); gtk_widget_set_sensitive (priv->add, FALSE); gtk_widget_set_sensitive (priv->edit, FALSE); @@ -661,7 +659,7 @@ task_page_fill_widgets (CompEditorPage *page, priv->user_org = FALSE; } - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (flags & COMP_EDITOR_DELEGATE)) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (flags & COMP_EDITOR_DELEGATE)) string = g_strdup (priv->user_add); else if ( organizer.cn != NULL) string = g_strdup_printf ("%s <%s>", organizer.cn, strip); @@ -714,7 +712,7 @@ task_page_fill_widgets (CompEditorPage *page, backend_mailto = mailto = NULL; } - if (client && e_cal_get_organizer_must_accept (client)) + if (client && e_cal_client_check_organizer_must_accept (client)) e_meeting_attendee_set_status ( attendee, ICAL_PARTSTAT_NEEDSACTION); else @@ -748,7 +746,7 @@ task_page_fill_component (CompEditorPage *page, ECalComponentDateTime date; CompEditor *editor; CompEditorFlags flags; - ECal *client; + ECalClient *client; struct icaltimetype start_tt, due_tt; gchar *cat, *str; gboolean start_date_set, due_date_set, time_set; @@ -898,7 +896,7 @@ task_page_fill_component (CompEditorPage *page, gchar *name; gchar *mailto; - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); /* Find the identity for the organizer or sentby field */ if (!get_current_identity (tpage, &name, &mailto)) { @@ -1314,7 +1312,7 @@ attendee_added_cb (EMeetingListView *emlv, TaskPagePrivate *priv = page->priv; CompEditor *editor; CompEditorFlags flags; - ECal *client; + ECalClient *client; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (page)); client = comp_editor_get_client (editor); @@ -1328,7 +1326,7 @@ attendee_added_cb (EMeetingListView *emlv, /* do not remove here, it did EMeetingListView already */ e_meeting_attendee_set_delfrom (ia, g_strdup_printf ("MAILTO:%s", priv->user_add ? priv->user_add : "")); - if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) { + if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) { EMeetingAttendee *delegator; gtk_widget_set_sensitive (priv->invite, FALSE); @@ -1773,7 +1771,8 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage) TaskPagePrivate *priv = tpage->priv; CompEditor *editor; ESource *source; - ECal *client; + ECalClient *client; + GError *error = NULL; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage)); source = e_source_combo_box_get_active (source_combo_box); @@ -1781,15 +1780,18 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage) if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (tpage))) return; - client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO); + client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_TASKS, &error); if (client) { icaltimezone *zone; zone = comp_editor_get_timezone (editor); - e_cal_set_default_timezone (client, zone, NULL); + e_cal_client_set_default_timezone (client, zone); } - if (!client || !e_cal_open (client, FALSE, NULL)) { + if (client) + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + + if (!client || !e_client_open_sync (E_CLIENT (client), FALSE, NULL, &error)) { GtkWidget *dialog; if (client) @@ -1799,18 +1801,22 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage) e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_selector), - e_cal_get_source (client)); + e_client_get_source (E_CLIENT (client))); dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - _("Unable to open tasks in '%s'."), - e_source_peek_name (source)); + _("Unable to open tasks in '%s': %s"), + e_source_peek_name (source), + error ? error->message : _("Unknown error")); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); + + if (error) + g_error_free (error); } else { comp_editor_set_client (editor, client); comp_editor_page_changed (COMP_EDITOR_PAGE (tpage)); - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_assignment) + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_assignment) task_page_show_options (tpage); else task_page_hide_options (tpage); @@ -1818,7 +1824,7 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage) if (client) { gchar *backend_addr = NULL; - e_cal_get_cal_address (client, &backend_addr, NULL); + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL); if (priv->is_assignment) task_page_select_organizer (tpage, backend_addr); @@ -1835,12 +1841,12 @@ static void set_subscriber_info_string (TaskPage *tpage, const gchar *backend_address) { CompEditor *editor; - ECal *client; + ECalClient *client; ESource *source; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage)); client = comp_editor_get_client (editor); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); if (e_source_get_property (source, "subscriber")) { g_free (tpage->priv->subscriber_info_text); @@ -1863,7 +1869,7 @@ task_page_send_options_clicked_cb (TaskPage *tpage) CompEditor *editor; GtkWidget *toplevel; ESource *source; - ECal *client; + ECalClient *client; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage)); client = comp_editor_get_client (editor); @@ -1876,7 +1882,7 @@ task_page_send_options_clicked_cb (TaskPage *tpage) e_send_options_utils_set_default_data (priv->sod, source, "task"); } - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)) { + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)) { e_send_options_set_need_general_options (priv->sod, FALSE); } @@ -2041,7 +2047,7 @@ task_page_select_organizer (TaskPage *tpage, const gchar *backend_address) const gchar *default_address; gboolean subscribed_cal = FALSE; ESource *source = NULL; - ECal *client; + ECalClient *client; const gchar *user_addr = NULL; gint ii; @@ -2049,7 +2055,7 @@ task_page_select_organizer (TaskPage *tpage, const gchar *backend_address) client = comp_editor_get_client (editor); if (client) - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); if (source) user_addr = e_source_get_property (source, "subscriber"); @@ -2094,7 +2100,7 @@ task_page_select_organizer (TaskPage *tpage, const gchar *backend_address) TaskPage * task_page_construct (TaskPage *tpage, EMeetingStore *meeting_store, - ECal *client) + ECalClient *client) { TaskPagePrivate *priv; GtkTreeModel *model; @@ -2155,7 +2161,7 @@ TaskPage * task_page_new (EMeetingStore *model, CompEditor *editor) { TaskPage *tpage; - ECal *client; + ECalClient *client; tpage = g_object_new (TYPE_TASK_PAGE, "editor", editor, NULL); client = comp_editor_get_client (editor); diff --git a/calendar/gui/dialogs/task-page.h b/calendar/gui/dialogs/task-page.h index 007dcdeec4..9d713deaef 100644 --- a/calendar/gui/dialogs/task-page.h +++ b/calendar/gui/dialogs/task-page.h @@ -72,7 +72,7 @@ struct _TaskPageClass { GType task_page_get_type (void); TaskPage * task_page_construct (TaskPage *epage, EMeetingStore *model, - ECal *client); + ECalClient *client); TaskPage * task_page_new (EMeetingStore *model, CompEditor *editor); ECalComponent * task_page_get_cancel_comp (TaskPage *page); diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c index c964a6f1ed..d2c979151f 100644 --- a/calendar/gui/e-cal-component-preview.c +++ b/calendar/gui/e-cal-component-preview.c @@ -70,7 +70,7 @@ clear_comp_info (ECalComponentPreview *preview) returns whether component in the preview changed */ static gboolean update_comp_info (ECalComponentPreview *preview, - ECal *ecal, + ECalClient *client, ECalComponent *comp) { ECalComponentPreviewPrivate *priv; @@ -81,7 +81,7 @@ update_comp_info (ECalComponentPreview *preview, priv = preview->priv; - if (!E_IS_CAL_COMPONENT (comp) || !E_IS_CAL (ecal)) { + if (!E_IS_CAL_COMPONENT (comp) || !E_IS_CAL_CLIENT (client)) { changed = !priv->cal_uid; clear_comp_info (preview); } else { @@ -92,7 +92,7 @@ update_comp_info (ECalComponentPreview *preview, gint *sequence = NULL; gint comp_sequence; - cal_uid = g_strdup (e_source_peek_uid (e_cal_get_source (ecal))); + cal_uid = g_strdup (e_source_peek_uid (e_client_get_source (E_CLIENT (client)))); e_cal_component_get_uid (comp, &uid); comp_uid = g_strdup (uid); e_cal_component_get_last_modified (comp, &itm); @@ -128,7 +128,7 @@ update_comp_info (ECalComponentPreview *preview, /* Converts a time_t to a string, relative to the specified timezone */ static gchar * timet_to_str_with_zone (ECalComponentDateTime *dt, - ECal *ecal, + ECalClient *client, icaltimezone *default_zone, gboolean use_24_hour_format) { @@ -139,7 +139,7 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, if (dt->tzid) { /* If we can't find the zone, we'll guess its "local" */ - if (!e_cal_get_timezone (ecal, dt->tzid, &zone, NULL)) + if (!e_cal_client_get_timezone_sync (client, dt->tzid, &zone, NULL, NULL)) zone = NULL; } else if (dt->value->is_utc) { zone = icaltimezone_get_utc_timezone (); @@ -161,7 +161,7 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, static void cal_component_preview_write_html (GString *buffer, - ECal *ecal, + ECalClient *client, ECalComponent *comp, icaltimezone *default_zone, gboolean use_24_hour_format) @@ -240,7 +240,7 @@ cal_component_preview_write_html (GString *buffer, e_cal_component_get_dtstart (comp, &dt); if (dt.value != NULL) { str = timet_to_str_with_zone ( - &dt, ecal, default_zone, use_24_hour_format); + &dt, client, default_zone, use_24_hour_format); g_string_append_printf ( buffer, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\">" "<B>%s</B></TD><TD>%s</TD></TR>", @@ -254,7 +254,7 @@ cal_component_preview_write_html (GString *buffer, e_cal_component_get_dtend (comp, &dt); if (dt.value != NULL) { str = timet_to_str_with_zone ( - &dt, ecal, default_zone, use_24_hour_format); + &dt, client, default_zone, use_24_hour_format); g_string_append_printf ( buffer, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\">" "<B>%s</B></TD><TD>%s</TD></TR>", @@ -268,7 +268,7 @@ cal_component_preview_write_html (GString *buffer, e_cal_component_get_due (comp, &dt); if (dt.value != NULL) { str = timet_to_str_with_zone ( - &dt, ecal, default_zone, use_24_hour_format); + &dt, client, default_zone, use_24_hour_format); g_string_append_printf ( buffer, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\">" "<B>%s</B></TD><TD>%s</TD></TR>", @@ -444,7 +444,7 @@ e_cal_component_preview_new (void) void e_cal_component_preview_display (ECalComponentPreview *preview, - ECal *ecal, + ECalClient *client, ECalComponent *comp, icaltimezone *zone, gboolean use_24_hour_format) @@ -456,14 +456,14 @@ e_cal_component_preview_display (ECalComponentPreview *preview, /* do not update preview when setting the same component as last time, which even didn't change */ - if (!update_comp_info (preview, ecal, comp)) + if (!update_comp_info (preview, client, comp)) return; /* XXX The initial buffer size is arbitrary. Tune it. */ buffer = g_string_sized_new (4096); cal_component_preview_write_html ( - buffer, ecal, comp, zone, use_24_hour_format); + buffer, client, comp, zone, use_24_hour_format); e_web_view_load_string (E_WEB_VIEW (preview), buffer->str); g_string_free (buffer, TRUE); } diff --git a/calendar/gui/e-cal-component-preview.h b/calendar/gui/e-cal-component-preview.h index f713df7321..091f66c252 100644 --- a/calendar/gui/e-cal-component-preview.h +++ b/calendar/gui/e-cal-component-preview.h @@ -25,7 +25,7 @@ #define E_CAL_COMPONENT_PREVIEW_H #include <gtk/gtk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <misc/e-web-view.h> /* Standard GObject macros */ @@ -69,7 +69,7 @@ struct _ECalComponentPreviewClass { GType e_cal_component_preview_get_type (void); GtkWidget * e_cal_component_preview_new (void); void e_cal_component_preview_display (ECalComponentPreview *preview, - ECal *ecal, + ECalClient *client, ECalComponent *comp, icaltimezone *zone, gboolean use_24_hour_format); diff --git a/calendar/gui/e-cal-config.h b/calendar/gui/e-cal-config.h index 7751c3e42f..f803e99285 100644 --- a/calendar/gui/e-cal-config.h +++ b/calendar/gui/e-cal-config.h @@ -24,7 +24,7 @@ #ifndef __E_CAL_CONFIG_H__ #define __E_CAL_CONFIG_H__ -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include "e-util/e-config.h" /* Standard GObject macros */ @@ -74,7 +74,7 @@ struct _ECalConfigTargetSource { EConfigTarget target; struct _ESource *source; - ECalSourceType source_type; + ECalClientSourceType source_type; }; struct _ECalConfigTargetPrefs { diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 7893dae0e8..c287b7a6ca 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -102,7 +102,6 @@ e_cal_list_view_class_init (ECalListViewClass *class) static void e_cal_list_view_init (ECalListView *cal_list_view) { - cal_list_view->query = NULL; cal_list_view->table = NULL; cal_list_view->cursor_event = NULL; cal_list_view->set_table_id = 0; @@ -330,13 +329,6 @@ e_cal_list_view_dispose (GObject *object) cal_list_view = E_CAL_LIST_VIEW (object); - if (cal_list_view->query) { - g_signal_handlers_disconnect_matched (cal_list_view->query, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, cal_list_view); - g_object_unref (cal_list_view->query); - cal_list_view->query = NULL; - } - if (cal_list_view->set_table_id) { g_source_remove (cal_list_view->set_table_id); cal_list_view->set_table_id = 0; diff --git a/calendar/gui/e-cal-list-view.h b/calendar/gui/e-cal-list-view.h index faf37bbc9f..ed4636f753 100644 --- a/calendar/gui/e-cal-list-view.h +++ b/calendar/gui/e-cal-list-view.h @@ -67,9 +67,6 @@ struct _ECalListView { /* The main display table */ ETable *table; - /* S-expression for query and the query object */ - ECalView *query; - /* The default category for new events */ gchar *default_category; diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c index 4ac73089bb..ea8dd7bba7 100644 --- a/calendar/gui/e-cal-model-calendar.c +++ b/calendar/gui/e-cal-model-calendar.c @@ -130,7 +130,7 @@ get_dtend (ECalModelCalendar *model, ECalModelComponent *comp_data) tt_end = icalproperty_get_dtend (prop); if (icaltime_get_tzid (tt_end) - && e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_end), &zone, NULL)) + && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_end), &zone, NULL, NULL)) got_zone = TRUE; model_zone = e_cal_model_get_timezone (E_CAL_MODEL (model)); @@ -295,6 +295,7 @@ ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) CalObjModType mod = CALOBJ_MOD_ALL; ECalComponent *comp; ECalModelCalendar *model = (ECalModelCalendar *) etm; + GError *error = NULL; g_return_if_fail (E_IS_CAL_MODEL_CALENDAR (model)); g_return_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST); @@ -335,7 +336,7 @@ ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) break; } - if (e_cal_modify_object (comp_data->client, comp_data->icalcomp, mod, NULL)) { + if (e_cal_client_modify_object_sync (comp_data->client, comp_data->icalcomp, mod, NULL, &error)) { gboolean strip_alarms = TRUE; if (itip_organizer_is_user (comp, comp_data->client) && @@ -348,7 +349,7 @@ ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) const gchar *uid = NULL; e_cal_component_get_uid (comp, &uid); - if (e_cal_get_object (comp_data->client, uid, NULL, &icalcomp, NULL) && icalcomp) { + if (e_cal_client_get_object_sync (comp_data->client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); @@ -365,9 +366,11 @@ ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) g_object_unref (send_comp); } } else { - g_warning (G_STRLOC ": Could not modify the object!"); + g_warning (G_STRLOC ": Could not modify the object! %s", error ? error->message : "Unknown error"); /* FIXME Show error dialog */ + if (error) + g_error_free (error); } g_object_unref (comp); diff --git a/calendar/gui/e-cal-model-memos.c b/calendar/gui/e-cal-model-memos.c index 0356dacf0c..59a48d031c 100644 --- a/calendar/gui/e-cal-model-memos.c +++ b/calendar/gui/e-cal-model-memos.c @@ -140,6 +140,7 @@ ecmm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) { ECalModelComponent *comp_data; ECalModelMemos *model = (ECalModelMemos *) etm; + GError *error = NULL; g_return_if_fail (E_IS_CAL_MODEL_MEMOS (model)); g_return_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST); @@ -157,10 +158,12 @@ ecmm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) } /* TODO ask about mod type */ - if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { - g_warning (G_STRLOC ": Could not modify the object!"); + if (!e_cal_client_modify_object_sync (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL, &error)) { + g_warning (G_STRLOC ": Could not modify the object! %s", error ? error->message : "Unknown error"); /* TODO Show error dialog */ + if (error) + g_error_free (error); } } diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index ff829e319f..51811c783f 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -325,7 +325,7 @@ get_completed (ECalModelComponent *comp_data) comp_data->completed->tt = tt_completed; if (icaltime_get_tzid (tt_completed) - && e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_completed), &zone, NULL)) + && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_completed), &zone, NULL, NULL)) comp_data->completed->zone = zone; else comp_data->completed->zone = NULL; @@ -355,7 +355,7 @@ get_due (ECalModelComponent *comp_data) comp_data->due->tt = tt_due; if (icaltime_get_tzid (tt_due) - && e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_due), &zone, NULL)) + && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_due), &zone, NULL, NULL)) comp_data->due->zone = zone; else comp_data->due->zone = NULL; @@ -525,7 +525,7 @@ get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data) /* Get the current time in the same timezone as the DUE date.*/ tzid = icalparameter_get_tzid (param); - if (!e_cal_get_timezone (comp_data->client, tzid, &zone, NULL)) + if (!e_cal_client_get_timezone_sync (comp_data->client, tzid, &zone, NULL, NULL)) return E_CAL_MODEL_TASKS_DUE_FUTURE; now_tt = icaltime_current_time_with_zone (zone); @@ -1252,13 +1252,17 @@ void e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model, ECalModelCom static void commit_component_changes (ECalModelComponent *comp_data) { + GError *error = NULL; + g_return_if_fail (comp_data != NULL); /* FIXME ask about mod type */ - if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { - g_warning (G_STRLOC ": Could not modify the object!"); + if (!e_cal_client_modify_object_sync (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL, &error)) { + g_warning (G_STRLOC ": Could not modify the object! %s", error ? error->message : "Unknown error"); /* FIXME Show error dialog */ + if (error) + g_error_free (error); } } diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index a2e0418cbc..5e0c9cc337 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -30,6 +30,7 @@ #include <glib/gi18n.h> #include <libedataserver/e-flag.h> #include <libedataserver/e-time-utils.h> +#include <libecal/e-cal-client-view.h> #include <libecal/e-cal-time-util.h> #include "comp-util.h" #include "e-cal-model.h" @@ -41,8 +42,8 @@ #include "e-util/e-util-enumtypes.h" typedef struct { - ECal *client; - ECalView *query; + ECalClient *client; + ECalClientView *view; gboolean do_query; } ECalModelClient; @@ -52,7 +53,7 @@ struct _ECalModelPrivate { GList *clients; /* The default client in the list */ - ECal *default_client; + ECalClient *default_client; /* Array for storing the objects. Each element is of type ECalModelComponent */ GPtrArray *objects; @@ -108,9 +109,9 @@ struct _ECalModelPrivate { gboolean in_modified; gboolean in_removed; - GList *notify_added; - GList *notify_modified; - GList *notify_removed; + GSList *notify_added; + GSList *notify_modified; + GSList *notify_removed; GMutex *notify_lock; }; @@ -129,8 +130,8 @@ static gchar *ecm_value_to_string (ETableModel *etm, gint col, gconstpointer val static const gchar *ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data); -static ECalModelClient *add_new_client (ECalModel *model, ECal *client, gboolean do_query); -static ECalModelClient *find_client_data (ECalModel *model, ECal *client); +static ECalModelClient *add_new_client (ECalModel *model, ECalClient *client, gboolean do_query); +static ECalModelClient *find_client_data (ECalModel *model, ECalClient *client); static void remove_client_objects (ECalModel *model, ECalModelClient *client_data); static void remove_client (ECalModel *model, ECalModelClient *client_data); @@ -156,9 +157,6 @@ enum { ROW_APPENDED, COMPS_DELETED, CAL_VIEW_PROGRESS, - #ifndef E_CAL_DISABLE_DEPRECATED - CAL_VIEW_DONE, - #endif CAL_VIEW_COMPLETE, STATUS_MESSAGE, TIMEZONE_CHANGED, @@ -385,15 +383,15 @@ cal_model_dispose (GObject *object) g_signal_handlers_disconnect_matched (client_data->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, object); - if (client_data->query) - g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA, + if (client_data->view) + g_signal_handlers_disconnect_matched (client_data->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, object); priv->clients = g_list_remove (priv->clients, client_data); g_object_unref (client_data->client); - if (client_data->query) - g_object_unref (client_data->query); + if (client_data->view) + g_object_unref (client_data->view); g_free (client_data); } @@ -493,9 +491,9 @@ e_cal_model_class_init (ECalModelClass *class) PROP_DEFAULT_CLIENT, g_param_spec_object ( "default-client", - "Default Client", + "Default ECalClient", NULL, - E_TYPE_CAL, + E_TYPE_CAL_CLIENT, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -646,25 +644,14 @@ e_cal_model_class_init (ECalModelClass *class) e_marshal_VOID__STRING_INT_INT, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); - #ifndef E_CAL_DISABLE_DEPRECATED - signals[CAL_VIEW_DONE] = - g_signal_new ("cal_view_done", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalModelClass, cal_view_done), - NULL, NULL, - e_marshal_VOID__INT_INT, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); - #endif - signals[CAL_VIEW_COMPLETE] = g_signal_new ("cal_view_complete", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, cal_view_complete), NULL, NULL, - e_marshal_VOID__INT_STRING_INT, - G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT); + e_marshal_VOID__BOXED_INT, + G_TYPE_NONE, 2, G_TYPE_ERROR, G_TYPE_INT); signals[STATUS_MESSAGE] = g_signal_new ( "status-message", @@ -827,7 +814,7 @@ get_dtstart (ECalModel *model, ECalModelComponent *comp_data) tt_start = icalproperty_get_dtstart (prop); if (icaltime_get_tzid (tt_start) - && e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_start), &zone, NULL)) + && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_start), &zone, NULL, NULL)) got_zone = TRUE; if (e_cal_model_get_flags (model) & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) { @@ -1080,7 +1067,7 @@ set_description (ECalModelComponent *comp_data, const gchar *value) } static void -datetime_to_zone (ECal *client, struct icaltimetype *tt, icaltimezone *tt_zone, const gchar *tzid) +datetime_to_zone (ECalClient *client, struct icaltimetype *tt, icaltimezone *tt_zone, const gchar *tzid) { icaltimezone *from, *to; const gchar *tt_tzid = NULL; @@ -1098,7 +1085,7 @@ datetime_to_zone (ECal *client, struct icaltimetype *tt, icaltimezone *tt_zone, to = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (!to) { /* do not check failure here, maybe the zone is not available there */ - e_cal_get_timezone (client, tzid, &to, NULL); + e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL); } icaltimezone_convert_time (tt, from, to); @@ -1196,6 +1183,7 @@ ecm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) ECalModelPrivate *priv; ECalModelComponent *comp_data; ECalModel *model = (ECalModel *) etm; + GError *error = NULL; g_return_if_fail (E_IS_CAL_MODEL (model)); @@ -1226,10 +1214,12 @@ ecm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) } /* FIXME ask about mod type */ - if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { - g_warning (G_STRLOC ": Could not modify the object!"); + if (!e_cal_client_modify_object_sync (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL, &error)) { + g_warning (G_STRLOC ": Could not modify the object! %s", error ? error->message : "Unknown error"); /* FIXME Show error dialog */ + if (error) + g_error_free (error); } } @@ -1248,7 +1238,7 @@ gboolean e_cal_model_test_row_editable (ECalModel *model, gint row) { gboolean readonly; - ECal *cal = NULL; + ECalClient *client = NULL; if (row != -1) { ECalModelComponent *comp_data; @@ -1256,17 +1246,16 @@ e_cal_model_test_row_editable (ECalModel *model, gint row) comp_data = e_cal_model_get_component_at (model, row); if (comp_data) - cal = comp_data->client; + client = comp_data->client; } else { - cal = e_cal_model_get_default_client (model); + client = e_cal_model_get_default_client (model); } - readonly = cal == NULL; + readonly = client == NULL; if (!readonly) - if (!e_cal_is_read_only (cal, &readonly, NULL)) - readonly = TRUE; + readonly = e_client_is_readonly (E_CLIENT (client)); return !readonly; } @@ -1305,6 +1294,8 @@ ecm_append_row (ETableModel *etm, ETableModel *source, gint row) ECalModelClass *model_class; ECalModelComponent *comp_data; ECalModel *model = (ECalModel *) etm; + gchar *uid = NULL; + GError *error = NULL; g_return_if_fail (E_IS_CAL_MODEL (model)); g_return_if_fail (E_IS_TABLE_MODEL (source)); @@ -1316,7 +1307,7 @@ ecm_append_row (ETableModel *etm, ETableModel *source, gint row) g_object_ref (comp_data->client); /* guard against saving before the calendar is open */ - if (!(comp_data->client && e_cal_get_load_state (comp_data->client) == E_CAL_LOAD_LOADED)) { + if (!comp_data->client || !e_client_is_opened (E_CLIENT (comp_data->client))) { g_object_unref (comp_data); return; } @@ -1353,14 +1344,20 @@ ecm_append_row (ETableModel *etm, ETableModel *source, gint row) model_class->fill_component_from_model (model, comp_data, source, row); } - if (!e_cal_create_object (comp_data->client, comp_data->icalcomp, NULL, NULL)) { - g_warning (G_STRLOC ": Could not create the object!"); + if (!e_cal_client_create_object_sync (comp_data->client, comp_data->icalcomp, &uid, NULL, &error)) { + g_warning (G_STRLOC ": Could not create the object! %s", error ? error->message : "Unknown error"); /* FIXME: show error dialog */ + if (error) + g_error_free (error); } else { + if (uid) + icalcomponent_set_uid (comp_data->icalcomp, uid); + g_signal_emit (G_OBJECT (model), signals[ROW_APPENDED], 0); } + g_free (uid); g_object_unref (comp_data); } @@ -1561,7 +1558,7 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL); - source = e_cal_get_source (comp_data->client); + source = e_client_get_source (E_CLIENT (comp_data->client)); color_spec = e_source_peek_color_spec (source); if (color_spec != NULL) { g_free (comp_data->color); @@ -1579,7 +1576,7 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) for (l = assigned_colors[i].uris; l != NULL; l = l->next) { if (!strcmp ((const gchar *) l->data, - e_cal_get_uri (comp_data->client))) + e_client_get_uri (E_CLIENT (comp_data->client)))) { return assigned_colors[i].color; } @@ -1588,7 +1585,7 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) /* return the first unused color */ assigned_colors[first_empty].uris = g_list_append (assigned_colors[first_empty].uris, - g_strdup (e_cal_get_uri (comp_data->client))); + g_strdup (e_client_get_uri (E_CLIENT (comp_data->client)))); return assigned_colors[first_empty].color; } @@ -1887,7 +1884,7 @@ e_cal_model_set_work_day_start_minute (ECalModel *model, g_object_notify (G_OBJECT (model), "work-day-start-minute"); } -ECal * +ECalClient * e_cal_model_get_default_client (ECalModel *model) { ECalModelPrivate *priv; @@ -1913,7 +1910,7 @@ e_cal_model_get_default_client (ECalModel *model) } void -e_cal_model_set_default_client (ECalModel *model, ECal *client) +e_cal_model_set_default_client (ECalModel *model, ECalClient *client) { ECalModelPrivate *priv; ECalModelClient *client_data; @@ -1921,7 +1918,7 @@ e_cal_model_set_default_client (ECalModel *model, ECal *client) g_return_if_fail (E_IS_CAL_MODEL (model)); if (client != NULL) - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); priv = model->priv; @@ -1951,7 +1948,7 @@ GList * e_cal_model_get_client_list (ECalModel *model) { GList *list = NULL, *l; - ECal *default_client; + ECalClient *default_client; g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL); @@ -1975,7 +1972,7 @@ e_cal_model_get_client_list (ECalModel *model) * @model: A calendar model. * @uri: Uri for the client to get. */ -ECal * +ECalClient * e_cal_model_get_client_for_uri (ECalModel *model, const gchar *uri) { GList *l; @@ -1986,7 +1983,7 @@ e_cal_model_get_client_for_uri (ECalModel *model, const gchar *uri) for (l = model->priv->clients; l != NULL; l = l->next) { ECalModelClient *client_data = (ECalModelClient *) l->data; - if (!strcmp (uri, e_cal_get_uri (client_data->client))) + if (!strcmp (uri, e_client_get_uri (E_CLIENT (client_data->client)))) return client_data->client; } @@ -1994,7 +1991,7 @@ e_cal_model_get_client_for_uri (ECalModel *model, const gchar *uri) } static ECalModelClient * -find_client_data (ECalModel *model, ECal *client) +find_client_data (ECalModel *model, ECalClient *client) { ECalModelPrivate *priv; GList *l; @@ -2012,7 +2009,7 @@ find_client_data (ECalModel *model, ECal *client) } static ECalModelComponent * -search_by_id_and_client (ECalModelPrivate *priv, ECal *client, const ECalComponentId *id) +search_by_id_and_client (ECalModelPrivate *priv, ECalClient *client, const ECalComponentId *id) { gint i; @@ -2051,8 +2048,8 @@ search_by_id_and_client (ECalModelPrivate *priv, ECal *client, const ECalCompone } typedef struct { - ECal *client; - ECalView *query; + ECalClient *client; + ECalClientView *view; ECalModel *model; icalcomponent *icalcomp; } RecurrenceExpansionData; @@ -2075,7 +2072,8 @@ add_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end /* set the right instance start date to component */ e_cal_component_get_dtstart (comp, &datetime); - e_cal_get_timezone (rdata->client, datetime.tzid, &zone, NULL); + if (datetime.tzid) + e_cal_client_get_timezone_sync (rdata->client, datetime.tzid, &zone, NULL, NULL); time = icaltime_from_timet_with_zone (instance_start, FALSE, zone ? zone : priv->zone); to_set.value = &time; to_set.tzid = datetime.tzid; @@ -2084,7 +2082,9 @@ add_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end /* set the right instance end date to component*/ e_cal_component_get_dtend (comp, &datetime); - e_cal_get_timezone (rdata->client, datetime.tzid, &zone, NULL); + zone = NULL; + if (datetime.tzid) + e_cal_client_get_timezone_sync (rdata->client, datetime.tzid, &zone, NULL, NULL); time = icaltime_from_timet_with_zone (instance_end, FALSE, zone ? zone : priv->zone); to_set.value = &time; to_set.tzid = datetime.tzid; @@ -2162,24 +2162,25 @@ place_master_object_first_cb (gconstpointer p1, gconstpointer p2) return res; } -static void e_cal_view_objects_added_cb (ECalView *query, GList *objects, ECalModel *model); +static void client_view_objects_added_cb (ECalClientView *view, const GSList *objects, ECalModel *model); static void -process_added (ECalView *query, GList *objects, ECalModel *model) +process_added (ECalClientView *view, const GSList *objects, ECalModel *model) { ECalModelPrivate *priv; - GList *l, *copy; + const GSList *l; + GSList *copy; priv = model->priv; /* order matters, process master object first, then detached instances */ - copy = g_list_sort (g_list_copy (objects), place_master_object_first_cb); + copy = g_slist_sort (g_slist_copy ((GSList *) objects), place_master_object_first_cb); for (l = copy; l; l = l->next) { ECalModelComponent *comp_data; ECalComponentId *id; ECalComponent *comp = e_cal_component_new (); - ECal *client = e_cal_view_get_client (query); + ECalClient *client = e_cal_client_view_get_client (view); /* This will fail for alarm or VCalendar component */ if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) { @@ -2217,19 +2218,17 @@ process_added (ECalView *query, GList *objects, ECalModel *model) if (e_cal_util_component_has_recurrences (l->data) && (priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES)) { RecurrenceExpansionData rdata; - rdata.client = e_cal_view_get_client (query); - rdata.query = query; + rdata.client = client; + rdata.view = view; rdata.model = model; rdata.icalcomp = l->data; - e_cal_generate_instances_for_object (rdata.client, l->data, - priv->start, priv->end, - (ECalRecurInstanceFn) add_instance_cb, - &rdata); + e_cal_client_generate_instances_for_object (rdata.client, l->data, priv->start, priv->end, + (ECalRecurInstanceFn) add_instance_cb, &rdata); } else { e_table_model_pre_change (E_TABLE_MODEL (model)); comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL); - comp_data->client = g_object_ref (e_cal_view_get_client (query)); + comp_data->client = g_object_ref (client); comp_data->icalcomp = icalcomponent_new_clone (l->data); e_cal_model_set_instance_times (comp_data, priv->zone); @@ -2238,27 +2237,28 @@ process_added (ECalView *query, GList *objects, ECalModel *model) } } - g_list_free (copy); + g_slist_free (copy); } static void -process_modified (ECalView *query, GList *objects, ECalModel *model) +process_modified (ECalClientView *view, const GSList *objects, ECalModel *model) { ECalModelPrivate *priv; - GList *l, *list = NULL; + const GSList *l; + GSList *list = NULL; priv = model->priv; /* re-add only the recurrence objects */ - for (l = objects; l != NULL; l = g_list_next (l)) { + for (l = objects; l != NULL; l = g_slist_next (l)) { if (!e_cal_util_component_is_instance (l->data) && e_cal_util_component_has_recurrences (l->data) && (priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES)) - list = g_list_prepend (list, l->data); + list = g_slist_prepend (list, l->data); else { gint pos; ECalModelComponent *comp_data; ECalComponentId *id; ECalComponent *comp = e_cal_component_new (); - ECal *client = e_cal_view_get_client (query); + ECalClient *client = e_cal_client_view_get_client (view); if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) { g_object_unref (comp); @@ -2319,15 +2319,15 @@ process_modified (ECalView *query, GList *objects, ECalModel *model) } } - e_cal_view_objects_added_cb (query, list, model); - g_list_free (list); + client_view_objects_added_cb (view, list, model); + g_slist_free (list); } static void -process_removed (ECalView *query, GList *ids, ECalModel *model) +process_removed (ECalClientView *view, const GSList *ids, ECalModel *model) { ECalModelPrivate *priv; - GList *l; + const GSList *l; priv = model->priv; @@ -2337,7 +2337,7 @@ process_removed (ECalView *query, GList *ids, ECalModel *model) gint pos; /* make sure we remove all objects with this UID */ - while ((comp_data = search_by_id_and_client (priv, e_cal_view_get_client (query), id))) { + while ((comp_data = search_by_id_and_client (priv, e_cal_client_view_get_client (view), id))) { GSList *l = NULL; pos = get_position_in_array (priv->objects, comp_data); @@ -2387,19 +2387,19 @@ free_comp_id (gpointer id) } static void -process_event (ECalView *query, GList *objects, ECalModel *model, - void (*process_fn) (ECalView *query, GList *objects, ECalModel *model), - gboolean *in, GList **save_list, gpointer (*copy_fn) (gpointer data), void (*free_fn)(gpointer data)) +process_event (ECalClientView *view, const GSList *objects, ECalModel *model, + void (*process_fn) (ECalClientView *view, const GSList *objects, ECalModel *model), + gboolean *in, GSList **save_list, gpointer (*copy_fn) (gpointer data), void (*free_fn)(gpointer data)) { gboolean skip = FALSE; - GList *l; + const GSList *l; g_mutex_lock (model->priv->notify_lock); if (*in) { skip = TRUE; for (l = objects; l; l = l->next) { if (l->data) - *save_list = g_list_append (*save_list, copy_fn (l->data)); + *save_list = g_slist_append (*save_list, copy_fn (l->data)); } } else { *in = TRUE; @@ -2411,23 +2411,23 @@ process_event (ECalView *query, GList *objects, ECalModel *model, return; /* do it */ - process_fn (query, objects, model); + process_fn (view, objects, model); g_mutex_lock (model->priv->notify_lock); while (*save_list) { - GList *copy = *save_list; + GSList *copy = *save_list; *save_list = NULL; g_mutex_unlock (model->priv->notify_lock); /* do it */ - process_fn (query, copy, model); + process_fn (view, copy, model); for (l = copy; l; l = l->next) { if (l->data) { free_fn (l->data); } } - g_list_free (copy); + g_slist_free (copy); g_mutex_lock (model->priv->notify_lock); } @@ -2437,56 +2437,51 @@ process_event (ECalView *query, GList *objects, ECalModel *model, } static void -e_cal_view_objects_added_cb (ECalView *query, GList *objects, ECalModel *model) +client_view_objects_added_cb (ECalClientView *view, const GSList *objects, ECalModel *model) { - process_event (query, objects, model, + process_event (view, objects, model, process_added, &model->priv->in_added, &model->priv->notify_added, (gpointer (*)(gpointer)) icalcomponent_new_clone, (void (*)(gpointer)) icalcomponent_free); } static void -e_cal_view_objects_modified_cb (ECalView *query, GList *objects, ECalModel *model) +client_view_objects_modified_cb (ECalClientView *view, const GSList *objects, ECalModel *model) { - process_event (query, objects, model, + process_event (view, objects, model, process_modified, &model->priv->in_modified, &model->priv->notify_modified, (gpointer (*)(gpointer)) icalcomponent_new_clone, (void (*)(gpointer)) icalcomponent_free); } static void -e_cal_view_objects_removed_cb (ECalView *query, GList *ids, ECalModel *model) +client_view_objects_removed_cb (ECalClientView *view, const GSList *ids, ECalModel *model) { - process_event (query, ids, model, + process_event (view, ids, model, process_removed, &model->priv->in_removed, &model->priv->notify_removed, copy_comp_id, free_comp_id); } static void -e_cal_view_progress_cb (ECalView *query, const gchar *message, gint percent, gpointer user_data) +client_view_progress_cb (ECalClientView *view, gint percent, const gchar *message, gpointer user_data) { ECalModel *model = (ECalModel *) user_data; - ECal *client = e_cal_view_get_client (query); + ECalClient *client = e_cal_client_view_get_client (view); g_return_if_fail (E_IS_CAL_MODEL (model)); g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_PROGRESS], 0, message, - percent, e_cal_get_source_type (client)); + percent, e_cal_client_get_source_type (client)); } static void -e_cal_view_complete_cb (ECalView *query, ECalendarStatus status, const gchar *error_msg, gpointer user_data) +client_view_complete_cb (ECalClientView *view, const GError *error, gpointer user_data) { ECalModel *model = (ECalModel *) user_data; - ECal *client = e_cal_view_get_client (query); + ECalClient *client = e_cal_client_view_get_client (view); g_return_if_fail (E_IS_CAL_MODEL (model)); - #ifndef E_CAL_DISABLE_DEPRECATED - /* emit the signal on the model and let the view catch it to display */ - g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_DONE], 0, status, - e_cal_get_source_type (client)); - #endif - g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_COMPLETE], 0, status, error_msg, - e_cal_get_source_type (client)); + g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_COMPLETE], 0, error, + e_cal_client_get_source_type (client)); } static void @@ -2499,27 +2494,27 @@ update_e_cal_view_for_client (ECalModel *model, ECalModelClient *client_data) priv = model->priv; /* Skip if this client has not finished loading yet */ - if (e_cal_get_load_state (client_data->client) != E_CAL_LOAD_LOADED) + if (!e_client_is_opened (E_CLIENT (client_data->client))) return; - /* free the previous query, if any */ - if (client_data->query) { - g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA, + /* free the previous view, if any */ + if (client_data->view) { + g_signal_handlers_disconnect_matched (client_data->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model); - g_object_unref (client_data->query); - client_data->query = NULL; + g_object_unref (client_data->view); + client_data->view = NULL; } - /* prepare the query */ + /* prepare the view */ g_return_if_fail (priv->full_sexp != NULL); /* Don't create the new query if we won't use it */ if (!client_data->do_query) return; -try_again: - if (!e_cal_get_query (client_data->client, priv->full_sexp, &client_data->query, &error)) { - if (error->code == E_CALENDAR_STATUS_BUSY && tries != 10) { + try_again: + if (!e_cal_client_get_view_sync (client_data->client, priv->full_sexp, &client_data->view, NULL, &error)) { + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY) && tries != 10) { tries++; /*TODO chose an optimal value */ g_usleep (500); @@ -2527,18 +2522,24 @@ try_again: goto try_again; } - g_warning (G_STRLOC ": Unable to get query, %s", error->message); + g_warning (G_STRLOC ": Unable to get query, %s", error ? error->message : "Unknown error"); + if (error) + g_error_free (error); return; } - g_signal_connect (client_data->query, "objects_added", G_CALLBACK (e_cal_view_objects_added_cb), model); - g_signal_connect (client_data->query, "objects_modified", G_CALLBACK (e_cal_view_objects_modified_cb), model); - g_signal_connect (client_data->query, "objects_removed", G_CALLBACK (e_cal_view_objects_removed_cb), model); - g_signal_connect (client_data->query, "view_progress", G_CALLBACK (e_cal_view_progress_cb), model); - g_signal_connect (client_data->query, "view_complete", G_CALLBACK (e_cal_view_complete_cb), model); + g_signal_connect (client_data->view, "objects-added", G_CALLBACK (client_view_objects_added_cb), model); + g_signal_connect (client_data->view, "objects-modified", G_CALLBACK (client_view_objects_modified_cb), model); + g_signal_connect (client_data->view, "objects-removed", G_CALLBACK (client_view_objects_removed_cb), model); + g_signal_connect (client_data->view, "progress", G_CALLBACK (client_view_progress_cb), model); + g_signal_connect (client_data->view, "complete", G_CALLBACK (client_view_complete_cb), model); - e_cal_view_start (client_data->query); + e_cal_client_view_start (client_data->view, &error); + if (error) { + g_debug ("%s: Failed to start view: %s", G_STRFUNC, error->message); + g_error_free (error); + } } void @@ -2550,7 +2551,7 @@ e_cal_model_update_status_message (ECalModel *model, const gchar *message, gdoub } static void -backend_died_cb (ECal *client, gpointer user_data) +backend_died_cb (ECalClient *client, gpointer user_data) { ECalModel *model; @@ -2559,35 +2560,20 @@ backend_died_cb (ECal *client, gpointer user_data) e_cal_model_remove_client (model, client); } -static gboolean -wait_open_cb (gpointer data) -{ - ECal *client = data; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (E_IS_CAL (client), FALSE); - - e_cal_open_async (client, FALSE); - - return FALSE; -} - static void -cal_opened_cb (ECal *client, const GError *error, gpointer user_data) +client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + ECalClient *client = E_CAL_CLIENT (source_object); ECalModel *model = (ECalModel *) user_data; ECalModelClient *client_data; + GError *error = NULL; - if (g_error_matches (error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY)) { - g_timeout_add (250, wait_open_cb, client); - return; - } - - /* Stop listening for this calendar to be opened */ - g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, cal_opened_cb, model); + e_client_open_finish (E_CLIENT (client), result, &error); if (error) { e_cal_model_remove_client (model, client); + g_debug ("%s: Failed to open '%s': %s", G_STRFUNC, e_client_get_uri (E_CLIENT (client)), error->message); + g_error_free (error); e_cal_model_update_status_message (model, NULL, -1.0); return; } @@ -2601,7 +2587,7 @@ cal_opened_cb (ECal *client, const GError *error, gpointer user_data) } static ECalModelClient * -add_new_client (ECalModel *model, ECal *client, gboolean do_query) +add_new_client (ECalModel *model, ECalClient *client, gboolean do_query) { ECalModelPrivate *priv; ECalModelClient *client_data; @@ -2626,7 +2612,7 @@ add_new_client (ECalModel *model, ECal *client, gboolean do_query) client_data = g_new0 (ECalModelClient, 1); client_data->client = g_object_ref (client); - client_data->query = NULL; + client_data->view = NULL; client_data->do_query = do_query; priv->clients = g_list_append (priv->clients, client_data); @@ -2635,19 +2621,18 @@ add_new_client (ECalModel *model, ECal *client, gboolean do_query) G_CALLBACK (backend_died_cb), model); load: - if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) { + if (e_client_is_opened (E_CLIENT (client))) { update_e_cal_view_for_client (model, client_data); } else { gchar *msg; - msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (client)); + msg = g_strdup_printf (_("Opening %s"), e_client_get_uri (E_CLIENT (client))); e_cal_model_update_status_message (model, msg, -1.0); g_free (msg); - e_cal_set_default_timezone (client, e_cal_model_get_timezone (model), NULL); + e_cal_client_set_default_timezone (client, e_cal_model_get_timezone (model)); - g_signal_connect (client, "cal_opened_ex", G_CALLBACK (cal_opened_cb), model); - e_cal_open_async (client, TRUE); + e_client_open (E_CLIENT (client), TRUE, NULL, client_opened_cb, model); } return client_data; @@ -2657,10 +2642,10 @@ add_new_client (ECalModel *model, ECal *client, gboolean do_query) * e_cal_model_add_client */ void -e_cal_model_add_client (ECalModel *model, ECal *client) +e_cal_model_add_client (ECalModel *model, ECalClient *client) { g_return_if_fail (E_IS_CAL_MODEL (model)); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); add_new_client (model, client, TRUE); } @@ -2701,8 +2686,8 @@ remove_client (ECalModel *model, ECalModelClient *client_data) { /* FIXME We might not want to disconnect the open signal for the default client */ g_signal_handlers_disconnect_matched (client_data->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model); - if (client_data->query) - g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model); + if (client_data->view) + g_signal_handlers_disconnect_matched (client_data->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model); remove_client_objects (model, client_data); @@ -2722,8 +2707,8 @@ remove_client (ECalModel *model, ECalModelClient *client_data) /* free all remaining memory */ g_object_unref (client_data->client); - if (client_data->query) - g_object_unref (client_data->query); + if (client_data->view) + g_object_unref (client_data->view); g_free (client_data); } @@ -2731,12 +2716,12 @@ remove_client (ECalModel *model, ECalModelClient *client_data) * e_cal_model_remove_client */ void -e_cal_model_remove_client (ECalModel *model, ECal *client) +e_cal_model_remove_client (ECalModel *model, ECalClient *client) { ECalModelClient *client_data; g_return_if_fail (E_IS_CAL_MODEL (model)); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); client_data = find_client_data (model, client); if (client_data) @@ -2876,7 +2861,7 @@ redo_queries (ECalModel *model) e_flag_free (data.eflag); - /* update the query for all clients */ + /* update the view for all clients */ for (l = priv->clients; l != NULL; l = l->next) { ECalModelClient *client_data; @@ -3002,7 +2987,7 @@ e_cal_model_create_component_with_defaults (ECalModel *model, gboolean all_day) ECalModelPrivate *priv; ECalComponent *comp; icalcomponent *icalcomp; - ECal *client; + ECalClient *client; g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL); @@ -3302,7 +3287,7 @@ e_cal_model_generate_instances (ECalModel *model, time_t start, time_t end, mdata.cb_data = cb_data; if (comp_data->instance_start < end && comp_data->instance_end > start) - e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp, start, end, cb, &mdata); + e_cal_client_generate_instances_for_object (comp_data->client, comp_data->icalcomp, start, end, cb, &mdata); } } @@ -3361,7 +3346,8 @@ e_cal_model_set_instance_times (ECalModelComponent *comp_data, const icaltimezon icaltimezone *st_zone = NULL; tzid = icalparameter_get_tzid (param); - e_cal_get_timezone (comp_data->client, tzid, &st_zone, NULL); + if (tzid) + e_cal_client_get_timezone_sync (comp_data->client, tzid, &st_zone, NULL, NULL); if (st_zone) zone = st_zone; @@ -3385,7 +3371,8 @@ e_cal_model_set_instance_times (ECalModelComponent *comp_data, const icaltimezon icaltimezone *end_zone = NULL; tzid = icalparameter_get_tzid (param); - e_cal_get_timezone (comp_data->client, tzid, &end_zone, NULL); + if (tzid) + e_cal_client_get_timezone_sync (comp_data->client, tzid, &end_zone, NULL, NULL); if (end_zone) zone = end_zone; diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h index db744d3d32..766fd6286f 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -28,7 +28,7 @@ #include <e-util/e-util-enums.h> #include <table/e-table-model.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include "e-cell-date-edit-text.h" /* Standard GObject macros */ @@ -105,7 +105,7 @@ typedef struct _ECalModelComponentPrivate ECalModelComponentPrivate; struct _ECalModelComponent { GObject object; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; time_t instance_start; time_t instance_end; @@ -160,16 +160,10 @@ struct _ECalModelClass { void (*cal_view_progress) (ECalModel *model, const gchar *message, gint progress, - ECalSourceType type); - #ifndef E_CAL_DISABLE_DEPRECATED - void (*cal_view_done) (ECalModel *model, - ECalendarStatus status, - ECalSourceType type); - #endif + ECalClientSourceType type); void (*cal_view_complete) (ECalModel *model, - ECalendarStatus status, - const gchar *error_msg, - ECalSourceType type); + const GError *error, + ECalClientSourceType type); void (*status_message) (ECalModel *model, const gchar *message, gdouble percent); @@ -246,16 +240,16 @@ gint e_cal_model_get_work_day_start_minute void e_cal_model_set_work_day_start_minute (ECalModel *model, gint work_day_start_minute); -ECal * e_cal_model_get_default_client (ECalModel *model); +ECalClient * e_cal_model_get_default_client (ECalModel *model); void e_cal_model_set_default_client (ECalModel *model, - ECal *client); + ECalClient *client); GList * e_cal_model_get_client_list (ECalModel *model); -ECal * e_cal_model_get_client_for_uri (ECalModel *model, +ECalClient * e_cal_model_get_client_for_uri (ECalModel *model, const gchar *uri); void e_cal_model_add_client (ECalModel *model, - ECal *client); + ECalClient *cal_client); void e_cal_model_remove_client (ECalModel *model, - ECal *client); + ECalClient *cal_client); void e_cal_model_remove_all_clients (ECalModel *model); void e_cal_model_get_time_range (ECalModel *model, time_t *start, diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c index 86d42aedb1..d31578cbd0 100644 --- a/calendar/gui/e-calendar-selector.c +++ b/calendar/gui/e-calendar-selector.c @@ -24,9 +24,9 @@ #include "e-calendar-selector.h" -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-selection.h" -#include "common/authentication.h" struct _ECalendarSelectorPrivate { gint dummy_value; @@ -35,7 +35,7 @@ struct _ECalendarSelectorPrivate { static gpointer parent_class; static gboolean -calendar_selector_update_single_object (ECal *client, +calendar_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { gchar *uid; @@ -43,15 +43,23 @@ calendar_selector_update_single_object (ECal *client, uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) - return e_cal_modify_object ( - client, icalcomp, CALOBJ_MOD_ALL, NULL); + if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) + return e_cal_client_modify_object_sync ( + client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL); - return e_cal_create_object (client, icalcomp, &uid, NULL); + uid = NULL; + if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) + return FALSE; + + if (uid) + icalcomponent_set_uid (icalcomp, uid); + g_free (uid); + + return TRUE; } static gboolean -calendar_selector_update_objects (ECal *client, +calendar_selector_update_objects (ECalClient *client, icalcomponent *icalcomp) { icalcomponent *subcomp; @@ -72,14 +80,19 @@ calendar_selector_update_objects (ECal *client, kind = icalcomponent_isa (subcomp); if (kind == ICAL_VTIMEZONE_COMPONENT) { icaltimezone *zone; + GError *error = NULL; zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - success = e_cal_add_timezone (client, zone, NULL); + success = e_cal_client_add_timezone_sync (client, zone, NULL, &error); icaltimezone_free (zone, 1); - if (!success) + if (!success) { + g_debug ("%s: Failed to ass timezone: %s", G_STRFUNC, error ? error->message : "Unknown error"); + if (error) + g_error_free (error); return FALSE; + } } else if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) { success = calendar_selector_update_single_object ( @@ -95,6 +108,31 @@ calendar_selector_update_objects (ECal *client, return TRUE; } +static void +client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + EClient *client = NULL; + icalcomponent *icalcomp = user_data; + GError *error = NULL; + + g_return_if_fail (icalcomp != NULL); + + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; + + if (client) { + calendar_selector_update_objects (E_CAL_CLIENT (client), icalcomp); + g_object_unref (client); + } + + if (error) { + g_debug ("%s: Failed to open client: %s", G_STRFUNC, error->message); + g_error_free (error); + } + + icalcomponent_free (icalcomp); +} + static gboolean calendar_selector_data_dropped (ESourceSelector *selector, GtkSelectionData *selection_data, @@ -103,7 +141,6 @@ calendar_selector_data_dropped (ESourceSelector *selector, guint info) { GtkTreePath *path = NULL; - ECal *client; icalcomponent *icalcomp; const guchar *data; gboolean success = FALSE; @@ -123,17 +160,9 @@ calendar_selector_data_dropped (ESourceSelector *selector, icalcomponent_set_uid (icalcomp, uid); } - client = e_auth_new_cal_from_source ( - destination, E_CAL_SOURCE_TYPE_EVENT); - - if (client != NULL) { - if (e_cal_open (client, TRUE, NULL)) - calendar_selector_update_objects (client, icalcomp); - - g_object_unref (client); - } - - icalcomponent_free (icalcomp); + e_client_utils_open_new (destination, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL, + e_client_utils_authenticate_handler, NULL, + client_opened_cb, icalcomp); success = TRUE; diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 34f6eae6b0..32c5301fe1 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -31,6 +31,7 @@ #include <glib/gstdio.h> #include <gdk/gdkkeysyms.h> #include <libedataserver/e-time-utils.h> +#include <libedataserverui/e-client-utils.h> #include <e-util/e-util.h> #include <e-util/e-alert-dialog.h> #include <e-util/e-extensible.h> @@ -43,7 +44,6 @@ #include <misc/e-selectable.h> #include <shell/e-shell.h> -#include "common/authentication.h" #include "comp-util.h" #include "ea-calendar.h" #include "e-cal-model-calendar.h" @@ -132,7 +132,7 @@ calendar_view_add_retract_data (ECalComponent *comp, static gboolean calendar_view_check_for_retract (ECalComponent *comp, - ECal *client) + ECalClient *client) { ECalComponentOrganizer organizer; const gchar *strip; @@ -142,14 +142,14 @@ calendar_view_check_for_retract (ECalComponent *comp, if (!e_cal_component_has_attendees (comp)) return FALSE; - if (!e_cal_get_save_schedules (client)) + if (!e_cal_client_check_save_schedules (client)) return FALSE; e_cal_component_get_organizer (comp, &organizer); strip = itip_strip_mailto (organizer.value); ret_val = - e_cal_get_cal_address (client, &email, NULL) && + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL) && (g_ascii_strcasecmp (email, strip) == 0); g_free (email); @@ -177,7 +177,7 @@ calendar_view_delete_event (ECalendarView *cal_view, vtype = e_cal_component_get_vtype (comp); /*FIXME remove it once the we dont set the recurrence id for all the generated instances */ - if (!e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) + if (!e_cal_client_check_recurrences_no_master (event->comp_data->client)) e_cal_component_set_recurid (comp, NULL); /*FIXME Retract should be moved to Groupwise features plugin */ @@ -187,15 +187,15 @@ calendar_view_delete_event (ECalendarView *cal_view, delete = prompt_retract_dialog (comp, &retract_comment, GTK_WIDGET (cal_view), &retract); if (retract) { - GList *users = NULL; + GSList *users = NULL; icalcomponent *icalcomp = NULL, *mod_comp = NULL; calendar_view_add_retract_data ( comp, retract_comment, CALOBJ_MOD_ALL); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_send_objects (event->comp_data->client, icalcomp, &users, - &mod_comp, &error)) { + if (!e_cal_client_send_objects_sync (event->comp_data->client, icalcomp, &users, + &mod_comp, NULL, &error)) { delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); error = NULL; @@ -205,8 +205,8 @@ calendar_view_delete_event (ECalendarView *cal_view, icalcomponent_free (mod_comp); if (users) { - g_list_foreach (users, (GFunc) g_free, NULL); - g_list_free (users); + g_slist_foreach (users, (GFunc) g_free, NULL); + g_slist_free (users); } } } @@ -232,10 +232,10 @@ calendar_view_delete_event (ECalendarView *cal_view, } rid = e_cal_component_get_recurid_as_string (comp); if (e_cal_util_component_is_instance (event->comp_data->icalcomp) || e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) - e_cal_remove_object_with_mod (event->comp_data->client, uid, - rid, CALOBJ_MOD_ALL, &error); + e_cal_client_remove_object_sync (event->comp_data->client, uid, + rid, CALOBJ_MOD_ALL, NULL, &error); else - e_cal_remove_object (event->comp_data->client, uid, &error); + e_cal_client_remove_object_sync (event->comp_data->client, uid, NULL, CALOBJ_MOD_THIS, NULL, &error); delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); @@ -392,9 +392,8 @@ calendar_view_update_actions (ESelectable *selectable, for (iter = list; iter != NULL; iter = iter->next) { ECalendarViewEvent *event = iter->data; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; - gboolean read_only; if (event == NULL || event->comp_data == NULL) continue; @@ -402,8 +401,7 @@ calendar_view_update_actions (ESelectable *selectable, client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; - e_cal_is_read_only (client, &read_only, NULL); - sources_are_editable &= !read_only; + sources_are_editable = sources_are_editable && !e_client_is_readonly (E_CLIENT (client)); recurring |= e_cal_util_component_is_instance (icalcomp) || @@ -488,17 +486,14 @@ calendar_view_cut_clipboard (ESelectable *selectable) /* when cutting detached instances, only cut that instance */ rid = e_cal_component_get_recurid_as_string (comp); - if (e_cal_get_object (event->comp_data->client, uid, rid, &icalcomp, NULL)) { - e_cal_remove_object_with_mod (event->comp_data->client, uid, - rid, CALOBJ_MOD_THIS, - &error); + if (e_cal_client_get_object_sync (event->comp_data->client, uid, rid, &icalcomp, NULL, NULL)) { + e_cal_client_remove_object_sync (event->comp_data->client, uid, rid, CALOBJ_MOD_THIS, NULL, &error); icalcomponent_free (icalcomp); } else - e_cal_remove_object_with_mod (event->comp_data->client, uid, NULL, - CALOBJ_MOD_ALL, &error); + e_cal_client_remove_object_sync (event->comp_data->client, uid, NULL, CALOBJ_MOD_ALL, NULL, &error); g_free (rid); } else - e_cal_remove_object (event->comp_data->client, uid, &error); + e_cal_client_remove_object_sync (event->comp_data->client, uid, NULL, CALOBJ_MOD_ALL, NULL, &error); delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); @@ -514,7 +509,7 @@ calendar_view_cut_clipboard (ESelectable *selectable) } static void -add_related_timezones (icalcomponent *des_icalcomp, icalcomponent *src_icalcomp, ECal *client) +add_related_timezones (icalcomponent *des_icalcomp, icalcomponent *src_icalcomp, ECalClient *client) { icalproperty_kind look_in[] = { ICAL_DTSTART_PROPERTY, @@ -540,7 +535,7 @@ add_related_timezones (icalcomponent *des_icalcomp, icalcomponent *src_icalcomp, GError *error = NULL; icaltimezone *zone = NULL; - if (!e_cal_get_timezone (client, tzid, &zone, &error)) { + if (!e_cal_client_get_timezone_sync (client, tzid, &zone, NULL, &error)) { g_warning ("%s: Cannot get timezone for '%s'. %s", G_STRFUNC, tzid, error ? error->message : ""); if (error) g_error_free (error); @@ -628,7 +623,7 @@ clipboard_get_calendar_data (ECalendarView *cal_view, icalcomponent_kind kind; time_t selected_time_start, selected_time_end; icaltimezone *default_zone; - ECal *client; + ECalClient *client; gboolean in_top_canvas; g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); @@ -671,7 +666,7 @@ clipboard_get_calendar_data (ECalendarView *cal_view, zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - if (!e_cal_add_timezone (client, zone, &error)) { + if (!e_cal_client_add_timezone_sync (client, zone, NULL, &error)) { icalproperty *tzidprop = icalcomponent_get_first_property (subcomp, ICAL_TZID_PROPERTY); g_warning ("%s: Add zone '%s' failed. %s", G_STRFUNC, tzidprop ? icalproperty_get_tzid (tzidprop) : "???", error ? error->message : ""); @@ -949,7 +944,7 @@ e_calendar_view_popup_event (ECalendarView *calendar_view, } void -e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart, +e_calendar_view_add_event (ECalendarView *cal_view, ECalClient *client, time_t dtstart, icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas) { ECalComponent *comp; @@ -1049,7 +1044,7 @@ e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart e_cal_component_commit_sequence (comp); uid = NULL; - if (e_cal_create_object (client, e_cal_component_get_icalcomponent (comp), &uid, &error)) { + if (e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) { gboolean strip_alarms = TRUE; if (uid) { @@ -1284,15 +1279,15 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) delete = prompt_retract_dialog (comp, &retract_comment, GTK_WIDGET (cal_view), &retract); if (retract) { - GList *users = NULL; + GSList *users = NULL; icalcomponent *icalcomp = NULL, *mod_comp = NULL; calendar_view_add_retract_data ( comp, retract_comment, CALOBJ_MOD_THIS); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_send_objects (event->comp_data->client, icalcomp, &users, - &mod_comp, &error)) { + if (!e_cal_client_send_objects_sync (event->comp_data->client, icalcomp, &users, + &mod_comp, NULL, &error)) { delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); error = NULL; @@ -1300,8 +1295,8 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) if (mod_comp) icalcomponent_free (mod_comp); if (users) { - g_list_foreach (users, (GFunc) g_free, NULL); - g_list_free (users); + g_slist_foreach (users, (GFunc) g_free, NULL); + g_slist_free (users); } } } @@ -1323,7 +1318,7 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) if (dt.tzid) { GError *error = NULL; - e_cal_get_timezone (event->comp_data->client, dt.tzid, &zone, &error); + e_cal_client_get_timezone_sync (event->comp_data->client, dt.tzid, &zone, NULL, &error); if (error) { zone = e_calendar_view_get_timezone (cal_view); g_clear_error (&error); @@ -1339,7 +1334,7 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) if ((itip_organizer_is_user (comp, event->comp_data->client) || itip_sentby_is_user (comp, event->comp_data->client)) && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)), event->comp_data->client, - comp, TRUE) && !e_cal_get_save_schedules (event->comp_data->client)) { + comp, TRUE) && !e_cal_client_check_save_schedules (event->comp_data->client)) { if (!e_cal_component_is_instance (comp)) { ECalComponentRange range; @@ -1355,15 +1350,14 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) } if (is_instance) - e_cal_remove_object_with_mod (event->comp_data->client, uid, rid, CALOBJ_MOD_THIS, &error); + e_cal_client_remove_object_sync (event->comp_data->client, uid, rid, CALOBJ_MOD_THIS, NULL, &error); else { struct icaltimetype instance_rid; instance_rid = icaltime_from_timet_with_zone (event->comp_data->instance_start, TRUE, zone ? zone : icaltimezone_get_utc_timezone ()); e_cal_util_remove_instances (event->comp_data->icalcomp, instance_rid, CALOBJ_MOD_THIS); - e_cal_modify_object (event->comp_data->client, event->comp_data->icalcomp, CALOBJ_MOD_THIS, - &error); + e_cal_client_modify_object_sync (event->comp_data->client, event->comp_data->icalcomp, CALOBJ_MOD_THIS, NULL, &error); } delete_error_dialog (error, E_CAL_COMPONENT_EVENT); @@ -1414,10 +1408,9 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view, ECalComponent *comp; icalcomponent *icalcomp; ECalComponentTransparency transparency; - ECal *default_client = NULL; + ECalClient *default_client = NULL; gpointer parent; guint32 flags = 0; - gboolean readonly = FALSE; g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); @@ -1428,15 +1421,15 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view, default_client = e_cal_model_get_default_client (priv->model); - if (!default_client || e_cal_get_load_state (default_client) != E_CAL_LOAD_LOADED) { + if (!default_client || !e_client_is_opened (E_CLIENT (default_client))) { g_warning ("Default client not loaded \n"); return; } - if (e_cal_is_read_only (default_client, &readonly, NULL) && readonly) { + if (e_client_is_readonly (E_CLIENT (default_client))) { GtkWidget *widget; - widget = e_alert_dialog_new_for_args (parent, "calendar:prompt-read-only-cal", e_source_peek_name (e_cal_get_source (default_client)), NULL); + widget = e_alert_dialog_new_for_args (parent, "calendar:prompt-read-only-cal", e_source_peek_name (e_client_get_source (E_CLIENT (default_client))), NULL); g_signal_connect ((GtkDialog *)widget, "response", G_CALLBACK (gtk_widget_destroy), widget); @@ -1588,7 +1581,7 @@ object_created_cb (CompEditor *ce, ECalendarView *cal_view) } CompEditor * -e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, icalcomponent *icalcomp, guint32 flags) +e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECalClient *client, icalcomponent *icalcomp, guint32 flags) { CompEditor *ce; const gchar *uid; @@ -1631,12 +1624,12 @@ e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, ic * object. */ void -e_calendar_view_edit_appointment (ECalendarView *cal_view, ECal *client, icalcomponent *icalcomp, EEditEventMode mode) +e_calendar_view_edit_appointment (ECalendarView *cal_view, ECalClient *client, icalcomponent *icalcomp, EEditEventMode mode) { guint32 flags = 0; g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); g_return_if_fail (icalcomp != NULL); if ((mode == EDIT_EVENT_AUTODETECT && icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY) != NULL) @@ -1654,15 +1647,17 @@ e_calendar_view_edit_appointment (ECalendarView *cal_view, ECal *client, icalcom void e_calendar_view_modify_and_send (ECalComponent *comp, - ECal *client, + ECalClient *client, CalObjModType mod, GtkWindow *toplevel, gboolean new) { gboolean only_new_attendees = FALSE; + GError *error = NULL; + e_cal_component_commit_sequence (comp); - if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) { + if (e_cal_client_modify_object_sync (client, e_cal_component_get_icalcomponent (comp), mod, NULL, &error)) { gboolean strip_alarms = TRUE; if ((itip_organizer_is_user (comp, client) || itip_sentby_is_user (comp, client)) && @@ -1675,7 +1670,7 @@ e_calendar_view_modify_and_send (ECalComponent *comp, const gchar *uid = NULL; e_cal_component_get_uid (comp, &uid); - if (e_cal_get_object (client, uid, NULL, &icalcomp, NULL) && icalcomp) { + if (e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); @@ -1694,7 +1689,10 @@ e_calendar_view_modify_and_send (ECalComponent *comp, g_object_unref (send_comp); } } else { - g_message (G_STRLOC ": Could not update the object!"); + g_message (G_STRLOC ": Could not update the object! %s", error ? error->message : "Unknown error"); + + if (error) + g_error_free (error); } } @@ -1770,7 +1768,7 @@ e_calendar_view_move_tip (GtkWidget *widget, gint x, gint y) * Free returned pointer with g_free. **/ gchar * -e_calendar_view_get_attendees_status_info (ECalComponent *comp, ECal *client) +e_calendar_view_get_attendees_status_info (ECalComponent *comp, ECalClient *client) { struct _values { icalparameter_partstat status; @@ -1867,7 +1865,7 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data) GdkWindow *window; ECalComponent *newcomp = e_cal_component_new (); icaltimezone *zone, *default_zone; - ECal *client = NULL; + ECalClient *client = NULL; gboolean free_text = FALSE; /* Delete any stray tooltip if left */ @@ -1961,7 +1959,7 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data) if (dtstart.tzid) { zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (newcomp), dtstart.tzid); if (!zone) - e_cal_get_timezone (client, dtstart.tzid, &zone, NULL); + e_cal_client_get_timezone_sync (client, dtstart.tzid, &zone, NULL, NULL); if (!zone) zone = default_zone; @@ -2067,7 +2065,7 @@ icalcomp_contains_category (icalcomponent *icalcomp, const gchar *category) */ const gchar * -e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text) +e_calendar_view_get_icalcomponent_summary (ECalClient *client, icalcomponent *icalcomp, gboolean *free_text) { const gchar *summary; @@ -2081,11 +2079,11 @@ e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp, struct icaltimetype dtstart, dtnow; icalcomponent *item_icalcomp = NULL; - if (e_cal_get_object (ecal, + if (e_cal_client_get_object_sync (client, icalcomponent_get_uid (icalcomp), icalcomponent_get_relcalid (icalcomp), &item_icalcomp, - NULL)) { + NULL, NULL)) { dtstart = icalcomponent_get_dtstart (item_icalcomp); dtnow = icalcomponent_get_dtstart (icalcomp); diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 88ebbeea66..decfdfffbf 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -24,7 +24,7 @@ #define E_CALENDAR_VIEW_H #include <gtk/gtk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include "e-cal-model.h" #include "gnome-cal.h" #include "dialogs/comp-editor.h" @@ -210,7 +210,7 @@ void e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view); CompEditor * e_calendar_view_open_event_with_flags (ECalendarView *cal_view, - ECal *client, + ECalClient *client, icalcomponent *icalcomp, guint32 flags); @@ -218,7 +218,7 @@ void e_calendar_view_popup_event (ECalendarView *cal_view, GdkEventButton *event); void e_calendar_view_add_event (ECalendarView *cal_view, - ECal *client, + ECalClient *client, time_t dtstart, icaltimezone *default_zone, icalcomponent *icalcomp, @@ -236,12 +236,12 @@ void e_calendar_view_new_appointment_full gboolean no_past_date); void e_calendar_view_new_appointment (ECalendarView *cal_view); void e_calendar_view_edit_appointment (ECalendarView *cal_view, - ECal *client, + ECalClient *client, icalcomponent *icalcomp, EEditEventMode mode); void e_calendar_view_open_event (ECalendarView *cal_view); void e_calendar_view_modify_and_send (ECalComponent *comp, - ECal *client, + ECalClient *client, CalObjModType mod, GtkWindow *toplevel, gboolean new); @@ -253,12 +253,12 @@ void e_calendar_view_move_tip (GtkWidget *widget, gint y); const gchar * e_calendar_view_get_icalcomponent_summary - (ECal *ecal, + (ECalClient *ecal, icalcomponent *icalcomp, gboolean *free_text); gchar * e_calendar_view_get_attendees_status_info (ECalComponent *comp, - ECal *client); + ECalClient *client); void e_calendar_view_emit_user_created (ECalendarView *cal_view); diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 4aa87719fe..e7e44bab46 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -273,7 +273,7 @@ static ECalendarViewPosition e_day_view_convert_position_in_main_canvas (EDayVie gint *row_return, gint *event_num_return); static gboolean e_day_view_find_event_from_uid (EDayView *day_view, - ECal *client, + ECalClient *client, const gchar *uid, const gchar *rid, gint *day_return, @@ -2137,7 +2137,7 @@ e_day_view_update_event_label (EDayView *day_view, "text", text, NULL); - if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) + if (e_client_check_capability (E_CLIENT (event->comp_data->client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) && e_cal_util_component_has_attendee (event->comp_data->icalcomp)) set_text_as_bold (event); @@ -2172,7 +2172,7 @@ e_day_view_update_long_event_label (EDayView *day_view, if (free_text) g_free ((gchar *) summary); - if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) + if (e_client_check_capability (E_CLIENT (event->comp_data->client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) && e_cal_util_component_has_attendee (event->comp_data->icalcomp)) set_text_as_bold (event); } @@ -2225,7 +2225,7 @@ e_day_view_find_event_from_item (EDayView *day_view, see if any events with the uid exist. */ static gboolean e_day_view_find_event_from_uid (EDayView *day_view, - ECal *client, + ECalClient *client, const gchar *uid, const gchar *rid, gint *day_return, @@ -3475,9 +3475,7 @@ e_day_view_on_event_click (EDayView *day_view, !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) && (pos == E_CALENDAR_VIEW_POS_TOP_EDGE || pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE)) { - gboolean read_only = FALSE; - - if (event && (!event->is_editable || (e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && read_only))) { + if (event && (!event->is_editable || e_client_is_readonly (E_CLIENT (event->comp_data->client)))) { return; } @@ -3936,11 +3934,10 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget, gtk_target_list_unref (target_list); } } else { - gboolean read_only = FALSE; cursor = day_view->normal_cursor; /* Check if the event is editable and client is not readonly while changing the cursor */ - if (event && event->is_editable && is_comp_data_valid (event) && e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && !read_only) { + if (event && event->is_editable && is_comp_data_valid (event) && !e_client_is_readonly (E_CLIENT (event->comp_data->client))) { switch (pos) { case E_CALENDAR_VIEW_POS_LEFT_EDGE: @@ -4119,7 +4116,6 @@ e_day_view_update_resize (EDayView *day_view, EDayViewEvent *event; gint day, event_num; gboolean need_reshape = FALSE; - gboolean read_only = FALSE; #if 0 g_print ("Updating resize Row:%i\n", row); @@ -4137,7 +4133,7 @@ e_day_view_update_resize (EDayView *day_view, event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - if (event && (!event->is_editable || !is_comp_data_valid (event) || (e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && read_only))) { + if (event && (!event->is_editable || !is_comp_data_valid (event) || e_client_is_readonly (E_CLIENT (event->comp_data->client)))) { return; } @@ -4175,7 +4171,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view) ECalComponentDateTime date; struct icaltimetype itt; time_t dt; - ECal *client; + ECalClient *client; CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; gint is_date; @@ -4290,7 +4286,7 @@ e_day_view_finish_resize (EDayView *day_view) ECalComponentDateTime date; struct icaltimetype itt; time_t dt; - ECal *client; + ECalClient *client; CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; @@ -5062,7 +5058,7 @@ static gboolean e_day_view_add_new_event_in_selected_range (EDayView *day_view, GdkEventKey *key_event) { icalcomponent *icalcomp; - ECal *ecal; + ECalClient *client; ECalModel *model; ECalComponent *comp; gint day, event_num; @@ -5071,12 +5067,11 @@ e_day_view_add_new_event_in_selected_range (EDayView *day_view, GdkEventKey *key struct icaltimetype start_tt, end_tt; const gchar *uid; AddEventData add_event_data; - gboolean read_only = TRUE; /* Check if the client is read only */ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); - ecal = e_cal_model_get_default_client (model); - if (!e_cal_is_read_only (ecal, &read_only, NULL) || read_only) + client = e_cal_model_get_default_client (model); + if (e_client_is_readonly (E_CLIENT (client))) return FALSE; icalcomp = e_cal_model_create_component_with_defaults (model, day_view->selection_in_top_canvas); @@ -5128,7 +5123,7 @@ e_day_view_add_new_event_in_selected_range (EDayView *day_view, GdkEventKey *key gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->main_canvas); - if (!e_day_view_find_event_from_uid (day_view, ecal, uid, NULL, &day, &event_num)) { + if (!e_day_view_find_event_from_uid (day_view, client, uid, NULL, &day, &event_num)) { g_warning ("Couldn't find event to start editing.\n"); g_object_unref (comp); return FALSE; @@ -5980,7 +5975,6 @@ e_day_view_start_editing_event (EDayView *day_view, EDayViewEvent *event; ETextEventProcessor *event_processor = NULL; ETextEventProcessorCommand command; - gboolean read_only; #if 0 g_print ("In e_day_view_start_editing_event\n"); @@ -6008,7 +6002,7 @@ e_day_view_start_editing_event (EDayView *day_view, if (!is_comp_data_valid (event)) return; - if (!e_cal_is_read_only (event->comp_data->client, &read_only, NULL) || read_only) + if (e_client_is_readonly (E_CLIENT (event->comp_data->client))) return; /* If the event is not shown, don't try to edit it. */ @@ -6416,7 +6410,7 @@ e_day_view_change_event_time (EDayView *day_view, time_t start_dt, time_t end_dt ECalComponent *comp; ECalComponentDateTime date; struct icaltimetype itt; - ECal *client; + ECalClient *client; CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; @@ -6643,7 +6637,7 @@ e_day_view_on_editing_stopped (EDayView *day_view, gchar *text = NULL; ECalComponentText summary; ECalComponent *comp; - ECal *client; + ECalClient *client; gboolean on_server; /* Note: the item we are passed here isn't reliable, so we just stop @@ -6728,11 +6722,21 @@ e_day_view_on_editing_stopped (EDayView *day_view, e_cal_component_commit_sequence (comp); if (!on_server) { - if (!e_cal_create_object (client, icalcomp, NULL, NULL)) - g_message (G_STRLOC ": Could not create the object!"); - else + gchar *uid = NULL; + GError *error = NULL; + + if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, &error)) { + uid = NULL; + g_debug (G_STRLOC ": Could not create the object! %s", error ? error->message : "Unknown error"); + if (error) + g_error_free (error); + } else { + icalcomponent_set_uid (icalcomp, uid); e_calendar_view_emit_user_created ( E_CALENDAR_VIEW (day_view)); + } + + g_free (uid); /* we remove the object since we either got the update from the server or failed */ e_day_view_remove_event_cb (day_view, day, event_num, NULL); @@ -7801,7 +7805,7 @@ e_day_view_on_drag_data_get (GtkWidget *widget, comp_str = icalcomponent_as_ical_string_r (vcal); if (comp_str) { - ESource *source = e_cal_get_source (event->comp_data->client); + ESource *source = e_client_get_source (E_CLIENT (event->comp_data->client)); const gchar *source_uid = e_source_peek_uid (source); GdkAtom target; gchar *tmp; @@ -7841,7 +7845,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, struct icaltimetype itt; time_t dt; gboolean all_day_event; - ECal *client; + ECalClient *client; ECalModel *model; ECalendarView *cal_view; gboolean drag_from_same_window; @@ -8043,7 +8047,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - e_cal_add_timezone (client, zone, NULL); + e_cal_client_add_timezone_sync (client, zone, NULL, NULL); icaltimezone_free (zone, 1); } @@ -8087,7 +8091,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, ECalComponentDateTime date; struct icaltimetype itt; time_t dt; - ECal *client; + ECalClient *client; gboolean drag_from_same_window; const guchar *data; gint format, length; @@ -8270,7 +8274,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - e_cal_add_timezone (client, zone, NULL); + e_cal_client_add_timezone_sync (client, zone, NULL, NULL); icaltimezone_free (zone, 1); } diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 8728b24283..ae1cf79d56 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -235,9 +235,6 @@ struct _EDayView { /* label showing week number in upper-left corner */ GtkWidget *week_number_label; - /* S-expression for query and the query object */ - ECalView *query; - /* The start and end of the days shown. */ time_t lower; time_t upper; diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c index c702bdfd77..11f47e6030 100644 --- a/calendar/gui/e-meeting-list-view.c +++ b/calendar/gui/e-meeting-list-view.c @@ -28,7 +28,7 @@ #include <string.h> #include <gtk/gtk.h> #include <glib/gi18n.h> -#include <libebook/e-book.h> +#include <libebook/e-book-client.h> #include <libebook/e-vcard.h> #include <libecal/e-cal-component.h> #include <libecal/e-cal-util.h> @@ -762,54 +762,54 @@ process_section (EMeetingListView *view, GList *destinations, icalparameter_role /* check if the contact is contact list which is not expanded yet */ /* we expand it by getting the list again from the server forming the query */ if (contact && e_contact_get (contact , E_CONTACT_IS_LIST)) { - EBook *book = NULL; + EBookClient *book_client = NULL; ENameSelectorDialog *dialog; ENameSelectorModel *model; EContactStore *c_store; - GList *books, *l; + GSList *clients, *l; gchar *uri = e_contact_get (contact, E_CONTACT_BOOK_URI); dialog = e_name_selector_peek_dialog (view->priv->name_selector); model = e_name_selector_dialog_peek_model (dialog); c_store = e_name_selector_model_peek_contact_store (model); - books = e_contact_store_get_books (c_store); + clients = e_contact_store_get_clients (c_store); - for (l = books; l; l = l->next) { - EBook *b = l->data; - if (g_str_equal (uri, e_book_get_uri (b))) { - book = b; + for (l = clients; l; l = l->next) { + EBookClient *b = l->data; + if (g_str_equal (uri, e_client_get_uri (E_CLIENT (b)))) { + book_client = b; break; } } - if (book) { - GList *contacts; + if (book_client) { + GSList *contacts; EContact *n_con = NULL; - gchar *qu; - EBookQuery *query; + gchar *query; - qu = g_strdup_printf ("(is \"full_name\" \"%s\")", + query = g_strdup_printf ("(is \"full_name\" \"%s\")", (gchar *) e_contact_get (contact, E_CONTACT_FULL_NAME)); - query = e_book_query_from_string (qu); - if (!e_book_get_contacts (book, query, &contacts, NULL)) { + if (!e_book_client_get_contacts_sync (book_client, query, &contacts, NULL, NULL)) { g_warning ("Could not get contact from the book \n"); + g_free (query); + g_slist_free (clients); return; } else { des = e_destination_new (); n_con = contacts->data; e_destination_set_contact (des, n_con, 0); + e_destination_set_client (des, book_client); list_dests = e_destination_list_get_dests (des); - g_list_foreach (contacts, (GFunc) g_object_unref, NULL); - g_list_free (contacts); + g_slist_foreach (contacts, (GFunc) g_object_unref, NULL); + g_slist_free (contacts); } - e_book_query_unref (query); - g_free (qu); + g_free (query); } - g_list_free (books); + g_slist_free (clients); } else { card_dest.next = NULL; card_dest.prev = NULL; @@ -822,31 +822,10 @@ process_section (EMeetingListView *view, GList *destinations, icalparameter_role EDestination *dest = l->data; EContact *contact; const gchar *name, *attendee = NULL; - gchar *attr = NULL, *fburi = NULL; + gchar *fburi = NULL; name = e_destination_get_name (dest); - - /* Get the field as attendee from the backend */ - if (e_cal_get_ldap_attribute (e_meeting_store_get_client (priv->store), - &attr, NULL)) { - /* FIXME this should be more general */ - if (!g_ascii_strcasecmp (attr, "icscalendar")) { - - /* FIXME: this does not work, have to use first - e_destination_use_contact () */ - contact = e_destination_get_contact (dest); - if (contact) { - attendee = e_contact_get (contact, E_CONTACT_FREEBUSY_URL); - if (!attendee) - attendee = e_contact_get (contact, E_CONTACT_CALENDAR_URI); - } - } - } - - /* If we couldn't get the attendee prior, get the email address as the default */ - if (attendee == NULL || *attendee == '\0') { - attendee = e_destination_get_email (dest); - } + attendee = e_destination_get_email (dest); if (attendee == NULL || *attendee == '\0') continue; diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c index e18c259f65..ca4df0b854 100644 --- a/calendar/gui/e-meeting-store.c +++ b/calendar/gui/e-meeting-store.c @@ -49,7 +49,7 @@ struct _EMeetingStorePrivate { GPtrArray *attendees; gint stamp; - ECal *client; + ECalClient *client; icaltimezone *zone; gint default_reminder_interval; @@ -756,9 +756,9 @@ e_meeting_store_class_init (EMeetingStoreClass *class) PROP_CLIENT, g_param_spec_object ( "client", - "Client", + "ECalClient", NULL, - E_TYPE_CAL, + E_TYPE_CAL_CLIENT, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -840,7 +840,7 @@ e_meeting_store_new (void) return g_object_new (E_TYPE_MEETING_STORE, NULL); } -ECal * +ECalClient * e_meeting_store_get_client (EMeetingStore *store) { g_return_val_if_fail (E_IS_MEETING_STORE (store), NULL); @@ -850,12 +850,12 @@ e_meeting_store_get_client (EMeetingStore *store) void e_meeting_store_set_client (EMeetingStore *store, - ECal *client) + ECalClient *client) { g_return_if_fail (E_IS_MEETING_STORE (store)); if (client != NULL) { - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); g_object_ref (client); } @@ -1454,11 +1454,11 @@ replace_string (gchar *string, const gchar *from_value, gchar *to_value) static void start_async_read (const gchar *uri, gpointer data); typedef struct { - ECal *client; + ECalClient *client; time_t startt; time_t endt; - GList *users; - GList *fb_data; + GSList *users; + GSList *fb_data; gchar *fb_uri; gchar *email; EMeetingAttendee *attendee; @@ -1469,6 +1469,21 @@ typedef struct { #define USER_SUB "%u" #define DOMAIN_SUB "%d" +static void +client_free_busy_data_cb (ECalClient *client, const GSList *ecalcomps, FreeBusyAsyncData *fbd) +{ + const GSList *iter; + + g_return_if_fail (fbd != NULL); + + for (iter = ecalcomps; iter != NULL; iter = iter->next) { + ECalComponent *comp = iter->data; + + if (comp) + fbd->fb_data = g_slist_prepend (fbd->fb_data, g_object_ref (comp)); + } +} + static gboolean freebusy_async (gpointer data) { @@ -1480,19 +1495,20 @@ freebusy_async (gpointer data) EMeetingStorePrivate *priv = fbd->store->priv; if (fbd->client) { + guint sigid; /* FIXME This a workaround for getting all the free busy * information for the users. We should be able to * get free busy asynchronously. */ g_static_mutex_lock (&mutex); priv->num_queries++; - e_cal_get_free_busy ( - fbd->client, fbd->users, fbd->startt, - fbd->endt, &(fbd->fb_data), NULL); + sigid = g_signal_connect (fbd->client, "free-busy-data", G_CALLBACK (client_free_busy_data_cb), fbd); + e_cal_client_get_free_busy_sync (fbd->client, fbd->startt, fbd->endt, fbd->users, NULL, NULL); + g_signal_handler_disconnect (fbd->client, sigid); priv->num_queries--; g_static_mutex_unlock (&mutex); - g_list_foreach (fbd->users, (GFunc) g_free, NULL); - g_list_free (fbd->users); + g_slist_foreach (fbd->users, (GFunc) g_free, NULL); + g_slist_free (fbd->users); if (fbd->fb_data != NULL) { ECalComponent *comp = fbd->fb_data->data; @@ -1623,7 +1639,7 @@ refresh_busy_periods (gpointer data) fbd->endt = icaltime_as_timet_with_zone (itt, priv->zone); fbd->qdata = qdata; - fbd->users = g_list_append (fbd->users, g_strdup (fbd->email)); + fbd->users = g_slist_append (fbd->users, g_strdup (fbd->email)); } @@ -1634,8 +1650,8 @@ refresh_busy_periods (gpointer data) thread = g_thread_create ((GThreadFunc) freebusy_async, fbd, FALSE, &error); if (!thread) { /* do clean up stuff here */ - g_list_foreach (fbd->users, (GFunc) g_free, NULL); - g_list_free (fbd->users); + g_slist_foreach (fbd->users, (GFunc) g_free, NULL); + g_slist_free (fbd->users); g_free (fbd->email); priv->refresh_idle_id = 0; diff --git a/calendar/gui/e-meeting-store.h b/calendar/gui/e-meeting-store.h index 2c863ef506..ec98bae554 100644 --- a/calendar/gui/e-meeting-store.h +++ b/calendar/gui/e-meeting-store.h @@ -24,7 +24,7 @@ #define E_MEETING_STORE_H #include <gtk/gtk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <e-util/e-util-enums.h> #include "e-meeting-attendee.h" @@ -86,9 +86,9 @@ void e_meeting_store_set_value (EMeetingStore *meeting_store, gint row, gint col, const gchar *val); -ECal * e_meeting_store_get_client (EMeetingStore *meeting_store); +ECalClient * e_meeting_store_get_client (EMeetingStore *meeting_store); void e_meeting_store_set_client (EMeetingStore *meeting_store, - ECal *client); + ECalClient *client); gint e_meeting_store_get_default_reminder_interval (EMeetingStore *meeting_store); void e_meeting_store_set_default_reminder_interval diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c index bb41412417..abc4bf9bf3 100644 --- a/calendar/gui/e-memo-list-selector.c +++ b/calendar/gui/e-memo-list-selector.c @@ -25,9 +25,9 @@ #include "e-memo-list-selector.h" #include <string.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-selection.h" -#include "calendar/common/authentication.h" #include "calendar/gui/comp-util.h" struct _EMemoListSelectorPrivate { @@ -37,23 +37,31 @@ struct _EMemoListSelectorPrivate { static gpointer parent_class; static gboolean -memo_list_selector_update_single_object (ECal *client, +memo_list_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { - gchar *uid; + gchar *uid = NULL; icalcomponent *tmp_icalcomp; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) - return e_cal_modify_object ( - client, icalcomp, CALOBJ_MOD_ALL, NULL); + if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) + return e_cal_client_modify_object_sync ( + client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL); - return e_cal_create_object (client, icalcomp, &uid, NULL); + if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) + return FALSE; + + if (uid) + icalcomponent_set_uid (icalcomp, uid); + + g_free (uid); + + return TRUE; } static gboolean -memo_list_selector_update_objects (ECal *client, +memo_list_selector_update_objects (ECalClient *client, icalcomponent *icalcomp) { icalcomponent *subcomp; @@ -74,14 +82,19 @@ memo_list_selector_update_objects (ECal *client, kind = icalcomponent_isa (subcomp); if (kind == ICAL_VTIMEZONE_COMPONENT) { icaltimezone *zone; + GError *error = NULL; zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - success = e_cal_add_timezone (client, zone, NULL); + success = e_cal_client_add_timezone_sync (client, zone, NULL, &error); icaltimezone_free (zone, 1); - if (!success) + if (!success) { + g_debug ("%s: Failed to add timezone: %s", G_STRFUNC, error ? error->message : "Unknown error"); + if (error) + g_error_free (error); return FALSE; + } } else if (kind == ICAL_VJOURNAL_COMPONENT) { success = memo_list_selector_update_single_object ( client, subcomp); @@ -96,9 +109,36 @@ memo_list_selector_update_objects (ECal *client, return TRUE; } +static void +client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + gchar *uid = user_data; + EClient *client = NULL; + GError *error = NULL; + + g_return_if_fail (uid != NULL); + + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; + + if (error) { + g_debug ("%s: Failed to open memo list: %s", G_STRFUNC, error->message); + g_error_free (error); + } + + if (client) { + if (!e_client_is_readonly (client)) + e_cal_client_remove_object_sync (E_CAL_CLIENT (client), uid, NULL, CALOBJ_MOD_THIS, NULL, NULL); + + g_object_unref (client); + } + + g_free (uid); +} + static gboolean memo_list_selector_process_data (ESourceSelector *selector, - ECal *client, + ECalClient *client, const gchar *source_uid, icalcomponent *icalcomp, GdkDragAction action) @@ -109,7 +149,6 @@ memo_list_selector_process_data (ESourceSelector *selector, const gchar *uid; gchar *old_uid = NULL; gboolean success = FALSE; - gboolean read_only = TRUE; GError *error = NULL; /* FIXME Deal with GDK_ACTION_ASK. */ @@ -123,13 +162,13 @@ memo_list_selector_process_data (ESourceSelector *selector, if (old_uid == NULL) old_uid = g_strdup (uid); - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) { + if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) { icalcomponent_free (tmp_icalcomp); success = TRUE; goto exit; } - if (error != NULL && error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND) { + if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { g_message ( "Failed to search the object in destination " "task list: %s", error->message); @@ -137,6 +176,9 @@ memo_list_selector_process_data (ESourceSelector *selector, goto exit; } + if (error) + g_error_free (error); + success = memo_list_selector_update_objects (client, icalcomp); if (!success || action != GDK_ACTION_MOVE) @@ -148,74 +190,93 @@ memo_list_selector_process_data (ESourceSelector *selector, if (!E_IS_SOURCE (source) || e_source_get_readonly (source)) goto exit; - client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL); - if (client == NULL) { - g_message ("Cannot create source client to remove old memo"); - goto exit; - } - - e_cal_is_read_only (client, &read_only, NULL); - if (!read_only && e_cal_open (client, TRUE, NULL)) - e_cal_remove_object (client, old_uid, NULL); - else if (!read_only) - g_message ("Cannot open source client to remove old memo"); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL, + e_client_utils_authenticate_handler, NULL, + client_opened_cb, g_strdup (old_uid)); - g_object_unref (client); - -exit: + exit: g_free (old_uid); return success; } -static gboolean -memo_list_selector_data_dropped (ESourceSelector *selector, - GtkSelectionData *selection_data, - ESource *destination, - GdkDragAction action, - guint info) +struct DropData { - ECal *client; - GSList *list, *iter; - gboolean success = FALSE; + ESourceSelector *selector; + GdkDragAction action; + GSList *list; +}; - client = e_auth_new_cal_from_source ( - destination, E_CAL_SOURCE_TYPE_JOURNAL); +static void +client_opened_for_drop_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + struct DropData *dd = user_data; + EClient *client = NULL; + GError *error = NULL; - if (client == NULL || !e_cal_open (client, TRUE, NULL)) - goto exit; + g_return_if_fail (dd != NULL); - list = cal_comp_selection_get_string_list (selection_data); + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; - for (iter = list; iter != NULL; iter = iter->next) { - gchar *source_uid = iter->data; - icalcomponent *icalcomp; - gchar *component_string; + if (error) { + g_debug ("%s: Failed to open memo list: %s", G_STRFUNC, error->message); + g_error_free (error); + } - /* Each string is "source_uid\ncomponent_string". */ - component_string = strchr (source_uid, '\n'); - if (component_string == NULL) - continue; + if (client) { + ECalClient *cal_client = E_CAL_CLIENT (client); + GSList *iter; - *component_string++ = '\0'; - icalcomp = icalparser_parse_string (component_string); - if (icalcomp == NULL) - continue; + for (iter = dd->list; iter != NULL; iter = iter->next) { + gchar *source_uid = iter->data; + icalcomponent *icalcomp; + gchar *component_string; - success = memo_list_selector_process_data ( - selector, client, source_uid, icalcomp, action); + /* Each string is "source_uid\ncomponent_string". */ + component_string = strchr (source_uid, '\n'); + if (component_string == NULL) + continue; - icalcomponent_free (icalcomp); - } + *component_string++ = '\0'; + icalcomp = icalparser_parse_string (component_string); + if (icalcomp == NULL) + continue; + + memo_list_selector_process_data ( + dd->selector, cal_client, source_uid, icalcomp, dd->action); - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); + icalcomponent_free (icalcomp); + } -exit: - if (client != NULL) g_object_unref (client); + } - return success; + g_slist_foreach (dd->list, (GFunc) g_free, NULL); + g_slist_free (dd->list); + g_object_unref (dd->selector); + g_free (dd); +} + +static gboolean +memo_list_selector_data_dropped (ESourceSelector *selector, + GtkSelectionData *selection_data, + ESource *destination, + GdkDragAction action, + guint info) +{ + struct DropData *dd; + + dd = g_new0 (struct DropData, 1); + dd->selector = g_object_ref (selector); + dd->action = action; + dd->list = cal_comp_selection_get_string_list (selection_data); + + e_client_utils_open_new (destination, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL, + e_client_utils_authenticate_handler, NULL, + client_opened_for_drop_cb, dd); + + return TRUE; } static void diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index ab0ce1253d..e6396427da 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -155,7 +155,7 @@ static void memo_table_model_cal_view_progress_cb (EMemoTable *memo_table, const gchar *message, gint progress, - ECalSourceType type) + ECalClientSourceType type) { gdouble percent = (gdouble) progress; @@ -164,9 +164,8 @@ memo_table_model_cal_view_progress_cb (EMemoTable *memo_table, static void memo_table_model_cal_view_complete_cb ( EMemoTable *memo_table, - ECalendarStatus status, - const gchar *error_msg, - ECalSourceType type) + const GError *error, + ECalClientSourceType type) { memo_table_emit_status_message (memo_table, NULL, -1.0); } @@ -187,8 +186,8 @@ delete_selected_components (EMemoTable *memo_table) ECalModelComponent *comp_data = (ECalModelComponent *) l->data; GError *error = NULL; - e_cal_remove_object (comp_data->client, - icalcomponent_get_uid (comp_data->icalcomp), &error); + e_cal_client_remove_object_sync (comp_data->client, + icalcomponent_get_uid (comp_data->icalcomp), NULL, CALOBJ_MOD_THIS, NULL, &error); delete_error_dialog (error, E_CAL_COMPONENT_JOURNAL); g_clear_error (&error); } @@ -560,8 +559,8 @@ memo_table_query_tooltip (GtkWidget *widget, e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); if (!zone) - e_cal_get_timezone ( - comp_data->client, dtstart.tzid, &zone, NULL); + e_cal_client_get_timezone_sync ( + comp_data->client, dtstart.tzid, &zone, NULL, NULL); if (!zone) zone = default_zone; } else { @@ -701,12 +700,10 @@ memo_table_update_actions (ESelectable *selectable, n_selected = e_table_selected_count (E_TABLE (memo_table)); list = e_memo_table_get_selected (memo_table); - for (iter = list; iter != NULL; iter = iter->next) { + for (iter = list; iter != NULL && sources_are_editable; iter = iter->next) { ECalModelComponent *comp_data = iter->data; - gboolean read_only; - e_cal_is_read_only (comp_data->client, &read_only, NULL); - sources_are_editable &= !read_only; + sources_are_editable = sources_are_editable && !e_client_is_readonly (E_CLIENT (comp_data->client)); } g_slist_free (list); @@ -826,7 +823,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table, icalcomponent *icalcomp; gchar *uid; ECalComponent *comp; - ECal *client; + ECalClient *client; ECalModel *model; icalcomponent_kind kind; const gchar *status_message; @@ -869,6 +866,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table, child_kind == ICAL_VTODO_COMPONENT || child_kind == ICAL_VJOURNAL_COMPONENT) { ECalComponent *tmp_comp; + GError *error = NULL; uid = e_cal_component_gen_uid (); tmp_comp = e_cal_component_new (); @@ -876,31 +874,45 @@ clipboard_get_calendar_data (EMemoTable *memo_table, tmp_comp, icalcomponent_new_clone (subcomp)); e_cal_component_set_uid (tmp_comp, uid); - free (uid); + g_free (uid); + uid = NULL; /* FIXME Should we convert start/due/complete * times? Also, need error handling.*/ - e_cal_create_object ( - client, e_cal_component_get_icalcomponent (tmp_comp), - NULL, NULL); + if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (tmp_comp), &uid, NULL, &error)) + uid = NULL; + g_free (uid); g_object_unref (tmp_comp); + + if (error) { + g_debug ("%s: Failed to create object: %s", G_STRFUNC, error->message); + g_error_free (error); + } } subcomp = icalcomponent_get_next_component ( vcal_comp, ICAL_ANY_COMPONENT); } } else { + GError *error = NULL; + comp = e_cal_component_new (); e_cal_component_set_icalcomponent (comp, icalcomp); uid = e_cal_component_gen_uid (); e_cal_component_set_uid (comp, (const gchar *) uid); - free (uid); + g_free (uid); - e_cal_create_object ( - client, e_cal_component_get_icalcomponent (comp), - NULL, NULL); + uid = NULL; + if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) + uid = NULL; + g_free (uid); g_object_unref (comp); + + if (error) { + g_debug ("%s: Failed to create object: %s", G_STRFUNC, error->message); + g_error_free (error); + } } memo_table_emit_status_message (memo_table, NULL, -1.0); diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c index 6967648b1f..9d1fb5cb99 100644 --- a/calendar/gui/e-task-list-selector.c +++ b/calendar/gui/e-task-list-selector.c @@ -25,9 +25,9 @@ #include "e-task-list-selector.h" #include <string.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-selection.h" -#include "calendar/common/authentication.h" #include "calendar/gui/comp-util.h" struct _ETaskListSelectorPrivate { @@ -37,23 +37,31 @@ struct _ETaskListSelectorPrivate { static gpointer parent_class; static gboolean -task_list_selector_update_single_object (ECal *client, +task_list_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { - gchar *uid; + gchar *uid = NULL; icalcomponent *tmp_icalcomp; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) - return e_cal_modify_object ( - client, icalcomp, CALOBJ_MOD_ALL, NULL); + if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) + return e_cal_client_modify_object_sync ( + client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL); - return e_cal_create_object (client, icalcomp, &uid, NULL); + if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) + return FALSE; + + if (uid) + icalcomponent_set_uid (icalcomp, uid); + + g_free (uid); + + return TRUE; } static gboolean -task_list_selector_update_objects (ECal *client, +task_list_selector_update_objects (ECalClient *client, icalcomponent *icalcomp) { icalcomponent *subcomp; @@ -74,14 +82,19 @@ task_list_selector_update_objects (ECal *client, kind = icalcomponent_isa (subcomp); if (kind == ICAL_VTIMEZONE_COMPONENT) { icaltimezone *zone; + GError *error = NULL; zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - success = e_cal_add_timezone (client, zone, NULL); + success = e_cal_client_add_timezone_sync (client, zone, NULL, &error); icaltimezone_free (zone, 1); - if (!success) + if (!success) { + g_debug ("%s: Failed to add timezone: %s", G_STRFUNC, error ? error->message : "Unknown error"); + if (error) + g_error_free (error); return FALSE; + } } else if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) { success = task_list_selector_update_single_object ( @@ -97,9 +110,36 @@ task_list_selector_update_objects (ECal *client, return TRUE; } +static void +client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + gchar *uid = user_data; + EClient *client = NULL; + GError *error = NULL; + + g_return_if_fail (uid != NULL); + + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; + + if (error) { + g_debug ("%s: Failed to open task list: %s", G_STRFUNC, error->message); + g_error_free (error); + } + + if (client) { + if (!e_client_is_readonly (client)) + e_cal_client_remove_object_sync (E_CAL_CLIENT (client), uid, NULL, CALOBJ_MOD_THIS, NULL, NULL); + + g_object_unref (client); + } + + g_free (uid); +} + static gboolean task_list_selector_process_data (ESourceSelector *selector, - ECal *client, + ECalClient *client, const gchar *source_uid, icalcomponent *icalcomp, GdkDragAction action) @@ -110,7 +150,6 @@ task_list_selector_process_data (ESourceSelector *selector, const gchar *uid; gchar *old_uid = NULL; gboolean success = FALSE; - gboolean read_only = TRUE; GError *error = NULL; /* FIXME Deal with GDK_ACTION_ASK. */ @@ -124,13 +163,13 @@ task_list_selector_process_data (ESourceSelector *selector, if (old_uid == NULL) old_uid = g_strdup (uid); - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) { + if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) { icalcomponent_free (tmp_icalcomp); success = TRUE; goto exit; } - if (error != NULL && error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND) { + if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { g_message ( "Failed to search the object in destination " "task list: %s", error->message); @@ -138,6 +177,10 @@ task_list_selector_process_data (ESourceSelector *selector, goto exit; } + if (error) + g_error_free (error); + error = NULL; + success = task_list_selector_update_objects (client, icalcomp); if (!success || action != GDK_ACTION_MOVE) @@ -149,74 +192,93 @@ task_list_selector_process_data (ESourceSelector *selector, if (!E_IS_SOURCE (source) || e_source_get_readonly (source)) goto exit; - client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO); - if (client == NULL) { - g_message ("Cannot create source client to remove old task"); - goto exit; - } - - e_cal_is_read_only (client, &read_only, NULL); - if (!read_only && e_cal_open (client, TRUE, NULL)) - e_cal_remove_object (client, old_uid, NULL); - else if (!read_only) - g_message ("Cannot open source client to remove old task"); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL, + e_client_utils_authenticate_handler, NULL, + client_opened_cb, g_strdup (old_uid)); - g_object_unref (client); - -exit: + exit: g_free (old_uid); return success; } -static gboolean -task_list_selector_data_dropped (ESourceSelector *selector, - GtkSelectionData *selection_data, - ESource *destination, - GdkDragAction action, - guint info) +struct DropData { - ECal *client; - GSList *list, *iter; - gboolean success = FALSE; + ESourceSelector *selector; + GdkDragAction action; + GSList *list; +}; - client = e_auth_new_cal_from_source ( - destination, E_CAL_SOURCE_TYPE_TODO); +static void +client_opened_for_drop_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + struct DropData *dd = user_data; + EClient *client = NULL; + GError *error = NULL; - if (client == NULL || !e_cal_open (client, TRUE, NULL)) - goto exit; + g_return_if_fail (dd != NULL); - list = cal_comp_selection_get_string_list (selection_data); + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; - for (iter = list; iter != NULL; iter = iter->next) { - gchar *source_uid = iter->data; - icalcomponent *icalcomp; - gchar *component_string; + if (error) { + g_debug ("%s: Failed to open task list: %s", G_STRFUNC, error->message); + g_error_free (error); + } - /* Each string is "source_uid\ncomponent_string". */ - component_string = strchr (source_uid, '\n'); - if (component_string == NULL) - continue; + if (client) { + ECalClient *cal_client = E_CAL_CLIENT (client); + GSList *iter; - *component_string++ = '\0'; - icalcomp = icalparser_parse_string (component_string); - if (icalcomp == NULL) - continue; + for (iter = dd->list; iter != NULL; iter = iter->next) { + gchar *source_uid = iter->data; + icalcomponent *icalcomp; + gchar *component_string; - success = task_list_selector_process_data ( - selector, client, source_uid, icalcomp, action); + /* Each string is "source_uid\ncomponent_string". */ + component_string = strchr (source_uid, '\n'); + if (component_string == NULL) + continue; - icalcomponent_free (icalcomp); - } + *component_string++ = '\0'; + icalcomp = icalparser_parse_string (component_string); + if (icalcomp == NULL) + continue; + + task_list_selector_process_data ( + dd->selector, cal_client, source_uid, icalcomp, dd->action); - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); + icalcomponent_free (icalcomp); + } -exit: - if (client != NULL) g_object_unref (client); + } - return success; + g_slist_foreach (dd->list, (GFunc) g_free, NULL); + g_slist_free (dd->list); + g_object_unref (dd->selector); + g_free (dd); +} + +static gboolean +task_list_selector_data_dropped (ESourceSelector *selector, + GtkSelectionData *selection_data, + ESource *destination, + GdkDragAction action, + guint info) +{ + struct DropData *dd; + + dd = g_new0 (struct DropData, 1); + dd->selector = g_object_ref (selector); + dd->action = action; + dd->list = cal_comp_selection_get_string_list (selection_data); + + e_client_utils_open_new (destination, E_CLIENT_SOURCE_TYPE_TASKS, TRUE, NULL, + e_client_utils_authenticate_handler, NULL, + client_opened_for_drop_cb, dd); + + return TRUE; } static void diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c index 540ce1cc63..38b1d9ece5 100644 --- a/calendar/gui/e-task-table.c +++ b/calendar/gui/e-task-table.c @@ -233,7 +233,7 @@ static void task_table_model_cal_view_progress_cb (ETaskTable *task_table, const gchar *message, gint progress, - ECalSourceType type) + ECalClientSourceType type) { gdouble percent = (gdouble) progress; @@ -242,9 +242,8 @@ task_table_model_cal_view_progress_cb (ETaskTable *task_table, static void task_table_model_cal_view_complete_cb ( ETaskTable *task_table, - ECalendarStatus status, - const gchar *error_msg, - ECalSourceType type) + const GError *error, + ECalClientSourceType type) { task_table_emit_status_message (task_table, NULL, -1.0); } @@ -265,8 +264,7 @@ delete_selected_components (ETaskTable *task_table) ECalModelComponent *comp_data = (ECalModelComponent *) l->data; GError *error = NULL; - e_cal_remove_object (comp_data->client, - icalcomponent_get_uid (comp_data->icalcomp), &error); + e_cal_client_remove_object_sync (comp_data->client, icalcomponent_get_uid (comp_data->icalcomp), NULL, CALOBJ_MOD_THIS, NULL, &error); delete_error_dialog (error, E_CAL_COMPONENT_TODO); g_clear_error (&error); } @@ -782,8 +780,8 @@ task_table_query_tooltip (GtkWidget *widget, e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); if (!zone) - e_cal_get_timezone ( - comp_data->client, dtstart.tzid, &zone, NULL); + e_cal_client_get_timezone_sync ( + comp_data->client, dtstart.tzid, &zone, NULL, NULL); if (!zone) zone = default_zone; } else { @@ -932,12 +930,10 @@ task_table_update_actions (ESelectable *selectable, n_selected = e_table_selected_count (E_TABLE (task_table)); list = e_task_table_get_selected (task_table); - for (iter = list; iter != NULL; iter = iter->next) { + for (iter = list; iter != NULL && sources_are_editable; iter = iter->next) { ECalModelComponent *comp_data = iter->data; - gboolean read_only; - e_cal_is_read_only (comp_data->client, &read_only, NULL); - sources_are_editable &= !read_only; + sources_are_editable = sources_are_editable && !e_client_is_readonly (E_CLIENT (comp_data->client)); } g_slist_free (list); @@ -1058,7 +1054,7 @@ clipboard_get_calendar_data (ETaskTable *task_table, gchar *uid; ECalComponent *comp; ECalModel *model; - ECal *client; + ECalClient *client; icalcomponent_kind kind; const gchar *status_message; @@ -1100,6 +1096,7 @@ clipboard_get_calendar_data (ETaskTable *task_table, child_kind == ICAL_VTODO_COMPONENT || child_kind == ICAL_VJOURNAL_COMPONENT) { ECalComponent *tmp_comp; + GError *error = NULL; uid = e_cal_component_gen_uid (); tmp_comp = e_cal_component_new (); @@ -1107,31 +1104,45 @@ clipboard_get_calendar_data (ETaskTable *task_table, tmp_comp, icalcomponent_new_clone (subcomp)); e_cal_component_set_uid (tmp_comp, uid); - free (uid); + g_free (uid); + uid = NULL; /* FIXME should we convert start/due/complete * times? Also, need error handling. */ - e_cal_create_object ( - client, e_cal_component_get_icalcomponent (tmp_comp), - NULL, NULL); + if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (tmp_comp), &uid, NULL, &error)) + uid = NULL; + + if (error) { + g_debug ("%s: Failed to create object: %s", G_STRFUNC, error->message); + g_error_free (error); + } g_object_unref (tmp_comp); + g_free (uid); } subcomp = icalcomponent_get_next_component ( vcal_comp, ICAL_ANY_COMPONENT); } } else { + GError *error = NULL; + comp = e_cal_component_new (); e_cal_component_set_icalcomponent (comp, icalcomp); uid = e_cal_component_gen_uid (); e_cal_component_set_uid (comp, (const gchar *) uid); - free (uid); + g_free (uid); + uid = NULL; - e_cal_create_object ( - client, e_cal_component_get_icalcomponent (comp), - NULL, NULL); + if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) + uid = NULL; + + if (error) { + g_debug ("%s: Failed to create object: %s", G_STRFUNC, error->message); + g_error_free (error); + } g_object_unref (comp); + g_free (uid); } task_table_emit_status_message (task_table, NULL, -1.0); @@ -1228,7 +1239,7 @@ add_retract_data (ECalComponent *comp, const gchar *retract_comment) } static gboolean -check_for_retract (ECalComponent *comp, ECal *client) +check_for_retract (ECalComponent *comp, ECalClient *client) { ECalComponentOrganizer org; gchar *email = NULL; @@ -1238,15 +1249,15 @@ check_for_retract (ECalComponent *comp, ECal *client) if (!e_cal_component_has_attendees (comp)) return FALSE; - if (!e_cal_get_save_schedules (client)) + if (!e_cal_client_check_save_schedules (client)) return FALSE; e_cal_component_get_organizer (comp, &org); strip = itip_strip_mailto (org.value); ret_val = - e_cal_get_cal_address (client, &email, NULL) && - g_ascii_strcasecmp (email, strip) == 0; + e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL) && + email && g_ascii_strcasecmp (email, strip) == 0; g_free (email); @@ -1292,14 +1303,13 @@ task_table_delete_selection (ESelectable *selectable) comp, &retract_comment, GTK_WIDGET (task_table), &retract); if (retract) { - GList *users = NULL; + GSList *users = NULL; icalcomponent *icalcomp = NULL, *mod_comp = NULL; add_retract_data (comp, retract_comment); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_send_objects (comp_data->client, icalcomp, &users, - &mod_comp, &error)) { + if (!e_cal_client_send_objects_sync (comp_data->client, icalcomp, &users, &mod_comp, NULL, &error)) { delete_error_dialog (error, E_CAL_COMPONENT_TODO); g_clear_error (&error); error = NULL; @@ -1309,8 +1319,8 @@ task_table_delete_selection (ESelectable *selectable) icalcomponent_free (mod_comp); if (users) { - g_list_foreach (users, (GFunc) g_free, NULL); - g_list_free (users); + g_slist_foreach (users, (GFunc) g_free, NULL); + g_slist_free (users); } } @@ -1596,17 +1606,21 @@ hide_completed_rows (ECalModel *model, gchar *hide_sexp, GPtrArray *comp_objects) { - GList *l, *m, *objects; - ECal *client; + GList *l; + GSList *m, *objects; + ECalClient *client; gint pos; gboolean changed = FALSE; for (l = clients_list; l != NULL; l = l->next) { - client = l->data; + GError *error = NULL; - if (!e_cal_get_object_list (client, hide_sexp, &objects, NULL)) { - g_warning (G_STRLOC ": Could not get the objects"); + client = l->data; + if (!e_cal_client_get_object_list_sync (client, hide_sexp, &objects, NULL, &error)) { + g_debug ("%s: Could not get the objects: %s", G_STRFUNC, error ? error->message : "Unknown error"); + if (error) + g_error_free (error); continue; } @@ -1635,8 +1649,8 @@ hide_completed_rows (ECalModel *model, g_object_unref (comp); } - g_list_foreach (objects, (GFunc) icalcomponent_free, NULL); - g_list_free (objects); + g_slist_foreach (objects, (GFunc) icalcomponent_free, NULL); + g_slist_free (objects); } if (changed) { @@ -1652,15 +1666,19 @@ show_completed_rows (ECalModel *model, gchar *show_sexp, GPtrArray *comp_objects) { - GList *l, *m, *objects; - ECal *client; + GList *l; + GSList *m, *objects; + ECalClient *client; for (l = clients_list; l != NULL; l = l->next) { - client = l->data; + GError *error = NULL; - if (!e_cal_get_object_list (client, show_sexp, &objects, NULL)) { - g_warning (G_STRLOC ": Could not get the objects"); + client = l->data; + if (!e_cal_client_get_object_list_sync (client, show_sexp, &objects, NULL, &error)) { + g_debug ("%s: Could not get the objects: %s", G_STRFUNC, error ? error->message : "Unknown error"); + if (error) + g_error_free (error); continue; } @@ -1697,6 +1715,9 @@ show_completed_rows (ECalModel *model, e_cal_component_free_id (id); g_object_unref (comp); } + + g_slist_foreach (objects, (GFunc) icalcomponent_free, NULL); + g_slist_free (objects); } } diff --git a/calendar/gui/e-timezone-entry.h b/calendar/gui/e-timezone-entry.h index 6c0cd1dc6b..59d2c00cb1 100644 --- a/calendar/gui/e-timezone-entry.h +++ b/calendar/gui/e-timezone-entry.h @@ -33,7 +33,7 @@ #define E_TIMEZONE_ENTRY_H #include <gtk/gtk.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> /* Standard GObject macros */ #define E_TYPE_TIMEZONE_ENTRY \ diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index d6f430f2a1..47f03a9fa2 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -148,7 +148,7 @@ static void e_week_view_on_editing_started (EWeekView *week_view, static void e_week_view_on_editing_stopped (EWeekView *week_view, GnomeCanvasItem *item); static gboolean e_week_view_find_event_from_uid (EWeekView *week_view, - ECal *client, + ECalClient *client, const gchar *uid, const gchar *rid, gint *event_num_return); @@ -708,7 +708,6 @@ e_week_view_init (EWeekView *week_view) gtk_widget_set_can_focus (GTK_WIDGET (week_view), TRUE); - week_view->query = NULL; week_view->event_destroyed = FALSE; week_view->events = g_array_new (FALSE, FALSE, sizeof (EWeekViewEvent)); @@ -875,13 +874,6 @@ e_week_view_dispose (GObject *object) week_view->events = NULL; } - if (week_view->query) { - g_signal_handlers_disconnect_matched (week_view->query, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, week_view); - g_object_unref (week_view->query); - week_view->query = NULL; - } - if (week_view->small_font_desc) { pango_font_description_free (week_view->small_font_desc); week_view->small_font_desc = NULL; @@ -3018,7 +3010,7 @@ tooltip_event_cb (GnomeCanvasItem *item, } static const gchar * -get_comp_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text) +get_comp_summary (ECalClient *client, icalcomponent *icalcomp, gboolean *free_text) { const gchar *my_summary, *location; const gchar *summary; @@ -3026,7 +3018,7 @@ get_comp_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text) g_return_val_if_fail (icalcomp != NULL && free_text != NULL, NULL); - my_summary = e_calendar_view_get_icalcomponent_summary (ecal, icalcomp, &my_free_text); + my_summary = e_calendar_view_get_icalcomponent_summary (client, icalcomp, &my_free_text); location = icalcomponent_get_location (icalcomp); if (location && *location) { @@ -3172,7 +3164,7 @@ e_week_view_reshape_event_span (EWeekView *week_view, if (free_text) g_free ((gchar *) summary); - if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) + if (e_client_check_capability (E_CLIENT (event->comp_data->client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) && e_cal_util_component_has_attendee (event->comp_data->icalcomp)) { set_text_as_bold (event, span); } @@ -3335,7 +3327,6 @@ e_week_view_start_editing_event (EWeekView *week_view, ETextEventProcessor *event_processor = NULL; ETextEventProcessorCommand command; ECalModelComponent *comp_data; - gboolean read_only; /* If we are already editing the event, just return. */ if (event_num == week_view->editing_event_num @@ -3356,7 +3347,7 @@ e_week_view_start_editing_event (EWeekView *week_view, span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num); - if (!e_cal_is_read_only (event->comp_data->client, &read_only, NULL) || read_only) + if (e_client_is_readonly (E_CLIENT (event->comp_data->client))) return FALSE; /* If the event is not shown, don't try to edit it. */ @@ -3814,7 +3805,7 @@ e_week_view_change_event_time (EWeekView *week_view, time_t start_dt, time_t end ECalComponent *comp; ECalComponentDateTime date; struct icaltimetype itt; - ECal *client; + ECalClient *client; CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; @@ -3924,7 +3915,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view, gchar *text = NULL; ECalComponent *comp; ECalComponentText summary; - ECal *client; + ECalClient *client; const gchar *uid; gboolean on_server; @@ -4003,11 +3994,24 @@ e_week_view_on_editing_stopped (EWeekView *week_view, e_cal_component_commit_sequence (comp); if (!on_server) { - if (!e_cal_create_object (client, icalcomp, NULL, NULL)) - g_message (G_STRLOC ": Could not create the object!"); - else + gchar *uid = NULL; + GError *error = NULL; + + if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, &error)) { + g_message (G_STRLOC ": Could not create the object! %s", error ? error->message : "Unknown error"); + uid = NULL; + } else { + if (uid) + icalcomponent_set_uid (icalcomp, uid); + e_calendar_view_emit_user_created ( E_CALENDAR_VIEW (week_view)); + } + + if (uid) + g_free (uid); + if (error) + g_error_free (error); /* we remove the object since we either got the update from the server or failed */ e_week_view_remove_event_cb (week_view, event_num, NULL); @@ -4130,7 +4134,7 @@ e_week_view_find_event_from_item (EWeekView *week_view, see if any events with the uid exist. */ static gboolean e_week_view_find_event_from_uid (EWeekView *week_view, - ECal *client, + ECalClient *client, const gchar *uid, const gchar *rid, gint *event_num_return) @@ -4256,7 +4260,7 @@ e_week_view_cursor_key_right (EWeekView *week_view) static gboolean e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar *initial_text) { - ECal *ecal; + ECalClient *client; ECalModel *model; ECalComponent *comp; icalcomponent *icalcomp; @@ -4266,14 +4270,13 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar * time_t dtstart, dtend; const gchar *uid; AddEventData add_event_data; - gboolean read_only = TRUE; EWeekViewEvent *wvevent; EWeekViewEventSpan *span; /* Check if the client is read only */ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)); - ecal = e_cal_model_get_default_client (model); - if (!e_cal_is_read_only (ecal, &read_only, NULL) || read_only) + client = e_cal_model_get_default_client (model); + if (e_client_is_readonly (E_CLIENT (client))) return FALSE; /* Add a new event covering the selected range. */ @@ -4316,7 +4319,7 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar * e_week_view_check_layout (week_view); gtk_widget_queue_draw (week_view->main_canvas); - if (!e_week_view_find_event_from_uid (week_view, ecal, uid, NULL, &event_num)) { + if (!e_week_view_find_event_from_uid (week_view, client, uid, NULL, &event_num)) { g_warning ("Couldn't find event to start editing.\n"); g_object_unref (comp); return FALSE; diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 3f65149f19..9525b87c02 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -185,9 +185,6 @@ struct _EWeekView { GtkWidget *vscrollbar; - /* The query object */ - ECalView *query; - /* The array of EWeekViewEvent elements. */ GArray *events; gboolean events_sorted; diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index ffbc449584..78721bf214 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -38,7 +38,9 @@ #include <libedataserver/e-categories.h> #include <libedataserver/e-url.h> #include <libedataserverui/e-passwords.h> +#include <libedataserverui/e-client-utils.h> +#include <libecal/e-cal-client-view.h> #include <libecal/e-cal-time-util.h> #include <widgets/menus/gal-view-factory-etable.h> #include <widgets/menus/gal-view-etable.h> @@ -63,7 +65,6 @@ #include "tag-calendar.h" #include "misc.h" #include "ea-calendar.h" -#include "common/authentication.h" #include "e-memo-table.h" #include "e-task-table.h" @@ -290,7 +291,7 @@ static void view_progress_cb (ECalModel *model, const gchar *message, gint percent, - ECalSourceType type, + ECalClientSourceType type, GnomeCalendar *gcal) { gcal_update_status_message (gcal, message, percent); @@ -298,9 +299,8 @@ view_progress_cb (ECalModel *model, static void view_complete_cb (ECalModel *model, - ECalendarStatus status, - const gchar *error_msg, - ECalSourceType type, + const GError *error, + ECalClientSourceType type, GnomeCalendar *gcal) { gcal_update_status_message (gcal, NULL, -1); @@ -752,11 +752,11 @@ ensure_dates_are_in_default_zone (GnomeCalendar *gcal, /* Callback used when the calendar query reports of an updated object */ static void -dn_e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer data) +dn_client_view_objects_added_cb (ECalClientView *view, const GSList *objects, gpointer data) { GnomeCalendar *gcal; GnomeCalendarPrivate *priv; - GList *l; + const GSList *l; gcal = GNOME_CALENDAR (data); priv = gcal->priv; @@ -774,14 +774,14 @@ dn_e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer data) tag_calendar_by_comp ( priv->date_navigator, comp, - e_cal_view_get_client (query), + e_cal_client_view_get_client (view), NULL, FALSE, TRUE, TRUE); g_object_unref (comp); } } static void -dn_e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer data) +dn_client_view_objects_modified_cb (ECalClientView *view, const GSList *objects, gpointer data) { GnomeCalendar *gcal; @@ -796,7 +796,7 @@ dn_e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer dat /* Callback used when the calendar query reports of a removed object */ static void -dn_e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer data) +dn_client_view_objects_removed_cb (ECalClientView *view, const GSList *ids, gpointer data) { GnomeCalendar *gcal; @@ -808,17 +808,11 @@ dn_e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer data) /* Callback used when the calendar query is done */ static void -dn_e_cal_view_complete_cb (ECalView *query, - ECalendarStatus status, - const gchar *error_msg, - gpointer data) +dn_client_view_complete_cb (ECalClientView *query, const GError *error, gpointer data) { /* FIXME Better error reporting */ - if (status != E_CALENDAR_STATUS_OK) - g_warning ( - G_STRLOC ": Query did not successfully complete, " - "code: %d (%s)", status, error_msg ? error_msg : - "Unknown error"); + if (error) + g_debug ("%s: Query did not complete successfully: %s", G_STRFUNC, error->message); } ECalendarView * @@ -1009,7 +1003,7 @@ get_date_navigator_range (GnomeCalendar *gcal, time_t *start_time, time_t *end_t /* Adjusts a given query sexp with the time range of the date navigator */ static gchar * -adjust_e_cal_view_sexp (GnomeCalendar *gcal, const gchar *sexp) +adjust_client_view_sexp (GnomeCalendar *gcal, const gchar *sexp) { time_t start_time, end_time; gchar *start, *end; @@ -1058,9 +1052,7 @@ free_dn_queries (GnomeCalendar *gcal) for (l = priv->dn_queries; l != NULL; l = l->next) { if (!l->data) continue; - g_signal_handlers_disconnect_matched ( - l->data, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, gcal); + g_signal_handlers_disconnect_matched (l->data, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal); g_object_unref (l->data); } @@ -1075,7 +1067,7 @@ update_query_async (struct _date_query_msg *msg) { GnomeCalendar *gcal = msg->gcal; GnomeCalendarPrivate *priv; - ECalView *new_query; + ECalClientView *new_view; gchar *real_sexp; GList *list, *iter; @@ -1086,7 +1078,7 @@ update_query_async (struct _date_query_msg *msg) g_return_if_fail (priv->sexp != NULL); - real_sexp = adjust_e_cal_view_sexp (gcal, priv->sexp); + real_sexp = adjust_client_view_sexp (gcal, priv->sexp); if (!real_sexp) { return; /* No time range is set, so don't start a query */ } @@ -1096,19 +1088,19 @@ update_query_async (struct _date_query_msg *msg) /* create queries for each loaded client */ for (iter = list; iter != NULL; iter = iter->next) { - ECal *client = E_CAL (iter->data); + ECalClient *client = E_CAL_CLIENT (iter->data); GError *error = NULL; gint tries = 0; /* don't create queries for clients not loaded yet */ - if (e_cal_get_load_state (client) != E_CAL_LOAD_LOADED) + if (!e_client_is_opened (E_CLIENT (client))) continue; -try_again: - new_query = NULL; - if (!e_cal_get_query (client, real_sexp, &new_query, &error)) { + try_again: + new_view = NULL; + if (!e_cal_client_get_view_sync (client, real_sexp, &new_view, NULL, &error)) { /* If calendar is busy try again for 3 times. */ - if (error->code == E_CALENDAR_STATUS_BUSY && tries != 10) { + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY) && tries != 10) { tries++; /*TODO chose an optimal value */ g_usleep (500); @@ -1117,24 +1109,28 @@ try_again: goto try_again; } - g_warning (G_STRLOC ": Could not create the query: %s ", error->message); + g_warning (G_STRLOC ": Could not create the view: %s ", error->message); g_clear_error (&error); continue; } - g_signal_connect (new_query, "objects_added", - G_CALLBACK (dn_e_cal_view_objects_added_cb), gcal); - g_signal_connect (new_query, "objects_modified", - G_CALLBACK (dn_e_cal_view_objects_modified_cb), gcal); - g_signal_connect (new_query, "objects_removed", - G_CALLBACK (dn_e_cal_view_objects_removed_cb), gcal); - g_signal_connect (new_query, "view_complete", - G_CALLBACK (dn_e_cal_view_complete_cb), gcal); + g_signal_connect (new_view, "objects-added", + G_CALLBACK (dn_client_view_objects_added_cb), gcal); + g_signal_connect (new_view, "objects-modified", + G_CALLBACK (dn_client_view_objects_modified_cb), gcal); + g_signal_connect (new_view, "objects-removed", + G_CALLBACK (dn_client_view_objects_removed_cb), gcal); + g_signal_connect (new_view, "complete", + G_CALLBACK (dn_client_view_complete_cb), gcal); g_mutex_lock (priv->dn_query_lock); - priv->dn_queries = g_list_append (priv->dn_queries, new_query); - e_cal_view_start (new_query); + priv->dn_queries = g_list_append (priv->dn_queries, new_view); + e_cal_client_view_start (new_view, &error); + if (error) { + g_debug ("%s: Failed to start view: %s", G_STRFUNC, error->message); + g_clear_error (&error); + } g_mutex_unlock (priv->dn_query_lock); } @@ -2221,15 +2217,17 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) /* FIXME Confirm expunge */ clients = e_cal_model_get_client_list (gnome_calendar_get_model (gcal)); for (l = clients; l != NULL; l = l->next) { - ECal *client = l->data; - GList *objects, *m; - gboolean read_only; + ECalClient *client = l->data; + GSList *objects, *m; + GError *error = NULL; - if (!e_cal_is_read_only (client, &read_only, NULL) || read_only) + if (e_client_is_readonly (E_CLIENT (client))) continue; - if (!e_cal_get_object_list (client, sexp, &objects, NULL)) { - g_warning (G_STRLOC ": Could not get the objects"); + if (!e_cal_client_get_object_list_sync (client, sexp, &objects, NULL, &error)) { + g_warning (G_STRLOC ": Could not get the objects: %s", error ? error->message : "Unknown error"); + if (error) + g_error_free (error); continue; } @@ -2240,16 +2238,15 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) /* FIXME write occur-before and occur-after * sexp funcs so we don't have to use the max * gint */ - if (!e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) { + if (!e_cal_client_check_recurrences_no_master (client)) { struct purge_data pd; pd.remove = TRUE; pd.older_than = older_than; - e_cal_generate_instances_for_object (client, m->data, + e_cal_client_generate_instances_for_object (client, m->data, older_than, G_MAXINT32, - (ECalRecurInstanceFn) check_instance_cb, + check_instance_cb, &pd); remove = pd.remove; @@ -2270,23 +2267,21 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) if (!icaltime_is_null_time (recur_id) ) rid = icaltime_as_ical_string_r (recur_id); - e_cal_remove_object_with_mod ( - client, uid, rid, - CALOBJ_MOD_ALL, &error); + e_cal_client_remove_object_sync (client, uid, rid, CALOBJ_MOD_ALL, NULL, &error); g_free (rid); } else { - e_cal_remove_object (client, uid, &error); + e_cal_client_remove_object_sync (client, uid, NULL, CALOBJ_MOD_THIS, NULL, &error); } if (error) { - g_warning ("Unable to purge events %s \n", error->message); + g_debug ("%s: Unable to purge events: %s", G_STRFUNC, error->message); g_error_free (error); } } } - g_list_foreach (objects, (GFunc) icalcomponent_free, NULL); - g_list_free (objects); + g_slist_foreach (objects, (GFunc) icalcomponent_free, NULL); + g_slist_free (objects); } g_list_free (clients); diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 92f6f3ad36..6657b8efe3 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -30,7 +30,7 @@ #include <time.h> #include <gtk/gtk.h> #include <misc/e-calendar.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include "e-cal-model.h" diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 4d56645b38..d095d4ecbe 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -157,14 +157,14 @@ itip_address_is_user (const gchar *address) gboolean itip_organizer_is_user (ECalComponent *comp, - ECal *client) + ECalClient *cal_client) { - return itip_organizer_is_user_ex (comp, client, FALSE); + return itip_organizer_is_user_ex (comp, cal_client, FALSE); } gboolean itip_organizer_is_user_ex (ECalComponent *comp, - ECal *client, + ECalClient *cal_client, gboolean skip_cap_test) { ECalComponentOrganizer organizer; @@ -172,8 +172,8 @@ itip_organizer_is_user_ex (ECalComponent *comp, gboolean user_org = FALSE; if (!e_cal_component_has_organizer (comp) || - (!skip_cap_test && e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_NO_ORGANIZER))) + (!skip_cap_test && e_client_check_capability ( + E_CLIENT (cal_client), CAL_STATIC_CAPABILITY_NO_ORGANIZER))) return FALSE; e_cal_component_get_organizer (comp, &organizer); @@ -181,11 +181,10 @@ itip_organizer_is_user_ex (ECalComponent *comp, strip = itip_strip_mailto (organizer.value); - if (e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) { + if (e_client_check_capability (E_CLIENT (cal_client), CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) { gchar *email = NULL; - if (e_cal_get_cal_address (client, &email, NULL) && + if (e_client_get_backend_property_sync (E_CLIENT (cal_client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL) && !g_ascii_strcasecmp (email, strip)) { g_free (email); @@ -204,15 +203,15 @@ itip_organizer_is_user_ex (ECalComponent *comp, gboolean itip_sentby_is_user (ECalComponent *comp, - ECal *client) + ECalClient *cal_client) { ECalComponentOrganizer organizer; const gchar *strip; gboolean user_sentby = FALSE; if (!e_cal_component_has_organizer (comp) || - e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_NO_ORGANIZER)) + e_client_check_capability ( + E_CLIENT (cal_client), CAL_STATIC_CAPABILITY_NO_ORGANIZER)) return FALSE; e_cal_component_get_organizer (comp, &organizer); @@ -277,7 +276,7 @@ html_new_lines_for (const gchar *string) gchar * itip_get_comp_attendee (ECalComponent *comp, - ECal *client) + ECalClient *cal_client) { GSList *attendees; EAccountList *al; @@ -289,8 +288,8 @@ itip_get_comp_attendee (ECalComponent *comp, e_cal_component_get_attendee_list (comp, &attendees); al = e_get_account_list (); - if (client) - e_cal_get_cal_address (client, &address, NULL); + if (cal_client) + e_client_get_backend_property_sync (E_CLIENT (cal_client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &address, NULL, NULL); if (address && *address) { attendee = get_attendee (attendees, address); @@ -386,7 +385,7 @@ get_label (struct icaltimetype *tt, typedef struct { GHashTable *tzids; icalcomponent *icomp; - ECal *client; + ECalClient *client; icalcomponent *zones; } ItipUtilTZData; @@ -409,7 +408,7 @@ foreach_tzid_callback (icalparameter *param, gpointer data) if (zone == NULL) zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (zone == NULL && tz_data->client != NULL) - e_cal_get_timezone (tz_data->client, tzid, &zone, NULL); + e_cal_client_get_timezone_sync (tz_data->client, tzid, &zone, NULL, NULL); if (zone == NULL) return; @@ -426,7 +425,7 @@ foreach_tzid_callback (icalparameter *param, gpointer data) static icalcomponent * comp_toplevel_with_zones (ECalComponentItipMethod method, ECalComponent *comp, - ECal *client, + ECalClient *cal_client, icalcomponent *zones) { icalcomponent *top_level, *icomp; @@ -446,7 +445,7 @@ comp_toplevel_with_zones (ECalComponentItipMethod method, tz_data.tzids = g_hash_table_new (g_str_hash, g_str_equal); tz_data.icomp = top_level; - tz_data.client = client; + tz_data.client = cal_client; tz_data.zones = zones; icalcomponent_foreach_tzid (icomp, foreach_tzid_callback, &tz_data); g_hash_table_destroy (tz_data.tzids); @@ -457,10 +456,10 @@ comp_toplevel_with_zones (ECalComponentItipMethod method, } static gboolean -users_has_attendee (GList *users, +users_has_attendee (const GSList *users, const gchar *address) { - GList *l; + const GSList *l; for (l = users; l != NULL; l = l->next) { if (!g_ascii_strcasecmp (address, l->data)) @@ -525,7 +524,7 @@ comp_from (ECalComponentItipMethod method, static EDestination ** comp_to_list (ECalComponentItipMethod method, ECalComponent *comp, - GList *users, + const GSList *users, gboolean reply_all, const GSList *only_attendees) { @@ -703,7 +702,7 @@ comp_to_list (ECalComponentItipMethod method, break; case E_CAL_COMPONENT_METHOD_PUBLISH: if (users) { - GList *list; + const GSList *list; array = g_ptr_array_new (); @@ -945,19 +944,19 @@ comp_description (ECalComponent *comp, static gboolean comp_server_send (ECalComponentItipMethod method, ECalComponent *comp, - ECal *client, + ECalClient *cal_client, icalcomponent *zones, - GList **users) + GSList **users) { icalcomponent *top_level, *returned_icalcomp = NULL; gboolean retval = TRUE; GError *error = NULL; - top_level = comp_toplevel_with_zones (method, comp, client, zones); - if (!e_cal_send_objects (client, top_level, users, &returned_icalcomp, &error)) { + top_level = comp_toplevel_with_zones (method, comp, cal_client, zones); + if (!e_cal_client_send_objects_sync (cal_client, top_level, users, &returned_icalcomp, NULL, &error)) { /* FIXME Really need a book problem status code */ - if (error->code != E_CALENDAR_STATUS_OK) { - if (error->code == E_CALENDAR_STATUS_OBJECT_ID_ALREADY_EXISTS) { + if (error) { + if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS)) { e_notice ( NULL, GTK_MESSAGE_ERROR, _("Unable to book a resource, the " @@ -1051,7 +1050,7 @@ comp_limit_attendees (ECalComponent *comp) } static void -comp_sentby (ECalComponent *comp, ECal *client) +comp_sentby (ECalComponent *comp, ECalClient *cal_client) { ECalComponentOrganizer organizer; GSList * attendees, *l; @@ -1073,7 +1072,7 @@ comp_sentby (ECalComponent *comp, ECal *client) } e_cal_component_get_attendee_list (comp, &attendees); - user = itip_get_comp_attendee (comp, client); + user = itip_get_comp_attendee (comp, cal_client); for (l = attendees; l; l = l->next) { ECalComponentAttendee *a = l->data; @@ -1086,8 +1085,7 @@ comp_sentby (ECalComponent *comp, ECal *client) } } - if (!itip_organizer_is_user (comp, client) && - !itip_sentby_is_user (comp, client)) { + if (!itip_organizer_is_user (comp, cal_client) && !itip_sentby_is_user (comp, cal_client)) { EAccount *a = e_get_default_account (); organizer.value = g_strdup (organizer.value); @@ -1213,7 +1211,7 @@ strip_x_microsoft_props (ECalComponent *comp) static ECalComponent * comp_compliant (ECalComponentItipMethod method, ECalComponent *comp, - ECal *client, + ECalClient *client, icalcomponent *zones, icaltimezone *default_zone, gboolean strip_alarms) @@ -1252,7 +1250,7 @@ comp_compliant (ECalComponentItipMethod method, from_zone = icaltimezone_get_builtin_timezone_from_tzid (dt.tzid); if (from_zone == NULL && client != NULL) /* FIXME Error checking */ - e_cal_get_timezone (client, dt.tzid, &from_zone, NULL); + e_cal_client_get_timezone_sync (client, dt.tzid, &from_zone, NULL, NULL); } to_zone = icaltimezone_get_utc_timezone (); @@ -1420,7 +1418,7 @@ find_enabled_account (EAccountList *accounts, static void setup_from (ECalComponentItipMethod method, ECalComponent *comp, - ECal *client, + ECalClient *cal_client, EComposerHeaderTable *table) { EAccountList *accounts; @@ -1430,7 +1428,7 @@ setup_from (ECalComponentItipMethod method, EAccount *account = NULL; /* always use organizer's email when user is an organizer */ - if (itip_organizer_is_user (comp, client)) { + if (itip_organizer_is_user (comp, cal_client)) { ECalComponentOrganizer organizer = {0}; e_cal_component_get_organizer (comp, &organizer); @@ -1458,10 +1456,10 @@ setup_from (ECalComponentItipMethod method, gboolean itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, - ECal *client, + ECalClient *cal_client, icalcomponent *zones, GSList *attachments_list, - GList *users, + GSList *users, gboolean strip_alarms, gboolean only_new_attendees) { @@ -1490,29 +1488,29 @@ itip_send_comp (ECalComponentItipMethod method, shell_settings, "cal-use-24-hour-format"); /* check whether backend could handle auto-saving requests/updates */ - if (method != E_CAL_COMPONENT_METHOD_PUBLISH && e_cal_get_save_schedules (client)) + if (method != E_CAL_COMPONENT_METHOD_PUBLISH && e_cal_client_check_save_schedules (cal_client)) return TRUE; /* Give the server a chance to manipulate the comp */ if (method != E_CAL_COMPONENT_METHOD_PUBLISH) { - if (!comp_server_send (method, send_comp, client, zones, &users)) + if (!comp_server_send (method, send_comp, cal_client, zones, &users)) goto cleanup; } /* check whether backend could handle sending requests/updates */ if (method != E_CAL_COMPONENT_METHOD_PUBLISH && - e_cal_get_static_capability (client, + e_client_check_capability (E_CLIENT (cal_client), CAL_STATIC_CAPABILITY_CREATE_MESSAGES)) { if (users) { - g_list_foreach (users, (GFunc) g_free, NULL); - g_list_free (users); + g_slist_foreach (users, (GFunc) g_free, NULL); + g_slist_free (users); } return TRUE; } /* Tidy up the comp */ comp = comp_compliant ( - method, send_comp, client, zones, default_zone, strip_alarms); + method, send_comp, cal_client, zones, default_zone, strip_alarms); if (comp == NULL) goto cleanup; @@ -1536,7 +1534,7 @@ itip_send_comp (ECalComponentItipMethod method, composer = e_msg_composer_new (shell); table = e_msg_composer_get_header_table (composer); - setup_from (method, send_comp, client, table); + setup_from (method, send_comp, cal_client, table); e_composer_header_table_set_subject (table, subject); e_composer_header_table_set_destinations_to (table, destinations); @@ -1545,7 +1543,7 @@ itip_send_comp (ECalComponentItipMethod method, /* Content type */ content_type = comp_content_type (comp, method); - top_level = comp_toplevel_with_zones (method, comp, client, zones); + top_level = comp_toplevel_with_zones (method, comp, cal_client, zones); ical_string = icalcomponent_as_ical_string_r (top_level); if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) { @@ -1595,8 +1593,8 @@ cleanup: icalcomponent_free (top_level); if (users) { - g_list_foreach (users, (GFunc) g_free, NULL); - g_list_free (users); + g_slist_foreach (users, (GFunc) g_free, NULL); + g_slist_free (users); } g_free (content_type); @@ -1609,7 +1607,7 @@ cleanup: gboolean reply_to_calendar_comp (ECalComponentItipMethod method, ECalComponent *send_comp, - ECal *client, + ECalClient *cal_client, gboolean reply_all, icalcomponent *zones, GSList *attachments_list) @@ -1622,7 +1620,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method, ECalComponent *comp = NULL; icalcomponent *top_level = NULL; icaltimezone *default_zone; - GList *users = NULL; + GSList *users = NULL; gchar *subject = NULL; gchar *ical_string = NULL; gboolean retval = FALSE; @@ -1636,7 +1634,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method, /* Tidy up the comp */ comp = comp_compliant ( - method, send_comp, client, zones, default_zone, TRUE); + method, send_comp, cal_client, zones, default_zone, TRUE); if (comp == NULL) goto cleanup; @@ -1649,13 +1647,13 @@ reply_to_calendar_comp (ECalComponentItipMethod method, composer = e_msg_composer_new (shell); table = e_msg_composer_get_header_table (composer); - setup_from (method, send_comp, client, table); + setup_from (method, send_comp, cal_client, table); e_composer_header_table_set_subject (table, subject); e_composer_header_table_set_destinations_to (table, destinations); e_destination_freev (destinations); - top_level = comp_toplevel_with_zones (method, comp, client, zones); + top_level = comp_toplevel_with_zones (method, comp, cal_client, zones); ical_string = icalcomponent_as_ical_string_r (top_level); if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) { @@ -1703,12 +1701,15 @@ reply_to_calendar_comp (ECalComponentItipMethod method, e_cal_component_get_dtstart (comp, &dtstart); if (dtstart.value) { start_zone = icaltimezone_get_builtin_timezone_from_tzid (dtstart.tzid); - if (!start_zone) { - if (!e_cal_get_timezone (client, dtstart.tzid, &start_zone, NULL)) - g_warning ( - "Couldn't get timezone from " - "server: %s", dtstart.tzid ? - dtstart.tzid : ""); + if (!start_zone && dtstart.tzid) { + GError *error = NULL; + + if (!e_cal_client_get_timezone_sync (cal_client, dtstart.tzid, &start_zone, NULL, &error)) + g_debug ("%s: Couldn't get timezone '%s' from server: %s", G_STRFUNC, + dtstart.tzid ? dtstart.tzid : "", error ? error->message : "Unknown error"); + + if (error) + g_error_free (error); } if (!start_zone || dtstart.value->is_date) @@ -1767,8 +1768,8 @@ reply_to_calendar_comp (ECalComponentItipMethod method, icalcomponent_free (top_level); if (users) { - g_list_foreach (users, (GFunc) g_free, NULL); - g_list_free (users); + g_slist_foreach (users, (GFunc) g_free, NULL); + g_slist_free (users); } g_free (subject); @@ -1778,11 +1779,11 @@ reply_to_calendar_comp (ECalComponentItipMethod method, gboolean itip_publish_begin (ECalComponent *pub_comp, - ECal *client, + ECalClient *cal_client, gboolean cloned, ECalComponent **clone) { - icalcomponent *icomp =NULL, *icomp_clone = NULL; + icalcomponent *icomp = NULL, *icomp_clone = NULL; icalproperty *prop; if (e_cal_component_get_vtype (pub_comp) == E_CAL_COMPONENT_FREEBUSY) { @@ -1920,7 +1921,7 @@ comp_fb_normalize (icalcomponent *icomp) } gboolean -itip_publish_comp (ECal *client, +itip_publish_comp (ECalClient *cal_client, gchar *uri, gchar *username, gchar *password, diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h index c5718894fc..6da2519d07 100644 --- a/calendar/gui/itip-utils.h +++ b/calendar/gui/itip-utils.h @@ -22,7 +22,7 @@ #include <libical/ical.h> #include <string.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-component.h> #include <libedataserver/e-account-list.h> @@ -53,35 +53,35 @@ gchar ** itip_get_user_identities (void); gchar * itip_get_fallback_identity (void); gboolean itip_address_is_user (const gchar *address); gboolean itip_organizer_is_user (ECalComponent *comp, - ECal *client); + ECalClient *cal_client); gboolean itip_organizer_is_user_ex (ECalComponent *comp, - ECal *client, + ECalClient *cal_client, gboolean skip_cap_test); gboolean itip_sentby_is_user (ECalComponent *comp, - ECal *client); + ECalClient *cal_client); const gchar * itip_strip_mailto (const gchar *address); gchar * itip_get_comp_attendee (ECalComponent *comp, - ECal *client); + ECalClient *cal_client); gboolean itip_send_comp (ECalComponentItipMethod method, ECalComponent *comp, - ECal *client, + ECalClient *cal_client, icalcomponent *zones, GSList *attachments_list, - GList *users, + GSList *users, gboolean strip_alarms, gboolean only_new_attendees); -gboolean itip_publish_comp (ECal *client, +gboolean itip_publish_comp (ECalClient *cal_client, gchar *uri, gchar *username, gchar *password, ECalComponent **pub_comp); gboolean itip_publish_begin (ECalComponent *pub_comp, - ECal *client, + ECalClient *cal_client, gboolean cloned, ECalComponent **clone); gboolean reply_to_calendar_comp (ECalComponentItipMethod method, ECalComponent *send_comp, - ECal *client, + ECalClient *cal_client, gboolean reply_all, icalcomponent *zones, GSList *attachments_list); diff --git a/calendar/gui/print.c b/calendar/gui/print.c index a4d4fd61c8..702f281b5a 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -57,7 +57,7 @@ typedef struct PrintCompItem PrintCompItem; typedef struct PrintCalItem PrintCalItem; struct PrintCompItem { - ECal *client; + ECalClient *client; ECalComponent *comp; icaltimezone *zone; gboolean use_24_hour_format; @@ -2924,18 +2924,22 @@ write_label_piece (time_t t, } static icaltimezone* -get_zone_from_tzid (ECal *client, const gchar *tzid) +get_zone_from_tzid (ECalClient *client, const gchar *tzid) { icaltimezone *zone; /* Note that the timezones may not be on the server, so we try to get the builtin timezone with the TZID first. */ zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - if (!zone) { - if (!e_cal_get_timezone (client, tzid, &zone, NULL)) - /* FIXME: Handle error better. */ - g_warning ("Couldn't get timezone from server: %s", - tzid ? tzid : ""); + if (!zone && tzid) { + GError *error = NULL; + + if (!e_cal_client_get_timezone_sync (client, tzid, &zone, NULL, &error)) { + g_warning ("Couldn't get timezone '%s' from server: %s", + tzid ? tzid : "", error ? error->message : "Unknown error"); + if (error) + g_error_free (error); + } } return zone; @@ -2944,7 +2948,7 @@ get_zone_from_tzid (ECal *client, const gchar *tzid) static void print_date_label (GtkPrintContext *context, ECalComponent *comp, - ECal *client, + ECalClient *client, icaltimezone *zone, gboolean use_24_hour_format, gdouble left, @@ -3137,7 +3141,7 @@ print_comp_draw_real (GtkPrintOperation *operation, { GtkPageSetup *setup; PangoFontDescription *font; - ECal *client; + ECalClient *client; ECalComponent *comp; ECalComponentVType vtype; ECalComponentText text; @@ -3413,7 +3417,7 @@ print_comp_begin_print (GtkPrintOperation *operation, void print_comp (ECalComponent *comp, - ECal *client, + ECalClient *cal_client, icaltimezone *zone, gboolean use_24_hour_format, GtkPrintOperationAction action) @@ -3424,7 +3428,7 @@ print_comp (ECalComponent *comp, g_return_if_fail (E_IS_CAL_COMPONENT (comp)); pci.comp = comp; - pci.client = client; + pci.client = cal_client; pci.zone = zone; pci.use_24_hour_format = use_24_hour_format; diff --git a/calendar/gui/print.h b/calendar/gui/print.h index 85397b0356..b81bcfa36c 100644 --- a/calendar/gui/print.h +++ b/calendar/gui/print.h @@ -40,7 +40,7 @@ void print_calendar (GnomeCalendar *gcal, GtkPrintOperationAction action, time_t start); void print_comp (ECalComponent *comp, - ECal *client, + ECalClient *cal_client, icaltimezone *zone, gboolean use_24_hour_format, GtkPrintOperationAction action); diff --git a/calendar/gui/tag-calendar.c b/calendar/gui/tag-calendar.c index 0af271e1de..dff1285587 100644 --- a/calendar/gui/tag-calendar.c +++ b/calendar/gui/tag-calendar.c @@ -151,18 +151,18 @@ get_recur_events_italic (void) **/ void tag_calendar_by_client (ECalendar *ecal, - ECal *client) + ECalClient *client) { struct calendar_tag_closure c; g_return_if_fail (E_IS_CALENDAR (ecal)); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); /* If the ECalendar isn't visible, we just return. */ if (!gtk_widget_get_visible (GTK_WIDGET (ecal))) return; - if (e_cal_get_load_state (client) != E_CAL_LOAD_LOADED) + if (!e_client_is_opened (E_CLIENT (client))) return; if (!prepare_tag (ecal, &c, NULL, TRUE)) @@ -171,7 +171,7 @@ tag_calendar_by_client (ECalendar *ecal, c.skip_transparent_events = TRUE; c.recur_events_italic = get_recur_events_italic (); - e_cal_generate_instances ( + e_cal_client_generate_instances ( client, c.start_time, c.end_time, tag_calendar_cb, &c); } @@ -182,19 +182,25 @@ static icaltimezone* resolve_tzid_cb (const gchar *tzid, gpointer data) { - ECal *client; + ECalClient *client; icaltimezone *zone = NULL; - g_return_val_if_fail (E_IS_CAL (data), NULL); + g_return_val_if_fail (E_IS_CAL_CLIENT (data), NULL); - client = E_CAL (data); + client = E_CAL_CLIENT (data); /* Try to find the builtin timezone first. */ zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - if (!zone) { + if (!zone && tzid) { /* FIXME: Handle errors. */ - e_cal_get_timezone (client, tzid, &zone, NULL); + GError *error = NULL; + + if (!e_cal_client_get_timezone_sync (client, tzid, &zone, NULL, &error)) { + g_debug ("%s: Failed to get timezone '%s': %s", G_STRFUNC, tzid, error->message); + if (error) + g_error_free (error); + } } return zone; @@ -217,7 +223,7 @@ resolve_tzid_cb (const gchar *tzid, void tag_calendar_by_comp (ECalendar *ecal, ECalComponent *comp, - ECal *client, + ECalClient *client, icaltimezone *display_zone, gboolean clear_first, gboolean comp_is_on_server, @@ -239,7 +245,7 @@ tag_calendar_by_comp (ECalendar *ecal, c.recur_events_italic = can_recur_events_italic && get_recur_events_italic (); if (comp_is_on_server) - e_cal_generate_instances_for_object ( + e_cal_client_generate_instances_for_object ( client, e_cal_component_get_icalcomponent (comp), c.start_time, c.end_time, tag_calendar_cb, &c); else diff --git a/calendar/gui/tag-calendar.h b/calendar/gui/tag-calendar.h index ebf996173e..2dc5bff176 100644 --- a/calendar/gui/tag-calendar.h +++ b/calendar/gui/tag-calendar.h @@ -28,11 +28,11 @@ #define TAG_CALENDAR_H #include <misc/e-calendar.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> -void tag_calendar_by_client (ECalendar *ecal, ECal *client); +void tag_calendar_by_client (ECalendar *ecal, ECalClient *client); void tag_calendar_by_comp (ECalendar *ecal, ECalComponent *comp, - ECal *client, icaltimezone *display_zone, + ECalClient *client, icaltimezone *display_zone, gboolean clear_first, gboolean comp_is_on_server, gboolean can_recur_events_italic); |