# HG changeset patch
# User Damien Riegel <[email protected]>
# Date 1464135121 14400
#      Tue May 24 20:12:01 2016 -0400
# Node ID 26d6dbbbe6bfc9dfb7629f0ba6008eb76c073b5f
# Parent  80d1d8cf64520b02cff20c9b3f5c81cb4a3cf23d
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 -r 80d1d8cf6452 -r 26d6dbbbe6bf imap/imap.c
--- a/imap/imap.c       Wed May 18 21:11:46 2016 -0400
+++ b/imap/imap.c       Tue May 24 20:12:01 2016 -0400
@@ -1464,6 +1464,17 @@
   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 -r 80d1d8cf6452 -r 26d6dbbbe6bf imap/imap.h
--- a/imap/imap.h       Wed May 18 21:11:46 2016 -0400
+++ b/imap/imap.h       Tue May 24 20:12:01 2016 -0400
@@ -34,6 +34,7 @@
 /* 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 -r 80d1d8cf6452 -r 26d6dbbbe6bf mx.c
--- a/mx.c      Wed May 18 21:11:46 2016 -0400
+++ b/mx.c      Tue May 24 20:12:01 2016 -0400
@@ -1300,11 +1300,7 @@
 
 #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

Reply via email to