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"
#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)
{
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:
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));
{ "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" },
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 *);