diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1998-08-28 00:53:12 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1998-08-28 00:53:12 +0000 |
commit | f58938adf13af45527dd59838ba9782ba10d033c (patch) | |
tree | 37206dbb14e94a23e81eb7633463fccaab458dff | |
parent | 4f94f6fbe594c03eebfceef4a5fd908c45bf27ba (diff) |
[patch-0.94.4i.tlr.get_attachment.1] Create a new
"get-attachment" function on the compose menu which will
copy an attachment to a temporary file.
-rw-r--r-- | OPS | 1 | ||||
-rw-r--r-- | attach.c | 34 | ||||
-rw-r--r-- | compose.c | 34 | ||||
-rw-r--r-- | functions.h | 3 | ||||
-rw-r--r-- | protos.h | 1 |
5 files changed, 70 insertions, 3 deletions
@@ -23,6 +23,7 @@ OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field" OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message" OP_COMPOSE_EDIT_TO "edit the TO list" OP_COMPOSE_EDIT_TYPE "edit attachment type" +OP_COMPOSE_GET_ATTACHMENT "get a temporary copy of an attachment" OP_COMPOSE_ISPELL "run ispell on the message" OP_COMPOSE_NEW_MIME "compose new attachment using mailcap entry" OP_COMPOSE_POSTPONE_MESSAGE "save this message to send later" @@ -40,6 +40,40 @@ #include <string.h> #include <errno.h> +int mutt_get_tmp_attachment (BODY *a) +{ + char type[STRING]; + char tempfile[_POSIX_PATH_MAX]; + rfc1524_entry *entry = rfc1524_new_entry(); + FILE *fpin = NULL, *fpout = NULL; + + if(a->unlink) + return 0; + + snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype); + rfc1524_mailcap_lookup(a, type, entry, 0); + rfc1524_expand_filename(entry->nametemplate, a->filename, + tempfile, sizeof(tempfile)); + + rfc1524_free_entry(&entry); + + if((fpin = fopen(a->filename, "r")) && (fpout = safe_fopen(tempfile, "w"))) + { + mutt_copy_stream (fpin, fpout); + FREE(&a->filename); + a->filename = safe_strdup(tempfile); + a->unlink = 1; + } + else + mutt_perror(fpin ? tempfile : a->filename); + + if(fpin) fclose(fpin); + if(fpout) fclose(fpout); + + return a->unlink ? 0 : -1; +} + + /* return 1 if require full screen redraw, 0 otherwise */ int mutt_compose_attachment (BODY *a) { @@ -746,8 +746,21 @@ int mutt_send_menu (HEADER *msg, /* structure for new message */ case OP_COMPOSE_UPDATE_ENCODING: CHECK_COUNT; - mutt_update_encoding(idx[menu->current]->content); - menu->redraw = REDRAW_CURRENT; + if(menu->tagprefix) + { + BODY *top; + for(top = msg->content; top; top = top->next) + { + if(top->tagged) + mutt_update_encoding(top); + } + menu->redraw = REDRAW_FULL; + } + else + { + mutt_update_encoding(idx[menu->current]->content); + menu->redraw = REDRAW_CURRENT; + } break; case OP_COMPOSE_EDIT_TYPE: @@ -825,6 +838,23 @@ int mutt_send_menu (HEADER *msg, /* structure for new message */ menu->redraw = REDRAW_INDEX; break; + case OP_COMPOSE_GET_ATTACHMENT: + CHECK_COUNT; + if(menu->tagprefix) + { + BODY *top; + for(top = msg->content; top; top = top->next) + { + if(top->tagged) + mutt_get_tmp_attachment(top); + } + menu->redraw = REDRAW_FULL; + } + else if (mutt_get_tmp_attachment(idx[menu->current]->content) == 0) + menu->redraw = REDRAW_CURRENT; + + break; + case OP_COMPOSE_RENAME_FILE: CHECK_COUNT; strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname)); diff --git a/functions.h b/functions.h index 9579ec7c..384c5fd1 100644 --- a/functions.h +++ b/functions.h @@ -322,7 +322,8 @@ struct binding_t OpCompose[] = { { "edit-encoding", OP_COMPOSE_EDIT_ENCODING, "\005" }, { "edit-from", OP_COMPOSE_EDIT_FROM, "\033f" }, { "edit-fcc", OP_COMPOSE_EDIT_FCC, "f" }, - { "filter-entry", OP_FILTER, "F" }, + { "filter-entry", OP_FILTER, "F" }, + { "get-attachment", OP_COMPOSE_GET_ATTACHMENT, "G" }, { "ispell", OP_COMPOSE_ISPELL, "i" }, { "print-entry", OP_PRINT, "l" }, { "redraw-screen", OP_REDRAW, "\014" }, @@ -222,6 +222,7 @@ int mutt_enter_string (unsigned char *, size_t, int, int, int); int mutt_get_field (char *, char *, size_t, int); int mutt_get_password (char *, char *, size_t); int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **); +int mutt_get_tmp_attachment (BODY *); int mutt_index_menu (int); int mutt_invoke_sendmail (ADDRESS *, ADDRESS *, ADDRESS *, const char *, int); int mutt_is_autoview (char *); |