From: Thomas Roessler Date: Mon, 28 Feb 2000 17:54:39 +0000 (+0000) Subject: New IMAP keep-alive code. This should work from all menus, and it X-Git-Tag: mutt-1-1-6-rel~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1477fa4cf9148fb801a998fbf1f8f61fc39aa9bb;p=mutt New IMAP keep-alive code. This should work from all menus, and it should always poll the current folder. --- diff --git a/imap/imap.h b/imap/imap.h index 3d90d2f1..0b4f9ae5 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -68,5 +68,6 @@ void imap_qualify_path (char* dest, size_t len, const IMAP_MBOX *mx, const char* path, const char* name); int imap_wait_keepalive (pid_t pid); +void imap_keepalive (void); #endif diff --git a/imap/util.c b/imap/util.c index 12fad71d..713e1990 100644 --- a/imap/util.c +++ b/imap/util.c @@ -305,8 +305,10 @@ int imap_wordcasecmp(const char *a, const char *b) return mutt_strcasecmp(a, tmp); } -/* imap keepalive: use buffy to poll a remote imap folder - * while waiting for an external process +/* + * Imap keepalive: poll the current folder to keep the + * connection alive. + * */ static RETSIGTYPE alrm_handler (int sig) @@ -314,6 +316,17 @@ static RETSIGTYPE alrm_handler (int sig) /* empty */ } +void imap_keepalive (void) +{ + CONTEXT *ctx = Context; + + if (ctx == NULL || ctx->magic != M_IMAP || + CTX_DATA->selected_ctx != ctx) + return; + + imap_check_mailbox (ctx, NULL); +} + int imap_wait_keepalive (pid_t pid) { struct sigaction oldalrm; @@ -342,9 +355,7 @@ int imap_wait_keepalive (pid_t pid) while (waitpid (pid, &rc, 0) < 0 && errno == EINTR) { alarm (0); /* cancel a possibly pending alarm */ - if (!option (OPTMSGERR)) - mutt_buffy_check (0); - + imap_keepalive (); alarm (ImapCheckTimeout > 0 ? ImapCheckTimeout : 60); } @@ -364,12 +375,12 @@ int imap_wait_keepalive (pid_t pid) void imap_allow_reopen (CONTEXT *ctx) { - if (ctx->magic == M_IMAP) + if (ctx->magic == M_IMAP && CTX_DATA->selected_ctx == ctx) CTX_DATA->reopen |= IMAP_REOPEN_ALLOW; } void imap_disallow_reopen (CONTEXT *ctx) { - if (ctx->magic == M_IMAP) + if (ctx->magic == M_IMAP && CTX_DATA->selected_ctx == ctx) CTX_DATA->reopen &= ~IMAP_REOPEN_ALLOW; } diff --git a/menu.c b/menu.c index 389f9447..11649e77 100644 --- a/menu.c +++ b/menu.c @@ -20,6 +20,10 @@ #include "mutt_curses.h" #include "mutt_menu.h" +#ifdef USE_IMAP +#include "imap.h" +#endif + #include #include @@ -751,10 +755,10 @@ int mutt_menuLoop (MUTTMENU *menu) { mutt_curs_set (0); - /* IMAP keepalive */ - if (mutt_buffy_notify () && option (OPTBEEPNEW)) - beep (); - +#ifdef USE_IMAP + imap_keepalive (); +#endif + /* See if all or part of the screen needs to be updated. */ if (menu->redraw & REDRAW_FULL) { diff --git a/pager.c b/pager.c index 048ffbf6..f63d7330 100644 --- a/pager.c +++ b/pager.c @@ -26,6 +26,9 @@ #include "pager.h" #include "attach.h" +#ifdef USE_IMAP +#include "imap.h" +#endif #ifdef HAVE_PGP @@ -1485,10 +1488,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) { mutt_curs_set (0); - /* IMAP keep-alive */ - if (mutt_buffy_notify () && option (OPTBEEPNEW)) - beep (); - +#ifdef USE_IMAP + imap_keepalive (); +#endif + if (redraw & REDRAW_FULL) { SETCOLOR (MT_COLOR_NORMAL);