diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-12-01 09:28:59 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-12-01 09:28:59 +0000 |
commit | 2fdb0604cf34d35a98e609b039ec11556ec1fb71 (patch) | |
tree | d85ac3c3466d1fd0df53380e4a85a13b4dd3f476 | |
parent | be18f8604edd1ab26bf41d4e08de4b60b30e2173 (diff) |
A modified version of Tommi Kommulainen's imap keepalive patch.
-rw-r--r-- | curs_lib.c | 44 | ||||
-rw-r--r-- | imap/imap.h | 2 | ||||
-rw-r--r-- | imap/util.c | 57 | ||||
-rw-r--r-- | mutt.h | 4 | ||||
-rw-r--r-- | system.c | 8 |
5 files changed, 101 insertions, 14 deletions
@@ -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 diff --git a/imap/imap.h b/imap/imap.h index fd41112d..6f86a1eb 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -52,4 +52,6 @@ int imap_parse_path (char* path, char* host, size_t hlen, int* port, void imap_qualify_path (char* dest, size_t len, const char* host, int port, const char* path, const char* name); +int imap_wait_keepalive (pid_t pid); + #endif diff --git a/imap/util.c b/imap/util.c index 6bc5d423..4c31b109 100644 --- a/imap/util.c +++ b/imap/util.c @@ -26,6 +26,12 @@ #include <stdlib.h> #include <ctype.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> + +#include <errno.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 +305,54 @@ 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 + */ + +static RETSIGTYPE alrm_handler (int sig) +{ + /* empty */ +} + +int imap_wait_keepalive (pid_t pid) +{ + struct sigaction oldalrm; + struct sigaction act; + int rc; + + short imap_passive = option (OPTIMAPPASSIVE); + + set_option (OPTIMAPPASSIVE); + set_option (OPTKEEPQUIET); + + sigemptyset (&act.sa_mask); + act.sa_handler = alrm_handler; +#ifdef SA_INTERRUPT + act.sa_flags = SA_INTERRUPT; +#else + act.sa_flags = 0; +#endif + + sigaction (SIGALRM, &act, &oldalrm); + + alarm (ImapCheckTimeout > 0 ? ImapCheckTimeout : 60); + while (waitpid (pid, &rc, 0) < 0 && errno == EINTR) + { + alarm (0); + + if (!option (OPTMSGERR)) + mutt_buffy_check (0); + + alarm (ImapCheckTimeout > 0 ? ImapCheckTimeout : 60); + } + + sigaction (SIGALRM, &oldalrm, NULL); + + unset_option (OPTKEEPQUIET); + if (!imap_passive) + unset_option (OPTIMAPPASSIVE); + + return rc; +} + @@ -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 () */ @@ -17,6 +17,10 @@ */ #include "mutt.h" +#ifdef USE_IMAP +# include "imap.h" +# include <errno.h> +#endif #include <stdlib.h> #include <signal.h> @@ -111,8 +115,12 @@ 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 + rc = imap_wait_keepalive (thepid); +#endif } sigaction (SIGCONT, &oldcont, NULL); |