]> granicus.if.org Git - mutt/commitdiff
Improve prompt when switching between PGP and S/MIME. (closes #3777)
authorKevin McCarthy <kevin@8t8.us>
Thu, 1 Oct 2015 07:38:47 +0000 (15:38 +0800)
committerKevin McCarthy <kevin@8t8.us>
Thu, 1 Oct 2015 07:38:47 +0000 (15:38 +0800)
Only prompt when encrypt or sign is enabled.

Also, improve oppenc to run and refresh the status when switching.

compose.c

index a89f6d169d750b6f833cd87cc7c3f5525d3d4782..5fd1384db9b6a10173e137a6e654824d4b0c2fb2 100644 (file)
--- 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);