2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
3 * Copyright (C) 2000 Thomas Roessler <roessler@does-not-exist.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 #include "mutt_curses.h"
26 #include "mutt_menu.h"
33 #include "mutt_crypt.h"
34 #include "mutt_idna.h"
36 #include <sys/types.h>
54 #include <sys/types.h>
57 extern char *ReleaseDate;
59 /* The folder the user last saved to. Used by ci_save_message() */
60 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
62 int mutt_display_message (HEADER * cur)
64 char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
65 int rc = 0, builtin = 0;
66 int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV;
68 FILE *fpfilterout = NULL;
72 snprintf (buf, sizeof (buf), "%s/%s", TYPE (cur->content),
73 cur->content->subtype);
75 mutt_parse_mime_message (Context, cur);
76 mutt_message_hook (Context, cur, M_MESSAGEHOOK);
78 /* see if crytpo is needed for this message. if so, we should exit curses */
79 if (WithCrypto && cur->security) {
80 if (cur->security & ENCRYPT) {
81 if (cur->security & APPLICATION_SMIME)
82 crypt_smime_getkeys (cur->env);
83 if (!crypt_valid_passphrase (cur->security))
86 cmflags |= M_CM_VERIFY;
88 else if (cur->security & SIGN) {
89 /* find out whether or not the verify signature */
90 if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) ==
92 cmflags |= M_CM_VERIFY;
97 if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT) {
98 if (cur->security & APPLICATION_PGP) {
100 crypt_pgp_invoke_getkeys (cur->env->from);
102 crypt_invoke_message (APPLICATION_PGP);
105 if (cur->security & APPLICATION_SMIME)
106 crypt_invoke_message (APPLICATION_SMIME);
110 mutt_mktemp (tempfile);
111 if ((fpout = safe_fopen (tempfile, "w")) == NULL) {
112 mutt_error _("Could not create temporary file!");
117 if (DisplayFilter && *DisplayFilter) {
120 /* mutt_endwin (NULL); */
121 filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL,
122 -1, fileno (fpfilterout), -1);
124 mutt_error (_("Cannot create display filter"));
125 safe_fclose (&fpfilterout);
131 if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
134 mutt_make_string (buf, sizeof (buf), NONULL (PagerFmt), Context, cur);
136 fputs ("\n\n", fpout);
139 res = mutt_copy_message (fpout, Context, cur, cmflags,
140 (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
141 CH_DECODE | CH_FROM);
142 if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1) {
143 mutt_error (_("Could not copy message"));
144 if (fpfilterout != NULL) {
145 mutt_wait_filter (filterpid);
146 safe_fclose (&fpfilterout);
148 mutt_unlink (tempfile);
152 if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
153 mutt_any_key_to_continue (NULL);
155 safe_fclose (&fpfilterout); /* XXX - check result? */
159 /* update crypto information for this message */
160 cur->security |= crypt_query (cur->content);
162 /* Remove color cache for this message, in case there
163 are color patterns for both ~g and ~V */
171 && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
172 if (cur->security & GOODSIGN) {
173 if (!crypt_smime_verify_sender (cur))
174 mutt_message (_("S/MIME signature successfully verified."));
176 mutt_error (_("S/MIME certificate owner does not match sender."));
178 else if (cur->security & PARTSIGN)
180 ("Warning: Part of this message has not been signed."));
181 else if (cur->security & SIGN || cur->security & BADSIGN)
182 mutt_error (_("S/MIME signature could NOT be verified."));
186 && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) {
187 if (cur->security & GOODSIGN)
188 mutt_message (_("PGP signature successfully verified."));
189 else if (cur->security & PARTSIGN)
191 ("Warning: Part of this message has not been signed."));
193 mutt_message (_("PGP signature could NOT be verified."));
196 /* Invoke the builtin pager */
197 memset (&info, 0, sizeof (pager_t));
200 rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
206 snprintf (buf, sizeof (buf), "%s %s", NONULL (Pager), tempfile);
207 if ((r = mutt_system (buf)) == -1)
208 mutt_error (_("Error running \"%s\"!"), buf);
210 keypad (stdscr, TRUE);
212 mutt_set_flag (Context, cur, M_READ, 1);
213 if (r != -1 && option (OPTPROMPTAFTER)) {
214 mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
215 rc = km_dokey (MENU_PAGER);
224 void ci_bounce_message (HEADER * h, int *redraw)
226 char prompt[SHORT_STRING];
227 char buf[HUGE_STRING] = { 0 };
233 strfcpy (prompt, _("Bounce message to: "), sizeof (prompt));
235 strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));
237 rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
239 if (option (OPTNEEDREDRAW)) {
240 unset_option (OPTNEEDREDRAW);
241 *redraw = REDRAW_FULL;
247 if (!(adr = rfc822_parse_adrlist (adr, buf))) {
248 mutt_error _("Error parsing address!");
253 adr = mutt_expand_aliases (adr);
255 if (mutt_addrlist_to_idna (adr, &err) < 0) {
256 mutt_error (_("Bad IDN: '%s'"), err);
258 rfc822_free_address (&adr);
263 rfc822_write_address (buf, sizeof (buf), adr, 1);
265 #define extra_space (15 + 7 + 2)
266 snprintf (prompt, sizeof (prompt),
267 (h ? _("Bounce message to %s") : _("Bounce messages to %s")),
270 if (mutt_strwidth (prompt) > COLS - extra_space) {
271 mutt_format_string (prompt, sizeof (prompt),
272 0, COLS - extra_space, 0, 0,
273 prompt, sizeof (prompt), 0);
274 safe_strcat (prompt, sizeof (prompt), "...?");
277 safe_strcat (prompt, sizeof (prompt), "?");
279 if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
280 rfc822_free_address (&adr);
281 CLEARLINE (LINES - 1);
282 mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
286 CLEARLINE (LINES - 1);
288 rc = mutt_bounce_message (NULL, h, adr);
289 rfc822_free_address (&adr);
290 /* If no error, or background, display message. */
291 if ((rc == 0) || (rc == S_BKG))
292 mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
295 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
298 *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
299 *chflags |= CH_DECODE | CH_REORDER;
301 if (option (OPTWEED)) {
303 *cmflags |= M_CM_WEED;
308 *cmflags |= M_CM_PRINTING;
312 static void pipe_msg (HEADER * h, FILE * fp, int decode, int print)
315 int chflags = CH_FROM;
317 pipe_set_flags (decode, print, &cmflags, &chflags);
319 if (WithCrypto && decode && h->security & ENCRYPT) {
320 if (!crypt_valid_passphrase (h->security))
326 mutt_parse_mime_message (Context, h);
328 mutt_copy_message (fp, Context, h, cmflags, chflags);
332 /* the following code is shared between printing and piping */
334 static int _mutt_pipe_message (HEADER * h, char *cmd,
335 int decode, int print, int split, char *sep)
342 /* mutt_endwin (NULL);
344 is this really needed here ?
345 it makes the screen flicker on pgp and s/mime messages,
346 before asking for a passphrase...
350 mutt_message_hook (Context, h, M_MESSAGEHOOK);
352 if (WithCrypto && decode) {
353 mutt_parse_mime_message (Context, h);
354 if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
359 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
360 mutt_perror _("Can't create filter process");
365 pipe_msg (h, fpout, decode, print);
367 rc = mutt_wait_filter (thepid);
369 else { /* handle tagged messages */
371 if (WithCrypto && decode) {
372 for (i = 0; i < Context->vcount; i++)
373 if (Context->hdrs[Context->v2r[i]]->tagged) {
374 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
376 mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
377 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
378 !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
385 for (i = 0; i < Context->vcount; i++) {
386 if (Context->hdrs[Context->v2r[i]]->tagged) {
387 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
390 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
391 mutt_perror _("Can't create filter process");
395 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
396 /* add the message separator */
399 safe_fclose (&fpout);
400 if (mutt_wait_filter (thepid) != 0)
407 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
408 mutt_perror _("Can't create filter process");
412 for (i = 0; i < Context->vcount; i++) {
413 if (Context->hdrs[Context->v2r[i]]->tagged) {
414 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
416 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
417 /* add the message separator */
422 safe_fclose (&fpout);
423 if (mutt_wait_filter (thepid) != 0)
428 if (rc || option (OPTWAITKEY))
429 mutt_any_key_to_continue (NULL);
433 void mutt_pipe_message (HEADER * h)
435 char buffer[LONG_STRING];
438 if (mutt_get_field (_("Pipe to command: "), buffer, sizeof (buffer), M_CMD)
442 mutt_expand_path (buffer, sizeof (buffer));
443 _mutt_pipe_message (h, buffer,
444 option (OPTPIPEDECODE),
445 0, option (OPTPIPESPLIT), PipeSep);
448 void mutt_print_message (HEADER * h)
451 if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd)) {
452 mutt_message (_("No printing command has been defined."));
456 if (query_quadoption (OPT_PRINT,
457 h ? _("Print message?") : _("Print tagged messages?"))
461 if (_mutt_pipe_message (h, PrintCmd,
462 option (OPTPRINTDECODE),
463 1, option (OPTPRINTSPLIT), "\f") == 0)
464 mutt_message (h ? _("Message printed") : _("Messages printed"));
466 mutt_message (h ? _("Message could not be printed") :
467 _("Messages could not be printed"));
471 int mutt_select_sort (int reverse)
473 int method = Sort; /* save the current method in case of abort */
475 switch (mutt_multi_choice (reverse ?
477 ("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?: ")
480 ("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
482 case -1: /* abort - don't resort */
494 Sort = SORT_RECEIVED;
505 case 6: /* (t)hread */
509 case 7: /* (u)nsort */
517 case 9: /* s(c)ore */
521 case 10: /* s(p)am */
526 Sort |= SORT_REVERSE;
528 return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
531 /* invoke a command in a subshell */
532 void mutt_shell_escape (void)
534 char buf[LONG_STRING];
537 if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
538 if (!buf[0] && Shell)
539 strfcpy (buf, Shell, sizeof (buf));
541 CLEARLINE (LINES - 1);
544 if (mutt_system (buf) != 0 || option (OPTWAITKEY))
545 mutt_any_key_to_continue (NULL);
550 /* enter a mutt command */
551 void mutt_enter_command (void)
554 char buffer[LONG_STRING], errbuf[SHORT_STRING];
558 if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0
562 err.dsize = sizeof (errbuf);
563 memset (&token, 0, sizeof (token));
564 r = mutt_parse_rc_line (buffer, &token, &err);
567 /* since errbuf could potentially contain printf() sequences in it,
568 we must call mutt_error() in this fashion so that vsprintf()
569 doesn't expect more arguments that we passed */
571 mutt_message ("%s", errbuf);
573 mutt_error ("%s", errbuf);
577 void mutt_display_address (ENVELOPE * env)
580 char buf[SHORT_STRING];
583 adr = mutt_get_address (env, &pfx);
589 * Note: We don't convert IDNA to local representation this time.
590 * That is intentional, so the user has an opportunity to copy &
591 * paste the on-the-wire form of the address to other, IDN-unable
596 rfc822_write_address (buf, sizeof (buf), adr, 0);
597 mutt_message ("%s: %s", pfx, buf);
600 static void set_copy_flags (HEADER * hdr, int decode, int decrypt,
601 int *cmflags, int *chflags)
604 *chflags = CH_UPDATE_LEN;
606 if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT)) {
607 if ((WithCrypto & APPLICATION_PGP)
608 && mutt_is_multipart_encrypted (hdr->content)) {
609 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
610 *cmflags = M_CM_DECODE_PGP;
612 else if ((WithCrypto & APPLICATION_PGP)
613 && mutt_is_application_pgp (hdr->content) & ENCRYPT)
615 else if ((WithCrypto & APPLICATION_SMIME)
616 && mutt_is_application_smime (hdr->content) & ENCRYPT) {
617 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
618 *cmflags = M_CM_DECODE_SMIME;
623 *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
624 *cmflags = M_CM_DECODE | M_CM_CHARCONV;
626 if (!decrypt) { /* If decode doesn't kick in for decrypt, */
627 *chflags |= CH_DECODE; /* then decode RFC 2047 headers, */
629 if (option (OPTWEED)) {
630 *chflags |= CH_WEED; /* and respect $weed. */
631 *cmflags |= M_CM_WEED;
637 void _mutt_save_message (HEADER * h, CONTEXT * ctx, int delete, int decode,
640 int cmflags, chflags;
642 set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
644 if (decode || decrypt)
645 mutt_parse_mime_message (Context, h);
647 if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0) {
649 mutt_set_flag (Context, h, M_DELETE, 1);
650 if (option (OPTDELETEUNTAG))
651 mutt_set_flag (Context, h, M_TAG, 0);
653 mutt_set_flag (Context, h, M_APPENDED, 1);
657 /* returns 0 if the copy/save was successful, or -1 on error/abort */
658 int mutt_save_message (HEADER * h, int delete,
659 int decode, int decrypt, int *redraw)
661 int i, need_buffy_cleanup;
662 int need_passphrase = 0, app = 0;
663 char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
676 snprintf (prompt, sizeof (prompt),
677 decode ? (delete ? _("Decode-save%s to mailbox") :
678 _("Decode-copy%s to mailbox")) :
679 (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
680 _("Decrypt-copy%s to mailbox")) :
681 (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
682 h ? "" : _(" tagged"));
687 need_passphrase = h->security & ENCRYPT;
690 mutt_message_hook (Context, h, M_MESSAGEHOOK);
691 mutt_default_save (buf, sizeof (buf), h);
694 /* look for the first tagged message */
696 for (i = 0; i < Context->vcount; i++) {
697 if (Context->hdrs[Context->v2r[i]]->tagged) {
698 h = Context->hdrs[Context->v2r[i]];
705 mutt_message_hook (Context, h, M_MESSAGEHOOK);
706 mutt_default_save (buf, sizeof (buf), h);
708 need_passphrase = h->security & ENCRYPT;
715 mutt_pretty_mailbox (buf);
716 if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
719 if (*redraw != REDRAW_FULL) {
721 *redraw = REDRAW_INDEX | REDRAW_STATUS;
723 *redraw = REDRAW_STATUS;
729 /* This is an undocumented feature of ELM pointed out to me by Felix von
730 * Leitner <leitner@prz.fu-berlin.de>
732 if (mutt_strcmp (buf, ".") == 0)
733 strfcpy (buf, LastSaveFolder, sizeof (buf));
735 strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
737 mutt_expand_path (buf, sizeof (buf));
739 /* check to make sure that this file is really the one the user wants */
740 if (mutt_save_confirm (buf, &st) != 0)
743 if (WithCrypto && need_passphrase && (decode || decrypt)
744 && !crypt_valid_passphrase (app))
747 mutt_message (_("Copying to %s..."), buf);
750 if (Context->magic == M_IMAP && !(decode || decrypt) && mx_is_imap (buf)) {
751 switch (imap_copy_messages (Context, h, buf, delete)) {
756 /* non-fatal error: fall through to fetch/append */
759 /* fatal error, abort */
766 if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL) {
768 _mutt_save_message (h, &ctx, delete, decode, decrypt);
770 for (i = 0; i < Context->vcount; i++) {
771 if (Context->hdrs[Context->v2r[i]]->tagged) {
772 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
774 _mutt_save_message (Context->hdrs[Context->v2r[i]], &ctx, delete,
780 need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
782 mx_close_mailbox (&ctx, NULL);
784 if (need_buffy_cleanup) {
786 tmp = mutt_find_mailbox (buf);
787 if (tmp && tmp->new <= 0)
788 mutt_update_mailbox (tmp);
790 /* fix up the times so buffy won't get confused */
791 if (st.st_mtime > st.st_atime) {
792 ut.actime = st.st_atime;
793 ut.modtime = time (NULL);
808 int mutt_update_list_file (char *filename, char *section, char *key,
813 char buf[HUGE_STRING];
814 char oldfile[_POSIX_PATH_MAX];
816 int ext = 0, done = 0, r = 0;
818 snprintf (oldfile, sizeof (oldfile), "%s.bak", filename);
819 dprint (1, (debugfile, "Renaming %s to %s\n", filename, oldfile));
821 /* if file not exist, create it */
822 if ((ifp = safe_fopen (filename, "a")))
824 if (_mutt_rename_file (filename, oldfile, 1)) {
825 mutt_perror _("Unable to create backup file");
829 dprint (1, (debugfile, "Opening %s\n", oldfile));
830 if (!(ifp = safe_fopen (oldfile, "r"))) {
831 mutt_perror _("Unable to open backup file for reading");
835 dprint (1, (debugfile, "Opening %s\n", filename));
836 if (!(ofp = safe_fopen (filename, "w"))) {
838 mutt_perror _("Unable to open new file for writing");
842 if (mx_lock_file (filename, fileno (ofp), 1, 0, 1)) {
845 mutt_error (_("Unable to lock %s, old file saved as %s"), filename,
851 while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) {
852 r = fputs (buf, ofp);
854 while (*c && *c != '\n')
856 c[0] = 0; /* strip EOL */
857 if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf + 3, section))
860 if (r != EOF && !done) {
861 snprintf (buf, sizeof (buf), "#: %s\n", section);
862 r = fputs (buf, ofp);
867 while (r != EOF && fgets (buf, sizeof (buf), ifp)) {
870 while (*c && (*c != '\r') && (*c != '\n'))
876 else if ((section && !strncmp (buf, "#: ", 3))) {
881 r = fputs (buf, ofp);
885 else if (key && !strncmp (buf, key, strlen (key)) &&
886 (!*key || buf[strlen (key)] == ' ')) {
889 while (*c && (*c != '\r') && (*c != '\n'))
895 r = fputs (line, ofp);
897 r = fputc ('\n', ofp);
902 r = fputs (buf, ofp);
906 while (r != EOF && fgets (buf, sizeof (buf), ifp))
907 r = fputs (buf, ofp);
909 /* If there wasn't a line to replace, put it on the end of the file */
910 if (r != EOF && !done && line) {
912 r = fputc ('\n', ofp);
914 mx_unlock_file (filename, fileno (ofp), 0);
922 mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
928 void mutt_version (void)
930 mutt_message ("Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate);
933 void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
935 char buf[LONG_STRING];
936 char obuf[LONG_STRING];
940 char charset[STRING];
943 short charset_changed = 0;
944 short type_changed = 0;
946 cp = mutt_get_parameter ("charset", b->parameter);
947 strfcpy (charset, NONULL (cp), sizeof (charset));
949 snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
950 strfcpy (obuf, buf, sizeof (obuf));
954 for (p = b->parameter; p; p = p->next) {
957 rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
958 snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
962 if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
966 /* clean up previous junk */
967 mutt_free_parameter (&b->parameter);
970 mutt_parse_content_type (buf, b);
973 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
974 type_changed = ascii_strcasecmp (tmp, obuf);
976 ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
978 /* if in send mode, check for conversion - current setting is default. */
980 if (!h && b->type == TYPETEXT && charset_changed) {
983 snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
984 mutt_get_parameter ("charset", b->parameter));
985 if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
986 b->noconv = (r == M_NO);
989 /* inform the user */
991 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
993 mutt_message (_("Content-Type changed to %s."), tmp);
994 if (b->type == TYPETEXT && charset_changed) {
997 mutt_message (_("Character set changed to %s; %s."),
998 mutt_get_parameter ("charset", b->parameter),
999 b->noconv ? _("not converting") : _("converting"));
1002 b->force_charset |= charset_changed ? 1 : 0;
1004 if (!is_multipart (b) && b->parts)
1005 mutt_free_body (&b->parts);
1006 if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
1007 b->hdr->content = NULL;
1008 mutt_free_header (&b->hdr);
1011 if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
1012 mutt_parse_part (fp, b);
1014 if (WithCrypto && h) {
1015 if (h->content == b)
1018 h->security |= crypt_query (b);
1023 static int _mutt_check_traditional_pgp (HEADER * h, int *redraw)
1028 h->security |= PGP_TRADITIONAL_CHECKED;
1030 mutt_parse_mime_message (Context, h);
1031 if ((msg = mx_open_message (Context, h->msgno)) == NULL)
1033 if (crypt_pgp_check_traditional (msg->fp, h->content, 0)) {
1034 h->security = crypt_query (h->content);
1035 *redraw |= REDRAW_FULL;
1039 h->security |= PGP_TRADITIONAL_CHECKED;
1040 mx_close_message (&msg);
1044 int mutt_check_traditional_pgp (HEADER * h, int *redraw)
1049 if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
1050 rv = _mutt_check_traditional_pgp (h, redraw);
1052 for (i = 0; i < Context->vcount; i++)
1053 if (Context->hdrs[Context->v2r[i]]->tagged &&
1054 !(Context->hdrs[Context->v2r[i]]->
1055 security & PGP_TRADITIONAL_CHECKED))
1057 _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)