diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | attach.c | 7 | ||||
-rw-r--r-- | attach.h | 8 | ||||
-rw-r--r-- | browser.c | 2 | ||||
-rw-r--r-- | commands.c | 2 | ||||
-rw-r--r-- | compose.c | 2 | ||||
-rw-r--r-- | curs_main.c | 5 | ||||
-rw-r--r-- | functions.h | 1 | ||||
-rw-r--r-- | init.h | 30 | ||||
-rw-r--r-- | mutt.h | 2 | ||||
-rw-r--r-- | muttlib.c | 107 | ||||
-rw-r--r-- | pager.c | 92 | ||||
-rw-r--r-- | pager.h | 2 | ||||
-rw-r--r-- | postpone.c | 36 | ||||
-rw-r--r-- | protos.h | 21 | ||||
-rw-r--r-- | recvattach.c | 357 | ||||
-rw-r--r-- | recvcmd.c | 873 | ||||
-rw-r--r-- | rfc1524.c | 39 | ||||
-rw-r--r-- | rfc1524.h | 1 | ||||
-rw-r--r-- | send.c | 235 | ||||
-rw-r--r-- | sendlib.c | 58 |
21 files changed, 1369 insertions, 513 deletions
diff --git a/Makefile.am b/Makefile.am index 4a6f3b93..d0ff659c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,7 +29,7 @@ mutt_SOURCES = $(BUILT_SOURCES) \ edit.c enter.c flags.c init.c filter.c from.c getdomain.c \ handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \ main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c \ - postpone.c query.c recvattach.c \ + postpone.c query.c recvattach.c recvcmd.c \ rfc822.c rfc1524.c rfc2047.c rfc2231.c \ score.c send.c sendlib.c signal.c sort.c \ status.c system.c thread.c charset.c history.c lib.c \ @@ -360,7 +360,8 @@ int mutt_is_autoview (BODY *b, const char *type) } /* returns -1 on error, 0 or the return code from mutt_do_pager() on success */ -int mutt_view_attachment (FILE *fp, BODY *a, int flag) +int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr, + ATTACHPTR **idx, short idxlen) { char tempfile[_POSIX_PATH_MAX] = ""; char pagerfile[_POSIX_PATH_MAX] = ""; @@ -570,6 +571,10 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag) info.fp = fp; info.bdy = a; info.ctx = Context; + info.idx = idx; + info.idxlen = idxlen; + info.hdr = hdr; + rc = mutt_do_pager (descrip, pagerfile, is_message ? M_PAGER_MESSAGE : 0, &info); } @@ -23,4 +23,10 @@ int mutt_tag_attach (MUTTMENU *menu, int n); void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr); void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter); void mutt_print_attachment_list (FILE *fp, int tag, BODY *top); -void mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, ATTACHPTR **idx); +void mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr, + ATTACHPTR **idx, short idxlen); + +void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *); +void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *); +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *); +void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); @@ -1030,7 +1030,7 @@ void _mutt_select_file (char *f, size_t flen, int buffy, b = mutt_make_file_attach (buf); if (b != NULL) { - mutt_view_attachment (NULL, b, M_REGULAR); + mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0); mutt_free_body (&b); menu->redraw = REDRAW_FULL; } @@ -227,7 +227,7 @@ void ci_bounce_message (HEADER *h, int *redraw) return; } - mutt_bounce_message (h, adr); + mutt_bounce_message (NULL, h, adr); rfc822_free_address (&adr); mutt_message (h ? _("Message bounced.") : _("Messages bounced.")); } @@ -1102,7 +1102,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ case OP_VIEW_ATTACH: case OP_DISPLAY_HEADERS: CHECK_COUNT; - mutt_attach_display_loop (menu, op, NULL, idx); + mutt_attach_display_loop (menu, op, NULL, NULL, idx, idxlen); menu->redraw = REDRAW_FULL; mutt_clear_error (); break; diff --git a/curs_main.c b/curs_main.c index d0c99587..5bdf8a40 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1676,12 +1676,11 @@ int mutt_index_menu (void) for (j = 0; j < Context->vcount; j++) { if (Context->hdrs[Context->v2r[j]]->tagged) - ci_send_message (SENDRESEND, NULL, NULL, Context, - Context->hdrs[Context->v2r[j]]); + mutt_resend_message (NULL, Context, Context->hdrs[Context->v2r[j]]); } } else - ci_send_message (SENDRESEND, NULL, NULL, Context, CURHDR); + mutt_resend_message (NULL, Context, CURHDR); menu->redraw = REDRAW_FULL; break; diff --git a/functions.h b/functions.h index 92c439e6..5bac5774 100644 --- a/functions.h +++ b/functions.h @@ -239,6 +239,7 @@ struct binding_t OpAttach[] = { { "pipe-entry", OP_PIPE, "|" }, { "view-mailcap", OP_ATTACH_VIEW_MAILCAP, "m" }, { "reply", OP_REPLY, "r" }, + { "resend-message", OP_RESEND, "\033e" }, { "group-reply", OP_GROUP_REPLY, "g" }, { "list-reply", OP_LIST_REPLY, "L" }, { "forward-message", OP_FORWARD_MESSAGE, "f" }, @@ -483,28 +483,6 @@ struct option_t MuttVars[] = { ** .pp ** Also see the ``$$record'' variable. */ - { "forward_attachment", DT_BOOL, R_NONE, OPTFORWATTACH, 0 }, - /* - ** .pp - ** When set, and you (tag-)forward attachments from the Attachment menu, - ** Mutt creates a new message with the specified attachments \fIonly\fP. - ** ``$$forward_format'' is used to set the default subject. - ** .pp - ** When unset, Mutt creates a pseudo-message comprising the tagged - ** attachments and forwards that. See the section on Forwarding a message - ** for details. - ** .pp - ** For example: if you have a message containing a image/gif, - ** application/octet-stream, or whatever attachment, you can go to the - ** Attachment menu and forward ONLY that attachment to someone else. - ** .pp - ** Basically, setting this variable produces the same effect as - ** explicitly saving the attachment(s), composing a new message and then - ** attaching the saved file(s). - */ - { "forw_attachment", DT_SYN, R_NONE, UL "forward_attachment", 0 }, - /* - */ { "forward_decode", DT_BOOL, R_NONE, OPTFORWDECODE, 1 }, /* ** .pp @@ -922,6 +900,14 @@ struct option_t MuttVars[] = { /* */ + { "mime_forward_rest", DT_QUAD, R_NONE, OPT_MIMEFWDREST, M_YES }, + /* + ** .pp + ** When forwarding multiple attachments of a MIME message from the recvattach + ** menu, attachments which cannot be decoded in a reasonable manner will + ** be attached to the newly composed message if this option is set. + */ + #ifdef MIXMASTER { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" }, /* @@ -245,6 +245,7 @@ enum OPT_ABORT, OPT_RECALL, OPT_SUBJECT, + OPT_MIMEFWDREST, OPT_MAX }; @@ -284,7 +285,6 @@ enum OPTFCCATTACH, OPTFOLLOWUPTO, OPTFORCENAME, - OPTFORWATTACH, OPTFORWDECODE, OPTFORWQUOTE, OPTHDRS, @@ -55,6 +55,113 @@ BODY *mutt_dup_body (BODY *b) return bn; } +/* Modified by blong to accept a "suggestion" for file name. If + * that file exists, then construct one with unique name but + * keep any extension. This might fail, I guess. + * Renamed to mutt_adv_mktemp so I only have to change where it's + * called, and not all possible cases. + */ +void mutt_adv_mktemp (char *s, size_t l) +{ + char buf[_POSIX_PATH_MAX]; + char tmp[_POSIX_PATH_MAX]; + char *period; + size_t sl; + struct stat sb; + + strfcpy (buf, NONULL (Tempdir), sizeof (buf)); + mutt_expand_path (buf, sizeof (buf)); + if (s[0] == '\0') + { + snprintf (s, l, "%s/muttXXXXXX", buf); + mktemp (s); + } + else + { + strfcpy (tmp, s, sizeof (tmp)); + snprintf (s, l, "%s/%s", buf, tmp); + if (lstat (s, &sb) == -1 && errno == ENOENT) + return; + if ((period = strrchr (tmp, '.')) != NULL) + *period = 0; + snprintf (s, l, "%s/%s.XXXXXX", buf, tmp); + mktemp (s); + if (period != NULL) + { + *period = '.'; + sl = mutt_strlen(s); + strfcpy(s + sl, period, l - sl); + } + } +} + +/* create a send-mode duplicate from a receive-mode body */ + +int mutt_copy_body (FILE *fp, BODY **tgt, BODY *src) +{ + char tmp[_POSIX_PATH_MAX]; + BODY *b; + + PARAMETER *par, **ppar; + + short use_disp; + + if (src->filename) + { + use_disp = 1; + strfcpy (tmp, src->filename, sizeof (tmp)); + } + else + { + use_disp = 0; + tmp[0] = '\0'; + } + + mutt_adv_mktemp (tmp, sizeof (tmp)); + if (mutt_save_attachment (fp, src, tmp, 0, NULL) == -1) + return -1; + + *tgt = mutt_new_body (); + b = *tgt; + + memcpy (b, src, sizeof (BODY)); + b->parts = NULL; + b->next = NULL; + + b->filename = safe_strdup (tmp); + b->use_disp = use_disp; + b->unlink = 1; + + if (mutt_is_text_type (b->type, b->subtype)) + b->noconv = 1; + + /* the following code is borrowed from mutt_prepare_template (). + * Does someone have a nice function name for it, so we can re-unite + * it? + */ + + b->xtype = safe_strdup (b->xtype); + b->subtype = safe_strdup (b->subtype); + b->form_name = safe_strdup (b->form_name); + b->filename = safe_strdup (b->filename); + b->d_filename = safe_strdup (b->d_filename); + + /* copy parameters */ + for (par = b->parameter, ppar = &b->parameter; par; ppar = &(*ppar)->next, par = par->next) + { + *ppar = mutt_new_parameter (); + (*ppar)->attribute = safe_strdup (par->attribute); + (*ppar)->value = safe_strdup (par->value); + } + + mutt_stamp_attachment (b); + + return 0; + +} + + + void mutt_free_body (BODY **p) { BODY *a = *p, *b; @@ -49,7 +49,10 @@ #define ISHEADER(x) ((x) == MT_COLOR_HEADER || (x) == MT_COLOR_HDEFAULT) #define IsAttach(x) (x && (x)->bdy) -#define IsHeader(x) (x && (x)->hdr) +#define IsRecvAttach(x) (x && (x)->bdy && (x)->fp) +#define IsSendAttach(x) (x && (x)->bdy && !(x)->fp) +#define IsMsgAttach(x) (x && (x)->fp && (x)->bdy && (x)->bdy->hdr) +#define IsHeader(x) (x && (x)->hdr && !(x)->bdy) static const char *Not_available_in_this_menu = N_("Not available in this menu."); static const char *Mailbox_is_read_only = N_("Mailbox is read-only."); @@ -1638,7 +1641,14 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) COLS-9 < sizeof (buffer) ? COLS-9 : sizeof (buffer), NONULL (PagerFmt), Context, extra->hdr, M_FORMAT_MAKEPRINT); } - printw ("%-*.*s -- (", COLS-10, COLS-10, IsHeader (extra) ? buffer : banner); + else if (IsMsgAttach (extra)) + { + _mutt_make_string (buffer, + COLS - 9 < sizeof (buffer) ? COLS - 9: sizeof (buffer), + NONULL (PagerFmt), Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT); + } + printw ("%-*.*s -- (", COLS-10, COLS-10, + IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner); if (last_pos < sb.st_size - 1) printw ("%d%%)", (int) (100 * last_offset / sb.st_size)); else @@ -2046,14 +2056,33 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) */ case OP_BOUNCE_MESSAGE: - CHECK_MODE(IsHeader (extra)); + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)) CHECK_ATTACH; - ci_bounce_message (extra->hdr, &redraw); + if (IsMsgAttach (extra)) + mutt_attach_bounce (extra->fp, extra->hdr, + extra->idx, extra->idxlen, + extra->bdy); + else + ci_bounce_message (extra->hdr, &redraw); break; + case OP_RESEND: + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)) + CHECK_ATTACH; + if (IsMsgAttach (extra)) + mutt_attach_resend (extra->fp, extra->hdr, + extra->idx, extra->idxlen, + extra->bdy); + else + mutt_resend_message (NULL, extra->ctx, extra->hdr); + break; + case OP_CREATE_ALIAS: - CHECK_MODE(IsHeader (extra)); - mutt_create_alias (extra->hdr->env, NULL); + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); + if (IsMsgAttach (extra)) + mutt_create_alias (extra->bdy->hdr->env, NULL); + else + mutt_create_alias (extra->hdr->env, NULL); MAYBE_REDRAW (redraw); break; @@ -2094,8 +2123,11 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) break; case OP_DISPLAY_ADDRESS: - CHECK_MODE(IsHeader (extra)); - mutt_display_address (extra->hdr->env); + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); + if (IsMsgAttach (extra)) + mutt_display_address (extra->bdy->hdr->env); + else + mutt_display_address (extra->hdr->env); break; case OP_ENTER_COMMAND: @@ -2206,21 +2238,29 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) break; case OP_PRINT: - CHECK_MODE(IsHeader (extra)); - mutt_print_message (extra->hdr); + CHECK_MODE(IsHeader (extra) || IsAttach (extra)); + if (IsAttach (extra)) + mutt_print_attachment_list (extra->fp, 0, extra->bdy); + else + mutt_print_message (extra->hdr); break; case OP_MAIL: - CHECK_MODE(IsHeader (extra)); + CHECK_MODE(IsHeader (extra) && !IsAttach (extra)); CHECK_ATTACH; ci_send_message (0, NULL, NULL, NULL, NULL); redraw = REDRAW_FULL; break; case OP_REPLY: - CHECK_MODE(IsHeader (extra)); + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); CHECK_ATTACH; - ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr); + if (IsMsgAttach (extra)) + mutt_attach_reply (extra->fp, extra->hdr, extra->idx, + extra->idxlen, extra->bdy, + SENDREPLY); + else + ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr); redraw = REDRAW_FULL; break; @@ -2232,23 +2272,35 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) break; case OP_GROUP_REPLY: - CHECK_MODE(IsHeader (extra)); + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); CHECK_ATTACH; - ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr); + if (IsMsgAttach (extra)) + mutt_attach_reply (extra->fp, extra->hdr, extra->idx, + extra->idxlen, extra->bdy, SENDREPLY|SENDGROUPREPLY); + else + ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr); redraw = REDRAW_FULL; break; case OP_LIST_REPLY: - CHECK_MODE(IsHeader (extra)); - CHECK_ATTACH; - ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr); + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); + CHECK_ATTACH; + if (IsMsgAttach (extra)) + mutt_attach_reply (extra->fp, extra->hdr, extra->idx, + extra->idxlen, extra->bdy, SENDREPLY|SENDLISTREPLY); + else + ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr); redraw = REDRAW_FULL; break; case OP_FORWARD_MESSAGE: - CHECK_MODE(IsHeader (extra)); + CHECK_MODE(IsHeader (extra) && !IsMsgAttach (extra)); CHECK_ATTACH; - ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); + if (IsMsgAttach (extra)) + mutt_attach_forward (extra->fp, extra->hdr, extra->idx, + extra->idxlen, extra->bdy); + else + ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); redraw = REDRAW_FULL; break; @@ -38,6 +38,8 @@ typedef struct HEADER *hdr; /* current message */ BODY *bdy; /* current attachment */ FILE *fp; /* source stream */ + ATTACHPTR **idx; /* attachment information */ + short idxlen; } pager_t; int mutt_do_pager (const char *, const char *, int, pager_t *); @@ -282,7 +282,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size return (-1); } - if (mutt_prepare_template (PostContext, hdr, h, 0) < 0) + if (mutt_prepare_template (NULL, PostContext, hdr, h, 0) < 0) { mx_fastclose_mailbox (PostContext); #ifdef USE_IMAP @@ -510,23 +510,31 @@ static void free_body_list (BODY **bp) } -int mutt_prepare_template (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, +int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, short weed) { PARAMETER *par, **ppar; - MESSAGE *msg; + MESSAGE *msg = NULL; char file[_POSIX_PATH_MAX]; BODY *b; LIST *p, **q; FILE *bfp; - - if ((msg = mx_open_message (ctx, hdr->msgno)) == NULL) + + if (!fp && (msg = mx_open_message (ctx, hdr->msgno)) == NULL) return (-1); + if (!fp) fp = msg->fp; + /* parse the message header */ - fseek (msg->fp, hdr->offset, 0); - newhdr->env = mutt_read_rfc822_header (msg->fp, newhdr, 1, weed); + fseek (fp, hdr->offset, 0); + newhdr->env = mutt_read_rfc822_header (fp, newhdr, 1, weed); + + /* NOTE: We do have easy access to the entire MIME structure of + * the message to be recalled here. We could use this to + * considerably simplify the code below. + */ + mutt_free_body (&newhdr->content); /* weed user-agent, x-mailer - we don't want them here */ @@ -551,7 +559,7 @@ int mutt_prepare_template (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, safe_free ((void **) &newhdr->env->mail_followup_to); /* make sure we parse the message */ - mutt_parse_part (msg->fp, hdr->content); + mutt_parse_part (fp, hdr->content); #ifdef _PGPPATH /* decrypt pgp/mime encoded messages */ @@ -562,7 +570,7 @@ int mutt_prepare_template (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, goto err; mutt_message _("Invoking PGP..."); - if (pgp_decrypt_mime (msg->fp, &bfp, hdr->content, &b) == -1) + if (pgp_decrypt_mime (fp, &bfp, hdr->content, &b) == -1) { err: mx_close_message (&msg); @@ -594,7 +602,7 @@ int mutt_prepare_template (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, (*ppar)->value = safe_strdup (par->value); } - bfp = msg->fp; + bfp = fp; } #ifdef _PGPPATH @@ -645,8 +653,8 @@ int mutt_prepare_template (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, { mutt_free_envelope (&newhdr->env); free_body_list (&newhdr->content); - if (bfp != msg->fp) fclose (bfp); - mx_close_message (&msg); + if (bfp != fp) fclose (bfp); + if (msg) mx_close_message (&msg); return -1; } @@ -664,8 +672,8 @@ int mutt_prepare_template (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, } /* that's it. */ - if (bfp != msg->fp) fclose (bfp); - mx_close_message (&msg); + if (bfp != fp) fclose (bfp); + if (msg) mx_close_message (&msg); return 0; } @@ -87,6 +87,8 @@ BODY *mutt_parse_multipart (FILE *, const char *, long, int); BODY *mutt_parse_messageRFC822 (FILE *, BODY *); BODY *mutt_read_mime_header (FILE *, int); +LIST *mutt_make_references(ENVELOPE *e); + ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short); HEADER *mutt_dup_header (HEADER *); @@ -123,11 +125,12 @@ char *mutt_make_date (char *, size_t); const char *mutt_fqdn(short); +void mutt_adv_mktemp (char *, size_t); void mutt_alias_menu (char *, size_t, ALIAS *); void mutt_block_signals (void); void mutt_block_signals_system (void); void mutt_body_handler (BODY *, STATE *); -void mutt_bounce_message (HEADER *, ADDRESS *); +void mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *); void mutt_buffy (char *); void mutt_check_rescore (CONTEXT *); void mutt_clear_error (void); @@ -143,7 +146,10 @@ void mutt_expand_file_fmt (char *, size_t, const char *, const char *); void mutt_expand_fmt (char *, size_t, const char *, const char *); void mutt_expand_link (char *, const char *, const char *); void mutt_fetchPopMail (void); +void mutt_fix_reply_recipients (ENVELOPE *env); void mutt_folder_hook (char *); +void mutt_forward_intro (FILE *fp, HEADER *cur); +void mutt_forward_trailer (FILE *fp); void mutt_free_alias (ALIAS **); void mutt_free_body (BODY **); void mutt_free_color (int fg, int bg); @@ -153,7 +159,11 @@ void mutt_free_parameter (PARAMETER **); void mutt_generate_header (char *, size_t, HEADER *, int); void mutt_help (int); void mutt_linearize_tree (CONTEXT *, int); +void mutt_make_attribution (CONTEXT *ctx, HEADER *cur, FILE *out); +void mutt_make_forward_subject (ENVELOPE *env, CONTEXT *ctx, HEADER *cur); void mutt_make_help (char *, size_t, char *, int, int); +void mutt_make_misc_reply_headers (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, ENVELOPE *curenv); +void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out); void mutt_message (const char *, ...); void mutt_message_to_7bit (BODY *, FILE *); void mutt_mktemp (char *); @@ -212,12 +222,15 @@ int mutt_command_complete (char *, size_t, int, int); int mutt_var_value_complete (char *, size_t, int); int mutt_complete (char *, size_t); int mutt_compose_attachment (BODY *a); +int mutt_copy_body (FILE *, BODY **, BODY *); int mutt_decode_save_attachment (FILE *, BODY *, char *, int, int); int mutt_display_message (HEADER *h); int mutt_edit_attachment(BODY *); int mutt_edit_message (CONTEXT *, HEADER *); +int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags); int mutt_parent_message (CONTEXT *, HEADER *); -int mutt_prepare_template(CONTEXT *, HEADER *, HEADER *, short); +int mutt_prepare_template(FILE*, CONTEXT *, HEADER *, HEADER *, short); +int mutt_resend_message (FILE *, CONTEXT *, HEADER *); #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL) int _mutt_enter_fname (const char *, char *, size_t, int *, int, int, char ***, int *); #define mutt_enter_string(A,B,C,D,E) _mutt_enter_string(A,B,C,D,E,0,NULL,NULL) @@ -264,7 +277,7 @@ int mutt_compose_menu (HEADER *, char *, size_t, HEADER *); int mutt_thread_set_flag (HEADER *, int, int, int); int mutt_user_is_recipient (HEADER *); void mutt_update_num_postponed (void); -int mutt_view_attachment (FILE*, BODY *, int); +int mutt_view_attachment (FILE*, BODY *, int, HEADER *, ATTACHPTR **, short); int mutt_wait_filter (pid_t); int mutt_which_case (const char *); int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *); @@ -414,6 +427,6 @@ int ioctl (int, int, ...); /* unsorted */ void ci_bounce_message (HEADER *, int *); -void ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *); +int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *); diff --git a/recvattach.c b/recvattach.c index da82819d..3d72d643 100644 --- a/recvattach.c +++ b/recvattach.c @@ -519,17 +519,16 @@ mutt_query_pipe_attachment (char *command, FILE *fp, BODY *body, int filter) } } -static STATE state; -static void pipe_attachment (FILE *fp, BODY *b) +static void pipe_attachment (FILE *fp, BODY *b, STATE *state) { FILE *ifp; if (fp) { - state.fpin = fp; - mutt_decode_attachment (b, &state); + state->fpin = fp; + mutt_decode_attachment (b, state); if (AttachSep) - state_puts (AttachSep, &state); + state_puts (AttachSep, state); } else { @@ -538,27 +537,28 @@ static void pipe_attachment (FILE *fp, BODY *b) mutt_perror ("fopen"); return; } - mutt_copy_stream (ifp, state.fpout); + mutt_copy_stream (ifp, state->fpout); fclose (ifp); if (AttachSep) - state_puts (AttachSep, &state); + state_puts (AttachSep, state); } } static void -pipe_attachment_list (char *command, FILE *fp, int tag, BODY *top, int filter) +pipe_attachment_list (char *command, FILE *fp, int tag, BODY *top, int filter, + STATE *state) { for (; top; top = top->next) { if (!tag || top->tagged) { if (!filter && !option (OPTATTACHSPLIT)) - pipe_attachment (fp, top); + pipe_attachment (fp, top, state); else mutt_query_pipe_attachment (command, fp, top, filter); } else if (top->parts) - pipe_attachment_list (command, fp, tag, top->parts, filter); + pipe_attachment_list (command, fp, tag, top->parts, filter, state); if (!tag) break; } @@ -566,6 +566,7 @@ pipe_attachment_list (char *command, FILE *fp, int tag, BODY *top, int filter) void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter) { + STATE state; char buf[SHORT_STRING]; pid_t thepid; @@ -585,13 +586,13 @@ void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter) { endwin (); thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL); - pipe_attachment_list (buf, fp, tag, top, filter); + pipe_attachment_list (buf, fp, tag, top, filter, &state); fclose (state.fpout); if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY)) mutt_any_key_to_continue (NULL); } else - pipe_attachment_list (buf, fp, tag, top, filter); + pipe_attachment_list (buf, fp, tag, top, filter, &state); } static int can_print (BODY *top, int tag) @@ -624,7 +625,7 @@ static int can_print (BODY *top, int tag) return (1); } -static void print_attachment_list (FILE *fp, int tag, BODY *top) +static void print_attachment_list (FILE *fp, int tag, BODY *top, STATE *state) { char type [STRING]; @@ -638,7 +639,7 @@ static void print_attachment_list (FILE *fp, int tag, BODY *top) { if (!mutt_strcasecmp ("text/plain", top->subtype) || !mutt_strcasecmp ("application/postscript", top->subtype)) - pipe_attachment (fp, top); + pipe_attachment (fp, top, state); else if (mutt_can_decode (top)) { /* decode and print */ @@ -651,10 +652,10 @@ static void print_attachment_list (FILE *fp, int tag, BODY *top) { if ((ifp = fopen (newfile, "r")) != NULL) { - mutt_copy_stream (ifp, state.fpout); + mutt_copy_stream (ifp, state->fpout); fclose (ifp); if (AttachSep) - state_puts (AttachSep, &state); + state_puts (AttachSep, state); } } mutt_unlink (newfile); @@ -664,7 +665,7 @@ static void print_attachment_list (FILE *fp, int tag, BODY *top) mutt_print_attachment (fp, top); } else if (top->parts) - print_attachment_list (fp, tag, top->parts); + print_attachment_list (fp, tag, top->parts, state); if (!tag) return; } @@ -672,6 +673,8 @@ static void print_attachment_list (FILE *fp, int tag, BODY *top) void mutt_print_attachment_list (FILE *fp, int tag, BODY *top) { + STATE state; + pid_t thepid; if (query_quadoption (OPT_PRINT, tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) != M_YES) return; @@ -683,255 +686,18 @@ void mutt_print_attachment_list (FILE *fp, int tag, BODY *top) endwin (); memset (&state, 0, sizeof (STATE)); thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL); - print_attachment_list (fp, tag, top); + print_attachment_list (fp, tag, top, &state); fclose (state.fpout); if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY)) mutt_any_key_to_continue (NULL); } else - print_attachment_list (fp, tag, top); -} - -static void -bounce_attachment_list (ADDRESS *adr, int tag, BODY *body, HEADER *hdr) -{ - for (; body; body = body->next) - { - if (!tag || body->tagged) - { - if (!mutt_is_message_type (body->type, body->subtype)) - { - mutt_error _("You may only bounce message/rfc822 parts."); - continue; - } - body->hdr->msgno = hdr->msgno; - mutt_bounce_message (body->hdr, adr); - } - else if (body->parts) - bounce_attachment_list (adr, tag, body->parts, hdr); - if (!tag) - break; - } -} - -static void query_bounce_attachment (int tag, BODY *top, HEADER *hdr) -{ - char prompt[SHORT_STRING]; - char buf[HUGE_STRING]; - ADDRESS *adr = NULL; - int rc; - - buf[0] = 0; - - if(!tag) - strfcpy(prompt, _("Bounce message to: "), sizeof(prompt)); - else - strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt)); - - rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS); - - if (rc || !buf[0]) - return; - - adr = rfc822_parse_adrlist (adr, buf); - adr = mutt_expand_aliases (adr); - buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), adr); - snprintf (prompt, sizeof (prompt), tag ? _("Bounce messages to %s...?") - : _("Bounce message to %s...?"), buf); - if (mutt_yesorno (prompt, 1) != 1) - { - rfc822_free_address (&adr); - CLEARLINE (LINES-1); - return; - } - bounce_attachment_list (adr, tag, top, hdr); - rfc822_free_address (&adr); -} - -static void -copy_tagged_attachments (FILE *fpout, FILE *fpin, const char *boundary, BODY *bdy) -{ - for (; bdy; bdy = bdy->next) - { - if (bdy->tagged) - { - fprintf (fpout, "\n--%s\n", boundary); - fseek (fpin, bdy->hdr_offset, 0); - mutt_copy_bytes (fpin, fpout, bdy->length + bdy->offset - bdy->hdr_offset); - } - else if (bdy->parts) - copy_tagged_attachments (fpout, fpin, boundary, bdy->parts); - } -} - -static int -create_tagged_message (const char *tempfile, - int tag, - CONTEXT *ctx, - HEADER *cur, - BODY *body) -{ - char *boundary; - MESSAGE *msg, *src; - CONTEXT tmpctx; - int magic; - - magic = DefaultMagic; - DefaultMagic = M_MBOX; - mx_open_mailbox (tempfile, M_APPEND, &tmpctx); - msg = mx_open_new_message (&tmpctx, cur, M_ADD_FROM); - src = mx_open_message (ctx, cur->msgno); - - if (tag) - { - mutt_copy_header (src->fp, cur, msg->fp, CH_XMIT, NULL); - boundary = mutt_get_parameter ("boundary", cur->content->parameter); - copy_tagged_attachments (msg->fp, src->fp, boundary, cur->content->parts); - fprintf (msg->fp, "--%s--\n", boundary); - } - else - { - /* single attachment */ - mutt_copy_header (src->fp, cur, msg->fp, CH_XMIT | CH_MIME | CH_NONEWLINE, NULL); - fputs ("Mime-Version: 1.0\n", msg->fp); - mutt_write_mime_header (body, msg->fp); - fputc ('\n', msg->fp); - fseek (src->fp, body->offset, 0); - mutt_copy_bytes (src->fp, msg->fp, body->length); - } - - mx_commit_message (msg, &tmpctx); - mx_close_message (&msg); - mx_close_message (&src); - mx_close_mailbox (&tmpctx); < |