From: Richard Russon Date: Wed, 17 Jul 2019 13:33:19 +0000 (+0100) Subject: context: crypt_extract_keys_from_messages() X-Git-Tag: 2019-10-25~127 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2217f1de17808d9f9d480cd93fdac5c32a78500c;p=neomutt context: crypt_extract_keys_from_messages() Change crypt_extract_keys_from_messages() to use a Context parameter rather than the global. --- diff --git a/index.c b/index.c index 641627f00..30157b5c1 100644 --- a/index.c +++ b/index.c @@ -3253,7 +3253,7 @@ int mutt_index_menu(void) break; struct EmailList el = STAILQ_HEAD_INITIALIZER(el); el_add_tagged(&el, Context, CUR_EMAIL, tag); - crypt_extract_keys_from_messages(&el); + crypt_extract_keys_from_messages(Context->mailbox, &el); emaillist_clear(&el); menu->redraw = REDRAW_FULL; break; diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index 54fb77c74..89f7a4aa6 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -810,11 +810,12 @@ void crypt_convert_to_7bit(struct Body *a) /** * crypt_extract_keys_from_messages - Extract keys from a message + * @param m Mailbox * @param el List of Emails to process * * The extracted keys will be added to the user's keyring. */ -void crypt_extract_keys_from_messages(struct EmailList *el) +void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailList *el) { if (!WithCrypto) return; @@ -837,7 +838,7 @@ void crypt_extract_keys_from_messages(struct EmailList *el) { struct Email *e = en->email; - mutt_parse_mime_message(Context->mailbox, e); + mutt_parse_mime_message(m, e); if (e->security & SEC_ENCRYPT && !crypt_valid_passphrase(e->security)) { mutt_file_fclose(&fp_out); @@ -846,8 +847,7 @@ void crypt_extract_keys_from_messages(struct EmailList *el) if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP)) { - mutt_copy_message(fp_out, Context->mailbox, e, - MUTT_CM_DECODE | MUTT_CM_CHARCONV, CH_NO_FLAGS); + mutt_copy_message(fp_out, m, e, MUTT_CM_DECODE | MUTT_CM_CHARCONV, CH_NO_FLAGS); fflush(fp_out); mutt_endwin(); @@ -859,12 +859,11 @@ void crypt_extract_keys_from_messages(struct EmailList *el) { if (e->security & SEC_ENCRYPT) { - mutt_copy_message(fp_out, Context->mailbox, e, - MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME, + mutt_copy_message(fp_out, m, e, MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME, CH_NO_FLAGS); } else - mutt_copy_message(fp_out, Context->mailbox, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS); + mutt_copy_message(fp_out, m, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS); fflush(fp_out); char *mbox = NULL; diff --git a/ncrypt/ncrypt.h b/ncrypt/ncrypt.h index 591e745bd..354efcd37 100644 --- a/ncrypt/ncrypt.h +++ b/ncrypt/ncrypt.h @@ -59,6 +59,7 @@ struct Body; struct Envelope; struct Email; struct EmailList; +struct Mailbox; struct State; /* These Config Variables are only used in ncrypt/crypt.c */ @@ -182,7 +183,7 @@ typedef uint16_t KeyFlags; ///< Flags describing PGP/SMIME keys #define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN | KEYFLAG_CANENCRYPT | KEYFLAG_PREFER_ENCRYPTION | KEYFLAG_PREFER_SIGNING) /* crypt.c */ -void crypt_extract_keys_from_messages(struct EmailList *el); +void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailList *el); void crypt_forget_passphrase(void); int crypt_get_keys(struct Email *e, char **keylist, bool oppenc_mode); void crypt_opportunistic_encrypt(struct Email *e); diff --git a/pager.c b/pager.c index aeca2501b..33e3e445e 100644 --- a/pager.c +++ b/pager.c @@ -3509,7 +3509,7 @@ int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct P CHECK_MODE(IsEmail(extra)); struct EmailList el = STAILQ_HEAD_INITIALIZER(el); el_add_email(&el, extra->email); - crypt_extract_keys_from_messages(&el); + crypt_extract_keys_from_messages(Context->mailbox, &el); emaillist_clear(&el); pager_menu->redraw = REDRAW_FULL; break;