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.
21 #include "mutt_curses.h"
22 #include "mutt_menu.h"
29 #include "mutt_crypt.h"
30 #include "mutt_idna.h"
32 #include <sys/types.h>
50 #include <sys/types.h>
53 extern char *ReleaseDate;
55 /* The folder the user last saved to. Used by ci_save_message() */
56 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
58 int mutt_display_message (HEADER *cur)
60 char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
61 int rc = 0, builtin = 0;
62 int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV;
64 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 /* see if crytpo is needed for this message. if so, we should exit curses */
75 if (WithCrypto && cur->security)
77 if (cur->security & ENCRYPT)
79 if (cur->security & APPLICATION_SMIME)
80 crypt_smime_getkeys (cur->env);
81 if(!crypt_valid_passphrase(cur->security))
84 cmflags |= M_CM_VERIFY;
86 else if (cur->security & SIGN)
88 /* find out whether or not the verify signature */
89 if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) == M_YES)
91 cmflags |= M_CM_VERIFY;
96 if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT)
98 if (cur->security & APPLICATION_PGP)
101 crypt_pgp_invoke_getkeys (cur->env->from);
103 crypt_invoke_message (APPLICATION_PGP);
106 if (cur->security & APPLICATION_SMIME)
107 crypt_invoke_message (APPLICATION_SMIME);
111 mutt_mktemp (tempfile);
112 if ((fpout = safe_fopen (tempfile, "w")) == NULL)
114 mutt_error _("Could not create temporary file!");
118 if (DisplayFilter && *DisplayFilter)
122 /* mutt_endwin (NULL); */
123 filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL,
124 -1, fileno(fpfilterout), -1);
127 mutt_error (_("Cannot create display filter"));
128 safe_fclose (&fpfilterout);
134 if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
138 mutt_make_string (buf, sizeof (buf), NONULL(PagerFmt), Context, cur);
140 fputs ("\n\n", fpout);
143 res = mutt_copy_message (fpout, Context, cur, cmflags,
144 (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM);
145 if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1)
147 mutt_error (_("Could not copy message"));
148 if (fpfilterout != NULL)
150 mutt_wait_filter (filterpid);
151 safe_fclose (&fpfilterout);
153 mutt_unlink (tempfile);
157 if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
158 mutt_any_key_to_continue (NULL);
160 safe_fclose (&fpfilterout); /* XXX - check result? */
165 /* update crypto information for this message */
166 cur->security |= crypt_query (cur->content);
168 /* Remove color cache for this message, in case there
169 are color patterns for both ~g and ~V */
178 && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY))
180 if (cur->security & GOODSIGN)
182 if (!crypt_smime_verify_sender(cur))
183 mutt_message ( _("S/MIME signature successfully verified."));
185 mutt_error ( _("S/MIME certificate owner does not match sender."));
187 else if (cur->security & PARTSIGN)
188 mutt_message (_("Warning: Part of this message has not been signed."));
189 else if (cur->security & SIGN || cur->security & BADSIGN)
190 mutt_error ( _("S/MIME signature could NOT be verified."));
194 && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
196 if (cur->security & GOODSIGN)
197 mutt_message (_("PGP signature successfully verified."));
198 else if (cur->security & PARTSIGN)
199 mutt_message (_("Warning: Part of this message has not been signed."));
201 mutt_message (_("PGP signature could NOT be verified."));
204 /* Invoke the builtin pager */
205 memset (&info, 0, sizeof (pager_t));
208 rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
215 snprintf (buf, sizeof (buf), "%s %s", NONULL(Pager), tempfile);
216 if ((r = mutt_system (buf)) == -1)
217 mutt_error (_("Error running \"%s\"!"), buf);
219 keypad (stdscr, TRUE);
221 mutt_set_flag (Context, cur, M_READ, 1);
222 if (r != -1 && option (OPTPROMPTAFTER))
224 mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
225 rc = km_dokey (MENU_PAGER);
234 void ci_bounce_message (HEADER *h, int *redraw)
236 char prompt[SHORT_STRING];
237 char buf[HUGE_STRING] = { 0 };
243 strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
245 strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
247 rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
249 if (option (OPTNEEDREDRAW))
251 unset_option (OPTNEEDREDRAW);
252 *redraw = REDRAW_FULL;
258 if (!(adr = rfc822_parse_adrlist (adr, buf)))
260 mutt_error _("Error parsing address!");
264 adr = mutt_expand_aliases (adr);
266 if (mutt_addrlist_to_idna (adr, &err) < 0)
268 mutt_error (_("Bad IDN: '%s'"), err);
270 rfc822_free_address (&adr);
275 rfc822_write_address (buf, sizeof (buf), adr, 1);
277 #define extra_space (15 + 7 + 2)
278 snprintf (prompt, sizeof (prompt),
279 (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);
281 if (mutt_strwidth (prompt) > COLS - extra_space)
283 mutt_format_string (prompt, sizeof (prompt),
284 0, COLS-extra_space, 0, 0,
285 prompt, sizeof (prompt), 0);
286 strncat (prompt, "...?", sizeof (prompt));
289 strncat (prompt, "?", sizeof (prompt));
291 if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
293 rfc822_free_address (&adr);
294 CLEARLINE (LINES - 1);
295 mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
299 CLEARLINE (LINES - 1);
301 rc = mutt_bounce_message (NULL, h, adr);
302 rfc822_free_address (&adr);
303 /* If no error, or background, display message. */
304 if ((rc == 0) || (rc == S_BKG))
305 mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
308 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
312 *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
313 *chflags |= CH_DECODE | CH_REORDER;
315 if (option (OPTWEED))
318 *cmflags |= M_CM_WEED;
323 *cmflags |= M_CM_PRINTING;
327 void pipe_msg (HEADER *h, FILE *fp, int decode, int print)
330 int chflags = CH_FROM;
332 pipe_set_flags (decode, print, &cmflags, &chflags);
334 if (WithCrypto && decode && h->security & ENCRYPT)
336 if(!crypt_valid_passphrase(h->security))
342 mutt_parse_mime_message (Context, h);
344 mutt_copy_message (fp, Context, h, cmflags, chflags);
348 /* the following code is shared between printing and piping */
350 static int _mutt_pipe_message (HEADER *h, char *cmd,
361 /* mutt_endwin (NULL);
363 is this really needed here ?
364 it makes the screen flicker on pgp and s/mime messages,
365 before asking for a passphrase...
370 mutt_message_hook (Context, h, M_MESSAGEHOOK);
372 if (WithCrypto && decode)
374 mutt_parse_mime_message (Context, h);
375 if(h->security & ENCRYPT && !crypt_valid_passphrase(h->security))
380 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
382 mutt_perror _("Can't create filter process");
386 pipe_msg (h, fpout, decode, print);
388 rc = mutt_wait_filter (thepid);
391 { /* handle tagged messages */
393 if (WithCrypto && decode)
395 for (i = 0; i < Context->vcount; i++)
396 if(Context->hdrs[Context->v2r[i]]->tagged)
398 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
399 mutt_parse_mime_message(Context, Context->hdrs[Context->v2r[i]]);
400 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
401 !crypt_valid_passphrase(Context->hdrs[Context->v2r[i]]->security))
408 for (i = 0; i < Context->vcount; i++)
410 if (Context->hdrs[Context->v2r[i]]->tagged)
412 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
414 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
416 mutt_perror _("Can't create filter process");
419 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
420 /* add the message separator */
421 if (sep) fputs (sep, fpout);
422 safe_fclose (&fpout);
423 if (mutt_wait_filter (thepid) != 0)
431 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
433 mutt_perror _("Can't create filter process");
436 for (i = 0; i < Context->vcount; i++)
438 if (Context->hdrs[Context->v2r[i]]->tagged)
440 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
441 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
442 /* add the message separator */
443 if (sep) fputs (sep, fpout);
446 safe_fclose (&fpout);
447 if (mutt_wait_filter (thepid) != 0)
452 if (rc || option (OPTWAITKEY))
453 mutt_any_key_to_continue (NULL);
457 void mutt_pipe_message (HEADER *h)
459 char buffer[LONG_STRING];
462 if (mutt_get_field (_("Pipe to command: "), buffer, sizeof (buffer), M_CMD)
466 mutt_expand_path (buffer, sizeof (buffer));
467 _mutt_pipe_message (h, buffer,
468 option (OPTPIPEDECODE),
470 option (OPTPIPESPLIT),
474 void mutt_print_message (HEADER *h)
477 if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd))
479 mutt_message (_("No printing command has been defined."));
483 if (query_quadoption (OPT_PRINT,
484 h ? _("Print message?") : _("Print tagged messages?"))
488 if (_mutt_pipe_message (h, PrintCmd,
489 option (OPTPRINTDECODE),
491 option (OPTPRINTSPLIT),
493 mutt_message (h ? _("Message printed") : _("Messages printed"));
495 mutt_message (h ? _("Message could not be printed") :
496 _("Messages could not be printed"));
500 int mutt_select_sort (int reverse)
502 int method = Sort; /* save the current method in case of abort */
504 switch (mutt_multi_choice (reverse ?
505 _("Rev-Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore?: ") :
506 _("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore?: "),
509 case -1: /* abort - don't resort */
521 Sort = SORT_RECEIVED;
532 case 6: /* (t)hread */
536 case 7: /* (u)nsort */
544 case 9: /* s(c)ore */
549 Sort |= SORT_REVERSE;
551 return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
554 /* invoke a command in a subshell */
555 void mutt_shell_escape (void)
557 char buf[LONG_STRING];
560 if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0)
562 if (!buf[0] && Shell)
563 strfcpy (buf, Shell, sizeof (buf));
569 if (mutt_system (buf) != 0 || option (OPTWAITKEY))
570 mutt_any_key_to_continue (NULL);
575 /* enter a mutt command */
576 void mutt_enter_command (void)
579 char buffer[LONG_STRING], errbuf[SHORT_STRING];
583 if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0 || !buffer[0])
586 err.dsize = sizeof (errbuf);
587 memset (&token, 0, sizeof (token));
588 r = mutt_parse_rc_line (buffer, &token, &err);
592 /* since errbuf could potentially contain printf() sequences in it,
593 we must call mutt_error() in this fashion so that vsprintf()
594 doesn't expect more arguments that we passed */
596 mutt_message ("%s", errbuf);
598 mutt_error ("%s", errbuf);
602 void mutt_display_address (ENVELOPE *env)
605 char buf[SHORT_STRING];
608 adr = mutt_get_address (env, &pfx);
613 * Note: We don't convert IDNA to local representation this time.
614 * That is intentional, so the user has an opportunity to copy &
615 * paste the on-the-wire form of the address to other, IDN-unable
620 rfc822_write_address (buf, sizeof (buf), adr, 0);
621 mutt_message ("%s: %s", pfx, buf);
624 static void set_copy_flags (HEADER *hdr, int decode, int decrypt, int *cmflags, int *chflags)
627 *chflags = CH_UPDATE_LEN;
629 if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT))
631 if ((WithCrypto & APPLICATION_PGP)
632 && mutt_is_multipart_encrypted(hdr->content))
634 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
635 *cmflags = M_CM_DECODE_PGP;
637 else if ((WithCrypto & APPLICATION_PGP)
638 && mutt_is_application_pgp (hdr->content) & ENCRYPT)
640 else if ((WithCrypto & APPLICATION_SMIME)
641 && mutt_is_application_smime(hdr->content) & ENCRYPT)
643 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
644 *cmflags = M_CM_DECODE_SMIME;
650 *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
651 *cmflags = M_CM_DECODE | M_CM_CHARCONV;
653 if (!decrypt) /* If decode doesn't kick in for decrypt, */
655 *chflags |= CH_DECODE; /* then decode RFC 2047 headers, */
657 if (option (OPTWEED))
659 *chflags |= CH_WEED; /* and respect $weed. */
660 *cmflags |= M_CM_WEED;
666 void _mutt_save_message (HEADER *h, CONTEXT *ctx, int delete, int decode, int decrypt)
668 int cmflags, chflags;
670 set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
672 if (decode || decrypt)
673 mutt_parse_mime_message (Context, h);
675 if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0)
679 mutt_set_flag (Context, h, M_DELETE, 1);
680 if (option (OPTDELETEUNTAG))
681 mutt_set_flag (Context, h, M_TAG, 0);
683 mutt_set_flag (Context, h, M_APPENDED, 1);
687 /* returns 0 if the copy/save was successful, or -1 on error/abort */
688 int mutt_save_message (HEADER *h, int delete,
689 int decode, int decrypt, int *redraw)
691 int i, need_buffy_cleanup;
692 int need_passphrase = 0, app=0;
693 char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
705 snprintf (prompt, sizeof (prompt),
706 decode ? (delete ? _("Decode-save%s to mailbox") :
707 _("Decode-copy%s to mailbox")) :
708 (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
709 _("Decrypt-copy%s to mailbox")) :
710 (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
711 h ? "" : _(" tagged"));
718 need_passphrase = h->security & ENCRYPT;
721 mutt_message_hook (Context, h, M_MESSAGEHOOK);
722 mutt_default_save (buf, sizeof (buf), h);
726 /* look for the first tagged message */
728 for (i = 0; i < Context->vcount; i++)
730 if (Context->hdrs[Context->v2r[i]]->tagged)
732 h = Context->hdrs[Context->v2r[i]];
740 mutt_message_hook (Context, h, M_MESSAGEHOOK);
741 mutt_default_save (buf, sizeof (buf), h);
744 need_passphrase = h->security & ENCRYPT;
751 mutt_pretty_mailbox (buf);
752 if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
755 if (*redraw != REDRAW_FULL)
758 *redraw = REDRAW_INDEX | REDRAW_STATUS;
760 *redraw = REDRAW_STATUS;
766 /* This is an undocumented feature of ELM pointed out to me by Felix von
767 * Leitner <leitner@prz.fu-berlin.de>
769 if (mutt_strcmp (buf, ".") == 0)
770 strfcpy (buf, LastSaveFolder, sizeof (buf));
772 strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
774 mutt_expand_path (buf, sizeof (buf));
776 /* check to make sure that this file is really the one the user wants */
777 if (mutt_save_confirm (buf, &st) != 0)
780 if (WithCrypto && need_passphrase && (decode || decrypt)
781 && !crypt_valid_passphrase(app))
784 mutt_message (_("Copying to %s..."), buf);
787 if (Context->magic == M_IMAP &&
788 !(decode || decrypt) && mx_is_imap (buf))
790 switch (imap_copy_messages (Context, h, buf, delete))
793 case 0: mutt_clear_error (); return 0;
794 /* non-fatal error: fall through to fetch/append */
796 /* fatal error, abort */
802 if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL)
805 _mutt_save_message(h, &ctx, delete, decode, decrypt);
808 for (i = 0; i < Context->vcount; i++)
810 if (Context->hdrs[Context->v2r[i]]->tagged)
812 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
813 _mutt_save_message(Context->hdrs[Context->v2r[i]],
814 &ctx, delete, decode, decrypt);
819 need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
821 mx_close_mailbox (&ctx, NULL);
823 if (need_buffy_cleanup)
826 tmp = mutt_find_mailbox (buf);
827 if (tmp && !tmp->new)
828 mutt_update_mailbox (tmp);
830 /* fix up the times so buffy won't get confused */
831 if (st.st_mtime > st.st_atime)
833 ut.actime = st.st_atime;
834 ut.modtime = time (NULL);
849 int mutt_update_list_file (char *filename, char *section, char *key, char *line)
853 char buf[HUGE_STRING];
854 char oldfile[_POSIX_PATH_MAX];
856 int ext = 0, done = 0, r = 0;
858 snprintf (oldfile, sizeof(oldfile), "%s.bak", filename);
859 dprint (1, (debugfile, "Renaming %s to %s\n", filename, oldfile));
861 /* if file not exist, create it */
862 if ((ifp = safe_fopen (filename, "a")))
864 if (_mutt_rename_file (filename, oldfile, 1))
866 mutt_perror _("Unable to create backup file");
869 dprint (1, (debugfile, "Opening %s\n", oldfile));
870 if (!(ifp = safe_fopen (oldfile, "r")))
872 mutt_perror _("Unable to open backup file for reading");
875 dprint (1, (debugfile, "Opening %s\n", filename));
876 if (!(ofp = safe_fopen (filename, "w")))
879 mutt_perror _("Unable to open new file for writing");
882 if (mx_lock_file (filename, fileno (ofp), 1, 0, 1))
886 mutt_error (_("Unable to lock %s, old file saved as %s"), filename, oldfile);
892 while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
894 r = fputs (buf, ofp);
896 while (*c && *c != '\n') c++;
897 c[0] = 0; /* strip EOL */
898 if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
901 if (r != EOF && !done)
903 snprintf (buf, sizeof(buf), "#: %s\n", section);
904 r = fputs (buf, ofp);
909 while (r != EOF && fgets (buf, sizeof (buf), ifp))
914 while (*c && (*c != '\r') && (*c != '\n')) c++;
916 if (*c != '\\') ext = 0;
918 else if ((section && !strncmp (buf, "#: ", 3)))
925 r = fputs (buf, ofp);
929 else if (key && !strncmp (buf, key, strlen(key)) &&
930 (!*key || buf[strlen(key)] == ' '))
934 while (*c && (*c != '\r') && (*c != '\n')) c++;
936 if (*c == '\\') ext = 1;
939 r = fputs (line, ofp);
941 r = fputc ('\n', ofp);
947 r = fputs (buf, ofp);
951 while (r != EOF && fgets (buf, sizeof (buf), ifp))
952 r = fputs (buf, ofp);
954 /* If there wasn't a line to replace, put it on the end of the file */
955 if (r != EOF && !done && line)
958 r = fputc ('\n', ofp);
960 mx_unlock_file (filename, fileno (ofp), 0);
969 mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
975 void mutt_version (void)
977 mutt_message ("Mutt %s (%s)", MUTT_VERSION, ReleaseDate);
980 void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
982 char buf[LONG_STRING];
983 char obuf[LONG_STRING];
987 char charset[STRING];
990 short charset_changed = 0;
991 short type_changed = 0;
993 cp = mutt_get_parameter ("charset", b->parameter);
994 strfcpy (charset, NONULL (cp), sizeof (charset));
996 snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
997 strfcpy (obuf, buf, sizeof (obuf));
1002 for (p = b->parameter; p; p = p->next)
1006 rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
1007 snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
1011 if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
1015 /* clean up previous junk */
1016 mutt_free_parameter (&b->parameter);
1019 mutt_parse_content_type (buf, b);
1022 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
1023 type_changed = ascii_strcasecmp (tmp, obuf);
1024 charset_changed = ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
1026 /* if in send mode, check for conversion - current setting is default. */
1028 if (!h && b->type == TYPETEXT && charset_changed)
1031 snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
1032 mutt_get_parameter ("charset", b->parameter));
1033 if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
1034 b->noconv = (r == M_NO);
1037 /* inform the user */
1040 mutt_message (_("Content-Type changed to %s."), tmp);
1041 else if (b->type == TYPETEXT && charset_changed)
1042 mutt_message (_("Character set changed to %s; %s."),
1043 mutt_get_parameter ("charset", b->parameter),
1044 b->noconv ? _("not converting") : _("converting"));
1046 b->force_charset |= charset_changed ? 1 : 0;
1048 if (!is_multipart (b) && b->parts)
1049 mutt_free_body (&b->parts);
1050 if (!mutt_is_message_type (b->type, b->subtype) && b->hdr)
1052 b->hdr->content = NULL;
1053 mutt_free_header (&b->hdr);
1056 if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
1057 mutt_parse_part (fp, b);
1059 if (WithCrypto && h)
1061 if (h->content == b)
1064 h->security |= crypt_query (b);
1069 static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
1074 mutt_parse_mime_message (Context, h);
1075 if ((msg = mx_open_message (Context, h->msgno)) == NULL)
1077 if (crypt_pgp_check_traditional (msg->fp, h->content, 0))
1079 h->security = crypt_query (h->content);
1080 *redraw |= REDRAW_FULL;
1084 mx_close_message (&msg);
1088 int mutt_check_traditional_pgp (HEADER *h, int *redraw)
1093 rv = _mutt_check_traditional_pgp (h, redraw);
1096 for (i = 0; i < Context->vcount; i++)
1097 if (Context->hdrs[Context->v2r[i]]->tagged)
1098 rv = _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)