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.
19 #include "recvattach.h"
20 #include "mutt_curses.h"
21 #include "mutt_menu.h"
28 #include "mutt_crypt.h"
42 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
43 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
45 #define CHECK_READONLY if (Context->readonly) \
48 mutt_error _(Mailbox_is_read_only); \
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 = mem_malloc (sizeof (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) < sizeof (buf)) {
91 s = buf + 2 * (idx[x]->level - 1);
92 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
102 if (str_cmp (idx[x]->tree, buf) != 0)
103 str_replace (&idx[x]->tree, buf);
106 idx[x]->tree = str_dup (buf);
108 if (2 * (idx[x]->level + 2) < sizeof (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 mem_realloc (&idx, sizeof (ATTACHPTR *) * ((*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 && (!(WithCrypto & APPLICATION_PGP)
137 || !mutt_is_multipart_encrypted (m))
140 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
145 idx[*idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR));
147 new = idx[(*idxlen)++];
150 new->parent_type = parent_type;
153 /* We don't support multipart messages in the compose menu yet */
154 if (!compose && !m->collapsed &&
155 ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP)
156 || !mutt_is_multipart_encrypted (m))
158 || mutt_is_message_type (m->type, m->subtype))) {
160 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
167 mutt_update_tree (idx, *idxlen);
172 /* %c = character set: convert?
176 * %e = MIME content-transfer-encoding
178 * %I = content-disposition, either I (inline) or A (attachment)
181 * %m = major MIME type
183 * %n = attachment number
187 const char *mutt_attach_fmt (char *dest,
192 const char *ifstring,
193 const char *elsestring,
194 unsigned long data, format_flag flags)
197 char tmp[SHORT_STRING];
198 char charset[SHORT_STRING];
199 ATTACHPTR *aptr = (ATTACHPTR *) data;
200 int optional = (flags & M_FORMAT_OPTIONAL);
206 if (mutt_is_text_part (aptr->content) &&
207 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
208 mutt_format_s (dest, destlen, prefix, charset);
210 mutt_format_s (dest, destlen, prefix, "");
212 else if (!mutt_is_text_part (aptr->content) ||
213 !mutt_get_body_charset (charset, sizeof (charset),
220 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
221 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
222 aptr->content->noconv ? 'n' : 'c');
224 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
229 if (aptr->content->description) {
230 mutt_format_s (dest, destlen, prefix, aptr->content->description);
233 if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
234 && MsgFmt && aptr->content->hdr) {
235 char s[SHORT_STRING];
237 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
238 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
239 M_FORMAT_ARROWCURSOR);
241 mutt_format_s (dest, destlen, prefix, s);
245 if (!aptr->content->filename) {
246 mutt_format_s (dest, destlen, prefix, "<no description>");
250 else if (aptr->content->description ||
251 (mutt_is_message_type
252 (aptr->content->type, aptr->content->subtype)
253 && MsgFmt && aptr->content->hdr))
255 /* FALLS THROUGH TO 'f' */
258 if (aptr->content->filename && *aptr->content->filename == '/') {
259 char path[_POSIX_PATH_MAX];
261 strfcpy (path, aptr->content->filename, sizeof (path));
262 mutt_pretty_mailbox (path);
263 mutt_format_s (dest, destlen, prefix, path);
266 mutt_format_s (dest, destlen, prefix,
267 NONULL (aptr->content->filename));
269 else if (!aptr->content->filename)
274 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
275 else if (!aptr->content->deleted)
280 mutt_format_s (dest, destlen, prefix,
281 ENCODING (aptr->content->encoding));
285 snprintf (dest, destlen, "%c",
286 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
291 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
295 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
296 else if (!aptr->content->subtype)
301 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
302 snprintf (dest, destlen, fmt, aptr->num + 1);
307 optional = aptr->content->attach_qualifies;
309 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
310 mutt_format_s (dest, destlen, fmt, "Q");
314 if (flags & M_FORMAT_STAT_FILE) {
317 stat (aptr->content->filename, &st);
321 l = aptr->content->length;
324 mutt_pretty_size (tmp, sizeof (tmp), l);
325 mutt_format_s (dest, destlen, prefix, tmp);
333 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
334 else if (!aptr->content->tagged)
339 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
340 else if (!aptr->tree)
345 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
346 else if (!aptr->content->unlink)
351 optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
353 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
354 snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
362 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
363 else if (flags & M_FORMAT_OPTIONAL)
364 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
368 static void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
370 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
371 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
372 M_FORMAT_ARROWCURSOR);
375 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
377 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
378 int ot = cur->tagged;
380 cur->tagged = (m >= 0 ? m : !cur->tagged);
381 return cur->tagged - ot;
384 int mutt_is_message_type (int type, const char *subtype)
386 if (type != TYPEMESSAGE)
389 subtype = NONULL (subtype);
390 return (ascii_strcasecmp (subtype, "rfc822") == 0
391 || ascii_strcasecmp (subtype, "news") == 0);
394 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
398 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
399 char path[_POSIX_PATH_MAX] = "";
405 if (body->filename) {
406 if (directory && *directory)
407 mutt_concat_path (buf, *directory, mutt_basename (body->filename),
410 strfcpy (buf, body->filename, sizeof (buf));
412 else if (body->hdr &&
413 body->encoding != ENCBASE64 &&
414 body->encoding != ENCQUOTEDPRINTABLE &&
415 mutt_is_message_type (body->type, body->subtype))
416 mutt_default_save (buf, sizeof (buf), body->hdr);
420 prompt = _("Save to file ('#' for last used folder): ");
423 mutt_get_field (prompt, buf, sizeof (buf),
424 M_FILE | M_CLEAR | M_LASTFOLDER);
425 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
429 char tmpbuf[_POSIX_PATH_MAX];
431 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
432 strfcpy (buf, tmpbuf, sizeof (buf));
433 ret = mutt_get_field (_("Save to file: ")
434 , buf, sizeof (buf), M_FILE);
435 if ((ret != 0) || (!buf[0]))
439 mutt_extract_path (buf, path);
440 strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder));
444 mutt_expand_path (buf, sizeof (buf));
448 body->encoding != ENCBASE64 &&
449 body->encoding != ENCQUOTEDPRINTABLE &&
450 mutt_is_message_type (body->type, body->subtype));
455 /* check to make sure that this file is really the one the user wants */
456 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
457 prompt = _("Save to file: ");
462 strfcpy (tfile, buf, sizeof (tfile));
466 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
467 &append, directory)) == -1)
470 prompt = _("Save to file: ");
475 mutt_message _("Saving...");
477 if (mutt_save_attachment
478 (fp, body, tfile, append,
479 (hdr || !is_message) ? hdr : body->hdr) == 0) {
480 mutt_message _("Attachment saved.");
485 prompt = _("Save to file: ");
492 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
495 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
496 char *directory = NULL;
498 int last = menu ? menu->current : -1;
503 for (; top; top = top->next) {
504 if (!tag || top->tagged) {
505 if (!option (OPTATTACHSPLIT)) {
509 strfcpy (buf, NONULL (top->filename), sizeof (buf));
510 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
511 M_FILE | M_CLEAR) != 0 || !buf[0])
513 mutt_expand_path (buf, sizeof (buf));
514 if (mutt_check_overwrite (top->filename, buf, tfile,
515 sizeof (tfile), &append, NULL))
517 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
518 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
519 fprintf (fpout, "%s", AttachSep);
524 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
525 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
526 fprintf (fpout, "%s", AttachSep);
532 if (tag && menu && top->aptr) {
533 menu->oldcurrent = menu->current;
534 menu->current = top->aptr->num;
535 menu_check_recenter (menu);
536 menu->redraw |= REDRAW_MOTION;
540 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
545 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
550 mem_free (&directory);
553 menu->oldcurrent = menu->current;
554 menu->current = last;
555 menu_check_recenter (menu);
556 menu->redraw |= REDRAW_MOTION;
559 if (!option (OPTATTACHSPLIT) && (rc == 0))
560 mutt_message _("Attachment saved.");
564 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int filter)
566 char tfile[_POSIX_PATH_MAX];
567 char warning[STRING + _POSIX_PATH_MAX];
570 snprintf (warning, sizeof (warning),
571 _("WARNING! You are about to overwrite %s, continue?"),
573 if (mutt_yesorno (warning, M_NO) != M_YES) {
574 CLEARLINE (LINES - 1);
582 if (mutt_pipe_attachment (fp, body, command, tfile)) {
584 mutt_unlink (body->filename);
585 mutt_rename_file (tfile, body->filename);
586 mutt_update_encoding (body);
587 mutt_message _("Attachment filtered.");
591 if (filter && tfile[0])
596 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
602 mutt_decode_attachment (b, state);
604 state_puts (AttachSep, state);
607 if ((ifp = fopen (b->filename, "r")) == NULL) {
608 mutt_perror ("fopen");
611 mutt_copy_stream (ifp, state->fpout);
614 state_puts (AttachSep, state);
619 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
620 int filter, STATE * state)
622 for (; top; top = top->next) {
623 if (!tag || top->tagged) {
624 if (!filter && !option (OPTATTACHSPLIT))
625 pipe_attachment (fp, top, state);
627 mutt_query_pipe_attachment (command, fp, top, filter);
630 pipe_attachment_list (command, fp, tag, top->parts, filter, state);
636 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
639 char buf[SHORT_STRING];
643 filter = 0; /* sanity check: we can't filter in the recv case yet */
646 memset (&state, 0, sizeof (STATE));
648 if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
649 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
652 mutt_expand_path (buf, sizeof (buf));
654 if (!filter && !option (OPTATTACHSPLIT)) {
656 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
657 pipe_attachment_list (buf, fp, tag, top, filter, &state);
658 fclose (state.fpout);
659 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
660 mutt_any_key_to_continue (NULL);
663 pipe_attachment_list (buf, fp, tag, top, filter, &state);
666 static int can_print (BODY * top, int tag)
670 for (; top; top = top->next) {
671 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
672 if (!tag || top->tagged) {
673 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
674 if (ascii_strcasecmp ("text/plain", top->subtype) &&
675 ascii_strcasecmp ("application/postscript", top->subtype)) {
676 if (!mutt_can_decode (top)) {
677 mutt_error (_("I dont know how to print %s attachments!"), type);
684 return (can_print (top->parts, tag));
691 static void print_attachment_list (FILE * fp, int tag, BODY * top,
697 for (; top; top = top->next) {
698 if (!tag || top->tagged) {
699 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
700 if (!option (OPTATTACHSPLIT)
701 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
702 if (!ascii_strcasecmp ("text/plain", top->subtype)
703 || !ascii_strcasecmp ("application/postscript", top->subtype))
704 pipe_attachment (fp, top, state);
705 else if (mutt_can_decode (top)) {
706 /* decode and print */
708 char newfile[_POSIX_PATH_MAX] = "";
711 mutt_mktemp (newfile);
712 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
714 if ((ifp = fopen (newfile, "r")) != NULL) {
715 mutt_copy_stream (ifp, state->fpout);
718 state_puts (AttachSep, state);
721 mutt_unlink (newfile);
725 mutt_print_attachment (fp, top);
728 print_attachment_list (fp, tag, top->parts, state);
734 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
742 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
746 if (!option (OPTATTACHSPLIT)) {
747 if (!can_print (top, tag))
750 memset (&state, 0, sizeof (STATE));
751 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
752 print_attachment_list (fp, tag, top, &state);
753 fclose (state.fpout);
754 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
755 mutt_any_key_to_continue (NULL);
758 print_attachment_list (fp, tag, top, &state);
762 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
763 short *idxlen, short *idxmax, MUTTMENU * menu)
765 ATTACHPTR **idx = *idxp;
767 while (--(*idxlen) >= 0)
768 idx[(*idxlen)]->content = NULL;
771 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
776 if (menu->current >= menu->max)
777 menu->current = menu->max - 1;
778 menu_check_recenter (menu);
779 menu->redraw |= REDRAW_INDEX;
785 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
786 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
787 short *idxmax, int recv)
789 ATTACHPTR **idx = *idxp;
792 int old_optweed = option (OPTWEED);
794 set_option (OPTWEED);
799 case OP_DISPLAY_HEADERS:
800 toggle_option (OPTWEED);
804 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
809 case OP_MAIN_NEXT_UNDELETED: /* hack */
810 if (menu->current < menu->max - 1) {
818 case OP_MAIN_PREV_UNDELETED: /* hack */
819 if (menu->current > 0) {
827 /* when we edit the content-type, we should redisplay the attachment
829 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
831 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
836 /* functions which are passed through from the pager */
837 case OP_CHECK_TRADITIONAL:
838 if (!(WithCrypto & APPLICATION_PGP)
839 || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) {
844 case OP_ATTACH_COLLAPSE:
851 while (op != OP_NULL);
854 if (option (OPTWEED) != old_optweed)
855 toggle_option (OPTWEED);
860 static void attach_collapse (BODY * b, short collapse, short init,
865 for (; b; b = b->next) {
866 i = init || b->collapsed;
867 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
868 && !ascii_strcasecmp (b->subtype, "digest"))
869 attach_collapse (b->parts, 1, 1, 0);
870 else if (b->type == TYPEMULTIPART
871 || mutt_is_message_type (b->type, b->subtype))
872 attach_collapse (b->parts, collapse, i, 0);
873 b->collapsed = collapse;
879 void mutt_attach_init (BODY * b)
881 for (; b; b = b->next) {
885 mutt_attach_init (b->parts);
889 static const char *Function_not_permitted =
890 N_("Function not permitted in attach-message mode.");
892 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
895 mutt_error _(Function_not_permitted); \
902 void mutt_view_attachments (HEADER * hdr)
905 int need_secured = 0;
907 char helpstr[SHORT_STRING];
912 ATTACHPTR **idx = NULL;
918 /* make sure we have parsed this message */
919 mutt_parse_mime_message (Context, hdr);
921 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
923 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
927 if (WithCrypto && ((hdr->security & ENCRYPT) ||
928 (mutt_is_application_smime (hdr->content) &
932 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
933 mx_close_message (&msg);
936 if ((WithCrypto & APPLICATION_SMIME)
937 && (hdr->security & APPLICATION_SMIME)) {
939 crypt_smime_getkeys (hdr->env);
941 if (mutt_is_application_smime (hdr->content)) {
942 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
946 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
952 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
954 mutt_free_body (&_cur);
961 if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) {
962 if (mutt_is_multipart_encrypted (hdr->content))
963 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
968 if (need_secured && !secured) {
969 mx_close_message (&msg);
970 mutt_error _("Can't decrypt encrypted message!");
976 if (!WithCrypto || !need_secured) {
981 menu = mutt_new_menu ();
982 menu->menu = MENU_ATTACH;
983 menu->title = _("Attachments");
984 menu->make_entry = attach_entry;
985 menu->tag = mutt_tag_attach;
987 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
989 mutt_attach_init (cur);
990 attach_collapse (cur, 0, 1, 0);
991 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
995 op = mutt_menuLoop (menu);
997 case OP_ATTACH_VIEW_MAILCAP:
998 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
1000 menu->redraw = REDRAW_FULL;
1003 case OP_ATTACH_VIEW_TEXT:
1004 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
1006 menu->redraw = REDRAW_FULL;
1009 case OP_DISPLAY_HEADERS:
1010 case OP_VIEW_ATTACH:
1012 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
1014 menu->redraw = REDRAW_FULL;
1017 case OP_ATTACH_COLLAPSE:
1018 if (!idx[menu->current]->content->parts) {
1019 mutt_error _("There are no subparts to show!");
1023 if (!idx[menu->current]->content->collapsed)
1024 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1026 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1027 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1030 case OP_FORGET_PASSPHRASE:
1031 crypt_forget_passphrase ();
1034 case OP_EXTRACT_KEYS:
1035 if ((WithCrypto & APPLICATION_PGP)) {
1036 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1039 idx[menu->current]->
1041 menu->redraw = REDRAW_FULL;
1045 case OP_CHECK_TRADITIONAL:
1046 if ((WithCrypto & APPLICATION_PGP)
1047 && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1048 : idx[menu->current]->content,
1050 hdr->security = crypt_query (cur);
1051 menu->redraw = REDRAW_FULL;
1056 mutt_print_attachment_list (fp, menu->tagprefix,
1057 menu->tagprefix ? cur : idx[menu->current]->
1062 mutt_pipe_attachment_list (fp, menu->tagprefix,
1063 menu->tagprefix ? cur : idx[menu->current]->
1068 mutt_save_attachment_list (fp, menu->tagprefix,
1069 menu->tagprefix ? cur : idx[menu->current]->
1070 content, hdr, menu);
1072 if (!menu->tagprefix && option (OPTRESOLVE)
1073 && menu->current < menu->max - 1)
1076 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1083 if (Context->magic == M_POP) {
1085 mutt_error _("Can't delete attachment from POP server.");
1092 if (Context->magic == M_NNTP) {
1094 mutt_error _("Can't delete attachment from newsserver.");
1100 if (WithCrypto && (hdr->security & (~PGP_TRADITIONAL_CHECKED))) {
1103 ("Deletion of attachments from encrypted messages is unsupported.");
1106 if (!menu->tagprefix) {
1107 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1108 idx[menu->current]->content->deleted = 1;
1109 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1111 menu->redraw = REDRAW_MOTION_RESYNCH;
1114 menu->redraw = REDRAW_CURRENT;
1118 _("Only deletion of multipart attachments is supported.");
1123 for (x = 0; x < menu->max; x++) {
1124 if (idx[x]->content->tagged) {
1125 if (idx[x]->parent_type == TYPEMULTIPART) {
1126 idx[x]->content->deleted = 1;
1127 menu->redraw = REDRAW_INDEX;
1131 _("Only deletion of multipart attachments is supported.");
1140 if (!menu->tagprefix) {
1141 idx[menu->current]->content->deleted = 0;
1142 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1144 menu->redraw = REDRAW_MOTION_RESYNCH;
1147 menu->redraw = REDRAW_CURRENT;
1152 for (x = 0; x < menu->max; x++) {
1153 if (idx[x]->content->tagged) {
1154 idx[x]->content->deleted = 0;
1155 menu->redraw = REDRAW_INDEX;
1163 mutt_attach_resend (fp, hdr, idx, idxlen,
1164 menu->tagprefix ? NULL : idx[menu->current]->
1166 menu->redraw = REDRAW_FULL;
1169 case OP_BOUNCE_MESSAGE:
1171 mutt_attach_bounce (fp, hdr, idx, idxlen,
1172 menu->tagprefix ? NULL : idx[menu->current]->
1174 menu->redraw = REDRAW_FULL;
1177 case OP_FORWARD_MESSAGE:
1179 mutt_attach_forward (fp, hdr, idx, idxlen,
1180 menu->tagprefix ? NULL : idx[menu->current]->
1182 menu->redraw = REDRAW_FULL;
1186 case OP_FORWARD_TO_GROUP:
1188 mutt_attach_forward (fp, hdr, idx, idxlen,
1189 menu->tagprefix ? NULL : idx[menu->current]->
1191 menu->redraw = REDRAW_FULL;
1197 if (!idx[menu->current]->content->hdr->env->followup_to ||
1198 str_casecmp (idx[menu->current]->content->hdr->env->followup_to,
1200 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1201 _("Reply by mail as poster prefers?")) !=
1203 mutt_attach_reply (fp, hdr, idx, idxlen,
1204 menu->tagprefix ? NULL : idx[menu->current]->
1205 content, SENDNEWS | SENDREPLY);
1206 menu->redraw = REDRAW_FULL;
1212 case OP_GROUP_REPLY:
1218 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1219 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1220 mutt_attach_reply (fp, hdr, idx, idxlen,
1221 menu->tagprefix ? NULL : idx[menu->current]->content,
1223 menu->redraw = REDRAW_FULL;
1227 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1228 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1232 mx_close_message (&msg);
1233 hdr->attach_del = 0;
1234 while (idxmax-- > 0) {
1237 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1238 hdr->attach_del = 1;
1239 if (idx[idxmax]->content)
1240 idx[idxmax]->content->aptr = NULL;
1241 mem_free (&idx[idxmax]->tree);
1242 mem_free (&idx[idxmax]);
1244 if (hdr->attach_del)
1249 if (WithCrypto && need_secured && secured) {
1251 mutt_free_body (&cur);
1254 mutt_menuDestroy (&menu);