lowercase the name of the inbox
[org.ibex.mail.git] / src / org / ibex / mail / IMAP.java
index 27e6643..f97e771 100644 (file)
@@ -117,11 +117,9 @@ public class IMAP {
             if (name.equalsIgnoreCase("inbox")) return inbox;
             if (name.equalsIgnoreCase("trash")) name = "trash";
             MailTree mt =  mailboxTree(name, create, throwexn);
-            /* FIXME: throw throwexn here
-            if (mt==null || mt.getMailbox()==null)
-                Log.error("mt==null", name);
-            */
-            return mt==null ? null : mt.getMailbox();
+            Mailbox ret = mt==null ? null : mt.getMailbox();
+            if (ret==null && throwexn) throw new Server.No("no such mailbox " + name);
+            return ret;
         }
         private MailTree mailboxTree(String name, boolean create) { return mailboxTree(name, create, true); }
         private MailTree mailboxTree(String name, boolean create, boolean throwexn) {
@@ -232,7 +230,8 @@ public class IMAP {
             Vec.Int vec = new Vec.Int();
             for(Mailbox.Iterator it = selected().iterator(q); it.next();) {
                 vec.addElement(uid ? it.uid() : it.imapNumber());
-                it.setFlags(it.getFlags() & ~Mailbox.Flag.RECENT);
+                if ((it.getFlags() & Mailbox.Flag.RECENT) != 0)
+                    it.setFlags(it.getFlags() & ~Mailbox.Flag.RECENT);
             }
             return vec.dump();
         }
@@ -295,7 +294,7 @@ public class IMAP {
             } else {
                 Account account = (Account)ret;
                 ((MailboxWrapper)api).root = root = account.getMailbox(IMAP.class);
-                MailTree ibt = root.slash("INBOX", false);
+                MailTree ibt = root.slash("inbox", false);
                 Mailbox ib = ibt==null ? null : ibt.getMailbox();
                 ((MailboxWrapper)api).inbox = inbox = ib;
             }