From 540acdbfa95d29a66ad94bad68222b5ae9c98720 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 2 Jun 2013 09:23:58 -0400 Subject: Simplify em_utils_forward_message() arguments. Replace the EShell and CamelSession arguments with a single EMailBackend argument, from which both the EShell and CamelSession can be obtained. --- modules/mail/e-mail-attachment-handler.c | 36 +++++++++++++------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'modules/mail') diff --git a/modules/mail/e-mail-attachment-handler.c b/modules/mail/e-mail-attachment-handler.c index 5e328c4aab..fbd076227c 100644 --- a/modules/mail/e-mail-attachment-handler.c +++ b/modules/mail/e-mail-attachment-handler.c @@ -35,8 +35,7 @@ ((obj), E_TYPE_MAIL_ATTACHMENT_HANDLER, EMailAttachmentHandlerPrivate)) struct _EMailAttachmentHandlerPrivate { - EShell *shell; - EMailSession *session; + EMailBackend *backend; }; static gpointer parent_class; @@ -153,9 +152,7 @@ mail_attachment_handler_forward (GtkAction *action, style = g_settings_get_enum (settings, "forward-style-name"); g_object_unref (settings); - em_utils_forward_message ( - priv->shell, CAMEL_SESSION (priv->session), - message, style, NULL, NULL); + em_utils_forward_message (priv->backend, message, style, NULL, NULL); g_object_unref (message); } @@ -168,6 +165,8 @@ mail_attachment_handler_reply (EAttachmentHandler *handler, GSettings *settings; EMailReplyStyle style; CamelMimeMessage *message; + EShellBackend *shell_backend; + EShell *shell; priv = E_MAIL_ATTACHMENT_HANDLER_GET_PRIVATE (handler); @@ -178,9 +177,11 @@ mail_attachment_handler_reply (EAttachmentHandler *handler, style = g_settings_get_enum (settings, "reply-style-name"); g_object_unref (settings); + shell_backend = E_SHELL_BACKEND (priv->backend); + shell = e_shell_backend_get_shell (shell_backend); + em_utils_reply_to_message ( - priv->shell, message, - NULL, NULL, reply_type, style, NULL, NULL); + shell, message, NULL, NULL, reply_type, style, NULL, NULL); g_object_unref (message); } @@ -306,6 +307,7 @@ mail_attachment_handler_x_uid_list (EAttachmentView *view, CamelFolder *folder = NULL; EAttachment *attachment; EAttachmentStore *store; + EMailSession *session; GPtrArray *uids; const gchar *data; const gchar *cp, *end; @@ -354,10 +356,12 @@ mail_attachment_handler_x_uid_list (EAttachmentView *view, if (uids->len == 0) goto exit; + session = e_mail_backend_get_session (priv->backend); + /* The first string is the folder URI. */ /* FIXME Not passing a GCancellable here. */ folder = e_mail_session_uri_to_folder_sync ( - priv->session, data, 0, NULL, &local_error); + session, data, 0, NULL, &local_error); if (folder == NULL) goto exit; @@ -507,15 +511,7 @@ mail_attachment_handler_dispose (GObject *object) priv = E_MAIL_ATTACHMENT_HANDLER_GET_PRIVATE (object); - if (priv->shell != NULL) { - g_object_unref (priv->shell); - priv->shell = NULL; - } - - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; - } + g_clear_object (&priv->backend); /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); @@ -529,7 +525,6 @@ mail_attachment_handler_constructed (GObject *object) EShellBackend *shell_backend; EAttachmentHandler *handler; EAttachmentView *view; - EMailSession *session; GtkActionGroup *action_group; GtkUIManager *ui_manager; GError *error = NULL; @@ -542,10 +537,7 @@ mail_attachment_handler_constructed (GObject *object) shell = e_shell_get_default (); shell_backend = e_shell_get_backend_by_name (shell, "mail"); - session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend)); - - priv->shell = g_object_ref (shell); - priv->session = g_object_ref (session); + priv->backend = g_object_ref (shell_backend); view = e_attachment_handler_get_view (handler); -- cgit v1.2.3