various rewrites and cleanups.
[apps/madmutt.git] / commands.c
index 3590596..cf56023 100644 (file)
@@ -16,6 +16,7 @@
 #include <lib-sys/exit.h>
 #include <lib-sys/unix.h>
 
+#include <lib-lua/lib-lua.h>
 #include <lib-ui/curses.h>
 #include <lib-ui/enter.h>
 #include <lib-ui/menu.h>
@@ -27,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>
@@ -55,7 +56,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;
@@ -90,11 +91,6 @@ 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) {
@@ -107,15 +103,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,
@@ -300,8 +288,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 ();
   }
 
@@ -334,8 +320,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);
 
@@ -357,10 +341,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;
         }
     }
 
@@ -518,8 +498,8 @@ void mutt_shell_escape (void)
 
   buf[0] = 0;
   if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
-    if (!buf[0] && Shell)
-      m_strcpy(buf, sizeof(buf), Shell);
+    if (!buf[0])
+      m_strcpy(buf, sizeof(buf), MCore.shell);
     if (buf[0]) {
       CLEARLINE (LINES - 1);
       mutt_endwin (NULL);
@@ -712,10 +692,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) {
@@ -777,7 +753,7 @@ int mutt_save_message (HEADER * h, int delete,
 
 void mutt_version (void)
 {
-  mutt_message (mutt_make_version (1));
+  mutt_message (mutt_make_version());
 }
 
 void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)