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.
15 #include <lib-lib/mem.h>
16 #include <lib-lib/macros.h>
22 #include "recvattach.h"
23 #include "mutt_curses.h"
24 #include "mutt_menu.h"
31 #include "mutt_crypt.h"
43 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
44 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
46 #define CHECK_READONLY if (Context->readonly) \
49 mutt_error _(Mailbox_is_read_only); \
53 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
55 static struct mapping_t AttachHelp[] = {
56 {N_("Exit"), OP_EXIT},
57 {N_("Save"), OP_SAVE},
58 {N_("Pipe"), OP_PIPE},
59 {N_("Print"), OP_PRINT},
60 {N_("Help"), OP_HELP},
64 static int mutt_extract_path (char *filename, char *path)
66 char *tmp = p_new(char, _POSIX_PATH_MAX);
71 while (*filename != '\0') {
72 if (*filename == '/') {
73 *help_ptr++ = *filename++;
78 *help_ptr++ = *filename++;
84 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
90 for (x = 0; x < idxlen; x++) {
92 if (2 * (idx[x]->level + 2) < sizeof (buf)) {
94 s = buf + 2 * (idx[x]->level - 1);
95 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
105 if (str_cmp (idx[x]->tree, buf) != 0)
106 str_replace (&idx[x]->tree, buf);
109 idx[x]->tree = str_dup (buf);
111 if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
112 s = buf + 2 * (idx[x]->level - 1);
113 *s++ = (idx[x]->content->next) ? '\005' : '\006';
119 ATTACHPTR **mutt_gen_attach_list (BODY * m,
123 short *idxmax, int level, int compose)
128 for (; m; m = m->next) {
129 if (*idxlen == *idxmax) {
130 p_realloc(&idx, (*idxmax) += 5);
131 for (i = *idxlen; i < *idxmax; i++)
135 if (m->type == TYPEMULTIPART && m->parts
137 || (parent_type == -1
138 && ascii_strcasecmp ("alternative", m->subtype)))
139 && (!(WithCrypto & APPLICATION_PGP)
140 || !mutt_is_multipart_encrypted (m))
143 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
148 idx[*idxlen] = p_new(ATTACHPTR, 1);
150 new = idx[(*idxlen)++];
153 new->parent_type = parent_type;
156 /* We don't support multipart messages in the compose menu yet */
157 if (!compose && !m->collapsed &&
158 ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP)
159 || !mutt_is_multipart_encrypted (m))
161 || mutt_is_message_type (m->type, m->subtype))) {
163 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
170 mutt_update_tree (idx, *idxlen);
175 /* %c = character set: convert?
179 * %e = MIME content-transfer-encoding
181 * %I = content-disposition, either I (inline) or A (attachment)
184 * %m = major MIME type
186 * %n = attachment number
190 const char *mutt_attach_fmt (char *dest,
195 const char *ifstring,
196 const char *elsestring,
197 unsigned long data, format_flag flags)
200 char tmp[SHORT_STRING];
201 char charset[SHORT_STRING];
202 ATTACHPTR *aptr = (ATTACHPTR *) data;
203 int optional = (flags & M_FORMAT_OPTIONAL);
209 if (mutt_is_text_part (aptr->content) &&
210 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
211 mutt_format_s (dest, destlen, prefix, charset);
213 mutt_format_s (dest, destlen, prefix, "");
215 else if (!mutt_is_text_part (aptr->content) ||
216 !mutt_get_body_charset (charset, sizeof (charset),
223 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
224 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
225 aptr->content->noconv ? 'n' : 'c');
227 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
232 if (aptr->content->description) {
233 mutt_format_s (dest, destlen, prefix, aptr->content->description);
236 if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
237 && MsgFmt && aptr->content->hdr) {
238 char s[SHORT_STRING];
240 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
241 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
242 M_FORMAT_ARROWCURSOR);
244 mutt_format_s (dest, destlen, prefix, s);
248 if (!aptr->content->filename) {
249 mutt_format_s (dest, destlen, prefix, "<no description>");
253 else if (aptr->content->description ||
254 (mutt_is_message_type
255 (aptr->content->type, aptr->content->subtype)
256 && MsgFmt && aptr->content->hdr))
258 /* FALLS THROUGH TO 'f' */
261 if (aptr->content->filename && *aptr->content->filename == '/') {
262 char path[_POSIX_PATH_MAX];
264 strfcpy (path, aptr->content->filename, sizeof (path));
265 mutt_pretty_mailbox (path);
266 mutt_format_s (dest, destlen, prefix, path);
269 mutt_format_s (dest, destlen, prefix,
270 NONULL (aptr->content->filename));
272 else if (!aptr->content->filename)
277 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
278 else if (!aptr->content->deleted)
283 mutt_format_s (dest, destlen, prefix,
284 ENCODING (aptr->content->encoding));
288 snprintf (dest, destlen, "%c",
289 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
294 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
298 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
299 else if (!aptr->content->subtype)
304 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
305 snprintf (dest, destlen, fmt, aptr->num + 1);
310 optional = aptr->content->attach_qualifies;
312 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
313 mutt_format_s (dest, destlen, fmt, "Q");
317 if (flags & M_FORMAT_STAT_FILE) {
320 stat (aptr->content->filename, &st);
324 l = aptr->content->length;
327 mutt_pretty_size (tmp, sizeof (tmp), l);
328 mutt_format_s (dest, destlen, prefix, tmp);
336 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
337 else if (!aptr->content->tagged)
342 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
343 else if (!aptr->tree)
348 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
349 else if (!aptr->content->unlink)
354 optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
356 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
357 snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
365 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
366 else if (flags & M_FORMAT_OPTIONAL)
367 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
371 static void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
373 int w=(COLS-SW)>blen?blen:(COLS-SW);
374 mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
375 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
376 M_FORMAT_ARROWCURSOR);
379 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
381 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
382 int ot = cur->tagged;
384 cur->tagged = (m >= 0 ? m : !cur->tagged);
385 return cur->tagged - ot;
388 int mutt_is_message_type (int type, const char *subtype)
390 if (type != TYPEMESSAGE)
393 subtype = NONULL (subtype);
394 return (ascii_strcasecmp (subtype, "rfc822") == 0
395 || ascii_strcasecmp (subtype, "news") == 0);
398 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
402 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
403 char path[_POSIX_PATH_MAX] = "";
409 if (body->filename) {
410 if (directory && *directory)
411 mutt_concat_path (buf, *directory, mutt_basename (body->filename),
414 strfcpy (buf, body->filename, sizeof (buf));
416 else if (body->hdr &&
417 body->encoding != ENCBASE64 &&
418 body->encoding != ENCQUOTEDPRINTABLE &&
419 mutt_is_message_type (body->type, body->subtype))
420 mutt_default_save (buf, sizeof (buf), body->hdr);
424 prompt = _("Save to file ('#' for last used folder): ");
427 mutt_get_field (prompt, buf, sizeof (buf),
428 M_FILE | M_CLEAR | M_LASTFOLDER);
429 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
433 char tmpbuf[_POSIX_PATH_MAX];
435 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
436 strfcpy (buf, tmpbuf, sizeof (buf));
437 ret = mutt_get_field (_("Save to file: ")
438 , buf, sizeof (buf), M_FILE);
439 if ((ret != 0) || (!buf[0]))
443 mutt_extract_path (buf, path);
444 strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder));
448 mutt_expand_path (buf, sizeof (buf));
452 body->encoding != ENCBASE64 &&
453 body->encoding != ENCQUOTEDPRINTABLE &&
454 mutt_is_message_type (body->type, body->subtype));
459 /* check to make sure that this file is really the one the user wants */
460 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
461 prompt = _("Save to file: ");
466 strfcpy (tfile, buf, sizeof (tfile));
470 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
471 &append, directory)) == -1)
474 prompt = _("Save to file: ");
479 mutt_message _("Saving...");
481 if (mutt_save_attachment
482 (fp, body, tfile, append,
483 (hdr || !is_message) ? hdr : body->hdr) == 0) {
484 mutt_message _("Attachment saved.");
489 prompt = _("Save to file: ");
496 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
499 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
500 char *directory = NULL;
502 int last = menu ? menu->current : -1;
507 for (; top; top = top->next) {
508 if (!tag || top->tagged) {
509 if (!option (OPTATTACHSPLIT)) {
513 strfcpy (buf, NONULL (top->filename), sizeof (buf));
514 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
515 M_FILE | M_CLEAR) != 0 || !buf[0])
517 mutt_expand_path (buf, sizeof (buf));
518 if (mutt_check_overwrite (top->filename, buf, tfile,
519 sizeof (tfile), &append, NULL))
521 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
522 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
523 fprintf (fpout, "%s", AttachSep);
528 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
529 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
530 fprintf (fpout, "%s", AttachSep);
536 if (tag && menu && top->aptr) {
537 menu->oldcurrent = menu->current;
538 menu->current = top->aptr->num;
539 menu_check_recenter (menu);
540 menu->redraw |= REDRAW_MOTION;
544 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
549 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
554 p_delete(&directory);
557 menu->oldcurrent = menu->current;
558 menu->current = last;
559 menu_check_recenter (menu);
560 menu->redraw |= REDRAW_MOTION;
563 if (!option (OPTATTACHSPLIT) && (rc == 0))
564 mutt_message _("Attachment saved.");
568 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int filter)
570 char tfile[_POSIX_PATH_MAX];
571 char warning[STRING + _POSIX_PATH_MAX];
574 snprintf (warning, sizeof (warning),
575 _("WARNING! You are about to overwrite %s, continue?"),
577 if (mutt_yesorno (warning, M_NO) != M_YES) {
578 CLEARLINE (LINES - 1);
586 if (mutt_pipe_attachment (fp, body, command, tfile)) {
588 mutt_unlink (body->filename);
589 mutt_rename_file (tfile, body->filename);
590 mutt_update_encoding (body);
591 mutt_message _("Attachment filtered.");
595 if (filter && tfile[0])
600 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
606 mutt_decode_attachment (b, state);
608 state_puts (AttachSep, state);
611 if ((ifp = fopen (b->filename, "r")) == NULL) {
612 mutt_perror ("fopen");
615 mutt_copy_stream (ifp, state->fpout);
618 state_puts (AttachSep, state);
623 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
624 int filter, STATE * state)
626 for (; top; top = top->next) {
627 if (!tag || top->tagged) {
628 if (!filter && !option (OPTATTACHSPLIT))
629 pipe_attachment (fp, top, state);
631 mutt_query_pipe_attachment (command, fp, top, filter);
634 pipe_attachment_list (command, fp, tag, top->parts, filter, state);
640 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
643 char buf[SHORT_STRING];
647 filter = 0; /* sanity check: we can't filter in the recv case yet */
650 memset (&state, 0, sizeof (STATE));
652 if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
653 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
656 mutt_expand_path (buf, sizeof (buf));
658 if (!filter && !option (OPTATTACHSPLIT)) {
660 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
661 pipe_attachment_list (buf, fp, tag, top, filter, &state);
662 fclose (state.fpout);
663 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
664 mutt_any_key_to_continue (NULL);
667 pipe_attachment_list (buf, fp, tag, top, filter, &state);
670 static int can_print (BODY * top, int tag)
674 for (; top; top = top->next) {
675 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
676 if (!tag || top->tagged) {
677 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
678 if (ascii_strcasecmp ("text/plain", top->subtype) &&
679 ascii_strcasecmp ("application/postscript", top->subtype)) {
680 if (!mutt_can_decode (top)) {
681 mutt_error (_("I dont know how to print %s attachments!"), type);
688 return (can_print (top->parts, tag));
695 static void print_attachment_list (FILE * fp, int tag, BODY * top,
701 for (; top; top = top->next) {
702 if (!tag || top->tagged) {
703 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
704 if (!option (OPTATTACHSPLIT)
705 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
706 if (!ascii_strcasecmp ("text/plain", top->subtype)
707 || !ascii_strcasecmp ("application/postscript", top->subtype))
708 pipe_attachment (fp, top, state);
709 else if (mutt_can_decode (top)) {
710 /* decode and print */
712 char newfile[_POSIX_PATH_MAX] = "";
715 mutt_mktemp (newfile);
716 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
718 if ((ifp = fopen (newfile, "r")) != NULL) {
719 mutt_copy_stream (ifp, state->fpout);
722 state_puts (AttachSep, state);
725 mutt_unlink (newfile);
729 mutt_print_attachment (fp, top);
732 print_attachment_list (fp, tag, top->parts, state);
738 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
746 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
750 if (!option (OPTATTACHSPLIT)) {
751 if (!can_print (top, tag))
754 memset (&state, 0, sizeof (STATE));
755 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
756 print_attachment_list (fp, tag, top, &state);
757 fclose (state.fpout);
758 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
759 mutt_any_key_to_continue (NULL);
762 print_attachment_list (fp, tag, top, &state);
766 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
767 short *idxlen, short *idxmax, MUTTMENU * menu)
769 ATTACHPTR **idx = *idxp;
771 while (--(*idxlen) >= 0)
772 idx[(*idxlen)]->content = NULL;
775 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
780 if (menu->current >= menu->max)
781 menu->current = menu->max - 1;
782 menu_check_recenter (menu);
783 menu->redraw |= REDRAW_INDEX;
789 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
790 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
791 short *idxmax, int recv)
793 ATTACHPTR **idx = *idxp;
796 int old_optweed = option (OPTWEED);
798 set_option (OPTWEED);
803 case OP_DISPLAY_HEADERS:
804 toggle_option (OPTWEED);
808 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
813 case OP_MAIN_NEXT_UNDELETED: /* hack */
814 if (menu->current < menu->max - 1) {
822 case OP_MAIN_PREV_UNDELETED: /* hack */
823 if (menu->current > 0) {
831 /* when we edit the content-type, we should redisplay the attachment
833 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
835 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
840 /* functions which are passed through from the pager */
841 case OP_CHECK_TRADITIONAL:
842 if (!(WithCrypto & APPLICATION_PGP)
843 || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) {
848 case OP_ATTACH_COLLAPSE:
855 while (op != OP_NULL);
858 if (option (OPTWEED) != old_optweed)
859 toggle_option (OPTWEED);
864 static void attach_collapse (BODY * b, short collapse, short init,
869 for (; b; b = b->next) {
870 i = init || b->collapsed;
871 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
872 && !ascii_strcasecmp (b->subtype, "digest"))
873 attach_collapse (b->parts, 1, 1, 0);
874 else if (b->type == TYPEMULTIPART
875 || mutt_is_message_type (b->type, b->subtype))
876 attach_collapse (b->parts, collapse, i, 0);
877 b->collapsed = collapse;
883 void mutt_attach_init (BODY * b)
885 for (; b; b = b->next) {
889 mutt_attach_init (b->parts);
893 static const char *Function_not_permitted =
894 N_("Function not permitted in attach-message mode.");
896 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
899 mutt_error _(Function_not_permitted); \
906 void mutt_view_attachments (HEADER * hdr)
909 int need_secured = 0;
911 char helpstr[SHORT_STRING];
916 ATTACHPTR **idx = NULL;
922 /* make sure we have parsed this message */
923 mutt_parse_mime_message (Context, hdr);
925 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
927 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
931 if (WithCrypto && ((hdr->security & ENCRYPT) ||
932 (mutt_is_application_smime (hdr->content) &
936 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
937 mx_close_message (&msg);
940 if ((WithCrypto & APPLICATION_SMIME)
941 && (hdr->security & APPLICATION_SMIME)) {
943 crypt_smime_getkeys (hdr->env);
945 if (mutt_is_application_smime (hdr->content)) {
946 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
950 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
956 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
958 mutt_free_body (&_cur);
965 if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) {
966 if (mutt_is_multipart_encrypted (hdr->content))
967 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
972 if (need_secured && !secured) {
973 mx_close_message (&msg);
974 mutt_error _("Can't decrypt encrypted message!");
980 if (!WithCrypto || !need_secured) {
985 menu = mutt_new_menu ();
986 menu->menu = MENU_ATTACH;
987 menu->title = _("Attachments");
988 menu->make_entry = attach_entry;
989 menu->tag = mutt_tag_attach;
991 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
993 mutt_attach_init (cur);
994 attach_collapse (cur, 0, 1, 0);
995 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
999 op = mutt_menuLoop (menu);
1001 case OP_ATTACH_VIEW_MAILCAP:
1002 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
1004 menu->redraw = REDRAW_FULL;
1007 case OP_ATTACH_VIEW_TEXT:
1008 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
1010 menu->redraw = REDRAW_FULL;
1013 case OP_DISPLAY_HEADERS:
1014 case OP_VIEW_ATTACH:
1016 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
1018 menu->redraw = REDRAW_FULL;
1021 case OP_ATTACH_COLLAPSE:
1022 if (!idx[menu->current]->content->parts) {
1023 mutt_error _("There are no subparts to show!");
1027 if (!idx[menu->current]->content->collapsed)
1028 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1030 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1031 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1034 case OP_FORGET_PASSPHRASE:
1035 crypt_forget_passphrase ();
1038 case OP_EXTRACT_KEYS:
1039 if ((WithCrypto & APPLICATION_PGP)) {
1040 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1043 idx[menu->current]->
1045 menu->redraw = REDRAW_FULL;
1049 case OP_CHECK_TRADITIONAL:
1050 if ((WithCrypto & APPLICATION_PGP)
1051 && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1052 : idx[menu->current]->content,
1054 hdr->security = crypt_query (cur);
1055 menu->redraw = REDRAW_FULL;
1060 mutt_print_attachment_list (fp, menu->tagprefix,
1061 menu->tagprefix ? cur : idx[menu->current]->
1066 mutt_pipe_attachment_list (fp, menu->tagprefix,
1067 menu->tagprefix ? cur : idx[menu->current]->
1072 mutt_save_attachment_list (fp, menu->tagprefix,
1073 menu->tagprefix ? cur : idx[menu->current]->
1074 content, hdr, menu);
1076 if (!menu->tagprefix && option (OPTRESOLVE)
1077 && menu->current < menu->max - 1)
1080 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1087 if (Context->magic == M_POP) {
1089 mutt_error _("Can't delete attachment from POP server.");
1096 if (Context->magic == M_NNTP) {
1098 mutt_error _("Can't delete attachment from newsserver.");
1104 if (WithCrypto && (hdr->security & (~PGP_TRADITIONAL_CHECKED))) {
1107 ("Deletion of attachments from encrypted messages is unsupported.");
1110 if (!menu->tagprefix) {
1111 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1112 idx[menu->current]->content->deleted = 1;
1113 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1115 menu->redraw = REDRAW_MOTION_RESYNCH;
1118 menu->redraw = REDRAW_CURRENT;
1122 _("Only deletion of multipart attachments is supported.");
1127 for (x = 0; x < menu->max; x++) {
1128 if (idx[x]->content->tagged) {
1129 if (idx[x]->parent_type == TYPEMULTIPART) {
1130 idx[x]->content->deleted = 1;
1131 menu->redraw = REDRAW_INDEX;
1135 _("Only deletion of multipart attachments is supported.");
1144 if (!menu->tagprefix) {
1145 idx[menu->current]->content->deleted = 0;
1146 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1148 menu->redraw = REDRAW_MOTION_RESYNCH;
1151 menu->redraw = REDRAW_CURRENT;
1156 for (x = 0; x < menu->max; x++) {
1157 if (idx[x]->content->tagged) {
1158 idx[x]->content->deleted = 0;
1159 menu->redraw = REDRAW_INDEX;
1167 mutt_attach_resend (fp, hdr, idx, idxlen,
1168 menu->tagprefix ? NULL : idx[menu->current]->
1170 menu->redraw = REDRAW_FULL;
1173 case OP_BOUNCE_MESSAGE:
1175 mutt_attach_bounce (fp, hdr, idx, idxlen,
1176 menu->tagprefix ? NULL : idx[menu->current]->
1178 menu->redraw = REDRAW_FULL;
1181 case OP_FORWARD_MESSAGE:
1183 mutt_attach_forward (fp, hdr, idx, idxlen,
1184 menu->tagprefix ? NULL : idx[menu->current]->
1186 menu->redraw = REDRAW_FULL;
1190 case OP_FORWARD_TO_GROUP:
1192 mutt_attach_forward (fp, hdr, idx, idxlen,
1193 menu->tagprefix ? NULL : idx[menu->current]->
1195 menu->redraw = REDRAW_FULL;
1201 if (!idx[menu->current]->content->hdr->env->followup_to ||
1202 str_casecmp (idx[menu->current]->content->hdr->env->followup_to,
1204 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1205 _("Reply by mail as poster prefers?")) !=
1207 mutt_attach_reply (fp, hdr, idx, idxlen,
1208 menu->tagprefix ? NULL : idx[menu->current]->
1209 content, SENDNEWS | SENDREPLY);
1210 menu->redraw = REDRAW_FULL;
1216 case OP_GROUP_REPLY:
1222 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1223 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1224 mutt_attach_reply (fp, hdr, idx, idxlen,
1225 menu->tagprefix ? NULL : idx[menu->current]->content,
1227 menu->redraw = REDRAW_FULL;
1231 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1232 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1236 mx_close_message (&msg);
1237 hdr->attach_del = 0;
1238 while (idxmax-- > 0) {
1241 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1242 hdr->attach_del = 1;
1243 if (idx[idxmax]->content)
1244 idx[idxmax]->content->aptr = NULL;
1245 p_delete(&idx[idxmax]->tree);
1246 p_delete(&idx[idxmax]);
1248 if (hdr->attach_del)
1253 if (WithCrypto && need_secured && secured) {
1255 mutt_free_body (&cur);
1258 mutt_menuDestroy (&menu);