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)
81 if (cur->security & ENCRYPT)
83 if (cur->security & APPLICATION_SMIME)
84 crypt_smime_getkeys (cur->env);
85 if(!crypt_valid_passphrase(cur->security))
88 cmflags |= M_CM_VERIFY;
90 else if (cur->security & SIGN)
92 /* find out whether or not the verify signature */
93 if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) == M_YES)
95 cmflags |= M_CM_VERIFY;
100 if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT)
102 if (cur->security & APPLICATION_PGP)
105 crypt_pgp_invoke_getkeys (cur->env->from);
107 crypt_invoke_message (APPLICATION_PGP);
110 if (cur->security & APPLICATION_SMIME)
111 crypt_invoke_message (APPLICATION_SMIME);
115 mutt_mktemp (tempfile);
116 if ((fpout = safe_fopen (tempfile, "w")) == NULL)
118 mutt_error _("Could not create temporary file!");
122 if (DisplayFilter && *DisplayFilter)
126 /* mutt_endwin (NULL); */
127 filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL,
128 -1, fileno(fpfilterout), -1);
131 mutt_error (_("Cannot create display filter"));
132 safe_fclose (&fpfilterout);
138 if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
142 mutt_make_string (buf, sizeof (buf), NONULL(PagerFmt), Context, cur);
144 fputs ("\n\n", fpout);
147 res = mutt_copy_message (fpout, Context, cur, cmflags,
148 (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM);
149 if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1)
151 mutt_error (_("Could not copy message"));
152 if (fpfilterout != NULL)
154 mutt_wait_filter (filterpid);
155 safe_fclose (&fpfilterout);
157 mutt_unlink (tempfile);
161 if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
162 mutt_any_key_to_continue (NULL);
164 safe_fclose (&fpfilterout); /* XXX - check result? */
169 /* update crypto information for this message */
170 cur->security |= crypt_query (cur->content);
172 /* Remove color cache for this message, in case there
173 are color patterns for both ~g and ~V */
182 && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY))
184 if (cur->security & GOODSIGN)
186 if (!crypt_smime_verify_sender(cur))
187 mutt_message ( _("S/MIME signature successfully verified."));
189 mutt_error ( _("S/MIME certificate owner does not match sender."));
191 else if (cur->security & PARTSIGN)
192 mutt_message (_("Warning: Part of this message has not been signed."));
193 else if (cur->security & SIGN || cur->security & BADSIGN)
194 mutt_error ( _("S/MIME signature could NOT be verified."));
198 && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
200 if (cur->security & GOODSIGN)
201 mutt_message (_("PGP signature successfully verified."));
202 else if (cur->security & PARTSIGN)
203 mutt_message (_("Warning: Part of this message has not been signed."));
205 mutt_message (_("PGP signature could NOT be verified."));
208 /* Invoke the builtin pager */
209 memset (&info, 0, sizeof (pager_t));
212 rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
219 snprintf (buf, sizeof (buf), "%s %s", NONULL(Pager), tempfile);
220 if ((r = mutt_system (buf)) == -1)
221 mutt_error (_("Error running \"%s\"!"), buf);
223 keypad (stdscr, TRUE);
225 mutt_set_flag (Context, cur, M_READ, 1);
226 if (r != -1 && option (OPTPROMPTAFTER))
228 mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
229 rc = km_dokey (MENU_PAGER);
238 void ci_bounce_message (HEADER *h, int *redraw)
240 char prompt[SHORT_STRING];
241 char buf[HUGE_STRING] = { 0 };
247 strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
249 strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
251 rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
253 if (option (OPTNEEDREDRAW))
255 unset_option (OPTNEEDREDRAW);
256 *redraw = REDRAW_FULL;
262 if (!(adr = rfc822_parse_adrlist (adr, buf)))
264 mutt_error _("Error parsing address!");
268 adr = mutt_expand_aliases (adr);
270 if (mutt_addrlist_to_idna (adr, &err) < 0)
272 mutt_error (_("Bad IDN: '%s'"), err);
274 rfc822_free_address (&adr);
279 rfc822_write_address (buf, sizeof (buf), adr, 1);
281 #define extra_space (15 + 7 + 2)
282 snprintf (prompt, sizeof (prompt),
283 (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);
285 if (mutt_strwidth (prompt) > COLS - extra_space)
287 mutt_format_string (prompt, sizeof (prompt),
288 0, COLS-extra_space, 0, 0,
289 prompt, sizeof (prompt), 0);
290 safe_strcat (prompt, sizeof (prompt), "...?");
293 safe_strcat (prompt, sizeof (prompt), "?");
295 if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
297 rfc822_free_address (&adr);
298 CLEARLINE (LINES - 1);
299 mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
303 CLEARLINE (LINES - 1);
305 rc = mutt_bounce_message (NULL, h, adr);
306 rfc822_free_address (&adr);
307 /* If no error, or background, display message. */
308 if ((rc == 0) || (rc == S_BKG))
309 mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
312 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
316 *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
317 *chflags |= CH_DECODE | CH_REORDER;
319 if (option (OPTWEED))
322 *cmflags |= M_CM_WEED;
327 *cmflags |= M_CM_PRINTING;
331 static void pipe_msg (HEADER *h, FILE *fp, int decode, int print)
334 int chflags = CH_FROM;
336 pipe_set_flags (decode, print, &cmflags, &chflags);
338 if (WithCrypto && decode && h->security & ENCRYPT)
340 if(!crypt_valid_passphrase(h->security))
346 mutt_parse_mime_message (Context, h);
348 mutt_copy_message (fp, Context, h, cmflags, chflags);
352 /* the following code is shared between printing and piping */
354 static int _mutt_pipe_message (HEADER *h, char *cmd,
365 /* mutt_endwin (NULL);
367 is this really needed here ?
368 it makes the screen flicker on pgp and s/mime messages,
369 before asking for a passphrase...
374 mutt_message_hook (Context, h, M_MESSAGEHOOK);
376 if (WithCrypto && decode)
378 mutt_parse_mime_message (Context, h);
379 if(h->security & ENCRYPT && !crypt_valid_passphrase(h->security))
384 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
386 mutt_perror _("Can't create filter process");
390 pipe_msg (h, fpout, decode, print);
392 rc = mutt_wait_filter (thepid);
395 { /* handle tagged messages */
397 if (WithCrypto && decode)
399 for (i = 0; i < Context->vcount; i++)
400 if(Context->hdrs[Context->v2r[i]]->tagged)
402 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
403 mutt_parse_mime_message(Context, Context->hdrs[Context->v2r[i]]);
404 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
405 !crypt_valid_passphrase(Context->hdrs[Context->v2r[i]]->security))
412 for (i = 0; i < Context->vcount; i++)
414 if (Context->hdrs[Context->v2r[i]]->tagged)
416 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
418 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
420 mutt_perror _("Can't create filter process");
423 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
424 /* add the message separator */
425 if (sep) fputs (sep, fpout);
426 safe_fclose (&fpout);
427 if (mutt_wait_filter (thepid) != 0)
435 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
437 mutt_perror _("Can't create filter process");
440 for (i = 0; i < Context->vcount; i++)
442 if (Context->hdrs[Context->v2r[i]]->tagged)
444 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
445 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
446 /* add the message separator */
447 if (sep) fputs (sep, fpout);
450 safe_fclose (&fpout);
451 if (mutt_wait_filter (thepid) != 0)
456 if (rc || option (OPTWAITKEY))
457 mutt_any_key_to_continue (NULL);
461 void mutt_pipe_message (HEADER *h)
463 char buffer[LONG_STRING];
466 if (mutt_get_field (_("Pipe to command: "), buffer, sizeof (buffer), M_CMD)
470 mutt_expand_path (buffer, sizeof (buffer));
471 _mutt_pipe_message (h, buffer,
472 option (OPTPIPEDECODE),
474 option (OPTPIPESPLIT),
478 void mutt_print_message (HEADER *h)
481 if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd))
483 mutt_message (_("No printing command has been defined."));
487 if (query_quadoption (OPT_PRINT,
488 h ? _("Print message?") : _("Print tagged messages?"))
492 if (_mutt_pipe_message (h, PrintCmd,
493 option (OPTPRINTDECODE),
495 option (OPTPRINTSPLIT),
497 mutt_message (h ? _("Message printed") : _("Messages printed"));
499 mutt_message (h ? _("Message could not be printed") :
500 _("Messages could not be printed"));
504 int mutt_select_sort (int reverse)
506 int method = Sort; /* save the current method in case of abort */
508 switch (mutt_multi_choice (reverse ?
509 _("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?: ") :
510 _("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
513 case -1: /* abort - don't resort */
525 Sort = SORT_RECEIVED;
536 case 6: /* (t)hread */
540 case 7: /* (u)nsort */
548 case 9: /* s(c)ore */
552 case 10: /* s(p)am */
557 Sort |= SORT_REVERSE;
559 return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
562 /* invoke a command in a subshell */
563 void mutt_shell_escape (void)
565 char buf[LONG_STRING];
568 if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0)
570 if (!buf[0] && Shell)
571 strfcpy (buf, Shell, sizeof (buf));
577 if (mutt_system (buf) != 0 || option (OPTWAITKEY))
578 mutt_any_key_to_continue (NULL);
583 /* enter a mutt command */
584 void mutt_enter_command (void)
587 char buffer[LONG_STRING], errbuf[SHORT_STRING];
591 if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0 || !buffer[0])
594 err.dsize = sizeof (errbuf);
595 memset (&token, 0, sizeof (token));
596 r = mutt_parse_rc_line (buffer, &token, &err);
600 /* since errbuf could potentially contain printf() sequences in it,
601 we must call mutt_error() in this fashion so that vsprintf()
602 doesn't expect more arguments that we passed */
604 mutt_message ("%s", errbuf);
606 mutt_error ("%s", errbuf);
610 void mutt_display_address (ENVELOPE *env)
613 char buf[SHORT_STRING];
616 adr = mutt_get_address (env, &pfx);
621 * Note: We don't convert IDNA to local representation this time.
622 * That is intentional, so the user has an opportunity to copy &
623 * paste the on-the-wire form of the address to other, IDN-unable
628 rfc822_write_address (buf, sizeof (buf), adr, 0);
629 mutt_message ("%s: %s", pfx, buf);
632 static void set_copy_flags (HEADER *hdr, int decode, int decrypt, int *cmflags, int *chflags)
635 *chflags = CH_UPDATE_LEN;
637 if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT))
639 if ((WithCrypto & APPLICATION_PGP)
640 && mutt_is_multipart_encrypted(hdr->content))
642 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
643 *cmflags = M_CM_DECODE_PGP;
645 else if ((WithCrypto & APPLICATION_PGP)
646 && mutt_is_application_pgp (hdr->content) & ENCRYPT)
648 else if ((WithCrypto & APPLICATION_SMIME)
649 && mutt_is_application_smime(hdr->content) & ENCRYPT)
651 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
652 *cmflags = M_CM_DECODE_SMIME;
658 *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
659 *cmflags = M_CM_DECODE | M_CM_CHARCONV;
661 if (!decrypt) /* If decode doesn't kick in for decrypt, */
663 *chflags |= CH_DECODE; /* then decode RFC 2047 headers, */
665 if (option (OPTWEED))
667 *chflags |= CH_WEED; /* and respect $weed. */
668 *cmflags |= M_CM_WEED;
674 void _mutt_save_message (HEADER *h, CONTEXT *ctx, int delete, int decode, int decrypt)
676 int cmflags, chflags;
678 set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
680 if (decode || decrypt)
681 mutt_parse_mime_message (Context, h);
683 if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0)
687 mutt_set_flag (Context, h, M_DELETE, 1);
688 if (option (OPTDELETEUNTAG))
689 mutt_set_flag (Context, h, M_TAG, 0);
691 mutt_set_flag (Context, h, M_APPENDED, 1);
695 /* returns 0 if the copy/save was successful, or -1 on error/abort */
696 int mutt_save_message (HEADER *h, int delete,
697 int decode, int decrypt, int *redraw)
699 int i, need_buffy_cleanup;
700 int need_passphrase = 0, app=0;
701 char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
713 snprintf (prompt, sizeof (prompt),
714 decode ? (delete ? _("Decode-save%s to mailbox") :
715 _("Decode-copy%s to mailbox")) :
716 (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
717 _("Decrypt-copy%s to mailbox")) :
718 (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
719 h ? "" : _(" tagged"));
726 need_passphrase = h->security & ENCRYPT;
729 mutt_message_hook (Context, h, M_MESSAGEHOOK);
730 mutt_default_save (buf, sizeof (buf), h);
734 /* look for the first tagged message */
736 for (i = 0; i < Context->vcount; i++)
738 if (Context->hdrs[Context->v2r[i]]->tagged)
740 h = Context->hdrs[Context->v2r[i]];
748 mutt_message_hook (Context, h, M_MESSAGEHOOK);
749 mutt_default_save (buf, sizeof (buf), h);
752 need_passphrase = h->security & ENCRYPT;
759 mutt_pretty_mailbox (buf);
760 if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
763 if (*redraw != REDRAW_FULL)
766 *redraw = REDRAW_INDEX | REDRAW_STATUS;
768 *redraw = REDRAW_STATUS;
774 /* This is an undocumented feature of ELM pointed out to me by Felix von
775 * Leitner <leitner@prz.fu-berlin.de>
777 if (mutt_strcmp (buf, ".") == 0)
778 strfcpy (buf, LastSaveFolder, sizeof (buf));
780 strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
782 mutt_expand_path (buf, sizeof (buf));
784 /* check to make sure that this file is really the one the user wants */
785 if (mutt_save_confirm (buf, &st) != 0)
788 if (WithCrypto && need_passphrase && (decode || decrypt)
789 && !crypt_valid_passphrase(app))
792 mutt_message (_("Copying to %s..."), buf);
795 if (Context->magic == M_IMAP &&
796 !(decode || decrypt) && mx_is_imap (buf))
798 switch (imap_copy_messages (Context, h, buf, delete))
801 case 0: mutt_clear_error (); return 0;
802 /* non-fatal error: fall through to fetch/append */
804 /* fatal error, abort */
810 if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL)
813 _mutt_save_message(h, &ctx, delete, decode, decrypt);
816 for (i = 0; i < Context->vcount; i++)
818 if (Context->hdrs[Context->v2r[i]]->tagged)
820 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
821 _mutt_save_message(Context->hdrs[Context->v2r[i]],
822 &ctx, delete, decode, decrypt);
827 need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
829 mx_close_mailbox (&ctx, NULL);
831 if (need_buffy_cleanup)
834 tmp = mutt_find_mailbox (buf);
835 if (tmp && !tmp->new)
836 mutt_update_mailbox (tmp);
838 /* fix up the times so buffy won't get confused */
839 if (st.st_mtime > st.st_atime)
841 ut.actime = st.st_atime;
842 ut.modtime = time (NULL);
857 int mutt_update_list_file (char *filename, char *section, char *key, char *line)
861 char buf[HUGE_STRING];
862 char oldfile[_POSIX_PATH_MAX];
864 int ext = 0, done = 0, r = 0;
866 snprintf (oldfile, sizeof(oldfile), "%s.bak", filename);
867 dprint (1, (debugfile, "Renaming %s to %s\n", filename, oldfile));
869 /* if file not exist, create it */
870 if ((ifp = safe_fopen (filename, "a")))
872 if (_mutt_rename_file (filename, oldfile, 1))
874 mutt_perror _("Unable to create backup file");
877 dprint (1, (debugfile, "Opening %s\n", oldfile));
878 if (!(ifp = safe_fopen (oldfile, "r")))
880 mutt_perror _("Unable to open backup file for reading");
883 dprint (1, (debugfile, "Opening %s\n", filename));
884 if (!(ofp = safe_fopen (filename, "w")))
887 mutt_perror _("Unable to open new file for writing");
890 if (mx_lock_file (filename, fileno (ofp), 1, 0, 1))
894 mutt_error (_("Unable to lock %s, old file saved as %s"), filename, oldfile);
900 while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
902 r = fputs (buf, ofp);
904 while (*c && *c != '\n') c++;
905 c[0] = 0; /* strip EOL */
906 if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
909 if (r != EOF && !done)
911 snprintf (buf, sizeof(buf), "#: %s\n", section);
912 r = fputs (buf, ofp);
917 while (r != EOF && fgets (buf, sizeof (buf), ifp))
922 while (*c && (*c != '\r') && (*c != '\n')) c++;
924 if (*c != '\\') ext = 0;
926 else if ((section && !strncmp (buf, "#: ", 3)))
933 r = fputs (buf, ofp);
937 else if (key && !strncmp (buf, key, strlen(key)) &&
938 (!*key || buf[strlen(key)] == ' '))
942 while (*c && (*c != '\r') && (*c != '\n')) c++;
944 if (*c == '\\') ext = 1;
947 r = fputs (line, ofp);
949 r = fputc ('\n', ofp);
955 r = fputs (buf, ofp);
959 while (r != EOF && fgets (buf, sizeof (buf), ifp))
960 r = fputs (buf, ofp);
962 /* If there wasn't a line to replace, put it on the end of the file */
963 if (r != EOF && !done && line)
966 r = fputc ('\n', ofp);
968 mx_unlock_file (filename, fileno (ofp), 0);
977 mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
983 void mutt_version (void)
985 mutt_message ("Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate);
988 void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
990 char buf[LONG_STRING];
991 char obuf[LONG_STRING];
995 char charset[STRING];
998 short charset_changed = 0;
999 short type_changed = 0;
1001 cp = mutt_get_parameter ("charset", b->parameter);
1002 strfcpy (charset, NONULL (cp), sizeof (charset));
1004 snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
1005 strfcpy (obuf, buf, sizeof (obuf));
1010 for (p = b->parameter; p; p = p->next)
1014 rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
1015 snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
1019 if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
1023 /* clean up previous junk */
1024 mutt_free_parameter (&b->parameter);
1027 mutt_parse_content_type (buf, b);
1030 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
1031 type_changed = ascii_strcasecmp (tmp, obuf);
1032 charset_changed = ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
1034 /* if in send mode, check for conversion - current setting is default. */
1036 if (!h && b->type == TYPETEXT && charset_changed)
1039 snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
1040 mutt_get_parameter ("charset", b->parameter));
1041 if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
1042 b->noconv = (r == M_NO);
1045 /* inform the user */
1047 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
1049 mutt_message (_("Content-Type changed to %s."), tmp);
1050 if (b->type == TYPETEXT && charset_changed)
1054 mutt_message (_("Character set changed to %s; %s."),
1055 mutt_get_parameter ("charset", b->parameter),
1056 b->noconv ? _("not converting") : _("converting"));
1059 b->force_charset |= charset_changed ? 1 : 0;
1061 if (!is_multipart (b) && b->parts)
1062 mutt_free_body (&b->parts);
1063 if (!mutt_is_message_type (b->type, b->subtype) && b->hdr)
1065 b->hdr->content = NULL;
1066 mutt_free_header (&b->hdr);
1069 if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
1070 mutt_parse_part (fp, b);
1072 if (WithCrypto && h)
1074 if (h->content == b)
1077 h->security |= crypt_query (b);
1082 static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
1087 h->security |= PGP_TRADITIONAL_CHECKED;
1089 mutt_parse_mime_message (Context, h);
1090 if ((msg = mx_open_message (Context, h->msgno)) == NULL)
1092 if (crypt_pgp_check_traditional (msg->fp, h->content, 0))
1094 h->security = crypt_query (h->content);
1095 *redraw |= REDRAW_FULL;
1099 h->security |= PGP_TRADITIONAL_CHECKED;
1100 mx_close_message (&msg);
1104 int mutt_check_traditional_pgp (HEADER *h, int *redraw)
1108 if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
1109 rv = _mutt_check_traditional_pgp (h, redraw);
1112 for (i = 0; i < Context->vcount; i++)
1113 if (Context->hdrs[Context->v2r[i]]->tagged &&
1114 !(Context->hdrs[Context->v2r[i]]->security & PGP_TRADITIONAL_CHECKED))
1115 rv = _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)