]> granicus.if.org Git - neomutt/commitdiff
add function imap_check_mailbox_reopen
authorDamien Riegel <damien@riegel.io>
Thu, 26 May 2016 21:05:36 +0000 (14:05 -0700)
committerDamien Riegel <damien@riegel.io>
Thu, 26 May 2016 21:05:36 +0000 (14:05 -0700)
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.

imap/imap.c
imap/imap.h
mx.c

index c2db3c222ecde62ddc3835c16a0acd7144ef93ef..d565ad8d08db5e2b51a850238bcadd924d58b08c 100644 (file)
@@ -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)
 {
index 132ae2b9ba342ef2141284f7d0cc71caffd75c53..1defdd47cb6db1048c7ee6ef9c6e52cc8f15b07c 100644 (file)
@@ -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 4c7e8d08fa9a93603e4e1406be28cd2614ab290f..cf50d538a4dd591ecc4f2bc6f42ba5d0aef851c9 100644 (file)
--- 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