]> granicus.if.org Git - mutt/commitdiff
Detect external modifications of IMAP folders. From Brendan Cully.
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 28 May 2001 15:34:28 +0000 (15:34 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 28 May 2001 15:34:28 +0000 (15:34 +0000)
imap/command.c
imap/imap.c
imap/imap_private.h

index 61dd622bd1e85890e3381b3567456807cbc80960..1d7e3cf82131d13a06acbca0c529cf69f5934a46 100644 (file)
@@ -263,7 +263,12 @@ static void cmd_finish (IMAP_DATA* idata)
     {
       dprint (2, (debugfile, "cmd_finish: Expunging mailbox\n"));
       imap_expunge_mailbox (idata);
-      idata->reopen &= ~(IMAP_EXPUNGE_PENDING|IMAP_NEWMAIL_PENDING);
+      /* Detect whether we've gotten unexpected EXPUNGE messages */
+      if (idata->reopen & IMAP_EXPUNGE_PENDING &&
+         !(idata->reopen & IMAP_EXPUNGE_EXPECTED))
+       idata->check_status = IMAP_EXPUNGE_PENDING;
+      idata->reopen &= ~(IMAP_EXPUNGE_PENDING | IMAP_NEWMAIL_PENDING |
+                        IMAP_EXPUNGE_EXPECTED);
     }
   }
 
index 1ba339d6f41686a2113aa3b40ec4de656c834a61..8f911dc3b87d3aace3f47581bf56e594de24ef04 100644 (file)
@@ -1006,6 +1006,8 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
       mutt_bit_isset(idata->rights, IMAP_ACL_DELETE))
   {
     mutt_message _("Expunging messages from server...");
+    /* Set expunge bit so we don't get spurious reopened messages */
+    idata->reopen |= IMAP_EXPUNGE_EXPECTED;
     if (imap_exec (idata, "EXPUNGE", 0) != 0)
     {
       imap_error ("imap_sync_mailbox: EXPUNGE failed", idata->cmd.buf);
@@ -1096,9 +1098,12 @@ int imap_check_mailbox (CONTEXT *ctx, int *index_hint)
     idata->check_status &= ~IMAP_NEWMAIL_PENDING;
     return M_NEW_MAIL;
   }
-  /* TODO: we should be able to detect external changes and return
-   *   M_REOPENED here. */
-  
+  if (idata->check_status & IMAP_EXPUNGE_PENDING)
+  {
+    idata->check_status &= ~IMAP_EXPUNGE_PENDING;
+    return M_REOPENED;
+  }
+
   return 0;
 }
 
index 78f6e62f51999f322525d2a778e95ea38405af72..3dbcdf6f226ae0fc860f8535be77484c4d69e2b5 100644 (file)
 
 #define SEQLEN 5
 
-#define IMAP_REOPEN_ALLOW    (1<<0)
-#define IMAP_EXPUNGE_PENDING (1<<1)
-#define IMAP_NEWMAIL_PENDING (1<<2)
+#define IMAP_REOPEN_ALLOW     (1<<0)
+#define IMAP_EXPUNGE_PENDING  (1<<1)
+#define IMAP_NEWMAIL_PENDING  (1<<2)
+#define IMAP_EXPUNGE_EXPECTED (1<<3)
 
 /* imap_exec flags (see imap_exec) */
 #define IMAP_CMD_FAIL_OK (1<<0)