diff options
author | Milan Crha <mcrha@redhat.com> | 2011-06-14 14:54:20 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:27 +0800 |
commit | 84339b3be5a771406fcd5898bbd21dc1c5b98c82 (patch) | |
tree | 15a9cfd61451b56d6b35541b1b1e966a34b17faf /calendar/gui/dialogs | |
parent | fa4289a2f3c26112c907f283a1fd8ab3fb4f26d6 (diff) | |
download | gsoc2013-evolution-84339b3be5a771406fcd5898bbd21dc1c5b98c82.tar.gz gsoc2013-evolution-84339b3be5a771406fcd5898bbd21dc1c5b98c82.tar.zst gsoc2013-evolution-84339b3be5a771406fcd5898bbd21dc1c5b98c82.zip |
Do not use deprecated EBook/ECal API
Diffstat (limited to 'calendar/gui/dialogs')
34 files changed, 561 insertions, 446 deletions
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); |