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/lib-ui.h>
17 #include <lib-ui/enter.h>
18 #include <lib-ui/menu.h>
19 #include <lib-mx/mx.h>
24 #include "recvattach.h"
28 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
34 for (x = 0; x < idxlen; x++) {
36 if (2 * (idx[x]->level + 2) < ssizeof (buf)) {
38 s = buf + 2 * (idx[x]->level - 1);
39 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
49 if (m_strcmp(idx[x]->tree, buf) != 0)
50 m_strreplace(&idx[x]->tree, buf);
53 idx[x]->tree = m_strdup(buf);
55 if (2 * (idx[x]->level + 2) < ssizeof (buf) && idx[x]->level) {
56 s = buf + 2 * (idx[x]->level - 1);
57 *s++ = (idx[x]->content->next) ? '\005' : '\006';
63 ATTACHPTR **mutt_gen_attach_list (BODY * m,
67 short *idxmax, int level, int compose)
72 for (; m; m = m->next) {
73 if (*idxlen == *idxmax) {
74 p_realloc(&idx, (*idxmax) += 5);
75 for (i = *idxlen; i < *idxmax; i++)
79 if (m->type == TYPEMULTIPART && m->parts
82 && ascii_strcasecmp ("alternative", m->subtype)))
83 && (!mutt_is_multipart_encrypted (m))
86 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
91 idx[*idxlen] = p_new(ATTACHPTR, 1);
93 new = idx[(*idxlen)++];
96 new->parent_type = parent_type;
99 /* We don't support multipart messages in the compose menu yet */
100 if (!compose && !m->collapsed
101 && ((m->type == TYPEMULTIPART && !mutt_is_multipart_encrypted(m))
102 || mutt_is_message_type(m)))
104 idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
111 mutt_update_tree (idx, *idxlen);
116 /* %c = character set: convert?
120 * %e = MIME content-transfer-encoding
122 * %I = content-disposition, either I (inline) or A (attachment)
125 * %m = major MIME type
127 * %n = attachment number
132 mutt_attach_fmt(char *dest, ssize_t destlen, char op, const char *src,
133 const char *prefix, const char *ifstr, const char *elstr,
134 anytype data, format_flag flags)
138 char charset[STRING];
139 ATTACHPTR *aptr = data.ptr;
140 int optional = (flags & M_FORMAT_OPTIONAL);
146 if (mutt_is_text_part (aptr->content) &&
147 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
148 mutt_format_s (dest, destlen, prefix, charset);
150 mutt_format_s (dest, destlen, prefix, "");
152 else if (!mutt_is_text_part (aptr->content) ||
153 !mutt_get_body_charset (charset, sizeof (charset),
160 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
161 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
162 aptr->content->noconv ? 'n' : 'c');
164 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
169 if (aptr->content->description) {
170 mutt_format_s (dest, destlen, prefix, aptr->content->description);
173 if (mutt_is_message_type(aptr->content) && MsgFmt && aptr->content->hdr)
177 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
178 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT);
180 mutt_format_s (dest, destlen, prefix, s);
184 if (!aptr->content->filename) {
185 mutt_format_s (dest, destlen, prefix, "<no description>");
189 else if (aptr->content->description ||
190 (mutt_is_message_type(aptr->content)
191 && MsgFmt && aptr->content->hdr))
193 /* FALLS THROUGH TO 'f' */
196 if (aptr->content->filename && *aptr->content->filename == '/') {
197 char path[_POSIX_PATH_MAX];
199 m_strcpy(path, sizeof(path), aptr->content->filename);
200 mutt_pretty_mailbox (path);
201 mutt_format_s (dest, destlen, prefix, path);
204 mutt_format_s (dest, destlen, prefix,
205 NONULL (aptr->content->filename));
207 else if (!aptr->content->filename)
212 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
213 else if (!aptr->content->deleted)
218 mutt_format_s (dest, destlen, prefix,
219 ENCODING (aptr->content->encoding));
223 snprintf (dest, destlen, "%c",
224 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
229 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
233 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
234 else if (!aptr->content->subtype)
239 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
240 snprintf (dest, destlen, fmt, aptr->num + 1);
245 optional = aptr->content->attach_qualifies;
247 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
248 mutt_format_s (dest, destlen, fmt, "Q");
252 if (flags & M_FORMAT_STAT_FILE) {
255 stat (aptr->content->filename, &st);
259 l = aptr->content->length;
262 mutt_pretty_size (tmp, sizeof (tmp), l);
263 mutt_format_s (dest, destlen, prefix, tmp);
271 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
272 else if (!aptr->content->tagged)
277 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
278 else if (!aptr->tree)
283 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
284 else if (!aptr->content->unlink)
289 optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
291 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
292 snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
299 if (flags & M_FORMAT_OPTIONAL)
300 m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
301 mutt_attach_fmt, data, 0);
305 static void attach_entry(char *b, ssize_t blen, MUTTMENU * menu, int num)
307 m_strformat(b, blen, getmaxx(main_w), AttachFormat, mutt_attach_fmt,
308 ((ATTACHPTR **) menu->data)[num], 0);
311 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
313 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
314 int ot = cur->tagged;
316 cur->tagged = (m >= 0 ? m : !cur->tagged);
317 return cur->tagged - ot;
320 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
324 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
330 if (body->filename) {
331 if (directory && *directory)
332 mutt_concat_path(buf, sizeof(buf), *directory,
333 mutt_basename(body->filename));
335 m_strcpy(buf, sizeof(buf), body->filename);
337 else if (body->hdr &&
338 body->encoding != ENCBASE64 &&
339 body->encoding != ENCQUOTEDPRINTABLE &&
340 mutt_is_message_type(body))
341 mutt_default_save (buf, sizeof (buf), body->hdr);
345 prompt = _("Save to file ('#' for last used folder): ");
347 static char LastSaveFolder[_POSIX_PATH_MAX] = ".";
349 ret = mutt_get_field(prompt, buf, sizeof (buf),
350 M_FILE | M_CLEAR | M_LASTFOLDER);
351 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
355 char tmpbuf[_POSIX_PATH_MAX];
357 snprintf (tmpbuf, sizeof (tmpbuf), "%s/%s", LastSaveFolder, buf);
358 m_strcpy(buf, sizeof(buf), tmpbuf);
359 ret = mutt_get_field(_("Save to file: "), buf, sizeof (buf), M_FILE);
360 if ((ret != 0) || (!buf[0]))
363 m_dirname(LastSaveFolder, sizeof(LastSaveFolder), buf);
366 mutt_expand_path(buf, sizeof(buf));
368 is_message = (fp && body->hdr &&
369 body->encoding != ENCBASE64 &&
370 body->encoding != ENCQUOTEDPRINTABLE &&
371 mutt_is_message_type(body));
376 /* check to make sure that this file is really the one the user wants */
377 rc = mutt_save_confirm(buf, &st);
378 m_strcpy(tfile, sizeof(tfile), buf);
380 rc = mutt_check_overwrite(body->filename, buf, tfile, sizeof(tfile),
386 prompt = _("Save to file: ");
390 mutt_message _("Saving...");
392 if (mutt_save_attachment(fp, body, tfile, append,
393 (hdr || !is_message) ? hdr : body->hdr) == 0)
395 mutt_message _("Attachment saved.");
398 prompt = _("Save to file: ");
405 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
408 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
409 char *directory = NULL;
411 int last = menu ? menu->current : -1;
416 for (; top; top = top->next) {
417 if (!tag || top->tagged) {
418 if (!option (OPTATTACHSPLIT)) {
422 m_strcpy(buf, sizeof(buf), NONULL(top->filename));
423 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
424 M_FILE | M_CLEAR) != 0 || !buf[0])
426 mutt_expand_path (buf, sizeof (buf));
427 if (mutt_check_overwrite (top->filename, buf, tfile,
428 sizeof (tfile), &append, NULL))
430 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
431 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
432 fprintf (fpout, "%s", AttachSep);
437 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
438 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
439 fprintf (fpout, "%s", AttachSep);
444 if (tag && menu && top->aptr) {
445 menu->oldcurrent = menu->current;
446 menu->current = top->aptr->num;
447 menu_check_recenter (menu);
448 menu->redraw |= REDRAW_MOTION;
452 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
457 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
462 p_delete(&directory);
465 menu->oldcurrent = menu->current;
466 menu->current = last;
467 menu_check_recenter (menu);
468 menu->redraw |= REDRAW_MOTION;
471 if (!option (OPTATTACHSPLIT) && (rc == 0))
472 mutt_message _("Attachment saved.");
476 mutt_query_pipe_attachment(char *command, FILE * fp, BODY * body, int afilter)
478 char tfile[_POSIX_PATH_MAX];
479 char warning[STRING + _POSIX_PATH_MAX];
483 snprintf(warning, sizeof (warning),
484 _("WARNING! You are about to overwrite %s, continue?"),
486 if (mutt_yesorno (warning, M_NO) != M_YES) {
487 CLEARLINE(main_w, LINES - 1);
490 tempfd = m_tempfd(tfile, sizeof(tfile), NONULL(mod_core.tmpdir), NULL);
493 if (mutt_pipe_attachment(fp, body, command, tempfd)) {
495 mutt_unlink (body->filename);
496 mutt_rename_file (tfile, body->filename);
497 mutt_update_encoding (body);
498 mutt_message _("Attachment filtered.");
500 } else if (afilter) {
506 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
512 mutt_decode_attachment (b, state);
514 state_puts (AttachSep, state);
516 if ((ifp = fopen (b->filename, "r")) == NULL) {
517 mutt_perror ("fopen");
520 mutt_copy_stream (ifp, state->fpout);
523 state_puts (AttachSep, state);
528 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
529 int afilter, STATE * state)
531 for (; top; top = top->next) {
532 if (!tag || top->tagged) {
533 if (!afilter && !option (OPTATTACHSPLIT))
534 pipe_attachment (fp, top, state);
536 mutt_query_pipe_attachment (command, fp, top, afilter);
539 pipe_attachment_list (command, fp, tag, top->parts, afilter, state);
545 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int afilter)
552 afilter = 0; /* sanity check: we can't filter in the recv case yet */
557 if (mutt_get_field ((afilter ? _("Filter through: ") : _("Pipe to: ")),
558 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
561 mutt_expand_path (buf, sizeof (buf));
563 if (!afilter && !option (OPTATTACHSPLIT)) {
565 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
566 pipe_attachment_list (buf, fp, tag, top, afilter, &state);
567 m_fclose(&state.fpout);
568 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
569 mutt_any_key_to_continue (NULL);
571 pipe_attachment_list (buf, fp, tag, top, afilter, &state);
575 static int can_print(BODY * top, int tag)
577 for (; top; top = top->next) {
579 int tok = mime_which_token(top->subtype, -1);
581 snprintf(type, sizeof(type), "%s/%s", TYPE(top), top->subtype);
583 if (!tag || top->tagged) {
584 if (!rfc1524_mailcap_lookup(top, type, NULL, M_PRINT)
585 && !(top->type == TYPETEXT && tok == MIME_PLAIN)
586 && !(top->type == TYPEAPPLICATION && tok == MIME_POSTSCRIPT)
587 && !mutt_can_decode(top))
589 mutt_error(_("I dont know how to print %s attachments!"), type);
594 return (can_print(top->parts, tag));
601 static void print_attachment_list (FILE * fp, int tag, BODY * top,
606 for (; top; top = top->next) {
607 if (!tag || top->tagged) {
608 int tok = mime_which_token(top->subtype, -1);
610 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
611 if (!option (OPTATTACHSPLIT)
612 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
613 if ((top->type == TYPETEXT && tok == MIME_PLAIN)
614 || (top->type == TYPEAPPLICATION && tok == MIME_POSTSCRIPT)) {
615 pipe_attachment (fp, top, state);
617 if (mutt_can_decode (top)) {
618 /* decode and print */
620 char newfile[_POSIX_PATH_MAX] = "";
624 newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(mod_core.tmpdir), NULL);
625 if (mutt_decode_save_attachment (fp, top, newfile_fd, M_PRINTING) == 0) {
626 if ((ifp = fopen (newfile, "r")) != NULL) {
627 mutt_copy_stream (ifp, state->fpout);
630 state_puts (AttachSep, state);
633 mutt_unlink (newfile);
636 mutt_print_attachment(fp, top);
640 print_attachment_list (fp, tag, top->parts, state);
646 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
652 if (query_quadoption(OPT_PRINT,
653 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
657 if (!option (OPTATTACHSPLIT)) {
658 if (!can_print (top, tag))
662 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
663 print_attachment_list (fp, tag, top, &state);
664 m_fclose(&state.fpout);
665 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
666 mutt_any_key_to_continue (NULL);
669 print_attachment_list (fp, tag, top, &state);
673 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
674 short *idxlen, short *idxmax, MUTTMENU * menu)
676 ATTACHPTR **idx = *idxp;
678 while (--(*idxlen) >= 0)
679 idx[(*idxlen)]->content = NULL;
682 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
687 if (menu->current >= menu->max)
688 menu->current = menu->max - 1;
689 menu_check_recenter (menu);
690 menu->redraw |= REDRAW_INDEX;
694 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
695 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
696 short *idxmax, int recv)
698 ATTACHPTR **idx = *idxp;
702 case OP_DISPLAY_HEADERS:
703 toggle_option (OPTWEED);
707 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
712 case OP_MAIN_NEXT_UNDELETED: /* hack */
713 if (menu->current < menu->max - 1) {
721 case OP_MAIN_PREV_UNDELETED: /* hack */
722 if (menu->current > 0) {
730 /* when we edit the content-type, we should redisplay the attachment
732 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
734 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
739 /* functions which are passed through from the pager */
740 case OP_CHECK_TRADITIONAL:
741 if (hdr && hdr->security & PGP_TRADITIONAL_CHECKED) {
746 case OP_ATTACH_COLLAPSE:
753 while (op != OP_NULL);
758 static void attach_collapse (BODY * b, short collapse, short init,
763 for (; b; b = b->next) {
764 i = init || b->collapsed;
765 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
766 && mime_which_token(b->subtype, -1) == MIME_DIGEST)
767 attach_collapse (b->parts, 1, 1, 0);
768 else if (b->type == TYPEMULTIPART || mutt_is_message_type(b))
769 attach_collapse (b->parts, collapse, i, 0);
770 b->collapsed = collapse;
776 void mutt_attach_init (BODY * b)
778 for (; b; b = b->next) {
782 mutt_attach_init (b->parts);
786 void mutt_view_attachments (HEADER * hdr)
789 int need_secured = 0;
795 ATTACHPTR **idx = NULL;
801 /* make sure we have parsed this message */
802 mutt_parse_mime_message (Context, hdr);
804 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
806 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
809 if ((hdr->security & ENCRYPT) ||
810 (mutt_is_application_smime (hdr->content) & SMIMEOPAQUE))
814 if (hdr->security & APPLICATION_SMIME) {
815 if (mutt_is_application_smime (hdr->content)) {
816 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
820 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
826 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
828 body_list_wipe(&_cur);
835 if (hdr->security & APPLICATION_PGP) {
836 if (mutt_is_multipart_encrypted (hdr->content))
837 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
842 if (need_secured && !secured) {
843 mx_close_message (&msg);
844 mutt_error _("Can't decrypt encrypted message!");
854 menu = mutt_new_menu ();
855 menu->menu = MENU_ATTACH;
856 menu->title = _("Attachments");
857 menu->make_entry = attach_entry;
858 menu->tag = mutt_tag_attach;
860 mutt_attach_init (cur);
861 attach_collapse (cur, 0, 1, 0);
862 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
864 #define CHECK_READONLY \
865 if (Context->readonly) { \
867 mutt_error _("Mailbox is read-only."); \
871 #define CHECK_ATTACH \
872 if (option(OPTATTACHMSG)) { \
874 mutt_error _("Function not permitted in attach-message mode."); \
880 op = mutt_menuLoop(menu);
882 case OP_ATTACH_VIEW_MAILCAP:
883 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
885 menu->redraw = REDRAW_FULL;
888 case OP_ATTACH_VIEW_TEXT:
889 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
891 menu->redraw = REDRAW_FULL;
894 case OP_DISPLAY_HEADERS:
897 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
899 menu->redraw = REDRAW_FULL;
902 case OP_ATTACH_COLLAPSE:
903 if (!idx[menu->current]->content->parts) {
904 mutt_error _("There are no subparts to show!");
908 if (!idx[menu->current]->content->collapsed)
909 attach_collapse (idx[menu->current]->content, 1, 0, 1);
911 attach_collapse (idx[menu->current]->content, 0, 1, 1);
912 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
915 case OP_EXTRACT_KEYS:
916 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
921 menu->redraw = REDRAW_FULL;
924 case OP_CHECK_TRADITIONAL:
925 if (crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
926 : idx[menu->current]->content,
929 hdr->security = crypt_query (cur);
930 menu->redraw = REDRAW_FULL;
935 mutt_print_attachment_list (fp, menu->tagprefix,
936 menu->tagprefix ? cur : idx[menu->current]->
941 mutt_pipe_attachment_list (fp, menu->tagprefix,
942 menu->tagprefix ? cur : idx[menu->current]->
947 mutt_save_attachment_list (fp, menu->tagprefix,
948 menu->tagprefix ? cur : idx[menu->current]->
951 if (!menu->tagprefix && option (OPTRESOLVE)
952 && menu->current < menu->max - 1)
955 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
961 if (Context->magic == M_POP) {
963 mutt_error _("Can't delete attachment from POP server.");
969 if (Context->magic == M_NNTP) {
971 mutt_error _("Can't delete attachment from newsserver.");
977 if (hdr->security & (~PGP_TRADITIONAL_CHECKED)) {
979 _("Deletion of attachments from encrypted messages is unsupported.");
982 if (!menu->tagprefix) {
983 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
984 idx[menu->current]->content->deleted = 1;
985 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
987 menu->redraw = REDRAW_MOTION_RESYNCH;
990 menu->redraw = REDRAW_CURRENT;
994 _("Only deletion of multipart attachments is supported.");
999 for (x = 0; x < menu->max; x++) {
1000 if (idx[x]->content->tagged) {
1001 if (idx[x]->parent_type == TYPEMULTIPART) {
1002 idx[x]->content->deleted = 1;
1003 menu->redraw = REDRAW_INDEX;
1007 _("Only deletion of multipart attachments is supported.");
1016 if (!menu->tagprefix) {
1017 idx[menu->current]->content->deleted = 0;
1018 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1020 menu->redraw = REDRAW_MOTION_RESYNCH;
1023 menu->redraw = REDRAW_CURRENT;
1028 for (x = 0; x < menu->max; x++) {
1029 if (idx[x]->content->tagged) {
1030 idx[x]->content->deleted = 0;
1031 menu->redraw = REDRAW_INDEX;
1039 mutt_attach_resend (fp, hdr, idx, idxlen,
1040 menu->tagprefix ? NULL : idx[menu->current]->
1042 menu->redraw = REDRAW_FULL;
1045 case OP_BOUNCE_MESSAGE:
1047 mutt_attach_bounce (fp, hdr, idx, idxlen,
1048 menu->tagprefix ? NULL : idx[menu->current]->
1050 menu->redraw = REDRAW_FULL;
1053 case OP_FORWARD_MESSAGE:
1055 mutt_attach_forward (fp, hdr, idx, idxlen,
1056 menu->tagprefix ? NULL : idx[menu->current]->
1058 menu->redraw = REDRAW_FULL;
1062 case OP_FORWARD_TO_GROUP:
1064 mutt_attach_forward (fp, hdr, idx, idxlen,
1065 menu->tagprefix ? NULL : idx[menu->current]->
1067 menu->redraw = REDRAW_FULL;
1073 if (!idx[menu->current]->content->hdr->env->followup_to ||
1074 m_strcasecmp(idx[menu->current]->content->hdr->env->followup_to,
1076 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1077 _("Reply by mail as poster prefers?")) !=
1079 mutt_attach_reply (fp, hdr, idx, idxlen,
1080 menu->tagprefix ? NULL : idx[menu->current]->
1081 content, SENDNEWS | SENDREPLY);
1082 menu->redraw = REDRAW_FULL;
1088 case OP_GROUP_REPLY:
1094 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1095 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1096 mutt_attach_reply (fp, hdr, idx, idxlen,
1097 menu->tagprefix ? NULL : idx[menu->current]->content,
1099 menu->redraw = REDRAW_FULL;
1103 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1104 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1108 mx_close_message (&msg);
1109 hdr->attach_del = 0;
1110 while (idxmax-- > 0) {
1113 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1114 hdr->attach_del = 1;
1115 if (idx[idxmax]->content)
1116 idx[idxmax]->content->aptr = NULL;
1117 p_delete(&idx[idxmax]->tree);
1118 p_delete(&idx[idxmax]);
1120 if (hdr->attach_del)
1125 if (need_secured && secured) {
1127 body_list_wipe(&cur);
1130 mutt_menuDestroy (&menu);
1136 #undef CHECK_READONLY