diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-08-31 07:05:30 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-08-31 08:35:11 +0800 |
commit | f67a5f3d42aa9d743e6b78ace26a6ed1dbdc43e7 (patch) | |
tree | 98d3c6e13879d356ed0a4236ed9d2f5d48627980 | |
parent | 60383e0427e57bfb5e2fb836b450ec7cf9717b5f (diff) | |
download | gsoc2013-evolution-f67a5f3d42aa9d743e6b78ace26a6ed1dbdc43e7.tar.gz gsoc2013-evolution-f67a5f3d42aa9d743e6b78ace26a6ed1dbdc43e7.tar.zst gsoc2013-evolution-f67a5f3d42aa9d743e6b78ace26a6ed1dbdc43e7.zip |
Miscellaneous cleanups.
Reducing diff noise with the account-mgmt branch.
Trying to erode our dependency on EAccount as much as possible, or at
least isolate its usage, to make things easier for me on the branch.
-rw-r--r-- | mail/em-account-editor.c | 18 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 70 | ||||
-rw-r--r-- | mail/em-composer-utils.h | 2 | ||||
-rw-r--r-- | mail/em-filter-source-element.c | 24 | ||||
-rw-r--r-- | mail/em-folder-selection-button.c | 143 | ||||
-rw-r--r-- | mail/em-folder-selection-button.h | 11 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 11 | ||||
-rw-r--r-- | mail/em-folder-tree-model.h | 1 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 43 | ||||
-rw-r--r-- | mail/em-folder-tree.h | 2 | ||||
-rw-r--r-- | mail/em-subscription-editor.c | 7 | ||||
-rw-r--r-- | mail/em-utils.c | 64 | ||||
-rw-r--r-- | mail/em-utils.h | 12 | ||||
-rw-r--r-- | mail/mail-ops.c | 259 | ||||
-rw-r--r-- | mail/mail-ops.h | 14 | ||||
-rw-r--r-- | mail/mail-send-recv.h | 1 | ||||
-rw-r--r-- | mail/mail-vfolder.c | 8 | ||||
-rw-r--r-- | mail/message-list.c | 1 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-backend.h | 3 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-settings.c | 3 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 39 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view.c | 13 | ||||
-rw-r--r-- | modules/mail/em-composer-prefs.c | 9 |
23 files changed, 403 insertions, 355 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index 8c184ae071..93e61a2d9f 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -3141,7 +3141,9 @@ emae_defaults_page (EConfig *ec, EMFolderSelectionButton *button; CamelProviderFlags flags; CamelSettings *settings; + CamelStore *store = NULL; EMailBackend *backend; + EMailSession *session; EAccount *account; GtkWidget *widget; GtkBuilder *builder; @@ -3156,6 +3158,18 @@ emae_defaults_page (EConfig *ec, account = em_account_editor_get_modified_account (emae); backend = em_account_editor_get_backend (emae); + session = e_mail_backend_get_session (backend); + + if (account != NULL) { + CamelService *service; + + service = camel_session_get_service ( + CAMEL_SESSION (session), account->uid); + + if (CAMEL_IS_STORE (service)) + store = CAMEL_STORE (service); + } + settings = emae->priv->source.settings; /* Make sure we have a valid EMailBackend. */ @@ -3182,8 +3196,8 @@ emae_defaults_page (EConfig *ec, widget = e_builder_get_widget (builder, "trash_folder_butt"); button = EM_FOLDER_SELECTION_BUTTON (widget); - em_folder_selection_button_set_account (button, account); em_folder_selection_button_set_backend (button, backend); + em_folder_selection_button_set_store (button, store); priv->trash_folder_button = GTK_BUTTON (button); g_signal_connect ( @@ -3227,8 +3241,8 @@ emae_defaults_page (EConfig *ec, widget = e_builder_get_widget (builder, "junk_folder_butt"); button = EM_FOLDER_SELECTION_BUTTON (widget); - em_folder_selection_button_set_account (button, account); em_folder_selection_button_set_backend (button, backend); + em_folder_selection_button_set_store (button, store); priv->junk_folder_button = GTK_BUTTON (button); g_signal_connect ( diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index afbf81ccfa..12fdd96490 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -1782,27 +1782,27 @@ static EMsgComposer * redirect_get_composer (EShell *shell, CamelMimeMessage *message) { - EMsgComposer *composer; + CamelMedium *medium; EAccount *account; + medium = CAMEL_MEDIUM (message); + /* QMail will refuse to send a message if it finds one of it's Delivered-To headers in the message, so remove all Delivered-To headers. Fixes bug #23635. */ - while (camel_medium_get_header (CAMEL_MEDIUM (message), "Delivered-To")) - camel_medium_remove_header (CAMEL_MEDIUM (message), "Delivered-To"); + while (camel_medium_get_header (medium, "Delivered-To")) + camel_medium_remove_header (medium, "Delivered-To"); - while (camel_medium_get_header (CAMEL_MEDIUM (message), "Bcc")) - camel_medium_remove_header (CAMEL_MEDIUM (message), "Bcc"); + while (camel_medium_get_header (medium, "Bcc")) + camel_medium_remove_header (medium, "Bcc"); - while (camel_medium_get_header (CAMEL_MEDIUM (message), "Resent-Bcc")) - camel_medium_remove_header (CAMEL_MEDIUM (message), "Resent-Bcc"); + while (camel_medium_get_header (medium, "Resent-Bcc")) + camel_medium_remove_header (medium, "Resent-Bcc"); account = em_utils_guess_account_with_recipients (message, NULL); - composer = e_msg_composer_new_redirect ( + return e_msg_composer_new_redirect ( shell, message, account ? account->name : NULL, NULL); - - return composer; } /** @@ -1967,9 +1967,10 @@ em_utils_send_receipt (EMailSession *session, message_date =""; /* Create toplevel container */ - camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (body), - "multipart/report;" - "report-type=\"disposition-notification\""); + camel_data_wrapper_set_mime_type ( + CAMEL_DATA_WRAPPER (body), + "multipart/report;" + "report-type=\"disposition-notification\""); camel_multipart_set_boundary (body, NULL); /* Create textual receipt */ @@ -2036,7 +2037,8 @@ em_utils_send_receipt (EMailSession *session, g_object_unref (part); /* Finish creating the message */ - camel_medium_set_content (CAMEL_MEDIUM (receipt), CAMEL_DATA_WRAPPER (body)); + camel_medium_set_content ( + CAMEL_MEDIUM (receipt), CAMEL_DATA_WRAPPER (body)); g_object_unref (body); /* Translators: %s is the subject of the email message */ @@ -2052,7 +2054,8 @@ em_utils_send_receipt (EMailSession *session, addr = camel_internet_address_new (); camel_address_decode (CAMEL_ADDRESS (addr), receipt_address); - camel_mime_message_set_recipients (receipt, CAMEL_RECIPIENT_TYPE_TO, addr); + camel_mime_message_set_recipients ( + receipt, CAMEL_RECIPIENT_TYPE_TO, addr); g_object_unref (addr); transport_uid = g_strconcat (account->uid, "-transport", NULL); @@ -2139,12 +2142,17 @@ reply_get_composer (EShell *shell, EDestination **tov, **ccv; EMsgComposer *composer; EComposerHeaderTable *table; + CamelMedium *medium; gchar *subject; g_return_val_if_fail (E_IS_SHELL (shell), NULL); g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); - g_return_val_if_fail (to == NULL || CAMEL_IS_INTERNET_ADDRESS (to), NULL); - g_return_val_if_fail (cc == NULL || CAMEL_IS_INTERNET_ADDRESS (cc), NULL); + + if (to != NULL) + g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (to), NULL); + + if (cc != NULL) + g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (cc), NULL); composer = e_msg_composer_new (shell); @@ -2207,22 +2215,30 @@ reply_get_composer (EShell *shell, } /* Add In-Reply-To and References. */ - message_id = camel_medium_get_header (CAMEL_MEDIUM (message), "Message-ID"); - references = camel_medium_get_header (CAMEL_MEDIUM (message), "References"); - if (message_id) { + + medium = CAMEL_MEDIUM (message); + message_id = camel_medium_get_header (medium, "Message-ID"); + references = camel_medium_get_header (medium, "References"); + + if (message_id != NULL) { gchar *reply_refs; - e_msg_composer_add_header (composer, "In-Reply-To", message_id); + e_msg_composer_add_header ( + composer, "In-Reply-To", message_id); if (references) - reply_refs = g_strdup_printf ("%s %s", references, message_id); + reply_refs = g_strdup_printf ( + "%s %s", references, message_id); else reply_refs = g_strdup (message_id); - e_msg_composer_add_header (composer, "References", reply_refs); + e_msg_composer_add_header ( + composer, "References", reply_refs); g_free (reply_refs); - } else if (references) { - e_msg_composer_add_header (composer, "References", references); + + } else if (references != NULL) { + e_msg_composer_add_header ( + composer, "References", references); } return composer; @@ -2865,7 +2881,7 @@ em_utils_reply_to_message (EShell *shell, const gchar *message_uid, EMailReplyType type, EMailReplyStyle style, - EMFormat *source, + EMFormat *source_formatter, CamelInternetAddress *address) { CamelInternetAddress *to, *cc; @@ -2925,7 +2941,7 @@ em_utils_reply_to_message (EShell *shell, g_object_unref (to); g_object_unref (cc); - composer_set_body (composer, message, style, source); + composer_set_body (composer, message, style, source_formatter); if (folder != NULL) { gchar *folder_uri; diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h index 59b6e16d60..e651186afc 100644 --- a/mail/em-composer-utils.h +++ b/mail/em-composer-utils.h @@ -66,7 +66,7 @@ void em_utils_send_receipt (EMailSession *session, CamelMimeMessage *message); gchar * em_utils_construct_composer_text (CamelMimeMessage *message, - EMFormat *source); + EMFormat *source_formatter); gboolean em_utils_is_munged_list_message (CamelMimeMessage *message); void em_utils_get_reply_sender (CamelMimeMessage *message, CamelInternetAddress *to, diff --git a/mail/em-filter-source-element.c b/mail/em-filter-source-element.c index fe64a7a6c8..b95c140c58 100644 --- a/mail/em-filter-source-element.c +++ b/mail/em-filter-source-element.c @@ -31,11 +31,11 @@ #include <gtk/gtk.h> #include <camel/camel.h> + #include <libedataserver/e-sexp.h> #include <e-util/e-account-utils.h> - -#include "filter/e-filter-part.h" +#include <filter/e-filter-part.h> #define EM_FILTER_SOURCE_ELEMENT_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -343,18 +343,28 @@ filter_source_element_get_widget (EFilterElement *fe) for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) { SourceInfo *info = (SourceInfo *) i->data; + const gchar *display_name; + const gchar *address; + const gchar *name; + const gchar *uid; gchar *label; - if (g_strcmp0 (info->account_name, info->address) == 0) + uid = info->uid; + display_name = info->account_name; + + name = info->name; + address = info->address; + + if (g_strcmp0 (display_name, address) == 0) label = g_strdup_printf ( - "%s <%s>", info->name, info->address); + "%s <%s>", name, address); else label = g_strdup_printf ( - "%s <%s> (%s)", info->name, - info->address, info->account_name); + "%s <%s> (%s)", name, + address, display_name); gtk_combo_box_text_append ( - GTK_COMBO_BOX_TEXT (combo_box), info->uid, label); + GTK_COMBO_BOX_TEXT (combo_box), uid, label); g_free (label); } diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c index e675fc0eee..3f05147078 100644 --- a/mail/em-folder-selection-button.c +++ b/mail/em-folder-selection-button.c @@ -27,7 +27,6 @@ #include <string.h> #include <glib/gi18n.h> #include <e-util/e-util.h> -#include <e-util/e-account-utils.h> #include "e-mail-folder-utils.h" #include "em-folder-tree.h" @@ -44,7 +43,7 @@ struct _EMFolderSelectionButtonPrivate { EMailBackend *backend; GtkWidget *icon; GtkWidget *label; - EAccount *account; + CamelStore *store; gchar *title; gchar *caption; @@ -53,10 +52,10 @@ struct _EMFolderSelectionButtonPrivate { enum { PROP_0, - PROP_ACCOUNT, PROP_BACKEND, PROP_CAPTION, PROP_FOLDER_URI, + PROP_STORE, PROP_TITLE }; @@ -87,9 +86,9 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button) { EMailBackend *backend; CamelStore *store = NULL; - EAccount *account; + CamelService *service; GtkLabel *label; - const gchar *uid; + const gchar *display_name; gchar *folder_name = NULL; label = GTK_LABEL (button->priv->label); @@ -110,15 +109,14 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button) return; } - uid = camel_service_get_uid (CAMEL_SERVICE (store)); - account = e_get_account_by_uid (uid); + service = CAMEL_SERVICE (store); + display_name = camel_service_get_display_name (service); - if (account != NULL) { + if (display_name != NULL) { gchar *text; text = g_strdup_printf ( - "%s/%s", e_account_get_string ( - account, E_ACCOUNT_NAME), _(folder_name)); + "%s/%s", display_name, _(folder_name)); gtk_label_set_text (label, text); g_free (text); } else @@ -135,12 +133,6 @@ folder_selection_button_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_ACCOUNT: - em_folder_selection_button_set_account ( - EM_FOLDER_SELECTION_BUTTON (object), - g_value_get_object (value)); - return; - case PROP_BACKEND: em_folder_selection_button_set_backend ( EM_FOLDER_SELECTION_BUTTON (object), @@ -159,6 +151,12 @@ folder_selection_button_set_property (GObject *object, g_value_get_string (value)); return; + case PROP_STORE: + em_folder_selection_button_set_store ( + EM_FOLDER_SELECTION_BUTTON (object), + g_value_get_object (value)); + return; + case PROP_TITLE: em_folder_selection_button_set_title ( EM_FOLDER_SELECTION_BUTTON (object), @@ -176,13 +174,6 @@ folder_selection_button_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_ACCOUNT: - g_value_set_object ( - value, - em_folder_selection_button_get_account ( - EM_FOLDER_SELECTION_BUTTON (object))); - return; - case PROP_BACKEND: g_value_set_object ( value, @@ -204,6 +195,13 @@ folder_selection_button_get_property (GObject *object, EM_FOLDER_SELECTION_BUTTON (object))); return; + case PROP_STORE: + g_value_set_object ( + value, + em_folder_selection_button_get_store ( + EM_FOLDER_SELECTION_BUTTON (object))); + return; + case PROP_TITLE: g_value_set_string ( value, @@ -222,16 +220,16 @@ folder_selection_button_dispose (GObject *object) priv = EM_FOLDER_SELECTION_BUTTON_GET_PRIVATE (object); - if (priv->account != NULL) { - g_object_unref (priv->account); - priv->account = NULL; - } - if (priv->backend != NULL) { g_object_unref (priv->backend); priv->backend = NULL; } + if (priv->store != NULL) { + g_object_unref (priv->store); + priv->store = NULL; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (em_folder_selection_button_parent_class)-> dispose (object); @@ -269,21 +267,14 @@ folder_selection_button_clicked (GtkButton *button) parent = gtk_widget_get_toplevel (GTK_WIDGET (button)); parent = gtk_widget_is_toplevel (parent) ? parent : NULL; - if (priv->account != NULL && priv->account->source != NULL) { + if (priv->store != NULL) { EMailSession *session; - CamelService *service; session = e_mail_backend_get_session (priv->backend); - service = camel_session_get_service ( - CAMEL_SESSION (session), priv->account->uid); - - if (CAMEL_IS_STORE (service)) { - model = em_folder_tree_model_new (); - em_folder_tree_model_set_session (model, session); - em_folder_tree_model_add_store ( - model, CAMEL_STORE (service)); - } + model = em_folder_tree_model_new (); + em_folder_tree_model_set_session (model, session); + em_folder_tree_model_add_store (model, priv->store); } if (model == NULL) @@ -342,16 +333,6 @@ em_folder_selection_button_class_init (EMFolderSelectionButtonClass *class) g_object_class_install_property ( object_class, - PROP_ACCOUNT, - g_param_spec_object ( - "account", - NULL, - NULL, - E_TYPE_ACCOUNT, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, PROP_BACKEND, g_param_spec_object ( "backend", @@ -385,6 +366,16 @@ em_folder_selection_button_class_init (EMFolderSelectionButtonClass *class) g_object_class_install_property ( object_class, + PROP_STORE, + g_param_spec_object ( + "store", + NULL, + NULL, + CAMEL_TYPE_STORE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, PROP_TITLE, g_param_spec_string ( "title", @@ -439,33 +430,6 @@ em_folder_selection_button_new (EMailBackend *backend, "caption", caption, NULL); } -EAccount * -em_folder_selection_button_get_account (EMFolderSelectionButton *button) -{ - g_return_val_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button), NULL); - - return button->priv->account; -} - -void -em_folder_selection_button_set_account (EMFolderSelectionButton *button, - EAccount *account) -{ - g_return_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button)); - - if (account != NULL) { - g_return_if_fail (E_IS_ACCOUNT (account)); - g_object_ref (account); - } - - if (button->priv->account != NULL) - g_object_unref (button->priv->account); - - button->priv->account = account; - - g_object_notify (G_OBJECT (button), "account"); -} - EMailBackend * em_folder_selection_button_get_backend (EMFolderSelectionButton *button) { @@ -539,6 +503,33 @@ em_folder_selection_button_set_folder_uri (EMFolderSelectionButton *button, g_object_notify (G_OBJECT (button), "folder-uri"); } +CamelStore * +em_folder_selection_button_get_store (EMFolderSelectionButton *button) +{ + g_return_val_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button), NULL); + + return button->priv->store; +} + +void +em_folder_selection_button_set_store (EMFolderSelectionButton *button, + CamelStore *store) +{ + g_return_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button)); + + if (store != NULL) { + g_return_if_fail (CAMEL_IS_STORE (store)); + g_object_ref (store); + } + + if (button->priv->store != NULL) + g_object_unref (button->priv->store); + + button->priv->store = store; + + g_object_notify (G_OBJECT (button), "store"); +} + const gchar * em_folder_selection_button_get_title (EMFolderSelectionButton *button) { diff --git a/mail/em-folder-selection-button.h b/mail/em-folder-selection-button.h index dd826d1bab..125e96ebce 100644 --- a/mail/em-folder-selection-button.h +++ b/mail/em-folder-selection-button.h @@ -26,7 +26,6 @@ #include <gtk/gtk.h> #include <mail/e-mail-backend.h> -#include <libedataserver/e-account.h> /* Standard GObject macros */ #define EM_TYPE_FOLDER_SELECTION_BUTTON \ @@ -71,11 +70,6 @@ GtkWidget * em_folder_selection_button_new (EMailBackend *backend, const gchar *title, const gchar *caption); -EAccount * em_folder_selection_button_get_account - (EMFolderSelectionButton *button); -void em_folder_selection_button_set_account - (EMFolderSelectionButton *button, - EAccount *account); EMailBackend * em_folder_selection_button_get_backend (EMFolderSelectionButton *button); void em_folder_selection_button_set_backend @@ -91,6 +85,11 @@ const gchar * em_folder_selection_button_get_folder_uri void em_folder_selection_button_set_folder_uri (EMFolderSelectionButton *button, const gchar *folder_uri); +CamelStore * em_folder_selection_button_get_store + (EMFolderSelectionButton *button); +void em_folder_selection_button_set_store + (EMFolderSelectionButton *button, + CamelStore *store); const gchar * em_folder_selection_button_get_title (EMFolderSelectionButton *button); void em_folder_selection_button_set_title diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 1b79ca9ac6..6c9fc55338 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -55,6 +55,10 @@ #include "e-mail-store.h" #include "shell/e-shell.h" +#define EM_FOLDER_TREE_MODEL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_FOLDER_TREE_MODEL, EMFolderTreeModelPrivate)) + #define d(x) struct _EMFolderTreeModelPrivate { @@ -316,7 +320,7 @@ folder_tree_model_dispose (GObject *object) { EMFolderTreeModelPrivate *priv; - priv = EM_FOLDER_TREE_MODEL (object)->priv; + priv = EM_FOLDER_TREE_MODEL_GET_PRIVATE (object); if (priv->selection != NULL) { g_object_weak_unref ( @@ -339,7 +343,7 @@ folder_tree_model_finalize (GObject *object) { EMFolderTreeModelPrivate *priv; - priv = EM_FOLDER_TREE_MODEL (object)->priv; + priv = EM_FOLDER_TREE_MODEL_GET_PRIVATE (object); g_hash_table_destroy (priv->store_index); g_hash_table_destroy (priv->uri_index); @@ -498,8 +502,7 @@ em_folder_tree_model_init (EMFolderTreeModel *model) (GDestroyNotify) g_free, (GDestroyNotify) gtk_tree_row_reference_free); - model->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - model, EM_TYPE_FOLDER_TREE_MODEL, EMFolderTreeModelPrivate); + model->priv = EM_FOLDER_TREE_MODEL_GET_PRIVATE (model); model->priv->store_index = store_index; model->priv->uri_index = uri_index; diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h index 66984fc904..1bf5483367 100644 --- a/mail/em-folder-tree-model.h +++ b/mail/em-folder-tree-model.h @@ -25,7 +25,6 @@ #include <gtk/gtk.h> #include <camel/camel.h> -#include <libedataserver/e-account-list.h> #include <mail/e-mail-session.h> diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 18320eccf7..85a0acbcb1 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -39,7 +39,6 @@ #include <gdk/gdkkeysyms.h> #include <glib/gi18n.h> -#include "e-util/e-account-utils.h" #include "e-util/e-mktemp.h" #include "e-util/e-icon-factory.h" #include "e-util/e-alert-dialog.h" @@ -496,10 +495,9 @@ folder_tree_expand_node (const gchar *key, GtkTreeView *tree_view; GtkTreeModel *model; GtkTreePath *path; - EAccount *account; EMailBackend *backend; EMailSession *session; - CamelStore *store; + CamelService *service; const gchar *p; gchar *uid; gsize n; @@ -520,36 +518,21 @@ folder_tree_expand_node (const gchar *key, backend = em_folder_tree_get_backend (folder_tree); session = e_mail_backend_get_session (backend); - if ((account = e_get_account_by_uid (uid)) && account->enabled) { - store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), account->uid); - - if (store == NULL) - return; - - g_object_ref (store); - } else if (!strcmp (uid, "vfolder")) { - if (!(store = vfolder_store)) - return; - - g_object_ref (store); - } else if (!strcmp (uid, "local")) { - if (!(store = e_mail_local_get_store ())) - return; + service = camel_session_get_service (CAMEL_SESSION (session), uid); - g_object_ref (store); - } else { + if (!CAMEL_IS_STORE (service)) return; - } + + g_object_ref (service); si = em_folder_tree_model_lookup_store_info ( - EM_FOLDER_TREE_MODEL (model), store); + EM_FOLDER_TREE_MODEL (model), CAMEL_STORE (service)); if (si == NULL) { - g_object_unref (store); + g_object_unref (service); return; } - g_object_unref (store); + g_object_unref (service); if (p != NULL) { if (!(row = g_hash_table_lookup (si->full_hash, p + 1))) @@ -3308,15 +3291,14 @@ em_folder_tree_get_selected_folder (EMFolderTree *folder_tree) return folder; } -EAccount * -em_folder_tree_get_selected_account (EMFolderTree *folder_tree) +CamelStore * +em_folder_tree_get_selected_store (EMFolderTree *folder_tree) { GtkTreeView *tree_view; GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; CamelStore *store = NULL; - const gchar *uid = NULL; g_return_val_if_fail (EM_IS_FOLDER_TREE (folder_tree), NULL); @@ -3331,10 +3313,7 @@ em_folder_tree_get_selected_account (EMFolderTree *folder_tree) model, &iter, COL_POINTER_CAMEL_STORE, &store, -1); - if (CAMEL_IS_STORE (store)) - uid = camel_service_get_uid (CAMEL_SERVICE (store)); - - return (uid != NULL) ? e_get_account_by_uid (uid) : NULL; + return CAMEL_IS_STORE (store) ? store : NULL; } void diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h index eeea8df0ee..e136d680ad 100644 --- a/mail/em-folder-tree.h +++ b/mail/em-folder-tree.h @@ -135,7 +135,7 @@ gboolean em_folder_tree_store_root_selected gchar * em_folder_tree_get_selected_uri (EMFolderTree *folder_tree); CamelFolder * em_folder_tree_get_selected_folder (EMFolderTree *folder_tree); -EAccount * em_folder_tree_get_selected_account +CamelStore * em_folder_tree_get_selected_store (EMFolderTree *folder_tree); gboolean em_folder_tree_create_folder (EMFolderTree *folder_tree, const gchar *full_name, diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c index ba7bcc1458..baaeb34b3b 100644 --- a/mail/em-subscription-editor.c +++ b/mail/em-subscription-editor.c @@ -1038,14 +1038,19 @@ subscription_editor_constructed (GObject *object) editor = EM_SUBSCRIPTION_EDITOR (object); + /* Pick an initial store based on the default mail account, if + * one wasn't already given in em_subscription_editor_new(). */ if (editor->priv->initial_store == NULL) { EAccount *account; CamelService *service; CamelSession *session; + const gchar *uid; account = e_get_default_account (); + uid = account->uid; + session = em_subscription_editor_get_session (editor); - service = camel_session_get_service (session, account->uid); + service = camel_session_get_service (session, uid); if (CAMEL_IS_SUBSCRIBABLE (service)) editor->priv->initial_store = g_object_ref (service); diff --git a/mail/em-utils.c b/mail/em-utils.c index 33e664976b..3b42e9b200 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1361,13 +1361,15 @@ em_utils_message_to_html (CamelMimeMessage *message, /** * em_utils_expunge_folder: * @parent: parent window - * @session: #EMailSession + * @backend: #EMailBackend * @folder: folder to expunge * * Expunges @folder. **/ void -em_utils_expunge_folder (GtkWidget *parent, EMailSession *session, CamelFolder *folder) +em_utils_expunge_folder (GtkWidget *parent, + EMailBackend *backend, + CamelFolder *folder) { const gchar *description; @@ -1379,56 +1381,62 @@ em_utils_expunge_folder (GtkWidget *parent, EMailSession *session, CamelFolder * "mail:ask-expunge", description, NULL)) return; - mail_expunge_folder (session, folder, NULL, NULL); + mail_expunge_folder (backend, folder); } /** * em_utils_empty_trash: * @parent: parent window - * @session: an #EMailSession + * @backend: an #EMailBackend * * Empties all Trash folders. **/ void em_utils_empty_trash (GtkWidget *parent, - EMailSession *session) + EMailBackend *backend) { - CamelProvider *provider; - EAccountList *account_list; - EAccount *account; - EIterator *iterator; + EMailSession *session; + GList *list, *iter; - g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); if (!em_utils_prompt_user ((GtkWindow *) parent, "/apps/evolution/mail/prompts/empty_trash", "mail:ask-empty-trash", NULL)) return; - account_list = e_get_account_list (); - iterator = e_list_get_iterator (E_LIST (account_list)); + session = e_mail_backend_get_session (backend); + list = camel_session_list_services (CAMEL_SESSION (session)); - while (e_iterator_is_valid (iterator)) { - account = (EAccount *) e_iterator_get (iterator); + for (iter = list; iter != NULL; iter = g_list_next (iter)) { + EAccount *account; + CamelProvider *provider; + CamelService *service; + const gchar *uid; - /* make sure this is a valid source */ - if (account->enabled && account->source->url) { - provider = camel_provider_get (account->source->url, NULL); - if (provider) { - /* make sure this store is a remote store */ - if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) { - mail_empty_trash (session, account, NULL, NULL); - } - } + service = CAMEL_SERVICE (iter->data); + provider = camel_service_get_provider (service); + uid = camel_service_get_uid (service); + + if (!CAMEL_IS_STORE (service)) + continue; + + if ((provider->flags & CAMEL_PROVIDER_IS_STORAGE) == 0) + continue; + + account = e_get_account_by_uid (uid); + + /* The local store has no corresponding + * EAccount, so skip the enabled check. */ + if (account != NULL) { + if (!account->enabled) + continue; } - e_iterator_next (iterator); + mail_empty_trash (backend, CAMEL_STORE (service)); } - g_object_unref (iterator); - - /* Now empty the local trash folder */ - mail_empty_trash (session, NULL, NULL, NULL); + g_list_free (list); } /* ********************************************************************** */ diff --git a/mail/em-utils.h b/mail/em-utils.h index cb547e09a3..e8ffd190d6 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -61,18 +61,18 @@ void em_utils_selection_get_uidlist (GtkSelectionData *data, EMailSession *sessi void em_utils_selection_set_urilist (GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids); void em_utils_selection_get_urilist (GtkSelectionData *data, CamelFolder *folder); -gboolean em_utils_folder_is_drafts (CamelFolder *folder); -gboolean em_utils_folder_is_templates (CamelFolder *folder); -gboolean em_utils_folder_is_sent (CamelFolder *folder); -gboolean em_utils_folder_is_outbox (CamelFolder *folder); +gboolean em_utils_folder_is_drafts (CamelFolder *folder); +gboolean em_utils_folder_is_templates (CamelFolder *folder); +gboolean em_utils_folder_is_sent (CamelFolder *folder); +gboolean em_utils_folder_is_outbox (CamelFolder *folder); gchar *em_utils_get_proxy_uri (const gchar *uri); /* FIXME: should this have an override charset? */ gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, guint32 flags, struct _EMFormat *source, const gchar *append, guint32 *validity_found); -void em_utils_expunge_folder (GtkWidget *parent, EMailSession *session, CamelFolder *folder); -void em_utils_empty_trash (GtkWidget *parent, EMailSession *session); +void em_utils_expunge_folder (GtkWidget *parent, EMailBackend *backend, CamelFolder *folder); +void em_utils_empty_trash (GtkWidget *parent, EMailBackend *backend); /* is this address in the addressbook? caches results */ gboolean em_utils_in_addressbook (CamelInternetAddress *addr, gboolean local_only); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 1132271e08..8bfc050149 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1091,7 +1091,7 @@ mail_transfer_messages (EMailSession *session, struct _sync_folder_msg { MailMsg base; - EMailSession *session; + EMailBackend *backend; CamelFolder *folder; void (*done) (CamelFolder *folder, gpointer data); gpointer data; @@ -1123,10 +1123,11 @@ sync_folder_done (struct _sync_folder_msg *m) static void sync_folder_free (struct _sync_folder_msg *m) { - g_object_unref (m->folder); + if (m->backend) + g_object_unref (m->backend); - if (m->session) - g_object_unref (m->session); + if (m->folder) + g_object_unref (m->folder); } static MailMsgInfo sync_folder_info = { @@ -1145,8 +1146,7 @@ mail_sync_folder (CamelFolder *folder, struct _sync_folder_msg *m; m = mail_msg_new (&sync_folder_info); - m->folder = folder; - g_object_ref (folder); + m->folder = g_object_ref (folder); m->data = data; m->done = done; @@ -1222,9 +1222,8 @@ mail_sync_store (CamelStore *store, struct _sync_store_msg *m; m = mail_msg_new (&sync_store_info); - m->store = store; + m->store = g_object_ref (store); m->expunge = expunge; - g_object_ref (store); m->data = data; m->done = done; @@ -1267,8 +1266,7 @@ mail_refresh_folder (CamelFolder *folder, struct _sync_folder_msg *m; m = mail_msg_new (&refresh_folder_info); - m->folder = folder; - g_object_ref (folder); + m->folder = g_object_ref (folder); m->data = data; m->done = done; @@ -1293,115 +1291,125 @@ folder_is_from_source_uid (CamelFolder *folder, /* This is because pop3 accounts are hidden under local Inbox, * thus whenever an expunge is done on a local trash or Inbox, * then also all active pop3 accounts should be expunged. */ -static void +static gboolean expunge_pop3_stores (CamelFolder *expunging, - EMailSession *session, + EMailBackend *backend, GCancellable *cancellable, GError **error) { + GHashTable *expunging_uids; + EMailSession *session; GPtrArray *uids; - CamelFolder *folder; EAccount *account; EIterator *iter; - guint i; - GHashTable *expunging_uids = NULL; + gboolean success = TRUE; + guint ii; - uids = camel_folder_get_uids (expunging); - if (!uids) - return; - - for (i = 0; i < uids->len; i++) { - CamelMessageInfo *info; + session = e_mail_backend_get_session (backend); - info = camel_folder_get_message_info ( - expunging, uids->pdata[i]); + uids = camel_folder_get_uids (expunging); - if (!info) - continue; + if (uids == NULL) + return TRUE; - if ((camel_message_info_flags (info) & CAMEL_MESSAGE_DELETED) != 0) { - CamelMimeMessage *msg; - GError *local_error = NULL; + expunging_uids = g_hash_table_new_full ( + (GHashFunc) g_str_hash, + (GEqualFunc) g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_free); - /* because the UID in the local store doesn't - * match with the UID in the pop3 store */ - msg = camel_folder_get_message_sync ( - expunging, uids->pdata[i], - cancellable, &local_error); - if (msg) { - const gchar *pop3_uid; + for (ii = 0; ii < uids->len; ii++) { + CamelMessageInfo *info; + CamelMessageFlags flags = 0; + CamelMimeMessage *message; + const gchar *pop3_uid; + const gchar *source_uid; - pop3_uid = camel_medium_get_header ( - CAMEL_MEDIUM (msg), - "X-Evolution-POP3-UID"); - if (pop3_uid) { - gchar *duped; + info = camel_folder_get_message_info ( + expunging, uids->pdata[ii]); - duped = g_strstrip (g_strdup (pop3_uid)); + if (info != NULL) { + flags = camel_message_info_flags (info); + camel_folder_free_message_info (expunging, info); + } - if (!expunging_uids) - expunging_uids = g_hash_table_new_full ( - g_str_hash, g_str_equal, + /* Only interested in deleted messages. */ + if ((flags & CAMEL_MESSAGE_DELETED) == 0) + continue; - g_free, g_free); + /* because the UID in the local store doesn't + * match with the UID in the pop3 store */ + message = camel_folder_get_message_sync ( + expunging, uids->pdata[ii], cancellable, NULL); - g_hash_table_insert ( - expunging_uids, duped, - g_strdup (camel_mime_message_get_source (msg))); - } + if (message == NULL) + continue; - g_object_unref (msg); - } + pop3_uid = camel_medium_get_header ( + CAMEL_MEDIUM (message), "X-Evolution-POP3-UID"); + source_uid = camel_mime_message_get_source (message); - if (local_error) - g_clear_error (&local_error); - } + if (pop3_uid != NULL) + g_hash_table_insert ( + expunging_uids, + g_strstrip (g_strdup (pop3_uid)), + g_strstrip (g_strdup (source_uid))); - camel_folder_free_message_info (expunging, info); + g_object_unref (message); } camel_folder_free_uids (expunging, uids); uids = NULL; - if (!expunging_uids) - return; + if (g_hash_table_size (expunging_uids) == 0) { + g_hash_table_destroy (expunging_uids); + return TRUE; + } for (iter = e_list_get_iterator ((EList *) e_get_account_list ()); - e_iterator_is_valid (iter) && (!error || !*error); - e_iterator_next (iter)) { + e_iterator_is_valid (iter); e_iterator_next (iter)) { account = (EAccount *) e_iterator_get (iter); if (account->enabled && account->source && account->source->url && g_str_has_prefix (account->source->url, "pop://")) { + CamelFolder *folder; gboolean any_found = FALSE; folder = e_mail_session_get_inbox_sync ( session, account->uid, cancellable, error); - if (!folder || (error && *error)) - continue; + + /* Abort the loop on error. */ + if (folder == NULL) { + success = FALSE; + break; + } uids = camel_folder_get_uids (folder); if (uids) { - for (i = 0; i < uids->len; i++) { + for (ii = 0; ii < uids->len; ii++) { /* ensure the ID is from this account, * as it's generated by evolution */ const gchar *source_uid; source_uid = g_hash_table_lookup ( - expunging_uids, uids->pdata[i]); + expunging_uids, uids->pdata[ii]); if (folder_is_from_source_uid (folder, source_uid)) { any_found = TRUE; - camel_folder_delete_message (folder, uids->pdata[i]); + camel_folder_delete_message (folder, uids->pdata[ii]); } } camel_folder_free_uids (folder, uids); } if (any_found) - camel_folder_synchronize_sync (folder, TRUE, cancellable, error); + success = camel_folder_synchronize_sync (folder, TRUE, cancellable, error); g_object_unref (folder); + + /* Abort the loop on error. */ + if (!success) + break; } } @@ -1409,6 +1417,8 @@ expunge_pop3_stores (CamelFolder *expunging, g_object_unref (iter); g_hash_table_destroy (expunging_uids); + + return success; } static gchar * @@ -1424,26 +1434,38 @@ expunge_folder_exec (struct _sync_folder_msg *m, GCancellable *cancellable, GError **error) { - gboolean is_local_inbox_or_trash = - m->folder == e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_INBOX); + CamelFolder *local_inbox; + CamelStore *local_store; + CamelStore *parent_store; + gboolean is_local_inbox_or_trash; + gboolean success = TRUE; - if (!is_local_inbox_or_trash && e_mail_local_get_store () == - camel_folder_get_parent_store (m->folder)) { + local_inbox = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_INBOX); + is_local_inbox_or_trash = (m->folder == local_inbox); + + local_store = e_mail_local_get_store (); + parent_store = camel_folder_get_parent_store (m->folder); + + if (!is_local_inbox_or_trash && local_store == parent_store) { CamelFolder *trash; - trash = e_mail_session_get_trash_sync ( - m->session, "local", cancellable, error); + trash = camel_store_get_trash_folder_sync ( + parent_store, cancellable, error); + + if (trash == NULL) + return; - is_local_inbox_or_trash = m->folder == trash; + is_local_inbox_or_trash = (m->folder == trash); g_object_unref (trash); } /* do this before expunge, to know which messages will be expunged */ - if (is_local_inbox_or_trash && (!error || !*error)) - expunge_pop3_stores (m->folder, m->session, cancellable, error); + if (is_local_inbox_or_trash) + success = expunge_pop3_stores ( + m->folder, m->backend, cancellable, error); - if (!error || !*error) + if (success) camel_folder_expunge_sync (m->folder, cancellable, error); } @@ -1457,19 +1479,14 @@ static MailMsgInfo expunge_folder_info = { }; void -mail_expunge_folder (EMailSession *session, - CamelFolder *folder, - void (*done) (CamelFolder *folder, gpointer data), - gpointer data) +mail_expunge_folder (EMailBackend *backend, + CamelFolder *folder) { struct _sync_folder_msg *m; m = mail_msg_new (&expunge_folder_info); - m->session = g_object_ref (session); - m->folder = folder; - g_object_ref (folder); - m->data = data; - m->done = done; + m->backend = g_object_ref (backend); + m->folder = g_object_ref (folder); mail_msg_slow_ordered_push (m); } @@ -1479,17 +1496,21 @@ mail_expunge_folder (EMailSession *session, struct _empty_trash_msg { MailMsg base; - EMailSession *session; - EAccount *account; - void (*done) (EAccount *account, gpointer data); - gpointer data; + EMailBackend *backend; + CamelStore *store; }; static gchar * empty_trash_desc (struct _empty_trash_msg *m) { - return g_strdup_printf (_("Emptying trash in '%s'"), - m->account ? m->account->name : _("Local Folders")); + CamelService *service; + const gchar *display_name; + + service = CAMEL_SERVICE (m->store); + display_name = camel_service_get_display_name (service); + + return g_strdup_printf ( + _("Emptying trash in '%s'"), display_name); } static void @@ -1497,39 +1518,46 @@ empty_trash_exec (struct _empty_trash_msg *m, GCancellable *cancellable, GError **error) { + CamelService *service; CamelFolder *trash; const gchar *uid; + gboolean success = TRUE; - uid = (m->account != NULL) ? m->account->uid : "local"; + service = CAMEL_SERVICE (m->store); + uid = camel_service_get_uid (service); - trash = e_mail_session_get_trash_sync ( - m->session, uid, cancellable, error); + if (!em_utils_connect_service_sync (service, cancellable, error)) + return; - if (trash) { - /* do this before expunge, to know which messages will be expunged */ - if (!m->account && (!error || !*error)) - expunge_pop3_stores (trash, m->session, cancellable, error); + trash = camel_store_get_trash_folder_sync ( + m->store, cancellable, error); - if (!error || !*error) - camel_folder_expunge_sync (trash, cancellable, error); - g_object_unref (trash); - } + if (trash == NULL) + return; + + /* do this before expunge, to know which messages will be expunged */ + if (g_strcmp0 (uid, "local") == 0) + success = expunge_pop3_stores ( + trash, m->backend, cancellable, error); + + if (success) + camel_folder_expunge_sync (trash, cancellable, error); + + g_object_unref (trash); } static void empty_trash_done (struct _empty_trash_msg *m) { - if (m->done) - m->done (m->account, m->data); } static void empty_trash_free (struct _empty_trash_msg *m) { - if (m->session) - g_object_unref (m->session); - if (m->account) - g_object_unref (m->account); + if (m->backend) + g_object_unref (m->backend); + if (m->store) + g_object_unref (m->store); } static MailMsgInfo empty_trash_info = { @@ -1541,20 +1569,17 @@ static MailMsgInfo empty_trash_info = { }; void -mail_empty_trash (EMailSession *session, - EAccount *account, - void (*done) (EAccount *account, gpointer data), - gpointer data) +mail_empty_trash (EMailBackend *backend, + CamelStore *store) { struct _empty_trash_msg *m; + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (CAMEL_IS_STORE (store)); + m = mail_msg_new (&empty_trash_info); - m->session = g_object_ref (session); - m->account = account; - if (account) - g_object_ref (account); - m->data = data; - m->done = done; + m->backend = g_object_ref (backend); + m->store = g_object_ref (store); mail_msg_slow_ordered_push (m); } diff --git a/mail/mail-ops.h b/mail/mail-ops.h index 9803a6bb85..32784be245 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -27,10 +27,9 @@ G_BEGIN_DECLS #include <camel/camel.h> -#include <libedataserver/e-account.h> #include <mail/mail-mt.h> -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> void mail_transfer_messages (EMailSession *session, CamelFolder *source, @@ -51,14 +50,11 @@ void mail_refresh_folder (CamelFolder *folder, void (*done) (CamelFolder *folder, gpointer data), gpointer data); -void mail_expunge_folder (EMailSession *session, CamelFolder *folder, - void (*done) (CamelFolder *folder, gpointer data), - gpointer data); +void mail_expunge_folder (EMailBackend *backend, + CamelFolder *folder); -void mail_empty_trash (EMailSession *session, - EAccount *account, - void (*done) (EAccount *account, gpointer data), - gpointer data); +void mail_empty_trash (EMailBackend *backend, + CamelStore *store); /* transfer (copy/move) a folder */ void mail_xfer_folder (const gchar *src_uri, const gchar *dest_uri, gboolean remove_source, diff --git a/mail/mail-send-recv.h b/mail/mail-send-recv.h index bba2eac67f..5da6599712 100644 --- a/mail/mail-send-recv.h +++ b/mail/mail-send-recv.h @@ -26,6 +26,7 @@ #include <gtk/gtk.h> #include <camel/camel.h> #include <mail/e-mail-backend.h> +#include <libedataserver/e-account.h> G_BEGIN_DECLS diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 2a7ed99893..71431e3fe0 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -347,12 +347,13 @@ mv_find_folder (GQueue *queue, } static gint -uri_is_ignore (EMailSession *session, const gchar *uri) +uri_is_ignore (EMailBackend *backend, const gchar *uri) { + EMailSession *session; + CamelSession *camel_session; EAccountList *accounts; EAccount *account; EIterator *iter; - CamelSession *camel_session; const gchar *local_drafts_uri; const gchar *local_outbox_uri; const gchar *local_sent_uri; @@ -365,6 +366,7 @@ uri_is_ignore (EMailSession *session, const gchar *uri) local_sent_uri = e_mail_local_get_folder_uri (E_MAIL_LOCAL_FOLDER_SENT); + session = e_mail_backend_get_session (backend); camel_session = CAMEL_SESSION (session); if (e_mail_folder_uri_equal (camel_session, local_outbox_uri, uri)) @@ -468,7 +470,7 @@ mail_vfolder_add_folder (EMailBackend *backend, uri = e_mail_folder_uri_build (store, folder_name); - is_ignore = uri_is_ignore (session, uri); + is_ignore = uri_is_ignore (backend, uri); G_LOCK (vfolder); diff --git a/mail/message-list.c b/mail/message-list.c index 3f55d2cf0f..2529e10e7f 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -38,7 +38,6 @@ #include <gconf/gconf-client.h> -#include "e-util/e-account-utils.h" #include "e-util/e-icon-factory.h" #include "e-util/e-poolv.h" #include "e-util/e-util-private.h" diff --git a/modules/mail/e-mail-shell-backend.h b/modules/mail/e-mail-shell-backend.h index e545fa2566..edec7c67a3 100644 --- a/modules/mail/e-mail-shell-backend.h +++ b/modules/mail/e-mail-shell-backend.h @@ -24,9 +24,6 @@ #include <mail/e-mail-backend.h> -#include <e-util/e-signature-list.h> -#include <libedataserver/e-account-list.h> - /* Standard GObject macros */ #define E_TYPE_MAIL_SHELL_BACKEND \ (e_mail_shell_backend_get_type ()) diff --git a/modules/mail/e-mail-shell-settings.c b/modules/mail/e-mail-shell-settings.c index d795749c82..99402d5f29 100644 --- a/modules/mail/e-mail-shell-settings.c +++ b/modules/mail/e-mail-shell-settings.c @@ -26,9 +26,6 @@ #include "e-mail-shell-settings.h" #include <gconf/gconf-client.h> -#include <libedataserver/e-account-list.h> - -#include <e-util/e-signature-list.h> #include <mail/e-mail-backend.h> #include <mail/e-mail-label-list-store.h> diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 5db80011aa..f4f5ea26f6 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -87,8 +87,11 @@ action_mail_account_disable_cb (GtkAction *action, EMailBackend *backend; EMailSession *session; EMFolderTree *folder_tree; + CamelService *service; + CamelStore *store; EAccountList *account_list; EAccount *account; + const gchar *uid; mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; @@ -99,7 +102,12 @@ action_mail_account_disable_cb (GtkAction *action, session = e_mail_backend_get_session (backend); folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); - account = em_folder_tree_get_selected_account (folder_tree); + store = em_folder_tree_get_selected_store (folder_tree); + g_return_if_fail (store != NULL); + + service = CAMEL_SERVICE (store); + uid = camel_service_get_uid (service); + account = e_get_account_by_uid (uid); g_return_if_fail (account != NULL); account_list = e_get_account_list (); @@ -308,7 +316,6 @@ action_mail_folder_expunge_cb (GtkAction *action, EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; - EMailSession *session; CamelFolder *folder; /* This handles both the "folder-expunge" and "account-expunge" @@ -329,9 +336,10 @@ action_mail_folder_expunge_cb (GtkAction *action, g_return_if_fail (folder != NULL); shell_backend = e_shell_view_get_shell_backend (shell_view); - session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend)); - em_utils_expunge_folder (GTK_WIDGET (shell_window), session, folder); + em_utils_expunge_folder ( + GTK_WIDGET (shell_window), + E_MAIL_BACKEND (shell_backend), folder); } static void @@ -594,17 +602,14 @@ 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), session); + em_utils_empty_trash ( + GTK_WIDGET (shell_window), + E_MAIL_BACKEND (shell_backend)); } static void @@ -1056,9 +1061,8 @@ action_mail_tools_subscriptions_cb (GtkAction *action, EMailBackend *backend; EMailSession *session; EMFolderTree *folder_tree; - EAccount *account; GtkWidget *dialog; - CamelStore *store = NULL; + CamelStore *store; shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); @@ -1066,20 +1070,11 @@ action_mail_tools_subscriptions_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); - account = em_folder_tree_get_selected_account (folder_tree); + store = em_folder_tree_get_selected_store (folder_tree); backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - if (account != NULL) { - CamelService *service; - - service = camel_session_get_service ( - CAMEL_SESSION (session), account->uid); - if (service != NULL) - store = CAMEL_STORE (service); - } - dialog = em_subscription_editor_new ( GTK_WINDOW (shell_window), CAMEL_SESSION (session), store); diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index 73041d7971..5759b5830f 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -828,6 +828,7 @@ mail_shell_view_update_actions (EShellView *shell_view) EMFolderTreeModel *model; EMailReader *reader; EMailView *mail_view; + CamelStore *store; EAccount *account; GtkAction *action; GList *list, *link; @@ -883,7 +884,17 @@ mail_shell_view_update_actions (EShellView *shell_view) (state & E_MAIL_SIDEBAR_STORE_IS_SUBSCRIBABLE); uri = em_folder_tree_get_selected_uri (folder_tree); - account = em_folder_tree_get_selected_account (folder_tree); + store = em_folder_tree_get_selected_store (folder_tree); + + if (store != NULL) { + CamelService *service; + const gchar *uid; + + service = CAMEL_SERVICE (store); + uid = camel_service_get_uid (service); + account = e_get_account_by_uid (uid); + } else + account = NULL; if (uri != NULL) { GtkTreeRowReference *reference; diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c index f8825f701c..d5b1c6697d 100644 --- a/modules/mail/em-composer-prefs.c +++ b/modules/mail/em-composer-prefs.c @@ -569,10 +569,11 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, G_BINDING_SYNC_CREATE); /* Sanitize the dialog for Express mode */ - e_shell_hide_widgets_for_express_mode (shell, prefs->builder, - "chkOutlookFilenames", - "chkTopSignature", - NULL); + e_shell_hide_widgets_for_express_mode ( + shell, prefs->builder, + "chkOutlookFilenames", + "chkTopSignature", + NULL); /* get our toplevel widget */ client = gconf_client_get_default (); |