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>
48 #include <sys/types.h>
51 extern char *ReleaseDate;
53 /* The folder the user last saved to. Used by ci_save_message() */
54 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
56 int mutt_display_message (HEADER * cur)
58 char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
59 int rc = 0, builtin = 0;
60 int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV;
62 FILE *fpfilterout = NULL;
66 snprintf (buf, sizeof (buf), "%s/%s", TYPE (cur->content),
67 cur->content->subtype);
69 mutt_parse_mime_message (Context, cur);
70 mutt_message_hook (Context, cur, M_MESSAGEHOOK);
72 /* see if crytpo is needed for this message. if so, we should exit curses */
73 if (WithCrypto && cur->security) {
74 if (cur->security & ENCRYPT) {
75 if (cur->security & APPLICATION_SMIME)
76 crypt_smime_getkeys (cur->env);
77 if (!crypt_valid_passphrase (cur->security))
80 cmflags |= M_CM_VERIFY;
82 else if (cur->security & SIGN) {
83 /* find out whether or not the verify signature */
84 if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) ==
86 cmflags |= M_CM_VERIFY;
91 if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT) {
92 if (cur->security & APPLICATION_PGP) {
94 crypt_pgp_invoke_getkeys (cur->env->from);
96 crypt_invoke_message (APPLICATION_PGP);
99 if (cur->security & APPLICATION_SMIME)
100 crypt_invoke_message (APPLICATION_SMIME);
104 mutt_mktemp (tempfile);
105 if ((fpout = safe_fopen (tempfile, "w")) == NULL) {
106 mutt_error _("Could not create temporary file!");
111 if (DisplayFilter && *DisplayFilter) {
114 /* mutt_endwin (NULL); */
115 filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL,
116 -1, fileno (fpfilterout), -1);
118 mutt_error (_("Cannot create display filter"));
119 safe_fclose (&fpfilterout);
125 if (!Pager || safe_strcmp (Pager, "builtin") == 0)
128 mutt_make_string (buf, sizeof (buf), NONULL (PagerFmt), Context, cur);
130 fputs ("\n\n", fpout);
133 res = mutt_copy_message (fpout, Context, cur, cmflags,
134 (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
135 CH_DECODE | CH_FROM);
136 if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1) {
137 mutt_error (_("Could not copy message"));
138 if (fpfilterout != NULL) {
139 mutt_wait_filter (filterpid);
140 safe_fclose (&fpfilterout);
142 mutt_unlink (tempfile);
146 if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
147 mutt_any_key_to_continue (NULL);
149 safe_fclose (&fpfilterout); /* XXX - check result? */
153 /* update crypto information for this message */
154 cur->security |= crypt_query (cur->content);
156 /* Remove color cache for this message, in case there
157 are color patterns for both ~g and ~V */
165 && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
166 if (cur->security & GOODSIGN) {
167 if (!crypt_smime_verify_sender (cur))
168 mutt_message (_("S/MIME signature successfully verified."));
170 mutt_error (_("S/MIME certificate owner does not match sender."));
172 else if (cur->security & PARTSIGN)
174 ("Warning: Part of this message has not been signed."));
175 else if (cur->security & SIGN || cur->security & BADSIGN)
176 mutt_error (_("S/MIME signature could NOT be verified."));
180 && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) {
181 if (cur->security & GOODSIGN)
182 mutt_message (_("PGP signature successfully verified."));
183 else if (cur->security & PARTSIGN)
185 ("Warning: Part of this message has not been signed."));
187 mutt_message (_("PGP signature could NOT be verified."));
190 /* Invoke the builtin pager */
191 memset (&info, 0, sizeof (pager_t));
194 rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
200 snprintf (buf, sizeof (buf), "%s %s", NONULL (Pager), tempfile);
201 if ((r = mutt_system (buf)) == -1)
202 mutt_error (_("Error running \"%s\"!"), buf);
204 keypad (stdscr, TRUE);
206 mutt_set_flag (Context, cur, M_READ, 1);
207 if (r != -1 && option (OPTPROMPTAFTER)) {
208 mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
209 rc = km_dokey (MENU_PAGER);
218 void ci_bounce_message (HEADER * h, int *redraw)
220 char prompt[SHORT_STRING];
221 char buf[HUGE_STRING] = { 0 };
227 strfcpy (prompt, _("Bounce message to: "), sizeof (prompt));
229 strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));
231 rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
233 if (option (OPTNEEDREDRAW)) {
234 unset_option (OPTNEEDREDRAW);
235 *redraw = REDRAW_FULL;
241 if (!(adr = rfc822_parse_adrlist (adr, buf))) {
242 mutt_error _("Error parsing address!");
247 adr = mutt_expand_aliases (adr);
249 if (mutt_addrlist_to_idna (adr, &err) < 0) {
250 mutt_error (_("Bad IDN: '%s'"), err);
252 rfc822_free_address (&adr);
257 rfc822_write_address (buf, sizeof (buf), adr, 1);
259 #define extra_space (15 + 7 + 2)
260 snprintf (prompt, sizeof (prompt),
261 (h ? _("Bounce message to %s") : _("Bounce messages to %s")),
264 if (mutt_strwidth (prompt) > COLS - extra_space) {
265 mutt_format_string (prompt, sizeof (prompt),
266 0, COLS - extra_space, 0, 0,
267 prompt, sizeof (prompt), 0);
268 safe_strcat (prompt, sizeof (prompt), "...?");
271 safe_strcat (prompt, sizeof (prompt), "?");
273 if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
274 rfc822_free_address (&adr);
275 CLEARLINE (LINES - 1);
276 mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
280 CLEARLINE (LINES - 1);
282 rc = mutt_bounce_message (NULL, h, adr);
283 rfc822_free_address (&adr);
284 /* If no error, or background, display message. */
285 if ((rc == 0) || (rc == S_BKG))
286 mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
289 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
292 *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
293 *chflags |= CH_DECODE | CH_REORDER;
295 if (option (OPTWEED)) {
297 *cmflags |= M_CM_WEED;
302 *cmflags |= M_CM_PRINTING;
306 static void pipe_msg (HEADER * h, FILE * fp, int decode, int print)
309 int chflags = CH_FROM;
311 pipe_set_flags (decode, print, &cmflags, &chflags);
313 if (WithCrypto && decode && h->security & ENCRYPT) {
314 if (!crypt_valid_passphrase (h->security))
320 mutt_parse_mime_message (Context, h);
322 mutt_copy_message (fp, Context, h, cmflags, chflags);
326 /* the following code is shared between printing and piping */
328 static int _mutt_pipe_message (HEADER * h, char *cmd,
329 int decode, int print, int split, char *sep)
336 /* mutt_endwin (NULL);
338 is this really needed here ?
339 it makes the screen flicker on pgp and s/mime messages,
340 before asking for a passphrase...
344 mutt_message_hook (Context, h, M_MESSAGEHOOK);
346 if (WithCrypto && decode) {
347 mutt_parse_mime_message (Context, h);
348 if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
353 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
354 mutt_perror (_("Can't create filter process"));
359 pipe_msg (h, fpout, decode, print);
361 rc = mutt_wait_filter (thepid);
363 else { /* handle tagged messages */
365 if (WithCrypto && decode) {
366 for (i = 0; i < Context->vcount; i++)
367 if (Context->hdrs[Context->v2r[i]]->tagged) {
368 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
370 mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
371 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
372 !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
379 for (i = 0; i < Context->vcount; i++) {
380 if (Context->hdrs[Context->v2r[i]]->tagged) {
381 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
384 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
385 mutt_perror (_("Can't create filter process"));
389 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
390 /* add the message separator */
393 safe_fclose (&fpout);
394 if (mutt_wait_filter (thepid) != 0)
401 if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
402 mutt_perror (_("Can't create filter process"));
406 for (i = 0; i < Context->vcount; i++) {
407 if (Context->hdrs[Context->v2r[i]]->tagged) {
408 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
410 pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
411 /* add the message separator */
416 safe_fclose (&fpout);
417 if (mutt_wait_filter (thepid) != 0)
422 if (rc || option (OPTWAITKEY))
423 mutt_any_key_to_continue (NULL);
427 void mutt_pipe_message (HEADER * h)
429 char buffer[LONG_STRING];
432 if (mutt_get_field (_("Pipe to command: "), buffer, sizeof (buffer), M_CMD)
436 mutt_expand_path (buffer, sizeof (buffer));
437 _mutt_pipe_message (h, buffer,
438 option (OPTPIPEDECODE),
439 0, option (OPTPIPESPLIT), PipeSep);
442 void mutt_print_message (HEADER * h)
445 if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd)) {
446 mutt_message (_("No printing command has been defined."));
450 if (query_quadoption (OPT_PRINT,
451 h ? _("Print message?") : _("Print tagged messages?"))
455 if (_mutt_pipe_message (h, PrintCmd,
456 option (OPTPRINTDECODE),
457 1, option (OPTPRINTSPLIT), "\f") == 0)
458 mutt_message (h ? _("Message printed") : _("Messages printed"));
460 mutt_message (h ? _("Message could not be printed") :
461 _("Messages could not be printed"));
465 int mutt_select_sort (int reverse)
467 int method = Sort; /* save the current method in case of abort */
469 switch (mutt_multi_choice (reverse ?
471 ("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?: ")
474 ("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
476 case -1: /* abort - don't resort */
488 Sort = SORT_RECEIVED;
499 case 6: /* (t)hread */
503 case 7: /* (u)nsort */
511 case 9: /* s(c)ore */
515 case 10: /* s(p)am */
520 Sort |= SORT_REVERSE;
522 return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
525 /* invoke a command in a subshell */
526 void mutt_shell_escape (void)
528 char buf[LONG_STRING];
531 if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
532 if (!buf[0] && Shell)
533 strfcpy (buf, Shell, sizeof (buf));
535 CLEARLINE (LINES - 1);
538 if (mutt_system (buf) != 0 || option (OPTWAITKEY))
539 mutt_any_key_to_continue (NULL);
544 /* enter a mutt command */
545 void mutt_enter_command (void)
548 char buffer[LONG_STRING], errbuf[SHORT_STRING];
552 if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0
556 err.dsize = sizeof (errbuf);
557 memset (&token, 0, sizeof (token));
558 r = mutt_parse_rc_line (buffer, &token, &err);
561 /* since errbuf could potentially contain printf() sequences in it,
562 we must call mutt_error() in this fashion so that vsprintf()
563 doesn't expect more arguments that we passed */
565 mutt_message ("%s", errbuf);
567 mutt_error ("%s", errbuf);
571 void mutt_display_address (ENVELOPE * env)
574 char buf[SHORT_STRING];
577 adr = mutt_get_address (env, &pfx);
583 * Note: We don't convert IDNA to local representation this time.
584 * That is intentional, so the user has an opportunity to copy &
585 * paste the on-the-wire form of the address to other, IDN-unable
590 rfc822_write_address (buf, sizeof (buf), adr, 0);
591 mutt_message ("%s: %s", pfx, buf);
594 static void set_copy_flags (HEADER * hdr, int decode, int decrypt,
595 int *cmflags, int *chflags)
598 *chflags = CH_UPDATE_LEN;
600 if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT)) {
601 if ((WithCrypto & APPLICATION_PGP)
602 && mutt_is_multipart_encrypted (hdr->content)) {
603 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
604 *cmflags = M_CM_DECODE_PGP;
606 else if ((WithCrypto & APPLICATION_PGP)
607 && mutt_is_application_pgp (hdr->content) & ENCRYPT)
609 else if ((WithCrypto & APPLICATION_SMIME)
610 && mutt_is_application_smime (hdr->content) & ENCRYPT) {
611 *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
612 *cmflags = M_CM_DECODE_SMIME;
617 *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
618 *cmflags = M_CM_DECODE | M_CM_CHARCONV;
620 if (!decrypt) { /* If decode doesn't kick in for decrypt, */
621 *chflags |= CH_DECODE; /* then decode RFC 2047 headers, */
623 if (option (OPTWEED)) {
624 *chflags |= CH_WEED; /* and respect $weed. */
625 *cmflags |= M_CM_WEED;
631 void _mutt_save_message (HEADER * h, CONTEXT * ctx, int delete, int decode,
634 int cmflags, chflags;
636 set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
638 if (decode || decrypt)
639 mutt_parse_mime_message (Context, h);
641 if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0) {
643 mutt_set_flag (Context, h, M_DELETE, 1);
644 if (option (OPTDELETEUNTAG))
645 mutt_set_flag (Context, h, M_TAG, 0);
647 mutt_set_flag (Context, h, M_APPENDED, 1);
651 /* returns 0 if the copy/save was successful, or -1 on error/abort */
652 int mutt_save_message (HEADER * h, int delete,
653 int decode, int decrypt, int *redraw)
655 int i, need_buffy_cleanup;
656 int need_passphrase = 0, app = 0;
657 char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
670 snprintf (prompt, sizeof (prompt),
671 decode ? (delete ? _("Decode-save%s to mailbox") :
672 _("Decode-copy%s to mailbox")) :
673 (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
674 _("Decrypt-copy%s to mailbox")) :
675 (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
676 h ? "" : _(" tagged"));
681 need_passphrase = h->security & ENCRYPT;
684 mutt_message_hook (Context, h, M_MESSAGEHOOK);
685 mutt_default_save (buf, sizeof (buf), h);
688 /* look for the first tagged message */
690 for (i = 0; i < Context->vcount; i++) {
691 if (Context->hdrs[Context->v2r[i]]->tagged) {
692 h = Context->hdrs[Context->v2r[i]];
699 mutt_message_hook (Context, h, M_MESSAGEHOOK);
700 mutt_default_save (buf, sizeof (buf), h);
702 need_passphrase = h->security & ENCRYPT;
709 mutt_pretty_mailbox (buf);
710 if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
713 if (*redraw != REDRAW_FULL) {
715 *redraw = REDRAW_INDEX | REDRAW_STATUS;
717 *redraw = REDRAW_STATUS;
723 /* This is an undocumented feature of ELM pointed out to me by Felix von
724 * Leitner <leitner@prz.fu-berlin.de>
726 if (safe_strcmp (buf, ".") == 0)
727 strfcpy (buf, LastSaveFolder, sizeof (buf));
729 strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
731 mutt_expand_path (buf, sizeof (buf));
733 /* check to make sure that this file is really the one the user wants */
734 if (mutt_save_confirm (buf, &st) != 0)
737 if (WithCrypto && need_passphrase && (decode || decrypt)
738 && !crypt_valid_passphrase (app))
741 mutt_message (_("Copying to %s..."), buf);
744 if (Context->magic == M_IMAP && !(decode || decrypt) && mx_get_magic (buf) == M_IMAP) {
745 switch (imap_copy_messages (Context, h, buf, delete)) {
750 /* non-fatal error: fall through to fetch/append */
753 /* fatal error, abort */
760 if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL) {
762 _mutt_save_message (h, &ctx, delete, decode, decrypt);
764 for (i = 0; i < Context->vcount; i++) {
765 if (Context->hdrs[Context->v2r[i]]->tagged) {
766 mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
768 _mutt_save_message (Context->hdrs[Context->v2r[i]], &ctx, delete,
774 need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
776 mx_close_mailbox (&ctx, NULL);
778 if (need_buffy_cleanup) {
780 tmp = mutt_find_mailbox (buf);
781 if (tmp && tmp->new <= 0)
782 mutt_update_mailbox (tmp);
784 /* fix up the times so buffy won't get confused */
785 if (st.st_mtime > st.st_atime) {
786 ut.actime = st.st_atime;
787 ut.modtime = time (NULL);
802 int mutt_update_list_file (char *filename, char *section, char *key,
807 char buf[HUGE_STRING];
808 char oldfile[_POSIX_PATH_MAX];
810 int ext = 0, done = 0, r = 0;
812 snprintf (oldfile, sizeof (oldfile), "%s.bak", filename);
813 dprint (1, (debugfile, "Renaming %s to %s\n", filename, oldfile));
815 /* if file not exist, create it */
816 if ((ifp = safe_fopen (filename, "a")))
818 if (_mutt_rename_file (filename, oldfile, 1)) {
819 mutt_perror (_("Unable to create backup file"));
823 dprint (1, (debugfile, "Opening %s\n", oldfile));
824 if (!(ifp = safe_fopen (oldfile, "r"))) {
825 mutt_perror (_("Unable to open backup file for reading"));
829 dprint (1, (debugfile, "Opening %s\n", filename));
830 if (!(ofp = safe_fopen (filename, "w"))) {
832 mutt_perror (_("Unable to open new file for writing"));
836 if (mx_lock_file (filename, fileno (ofp), 1, 0, 1)) {
839 mutt_error (_("Unable to lock %s, old file saved as %s"), filename,
845 while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) {
846 r = fputs (buf, ofp);
848 while (*c && *c != '\n')
850 c[0] = 0; /* strip EOL */
851 if (!strncmp (buf, "#: ", 3) && !safe_strcasecmp (buf + 3, section))
854 if (r != EOF && !done) {
855 snprintf (buf, sizeof (buf), "#: %s\n", section);
856 r = fputs (buf, ofp);
861 while (r != EOF && fgets (buf, sizeof (buf), ifp)) {
864 while (*c && (*c != '\r') && (*c != '\n'))
870 else if ((section && !strncmp (buf, "#: ", 3))) {
875 r = fputs (buf, ofp);
879 else if (key && !strncmp (buf, key, safe_strlen (key)) &&
880 (!*key || buf[safe_strlen (key)] == ' ')) {
883 while (*c && (*c != '\r') && (*c != '\n'))
889 r = fputs (line, ofp);
891 r = fputc ('\n', ofp);
896 r = fputs (buf, ofp);
900 while (r != EOF && fgets (buf, sizeof (buf), ifp))
901 r = fputs (buf, ofp);
903 /* If there wasn't a line to replace, put it on the end of the file */
904 if (r != EOF && !done && line) {
906 r = fputc ('\n', ofp);
908 mx_unlock_file (filename, fileno (ofp), 0);
916 mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
922 void mutt_version (void)
924 mutt_message ("Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate);
927 void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
929 char buf[LONG_STRING];
930 char obuf[LONG_STRING];
934 char charset[STRING];
937 short charset_changed = 0;
938 short type_changed = 0;
940 cp = mutt_get_parameter ("charset", b->parameter);
941 strfcpy (charset, NONULL (cp), sizeof (charset));
943 snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
944 strfcpy (obuf, buf, sizeof (obuf));
948 for (p = b->parameter; p; p = p->next) {
949 l = safe_strlen (buf);
951 rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
952 snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
956 if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
960 /* clean up previous junk */
961 mutt_free_parameter (&b->parameter);
964 mutt_parse_content_type (buf, b);
967 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
968 type_changed = ascii_strcasecmp (tmp, obuf);
970 ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
972 /* if in send mode, check for conversion - current setting is default. */
974 if (!h && b->type == TYPETEXT && charset_changed) {
977 snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
978 mutt_get_parameter ("charset", b->parameter));
979 if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
980 b->noconv = (r == M_NO);
983 /* inform the user */
985 snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
987 mutt_message (_("Content-Type changed to %s."), tmp);
988 if (b->type == TYPETEXT && charset_changed) {
991 mutt_message (_("Character set changed to %s; %s."),
992 mutt_get_parameter ("charset", b->parameter),
993 b->noconv ? _("not converting") : _("converting"));
996 b->force_charset |= charset_changed ? 1 : 0;
998 if (!is_multipart (b) && b->parts)
999 mutt_free_body (&b->parts);
1000 if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
1001 b->hdr->content = NULL;
1002 mutt_free_header (&b->hdr);
1005 if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
1006 mutt_parse_part (fp, b);
1008 if (WithCrypto && h) {
1009 if (h->content == b)
1012 h->security |= crypt_query (b);
1017 static int _mutt_check_traditional_pgp (HEADER * h, int *redraw)
1022 h->security |= PGP_TRADITIONAL_CHECKED;
1024 mutt_parse_mime_message (Context, h);
1025 if ((msg = mx_open_message (Context, h->msgno)) == NULL)
1027 if (crypt_pgp_check_traditional (msg->fp, h->content, 0)) {
1028 h->security = crypt_query (h->content);
1029 *redraw |= REDRAW_FULL;
1033 h->security |= PGP_TRADITIONAL_CHECKED;
1034 mx_close_message (&msg);
1038 int mutt_check_traditional_pgp (HEADER * h, int *redraw)
1043 if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
1044 rv = _mutt_check_traditional_pgp (h, redraw);
1046 for (i = 0; i < Context->vcount; i++)
1047 if (Context->hdrs[Context->v2r[i]]->tagged &&
1048 !(Context->hdrs[Context->v2r[i]]->
1049 security & PGP_TRADITIONAL_CHECKED))
1051 _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)