[evolution-data-server/imap-notify: 38/40] Hack around default Courier namespaces.



commit e2b8984c3b1a87e5aa1b41e38c469a0231d53a5d
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 9a73ae1..a557f16 100644
--- a/camel/camel-imapx-server.c
+++ b/camel/camel-imapx-server.c
@@ -967,6 +967,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 c975ef3..e830f9a 100644
--- a/camel/camel-imapx-store.c
+++ b/camel/camel-imapx-store.c
@@ -1376,6 +1376,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,
@@ -1513,10 +1543,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]