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/str.h>
17 #include <lib-lib/macros.h>
18 #include <lib-lib/ascii.h>
19 #include <lib-lib/file.h>
20 #include <lib-lib/mapping.h>
22 #include <lib-mime/mime.h>
27 #include "recvattach.h"
28 #include "mutt_curses.h"
29 #include "mutt_menu.h"
34 #include <lib-crypt/crypt.h>
45 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
46 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
48 #define CHECK_READONLY if (Context->readonly) \
51 mutt_error _(Mailbox_is_read_only); \
55 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
57 static struct mapping_t AttachHelp[] = {
58 {N_("Exit"), OP_EXIT},
59 {N_("Save"), OP_SAVE},
60 {N_("Pipe"), OP_PIPE},
61 {N_("Print"), OP_PRINT},
62 {N_("Help"), OP_HELP},
66 static int mutt_extract_path (char *filename, char *path)
68 char *tmp = p_new(char, _POSIX_PATH_MAX);
73 while (*filename != '\0') {
74 if (*filename == '/') {
75 *help_ptr++ = *filename++;
80 *help_ptr++ = *filename++;
86 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
92 for (x = 0; x < idxlen; x++) {
94 if (2 * (idx[x]->level + 2) < sizeof (buf)) {
96 s = buf + 2 * (idx[x]->level - 1);
97 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
107 if (m_strcmp(idx[x]->tree, buf) != 0)
108 m_strreplace(&idx[x]->tree, buf);
111 idx[x]->tree = m_strdup(buf);
113 if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
114 s = buf + 2 * (idx[x]->level - 1);
115 *s++ = (idx[x]->content->next) ? '\005' : '\006';
121 ATTACHPTR **mutt_gen_attach_list (BODY * m,
125 short *idxmax, int level, int compose)
130 for (; m; m = m->next) {
131 if (*idxlen == *idxmax) {
132 p_realloc(&idx, (*idxmax) += 5);
133 for (i = *idxlen; i < *idxmax; i++)
137 if (m->type == TYPEMULTIPART && m->parts
139 || (parent_type == -1
140 && ascii_strcasecmp ("alternative", m->subtype)))
141 && (!mutt_is_multipart_encrypted (m))
144 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
149 idx[*idxlen] = p_new(ATTACHPTR, 1);
151 new = idx[(*idxlen)++];
154 new->parent_type = parent_type;
157 /* We don't support multipart messages in the compose menu yet */
158 if (!compose && !m->collapsed
159 && ((m->type == TYPEMULTIPART && !mutt_is_multipart_encrypted(m))
160 || mutt_is_message_type (m->type, m->subtype)))
162 idx = 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 m_strcpy(path, sizeof(path), aptr->content->filename);
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, sizeof(buf), *directory,
411 mutt_basename(body->filename));
413 m_strcpy(buf, sizeof(buf), body->filename);
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 m_strcpy(buf, sizeof(buf), tmpbuf);
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 m_strcpy(LastSaveFolder, sizeof(LastSaveFolder), path);
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 m_strcpy(tfile, sizeof(tfile), buf);
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 m_strcpy(buf, sizeof(buf), NONULL(top->filename));
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 p_delete(&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 */
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))
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 (hdr && hdr->security & PGP_TRADITIONAL_CHECKED) {
846 case OP_ATTACH_COLLAPSE:
853 while (op != OP_NULL);
856 if (option (OPTWEED) != old_optweed)
857 toggle_option (OPTWEED);
862 static void attach_collapse (BODY * b, short collapse, short init,
867 for (; b; b = b->next) {
868 i = init || b->collapsed;
869 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
870 && !ascii_strcasecmp (b->subtype, "digest"))
871 attach_collapse (b->parts, 1, 1, 0);
872 else if (b->type == TYPEMULTIPART
873 || mutt_is_message_type (b->type, b->subtype))
874 attach_collapse (b->parts, collapse, i, 0);
875 b->collapsed = collapse;
881 void mutt_attach_init (BODY * b)
883 for (; b; b = b->next) {
887 mutt_attach_init (b->parts);
891 static const char *Function_not_permitted =
892 N_("Function not permitted in attach-message mode.");
894 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
897 mutt_error _(Function_not_permitted); \
904 void mutt_view_attachments (HEADER * hdr)
907 int need_secured = 0;
909 char helpstr[SHORT_STRING];
914 ATTACHPTR **idx = NULL;
920 /* make sure we have parsed this message */
921 mutt_parse_mime_message (Context, hdr);
923 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
925 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
929 if ((hdr->security & ENCRYPT) ||
930 (mutt_is_application_smime (hdr->content) & SMIMEOPAQUE))
934 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
935 mx_close_message (&msg);
938 if (hdr->security & APPLICATION_SMIME) {
940 crypt_smime_getkeys (hdr->env);
942 if (mutt_is_application_smime (hdr->content)) {
943 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
947 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
953 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
955 mutt_free_body (&_cur);
962 if (hdr->security & APPLICATION_PGP) {
963 if (mutt_is_multipart_encrypted (hdr->content))
964 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
969 if (need_secured && !secured) {
970 mx_close_message (&msg);
971 mutt_error _("Can't decrypt encrypted message!");
982 menu = mutt_new_menu ();
983 menu->menu = MENU_ATTACH;
984 menu->title = _("Attachments");
985 menu->make_entry = attach_entry;
986 menu->tag = mutt_tag_attach;
988 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
990 mutt_attach_init (cur);
991 attach_collapse (cur, 0, 1, 0);
992 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
996 op = mutt_menuLoop (menu);
998 case OP_ATTACH_VIEW_MAILCAP:
999 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
1001 menu->redraw = REDRAW_FULL;
1004 case OP_ATTACH_VIEW_TEXT:
1005 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
1007 menu->redraw = REDRAW_FULL;
1010 case OP_DISPLAY_HEADERS:
1011 case OP_VIEW_ATTACH:
1013 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
1015 menu->redraw = REDRAW_FULL;
1018 case OP_ATTACH_COLLAPSE:
1019 if (!idx[menu->current]->content->parts) {
1020 mutt_error _("There are no subparts to show!");
1024 if (!idx[menu->current]->content->collapsed)
1025 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1027 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1028 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1031 case OP_FORGET_PASSPHRASE:
1032 crypt_forget_passphrase ();
1035 case OP_EXTRACT_KEYS:
1036 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1039 idx[menu->current]->
1041 menu->redraw = REDRAW_FULL;
1044 case OP_CHECK_TRADITIONAL:
1045 if (crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1046 : idx[menu->current]->content,
1049 hdr->security = crypt_query (cur);
1050 menu->redraw = REDRAW_FULL;
1055 mutt_print_attachment_list (fp, menu->tagprefix,
1056 menu->tagprefix ? cur : idx[menu->current]->
1061 mutt_pipe_attachment_list (fp, menu->tagprefix,
1062 menu->tagprefix ? cur : idx[menu->current]->
1067 mutt_save_attachment_list (fp, menu->tagprefix,
1068 menu->tagprefix ? cur : idx[menu->current]->
1069 content, hdr, menu);
1071 if (!menu->tagprefix && option (OPTRESOLVE)
1072 && menu->current < menu->max - 1)
1075 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1081 if (Context->magic == M_POP) {
1083 mutt_error _("Can't delete attachment from POP server.");
1089 if (Context->magic == M_NNTP) {
1091 mutt_error _("Can't delete attachment from newsserver.");
1097 if (hdr->security & (~PGP_TRADITIONAL_CHECKED)) {
1099 _("Deletion of attachments from encrypted messages is unsupported.");
1102 if (!menu->tagprefix) {
1103 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1104 idx[menu->current]->content->deleted = 1;
1105 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1107 menu->redraw = REDRAW_MOTION_RESYNCH;
1110 menu->redraw = REDRAW_CURRENT;
1114 _("Only deletion of multipart attachments is supported.");
1119 for (x = 0; x < menu->max; x++) {
1120 if (idx[x]->content->tagged) {
1121 if (idx[x]->parent_type == TYPEMULTIPART) {
1122 idx[x]->content->deleted = 1;
1123 menu->redraw = REDRAW_INDEX;
1127 _("Only deletion of multipart attachments is supported.");
1136 if (!menu->tagprefix) {
1137 idx[menu->current]->content->deleted = 0;
1138 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1140 menu->redraw = REDRAW_MOTION_RESYNCH;
1143 menu->redraw = REDRAW_CURRENT;
1148 for (x = 0; x < menu->max; x++) {
1149 if (idx[x]->content->tagged) {
1150 idx[x]->content->deleted = 0;
1151 menu->redraw = REDRAW_INDEX;
1159 mutt_attach_resend (fp, hdr, idx, idxlen,
1160 menu->tagprefix ? NULL : idx[menu->current]->
1162 menu->redraw = REDRAW_FULL;
1165 case OP_BOUNCE_MESSAGE:
1167 mutt_attach_bounce (fp, hdr, idx, idxlen,
1168 menu->tagprefix ? NULL : idx[menu->current]->
1170 menu->redraw = REDRAW_FULL;
1173 case OP_FORWARD_MESSAGE:
1175 mutt_attach_forward (fp, hdr, idx, idxlen,
1176 menu->tagprefix ? NULL : idx[menu->current]->
1178 menu->redraw = REDRAW_FULL;
1182 case OP_FORWARD_TO_GROUP:
1184 mutt_attach_forward (fp, hdr, idx, idxlen,
1185 menu->tagprefix ? NULL : idx[menu->current]->
1187 menu->redraw = REDRAW_FULL;
1193 if (!idx[menu->current]->content->hdr->env->followup_to ||
1194 m_strcasecmp(idx[menu->current]->content->hdr->env->followup_to,
1196 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1197 _("Reply by mail as poster prefers?")) !=
1199 mutt_attach_reply (fp, hdr, idx, idxlen,
1200 menu->tagprefix ? NULL : idx[menu->current]->
1201 content, SENDNEWS | SENDREPLY);
1202 menu->redraw = REDRAW_FULL;
1208 case OP_GROUP_REPLY:
1214 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1215 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1216 mutt_attach_reply (fp, hdr, idx, idxlen,
1217 menu->tagprefix ? NULL : idx[menu->current]->content,
1219 menu->redraw = REDRAW_FULL;
1223 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1224 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1228 mx_close_message (&msg);
1229 hdr->attach_del = 0;
1230 while (idxmax-- > 0) {
1233 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1234 hdr->attach_del = 1;
1235 if (idx[idxmax]->content)
1236 idx[idxmax]->content->aptr = NULL;
1237 p_delete(&idx[idxmax]->tree);
1238 p_delete(&idx[idxmax]);
1240 if (hdr->attach_del)
1245 if (need_secured && secured) {
1247 mutt_free_body (&cur);
1250 mutt_menuDestroy (&menu);