Andreas Krennmair:
[apps/madmutt.git] / compose.c
index 6711dd9..ddf10cc 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ * Copyright (C) 2004 g10 Code GmbH
  * 
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  */ 
 
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "mutt.h"
 #include "mutt_curses.h"
 #include "mutt_idna.h"
@@ -60,6 +65,9 @@ enum
   HDR_REPLYTO,
   HDR_FCC,
 
+#ifdef MIXMASTER  
+  HDR_MIX,
+#endif
 
   HDR_CRYPT,
   HDR_CRYPTINFO,
@@ -70,12 +78,16 @@ enum
   HDR_XCOMMENTTO,
 #endif
 
+#ifndef USE_NNTP
   HDR_ATTACH  = (HDR_FCC + 5) /* where to start printing the attachments */
+#else
+  HDR_ATTACH  = (HDR_FCC + 7) 
+#endif
 };
 
 #define HDR_XOFFSET 14
 #define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
-#define W (COLS - HDR_XOFFSET)
+#define W (COLS - HDR_XOFFSET - SidebarWidth)
 
 static char *Prompts[] =
 {
@@ -141,16 +153,16 @@ static void redraw_crypt_lines (HEADER *msg)
   if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
   {     
     if (!msg->security)
-      mvaddstr (HDR_CRYPT, 0,     "    Security: ");
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "    Security: ");
     else if (msg->security & APPLICATION_SMIME)
-      mvaddstr (HDR_CRYPT, 0,     "      S/MIME: ");
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "      S/MIME: ");
     else if (msg->security & APPLICATION_PGP)
-      mvaddstr (HDR_CRYPT, 0,     "         PGP: ");
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "         PGP: ");
   }
   else if ((WithCrypto & APPLICATION_SMIME))
-    mvaddstr (HDR_CRYPT, 0,     "      S/MIME: ");
+    mvaddstr (HDR_CRYPT, SidebarWidth,     "      S/MIME: ");
   else if ((WithCrypto & APPLICATION_PGP))
-    mvaddstr (HDR_CRYPT, 0,     "         PGP: ");
+    mvaddstr (HDR_CRYPT, SidebarWidth,     "         PGP: ");
   else
     return;
 
@@ -162,176 +174,41 @@ static void redraw_crypt_lines (HEADER *msg)
     addstr (_("Sign"));
   else
     addstr (_("Clear"));
+
+  if ((WithCrypto & APPLICATION_PGP))
+    if ((msg->security & APPLICATION_PGP) 
+       && (msg->security & (ENCRYPT | SIGN)))
+    {
+      if ((msg->security & INLINE))
+       addstr (_(" (inline)"));
+      else
+       addstr (_(" (PGP/MIME)"));
+    }
   clrtoeol ();
 
-  move (HDR_CRYPTINFO, 0);
+  move (HDR_CRYPTINFO, SidebarWidth);
   clrtoeol ();
   if ((WithCrypto & APPLICATION_PGP)
       && msg->security & APPLICATION_PGP  && msg->security & SIGN)
-    printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
+    printw ("%s%s", _("     sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
 
   if ((WithCrypto & APPLICATION_SMIME)
-      && msg->security & APPLICATION_SMIME  && msg->security & SIGN) {
-      printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
+     && msg->security & APPLICATION_SMIME  && msg->security & SIGN) {
+      printw ("%s%s", _("     sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
   }
 
   if ((WithCrypto & APPLICATION_SMIME)
-       && msg->security & APPLICATION_SMIME  && (msg->security & ENCRYPT)) {
-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
+       && (msg->security & APPLICATION_SMIME)
+       && (msg->security & ENCRYPT)
+       && SmimeCryptAlg
+       && *SmimeCryptAlg) {
+      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
                NONULL(SmimeCryptAlg));
       off = 20;
   }
 }
 
 
-
-static int pgp_send_menu (HEADER *msg, int *redraw)
-{
-  pgp_key_t p;
-  char input_signas[SHORT_STRING];
-
-  if (!(WithCrypto & APPLICATION_PGP))
-    return msg->security;
-
-  switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "),
-                            _("esabf")))
-  {
-  case 1: /* (e)ncrypt */
-    msg->security |= ENCRYPT;
-    break;
-
-  case 2: /* (s)ign */
-    msg->security |= SIGN;
-    break;
-
-  case 3: /* sign (a)s */
-    unset_option(OPTPGPCHECKTRUST);
-
-    if ((p = crypt_pgp_ask_for_key (_("Sign as: "), NULL,
-                                    KEYFLAG_CANSIGN, PGP_PUBRING)))
-    {
-      snprintf (input_signas, sizeof (input_signas), "0x%s",
-                crypt_pgp_keyid (p));
-      mutt_str_replace (&PgpSignAs, input_signas);
-      crypt_pgp_free_key (&p);
-      
-      msg->security |= SIGN;
-       
-      crypt_pgp_void_passphrase ();  /* probably need a different passphrase */
-    }
-    else
-    {
-      msg->security &= ~SIGN;
-    }
-
-    *redraw = REDRAW_FULL;
-    break;
-
-  case 4: /* (b)oth */
-    msg->security = ENCRYPT | SIGN;
-    break;
-
-  case 5: /* (f)orget it */
-    msg->security = 0;
-    break;
-  }
-
-  if (msg->security && msg->security != APPLICATION_PGP)
-    msg->security |= APPLICATION_PGP;
-  else
-    msg->security = 0;
-
-  if(*redraw)
-      redraw_crypt_lines (msg);
-  return (msg->security);
-}
-
-
-
-static int smime_send_menu (HEADER *msg, int *redraw)
-{
-  char *p;
-
-  if (!(WithCrypto & APPLICATION_SMIME))
-    return msg->security;
-
-  switch (mutt_multi_choice (_("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (f)orget it? "),
-                            _("eswabf")))
-  {
-  case 1: /* (e)ncrypt */
-    msg->security |= ENCRYPT;
-    break;
-
-  case 3: /* encrypt (w)ith */
-    msg->security |= ENCRYPT;
-    switch (mutt_multi_choice (_("1: DES, 2: Triple-DES, 3: RC2-40,"
-                                " 4: RC2-64, 5: RC2-128, or (f)orget it? "),
-                              _("12345f"))) {
-    case 1:
-       mutt_str_replace (&SmimeCryptAlg, "des");
-       break;
-    case 2:
-       mutt_str_replace (&SmimeCryptAlg, "des3");
-       break;
-    case 3:
-       mutt_str_replace (&SmimeCryptAlg, "rc2-40");
-       break;
-    case 4:
-       mutt_str_replace (&SmimeCryptAlg, "rc2-64");
-       break;
-    case 5:
-       mutt_str_replace (&SmimeCryptAlg, "rc2-128");
-       break;
-    case 6: /* forget it */
-       break;
-    }
-    break;
-
-  case 2: /* (s)ign */
-      
-    if(!SmimeDefaultKey)
-       mutt_message("Can\'t sign: No key specified. use sign(as).");
-    else
-       msg->security |= SIGN;
-    break;
-
-  case 4: /* sign (a)s */
-
-    if ((p = crypt_smime_ask_for_key (_("Sign as: "), NULL, 0))) {
-      p[mutt_strlen (p)-1] = '\0';
-      mutt_str_replace (&SmimeDefaultKey, p);
-       
-      msg->security |= SIGN;
-
-      /* probably need a different passphrase */
-      crypt_smime_void_passphrase ();
-    }
-    else
-      msg->security &= ~SIGN;
-
-    *redraw = REDRAW_FULL;
-    break;
-
-  case 5: /* (b)oth */
-    msg->security = ENCRYPT | SIGN;
-    break;
-
-  case 6: /* (f)orget it */
-    msg->security = 0;
-    break;
-  }
-
-  if (msg->security && msg->security != APPLICATION_SMIME)
-    msg->security |= APPLICATION_SMIME;
-  else
-    msg->security = 0;
-
-  if(*redraw)
-      redraw_crypt_lines (msg);
-  return (msg->security);
-}
-
-
 #ifdef MIXMASTER
 
 static void redraw_mix_line (LIST *chain)
@@ -339,7 +216,7 @@ static void redraw_mix_line (LIST *chain)
   int c;
   char *t;
 
-  mvaddstr (HDR_MIX, 0,     "     Mix: ");
+  mvaddstr (HDR_MIX, SidebarWidth,     "         Mix: ");
 
   if (!chain)
   {
@@ -354,7 +231,7 @@ static void redraw_mix_line (LIST *chain)
     if (t && t[0] == '0' && t[1] == '\0')
       t = "<random>";
     
-    if (c + mutt_strlen (t) + 2 >= COLS)
+    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
       break;
 
     addstr (NONULL(t));
@@ -406,7 +283,7 @@ static void draw_envelope_addr (int line, ADDRESS *addr)
 
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), addr, 1);
-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
+  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
   mutt_paddstr (W, buf);
 }
 
@@ -424,9 +301,9 @@ static void draw_envelope (HEADER *msg, char *fcc)
   }
   else
   {
-    mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
+    mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
     mutt_paddstr (W, NONULL (msg->env->newsgroups));
-    mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
+    mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
     mutt_paddstr (W, NONULL (msg->env->followup_to));
     if (option (OPTXCOMMENTTO))
     {
@@ -435,10 +312,10 @@ static void draw_envelope (HEADER *msg, char *fcc)
     }
   }
 #endif
-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
+  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
   mutt_paddstr (W, NONULL (msg->env->subject));
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
+  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
   mutt_paddstr (W, fcc);
 
   if (WithCrypto)
@@ -449,7 +326,7 @@ static void draw_envelope (HEADER *msg, char *fcc)
 #endif
 
   SETCOLOR (MT_COLOR_STATUS);
-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
+  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
   BKGDSET (MT_COLOR_STATUS);
   clrtoeol ();
 
@@ -487,7 +364,7 @@ static int edit_address_list (int line, ADDRESS **addr)
   /* redraw the expanded list so the user can see the result */
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), *addr, 1);
-  move (line, HDR_XOFFSET);
+  move (line, HDR_XOFFSET+SidebarWidth);
   mutt_paddstr (W, buf);
   
   return 0;
@@ -586,7 +463,7 @@ static unsigned long cum_attachs_size (MUTTMENU *menu)
 }
 
 /* prototype for use below */
-void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu, 
+static void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu, 
       const char *p);
 
 /*
@@ -631,7 +508,7 @@ compose_format_str (char *buf, size_t buflen, char op, const char *src,
       break;
 
     case 'v':
-      snprintf (fmt, sizeof (fmt), "Mutt %%s");
+      snprintf (fmt, sizeof (fmt), "Mutt-ng %%s");
       snprintf (buf, buflen, fmt, MUTT_VERSION);
       break;
 
@@ -652,7 +529,7 @@ compose_format_str (char *buf, size_t buflen, char op, const char *src,
   return (src);
 }
 
-void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu, 
+static void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu, 
       const char *p)
 {
   mutt_FormatString (buf, buflen, p, compose_format_str, 
@@ -711,6 +588,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
 #endif
   menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
   
+  if (option(OPTMBOXPANE))
+    mutt_buffy_check(1);
   while (loop)
   {
 #ifdef USE_NNTP
@@ -725,24 +604,37 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
        break;
       case OP_COMPOSE_EDIT_FROM:
        menu->redraw = edit_address_list (HDR_FROM, &msg->env->from);
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
        break;
       case OP_COMPOSE_EDIT_TO:
 #ifdef USE_NNTP
-       if (!news)
+       if (!news) {
 #endif
          menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
+          mutt_message_hook (NULL, msg, M_SEND2HOOK);
+#ifdef USE_NNTP
+       }
+#endif
        break;
       case OP_COMPOSE_EDIT_BCC:
 #ifdef USE_NNTP
-       if (!news)
+       if (!news) {
 #endif
          menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
+          mutt_message_hook (NULL, msg, M_SEND2HOOK);
+#ifdef USE_NNTP
+       }
+#endif
        break;
       case OP_COMPOSE_EDIT_CC:
 #ifdef USE_NNTP
-       if (!news)
+       if (!news) {
 #endif
          menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
+          mutt_message_hook (NULL, msg, M_SEND2HOOK);  
+#ifdef USE_NNTP
+       }
+#endif
        break;
 #ifdef USE_NNTP
       case OP_COMPOSE_EDIT_NEWSGROUPS:
@@ -810,14 +702,16 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
        if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
        {
          mutt_str_replace (&msg->env->subject, buf);
-         move (HDR_SUBJECT, HDR_XOFFSET);
+         move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
          clrtoeol ();
          if (msg->env->subject)
            mutt_paddstr (W, msg->env->subject);
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
       case OP_COMPOSE_EDIT_REPLY_TO:
        menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to);
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
        break;
       case OP_COMPOSE_EDIT_FCC:
        strfcpy (buf, fcc, sizeof (buf));
@@ -825,24 +719,27 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
        {
          strfcpy (fcc, buf, _POSIX_PATH_MAX);
          mutt_pretty_mailbox (fcc);
-         move (HDR_FCC, HDR_XOFFSET);
+         move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
          mutt_paddstr (W, fcc);
          fccSet = 1;
        }
        MAYBE_REDRAW (menu->redraw);
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
       case OP_COMPOSE_EDIT_MESSAGE:
        if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS))
        {
          mutt_edit_file (Editor, msg->content->filename);
          mutt_update_encoding (msg->content);
          menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
+         mutt_message_hook (NULL, msg, M_SEND2HOOK);
          break;
        }
        /* fall through */
       case OP_COMPOSE_EDIT_HEADERS:
-       if (op == OP_COMPOSE_EDIT_HEADERS ||
-           (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS)))
+       if (mutt_strcmp ("builtin", Editor) != 0 &&
+           (op == OP_COMPOSE_EDIT_HEADERS ||
+           (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS))))
        {
          char *tag = NULL, *err = NULL;
          mutt_env_to_local (msg->env);
@@ -875,7 +772,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          menu->max = idxlen;
        }
 
-       menu->redraw = REDRAW_FULL;
+        menu->redraw = REDRAW_FULL;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
        break;
 
 
@@ -906,7 +804,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          unset_option(OPTNEEDREDRAW);
        }
        
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
 
       case OP_COMPOSE_ATTACH_FILE:
@@ -952,7 +851,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
 
          menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
       case OP_COMPOSE_ATTACH_MESSAGE:
 #ifdef USE_NNTP
@@ -1084,7 +984,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          Sort = oldSort;
          SortAux = oldSortAux;
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
       case OP_DELETE:
        CHECK_COUNT;
@@ -1103,7 +1004,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          msg->content = idx[0]->content;
 
         menu->redraw |= REDRAW_STATUS;
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
 #define CURRENT idx[menu->current]->content
       
@@ -1121,6 +1023,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
         else
          mutt_message (_("The current attachment will be converted."));
        menu->redraw = REDRAW_CURRENT;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
         break;
       }
 #undef CURRENT
@@ -1137,7 +1040,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          mutt_str_replace (&idx[menu->current]->content->description, buf);
          menu->redraw = REDRAW_CURRENT;
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
       case OP_COMPOSE_UPDATE_ENCODING:
         CHECK_COUNT;
@@ -1156,6 +1060,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
           mutt_update_encoding(idx[menu->current]->content);
          menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
        }
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
         break;
       
       case OP_COMPOSE_TOGGLE_DISPOSITION:
@@ -1174,7 +1079,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
 
          menu->redraw = REDRAW_CURRENT;
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
       case OP_COMPOSE_EDIT_ENCODING:
        CHECK_COUNT;
@@ -1192,9 +1098,14 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          else
            mutt_error _("Invalid encoding.");
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
       case OP_COMPOSE_SEND_MESSAGE:
+
+        /* Note: We don't invoke send2-hook here, since we want to leave
+        * users an opportunity to change settings from the ":" prompt.
+        */
       
         if(check_attachments(idx, idxlen) != 0)
         {
@@ -1226,6 +1137,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
        mutt_edit_file (NONULL(Editor), idx[menu->current]->content->filename);
        mutt_update_encoding (idx[menu->current]->content);
        menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
        break;
 
       case OP_COMPOSE_TOGGLE_UNLINK:
@@ -1241,6 +1153,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          menu->current++;
 # endif
        menu->redraw = REDRAW_INDEX;
+        /* No send2hook since this doesn't change the message. */
        break;
 
       case OP_COMPOSE_GET_ATTACHMENT:
@@ -1258,6 +1171,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
         else if (mutt_get_tmp_attachment(idx[menu->current]->content) == 0)
          menu->redraw = REDRAW_CURRENT;
 
+        /* No send2hook since this doesn't change the message. */
         break;
       
       case OP_COMPOSE_RENAME_FILE:
@@ -1284,7 +1198,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
            mutt_stamp_attachment(idx[menu->current]->content);
          
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
       case OP_COMPOSE_NEW_MIME:
        {
@@ -1351,7 +1266,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
            menu->redraw = REDRAW_FULL;
          }
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);    
+        break;
 
       case OP_COMPOSE_EDIT_MIME:
        CHECK_COUNT;
@@ -1360,24 +1276,28 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          mutt_update_encoding (idx[menu->current]->content);
          menu->redraw = REDRAW_FULL;
        }
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
       case OP_VIEW_ATTACH:
       case OP_DISPLAY_HEADERS:
        CHECK_COUNT;
        mutt_attach_display_loop (menu, op, NULL, NULL, NULL, &idx, &idxlen, NULL, 0);
        menu->redraw = REDRAW_FULL;
+        /* no send2hook, since this doesn't modify the message */
        break;
 
       case OP_SAVE:
        CHECK_COUNT;
        mutt_save_attachment_list (NULL, menu->tagprefix, menu->tagprefix ?  msg->content : idx[menu->current]->content, NULL, menu);
        MAYBE_REDRAW (menu->redraw);
+        /* no send2hook, since this doesn't modify the message */
        break;
 
       case OP_PRINT:
        CHECK_COUNT;
        mutt_print_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content);
+        /* no send2hook, since this doesn't modify the message */
        break;
 
       case OP_PIPE:
@@ -1385,8 +1305,9 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
         CHECK_COUNT;
        mutt_pipe_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content, op == OP_FILTER);
        if (op == OP_FILTER) /* cte might have changed */
-         menu->redraw = menu->tagprefix ? REDRAW_FULL : REDRAW_CURRENT; 
+         menu->redraw = menu->tagprefix ? REDRAW_FULL : REDRAW_CURRENT;
         menu->redraw |= REDRAW_STATUS;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
        break;
 
       case OP_EXIT:
@@ -1479,9 +1400,10 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          }
          msg->security = 0;
        }
-       msg->security = pgp_send_menu (msg, &menu->redraw);
+       msg->security = crypt_pgp_send_menu (msg, &menu->redraw);
        redraw_crypt_lines (msg);
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
 
       case OP_FORGET_PASSPHRASE:
@@ -1504,15 +1426,17 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          }
          msg->security = 0;
        }
-       msg->security = smime_send_menu(msg, &menu->redraw);
+       msg->security = crypt_smime_send_menu(msg, &menu->redraw);
        redraw_crypt_lines (msg);
-       break;
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        break;
 
 
 #ifdef MIXMASTER
       case OP_COMPOSE_MIX:
       
        mix_make_chain (&msg->chain, &menu->redraw);
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
         break;
 #endif