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"
24 #include "mutt_crypt.h"
25 #include "mutt_idna.h"
27 #include <sys/types.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;
67 snprintf (buf, sizeof (buf), "%s/%s", TYPE (cur->content),
68 cur->content->subtype);
70 mutt_parse_mime_message (Context, cur);
71 mutt_message_hook (Context, cur, M_MESSAGEHOOK);
73 /* see if crytpo is needed for this message. if so, we should exit curses */
74 if (WithCrypto && cur->security) {
75 if (cur->security & ENCRYPT) {
76 if (cur->security & APPLICATION_SMIME)
77 crypt_smime_getkeys (cur->env);
78 if (!crypt_valid_passphrase (cur->security))
81 cmflags |= M_CM_VERIFY;
83 else if (cur->security & SIGN) {
84 /* find out whether or not the verify signature */
85 if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) ==
87 cmflags |= M_CM_VERIFY;
92 if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT) {
93 if (cur->security & APPLICATION_PGP) {
95 crypt_pgp_invoke_getkeys (cur->env->from);
97 crypt_invoke_message (APPLICATION_PGP);
100 if (cur->security & APPLICATION_SMIME)
101 crypt_invoke_message (APPLICATION_SMIME);
105 mutt_mktemp (tempfile);
106 if ((fpout = safe_fopen (tempfile, "w")) == NULL) {
107 mutt_error _("Could not create temporary file!");
112 if (DisplayFilter && *DisplayFilter) {
115 /* mutt_endwin (NULL); */
116 filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL,
117 -1, fileno (fpfilterout), -1);
119 mutt_error (_("Cannot create display filter"));
120 safe_fclose (&fpfilterout);
126 if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
129 mutt_make_string (buf, sizeof (buf), NONULL (PagerFmt), Context, cur);
131 fputs ("\n\n", fpout);
134 res = mutt_copy_message (fpout, Context, cur, cmflags,
135 (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
136 CH_DECODE | CH_FROM);
137 if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1) {
138 mutt_error (_("Could not copy message"));
139 if (fpfilterout != NULL) {
140 mutt_wait_filter (filterpid);
141 safe_fclose (&fpfilterout);
143 mutt_unlink (tempfile);
147 if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
148 mutt_any_key_to_continue (NULL);
150 safe_fclose (&fpfilterout); /* XXX - check result? */
154 /* update crypto information for this message */
155 cur->security |= crypt_query (cur->content);
157 /* Remove color cache for this message, in case there
158 are color patterns for both ~g and ~V */
166 && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
167 if (cur->security & GOODSIGN) {
168 if (!crypt_smime_verify_sender (cur))
169 mutt_message (_("S/MIME signature successfully verified."));
171 mutt_error (_("S/MIME certificate owner does not match sender."));
173 else if (cur->security & PARTSIGN)
175 ("Warning: Part of this message has not been signed."));
176 else if (cur->security & SIGN || cur->security & BADSIGN)
177 mutt_error (_("S/MIME signature could NOT be verified."));
181 && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) {
182 if (cur->security & GOODSIGN)
183 mutt_message (_("PGP signature successfully verified."));
184 else if (cur->security & PARTSIGN)
186 ("Warning: Part of this message has not been signed."));
188 mutt_message (_("PGP signature could NOT be verified."));
191 /* Invoke the builtin pager */
192 memset (&info, 0, sizeof (pager_t));
195 rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
201 snprintf (buf, sizeof (buf), "%s %s", NONULL (Pager), tempfile);
202 if ((r = mutt_system (buf)) == -1)
203 mutt_error (_("Error running \"%s\"!"), buf);
205 keypad (stdscr, TRUE);
207 mutt_set_flag (Context, cur, M_READ, 1);
208 if (r != -1 && option (OPTPROMPTAFTER)) {
209 mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
210 rc = km_dokey (MENU_PAGER);
219 void ci_bounce_message (HEADER * h, int *redraw)
221 char prompt[SHORT_STRING];
222 char buf[HUGE_STRING] = { 0 };
228 strfcpy (prompt, _("Bounce message to: "), sizeof (prompt));
230 strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));
232 rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
234 if (option (OPTNEEDREDRAW)) {
235 unset_option (OPTNEEDREDRAW);
236 *redraw = REDRAW_FULL;
242 if (!(adr = rfc822_parse_adrlist (adr, buf))) {
243 mutt_error _("Error parsing address!");
248 adr = mutt_expand_aliases (adr);
250 if (mutt_addrlist_to_idna (adr, &err) < 0) {
251 mutt_error (_("Bad IDN: '%s'"), err);
253 rfc822_free_address (&adr);
258 rfc822_write_address (buf, sizeof (buf), adr, 1);
260 #define extra_space (15 + 7 + 2)
261 snprintf (prompt, sizeof (prompt),
262 (h ? _("Bounce message to %s") : _("Bounce messages to %s")),
265 if (mutt_strwidth (prompt) > COLS - extra_space) {
266 mutt_format_string (prompt, sizeof (prompt),
267 0, COLS - extra_space, 0, 0,
268 prompt, sizeof (prompt), 0);
269 safe_strcat (prompt, sizeof (prompt), "...?");
272 safe_strcat (prompt, sizeof (prompt), "?");
274 if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
275 rfc822_free_address (&adr);
276 CLEARLINE (LINES - 1);
277 mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
281 CLEARLINE (LINES - 1);
283 rc = mutt_bounce_message (NULL, h, adr);
284 rfc822_free_address (&adr);
285 /* If no error, or background, display message. */
286 if ((rc == 0) || (rc == S_BKG))
287 mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
290 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
293 *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
294 *chflags |= CH_DECODE | CH_REORDER;
296 if (option (OPTWEED)) {
298 *cmflags |= M_CM_WEED;
303 *cmflags |= M_CM_PRINTING;
307 static void pipe_msg (HEADER * h, FILE * fp, int decode, int print)
310 int chflags = CH_FROM;
312 pipe_set_flags (decode, print, &cmflags, &chflags);
314 if (WithCrypto && decode && h->security & ENCRYPT) {
315 if (!crypt_valid_passphrase (h->security))
321 mutt_parse_mime_message (Context, h);
323 mutt_copy_message (fp, Context, h, cmflags, chflags);
327 /* the following code is shared between printing and piping */
329 static int _mutt_pipe_message (HEADER * h, char *cmd,
330 int decode, int print, int split, char *sep)
337 /* mutt_endwin (NULL);
339 is this really needed here ?
340 it makes the screen flicker on pgp and s/mime messages,
341 before asking for a passphrase...
345 mutt_message_hook (Context, h, M_MESSAGEHOOK);
347 if (WithCrypto && decode) {
348 mutt_parse_mime_message (Context, h);
349 if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
354 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
355 mutt_perror _("Can't create filter process");
360 pipe_msg (h, fpout, decode, print);
362 rc = mutt_wait_filter (thepid);
364 else { /* handle tagged messages */
366 if (WithCrypto && decode) {
367 for (i = 0; i < Context->vcount; i++)
368 if (Context->hdrs[Context->v2r[i]]->tagged) {
369 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
371 mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
372 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
373 !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
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]],
385 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
386 mutt_perror _("Can't create filter process");
390 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
391 /* add the message separator */
394 safe_fclose (&fpout);
395 if (mutt_wait_filter (thepid) != 0)
402 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
403 mutt_perror _("Can't create filter process");
407 for (i = 0; i < Context->vcount; i++) {
408 if (Context->hdrs[Context->v2r[i]]->tagged) {
409 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
411 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
412 /* add the message separator */
417 safe_fclose (&fpout);
418 if (mutt_wait_filter (thepid) != 0)
423 if (rc || option (OPTWAITKEY))
424 mutt_any_key_to_continue (NULL);
428 void mutt_pipe_message (HEADER * h)
430 char buffer[LONG_STRING];
433 if (mutt_get_field (_("Pipe to command: "), buffer, sizeof (buffer), M_CMD)
437 mutt_expand_path (buffer, sizeof (buffer));
438 _mutt_pipe_message (h, buffer,
439 option (OPTPIPEDECODE),
440 0, option (OPTPIPESPLIT), PipeSep);
443 void mutt_print_message (HEADER * h)
446 if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd)) {
447 mutt_message (_("No printing command has been defined."));
451 if (query_quadoption (OPT_PRINT,
452 h ? _("Print message?") : _("Print tagged messages?"))
456 if (_mutt_pipe_message (h, PrintCmd,
457 option (OPTPRINTDECODE),
458 1, option (OPTPRINTSPLIT), "\f") == 0)
459 mutt_message (h ? _("Message printed") : _("Messages printed"));
461 mutt_message (h ? _("Message could not be printed") :
462 _("Messages could not be printed"));
466 int mutt_select_sort (int reverse)
468 int method = Sort; /* save the current method in case of abort */
470 switch (mutt_multi_choice (reverse ?
472 ("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?: ")
475 ("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
477 case -1: /* abort - don't resort */
489 Sort = SORT_RECEIVED;
500 case 6: /* (t)hread */
504 case 7: /* (u)nsort */
512 case 9: /* s(c)ore */
516 case 10: /* s(p)am */
521 Sort |= SORT_REVERSE;
523 return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
526 /* invoke a command in a subshell */
527 void mutt_shell_escape (void)
529 char buf[LONG_STRING];
532 if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
533 if (!buf[0] && Shell)
534 strfcpy (buf, Shell, sizeof (buf));
536 CLEARLINE (LINES - 1);
539 if (mutt_system (buf) != 0 || option (OPTWAITKEY))
540 mutt_any_key_to_continue (NULL);
545 /* enter a mutt command */
546 void mutt_enter_command (void)
549 char buffer[LONG_STRING], errbuf[SHORT_STRING];
553 if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0
557 err.dsize = sizeof (errbuf);
558 memset (&token, 0, sizeof (token));
559 r = mutt_parse_rc_line (buffer, &token, &err);
562 /* since errbuf could potentially contain printf() sequences in it,
563 we must call mutt_error() in this fashion so that vsprintf()
564 doesn't expect more arguments that we passed */
566 mutt_message ("%s", errbuf);
568 mutt_error ("%s", errbuf);
572 void mutt_display_address (ENVELOPE * env)
575 char buf[SHORT_STRING];
578 adr = mutt_get_address (env, &pfx);
584 * Note: We don't convert IDNA to local representation this time.
585 * That is intentional, so the user has an opportunity to copy &
586 * paste the on-the-wire form of the address to other, IDN-unable
591 rfc822_write_address (buf, sizeof (buf), adr, 0);
592 mutt_message ("%s: %s", pfx, buf);
595 static void set_copy_flags (HEADER * hdr, int decode, int decrypt,
596 int *cmflags, int *chflags)
599 *chflags = CH_UPDATE_LEN;
601 if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT)) {
602 if ((WithCrypto & APPLICATION_PGP)
603 && mutt_is_multipart_encrypted (hdr->content)) {
604 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
605 *cmflags = M_CM_DECODE_PGP;
607 else if ((WithCrypto & APPLICATION_PGP)
608 && mutt_is_application_pgp (hdr->content) & ENCRYPT)
610 else if ((WithCrypto & APPLICATION_SMIME)
611 && mutt_is_application_smime (hdr->content) & ENCRYPT) {
612 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
613 *cmflags = M_CM_DECODE_SMIME;
618 *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
619 *cmflags = M_CM_DECODE | M_CM_CHARCONV;
621 if (!decrypt) { /* If decode doesn't kick in for decrypt, */
622 *chflags |= CH_DECODE; /* then decode RFC 2047 headers, */
624 if (option (OPTWEED)) {
625 *chflags |= CH_WEED; /* and respect $weed. */
626 *cmflags |= M_CM_WEED;
632 void _mutt_save_message (HEADER * h, CONTEXT * ctx, int delete, int decode,
635 int cmflags, chflags;
637 set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
639 if (decode || decrypt)
640 mutt_parse_mime_message (Context, h);
642 if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0) {
644 mutt_set_flag (Context, h, M_DELETE, 1);
645 if (option (OPTDELETEUNTAG))
646 mutt_set_flag (Context, h, M_TAG, 0);
648 mutt_set_flag (Context, h, M_APPENDED, 1);
652 /* returns 0 if the copy/save was successful, or -1 on error/abort */
653 int mutt_save_message (HEADER * h, int delete,
654 int decode, int decrypt, int *redraw)
656 int i, need_buffy_cleanup;
657 int need_passphrase = 0, app = 0;
658 char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
671 snprintf (prompt, sizeof (prompt),
672 decode ? (delete ? _("Decode-save%s to mailbox") :
673 _("Decode-copy%s to mailbox")) :
674 (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
675 _("Decrypt-copy%s to mailbox")) :
676 (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
677 h ? "" : _(" tagged"));
682 need_passphrase = h->security & ENCRYPT;
685 mutt_message_hook (Context, h, M_MESSAGEHOOK);
686 mutt_default_save (buf, sizeof (buf), h);
689 /* look for the first tagged message */
691 for (i = 0; i < Context->vcount; i++) {
692 if (Context->hdrs[Context->v2r[i]]->tagged) {
693 h = Context->hdrs[Context->v2r[i]];
700 mutt_message_hook (Context, h, M_MESSAGEHOOK);
701 mutt_default_save (buf, sizeof (buf), h);
703 need_passphrase = h->security & ENCRYPT;
710 mutt_pretty_mailbox (buf);
711 if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
714 if (*redraw != REDRAW_FULL) {
716 *redraw = REDRAW_INDEX | REDRAW_STATUS;
718 *redraw = REDRAW_STATUS;
724 /* This is an undocumented feature of ELM pointed out to me by Felix von
725 * Leitner <leitner@prz.fu-berlin.de>
727 if (mutt_strcmp (buf, ".") == 0)
728 strfcpy (buf, LastSaveFolder, sizeof (buf));
730 strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
732 mutt_expand_path (buf, sizeof (buf));
734 /* check to make sure that this file is really the one the user wants */
735 if (mutt_save_confirm (buf, &st) != 0)
738 if (WithCrypto && need_passphrase && (decode || decrypt)
739 && !crypt_valid_passphrase (app))
742 mutt_message (_("Copying to %s..."), buf);
745 if (Context->magic == M_IMAP && !(decode || decrypt) && mx_is_imap (buf)) {
746 switch (imap_copy_messages (Context, h, buf, delete)) {
751 /* non-fatal error: fall through to fetch/append */
754 /* fatal error, abort */
761 if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL) {
763 _mutt_save_message (h, &ctx, delete, decode, decrypt);
765 for (i = 0; i < Context->vcount; i++) {
766 if (Context->hdrs[Context->v2r[i]]->tagged) {
767 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
769 _mutt_save_message (Context->hdrs[Context->v2r[i]], &ctx, delete,
775 need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
777 mx_close_mailbox (&ctx, NULL);
779 if (need_buffy_cleanup) {
781 tmp = mutt_find_mailbox (buf);
782 if (tmp && tmp->new <= 0)
783 mutt_update_mailbox (tmp);
785 /* fix up the times so buffy won't get confused */
786 if (st.st_mtime > st.st_atime) {
787 ut.actime = st.st_atime;
788 ut.modtime = time (NULL);
803 int mutt_update_list_file (char *filename, char *section, char *key,
808 char buf[HUGE_STRING];
809 char oldfile[_POSIX_PATH_MAX];
811 int ext = 0, done = 0, r = 0;
813 snprintf (oldfile, sizeof (oldfile), "%s.bak", filename);
814 dprint (1, (debugfile, "Renaming %s to %s\n", filename, oldfile));
816 /* if file not exist, create it */
817 if ((ifp = safe_fopen (filename, "a")))
819 if (_mutt_rename_file (filename, oldfile, 1)) {
820 mutt_perror _("Unable to create backup file");
824 dprint (1, (debugfile, "Opening %s\n", oldfile));
825 if (!(ifp = safe_fopen (oldfile, "r"))) {
826 mutt_perror _("Unable to open backup file for reading");
830 dprint (1, (debugfile, "Opening %s\n", filename));
831 if (!(ofp = safe_fopen (filename, "w"))) {
833 mutt_perror _("Unable to open new file for writing");
837 if (mx_lock_file (filename, fileno (ofp), 1, 0, 1)) {
840 mutt_error (_("Unable to lock %s, old file saved as %s"), filename,
846 while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) {
847 r = fputs (buf, ofp);
849 while (*c && *c != '\n')
851 c[0] = 0; /* strip EOL */
852 if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf + 3, section))
855 if (r != EOF && !done) {
856 snprintf (buf, sizeof (buf), "#: %s\n", section);
857 r = fputs (buf, ofp);
862 while (r != EOF && fgets (buf, sizeof (buf), ifp)) {
865 while (*c && (*c != '\r') && (*c != '\n'))
871 else if ((section && !strncmp (buf, "#: ", 3))) {
876 r = fputs (buf, ofp);
880 else if (key && !strncmp (buf, key, mutt_strlen (key)) &&
881 (!*key || buf[mutt_strlen (key)] == ' ')) {
884 while (*c && (*c != '\r') && (*c != '\n'))
890 r = fputs (line, ofp);
892 r = fputc ('\n', ofp);
897 r = fputs (buf, ofp);
901 while (r != EOF && fgets (buf, sizeof (buf), ifp))
902 r = fputs (buf, ofp);
904 /* If there wasn't a line to replace, put it on the end of the file */
905 if (r != EOF && !done && line) {
907 r = fputc ('\n', ofp);
909 mx_unlock_file (filename, fileno (ofp), 0);
917 mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
923 void mutt_version (void)
925 mutt_message ("Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate);
928 void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
930 char buf[LONG_STRING];
931 char obuf[LONG_STRING];
935 char charset[STRING];
938 short charset_changed = 0;
939 short type_changed = 0;
941 cp = mutt_get_parameter ("charset", b->parameter);
942 strfcpy (charset, NONULL (cp), sizeof (charset));
944 snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
945 strfcpy (obuf, buf, sizeof (obuf));
949 for (p = b->parameter; p; p = p->next) {
950 l = mutt_strlen (buf);
952 rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
953 snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
957 if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
961 /* clean up previous junk */
962 mutt_free_parameter (&b->parameter);
965 mutt_parse_content_type (buf, b);
968 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
969 type_changed = ascii_strcasecmp (tmp, obuf);
971 ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
973 /* if in send mode, check for conversion - current setting is default. */
975 if (!h && b->type == TYPETEXT && charset_changed) {
978 snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
979 mutt_get_parameter ("charset", b->parameter));
980 if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
981 b->noconv = (r == M_NO);
984 /* inform the user */
986 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
988 mutt_message (_("Content-Type changed to %s."), tmp);
989 if (b->type == TYPETEXT && charset_changed) {
992 mutt_message (_("Character set changed to %s; %s."),
993 mutt_get_parameter ("charset", b->parameter),
994 b->noconv ? _("not converting") : _("converting"));
997 b->force_charset |= charset_changed ? 1 : 0;
999 if (!is_multipart (b) && b->parts)
1000 mutt_free_body (&b->parts);
1001 if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
1002 b->hdr->content = NULL;
1003 mutt_free_header (&b->hdr);
1006 if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
1007 mutt_parse_part (fp, b);
1009 if (WithCrypto && h) {
1010 if (h->content == b)
1013 h->security |= crypt_query (b);
1018 static int _mutt_check_traditional_pgp (HEADER * h, int *redraw)
1023 h->security |= PGP_TRADITIONAL_CHECKED;
1025 mutt_parse_mime_message (Context, h);
1026 if ((msg = mx_open_message (Context, h->msgno)) == NULL)
1028 if (crypt_pgp_check_traditional (msg->fp, h->content, 0)) {
1029 h->security = crypt_query (h->content);
1030 *redraw |= REDRAW_FULL;
1034 h->security |= PGP_TRADITIONAL_CHECKED;
1035 mx_close_message (&msg);
1039 int mutt_check_traditional_pgp (HEADER * h, int *redraw)
1044 if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
1045 rv = _mutt_check_traditional_pgp (h, redraw);
1047 for (i = 0; i < Context->vcount; i++)
1048 if (Context->hdrs[Context->v2r[i]]->tagged &&
1049 !(Context->hdrs[Context->v2r[i]]->
1050 security & PGP_TRADITIONAL_CHECKED))
1052 _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)