X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=imap%2Fmessage.c;h=949ca2cece0891d86bb109214cb54ea47b6ac253;hp=e09ec4e3277ea4a5c315ee7469df25d3eb303522;hb=a0aa3d4bba449529dfed997214b34e309ce451dd;hpb=a8477ebaa09990b3688164cbe5cf661c4189541d diff --git a/imap/message.c b/imap/message.c index e09ec4e..949ca2c 100644 --- a/imap/message.c +++ b/imap/message.c @@ -18,10 +18,13 @@ #include #include "mutt.h" +#include "ascii.h" +#include "buffer.h" #include "mutt_curses.h" #include "imap_private.h" #include "message.h" #include "mx.h" +#include "hcache.h" #ifdef HAVE_PGP #include "pgp.h" @@ -128,7 +131,7 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) rewind (fp); memset (&h, 0, sizeof (h)); - h.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA)); + h.data = mem_calloc (1, sizeof (IMAP_HEADER_DATA)); do { mfhrc = 0; @@ -171,7 +174,7 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) rewind (fp); - FREE (&uid_validity); + mem_free (&uid_validity); } while ((rc != IMAP_CMD_OK) && ((mfhrc == -1) || @@ -218,7 +221,7 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) /* freshen fp, h */ rewind (fp); memset (&h, 0, sizeof (h)); - h.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA)); + h.data = mem_calloc (1, sizeof (IMAP_HEADER_DATA)); /* this DO loop does two things: * 1. handles untagged messages, so we can try again on the same msg @@ -322,6 +325,7 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) IMAP_CACHE *cache; int read; int rc; + progress_t bar; /* Sam's weird courier server returns an OK response even when FETCH * fails. Thanks Sam. */ @@ -340,7 +344,7 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) return 0; else { unlink (cache->path); - FREE (&cache->path); + mem_free (&cache->path); } } @@ -351,7 +355,7 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) mutt_mktemp (path); cache->path = str_dup (path); if (!(msg->fp = safe_fopen (path, "w+"))) { - FREE (&cache->path); + mem_free (&cache->path); return -1; } @@ -392,7 +396,12 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) imap_error ("imap_fetch_message()", buf); goto bail; } - if (imap_read_literal (msg->fp, idata, bytes) < 0) + bar.size = bytes; + bar.msg = _("Fetching message..."); +#ifdef USE_SOCKET + mutt_progress_bar (&bar, 0); +#endif + if (imap_read_literal (msg->fp, idata, bytes, &bar) < 0) goto bail; /* pick up trailing line */ if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE) @@ -472,7 +481,7 @@ bail: safe_fclose (&msg->fp); if (cache->path) { unlink (cache->path); - FREE (&cache->path); + mem_free (&cache->path); } return -1; @@ -489,6 +498,8 @@ int imap_append_message (CONTEXT * ctx, MESSAGE * msg) int c, last; IMAP_MBOX mx; int rc; + progress_t bar; + size_t sent; idata = (IMAP_DATA *) ctx->data; @@ -516,6 +527,12 @@ int imap_append_message (CONTEXT * ctx, MESSAGE * msg) } rewind (fp); + bar.msg = _("Uploading message..."); + bar.size = len; +#ifdef USE_SOCKET + mutt_progress_bar (&bar, 0); +#endif + imap_munge_mbox_name (mbox, sizeof (mbox), mailbox); snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s%s%s) {%lu}", mbox, msg->flags.read ? "\\Seen" : "", @@ -545,16 +562,19 @@ int imap_append_message (CONTEXT * ctx, MESSAGE * msg) 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) + if (len > sizeof (buf) - 3) { + sent += len; flush_buffer (buf, &len, idata->conn); +#ifdef USE_SOCKET + mutt_progress_bar (&bar, sent); +#endif + } } if (len) @@ -579,11 +599,11 @@ int imap_append_message (CONTEXT * ctx, MESSAGE * msg) goto fail; } - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; fail: - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -725,18 +745,18 @@ int imap_copy_messages (CONTEXT * ctx, HEADER * h, char *dest, int delete) } if (cmd.data) - FREE (&cmd.data); + mem_free (&cmd.data); if (sync_cmd.data) - FREE (&sync_cmd.data); - FREE (&mx.mbox); + mem_free (&sync_cmd.data); + mem_free (&mx.mbox); return 0; fail: if (cmd.data) - FREE (&cmd.data); + mem_free (&cmd.data); if (sync_cmd.data) - FREE (&sync_cmd.data); - FREE (&mx.mbox); + mem_free (&sync_cmd.data); + mem_free (&mx.mbox); return -1; } @@ -767,7 +787,7 @@ void imap_free_header_data (void **data) /* this should be safe even if the list wasn't used */ mutt_free_list (&(((IMAP_HEADER_DATA *) * data)->keywords)); - FREE (data); + mem_free (data); } /* imap_set_flags: fill out the message header according to the flags from @@ -779,11 +799,11 @@ char *imap_set_flags (IMAP_DATA * idata, HEADER * h, char *s) unsigned char readonly; memset (&newh, 0, sizeof (newh)); - newh.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA)); + newh.data = mem_calloc (1, sizeof (IMAP_HEADER_DATA)); debug_print (2, ("parsing FLAGS\n")); if ((s = msg_parse_flags (&newh, s)) == NULL) { - FREE (&newh.data); + mem_free (&newh.data); return NULL; } @@ -809,7 +829,7 @@ char *imap_set_flags (IMAP_DATA * idata, HEADER * h, char *s) mutt_free_list (&(HEADER_DATA (h)->keywords)); HEADER_DATA (h)->keywords = newh.data->keywords; - FREE (&newh.data); + mem_free (&newh.data); return s; } @@ -853,7 +873,7 @@ static int msg_fetch_header (CONTEXT * ctx, IMAP_HEADER * h, char *buf, return rc; 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.