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.
15 #include <lib-lib/lib-lib.h>
17 #include <lib-mime/mime.h>
19 #include <lib-ui/curses.h>
20 #include <lib-ui/enter.h>
21 #include <lib-ui/menu.h>
25 #include "recvattach.h"
29 #include <lib-crypt/crypt.h>
40 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
41 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
43 #define CHECK_READONLY if (Context->readonly) \
46 mutt_error _(Mailbox_is_read_only); \
50 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
52 static struct mapping_t AttachHelp[] = {
53 {N_("Exit"), OP_EXIT},
54 {N_("Save"), OP_SAVE},
55 {N_("Pipe"), OP_PIPE},
56 {N_("Print"), OP_PRINT},
57 {N_("Help"), OP_HELP},
61 static int mutt_extract_path (char *filename, char *path)
63 char *tmp = p_new(char, _POSIX_PATH_MAX);
68 while (*filename != '\0') {
69 if (*filename == '/') {
70 *help_ptr++ = *filename++;
75 *help_ptr++ = *filename++;
81 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
87 for (x = 0; x < idxlen; x++) {
89 if (2 * (idx[x]->level + 2) < ssizeof (buf)) {
91 s = buf + 2 * (idx[x]->level - 1);
92 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
102 if (m_strcmp(idx[x]->tree, buf) != 0)
103 m_strreplace(&idx[x]->tree, buf);
106 idx[x]->tree = m_strdup(buf);
108 if (2 * (idx[x]->level + 2) < ssizeof (buf) && idx[x]->level) {
109 s = buf + 2 * (idx[x]->level - 1);
110 *s++ = (idx[x]->content->next) ? '\005' : '\006';
116 ATTACHPTR **mutt_gen_attach_list (BODY * m,
120 short *idxmax, int level, int compose)
125 for (; m; m = m->next) {
126 if (*idxlen == *idxmax) {
127 p_realloc(&idx, (*idxmax) += 5);
128 for (i = *idxlen; i < *idxmax; i++)
132 if (m->type == TYPEMULTIPART && m->parts
134 || (parent_type == -1
135 && ascii_strcasecmp ("alternative", m->subtype)))
136 && (!mutt_is_multipart_encrypted (m))
139 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
144 idx[*idxlen] = p_new(ATTACHPTR, 1);
146 new = idx[(*idxlen)++];
149 new->parent_type = parent_type;
152 /* We don't support multipart messages in the compose menu yet */
153 if (!compose && !m->collapsed
154 && ((m->type == TYPEMULTIPART && !mutt_is_multipart_encrypted(m))
155 || mutt_is_message_type (m->type, m->subtype)))
157 idx = 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 m_strcpy(path, sizeof(path), aptr->content->filename);
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);
304 optional = aptr->content->attach_qualifies;
306 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
307 mutt_format_s (dest, destlen, fmt, "Q");
311 if (flags & M_FORMAT_STAT_FILE) {
314 stat (aptr->content->filename, &st);
318 l = aptr->content->length;
321 mutt_pretty_size (tmp, sizeof (tmp), l);
322 mutt_format_s (dest, destlen, prefix, tmp);
330 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
331 else if (!aptr->content->tagged)
336 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
337 else if (!aptr->tree)
342 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
343 else if (!aptr->content->unlink)
348 optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
350 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
351 snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
359 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
360 else if (flags & M_FORMAT_OPTIONAL)
361 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
365 static void attach_entry (char *b, ssize_t blen, MUTTMENU * menu, int num)
367 int w=(COLS-SW)>blen?blen:(COLS-SW);
368 mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
369 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
370 M_FORMAT_ARROWCURSOR);
373 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
375 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
376 int ot = cur->tagged;
378 cur->tagged = (m >= 0 ? m : !cur->tagged);
379 return cur->tagged - ot;
382 int mutt_is_message_type (int type, const char *subtype)
384 if (type != TYPEMESSAGE)
387 subtype = NONULL (subtype);
388 return (ascii_strcasecmp (subtype, "rfc822") == 0
389 || ascii_strcasecmp (subtype, "news") == 0);
392 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
396 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
397 char path[_POSIX_PATH_MAX] = "";
403 if (body->filename) {
404 if (directory && *directory)
405 mutt_concat_path(buf, sizeof(buf), *directory,
406 mutt_basename(body->filename));
408 m_strcpy(buf, sizeof(buf), body->filename);
410 else if (body->hdr &&
411 body->encoding != ENCBASE64 &&
412 body->encoding != ENCQUOTEDPRINTABLE &&
413 mutt_is_message_type (body->type, body->subtype))
414 mutt_default_save (buf, sizeof (buf), body->hdr);
418 prompt = _("Save to file ('#' for last used folder): ");
421 mutt_get_field (prompt, buf, sizeof (buf),
422 M_FILE | M_CLEAR | M_LASTFOLDER);
423 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
427 char tmpbuf[_POSIX_PATH_MAX];
429 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
430 m_strcpy(buf, sizeof(buf), tmpbuf);
431 ret = mutt_get_field (_("Save to file: ")
432 , buf, sizeof (buf), M_FILE);
433 if ((ret != 0) || (!buf[0]))
437 mutt_extract_path (buf, path);
438 m_strcpy(LastSaveFolder, sizeof(LastSaveFolder), path);
442 mutt_expand_path (buf, sizeof (buf));
446 body->encoding != ENCBASE64 &&
447 body->encoding != ENCQUOTEDPRINTABLE &&
448 mutt_is_message_type (body->type, body->subtype));
453 /* check to make sure that this file is really the one the user wants */
454 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
455 prompt = _("Save to file: ");
460 m_strcpy(tfile, sizeof(tfile), buf);
464 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
465 &append, directory)) == -1)
468 prompt = _("Save to file: ");
473 mutt_message _("Saving...");
475 if (mutt_save_attachment
476 (fp, body, tfile, append,
477 (hdr || !is_message) ? hdr : body->hdr) == 0) {
478 mutt_message _("Attachment saved.");
483 prompt = _("Save to file: ");
490 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
493 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
494 char *directory = NULL;
496 int last = menu ? menu->current : -1;
501 for (; top; top = top->next) {
502 if (!tag || top->tagged) {
503 if (!option (OPTATTACHSPLIT)) {
507 m_strcpy(buf, sizeof(buf), NONULL(top->filename));
508 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
509 M_FILE | M_CLEAR) != 0 || !buf[0])
511 mutt_expand_path (buf, sizeof (buf));
512 if (mutt_check_overwrite (top->filename, buf, tfile,
513 sizeof (tfile), &append, NULL))
515 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
516 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
517 fprintf (fpout, "%s", AttachSep);
522 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
523 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
524 fprintf (fpout, "%s", AttachSep);
530 if (tag && menu && top->aptr) {
531 menu->oldcurrent = menu->current;
532 menu->current = top->aptr->num;
533 menu_check_recenter (menu);
534 menu->redraw |= REDRAW_MOTION;
538 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
543 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
548 p_delete(&directory);
551 menu->oldcurrent = menu->current;
552 menu->current = last;
553 menu_check_recenter (menu);
554 menu->redraw |= REDRAW_MOTION;
557 if (!option (OPTATTACHSPLIT) && (rc == 0))
558 mutt_message _("Attachment saved.");
562 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int afilter)
564 char tfile[_POSIX_PATH_MAX];
565 char warning[STRING + _POSIX_PATH_MAX];
568 snprintf (warning, sizeof (warning),
569 _("WARNING! You are about to overwrite %s, continue?"),
571 if (mutt_yesorno (warning, M_NO) != M_YES) {
572 CLEARLINE (LINES - 1);
580 if (mutt_pipe_attachment (fp, body, command, tfile)) {
582 mutt_unlink (body->filename);
583 mutt_rename_file (tfile, body->filename);
584 mutt_update_encoding (body);
585 mutt_message _("Attachment filtered.");
589 if (afilter && tfile[0])
594 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
600 mutt_decode_attachment (b, state);
602 state_puts (AttachSep, state);
605 if ((ifp = fopen (b->filename, "r")) == NULL) {
606 mutt_perror ("fopen");
609 mutt_copy_stream (ifp, state->fpout);
612 state_puts (AttachSep, state);
617 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
618 int afilter, STATE * state)
620 for (; top; top = top->next) {
621 if (!tag || top->tagged) {
622 if (!afilter && !option (OPTATTACHSPLIT))
623 pipe_attachment (fp, top, state);
625 mutt_query_pipe_attachment (command, fp, top, afilter);
628 pipe_attachment_list (command, fp, tag, top->parts, afilter, state);
634 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int afilter)
637 char buf[SHORT_STRING];
641 afilter = 0; /* sanity check: we can't filter in the recv case yet */
646 if (mutt_get_field ((afilter ? _("Filter through: ") : _("Pipe to: ")),
647 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
650 mutt_expand_path (buf, sizeof (buf));
652 if (!afilter && !option (OPTATTACHSPLIT)) {
654 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
655 pipe_attachment_list (buf, fp, tag, top, afilter, &state);
656 fclose (state.fpout);
657 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
658 mutt_any_key_to_continue (NULL);
661 pipe_attachment_list (buf, fp, tag, top, afilter, &state);
664 static int can_print (BODY * top, int tag)
668 for (; top; top = top->next) {
669 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
670 if (!tag || top->tagged) {
671 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
672 if (ascii_strcasecmp ("text/plain", top->subtype) &&
673 ascii_strcasecmp ("application/postscript", top->subtype)) {
674 if (!mutt_can_decode (top)) {
675 mutt_error (_("I dont know how to print %s attachments!"), type);
682 return (can_print (top->parts, tag));
689 static void print_attachment_list (FILE * fp, int tag, BODY * top,
695 for (; top; top = top->next) {
696 if (!tag || top->tagged) {
697 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
698 if (!option (OPTATTACHSPLIT)
699 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
700 if (!ascii_strcasecmp ("text/plain", top->subtype)
701 || !ascii_strcasecmp ("application/postscript", top->subtype))
702 pipe_attachment (fp, top, state);
703 else if (mutt_can_decode (top)) {
704 /* decode and print */
706 char newfile[_POSIX_PATH_MAX] = "";
709 mutt_mktemp (newfile);
710 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
712 if ((ifp = fopen (newfile, "r")) != NULL) {
713 mutt_copy_stream (ifp, state->fpout);
716 state_puts (AttachSep, state);
719 mutt_unlink (newfile);
723 mutt_print_attachment (fp, top);
726 print_attachment_list (fp, tag, top->parts, state);
732 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
740 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
744 if (!option (OPTATTACHSPLIT)) {
745 if (!can_print (top, tag))
749 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
750 print_attachment_list (fp, tag, top, &state);
751 fclose (state.fpout);
752 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
753 mutt_any_key_to_continue (NULL);
756 print_attachment_list (fp, tag, top, &state);
760 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
761 short *idxlen, short *idxmax, MUTTMENU * menu)
763 ATTACHPTR **idx = *idxp;
765 while (--(*idxlen) >= 0)
766 idx[(*idxlen)]->content = NULL;
769 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
774 if (menu->current >= menu->max)
775 menu->current = menu->max - 1;
776 menu_check_recenter (menu);
777 menu->redraw |= REDRAW_INDEX;
783 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
784 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
785 short *idxmax, int recv)
787 ATTACHPTR **idx = *idxp;
790 int old_optweed = option (OPTWEED);
792 set_option (OPTWEED);
797 case OP_DISPLAY_HEADERS:
798 toggle_option (OPTWEED);
802 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
807 case OP_MAIN_NEXT_UNDELETED: /* hack */
808 if (menu->current < menu->max - 1) {
816 case OP_MAIN_PREV_UNDELETED: /* hack */
817 if (menu->current > 0) {
825 /* when we edit the content-type, we should redisplay the attachment
827 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
829 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
834 /* functions which are passed through from the pager */
835 case OP_CHECK_TRADITIONAL:
836 if (hdr && hdr->security & PGP_TRADITIONAL_CHECKED) {
841 case OP_ATTACH_COLLAPSE:
848 while (op != OP_NULL);
851 if (option (OPTWEED) != old_optweed)
852 toggle_option (OPTWEED);
857 static void attach_collapse (BODY * b, short collapse, short init,
862 for (; b; b = b->next) {
863 i = init || b->collapsed;
864 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
865 && !ascii_strcasecmp (b->subtype, "digest"))
866 attach_collapse (b->parts, 1, 1, 0);
867 else if (b->type == TYPEMULTIPART
868 || mutt_is_message_type (b->type, b->subtype))
869 attach_collapse (b->parts, collapse, i, 0);
870 b->collapsed = collapse;
876 void mutt_attach_init (BODY * b)
878 for (; b; b = b->next) {
882 mutt_attach_init (b->parts);
886 static const char *Function_not_permitted =
887 N_("Function not permitted in attach-message mode.");
889 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
892 mutt_error _(Function_not_permitted); \
899 void mutt_view_attachments (HEADER * hdr)
902 int need_secured = 0;
904 char helpstr[SHORT_STRING];
909 ATTACHPTR **idx = NULL;
915 /* make sure we have parsed this message */
916 mutt_parse_mime_message (Context, hdr);
918 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
920 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
924 if ((hdr->security & ENCRYPT) ||
925 (mutt_is_application_smime (hdr->content) & SMIMEOPAQUE))
929 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
930 mx_close_message (&msg);
933 if (hdr->security & APPLICATION_SMIME) {
935 crypt_smime_getkeys (hdr->env);
937 if (mutt_is_application_smime (hdr->content)) {
938 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
942 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
948 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
950 body_list_wipe(&_cur);
957 if (hdr->security & APPLICATION_PGP) {
958 if (mutt_is_multipart_encrypted (hdr->content))
959 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
964 if (need_secured && !secured) {
965 mx_close_message (&msg);
966 mutt_error _("Can't decrypt encrypted message!");
977 menu = mutt_new_menu ();
978 menu->menu = MENU_ATTACH;
979 menu->title = _("Attachments");
980 menu->make_entry = attach_entry;
981 menu->tag = mutt_tag_attach;
983 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
985 mutt_attach_init (cur);
986 attach_collapse (cur, 0, 1, 0);
987 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
991 op = mutt_menuLoop (menu);
993 case OP_ATTACH_VIEW_MAILCAP:
994 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
996 menu->redraw = REDRAW_FULL;
999 case OP_ATTACH_VIEW_TEXT:
1000 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
1002 menu->redraw = REDRAW_FULL;
1005 case OP_DISPLAY_HEADERS:
1006 case OP_VIEW_ATTACH:
1008 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
1010 menu->redraw = REDRAW_FULL;
1013 case OP_ATTACH_COLLAPSE:
1014 if (!idx[menu->current]->content->parts) {
1015 mutt_error _("There are no subparts to show!");
1019 if (!idx[menu->current]->content->collapsed)
1020 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1022 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1023 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1026 case OP_FORGET_PASSPHRASE:
1027 crypt_forget_passphrase ();
1030 case OP_EXTRACT_KEYS:
1031 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1034 idx[menu->current]->
1036 menu->redraw = REDRAW_FULL;
1039 case OP_CHECK_TRADITIONAL:
1040 if (crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1041 : idx[menu->current]->content,
1044 hdr->security = crypt_query (cur);
1045 menu->redraw = REDRAW_FULL;
1050 mutt_print_attachment_list (fp, menu->tagprefix,
1051 menu->tagprefix ? cur : idx[menu->current]->
1056 mutt_pipe_attachment_list (fp, menu->tagprefix,
1057 menu->tagprefix ? cur : idx[menu->current]->
1062 mutt_save_attachment_list (fp, menu->tagprefix,
1063 menu->tagprefix ? cur : idx[menu->current]->
1064 content, hdr, menu);
1066 if (!menu->tagprefix && option (OPTRESOLVE)
1067 && menu->current < menu->max - 1)
1070 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1076 if (Context->magic == M_POP) {
1078 mutt_error _("Can't delete attachment from POP server.");
1084 if (Context->magic == M_NNTP) {
1086 mutt_error _("Can't delete attachment from newsserver.");
1092 if (hdr->security & (~PGP_TRADITIONAL_CHECKED)) {
1094 _("Deletion of attachments from encrypted messages is unsupported.");
1097 if (!menu->tagprefix) {
1098 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1099 idx[menu->current]->content->deleted = 1;
1100 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1102 menu->redraw = REDRAW_MOTION_RESYNCH;
1105 menu->redraw = REDRAW_CURRENT;
1109 _("Only deletion of multipart attachments is supported.");
1114 for (x = 0; x < menu->max; x++) {
1115 if (idx[x]->content->tagged) {
1116 if (idx[x]->parent_type == TYPEMULTIPART) {
1117 idx[x]->content->deleted = 1;
1118 menu->redraw = REDRAW_INDEX;
1122 _("Only deletion of multipart attachments is supported.");
1131 if (!menu->tagprefix) {
1132 idx[menu->current]->content->deleted = 0;
1133 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1135 menu->redraw = REDRAW_MOTION_RESYNCH;
1138 menu->redraw = REDRAW_CURRENT;
1143 for (x = 0; x < menu->max; x++) {
1144 if (idx[x]->content->tagged) {
1145 idx[x]->content->deleted = 0;
1146 menu->redraw = REDRAW_INDEX;
1154 mutt_attach_resend (fp, hdr, idx, idxlen,
1155 menu->tagprefix ? NULL : idx[menu->current]->
1157 menu->redraw = REDRAW_FULL;
1160 case OP_BOUNCE_MESSAGE:
1162 mutt_attach_bounce (fp, hdr, idx, idxlen,
1163 menu->tagprefix ? NULL : idx[menu->current]->
1165 menu->redraw = REDRAW_FULL;
1168 case OP_FORWARD_MESSAGE:
1170 mutt_attach_forward (fp, hdr, idx, idxlen,
1171 menu->tagprefix ? NULL : idx[menu->current]->
1173 menu->redraw = REDRAW_FULL;
1177 case OP_FORWARD_TO_GROUP:
1179 mutt_attach_forward (fp, hdr, idx, idxlen,
1180 menu->tagprefix ? NULL : idx[menu->current]->
1182 menu->redraw = REDRAW_FULL;
1188 if (!idx[menu->current]->content->hdr->env->followup_to ||
1189 m_strcasecmp(idx[menu->current]->content->hdr->env->followup_to,
1191 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1192 _("Reply by mail as poster prefers?")) !=
1194 mutt_attach_reply (fp, hdr, idx, idxlen,
1195 menu->tagprefix ? NULL : idx[menu->current]->
1196 content, SENDNEWS | SENDREPLY);
1197 menu->redraw = REDRAW_FULL;
1203 case OP_GROUP_REPLY:
1209 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1210 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1211 mutt_attach_reply (fp, hdr, idx, idxlen,
1212 menu->tagprefix ? NULL : idx[menu->current]->content,
1214 menu->redraw = REDRAW_FULL;
1218 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1219 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1223 mx_close_message (&msg);
1224 hdr->attach_del = 0;
1225 while (idxmax-- > 0) {
1228 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1229 hdr->attach_del = 1;
1230 if (idx[idxmax]->content)
1231 idx[idxmax]->content->aptr = NULL;
1232 p_delete(&idx[idxmax]->tree);
1233 p_delete(&idx[idxmax]);
1235 if (hdr->attach_del)
1240 if (need_secured && secured) {
1242 body_list_wipe(&cur);
1245 mutt_menuDestroy (&menu);