[geary] Respect \NonExistent mailbox attribute: Closes bgo#724703



commit 4caaa3a32d8c25c1e282702b26ea7298ae4fd1c9
Author: Jim Nelson <jim yorba org>
Date:   Thu Feb 20 12:53:52 2014 -0800

    Respect \NonExistent mailbox attribute: Closes bgo#724703

 src/engine/imap/api/imap-account.vala              |    4 ++--
 src/engine/imap/api/imap-folder-properties.vala    |    2 +-
 .../imap/response/imap-mailbox-attribute.vala      |    6 ++++++
 .../imap/response/imap-mailbox-attributes.vala     |   11 +++++++++++
 4 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/imap/api/imap-account.vala b/src/engine/imap/api/imap-account.vala
index 090e582..d3a9092 100644
--- a/src/engine/imap/api/imap-account.vala
+++ b/src/engine/imap/api/imap-account.vala
@@ -182,7 +182,7 @@ private class Geary.Imap.Account : BaseObject {
             throw_not_found(path);
         
         Imap.Folder folder;
-        if (!mailbox_info.attrs.contains(MailboxAttribute.NO_SELECT)) {
+        if (!mailbox_info.attrs.is_no_select) {
             StatusData status = yield fetch_status_async(path, cancellable);
             
             folder = new Imap.Folder(session_mgr, status, mailbox_info);
@@ -240,7 +240,7 @@ private class Geary.Imap.Account : BaseObject {
             StatusCommand, MailboxSpecifier>();
         foreach (MailboxInformation mailbox_info in child_info) {
             // if new mailbox is unselectable, don't bother doing a STATUS command
-            if (mailbox_info.attrs.contains(MailboxAttribute.NO_SELECT)) {
+            if (mailbox_info.attrs.is_no_select) {
                 Imap.Folder folder = new Imap.Folder.unselectable(session_mgr, mailbox_info);
                 folders.set(folder.path, folder);
                 child_folders.add(folder);
diff --git a/src/engine/imap/api/imap-folder-properties.vala b/src/engine/imap/api/imap-folder-properties.vala
index ce1bbf8..4b7b4b3 100644
--- a/src/engine/imap/api/imap-folder-properties.vala
+++ b/src/engine/imap/api/imap-folder-properties.vala
@@ -166,7 +166,7 @@ public class Geary.Imap.FolderProperties : Geary.FolderProperties {
                 has_children = Trillian.FALSE;
         }
         
-        is_openable = Trillian.from_boolean(!attrs.contains(MailboxAttribute.NO_SELECT));
+        is_openable = Trillian.from_boolean(!attrs.is_no_select);
     }
     
     /**
diff --git a/src/engine/imap/response/imap-mailbox-attribute.vala 
b/src/engine/imap/response/imap-mailbox-attribute.vala
index 8a7daa9..cc4c0d8 100644
--- a/src/engine/imap/response/imap-mailbox-attribute.vala
+++ b/src/engine/imap/response/imap-mailbox-attribute.vala
@@ -22,6 +22,11 @@ public class Geary.Imap.MailboxAttribute : Geary.Imap.Flag {
         return _no_inferiors;
     } }
     
+    private static MailboxAttribute? _nonexistent = null;
+    public static MailboxAttribute NONEXISTENT { get {
+        return (_nonexistent != null) ? _nonexistent : _nonexistent = new MailboxAttribute("\\NonExistent");
+    } }
+    
     private static MailboxAttribute? _no_select = null;
     public static MailboxAttribute NO_SELECT { get {
         if (_no_select == null)
@@ -165,6 +170,7 @@ public class Geary.Imap.MailboxAttribute : Geary.Imap.Flag {
     // Call these at init time to prevent thread issues
     internal static void init() {
         MailboxAttribute to_init = NO_INFERIORS;
+        to_init = NONEXISTENT;
         to_init = NO_SELECT;
         to_init = MARKED;
         to_init = UNMARKED;
diff --git a/src/engine/imap/response/imap-mailbox-attributes.vala 
b/src/engine/imap/response/imap-mailbox-attributes.vala
index ad4d1f1..b23af14 100644
--- a/src/engine/imap/response/imap-mailbox-attributes.vala
+++ b/src/engine/imap/response/imap-mailbox-attributes.vala
@@ -12,6 +12,17 @@
  */
 
 public class Geary.Imap.MailboxAttributes : Geary.Imap.Flags {
+    /**
+     * True if the mailbox should not be accessed via SELECT, EXAMINE, or STATUS, i.e. is a
+     * "no-select" mailbox.
+     *
+     * See [[http://tools.ietf.org/html/rfc3501#section-7.2.2]] and
+     * [[http://tools.ietf.org/html/rfc5258#section-3]]
+     */
+    public bool is_no_select { get {
+        return contains(MailboxAttribute.NO_SELECT) || contains(MailboxAttribute.NONEXISTENT);
+    } }
+    
     public MailboxAttributes(Gee.Collection<MailboxAttribute> attrs) {
         base (attrs);
     }


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