From 2e858dc05e7e759971f9ec46af87afdbe4c92569 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 17 Feb 2013 10:17:14 -0500 Subject: EBookShellView: Use EClientCache to obtain an EClient. --- modules/addressbook/e-book-shell-view-actions.c | 31 ++++++++++++++++++++++--- modules/addressbook/e-book-shell-view-private.c | 21 +++++++++++++---- 2 files changed, 44 insertions(+), 8 deletions(-) (limited to 'modules/addressbook') diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c index e4e31039da..78ea77d1b2 100644 --- a/modules/addressbook/e-book-shell-view-actions.c +++ b/modules/addressbook/e-book-shell-view-actions.c @@ -229,12 +229,15 @@ map_window_show_contact_editor_cb (EContactMapWindow *window, const gchar *contact_uid, gpointer user_data) { - EShell *shell = e_shell_get_default (); EBookShellView *book_shell_view = user_data; EBookShellSidebar *book_shell_sidebar; + EShell *shell; + EShellView *shell_view; + EShellBackend *shell_backend; ESource *source; ESourceSelector *selector; EClient *client; + EClientCache *client_cache; EContact *contact; EABEditor *editor; GError *error = NULL; @@ -244,7 +247,16 @@ map_window_show_contact_editor_cb (EContactMapWindow *window, source = e_source_selector_ref_primary_selection (selector); g_return_if_fail (source != NULL); - client = e_book_client_connect_sync (source, NULL, &error); + shell_view = E_SHELL_VIEW (book_shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_backend_get_shell (shell_backend); + client_cache = e_shell_get_client_cache (shell); + + /* FIXME This blocks. Needs to be asynchronous. */ + client = e_client_cache_get_client_sync ( + client_cache, source, + E_SOURCE_EXTENSION_ADDRESS_BOOK, + NULL, &error); g_object_unref (source); @@ -289,11 +301,15 @@ action_address_book_map_cb (GtkAction *action, EBookShellView *book_shell_view) { #ifdef WITH_CONTACT_MAPS + EShell *shell; + EShellView *shell_view; + EShellBackend *shell_backend; EContactMapWindow *map_window; EBookShellSidebar *book_shell_sidebar; ESource *source; ESourceSelector *selector; EClient *client; + EClientCache *client_cache; GError *error = NULL; book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; @@ -301,7 +317,16 @@ action_address_book_map_cb (GtkAction *action, source = e_source_selector_ref_primary_selection (selector); g_return_if_fail (source != NULL); - client = e_book_client_connect_sync (source, NULL, &error); + shell_view = E_SHELL_VIEW (book_shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_backend_get_shell (shell_backend); + client_cache = e_shell_get_client_cache (shell); + + /* FIXME This blocks. Needs to be asynchronous. */ + client = e_client_cache_get_client_sync ( + client_cache, source, + E_SOURCE_EXTENSION_ADDRESS_BOOK, + NULL, &error); g_object_unref (source); diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c index 6f23d4faed..8bb90fe758 100644 --- a/modules/addressbook/e-book-shell-view-private.c +++ b/modules/addressbook/e-book-shell-view-private.c @@ -214,7 +214,8 @@ book_shell_view_client_connect_cb (GObject *source_object, EAddressbookModel *model; GError *error = NULL; - client = e_book_client_connect_finish (result, &error); + client = e_client_cache_get_client_finish ( + E_CLIENT_CACHE (source_object), result, &error); /* Sanity check. */ g_return_if_fail ( @@ -255,10 +256,13 @@ static void book_shell_view_activate_selected_source (EBookShellView *book_shell_view, ESourceSelector *selector) { + EShell *shell; EShellView *shell_view; + EShellBackend *shell_backend; EBookShellContent *book_shell_content; EAddressbookView *view; EAddressbookModel *model; + EClientCache *client_cache; ESource *source; GalViewInstance *view_instance; GHashTable *hash_table; @@ -267,6 +271,9 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, gchar *view_id; shell_view = E_SHELL_VIEW (book_shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_backend_get_shell (shell_backend); + client_cache = e_shell_get_client_cache (shell); book_shell_content = book_shell_view->priv->book_shell_content; source = e_source_selector_ref_primary_selection (selector); @@ -288,8 +295,10 @@ 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_book_client_connect ( - source, NULL, + e_client_cache_get_client ( + client_cache, source, + E_SOURCE_EXTENSION_ADDRESS_BOOK, + NULL, book_shell_view_client_connect_cb, g_object_ref (view)); @@ -334,8 +343,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_book_client_connect ( - source, NULL, + e_client_cache_get_client ( + client_cache, source, + E_SOURCE_EXTENSION_ADDRESS_BOOK, + NULL, book_shell_view_client_connect_cb, g_object_ref (view)); -- cgit v1.2.3