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.
11 #include <lib-lib/lib-lib.h>
13 #include <lib-mime/mime.h>
15 #include <lib-ui/curses.h>
16 #include <lib-ui/enter.h>
17 #include <lib-ui/menu.h>
21 #include "recvattach.h"
25 #include <lib-crypt/crypt.h>
28 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
29 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
31 #define CHECK_READONLY if (Context->readonly) \
34 mutt_error _(Mailbox_is_read_only); \
38 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
40 static struct mapping_t AttachHelp[] = {
41 {N_("Exit"), OP_EXIT},
42 {N_("Save"), OP_SAVE},
43 {N_("Pipe"), OP_PIPE},
44 {N_("Print"), OP_PRINT},
45 {N_("Help"), OP_HELP},
49 static int mutt_extract_path (char *filename, char *path)
51 char *tmp = p_new(char, _POSIX_PATH_MAX);
56 while (*filename != '\0') {
57 if (*filename == '/') {
58 *help_ptr++ = *filename++;
63 *help_ptr++ = *filename++;
69 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
75 for (x = 0; x < idxlen; x++) {
77 if (2 * (idx[x]->level + 2) < ssizeof (buf)) {
79 s = buf + 2 * (idx[x]->level - 1);
80 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
90 if (m_strcmp(idx[x]->tree, buf) != 0)
91 m_strreplace(&idx[x]->tree, buf);
94 idx[x]->tree = m_strdup(buf);
96 if (2 * (idx[x]->level + 2) < ssizeof (buf) && idx[x]->level) {
97 s = buf + 2 * (idx[x]->level - 1);
98 *s++ = (idx[x]->content->next) ? '\005' : '\006';
104 ATTACHPTR **mutt_gen_attach_list (BODY * m,
108 short *idxmax, int level, int compose)
113 for (; m; m = m->next) {
114 if (*idxlen == *idxmax) {
115 p_realloc(&idx, (*idxmax) += 5);
116 for (i = *idxlen; i < *idxmax; i++)
120 if (m->type == TYPEMULTIPART && m->parts
122 || (parent_type == -1
123 && ascii_strcasecmp ("alternative", m->subtype)))
124 && (!mutt_is_multipart_encrypted (m))
127 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
132 idx[*idxlen] = p_new(ATTACHPTR, 1);
134 new = idx[(*idxlen)++];
137 new->parent_type = parent_type;
140 /* We don't support multipart messages in the compose menu yet */
141 if (!compose && !m->collapsed
142 && ((m->type == TYPEMULTIPART && !mutt_is_multipart_encrypted(m))
143 || mutt_is_message_type (m->type, m->subtype)))
145 idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
152 mutt_update_tree (idx, *idxlen);
157 /* %c = character set: convert?
161 * %e = MIME content-transfer-encoding
163 * %I = content-disposition, either I (inline) or A (attachment)
166 * %m = major MIME type
168 * %n = attachment number
172 const char *mutt_attach_fmt (char *dest,
177 const char *ifstring,
178 const char *elsestring,
179 unsigned long data, format_flag flags)
182 char tmp[SHORT_STRING];
183 char charset[SHORT_STRING];
184 ATTACHPTR *aptr = (ATTACHPTR *) data;
185 int optional = (flags & M_FORMAT_OPTIONAL);
191 if (mutt_is_text_part (aptr->content) &&
192 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
193 mutt_format_s (dest, destlen, prefix, charset);
195 mutt_format_s (dest, destlen, prefix, "");
197 else if (!mutt_is_text_part (aptr->content) ||
198 !mutt_get_body_charset (charset, sizeof (charset),
205 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
206 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
207 aptr->content->noconv ? 'n' : 'c');
209 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
214 if (aptr->content->description) {
215 mutt_format_s (dest, destlen, prefix, aptr->content->description);
218 if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
219 && MsgFmt && aptr->content->hdr) {
220 char s[SHORT_STRING];
222 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
223 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
224 M_FORMAT_ARROWCURSOR);
226 mutt_format_s (dest, destlen, prefix, s);
230 if (!aptr->content->filename) {
231 mutt_format_s (dest, destlen, prefix, "<no description>");
235 else if (aptr->content->description ||
236 (mutt_is_message_type
237 (aptr->content->type, aptr->content->subtype)
238 && MsgFmt && aptr->content->hdr))
240 /* FALLS THROUGH TO 'f' */
243 if (aptr->content->filename && *aptr->content->filename == '/') {
244 char path[_POSIX_PATH_MAX];
246 m_strcpy(path, sizeof(path), aptr->content->filename);
247 mutt_pretty_mailbox (path);
248 mutt_format_s (dest, destlen, prefix, path);
251 mutt_format_s (dest, destlen, prefix,
252 NONULL (aptr->content->filename));
254 else if (!aptr->content->filename)
259 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
260 else if (!aptr->content->deleted)
265 mutt_format_s (dest, destlen, prefix,
266 ENCODING (aptr->content->encoding));
270 snprintf (dest, destlen, "%c",
271 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
276 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
280 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
281 else if (!aptr->content->subtype)
286 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
287 snprintf (dest, destlen, fmt, aptr->num + 1);
292 optional = aptr->content->attach_qualifies;
294 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
295 mutt_format_s (dest, destlen, fmt, "Q");
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)
336 optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
338 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
339 snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
347 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
348 else if (flags & M_FORMAT_OPTIONAL)
349 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
353 static void attach_entry (char *b, ssize_t blen, MUTTMENU * menu, int num)
355 int w=(COLS-SW)>blen?blen:(COLS-SW);
356 mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
357 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
358 M_FORMAT_ARROWCURSOR);
361 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
363 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
364 int ot = cur->tagged;
366 cur->tagged = (m >= 0 ? m : !cur->tagged);
367 return cur->tagged - ot;
370 int mutt_is_message_type (int type, const char *subtype)
372 if (type != TYPEMESSAGE)
375 subtype = NONULL (subtype);
376 return (ascii_strcasecmp (subtype, "rfc822") == 0
377 || ascii_strcasecmp (subtype, "news") == 0);
380 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
384 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
385 char path[_POSIX_PATH_MAX] = "";
391 if (body->filename) {
392 if (directory && *directory)
393 mutt_concat_path(buf, sizeof(buf), *directory,
394 mutt_basename(body->filename));
396 m_strcpy(buf, sizeof(buf), body->filename);
398 else if (body->hdr &&
399 body->encoding != ENCBASE64 &&
400 body->encoding != ENCQUOTEDPRINTABLE &&
401 mutt_is_message_type (body->type, body->subtype))
402 mutt_default_save (buf, sizeof (buf), body->hdr);
406 prompt = _("Save to file ('#' for last used folder): ");
409 mutt_get_field (prompt, buf, sizeof (buf),
410 M_FILE | M_CLEAR | M_LASTFOLDER);
411 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
415 char tmpbuf[_POSIX_PATH_MAX];
417 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
418 m_strcpy(buf, sizeof(buf), tmpbuf);
419 ret = mutt_get_field (_("Save to file: ")
420 , buf, sizeof (buf), M_FILE);
421 if ((ret != 0) || (!buf[0]))
425 mutt_extract_path (buf, path);
426 m_strcpy(LastSaveFolder, sizeof(LastSaveFolder), path);
430 mutt_expand_path (buf, sizeof (buf));
434 body->encoding != ENCBASE64 &&
435 body->encoding != ENCQUOTEDPRINTABLE &&
436 mutt_is_message_type (body->type, body->subtype));
441 /* check to make sure that this file is really the one the user wants */
442 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
443 prompt = _("Save to file: ");
448 m_strcpy(tfile, sizeof(tfile), buf);
452 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
453 &append, directory)) == -1)
456 prompt = _("Save to file: ");
461 mutt_message _("Saving...");
463 if (mutt_save_attachment
464 (fp, body, tfile, append,
465 (hdr || !is_message) ? hdr : body->hdr) == 0) {
466 mutt_message _("Attachment saved.");
471 prompt = _("Save to file: ");
478 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
481 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
482 char *directory = NULL;
484 int last = menu ? menu->current : -1;
489 for (; top; top = top->next) {
490 if (!tag || top->tagged) {
491 if (!option (OPTATTACHSPLIT)) {
495 m_strcpy(buf, sizeof(buf), NONULL(top->filename));
496 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
497 M_FILE | M_CLEAR) != 0 || !buf[0])
499 mutt_expand_path (buf, sizeof (buf));
500 if (mutt_check_overwrite (top->filename, buf, tfile,
501 sizeof (tfile), &append, NULL))
503 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
504 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
505 fprintf (fpout, "%s", AttachSep);
510 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
511 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
512 fprintf (fpout, "%s", AttachSep);
518 if (tag && menu && top->aptr) {
519 menu->oldcurrent = menu->current;
520 menu->current = top->aptr->num;
521 menu_check_recenter (menu);
522 menu->redraw |= REDRAW_MOTION;
526 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
531 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
536 p_delete(&directory);
539 menu->oldcurrent = menu->current;
540 menu->current = last;
541 menu_check_recenter (menu);
542 menu->redraw |= REDRAW_MOTION;
545 if (!option (OPTATTACHSPLIT) && (rc == 0))
546 mutt_message _("Attachment saved.");
550 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int afilter)
552 char tfile[_POSIX_PATH_MAX];
553 char warning[STRING + _POSIX_PATH_MAX];
556 snprintf (warning, sizeof (warning),
557 _("WARNING! You are about to overwrite %s, continue?"),
559 if (mutt_yesorno (warning, M_NO) != M_YES) {
560 CLEARLINE (LINES - 1);
568 if (mutt_pipe_attachment (fp, body, command, tfile)) {
570 mutt_unlink (body->filename);
571 mutt_rename_file (tfile, body->filename);
572 mutt_update_encoding (body);
573 mutt_message _("Attachment filtered.");
577 if (afilter && tfile[0])
582 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
588 mutt_decode_attachment (b, state);
590 state_puts (AttachSep, state);
593 if ((ifp = fopen (b->filename, "r")) == NULL) {
594 mutt_perror ("fopen");
597 mutt_copy_stream (ifp, state->fpout);
600 state_puts (AttachSep, state);
605 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
606 int afilter, STATE * state)
608 for (; top; top = top->next) {
609 if (!tag || top->tagged) {
610 if (!afilter && !option (OPTATTACHSPLIT))
611 pipe_attachment (fp, top, state);
613 mutt_query_pipe_attachment (command, fp, top, afilter);
616 pipe_attachment_list (command, fp, tag, top->parts, afilter, state);
622 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int afilter)
625 char buf[SHORT_STRING];
629 afilter = 0; /* sanity check: we can't filter in the recv case yet */
634 if (mutt_get_field ((afilter ? _("Filter through: ") : _("Pipe to: ")),
635 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
638 mutt_expand_path (buf, sizeof (buf));
640 if (!afilter && !option (OPTATTACHSPLIT)) {
642 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
643 pipe_attachment_list (buf, fp, tag, top, afilter, &state);
644 fclose (state.fpout);
645 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
646 mutt_any_key_to_continue (NULL);
649 pipe_attachment_list (buf, fp, tag, top, afilter, &state);
652 static int can_print (BODY * top, int tag)
656 for (; top; top = top->next) {
657 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
658 if (!tag || top->tagged) {
659 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
660 if (ascii_strcasecmp ("text/plain", top->subtype) &&
661 ascii_strcasecmp ("application/postscript", top->subtype)) {
662 if (!mutt_can_decode (top)) {
663 mutt_error (_("I dont know how to print %s attachments!"), type);
670 return (can_print (top->parts, tag));
677 static void print_attachment_list (FILE * fp, int tag, BODY * top,
683 for (; top; top = top->next) {
684 if (!tag || top->tagged) {
685 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
686 if (!option (OPTATTACHSPLIT)
687 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
688 if (!ascii_strcasecmp ("text/plain", top->subtype)
689 || !ascii_strcasecmp ("application/postscript", top->subtype))
690 pipe_attachment (fp, top, state);
691 else if (mutt_can_decode (top)) {
692 /* decode and print */
694 char newfile[_POSIX_PATH_MAX] = "";
697 mutt_mktemp (newfile);
698 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
700 if ((ifp = fopen (newfile, "r")) != NULL) {
701 mutt_copy_stream (ifp, state->fpout);
704 state_puts (AttachSep, state);
707 mutt_unlink (newfile);
711 mutt_print_attachment (fp, top);
714 print_attachment_list (fp, tag, top->parts, state);
720 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
728 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
732 if (!option (OPTATTACHSPLIT)) {
733 if (!can_print (top, tag))
737 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
738 print_attachment_list (fp, tag, top, &state);
739 fclose (state.fpout);
740 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
741 mutt_any_key_to_continue (NULL);
744 print_attachment_list (fp, tag, top, &state);
748 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
749 short *idxlen, short *idxmax, MUTTMENU * menu)
751 ATTACHPTR **idx = *idxp;
753 while (--(*idxlen) >= 0)
754 idx[(*idxlen)]->content = NULL;
757 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
762 if (menu->current >= menu->max)
763 menu->current = menu->max - 1;
764 menu_check_recenter (menu);
765 menu->redraw |= REDRAW_INDEX;
771 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
772 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
773 short *idxmax, int recv)
775 ATTACHPTR **idx = *idxp;
778 int old_optweed = option (OPTWEED);
780 set_option (OPTWEED);
785 case OP_DISPLAY_HEADERS:
786 toggle_option (OPTWEED);
790 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
795 case OP_MAIN_NEXT_UNDELETED: /* hack */
796 if (menu->current < menu->max - 1) {
804 case OP_MAIN_PREV_UNDELETED: /* hack */
805 if (menu->current > 0) {
813 /* when we edit the content-type, we should redisplay the attachment
815 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
817 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
822 /* functions which are passed through from the pager */
823 case OP_CHECK_TRADITIONAL:
824 if (hdr && hdr->security & PGP_TRADITIONAL_CHECKED) {
829 case OP_ATTACH_COLLAPSE:
836 while (op != OP_NULL);
839 if (option (OPTWEED) != old_optweed)
840 toggle_option (OPTWEED);
845 static void attach_collapse (BODY * b, short collapse, short init,
850 for (; b; b = b->next) {
851 i = init || b->collapsed;
852 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
853 && !ascii_strcasecmp (b->subtype, "digest"))
854 attach_collapse (b->parts, 1, 1, 0);
855 else if (b->type == TYPEMULTIPART
856 || mutt_is_message_type (b->type, b->subtype))
857 attach_collapse (b->parts, collapse, i, 0);
858 b->collapsed = collapse;
864 void mutt_attach_init (BODY * b)
866 for (; b; b = b->next) {
870 mutt_attach_init (b->parts);
874 static const char *Function_not_permitted =
875 N_("Function not permitted in attach-message mode.");
877 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
880 mutt_error _(Function_not_permitted); \
887 void mutt_view_attachments (HEADER * hdr)
890 int need_secured = 0;
892 char helpstr[SHORT_STRING];
897 ATTACHPTR **idx = NULL;
903 /* make sure we have parsed this message */
904 mutt_parse_mime_message (Context, hdr);
906 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
908 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
912 if ((hdr->security & ENCRYPT) ||
913 (mutt_is_application_smime (hdr->content) & SMIMEOPAQUE))
917 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
918 mx_close_message (&msg);
921 if (hdr->security & APPLICATION_SMIME) {
923 crypt_smime_getkeys (hdr->env);
925 if (mutt_is_application_smime (hdr->content)) {
926 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
930 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
936 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
938 body_list_wipe(&_cur);
945 if (hdr->security & APPLICATION_PGP) {
946 if (mutt_is_multipart_encrypted (hdr->content))
947 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
952 if (need_secured && !secured) {
953 mx_close_message (&msg);
954 mutt_error _("Can't decrypt encrypted message!");
965 menu = mutt_new_menu ();
966 menu->menu = MENU_ATTACH;
967 menu->title = _("Attachments");
968 menu->make_entry = attach_entry;
969 menu->tag = mutt_tag_attach;
971 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
973 mutt_attach_init (cur);
974 attach_collapse (cur, 0, 1, 0);
975 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
979 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:
996 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
998 menu->redraw = REDRAW_FULL;
1001 case OP_ATTACH_COLLAPSE:
1002 if (!idx[menu->current]->content->parts) {
1003 mutt_error _("There are no subparts to show!");
1007 if (!idx[menu->current]->content->collapsed)
1008 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1010 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1011 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1014 case OP_FORGET_PASSPHRASE:
1015 crypt_forget_passphrase ();
1018 case OP_EXTRACT_KEYS:
1019 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1022 idx[menu->current]->
1024 menu->redraw = REDRAW_FULL;
1027 case OP_CHECK_TRADITIONAL:
1028 if (crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1029 : idx[menu->current]->content,
1032 hdr->security = crypt_query (cur);
1033 menu->redraw = REDRAW_FULL;
1038 mutt_print_attachment_list (fp, menu->tagprefix,
1039 menu->tagprefix ? cur : idx[menu->current]->
1044 mutt_pipe_attachment_list (fp, menu->tagprefix,
1045 menu->tagprefix ? cur : idx[menu->current]->
1050 mutt_save_attachment_list (fp, menu->tagprefix,
1051 menu->tagprefix ? cur : idx[menu->current]->
1052 content, hdr, menu);
1054 if (!menu->tagprefix && option (OPTRESOLVE)
1055 && menu->current < menu->max - 1)
1058 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1064 if (Context->magic == M_POP) {
1066 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 (hdr->security & (~PGP_TRADITIONAL_CHECKED)) {
1082 _("Deletion of attachments from encrypted messages is unsupported.");
1085 if (!menu->tagprefix) {
1086 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1087 idx[menu->current]->content->deleted = 1;
1088 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1090 menu->redraw = REDRAW_MOTION_RESYNCH;
1093 menu->redraw = REDRAW_CURRENT;
1097 _("Only deletion of multipart attachments is supported.");
1102 for (x = 0; x < menu->max; x++) {
1103 if (idx[x]->content->tagged) {
1104 if (idx[x]->parent_type == TYPEMULTIPART) {
1105 idx[x]->content->deleted = 1;
1106 menu->redraw = REDRAW_INDEX;
1110 _("Only deletion of multipart attachments is supported.");
1119 if (!menu->tagprefix) {
1120 idx[menu->current]->content->deleted = 0;
1121 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1123 menu->redraw = REDRAW_MOTION_RESYNCH;
1126 menu->redraw = REDRAW_CURRENT;
1131 for (x = 0; x < menu->max; x++) {
1132 if (idx[x]->content->tagged) {
1133 idx[x]->content->deleted = 0;
1134 menu->redraw = REDRAW_INDEX;
1142 mutt_attach_resend (fp, hdr, idx, idxlen,
1143 menu->tagprefix ? NULL : idx[menu->current]->
1145 menu->redraw = REDRAW_FULL;
1148 case OP_BOUNCE_MESSAGE:
1150 mutt_attach_bounce (fp, hdr, idx, idxlen,
1151 menu->tagprefix ? NULL : idx[menu->current]->
1153 menu->redraw = REDRAW_FULL;
1156 case OP_FORWARD_MESSAGE:
1158 mutt_attach_forward (fp, hdr, idx, idxlen,
1159 menu->tagprefix ? NULL : idx[menu->current]->
1161 menu->redraw = REDRAW_FULL;
1165 case OP_FORWARD_TO_GROUP:
1167 mutt_attach_forward (fp, hdr, idx, idxlen,
1168 menu->tagprefix ? NULL : idx[menu->current]->
1170 menu->redraw = REDRAW_FULL;
1176 if (!idx[menu->current]->content->hdr->env->followup_to ||
1177 m_strcasecmp(idx[menu->current]->content->hdr->env->followup_to,
1179 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1180 _("Reply by mail as poster prefers?")) !=
1182 mutt_attach_reply (fp, hdr, idx, idxlen,
1183 menu->tagprefix ? NULL : idx[menu->current]->
1184 content, SENDNEWS | SENDREPLY);
1185 menu->redraw = REDRAW_FULL;
1191 case OP_GROUP_REPLY:
1197 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1198 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1199 mutt_attach_reply (fp, hdr, idx, idxlen,
1200 menu->tagprefix ? NULL : idx[menu->current]->content,
1202 menu->redraw = REDRAW_FULL;
1206 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1207 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1211 mx_close_message (&msg);
1212 hdr->attach_del = 0;
1213 while (idxmax-- > 0) {
1216 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1217 hdr->attach_del = 1;
1218 if (idx[idxmax]->content)
1219 idx[idxmax]->content->aptr = NULL;
1220 p_delete(&idx[idxmax]->tree);
1221 p_delete(&idx[idxmax]);
1223 if (hdr->attach_del)
1228 if (need_secured && secured) {
1230 body_list_wipe(&cur);
1233 mutt_menuDestroy (&menu);