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"
25 #include "mutt_crypt.h"
39 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
40 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
42 #define CHECK_READONLY if (Context->readonly) \
45 mutt_error _(Mailbox_is_read_only); \
49 static struct mapping_t AttachHelp[] = {
50 {N_("Exit"), OP_EXIT},
51 {N_("Save"), OP_SAVE},
52 {N_("Pipe"), OP_PIPE},
53 {N_("Print"), OP_PRINT},
54 {N_("Help"), OP_HELP},
58 int mutt_extract_path (char *filename, char *path)
60 char *tmp = safe_malloc (sizeof (char) * _POSIX_PATH_MAX);
65 while (*filename != '\0') {
66 if (*filename == '/') {
67 *help_ptr++ = *filename++;
72 *help_ptr++ = *filename++;
78 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
84 for (x = 0; x < idxlen; x++) {
86 if (2 * (idx[x]->level + 2) < sizeof (buf)) {
88 s = buf + 2 * (idx[x]->level - 1);
89 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
99 if (mutt_strcmp (idx[x]->tree, buf) != 0)
100 mutt_str_replace (&idx[x]->tree, buf);
103 idx[x]->tree = safe_strdup (buf);
105 if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
106 s = buf + 2 * (idx[x]->level - 1);
107 *s++ = (idx[x]->content->next) ? '\005' : '\006';
113 ATTACHPTR **mutt_gen_attach_list (BODY * m,
117 short *idxmax, int level, int compose)
122 for (; m; m = m->next) {
123 if (*idxlen == *idxmax) {
124 safe_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
125 for (i = *idxlen; i < *idxmax; i++)
129 if (m->type == TYPEMULTIPART && m->parts
131 || (parent_type == -1
132 && ascii_strcasecmp ("alternative", m->subtype)))
133 && (!(WithCrypto & APPLICATION_PGP)
134 || !mutt_is_multipart_encrypted (m))
137 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
142 idx[*idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
144 new = idx[(*idxlen)++];
147 new->parent_type = parent_type;
150 /* We don't support multipart messages in the compose menu yet */
151 if (!compose && !m->collapsed &&
152 ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP)
153 || !mutt_is_multipart_encrypted (m))
155 || mutt_is_message_type (m->type, m->subtype))) {
157 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
164 mutt_update_tree (idx, *idxlen);
169 /* %c = character set: convert?
173 * %e = MIME content-transfer-encoding
175 * %I = content-disposition, either I (inline) or A (attachment)
178 * %m = major MIME type
180 * %n = attachment number
184 const char *mutt_attach_fmt (char *dest,
189 const char *ifstring,
190 const char *elsestring,
191 unsigned long data, format_flag flags)
194 char tmp[SHORT_STRING];
195 char charset[SHORT_STRING];
196 ATTACHPTR *aptr = (ATTACHPTR *) data;
197 int optional = (flags & M_FORMAT_OPTIONAL);
203 if (mutt_is_text_part (aptr->content) &&
204 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
205 mutt_format_s (dest, destlen, prefix, charset);
207 mutt_format_s (dest, destlen, prefix, "");
209 else if (!mutt_is_text_part (aptr->content) ||
210 !mutt_get_body_charset (charset, sizeof (charset),
217 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
218 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
219 aptr->content->noconv ? 'n' : 'c');
221 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
226 if (aptr->content->description) {
227 mutt_format_s (dest, destlen, prefix, aptr->content->description);
230 if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
231 && MsgFmt && aptr->content->hdr) {
232 char s[SHORT_STRING];
234 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
235 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
236 M_FORMAT_ARROWCURSOR);
238 mutt_format_s (dest, destlen, prefix, s);
242 if (!aptr->content->filename) {
243 mutt_format_s (dest, destlen, prefix, "<no description>");
247 else if (aptr->content->description ||
248 (mutt_is_message_type
249 (aptr->content->type, aptr->content->subtype)
250 && MsgFmt && aptr->content->hdr))
252 /* FALLS THROUGH TO 'f' */
255 if (aptr->content->filename && *aptr->content->filename == '/') {
256 char path[_POSIX_PATH_MAX];
258 strfcpy (path, aptr->content->filename, sizeof (path));
259 mutt_pretty_mailbox (path);
260 mutt_format_s (dest, destlen, prefix, path);
263 mutt_format_s (dest, destlen, prefix,
264 NONULL (aptr->content->filename));
266 else if (!aptr->content->filename)
271 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
272 else if (!aptr->content->deleted)
277 mutt_format_s (dest, destlen, prefix,
278 ENCODING (aptr->content->encoding));
282 snprintf (dest, destlen, "%c",
283 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
288 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
292 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
293 else if (!aptr->content->subtype)
298 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
299 snprintf (dest, destlen, fmt, aptr->num + 1);
303 if (flags & M_FORMAT_STAT_FILE) {
306 stat (aptr->content->filename, &st);
310 l = aptr->content->length;
313 mutt_pretty_size (tmp, sizeof (tmp), l);
314 mutt_format_s (dest, destlen, prefix, tmp);
322 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
323 else if (!aptr->content->tagged)
328 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
329 else if (!aptr->tree)
334 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
335 else if (!aptr->content->unlink)
343 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
344 else if (flags & M_FORMAT_OPTIONAL)
345 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
349 void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
351 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
352 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
353 M_FORMAT_ARROWCURSOR);
356 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
358 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
359 int ot = cur->tagged;
361 cur->tagged = (m >= 0 ? m : !cur->tagged);
362 return cur->tagged - ot;
365 int mutt_is_message_type (int type, const char *subtype)
367 if (type != TYPEMESSAGE)
370 subtype = NONULL (subtype);
371 return (ascii_strcasecmp (subtype, "rfc822") == 0
372 || ascii_strcasecmp (subtype, "news") == 0);
375 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
379 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
380 char path[_POSIX_PATH_MAX] = "";
386 if (body->filename) {
387 if (directory && *directory)
388 mutt_concat_path (buf, *directory, mutt_basename (body->filename),
391 strfcpy (buf, body->filename, sizeof (buf));
393 else if (body->hdr &&
394 body->encoding != ENCBASE64 &&
395 body->encoding != ENCQUOTEDPRINTABLE &&
396 mutt_is_message_type (body->type, body->subtype))
397 mutt_default_save (buf, sizeof (buf), body->hdr);
401 prompt = _("Save to file ('#' for last used folder): ");
404 mutt_get_field (prompt, buf, sizeof (buf),
405 M_FILE | M_CLEAR | M_LASTFOLDER);
406 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
410 char tmpbuf[_POSIX_PATH_MAX];
412 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
413 strfcpy (buf, tmpbuf, sizeof (buf));
414 ret = mutt_get_field (_("Save to file: ")
415 , buf, sizeof (buf), M_FILE);
416 if ((ret != 0) || (!buf[0]))
420 mutt_extract_path (buf, path);
421 strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder));
425 mutt_expand_path (buf, sizeof (buf));
429 body->encoding != ENCBASE64 &&
430 body->encoding != ENCQUOTEDPRINTABLE &&
431 mutt_is_message_type (body->type, body->subtype));
436 /* check to make sure that this file is really the one the user wants */
437 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
438 prompt = _("Save to file: ");
443 strfcpy (tfile, buf, sizeof (tfile));
447 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
448 &append, directory)) == -1)
451 prompt = _("Save to file: ");
456 mutt_message _("Saving...");
458 if (mutt_save_attachment
459 (fp, body, tfile, append,
460 (hdr || !is_message) ? hdr : body->hdr) == 0) {
461 mutt_message _("Attachment saved.");
466 prompt = _("Save to file: ");
473 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
476 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
477 char *directory = NULL;
479 int last = menu ? menu->current : -1;
484 for (; top; top = top->next) {
485 if (!tag || top->tagged) {
486 if (!option (OPTATTACHSPLIT)) {
490 strfcpy (buf, NONULL (top->filename), sizeof (buf));
491 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
492 M_FILE | M_CLEAR) != 0 || !buf[0])
494 mutt_expand_path (buf, sizeof (buf));
495 if (mutt_check_overwrite (top->filename, buf, tfile,
496 sizeof (tfile), &append, NULL))
498 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
499 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
500 fprintf (fpout, "%s", AttachSep);
505 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
506 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
507 fprintf (fpout, "%s", AttachSep);
513 if (tag && menu && top->aptr) {
514 menu->oldcurrent = menu->current;
515 menu->current = top->aptr->num;
516 menu_check_recenter (menu);
517 menu->redraw |= REDRAW_MOTION;
521 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
526 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
534 menu->oldcurrent = menu->current;
535 menu->current = last;
536 menu_check_recenter (menu);
537 menu->redraw |= REDRAW_MOTION;
540 if (!option (OPTATTACHSPLIT) && (rc == 0))
541 mutt_message _("Attachment saved.");
545 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int filter)
547 char tfile[_POSIX_PATH_MAX];
548 char warning[STRING + _POSIX_PATH_MAX];
551 snprintf (warning, sizeof (warning),
552 _("WARNING! You are about to overwrite %s, continue?"),
554 if (mutt_yesorno (warning, M_NO) != M_YES) {
555 CLEARLINE (LINES - 1);
563 if (mutt_pipe_attachment (fp, body, command, tfile)) {
565 mutt_unlink (body->filename);
566 mutt_rename_file (tfile, body->filename);
567 mutt_update_encoding (body);
568 mutt_message _("Attachment filtered.");
572 if (filter && tfile[0])
577 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
583 mutt_decode_attachment (b, state);
585 state_puts (AttachSep, state);
588 if ((ifp = fopen (b->filename, "r")) == NULL) {
589 mutt_perror ("fopen");
592 mutt_copy_stream (ifp, state->fpout);
595 state_puts (AttachSep, state);
600 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
601 int filter, STATE * state)
603 for (; top; top = top->next) {
604 if (!tag || top->tagged) {
605 if (!filter && !option (OPTATTACHSPLIT))
606 pipe_attachment (fp, top, state);
608 mutt_query_pipe_attachment (command, fp, top, filter);
611 pipe_attachment_list (command, fp, tag, top->parts, filter, state);
617 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
620 char buf[SHORT_STRING];
624 filter = 0; /* sanity check: we can't filter in the recv case yet */
627 memset (&state, 0, sizeof (STATE));
629 if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
630 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
633 mutt_expand_path (buf, sizeof (buf));
635 if (!filter && !option (OPTATTACHSPLIT)) {
637 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
638 pipe_attachment_list (buf, fp, tag, top, filter, &state);
639 fclose (state.fpout);
640 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
641 mutt_any_key_to_continue (NULL);
644 pipe_attachment_list (buf, fp, tag, top, filter, &state);
647 static int can_print (BODY * top, int tag)
651 for (; top; top = top->next) {
652 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
653 if (!tag || top->tagged) {
654 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
655 if (ascii_strcasecmp ("text/plain", top->subtype) &&
656 ascii_strcasecmp ("application/postscript", top->subtype)) {
657 if (!mutt_can_decode (top)) {
658 mutt_error (_("I dont know how to print %s attachments!"), type);
665 return (can_print (top->parts, tag));
672 static void print_attachment_list (FILE * fp, int tag, BODY * top,
678 for (; top; top = top->next) {
679 if (!tag || top->tagged) {
680 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
681 if (!option (OPTATTACHSPLIT)
682 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
683 if (!ascii_strcasecmp ("text/plain", top->subtype)
684 || !ascii_strcasecmp ("application/postscript", top->subtype))
685 pipe_attachment (fp, top, state);
686 else if (mutt_can_decode (top)) {
687 /* decode and print */
689 char newfile[_POSIX_PATH_MAX] = "";
692 mutt_mktemp (newfile);
693 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
695 if ((ifp = fopen (newfile, "r")) != NULL) {
696 mutt_copy_stream (ifp, state->fpout);
699 state_puts (AttachSep, state);
702 mutt_unlink (newfile);
706 mutt_print_attachment (fp, top);
709 print_attachment_list (fp, tag, top->parts, state);
715 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
723 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
727 if (!option (OPTATTACHSPLIT)) {
728 if (!can_print (top, tag))
731 memset (&state, 0, sizeof (STATE));
732 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
733 print_attachment_list (fp, tag, top, &state);
734 fclose (state.fpout);
735 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
736 mutt_any_key_to_continue (NULL);
739 print_attachment_list (fp, tag, top, &state);
743 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
744 short *idxlen, short *idxmax, MUTTMENU * menu)
746 ATTACHPTR **idx = *idxp;
748 while (--(*idxlen) >= 0)
749 idx[(*idxlen)]->content = NULL;
752 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
757 if (menu->current >= menu->max)
758 menu->current = menu->max - 1;
759 menu_check_recenter (menu);
760 menu->redraw |= REDRAW_INDEX;
766 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
767 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
768 short *idxmax, int recv)
770 ATTACHPTR **idx = *idxp;
773 int old_optweed = option (OPTWEED);
775 set_option (OPTWEED);
780 case OP_DISPLAY_HEADERS:
781 toggle_option (OPTWEED);
785 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
790 case OP_MAIN_NEXT_UNDELETED: /* hack */
791 if (menu->current < menu->max - 1) {
799 case OP_MAIN_PREV_UNDELETED: /* hack */
800 if (menu->current > 0) {
808 /* when we edit the content-type, we should redisplay the attachment
810 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
812 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
817 /* functions which are passed through from the pager */
818 case OP_CHECK_TRADITIONAL:
819 if (!(WithCrypto & APPLICATION_PGP)
820 || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) {
825 case OP_ATTACH_COLLAPSE:
832 while (op != OP_NULL);
835 if (option (OPTWEED) != old_optweed)
836 toggle_option (OPTWEED);
841 static void attach_collapse (BODY * b, short collapse, short init,
846 for (; b; b = b->next) {
847 i = init || b->collapsed;
848 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
849 && !ascii_strcasecmp (b->subtype, "digest"))
850 attach_collapse (b->parts, 1, 1, 0);
851 else if (b->type == TYPEMULTIPART
852 || mutt_is_message_type (b->type, b->subtype))
853 attach_collapse (b->parts, collapse, i, 0);
854 b->collapsed = collapse;
860 void mutt_attach_init (BODY * b)
862 for (; b; b = b->next) {
866 mutt_attach_init (b->parts);
870 static const char *Function_not_permitted =
871 N_("Function not permitted in attach-message mode.");
873 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
876 mutt_error _(Function_not_permitted); \
883 void mutt_view_attachments (HEADER * hdr)
886 int need_secured = 0;
888 char helpstr[SHORT_STRING];
893 ATTACHPTR **idx = NULL;
899 /* make sure we have parsed this message */
900 mutt_parse_mime_message (Context, hdr);
902 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
904 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
908 if (WithCrypto && ((hdr->security & ENCRYPT) ||
909 (mutt_is_application_smime (hdr->content) &
913 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
914 mx_close_message (&msg);
917 if ((WithCrypto & APPLICATION_SMIME)
918 && (hdr->security & APPLICATION_SMIME)) {
920 crypt_smime_getkeys (hdr->env);
922 if (mutt_is_application_smime (hdr->content)) {
923 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
927 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
933 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
935 mutt_free_body (&_cur);
942 if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) {
943 if (mutt_is_multipart_encrypted (hdr->content))
944 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
949 if (need_secured && !secured) {
950 mx_close_message (&msg);
951 mutt_error _("Can't decrypt encrypted message!");
957 if (!WithCrypto || !need_secured) {
962 menu = mutt_new_menu ();
963 menu->menu = MENU_ATTACH;
964 menu->title = _("Attachments");
965 menu->make_entry = attach_entry;
966 menu->tag = mutt_tag_attach;
968 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
970 mutt_attach_init (cur);
971 attach_collapse (cur, 0, 1, 0);
972 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
976 op = mutt_menuLoop (menu);
978 case OP_ATTACH_VIEW_MAILCAP:
979 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
981 menu->redraw = REDRAW_FULL;
984 case OP_ATTACH_VIEW_TEXT:
985 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
987 menu->redraw = REDRAW_FULL;
990 case OP_DISPLAY_HEADERS:
993 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
995 menu->redraw = REDRAW_FULL;
998 case OP_ATTACH_COLLAPSE:
999 if (!idx[menu->current]->content->parts) {
1000 mutt_error _("There are no subparts to show!");
1004 if (!idx[menu->current]->content->collapsed)
1005 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1007 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1008 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1011 case OP_FORGET_PASSPHRASE:
1012 crypt_forget_passphrase ();
1015 case OP_EXTRACT_KEYS:
1016 if ((WithCrypto & APPLICATION_PGP)) {
1017 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1020 idx[menu->current]->
1022 menu->redraw = REDRAW_FULL;
1026 case OP_CHECK_TRADITIONAL:
1027 if ((WithCrypto & APPLICATION_PGP)
1028 && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1029 : idx[menu->current]->content,
1031 hdr->security = crypt_query (cur);
1032 menu->redraw = REDRAW_FULL;
1037 mutt_print_attachment_list (fp, menu->tagprefix,
1038 menu->tagprefix ? cur : idx[menu->current]->
1043 mutt_pipe_attachment_list (fp, menu->tagprefix,
1044 menu->tagprefix ? cur : idx[menu->current]->
1049 mutt_save_attachment_list (fp, menu->tagprefix,
1050 menu->tagprefix ? cur : idx[menu->current]->
1051 content, hdr, menu);
1053 if (!menu->tagprefix && option (OPTRESOLVE)
1054 && menu->current < menu->max - 1)
1057 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1064 if (Context->magic == M_POP) {
1066 mutt_error _("Can't delete attachment from POP server.");
1073 if (Context->magic == M_NNTP) {
1075 mutt_error _("Can't delete attachment from newsserver.");
1081 if (WithCrypto && hdr->security) {
1084 ("Deletion of attachments from encrypted messages is unsupported.");
1087 if (!menu->tagprefix) {
1088 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1089 idx[menu->current]->content->deleted = 1;
1090 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1092 menu->redraw = REDRAW_MOTION_RESYNCH;
1095 menu->redraw = REDRAW_CURRENT;
1099 _("Only deletion of multipart attachments is supported.");
1104 for (x = 0; x < menu->max; x++) {
1105 if (idx[x]->content->tagged) {
1106 if (idx[x]->parent_type == TYPEMULTIPART) {
1107 idx[x]->content->deleted = 1;
1108 menu->redraw = REDRAW_INDEX;
1112 _("Only deletion of multipart attachments is supported.");
1121 if (!menu->tagprefix) {
1122 idx[menu->current]->content->deleted = 0;
1123 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1125 menu->redraw = REDRAW_MOTION_RESYNCH;
1128 menu->redraw = REDRAW_CURRENT;
1133 for (x = 0; x < menu->max; x++) {
1134 if (idx[x]->content->tagged) {
1135 idx[x]->content->deleted = 0;
1136 menu->redraw = REDRAW_INDEX;
1144 mutt_attach_resend (fp, hdr, idx, idxlen,
1145 menu->tagprefix ? NULL : idx[menu->current]->
1147 menu->redraw = REDRAW_FULL;
1150 case OP_BOUNCE_MESSAGE:
1152 mutt_attach_bounce (fp, hdr, idx, idxlen,
1153 menu->tagprefix ? NULL : idx[menu->current]->
1155 menu->redraw = REDRAW_FULL;
1158 case OP_FORWARD_MESSAGE:
1160 mutt_attach_forward (fp, hdr, idx, idxlen,
1161 menu->tagprefix ? NULL : idx[menu->current]->
1163 menu->redraw = REDRAW_FULL;
1167 case OP_FORWARD_TO_GROUP:
1169 mutt_attach_forward (fp, hdr, idx, idxlen,
1170 menu->tagprefix ? NULL : idx[menu->current]->
1172 menu->redraw = REDRAW_FULL;
1178 if (!idx[menu->current]->content->hdr->env->followup_to ||
1179 mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to,
1181 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1182 _("Reply by mail as poster prefers?")) !=
1184 mutt_attach_reply (fp, hdr, idx, idxlen,
1185 menu->tagprefix ? NULL : idx[menu->current]->
1186 content, SENDNEWS | SENDREPLY);
1187 menu->redraw = REDRAW_FULL;
1193 case OP_GROUP_REPLY:
1199 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1200 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1201 mutt_attach_reply (fp, hdr, idx, idxlen,
1202 menu->tagprefix ? NULL : idx[menu->current]->content,
1204 menu->redraw = REDRAW_FULL;
1208 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1209 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1213 mx_close_message (&msg);
1214 hdr->attach_del = 0;
1215 while (idxmax-- > 0) {
1218 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1219 hdr->attach_del = 1;
1220 if (idx[idxmax]->content)
1221 idx[idxmax]->content->aptr = NULL;
1222 FREE (&idx[idxmax]->tree);
1223 FREE (&idx[idxmax]);
1225 if (hdr->attach_del)
1230 if (WithCrypto && need_secured && secured) {
1232 mutt_free_body (&cur);
1235 mutt_menuDestroy (&menu);