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>
45 #include <sys/types.h>
48 extern char *ReleaseDate;
50 /* The folder the user last saved to. Used by ci_save_message() */
51 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
53 int mutt_display_message (HEADER * cur)
55 char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
56 int rc = 0, builtin = 0;
57 int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV;
59 FILE *fpfilterout = NULL;
63 snprintf (buf, sizeof (buf), "%s/%s", TYPE (cur->content),
64 cur->content->subtype);
66 mutt_parse_mime_message (Context, cur);
67 mutt_message_hook (Context, cur, M_MESSAGEHOOK);
69 /* see if crytpo is needed for this message. if so, we should exit curses */
70 if (WithCrypto && cur->security) {
71 if (cur->security & ENCRYPT) {
72 if (cur->security & APPLICATION_SMIME)
73 crypt_smime_getkeys (cur->env);
74 if (!crypt_valid_passphrase (cur->security))
77 cmflags |= M_CM_VERIFY;
79 else if (cur->security & SIGN) {
80 /* find out whether or not the verify signature */
81 if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) ==
83 cmflags |= M_CM_VERIFY;
88 if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT) {
89 if (cur->security & APPLICATION_PGP) {
91 crypt_pgp_invoke_getkeys (cur->env->from);
93 crypt_invoke_message (APPLICATION_PGP);
96 if (cur->security & APPLICATION_SMIME)
97 crypt_invoke_message (APPLICATION_SMIME);
101 mutt_mktemp (tempfile);
102 if ((fpout = safe_fopen (tempfile, "w")) == NULL) {
103 mutt_error _("Could not create temporary file!");
108 if (DisplayFilter && *DisplayFilter) {
111 /* mutt_endwin (NULL); */
112 filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL,
113 -1, fileno (fpfilterout), -1);
115 mutt_error (_("Cannot create display filter"));
116 safe_fclose (&fpfilterout);
122 if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
125 mutt_make_string (buf, sizeof (buf), NONULL (PagerFmt), Context, cur);
127 fputs ("\n\n", fpout);
130 res = mutt_copy_message (fpout, Context, cur, cmflags,
131 (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
132 CH_DECODE | CH_FROM);
133 if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1) {
134 mutt_error (_("Could not copy message"));
135 if (fpfilterout != NULL) {
136 mutt_wait_filter (filterpid);
137 safe_fclose (&fpfilterout);
139 mutt_unlink (tempfile);
143 if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
144 mutt_any_key_to_continue (NULL);
146 safe_fclose (&fpfilterout); /* XXX - check result? */
150 /* update crypto information for this message */
151 cur->security |= crypt_query (cur->content);
153 /* Remove color cache for this message, in case there
154 are color patterns for both ~g and ~V */
162 && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
163 if (cur->security & GOODSIGN) {
164 if (!crypt_smime_verify_sender (cur))
165 mutt_message (_("S/MIME signature successfully verified."));
167 mutt_error (_("S/MIME certificate owner does not match sender."));
169 else if (cur->security & PARTSIGN)
171 ("Warning: Part of this message has not been signed."));
172 else if (cur->security & SIGN || cur->security & BADSIGN)
173 mutt_error (_("S/MIME signature could NOT be verified."));
177 && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) {
178 if (cur->security & GOODSIGN)
179 mutt_message (_("PGP signature successfully verified."));
180 else if (cur->security & PARTSIGN)
182 ("Warning: Part of this message has not been signed."));
184 mutt_message (_("PGP signature could NOT be verified."));
187 /* Invoke the builtin pager */
188 memset (&info, 0, sizeof (pager_t));
191 rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
197 snprintf (buf, sizeof (buf), "%s %s", NONULL (Pager), tempfile);
198 if ((r = mutt_system (buf)) == -1)
199 mutt_error (_("Error running \"%s\"!"), buf);
201 keypad (stdscr, TRUE);
203 mutt_set_flag (Context, cur, M_READ, 1);
204 if (r != -1 && option (OPTPROMPTAFTER)) {
205 mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
206 rc = km_dokey (MENU_PAGER);
215 void ci_bounce_message (HEADER * h, int *redraw)
217 char prompt[SHORT_STRING];
218 char buf[HUGE_STRING] = { 0 };
224 strfcpy (prompt, _("Bounce message to: "), sizeof (prompt));
226 strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));
228 rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
230 if (option (OPTNEEDREDRAW)) {
231 unset_option (OPTNEEDREDRAW);
232 *redraw = REDRAW_FULL;
238 if (!(adr = rfc822_parse_adrlist (adr, buf))) {
239 mutt_error _("Error parsing address!");
244 adr = mutt_expand_aliases (adr);
246 if (mutt_addrlist_to_idna (adr, &err) < 0) {
247 mutt_error (_("Bad IDN: '%s'"), err);
249 rfc822_free_address (&adr);
254 rfc822_write_address (buf, sizeof (buf), adr, 1);
256 #define extra_space (15 + 7 + 2)
257 snprintf (prompt, sizeof (prompt),
258 (h ? _("Bounce message to %s") : _("Bounce messages to %s")),
261 if (mutt_strwidth (prompt) > COLS - extra_space) {
262 mutt_format_string (prompt, sizeof (prompt),
263 0, COLS - extra_space, 0, 0,
264 prompt, sizeof (prompt), 0);
265 safe_strcat (prompt, sizeof (prompt), "...?");
268 safe_strcat (prompt, sizeof (prompt), "?");
270 if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
271 rfc822_free_address (&adr);
272 CLEARLINE (LINES - 1);
273 mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
277 CLEARLINE (LINES - 1);
279 rc = mutt_bounce_message (NULL, h, adr);
280 rfc822_free_address (&adr);
281 /* If no error, or background, display message. */
282 if ((rc == 0) || (rc == S_BKG))
283 mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
286 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
289 *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
290 *chflags |= CH_DECODE | CH_REORDER;
292 if (option (OPTWEED)) {
294 *cmflags |= M_CM_WEED;
299 *cmflags |= M_CM_PRINTING;
303 static void pipe_msg (HEADER * h, FILE * fp, int decode, int print)
306 int chflags = CH_FROM;
308 pipe_set_flags (decode, print, &cmflags, &chflags);
310 if (WithCrypto && decode && h->security & ENCRYPT) {
311 if (!crypt_valid_passphrase (h->security))
317 mutt_parse_mime_message (Context, h);
319 mutt_copy_message (fp, Context, h, cmflags, chflags);
323 /* the following code is shared between printing and piping */
325 static int _mutt_pipe_message (HEADER * h, char *cmd,
326 int decode, int print, int split, char *sep)
333 /* mutt_endwin (NULL);
335 is this really needed here ?
336 it makes the screen flicker on pgp and s/mime messages,
337 before asking for a passphrase...
341 mutt_message_hook (Context, h, M_MESSAGEHOOK);
343 if (WithCrypto && decode) {
344 mutt_parse_mime_message (Context, h);
345 if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
350 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
351 mutt_perror _("Can't create filter process");
356 pipe_msg (h, fpout, decode, print);
358 rc = mutt_wait_filter (thepid);
360 else { /* handle tagged messages */
362 if (WithCrypto && decode) {
363 for (i = 0; i < Context->vcount; i++)
364 if (Context->hdrs[Context->v2r[i]]->tagged) {
365 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
367 mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
368 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
369 !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
376 for (i = 0; i < Context->vcount; i++) {
377 if (Context->hdrs[Context->v2r[i]]->tagged) {
378 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
381 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
382 mutt_perror _("Can't create filter process");
386 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
387 /* add the message separator */
390 safe_fclose (&fpout);
391 if (mutt_wait_filter (thepid) != 0)
398 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
399 mutt_perror _("Can't create filter process");
403 for (i = 0; i < Context->vcount; i++) {
404 if (Context->hdrs[Context->v2r[i]]->tagged) {
405 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
407 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
408 /* add the message separator */
413 safe_fclose (&fpout);
414 if (mutt_wait_filter (thepid) != 0)
419 if (rc || option (OPTWAITKEY))
420 mutt_any_key_to_continue (NULL);
424 void mutt_pipe_message (HEADER * h)
426 char buffer[LONG_STRING];
429 if (mutt_get_field (_("Pipe to command: "), buffer, sizeof (buffer), M_CMD)
433 mutt_expand_path (buffer, sizeof (buffer));
434 _mutt_pipe_message (h, buffer,
435 option (OPTPIPEDECODE),
436 0, option (OPTPIPESPLIT), PipeSep);
439 void mutt_print_message (HEADER * h)
442 if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd)) {
443 mutt_message (_("No printing command has been defined."));
447 if (query_quadoption (OPT_PRINT,
448 h ? _("Print message?") : _("Print tagged messages?"))
452 if (_mutt_pipe_message (h, PrintCmd,
453 option (OPTPRINTDECODE),
454 1, option (OPTPRINTSPLIT), "\f") == 0)
455 mutt_message (h ? _("Message printed") : _("Messages printed"));
457 mutt_message (h ? _("Message could not be printed") :
458 _("Messages could not be printed"));
462 int mutt_select_sort (int reverse)
464 int method = Sort; /* save the current method in case of abort */
466 switch (mutt_multi_choice (reverse ?
468 ("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?: ")
471 ("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
473 case -1: /* abort - don't resort */
485 Sort = SORT_RECEIVED;
496 case 6: /* (t)hread */
500 case 7: /* (u)nsort */
508 case 9: /* s(c)ore */
512 case 10: /* s(p)am */
517 Sort |= SORT_REVERSE;
519 return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
522 /* invoke a command in a subshell */
523 void mutt_shell_escape (void)
525 char buf[LONG_STRING];
528 if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
529 if (!buf[0] && Shell)
530 strfcpy (buf, Shell, sizeof (buf));
532 CLEARLINE (LINES - 1);
535 if (mutt_system (buf) != 0 || option (OPTWAITKEY))
536 mutt_any_key_to_continue (NULL);
541 /* enter a mutt command */
542 void mutt_enter_command (void)
545 char buffer[LONG_STRING], errbuf[SHORT_STRING];
549 if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0
553 err.dsize = sizeof (errbuf);
554 memset (&token, 0, sizeof (token));
555 r = mutt_parse_rc_line (buffer, &token, &err);
558 /* since errbuf could potentially contain printf() sequences in it,
559 we must call mutt_error() in this fashion so that vsprintf()
560 doesn't expect more arguments that we passed */
562 mutt_message ("%s", errbuf);
564 mutt_error ("%s", errbuf);
568 void mutt_display_address (ENVELOPE * env)
571 char buf[SHORT_STRING];
574 adr = mutt_get_address (env, &pfx);
580 * Note: We don't convert IDNA to local representation this time.
581 * That is intentional, so the user has an opportunity to copy &
582 * paste the on-the-wire form of the address to other, IDN-unable
587 rfc822_write_address (buf, sizeof (buf), adr, 0);
588 mutt_message ("%s: %s", pfx, buf);
591 static void set_copy_flags (HEADER * hdr, int decode, int decrypt,
592 int *cmflags, int *chflags)
595 *chflags = CH_UPDATE_LEN;
597 if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT)) {
598 if ((WithCrypto & APPLICATION_PGP)
599 && mutt_is_multipart_encrypted (hdr->content)) {
600 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
601 *cmflags = M_CM_DECODE_PGP;
603 else if ((WithCrypto & APPLICATION_PGP)
604 && mutt_is_application_pgp (hdr->content) & ENCRYPT)
606 else if ((WithCrypto & APPLICATION_SMIME)
607 && mutt_is_application_smime (hdr->content) & ENCRYPT) {
608 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
609 *cmflags = M_CM_DECODE_SMIME;
614 *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
615 *cmflags = M_CM_DECODE | M_CM_CHARCONV;
617 if (!decrypt) { /* If decode doesn't kick in for decrypt, */
618 *chflags |= CH_DECODE; /* then decode RFC 2047 headers, */
620 if (option (OPTWEED)) {
621 *chflags |= CH_WEED; /* and respect $weed. */
622 *cmflags |= M_CM_WEED;
628 void _mutt_save_message (HEADER * h, CONTEXT * ctx, int delete, int decode,
631 int cmflags, chflags;
633 set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
635 if (decode || decrypt)
636 mutt_parse_mime_message (Context, h);
638 if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0) {
640 mutt_set_flag (Context, h, M_DELETE, 1);
641 if (option (OPTDELETEUNTAG))
642 mutt_set_flag (Context, h, M_TAG, 0);
644 mutt_set_flag (Context, h, M_APPENDED, 1);
648 /* returns 0 if the copy/save was successful, or -1 on error/abort */
649 int mutt_save_message (HEADER * h, int delete,
650 int decode, int decrypt, int *redraw)
652 int i, need_buffy_cleanup;
653 int need_passphrase = 0, app = 0;
654 char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
667 snprintf (prompt, sizeof (prompt),
668 decode ? (delete ? _("Decode-save%s to mailbox") :
669 _("Decode-copy%s to mailbox")) :
670 (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
671 _("Decrypt-copy%s to mailbox")) :
672 (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
673 h ? "" : _(" tagged"));
678 need_passphrase = h->security & ENCRYPT;
681 mutt_message_hook (Context, h, M_MESSAGEHOOK);
682 mutt_default_save (buf, sizeof (buf), h);
685 /* look for the first tagged message */
687 for (i = 0; i < Context->vcount; i++) {
688 if (Context->hdrs[Context->v2r[i]]->tagged) {
689 h = Context->hdrs[Context->v2r[i]];
696 mutt_message_hook (Context, h, M_MESSAGEHOOK);
697 mutt_default_save (buf, sizeof (buf), h);
699 need_passphrase = h->security & ENCRYPT;
706 mutt_pretty_mailbox (buf);
707 if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
710 if (*redraw != REDRAW_FULL) {
712 *redraw = REDRAW_INDEX | REDRAW_STATUS;
714 *redraw = REDRAW_STATUS;
720 /* This is an undocumented feature of ELM pointed out to me by Felix von
721 * Leitner <leitner@prz.fu-berlin.de>
723 if (mutt_strcmp (buf, ".") == 0)
724 strfcpy (buf, LastSaveFolder, sizeof (buf));
726 strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
728 mutt_expand_path (buf, sizeof (buf));
730 /* check to make sure that this file is really the one the user wants */
731 if (mutt_save_confirm (buf, &st) != 0)
734 if (WithCrypto && need_passphrase && (decode || decrypt)
735 && !crypt_valid_passphrase (app))
738 mutt_message (_("Copying to %s..."), buf);
741 if (Context->magic == M_IMAP && !(decode || decrypt) && mx_is_imap (buf)) {
742 switch (imap_copy_messages (Context, h, buf, delete)) {
747 /* non-fatal error: fall through to fetch/append */
750 /* fatal error, abort */
757 if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL) {
759 _mutt_save_message (h, &ctx, delete, decode, decrypt);
761 for (i = 0; i < Context->vcount; i++) {
762 if (Context->hdrs[Context->v2r[i]]->tagged) {
763 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
765 _mutt_save_message (Context->hdrs[Context->v2r[i]], &ctx, delete,
771 need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
773 mx_close_mailbox (&ctx, NULL);
775 if (need_buffy_cleanup) {
777 tmp = mutt_find_mailbox (buf);
778 if (tmp && tmp->new <= 0)
779 mutt_update_mailbox (tmp);
781 /* fix up the times so buffy won't get confused */
782 if (st.st_mtime > st.st_atime) {
783 ut.actime = st.st_atime;
784 ut.modtime = time (NULL);
799 int mutt_update_list_file (char *filename, char *section, char *key,
804 char buf[HUGE_STRING];
805 char oldfile[_POSIX_PATH_MAX];
807 int ext = 0, done = 0, r = 0;
809 snprintf (oldfile, sizeof (oldfile), "%s.bak", filename);
810 dprint (1, (debugfile, "Renaming %s to %s\n", filename, oldfile));
812 /* if file not exist, create it */
813 if ((ifp = safe_fopen (filename, "a")))
815 if (_mutt_rename_file (filename, oldfile, 1)) {
816 mutt_perror _("Unable to create backup file");
820 dprint (1, (debugfile, "Opening %s\n", oldfile));
821 if (!(ifp = safe_fopen (oldfile, "r"))) {
822 mutt_perror _("Unable to open backup file for reading");
826 dprint (1, (debugfile, "Opening %s\n", filename));
827 if (!(ofp = safe_fopen (filename, "w"))) {
829 mutt_perror _("Unable to open new file for writing");
833 if (mx_lock_file (filename, fileno (ofp), 1, 0, 1)) {
836 mutt_error (_("Unable to lock %s, old file saved as %s"), filename,
842 while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) {
843 r = fputs (buf, ofp);
845 while (*c && *c != '\n')
847 c[0] = 0; /* strip EOL */
848 if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf + 3, section))
851 if (r != EOF && !done) {
852 snprintf (buf, sizeof (buf), "#: %s\n", section);
853 r = fputs (buf, ofp);
858 while (r != EOF && fgets (buf, sizeof (buf), ifp)) {
861 while (*c && (*c != '\r') && (*c != '\n'))
867 else if ((section && !strncmp (buf, "#: ", 3))) {
872 r = fputs (buf, ofp);
876 else if (key && !strncmp (buf, key, mutt_strlen (key)) &&
877 (!*key || buf[mutt_strlen (key)] == ' ')) {
880 while (*c && (*c != '\r') && (*c != '\n'))
886 r = fputs (line, ofp);
888 r = fputc ('\n', ofp);
893 r = fputs (buf, ofp);
897 while (r != EOF && fgets (buf, sizeof (buf), ifp))
898 r = fputs (buf, ofp);
900 /* If there wasn't a line to replace, put it on the end of the file */
901 if (r != EOF && !done && line) {
903 r = fputc ('\n', ofp);
905 mx_unlock_file (filename, fileno (ofp), 0);
913 mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
919 void mutt_version (void)
921 mutt_message ("Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate);
924 void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
926 char buf[LONG_STRING];
927 char obuf[LONG_STRING];
931 char charset[STRING];
934 short charset_changed = 0;
935 short type_changed = 0;
937 cp = mutt_get_parameter ("charset", b->parameter);
938 strfcpy (charset, NONULL (cp), sizeof (charset));
940 snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
941 strfcpy (obuf, buf, sizeof (obuf));
945 for (p = b->parameter; p; p = p->next) {
946 l = mutt_strlen (buf);
948 rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
949 snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
953 if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
957 /* clean up previous junk */
958 mutt_free_parameter (&b->parameter);
961 mutt_parse_content_type (buf, b);
964 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
965 type_changed = ascii_strcasecmp (tmp, obuf);
967 ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
969 /* if in send mode, check for conversion - current setting is default. */
971 if (!h && b->type == TYPETEXT && charset_changed) {
974 snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
975 mutt_get_parameter ("charset", b->parameter));
976 if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
977 b->noconv = (r == M_NO);
980 /* inform the user */
982 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
984 mutt_message (_("Content-Type changed to %s."), tmp);
985 if (b->type == TYPETEXT && charset_changed) {
988 mutt_message (_("Character set changed to %s; %s."),
989 mutt_get_parameter ("charset", b->parameter),
990 b->noconv ? _("not converting") : _("converting"));
993 b->force_charset |= charset_changed ? 1 : 0;
995 if (!is_multipart (b) && b->parts)
996 mutt_free_body (&b->parts);
997 if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
998 b->hdr->content = NULL;
999 mutt_free_header (&b->hdr);
1002 if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
1003 mutt_parse_part (fp, b);
1005 if (WithCrypto && h) {
1006 if (h->content == b)
1009 h->security |= crypt_query (b);
1014 static int _mutt_check_traditional_pgp (HEADER * h, int *redraw)
1019 h->security |= PGP_TRADITIONAL_CHECKED;
1021 mutt_parse_mime_message (Context, h);
1022 if ((msg = mx_open_message (Context, h->msgno)) == NULL)
1024 if (crypt_pgp_check_traditional (msg->fp, h->content, 0)) {
1025 h->security = crypt_query (h->content);
1026 *redraw |= REDRAW_FULL;
1030 h->security |= PGP_TRADITIONAL_CHECKED;
1031 mx_close_message (&msg);
1035 int mutt_check_traditional_pgp (HEADER * h, int *redraw)
1040 if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
1041 rv = _mutt_check_traditional_pgp (h, redraw);
1043 for (i = 0; i < Context->vcount; i++)
1044 if (Context->hdrs[Context->v2r[i]]->tagged &&
1045 !(Context->hdrs[Context->v2r[i]]->
1046 security & PGP_TRADITIONAL_CHECKED))
1048 _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)