2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 2000 Thomas Roessler <roessler@does-not-exist.org>
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
16 #include "mutt_curses.h"
17 #include "mutt_menu.h"
23 #include "mutt_crypt.h"
24 #include "mutt_idna.h"
26 #include <sys/types.h>
41 #include "lib/debug.h"
49 #include <sys/types.h>
52 extern char *ReleaseDate;
54 /* The folder the user last saved to. Used by ci_save_message() */
55 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
57 int mutt_display_message (HEADER * cur)
59 char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
60 int rc = 0, builtin = 0;
61 int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV;
63 FILE *fpfilterout = NULL;
68 snprintf (buf, sizeof (buf), "%s/%s", TYPE (cur->content),
69 cur->content->subtype);
71 mutt_parse_mime_message (Context, cur);
72 mutt_message_hook (Context, cur, M_MESSAGEHOOK);
74 mutt_mktemp (tempfile);
75 if ((fpout = safe_fopen (tempfile, "w")) == NULL) {
76 mutt_error _("Could not create temporary file!");
81 if (DisplayFilter && *DisplayFilter) {
84 /* mutt_endwin (NULL); */
85 filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL,
86 -1, fileno (fpfilterout), -1);
88 mutt_error (_("Cannot create display filter"));
89 safe_fclose (&fpfilterout);
95 if (!Pager || safe_strcmp (Pager, "builtin") == 0)
98 mutt_make_string (buf, sizeof (buf), NONULL (PagerFmt), Context, cur);
100 fputs ("\n\n", fpout);
103 msg = mx_open_message (Context, cur->msgno);
104 if (msg == NULL) res = -1;
107 /* see if crytpo is needed for this message. if so, we should exit curses */
108 if (WithCrypto && cur->security) {
109 if (cur->security & ENCRYPT) {
110 if (cur->security & APPLICATION_SMIME)
111 crypt_smime_getkeys (cur->env);
112 if (!crypt_valid_passphrase (cur->security))
115 cmflags |= M_CM_VERIFY;
117 else if (cur->security & SIGN) {
118 /* find out whether or not the verify signature */
119 if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) ==
121 cmflags |= M_CM_VERIFY;
126 if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT) {
127 if (cur->security & APPLICATION_PGP) {
129 crypt_pgp_invoke_getkeys (cur->env->from);
131 crypt_invoke_message (APPLICATION_PGP);
134 if (cur->security & APPLICATION_SMIME)
135 crypt_invoke_message (APPLICATION_SMIME);
138 res = _mutt_copy_message (fpout, msg->fp, cur, cur->content, cmflags,
139 (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
140 CH_DECODE | CH_FROM);
141 if (res == 0 && (ferror(fpout) || feof(fpout))) {
142 debug_print (1, ("_mutt_copy_message failed to detect EOF!\n"));
146 mx_close_message (&msg);
149 if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1) {
150 mutt_error (_("Could not copy message"));
151 if (fpfilterout != NULL) {
152 mutt_wait_filter (filterpid);
153 safe_fclose (&fpfilterout);
155 mutt_unlink (tempfile);
159 if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
160 mutt_any_key_to_continue (NULL);
162 safe_fclose (&fpfilterout); /* XXX - check result? */
166 /* update crypto information for this message */
167 cur->security |= crypt_query (cur->content);
169 /* Remove color cache for this message, in case there
170 are color patterns for both ~g and ~V */
178 && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
179 if (cur->security & GOODSIGN) {
180 if (!crypt_smime_verify_sender (cur))
181 mutt_message (_("S/MIME signature successfully verified."));
183 mutt_error (_("S/MIME certificate owner does not match sender."));
185 else if (cur->security & PARTSIGN)
187 ("Warning: Part of this message has not been signed."));
188 else if (cur->security & SIGN || cur->security & BADSIGN)
189 mutt_error (_("S/MIME signature could NOT be verified."));
193 && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) {
194 if (cur->security & GOODSIGN)
195 mutt_message (_("PGP signature successfully verified."));
196 else if (cur->security & PARTSIGN)
198 ("Warning: Part of this message has not been signed."));
200 mutt_message (_("PGP signature could NOT be verified."));
203 /* Invoke the builtin pager */
204 memset (&info, 0, sizeof (pager_t));
207 rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
213 snprintf (buf, sizeof (buf), "%s %s", NONULL (Pager), tempfile);
214 if ((r = mutt_system (buf)) == -1)
215 mutt_error (_("Error running \"%s\"!"), buf);
217 keypad (stdscr, TRUE);
219 mutt_set_flag (Context, cur, M_READ, 1);
220 if (r != -1 && option (OPTPROMPTAFTER)) {
221 mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
222 rc = km_dokey (MENU_PAGER);
231 void ci_bounce_message (HEADER * h, int *redraw)
233 char prompt[SHORT_STRING];
234 char buf[HUGE_STRING] = { 0 };
240 strfcpy (prompt, _("Bounce message to: "), sizeof (prompt));
242 strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));
244 rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
246 if (option (OPTNEEDREDRAW)) {
247 unset_option (OPTNEEDREDRAW);
248 *redraw = REDRAW_FULL;
254 if (!(adr = rfc822_parse_adrlist (adr, buf))) {
255 mutt_error _("Error parsing address!");
260 adr = mutt_expand_aliases (adr);
262 if (mutt_addrlist_to_idna (adr, &err) < 0) {
263 mutt_error (_("Bad IDN: '%s'"), err);
265 rfc822_free_address (&adr);
270 rfc822_write_address (buf, sizeof (buf), adr, 1);
272 #define extra_space (15 + 7 + 2)
273 snprintf (prompt, sizeof (prompt),
274 (h ? _("Bounce message to %s") : _("Bounce messages to %s")),
277 if (mutt_strwidth (prompt) > COLS - extra_space) {
278 mutt_format_string (prompt, sizeof (prompt),
279 0, COLS - extra_space, 0, 0,
280 prompt, sizeof (prompt), 0);
281 safe_strcat (prompt, sizeof (prompt), "...?");
284 safe_strcat (prompt, sizeof (prompt), "?");
286 if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
287 rfc822_free_address (&adr);
288 CLEARLINE (LINES - 1);
289 mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
293 CLEARLINE (LINES - 1);
295 rc = mutt_bounce_message (NULL, h, adr);
296 rfc822_free_address (&adr);
297 /* If no error, or background, display message. */
298 if ((rc == 0) || (rc == S_BKG))
299 mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
302 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
305 *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
306 *chflags |= CH_DECODE | CH_REORDER;
308 if (option (OPTWEED)) {
310 *cmflags |= M_CM_WEED;
315 *cmflags |= M_CM_PRINTING;
319 static void pipe_msg (HEADER * h, FILE * fp, int decode, int print)
322 int chflags = CH_FROM;
324 pipe_set_flags (decode, print, &cmflags, &chflags);
326 if (WithCrypto && decode && h->security & ENCRYPT) {
327 if (!crypt_valid_passphrase (h->security))
333 mutt_parse_mime_message (Context, h);
335 mutt_copy_message (fp, Context, h, cmflags, chflags);
339 /* the following code is shared between printing and piping */
341 static int _mutt_pipe_message (HEADER * h, char *cmd,
342 int decode, int print, int split, char *sep)
349 /* mutt_endwin (NULL);
351 is this really needed here ?
352 it makes the screen flicker on pgp and s/mime messages,
353 before asking for a passphrase...
357 mutt_message_hook (Context, h, M_MESSAGEHOOK);
359 if (WithCrypto && decode) {
360 mutt_parse_mime_message (Context, h);
361 if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
366 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
367 mutt_perror (_("Can't create filter process"));
372 pipe_msg (h, fpout, decode, print);
374 rc = mutt_wait_filter (thepid);
376 else { /* handle tagged messages */
378 if (WithCrypto && decode) {
379 for (i = 0; i < Context->vcount; i++)
380 if (Context->hdrs[Context->v2r[i]]->tagged) {
381 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
383 mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
384 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
385 !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
392 for (i = 0; i < Context->vcount; i++) {
393 if (Context->hdrs[Context->v2r[i]]->tagged) {
394 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
397 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
398 mutt_perror (_("Can't create filter process"));
402 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
403 /* add the message separator */
406 safe_fclose (&fpout);
407 if (mutt_wait_filter (thepid) != 0)
414 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
415 mutt_perror (_("Can't create filter process"));
419 for (i = 0; i < Context->vcount; i++) {
420 if (Context->hdrs[Context->v2r[i]]->tagged) {
421 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
423 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
424 /* add the message separator */
429 safe_fclose (&fpout);
430 if (mutt_wait_filter (thepid) != 0)
435 if (rc || option (OPTWAITKEY))
436 mutt_any_key_to_continue (NULL);
440 void mutt_pipe_message (HEADER * h)
442 char buffer[LONG_STRING];
445 if (mutt_get_field (_("Pipe to command: "), buffer, sizeof (buffer), M_CMD)
449 mutt_expand_path (buffer, sizeof (buffer));
450 _mutt_pipe_message (h, buffer,
451 option (OPTPIPEDECODE),
452 0, option (OPTPIPESPLIT), PipeSep);
455 void mutt_print_message (HEADER * h)
458 if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd)) {
459 mutt_message (_("No printing command has been defined."));
463 if (query_quadoption (OPT_PRINT,
464 h ? _("Print message?") : _("Print tagged messages?"))
468 if (_mutt_pipe_message (h, PrintCmd,
469 option (OPTPRINTDECODE),
470 1, option (OPTPRINTSPLIT), "\f") == 0)
471 mutt_message (h ? _("Message printed") : _("Messages printed"));
473 mutt_message (h ? _("Message could not be printed") :
474 _("Messages could not be printed"));
478 int mutt_select_sort (int reverse)
480 int method = Sort; /* save the current method in case of abort */
482 switch (mutt_multi_choice (reverse ?
484 ("Rev-Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: ")
487 ("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
489 case -1: /* abort - don't resort */
501 Sort = SORT_RECEIVED;
512 case 6: /* (t)hread */
516 case 7: /* (u)nsort */
524 case 9: /* s(c)ore */
528 case 10: /* s(p)am */
533 Sort |= SORT_REVERSE;
535 return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
538 /* invoke a command in a subshell */
539 void mutt_shell_escape (void)
541 char buf[LONG_STRING];
544 if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
545 if (!buf[0] && Shell)
546 strfcpy (buf, Shell, sizeof (buf));
548 CLEARLINE (LINES - 1);
551 if (mutt_system (buf) != 0 || option (OPTWAITKEY))
552 mutt_any_key_to_continue (NULL);
557 /* enter a mutt command */
558 void mutt_enter_command (void)
561 char buffer[LONG_STRING], errbuf[SHORT_STRING];
565 if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0
569 err.dsize = sizeof (errbuf);
570 memset (&token, 0, sizeof (token));
571 r = mutt_parse_rc_line (buffer, &token, &err);
574 /* since errbuf could potentially contain printf() sequences in it,
575 we must call mutt_error() in this fashion so that vsprintf()
576 doesn't expect more arguments that we passed */
578 mutt_message ("%s", errbuf);
580 mutt_error ("%s", errbuf);
584 void mutt_display_address (ENVELOPE * env)
587 char buf[SHORT_STRING];
590 adr = mutt_get_address (env, &pfx);
596 * Note: We don't convert IDNA to local representation this time.
597 * That is intentional, so the user has an opportunity to copy &
598 * paste the on-the-wire form of the address to other, IDN-unable
603 rfc822_write_address (buf, sizeof (buf), adr, 0);
604 mutt_message ("%s: %s", pfx, buf);
607 static void set_copy_flags (HEADER * hdr, int decode, int decrypt,
608 int *cmflags, int *chflags)
611 *chflags = CH_UPDATE_LEN;
613 if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT)) {
614 if ((WithCrypto & APPLICATION_PGP)
615 && mutt_is_multipart_encrypted (hdr->content)) {
616 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
617 *cmflags = M_CM_DECODE_PGP;
619 else if ((WithCrypto & APPLICATION_PGP)
620 && mutt_is_application_pgp (hdr->content) & ENCRYPT)
622 else if ((WithCrypto & APPLICATION_SMIME)
623 && mutt_is_application_smime (hdr->content) & ENCRYPT) {
624 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
625 *cmflags = M_CM_DECODE_SMIME;
630 *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
631 *cmflags = M_CM_DECODE | M_CM_CHARCONV;
633 if (!decrypt) { /* If decode doesn't kick in for decrypt, */
634 *chflags |= CH_DECODE; /* then decode RFC 2047 headers, */
636 if (option (OPTWEED)) {
637 *chflags |= CH_WEED; /* and respect $weed. */
638 *cmflags |= M_CM_WEED;
644 void _mutt_save_message (HEADER * h, CONTEXT * ctx, int delete, int decode,
647 int cmflags, chflags;
649 set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
651 if (decode || decrypt)
652 mutt_parse_mime_message (Context, h);
654 if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0) {
656 mutt_set_flag (Context, h, M_DELETE, 1);
657 if (option (OPTDELETEUNTAG))
658 mutt_set_flag (Context, h, M_TAG, 0);
660 mutt_set_flag (Context, h, M_APPENDED, 1);
664 /* returns 0 if the copy/save was successful, or -1 on error/abort */
665 int mutt_save_message (HEADER * h, int delete,
666 int decode, int decrypt, int *redraw)
668 int i, need_buffy_cleanup;
669 int need_passphrase = 0, app = 0;
670 char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
683 snprintf (prompt, sizeof (prompt),
684 decode ? (delete ? _("Decode-save%s to mailbox") :
685 _("Decode-copy%s to mailbox")) :
686 (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
687 _("Decrypt-copy%s to mailbox")) :
688 (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
689 h ? "" : _(" tagged"));
694 need_passphrase = h->security & ENCRYPT;
697 mutt_message_hook (Context, h, M_MESSAGEHOOK);
698 mutt_default_save (buf, sizeof (buf), h);
701 /* look for the first tagged message */
703 for (i = 0; i < Context->vcount; i++) {
704 if (Context->hdrs[Context->v2r[i]]->tagged) {
705 h = Context->hdrs[Context->v2r[i]];
712 mutt_message_hook (Context, h, M_MESSAGEHOOK);
713 mutt_default_save (buf, sizeof (buf), h);
715 need_passphrase = h->security & ENCRYPT;
722 mutt_pretty_mailbox (buf);
723 if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
726 if (*redraw != REDRAW_FULL) {
728 *redraw = REDRAW_INDEX | REDRAW_STATUS;
730 *redraw = REDRAW_STATUS;
736 /* This is an undocumented feature of ELM pointed out to me by Felix von
737 * Leitner <leitner@prz.fu-berlin.de>
739 if (safe_strcmp (buf, ".") == 0)
740 strfcpy (buf, LastSaveFolder, sizeof (buf));
742 strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
744 mutt_expand_path (buf, sizeof (buf));
746 /* check to make sure that this file is really the one the user wants */
747 if (mutt_save_confirm (buf, &st) != 0)
750 if (WithCrypto && need_passphrase && (decode || decrypt)
751 && !crypt_valid_passphrase (app))
754 mutt_message (_("Copying to %s..."), buf);
757 if (Context->magic == M_IMAP && !(decode || decrypt) && mx_get_magic (buf) == M_IMAP) {
758 switch (imap_copy_messages (Context, h, buf, delete)) {
763 /* non-fatal error: fall through to fetch/append */
766 /* fatal error, abort */
773 if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL) {
775 _mutt_save_message (h, &ctx, delete, decode, decrypt);
777 for (i = 0; i < Context->vcount; i++) {
778 if (Context->hdrs[Context->v2r[i]]->tagged) {
779 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
781 _mutt_save_message (Context->hdrs[Context->v2r[i]], &ctx, delete,
787 need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
789 mx_close_mailbox (&ctx, NULL);
791 if (need_buffy_cleanup) {
793 tmp = buffy_find_mailbox (buf);
794 if (tmp && tmp->new <= 0)
795 buffy_update_mailbox (tmp);
797 /* fix up the times so buffy won't get confused */
798 if (st.st_mtime > st.st_atime) {
799 ut.actime = st.st_atime;
800 ut.modtime = time (NULL);
815 int mutt_update_list_file (char *filename, char *section, char *key,
820 char buf[HUGE_STRING];
821 char oldfile[_POSIX_PATH_MAX];
823 int ext = 0, done = 0, r = 0;
825 snprintf (oldfile, sizeof (oldfile), "%s.bak", filename);
826 debug_print (1, ("Renaming %s to %s\n", filename, oldfile));
828 /* if file not exist, create it */
829 if ((ifp = safe_fopen (filename, "a")))
831 if (_mutt_rename_file (filename, oldfile, 1)) {
832 mutt_perror (_("Unable to create backup file"));
836 debug_print (1, ("Opening %s\n", oldfile));
837 if (!(ifp = safe_fopen (oldfile, "r"))) {
838 mutt_perror (_("Unable to open backup file for reading"));
842 debug_print (1, ("Opening %s\n", filename));
843 if (!(ofp = safe_fopen (filename, "w"))) {
845 mutt_perror (_("Unable to open new file for writing"));
849 if (mx_lock_file (filename, fileno (ofp), 1, 0, 1)) {
852 mutt_error (_("Unable to lock %s, old file saved as %s"), filename,
858 while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) {
859 r = fputs (buf, ofp);
861 while (*c && *c != '\n')
863 c[0] = 0; /* strip EOL */
864 if (!strncmp (buf, "#: ", 3) && !safe_strcasecmp (buf + 3, section))
867 if (r != EOF && !done) {
868 snprintf (buf, sizeof (buf), "#: %s\n", section);
869 r = fputs (buf, ofp);
874 while (r != EOF && fgets (buf, sizeof (buf), ifp)) {
877 while (*c && (*c != '\r') && (*c != '\n'))
883 else if ((section && !strncmp (buf, "#: ", 3))) {
888 r = fputs (buf, ofp);
892 else if (key && !strncmp (buf, key, safe_strlen (key)) &&
893 (!*key || buf[safe_strlen (key)] == ' ')) {
896 while (*c && (*c != '\r') && (*c != '\n'))
902 r = fputs (line, ofp);
904 r = fputc ('\n', ofp);
909 r = fputs (buf, ofp);
913 while (r != EOF && fgets (buf, sizeof (buf), ifp))
914 r = fputs (buf, ofp);
916 /* If there wasn't a line to replace, put it on the end of the file */
917 if (r != EOF && !done && line) {
919 r = fputc ('\n', ofp);
921 mx_unlock_file (filename, fileno (ofp), 0);
929 mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
935 void mutt_version (void)
937 mutt_message ("Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate);
940 void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
942 char buf[LONG_STRING];
943 char obuf[LONG_STRING];
947 char charset[STRING];
950 short charset_changed = 0;
951 short type_changed = 0;
953 cp = mutt_get_parameter ("charset", b->parameter);
954 strfcpy (charset, NONULL (cp), sizeof (charset));
956 snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
957 strfcpy (obuf, buf, sizeof (obuf));
961 for (p = b->parameter; p; p = p->next) {
962 l = safe_strlen (buf);
964 rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
965 snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
969 if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
973 /* clean up previous junk */
974 mutt_free_parameter (&b->parameter);
977 mutt_parse_content_type (buf, b);
980 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
981 type_changed = ascii_strcasecmp (tmp, obuf);
983 ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
985 /* if in send mode, check for conversion - current setting is default. */
987 if (!h && b->type == TYPETEXT && charset_changed) {
990 snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
991 mutt_get_parameter ("charset", b->parameter));
992 if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
993 b->noconv = (r == M_NO);
996 /* inform the user */
998 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
1000 mutt_message (_("Content-Type changed to %s."), tmp);
1001 if (b->type == TYPETEXT && charset_changed) {
1004 mutt_message (_("Character set changed to %s; %s."),
1005 mutt_get_parameter ("charset", b->parameter),
1006 b->noconv ? _("not converting") : _("converting"));
1009 b->force_charset |= charset_changed ? 1 : 0;
1011 if (!is_multipart (b) && b->parts)
1012 mutt_free_body (&b->parts);
1013 if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
1014 b->hdr->content = NULL;
1015 mutt_free_header (&b->hdr);
1018 if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
1019 mutt_parse_part (fp, b);
1021 if (WithCrypto && h) {
1022 if (h->content == b)
1025 h->security |= crypt_query (b);
1030 static int _mutt_check_traditional_pgp (HEADER * h, int *redraw)
1035 h->security |= PGP_TRADITIONAL_CHECKED;
1037 mutt_parse_mime_message (Context, h);
1038 if ((msg = mx_open_message (Context, h->msgno)) == NULL)
1040 if (crypt_pgp_check_traditional (msg->fp, h->content, 0)) {
1041 h->security = crypt_query (h->content);
1042 *redraw |= REDRAW_FULL;
1046 h->security |= PGP_TRADITIONAL_CHECKED;
1047 mx_close_message (&msg);
1051 int mutt_check_traditional_pgp (HEADER * h, int *redraw)
1056 if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
1057 rv = _mutt_check_traditional_pgp (h, redraw);
1059 for (i = 0; i < Context->vcount; i++)
1060 if (Context->hdrs[Context->v2r[i]]->tagged &&
1061 !(Context->hdrs[Context->v2r[i]]->
1062 security & PGP_TRADITIONAL_CHECKED))
1064 _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)