From 91409e034831b8132183dce5ab80233b821da23a Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Thu, 10 May 2001 08:02:18 +0000 Subject: [PATCH] A slightly extended version of Dave Ewart's sleeptime patch. --- copy.c | 2 +- curs_main.c | 4 ++-- globals.h | 1 + hook.c | 4 ++-- imap/auth_anon.c | 2 +- imap/auth_cram.c | 2 +- imap/auth_gss.c | 2 +- imap/auth_login.c | 2 +- imap/auth_sasl.c | 2 +- imap/browse.c | 2 +- imap/command.c | 4 ++-- imap/imap.c | 8 ++++---- imap/message.c | 6 +++--- imap/util.c | 2 +- init.h | 8 ++++++++ mbox.c | 24 ++++++++++++------------ menu.c | 2 +- mutt_socket.c | 10 +++++----- mutt_ssl.c | 23 ++++++++++++++--------- muttlib.c | 7 +++++++ mx.c | 4 ++-- pgpkey.c | 2 +- pop.c | 16 ++++++++-------- pop_auth.c | 6 +++--- pop_lib.c | 10 +++++----- protos.h | 1 + sort.c | 2 +- 27 files changed, 90 insertions(+), 68 deletions(-) diff --git a/copy.c b/copy.c index 87c7a609..7e590838 100644 --- a/copy.c +++ b/copy.c @@ -479,7 +479,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body, { mutt_error ("The length calculation was wrong by %ld bytes", fail); new_length += fail; - sleep (5); + mutt_sleep (1); } } #endif diff --git a/curs_main.c b/curs_main.c index b28d9c50..c2ccc647 100644 --- a/curs_main.c +++ b/curs_main.c @@ -983,8 +983,8 @@ int mutt_index_menu (void) safe_free ((void **) &Context); } - sleep (1); /* give a second to read the mailbox status */ - + mutt_sleep (0); + mutt_folder_hook (buf); if ((Context = mx_open_mailbox (buf, diff --git a/globals.h b/globals.h index 5697061e..1888d446 100644 --- a/globals.h +++ b/globals.h @@ -137,6 +137,7 @@ WHERE short PagerContext; WHERE short PagerIndexLines; WHERE short ReadInc; WHERE short SendmailWait; +WHERE short SleepTime INITVAL (1); WHERE short Timeout; WHERE short WriteInc; WHERE short ScoreThresholdDelete; diff --git a/hook.c b/hook.c index bd41e081..3e3588c7 100644 --- a/hook.c +++ b/hook.c @@ -292,7 +292,7 @@ void mutt_folder_hook (char *path) { mutt_error ("%s", err.data); FREE (&token.data); - sleep (1); /* pause a moment to let the user see the error */ + mutt_sleep (1); /* pause a moment to let the user see the error */ current_hook_type = 0; return; } @@ -339,7 +339,7 @@ void mutt_message_hook (CONTEXT *ctx, HEADER *hdr, int type) { FREE (&token.data); mutt_error ("%s", err.data); - sleep (1); + mutt_sleep (1); current_hook_type = 0; return; } diff --git a/imap/auth_anon.c b/imap/auth_anon.c index 78d6f932..7d60e017 100644 --- a/imap/auth_anon.c +++ b/imap/auth_anon.c @@ -67,6 +67,6 @@ imap_auth_res_t imap_auth_anon (IMAP_DATA* idata) bail: mutt_error _("Anonymous authentication failed."); - sleep (2); + mutt_sleep (2); return IMAP_AUTH_FAILURE; } diff --git a/imap/auth_cram.c b/imap/auth_cram.c index 07bf6e89..741e26c6 100644 --- a/imap/auth_cram.c +++ b/imap/auth_cram.c @@ -122,7 +122,7 @@ imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA* idata) bail: mutt_error _("CRAM-MD5 authentication failed."); - sleep (2); + mutt_sleep (2); return IMAP_AUTH_FAILURE; } diff --git a/imap/auth_gss.c b/imap/auth_gss.c index 1cc46641..a269230c 100644 --- a/imap/auth_gss.c +++ b/imap/auth_gss.c @@ -260,6 +260,6 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata) bail: mutt_error _("GSSAPI authentication failed."); - sleep (2); + mutt_sleep (2); return IMAP_AUTH_FAILURE; } diff --git a/imap/auth_login.c b/imap/auth_login.c index 212d7fde..9bdbb9fe 100644 --- a/imap/auth_login.c +++ b/imap/auth_login.c @@ -61,6 +61,6 @@ imap_auth_res_t imap_auth_login (IMAP_DATA* idata) return IMAP_AUTH_SUCCESS; mutt_error _("Login failed."); - sleep (2); + mutt_sleep (2); return IMAP_AUTH_FAILURE; } diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index 75d0659c..7eb78131 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -162,7 +162,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata) bail: mutt_error _("SASL authentication failed."); - sleep(2); + mutt_sleep(2); sasl_dispose (&saslconn); return IMAP_AUTH_FAILURE; diff --git a/imap/browse.c b/imap/browse.c index 2ed91a06..284ba2dd 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -270,7 +270,7 @@ int imap_mailbox_create (const char* folder) goto fail; mutt_message _("Mailbox created."); - sleep (1); + mutt_sleep (0); FREE (&mx.mbox); return 0; diff --git a/imap/command.c b/imap/command.c index 32a6405a..61dd622b 100644 --- a/imap/command.c +++ b/imap/command.c @@ -216,7 +216,7 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags) pc = idata->cmd.buf; pc = imap_next_word (pc); mutt_error ("%s", pc); - sleep (2); + mutt_sleep (2); return -1; } @@ -368,7 +368,7 @@ static int cmd_handle_untagged (IMAP_DATA* idata) /* Display the warning message from the server */ mutt_error ("%s", s+3); - sleep (2); + mutt_sleep (2); } return 0; diff --git a/imap/imap.c b/imap/imap.c index b073d51c..0be0040c 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -292,7 +292,7 @@ static int imap_check_capabilities (IMAP_DATA* idata) ||mutt_bit_isset(idata->capabilities,IMAP4REV1))) { mutt_error _("This IMAP server is ancient. Mutt does not work with it."); - sleep (5); /* pause a moment to let the user see the error */ + mutt_sleep (5); /* pause a moment to let the user see the error */ return -1; } @@ -361,7 +361,7 @@ int imap_open_connection (IMAP_DATA* idata) if (mutt_socket_open (idata->conn) < 0) { mutt_error (_("Connection to %s failed."), idata->conn->account.host); - sleep (1); + mutt_sleep (1); return -1; } @@ -390,7 +390,7 @@ int imap_open_connection (IMAP_DATA* idata) if (mutt_ssl_starttls (idata->conn)) { mutt_error ("Could not negotiate TLS connection"); - sleep (1); + mutt_sleep (1); goto bail; } else @@ -593,7 +593,7 @@ int imap_open_mailbox (CONTEXT* ctx) s = imap_next_word (idata->cmd.buf); /* skip seq */ s = imap_next_word (s); /* Skip response */ mutt_error ("%s", s); - sleep (2); + mutt_sleep (2); goto fail; } diff --git a/imap/message.c b/imap/message.c index a76aa213..ff70ca7c 100644 --- a/imap/message.c +++ b/imap/message.c @@ -72,7 +72,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend) else { /* Unable to fetch headers for lower versions */ mutt_error _("Unable to fetch headers from this IMAP server version."); - sleep (2); /* pause a moment to let the user see the error */ + mutt_sleep (2); /* pause a moment to let the user see the error */ return -1; } @@ -476,7 +476,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg) SKIPWS (pc); pc = imap_next_word (pc); mutt_error ("%s", pc); - sleep (1); + mutt_sleep (1); fclose (fp); goto fail; } @@ -514,7 +514,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg) SKIPWS (pc); pc = imap_next_word (pc); mutt_error ("%s", pc); - sleep (1); + mutt_sleep (1); goto fail; } diff --git a/imap/util.c b/imap/util.c index e76d551f..97a0bce3 100644 --- a/imap/util.c +++ b/imap/util.c @@ -219,7 +219,7 @@ int imap_continue (const char* msg, const char* resp) void imap_error (const char *where, const char *msg) { mutt_error (_("%s [%s]\n"), where, msg); - sleep (2); + mutt_sleep (2); } /* imap_new_idata: Allocate and initialise a new IMAP_DATA structure. diff --git a/init.h b/init.h index 87298215..0e44e176 100644 --- a/init.h +++ b/init.h @@ -1880,6 +1880,14 @@ struct option_t MuttVars[] = { ** positives of ``$$quote_regexp'', most notably smileys in the beginning ** of a line */ + { "sleep_time", DT_NUM, R_NONE, UL &SleepTime, 1 }, + /* + ** .pp + ** Specifies time, in seconds, to pause while displaying certain informational + ** messages, while moving from folder to folder and after expunging + ** messages from the current folder. The default is to pause one second, so + ** a value of zero for this option suppresses the pause. + */ { "sort", DT_SORT, R_INDEX|R_RESORT, UL &Sort, SORT_DATE }, /* ** .pp diff --git a/mbox.c b/mbox.c index bb008bf4..08d1167d 100644 --- a/mbox.c +++ b/mbox.c @@ -732,7 +732,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) unlink (tempfile); } mutt_error _("Could not create temporary file!"); - sleep (5); + mutt_sleep (5); goto bail; } @@ -749,7 +749,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) * never happen, is we presume it is a bug in mutt. */ mutt_error _("sync: mbox modified, but no modified messages! (report this bug)"); - sleep(5); /* the mutt_error /will/ get cleared! */ + mutt_sleep(5); /* the mutt_error /will/ get cleared! */ dprint(1, (debugfile, "mbox_sync_mailbox(): no modified messages.\n")); unlink (tempfile); goto bail; @@ -797,7 +797,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) if (fputs (MMDF_SEP, fp) == EOF) { mutt_perror (tempfile); - sleep (5); + mutt_sleep (5); unlink (tempfile); goto bail; } @@ -808,7 +808,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) if (fputs (KENDRA_SEP, fp) == EOF) { mutt_perror (tempfile); - sleep (5); + mutt_sleep (5); unlink (tempfile); goto bail; } @@ -823,7 +823,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) if (mutt_copy_message (fp, ctx, ctx->hdrs[i], M_CM_UPDATE, CH_FROM | CH_UPDATE | CH_UPDATE_LEN) == -1) { mutt_perror (tempfile); - sleep (5); + mutt_sleep (5); unlink (tempfile); goto bail; } @@ -843,7 +843,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) if(fputs(MMDF_SEP, fp) == EOF) { mutt_perror (tempfile); - sleep (5); + mutt_sleep (5); unlink (tempfile); goto bail; } @@ -852,7 +852,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) if(fputs(KENDRA_SEP, fp) == EOF) { mutt_perror (tempfile); - sleep (5); + mutt_sleep (5); unlink (tempfile); goto bail; } @@ -861,7 +861,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) if(fputs("\n", fp) == EOF) { mutt_perror (tempfile); - sleep (5); + mutt_sleep (5); unlink (tempfile); goto bail; } @@ -875,7 +875,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) dprint(1, (debugfile, "mbox_sync_mailbox: fclose() returned non-zero.\n")); unlink (tempfile); mutt_perror (tempfile); - sleep (5); + mutt_sleep (5); goto bail; } fp = NULL; @@ -884,7 +884,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) if (stat (ctx->path, &statbuf) == -1) { mutt_perror (ctx->path); - sleep (5); + mutt_sleep (5); unlink (tempfile); goto bail; } @@ -895,7 +895,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) mx_fastclose_mailbox (ctx); dprint (1, (debugfile, "mbox_sync_mailbox: unable to reopen temp copy of mailbox!\n")); mutt_perror (tempfile); - sleep (5); + mutt_sleep (5); return (-1); } @@ -953,7 +953,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) mx_fastclose_mailbox (ctx); mutt_pretty_mailbox (savefile); mutt_error (_("Write failed! Saved partial mailbox to %s"), savefile); - sleep (5); + mutt_sleep (5); return (-1); } diff --git a/menu.c b/menu.c index 39e4d729..19d36a5e 100644 --- a/menu.c +++ b/menu.c @@ -340,7 +340,7 @@ void menu_redraw_prompt (MUTTMENU *menu) { if (option (OPTMSGERR)) { - sleep (1); + mutt_sleep (1); unset_option (OPTMSGERR); } diff --git a/mutt_socket.c b/mutt_socket.c index dd65b10e..e628d65e 100644 --- a/mutt_socket.c +++ b/mutt_socket.c @@ -200,7 +200,7 @@ CONNECTION* mutt_conn_find (const CONNECTION* start, const ACCOUNT* account) mutt_nss_socket_setup (conn); #else mutt_error _("SSL is unavailable."); - sleep (2); + mutt_sleep (2); FREE (&conn); return NULL; @@ -234,10 +234,10 @@ static int socket_connect (int fd, struct sockaddr* sa) dprint (1, (debugfile, "Preconnect result: %d\n", rc)); if (rc) { - save_errno = errno; - mutt_perror (_("Preconnect command failed.")); - sleep (1); - + save_errno = errno; + mutt_perror (_("Preconnect command failed.")); + mutt_sleep (1); + return save_errno; } } diff --git a/mutt_ssl.c b/mutt_ssl.c index 6fe687a4..b6ac5594 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -170,7 +170,7 @@ int ssl_init (void) if (! HAVE_ENTROPY()) { mutt_error (_("Failed to find enough entropy on your system")); - sleep (2); + mutt_sleep (2); return -1; } } @@ -202,7 +202,7 @@ static int add_entropy (const char *file) ((st.st_mode & (S_IWOTH | S_IROTH)) != 0)) { mutt_error (_("%s has insecure permissions!"), file); - sleep (2); + mutt_sleep (2); return -1; } @@ -221,7 +221,7 @@ static int add_entropy (const char *file) static int ssl_socket_open_err (CONNECTION *conn) { mutt_error (_("SSL disabled due the lack of entropy")); - sleep (2); + mutt_sleep (2); return -1; } @@ -324,7 +324,7 @@ int ssl_negotiate (sslsockdata* ssldata) } mutt_error ("SSL failed: %s", errmsg); - sleep (1); + mutt_sleep (1); return -1; } @@ -333,7 +333,7 @@ int ssl_negotiate (sslsockdata* ssldata) if (!ssldata->cert) { mutt_error (_("Unable to get certificate from peer")); - sleep (1); + mutt_sleep (1); return -1; } @@ -342,7 +342,7 @@ int ssl_negotiate (sslsockdata* ssldata) mutt_message (_("SSL connection using %s (%s)"), SSL_get_cipher_version (ssldata->ssl), SSL_get_cipher_name (ssldata->ssl)); - sleep (1); + mutt_sleep (0); return 0; } @@ -489,14 +489,14 @@ static int check_certificate_by_digest (X509 *peercert) { dprint (2, (debugfile, "Server certificate is not yet valid\n")); mutt_error (_("Server certificate is not yet valid")); - sleep (2); + mutt_sleep (2); return 0; } if (X509_cmp_current_time (X509_get_notAfter (peercert)) <= 0) { dprint (2, (debugfile, "Server certificate has expired")); mutt_error (_("Server certificate has expired")); - sleep (2); + mutt_sleep (2); return 0; } @@ -637,10 +637,15 @@ static int ssl_check_certificate (sslsockdata * data) fclose (fp); } if (!done) + { mutt_error (_("Warning: Couldn't save certificate")); + mutt_sleep (2); + } else + { mutt_message (_("Certificate saved")); - sleep (1); + mutt_sleep (0); + } /* fall through */ case OP_MAX + 2: /* accept once */ done = 2; diff --git a/muttlib.c b/muttlib.c index 4f89f089..d973514f 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1216,3 +1216,10 @@ void mutt_display_sanitize (char *s) } } +void mutt_sleep (short s) +{ + if (SleepTime > s) + sleep (SleepTime); + else if (s) + sleep (s); +} diff --git a/mx.c b/mx.c index e591e0e2..786887f0 100644 --- a/mx.c +++ b/mx.c @@ -1175,8 +1175,8 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint) mutt_message (_("%d kept, %d deleted."), msgcount - deleted, deleted); - sleep (1); /* allow the user time to read the message */ - + mutt_sleep (0); + if (ctx->msgcount == ctx->deleted && (ctx->magic == M_MBOX || ctx->magic == M_MMDF) && !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY)) diff --git a/pgpkey.c b/pgpkey.c index bfc6ff82..fa40fea1 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -484,7 +484,7 @@ static pgp_key_t *pgp_select_key (pgp_key_t *keys, if (!i && unusable) { mutt_error _("All matching keys are marked expired/revoked."); - sleep (1); + mutt_sleep (1); return NULL; } diff --git a/pop.c b/pop.c index ac3f5ddd..dba20846 100644 --- a/pop.c +++ b/pop.c @@ -240,7 +240,7 @@ int pop_open_mailbox (CONTEXT *ctx) if (pop_parse_path (ctx->path, &acct)) { mutt_error ("%s is an invalid POP path", ctx->path); - sleep (2); + mutt_sleep (2); return -1; } @@ -276,7 +276,7 @@ int pop_open_mailbox (CONTEXT *ctx) if (ret < -1) { - sleep (2); + mutt_sleep (2); return -1; } } @@ -351,7 +351,7 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno) return 0; mutt_perror (cache->path); - sleep (2); + mutt_sleep (2); return -1; } else @@ -371,7 +371,7 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno) if (h->refno < 0) { mutt_error _("The message index is incorrect. Try reopening the mailbox."); - sleep (2); + mutt_sleep (2); return -1; } @@ -382,7 +382,7 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno) if (!msg->fp) { mutt_perror (path); - sleep (2); + mutt_sleep (2); return -1; } @@ -398,14 +398,14 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno) if (ret == -2) { mutt_error ("%s", pop_data->err_msg); - sleep (2); + mutt_sleep (2); return -1; } if (ret == -3) { mutt_error _("Can't write message to temporary file!"); - sleep (2); + mutt_sleep (2); return -1; } } @@ -483,7 +483,7 @@ int pop_sync_mailbox (CONTEXT *ctx, int *index_hint) if (ret == -2) { mutt_error ("%s", pop_data->err_msg); - sleep (2); + mutt_sleep (2); return -1; } } diff --git a/pop_auth.c b/pop_auth.c index 09ec5e72..2df92212 100644 --- a/pop_auth.c +++ b/pop_auth.c @@ -152,7 +152,7 @@ bail: } mutt_error _("SASL authentication failed."); - sleep (2); + mutt_sleep (2); if (rc == SASL_OK) return POP_A_FAILURE; @@ -212,7 +212,7 @@ static pop_auth_res_t pop_auth_apop (POP_DATA *pop_data) } mutt_error _("APOP authentication failed."); - sleep (2); + mutt_sleep (2); return POP_A_SKIP; } @@ -270,7 +270,7 @@ static pop_auth_res_t pop_auth_user (POP_DATA *pop_data) } mutt_error ("%s %s", _("Login failed."), pop_data->err_msg); - sleep (2); + mutt_sleep (2); return POP_A_FAILURE; } diff --git a/pop_lib.c b/pop_lib.c index 6cbf1eb2..b38d7d05 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -235,7 +235,7 @@ int pop_open_connection (POP_DATA *pop_data) ret = pop_connect (pop_data); if (ret < 0) { - sleep (2); + mutt_sleep (2); return ret; } @@ -244,7 +244,7 @@ int pop_open_connection (POP_DATA *pop_data) goto err_conn; if (ret == -2) { - sleep (2); + mutt_sleep (2); return -2; } @@ -262,7 +262,7 @@ int pop_open_connection (POP_DATA *pop_data) if (ret == -2) { mutt_error ("%s", pop_data->err_msg); - sleep (2); + mutt_sleep (2); return ret; } @@ -272,7 +272,7 @@ int pop_open_connection (POP_DATA *pop_data) err_conn: pop_data->status = POP_DISCONNECTED; mutt_error _("Server closed connection!"); - sleep (2); + mutt_sleep (2); return -1; } @@ -462,7 +462,7 @@ int pop_reconnect (CONTEXT *ctx) if (ret == -2) { mutt_error ("%s", pop_data->err_msg); - sleep (2); + mutt_sleep (2); } } if (ret == 0) diff --git a/protos.h b/protos.h index a221e5f6..0923589c 100644 --- a/protos.h +++ b/protos.h @@ -320,6 +320,7 @@ int mutt_write_mime_header (BODY *, FILE *); int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int); int mutt_yesorno (const char *, int); void mutt_set_header_color(CONTEXT *, HEADER *); +void mutt_sleep (short); int mutt_save_confirm (const char *, struct stat *); int mh_valid_message (const char *); diff --git a/sort.c b/sort.c index 7fd4633d..9c5c0a45 100644 --- a/sort.c +++ b/sort.c @@ -230,7 +230,7 @@ void mutt_sort_headers (CONTEXT *ctx, int init) (AuxSort = mutt_get_sort_func (SortAux)) == NULL) { mutt_error _("Could not find sorting function! [report this bug]"); - sleep (1); + mutt_sleep (1); return; } else -- 2.40.0