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"
35 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
36 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
38 #define CHECK_READONLY if (Context->readonly) \
41 mutt_error _(Mailbox_is_read_only); \
45 static struct mapping_t AttachHelp[] = {
46 {N_("Exit"), OP_EXIT},
47 {N_("Save"), OP_SAVE},
48 {N_("Pipe"), OP_PIPE},
49 {N_("Print"), OP_PRINT},
50 {N_("Help"), OP_HELP},
54 int mutt_extract_path (char *filename, char *path)
56 char *tmp = safe_malloc (sizeof (char) * _POSIX_PATH_MAX);
61 while (*filename != '\0') {
62 if (*filename == '/') {
63 *help_ptr++ = *filename++;
68 *help_ptr++ = *filename++;
74 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
80 for (x = 0; x < idxlen; x++) {
82 if (2 * (idx[x]->level + 2) < sizeof (buf)) {
84 s = buf + 2 * (idx[x]->level - 1);
85 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
95 if (mutt_strcmp (idx[x]->tree, buf) != 0)
96 mutt_str_replace (&idx[x]->tree, buf);
99 idx[x]->tree = safe_strdup (buf);
101 if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
102 s = buf + 2 * (idx[x]->level - 1);
103 *s++ = (idx[x]->content->next) ? '\005' : '\006';
109 ATTACHPTR **mutt_gen_attach_list (BODY * m,
113 short *idxmax, int level, int compose)
118 for (; m; m = m->next) {
119 if (*idxlen == *idxmax) {
120 safe_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
121 for (i = *idxlen; i < *idxmax; i++)
125 if (m->type == TYPEMULTIPART && m->parts
127 || (parent_type == -1
128 && ascii_strcasecmp ("alternative", m->subtype)))
129 && (!(WithCrypto & APPLICATION_PGP)
130 || !mutt_is_multipart_encrypted (m))
133 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
138 idx[*idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
140 new = idx[(*idxlen)++];
143 new->parent_type = parent_type;
146 /* We don't support multipart messages in the compose menu yet */
147 if (!compose && !m->collapsed &&
148 ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP)
149 || !mutt_is_multipart_encrypted (m))
151 || mutt_is_message_type (m->type, m->subtype))) {
153 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
160 mutt_update_tree (idx, *idxlen);
165 /* %c = character set: convert?
169 * %e = MIME content-transfer-encoding
171 * %I = content-disposition, either I (inline) or A (attachment)
174 * %m = major MIME type
176 * %n = attachment number
180 const char *mutt_attach_fmt (char *dest,
185 const char *ifstring,
186 const char *elsestring,
187 unsigned long data, format_flag flags)
190 char tmp[SHORT_STRING];
191 char charset[SHORT_STRING];
192 ATTACHPTR *aptr = (ATTACHPTR *) data;
193 int optional = (flags & M_FORMAT_OPTIONAL);
199 if (mutt_is_text_part (aptr->content) &&
200 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
201 mutt_format_s (dest, destlen, prefix, charset);
203 mutt_format_s (dest, destlen, prefix, "");
205 else if (!mutt_is_text_part (aptr->content) ||
206 !mutt_get_body_charset (charset, sizeof (charset),
213 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
214 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
215 aptr->content->noconv ? 'n' : 'c');
217 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
222 if (aptr->content->description) {
223 mutt_format_s (dest, destlen, prefix, aptr->content->description);
226 if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
227 && MsgFmt && aptr->content->hdr) {
228 char s[SHORT_STRING];
230 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
231 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
232 M_FORMAT_ARROWCURSOR);
234 mutt_format_s (dest, destlen, prefix, s);
238 if (!aptr->content->filename) {
239 mutt_format_s (dest, destlen, prefix, "<no description>");
243 else if (aptr->content->description ||
244 (mutt_is_message_type
245 (aptr->content->type, aptr->content->subtype)
246 && MsgFmt && aptr->content->hdr))
248 /* FALLS THROUGH TO 'f' */
251 if (aptr->content->filename && *aptr->content->filename == '/') {
252 char path[_POSIX_PATH_MAX];
254 strfcpy (path, aptr->content->filename, sizeof (path));
255 mutt_pretty_mailbox (path);
256 mutt_format_s (dest, destlen, prefix, path);
259 mutt_format_s (dest, destlen, prefix,
260 NONULL (aptr->content->filename));
262 else if (!aptr->content->filename)
267 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
268 else if (!aptr->content->deleted)
273 mutt_format_s (dest, destlen, prefix,
274 ENCODING (aptr->content->encoding));
278 snprintf (dest, destlen, "%c",
279 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
284 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
288 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
289 else if (!aptr->content->subtype)
294 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
295 snprintf (dest, destlen, fmt, aptr->num + 1);
299 if (flags & M_FORMAT_STAT_FILE) {
302 stat (aptr->content->filename, &st);
306 l = aptr->content->length;
309 mutt_pretty_size (tmp, sizeof (tmp), l);
310 mutt_format_s (dest, destlen, prefix, tmp);
318 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
319 else if (!aptr->content->tagged)
324 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
325 else if (!aptr->tree)
330 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
331 else if (!aptr->content->unlink)
339 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
340 else if (flags & M_FORMAT_OPTIONAL)
341 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
345 void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
347 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
348 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
349 M_FORMAT_ARROWCURSOR);
352 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
354 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
355 int ot = cur->tagged;
357 cur->tagged = (m >= 0 ? m : !cur->tagged);
358 return cur->tagged - ot;
361 int mutt_is_message_type (int type, const char *subtype)
363 if (type != TYPEMESSAGE)
366 subtype = NONULL (subtype);
367 return (ascii_strcasecmp (subtype, "rfc822") == 0
368 || ascii_strcasecmp (subtype, "news") == 0);
371 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
375 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
376 char path[_POSIX_PATH_MAX] = "";
382 if (body->filename) {
383 if (directory && *directory)
384 mutt_concat_path (buf, *directory, mutt_basename (body->filename),
387 strfcpy (buf, body->filename, sizeof (buf));
389 else if (body->hdr &&
390 body->encoding != ENCBASE64 &&
391 body->encoding != ENCQUOTEDPRINTABLE &&
392 mutt_is_message_type (body->type, body->subtype))
393 mutt_default_save (buf, sizeof (buf), body->hdr);
397 prompt = _("Save to file ('#' for last used folder): ");
400 mutt_get_field (prompt, buf, sizeof (buf),
401 M_FILE | M_CLEAR | M_LASTFOLDER);
402 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
406 char tmpbuf[_POSIX_PATH_MAX];
408 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
409 strfcpy (buf, tmpbuf, sizeof (buf));
410 ret = mutt_get_field (_("Save to file: ")
411 , buf, sizeof (buf), M_FILE);
412 if ((ret != 0) || (!buf[0]))
416 mutt_extract_path (buf, path);
417 strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder));
421 mutt_expand_path (buf, sizeof (buf));
425 body->encoding != ENCBASE64 &&
426 body->encoding != ENCQUOTEDPRINTABLE &&
427 mutt_is_message_type (body->type, body->subtype));
432 /* check to make sure that this file is really the one the user wants */
433 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
434 prompt = _("Save to file: ");
439 strfcpy (tfile, buf, sizeof (tfile));
443 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
444 &append, directory)) == -1)
447 prompt = _("Save to file: ");
452 mutt_message _("Saving...");
454 if (mutt_save_attachment
455 (fp, body, tfile, append,
456 (hdr || !is_message) ? hdr : body->hdr) == 0) {
457 mutt_message _("Attachment saved.");
462 prompt = _("Save to file: ");
469 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
472 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
473 char *directory = NULL;
475 int last = menu ? menu->current : -1;
480 for (; top; top = top->next) {
481 if (!tag || top->tagged) {
482 if (!option (OPTATTACHSPLIT)) {
486 strfcpy (buf, NONULL (top->filename), sizeof (buf));
487 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
488 M_FILE | M_CLEAR) != 0 || !buf[0])
490 mutt_expand_path (buf, sizeof (buf));
491 if (mutt_check_overwrite (top->filename, buf, tfile,
492 sizeof (tfile), &append, NULL))
494 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
495 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
496 fprintf (fpout, "%s", AttachSep);
501 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
502 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
503 fprintf (fpout, "%s", AttachSep);
509 if (tag && menu && top->aptr) {
510 menu->oldcurrent = menu->current;
511 menu->current = top->aptr->num;
512 menu_check_recenter (menu);
513 menu->redraw |= REDRAW_MOTION;
517 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
522 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
530 menu->oldcurrent = menu->current;
531 menu->current = last;
532 menu_check_recenter (menu);
533 menu->redraw |= REDRAW_MOTION;
536 if (!option (OPTATTACHSPLIT) && (rc == 0))
537 mutt_message _("Attachment saved.");
541 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int filter)
543 char tfile[_POSIX_PATH_MAX];
544 char warning[STRING + _POSIX_PATH_MAX];
547 snprintf (warning, sizeof (warning),
548 _("WARNING! You are about to overwrite %s, continue?"),
550 if (mutt_yesorno (warning, M_NO) != M_YES) {
551 CLEARLINE (LINES - 1);
559 if (mutt_pipe_attachment (fp, body, command, tfile)) {
561 mutt_unlink (body->filename);
562 mutt_rename_file (tfile, body->filename);
563 mutt_update_encoding (body);
564 mutt_message _("Attachment filtered.");
568 if (filter && tfile[0])
573 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
579 mutt_decode_attachment (b, state);
581 state_puts (AttachSep, state);
584 if ((ifp = fopen (b->filename, "r")) == NULL) {
585 mutt_perror ("fopen");
588 mutt_copy_stream (ifp, state->fpout);
591 state_puts (AttachSep, state);
596 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
597 int filter, STATE * state)
599 for (; top; top = top->next) {
600 if (!tag || top->tagged) {
601 if (!filter && !option (OPTATTACHSPLIT))
602 pipe_attachment (fp, top, state);
604 mutt_query_pipe_attachment (command, fp, top, filter);
607 pipe_attachment_list (command, fp, tag, top->parts, filter, state);
613 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
616 char buf[SHORT_STRING];
620 filter = 0; /* sanity check: we can't filter in the recv case yet */
623 memset (&state, 0, sizeof (STATE));
625 if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
626 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
629 mutt_expand_path (buf, sizeof (buf));
631 if (!filter && !option (OPTATTACHSPLIT)) {
633 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
634 pipe_attachment_list (buf, fp, tag, top, filter, &state);
635 fclose (state.fpout);
636 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
637 mutt_any_key_to_continue (NULL);
640 pipe_attachment_list (buf, fp, tag, top, filter, &state);
643 static int can_print (BODY * top, int tag)
647 for (; top; top = top->next) {
648 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
649 if (!tag || top->tagged) {
650 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
651 if (ascii_strcasecmp ("text/plain", top->subtype) &&
652 ascii_strcasecmp ("application/postscript", top->subtype)) {
653 if (!mutt_can_decode (top)) {
654 mutt_error (_("I dont know how to print %s attachments!"), type);
661 return (can_print (top->parts, tag));
668 static void print_attachment_list (FILE * fp, int tag, BODY * top,
674 for (; top; top = top->next) {
675 if (!tag || top->tagged) {
676 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
677 if (!option (OPTATTACHSPLIT)
678 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
679 if (!ascii_strcasecmp ("text/plain", top->subtype)
680 || !ascii_strcasecmp ("application/postscript", top->subtype))
681 pipe_attachment (fp, top, state);
682 else if (mutt_can_decode (top)) {
683 /* decode and print */
685 char newfile[_POSIX_PATH_MAX] = "";
688 mutt_mktemp (newfile);
689 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
691 if ((ifp = fopen (newfile, "r")) != NULL) {
692 mutt_copy_stream (ifp, state->fpout);
695 state_puts (AttachSep, state);
698 mutt_unlink (newfile);
702 mutt_print_attachment (fp, top);
705 print_attachment_list (fp, tag, top->parts, state);
711 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
719 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
723 if (!option (OPTATTACHSPLIT)) {
724 if (!can_print (top, tag))
727 memset (&state, 0, sizeof (STATE));
728 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
729 print_attachment_list (fp, tag, top, &state);
730 fclose (state.fpout);
731 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
732 mutt_any_key_to_continue (NULL);
735 print_attachment_list (fp, tag, top, &state);
739 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
740 short *idxlen, short *idxmax, MUTTMENU * menu)
742 ATTACHPTR **idx = *idxp;
744 while (--(*idxlen) >= 0)
745 idx[(*idxlen)]->content = NULL;
748 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
753 if (menu->current >= menu->max)
754 menu->current = menu->max - 1;
755 menu_check_recenter (menu);
756 menu->redraw |= REDRAW_INDEX;
762 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
763 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
764 short *idxmax, int recv)
766 ATTACHPTR **idx = *idxp;
769 int old_optweed = option (OPTWEED);
771 set_option (OPTWEED);
776 case OP_DISPLAY_HEADERS:
777 toggle_option (OPTWEED);
781 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
786 case OP_MAIN_NEXT_UNDELETED: /* hack */
787 if (menu->current < menu->max - 1) {
795 case OP_MAIN_PREV_UNDELETED: /* hack */
796 if (menu->current > 0) {
804 /* when we edit the content-type, we should redisplay the attachment
806 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
808 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
813 /* functions which are passed through from the pager */
814 case OP_CHECK_TRADITIONAL:
815 if (!(WithCrypto & APPLICATION_PGP)
816 || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) {
821 case OP_ATTACH_COLLAPSE:
828 while (op != OP_NULL);
831 if (option (OPTWEED) != old_optweed)
832 toggle_option (OPTWEED);
837 static void attach_collapse (BODY * b, short collapse, short init,
842 for (; b; b = b->next) {
843 i = init || b->collapsed;
844 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
845 && !ascii_strcasecmp (b->subtype, "digest"))
846 attach_collapse (b->parts, 1, 1, 0);
847 else if (b->type == TYPEMULTIPART
848 || mutt_is_message_type (b->type, b->subtype))
849 attach_collapse (b->parts, collapse, i, 0);
850 b->collapsed = collapse;
856 void mutt_attach_init (BODY * b)
858 for (; b; b = b->next) {
862 mutt_attach_init (b->parts);
866 static const char *Function_not_permitted =
867 N_("Function not permitted in attach-message mode.");
869 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
872 mutt_error _(Function_not_permitted); \
879 void mutt_view_attachments (HEADER * hdr)
882 int need_secured = 0;
884 char helpstr[SHORT_STRING];
889 ATTACHPTR **idx = NULL;
895 /* make sure we have parsed this message */
896 mutt_parse_mime_message (Context, hdr);
898 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
900 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
904 if (WithCrypto && ((hdr->security & ENCRYPT) ||
905 (mutt_is_application_smime (hdr->content) &
909 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
910 mx_close_message (&msg);
913 if ((WithCrypto & APPLICATION_SMIME)
914 && (hdr->security & APPLICATION_SMIME)) {
916 crypt_smime_getkeys (hdr->env);
918 if (mutt_is_application_smime (hdr->content)) {
919 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
923 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
929 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
931 mutt_free_body (&_cur);
938 if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) {
939 if (mutt_is_multipart_encrypted (hdr->content))
940 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
945 if (need_secured && !secured) {
946 mx_close_message (&msg);
947 mutt_error _("Can't decrypt encrypted message!");
953 if (!WithCrypto || !need_secured) {
958 menu = mutt_new_menu ();
959 menu->menu = MENU_ATTACH;
960 menu->title = _("Attachments");
961 menu->make_entry = attach_entry;
962 menu->tag = mutt_tag_attach;
964 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
966 mutt_attach_init (cur);
967 attach_collapse (cur, 0, 1, 0);
968 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
972 op = mutt_menuLoop (menu);
974 case OP_ATTACH_VIEW_MAILCAP:
975 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
977 menu->redraw = REDRAW_FULL;
980 case OP_ATTACH_VIEW_TEXT:
981 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
983 menu->redraw = REDRAW_FULL;
986 case OP_DISPLAY_HEADERS:
989 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
991 menu->redraw = REDRAW_FULL;
994 case OP_ATTACH_COLLAPSE:
995 if (!idx[menu->current]->content->parts) {
996 mutt_error _("There are no subparts to show!");
1000 if (!idx[menu->current]->content->collapsed)
1001 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1003 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1004 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1007 case OP_FORGET_PASSPHRASE:
1008 crypt_forget_passphrase ();
1011 case OP_EXTRACT_KEYS:
1012 if ((WithCrypto & APPLICATION_PGP)) {
1013 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1016 idx[menu->current]->
1018 menu->redraw = REDRAW_FULL;
1022 case OP_CHECK_TRADITIONAL:
1023 if ((WithCrypto & APPLICATION_PGP)
1024 && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1025 : idx[menu->current]->content,
1027 hdr->security = crypt_query (cur);
1028 menu->redraw = REDRAW_FULL;
1033 mutt_print_attachment_list (fp, menu->tagprefix,
1034 menu->tagprefix ? cur : idx[menu->current]->
1039 mutt_pipe_attachment_list (fp, menu->tagprefix,
1040 menu->tagprefix ? cur : idx[menu->current]->
1045 mutt_save_attachment_list (fp, menu->tagprefix,
1046 menu->tagprefix ? cur : idx[menu->current]->
1047 content, hdr, menu);
1049 if (!menu->tagprefix && option (OPTRESOLVE)
1050 && menu->current < menu->max - 1)
1053 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1060 if (Context->magic == M_POP) {
1062 mutt_error _("Can't delete attachment from POP server.");
1069 if (Context->magic == M_NNTP) {
1071 mutt_error _("Can't delete attachment from newsserver.");
1077 if (WithCrypto && hdr->security) {
1080 ("Deletion of attachments from encrypted messages is unsupported.");
1083 if (!menu->tagprefix) {
1084 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1085 idx[menu->current]->content->deleted = 1;
1086 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1088 menu->redraw = REDRAW_MOTION_RESYNCH;
1091 menu->redraw = REDRAW_CURRENT;
1095 _("Only deletion of multipart attachments is supported.");
1100 for (x = 0; x < menu->max; x++) {
1101 if (idx[x]->content->tagged) {
1102 if (idx[x]->parent_type == TYPEMULTIPART) {
1103 idx[x]->content->deleted = 1;
1104 menu->redraw = REDRAW_INDEX;
1108 _("Only deletion of multipart attachments is supported.");
1117 if (!menu->tagprefix) {
1118 idx[menu->current]->content->deleted = 0;
1119 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1121 menu->redraw = REDRAW_MOTION_RESYNCH;
1124 menu->redraw = REDRAW_CURRENT;
1129 for (x = 0; x < menu->max; x++) {
1130 if (idx[x]->content->tagged) {
1131 idx[x]->content->deleted = 0;
1132 menu->redraw = REDRAW_INDEX;
1140 mutt_attach_resend (fp, hdr, idx, idxlen,
1141 menu->tagprefix ? NULL : idx[menu->current]->
1143 menu->redraw = REDRAW_FULL;
1146 case OP_BOUNCE_MESSAGE:
1148 mutt_attach_bounce (fp, hdr, idx, idxlen,
1149 menu->tagprefix ? NULL : idx[menu->current]->
1151 menu->redraw = REDRAW_FULL;
1154 case OP_FORWARD_MESSAGE:
1156 mutt_attach_forward (fp, hdr, idx, idxlen,
1157 menu->tagprefix ? NULL : idx[menu->current]->
1159 menu->redraw = REDRAW_FULL;
1163 case OP_FORWARD_TO_GROUP:
1165 mutt_attach_forward (fp, hdr, idx, idxlen,
1166 menu->tagprefix ? NULL : idx[menu->current]->
1168 menu->redraw = REDRAW_FULL;
1174 if (!idx[menu->current]->content->hdr->env->followup_to ||
1175 mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to,
1177 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1178 _("Reply by mail as poster prefers?")) !=
1180 mutt_attach_reply (fp, hdr, idx, idxlen,
1181 menu->tagprefix ? NULL : idx[menu->current]->
1182 content, SENDNEWS | SENDREPLY);
1183 menu->redraw = REDRAW_FULL;
1189 case OP_GROUP_REPLY:
1195 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1196 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1197 mutt_attach_reply (fp, hdr, idx, idxlen,
1198 menu->tagprefix ? NULL : idx[menu->current]->content,
1200 menu->redraw = REDRAW_FULL;
1204 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1205 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1209 mx_close_message (&msg);
1210 hdr->attach_del = 0;
1211 while (idxmax-- > 0) {
1214 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1215 hdr->attach_del = 1;
1216 if (idx[idxmax]->content)
1217 idx[idxmax]->content->aptr = NULL;
1218 FREE (&idx[idxmax]->tree);
1219 FREE (&idx[idxmax]);
1221 if (hdr->attach_del)
1226 if (WithCrypto && need_secured && secured) {
1228 mutt_free_body (&cur);
1231 mutt_menuDestroy (&menu);