From: Richard Russon Date: Thu, 10 Jan 2019 14:26:15 +0000 (+0000) Subject: mutt_check_traditional_pgp: factor out Context X-Git-Tag: 2019-10-25~373^2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=016e16b3292aafa24b8c1718c1c171a65fc73947;p=neomutt mutt_check_traditional_pgp: factor out Context --- diff --git a/commands.c b/commands.c index 53fd3c2c9..084f07fd6 100644 --- a/commands.c +++ b/commands.c @@ -1323,26 +1323,20 @@ static bool check_traditional_pgp(struct Email *e, int *redraw) /** * mutt_check_traditional_pgp - Check if a message has inline PGP content - * @param[in] e Header of message to check + * @param[in] el List of Emails to check * @param[out] redraw Set of #REDRAW_FULL if the screen may need redrawing * @retval true If message contains inline PGP content */ -bool mutt_check_traditional_pgp(struct Email *e, int *redraw) +bool mutt_check_traditional_pgp(struct EmailList *el, int *redraw) { bool rc = false; - if (e && !(e->security & PGP_TRADITIONAL_CHECKED)) - rc = check_traditional_pgp(e, redraw); - else + struct EmailNode *en = NULL; + STAILQ_FOREACH(en, el, entries) { - for (int i = 0; i < Context->mailbox->msg_count; i++) - { - if (message_is_tagged(Context, i) && - !(Context->mailbox->emails[i]->security & PGP_TRADITIONAL_CHECKED)) - { - rc = check_traditional_pgp(Context->mailbox->emails[i], redraw) || rc; - } - } + if (!(en->email->security & PGP_TRADITIONAL_CHECKED)) + rc = check_traditional_pgp(en->email, redraw) || rc; } + return rc; } diff --git a/commands.h b/commands.h index d6ecf2224..193b80644 100644 --- a/commands.h +++ b/commands.h @@ -28,6 +28,7 @@ struct Body; struct Email; +struct EmailList; struct Envelope; struct Mailbox; @@ -43,7 +44,7 @@ extern bool PromptAfter; void ci_bounce_message(struct Mailbox *m, struct EmailList *el); void mutt_check_stats(void); -bool mutt_check_traditional_pgp(struct Email *e, int *redraw); +bool mutt_check_traditional_pgp(struct EmailList *el, int *redraw); void mutt_display_address(struct Envelope *env); int mutt_display_message(struct Email *cur); int mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp); diff --git a/index.c b/index.c index 4d82406d0..b6fea88dc 100644 --- a/index.c +++ b/index.c @@ -2299,7 +2299,10 @@ int mutt_index_menu(void) if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED))) { - mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw); + 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); } int hint = Context->mailbox->emails[Context->mailbox->v2r[menu->current]]->index; @@ -3077,7 +3080,10 @@ int mutt_index_menu(void) if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED))) { - mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw); + 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); } struct EmailList el = STAILQ_HEAD_INITIALIZER(el); el_add_tagged(&el, Context, CUR_EMAIL, tag); @@ -3095,7 +3101,10 @@ int mutt_index_menu(void) CHECK_ATTACH; if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED))) { - mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw); + 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); menu->redraw = REDRAW_FULL; @@ -3112,7 +3121,10 @@ int mutt_index_menu(void) CHECK_ATTACH; if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED))) { - mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw); + 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); @@ -3149,7 +3161,10 @@ int mutt_index_menu(void) CHECK_VISIBLE; if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED))) { - mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw); + 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); @@ -3186,7 +3201,12 @@ int mutt_index_menu(void) CHECK_MSGCOUNT; CHECK_VISIBLE; if (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)) - mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw); + { + 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); + } if (menu->menu == MENU_PAGER) { @@ -3372,7 +3392,10 @@ int mutt_index_menu(void) CHECK_VISIBLE; if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED))) { - mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw); + 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); menu->redraw = REDRAW_FULL;