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.
11 #include <lib-lib/lib-lib.h>
13 #include <lib-mime/mime.h>
14 #include <lib-sys/unix.h>
16 #include <lib-ui/curses.h>
17 #include <lib-ui/enter.h>
18 #include <lib-ui/menu.h>
19 #include <lib-mx/mx.h>
24 #include "recvattach.h"
28 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
30 static struct mapping_t AttachHelp[] = {
31 {N_("Exit"), OP_EXIT},
32 {N_("Save"), OP_SAVE},
33 {N_("Pipe"), OP_PIPE},
34 {N_("Print"), OP_PRINT},
35 {N_("Help"), OP_HELP},
39 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
45 for (x = 0; x < idxlen; x++) {
47 if (2 * (idx[x]->level + 2) < ssizeof (buf)) {
49 s = buf + 2 * (idx[x]->level - 1);
50 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
60 if (m_strcmp(idx[x]->tree, buf) != 0)
61 m_strreplace(&idx[x]->tree, buf);
64 idx[x]->tree = m_strdup(buf);
66 if (2 * (idx[x]->level + 2) < ssizeof (buf) && idx[x]->level) {
67 s = buf + 2 * (idx[x]->level - 1);
68 *s++ = (idx[x]->content->next) ? '\005' : '\006';
74 ATTACHPTR **mutt_gen_attach_list (BODY * m,
78 short *idxmax, int level, int compose)
83 for (; m; m = m->next) {
84 if (*idxlen == *idxmax) {
85 p_realloc(&idx, (*idxmax) += 5);
86 for (i = *idxlen; i < *idxmax; i++)
90 if (m->type == TYPEMULTIPART && m->parts
93 && ascii_strcasecmp ("alternative", m->subtype)))
94 && (!mutt_is_multipart_encrypted (m))
97 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
102 idx[*idxlen] = p_new(ATTACHPTR, 1);
104 new = idx[(*idxlen)++];
107 new->parent_type = parent_type;
110 /* We don't support multipart messages in the compose menu yet */
111 if (!compose && !m->collapsed
112 && ((m->type == TYPEMULTIPART && !mutt_is_multipart_encrypted(m))
113 || mutt_is_message_type(m)))
115 idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
122 mutt_update_tree (idx, *idxlen);
127 /* %c = character set: convert?
131 * %e = MIME content-transfer-encoding
133 * %I = content-disposition, either I (inline) or A (attachment)
136 * %m = major MIME type
138 * %n = attachment number
143 mutt_attach_fmt(char *dest, ssize_t destlen, char op, const char *src,
144 const char *prefix, const char *ifstr, const char *elstr,
145 anytype data, format_flag flags)
149 char charset[STRING];
150 ATTACHPTR *aptr = data.ptr;
151 int optional = (flags & M_FORMAT_OPTIONAL);
157 if (mutt_is_text_part (aptr->content) &&
158 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
159 mutt_format_s (dest, destlen, prefix, charset);
161 mutt_format_s (dest, destlen, prefix, "");
163 else if (!mutt_is_text_part (aptr->content) ||
164 !mutt_get_body_charset (charset, sizeof (charset),
171 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
172 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
173 aptr->content->noconv ? 'n' : 'c');
175 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
180 if (aptr->content->description) {
181 mutt_format_s (dest, destlen, prefix, aptr->content->description);
184 if (mutt_is_message_type(aptr->content) && MsgFmt && aptr->content->hdr)
188 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
189 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT);
191 mutt_format_s (dest, destlen, prefix, s);
195 if (!aptr->content->filename) {
196 mutt_format_s (dest, destlen, prefix, "<no description>");
200 else if (aptr->content->description ||
201 (mutt_is_message_type(aptr->content)
202 && MsgFmt && aptr->content->hdr))
204 /* FALLS THROUGH TO 'f' */
207 if (aptr->content->filename && *aptr->content->filename == '/') {
208 char path[_POSIX_PATH_MAX];
210 m_strcpy(path, sizeof(path), aptr->content->filename);
211 mutt_pretty_mailbox (path);
212 mutt_format_s (dest, destlen, prefix, path);
215 mutt_format_s (dest, destlen, prefix,
216 NONULL (aptr->content->filename));
218 else if (!aptr->content->filename)
223 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
224 else if (!aptr->content->deleted)
229 mutt_format_s (dest, destlen, prefix,
230 ENCODING (aptr->content->encoding));
234 snprintf (dest, destlen, "%c",
235 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
240 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
244 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
245 else if (!aptr->content->subtype)
250 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
251 snprintf (dest, destlen, fmt, aptr->num + 1);
256 optional = aptr->content->attach_qualifies;
258 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
259 mutt_format_s (dest, destlen, fmt, "Q");
263 if (flags & M_FORMAT_STAT_FILE) {
266 stat (aptr->content->filename, &st);
270 l = aptr->content->length;
273 mutt_pretty_size (tmp, sizeof (tmp), l);
274 mutt_format_s (dest, destlen, prefix, tmp);
282 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
283 else if (!aptr->content->tagged)
288 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
289 else if (!aptr->tree)
294 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
295 else if (!aptr->content->unlink)
300 optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
302 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
303 snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
310 if (flags & M_FORMAT_OPTIONAL)
311 m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
312 mutt_attach_fmt, data, 0);
316 static void attach_entry(char *b, ssize_t blen, MUTTMENU * menu, int num)
318 m_strformat(b, blen, COLS - SW, AttachFormat, mutt_attach_fmt,
319 ((ATTACHPTR **) menu->data)[num], 0);
322 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
324 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
325 int ot = cur->tagged;
327 cur->tagged = (m >= 0 ? m : !cur->tagged);
328 return cur->tagged - ot;
331 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
335 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
341 if (body->filename) {
342 if (directory && *directory)
343 mutt_concat_path(buf, sizeof(buf), *directory,
344 mutt_basename(body->filename));
346 m_strcpy(buf, sizeof(buf), body->filename);
348 else if (body->hdr &&
349 body->encoding != ENCBASE64 &&
350 body->encoding != ENCQUOTEDPRINTABLE &&
351 mutt_is_message_type(body))
352 mutt_default_save (buf, sizeof (buf), body->hdr);
356 prompt = _("Save to file ('#' for last used folder): ");
358 static char LastSaveFolder[_POSIX_PATH_MAX] = ".";
360 ret = mutt_get_field(prompt, buf, sizeof (buf),
361 M_FILE | M_CLEAR | M_LASTFOLDER);
362 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
366 char tmpbuf[_POSIX_PATH_MAX];
368 snprintf (tmpbuf, sizeof (tmpbuf), "%s/%s", LastSaveFolder, buf);
369 m_strcpy(buf, sizeof(buf), tmpbuf);
370 ret = mutt_get_field(_("Save to file: "), buf, sizeof (buf), M_FILE);
371 if ((ret != 0) || (!buf[0]))
374 m_dirname(LastSaveFolder, sizeof(LastSaveFolder), buf);
377 mutt_expand_path(buf, sizeof(buf));
379 is_message = (fp && body->hdr &&
380 body->encoding != ENCBASE64 &&
381 body->encoding != ENCQUOTEDPRINTABLE &&
382 mutt_is_message_type(body));
387 /* check to make sure that this file is really the one the user wants */
388 rc = mutt_save_confirm(buf, &st);
389 m_strcpy(tfile, sizeof(tfile), buf);
391 rc = mutt_check_overwrite(body->filename, buf, tfile, sizeof(tfile),
397 prompt = _("Save to file: ");
401 mutt_message _("Saving...");
403 if (mutt_save_attachment(fp, body, tfile, append,
404 (hdr || !is_message) ? hdr : body->hdr) == 0)
406 mutt_message _("Attachment saved.");
409 prompt = _("Save to file: ");
416 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
419 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
420 char *directory = NULL;
422 int last = menu ? menu->current : -1;
427 for (; top; top = top->next) {
428 if (!tag || top->tagged) {
429 if (!option (OPTATTACHSPLIT)) {
433 m_strcpy(buf, sizeof(buf), NONULL(top->filename));
434 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
435 M_FILE | M_CLEAR) != 0 || !buf[0])
437 mutt_expand_path (buf, sizeof (buf));
438 if (mutt_check_overwrite (top->filename, buf, tfile,
439 sizeof (tfile), &append, NULL))
441 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
442 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
443 fprintf (fpout, "%s", AttachSep);
448 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
449 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
450 fprintf (fpout, "%s", AttachSep);
455 if (tag && menu && top->aptr) {
456 menu->oldcurrent = menu->current;
457 menu->current = top->aptr->num;
458 menu_check_recenter (menu);
459 menu->redraw |= REDRAW_MOTION;
463 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
468 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
473 p_delete(&directory);
476 menu->oldcurrent = menu->current;
477 menu->current = last;
478 menu_check_recenter (menu);
479 menu->redraw |= REDRAW_MOTION;
482 if (!option (OPTATTACHSPLIT) && (rc == 0))
483 mutt_message _("Attachment saved.");
487 mutt_query_pipe_attachment(char *command, FILE * fp, BODY * body, int afilter)
489 char tfile[_POSIX_PATH_MAX];
490 char warning[STRING + _POSIX_PATH_MAX];
494 snprintf(warning, sizeof (warning),
495 _("WARNING! You are about to overwrite %s, continue?"),
497 if (mutt_yesorno (warning, M_NO) != M_YES) {
498 CLEARLINE (LINES - 1);
501 tempfd = m_tempfd(tfile, sizeof(tfile), NONULL(mod_core.tmpdir), NULL);
504 if (mutt_pipe_attachment(fp, body, command, tempfd)) {
506 mutt_unlink (body->filename);
507 mutt_rename_file (tfile, body->filename);
508 mutt_update_encoding (body);
509 mutt_message _("Attachment filtered.");
511 } else if (afilter) {
517 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
523 mutt_decode_attachment (b, state);
525 state_puts (AttachSep, state);
527 if ((ifp = fopen (b->filename, "r")) == NULL) {
528 mutt_perror ("fopen");
531 mutt_copy_stream (ifp, state->fpout);
534 state_puts (AttachSep, state);
539 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
540 int afilter, STATE * state)
542 for (; top; top = top->next) {
543 if (!tag || top->tagged) {
544 if (!afilter && !option (OPTATTACHSPLIT))
545 pipe_attachment (fp, top, state);
547 mutt_query_pipe_attachment (command, fp, top, afilter);
550 pipe_attachment_list (command, fp, tag, top->parts, afilter, state);
556 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int afilter)
563 afilter = 0; /* sanity check: we can't filter in the recv case yet */
568 if (mutt_get_field ((afilter ? _("Filter through: ") : _("Pipe to: ")),
569 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
572 mutt_expand_path (buf, sizeof (buf));
574 if (!afilter && !option (OPTATTACHSPLIT)) {
576 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
577 pipe_attachment_list (buf, fp, tag, top, afilter, &state);
578 m_fclose(&state.fpout);
579 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
580 mutt_any_key_to_continue (NULL);
582 pipe_attachment_list (buf, fp, tag, top, afilter, &state);
586 static int can_print(BODY * top, int tag)
588 for (; top; top = top->next) {
590 int tok = mime_which_token(top->subtype, -1);
592 snprintf(type, sizeof(type), "%s/%s", TYPE(top), top->subtype);
594 if (!tag || top->tagged) {
595 if (!rfc1524_mailcap_lookup(top, type, NULL, M_PRINT)
596 && !(top->type == TYPETEXT && tok == MIME_PLAIN)
597 && !(top->type == TYPEAPPLICATION && tok == MIME_POSTSCRIPT)
598 && !mutt_can_decode(top))
600 mutt_error(_("I dont know how to print %s attachments!"), type);
605 return (can_print(top->parts, tag));
612 static void print_attachment_list (FILE * fp, int tag, BODY * top,
617 for (; top; top = top->next) {
618 if (!tag || top->tagged) {
619 int tok = mime_which_token(top->subtype, -1);
621 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
622 if (!option (OPTATTACHSPLIT)
623 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
624 if ((top->type == TYPETEXT && tok == MIME_PLAIN)
625 || (top->type == TYPEAPPLICATION && tok == MIME_POSTSCRIPT)) {
626 pipe_attachment (fp, top, state);
628 if (mutt_can_decode (top)) {
629 /* decode and print */
631 char newfile[_POSIX_PATH_MAX] = "";
635 newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(mod_core.tmpdir), NULL);
636 if (mutt_decode_save_attachment (fp, top, newfile_fd, M_PRINTING) == 0) {
637 if ((ifp = fopen (newfile, "r")) != NULL) {
638 mutt_copy_stream (ifp, state->fpout);
641 state_puts (AttachSep, state);
644 mutt_unlink (newfile);
647 mutt_print_attachment(fp, top);
651 print_attachment_list (fp, tag, top->parts, state);
657 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
663 if (query_quadoption(OPT_PRINT,
664 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
668 if (!option (OPTATTACHSPLIT)) {
669 if (!can_print (top, tag))
673 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
674 print_attachment_list (fp, tag, top, &state);
675 m_fclose(&state.fpout);
676 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
677 mutt_any_key_to_continue (NULL);
680 print_attachment_list (fp, tag, top, &state);
684 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
685 short *idxlen, short *idxmax, MUTTMENU * menu)
687 ATTACHPTR **idx = *idxp;
689 while (--(*idxlen) >= 0)
690 idx[(*idxlen)]->content = NULL;
693 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
698 if (menu->current >= menu->max)
699 menu->current = menu->max - 1;
700 menu_check_recenter (menu);
701 menu->redraw |= REDRAW_INDEX;
705 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
706 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
707 short *idxmax, int recv)
709 ATTACHPTR **idx = *idxp;
713 case OP_DISPLAY_HEADERS:
714 toggle_option (OPTWEED);
718 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
723 case OP_MAIN_NEXT_UNDELETED: /* hack */
724 if (menu->current < menu->max - 1) {
732 case OP_MAIN_PREV_UNDELETED: /* hack */
733 if (menu->current > 0) {
741 /* when we edit the content-type, we should redisplay the attachment
743 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
745 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
750 /* functions which are passed through from the pager */
751 case OP_CHECK_TRADITIONAL:
752 if (hdr && hdr->security & PGP_TRADITIONAL_CHECKED) {
757 case OP_ATTACH_COLLAPSE:
764 while (op != OP_NULL);
769 static void attach_collapse (BODY * b, short collapse, short init,
774 for (; b; b = b->next) {
775 i = init || b->collapsed;
776 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
777 && mime_which_token(b->subtype, -1) == MIME_DIGEST)
778 attach_collapse (b->parts, 1, 1, 0);
779 else if (b->type == TYPEMULTIPART || mutt_is_message_type(b))
780 attach_collapse (b->parts, collapse, i, 0);
781 b->collapsed = collapse;
787 void mutt_attach_init (BODY * b)
789 for (; b; b = b->next) {
793 mutt_attach_init (b->parts);
797 void mutt_view_attachments (HEADER * hdr)
800 int need_secured = 0;
802 char helpstr[STRING];
807 ATTACHPTR **idx = NULL;
813 /* make sure we have parsed this message */
814 mutt_parse_mime_message (Context, hdr);
816 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
818 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
821 if ((hdr->security & ENCRYPT) ||
822 (mutt_is_application_smime (hdr->content) & SMIMEOPAQUE))
826 if (hdr->security & APPLICATION_SMIME) {
827 if (mutt_is_application_smime (hdr->content)) {
828 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
832 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
838 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
840 body_list_wipe(&_cur);
847 if (hdr->security & APPLICATION_PGP) {
848 if (mutt_is_multipart_encrypted (hdr->content))
849 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
854 if (need_secured && !secured) {
855 mx_close_message (&msg);
856 mutt_error _("Can't decrypt encrypted message!");
866 menu = mutt_new_menu ();
867 menu->menu = MENU_ATTACH;
868 menu->title = _("Attachments");
869 menu->make_entry = attach_entry;
870 menu->tag = mutt_tag_attach;
872 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
874 mutt_attach_init (cur);
875 attach_collapse (cur, 0, 1, 0);
876 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
878 #define CHECK_READONLY \
879 if (Context->readonly) { \
881 mutt_error _("Mailbox is read-only."); \
885 #define CHECK_ATTACH \
886 if (option(OPTATTACHMSG)) { \
888 mutt_error _("Function not permitted in attach-message mode."); \
894 op = mutt_menuLoop(menu);
896 case OP_ATTACH_VIEW_MAILCAP:
897 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
899 menu->redraw = REDRAW_FULL;
902 case OP_ATTACH_VIEW_TEXT:
903 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
905 menu->redraw = REDRAW_FULL;
908 case OP_DISPLAY_HEADERS:
911 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
913 menu->redraw = REDRAW_FULL;
916 case OP_ATTACH_COLLAPSE:
917 if (!idx[menu->current]->content->parts) {
918 mutt_error _("There are no subparts to show!");
922 if (!idx[menu->current]->content->collapsed)
923 attach_collapse (idx[menu->current]->content, 1, 0, 1);
925 attach_collapse (idx[menu->current]->content, 0, 1, 1);
926 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
929 case OP_EXTRACT_KEYS:
930 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
935 menu->redraw = REDRAW_FULL;
938 case OP_CHECK_TRADITIONAL:
939 if (crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
940 : idx[menu->current]->content,
943 hdr->security = crypt_query (cur);
944 menu->redraw = REDRAW_FULL;
949 mutt_print_attachment_list (fp, menu->tagprefix,
950 menu->tagprefix ? cur : idx[menu->current]->
955 mutt_pipe_attachment_list (fp, menu->tagprefix,
956 menu->tagprefix ? cur : idx[menu->current]->
961 mutt_save_attachment_list (fp, menu->tagprefix,
962 menu->tagprefix ? cur : idx[menu->current]->
965 if (!menu->tagprefix && option (OPTRESOLVE)
966 && menu->current < menu->max - 1)
969 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
975 if (Context->magic == M_POP) {
977 mutt_error _("Can't delete attachment from POP server.");
983 if (Context->magic == M_NNTP) {
985 mutt_error _("Can't delete attachment from newsserver.");
991 if (hdr->security & (~PGP_TRADITIONAL_CHECKED)) {
993 _("Deletion of attachments from encrypted messages is unsupported.");
996 if (!menu->tagprefix) {
997 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
998 idx[menu->current]->content->deleted = 1;
999 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1001 menu->redraw = REDRAW_MOTION_RESYNCH;
1004 menu->redraw = REDRAW_CURRENT;
1008 _("Only deletion of multipart attachments is supported.");
1013 for (x = 0; x < menu->max; x++) {
1014 if (idx[x]->content->tagged) {
1015 if (idx[x]->parent_type == TYPEMULTIPART) {
1016 idx[x]->content->deleted = 1;
1017 menu->redraw = REDRAW_INDEX;
1021 _("Only deletion of multipart attachments is supported.");
1030 if (!menu->tagprefix) {
1031 idx[menu->current]->content->deleted = 0;
1032 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1034 menu->redraw = REDRAW_MOTION_RESYNCH;
1037 menu->redraw = REDRAW_CURRENT;
1042 for (x = 0; x < menu->max; x++) {
1043 if (idx[x]->content->tagged) {
1044 idx[x]->content->deleted = 0;
1045 menu->redraw = REDRAW_INDEX;
1053 mutt_attach_resend (fp, hdr, idx, idxlen,
1054 menu->tagprefix ? NULL : idx[menu->current]->
1056 menu->redraw = REDRAW_FULL;
1059 case OP_BOUNCE_MESSAGE:
1061 mutt_attach_bounce (fp, hdr, idx, idxlen,
1062 menu->tagprefix ? NULL : idx[menu->current]->
1064 menu->redraw = REDRAW_FULL;
1067 case OP_FORWARD_MESSAGE:
1069 mutt_attach_forward (fp, hdr, idx, idxlen,
1070 menu->tagprefix ? NULL : idx[menu->current]->
1072 menu->redraw = REDRAW_FULL;
1076 case OP_FORWARD_TO_GROUP:
1078 mutt_attach_forward (fp, hdr, idx, idxlen,
1079 menu->tagprefix ? NULL : idx[menu->current]->
1081 menu->redraw = REDRAW_FULL;
1087 if (!idx[menu->current]->content->hdr->env->followup_to ||
1088 m_strcasecmp(idx[menu->current]->content->hdr->env->followup_to,
1090 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1091 _("Reply by mail as poster prefers?")) !=
1093 mutt_attach_reply (fp, hdr, idx, idxlen,
1094 menu->tagprefix ? NULL : idx[menu->current]->
1095 content, SENDNEWS | SENDREPLY);
1096 menu->redraw = REDRAW_FULL;
1102 case OP_GROUP_REPLY:
1108 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1109 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1110 mutt_attach_reply (fp, hdr, idx, idxlen,
1111 menu->tagprefix ? NULL : idx[menu->current]->content,
1113 menu->redraw = REDRAW_FULL;
1117 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1118 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1122 mx_close_message (&msg);
1123 hdr->attach_del = 0;
1124 while (idxmax-- > 0) {
1127 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1128 hdr->attach_del = 1;
1129 if (idx[idxmax]->content)
1130 idx[idxmax]->content->aptr = NULL;
1131 p_delete(&idx[idxmax]->tree);
1132 p_delete(&idx[idxmax]);
1134 if (hdr->attach_del)
1139 if (need_secured && secured) {
1141 body_list_wipe(&cur);
1144 mutt_menuDestroy (&menu);
1150 #undef CHECK_READONLY