2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 1999-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.
19 #include "recvattach.h"
20 #include "mutt_curses.h"
21 #include "mutt_menu.h"
28 #include "mutt_crypt.h"
42 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
43 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
45 #define CHECK_READONLY if (Context->readonly) \
48 mutt_error _(Mailbox_is_read_only); \
52 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
54 static struct mapping_t AttachHelp[] = {
55 {N_("Exit"), OP_EXIT},
56 {N_("Save"), OP_SAVE},
57 {N_("Pipe"), OP_PIPE},
58 {N_("Print"), OP_PRINT},
59 {N_("Help"), OP_HELP},
63 static int mutt_extract_path (char *filename, char *path)
65 char *tmp = mem_malloc (sizeof (char) * _POSIX_PATH_MAX);
70 while (*filename != '\0') {
71 if (*filename == '/') {
72 *help_ptr++ = *filename++;
77 *help_ptr++ = *filename++;
83 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
89 for (x = 0; x < idxlen; x++) {
91 if (2 * (idx[x]->level + 2) < sizeof (buf)) {
93 s = buf + 2 * (idx[x]->level - 1);
94 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
104 if (str_cmp (idx[x]->tree, buf) != 0)
105 str_replace (&idx[x]->tree, buf);
108 idx[x]->tree = str_dup (buf);
110 if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
111 s = buf + 2 * (idx[x]->level - 1);
112 *s++ = (idx[x]->content->next) ? '\005' : '\006';
118 ATTACHPTR **mutt_gen_attach_list (BODY * m,
122 short *idxmax, int level, int compose)
127 for (; m; m = m->next) {
128 if (*idxlen == *idxmax) {
129 mem_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
130 for (i = *idxlen; i < *idxmax; i++)
134 if (m->type == TYPEMULTIPART && m->parts
136 || (parent_type == -1
137 && ascii_strcasecmp ("alternative", m->subtype)))
138 && (!(WithCrypto & APPLICATION_PGP)
139 || !mutt_is_multipart_encrypted (m))
142 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
147 idx[*idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR));
149 new = idx[(*idxlen)++];
152 new->parent_type = parent_type;
155 /* We don't support multipart messages in the compose menu yet */
156 if (!compose && !m->collapsed &&
157 ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP)
158 || !mutt_is_multipart_encrypted (m))
160 || mutt_is_message_type (m->type, m->subtype))) {
162 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
169 mutt_update_tree (idx, *idxlen);
174 /* %c = character set: convert?
178 * %e = MIME content-transfer-encoding
180 * %I = content-disposition, either I (inline) or A (attachment)
183 * %m = major MIME type
185 * %n = attachment number
189 const char *mutt_attach_fmt (char *dest,
194 const char *ifstring,
195 const char *elsestring,
196 unsigned long data, format_flag flags)
199 char tmp[SHORT_STRING];
200 char charset[SHORT_STRING];
201 ATTACHPTR *aptr = (ATTACHPTR *) data;
202 int optional = (flags & M_FORMAT_OPTIONAL);
208 if (mutt_is_text_part (aptr->content) &&
209 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
210 mutt_format_s (dest, destlen, prefix, charset);
212 mutt_format_s (dest, destlen, prefix, "");
214 else if (!mutt_is_text_part (aptr->content) ||
215 !mutt_get_body_charset (charset, sizeof (charset),
222 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
223 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
224 aptr->content->noconv ? 'n' : 'c');
226 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
231 if (aptr->content->description) {
232 mutt_format_s (dest, destlen, prefix, aptr->content->description);
235 if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
236 && MsgFmt && aptr->content->hdr) {
237 char s[SHORT_STRING];
239 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
240 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
241 M_FORMAT_ARROWCURSOR);
243 mutt_format_s (dest, destlen, prefix, s);
247 if (!aptr->content->filename) {
248 mutt_format_s (dest, destlen, prefix, "<no description>");
252 else if (aptr->content->description ||
253 (mutt_is_message_type
254 (aptr->content->type, aptr->content->subtype)
255 && MsgFmt && aptr->content->hdr))
257 /* FALLS THROUGH TO 'f' */
260 if (aptr->content->filename && *aptr->content->filename == '/') {
261 char path[_POSIX_PATH_MAX];
263 strfcpy (path, aptr->content->filename, sizeof (path));
264 mutt_pretty_mailbox (path);
265 mutt_format_s (dest, destlen, prefix, path);
268 mutt_format_s (dest, destlen, prefix,
269 NONULL (aptr->content->filename));
271 else if (!aptr->content->filename)
276 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
277 else if (!aptr->content->deleted)
282 mutt_format_s (dest, destlen, prefix,
283 ENCODING (aptr->content->encoding));
287 snprintf (dest, destlen, "%c",
288 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
293 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
297 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
298 else if (!aptr->content->subtype)
303 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
304 snprintf (dest, destlen, fmt, aptr->num + 1);
309 optional = aptr->content->attach_qualifies;
311 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
312 mutt_format_s (dest, destlen, fmt, "Q");
316 if (flags & M_FORMAT_STAT_FILE) {
319 stat (aptr->content->filename, &st);
323 l = aptr->content->length;
326 mutt_pretty_size (tmp, sizeof (tmp), l);
327 mutt_format_s (dest, destlen, prefix, tmp);
335 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
336 else if (!aptr->content->tagged)
341 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
342 else if (!aptr->tree)
347 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
348 else if (!aptr->content->unlink)
353 optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
355 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
356 snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
364 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
365 else if (flags & M_FORMAT_OPTIONAL)
366 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
370 static void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
372 int w=(COLS-SW)>blen?blen:(COLS-SW);
373 mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
374 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
375 M_FORMAT_ARROWCURSOR);
378 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
380 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
381 int ot = cur->tagged;
383 cur->tagged = (m >= 0 ? m : !cur->tagged);
384 return cur->tagged - ot;
387 int mutt_is_message_type (int type, const char *subtype)
389 if (type != TYPEMESSAGE)
392 subtype = NONULL (subtype);
393 return (ascii_strcasecmp (subtype, "rfc822") == 0
394 || ascii_strcasecmp (subtype, "news") == 0);
397 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
401 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
402 char path[_POSIX_PATH_MAX] = "";
408 if (body->filename) {
409 if (directory && *directory)
410 mutt_concat_path (buf, *directory, mutt_basename (body->filename),
413 strfcpy (buf, body->filename, sizeof (buf));
415 else if (body->hdr &&
416 body->encoding != ENCBASE64 &&
417 body->encoding != ENCQUOTEDPRINTABLE &&
418 mutt_is_message_type (body->type, body->subtype))
419 mutt_default_save (buf, sizeof (buf), body->hdr);
423 prompt = _("Save to file ('#' for last used folder): ");
426 mutt_get_field (prompt, buf, sizeof (buf),
427 M_FILE | M_CLEAR | M_LASTFOLDER);
428 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
432 char tmpbuf[_POSIX_PATH_MAX];
434 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
435 strfcpy (buf, tmpbuf, sizeof (buf));
436 ret = mutt_get_field (_("Save to file: ")
437 , buf, sizeof (buf), M_FILE);
438 if ((ret != 0) || (!buf[0]))
442 mutt_extract_path (buf, path);
443 strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder));
447 mutt_expand_path (buf, sizeof (buf));
451 body->encoding != ENCBASE64 &&
452 body->encoding != ENCQUOTEDPRINTABLE &&
453 mutt_is_message_type (body->type, body->subtype));
458 /* check to make sure that this file is really the one the user wants */
459 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
460 prompt = _("Save to file: ");
465 strfcpy (tfile, buf, sizeof (tfile));
469 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
470 &append, directory)) == -1)
473 prompt = _("Save to file: ");
478 mutt_message _("Saving...");
480 if (mutt_save_attachment
481 (fp, body, tfile, append,
482 (hdr || !is_message) ? hdr : body->hdr) == 0) {
483 mutt_message _("Attachment saved.");
488 prompt = _("Save to file: ");
495 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
498 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
499 char *directory = NULL;
501 int last = menu ? menu->current : -1;
506 for (; top; top = top->next) {
507 if (!tag || top->tagged) {
508 if (!option (OPTATTACHSPLIT)) {
512 strfcpy (buf, NONULL (top->filename), sizeof (buf));
513 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
514 M_FILE | M_CLEAR) != 0 || !buf[0])
516 mutt_expand_path (buf, sizeof (buf));
517 if (mutt_check_overwrite (top->filename, buf, tfile,
518 sizeof (tfile), &append, NULL))
520 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
521 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
522 fprintf (fpout, "%s", AttachSep);
527 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
528 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
529 fprintf (fpout, "%s", AttachSep);
535 if (tag && menu && top->aptr) {
536 menu->oldcurrent = menu->current;
537 menu->current = top->aptr->num;
538 menu_check_recenter (menu);
539 menu->redraw |= REDRAW_MOTION;
543 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
548 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
553 mem_free (&directory);
556 menu->oldcurrent = menu->current;
557 menu->current = last;
558 menu_check_recenter (menu);
559 menu->redraw |= REDRAW_MOTION;
562 if (!option (OPTATTACHSPLIT) && (rc == 0))
563 mutt_message _("Attachment saved.");
567 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int filter)
569 char tfile[_POSIX_PATH_MAX];
570 char warning[STRING + _POSIX_PATH_MAX];
573 snprintf (warning, sizeof (warning),
574 _("WARNING! You are about to overwrite %s, continue?"),
576 if (mutt_yesorno (warning, M_NO) != M_YES) {
577 CLEARLINE (LINES - 1);
585 if (mutt_pipe_attachment (fp, body, command, tfile)) {
587 mutt_unlink (body->filename);
588 mutt_rename_file (tfile, body->filename);
589 mutt_update_encoding (body);
590 mutt_message _("Attachment filtered.");
594 if (filter && tfile[0])
599 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
605 mutt_decode_attachment (b, state);
607 state_puts (AttachSep, state);
610 if ((ifp = fopen (b->filename, "r")) == NULL) {
611 mutt_perror ("fopen");
614 mutt_copy_stream (ifp, state->fpout);
617 state_puts (AttachSep, state);
622 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
623 int filter, STATE * state)
625 for (; top; top = top->next) {
626 if (!tag || top->tagged) {
627 if (!filter && !option (OPTATTACHSPLIT))
628 pipe_attachment (fp, top, state);
630 mutt_query_pipe_attachment (command, fp, top, filter);
633 pipe_attachment_list (command, fp, tag, top->parts, filter, state);
639 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
642 char buf[SHORT_STRING];
646 filter = 0; /* sanity check: we can't filter in the recv case yet */
649 memset (&state, 0, sizeof (STATE));
651 if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
652 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
655 mutt_expand_path (buf, sizeof (buf));
657 if (!filter && !option (OPTATTACHSPLIT)) {
659 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
660 pipe_attachment_list (buf, fp, tag, top, filter, &state);
661 fclose (state.fpout);
662 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
663 mutt_any_key_to_continue (NULL);
666 pipe_attachment_list (buf, fp, tag, top, filter, &state);
669 static int can_print (BODY * top, int tag)
673 for (; top; top = top->next) {
674 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
675 if (!tag || top->tagged) {
676 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
677 if (ascii_strcasecmp ("text/plain", top->subtype) &&
678 ascii_strcasecmp ("application/postscript", top->subtype)) {
679 if (!mutt_can_decode (top)) {
680 mutt_error (_("I dont know how to print %s attachments!"), type);
687 return (can_print (top->parts, tag));
694 static void print_attachment_list (FILE * fp, int tag, BODY * top,
700 for (; top; top = top->next) {
701 if (!tag || top->tagged) {
702 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
703 if (!option (OPTATTACHSPLIT)
704 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
705 if (!ascii_strcasecmp ("text/plain", top->subtype)
706 || !ascii_strcasecmp ("application/postscript", top->subtype))
707 pipe_attachment (fp, top, state);
708 else if (mutt_can_decode (top)) {
709 /* decode and print */
711 char newfile[_POSIX_PATH_MAX] = "";
714 mutt_mktemp (newfile);
715 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
717 if ((ifp = fopen (newfile, "r")) != NULL) {
718 mutt_copy_stream (ifp, state->fpout);
721 state_puts (AttachSep, state);
724 mutt_unlink (newfile);
728 mutt_print_attachment (fp, top);
731 print_attachment_list (fp, tag, top->parts, state);
737 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
745 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
749 if (!option (OPTATTACHSPLIT)) {
750 if (!can_print (top, tag))
753 memset (&state, 0, sizeof (STATE));
754 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
755 print_attachment_list (fp, tag, top, &state);
756 fclose (state.fpout);
757 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
758 mutt_any_key_to_continue (NULL);
761 print_attachment_list (fp, tag, top, &state);
765 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
766 short *idxlen, short *idxmax, MUTTMENU * menu)
768 ATTACHPTR **idx = *idxp;
770 while (--(*idxlen) >= 0)
771 idx[(*idxlen)]->content = NULL;
774 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
779 if (menu->current >= menu->max)
780 menu->current = menu->max - 1;
781 menu_check_recenter (menu);
782 menu->redraw |= REDRAW_INDEX;
788 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
789 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
790 short *idxmax, int recv)
792 ATTACHPTR **idx = *idxp;
795 int old_optweed = option (OPTWEED);
797 set_option (OPTWEED);
802 case OP_DISPLAY_HEADERS:
803 toggle_option (OPTWEED);
807 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
812 case OP_MAIN_NEXT_UNDELETED: /* hack */
813 if (menu->current < menu->max - 1) {
821 case OP_MAIN_PREV_UNDELETED: /* hack */
822 if (menu->current > 0) {
830 /* when we edit the content-type, we should redisplay the attachment
832 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
834 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
839 /* functions which are passed through from the pager */
840 case OP_CHECK_TRADITIONAL:
841 if (!(WithCrypto & APPLICATION_PGP)
842 || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) {
847 case OP_ATTACH_COLLAPSE:
854 while (op != OP_NULL);
857 if (option (OPTWEED) != old_optweed)
858 toggle_option (OPTWEED);
863 static void attach_collapse (BODY * b, short collapse, short init,
868 for (; b; b = b->next) {
869 i = init || b->collapsed;
870 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
871 && !ascii_strcasecmp (b->subtype, "digest"))
872 attach_collapse (b->parts, 1, 1, 0);
873 else if (b->type == TYPEMULTIPART
874 || mutt_is_message_type (b->type, b->subtype))
875 attach_collapse (b->parts, collapse, i, 0);
876 b->collapsed = collapse;
882 void mutt_attach_init (BODY * b)
884 for (; b; b = b->next) {
888 mutt_attach_init (b->parts);
892 static const char *Function_not_permitted =
893 N_("Function not permitted in attach-message mode.");
895 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
898 mutt_error _(Function_not_permitted); \
905 void mutt_view_attachments (HEADER * hdr)
908 int need_secured = 0;
910 char helpstr[SHORT_STRING];
915 ATTACHPTR **idx = NULL;
921 /* make sure we have parsed this message */
922 mutt_parse_mime_message (Context, hdr);
924 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
926 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
930 if (WithCrypto && ((hdr->security & ENCRYPT) ||
931 (mutt_is_application_smime (hdr->content) &
935 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
936 mx_close_message (&msg);
939 if ((WithCrypto & APPLICATION_SMIME)
940 && (hdr->security & APPLICATION_SMIME)) {
942 crypt_smime_getkeys (hdr->env);
944 if (mutt_is_application_smime (hdr->content)) {
945 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
949 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
955 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
957 mutt_free_body (&_cur);
964 if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) {
965 if (mutt_is_multipart_encrypted (hdr->content))
966 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
971 if (need_secured && !secured) {
972 mx_close_message (&msg);
973 mutt_error _("Can't decrypt encrypted message!");
979 if (!WithCrypto || !need_secured) {
984 menu = mutt_new_menu ();
985 menu->menu = MENU_ATTACH;
986 menu->title = _("Attachments");
987 menu->make_entry = attach_entry;
988 menu->tag = mutt_tag_attach;
990 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
992 mutt_attach_init (cur);
993 attach_collapse (cur, 0, 1, 0);
994 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
998 op = mutt_menuLoop (menu);
1000 case OP_ATTACH_VIEW_MAILCAP:
1001 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
1003 menu->redraw = REDRAW_FULL;
1006 case OP_ATTACH_VIEW_TEXT:
1007 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
1009 menu->redraw = REDRAW_FULL;
1012 case OP_DISPLAY_HEADERS:
1013 case OP_VIEW_ATTACH:
1015 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
1017 menu->redraw = REDRAW_FULL;
1020 case OP_ATTACH_COLLAPSE:
1021 if (!idx[menu->current]->content->parts) {
1022 mutt_error _("There are no subparts to show!");
1026 if (!idx[menu->current]->content->collapsed)
1027 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1029 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1030 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1033 case OP_FORGET_PASSPHRASE:
1034 crypt_forget_passphrase ();
1037 case OP_EXTRACT_KEYS:
1038 if ((WithCrypto & APPLICATION_PGP)) {
1039 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1042 idx[menu->current]->
1044 menu->redraw = REDRAW_FULL;
1048 case OP_CHECK_TRADITIONAL:
1049 if ((WithCrypto & APPLICATION_PGP)
1050 && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1051 : idx[menu->current]->content,
1053 hdr->security = crypt_query (cur);
1054 menu->redraw = REDRAW_FULL;
1059 mutt_print_attachment_list (fp, menu->tagprefix,
1060 menu->tagprefix ? cur : idx[menu->current]->
1065 mutt_pipe_attachment_list (fp, menu->tagprefix,
1066 menu->tagprefix ? cur : idx[menu->current]->
1071 mutt_save_attachment_list (fp, menu->tagprefix,
1072 menu->tagprefix ? cur : idx[menu->current]->
1073 content, hdr, menu);
1075 if (!menu->tagprefix && option (OPTRESOLVE)
1076 && menu->current < menu->max - 1)
1079 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1086 if (Context->magic == M_POP) {
1088 mutt_error _("Can't delete attachment from POP server.");
1095 if (Context->magic == M_NNTP) {
1097 mutt_error _("Can't delete attachment from newsserver.");
1103 if (WithCrypto && (hdr->security & (~PGP_TRADITIONAL_CHECKED))) {
1106 ("Deletion of attachments from encrypted messages is unsupported.");
1109 if (!menu->tagprefix) {
1110 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1111 idx[menu->current]->content->deleted = 1;
1112 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1114 menu->redraw = REDRAW_MOTION_RESYNCH;
1117 menu->redraw = REDRAW_CURRENT;
1121 _("Only deletion of multipart attachments is supported.");
1126 for (x = 0; x < menu->max; x++) {
1127 if (idx[x]->content->tagged) {
1128 if (idx[x]->parent_type == TYPEMULTIPART) {
1129 idx[x]->content->deleted = 1;
1130 menu->redraw = REDRAW_INDEX;
1134 _("Only deletion of multipart attachments is supported.");
1143 if (!menu->tagprefix) {
1144 idx[menu->current]->content->deleted = 0;
1145 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1147 menu->redraw = REDRAW_MOTION_RESYNCH;
1150 menu->redraw = REDRAW_CURRENT;
1155 for (x = 0; x < menu->max; x++) {
1156 if (idx[x]->content->tagged) {
1157 idx[x]->content->deleted = 0;
1158 menu->redraw = REDRAW_INDEX;
1166 mutt_attach_resend (fp, hdr, idx, idxlen,
1167 menu->tagprefix ? NULL : idx[menu->current]->
1169 menu->redraw = REDRAW_FULL;
1172 case OP_BOUNCE_MESSAGE:
1174 mutt_attach_bounce (fp, hdr, idx, idxlen,
1175 menu->tagprefix ? NULL : idx[menu->current]->
1177 menu->redraw = REDRAW_FULL;
1180 case OP_FORWARD_MESSAGE:
1182 mutt_attach_forward (fp, hdr, idx, idxlen,
1183 menu->tagprefix ? NULL : idx[menu->current]->
1185 menu->redraw = REDRAW_FULL;
1189 case OP_FORWARD_TO_GROUP:
1191 mutt_attach_forward (fp, hdr, idx, idxlen,
1192 menu->tagprefix ? NULL : idx[menu->current]->
1194 menu->redraw = REDRAW_FULL;
1200 if (!idx[menu->current]->content->hdr->env->followup_to ||
1201 str_casecmp (idx[menu->current]->content->hdr->env->followup_to,
1203 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1204 _("Reply by mail as poster prefers?")) !=
1206 mutt_attach_reply (fp, hdr, idx, idxlen,
1207 menu->tagprefix ? NULL : idx[menu->current]->
1208 content, SENDNEWS | SENDREPLY);
1209 menu->redraw = REDRAW_FULL;
1215 case OP_GROUP_REPLY:
1221 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1222 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1223 mutt_attach_reply (fp, hdr, idx, idxlen,
1224 menu->tagprefix ? NULL : idx[menu->current]->content,
1226 menu->redraw = REDRAW_FULL;
1230 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1231 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1235 mx_close_message (&msg);
1236 hdr->attach_del = 0;
1237 while (idxmax-- > 0) {
1240 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1241 hdr->attach_del = 1;
1242 if (idx[idxmax]->content)
1243 idx[idxmax]->content->aptr = NULL;
1244 mem_free (&idx[idxmax]->tree);
1245 mem_free (&idx[idxmax]);
1247 if (hdr->attach_del)
1252 if (WithCrypto && need_secured && secured) {
1254 mutt_free_body (&cur);
1257 mutt_menuDestroy (&menu);