From: Damien Riegel Date: Thu, 26 May 2016 21:05:36 +0000 (-0700) Subject: add function imap_check_mailbox_reopen X-Git-Tag: neomutt-20160822~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f280e41ee9d920ef0933caf548ef7c22a1c0e932;p=neomutt add function imap_check_mailbox_reopen In mx_check_mailbox, imap mailbox is the only function with a different prototype: it has an extra force argument. In order to move the check operation to the mx_ops structure, we need that all mailboxes have the same prototype. To do so, a new function imap_check_mailbox_reopen is added. --- diff --git a/imap/imap.c b/imap/imap.c index c2db3c222..d565ad8d0 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1464,6 +1464,17 @@ int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force) return result; } +int imap_check_mailbox_reopen (CONTEXT *ctx, int *index_hint) +{ + int rc; + + imap_allow_reopen (ctx); + rc = imap_check_mailbox (ctx, index_hint, 0); + imap_disallow_reopen (ctx); + + return rc; +} + /* split path into (idata,mailbox name) */ static int imap_get_mailbox (const char* path, IMAP_DATA** hidata, char* buf, size_t blen) { diff --git a/imap/imap.h b/imap/imap.h index 132ae2b9b..1defdd47c 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -34,6 +34,7 @@ typedef struct /* imap.c */ int imap_access (const char*, int); int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force); +int imap_check_mailbox_reopen (CONTEXT *ctx, int *index_hint); int imap_delete_mailbox (CONTEXT* idata, IMAP_MBOX mx); int imap_open_mailbox_append (CONTEXT *ctx); int imap_sync_mailbox (CONTEXT *ctx, int expunge, int *index_hint); diff --git a/mx.c b/mx.c index 4c7e8d08f..cf50d538a 100644 --- a/mx.c +++ b/mx.c @@ -1303,11 +1303,7 @@ int mx_check_mailbox (CONTEXT *ctx, int *index_hint, int lock) #ifdef USE_IMAP case MUTT_IMAP: - /* caller expects that mailbox may change */ - imap_allow_reopen (ctx); - rc = imap_check_mailbox (ctx, index_hint, 0); - imap_disallow_reopen (ctx); - return rc; + return imap_check_mailbox_reopen (ctx, index_hint); #endif /* USE_IMAP */ #ifdef USE_POP