From e583928e0401a4baea4432c5b7e12a1b1eff8c2e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 23 Jan 2013 14:59:41 -0500 Subject: Use e_book_client_connect(). Instead of e_client_utils_open_new() and e_book_client_new(). --- addressbook/gui/contact-editor/e-contact-editor.c | 27 +++++++++--------- .../gui/contact-editor/e-contact-quick-add.c | 33 +++++++++++----------- 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'addressbook/gui/contact-editor') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index b168b79985..a0bd221f94 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -3084,16 +3084,21 @@ init_all (EContactEditor *editor) } static void -contact_editor_book_loaded_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +contact_editor_client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { ESource *source = E_SOURCE (source_object); EContactEditor *editor = user_data; - EClient *client = NULL; + EClient *client; GError *error = NULL; - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_book_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)) { @@ -3105,8 +3110,6 @@ contact_editor_book_loaded_cb (GObject *source_object, GtkWidget *source_combo_box; GtkWindow *parent; - g_warn_if_fail (client == NULL); - parent = eab_editor_get_window (EAB_EDITOR (editor)); eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error); @@ -3119,8 +3122,6 @@ contact_editor_book_loaded_cb (GObject *source_object, goto exit; } - g_return_if_fail (E_IS_CLIENT (client)); - /* FIXME Write a private contact_editor_set_target_client(). */ g_object_set (editor, "target_client", client, NULL); @@ -3162,10 +3163,10 @@ source_changed (ESourceComboBox *source_combo_box, editor->cancellable = g_cancellable_new (); - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_CONTACTS, - FALSE, editor->cancellable, - contact_editor_book_loaded_cb, g_object_ref (editor)); + e_book_client_connect ( + source, editor->cancellable, + contact_editor_client_connect_cb, + g_object_ref (editor)); exit: g_object_unref (source); diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c index 6dcb7dc628..afbd817ac7 100644 --- a/addressbook/gui/contact-editor/e-contact-quick-add.c +++ b/addressbook/gui/contact-editor/e-contact-quick-add.c @@ -126,10 +126,15 @@ merge_cb (GObject *source_object, { ESource *source = E_SOURCE (source_object); QuickAdd *qa = user_data; - EClient *client = NULL; + EClient *client; GError *error = NULL; - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_book_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); /* Ignore cancellations. */ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || @@ -140,7 +145,6 @@ merge_cb (GObject *source_object, } if (error != NULL) { - g_warn_if_fail (client == NULL); if (qa->cb) qa->cb (NULL, qa->closure); g_error_free (error); @@ -148,8 +152,6 @@ merge_cb (GObject *source_object, return; } - g_return_if_fail (E_IS_CLIENT (client)); - if (!e_client_is_readonly (client)) eab_merging_book_add_contact ( qa->registry, E_BOOK_CLIENT (client), @@ -179,9 +181,7 @@ quick_add_merge_contact (QuickAdd *qa) qa->cancellable = g_cancellable_new (); - e_client_utils_open_new ( - qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS, - FALSE, qa->cancellable, merge_cb, qa); + e_book_client_connect (qa->source, qa->cancellable, merge_cb, qa); } /* Raise a contact editor with all fields editable, @@ -279,12 +279,16 @@ ce_have_book (GObject *source_object, GAsyncResult *result, gpointer user_data) { - ESource *source = E_SOURCE (source_object); QuickAdd *qa = user_data; - EClient *client = NULL; + EClient *client; GError *error = NULL; - e_client_utils_open_new_finish (source, result, &client, &error); + client = e_book_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); /* Ignore cancellations. */ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || @@ -295,7 +299,6 @@ ce_have_book (GObject *source_object, } if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "Couldn't open local address book (%s).", error->message); @@ -304,8 +307,6 @@ ce_have_book (GObject *source_object, return; } - g_return_if_fail (E_IS_CLIENT (client)); - eab_merging_book_find_contact ( qa->registry, E_BOOK_CLIENT (client), qa->contact, ce_have_contact, qa); @@ -321,9 +322,7 @@ edit_contact (QuickAdd *qa) qa->cancellable = g_cancellable_new (); - e_client_utils_open_new ( - qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS, - FALSE, qa->cancellable, ce_have_book, qa); + e_book_client_connect (qa->source, qa->cancellable, ce_have_book, qa); } #define QUICK_ADD_RESPONSE_EDIT_FULL 2 -- cgit v1.2.3