]> granicus.if.org Git - mutt/commitdiff
A modified version of Tommi Komulainen's imap keepalive patch.
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 25 Nov 1999 12:57:31 +0000 (12:57 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 25 Nov 1999 12:57:31 +0000 (12:57 +0000)
curs_lib.c
imap/imap.h
imap/util.c
mutt.h
system.c

index 7672e550063ae64e4ab7fc711f84f8d881b25bcb..a8a34a4256cb830248dbf2cab5836428adda7867 100644 (file)
@@ -40,9 +40,16 @@ static event_t *KeyEvent;
 
 void mutt_refresh (void)
 {
+  /* don't refresh when we are waiting for a child. */
+  if (option (OPTKEEPQUIET))
+    return;
+
   /* don't refresh in the middle of macros unless necessary */
-  if (!UngetCount || option (OPTFORCEREFRESH))
-    refresh ();
+  if (UngetCount && !option (OPTFORCEREFRESH))
+    return;
+
+  /* else */
+  refresh ();
 }
 
 event_t mutt_getch (void)
@@ -205,12 +212,15 @@ void mutt_curses_error (const char *fmt, ...)
   Errorbuf[ (COLS < sizeof (Errorbuf) ? COLS : sizeof (Errorbuf)) - 2 ] = 0;
   clean_error_buf();
 
-  BEEP ();
-  SETCOLOR (MT_COLOR_ERROR);
-  mvaddstr (LINES-1, 0, Errorbuf);
-  clrtoeol ();
-  SETCOLOR (MT_COLOR_NORMAL);
-  mutt_refresh ();
+  if (!option (OPTKEEPQUIET))
+  {
+    BEEP ();
+    SETCOLOR (MT_COLOR_ERROR);
+    mvaddstr (LINES-1, 0, Errorbuf);
+    clrtoeol ();
+    SETCOLOR (MT_COLOR_NORMAL);
+    mutt_refresh ();
+  }
 
   set_option (OPTMSGERR);
 }
@@ -226,17 +236,23 @@ void mutt_message (const char *fmt, ...)
   Errorbuf[ (COLS < sizeof (Errorbuf) ? COLS : sizeof (Errorbuf)) - 2 ] = 0;
   clean_error_buf();
 
-  SETCOLOR (MT_COLOR_MESSAGE);
-  mvaddstr (LINES - 1, 0, Errorbuf);
-  clrtoeol ();
-  SETCOLOR (MT_COLOR_NORMAL);
-  mutt_refresh ();
+  if (!option (OPTKEEPQUIET))
+  {
+    SETCOLOR (MT_COLOR_MESSAGE);
+    mvaddstr (LINES - 1, 0, Errorbuf);
+    clrtoeol ();
+    SETCOLOR (MT_COLOR_NORMAL);
+    mutt_refresh ();
+  }
 
   unset_option (OPTMSGERR);
 }
 
 void mutt_show_error (void)
 {
+  if (option (OPTKEEPQUIET))
+    return;
+  
   SETCOLOR (option (OPTMSGERR) ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
   CLEARLINE (LINES-1);
   addstr (Errorbuf);
@@ -251,7 +267,7 @@ void mutt_endwin (const char *msg)
     CLEARLINE (LINES - 1);
     move (LINES - 1, 0);
 #else
-      move (LINES - 1, COLS - 1);
+    move (LINES - 1, COLS - 1);
     CLEARLINE (LINES - 1);
 #endif
     
index fd41112dee6c648113d91afbffa6cb0d019db838..7fdb30d81afe209fcaba315218a87a62f20c9a80 100644 (file)
@@ -51,5 +51,6 @@ int imap_parse_path (char* path, char* host, size_t hlen, int* port,
   int *socktype, char** mbox);
 void imap_qualify_path (char* dest, size_t len, const char* host, int port,
   const char* path, const char* name);
+void imap_keepalive (void);
 
 #endif
index 6bc5d42332e10d0bb9a15e43421c1fc9c6b2ac0c..fae9defe274b33cc4c20e9945abee9a8a59c97cf 100644 (file)
@@ -26,6 +26,8 @@
 #include <stdlib.h>
 #include <ctype.h>
 
+#include <signal.h>
+
 /* imap_continue: display a message and ask the user if she wants to
  *   go on. */
 int imap_continue (const char* msg, const char* resp)
@@ -299,3 +301,30 @@ 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
+ */
+
+void imap_keepalive (void)
+{
+  sigset_t sigset;
+  sigset_t osigset;
+
+  if (option (OPTMSGERR))
+    return;
+  
+  sigemptyset (&sigset);
+  sigaddset (&sigset, SIGCHLD);
+  sigprocmask (SIG_UNBLOCK, &sigset, &osigset);
+  
+  set_option (OPTKEEPQUIET);
+  
+  mutt_buffy_check (0);
+  sleep (ImapCheckTimeout > 0 ? ImapCheckTimeout : 60);
+  
+  unset_option (OPTKEEPQUIET);
+  sigprocmask (SIG_BLOCK, &osigset, NULL);
+}
+
+
diff --git a/mutt.h b/mutt.h
index b72a7cb1f1a3f1c2d5e04ec907b2bab87b6c39ab..5d9d1a0ace5d3e72b7bff2d548cc35a17c8916ae 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -380,6 +380,10 @@ enum
   OPTSORTSUBTHREADS,   /* (pseudo) used when $sort_aux changes */
   OPTNEEDRESCORE,      /* (pseudo) set when the `score' command is used */
   OPTATTACHMSG,                /* (pseudo) used by attach-message */
+  OPTKEEPQUIET,                /* (pseudo) shut up the message and refresh
+                        *          functions while we are executing an
+                        *          external program.
+                        */
   
 #ifdef _PGPPATH
   OPTPGPCHECKTRUST,    /* (pseudo) used by pgp_select_key () */
index 7bd1de29ca7db7c4163cd6d90419603fbd561b1c..16db0f65798629643d6e90763f8df4f175b94a26 100644 (file)
--- a/system.c
+++ b/system.c
@@ -17,6 +17,9 @@
  */ 
 
 #include "mutt.h"
+#ifdef USE_IMAP
+# include "imap.h"
+#endif
 
 #include <stdlib.h>
 #include <signal.h>
@@ -111,8 +114,13 @@ int _mutt_system (const char *cmd, int flags)
   }
   else if (thepid != -1)
   {
+#ifndef USE_IMAP
     /* wait for the (first) child process to finish */
     waitpid (thepid, &rc, 0);
+#else
+    while (waitpid (thepid, &rc, WNOHANG) == 0)
+      imap_keepalive ();
+#endif
   }
 
   sigaction (SIGCONT, &oldcont, NULL);