diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-01-24 05:05:08 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-01-30 22:35:27 +0800 |
commit | f19241d136043d5cfffbfbaf5b2d6d1affc70682 (patch) | |
tree | 6abc10286b092dfc9b046bde599f24767ad0c177 /calendar | |
parent | e583928e0401a4baea4432c5b7e12a1b1eff8c2e (diff) | |
download | gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.tar.gz gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.tar.zst gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.zip |
Use e_cal_client_connect().
Instead of e_client_utils_open_new() or e_cal_client_new().
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/alarm-notify/alarm-notify.c | 24 | ||||
-rw-r--r-- | calendar/gui/dialogs/copy-source-dialog.c | 59 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 59 | ||||
-rw-r--r-- | calendar/gui/dialogs/memo-page.c | 58 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-page.c | 59 | ||||
-rw-r--r-- | calendar/gui/e-calendar-selector.c | 25 | ||||
-rw-r--r-- | calendar/gui/e-memo-list-selector.c | 50 | ||||
-rw-r--r-- | calendar/gui/e-task-list-selector.c | 50 | ||||
-rw-r--r-- | calendar/importers/icalendar-importer.c | 65 |
9 files changed, 240 insertions, 209 deletions
diff --git a/calendar/alarm-notify/alarm-notify.c b/calendar/alarm-notify/alarm-notify.c index ce7efee9ac..a4552a055b 100644 --- a/calendar/alarm-notify/alarm-notify.c +++ b/calendar/alarm-notify/alarm-notify.c @@ -225,17 +225,17 @@ alarm_notify_new (GCancellable *cancellable, } static void -client_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { ESource *source = E_SOURCE (source_object); AlarmNotify *an = ALARM_NOTIFY (user_data); - EClient *client = NULL; + EClient *client; ECalClient *cal_client; GError *error = NULL; - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); /* Sanity check. */ g_return_if_fail ( @@ -276,7 +276,7 @@ void alarm_notify_add_calendar (AlarmNotify *an, ESource *source) { - EClientSourceType client_source_type; + ECalClientSourceType source_type; const gchar *extension_name; g_return_if_fail (IS_ALARM_NOTIFY (an)); @@ -291,11 +291,11 @@ alarm_notify_add_calendar (AlarmNotify *an, /* Check if this is an ESource we're interested in. */ if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR)) - client_source_type = E_CLIENT_SOURCE_TYPE_EVENTS; + source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; else if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST)) - client_source_type = E_CLIENT_SOURCE_TYPE_MEMOS; + source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS; else if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST)) - client_source_type = E_CLIENT_SOURCE_TYPE_TASKS; + source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS; else { g_mutex_unlock (&an->priv->mutex); return; @@ -314,9 +314,9 @@ alarm_notify_add_calendar (AlarmNotify *an, debug (("Opening '%s' (%s)", e_source_get_display_name (source), e_source_get_uid (source))); - e_client_utils_open_new ( - source, client_source_type, TRUE, NULL, - client_opened_cb, an); + e_cal_client_connect ( + source, source_type, NULL, + client_connect_cb, an); g_mutex_unlock (&an->priv->mutex); } diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c index f8b668b933..0f0dc0545e 100644 --- a/calendar/gui/dialogs/copy-source-dialog.c +++ b/calendar/gui/dialogs/copy-source-dialog.c @@ -36,7 +36,7 @@ typedef struct { GtkWindow *parent; ESource *orig_source; - EClientSourceType obj_type; + ECalClientSourceType obj_type; ESource *selected_source; ECalClient *source_client, *dest_client; } CopySourceDialogData; @@ -99,27 +99,28 @@ free_copy_data (CopySourceDialogData *csdd) } static void -dest_source_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +dest_source_connected_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); CopySourceDialogData *csdd = user_data; - EClient *client = NULL; + EClient *client; GError *error = NULL; - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); if (error != NULL) { - g_warn_if_fail (client == NULL); show_error (csdd, _("Could not open destination"), error); g_error_free (error); free_copy_data (csdd); return; } - g_return_if_fail (E_IS_CLIENT (client)); - csdd->dest_client = E_CAL_CLIENT (client); /* check if the destination is read only */ @@ -174,32 +175,33 @@ dest_source_opened_cb (GObject *source_object, } static void -orig_source_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +orig_source_connected_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); CopySourceDialogData *csdd = user_data; - EClient *client = NULL; + EClient *client; GError *error = NULL; - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); if (error != NULL) { - g_warn_if_fail (client == NULL); show_error (csdd, _("Could not open source"), error); g_error_free (error); free_copy_data (csdd); return; } - g_return_if_fail (E_IS_CLIENT (client)); - csdd->source_client = E_CAL_CLIENT (client); - e_client_utils_open_new ( - csdd->selected_source, csdd->obj_type, FALSE, NULL, - dest_source_opened_cb, csdd); + e_cal_client_connect ( + csdd->selected_source, csdd->obj_type, NULL, + dest_source_connected_cb, csdd); } static void @@ -210,17 +212,15 @@ copy_source (const CopySourceDialogData *const_csdd) if (!const_csdd->selected_source) return; - 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, - orig_source_opened_cb, csdd); + e_cal_client_connect ( + csdd->orig_source, csdd->obj_type, NULL, + orig_source_connected_cb, csdd); } /** @@ -246,10 +246,7 @@ copy_source_dialog (GtkWindow *parent, csdd.parent = parent; csdd.orig_source = source; csdd.selected_source = NULL; - 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.obj_type = obj_type; csdd.selected_source = select_source_dialog ( parent, registry, obj_type, source); diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index c12b7c7360..6850a3b151 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -183,7 +183,7 @@ struct _EventPagePrivate { /* either with-user-time or without it */ const gint *alarm_map; - GCancellable *open_cancellable; + GCancellable *connect_cancellable; }; static void event_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); @@ -878,10 +878,10 @@ event_page_dispose (GObject *object) priv = EVENT_PAGE_GET_PRIVATE (object); - if (priv->open_cancellable) { - g_cancellable_cancel (priv->open_cancellable); - g_object_unref (priv->open_cancellable); - priv->open_cancellable = NULL; + if (priv->connect_cancellable != NULL) { + g_cancellable_cancel (priv->connect_cancellable); + g_object_unref (priv->connect_cancellable); + priv->connect_cancellable = NULL; } if (priv->location_completion != NULL) { @@ -1842,7 +1842,6 @@ event_page_init (EventPage *epage) epage->priv->alarm_interval = -1; epage->priv->alarm_map = alarm_map_with_user_time; epage->priv->location_completion = gtk_entry_completion_new (); - epage->priv->open_cancellable = NULL; } void @@ -2988,23 +2987,27 @@ event_page_send_options_clicked_cb (EventPage *epage) } static void -epage_client_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +epage_client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; EventPage *epage = user_data; EventPagePrivate *priv; CompEditor *editor; GError *error = NULL; - if (!e_client_utils_open_new_finish (source, result, &client, &error)) { - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_clear_error (&error); - return; - } + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_clear_error (&error); + return; } editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); @@ -3013,9 +3016,13 @@ epage_client_opened_cb (GObject *source_object, if (error) { GtkWidget *dialog; ECalClient *old_client; + ESource *source; old_client = comp_editor_get_client (editor); + source = e_source_combo_box_ref_active ( + E_SOURCE_COMBO_BOX (priv->source_combo_box)); + e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_combo_box), e_client_get_source (E_CLIENT (old_client))); @@ -3029,6 +3036,8 @@ epage_client_opened_cb (GObject *source_object, gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); + g_object_unref (source); + g_clear_error (&error); } else { gchar *backend_addr = NULL; @@ -3074,16 +3083,16 @@ source_changed_cb (ESourceComboBox *source_combo_box, source = e_source_combo_box_ref_active (source_combo_box); g_return_if_fail (source != NULL); - if (priv->open_cancellable) { - g_cancellable_cancel (priv->open_cancellable); - g_object_unref (priv->open_cancellable); + if (priv->connect_cancellable != NULL) { + g_cancellable_cancel (priv->connect_cancellable); + g_object_unref (priv->connect_cancellable); } - priv->open_cancellable = g_cancellable_new (); + priv->connect_cancellable = g_cancellable_new (); - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_EVENTS, - FALSE, priv->open_cancellable, - epage_client_opened_cb, epage); + e_cal_client_connect ( + source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, + priv->connect_cancellable, + epage_client_connect_cb, epage); g_object_unref (source); } diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c index d6f9d93ffc..a93068cb14 100644 --- a/calendar/gui/dialogs/memo-page.c +++ b/calendar/gui/dialogs/memo-page.c @@ -85,7 +85,7 @@ struct _MemoPagePrivate { ENameSelector *name_selector; - GCancellable *open_cancellable; + GCancellable *connect_cancellable; }; static void set_subscriber_info_string (MemoPage *mpage, const gchar *backend_address); @@ -187,10 +187,10 @@ memo_page_dispose (GObject *object) priv = MEMO_PAGE_GET_PRIVATE (object); - if (priv->open_cancellable) { - g_cancellable_cancel (priv->open_cancellable); - g_object_unref (priv->open_cancellable); - priv->open_cancellable = NULL; + if (priv->connect_cancellable != NULL) { + g_cancellable_cancel (priv->connect_cancellable); + g_object_unref (priv->connect_cancellable); + priv->connect_cancellable = NULL; } g_strfreev (priv->address_strings); @@ -941,23 +941,27 @@ categories_clicked_cb (GtkWidget *button, } static void -mpage_client_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +mpage_client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; MemoPage *mpage = user_data; MemoPagePrivate *priv; CompEditor *editor; GError *error = NULL; - if (!e_client_utils_open_new_finish (source, result, &client, &error)) { - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_clear_error (&error); - return; - } + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_clear_error (&error); + return; } editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (mpage)); @@ -966,9 +970,13 @@ mpage_client_opened_cb (GObject *source_object, if (error != NULL) { GtkWidget *dialog; ECalClient *old_client; + ESource *source; old_client = comp_editor_get_client (editor); + source = e_source_combo_box_ref_active ( + E_SOURCE_COMBO_BOX (priv->source_combo_box)); + e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_combo_box), e_client_get_source (E_CLIENT (old_client))); @@ -982,6 +990,8 @@ mpage_client_opened_cb (GObject *source_object, gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); + g_object_unref (source); + g_clear_error (&error); } else { icaltimezone *zone; @@ -1025,16 +1035,16 @@ source_changed_cb (ESourceComboBox *source_combo_box, source = e_source_combo_box_ref_active (source_combo_box); g_return_if_fail (source != NULL); - if (priv->open_cancellable) { - g_cancellable_cancel (priv->open_cancellable); - g_object_unref (priv->open_cancellable); + if (priv->connect_cancellable != NULL) { + g_cancellable_cancel (priv->connect_cancellable); + g_object_unref (priv->connect_cancellable); } - priv->open_cancellable = g_cancellable_new (); + priv->connect_cancellable = g_cancellable_new (); - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_MEMOS, - FALSE, priv->open_cancellable, - mpage_client_opened_cb, mpage); + e_cal_client_connect ( + source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, + priv->connect_cancellable, + mpage_client_connect_cb, mpage); g_object_unref (source); } diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index b8324331c8..b728b6f873 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -113,7 +113,7 @@ struct _TaskPagePrivate { ESendOptionsDialog *sod; - GCancellable *open_cancellable; + GCancellable *connect_cancellable; }; static const gint classification_map[] = { @@ -399,10 +399,10 @@ task_page_dispose (GObject *object) priv = TASK_PAGE_GET_PRIVATE (object); - if (priv->open_cancellable) { - g_cancellable_cancel (priv->open_cancellable); - g_object_unref (priv->open_cancellable); - priv->open_cancellable = NULL; + if (priv->connect_cancellable != NULL) { + g_cancellable_cancel (priv->connect_cancellable); + g_object_unref (priv->connect_cancellable); + priv->connect_cancellable = NULL; } if (priv->main != NULL) { @@ -1049,7 +1049,6 @@ task_page_init (TaskPage *tpage) { tpage->priv = TASK_PAGE_GET_PRIVATE (tpage); tpage->priv->deleted_attendees = g_ptr_array_new (); - tpage->priv->open_cancellable = NULL; } void @@ -1785,23 +1784,27 @@ due_date_changed_cb (TaskPage *tpage) } static void -tpage_client_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +tpage_client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; TaskPage *tpage = user_data; TaskPagePrivate *priv; CompEditor *editor; GError *error = NULL; - if (!e_client_utils_open_new_finish (source, result, &client, &error)) { - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_clear_error (&error); - return; - } + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_clear_error (&error); + return; } editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage)); @@ -1809,9 +1812,13 @@ tpage_client_opened_cb (GObject *source_object, if (error) { GtkWidget *dialog; ECalClient *old_client; + ESource *source; old_client = comp_editor_get_client (editor); + source = e_source_combo_box_ref_active ( + E_SOURCE_COMBO_BOX (priv->source_combo_box)); + e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_combo_box), e_client_get_source (E_CLIENT (old_client))); @@ -1825,6 +1832,8 @@ tpage_client_opened_cb (GObject *source_object, gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); + g_object_unref (source); + g_clear_error (&error); } else { icaltimezone *zone; @@ -1871,16 +1880,16 @@ source_changed_cb (ESourceComboBox *source_combo_box, source = e_source_combo_box_ref_active (source_combo_box); g_return_if_fail (source != NULL); - if (priv->open_cancellable) { - g_cancellable_cancel (priv->open_cancellable); - g_object_unref (priv->open_cancellable); + if (priv->connect_cancellable != NULL) { + g_cancellable_cancel (priv->connect_cancellable); + g_object_unref (priv->connect_cancellable); } - priv->open_cancellable = g_cancellable_new (); + priv->connect_cancellable = g_cancellable_new (); - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_TASKS, - FALSE, priv->open_cancellable, - tpage_client_opened_cb, tpage); + e_cal_client_connect ( + source, E_CAL_CLIENT_SOURCE_TYPE_TASKS, + priv->connect_cancellable, + tpage_client_connect_cb, tpage); g_object_unref (source); } diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c index 19eb4335b1..798280f852 100644 --- a/calendar/gui/e-calendar-selector.c +++ b/calendar/gui/e-calendar-selector.c @@ -117,29 +117,30 @@ calendar_selector_update_objects (ECalClient *client, } static void -client_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; icalcomponent *icalcomp = user_data; GError *error = NULL; g_return_if_fail (icalcomp != NULL); - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open client: %s", G_STRFUNC, error->message); g_error_free (error); } - g_return_if_fail (E_IS_CLIENT (client)); - calendar_selector_update_objects (E_CAL_CLIENT (client), icalcomp); g_object_unref (client); @@ -191,9 +192,9 @@ calendar_selector_data_dropped (ESourceSelector *selector, icalcomponent_set_uid (icalcomp, uid); } - e_client_utils_open_new ( - destination, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL, - client_opened_cb, icalcomp); + e_cal_client_connect ( + destination, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL, + client_connect_cb, icalcomp); success = TRUE; diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c index 366d41e702..74ca1d1b64 100644 --- a/calendar/gui/e-memo-list-selector.c +++ b/calendar/gui/e-memo-list-selector.c @@ -118,21 +118,24 @@ memo_list_selector_update_objects (ECalClient *client, } static void -client_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; gchar *uid = user_data; GError *error = NULL; g_return_if_fail (uid != NULL); - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open memo list: %s", G_STRFUNC, error->message); @@ -140,8 +143,6 @@ client_opened_cb (GObject *source_object, goto exit; } - g_return_if_fail (E_IS_CLIENT (client)); - if (!e_client_is_readonly (client)) e_cal_client_remove_object_sync ( E_CAL_CLIENT (client), uid, NULL, @@ -205,9 +206,9 @@ memo_list_selector_process_data (ESourceSelector *selector, source = e_source_registry_ref_source (registry, source_uid); if (source != NULL) { - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL, - client_opened_cb, g_strdup (old_uid)); + e_cal_client_connect ( + source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL, + client_connect_cb, g_strdup (old_uid)); g_object_unref (source); } @@ -225,23 +226,26 @@ struct DropData }; static void -client_opened_for_drop_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +client_connect_for_drop_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); struct DropData *dd = user_data; - EClient *client = NULL; + EClient *client; ECalClient *cal_client; GSList *iter; GError *error = NULL; g_return_if_fail (dd != NULL); - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open memo list: %s", G_STRFUNC, error->message); @@ -249,8 +253,6 @@ client_opened_for_drop_cb (GObject *source_object, goto exit; } - g_return_if_fail (E_IS_CLIENT (client)); - cal_client = E_CAL_CLIENT (client); for (iter = dd->list; iter != NULL; iter = iter->next) { @@ -316,9 +318,9 @@ memo_list_selector_data_dropped (ESourceSelector *selector, dd->action = action; dd->list = cal_comp_selection_get_string_list (selection_data); - e_client_utils_open_new ( - destination, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL, - client_opened_for_drop_cb, dd); + e_cal_client_connect ( + destination, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL, + client_connect_for_drop_cb, dd); return TRUE; } diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c index 0989e7436c..151967f7f4 100644 --- a/calendar/gui/e-task-list-selector.c +++ b/calendar/gui/e-task-list-selector.c @@ -119,21 +119,24 @@ task_list_selector_update_objects (ECalClient *client, } static void -client_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; gchar *uid = user_data; GError *error = NULL; g_return_if_fail (uid != NULL); - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open task list: %s", G_STRFUNC, error->message); @@ -141,8 +144,6 @@ client_opened_cb (GObject *source_object, goto exit; } - g_return_if_fail (E_IS_CLIENT (client)); - if (!e_client_is_readonly (client)) e_cal_client_remove_object_sync ( E_CAL_CLIENT (client), uid, NULL, @@ -207,9 +208,9 @@ task_list_selector_process_data (ESourceSelector *selector, source = e_source_registry_ref_source (registry, source_uid); if (source != NULL) { - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL, - client_opened_cb, g_strdup (old_uid)); + e_cal_client_connect ( + source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL, + client_connect_cb, g_strdup (old_uid)); g_object_unref (source); } @@ -227,23 +228,26 @@ struct DropData }; static void -client_opened_for_drop_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +client_connect_for_drop_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); struct DropData *dd = user_data; - EClient *client = NULL; + EClient *client; ECalClient *cal_client; GSList *iter; GError *error = NULL; g_return_if_fail (dd != NULL); - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open task list: %s", G_STRFUNC, error->message); @@ -251,8 +255,6 @@ client_opened_for_drop_cb (GObject *source_object, goto exit; } - g_return_if_fail (E_IS_CLIENT (client)); - cal_client = E_CAL_CLIENT (client); for (iter = dd->list; iter != NULL; iter = iter->next) { @@ -318,9 +320,9 @@ task_list_selector_data_dropped (ESourceSelector *selector, dd->action = action; dd->list = cal_comp_selection_get_string_list (selection_data); - e_client_utils_open_new ( - destination, E_CLIENT_SOURCE_TYPE_TASKS, TRUE, NULL, - client_opened_for_drop_cb, dd); + e_cal_client_connect ( + destination, E_CAL_CLIENT_SOURCE_TYPE_TASKS, NULL, + client_connect_for_drop_cb, dd); return TRUE; } diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c index 891dc7b226..96c10bd6ab 100644 --- a/calendar/importers/icalendar-importer.c +++ b/calendar/importers/icalendar-importer.c @@ -53,7 +53,7 @@ typedef struct { guint idle_id; ECalClient *cal_client; - EClientSourceType source_type; + ECalClientSourceType source_type; icalcomponent *icalcomp; @@ -69,8 +69,8 @@ typedef struct { } ICalIntelligentImporter; static const gint import_type_map[] = { - E_CLIENT_SOURCE_TYPE_EVENTS, - E_CLIENT_SOURCE_TYPE_TASKS, + E_CAL_CLIENT_SOURCE_TYPE_EVENTS, + E_CAL_CLIENT_SOURCE_TYPE_TASKS, -1 }; @@ -316,10 +316,10 @@ ivcal_getwidget (EImport *ei, GList *list; switch (import_type_map[i]) { - case E_CLIENT_SOURCE_TYPE_EVENTS: + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: extension_name = E_SOURCE_EXTENSION_CALENDAR; break; - case E_CLIENT_SOURCE_TYPE_TASKS: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: extension_name = E_SOURCE_EXTENSION_TASK_LIST; break; default: @@ -389,11 +389,11 @@ ivcal_import_items (gpointer d) ICalImporter *ici = d; switch (ici->source_type) { - case E_CLIENT_SOURCE_TYPE_EVENTS: + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: prepare_events (ici->icalcomp, NULL); update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici); break; - case E_CLIENT_SOURCE_TYPE_TASKS: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: prepare_tasks (ici->icalcomp, NULL); update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici); break; @@ -411,21 +411,24 @@ ivcal_import_items (gpointer d) } static void -ivcal_opened (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +ivcal_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; ICalImporter *ici = user_data; GError *error = NULL; g_return_if_fail (ici != NULL); - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open calendar: %s", G_STRFUNC, error->message); @@ -434,8 +437,6 @@ ivcal_opened (GObject *source_object, return; } - g_return_if_fail (E_IS_CLIENT (client)); - ici->cal_client = E_CAL_CLIENT (client); e_import_status (ici->import, ici->target, _("Importing..."), 0); @@ -447,7 +448,7 @@ ivcal_import (EImport *ei, EImportTarget *target, icalcomponent *icalcomp) { - EClientSourceType type; + ECalClientSourceType type; ICalImporter *ici = g_malloc0 (sizeof (*ici)); type = GPOINTER_TO_INT (g_datalist_get_data (&target->data, "primary-type")); @@ -462,9 +463,9 @@ ivcal_import (EImport *ei, ici->cancellable = g_cancellable_new (); e_import_status (ei, target, _("Opening calendar"), 0); - e_client_utils_open_new ( + e_cal_client_connect ( g_datalist_get_data (&target->data, "primary-source"), - type, FALSE, ici->cancellable, ivcal_opened, ici); + type, ici->cancellable, ivcal_connect_cb, ici); } static void @@ -833,12 +834,11 @@ struct OpenDefaultSourceData }; static void -default_source_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +default_client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; struct OpenDefaultSourceData *odsd = user_data; GError *error = NULL; @@ -846,7 +846,12 @@ default_source_opened_cb (GObject *source_object, g_return_if_fail (odsd->ici != NULL); g_return_if_fail (odsd->opened_cb != NULL); - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); /* Client may be NULL; don't use a type cast macro. */ odsd->opened_cb ((ECalClient *) client, error, odsd->ici); @@ -869,7 +874,6 @@ open_default_source (ICalIntelligentImporter *ici, EShell *shell; ESource *source; ESourceRegistry *registry; - EClientSourceType client_source_type; struct OpenDefaultSourceData *odsd; g_return_if_fail (ici != NULL); @@ -880,15 +884,12 @@ open_default_source (ICalIntelligentImporter *ici, switch (source_type) { case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: - client_source_type = E_CLIENT_SOURCE_TYPE_EVENTS; source = e_source_registry_ref_default_calendar (registry); break; case E_CAL_CLIENT_SOURCE_TYPE_TASKS: - client_source_type = E_CLIENT_SOURCE_TYPE_TASKS; source = e_source_registry_ref_default_task_list (registry); break; case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: - client_source_type = E_CLIENT_SOURCE_TYPE_MEMOS; source = e_source_registry_ref_default_memo_list (registry); break; default: @@ -901,9 +902,9 @@ open_default_source (ICalIntelligentImporter *ici, e_import_status (ici->ei, ici->target, _("Opening calendar"), 0); - e_client_utils_open_new ( - source, client_source_type, FALSE, ici->cancellable, - default_source_opened_cb, odsd); + e_cal_client_connect ( + source, source_type, ici->cancellable, + default_client_connect_cb, odsd); g_object_unref (source); } |