[evolution] Reuse existing mail session when generating import preview



commit 6cde828d5893c81f6e88dcf440a53e19ba824c5f
Author: Milan Crha <mcrha redhat com>
Date:   Fri Oct 2 10:23:20 2020 +0200

    Reuse existing mail session when generating import preview
    
    No need to create a new EMailSession when one already exists.

 src/modules/mail/e-mail-shell-backend.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/modules/mail/e-mail-shell-backend.c b/src/modules/mail/e-mail-shell-backend.c
index b1c756bd67..05d823c6db 100644
--- a/src/modules/mail/e-mail-shell-backend.c
+++ b/src/modules/mail/e-mail-shell-backend.c
@@ -151,10 +151,10 @@ mbox_fill_preview_cb (GObject *preview,
                       CamelMimeMessage *msg)
 {
        EShell *shell;
+       EShellBackend *shell_backend;
        EMailDisplay *display;
        EMailParser *parser;
-       EMailSession *mail_session;
-       ESourceRegistry *registry;
+       EMailSession *mail_session = NULL;
 
        g_return_if_fail (preview != NULL);
        g_return_if_fail (msg != NULL);
@@ -163,8 +163,21 @@ mbox_fill_preview_cb (GObject *preview,
        g_return_if_fail (display != NULL);
 
        shell = e_shell_get_default ();
-       registry = e_shell_get_registry (shell);
-       mail_session = e_mail_session_new (registry);
+       shell_backend = e_shell_get_backend_by_name (shell, BACKEND_NAME);
+
+       if (E_IS_MAIL_BACKEND (shell_backend)) {
+               mail_session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
+
+               if (mail_session)
+                       g_object_ref (mail_session);
+       }
+
+       if (!mail_session) {
+               ESourceRegistry *registry;
+
+               registry = e_shell_get_registry (shell);
+               mail_session = e_mail_session_new (registry);
+       }
 
        parser = e_mail_parser_new (CAMEL_SESSION (mail_session));
        e_mail_parser_parse (


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]