diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-24 05:09:24 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:19 +0800 |
commit | 7050475f84247fb15e24aa1bb31502106c18815d (patch) | |
tree | 60e500f221d5f97b241045b10806c5c4ddbcc7c1 /modules/mail | |
parent | a98cb0a9820d2119bf10c317e5f6a9d56dd9073c (diff) | |
download | gsoc2013-evolution-7050475f84247fb15e24aa1bb31502106c18815d.tar.gz gsoc2013-evolution-7050475f84247fb15e24aa1bb31502106c18815d.tar.zst gsoc2013-evolution-7050475f84247fb15e24aa1bb31502106c18815d.zip |
EMFolderTree: Store an EMailBackend instead of an EMailSession.
All this so EMFolderTree can submit EActivity instances for async ops.
You can obtain an EMailSession from an EMailBackend, but not vice versa.
Creates lots of pretty ripples in the mail code, but ultimately reduces
complexity. So it's a code cleanup of sorts.
Diffstat (limited to 'modules/mail')
-rw-r--r-- | modules/mail/e-mail-shell-backend.c | 17 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-sidebar.c | 7 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 13 | ||||
-rw-r--r-- | modules/mail/em-account-prefs.c | 68 | ||||
-rw-r--r-- | modules/mail/em-account-prefs.h | 4 |
5 files changed, 50 insertions, 59 deletions
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 0c02a48a05..f7e9b81ae1 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -106,7 +106,7 @@ action_mail_folder_new_cb (GtkAction *action, { EMFolderTree *folder_tree = NULL; EMailShellSidebar *mail_shell_sidebar; - EMailSession *mail_session; + EMailBackend *backend; EShellSidebar *shell_sidebar; EShellView *shell_view; const gchar *view_name; @@ -114,19 +114,16 @@ action_mail_folder_new_cb (GtkAction *action, /* Take care not to unnecessarily load the mail shell view. */ view_name = e_shell_window_get_active_view (shell_window); if (g_strcmp0 (view_name, BACKEND_NAME) != 0) { - EShellBackend *mail_backend; + EShellBackend *shell_backend; EShell *shell; shell = e_shell_window_get_shell (shell_window); - mail_backend = + shell_backend = e_shell_get_backend_by_name (shell, BACKEND_NAME); - g_return_if_fail (mail_backend != NULL); + g_return_if_fail (E_IS_MAIL_BACKEND (shell_backend)); - mail_session = - e_mail_backend_get_session ( - E_MAIL_BACKEND (mail_backend)); - g_return_if_fail (mail_session != NULL); + backend = E_MAIL_BACKEND (shell_backend); goto exit; } @@ -136,11 +133,11 @@ action_mail_folder_new_cb (GtkAction *action, mail_shell_sidebar = E_MAIL_SHELL_SIDEBAR (shell_sidebar); folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); - mail_session = em_folder_tree_get_session (folder_tree); + backend = em_folder_tree_get_backend (folder_tree); exit: em_folder_utils_create_folder ( - GTK_WINDOW (shell_window), folder_tree, mail_session, NULL); + GTK_WINDOW (shell_window), backend, folder_tree, NULL); } static void diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c index c910310010..760ebb0b2e 100644 --- a/modules/mail/e-mail-shell-sidebar.c +++ b/modules/mail/e-mail-shell-sidebar.c @@ -116,8 +116,6 @@ mail_shell_sidebar_constructed (GObject *object) EShellWindow *shell_window; EShellView *shell_view; EShell *shell; - EMailBackend *backend; - EMailSession *session; GtkTreeSelection *selection; GtkTreeView *tree_view; GtkWidget *container; @@ -134,9 +132,6 @@ mail_shell_sidebar_constructed (GObject *object) shell = e_shell_window_get_shell (shell_window); shell_settings = e_shell_get_shell_settings (shell); - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - mail_shell_sidebar = E_MAIL_SHELL_SIDEBAR (object); /* Build sidebar widgets. */ @@ -154,7 +149,7 @@ mail_shell_sidebar_constructed (GObject *object) container = widget; - widget = e_mail_sidebar_new (session); + widget = e_mail_sidebar_new (E_MAIL_BACKEND (shell_backend)); gtk_container_add (GTK_CONTAINER (container), widget); mail_shell_sidebar->priv->folder_tree = g_object_ref (widget); gtk_widget_show (widget); diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index f5c5524648..7c55908b31 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -125,7 +125,6 @@ action_mail_create_search_folder_cb (GtkAction *action, EFilterRule *search_rule; EMVFolderRule *vfolder_rule; EMailBackend *backend; - EMailSession *session; EMailView *mail_view; CamelFolder *folder; const gchar *search_text; @@ -135,9 +134,6 @@ action_mail_create_search_folder_cb (GtkAction *action, shell_view = E_SHELL_VIEW (mail_shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); @@ -152,7 +148,8 @@ action_mail_create_search_folder_cb (GtkAction *action, reader = E_MAIL_READER (mail_view); folder = e_mail_reader_get_folder (reader); - search_rule = vfolder_clone_rule (session, search_rule); + backend = E_MAIL_BACKEND (shell_backend); + search_rule = vfolder_clone_rule (backend, search_rule); g_return_if_fail (search_rule != NULL); rule_name = g_strdup_printf ("%s %s", search_rule->name, search_text); @@ -426,7 +423,7 @@ action_mail_folder_new_cb (GtkAction *action, { EShellView *shell_view; EShellWindow *shell_window; - EMailSession *session; + EMailBackend *backend; EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; gchar *selected_uri; @@ -437,12 +434,12 @@ action_mail_folder_new_cb (GtkAction *action, mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); - session = em_folder_tree_get_session (folder_tree); + backend = em_folder_tree_get_backend (folder_tree); selected_uri = em_folder_tree_get_selected_uri (folder_tree); em_folder_utils_create_folder ( GTK_WINDOW (shell_window), - folder_tree, session, selected_uri); + backend, folder_tree, selected_uri); g_free (selected_uri); } diff --git a/modules/mail/em-account-prefs.c b/modules/mail/em-account-prefs.c index 356351a2f1..b5c458385c 100644 --- a/modules/mail/em-account-prefs.c +++ b/modules/mail/em-account-prefs.c @@ -43,14 +43,14 @@ #include "capplet/settings/mail-capplet-shell.h" struct _EMAccountPrefsPrivate { - EMailSession *session; + EMailBackend *backend; gpointer assistant; /* weak pointer */ gpointer editor; /* weak pointer */ }; enum { PROP_0, - PROP_SESSION + PROP_BACKEND }; G_DEFINE_TYPE ( @@ -63,11 +63,13 @@ account_prefs_enable_account_cb (EAccountTreeView *tree_view, EMAccountPrefs *prefs) { EAccount *account; + EMailSession *session; account = e_account_tree_view_get_selected (tree_view); g_return_if_fail (account != NULL); - e_mail_store_add_by_account (prefs->priv->session, account); + session = e_mail_backend_get_session (prefs->priv->backend); + e_mail_store_add_by_account (session, account); } static void @@ -75,6 +77,7 @@ account_prefs_disable_account_cb (EAccountTreeView *tree_view, EMAccountPrefs *prefs) { EAccountList *account_list; + EMailSession *session; EAccount *account; gpointer parent; gint response; @@ -85,8 +88,10 @@ account_prefs_disable_account_cb (EAccountTreeView *tree_view, account_list = e_account_tree_view_get_account_list (tree_view); g_return_if_fail (account_list != NULL); + session = e_mail_backend_get_session (prefs->priv->backend); + if (!e_account_list_account_has_proxies (account_list, account)) { - e_mail_store_remove_by_account (prefs->priv->session, account); + e_mail_store_remove_by_account (session, account); return; } @@ -103,17 +108,17 @@ account_prefs_disable_account_cb (EAccountTreeView *tree_view, e_account_list_remove_account_proxies (account_list, account); - e_mail_store_remove_by_account (prefs->priv->session, account); + e_mail_store_remove_by_account (session, account); } static void -account_prefs_set_session (EMAccountPrefs *prefs, - EMailSession *session) +account_prefs_set_backend (EMAccountPrefs *prefs, + EMailBackend *backend) { - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (prefs->priv->session == NULL); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (prefs->priv->backend == NULL); - prefs->priv->session = g_object_ref (session); + prefs->priv->backend = g_object_ref (backend); } static void @@ -123,8 +128,8 @@ account_prefs_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: - account_prefs_set_session ( + case PROP_BACKEND: + account_prefs_set_backend ( EM_ACCOUNT_PREFS (object), g_value_get_object (value)); return; @@ -140,10 +145,10 @@ account_prefs_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: + case PROP_BACKEND: g_value_set_object ( value, - em_account_prefs_get_session ( + em_account_prefs_get_backend ( EM_ACCOUNT_PREFS (object))); return; } @@ -158,9 +163,9 @@ account_prefs_dispose (GObject *object) priv = EM_ACCOUNT_PREFS (object)->priv; - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; + if (priv->backend != NULL) { + g_object_unref (priv->backend); + priv->backend = NULL; } if (priv->assistant != NULL) { @@ -206,7 +211,7 @@ account_prefs_add_account (EAccountManager *manager) * The new mail account assistant. */ emae = em_account_editor_new ( - NULL, EMAE_ASSISTANT, priv->session, + NULL, EMAE_ASSISTANT, priv->backend, "org.gnome.evolution.mail.config.accountAssistant"); e_config_create_window ( E_CONFIG (emae->config), NULL, @@ -256,7 +261,7 @@ account_prefs_edit_account (EAccountManager *manager) * The account editor window. */ emae = em_account_editor_new ( - account, EMAE_NOTEBOOK, priv->session, + account, EMAE_NOTEBOOK, priv->backend, "org.gnome.evolution.mail.config.accountEditor"); e_config_create_window ( E_CONFIG (emae->config), parent, _("Account Editor")); @@ -275,12 +280,14 @@ account_prefs_delete_account (EAccountManager *manager) EMAccountPrefsPrivate *priv; EAccountTreeView *tree_view; EAccountList *account_list; + EMailSession *session; EAccount *account; gboolean has_proxies; gpointer parent; gint response; priv = EM_ACCOUNT_PREFS (manager)->priv; + session = e_mail_backend_get_session (priv->backend); account_list = e_account_manager_get_account_list (manager); tree_view = e_account_manager_get_tree_view (manager); @@ -309,7 +316,7 @@ account_prefs_delete_account (EAccountManager *manager) /* Remove the account from the folder tree. */ if (account->enabled) - e_mail_store_remove_by_account (priv->session, account); + e_mail_store_remove_by_account (session, account); /* Remove all the proxies the account has created. */ if (has_proxies) @@ -341,12 +348,12 @@ em_account_prefs_class_init (EMAccountPrefsClass *class) g_object_class_install_property ( object_class, - PROP_SESSION, + PROP_BACKEND, g_param_spec_object ( - "session", + "backend", NULL, NULL, - E_TYPE_MAIL_SESSION, + E_TYPE_MAIL_BACKEND, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } @@ -377,30 +384,25 @@ em_account_prefs_new (EPreferencesWindow *window) { EShell *shell; EShellBackend *shell_backend; - EMailBackend *backend; - EMailSession *session; EAccountList *account_list; account_list = e_get_account_list (); g_return_val_if_fail (E_IS_ACCOUNT_LIST (account_list), NULL); - /* XXX Figure out a better way to get the EMailSession. */ + /* XXX Figure out a better way to get the mail backend. */ shell = e_preferences_window_get_shell (window); shell_backend = e_shell_get_backend_by_name (shell, "mail"); - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - return g_object_new ( EM_TYPE_ACCOUNT_PREFS, "account-list", account_list, - "session", session, NULL); + "backend", shell_backend, NULL); } -EMailSession * -em_account_prefs_get_session (EMAccountPrefs *prefs) +EMailBackend * +em_account_prefs_get_backend (EMAccountPrefs *prefs) { g_return_val_if_fail (EM_IS_ACCOUNT_PREFS (prefs), NULL); - return prefs->priv->session; + return prefs->priv->backend; } diff --git a/modules/mail/em-account-prefs.h b/modules/mail/em-account-prefs.h index c00b860d35..667b83f42f 100644 --- a/modules/mail/em-account-prefs.h +++ b/modules/mail/em-account-prefs.h @@ -25,7 +25,7 @@ #include <gtk/gtk.h> #include <table/e-table.h> #include <libedataserver/e-account-list.h> -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> #include <misc/e-account-manager.h> #include <widgets/misc/e-preferences-window.h> @@ -65,7 +65,7 @@ struct _EMAccountPrefsClass { GType em_account_prefs_get_type (void); GtkWidget * em_account_prefs_new (EPreferencesWindow *window); -EMailSession * em_account_prefs_get_session (EMAccountPrefs *prefs); +EMailBackend * em_account_prefs_get_backend (EMAccountPrefs *prefs); G_END_DECLS |