]> granicus.if.org Git - mutt/commitdiff
New IMAP keep-alive code. This should work from all menus, and it
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 28 Feb 2000 17:54:39 +0000 (17:54 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 28 Feb 2000 17:54:39 +0000 (17:54 +0000)
should always poll the current folder.

imap/imap.h
imap/util.c
menu.c
pager.c

index 3d90d2f196ab3a7a2886e172d094a4e54be639ad..0b4f9ae50d68e4c00928ac402142ad0163877204 100644 (file)
@@ -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
index 12fad71d81af4b01fbd69ec2aa35bad600a2c18a..713e1990a62618b54f8e745794f6474374372d1b 100644 (file)
@@ -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 389f94474ab5b3f65c93baf2def23511da42367b..11649e77a499cdf29b8a0e12f8033d90e371649d 100644 (file)
--- a/menu.c
+++ b/menu.c
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 
+#ifdef USE_IMAP
+#include "imap.h"
+#endif
+
 #include <string.h>
 #include <stdlib.h>
 
@@ -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 048ffbf6c2d357cfc7851e88127543001af9a364..f63d7330a49721d4375c32ef9a5776215cc94269 100644 (file)
--- 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);