simplify pop_query further.
[apps/madmutt.git] / commands.c
index a7cc074..8e24718 100644 (file)
@@ -28,7 +28,7 @@
 #include "sort.h"
 #include "copy.h"
 #include "pager.h"
-#include <lib-crypt/crypt.h>
+#include "crypt.h"
 #include "mutt_idna.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -42,7 +42,6 @@ static char LastSaveFolder[_POSIX_PATH_MAX] = "";
 int mutt_display_message (HEADER * cur)
 {
   char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
-  int rc = 0, builtin = 0;
   int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV;
   FILE *fpout = NULL;
   FILE *fpfilterout = NULL;
@@ -56,7 +55,7 @@ int mutt_display_message (HEADER * cur)
   mutt_parse_mime_message (Context, cur);
   mutt_message_hook (Context, cur, M_MESSAGEHOOK);
 
-  fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+  fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL);
   if (!fpout) {
     mutt_error _("Could not create temporary file!");
     return 0;
@@ -76,14 +75,6 @@ int mutt_display_message (HEADER * cur)
     }
   }
 
-  if (!Pager || m_strcmp(Pager, "builtin") == 0)
-    builtin = 1;
-  else {
-    mutt_make_string (buf, sizeof (buf), NONULL (PagerFmt), Context, cur);
-    fputs (buf, fpout);
-    fputs ("\n\n", fpout);
-  }
-
   msg = mx_open_message (Context, cur->msgno);
   if (msg == NULL) res = -1;
 
@@ -91,16 +82,11 @@ int mutt_display_message (HEADER * cur)
     /* see if crytpo is needed for this message.  if so, we should exit curses */
     if (cur->security) {
       if (cur->security & ENCRYPT) {
-        if (cur->security & APPLICATION_SMIME)
-          crypt_smime_getkeys (cur->env);
-        if (!crypt_valid_passphrase (cur->security))
-          return 0;
-
         cmflags |= M_CM_VERIFY;
       }
       else if (cur->security & SIGN) {
         /* find out whether or not the verify signature */
-        if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) ==
+        if (query_quadoption2(mod_crypt.verify_sig, _("Verify PGP signature?")) ==
             M_YES) {
           cmflags |= M_CM_VERIFY;
         }
@@ -108,15 +94,7 @@ int mutt_display_message (HEADER * cur)
     }
 
     if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT) {
-      if (cur->security & APPLICATION_PGP) {
-        if (cur->env->from)
-          crypt_pgp_invoke_getkeys (cur->env->from);
-
-        crypt_invoke_message (APPLICATION_PGP);
-      }
-
-      if (cur->security & APPLICATION_SMIME)
-        crypt_invoke_message (APPLICATION_SMIME);
+      crypt_invoke_message(cur->security);
     }
 
     res = _mutt_copy_message (fpout, msg->fp, cur, cur->content, cmflags,
@@ -151,59 +129,38 @@ int mutt_display_message (HEADER * cur)
      are color patterns for both ~g and ~V */
   cur->pair = 0;
 
-  if (builtin) {
-    pager_t info;
-
-    if ((cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
-      if (cur->security & GOODSIGN) {
-        if (!crypt_smime_verify_sender (cur))
-          mutt_message (_("S/MIME signature successfully verified."));
-        else
-          mutt_error (_("S/MIME certificate owner does not match sender."));
-      }
-      else if (cur->security & PARTSIGN)
-        mutt_message (_
-                      ("Warning: Part of this message has not been signed."));
-      else if (cur->security & SIGN || cur->security & BADSIGN)
-        mutt_error (_("S/MIME signature could NOT be verified."));
+  if ((cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
+    if (cur->security & GOODSIGN) {
+      if (!crypt_smime_verify_sender (cur))
+        mutt_message (_("S/MIME signature successfully verified."));
+      else
+        mutt_error (_("S/MIME certificate owner does not match sender."));
     }
+    else if (cur->security & PARTSIGN)
+      mutt_message (_
+                    ("Warning: Part of this message has not been signed."));
+    else if (cur->security & SIGN || cur->security & BADSIGN)
+      mutt_error (_("S/MIME signature could NOT be verified."));
+  }
 
-    if ((cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) {
-      if (cur->security & GOODSIGN)
-        mutt_message (_("PGP signature successfully verified."));
-      else if (cur->security & PARTSIGN)
-        mutt_message (_
-                      ("Warning: Part of this message has not been signed."));
-      else if (cur->security & SIGN)
-        mutt_message (_("PGP signature could NOT be verified."));
-    }
+  if ((cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) {
+    if (cur->security & GOODSIGN)
+      mutt_message (_("PGP signature successfully verified."));
+    else if (cur->security & PARTSIGN)
+      mutt_message (_
+                    ("Warning: Part of this message has not been signed."));
+    else if (cur->security & SIGN)
+      mutt_message (_("PGP signature could NOT be verified."));
+  }
+
+  {
+    pager_t info;
 
-    /* Invoke the builtin pager */
     p_clear(&info, 1);
     info.hdr = cur;
     info.ctx = Context;
-    rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
-  }
-  else {
-    int r;
-
-    mutt_endwin (NULL);
-    snprintf (buf, sizeof (buf), "%s %s", NONULL (Pager), tempfile);
-    if ((r = mutt_system (buf)) == -1)
-      mutt_error (_("Error running \"%s\"!"), buf);
-    unlink (tempfile);
-    keypad (stdscr, TRUE);
-    if (r != -1)
-      mutt_set_flag (Context, cur, M_READ, 1);
-    if (r != -1 && option (OPTPROMPTAFTER)) {
-      mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
-      rc = km_dokey (MENU_PAGER);
-    }
-    else
-      rc = 0;
+    return mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
   }
-
-  return rc;
 }
 
 void ci_bounce_message (HEADER * h, int *redraw)
@@ -301,8 +258,6 @@ static void pipe_msg (HEADER * h, FILE * fp, int decode, int print)
   pipe_set_flags (decode, print, &cmflags, &chflags);
 
   if (decode && h->security & ENCRYPT) {
-    if (!crypt_valid_passphrase (h->security))
-      return;
     endwin ();
   }
 
@@ -335,8 +290,6 @@ static int _mutt_pipe_message(HEADER * h, char *cmd, int decode, int print,
 
     if (decode) {
       mutt_parse_mime_message (Context, h);
-      if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
-        return 1;
     }
     mutt_endwin (NULL);
 
@@ -358,10 +311,6 @@ static int _mutt_pipe_message(HEADER * h, char *cmd, int decode, int print,
           mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
                              M_MESSAGEHOOK);
           mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
-          if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
-              !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
-                                       security))
-            return 1;
         }
     }
 
@@ -520,7 +469,7 @@ void mutt_shell_escape (void)
   buf[0] = 0;
   if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
     if (!buf[0])
-      m_strcpy(buf, sizeof(buf), mlua_reggets(LTK_SHELL));
+      m_strcpy(buf, sizeof(buf), MCore.shell);
     if (buf[0]) {
       CLEARLINE (LINES - 1);
       mutt_endwin (NULL);
@@ -713,10 +662,6 @@ int mutt_save_message (HEADER * h, int delete,
   if (mutt_save_confirm (buf, &st) != 0)
     return -1;
 
-  if (need_passphrase && (decode || decrypt)
-      && !crypt_valid_passphrase (app))
-    return -1;
-
   mutt_message (_("Copying to %s..."), buf);
 
   if (Context->magic == M_IMAP && !(decode || decrypt) && mx_get_magic (buf) == M_IMAP) {
@@ -754,7 +699,7 @@ int mutt_save_message (HEADER * h, int delete,
       }
     }
 
-    need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
+    need_buffy_cleanup = (ctx.magic == M_MBOX);
 
     mx_close_mailbox (&ctx, NULL);