]> granicus.if.org Git - mutt/commitdiff
patch-bac.postpone-2
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 20 Jul 2000 07:24:01 +0000 (07:24 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 20 Jul 2000 07:24:01 +0000 (07:24 +0000)
imap/BUGS
imap/imap.c
imap/imap.h
imap/util.c
postpone.c

index 7574ca67c2ffc8f83a9804efc47d7b2301ea6956..1aa70b1f2eb8e749e141c6361e2e4390c7480fc5 100644 (file)
--- a/imap/BUGS
+++ b/imap/BUGS
@@ -1,9 +1,5 @@
 In no particular order:
 
-* Mutt doesn't display untagged [ALERT] responses to the user. Pointed out
-  by Larry P Schrof <schrof@cig.mot.com>
-  19991220
-
 * ~h searches download the entire folder, setting everything to \Seen in
   the process.
   --> Use SEARCH? or at least try to use .PEEK when doing scans. I've been
@@ -41,4 +37,4 @@ In no particular order:
 * The mutt_pretty routines don't work well when the delimiter isn't '/'.
 
 Brendan Cully <brendan@kublai.com>
-Updated 20000704
+Updated 20000719
index f17e19ef8c14d5396ac190e79bfb09825c4cd997..73e88faef55a5802be1c85bc754b15422067c975 100644 (file)
@@ -747,41 +747,6 @@ int imap_open_mailbox (CONTEXT* ctx)
   return 0;
 }
 
-/* fast switch mailboxes on the same connection - sync without expunge and
- * SELECT */
-int imap_select_mailbox (CONTEXT* ctx, const char* path)
-{
-  IMAP_DATA* idata;
-  char curpath[LONG_STRING];
-  IMAP_MBOX mx;
-
-  idata = CTX_DATA;
-
-  strfcpy (curpath, path, sizeof (curpath));
-  /* check that the target folder makes sense */
-  if (imap_parse_path (curpath, &mx))
-    return -1;
-
-  /* and that it's on the same server as the current folder */
-  if (!mutt_account_match (&(mx.account), &(idata->conn->account)))
-  {
-    dprint(2, (debugfile,
-      "imap_select_mailbox: source server is not target server\n"));
-    return -1;
-  }
-
-  if (imap_sync_mailbox (ctx, 0, NULL) < 0)
-    return -1;
-
-  idata = CTX_DATA;
-  /* now trick imap_open_mailbox into thinking it can just select */
-  FREE (&(ctx->path));
-  ctx->path = safe_strdup(path);
-  idata->state = IMAP_AUTHENTICATED;
-  
-  return imap_open_mailbox (ctx);
-}
-
 int imap_open_mailbox_append (CONTEXT *ctx)
 {
   CONNECTION *conn;
@@ -1101,7 +1066,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int *index_hint)
         imap_error ("imap_sync_mailbox: CLOSE failed", buf);
         return -1;
       }
-      CTX_DATA->state = IMAP_AUTHENTICATED;
+      /* state is set in imap_fastclose_mailbox */
     }
     else if (mutt_bit_isset(CTX_DATA->rights, IMAP_ACL_DELETE))
     {
@@ -1139,7 +1104,10 @@ void imap_fastclose_mailbox (CONTEXT *ctx)
   CTX_DATA->reopen &= IMAP_REOPEN_ALLOW;
 
   if ((CTX_DATA->state == IMAP_SELECTED) && (ctx == CTX_DATA->selected_ctx))
+  {
     CTX_DATA->state = IMAP_AUTHENTICATED;
+    FREE (&(CTX_DATA->selected_mailbox));
+  }
 
   /* free IMAP part of headers */
   for (i = 0; i < ctx->msgcount; i++)
@@ -1153,21 +1121,6 @@ void imap_fastclose_mailbox (CONTEXT *ctx)
       safe_free ((void **) &CTX_DATA->cache[i].path);
     }
   }
-
-#if 0
-  /* This is not the right place to logout, actually. There are two dangers:
-   * 1. status is set to IMAP_LOGOUT as soon as the user says q, even if she
-   *    cancels a bit later.
-   * 2. We may get here when closing the $received folder, but before we sync
-   *    the spool. So the sync will currently cause an abort. */
-  if (CTX_DATA->status == IMAP_BYE || CTX_DATA->status == IMAP_FATAL ||
-    CTX_DATA->status == IMAP_LOGOUT)
-  {
-    imap_close_connection (ctx);
-    CTX_DATA->conn->data = NULL;
-    safe_free ((void **) &ctx->data);
-  }
-#endif
 }
 
 /* use the NOOP command to poll for new mail
@@ -1218,7 +1171,10 @@ int imap_check_mailbox (CONTEXT *ctx, int *index_hint)
 
 /* returns count of recent messages if new = 1, else count of total messages.
  * (useful for at least postponed function)
- * Question of taste: use RECENT or UNSEEN for new? */
+ * Question of taste: use RECENT or UNSEEN for new?
+ *   0+   number of messages in mailbox
+ *  -1    error while polling mailboxes
+ */
 int imap_mailbox_check (char* path, int new)
 {
   CONNECTION *conn;
@@ -1297,7 +1253,11 @@ int imap_mailbox_check (char* path, int new)
       if (mutt_strncasecmp ("STATUS", s, 6) == 0)
       {
        s = imap_next_word (s);
-       if (mutt_strncmp (mbox_unquoted, s, mutt_strlen (mbox_unquoted)) == 0)
+       /* The mailbox name may or may not be quoted here. We could try to 
+        * munge the server response and compare with quoted (or vise versa)
+        * but it is probably more efficient to just strncmp against both. */
+       if (mutt_strncmp (mbox_unquoted, s, mutt_strlen (mbox_unquoted)) == 0
+           || mutt_strncmp (mbox, s, mutt_strlen (mbox)) == 0)
        {
          s = imap_next_word (s);
          s = imap_next_word (s);
@@ -1310,6 +1270,8 @@ int imap_mailbox_check (char* path, int new)
            }
          }
        }
+       else
+         dprint (1, (debugfile, "imap_mailbox_check: STATUS response doesn't match requested mailbox.\n"));
       }
       else
       {
index c4997a10588b30af34d65f0392b44f713f3d4951..a1223faa98728eec5d987064ade5b71d9b25148c 100644 (file)
@@ -37,7 +37,6 @@ int imap_close_connection (CONTEXT *ctx);
 int imap_delete_mailbox (CONTEXT* idata, char* mailbox);
 int imap_open_mailbox (CONTEXT *ctx);
 int imap_open_mailbox_append (CONTEXT *ctx);
-int imap_select_mailbox (CONTEXT *ctx, const char* path);
 int imap_sync_mailbox (CONTEXT *ctx, int expunge, int *index_hint);
 void imap_fastclose_mailbox (CONTEXT *ctx);
 int imap_buffy_check (char *path);
index 958c87493bf87905b927afd7f8c37923641cdca4..cb16c43f16307548e7a116a10b69ee235c728c83 100644 (file)
@@ -144,7 +144,7 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
     return -1;
   else
     /* walk past closing '}' */
-    mx->mbox = safe_strdup (c+1);
+    mx->mbox = strdup (c+1);
   
   /* Defaults */
   mx->account.flags = 0;
index cb605b59ad69236ebeb58d0591b3798402b900a3..330f74713cec3302d4a71666181dcee9b096960c 100644 (file)
@@ -86,10 +86,16 @@ int mutt_num_postponed (int force)
   {
     if (force)
     {
-      PostCount = imap_mailbox_check (Postponed, 0);
-      PostCount = (PostCount < 0) ? 0 : PostCount;
-      dprint(2, (debugfile,
-        "mutt_num_postponed: %d postponed IMAP messages found.\n", PostCount));
+      short newpc;
+
+      newpc = imap_mailbox_check (Postponed, 0);
+      if (newpc >= 0)
+      {
+       PostCount = newpc;
+       dprint (2, (debugfile, "mutt_num_postponed: %d postponed IMAP messages found.\n", PostCount));
+      }
+      else
+       dprint (2, (debugfile, "mutt_num_postponed: using old IMAP postponed count.\n"));
     }
     return PostCount;
   }
@@ -222,28 +228,10 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
   LIST *next;
   char *p;
   int opt_delete;
-#ifdef USE_IMAP
-  char curpath[LONG_STRING];
-  int need_reopen = 0;
-#endif
 
   if (!Postponed)
     return (-1);
 
-#ifdef USE_IMAP
-  /* if we're in an IMAP folder and the postponed folder is also IMAP, we may
-   * need to take steps to avoid opening an additional connection to the same
-   * server. */
-  if ((ctx && ctx->magic == M_IMAP) && mx_is_imap (Postponed))
-  { 
-    strfcpy (curpath, ctx->path, sizeof (curpath));
-    if (imap_select_mailbox (ctx, Postponed) < 0)
-      return -1;
-    need_reopen = 1;
-    PostContext = ctx;
-  }
-  else
-#endif
   if ((PostContext = mx_open_mailbox (Postponed, M_NOSORT, NULL)) == NULL)
   {
     PostCount = 0;
@@ -255,11 +243,6 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
   {
     PostCount = 0;
     mx_close_mailbox (PostContext, NULL);
-#ifdef USE_IMAP
-  if (need_reopen)
-    ctx = mx_open_mailbox (curpath, 0, PostContext);
-  else
-#endif
     safe_free ((void **) &PostContext);
     mutt_error _("No postponed messages.");
     return (-1);
@@ -273,11 +256,6 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
   else if ((h = select_msg ()) == NULL)
   {
     mx_close_mailbox (PostContext, NULL);
-#ifdef USE_IMAP
-  if (need_reopen)
-    ctx = mx_open_mailbox (curpath, 0, PostContext);
-  else
-#endif
     safe_free ((void **) &PostContext);
     return (-1);
   }
@@ -285,11 +263,6 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
   if (mutt_prepare_template (NULL, PostContext, hdr, h, 0) < 0)
   {
     mx_fastclose_mailbox (PostContext);
-#ifdef USE_IMAP
-    if (need_reopen)
-      ctx = mx_open_mailbox (curpath, 0, NULL);
-    else
-#endif
     safe_free ((void **) &PostContext);
     return (-1);
   }
@@ -306,11 +279,6 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
   mx_close_mailbox (PostContext, NULL);
   set_quadoption (OPT_DELETE, opt_delete);
 
-#ifdef USE_IMAP
-  if (need_reopen)
-    ctx = mx_open_mailbox (curpath, 0, PostContext);
-  else
-#endif
   safe_free ((void **) &PostContext);
 
   for (tmp = hdr->env->userhdrs; tmp; )