commit d4527f9cca2f41abffc9215de6cfee4fe65abe1c
Author: Zisu Andrei <matzipan@gmail.com>
Date:   Mon Jun 27 16:45:07 2016 +0200

    Add missing folder type flags and clean up

diff --git a/camel/camel-enums.h b/camel/camel-enums.h
index 5ca476f..f3d9f70 100644
--- a/camel/camel-enums.h
+++ b/camel/camel-enums.h
@@ -50,7 +50,7 @@ typedef enum { /*< flags >*/
 	CAMEL_FOLDER_FILTER_JUNK = 1 << 6
 } CamelFolderFlags;
 
-#define CAMEL_FOLDER_TYPE_BIT (10)
+#define CAMEL_FOLDER_TYPE_BIT (19)
 
 /**
  * CamelFolderInfoFlags:
@@ -77,6 +77,8 @@ typedef enum { /*< flags >*/
  *    A folder being shared by someone else.
  * @CAMEL_FOLDER_SHARED_BY_ME:
  *    A folder being shared by the user.
+ * @CAMEL_FOLDER_READONLY:
+ *    The folder is read only.
  * @CAMEL_FOLDER_TYPE_NORMAL:
  *    The folder is a normal folder.
  * @CAMEL_FOLDER_TYPE_INBOX:
@@ -97,6 +99,14 @@ 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_FLAGGED:
+ *    This folder contains flagged messages. Some clients call this "starred. Used by RFC 6154.
+ * @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.
  *
  * These flags are abstractions.  It's up to the CamelProvider to give
  * them suitable interpretations.  Use #CAMEL_FOLDER_TYPE_MASK to isolate
@@ -115,6 +125,11 @@ typedef enum { /*< flags >*/
 	CAMEL_FOLDER_VTRASH = 1 << 7,
 	CAMEL_FOLDER_SHARED_TO_ME = 1 << 8,
 	CAMEL_FOLDER_SHARED_BY_ME = 1 << 9,
+
+	CAMEL_FOLDER_READONLY = 1 << 16,
+	CAMEL_FOLDER_WRITEONLY = 1 << 17,
+	CAMEL_FOLDER_FLAGGED = 1 << 18,
+
 	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 +140,17 @@ 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_READONLY = 1 << 16,
-	/* empty gap from unused flag removal */
-	CAMEL_FOLDER_FLAGGED = 1 << 18,
+	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_FLAGS_LAST    = 1 << 24  /*< skip >*/
 } CamelFolderInfoFlags;
 
-#define CAMEL_FOLDER_TYPE_MASK (63 << CAMEL_FOLDER_TYPE_BIT)
+#define CAMEL_FOLDER_TYPE_MASK (0xF << CAMEL_FOLDER_TYPE_BIT)
+
+#define CAMEL_STORE_INFO_FOLDER_TYPE_BIT (19)
+
 
 /* Note: The HTML elements are escaped in the doc comment intentionally,
  *       to have them shown as expected in generated documentation. */
@@ -192,13 +210,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_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_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_LAST          = 1 << 24  /*< skip >*/
 } CamelStoreInfoFlags;
 
+#define CAMEL_STORE_INFO_FOLDER_TYPE_MASK  (0xF << CAMEL_STORE_INFO_FOLDER_TYPE_BIT)
+
 /**
  * CamelFetchHeadersType:
  * @CAMEL_FETCH_HEADERS_BASIC:
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 8271bc8..6bdc244 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -394,6 +394,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;
 }
 
commit a6f04348334bed624bbe20506fa30a954f63c747
Author: Zisu Andrei <matzipan@gmail.com>
Date:   Mon Jun 27 15:09:55 2016 +0200

    Add check for the Gmail's IMAP extension capability

diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 569d9ad..e028e62 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -619,7 +619,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/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 7a94724..4c9d107 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -465,7 +465,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/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index 7fc055b..ac82418 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -186,7 +186,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 {
