[evolution/gnome-3-8] e_mail_folder_uri_parse: Handle local mbox folder URIs.



commit ac480dcea5e584a54adf4c5a6b832e49c70f7fe7
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Apr 8 08:25:35 2013 -0400

    e_mail_folder_uri_parse: Handle local mbox folder URIs.
    
    In Evolution 2.x, the local mail store used mbox format.  Camel will not
    recognize the old-style "mbox:///.../local" folder URIs, since the local
    mail store is now Maildir format.  Test for this and work around it.
    
    This should re-fix bug 638307 which was a nuisance error about failing
    to append to a "mbox:///.../local#Sent" folder after sending a message.
    
    (cherry picked from commit 94372b5f1857b66d1ae7e14a37075122b5c8336c)

 libemail-engine/e-mail-folder-utils.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/libemail-engine/e-mail-folder-utils.c b/libemail-engine/e-mail-folder-utils.c
index bd45f35..bbc1bdc 100644
--- a/libemail-engine/e-mail-folder-utils.c
+++ b/libemail-engine/e-mail-folder-utils.c
@@ -1873,8 +1873,30 @@ e_mail_folder_uri_parse (CamelSession *session,
         * To determine which it is, you have to check the provider
         * flags for CAMEL_URL_FRAGMENT_IS_PATH. */
        } else {
-               service = camel_session_ref_service_by_url (
-                       session, url, CAMEL_PROVIDER_STORE);
+               gboolean local_mbox_folder;
+
+               /* In Evolution 2.x, the local mail store used mbox
+                * format.  camel_session_ref_service_by_url() won't
+                * match "mbox:///.../mail/local" folder URIs, since
+                * the local mail store is now Maildir format.  Test
+                * for this corner case and work around it.
+                *
+                * The folder path is kept in the fragment part of the
+                * URL which makes it easy to test the filesystem path.
+                * The suffix "evolution/mail/local" should match both
+                * the current XDG-compliant location and the old "dot
+                * folder" location (~/.evolution/mail/local). */
+               local_mbox_folder =
+                       (g_strcmp0 (url->protocol, "mbox") == 0) &&
+                       (url->path != NULL) &&
+                       g_str_has_suffix (url->path, "evolution/mail/local");
+
+               if (local_mbox_folder) {
+                       service = camel_session_ref_service (session, "local");
+               } else {
+                       service = camel_session_ref_service_by_url (
+                               session, url, CAMEL_PROVIDER_STORE);
+               }
 
                if (CAMEL_IS_STORE (service)) {
                        CamelProvider *provider;


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