2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
3 * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21 #include "mutt_curses.h"
22 #include "mutt_menu.h"
30 #include "mutt_crypt.h"
40 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
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 void mutt_update_tree (ATTACHPTR **idx, short idxlen)
64 for (x = 0; x < idxlen; x++)
67 if (2 * (idx[x]->level + 2) < sizeof (buf))
71 s = buf + 2 * (idx[x]->level - 1);
72 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
83 if (mutt_strcmp (idx[x]->tree, buf) != 0)
84 mutt_str_replace (&idx[x]->tree, buf);
87 idx[x]->tree = safe_strdup (buf);
89 if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level)
91 s = buf + 2 * (idx[x]->level - 1);
92 *s++ = (idx[x]->content->next) ? '\005' : '\006';
98 ATTACHPTR **mutt_gen_attach_list (BODY *m,
109 for (; m; m = m->next)
111 if (*idxlen == *idxmax)
113 safe_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
114 for (i = *idxlen; i < *idxmax; i++)
118 if (m->type == TYPEMULTIPART && m->parts
119 && (compose || (parent_type == -1 && ascii_strcasecmp ("alternative", m->subtype)))
120 && (!(WithCrypto & APPLICATION_PGP) || !mutt_is_multipart_encrypted(m))
123 idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level, compose);
128 idx[*idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
130 new = idx[(*idxlen)++];
133 new->parent_type = parent_type;
136 /* We don't support multipart messages in the compose menu yet */
137 if (!compose && !m->collapsed &&
138 ((m->type == TYPEMULTIPART
139 && (!(WithCrypto & APPLICATION_PGP)
140 || !mutt_is_multipart_encrypted (m))
142 || mutt_is_message_type(m->type, m->subtype)))
144 idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level + 1, compose);
150 mutt_update_tree (idx, *idxlen);
155 /* %c = character set: convert?
159 * %e = MIME content-transfer-encoding
161 * %I = content-disposition, either I (inline) or A (attachment)
164 * %m = major MIME type
166 * %n = attachment number
170 const char *mutt_attach_fmt (char *dest,
175 const char *ifstring,
176 const char *elsestring,
181 char tmp[SHORT_STRING];
182 char charset[SHORT_STRING];
183 ATTACHPTR *aptr = (ATTACHPTR *) data;
184 int optional = (flags & M_FORMAT_OPTIONAL);
192 if (mutt_is_text_part (aptr->content) &&
193 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
194 mutt_format_s (dest, destlen, prefix, charset);
196 mutt_format_s (dest, destlen, prefix, "");
198 else if (!mutt_is_text_part (aptr->content) ||
199 !mutt_get_body_charset (charset, sizeof (charset), aptr->content))
206 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
207 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
208 aptr->content->noconv ? 'n' : 'c');
210 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
216 if (aptr->content->description)
218 mutt_format_s (dest, destlen, prefix, aptr->content->description);
221 if (mutt_is_message_type(aptr->content->type, aptr->content->subtype) &&
222 MsgFmt && aptr->content->hdr)
224 char s[SHORT_STRING];
225 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
226 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR);
229 mutt_format_s (dest, destlen, prefix, s);
233 if (!aptr->content->filename)
235 mutt_format_s (dest, destlen, prefix, "<no description>");
239 else if(aptr->content->description ||
240 (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
241 && MsgFmt && aptr->content->hdr))
243 /* FALLS THROUGH TO 'f' */
247 if (aptr->content->filename && *aptr->content->filename == '/')
249 char path[_POSIX_PATH_MAX];
251 strfcpy (path, aptr->content->filename, sizeof (path));
252 mutt_pretty_mailbox (path);
253 mutt_format_s (dest, destlen, prefix, path);
256 mutt_format_s (dest, destlen, prefix, NONULL (aptr->content->filename));
258 else if(!aptr->content->filename)
263 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
264 else if(!aptr->content->deleted)
269 mutt_format_s (dest, destlen, prefix,
270 ENCODING (aptr->content->encoding));
275 snprintf (dest, destlen, "%c",
276 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
281 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
285 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
286 else if(!aptr->content->subtype)
292 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
293 snprintf (dest, destlen, fmt, aptr->num + 1);
297 if (flags & M_FORMAT_STAT_FILE)
300 stat (aptr->content->filename, &st);
304 l = aptr->content->length;
308 mutt_pretty_size (tmp, sizeof(tmp), l);
309 mutt_format_s (dest, destlen, prefix, tmp);
317 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
318 else if(!aptr->content->tagged)
323 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
324 else if (!aptr->tree)
329 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
330 else if (!aptr->content->unlink)
338 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
339 else if (flags & M_FORMAT_OPTIONAL)
340 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
344 void attach_entry (char *b, size_t blen, MUTTMENU *menu, int num)
346 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt, (unsigned long) (((ATTACHPTR **)menu->data)[num]), M_FORMAT_ARROWCURSOR);
349 int mutt_tag_attach (MUTTMENU *menu, int n, int m)
351 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
352 int ot = cur->tagged;
354 cur->tagged = (m >= 0 ? m : !cur->tagged);
355 return cur->tagged - ot;
358 int mutt_is_message_type (int type, const char *subtype)
360 if (type != TYPEMESSAGE)
363 subtype = NONULL(subtype);
364 return (ascii_strcasecmp (subtype, "rfc822") == 0 || ascii_strcasecmp (subtype, "news") == 0);
367 static int mutt_query_save_attachment (FILE *fp, BODY *body, HEADER *hdr, char **directory)
370 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
377 if (directory && *directory)
378 mutt_concat_path (buf, *directory, mutt_basename (body->filename), sizeof (buf));
380 strfcpy (buf, body->filename, sizeof (buf));
383 body->encoding != ENCBASE64 &&
384 body->encoding != ENCQUOTEDPRINTABLE &&
385 mutt_is_message_type(body->type, body->subtype))
386 mutt_default_save(buf, sizeof(buf), body->hdr);
390 prompt = _("Save to file: ");
393 if (mutt_get_field (prompt, buf, sizeof (buf), M_FILE | M_CLEAR) != 0
398 mutt_expand_path (buf, sizeof (buf));
402 body->encoding != ENCBASE64 &&
403 body->encoding != ENCQUOTEDPRINTABLE &&
404 mutt_is_message_type (body->type, body->subtype));
410 /* check to make sure that this file is really the one the user wants */
411 if ((rc = mutt_save_confirm (buf, &st)) == 1)
413 prompt = _("Save to file: ");
418 strfcpy(tfile, buf, sizeof(tfile));
422 if ((rc = mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile), &append, directory)) == -1)
426 prompt = _("Save to file: ");
431 mutt_message _("Saving...");
432 if (mutt_save_attachment (fp, body, tfile, append, (hdr || !is_message) ? hdr : body->hdr) == 0)
434 mutt_message _("Attachment saved.");
439 prompt = _("Save to file: ");
446 void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr, MUTTMENU *menu)
448 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
449 char *directory = NULL;
451 int last = menu ? menu->current : -1;
456 for (; top; top = top->next)
458 if (!tag || top->tagged)
460 if (!option (OPTATTACHSPLIT))
466 strfcpy (buf, NONULL (top->filename), sizeof (buf));
467 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
468 M_FILE | M_CLEAR) != 0 || !buf[0])
470 mutt_expand_path (buf, sizeof (buf));
471 if (mutt_check_overwrite (top->filename, buf, tfile,
472 sizeof (tfile), &append, NULL))
474 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
475 if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL)
477 fprintf(fpout, "%s", AttachSep);
483 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
484 if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL)
486 fprintf(fpout, "%s", AttachSep);
493 if (tag && menu && top->aptr)
495 menu->oldcurrent = menu->current;
496 menu->current = top->aptr->num;
497 menu_check_recenter (menu);
498 menu->redraw |= REDRAW_MOTION;
502 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
507 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
516 menu->oldcurrent = menu->current;
517 menu->current = last;
518 menu_check_recenter (menu);
519 menu->redraw |= REDRAW_MOTION;
522 if (!option (OPTATTACHSPLIT) && (rc == 0))
523 mutt_message _("Attachment saved.");
527 mutt_query_pipe_attachment (char *command, FILE *fp, BODY *body, int filter)
529 char tfile[_POSIX_PATH_MAX];
530 char warning[STRING+_POSIX_PATH_MAX];
534 snprintf (warning, sizeof (warning),
535 _("WARNING! You are about to overwrite %s, continue?"),
537 if (mutt_yesorno (warning, M_NO) != M_YES) {
546 if (mutt_pipe_attachment (fp, body, command, tfile))
550 mutt_unlink (body->filename);
551 mutt_rename_file (tfile, body->filename);
552 mutt_update_encoding (body);
553 mutt_message _("Attachment filtered.");
558 if (filter && tfile[0])
563 static void pipe_attachment (FILE *fp, BODY *b, STATE *state)
570 mutt_decode_attachment (b, state);
572 state_puts (AttachSep, state);
576 if ((ifp = fopen (b->filename, "r")) == NULL)
578 mutt_perror ("fopen");
581 mutt_copy_stream (ifp, state->fpout);
584 state_puts (AttachSep, state);
589 pipe_attachment_list (char *command, FILE *fp, int tag, BODY *top, int filter,
592 for (; top; top = top->next)
594 if (!tag || top->tagged)
596 if (!filter && !option (OPTATTACHSPLIT))
597 pipe_attachment (fp, top, state);
599 mutt_query_pipe_attachment (command, fp, top, filter);
602 pipe_attachment_list (command, fp, tag, top->parts, filter, state);
608 void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter)
611 char buf[SHORT_STRING];
615 filter = 0; /* sanity check: we can't filter in the recv case yet */
618 memset (&state, 0, sizeof (STATE));
620 if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
621 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
624 mutt_expand_path (buf, sizeof (buf));
626 if (!filter && !option (OPTATTACHSPLIT))
629 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
630 pipe_attachment_list (buf, fp, tag, top, filter, &state);
631 fclose (state.fpout);
632 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
633 mutt_any_key_to_continue (NULL);
636 pipe_attachment_list (buf, fp, tag, top, filter, &state);
639 static int can_print (BODY *top, int tag)
643 for (; top; top = top->next)
645 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
646 if (!tag || top->tagged)
648 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT))
650 if (ascii_strcasecmp ("text/plain", top->subtype) &&
651 ascii_strcasecmp ("application/postscript", top->subtype))
653 if (!mutt_can_decode (top))
655 mutt_error (_("I dont know how to print %s attachments!"), type);
662 return (can_print (top->parts, tag));
669 static void print_attachment_list (FILE *fp, int tag, BODY *top, STATE *state)
674 for (; top; top = top->next)
676 if (!tag || top->tagged)
678 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
679 if (!option (OPTATTACHSPLIT) && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT))
681 if (!ascii_strcasecmp ("text/plain", top->subtype) ||
682 !ascii_strcasecmp ("application/postscript", top->subtype))
683 pipe_attachment (fp, top, state);
684 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) == 0)
694 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)
720 if (query_quadoption (OPT_PRINT, tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) != M_YES)
723 if (!option (OPTATTACHSPLIT))
725 if (!can_print (top, tag))
728 memset (&state, 0, sizeof (STATE));
729 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
730 print_attachment_list (fp, tag, top, &state);
731 fclose (state.fpout);
732 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
733 mutt_any_key_to_continue (NULL);
736 print_attachment_list (fp, tag, top, &state);
740 mutt_update_attach_index (BODY *cur, ATTACHPTR ***idxp,
741 short *idxlen, short *idxmax,
744 ATTACHPTR **idx = *idxp;
745 while (--(*idxlen) >= 0)
746 idx[(*idxlen)]->content = NULL;
749 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
754 if (menu->current >= menu->max)
755 menu->current = menu->max - 1;
756 menu_check_recenter (menu);
757 menu->redraw |= REDRAW_INDEX;
763 mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
764 BODY *cur, ATTACHPTR ***idxp, short *idxlen, short *idxmax,
767 ATTACHPTR **idx = *idxp;
769 int old_optweed = option (OPTWEED);
770 set_option (OPTWEED);
777 case OP_DISPLAY_HEADERS:
778 toggle_option (OPTWEED);
782 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
787 case OP_MAIN_NEXT_UNDELETED: /* hack */
788 if (menu->current < menu->max - 1)
797 case OP_MAIN_PREV_UNDELETED: /* hack */
798 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);
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) || (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, short just_one)
844 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 || mutt_is_message_type (b->type, b->subtype))
851 attach_collapse (b->parts, collapse, i, 0);
852 b->collapsed = collapse;
858 void mutt_attach_init (BODY *b)
860 for (; b; b = b->next)
865 mutt_attach_init (b->parts);
869 static const char *Function_not_permitted = N_("Function not permitted in attach-message mode.");
871 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
874 mutt_error _(Function_not_permitted); \
881 void mutt_view_attachments (HEADER *hdr)
884 int need_secured = 0;
886 char helpstr[SHORT_STRING];
891 ATTACHPTR **idx = NULL;
897 /* make sure we have parsed this message */
898 mutt_parse_mime_message (Context, hdr);
900 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
902 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
906 if (WithCrypto && ((hdr->security & ENCRYPT) ||
907 (mutt_is_application_smime(hdr->content) & SMIMEOPAQUE)))
911 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase(hdr->security))
913 mx_close_message (&msg);
916 if ((WithCrypto & APPLICATION_SMIME) && (hdr->security & APPLICATION_SMIME))
919 crypt_smime_getkeys (hdr->env);
921 if (mutt_is_application_smime(hdr->content))
923 secured = ! crypt_smime_decrypt_mime (msg->fp, &fp,
927 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE))
932 fp = NULL; cur = NULL;
933 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
935 mutt_free_body (&_cur);
942 if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP))
944 if (mutt_is_multipart_encrypted(hdr->content))
945 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
950 if (need_secured && !secured)
952 mx_close_message (&msg);
953 mutt_error _("Can't decrypt encrypted message!");
958 if (!WithCrypto || !need_secured)
964 menu = mutt_new_menu ();
965 menu->menu = MENU_ATTACH;
966 menu->title = _("Attachments");
967 menu->make_entry = attach_entry;
968 menu->tag = mutt_tag_attach;
969 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
971 mutt_attach_init (cur);
972 attach_collapse (cur, 0, 1, 0);
973 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
978 op = mutt_menuLoop (menu);
981 case OP_ATTACH_VIEW_MAILCAP:
982 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
984 menu->redraw = REDRAW_FULL;
987 case OP_ATTACH_VIEW_TEXT:
988 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
990 menu->redraw = REDRAW_FULL;
993 case OP_DISPLAY_HEADERS:
995 op = mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen, &idxmax, 1);
996 menu->redraw = REDRAW_FULL;
999 case OP_ATTACH_COLLAPSE:
1000 if (!idx[menu->current]->content->parts)
1002 mutt_error _("There are no subparts to show!");
1005 if (!idx[menu->current]->content->collapsed)
1006 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1008 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1009 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1012 case OP_FORGET_PASSPHRASE:
1013 crypt_forget_passphrase ();
1016 case OP_EXTRACT_KEYS:
1017 if ((WithCrypto & APPLICATION_PGP))
1019 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1020 menu->tagprefix ? cur : idx[menu->current]->content);
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,
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]->content);
1042 mutt_pipe_attachment_list (fp, menu->tagprefix,
1043 menu->tagprefix ? cur : idx[menu->current]->content, 0);
1047 mutt_save_attachment_list (fp, menu->tagprefix,
1048 menu->tagprefix ? cur : idx[menu->current]->content, hdr, menu);
1050 if (!menu->tagprefix && option (OPTRESOLVE) && menu->current < menu->max - 1)
1053 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1060 if (Context->magic == M_POP)
1063 mutt_error _("Can't delete attachment from POP server.");
1069 if (Context->magic == M_NNTP)
1072 mutt_error _("Can't delete attachment from newsserver.");
1077 if (WithCrypto && hdr->security)
1080 "Deletion of attachments from encrypted messages is unsupported.");
1084 if (!menu->tagprefix)
1086 if (idx[menu->current]->parent_type == TYPEMULTIPART)
1088 idx[menu->current]->content->deleted = 1;
1089 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.");
1105 for (x = 0; x < menu->max; x++)
1107 if (idx[x]->content->tagged)
1109 if (idx[x]->parent_type == TYPEMULTIPART)
1111 idx[x]->content->deleted = 1;
1112 menu->redraw = REDRAW_INDEX;
1116 "Only deletion of multipart attachments is supported.");
1125 if (!menu->tagprefix)
1127 idx[menu->current]->content->deleted = 0;
1128 if (option (OPTRESOLVE) && menu->current < menu->max - 1)
1131 menu->redraw = REDRAW_MOTION_RESYNCH;
1134 menu->redraw = REDRAW_CURRENT;
1140 for (x = 0; x < menu->max; x++)
1142 if (idx[x]->content->tagged)
1144 idx[x]->content->deleted = 0;
1145 menu->redraw = REDRAW_INDEX;
1153 mutt_attach_resend (fp, hdr, idx, idxlen,
1154 menu->tagprefix ? NULL : idx[menu->current]->content);
1155 menu->redraw = REDRAW_FULL;
1158 case OP_BOUNCE_MESSAGE:
1160 mutt_attach_bounce (fp, hdr, idx, idxlen,
1161 menu->tagprefix ? NULL : idx[menu->current]->content);
1162 menu->redraw = REDRAW_FULL;
1165 case OP_FORWARD_MESSAGE:
1167 mutt_attach_forward (fp, hdr, idx, idxlen,
1168 menu->tagprefix ? NULL : idx[menu->current]->content, 0);
1169 menu->redraw = REDRAW_FULL;
1173 case OP_FORWARD_TO_GROUP:
1175 mutt_attach_forward (fp, hdr, idx, idxlen,
1176 menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
1177 menu->redraw = REDRAW_FULL;
1183 if (!idx[menu->current]->content->hdr->env->followup_to ||
1184 mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
1185 query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
1187 mutt_attach_reply (fp, hdr, idx, idxlen,
1188 menu->tagprefix ? NULL : idx[menu->current]->content,
1189 SENDNEWS|SENDREPLY);
1190 menu->redraw = REDRAW_FULL;
1196 case OP_GROUP_REPLY:
1202 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1203 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1204 mutt_attach_reply (fp, hdr, idx, idxlen,
1205 menu->tagprefix ? NULL : idx[menu->current]->content, flags);
1206 menu->redraw = REDRAW_FULL;
1210 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1211 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1215 mx_close_message (&msg);
1216 hdr->attach_del = 0;
1217 while (idxmax-- > 0)
1221 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1222 hdr->attach_del = 1;
1223 if (idx[idxmax]->content)
1224 idx[idxmax]->content->aptr = NULL;
1225 FREE (&idx[idxmax]->tree);
1226 FREE (&idx[idxmax]);
1228 if (hdr->attach_del)
1233 if (WithCrypto && need_secured && secured)
1236 mutt_free_body (&cur);
1239 mutt_menuDestroy (&menu);