Commit 0106e172 authored by Thomas Roessler's avatar Thomas Roessler

patch-bac.postpone-2

parent 5bcdf384
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
......@@ -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
{
......
......@@ -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);
......
......@@ -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;
......
......@@ -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; )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment