fix rename with imap fake server, and be more forgiving w/ subscribe/unsubscribe, r=jcranmer, 497959
authorDavid Bienvenu <bienvenu@nventure.com>
Thu, 18 Jun 2009 14:11:44 -0700
changeset 2882 5d88125ac184911ba4a6e44cee0e518c3ff6a955
parent 2881 d2339f2c412c9d53a61579a345eb9e7344ce84c4
child 2883 25a32bafab5708d33aa91b14737e444256aa3e44
push idunknown
push userunknown
push dateunknown
reviewersjcranmer, 497959
bugs497959
fix rename with imap fake server, and be more forgiving w/ subscribe/unsubscribe, r=jcranmer, 497959
mailnews/test/fakeserver/imapd.js
--- a/mailnews/test/fakeserver/imapd.js
+++ b/mailnews/test/fakeserver/imapd.js
@@ -132,19 +132,21 @@ imapDaemon.prototype = {
       box = box.getChild(component);
       // Yes, we won't autocreate intermediary boxes
       if (box == null || box.flags.indexOf('\\Noinferiors') != -1)
         return false;
     }
     // If this is an imapMailbox...
     if (oldBox && oldBox._children) {
       // Only delete now so we don't screw ourselves up if creation fails
-      this._deleteMailbox(oldBox);
-      mailbox._parent = box == this.root ? null : box;
-      box.addMailbox(oldBox);
+      this.deleteMailbox(oldBox);
+      oldBox._parent = box == this.root ? null : box;
+      let newBox = new imapMailbox(oldBox.name, box, this.uidvalidity++);
+      newBox._messages = oldBox._messages;
+      box.addMailbox(newBox);
 
       // And if oldBox is an INBOX, we need to recreate that
       if (oldBox.name == "INBOX") {
         this.inbox = new imapMailbox("INBOX", null, this.uidvalidity++);
         this.root.addMailbox(this.inbox);
       }
       oldBox.name = subName;
     } else if (oldBox) {
@@ -953,27 +955,26 @@ IMAP_RFC3501_handler.prototype = {
     if (!mbox || mbox.name == "")
       return "NO no such mailbox";
     if (!this._daemon.createMailbox(args[1], mbox))
       return "NO cannot rename mailbox";
     return "OK RENAME completed";
   },
   SUBSCRIBE : function (args) {
     var mailbox = this._daemon.getMailbox(args[0]);
-    if (!mailbox || mailbox.subscribed)
+    if (!mailbox)
       return "NO error in subscribing";
     mailbox.subscribed = true;
     return "OK SUBSCRIBE completed";
   },
   UNSUBSCRIBE : function (args) {
     var mailbox = this._daemon.getMailbox(args[0]);
-    if (!mailbox || !mailbox.subscribed)
-      return "NO error in unsubscribing";
-    mailbox.subscribed = false;
-    return "OK SUBSCRIBE completed";
+    if (mailbox)
+      mailbox.subscribed = false;
+    return "OK UNSUBSCRIBE completed";
   },
   LIST : function (args) {
     var base = this._daemon.getMailbox(args[0]);
     if (!base)
       return "NO no such mailbox";
     var people = base.matchKids(args[1]);
     var response = "";
     for each (var box in people)