]> granicus.if.org Git - neomutt/commitdiff
ci_send_message: factor out Context
authorRichard Russon <rich@flatcap.org>
Fri, 11 Jan 2019 21:51:53 +0000 (21:51 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 8 Feb 2019 14:34:07 +0000 (14:34 +0000)
commands.c
hdrline.c
hdrline.h
index.c
pager.c
recvcmd.c
send.c
send.h

index f16f9e6eab0fd37d307ff21e82837231f02988ed..aa35fa608d113d59321ffbec2f16f06af84628a4 100644 (file)
@@ -255,6 +255,7 @@ int mutt_display_message(struct Email *cur)
   {
     struct HdrFormatInfo hfi;
     hfi.ctx = Context;
+    hfi.mailbox = Context->mailbox;
     hfi.pager_progress = ExtPagerProgress;
     hfi.email = cur;
     mutt_make_string_info(buf, sizeof(buf), MuttIndexWindow->cols,
index 5488d4ce286dc333a059aa719c5ff0b22ae0d9e2..437069d56ca1824a68d8ed736ba0722a791a14b3 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -560,7 +560,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
 
   struct Email *e = hfi->email;
   struct Context *ctx = hfi->ctx;
-  struct Mailbox *m = hfi->m;
+  struct Mailbox *m = hfi->mailbox;
 
   if (!e || !e->env)
     return src;
@@ -1460,7 +1460,7 @@ void mutt_make_string_flags(char *buf, size_t buflen, const char *s, struct Cont
 
   hfi.email = e;
   hfi.ctx = ctx;
-  hfi.m = m;
+  hfi.mailbox = m;
   hfi.pager_progress = 0;
 
   mutt_expando_format(buf, buflen, 0, MuttIndexWindow->cols, s,
index 76b14753f4fd9e47adb8d588bf1d330602a24b02..e27d1e5de0f2e022a00fdb08c509eed7a7d63df7 100644 (file)
--- a/hdrline.h
+++ b/hdrline.h
@@ -43,7 +43,7 @@ extern struct MbTable *ToChars;
 struct HdrFormatInfo
 {
   struct Context *ctx;
-  struct Mailbox *m;
+  struct Mailbox *mailbox;
   struct Email *email;
   const char *pager_progress;
 };
diff --git a/index.c b/index.c
index c15f765678b234f91c7fa11cd778b532c9a60831..91b381797d9eed759d0883331fe2589d2bca0084 100644 (file)
--- a/index.c
+++ b/index.c
@@ -1800,12 +1800,17 @@ int mutt_index_menu(void)
         break;
 
       case OP_COMPOSE_TO_SENDER:
+      {
         CHECK_ATTACH;
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
-        ci_send_message(SEND_TO_SENDER, NULL, NULL, Context, tag ? NULL : CUR_EMAIL);
+        struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+        el_add_tagged(&el, Context, CUR_EMAIL, tag);
+        ci_send_message(SEND_TO_SENDER, NULL, NULL, Context, &el);
+        el_free(&el);
         menu->redraw = REDRAW_FULL;
         break;
+      }
 
         /* --------------------------------------------------------------------
          * The following operations can be performed inside of the pager.
@@ -3111,41 +3116,42 @@ int mutt_index_menu(void)
       }
 
       case OP_FORWARD_MESSAGE:
-
+      {
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
         CHECK_ATTACH;
+        struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+        el_add_tagged(&el, Context, CUR_EMAIL, tag);
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
-          el_add_tagged(&el, Context, CUR_EMAIL, tag);
           mutt_check_traditional_pgp(&el, &menu->redraw);
-          el_free(&el);
         }
-        ci_send_message(SEND_FORWARD, NULL, NULL, Context, tag ? NULL : CUR_EMAIL);
+        ci_send_message(SEND_FORWARD, NULL, NULL, Context, &el);
+        el_free(&el);
         menu->redraw = REDRAW_FULL;
         break;
+      }
 
       case OP_FORGET_PASSPHRASE:
         crypt_forget_passphrase();
         break;
 
       case OP_GROUP_REPLY:
-
+      {
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
         CHECK_ATTACH;
+        struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+        el_add_tagged(&el, Context, CUR_EMAIL, tag);
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
-          el_add_tagged(&el, Context, CUR_EMAIL, tag);
           mutt_check_traditional_pgp(&el, &menu->redraw);
-          el_free(&el);
         }
-        ci_send_message(SEND_REPLY | SEND_GROUP_REPLY, NULL, NULL, Context,
-                        tag ? NULL : CUR_EMAIL);
+        ci_send_message(SEND_REPLY | SEND_GROUP_REPLY, NULL, NULL, Context, &el);
+        el_free(&el);
         menu->redraw = REDRAW_FULL;
         break;
+      }
 
       case OP_EDIT_LABEL:
       {
@@ -3177,21 +3183,21 @@ int mutt_index_menu(void)
       }
 
       case OP_LIST_REPLY:
-
+      {
         CHECK_ATTACH;
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
+        struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+        el_add_tagged(&el, Context, CUR_EMAIL, tag);
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
-          el_add_tagged(&el, Context, CUR_EMAIL, tag);
           mutt_check_traditional_pgp(&el, &menu->redraw);
-          el_free(&el);
         }
-        ci_send_message(SEND_REPLY | SEND_LIST_REPLY, NULL, NULL, Context,
-                        tag ? NULL : CUR_EMAIL);
+        ci_send_message(SEND_REPLY | SEND_LIST_REPLY, NULL, NULL, Context, &el);
+        el_free(&el);
         menu->redraw = REDRAW_FULL;
         break;
+      }
 
       case OP_MAIL:
 
@@ -3223,6 +3229,7 @@ int mutt_index_menu(void)
       }
 
       case OP_CHECK_TRADITIONAL:
+      {
         if (!(WithCrypto & APPLICATION_PGP))
           break;
         CHECK_MSGCOUNT;
@@ -3241,6 +3248,7 @@ int mutt_index_menu(void)
           continue;
         }
         break;
+      }
 
       case OP_PIPE:
 
@@ -3404,8 +3412,11 @@ int mutt_index_menu(void)
           else
           {
             CHECK_MSGCOUNT;
+            struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+            el_add_tagged(&el, Context, CUR_EMAIL, tag);
             ci_send_message((op == OP_FOLLOWUP ? SEND_REPLY : SEND_FORWARD) | SEND_NEWS,
-                            NULL, NULL, Context, tag ? NULL : CUR_EMAIL);
+                            NULL, NULL, Context, &el);
+            el_free(&el);
           }
           menu->redraw = REDRAW_FULL;
           break;
@@ -3413,20 +3424,21 @@ int mutt_index_menu(void)
 #endif
       /* fallthrough */
       case OP_REPLY:
-
+      {
         CHECK_ATTACH;
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
+        struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+        el_add_tagged(&el, Context, CUR_EMAIL, tag);
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
-          el_add_tagged(&el, Context, CUR_EMAIL, tag);
           mutt_check_traditional_pgp(&el, &menu->redraw);
-          el_free(&el);
         }
-        ci_send_message(SEND_REPLY, NULL, NULL, Context, tag ? NULL : CUR_EMAIL);
+        ci_send_message(SEND_REPLY, NULL, NULL, Context, &el);
+        el_free(&el);
         menu->redraw = REDRAW_FULL;
         break;
+      }
 
       case OP_SHELL_ESCAPE:
 
diff --git a/pager.c b/pager.c
index 339676ea92ea8a298b9b0554a15d0a6129f92711..c131a1a3b8ae2c9883618455c44abf4dc39aa746 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -2153,7 +2153,7 @@ static void pager_custom_redraw(struct Menu *pager_menu)
     char pager_progress_str[65]; /* Lots of space for translations */
 
     hfi.ctx = Context;
-    hfi.m = Context ? Context->mailbox : NULL;
+    hfi.mailbox = Context ? Context->mailbox : NULL;
     hfi.pager_progress = pager_progress_str;
 
     if (rd->last_pos < rd->sb.st_size - 1)
@@ -2962,7 +2962,12 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
         if (IsMsgAttach(extra))
           mutt_attach_mail_sender(extra->fp, extra->email, extra->actx, extra->bdy);
         else
-          ci_send_message(SEND_TO_SENDER, NULL, NULL, extra->ctx, extra->email);
+        {
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_email(&el, extra->email);
+          ci_send_message(SEND_TO_SENDER, NULL, NULL, extra->ctx, &el);
+          el_free(&el);
+        }
         pager_menu->redraw = REDRAW_FULL;
         break;
 
@@ -3163,8 +3168,12 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
         if (IsMsgAttach(extra))
           mutt_attach_forward(extra->fp, extra->email, extra->actx, extra->bdy, SEND_NEWS);
         else
-          ci_send_message(SEND_NEWS | SEND_FORWARD, NULL, NULL, extra->ctx,
-                          extra->email);
+        {
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_email(&el, extra->email);
+          ci_send_message(SEND_NEWS | SEND_FORWARD, NULL, NULL, extra->ctx, &el);
+          el_free(&el);
+        }
         pager_menu->redraw = REDRAW_FULL;
         break;
 
@@ -3192,8 +3201,12 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
                               SEND_NEWS | SEND_REPLY);
           }
           else
-            ci_send_message(SEND_NEWS | SEND_REPLY, NULL, NULL, extra->ctx,
-                            extra->email);
+          {
+            struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+            el_add_email(&el, extra->email);
+            ci_send_message(SEND_NEWS | SEND_REPLY, NULL, NULL, extra->ctx, &el);
+            el_free(&el);
+          }
           pager_menu->redraw = REDRAW_FULL;
           break;
         }
@@ -3205,16 +3218,26 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
         if (IsMsgAttach(extra))
           mutt_attach_reply(extra->fp, extra->email, extra->actx, extra->bdy, SEND_REPLY);
         else
-          ci_send_message(SEND_REPLY, NULL, NULL, extra->ctx, extra->email);
+        {
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_email(&el, extra->email);
+          ci_send_message(SEND_REPLY, NULL, NULL, extra->ctx, &el);
+          el_free(&el);
+        }
         pager_menu->redraw = REDRAW_FULL;
         break;
 
       case OP_RECALL_MESSAGE:
+      {
         CHECK_MODE(IsEmail(extra) && !IsAttach(extra));
         CHECK_ATTACH;
-        ci_send_message(SEND_POSTPONED, NULL, NULL, extra->ctx, extra->email);
+        struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+        el_add_email(&el, extra->email);
+        ci_send_message(SEND_POSTPONED, NULL, NULL, extra->ctx, &el);
+        el_free(&el);
         pager_menu->redraw = REDRAW_FULL;
         break;
+      }
 
       case OP_GROUP_REPLY:
         CHECK_MODE(IsEmail(extra) || IsMsgAttach(extra));
@@ -3226,8 +3249,10 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
         }
         else
         {
-          ci_send_message(SEND_REPLY | SEND_GROUP_REPLY, NULL, NULL, extra->ctx,
-                          extra->email);
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_email(&el, extra->email);
+          ci_send_message(SEND_REPLY | SEND_GROUP_REPLY, NULL, NULL, extra->ctx, &el);
+          el_free(&el);
         }
         pager_menu->redraw = REDRAW_FULL;
         break;
@@ -3242,8 +3267,10 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
         }
         else
         {
-          ci_send_message(SEND_REPLY | SEND_LIST_REPLY, NULL, NULL, extra->ctx,
-                          extra->email);
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_email(&el, extra->email);
+          ci_send_message(SEND_REPLY | SEND_LIST_REPLY, NULL, NULL, extra->ctx, &el);
+          el_free(&el);
         }
         pager_menu->redraw = REDRAW_FULL;
         break;
@@ -3254,7 +3281,12 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
         if (IsMsgAttach(extra))
           mutt_attach_forward(extra->fp, extra->email, extra->actx, extra->bdy, 0);
         else
-          ci_send_message(SEND_FORWARD, NULL, NULL, extra->ctx, extra->email);
+        {
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_email(&el, extra->email);
+          ci_send_message(SEND_FORWARD, NULL, NULL, extra->ctx, &el);
+          el_free(&el);
+        }
         pager_menu->redraw = REDRAW_FULL;
         break;
 
@@ -3422,6 +3454,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
         break;
 
       case OP_MAIL_KEY:
+      {
         if (!(WithCrypto & APPLICATION_PGP))
         {
           ch = -1;
@@ -3429,9 +3462,13 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
         }
         CHECK_MODE(IsEmail(extra));
         CHECK_ATTACH;
-        ci_send_message(SEND_KEY, NULL, NULL, extra->ctx, extra->email);
+        struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+        el_add_email(&el, extra->email);
+        ci_send_message(SEND_KEY, NULL, NULL, extra->ctx, &el);
+        el_free(&el);
         pager_menu->redraw = REDRAW_FULL;
         break;
+      }
 
       case OP_EDIT_LABEL:
       {
index 53606934b7a3e2155cae24de61df6ddc1a4aabf7..980c6f79b5231f2d15e984fbbd46187db3606c52 100644 (file)
--- a/recvcmd.c
+++ b/recvcmd.c
@@ -600,7 +600,10 @@ static void attach_forward_bodies(FILE *fp, struct Email *e, struct AttachCtx *a
   tmpfp = NULL;
 
   /* now that we have the template, send it. */
-  ci_send_message(0, tmphdr, tmpbody, NULL, parent_hdr);
+  struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+  el_add_email(&el, parent_hdr);
+  ci_send_message(0, tmphdr, tmpbody, NULL, &el);
+  el_free(&el);
   return;
 
 bail:
@@ -732,7 +735,10 @@ static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx, struct Body *c
   else
     mutt_email_free(&tmphdr);
 
-  ci_send_message(flags, tmphdr, *tmpbody ? tmpbody : NULL, NULL, curhdr);
+  struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+  el_add_email(&el, curhdr);
+  ci_send_message(flags, tmphdr, *tmpbody ? tmpbody : NULL, NULL, &el);
+  el_free(&el);
 }
 
 /**
@@ -1040,11 +1046,13 @@ void mutt_attach_reply(FILE *fp, struct Email *e, struct AttachCtx *actx,
 
   mutt_file_fclose(&tmpfp);
 
-  if (ci_send_message(flags, tmphdr, tmpbody, NULL,
-                      parent_hdr ? parent_hdr : (cur ? cur->email : NULL)) == 0)
+  struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+  el_add_email(&el, parent_hdr ? parent_hdr : (cur ? cur->email : NULL));
+  if (ci_send_message(flags, tmphdr, tmpbody, NULL, &el) == 0)
   {
     mutt_set_flag(Context->mailbox, e, MUTT_REPLIED, 1);
   }
+  el_free(&el);
 }
 
 /**
diff --git a/send.c b/send.c
index 484c5fd2a3e61c55ee9053a1bf1f25262c8f6f9f..5e4e7b7ec6d8c5eaca81d006329abe725601c309 100644 (file)
--- a/send.c
+++ b/send.c
@@ -863,13 +863,19 @@ void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv
  * @param env    Envelope for result
  * @param ctx    Mailbox
  */
-static void make_reference_headers(struct Envelope *curenv,
+static void make_reference_headers(struct EmailList *el,
                                    struct Envelope *env, struct Context *ctx)
 {
+  if (!el || STAILQ_EMPTY(el))
+    return;
+
   if (!env || !ctx || !ctx->mailbox)
     return;
 
-  if (!curenv)
+  struct EmailNode *en = STAILQ_FIRST(el);
+  bool single = !STAILQ_NEXT(en, entries);
+
+  if (!single)
   {
     for (int i = 0; i < ctx->mailbox->msg_count; i++)
     {
@@ -878,7 +884,7 @@ static void make_reference_headers(struct Envelope *curenv,
     }
   }
   else
-    mutt_add_to_reference_headers(env, curenv);
+    mutt_add_to_reference_headers(env, en->email->env);
 
   /* if there's more than entry in In-Reply-To (i.e. message has
      multiple parents), don't generate a References: header as it's
@@ -894,42 +900,21 @@ static void make_reference_headers(struct Envelope *curenv,
  * envelope_defaults - Fill in some defaults for a new email
  * @param env   Envelope for result
  * @param ctx   Mailbox
- * @param cur   Email
+ * @param el    List of Emails to use
  * @param flags Flags, e.g. #SEND_REPLY
  * @retval  0 Success
  * @retval -1 Failure
  */
 static int envelope_defaults(struct Envelope *env, struct Context *ctx,
-                             struct Email *cur, int flags)
+                             struct EmailList *el, int flags)
 {
-  struct Envelope *curenv = NULL;
-  bool tag = false;
-
-  if (!cur)
-  {
-    tag = true;
-    for (int i = 0; i < ctx->mailbox->msg_count; i++)
-    {
-      if (!message_is_tagged(ctx, i))
-        continue;
+  if (!el || STAILQ_EMPTY(el))
+    return -1;
 
-      cur = ctx->mailbox->emails[i];
-      curenv = cur->env;
-      break;
-    }
-
-    if (!cur)
-    {
-      /* This could happen if the user tagged some messages and then did
-       * a limit such that none of the tagged message are visible.
-       */
-      mutt_error(_("No tagged messages are visible"));
-      return -1;
-    }
-  }
-  else
-    curenv = cur->env;
+  struct EmailNode *en = STAILQ_FIRST(el);
+  bool single = !STAILQ_NEXT(en, entries);
 
+  struct Envelope *curenv = en->email->env;
   if (!curenv)
     return -1;
 
@@ -947,14 +932,11 @@ static int envelope_defaults(struct Envelope *env, struct Context *ctx,
     }
     else
 #endif
-        if (tag)
+        if (!single)
     {
-      for (int i = 0; i < ctx->mailbox->msg_count; i++)
+      STAILQ_FOREACH(en, el, entries)
       {
-        if (!message_is_tagged(ctx, i))
-          continue;
-
-        if (mutt_fetch_recips(env, ctx->mailbox->emails[i]->env, flags) == -1)
+        if (mutt_fetch_recips(env, en->email->env, flags) == -1)
           return -1;
       }
     }
@@ -970,14 +952,14 @@ static int envelope_defaults(struct Envelope *env, struct Context *ctx,
     if (flags & SEND_REPLY)
     {
       mutt_make_misc_reply_headers(env, curenv);
-      make_reference_headers(tag ? NULL : curenv, env, ctx);
+      make_reference_headers(el, env, ctx);
     }
   }
   else if (flags & SEND_FORWARD)
   {
-    mutt_make_forward_subject(env, ctx->mailbox, cur);
+    mutt_make_forward_subject(env, ctx->mailbox, en->email);
     if (ForwardReferences)
-      make_reference_headers(tag ? NULL : curenv, env, ctx);
+      make_reference_headers(el, env, ctx);
   }
 
   return 0;
@@ -989,15 +971,22 @@ static int envelope_defaults(struct Envelope *env, struct Context *ctx,
  * @param msg    header for outgoing message
  * @param flags  compose mode
  * @param ctx    current mailbox
- * @param cur    current message
+ * @param el     List of Emails to use
  * @retval  0 Success
  * @retval -1 Error
  */
 static int generate_body(FILE *tempfp, struct Email *msg, int flags,
-                         struct Context *ctx, struct Email *cur)
+                         struct Context *ctx, struct EmailList *el)
 {
   int i;
   struct Body *tmp = NULL;
+  struct EmailNode *en = NULL;
+  bool single = true;
+
+  if (el)
+    en = STAILQ_FIRST(el);
+  if (en)
+    single = !STAILQ_NEXT(en, entries);
 
   if (flags & SEND_REPLY)
   {
@@ -1008,14 +997,11 @@ static int generate_body(FILE *tempfp, struct Email *msg, int flags,
     if (i == MUTT_YES)
     {
       mutt_message(_("Including quoted message..."));
-      if (!cur)
+      if (!single)
       {
-        for (i = 0; i < ctx->mailbox->msg_count; i++)
+        STAILQ_FOREACH(en, el, entries)
         {
-          if (!message_is_tagged(ctx, i))
-            continue;
-
-          if (include_reply(ctx->mailbox, ctx->mailbox->emails[i], tempfp) == -1)
+          if (include_reply(ctx->mailbox, en->email, tempfp) == -1)
           {
             mutt_error(_("Could not include all requested messages"));
             return -1;
@@ -1024,7 +1010,7 @@ static int generate_body(FILE *tempfp, struct Email *msg, int flags,
         }
       }
       else
-        include_reply(ctx->mailbox, cur, tempfp);
+        include_reply(ctx->mailbox, en->email, tempfp);
     }
   }
   else if (flags & SEND_FORWARD)
@@ -1039,9 +1025,9 @@ static int generate_body(FILE *tempfp, struct Email *msg, int flags,
       while (last && last->next)
         last = last->next;
 
-      if (cur)
+      if (single)
       {
-        tmp = mutt_make_message_attach(ctx->mailbox, cur, false);
+        tmp = mutt_make_message_attach(ctx->mailbox, en->email, false);
         if (last)
           last->next = tmp;
         else
@@ -1049,12 +1035,9 @@ static int generate_body(FILE *tempfp, struct Email *msg, int flags,
       }
       else
       {
-        for (i = 0; i < ctx->mailbox->msg_count; i++)
+        STAILQ_FOREACH(en, el, entries)
         {
-          if (!message_is_tagged(ctx, i))
-            continue;
-
-          tmp = mutt_make_message_attach(ctx->mailbox, ctx->mailbox->emails[i], false);
+          tmp = mutt_make_message_attach(ctx->mailbox, en->email, false);
           if (last)
           {
             last->next = tmp;
@@ -1070,8 +1053,8 @@ static int generate_body(FILE *tempfp, struct Email *msg, int flags,
     }
     else if (i != -1)
     {
-      if (cur)
-        include_forward(ctx->mailbox, cur, tempfp);
+      if (single)
+        include_forward(ctx->mailbox, en->email, tempfp);
       else
       {
         for (i = 0; i < ctx->mailbox->msg_count; i++)
@@ -1415,7 +1398,12 @@ int mutt_resend_message(FILE *fp, struct Context *ctx, struct Email *cur)
     }
   }
 
-  return ci_send_message(SEND_RESEND, msg, NULL, ctx, cur);
+  struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+  el_add_email(&el, cur);
+  int rc = ci_send_message(SEND_RESEND, msg, NULL, ctx, &el);
+  el_free(&el);
+
+  return rc;
 }
 
 /**
@@ -1742,13 +1730,13 @@ static int postpone_message(struct Email *msg, struct Email *cur, char *fcc, int
  * @param msg      template to use for new message
  * @param tempfile file specified by -i or -H
  * @param ctx      current mailbox
- * @param cur      current message
+ * @param el       List of Emails to send
  * @retval  0 Message was successfully sent
  * @retval -1 Message was aborted or an error occurred
  * @retval  1 Message was postponed
  */
 int ci_send_message(int flags, struct Email *msg, const char *tempfile,
-                    struct Context *ctx, struct Email *cur)
+                    struct Context *ctx, struct EmailList *el)
 {
   char buf[LONG_STRING];
   char fcc[PATH_MAX] = ""; /* where to copy this message */
@@ -1767,6 +1755,13 @@ int ci_send_message(int flags, struct Email *msg, const char *tempfile,
   char *err = NULL;
   char *ctype = NULL;
   char *finalpath = NULL;
+  struct EmailNode *en = NULL;
+  struct Email *cur = NULL;
+
+  if (el)
+    en = STAILQ_FIRST(el);
+  if (en)
+    cur = STAILQ_NEXT(en, entries) ? en->email : NULL;
 
   int rc = -1;
 
@@ -1943,7 +1938,7 @@ int ci_send_message(int flags, struct Email *msg, const char *tempfile,
   if (!(flags & (SEND_POSTPONED | SEND_RESEND)) && !((flags & SEND_DRAFT_FILE) && ResumeDraftFiles))
   {
     if ((flags & (SEND_REPLY | SEND_FORWARD | SEND_TO_SENDER)) && ctx &&
-        envelope_defaults(msg->env, ctx, cur, flags) == -1)
+        envelope_defaults(msg->env, ctx, el, flags) == -1)
     {
       goto cleanup;
     }
@@ -2039,7 +2034,7 @@ int ci_send_message(int flags, struct Email *msg, const char *tempfile,
 
     /* include replies/forwarded messages, unless we are given a template */
     if (!tempfile && (ctx || !(flags & (SEND_REPLY | SEND_FORWARD))) &&
-        generate_body(tempfp, msg, flags, ctx, cur) == -1)
+        generate_body(tempfp, msg, flags, ctx, el) == -1)
     {
       goto cleanup;
     }
@@ -2490,13 +2485,9 @@ int ci_send_message(int flags, struct Email *msg, const char *tempfile,
       mutt_set_flag(ctx->mailbox, cur, MUTT_REPLIED, is_reply(cur, msg));
     else if (!(flags & SEND_POSTPONED) && ctx && ctx->mailbox && ctx->mailbox->msg_tagged)
     {
-      for (i = 0; i < ctx->mailbox->msg_count; i++)
+      STAILQ_FOREACH(en, el, entries)
       {
-        if (message_is_tagged(ctx, i))
-        {
-          mutt_set_flag(ctx->mailbox, ctx->mailbox->emails[i], MUTT_REPLIED,
-                        is_reply(ctx->mailbox->emails[i], msg));
-        }
+        mutt_set_flag(ctx->mailbox, en->email, MUTT_REPLIED, is_reply(en->email, msg));
       }
     }
   }
diff --git a/send.h b/send.h
index 68c167ffa6767bfc0ee0af5dd9480b6491846932..04686422322db260dc82d6b0f0b35e25d3e9b0cf 100644 (file)
--- a/send.h
+++ b/send.h
@@ -30,6 +30,7 @@ struct Address;
 struct Body;
 struct Context;
 struct Email;
+struct EmailList;
 struct Envelope;
 struct Mailbox;
 
@@ -95,7 +96,7 @@ extern bool          UseFrom;
 #define SEND_TO_SENDER      (1 << 12)
 #define SEND_NEWS           (1 << 13)
 
-int             ci_send_message(int flags, struct Email *msg, const char *tempfile, struct Context *ctx, struct Email *cur);
+int             ci_send_message(int flags, struct Email *msg, const char *tempfile, struct Context *ctx, struct EmailList *el);
 void            mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv);
 struct Address *mutt_default_from(void);
 void            mutt_encode_descriptions(struct Body *b, bool recurse);