From 0f8d71c0075a0fc0022505efa4e43f537da5a3ec Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Thu, 1 Oct 2015 15:38:47 +0800 Subject: [PATCH] Improve prompt when switching between PGP and S/MIME. (closes #3777) Only prompt when encrypt or sign is enabled. Also, improve oppenc to run and refresh the status when switching. --- compose.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/compose.c b/compose.c index a89f6d16..5fd1384d 100644 --- a/compose.c +++ b/compose.c @@ -1236,14 +1236,20 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME)) { - if (mutt_yesorno (_("S/MIME already selected. Clear & continue ? "), - M_YES) != M_YES) - { - mutt_clear_error (); - break; - } + if (msg->security & (ENCRYPT | SIGN)) + { + if (mutt_yesorno (_("S/MIME already selected. Clear & continue ? "), + M_YES) != M_YES) + { + mutt_clear_error (); + break; + } + msg->security &= ~(ENCRYPT | SIGN); + } msg->security &= ~APPLICATION_SMIME; msg->security |= APPLICATION_PGP; + crypt_opportunistic_encrypt (msg); + redraw_crypt_lines (msg); } msg->security = crypt_pgp_send_menu (msg, &menu->redraw); redraw_crypt_lines (msg); @@ -1263,14 +1269,20 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP)) { - if (mutt_yesorno (_("PGP already selected. Clear & continue ? "), - M_YES) != M_YES) - { - mutt_clear_error (); - break; - } + if (msg->security & (ENCRYPT | SIGN)) + { + if (mutt_yesorno (_("PGP already selected. Clear & continue ? "), + M_YES) != M_YES) + { + mutt_clear_error (); + break; + } + msg->security &= ~(ENCRYPT | SIGN); + } msg->security &= ~APPLICATION_PGP; msg->security |= APPLICATION_SMIME; + crypt_opportunistic_encrypt (msg); + redraw_crypt_lines (msg); } msg->security = crypt_smime_send_menu(msg, &menu->redraw); redraw_crypt_lines (msg); -- 2.40.0