]> granicus.if.org Git - neomutt/commitdiff
If imap_check_subscribed is set, mailbox or unmailbox folders in response
authorBrendan Cully <brendan@kublai.com>
Mon, 8 Aug 2005 00:31:57 +0000 (00:31 +0000)
committerBrendan Cully <brendan@kublai.com>
Mon, 8 Aug 2005 00:31:57 +0000 (00:31 +0000)
to subscribe/unsubscribe commands in the browser.

imap/imap.c

index 4e7ad5b14d47a952ee104f0bc7f4f1e52924d275..d0e849debc9b0ff7aa0ba651d04df97fe4b2d54a 100644 (file)
@@ -1378,6 +1378,8 @@ int imap_subscribe (char *path, int subscribe)
   IMAP_DATA *idata;
   char buf[LONG_STRING];
   char mbox[LONG_STRING];
+  char errstr[STRING];
+  BUFFER err, token;
   IMAP_MBOX mx;
 
   if (!mx_is_imap (path) || imap_parse_path (path, &mx))
@@ -1385,22 +1387,32 @@ int imap_subscribe (char *path, int subscribe)
     mutt_error (_("Bad mailbox name"));
     return -1;
   }
-  
-
   if (!(idata = imap_conn_find (&(mx.account), 0)))
     goto fail;
   
   conn = idata->conn;
 
   imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
+
+  if (option (OPTIMAPCHECKSUBSCRIBED))
+  {
+    memset (&token, 0, sizeof (token));
+    err.data = errstr;
+    err.dsize = sizeof (errstr);
+    snprintf (mbox, sizeof (mbox), "%smailboxes \"%s\"",
+              subscribe ? "" : "un", path);
+    if (mutt_parse_rc_line (mbox, &token, &err))
+      dprint (1, (debugfile, "Error adding subscribed mailbox: %s\n", errstr));
+    FREE (&token.data);
+  }
+  
   if (subscribe)
     mutt_message (_("Subscribing to %s..."), buf);
   else
     mutt_message (_("Unsubscribing to %s..."), buf);
   imap_munge_mbox_name (mbox, sizeof(mbox), buf);
 
-  snprintf (buf, sizeof (buf), "%s %s", subscribe ? "SUBSCRIBE" :
-    "UNSUBSCRIBE", mbox);
+  snprintf (buf, sizeof (buf), "%sSUBSCRIBE %s", subscribe ? "" : "UN", mbox);
 
   if (imap_exec (idata, buf, 0) < 0)
     goto fail;