From: Thomas Roessler Date: Mon, 28 Feb 2000 17:27:21 +0000 (+0000) Subject: Don't do Context updates from the background. X-Git-Tag: mutt-1-1-6-rel~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=112add1c97fafc6b74bc161b83584b63bd33f1b6;p=mutt Don't do Context updates from the background. --- diff --git a/imap/command.c b/imap/command.c index 964e4d6c..3fab7abe 100644 --- a/imap/command.c +++ b/imap/command.c @@ -42,14 +42,23 @@ static char *Capabilities[] = {"IMAP4", "IMAP4rev1", "STATUS", "ACL", * detected, do expunge) */ void imap_cmd_finish (const char* seq, IMAP_DATA* idata) { - if ((idata->state == IMAP_SELECTED) && - !idata->selected_ctx->closing && - (idata->status == IMAP_NEW_MAIL || - idata->status == IMAP_EXPUNGE)) + if (!(idata->state == IMAP_SELECTED) || idata->selected_ctx->closing) + { + idata->status = 0; + mutt_clear_error (); + return; + } + + if ((idata->status == IMAP_NEW_MAIL || + idata->status == IMAP_EXPUNGE || + (idata->reopen & (IMAP_REOPEN_PENDING|IMAP_NEWMAIL_PENDING))) + && (idata->reopen & IMAP_REOPEN_ALLOW)) { int count = idata->newMailCount; - if (idata->status == IMAP_NEW_MAIL && count > idata->selected_ctx->msgcount) + if (!(idata->reopen & IMAP_REOPEN_PENDING) && + ((idata->status == IMAP_NEW_MAIL) || (idata->reopen & IMAP_NEWMAIL_PENDING)) + && count > idata->selected_ctx->msgcount) { /* read new mail messages */ dprint (1, (debugfile, "imap_cmd_finish: fetching new mail\n")); @@ -60,17 +69,27 @@ void imap_cmd_finish (const char* seq, IMAP_DATA* idata) count = imap_read_headers (idata->selected_ctx, idata->selected_ctx->msgcount, count - 1) + 1; idata->check_status = IMAP_NEW_MAIL; + idata->reopen &= ~IMAP_NEWMAIL_PENDING; } else { imap_reopen_mailbox (idata->selected_ctx, NULL); idata->check_status = IMAP_REOPENED; + idata->reopen &= ~(IMAP_REOPEN_PENDING|IMAP_NEWMAIL_PENDING); } - idata->status = 0; - - mutt_clear_error (); } + else if (!(idata->reopen & IMAP_REOPEN_ALLOW)) + { + if (idata->status == IMAP_NEW_MAIL) + idata->reopen |= IMAP_NEWMAIL_PENDING; + + if (idata->status == IMAP_EXPUNGE) + idata->reopen |= IMAP_REOPEN_PENDING; + } + + idata->status = 0; + mutt_clear_error (); } /* imap_code: returns 1 if the command result was OK, or 0 if NO or BAD */ diff --git a/imap/imap.c b/imap/imap.c index 36cda2bc..63de926a 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1087,6 +1087,9 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge) } } + /* clear IMAP_REOPEN_PENDING, which may have been set during exec */ + CTX_DATA->reopen &= ~IMAP_REOPEN_PENDING; + return 0; } @@ -1162,6 +1165,7 @@ int imap_check_mailbox (CONTEXT *ctx, int *index_hint) return M_NEW_MAIL; if (CTX_DATA->check_status == IMAP_REOPENED) return M_REOPENED; + return 0; } diff --git a/imap/imap.h b/imap/imap.h index a88479f2..3d90d2f1 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -51,6 +51,9 @@ int imap_mailbox_check (char *path, int new); int imap_subscribe (char *path, int subscribe); int imap_complete (char* dest, size_t dlen, char* path); +void imap_allow_reopen (CONTEXT *ctx); +void imap_disallow_reopen (CONTEXT *ctx); + /* browse.c */ int imap_init_browse (char *path, struct browser_state *state); diff --git a/imap/imap_private.h b/imap/imap_private.h index a116a0b0..2d7b4085 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -38,6 +38,10 @@ #define M_IMAP_PASS (1<<3) #define M_IMAP_CRAM (1<<4) +#define IMAP_REOPEN_ALLOW (1<<0) +#define IMAP_REOPEN_PENDING (1<<1) +#define IMAP_NEWMAIL_PENDING (1<<2) + enum { IMAP_FATAL = 1, @@ -145,6 +149,8 @@ typedef struct unsigned char rights[(RIGHTSMAX + 7)/8]; unsigned int newMailCount; IMAP_CACHE cache[IMAP_CACHE_LEN]; + short reopen; + /* all folder flags - system flags AND keywords */ LIST *flags; } IMAP_DATA; diff --git a/imap/util.c b/imap/util.c index 720c7cf3..12fad71d 100644 --- a/imap/util.c +++ b/imap/util.c @@ -21,6 +21,7 @@ /* general IMAP utility functions */ #include "mutt.h" +#include "mx.h" /* for M_IMAP */ #include "imap_private.h" #include @@ -359,3 +360,16 @@ int imap_wait_keepalive (pid_t pid) return rc; } +/* Allow/disallow re-opening a folder upon expunge. */ + +void imap_allow_reopen (CONTEXT *ctx) +{ + if (ctx->magic == M_IMAP) + CTX_DATA->reopen |= IMAP_REOPEN_ALLOW; +} + +void imap_disallow_reopen (CONTEXT *ctx) +{ + if (ctx->magic == M_IMAP) + CTX_DATA->reopen &= ~IMAP_REOPEN_ALLOW; +}