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/mem.h>
16 #include <lib-lib/str.h>
17 #include <lib-lib/macros.h>
18 #include <lib-lib/ascii.h>
19 #include <lib-lib/file.h>
20 #include <lib-lib/mapping.h>
22 #include <lib-mime/mime.h>
27 #include "recvattach.h"
28 #include "mutt_curses.h"
29 #include "mutt_menu.h"
34 #include "mutt_crypt.h"
45 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
46 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
48 #define CHECK_READONLY if (Context->readonly) \
51 mutt_error _(Mailbox_is_read_only); \
55 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
57 static struct mapping_t AttachHelp[] = {
58 {N_("Exit"), OP_EXIT},
59 {N_("Save"), OP_SAVE},
60 {N_("Pipe"), OP_PIPE},
61 {N_("Print"), OP_PRINT},
62 {N_("Help"), OP_HELP},
66 static int mutt_extract_path (char *filename, char *path)
68 char *tmp = p_new(char, _POSIX_PATH_MAX);
73 while (*filename != '\0') {
74 if (*filename == '/') {
75 *help_ptr++ = *filename++;
80 *help_ptr++ = *filename++;
86 void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
92 for (x = 0; x < idxlen; x++) {
94 if (2 * (idx[x]->level + 2) < sizeof (buf)) {
96 s = buf + 2 * (idx[x]->level - 1);
97 *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
107 if (m_strcmp(idx[x]->tree, buf) != 0)
108 m_strreplace(&idx[x]->tree, buf);
111 idx[x]->tree = m_strdup(buf);
113 if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
114 s = buf + 2 * (idx[x]->level - 1);
115 *s++ = (idx[x]->content->next) ? '\005' : '\006';
121 ATTACHPTR **mutt_gen_attach_list (BODY * m,
125 short *idxmax, int level, int compose)
130 for (; m; m = m->next) {
131 if (*idxlen == *idxmax) {
132 p_realloc(&idx, (*idxmax) += 5);
133 for (i = *idxlen; i < *idxmax; i++)
137 if (m->type == TYPEMULTIPART && m->parts
139 || (parent_type == -1
140 && ascii_strcasecmp ("alternative", m->subtype)))
141 && (!(WithCrypto & APPLICATION_PGP)
142 || !mutt_is_multipart_encrypted (m))
145 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
150 idx[*idxlen] = p_new(ATTACHPTR, 1);
152 new = idx[(*idxlen)++];
155 new->parent_type = parent_type;
158 /* We don't support multipart messages in the compose menu yet */
159 if (!compose && !m->collapsed &&
160 ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP)
161 || !mutt_is_multipart_encrypted (m))
163 || mutt_is_message_type (m->type, m->subtype))) {
165 mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
172 mutt_update_tree (idx, *idxlen);
177 /* %c = character set: convert?
181 * %e = MIME content-transfer-encoding
183 * %I = content-disposition, either I (inline) or A (attachment)
186 * %m = major MIME type
188 * %n = attachment number
192 const char *mutt_attach_fmt (char *dest,
197 const char *ifstring,
198 const char *elsestring,
199 unsigned long data, format_flag flags)
202 char tmp[SHORT_STRING];
203 char charset[SHORT_STRING];
204 ATTACHPTR *aptr = (ATTACHPTR *) data;
205 int optional = (flags & M_FORMAT_OPTIONAL);
211 if (mutt_is_text_part (aptr->content) &&
212 mutt_get_body_charset (charset, sizeof (charset), aptr->content))
213 mutt_format_s (dest, destlen, prefix, charset);
215 mutt_format_s (dest, destlen, prefix, "");
217 else if (!mutt_is_text_part (aptr->content) ||
218 !mutt_get_body_charset (charset, sizeof (charset),
225 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
226 snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
227 aptr->content->noconv ? 'n' : 'c');
229 else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
234 if (aptr->content->description) {
235 mutt_format_s (dest, destlen, prefix, aptr->content->description);
238 if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
239 && MsgFmt && aptr->content->hdr) {
240 char s[SHORT_STRING];
242 _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
243 M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
244 M_FORMAT_ARROWCURSOR);
246 mutt_format_s (dest, destlen, prefix, s);
250 if (!aptr->content->filename) {
251 mutt_format_s (dest, destlen, prefix, "<no description>");
255 else if (aptr->content->description ||
256 (mutt_is_message_type
257 (aptr->content->type, aptr->content->subtype)
258 && MsgFmt && aptr->content->hdr))
260 /* FALLS THROUGH TO 'f' */
263 if (aptr->content->filename && *aptr->content->filename == '/') {
264 char path[_POSIX_PATH_MAX];
266 m_strcpy(path, sizeof(path), aptr->content->filename);
267 mutt_pretty_mailbox (path);
268 mutt_format_s (dest, destlen, prefix, path);
271 mutt_format_s (dest, destlen, prefix,
272 NONULL (aptr->content->filename));
274 else if (!aptr->content->filename)
279 snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
280 else if (!aptr->content->deleted)
285 mutt_format_s (dest, destlen, prefix,
286 ENCODING (aptr->content->encoding));
290 snprintf (dest, destlen, "%c",
291 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
296 mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
300 mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
301 else if (!aptr->content->subtype)
306 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
307 snprintf (dest, destlen, fmt, aptr->num + 1);
312 optional = aptr->content->attach_qualifies;
314 snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
315 mutt_format_s (dest, destlen, fmt, "Q");
319 if (flags & M_FORMAT_STAT_FILE) {
322 stat (aptr->content->filename, &st);
326 l = aptr->content->length;
329 mutt_pretty_size (tmp, sizeof (tmp), l);
330 mutt_format_s (dest, destlen, prefix, tmp);
338 snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
339 else if (!aptr->content->tagged)
344 mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
345 else if (!aptr->tree)
350 snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
351 else if (!aptr->content->unlink)
356 optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
358 snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
359 snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
367 mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
368 else if (flags & M_FORMAT_OPTIONAL)
369 mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
373 static void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
375 int w=(COLS-SW)>blen?blen:(COLS-SW);
376 mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
377 (unsigned long) (((ATTACHPTR **) menu->data)[num]),
378 M_FORMAT_ARROWCURSOR);
381 int mutt_tag_attach (MUTTMENU * menu, int n, int m)
383 BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
384 int ot = cur->tagged;
386 cur->tagged = (m >= 0 ? m : !cur->tagged);
387 return cur->tagged - ot;
390 int mutt_is_message_type (int type, const char *subtype)
392 if (type != TYPEMESSAGE)
395 subtype = NONULL (subtype);
396 return (ascii_strcasecmp (subtype, "rfc822") == 0
397 || ascii_strcasecmp (subtype, "news") == 0);
400 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
404 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
405 char path[_POSIX_PATH_MAX] = "";
411 if (body->filename) {
412 if (directory && *directory)
413 mutt_concat_path(buf, sizeof(buf), *directory,
414 mutt_basename(body->filename));
416 m_strcpy(buf, sizeof(buf), body->filename);
418 else if (body->hdr &&
419 body->encoding != ENCBASE64 &&
420 body->encoding != ENCQUOTEDPRINTABLE &&
421 mutt_is_message_type (body->type, body->subtype))
422 mutt_default_save (buf, sizeof (buf), body->hdr);
426 prompt = _("Save to file ('#' for last used folder): ");
429 mutt_get_field (prompt, buf, sizeof (buf),
430 M_FILE | M_CLEAR | M_LASTFOLDER);
431 if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
435 char tmpbuf[_POSIX_PATH_MAX];
437 snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
438 m_strcpy(buf, sizeof(buf), tmpbuf);
439 ret = mutt_get_field (_("Save to file: ")
440 , buf, sizeof (buf), M_FILE);
441 if ((ret != 0) || (!buf[0]))
445 mutt_extract_path (buf, path);
446 m_strcpy(LastSaveFolder, sizeof(LastSaveFolder), path);
450 mutt_expand_path (buf, sizeof (buf));
454 body->encoding != ENCBASE64 &&
455 body->encoding != ENCQUOTEDPRINTABLE &&
456 mutt_is_message_type (body->type, body->subtype));
461 /* check to make sure that this file is really the one the user wants */
462 if ((rc = mutt_save_confirm (buf, &st)) == 1) {
463 prompt = _("Save to file: ");
468 m_strcpy(tfile, sizeof(tfile), buf);
472 mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
473 &append, directory)) == -1)
476 prompt = _("Save to file: ");
481 mutt_message _("Saving...");
483 if (mutt_save_attachment
484 (fp, body, tfile, append,
485 (hdr || !is_message) ? hdr : body->hdr) == 0) {
486 mutt_message _("Attachment saved.");
491 prompt = _("Save to file: ");
498 void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
501 char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
502 char *directory = NULL;
504 int last = menu ? menu->current : -1;
509 for (; top; top = top->next) {
510 if (!tag || top->tagged) {
511 if (!option (OPTATTACHSPLIT)) {
515 m_strcpy(buf, sizeof(buf), NONULL(top->filename));
516 if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
517 M_FILE | M_CLEAR) != 0 || !buf[0])
519 mutt_expand_path (buf, sizeof (buf));
520 if (mutt_check_overwrite (top->filename, buf, tfile,
521 sizeof (tfile), &append, NULL))
523 rc = mutt_save_attachment (fp, top, tfile, append, hdr);
524 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
525 fprintf (fpout, "%s", AttachSep);
530 rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
531 if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
532 fprintf (fpout, "%s", AttachSep);
538 if (tag && menu && top->aptr) {
539 menu->oldcurrent = menu->current;
540 menu->current = top->aptr->num;
541 menu_check_recenter (menu);
542 menu->redraw |= REDRAW_MOTION;
546 if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
551 mutt_save_attachment_list (fp, 1, top->parts, hdr, menu);
556 p_delete(&directory);
559 menu->oldcurrent = menu->current;
560 menu->current = last;
561 menu_check_recenter (menu);
562 menu->redraw |= REDRAW_MOTION;
565 if (!option (OPTATTACHSPLIT) && (rc == 0))
566 mutt_message _("Attachment saved.");
570 mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int filter)
572 char tfile[_POSIX_PATH_MAX];
573 char warning[STRING + _POSIX_PATH_MAX];
576 snprintf (warning, sizeof (warning),
577 _("WARNING! You are about to overwrite %s, continue?"),
579 if (mutt_yesorno (warning, M_NO) != M_YES) {
580 CLEARLINE (LINES - 1);
588 if (mutt_pipe_attachment (fp, body, command, tfile)) {
590 mutt_unlink (body->filename);
591 mutt_rename_file (tfile, body->filename);
592 mutt_update_encoding (body);
593 mutt_message _("Attachment filtered.");
597 if (filter && tfile[0])
602 static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
608 mutt_decode_attachment (b, state);
610 state_puts (AttachSep, state);
613 if ((ifp = fopen (b->filename, "r")) == NULL) {
614 mutt_perror ("fopen");
617 mutt_copy_stream (ifp, state->fpout);
620 state_puts (AttachSep, state);
625 pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
626 int filter, STATE * state)
628 for (; top; top = top->next) {
629 if (!tag || top->tagged) {
630 if (!filter && !option (OPTATTACHSPLIT))
631 pipe_attachment (fp, top, state);
633 mutt_query_pipe_attachment (command, fp, top, filter);
636 pipe_attachment_list (command, fp, tag, top->parts, filter, state);
642 void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
645 char buf[SHORT_STRING];
649 filter = 0; /* sanity check: we can't filter in the recv case yet */
654 if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
655 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
658 mutt_expand_path (buf, sizeof (buf));
660 if (!filter && !option (OPTATTACHSPLIT)) {
662 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
663 pipe_attachment_list (buf, fp, tag, top, filter, &state);
664 fclose (state.fpout);
665 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
666 mutt_any_key_to_continue (NULL);
669 pipe_attachment_list (buf, fp, tag, top, filter, &state);
672 static int can_print (BODY * top, int tag)
676 for (; top; top = top->next) {
677 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
678 if (!tag || top->tagged) {
679 if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
680 if (ascii_strcasecmp ("text/plain", top->subtype) &&
681 ascii_strcasecmp ("application/postscript", top->subtype)) {
682 if (!mutt_can_decode (top)) {
683 mutt_error (_("I dont know how to print %s attachments!"), type);
690 return (can_print (top->parts, tag));
697 static void print_attachment_list (FILE * fp, int tag, BODY * top,
703 for (; top; top = top->next) {
704 if (!tag || top->tagged) {
705 snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
706 if (!option (OPTATTACHSPLIT)
707 && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
708 if (!ascii_strcasecmp ("text/plain", top->subtype)
709 || !ascii_strcasecmp ("application/postscript", top->subtype))
710 pipe_attachment (fp, top, state);
711 else if (mutt_can_decode (top)) {
712 /* decode and print */
714 char newfile[_POSIX_PATH_MAX] = "";
717 mutt_mktemp (newfile);
718 if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
720 if ((ifp = fopen (newfile, "r")) != NULL) {
721 mutt_copy_stream (ifp, state->fpout);
724 state_puts (AttachSep, state);
727 mutt_unlink (newfile);
731 mutt_print_attachment (fp, top);
734 print_attachment_list (fp, tag, top->parts, state);
740 void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
748 tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
752 if (!option (OPTATTACHSPLIT)) {
753 if (!can_print (top, tag))
757 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
758 print_attachment_list (fp, tag, top, &state);
759 fclose (state.fpout);
760 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
761 mutt_any_key_to_continue (NULL);
764 print_attachment_list (fp, tag, top, &state);
768 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
769 short *idxlen, short *idxmax, MUTTMENU * menu)
771 ATTACHPTR **idx = *idxp;
773 while (--(*idxlen) >= 0)
774 idx[(*idxlen)]->content = NULL;
777 idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
782 if (menu->current >= menu->max)
783 menu->current = menu->max - 1;
784 menu_check_recenter (menu);
785 menu->redraw |= REDRAW_INDEX;
791 mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
792 BODY * cur, ATTACHPTR *** idxp, short *idxlen,
793 short *idxmax, int recv)
795 ATTACHPTR **idx = *idxp;
798 int old_optweed = option (OPTWEED);
800 set_option (OPTWEED);
805 case OP_DISPLAY_HEADERS:
806 toggle_option (OPTWEED);
810 op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
815 case OP_MAIN_NEXT_UNDELETED: /* hack */
816 if (menu->current < menu->max - 1) {
824 case OP_MAIN_PREV_UNDELETED: /* hack */
825 if (menu->current > 0) {
833 /* when we edit the content-type, we should redisplay the attachment
835 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
837 mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
842 /* functions which are passed through from the pager */
843 case OP_CHECK_TRADITIONAL:
844 if (!(WithCrypto & APPLICATION_PGP)
845 || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) {
850 case OP_ATTACH_COLLAPSE:
857 while (op != OP_NULL);
860 if (option (OPTWEED) != old_optweed)
861 toggle_option (OPTWEED);
866 static void attach_collapse (BODY * b, short collapse, short init,
871 for (; b; b = b->next) {
872 i = init || b->collapsed;
873 if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
874 && !ascii_strcasecmp (b->subtype, "digest"))
875 attach_collapse (b->parts, 1, 1, 0);
876 else if (b->type == TYPEMULTIPART
877 || mutt_is_message_type (b->type, b->subtype))
878 attach_collapse (b->parts, collapse, i, 0);
879 b->collapsed = collapse;
885 void mutt_attach_init (BODY * b)
887 for (; b; b = b->next) {
891 mutt_attach_init (b->parts);
895 static const char *Function_not_permitted =
896 N_("Function not permitted in attach-message mode.");
898 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
901 mutt_error _(Function_not_permitted); \
908 void mutt_view_attachments (HEADER * hdr)
911 int need_secured = 0;
913 char helpstr[SHORT_STRING];
918 ATTACHPTR **idx = NULL;
924 /* make sure we have parsed this message */
925 mutt_parse_mime_message (Context, hdr);
927 mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
929 if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
933 if (WithCrypto && ((hdr->security & ENCRYPT) ||
934 (mutt_is_application_smime (hdr->content) &
938 if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
939 mx_close_message (&msg);
942 if ((WithCrypto & APPLICATION_SMIME)
943 && (hdr->security & APPLICATION_SMIME)) {
945 crypt_smime_getkeys (hdr->env);
947 if (mutt_is_application_smime (hdr->content)) {
948 secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
952 if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
958 secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
960 mutt_free_body (&_cur);
967 if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) {
968 if (mutt_is_multipart_encrypted (hdr->content))
969 secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
974 if (need_secured && !secured) {
975 mx_close_message (&msg);
976 mutt_error _("Can't decrypt encrypted message!");
982 if (!WithCrypto || !need_secured) {
987 menu = mutt_new_menu ();
988 menu->menu = MENU_ATTACH;
989 menu->title = _("Attachments");
990 menu->make_entry = attach_entry;
991 menu->tag = mutt_tag_attach;
993 mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
995 mutt_attach_init (cur);
996 attach_collapse (cur, 0, 1, 0);
997 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1001 op = mutt_menuLoop (menu);
1003 case OP_ATTACH_VIEW_MAILCAP:
1004 mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
1006 menu->redraw = REDRAW_FULL;
1009 case OP_ATTACH_VIEW_TEXT:
1010 mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
1012 menu->redraw = REDRAW_FULL;
1015 case OP_DISPLAY_HEADERS:
1016 case OP_VIEW_ATTACH:
1018 mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
1020 menu->redraw = REDRAW_FULL;
1023 case OP_ATTACH_COLLAPSE:
1024 if (!idx[menu->current]->content->parts) {
1025 mutt_error _("There are no subparts to show!");
1029 if (!idx[menu->current]->content->collapsed)
1030 attach_collapse (idx[menu->current]->content, 1, 0, 1);
1032 attach_collapse (idx[menu->current]->content, 0, 1, 1);
1033 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1036 case OP_FORGET_PASSPHRASE:
1037 crypt_forget_passphrase ();
1040 case OP_EXTRACT_KEYS:
1041 if ((WithCrypto & APPLICATION_PGP)) {
1042 crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
1045 idx[menu->current]->
1047 menu->redraw = REDRAW_FULL;
1051 case OP_CHECK_TRADITIONAL:
1052 if ((WithCrypto & APPLICATION_PGP)
1053 && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
1054 : idx[menu->current]->content,
1056 hdr->security = crypt_query (cur);
1057 menu->redraw = REDRAW_FULL;
1062 mutt_print_attachment_list (fp, menu->tagprefix,
1063 menu->tagprefix ? cur : idx[menu->current]->
1068 mutt_pipe_attachment_list (fp, menu->tagprefix,
1069 menu->tagprefix ? cur : idx[menu->current]->
1074 mutt_save_attachment_list (fp, menu->tagprefix,
1075 menu->tagprefix ? cur : idx[menu->current]->
1076 content, hdr, menu);
1078 if (!menu->tagprefix && option (OPTRESOLVE)
1079 && menu->current < menu->max - 1)
1082 menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
1089 if (Context->magic == M_POP) {
1091 mutt_error _("Can't delete attachment from POP server.");
1098 if (Context->magic == M_NNTP) {
1100 mutt_error _("Can't delete attachment from newsserver.");
1106 if (WithCrypto && (hdr->security & (~PGP_TRADITIONAL_CHECKED))) {
1109 ("Deletion of attachments from encrypted messages is unsupported.");
1112 if (!menu->tagprefix) {
1113 if (idx[menu->current]->parent_type == TYPEMULTIPART) {
1114 idx[menu->current]->content->deleted = 1;
1115 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1117 menu->redraw = REDRAW_MOTION_RESYNCH;
1120 menu->redraw = REDRAW_CURRENT;
1124 _("Only deletion of multipart attachments is supported.");
1129 for (x = 0; x < menu->max; x++) {
1130 if (idx[x]->content->tagged) {
1131 if (idx[x]->parent_type == TYPEMULTIPART) {
1132 idx[x]->content->deleted = 1;
1133 menu->redraw = REDRAW_INDEX;
1137 _("Only deletion of multipart attachments is supported.");
1146 if (!menu->tagprefix) {
1147 idx[menu->current]->content->deleted = 0;
1148 if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
1150 menu->redraw = REDRAW_MOTION_RESYNCH;
1153 menu->redraw = REDRAW_CURRENT;
1158 for (x = 0; x < menu->max; x++) {
1159 if (idx[x]->content->tagged) {
1160 idx[x]->content->deleted = 0;
1161 menu->redraw = REDRAW_INDEX;
1169 mutt_attach_resend (fp, hdr, idx, idxlen,
1170 menu->tagprefix ? NULL : idx[menu->current]->
1172 menu->redraw = REDRAW_FULL;
1175 case OP_BOUNCE_MESSAGE:
1177 mutt_attach_bounce (fp, hdr, idx, idxlen,
1178 menu->tagprefix ? NULL : idx[menu->current]->
1180 menu->redraw = REDRAW_FULL;
1183 case OP_FORWARD_MESSAGE:
1185 mutt_attach_forward (fp, hdr, idx, idxlen,
1186 menu->tagprefix ? NULL : idx[menu->current]->
1188 menu->redraw = REDRAW_FULL;
1192 case OP_FORWARD_TO_GROUP:
1194 mutt_attach_forward (fp, hdr, idx, idxlen,
1195 menu->tagprefix ? NULL : idx[menu->current]->
1197 menu->redraw = REDRAW_FULL;
1203 if (!idx[menu->current]->content->hdr->env->followup_to ||
1204 m_strcasecmp(idx[menu->current]->content->hdr->env->followup_to,
1206 || query_quadoption (OPT_FOLLOWUPTOPOSTER,
1207 _("Reply by mail as poster prefers?")) !=
1209 mutt_attach_reply (fp, hdr, idx, idxlen,
1210 menu->tagprefix ? NULL : idx[menu->current]->
1211 content, SENDNEWS | SENDREPLY);
1212 menu->redraw = REDRAW_FULL;
1218 case OP_GROUP_REPLY:
1224 (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
1225 (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
1226 mutt_attach_reply (fp, hdr, idx, idxlen,
1227 menu->tagprefix ? NULL : idx[menu->current]->content,
1229 menu->redraw = REDRAW_FULL;
1233 mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
1234 mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
1238 mx_close_message (&msg);
1239 hdr->attach_del = 0;
1240 while (idxmax-- > 0) {
1243 if (idx[idxmax]->content && idx[idxmax]->content->deleted)
1244 hdr->attach_del = 1;
1245 if (idx[idxmax]->content)
1246 idx[idxmax]->content->aptr = NULL;
1247 p_delete(&idx[idxmax]->tree);
1248 p_delete(&idx[idxmax]);
1250 if (hdr->attach_del)
1255 if (WithCrypto && need_secured && secured) {
1257 mutt_free_body (&cur);
1260 mutt_menuDestroy (&menu);