From 911df435c9f4220cb5d1a010de9ab47e01b0a600 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sat, 28 Jul 2018 15:26:34 -0700 Subject: [PATCH] Fix -z and -Z options to work with IMAP. -Z did not work if $imap_passive was set (the default). I think using the option implies the desire to open a new connection and check buffy at startup, so temporarily turn it off during the buffy. -z was not hooked up for IMAP. Change it to call imap_status(). This also requires $imap_passive be unset, so temporarily turn the option off too. --- imap/imap.c | 2 +- imap/imap.h | 2 +- main.c | 9 +++++++++ mx.c | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/imap/imap.c b/imap/imap.c index f4ed7f2f..be766e04 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1654,7 +1654,7 @@ int imap_buffy_check (int force, int check_stats) /* imap_status: returns count of messages in mailbox, or -1 on error. * if queue != 0, queue the command and expect it to have been run * on the next call (for pipelining the postponed count) */ -int imap_status (char* path, int queue) +int imap_status (const char* path, int queue) { static int queued = 0; diff --git a/imap/imap.h b/imap/imap.h index b89a6222..c5eb2aec 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -38,7 +38,7 @@ int imap_delete_mailbox (CONTEXT* idata, IMAP_MBOX mx); int imap_sync_mailbox (CONTEXT *ctx, int expunge, int *index_hint); int imap_close_mailbox (CONTEXT *ctx); int imap_buffy_check (int force, int check_stats); -int imap_status (char *path, int queue); +int imap_status (const char *path, int queue); int imap_search (CONTEXT* ctx, const pattern_t* pat); int imap_subscribe (char *path, int subscribe); int imap_complete (char* dest, size_t dlen, char* path); diff --git a/main.c b/main.c index 9b798f96..44f561ba 100644 --- a/main.c +++ b/main.c @@ -1231,6 +1231,11 @@ int main (int argc, char **argv, char **environ) { if (flags & MUTT_BUFFY) { +#ifdef USE_IMAP + int passive = option (OPTIMAPPASSIVE); + if (passive) + unset_option (OPTIMAPPASSIVE); +#endif if (!mutt_buffy_check (0)) { mutt_endwin _("No mailbox with new mail."); @@ -1238,6 +1243,10 @@ int main (int argc, char **argv, char **environ) } folder[0] = 0; mutt_buffy (folder, sizeof (folder)); +#ifdef USE_IMAP + if (passive) + set_option (OPTIMAPPASSIVE); +#endif } else if (flags & MUTT_SELECT) { diff --git a/mx.c b/mx.c index 0dfd1970..404daef9 100644 --- a/mx.c +++ b/mx.c @@ -1498,6 +1498,20 @@ int mx_check_empty (const char *path) return mh_check_empty (path); case MUTT_MAILDIR: return maildir_check_empty (path); +#ifdef USE_IMAP + case MUTT_IMAP: + { + int passive, rv; + + passive = option (OPTIMAPPASSIVE); + if (passive) + unset_option (OPTIMAPPASSIVE); + rv = imap_status (path, 0); + if (passive) + set_option (OPTIMAPPASSIVE); + return (rv <= 0); + } +#endif default: errno = EINVAL; return -1; -- 2.40.0