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 || str_cmp (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 &= ~(GOODSIGN|BADSIGN);
168 cur->security |= crypt_query (cur->content);
170 /* Remove color cache for this message, in case there
171 are color patterns for both ~g and ~V */
179 && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
180 if (cur->security & GOODSIGN) {
181 if (!crypt_smime_verify_sender (cur))
182 mutt_message (_("S/MIME signature successfully verified."));
184 mutt_error (_("S/MIME certificate owner does not match sender."));
186 else if (cur->security & PARTSIGN)
188 ("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)) {
195 if (cur->security & GOODSIGN)
196 mutt_message (_("PGP signature successfully verified."));
197 else if (cur->security & PARTSIGN)
199 ("Warning: Part of this message has not been signed."));
200 else if (cur->security & SIGN)
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);
214 snprintf (buf, sizeof (buf), "%s %s", NONULL (Pager), tempfile);
215 if ((r = mutt_system (buf)) == -1)
216 mutt_error (_("Error running \"%s\"!"), buf);
218 keypad (stdscr, TRUE);
220 mutt_set_flag (Context, cur, M_READ, 1);
221 if (r != -1 && option (OPTPROMPTAFTER)) {
222 mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
223 rc = km_dokey (MENU_PAGER);
232 void ci_bounce_message (HEADER * h, int *redraw)
234 char prompt[SHORT_STRING];
235 char buf[HUGE_STRING] = { 0 };
241 strfcpy (prompt, _("Bounce message to: "), sizeof (prompt));
243 strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));
245 rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
247 if (option (OPTNEEDREDRAW)) {
248 unset_option (OPTNEEDREDRAW);
249 *redraw = REDRAW_FULL;
255 if (!(adr = rfc822_parse_adrlist (adr, buf))) {
256 mutt_error _("Error parsing address!");
261 adr = mutt_expand_aliases (adr);
263 if (mutt_addrlist_to_idna (adr, &err) < 0) {
264 mutt_error (_("Bad IDN: '%s'"), err);
266 rfc822_free_address (&adr);
271 rfc822_write_address (buf, sizeof (buf), adr, 1);
273 #define extra_space (15 + 7 + 2)
274 snprintf (prompt, sizeof (prompt),
275 (h ? _("Bounce message to %s") : _("Bounce messages to %s")),
278 if (mutt_strwidth (prompt) > COLS - extra_space) {
279 mutt_format_string (prompt, sizeof (prompt),
280 0, COLS - extra_space, 0, 0,
281 prompt, sizeof (prompt), 0);
282 str_cat (prompt, sizeof (prompt), "...?");
285 str_cat (prompt, sizeof (prompt), "?");
287 if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
288 rfc822_free_address (&adr);
289 CLEARLINE (LINES - 1);
290 mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
294 CLEARLINE (LINES - 1);
296 rc = mutt_bounce_message (NULL, h, adr);
297 rfc822_free_address (&adr);
298 /* If no error, or background, display message. */
299 if ((rc == 0) || (rc == S_BKG))
300 mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
303 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
306 *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
307 *chflags |= CH_DECODE | CH_REORDER;
309 if (option (OPTWEED)) {
311 *cmflags |= M_CM_WEED;
316 *cmflags |= M_CM_PRINTING;
320 static void pipe_msg (HEADER * h, FILE * fp, int decode, int print)
323 int chflags = CH_FROM;
325 pipe_set_flags (decode, print, &cmflags, &chflags);
327 if (WithCrypto && decode && h->security & ENCRYPT) {
328 if (!crypt_valid_passphrase (h->security))
334 mutt_parse_mime_message (Context, h);
336 mutt_copy_message (fp, Context, h, cmflags, chflags);
340 /* the following code is shared between printing and piping */
342 static int _mutt_pipe_message (HEADER * h, char *cmd,
343 int decode, int print, int split, char *sep)
350 /* mutt_endwin (NULL);
352 is this really needed here ?
353 it makes the screen flicker on pgp and s/mime messages,
354 before asking for a passphrase...
358 mutt_message_hook (Context, h, M_MESSAGEHOOK);
360 if (WithCrypto && decode) {
361 mutt_parse_mime_message (Context, h);
362 if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
367 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
368 mutt_perror (_("Can't create filter process"));
373 pipe_msg (h, fpout, decode, print);
375 rc = mutt_wait_filter (thepid);
377 else { /* handle tagged messages */
379 if (WithCrypto && decode) {
380 for (i = 0; i < Context->vcount; i++)
381 if (Context->hdrs[Context->v2r[i]]->tagged) {
382 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
384 mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
385 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
386 !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
393 for (i = 0; i < Context->vcount; i++) {
394 if (Context->hdrs[Context->v2r[i]]->tagged) {
395 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
398 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
399 mutt_perror (_("Can't create filter process"));
403 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
404 /* add the message separator */
407 safe_fclose (&fpout);
408 if (mutt_wait_filter (thepid) != 0)
415 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
416 mutt_perror (_("Can't create filter process"));
420 for (i = 0; i < Context->vcount; i++) {
421 if (Context->hdrs[Context->v2r[i]]->tagged) {
422 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
424 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
425 /* add the message separator */
430 safe_fclose (&fpout);
431 if (mutt_wait_filter (thepid) != 0)
436 if (rc || option (OPTWAITKEY))
437 mutt_any_key_to_continue (NULL);
441 void mutt_pipe_message (HEADER * h)
443 char buffer[LONG_STRING];
446 if (mutt_get_field (_("Pipe to command: "), buffer, sizeof (buffer), M_CMD)
450 mutt_expand_path (buffer, sizeof (buffer));
451 _mutt_pipe_message (h, buffer,
452 option (OPTPIPEDECODE),
453 0, option (OPTPIPESPLIT), PipeSep);
456 void mutt_print_message (HEADER * h)
459 if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd)) {
460 mutt_message (_("No printing command has been defined."));
464 if (query_quadoption (OPT_PRINT,
465 h ? _("Print message?") : _("Print tagged messages?"))
469 if (_mutt_pipe_message (h, PrintCmd,
470 option (OPTPRINTDECODE),
471 1, option (OPTPRINTSPLIT), "\f") == 0)
472 mutt_message (h ? _("Message printed") : _("Messages printed"));
474 mutt_message (h ? _("Message could not be printed") :
475 _("Messages could not be printed"));
479 int mutt_select_sort (int reverse)
481 int method = Sort; /* save the current method in case of abort */
483 switch (mutt_multi_choice (reverse ?
485 ("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?: ")
488 ("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
490 case -1: /* abort - don't resort */
502 Sort = SORT_RECEIVED;
513 case 6: /* (t)hread */
517 case 7: /* (u)nsort */
525 case 9: /* s(c)ore */
529 case 10: /* s(p)am */
534 Sort |= SORT_REVERSE;
536 return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
539 /* invoke a command in a subshell */
540 void mutt_shell_escape (void)
542 char buf[LONG_STRING];
545 if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
546 if (!buf[0] && Shell)
547 strfcpy (buf, Shell, sizeof (buf));
549 CLEARLINE (LINES - 1);
552 if (mutt_system (buf) != 0 || option (OPTWAITKEY))
553 mutt_any_key_to_continue (NULL);
558 /* enter a mutt command */
559 void mutt_enter_command (void)
562 char buffer[LONG_STRING], errbuf[SHORT_STRING];
566 if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0
570 err.dsize = sizeof (errbuf);
571 memset (&token, 0, sizeof (token));
572 r = mutt_parse_rc_line (buffer, &token, &err);
575 /* since errbuf could potentially contain printf() sequences in it,
576 we must call mutt_error() in this fashion so that vsprintf()
577 doesn't expect more arguments that we passed */
579 mutt_message ("%s", errbuf);
581 mutt_error ("%s", errbuf);
585 void mutt_display_address (ENVELOPE * env)
588 char buf[SHORT_STRING];
591 adr = mutt_get_address (env, &pfx);
597 * Note: We don't convert IDNA to local representation this time.
598 * That is intentional, so the user has an opportunity to copy &
599 * paste the on-the-wire form of the address to other, IDN-unable
604 rfc822_write_address (buf, sizeof (buf), adr, 0);
605 mutt_message ("%s: %s", pfx, buf);
608 static void set_copy_flags (HEADER * hdr, int decode, int decrypt,
609 int *cmflags, int *chflags)
612 *chflags = CH_UPDATE_LEN;
614 if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT)) {
615 if ((WithCrypto & APPLICATION_PGP)
616 && mutt_is_multipart_encrypted (hdr->content)) {
617 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
618 *cmflags = M_CM_DECODE_PGP;
620 else if ((WithCrypto & APPLICATION_PGP)
621 && mutt_is_application_pgp (hdr->content) & ENCRYPT)
623 else if ((WithCrypto & APPLICATION_SMIME)
624 && mutt_is_application_smime (hdr->content) & ENCRYPT) {
625 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
626 *cmflags = M_CM_DECODE_SMIME;
631 *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
632 *cmflags = M_CM_DECODE | M_CM_CHARCONV;
634 if (!decrypt) { /* If decode doesn't kick in for decrypt, */
635 *chflags |= CH_DECODE; /* then decode RFC 2047 headers, */
637 if (option (OPTWEED)) {
638 *chflags |= CH_WEED; /* and respect $weed. */
639 *cmflags |= M_CM_WEED;
645 int _mutt_save_message (HEADER * h, CONTEXT * ctx, int delete, int decode,
647 int cmflags, chflags;
650 set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
652 if (decode || decrypt)
653 mutt_parse_mime_message (Context, h);
655 if ((rc = mutt_append_message (ctx, Context, h, cmflags, chflags)) != 0)
659 mutt_set_flag (Context, h, M_DELETE, 1);
660 if (option (OPTDELETEUNTAG))
661 mutt_set_flag (Context, h, M_TAG, 0);
662 mutt_set_flag (Context, h, M_APPENDED, 1);
667 /* returns 0 if the copy/save was successful, or -1 on error/abort */
668 int mutt_save_message (HEADER * h, int delete,
669 int decode, int decrypt, int *redraw) {
670 int i, need_buffy_cleanup;
671 int need_passphrase = 0, app = 0;
672 char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
685 snprintf (prompt, sizeof (prompt),
686 decode ? (delete ? _("Decode-save%s to mailbox") :
687 _("Decode-copy%s to mailbox")) :
688 (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
689 _("Decrypt-copy%s to mailbox")) :
690 (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
691 h ? "" : _(" tagged"));
696 need_passphrase = h->security & ENCRYPT;
699 mutt_message_hook (Context, h, M_MESSAGEHOOK);
700 mutt_default_save (buf, sizeof (buf), h);
703 /* look for the first tagged message */
705 for (i = 0; i < Context->vcount; i++) {
706 if (Context->hdrs[Context->v2r[i]]->tagged) {
707 h = Context->hdrs[Context->v2r[i]];
714 mutt_message_hook (Context, h, M_MESSAGEHOOK);
715 mutt_default_save (buf, sizeof (buf), h);
717 need_passphrase = h->security & ENCRYPT;
724 mutt_pretty_mailbox (buf);
725 if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
728 if (*redraw != REDRAW_FULL) {
730 *redraw = REDRAW_INDEX | REDRAW_STATUS;
732 *redraw = REDRAW_STATUS;
738 /* This is an undocumented feature of ELM pointed out to me by Felix von
739 * Leitner <leitner@prz.fu-berlin.de>
741 if (str_cmp (buf, ".") == 0)
742 strfcpy (buf, LastSaveFolder, sizeof (buf));
744 strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
746 mutt_expand_path (buf, sizeof (buf));
748 /* check to make sure that this file is really the one the user wants */
749 if (mutt_save_confirm (buf, &st) != 0)
752 if (WithCrypto && need_passphrase && (decode || decrypt)
753 && !crypt_valid_passphrase (app))
756 mutt_message (_("Copying to %s..."), buf);
759 if (Context->magic == M_IMAP && !(decode || decrypt) && mx_get_magic (buf) == M_IMAP) {
760 switch (imap_copy_messages (Context, h, buf, delete)) {
765 /* non-fatal error: fall through to fetch/append */
768 /* fatal error, abort */
775 if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL) {
777 if (_mutt_save_message (h, &ctx, delete, decode, decrypt) != 0) {
778 mx_close_mailbox (&ctx, NULL);
782 for (i = 0; i < Context->vcount; i++) {
783 if (Context->hdrs[Context->v2r[i]]->tagged) {
784 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
786 if (_mutt_save_message (Context->hdrs[Context->v2r[i]], &ctx, delete,
787 decode, decrypt) != 0) {
788 mx_close_mailbox (&ctx, NULL);
795 need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
797 mx_close_mailbox (&ctx, NULL);
799 if (need_buffy_cleanup) {
801 tmp = buffy_find_mailbox (buf);
802 if (tmp && tmp->new <= 0)
803 buffy_update_mailbox (tmp);
805 /* fix up the times so buffy won't get confused */
806 if (st.st_mtime > st.st_atime) {
807 ut.actime = st.st_atime;
808 ut.modtime = time (NULL);
823 int mutt_update_list_file (char *filename, char *section, char *key,
828 char buf[HUGE_STRING];
829 char oldfile[_POSIX_PATH_MAX];
831 int ext = 0, done = 0, r = 0;
833 snprintf (oldfile, sizeof (oldfile), "%s.bak", filename);
834 debug_print (1, ("Renaming %s to %s\n", filename, oldfile));
836 /* if file not exist, create it */
837 if ((ifp = safe_fopen (filename, "a")))
839 if (_mutt_rename_file (filename, oldfile, 1)) {
840 mutt_perror (_("Unable to create backup file"));
844 debug_print (1, ("Opening %s\n", oldfile));
845 if (!(ifp = safe_fopen (oldfile, "r"))) {
846 mutt_perror (_("Unable to open backup file for reading"));
850 debug_print (1, ("Opening %s\n", filename));
851 if (!(ofp = safe_fopen (filename, "w"))) {
853 mutt_perror (_("Unable to open new file for writing"));
857 if (mx_lock_file (filename, fileno (ofp), 1, 0, 1)) {
860 mutt_error (_("Unable to lock %s, old file saved as %s"), filename,
866 while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) {
867 r = fputs (buf, ofp);
869 while (*c && *c != '\n')
871 c[0] = 0; /* strip EOL */
872 if (!strncmp (buf, "#: ", 3) && !str_casecmp (buf + 3, section))
875 if (r != EOF && !done) {
876 snprintf (buf, sizeof (buf), "#: %s\n", section);
877 r = fputs (buf, ofp);
882 while (r != EOF && fgets (buf, sizeof (buf), ifp)) {
885 while (*c && (*c != '\r') && (*c != '\n'))
891 else if ((section && !strncmp (buf, "#: ", 3))) {
896 r = fputs (buf, ofp);
900 else if (key && !strncmp (buf, key, str_len (key)) &&
901 (!*key || buf[str_len (key)] == ' ')) {
904 while (*c && (*c != '\r') && (*c != '\n'))
910 r = fputs (line, ofp);
912 r = fputc ('\n', ofp);
917 r = fputs (buf, ofp);
921 while (r != EOF && fgets (buf, sizeof (buf), ifp))
922 r = fputs (buf, ofp);
924 /* If there wasn't a line to replace, put it on the end of the file */
925 if (r != EOF && !done && line) {
927 r = fputc ('\n', ofp);
929 mx_unlock_file (filename, fileno (ofp), 0);
937 mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
943 void mutt_version (void)
945 mutt_message ("Mutt-ng %s (%s) based on Mutt 1.5.9", MUTT_VERSION, ReleaseDate);
948 void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
950 char buf[LONG_STRING];
951 char obuf[LONG_STRING];
955 char charset[STRING];
958 short charset_changed = 0;
959 short type_changed = 0;
961 cp = mutt_get_parameter ("charset", b->parameter);
962 strfcpy (charset, NONULL (cp), sizeof (charset));
964 snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
965 strfcpy (obuf, buf, sizeof (obuf));
969 for (p = b->parameter; p; p = p->next) {
972 rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
973 snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
977 if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
981 /* clean up previous junk */
982 mutt_free_parameter (&b->parameter);
985 mutt_parse_content_type (buf, b);
988 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
989 type_changed = ascii_strcasecmp (tmp, obuf);
991 ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
993 /* if in send mode, check for conversion - current setting is default. */
995 if (!h && b->type == TYPETEXT && charset_changed) {
998 snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
999 mutt_get_parameter ("charset", b->parameter));
1000 if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
1001 b->noconv = (r == M_NO);
1004 /* inform the user */
1006 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
1008 mutt_message (_("Content-Type changed to %s."), tmp);
1009 if (b->type == TYPETEXT && charset_changed) {
1012 mutt_message (_("Character set changed to %s; %s."),
1013 mutt_get_parameter ("charset", b->parameter),
1014 b->noconv ? _("not converting") : _("converting"));
1017 b->force_charset |= charset_changed ? 1 : 0;
1019 if (!is_multipart (b) && b->parts)
1020 mutt_free_body (&b->parts);
1021 if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
1022 b->hdr->content = NULL;
1023 mutt_free_header (&b->hdr);
1026 if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
1027 mutt_parse_part (fp, b);
1029 if (WithCrypto && h) {
1030 if (h->content == b)
1033 h->security |= crypt_query (b);
1038 static int _mutt_check_traditional_pgp (HEADER * h, int *redraw)
1043 h->security |= PGP_TRADITIONAL_CHECKED;
1045 mutt_parse_mime_message (Context, h);
1046 if ((msg = mx_open_message (Context, h->msgno)) == NULL)
1048 if (crypt_pgp_check_traditional (msg->fp, h->content, 0)) {
1049 h->security = crypt_query (h->content);
1050 *redraw |= REDRAW_FULL;
1054 h->security |= PGP_TRADITIONAL_CHECKED;
1055 mx_close_message (&msg);
1059 int mutt_check_traditional_pgp (HEADER * h, int *redraw)
1064 if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
1065 rv = _mutt_check_traditional_pgp (h, redraw);
1067 for (i = 0; i < Context->vcount; i++)
1068 if (Context->hdrs[Context->v2r[i]]->tagged &&
1069 !(Context->hdrs[Context->v2r[i]]->
1070 security & PGP_TRADITIONAL_CHECKED))
1072 _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)