unset_option (OPTMSGERR);
}
+void mutt_progress_bar (progress_t* progress, long pos)
+{
+ char posstr[SHORT_STRING];
+
+ if (!pos)
+ {
+ if (!NetInc)
+ mutt_message (progress->msg);
+ else {
+ mutt_pretty_size (progress->sizestr, sizeof (progress->sizestr), progress->size);
+ progress->pos = 0;
+ }
+ }
+
+ if (!NetInc)
+ return;
+
+ if (pos > progress->pos + (NetInc << 10))
+ {
+ mutt_pretty_size (posstr, sizeof (posstr), pos);
+ mutt_message ("%s %s/%s", progress->msg, posstr, progress->sizestr);
+ progress->pos = pos;
+ }
+}
+
void mutt_show_error (void)
{
if (option (OPTKEEPQUIET))
#ifdef USE_SOCKET
WHERE char *Preconnect INITVAL (NULL);
WHERE char *Tunnel INITVAL (NULL);
+WHERE short NetInc;
#endif /* USE_SOCKET */
#ifdef MIXMASTER
#endif
#include "mutt.h"
-#include "mutt_curses.h"
#include "mx.h"
#include "mailbox.h"
#include "globals.h"
/* imap_read_literal: read bytes bytes from server into file. Not explicitly
* buffered, relies on FILE buffering. NOTE: strips \r from \r\n.
* Apparently even literals use \r\n-terminated strings ?! */
-int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes)
+int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes, progress_t* pbar)
{
long pos;
char c;
r = 0;
#endif
fputc (c, fp);
+
+ if (pbar && pos % 1024)
+ mutt_progress_bar (pbar, pos);
#ifdef DEBUG
if (debuglevel >= IMAP_LOG_LTRL)
fputc (c, debugfile);
#define _IMAP_PRIVATE_H 1
#include "imap.h"
+#include "mutt_curses.h"
#include "mutt_socket.h"
/* -- symbols -- */
IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags);
int imap_parse_list_response(IMAP_DATA* idata, char** name, int* noselect,
int* noinferiors, char* delim);
-int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes);
+int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes, progress_t*);
void imap_expunge_mailbox (IMAP_DATA* idata);
void imap_logout (IMAP_DATA* idata);
int imap_sync_message (IMAP_DATA *idata, HEADER *hdr, BUFFER *cmd,
#include <ctype.h>
#include "mutt.h"
-#include "mutt_curses.h"
#include "imap_private.h"
#include "message.h"
#include "mx.h"
char path[_POSIX_PATH_MAX];
char *pc;
long bytes;
+ progress_t progressbar;
int uid;
int cacheno;
IMAP_CACHE *cache;
imap_error ("imap_fetch_message()", buf);
goto bail;
}
- if (imap_read_literal (msg->fp, idata, bytes) < 0)
+ progressbar.size = bytes;
+ progressbar.msg = _("Fetching message...");
+ mutt_progress_bar (&progressbar, 0);
+ if (imap_read_literal (msg->fp, idata, bytes, &progressbar) < 0)
goto bail;
/* pick up trailing line */
if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
char mbox[LONG_STRING];
char mailbox[LONG_STRING];
size_t len;
+ progress_t progressbar;
+ size_t sent;
int c, last;
IMAP_MBOX mx;
int rc;
len++;
}
rewind (fp);
+
+ progressbar.msg = _("Uploading message...");
+ progressbar.size = len;
+ mutt_progress_bar (&progressbar, 0);
imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s%s%s) {%lu}", mbox,
goto fail;
}
- mutt_message _("Uploading message ...");
-
- for (last = EOF, len = 0; (c = fgetc(fp)) != EOF; last = c)
+ for (last = EOF, sent = len = 0; (c = fgetc(fp)) != EOF; last = c)
{
if (c == '\n' && last != '\r')
buf[len++] = '\r';
buf[len++] = c;
if (len > sizeof(buf) - 3)
+ {
+ sent += len;
flush_buffer(buf, &len, idata->conn);
+ mutt_progress_bar (&progressbar, sent);
+ }
}
if (len)
if (imap_get_literal_count (buf, &bytes) == 0)
{
- imap_read_literal (fp, idata, bytes);
+ imap_read_literal (fp, idata, bytes, NULL);
/* we may have other fields of the FETCH _after_ the literal
* (eg Domino puts FLAGS here). Nothing wrong with that, either.
** This variable, when set, makes the thread tree narrower, allowing
** deeper threads to fit on the screen.
*/
+#ifdef USE_SOCKET
+ { "net_inc", DT_NUM, R_NONE, UL &NetInc, 10 },
+ /*
+ ** .pp
+ ** Operations that expect to transfer a large amount of data over the
+ ** network will update their progress every \fInet_inc\fP kilobytes.
+ ** If set to 0, no progress messages will be displayed.
+ ** .pp
+ ** See also ``$$read_inc'' and ``$$write_inc''.
+ */
+#endif
{ "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
/*
** .pp
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
+#ifndef _MUTT_CURSES_H_
+#define _MUTT_CURSES_H_ 1
+
#ifdef USE_SLANG_CURSES
#ifndef unix /* this symbol is not defined by the hp-ux compiler (sigh) */
struct color_line *next;
} COLOR_LINE;
+typedef struct
+{
+ const char* msg;
+ long pos;
+ long size;
+ char sizestr[SHORT_STRING];
+} progress_t;
+
+void mutt_progress_bar (progress_t* progress, long pos);
+
extern int *ColorQuote;
extern int ColorQuoteUsed;
extern int ColorDefs[];
extern int waddstr();
extern int wclrtoeol();
#endif
+
+#endif /* _MUTT_CURSES_H_ */