Nico Golde:
[apps/madmutt.git] / imap / message.c
index 3653c53..949ca2c 100644 (file)
@@ -325,6 +325,7 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
   IMAP_CACHE *cache;
   int read;
   int rc;
   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. */
 
   /* Sam's weird courier server returns an OK response even when FETCH
    * fails. Thanks Sam. */
@@ -395,7 +396,12 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
             imap_error ("imap_fetch_message()", buf);
             goto bail;
           }
             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)
             goto bail;
           /* pick up trailing line */
           if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
@@ -492,6 +498,8 @@ int imap_append_message (CONTEXT * ctx, MESSAGE * msg)
   int c, last;
   IMAP_MBOX mx;
   int rc;
   int c, last;
   IMAP_MBOX mx;
   int rc;
+  progress_t bar;
+  size_t sent;
 
   idata = (IMAP_DATA *) ctx->data;
 
 
   idata = (IMAP_DATA *) ctx->data;
 
@@ -519,6 +527,12 @@ int imap_append_message (CONTEXT * ctx, MESSAGE * msg)
   }
   rewind (fp);
 
   }
   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" : "",
   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" : "",
@@ -548,16 +562,19 @@ int imap_append_message (CONTEXT * ctx, MESSAGE * msg)
     goto fail;
   }
 
     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 (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);
       flush_buffer (buf, &len, idata->conn);
+#ifdef USE_SOCKET
+    mutt_progress_bar (&bar, sent);
+#endif
+    }
   }
 
   if (len)
   }
 
   if (len)
@@ -856,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) {
     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.
 
     /* we may have other fields of the FETCH _after_ the literal
      * (eg Domino puts FLAGS here). Nothing wrong with that, either.