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.
16 #include "mutt_curses.h"
17 #include "mutt_menu.h"
24 #include "mutt_crypt.h"
38 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
39 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
41 #define CHECK_READONLY if (Context->readonly) \
44 mutt_error _(Mailbox_is_read_only); \
48 static struct mapping_t AttachHelp[] = {
49 {N_("Exit"), OP_EXIT},
50 {N_("Save"), OP_SAVE},
51 {N_("Pipe"), OP_PIPE},
52 {N_("Print"), OP_PRINT},
53 {N_("Help"), OP_HELP},
57 int mutt_extract_path (char *filename, char *path)
59 char *tmp = safe_malloc (sizeof (char) * _POSIX_PATH_MAX);
64 while (*filename != '\0') {
65 if (*filename == '/') {
66 *help_ptr++ = *filename++;
71 *help_ptr++ = *filename++;
77 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
83 for (x = 0; x < idxlen; x++) {
85 if (2 * (idx[x]->level + 2) < sizeof (buf)) {
87 s = buf + 2 * (idx[x]->level - 1);
88 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
98 if (safe_strcmp (idx[x]->tree, buf) != 0)
99 str_replace (&idx[x]->tree, buf);
102 idx[x]->tree = safe_strdup (buf);
104 if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
105 s = buf + 2 * (idx[x]->level - 1);
106 *s++ = (idx[x]->content->next) ? '\005' : '\006';
112 ATTACHPTR **mutt_gen_attach_list (BODY * m,
116 short *idxmax, int level, int compose)
121 for (; m; m = m->next) {
122 if (*idxlen == *idxmax) {
123 safe_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
124 for (i = *idxlen; i < *idxmax; i++)
128 if (m->type == TYPEMULTIPART && m->parts
130 || (parent_type == -1
131 && ascii_strcasecmp ("alternative", m->subtype)))
132 && (!(WithCrypto & APPLICATION_PGP)
133 || !mutt_is_multipart_encrypted (m))
136 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
141 idx[*idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
143 new = idx[(*idxlen)++];
146 new->parent_type = parent_type;
149 /* We don't support multipart messages in the compose menu yet */
150 if (!compose && !m->collapsed &&
151 ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP)
152 || !mutt_is_multipart_encrypted (m))
154 || mutt_is_message_type (m->type, m->subtype))) {
156 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
163 mutt_update_tree (idx, *idxlen);
168 /* %c = character set: convert?
172 * %e = MIME content-transfer-encoding
174 * %I = content-disposition, either I (inline) or A (attachment)
177 * %m = major MIME type
179 * %n = attachment number
183 const char *mutt_attach_fmt (char *dest,
188 const char *ifstring,
189 const char *elsestring,
190 unsigned long data, format_flag flags)
193 char tmp[SHORT_STRING];
194 char charset[SHORT_STRING];
195 ATTACHPTR *aptr = (ATTACHPTR *) data;
196 int optional = (flags & M_FORMAT_OPTIONAL);
202 if (mutt_is_text_part (aptr->content) &&
203 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
204 mutt_format_s (dest, destlen, prefix, charset);
206 mutt_format_s (dest, destlen, prefix, "");
208 else if (!mutt_is_text_part (aptr->content) ||
209 !mutt_get_body_charset (charset, sizeof (charset),
216 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
217 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
218 aptr->content->noconv ? 'n' : 'c');
220 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
225 if (aptr->content->description) {
226 mutt_format_s (dest, destlen, prefix, aptr->content->description);
229 if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
230 && MsgFmt && aptr->content->hdr) {
231 char s[SHORT_STRING];
233 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
234 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
235 M_FORMAT_ARROWCURSOR);
237 mutt_format_s (dest, destlen, prefix, s);
241 if (!aptr->content->filename) {
242 mutt_format_s (dest, destlen, prefix, "<no description>");
246 else if (aptr->content->description ||
247 (mutt_is_message_type
248 (aptr->content->type, aptr->content->subtype)
249 && MsgFmt && aptr->content->hdr))
251 /* FALLS THROUGH TO 'f' */
254 if (aptr->content->filename && *aptr->content->filename == '/') {
255 char path[_POSIX_PATH_MAX];
257 strfcpy (path, aptr->content->filename, sizeof (path));
258 mutt_pretty_mailbox (path);
259 mutt_format_s (dest, destlen, prefix, path);
262 mutt_format_s (dest, destlen, prefix,
263 NONULL (aptr->content->filename));
265 else if (!aptr->content->filename)
270 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
271 else if (!aptr->content->deleted)
276 mutt_format_s (dest, destlen, prefix,
277 ENCODING (aptr->content->encoding));
281 snprintf (dest, destlen, "%c",
282 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
287 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
291 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
292 else if (!aptr->content->subtype)
297 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
298 snprintf (dest, destlen, fmt, aptr->num + 1);
302 if (flags & M_FORMAT_STAT_FILE) {
305 stat (aptr->content->filename, &st);
309 l = aptr->content->length;
312 mutt_pretty_size (tmp, sizeof (tmp), l);
313 mutt_format_s (dest, destlen, prefix, tmp);
321 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
322 else if (!aptr->content->tagged)
327 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
328 else if (!aptr->tree)
333 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
334 else if (!aptr->content->unlink)
342 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
343 else if (flags & M_FORMAT_OPTIONAL)
344 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
348 void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
350 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
351 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
352 M_FORMAT_ARROWCURSOR);
355 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
357 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
358 int ot = cur->tagged;
360 cur->tagged = (m >= 0 ? m : !cur->tagged);
361 return cur->tagged - ot;
364 int mutt_is_message_type (int type, const char *subtype)
366 if (type != TYPEMESSAGE)
369 subtype = NONULL (subtype);
370 return (ascii_strcasecmp (subtype, "rfc822") == 0
371 || ascii_strcasecmp (subtype, "news") == 0);
374 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
378 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
379 char path[_POSIX_PATH_MAX] = "";
385 if (body->filename) {
386 if (directory && *directory)
387 mutt_concat_path (buf, *directory, mutt_basename (body->filename),
390 strfcpy (buf, body->filename, sizeof (buf));
392 else if (body->hdr &&
393 body->encoding != ENCBASE64 &&
394 body->encoding != ENCQUOTEDPRINTABLE &&
395 mutt_is_message_type (body->type, body->subtype))
396 mutt_default_save (buf, sizeof (buf), body->hdr);
400 prompt = _("Save to file ('#' for last used folder): ");
403 mutt_get_field (prompt, buf, sizeof (buf),
404 M_FILE | M_CLEAR | M_LASTFOLDER);
405 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
409 char tmpbuf[_POSIX_PATH_MAX];
411 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
412 strfcpy (buf, tmpbuf, sizeof (buf));
413 ret = mutt_get_field (_("Save to file: ")
414 , buf, sizeof (buf), M_FILE);
415 if ((ret != 0) || (!buf[0]))
419 mutt_extract_path (buf, path);
420 strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder));
424 mutt_expand_path (buf, sizeof (buf));
428 body->encoding != ENCBASE64 &&
429 body->encoding != ENCQUOTEDPRINTABLE &&
430 mutt_is_message_type (body->type, body->subtype));
435 /* check to make sure that this file is really the one the user wants */
436 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
437 prompt = _("Save to file: ");
442 strfcpy (tfile, buf, sizeof (tfile));
446 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
447 &append, directory)) == -1)
450 prompt = _("Save to file: ");
455 mutt_message _("Saving...");
457 if (mutt_save_attachment
458 (fp, body, tfile, append,
459 (hdr || !is_message) ? hdr : body->hdr) == 0) {
460 mutt_message _("Attachment saved.");
465 prompt = _("Save to file: ");
472 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
475 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
476 char *directory = NULL;
478 int last = menu ? menu->current : -1;
483 for (; top; top = top->next) {
484 if (!tag || top->tagged) {
485 if (!option (OPTATTACHSPLIT)) {
489 strfcpy (buf, NONULL (top->filename), sizeof (buf));
490 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
491 M_FILE | M_CLEAR) != 0 || !buf[0])
493 mutt_expand_path (buf, sizeof (buf));
494 if (mutt_check_overwrite (top->filename, buf, tfile,
495 sizeof (tfile), &append, NULL))
497 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
498 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
499 fprintf (fpout, "%s", AttachSep);
504 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
505 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
506 fprintf (fpout, "%s", AttachSep);
512 if (tag && menu && top->aptr) {
513 menu->oldcurrent = menu->current;
514 menu->current = top->aptr->num;
515 menu_check_recenter (menu);
516 menu->redraw |= REDRAW_MOTION;
520 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
525 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
533 menu->oldcurrent = menu->current;
534 menu->current = last;
535 menu_check_recenter (menu);
536 menu->redraw |= REDRAW_MOTION;
539 if (!option (OPTATTACHSPLIT) && (rc == 0))
540 mutt_message _("Attachment saved.");
544 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int filter)
546 char tfile[_POSIX_PATH_MAX];
547 char warning[STRING + _POSIX_PATH_MAX];
550 snprintf (warning, sizeof (warning),
551 _("WARNING! You are about to overwrite %s, continue?"),
553 if (mutt_yesorno (warning, M_NO) != M_YES) {
554 CLEARLINE (LINES - 1);
562 if (mutt_pipe_attachment (fp, body, command, tfile)) {
564 mutt_unlink (body->filename);
565 mutt_rename_file (tfile, body->filename);
566 mutt_update_encoding (body);
567 mutt_message _("Attachment filtered.");
571 if (filter && tfile[0])
576 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
582 mutt_decode_attachment (b, state);
584 state_puts (AttachSep, state);
587 if ((ifp = fopen (b->filename, "r")) == NULL) {
588 mutt_perror ("fopen");
591 mutt_copy_stream (ifp, state->fpout);
594 state_puts (AttachSep, state);
599 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
600 int filter, STATE * state)
602 for (; top; top = top->next) {
603 if (!tag || top->tagged) {
604 if (!filter && !option (OPTATTACHSPLIT))
605 pipe_attachment (fp, top, state);
607 mutt_query_pipe_attachment (command, fp, top, filter);
610 pipe_attachment_list (command, fp, tag, top->parts, filter, state);
616 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
619 char buf[SHORT_STRING];
623 filter = 0; /* sanity check: we can't filter in the recv case yet */
626 memset (&state, 0, sizeof (STATE));
628 if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
629 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
632 mutt_expand_path (buf, sizeof (buf));
634 if (!filter && !option (OPTATTACHSPLIT)) {
636 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
637 pipe_attachment_list (buf, fp, tag, top, filter, &state);
638 fclose (state.fpout);
639 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
640 mutt_any_key_to_continue (NULL);
643 pipe_attachment_list (buf, fp, tag, top, filter, &state);
646 static int can_print (BODY * top, int tag)
650 for (; top; top = top->next) {
651 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
652 if (!tag || top->tagged) {
653 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
654 if (ascii_strcasecmp ("text/plain", top->subtype) &&
655 ascii_strcasecmp ("application/postscript", top->subtype)) {
656 if (!mutt_can_decode (top)) {
657 mutt_error (_("I dont know how to print %s attachments!"), type);
664 return (can_print (top->parts, tag));
671 static void print_attachment_list (FILE * fp, int tag, BODY * top,
677 for (; top; top = top->next) {
678 if (!tag || top->tagged) {
679 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
680 if (!option (OPTATTACHSPLIT)
681 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
682 if (!ascii_strcasecmp ("text/plain", top->subtype)
683 || !ascii_strcasecmp ("application/postscript", top->subtype))
684 pipe_attachment (fp, top, state);
685 else if (mutt_can_decode (top)) {
686 /* decode and print */
688 char newfile[_POSIX_PATH_MAX] = "";
691 mutt_mktemp (newfile);
692 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
694 if ((ifp = fopen (newfile, "r")) != NULL) {
695 mutt_copy_stream (ifp, state->fpout);
698 state_puts (AttachSep, state);
701 mutt_unlink (newfile);
705 mutt_print_attachment (fp, top);
708 print_attachment_list (fp, tag, top->parts, state);
714 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
722 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
726 if (!option (OPTATTACHSPLIT)) {
727 if (!can_print (top, tag))
730 memset (&state, 0, sizeof (STATE));
731 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
732 print_attachment_list (fp, tag, top, &state);
733 fclose (state.fpout);
734 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
735 mutt_any_key_to_continue (NULL);
738 print_attachment_list (fp, tag, top, &state);
742 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
743 short *idxlen, short *idxmax, MUTTMENU * menu)
745 ATTACHPTR **idx = *idxp;
747 while (--(*idxlen) >= 0)
748 idx[(*idxlen)]->content = NULL;
751 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
756 if (menu->current >= menu->max)
757 menu->current = menu->max - 1;
758 menu_check_recenter (menu);
759 menu->redraw |= REDRAW_INDEX;
765 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
766 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
767 short *idxmax, int recv)
769 ATTACHPTR **idx = *idxp;
772 int old_optweed = option (OPTWEED);
774 set_option (OPTWEED);
779 case OP_DISPLAY_HEADERS:
780 toggle_option (OPTWEED);
784 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
789 case OP_MAIN_NEXT_UNDELETED: /* hack */
790 if (menu->current < menu->max - 1) {
798 case OP_MAIN_PREV_UNDELETED: /* hack */
799 if (menu->current > 0) {
807 /* when we edit the content-type, we should redisplay the attachment
809 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
811 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
816 /* functions which are passed through from the pager */
817 case OP_CHECK_TRADITIONAL:
818 if (!(WithCrypto & APPLICATION_PGP)
819 || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) {
824 case OP_ATTACH_COLLAPSE:
831 while (op != OP_NULL);
834 if (option (OPTWEED) != old_optweed)
835 toggle_option (OPTWEED);
840 static void attach_collapse (BODY * b, short collapse, short init,
845 for (; b; b = b->next) {
846 i = init || b->collapsed;
847 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
848 && !ascii_strcasecmp (b->subtype, "digest"))
849 attach_collapse (b->parts, 1, 1, 0);
850 else if (b->type == TYPEMULTIPART
851 || mutt_is_message_type (b->type, b->subtype))
852 attach_collapse (b->parts, collapse, i, 0);
853 b->collapsed = collapse;
859 void mutt_attach_init (BODY * b)
861 for (; b; b = b->next) {
865 mutt_attach_init (b->parts);
869 static const char *Function_not_permitted =
870 N_("Function not permitted in attach-message mode.");
872 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
875 mutt_error _(Function_not_permitted); \
882 void mutt_view_attachments (HEADER * hdr)
885 int need_secured = 0;
887 char helpstr[SHORT_STRING];
892 ATTACHPTR **idx = NULL;
898 /* make sure we have parsed this message */
899 mutt_parse_mime_message (Context, hdr);
901 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
903 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
907 if (WithCrypto && ((hdr->security & ENCRYPT) ||
908 (mutt_is_application_smime (hdr->content) &
912 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
913 mx_close_message (&msg);
916 if ((WithCrypto & APPLICATION_SMIME)
917 && (hdr->security & APPLICATION_SMIME)) {
919 crypt_smime_getkeys (hdr->env);
921 if (mutt_is_application_smime (hdr->content)) {
922 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
926 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
932 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
934 mutt_free_body (&_cur);
941 if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) {
942 if (mutt_is_multipart_encrypted (hdr->content))
943 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
948 if (need_secured && !secured) {
949 mx_close_message (&msg);
950 mutt_error _("Can't decrypt encrypted message!");
956 if (!WithCrypto || !need_secured) {
961 menu = mutt_new_menu ();
962 menu->menu = MENU_ATTACH;
963 menu->title = _("Attachments");
964 menu->make_entry = attach_entry;
965 menu->tag = mutt_tag_attach;
967 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
969 mutt_attach_init (cur);
970 attach_collapse (cur, 0, 1, 0);
971 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
975 op = mutt_menuLoop (menu);
977 case OP_ATTACH_VIEW_MAILCAP:
978 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
980 menu->redraw = REDRAW_FULL;
983 case OP_ATTACH_VIEW_TEXT:
984 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
986 menu->redraw = REDRAW_FULL;
989 case OP_DISPLAY_HEADERS:
992 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
994 menu->redraw = REDRAW_FULL;
997 case OP_ATTACH_COLLAPSE:
998 if (!idx[menu->current]->content->parts) {
999 mutt_error _("There are no subparts to show!");
1003 if (!idx[menu->current]->content->collapsed)
1004 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1006 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1007 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1010 case OP_FORGET_PASSPHRASE:
1011 crypt_forget_passphrase ();
1014 case OP_EXTRACT_KEYS:
1015 if ((WithCrypto & APPLICATION_PGP)) {
1016 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1019 idx[menu->current]->
1021 menu->redraw = REDRAW_FULL;
1025 case OP_CHECK_TRADITIONAL:
1026 if ((WithCrypto & APPLICATION_PGP)
1027 && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1028 : idx[menu->current]->content,
1030 hdr->security = crypt_query (cur);
1031 menu->redraw = REDRAW_FULL;
1036 mutt_print_attachment_list (fp, menu->tagprefix,
1037 menu->tagprefix ? cur : idx[menu->current]->
1042 mutt_pipe_attachment_list (fp, menu->tagprefix,
1043 menu->tagprefix ? cur : idx[menu->current]->
1048 mutt_save_attachment_list (fp, menu->tagprefix,
1049 menu->tagprefix ? cur : idx[menu->current]->
1050 content, hdr, menu);
1052 if (!menu->tagprefix && option (OPTRESOLVE)
1053 && menu->current < menu->max - 1)
1056 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1063 if (Context->magic == M_POP) {
1065 mutt_error _("Can't delete attachment from POP server.");
1072 if (Context->magic == M_NNTP) {
1074 mutt_error _("Can't delete attachment from newsserver.");
1080 if (WithCrypto && hdr->security) {
1083 ("Deletion of attachments from encrypted messages is unsupported.");
1086 if (!menu->tagprefix) {
1087 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1088 idx[menu->current]->content->deleted = 1;
1089 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1091 menu->redraw = REDRAW_MOTION_RESYNCH;
1094 menu->redraw = REDRAW_CURRENT;
1098 _("Only deletion of multipart attachments is supported.");
1103 for (x = 0; x < menu->max; x++) {
1104 if (idx[x]->content->tagged) {
1105 if (idx[x]->parent_type == TYPEMULTIPART) {
1106 idx[x]->content->deleted = 1;
1107 menu->redraw = REDRAW_INDEX;
1111 _("Only deletion of multipart attachments is supported.");
1120 if (!menu->tagprefix) {
1121 idx[menu->current]->content->deleted = 0;
1122 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1124 menu->redraw = REDRAW_MOTION_RESYNCH;
1127 menu->redraw = REDRAW_CURRENT;
1132 for (x = 0; x < menu->max; x++) {
1133 if (idx[x]->content->tagged) {
1134 idx[x]->content->deleted = 0;
1135 menu->redraw = REDRAW_INDEX;
1143 mutt_attach_resend (fp, hdr, idx, idxlen,
1144 menu->tagprefix ? NULL : idx[menu->current]->
1146 menu->redraw = REDRAW_FULL;
1149 case OP_BOUNCE_MESSAGE:
1151 mutt_attach_bounce (fp, hdr, idx, idxlen,
1152 menu->tagprefix ? NULL : idx[menu->current]->
1154 menu->redraw = REDRAW_FULL;
1157 case OP_FORWARD_MESSAGE:
1159 mutt_attach_forward (fp, hdr, idx, idxlen,
1160 menu->tagprefix ? NULL : idx[menu->current]->
1162 menu->redraw = REDRAW_FULL;
1166 case OP_FORWARD_TO_GROUP:
1168 mutt_attach_forward (fp, hdr, idx, idxlen,
1169 menu->tagprefix ? NULL : idx[menu->current]->
1171 menu->redraw = REDRAW_FULL;
1177 if (!idx[menu->current]->content->hdr->env->followup_to ||
1178 safe_strcasecmp (idx[menu->current]->content->hdr->env->followup_to,
1180 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1181 _("Reply by mail as poster prefers?")) !=
1183 mutt_attach_reply (fp, hdr, idx, idxlen,
1184 menu->tagprefix ? NULL : idx[menu->current]->
1185 content, SENDNEWS | SENDREPLY);
1186 menu->redraw = REDRAW_FULL;
1192 case OP_GROUP_REPLY:
1198 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1199 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1200 mutt_attach_reply (fp, hdr, idx, idxlen,
1201 menu->tagprefix ? NULL : idx[menu->current]->content,
1203 menu->redraw = REDRAW_FULL;
1207 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1208 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1212 mx_close_message (&msg);
1213 hdr->attach_del = 0;
1214 while (idxmax-- > 0) {
1217 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1218 hdr->attach_del = 1;
1219 if (idx[idxmax]->content)
1220 idx[idxmax]->content->aptr = NULL;
1221 FREE (&idx[idxmax]->tree);
1222 FREE (&idx[idxmax]);
1224 if (hdr->attach_del)
1229 if (WithCrypto && need_secured && secured) {
1231 mutt_free_body (&cur);
1234 mutt_menuDestroy (&menu);