Commit 6f4016be authored by Thomas Roessler's avatar Thomas Roessler

Michael Elkins' content-disposition patch, with some small changes.

parent d883b7e2
...@@ -36,6 +36,7 @@ OP_COMPOSE_RECODE "recode this attachment to/from the local charset" ...@@ -36,6 +36,7 @@ OP_COMPOSE_RECODE "recode this attachment to/from the local charset"
OP_COMPOSE_POSTPONE_MESSAGE "save this message to send later" OP_COMPOSE_POSTPONE_MESSAGE "save this message to send later"
OP_COMPOSE_RENAME_FILE "rename/move an attached file" OP_COMPOSE_RENAME_FILE "rename/move an attached file"
OP_COMPOSE_SEND_MESSAGE "send the message" OP_COMPOSE_SEND_MESSAGE "send the message"
OP_COMPOSE_TOGGLE_DISPOSITION "toggle disposition between inline/attachment"
OP_COMPOSE_TOGGLE_UNLINK "toggle whether to delete file after sending it" OP_COMPOSE_TOGGLE_UNLINK "toggle whether to delete file after sending it"
OP_COMPOSE_UPDATE_ENCODING "update an attachment's encoding info" OP_COMPOSE_UPDATE_ENCODING "update an attachment's encoding info"
OP_COMPOSE_WRITE_MESSAGE "write the message to a folder" OP_COMPOSE_WRITE_MESSAGE "write the message to a folder"
......
...@@ -845,6 +845,12 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ ...@@ -845,6 +845,12 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
} }
break; break;
case OP_COMPOSE_TOGGLE_DISPOSITION:
/* toggle the content-disposition between inline/attachment */
idx[menu->current]->content->disposition = (idx[menu->current]->content->disposition == DISPINLINE) ? DISPATTACH : DISPINLINE;
menu->redraw = REDRAW_CURRENT;
break;
case OP_EDIT_TYPE: case OP_EDIT_TYPE:
CHECK_COUNT; CHECK_COUNT;
{ {
......
...@@ -270,7 +270,7 @@ struct binding_t OpCompose[] = { ...@@ -270,7 +270,7 @@ struct binding_t OpCompose[] = {
{ "edit-cc", OP_COMPOSE_EDIT_CC, "c" }, { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
{ "copy-file", OP_SAVE, "C" }, { "copy-file", OP_SAVE, "C" },
{ "detach-file", OP_DELETE, "D" }, { "detach-file", OP_DELETE, "D" },
{ "display-toggle-weed", OP_DISPLAY_HEADERS, "h" }, { "toggle-disposition",OP_COMPOSE_TOGGLE_DISPOSITION, "\004" },
{ "edit-description", OP_COMPOSE_EDIT_DESCRIPTION, "d" }, { "edit-description", OP_COMPOSE_EDIT_DESCRIPTION, "d" },
{ "edit-message", OP_COMPOSE_EDIT_MESSAGE, "e" }, { "edit-message", OP_COMPOSE_EDIT_MESSAGE, "e" },
{ "edit-headers", OP_COMPOSE_EDIT_HEADERS, "E" }, { "edit-headers", OP_COMPOSE_EDIT_HEADERS, "E" },
...@@ -280,6 +280,7 @@ struct binding_t OpCompose[] = { ...@@ -280,6 +280,7 @@ struct binding_t OpCompose[] = {
{ "edit-fcc", OP_COMPOSE_EDIT_FCC, "f" }, { "edit-fcc", OP_COMPOSE_EDIT_FCC, "f" },
{ "filter-entry", OP_FILTER, "F" }, { "filter-entry", OP_FILTER, "F" },
{ "get-attachment", OP_COMPOSE_GET_ATTACHMENT, "G" }, { "get-attachment", OP_COMPOSE_GET_ATTACHMENT, "G" },
{ "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
{ "ispell", OP_COMPOSE_ISPELL, "i" }, { "ispell", OP_COMPOSE_ISPELL, "i" },
{ "print-entry", OP_PRINT, "l" }, { "print-entry", OP_PRINT, "l" },
{ "edit-mime", OP_COMPOSE_EDIT_MIME, "m" }, { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
......
...@@ -177,7 +177,7 @@ struct option_t MuttVars[] = { ...@@ -177,7 +177,7 @@ struct option_t MuttVars[] = {
** If set, Mutt will prompt you for carbon-copy (Cc) recipients before ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
** editing the body of an outgoing message. ** editing the body of an outgoing message.
*/ */
{ "attach_format", DT_STR, R_NONE, UL &AttachFormat, UL "%u%D%t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " }, { "attach_format", DT_STR, R_NONE, UL &AttachFormat, UL "%u%D%t%I%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " },
/* /*
** .pp ** .pp
** This variable describes the format of the `attachment' menu. The ** This variable describes the format of the `attachment' menu. The
...@@ -188,6 +188,7 @@ struct option_t MuttVars[] = { ...@@ -188,6 +188,7 @@ struct option_t MuttVars[] = {
** %d description ** %d description
** %e MIME content-transfer-encoding ** %e MIME content-transfer-encoding
** %f filename ** %f filename
** %I disposition (I=inline, A=attachment)
** %m major MIME type ** %m major MIME type
** %M MIME subtype ** %M MIME subtype
** %n attachment number ** %n attachment number
......
...@@ -519,7 +519,7 @@ typedef struct body ...@@ -519,7 +519,7 @@ typedef struct body
unsigned int type : 4; /* content-type primary type */ unsigned int type : 4; /* content-type primary type */
unsigned int encoding : 3; /* content-transfer-encoding */ unsigned int encoding : 3; /* content-transfer-encoding */
unsigned int disposition : 2; /* content-disposition */ unsigned int disposition : 2; /* content-disposition */
unsigned int use_disp : 1; /* Content-Disposition field printed? */ unsigned int use_disp : 1; /* Content-Disposition uses filename= ? */
unsigned int unlink : 1; /* flag to indicate the the file named by unsigned int unlink : 1; /* flag to indicate the the file named by
* "filename" should be unlink()ed before * "filename" should be unlink()ed before
* free()ing this structure * free()ing this structure
......
...@@ -370,11 +370,12 @@ BODY *mutt_read_mime_header (FILE *fp, int digest) ...@@ -370,11 +370,12 @@ BODY *mutt_read_mime_header (FILE *fp, int digest)
char *line = safe_malloc (LONG_STRING); char *line = safe_malloc (LONG_STRING);
size_t linelen = LONG_STRING; size_t linelen = LONG_STRING;
p->hdr_offset = ftell(fp); p->hdr_offset = ftell(fp);
p->encoding = ENC7BIT; /* default from RFC1521 */
p->type = digest ? TYPEMESSAGE : TYPETEXT;
p->encoding = ENC7BIT; /* default from RFC1521 */
p->type = digest ? TYPEMESSAGE : TYPETEXT;
p->disposition = DISPINLINE;
while (*(line = read_rfc822_line (fp, line, &linelen)) != 0) while (*(line = read_rfc822_line (fp, line, &linelen)) != 0)
{ {
/* Find the value of the current header */ /* Find the value of the current header */
...@@ -887,10 +888,13 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs, ...@@ -887,10 +888,13 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
hdr->content = mutt_new_body (); hdr->content = mutt_new_body ();
/* set the defaults from RFC1521 */ /* set the defaults from RFC1521 */
hdr->content->type = TYPETEXT; hdr->content->type = TYPETEXT;
hdr->content->subtype = safe_strdup ("plain"); hdr->content->subtype = safe_strdup ("plain");
hdr->content->encoding = ENC7BIT; hdr->content->encoding = ENC7BIT;
hdr->content->length = -1; hdr->content->length = -1;
/* RFC 2183 says this is arbitrary */
hdr->content->disposition = DISPINLINE;
} }
} }
......
...@@ -1122,8 +1122,9 @@ static BODY *pgp_sign_message (BODY *a) ...@@ -1122,8 +1122,9 @@ static BODY *pgp_sign_message (BODY *a)
t = mutt_new_body (); t = mutt_new_body ();
t->type = TYPEMULTIPART; t->type = TYPEMULTIPART;
t->subtype = safe_strdup ("signed"); t->subtype = safe_strdup ("signed");
t->use_disp = 0;
t->encoding = ENC7BIT; t->encoding = ENC7BIT;
t->use_disp = 0;
t->disposition = DISPINLINE;
mutt_generate_boundary (&t->parameter); mutt_generate_boundary (&t->parameter);
mutt_set_parameter ("protocol", "application/pgp-signature", &t->parameter); mutt_set_parameter ("protocol", "application/pgp-signature", &t->parameter);
...@@ -1138,6 +1139,7 @@ static BODY *pgp_sign_message (BODY *a) ...@@ -1138,6 +1139,7 @@ static BODY *pgp_sign_message (BODY *a)
t->subtype = safe_strdup ("pgp-signature"); t->subtype = safe_strdup ("pgp-signature");
t->filename = safe_strdup (sigfile); t->filename = safe_strdup (sigfile);
t->use_disp = 0; t->use_disp = 0;
t->disposition = DISPINLINE;
t->encoding = ENC7BIT; t->encoding = ENC7BIT;
t->unlink = 1; /* ok to remove this file after sending. */ t->unlink = 1; /* ok to remove this file after sending. */
...@@ -1345,6 +1347,7 @@ static BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign) ...@@ -1345,6 +1347,7 @@ static BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
t->subtype = safe_strdup ("encrypted"); t->subtype = safe_strdup ("encrypted");
t->encoding = ENC7BIT; t->encoding = ENC7BIT;
t->use_disp = 0; t->use_disp = 0;
t->disposition = DISPINLINE;
mutt_generate_boundary(&t->parameter); mutt_generate_boundary(&t->parameter);
mutt_set_parameter("protocol", "application/pgp-encrypted", &t->parameter); mutt_set_parameter("protocol", "application/pgp-encrypted", &t->parameter);
...@@ -1353,7 +1356,9 @@ static BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign) ...@@ -1353,7 +1356,9 @@ static BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
t->parts->type = TYPEAPPLICATION; t->parts->type = TYPEAPPLICATION;
t->parts->subtype = safe_strdup ("pgp-encrypted"); t->parts->subtype = safe_strdup ("pgp-encrypted");
t->parts->encoding = ENC7BIT; t->parts->encoding = ENC7BIT;
t->parts->use_disp = 0; t->parts->use_disp = 1;
t->parts->disposition = DISPINLINE;
t->parts->d_filename = safe_strdup ("msg.asc"); /* non pgp/mime can save */
t->parts->next = mutt_new_body (); t->parts->next = mutt_new_body ();
t->parts->next->type = TYPEAPPLICATION; t->parts->next->type = TYPEAPPLICATION;
...@@ -1361,6 +1366,7 @@ static BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign) ...@@ -1361,6 +1366,7 @@ static BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
t->parts->next->encoding = ENC7BIT; t->parts->next->encoding = ENC7BIT;
t->parts->next->filename = safe_strdup (tempfile); t->parts->next->filename = safe_strdup (tempfile);
t->parts->next->use_disp = 0; t->parts->next->use_disp = 0;
t->parts->next->disposition = DISPINLINE;
t->parts->next->unlink = 1; /* delete after sending the message */ t->parts->next->unlink = 1; /* delete after sending the message */
return (t); return (t);
......
...@@ -161,6 +161,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY *m, ...@@ -161,6 +161,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY *m,
* %d = description * %d = description
* %e = MIME content-transfer-encoding * %e = MIME content-transfer-encoding
* %f = filename * %f = filename
* %I = content-disposition, either I (inline) or A (attachment)
* %t = tagged flag * %t = tagged flag
* %m = major MIME type * %m = major MIME type
* %M = MIME subtype * %M = MIME subtype
...@@ -275,6 +276,13 @@ const char *mutt_attach_fmt (char *dest, ...@@ -275,6 +276,13 @@ const char *mutt_attach_fmt (char *dest,
snprintf (dest, destlen, fmt, ENCODING (aptr->content->encoding)); snprintf (dest, destlen, fmt, ENCODING (aptr->content->encoding));
} }
break; break;
case 'I':
if (!optional)
{
snprintf (dest, destlen, "%c",
(aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
}
break;
case 'm': case 'm':
if(!optional) if(!optional)
{ {
......
...@@ -1038,6 +1038,7 @@ ci_send_message (int flags, /* send mode */ ...@@ -1038,6 +1038,7 @@ ci_send_message (int flags, /* send mode */
msg->content->subtype = safe_strdup ("plain"); msg->content->subtype = safe_strdup ("plain");
msg->content->unlink = 1; msg->content->unlink = 1;
msg->content->use_disp = 0; msg->content->use_disp = 0;
msg->content->disposition = DISPINLINE;
if (!tempfile) if (!tempfile)
{ {
......
...@@ -407,10 +407,10 @@ int mutt_write_mime_header (BODY *a, FILE *f) ...@@ -407,10 +407,10 @@ int mutt_write_mime_header (BODY *a, FILE *f)
if (a->description) if (a->description)
fprintf(f, "Content-Description: %s\n", a->description); fprintf(f, "Content-Description: %s\n", a->description);
if (a->use_disp && (a->disposition == DISPATTACH || a->filename || a->d_filename)) fprintf (f, "Content-Disposition: %s", DISPOSITION (a->disposition));
{
fprintf (f, "Content-Disposition: %s", DISPOSITION (a->disposition));
if (a->use_disp)
{
if(!(fn = a->d_filename)) if(!(fn = a->d_filename))
fn = a->filename; fn = a->filename;
...@@ -427,10 +427,10 @@ int mutt_write_mime_header (BODY *a, FILE *f) ...@@ -427,10 +427,10 @@ int mutt_write_mime_header (BODY *a, FILE *f)
rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials); rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials);
fprintf (f, "; filename%s=%s", encode ? "*" : "", buffer); fprintf (f, "; filename%s=%s", encode ? "*" : "", buffer);
} }
fputc ('\n', f);
} }
fputc ('\n', f);
if (a->encoding != ENC7BIT) if (a->encoding != ENC7BIT)
fprintf(f, "Content-Transfer-Encoding: %s\n", ENCODING (a->encoding)); fprintf(f, "Content-Transfer-Encoding: %s\n", ENCODING (a->encoding));
...@@ -999,6 +999,7 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg) ...@@ -999,6 +999,7 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
body->filename = safe_strdup (buffer); body->filename = safe_strdup (buffer);
body->unlink = 1; body->unlink = 1;
body->use_disp = 0; body->use_disp = 0;
body->disposition = DISPINLINE;
mutt_parse_mime_message (ctx, hdr); mutt_parse_mime_message (ctx, hdr);
...@@ -1143,6 +1144,7 @@ BODY *mutt_make_multipart (BODY *b) ...@@ -1143,6 +1144,7 @@ BODY *mutt_make_multipart (BODY *b)
new->encoding = get_toplevel_encoding (b); new->encoding = get_toplevel_encoding (b);
mutt_generate_boundary (&new->parameter); mutt_generate_boundary (&new->parameter);
new->use_disp = 0; new->use_disp = 0;
new->disposition = DISPINLINE;
new->parts = b; new->parts = b;
return new; return new;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment