[evolution-data-server] Hack around default Courier namespaces.



commit 35044719bba6d45125db2bbf62b50b37c94a5e64
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Sep 12 09:32:04 2013 -0400

    Hack around default Courier namespaces.
    
    By default, Courier lists (("INBOX." ".")) for its personal namespaces,
    which excludes INBOX itself.  This causes problems for us so check for
    it specifically and hack around it where necessary.

 camel/camel-imapx-server.c |   11 +++++++++++
 camel/camel-imapx-store.c  |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-imapx-server.c b/camel/camel-imapx-server.c
index e3a498c..77db9e4 100644
--- a/camel/camel-imapx-server.c
+++ b/camel/camel-imapx-server.c
@@ -970,6 +970,17 @@ imapx_server_create_mailbox_unlocked (CamelIMAPXServer *is,
                mailbox = camel_imapx_mailbox_new (response, namespace);
                imapx_server_add_mailbox_unlocked (is, mailbox);
                g_object_unref (namespace);
+
+       /* XXX Slight hack, mainly for Courier servers.  If INBOX does
+        *     not match any defined namespace, just create one for it
+        *     on the fly.  The namespace response won't know about it. */
+       } else if (camel_imapx_mailbox_is_inbox (mailbox_name)) {
+               namespace = camel_imapx_namespace_new (
+                       CAMEL_IMAPX_NAMESPACE_PERSONAL, "", separator);
+               mailbox = camel_imapx_mailbox_new (response, namespace);
+               imapx_server_add_mailbox_unlocked (is, mailbox);
+               g_object_unref (namespace);
+
        } else {
                g_warning (
                        "%s: No matching namespace for \"%c\" %s",
diff --git a/camel/camel-imapx-store.c b/camel/camel-imapx-store.c
index fa975ad..53a2357 100644
--- a/camel/camel-imapx-store.c
+++ b/camel/camel-imapx-store.c
@@ -1446,6 +1446,36 @@ fetch_folder_info_for_pattern (CamelIMAPXServer *server,
 }
 
 static gboolean
+fetch_folder_info_for_inbox (CamelIMAPXServer *server,
+                             CamelStoreGetFolderInfoFlags flags,
+                             GHashTable *folder_info_results,
+                             GCancellable *cancellable,
+                             GError **error)
+{
+       gboolean success;
+
+       success = camel_imapx_server_list (
+               server, "INBOX", flags, cancellable, error);
+
+       if (success) {
+               CamelIMAPXStore *imapx_store;
+               CamelIMAPXMailbox *mailbox;
+
+               mailbox = camel_imapx_server_ref_mailbox (server, "INBOX");
+               g_return_val_if_fail (mailbox != NULL, FALSE);
+
+               imapx_store = camel_imapx_server_ref_store (server);
+
+               collect_folder_info_for_list (
+                       imapx_store, mailbox, folder_info_results);
+
+               g_object_unref (imapx_store);
+       }
+
+       return success;
+}
+
+static gboolean
 fetch_folder_info_for_namespace_category (CamelIMAPXServer *server,
                                           CamelIMAPXNamespaceCategory category,
                                           CamelStoreGetFolderInfoFlags flags,
@@ -1583,10 +1613,23 @@ sync_folders (CamelIMAPXStore *imapx_store,
                        server, root_folder_path, flags,
                        folder_info_results, cancellable, error);
        } else {
+               gboolean have_folder_info_for_inbox;
+
                /* XXX We only fetch personal mailboxes at this time. */
                success = fetch_folder_info_for_namespace_category (
                        server, CAMEL_IMAPX_NAMESPACE_PERSONAL, flags,
                        folder_info_results, cancellable, error);
+
+               have_folder_info_for_inbox =
+                       g_hash_table_contains (folder_info_results, "INBOX");
+
+               /* XXX Slight hack, mainly for Courier servers.  If INBOX
+                *     is not included in any defined personal namespaces,
+                *     then LIST it explicitly. */
+               if (success && !have_folder_info_for_inbox)
+                       success = fetch_folder_info_for_inbox (
+                               server, flags, folder_info_results,
+                               cancellable, error);
        }
 
        /* Don't need to test for zero, just decrement atomically. */


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