diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-01-24 03:59:41 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-01-30 21:37:15 +0800 |
commit | e583928e0401a4baea4432c5b7e12a1b1eff8c2e (patch) | |
tree | 786d3c1b3ed24456d88f3b8c6987755a08f310db /modules | |
parent | 5125cdac38ced3898bdd59ed29259e4c747374f7 (diff) | |
download | gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.gz gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.bz2 gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.lz gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.xz gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.zst gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.zip |
Use e_book_client_connect().
Instead of e_client_utils_open_new() and e_book_client_new().
Diffstat (limited to 'modules')
-rw-r--r-- | modules/addressbook/e-book-shell-backend.c | 34 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-actions.c | 41 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-private.c | 37 | ||||
-rw-r--r-- | modules/vcard-inline/e-mail-parser-vcard-inline.c | 25 |
4 files changed, 77 insertions, 60 deletions
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c index 3886c7f400..3cc5c9d722 100644 --- a/modules/addressbook/e-book-shell-backend.c +++ b/modules/addressbook/e-book-shell-backend.c @@ -93,18 +93,21 @@ book_shell_backend_new_contact_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { - ESource *source = E_SOURCE (source_object); EShell *shell = user_data; - EClient *client = NULL; + EClient *client; EContact *contact; EABEditor *editor; 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))); /* XXX Handle errors better. */ if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open book: %s", G_STRFUNC, error->message); @@ -112,8 +115,6 @@ book_shell_backend_new_contact_cb (GObject *source_object, goto exit; } - g_return_if_fail (E_IS_CLIENT (client)); - contact = e_contact_new (); editor = e_contact_editor_new ( @@ -133,18 +134,21 @@ book_shell_backend_new_contact_list_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { - ESource *source = E_SOURCE (source_object); EShell *shell = user_data; - EClient *client = NULL; + EClient *client; EContact *contact; EABEditor *editor; 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))); /* XXX Handle errors better. */ if (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open book: %s", G_STRFUNC, error->message); @@ -152,8 +156,6 @@ book_shell_backend_new_contact_list_cb (GObject *source_object, goto exit; } - g_return_if_fail (E_IS_CLIENT (client)); - contact = e_contact_new (); editor = e_contact_list_editor_new ( @@ -215,13 +217,13 @@ action_contact_new_cb (GtkAction *action, /* Use a callback function appropriate for the action. */ action_name = gtk_action_get_name (action); if (strcmp (action_name, "contact-new") == 0) - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL, + e_book_client_connect ( + source, NULL, book_shell_backend_new_contact_cb, g_object_ref (shell)); if (strcmp (action_name, "contact-new-list") == 0) - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL, + e_book_client_connect ( + source, NULL, book_shell_backend_new_contact_list_cb, g_object_ref (shell)); diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c index cbe2ef4e32..e4e31039da 100644 --- a/modules/addressbook/e-book-shell-view-actions.c +++ b/modules/addressbook/e-book-shell-view-actions.c @@ -234,7 +234,7 @@ map_window_show_contact_editor_cb (EContactMapWindow *window, EBookShellSidebar *book_shell_sidebar; ESource *source; ESourceSelector *selector; - EBookClient *book_client; + EClient *client; EContact *contact; EABEditor *editor; GError *error = NULL; @@ -244,26 +244,32 @@ map_window_show_contact_editor_cb (EContactMapWindow *window, source = e_source_selector_ref_primary_selection (selector); g_return_if_fail (source != NULL); - book_client = e_book_client_new (source, &error); + client = e_book_client_connect_sync (source, NULL, &error); + g_object_unref (source); - if (error) { + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); + + if (error != NULL) { g_warning ("Error loading addressbook: %s", error->message); g_error_free (error); - if (book_client) - g_object_unref (book_client); return; } - e_book_client_get_contact_sync (book_client, contact_uid, &contact, NULL, &error); - if (error) { + e_book_client_get_contact_sync ( + E_BOOK_CLIENT (client), contact_uid, &contact, NULL, &error); + if (error != NULL) { g_warning ("Error getting contact from addressbook: %s", error->message); g_error_free (error); - g_object_unref (book_client); + g_object_unref (client); return; } - editor = e_contact_editor_new (shell, book_client, contact, FALSE, TRUE); + editor = e_contact_editor_new ( + shell, E_BOOK_CLIENT (client), contact, FALSE, TRUE); g_signal_connect ( editor, "contact-modified", @@ -273,7 +279,7 @@ map_window_show_contact_editor_cb (EContactMapWindow *window, G_CALLBACK (g_object_unref), editor); eab_editor_show (editor); - g_object_unref (book_client); + g_object_unref (client); } #endif @@ -287,7 +293,7 @@ action_address_book_map_cb (GtkAction *action, EBookShellSidebar *book_shell_sidebar; ESource *source; ESourceSelector *selector; - EBookClient *book_client; + EClient *client; GError *error = NULL; book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; @@ -295,9 +301,15 @@ action_address_book_map_cb (GtkAction *action, source = e_source_selector_ref_primary_selection (selector); g_return_if_fail (source != NULL); - book_client = e_book_client_new (source, &error); + client = e_book_client_connect_sync (source, NULL, &error); + g_object_unref (source); + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); + if (error != NULL) { g_warning ("Error loading addressbook: %s", error->message); g_error_free (error); @@ -305,7 +317,8 @@ action_address_book_map_cb (GtkAction *action, } map_window = e_contact_map_window_new (); - e_contact_map_window_load_addressbook (map_window, book_client); + e_contact_map_window_load_addressbook ( + map_window, E_BOOK_CLIENT (client)); /* Free the map_window automatically when it is closed */ g_signal_connect_swapped ( @@ -317,7 +330,7 @@ action_address_book_map_cb (GtkAction *action, gtk_widget_show_all (GTK_WIDGET (map_window)); - g_object_unref (book_client); + g_object_unref (client); #endif } diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c index 884477f451..d33054e36f 100644 --- a/modules/addressbook/e-book-shell-view-private.c +++ b/modules/addressbook/e-book-shell-view-private.c @@ -205,21 +205,24 @@ model_query_changed_cb (EBookShellView *book_shell_view, } static void -book_shell_view_loaded_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +book_shell_view_client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); EAddressbookView *view = user_data; - EClient *client = NULL; + EClient *client; EAddressbookModel *model; 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, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_warn_if_fail (client == NULL); g_error_free (error); goto exit; @@ -227,9 +230,9 @@ book_shell_view_loaded_cb (GObject *source_object, EShellView *shell_view; EShellContent *shell_content; EAlertSink *alert_sink; + ESource *source; - g_warn_if_fail (client == NULL); - + source = e_addressbook_view_get_source (view); shell_view = e_addressbook_view_get_shell_view (view); shell_content = e_shell_view_get_shell_content (shell_view); alert_sink = E_ALERT_SINK (shell_content); @@ -240,8 +243,6 @@ book_shell_view_loaded_cb (GObject *source_object, goto exit; } - g_return_if_fail (E_IS_CLIENT (client)); - model = e_addressbook_view_get_model (view); e_addressbook_model_set_client (model, E_BOOK_CLIENT (client)); e_addressbook_model_force_folder_bar_message (model); @@ -287,10 +288,9 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, if (e_addressbook_model_get_client (model) == NULL) /* XXX No way to cancel this? */ - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_CONTACTS, - FALSE, NULL, - book_shell_view_loaded_cb, + e_book_client_connect ( + source, NULL, + book_shell_view_client_connect_cb, g_object_ref (view)); } else { @@ -334,9 +334,10 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, model = e_addressbook_view_get_model (view); /* XXX No way to cancel this? */ - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL, - book_shell_view_loaded_cb, g_object_ref (view)); + e_book_client_connect ( + source, NULL, + book_shell_view_client_connect_cb, + g_object_ref (view)); g_signal_connect_object ( model, "contact-changed", diff --git a/modules/vcard-inline/e-mail-parser-vcard-inline.c b/modules/vcard-inline/e-mail-parser-vcard-inline.c index c1064dd28f..2580059b94 100644 --- a/modules/vcard-inline/e-mail-parser-vcard-inline.c +++ b/modules/vcard-inline/e-mail-parser-vcard-inline.c @@ -93,21 +93,26 @@ mail_part_vcard_inline_free (EMailPart *mail_part) } static void -client_loaded_cb (ESource *source, - GAsyncResult *result, - GSList *contact_list) +client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { + GSList *contact_list = user_data; EShell *shell; - EClient *client = NULL; + EClient *client; EBookClient *book_client; ESourceRegistry *registry; GSList *iter; 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 (error != NULL) { - g_warn_if_fail (client == NULL); g_warning ( "%s: Failed to open book client: %s", G_STRFUNC, error->message); @@ -115,8 +120,6 @@ client_loaded_cb (ESource *source, goto exit; } - g_return_if_fail (E_IS_BOOK_CLIENT (client)); - book_client = E_BOOK_CLIENT (client); shell = e_shell_get_default (); @@ -178,10 +181,8 @@ save_vcard_cb (WebKitDOMEventTarget *button, vcard_part->contact_list, (GCopyFunc) g_object_ref, NULL); - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_CONTACTS, - FALSE, NULL, (GAsyncReadyCallback) client_loaded_cb, - contact_list); + e_book_client_connect ( + source, NULL, client_connect_cb, contact_list); } static void |