{
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,
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;
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,
struct HdrFormatInfo
{
struct Context *ctx;
- struct Mailbox *m;
+ struct Mailbox *mailbox;
struct Email *email;
const char *pager_progress;
};
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.
}
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:
{
}
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:
}
case OP_CHECK_TRADITIONAL:
+ {
if (!(WithCrypto & APPLICATION_PGP))
break;
CHECK_MSGCOUNT;
continue;
}
break;
+ }
case OP_PIPE:
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;
#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:
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)
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;
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;
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;
}
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));
}
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;
}
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;
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;
break;
case OP_MAIL_KEY:
+ {
if (!(WithCrypto & APPLICATION_PGP))
{
ch = -1;
}
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:
{
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:
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);
}
/**
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);
}
/**
* @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++)
{
}
}
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
* 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;
}
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;
}
}
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;
* @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)
{
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;
}
}
else
- include_reply(ctx->mailbox, cur, tempfp);
+ include_reply(ctx->mailbox, en->email, tempfp);
}
}
else if (flags & SEND_FORWARD)
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
}
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;
}
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++)
}
}
- 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;
}
/**
* @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 */
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;
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;
}
/* 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;
}
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));
}
}
}
struct Body;
struct Context;
struct Email;
+struct EmailList;
struct Envelope;
struct Mailbox;
#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);