diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-02-16 23:52:45 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-02-17 07:57:10 +0800 |
commit | 620d3deb3c4433881ca3f7f43b647a9c4d62d300 (patch) | |
tree | da89c7e408ab6b8da8712ebb7e9b937bc6d7cbea /modules/calendar | |
parent | 07973591ddd9a98d303ec2b2d29004cadb1bff30 (diff) | |
download | gsoc2013-evolution-620d3deb3c4433881ca3f7f43b647a9c4d62d300.tar.gz gsoc2013-evolution-620d3deb3c4433881ca3f7f43b647a9c4d62d300.tar.zst gsoc2013-evolution-620d3deb3c4433881ca3f7f43b647a9c4d62d300.zip |
EMemoShellSidebar: Use EClientCache to obtain EClient instances.
Also, defer to ESettingsClientCache to automatically set the default
timezone on new ECalClient instances.
Diffstat (limited to 'modules/calendar')
-rw-r--r-- | modules/calendar/e-memo-shell-sidebar.c | 105 |
1 files changed, 40 insertions, 65 deletions
diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index b282aaf17b..c9f3d6930e 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -155,6 +155,22 @@ memo_shell_sidebar_emit_status_message (EMemoShellSidebar *memo_shell_sidebar, g_signal_emit (memo_shell_sidebar, signal_id, 0, status_message, -1.0); } +static EClientCache * +memo_shell_sidebar_ref_client_cache (EMemoShellSidebar *memo_shell_sidebar) +{ + EShell *shell; + EShellView *shell_view; + EShellBackend *shell_backend; + EShellSidebar *shell_sidebar; + + shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_backend_get_shell (shell_backend); + + return g_object_ref (e_shell_get_client_cache (shell)); +} + static void memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, ECalClient *client) @@ -225,15 +241,10 @@ memo_shell_sidebar_client_connect_cb (GObject *source_object, { EClient *client; ConnectClosure *closure = user_data; - EMemoShellContent *memo_shell_content; - EShellContent *shell_content; - EShellSidebar *shell_sidebar; - EShellView *shell_view; - ECalModel *model; - icaltimezone *timezone; GError *error = NULL; - client = e_cal_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 ( @@ -250,18 +261,6 @@ memo_shell_sidebar_client_connect_cb (GObject *source_object, goto exit; } - /* FIXME Sidebar should not be accessing the EShellContent. - * This probably needs to be moved to EMemoShellView. */ - shell_sidebar = E_SHELL_SIDEBAR (closure->memo_shell_sidebar); - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_content = e_shell_view_get_shell_content (shell_view); - - memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content); - model = e_memo_shell_content_get_memo_model (memo_shell_content); - timezone = e_cal_model_get_timezone (model); - - e_cal_client_set_default_timezone (E_CAL_CLIENT (client), timezone); - e_memo_shell_sidebar_add_client (closure->memo_shell_sidebar, client); g_object_unref (client); @@ -279,17 +278,12 @@ memo_shell_sidebar_default_connect_cb (GObject *source_object, ESource *source; ConnectClosure *closure = user_data; EMemoShellSidebarPrivate *priv; - EShellContent *shell_content; - EShellSidebar *shell_sidebar; - EShellView *shell_view; - EMemoShellContent *memo_shell_content; - ECalModel *model; - icaltimezone *timezone; GError *error = NULL; priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (closure->memo_shell_sidebar); - client = e_cal_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 ( @@ -321,19 +315,8 @@ memo_shell_sidebar_default_connect_cb (GObject *source_object, priv->default_client = g_object_ref (client); - /* FIXME Sidebar should not be accessing the EShellContent. - * This probably needs to be moved to EMemoShellView. */ - shell_sidebar = E_SHELL_SIDEBAR (closure->memo_shell_sidebar); - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_content = e_shell_view_get_shell_content (shell_view); - - memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content); - model = e_memo_shell_content_get_memo_model (memo_shell_content); - timezone = e_cal_model_get_timezone (model); - - e_cal_client_set_default_timezone (E_CAL_CLIENT (client), timezone); - - g_object_notify (G_OBJECT (shell_sidebar), "default-client"); + g_object_notify ( + G_OBJECT (closure->memo_shell_sidebar), "default-client"); g_object_unref (client); @@ -346,9 +329,7 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar, ESource *source) { EMemoShellSidebarPrivate *priv; - EShellSidebar *shell_sidebar; - ECalClient *client; - const gchar *uid; + EClientCache *client_cache; priv = memo_shell_sidebar->priv; @@ -356,10 +337,6 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar, if (source == priv->connecting_default_source_instance) return; - /* FIXME Sidebar should not be accessing the EShellContent. - * This probably needs to be moved to EMemoShellView. */ - shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); - /* Cancel any unfinished previous request. */ if (priv->connecting_default_client != NULL) { g_cancellable_cancel (priv->connecting_default_client); @@ -367,28 +344,21 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar, priv->connecting_default_client = NULL; } - uid = e_source_get_uid (source); - client = g_hash_table_lookup (priv->client_table, uid); - - /* If we already have an open connection for - * this UID, we can finish immediately. */ - if (client != NULL) { - if (priv->default_client != NULL) - g_object_unref (priv->default_client); - priv->default_client = g_object_ref (client); - g_object_notify (G_OBJECT (shell_sidebar), "default-client"); - return; - } - /* it's only for pointer comparison, no need to ref it */ priv->connecting_default_source_instance = source; priv->connecting_default_client = g_cancellable_new (); - e_cal_client_connect ( - source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, + client_cache = + memo_shell_sidebar_ref_client_cache (memo_shell_sidebar); + + e_client_cache_get_client ( + client_cache, source, + E_SOURCE_EXTENSION_MEMO_LIST, priv->connecting_default_client, memo_shell_sidebar_default_connect_cb, connect_closure_new (memo_shell_sidebar, source)); + + g_object_unref (client_cache); } static void @@ -886,8 +856,8 @@ void e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, ESource *source) { - ECalClientSourceType source_type; ESourceSelector *selector; + EClientCache *client_cache; GHashTable *client_table; EClient *default_client; const gchar *display_name; @@ -897,7 +867,6 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar)); g_return_if_fail (E_IS_SOURCE (source)); - source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS; client_table = memo_shell_sidebar->priv->client_table; default_client = memo_shell_sidebar->priv->default_client; selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); @@ -926,11 +895,17 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, memo_shell_sidebar_emit_status_message (memo_shell_sidebar, message); g_free (message); - e_cal_client_connect ( - source, source_type, + client_cache = + memo_shell_sidebar_ref_client_cache (memo_shell_sidebar); + + e_client_cache_get_client ( + client_cache, source, + E_SOURCE_EXTENSION_MEMO_LIST, memo_shell_sidebar->priv->loading_clients, memo_shell_sidebar_client_connect_cb, connect_closure_new (memo_shell_sidebar, source)); + + g_object_unref (client_cache); } void |