diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-12-16 23:40:37 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-12-16 23:58:54 +0800 |
commit | a9cfed5938aef37d95c009411f965ebc185547c1 (patch) | |
tree | d0c6eb1d5acea6752425169aae47e8f4ed4b55ea /modules | |
parent | df85cb1b7a47f713cb775f648f735e642a1bb71b (diff) | |
download | gsoc2013-evolution-a9cfed5938aef37d95c009411f965ebc185547c1.tar.gz gsoc2013-evolution-a9cfed5938aef37d95c009411f965ebc185547c1.tar.zst gsoc2013-evolution-a9cfed5938aef37d95c009411f965ebc185547c1.zip |
Avoid passing EMailBackend as much as possible.
More mail API churn... reversing some previous API decisions.
I've made some key API changes to EMailSession on the account-mgmt
branch which should allow for this, and will hopefully also benefit
the "email-factory" branch.
EMailBackend barely needs to exist anymore, except as the owner of
EMailSession.
For several low-level functions, we replace its EMailBackend parameter
with EMailSession and EAlertSink parameters; the latter so it can still
pass user alerts up the chain.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mail/e-mail-shell-backend.c | 12 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-sidebar.c | 12 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 103 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-private.c | 14 | ||||
-rw-r--r-- | modules/mdn/evolution-mdn.c | 8 |
5 files changed, 100 insertions, 49 deletions
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 64817fad00..891fc64ae9 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -115,7 +115,7 @@ action_mail_folder_new_cb (GtkAction *action, { EMFolderTree *folder_tree = NULL; EMailShellSidebar *mail_shell_sidebar; - EMailBackend *backend; + EMailSession *session; EShellSidebar *shell_sidebar; EShellView *shell_view; const gchar *view_name; @@ -123,8 +123,9 @@ 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 *shell_backend; EShell *shell; + EShellBackend *shell_backend; + EMailBackend *backend; shell = e_shell_window_get_shell (shell_window); @@ -133,6 +134,7 @@ action_mail_folder_new_cb (GtkAction *action, g_return_if_fail (E_IS_MAIL_BACKEND (shell_backend)); backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); goto exit; } @@ -142,11 +144,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); - backend = em_folder_tree_get_backend (folder_tree); + session = em_folder_tree_get_session (folder_tree); exit: em_folder_utils_create_folder ( - GTK_WINDOW (shell_window), backend, folder_tree, NULL); + GTK_WINDOW (shell_window), session, folder_tree, NULL); } static void @@ -481,7 +483,7 @@ mail_shell_backend_start (EShellBackend *shell_backend) g_error_free (error); } - mail_autoreceive_init (backend); + mail_autoreceive_init (session); if (g_getenv ("CAMEL_FLUSH_CHANGES") != NULL) priv->mail_sync_source_id = g_timeout_add_seconds ( diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c index 698c02119d..857a0d6e0f 100644 --- a/modules/mail/e-mail-shell-sidebar.c +++ b/modules/mail/e-mail-shell-sidebar.c @@ -126,6 +126,9 @@ mail_shell_sidebar_constructed (GObject *object) EShellWindow *shell_window; EShellView *shell_view; EShell *shell; + EMailBackend *backend; + EMailSession *session; + EAlertSink *alert_sink; GtkTreeSelection *selection; GtkTreeView *tree_view; GtkWidget *container; @@ -142,6 +145,11 @@ 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); + + alert_sink = E_ALERT_SINK (shell_sidebar); + mail_shell_sidebar = E_MAIL_SHELL_SIDEBAR (object); /* Build sidebar widgets. */ @@ -159,9 +167,7 @@ mail_shell_sidebar_constructed (GObject *object) container = widget; - widget = e_mail_sidebar_new ( - E_MAIL_BACKEND (shell_backend), - E_ALERT_SINK (shell_sidebar)); + widget = e_mail_sidebar_new (session, alert_sink); 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 5de727e7e7..e0bdc492bc 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -125,6 +125,7 @@ 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; @@ -149,7 +150,9 @@ action_mail_create_search_folder_cb (GtkAction *action, folder = e_mail_reader_get_folder (reader); backend = E_MAIL_BACKEND (shell_backend); - search_rule = vfolder_clone_rule (backend, search_rule); + session = e_mail_backend_get_session (backend); + + search_rule = vfolder_clone_rule (session, search_rule); g_return_if_fail (search_rule != NULL); rule_name = g_strdup_printf ("%s %s", search_rule->name, search_text); @@ -240,12 +243,15 @@ action_mail_flush_outbox_cb (GtkAction *action, EShellBackend *shell_backend; EShellView *shell_view; EMailBackend *backend; + EMailSession *session; 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_send (backend); + mail_send (session); } static void @@ -253,24 +259,27 @@ action_mail_folder_copy_cb (GtkAction *action, EMailShellView *mail_shell_view) { EMailShellSidebar *mail_shell_sidebar; - EShellBackend *shell_backend; + EShellContent *shell_content; EShellWindow *shell_window; EShellView *shell_view; EMFolderTree *folder_tree; + EMailSession *session; gchar *selected_uri; shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - shell_backend = e_shell_view_get_shell_backend (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); selected_uri = em_folder_tree_get_selected_uri (folder_tree); + session = em_folder_tree_get_session (folder_tree); g_return_if_fail (selected_uri != NULL); em_folder_utils_copy_folder ( GTK_WINDOW (shell_window), - E_MAIL_BACKEND (shell_backend), + session, + E_ALERT_SINK (shell_content), selected_uri, FALSE); g_free (selected_uri); @@ -303,10 +312,11 @@ action_mail_folder_expunge_cb (GtkAction *action, { EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; - EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; CamelFolder *folder; + const gchar *description; + gboolean proceed; /* This handles both the "folder-expunge" and "account-expunge" * actions. */ @@ -325,11 +335,16 @@ action_mail_folder_expunge_cb (GtkAction *action, folder = em_folder_tree_get_selected_folder (folder_tree); g_return_if_fail (folder != NULL); - shell_backend = e_shell_view_get_shell_backend (shell_view); + description = camel_folder_get_description (folder); - em_utils_expunge_folder ( - GTK_WIDGET (shell_window), - E_MAIL_BACKEND (shell_backend), folder); + proceed = em_utils_prompt_user ( + GTK_WINDOW (shell_window), + "prompt-on-expunge", + "mail:ask-expunge", + description, NULL); + + if (proceed) + mail_expunge_folder (folder); } static void @@ -399,24 +414,27 @@ action_mail_folder_move_cb (GtkAction *action, EMailShellView *mail_shell_view) { EMailShellSidebar *mail_shell_sidebar; - EShellBackend *shell_backend; + EShellContent *shell_content; EShellWindow *shell_window; EShellView *shell_view; EMFolderTree *folder_tree; + EMailSession *session; gchar *selected_uri; shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - shell_backend = e_shell_view_get_shell_backend (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); selected_uri = em_folder_tree_get_selected_uri (folder_tree); + session = em_folder_tree_get_session (folder_tree); g_return_if_fail (selected_uri != NULL); em_folder_utils_copy_folder ( GTK_WINDOW (shell_window), - E_MAIL_BACKEND (shell_backend), + session, + E_ALERT_SINK (shell_content), selected_uri, TRUE); g_free (selected_uri); @@ -428,7 +446,7 @@ action_mail_folder_new_cb (GtkAction *action, { EShellView *shell_view; EShellWindow *shell_window; - EMailBackend *backend; + EMailSession *session; EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; gchar *selected_uri; @@ -439,12 +457,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); - backend = em_folder_tree_get_backend (folder_tree); + session = em_folder_tree_get_session (folder_tree); selected_uri = em_folder_tree_get_selected_uri (folder_tree); em_folder_utils_create_folder ( GTK_WINDOW (shell_window), - backend, folder_tree, selected_uri); + session, folder_tree, selected_uri); g_free (selected_uri); } @@ -454,19 +472,27 @@ action_mail_folder_properties_cb (GtkAction *action, EMailShellView *mail_shell_view) { EMailShellSidebar *mail_shell_sidebar; - EMFolderTree *folder_tree; EShellView *shell_view; + EShellWindow *shell_window; + EShellContent *shell_content; + EMFolderTree *folder_tree; CamelStore *store; gchar *folder_name; shell_view = E_SHELL_VIEW (mail_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); if (!em_folder_tree_get_selected (folder_tree, &store, &folder_name)) g_return_if_reached (); - em_folder_properties_show (shell_view, store, folder_name); + em_folder_properties_show ( + store, folder_name, + E_ALERT_SINK (shell_content), + GTK_WINDOW (shell_window)); g_object_unref (store); g_free (folder_name); @@ -592,14 +618,18 @@ action_mail_global_expunge_cb (GtkAction *action, EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; + EMailBackend *backend; + EMailSession *session; shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (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); + em_utils_empty_trash ( - GTK_WIDGET (shell_window), - E_MAIL_BACKEND (shell_backend)); + GTK_WIDGET (shell_window), session); } static void @@ -1021,23 +1051,41 @@ action_mail_tools_filters_cb (GtkAction *action, EMailShellView *mail_shell_view) { EShellBackend *shell_backend; + EShellContent *shell_content; EShellWindow *shell_window; EShellView *shell_view; + EMailBackend *backend; + EMailSession *session; shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + + backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); em_utils_edit_filters ( - GTK_WIDGET (shell_window), - E_MAIL_BACKEND (shell_backend)); + session, + E_ALERT_SINK (shell_content), + GTK_WINDOW (shell_window)); } static void action_mail_tools_search_folders_cb (GtkAction *action, EMailShellView *mail_shell_view) { - vfolder_edit (E_SHELL_VIEW (mail_shell_view)); + EShellView *shell_view; + EShellWindow *shell_window; + EShellBackend *shell_backend; + + shell_view = E_SHELL_VIEW (mail_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + + vfolder_edit ( + E_MAIL_BACKEND (shell_backend), + GTK_WINDOW (shell_window)); } static void @@ -1045,26 +1093,23 @@ action_mail_tools_subscriptions_cb (GtkAction *action, EMailShellView *mail_shell_view) { EMailShellSidebar *mail_shell_sidebar; - EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; - EMailBackend *backend; + EMailSession *session; EMFolderTree *folder_tree; GtkWidget *dialog; CamelStore *store; shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - shell_backend = e_shell_view_get_shell_backend (shell_view); mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); store = em_folder_tree_get_selected_store (folder_tree); - - backend = E_MAIL_BACKEND (shell_backend); + session = em_folder_tree_get_session (folder_tree); dialog = em_subscription_editor_new ( - GTK_WINDOW (shell_window), backend, store); + GTK_WINDOW (shell_window), session, store); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 05488156a7..aaa4e5e4f3 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -1096,6 +1096,7 @@ e_mail_shell_view_send_receive (EMailShellView *mail_shell_view, EShellWindow *shell_window; EShellBackend *shell_backend; EMailBackend *backend; + EMailSession *session; g_return_if_fail (mail_shell_view != NULL); @@ -1104,25 +1105,25 @@ e_mail_shell_view_send_receive (EMailShellView *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); em_utils_clear_get_password_canceled_accounts_flag (); if (!account_uid) { switch (mode) { case E_MAIL_SEND_RECEIVE_BOTH: - mail_send_receive (GTK_WINDOW (shell_window), backend); + mail_send_receive (GTK_WINDOW (shell_window), session); break; case E_MAIL_SEND_RECEIVE_RECEIVE: - mail_receive (GTK_WINDOW (shell_window), backend); + mail_receive (GTK_WINDOW (shell_window), session); break; case E_MAIL_SEND_RECEIVE_SEND: - mail_send (backend); + mail_send (session); break; } } else { /* allow only receive on individual accounts */ EAccount *account; - EMailSession *session; CamelService *service; account = e_get_account_by_uid (account_uid); @@ -1131,13 +1132,10 @@ e_mail_shell_view_send_receive (EMailShellView *mail_shell_view, if (!account->enabled) return; - session = e_mail_backend_get_session (backend); - service = camel_session_get_service ( CAMEL_SESSION (session), account->uid); - if (CAMEL_IS_SERVICE (service)) - mail_receive_service (backend, service); + mail_receive_service (service); } } diff --git a/modules/mdn/evolution-mdn.c b/modules/mdn/evolution-mdn.c index 6ce5dec555..d925c42b40 100644 --- a/modules/mdn/evolution-mdn.c +++ b/modules/mdn/evolution-mdn.c @@ -155,13 +155,13 @@ mdn_get_disposition (MdnActionMode action_mode, static void mdn_receipt_done (CamelFolder *folder, GAsyncResult *result, - EMailBackend *backend) + EMailSession *session) { /* FIXME Poor error handling. */ if (e_mail_folder_append_message_finish (folder, result, NULL, NULL)) - mail_send (backend); + mail_send (session); - g_object_unref (backend); + g_object_unref (session); } static void @@ -372,7 +372,7 @@ mdn_notify_sender (EAccount *account, e_mail_folder_append_message ( out_folder, receipt, receipt_info, G_PRIORITY_DEFAULT, NULL, (GAsyncReadyCallback) mdn_receipt_done, - g_object_ref (backend)); + g_object_ref (session)); camel_message_info_free (receipt_info); } |