[evolution-data-server] Bug 767821 - Recognize X-GM-EXT-1 as SPECIAL-USE for Gmail IMAP



commit d5d7b43fdf782b3a396feac1a748be6c75175853
Author: Zisu Andrei <matzipan gmail com>
Date:   Tue Nov 8 17:11:50 2016 +0100

    Bug 767821 - Recognize X-GM-EXT-1 as SPECIAL-USE for Gmail IMAP

 src/camel/camel-enums.h                        |   42 ++++++++++++++++++++++--
 src/camel/providers/imapx/camel-imapx-server.c |    2 +-
 src/camel/providers/imapx/camel-imapx-store.c  |   28 ++++++++++++++++
 src/camel/providers/imapx/camel-imapx-utils.c  |    3 +-
 src/camel/providers/imapx/camel-imapx-utils.h  |    4 ++-
 5 files changed, 73 insertions(+), 6 deletions(-)
---
diff --git a/src/camel/camel-enums.h b/src/camel/camel-enums.h
index e20578e..d456579 100644
--- a/src/camel/camel-enums.h
+++ b/src/camel/camel-enums.h
@@ -97,6 +97,18 @@ typedef enum { /*< flags >*/
  *    The folder contains memos, instead of mail messages.
  * @CAMEL_FOLDER_TYPE_TASKS:
  *    The folder contains tasks, instead of mail messages.
+ * @CAMEL_FOLDER_TYPE_ALL
+ *    This folder contains all the messages. Used by RFC 6154.
+ * @CAMEL_FOLDER_TYPE_ARCHIVE
+ *    This folder contains archived messages. Used by RFC 6154.
+ * @CAMEL_FOLDER_TYPE_DRAFTS
+ *    This folder contains drafts. Used by RFC 6154.
+ * @CAMEL_FOLDER_READONLY:
+ *    The folder is read only.
+ * @CAMEL_FOLDER_WRITEONLY:
+ *    The folder is write only.
+ * @CAMEL_FOLDER_FLAGGED:
+ *    This folder contains flagged messages. Some clients call this "starred". Used by RFC 6154.
  *
  * These flags are abstractions.  It's up to the CamelProvider to give
  * them suitable interpretations.  Use #CAMEL_FOLDER_TYPE_MASK to isolate
@@ -115,6 +127,7 @@ typedef enum { /*< flags >*/
        CAMEL_FOLDER_VTRASH = 1 << 7,
        CAMEL_FOLDER_SHARED_TO_ME = 1 << 8,
        CAMEL_FOLDER_SHARED_BY_ME = 1 << 9,
+
        CAMEL_FOLDER_TYPE_NORMAL = 0 << CAMEL_FOLDER_TYPE_BIT,
        CAMEL_FOLDER_TYPE_INBOX = 1 << CAMEL_FOLDER_TYPE_BIT,
        CAMEL_FOLDER_TYPE_OUTBOX = 2 << CAMEL_FOLDER_TYPE_BIT,
@@ -125,14 +138,18 @@ typedef enum { /*< flags >*/
        CAMEL_FOLDER_TYPE_EVENTS = 7 << CAMEL_FOLDER_TYPE_BIT,
        CAMEL_FOLDER_TYPE_MEMOS = 8 << CAMEL_FOLDER_TYPE_BIT,
        CAMEL_FOLDER_TYPE_TASKS = 9 << CAMEL_FOLDER_TYPE_BIT,
+       CAMEL_FOLDER_TYPE_ALL = 10 << CAMEL_FOLDER_TYPE_BIT,
+       CAMEL_FOLDER_TYPE_ARCHIVE = 11 << CAMEL_FOLDER_TYPE_BIT,
+       CAMEL_FOLDER_TYPE_DRAFTS = 12 << CAMEL_FOLDER_TYPE_BIT,
+
        CAMEL_FOLDER_READONLY = 1 << 16,
-       /* empty gap from unused flag removal */
+       CAMEL_FOLDER_WRITEONLY = 1 << 17,
        CAMEL_FOLDER_FLAGGED = 1 << 18,
 
        CAMEL_FOLDER_FLAGS_LAST    = 1 << 24  /*< skip >*/
 } CamelFolderInfoFlags;
 
-#define CAMEL_FOLDER_TYPE_MASK (63 << CAMEL_FOLDER_TYPE_BIT)
+#define CAMEL_FOLDER_TYPE_MASK (0x3F << CAMEL_FOLDER_TYPE_BIT)
 
 /* Note: The HTML elements are escaped in the doc comment intentionally,
  *       to have them shown as expected in generated documentation. */
@@ -179,6 +196,8 @@ typedef enum { /*< flags >*/
        CAMEL_MIME_FILTER_TOHTML_QUOTE_CITATION = 1 << 10
 } CamelMimeFilterToHTMLFlags;
 
+#define CAMEL_STORE_INFO_FOLDER_TYPE_BIT (10)
+
 /* WARNING: This enum and CamelFolderInfoFlags must stay in sync.
  * FIXME: Eliminate the need for two separate types. */
 typedef enum { /*< flags >*/
@@ -192,13 +211,30 @@ typedef enum { /*< flags >*/
        CAMEL_STORE_INFO_FOLDER_VTRASH = 1 << 7,
        CAMEL_STORE_INFO_FOLDER_SHARED_TO_ME = 1 << 8,
        CAMEL_STORE_INFO_FOLDER_SHARED_BY_ME = 1 << 9,
+
+       CAMEL_STORE_INFO_FOLDER_TYPE_NORMAL = 0 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_INBOX = 1 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_OUTBOX = 2 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_TRASH = 3 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_JUNK = 4 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_SENT = 5 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_CONTACTS = 6 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_EVENTS = 7 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_MEMOS = 8 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_TASKS = 9 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_ALL = 10 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_ARCHIVE = 11 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+       CAMEL_STORE_INFO_FOLDER_TYPE_DRAFTS = 12 << CAMEL_STORE_INFO_FOLDER_TYPE_BIT,
+
        CAMEL_STORE_INFO_FOLDER_READONLY = 1 << 16,
-       /* empty gap from unused flag removal */
+       CAMEL_STORE_INFO_FOLDER_WRITEONLY = 1 << 17,
        CAMEL_STORE_INFO_FOLDER_FLAGGED = 1 << 18,
 
        CAMEL_STORE_INFO_FOLDER_LAST          = 1 << 24  /*< skip >*/
 } CamelStoreInfoFlags;
 
+#define CAMEL_STORE_INFO_FOLDER_TYPE_MASK  (0x3F << CAMEL_STORE_INFO_FOLDER_TYPE_BIT)
+
 /**
  * CamelFetchHeadersType:
  * @CAMEL_FETCH_HEADERS_BASIC:
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index 1c91744..2e9bbef 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -621,7 +621,7 @@ imapx_server_stash_command_arguments (CamelIMAPXServer *is)
                        g_string_append_printf (
                                buffer, " STATUS (%s)",
                                is->priv->status_data_items);
-               if (CAMEL_IMAPX_HAVE_CAPABILITY (is->priv->cinfo, SPECIAL_USE))
+               if (CAMEL_IMAPX_HAVE_CAPABILITY (is->priv->cinfo, SPECIAL_USE) || CAMEL_IMAPX_HAVE_CAPABILITY 
(is->priv->cinfo, X_GM_EXT_1))
                        g_string_append_printf (buffer, " SPECIAL-USE");
                is->priv->list_return_opts = g_string_free (buffer, FALSE);
        } else {
diff --git a/src/camel/providers/imapx/camel-imapx-store.c b/src/camel/providers/imapx/camel-imapx-store.c
index 9a8282e..292071a 100644
--- a/src/camel/providers/imapx/camel-imapx-store.c
+++ b/src/camel/providers/imapx/camel-imapx-store.c
@@ -395,6 +395,34 @@ imapx_store_mailbox_attributes_to_flags (CamelIMAPXMailbox *mailbox)
        /* XXX Does "\Marked" mean CAMEL_STORE_INFO_FOLDER_FLAGGED?
         *     Who the heck knows; the enum value is undocumented. */
 
+       attribute = CAMEL_IMAPX_LIST_ATTR_FLAGGED;
+       if (camel_imapx_mailbox_has_attribute (mailbox, attribute))
+               store_info_flags |= CAMEL_STORE_INFO_FOLDER_FLAGGED;
+
+       attribute = CAMEL_IMAPX_LIST_ATTR_ALL;
+       if (camel_imapx_mailbox_has_attribute (mailbox, attribute))
+               store_info_flags |= CAMEL_STORE_INFO_FOLDER_TYPE_ALL;
+
+       attribute = CAMEL_IMAPX_LIST_ATTR_ARCHIVE;
+       if (camel_imapx_mailbox_has_attribute (mailbox, attribute))
+               store_info_flags |= CAMEL_STORE_INFO_FOLDER_TYPE_ARCHIVE;
+
+       attribute = CAMEL_IMAPX_LIST_ATTR_DRAFTS;
+       if (camel_imapx_mailbox_has_attribute (mailbox, attribute))
+               store_info_flags |= CAMEL_STORE_INFO_FOLDER_TYPE_DRAFTS;
+
+       attribute = CAMEL_IMAPX_LIST_ATTR_JUNK;
+       if (camel_imapx_mailbox_has_attribute (mailbox, attribute))
+               store_info_flags |= CAMEL_STORE_INFO_FOLDER_TYPE_JUNK;
+
+       attribute = CAMEL_IMAPX_LIST_ATTR_SENT;
+       if (camel_imapx_mailbox_has_attribute (mailbox, attribute))
+               store_info_flags |= CAMEL_STORE_INFO_FOLDER_TYPE_SENT;
+
+       attribute = CAMEL_IMAPX_LIST_ATTR_TRASH;
+       if (camel_imapx_mailbox_has_attribute (mailbox, attribute))
+               store_info_flags |= CAMEL_STORE_INFO_FOLDER_TYPE_TRASH;
+
        return store_info_flags;
 }
 
diff --git a/src/camel/providers/imapx/camel-imapx-utils.c b/src/camel/providers/imapx/camel-imapx-utils.c
index 3d981f4..5c3119e 100644
--- a/src/camel/providers/imapx/camel-imapx-utils.c
+++ b/src/camel/providers/imapx/camel-imapx-utils.c
@@ -476,7 +476,8 @@ struct {
        { "QUOTA", IMAPX_CAPABILITY_QUOTA },
        { "MOVE", IMAPX_CAPABILITY_MOVE },
        { "NOTIFY", IMAPX_CAPABILITY_NOTIFY },
-       { "SPECIAL-USE", IMAPX_CAPABILITY_SPECIAL_USE }
+       { "SPECIAL-USE", IMAPX_CAPABILITY_SPECIAL_USE },
+       { "X-GM-EXT-1", IMAPX_CAPABILITY_X_GM_EXT_1 }
 };
 
 static GMutex capa_htable_lock;         /* capabilities lookup table lock */
diff --git a/src/camel/providers/imapx/camel-imapx-utils.h b/src/camel/providers/imapx/camel-imapx-utils.h
index d9d7e34..f9970d8 100644
--- a/src/camel/providers/imapx/camel-imapx-utils.h
+++ b/src/camel/providers/imapx/camel-imapx-utils.h
@@ -185,7 +185,9 @@ enum {
        IMAPX_CAPABILITY_QUOTA = (1 << 12),
        IMAPX_CAPABILITY_MOVE = (1 << 13),
        IMAPX_CAPABILITY_NOTIFY = (1 << 14),
-       IMAPX_CAPABILITY_SPECIAL_USE = (1 << 15)
+       IMAPX_CAPABILITY_SPECIAL_USE = (1 << 15),
+       IMAPX_CAPABILITY_X_GM_EXT_1 = (1 << 16)
+
 };
 
 struct _capability_info {


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