]> granicus.if.org Git - mutt/commitdiff
Michael Elkins' content-disposition patch, with some small changes.
authorThomas Roessler <roessler@does-not-exist.org>
Sat, 29 Jan 2000 07:56:37 +0000 (07:56 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Sat, 29 Jan 2000 07:56:37 +0000 (07:56 +0000)
OPS
compose.c
functions.h
init.h
mutt.h
parse.c
pgp.c
recvattach.c
send.c
sendlib.c

diff --git a/OPS b/OPS
index 2c3898fa8286258cee139cff267c6fa3cf67bbf0..b615035417fbeea22c34942a92606994ad7becd4 100644 (file)
--- a/OPS
+++ b/OPS
@@ -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_RENAME_FILE "rename/move an attached file"
 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_UPDATE_ENCODING "update an attachment's encoding info"
 OP_COMPOSE_WRITE_MESSAGE "write the message to a folder"
index dcbc8e8a8b41a611ca367d91f604b7f53c53c624..73fe63383d45ea366dcc00ca2e82cbacfd375a37 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -845,6 +845,12 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
        }
         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:
        CHECK_COUNT;
         {
index e5f6ad0cca02379e0c109212c54434fd47f8ae17..df62df785c98d2656fbffb47e765b12a0fc519f9 100644 (file)
@@ -270,7 +270,7 @@ struct binding_t OpCompose[] = {
   { "edit-cc",         OP_COMPOSE_EDIT_CC,             "c" },
   { "copy-file",       OP_SAVE,                        "C" },
   { "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-message",    OP_COMPOSE_EDIT_MESSAGE,        "e" },
   { "edit-headers",    OP_COMPOSE_EDIT_HEADERS,        "E" },
@@ -280,6 +280,7 @@ struct binding_t OpCompose[] = {
   { "edit-fcc",                OP_COMPOSE_EDIT_FCC,            "f" },
   { "filter-entry",    OP_FILTER,                      "F" },
   { "get-attachment",  OP_COMPOSE_GET_ATTACHMENT,      "G" },
+  { "display-toggle-weed",     OP_DISPLAY_HEADERS,             "h" },
   { "ispell",          OP_COMPOSE_ISPELL,              "i" },
   { "print-entry",     OP_PRINT,                       "l" },
   { "edit-mime",       OP_COMPOSE_EDIT_MIME,           "m" },
diff --git a/init.h b/init.h
index 438dd8c5a4f2bf42307300d24ec2d0435f3b6db7..9e866fbcbf8990121237be355fdf78bace7ba79e 100644 (file)
--- a/init.h
+++ b/init.h
@@ -177,7 +177,7 @@ struct option_t MuttVars[] = {
   ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
   ** 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
   ** This variable describes the format of the `attachment' menu.  The
@@ -188,6 +188,7 @@ struct option_t MuttVars[] = {
   ** %d      description
   ** %e      MIME content-transfer-encoding
   ** %f      filename
+  ** %I      disposition (I=inline, A=attachment)
   ** %m      major MIME type
   ** %M      MIME subtype
   ** %n      attachment number
diff --git a/mutt.h b/mutt.h
index 5b0d685458764fcd8be37574b16afdc731b52583..abf1ccf465c0d25aa42da9244c8da0fdae1c46da 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -519,7 +519,7 @@ typedef struct body
   unsigned int type : 4;        /* content-type primary type */
   unsigned int encoding : 3;    /* content-transfer-encoding */
   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
                                 * "filename" should be unlink()ed before
                                 * free()ing this structure
diff --git a/parse.c b/parse.c
index 0f6a82c827a3b9286ce56c30034b51fe229a9cdf..cdaa577d93bb421092e310cd004ee53c682ffa40 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -370,11 +370,12 @@ BODY *mutt_read_mime_header (FILE *fp, int digest)
   char *line = safe_malloc (LONG_STRING);
   size_t linelen = LONG_STRING;
   
-  p->hdr_offset = ftell(fp);
-
-  p->encoding = ENC7BIT; /* default from RFC1521 */
-  p->type = digest ? TYPEMESSAGE : TYPETEXT;
+  p->hdr_offset  = ftell(fp);
 
+  p->encoding    = ENC7BIT; /* default from RFC1521 */
+  p->type        = digest ? TYPEMESSAGE : TYPETEXT;
+  p->disposition = DISPINLINE;
+  
   while (*(line = read_rfc822_line (fp, line, &linelen)) != 0)
   {
     /* Find the value of the current header */
@@ -887,10 +888,13 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
       hdr->content = mutt_new_body ();
 
       /* set the defaults from RFC1521 */
-      hdr->content->type = TYPETEXT;
-      hdr->content->subtype = safe_strdup ("plain");
-      hdr->content->encoding = ENC7BIT;
-      hdr->content->length = -1;
+      hdr->content->type        = TYPETEXT;
+      hdr->content->subtype     = safe_strdup ("plain");
+      hdr->content->encoding    = ENC7BIT;
+      hdr->content->length      = -1;
+
+      /* RFC 2183 says this is arbitrary */
+      hdr->content->disposition = DISPINLINE;
     }
   }
 
diff --git a/pgp.c b/pgp.c
index 2f7c0acde7eb6d176480518f70cb44f2cfdbaa22..5902d6771c2cedf2f4e132377a980ffb1e98e6ac 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -1122,8 +1122,9 @@ static BODY *pgp_sign_message (BODY *a)
   t = mutt_new_body ();
   t->type = TYPEMULTIPART;
   t->subtype = safe_strdup ("signed");
-  t->use_disp = 0;
   t->encoding = ENC7BIT;
+  t->use_disp = 0;
+  t->disposition = DISPINLINE;
 
   mutt_generate_boundary (&t->parameter);
   mutt_set_parameter ("protocol", "application/pgp-signature", &t->parameter);
@@ -1138,6 +1139,7 @@ static BODY *pgp_sign_message (BODY *a)
   t->subtype = safe_strdup ("pgp-signature");
   t->filename = safe_strdup (sigfile);
   t->use_disp = 0;
+  t->disposition = DISPINLINE;
   t->encoding = ENC7BIT;
   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)
   t->subtype = safe_strdup ("encrypted");
   t->encoding = ENC7BIT;
   t->use_disp = 0;
+  t->disposition = DISPINLINE;
 
   mutt_generate_boundary(&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)
   t->parts->type = TYPEAPPLICATION;
   t->parts->subtype = safe_strdup ("pgp-encrypted");
   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->type = TYPEAPPLICATION;
@@ -1361,6 +1366,7 @@ static BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   t->parts->next->encoding = ENC7BIT;
   t->parts->next->filename = safe_strdup (tempfile);
   t->parts->next->use_disp = 0;
+  t->parts->next->disposition = DISPINLINE;
   t->parts->next->unlink = 1; /* delete after sending the message */
 
   return (t);
index 17dbe1d3499cd7245f55560ff5303739b0f88b2e..01f829705a1fd24754b5d0e163be868544575b5a 100644 (file)
@@ -161,6 +161,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY *m,
  * %d = description
  * %e = MIME content-transfer-encoding
  * %f = filename
+ * %I = content-disposition, either I (inline) or A (attachment)
  * %t = tagged flag
  * %m = major MIME type
  * %M = MIME subtype
@@ -275,6 +276,13 @@ const char *mutt_attach_fmt (char *dest,
        snprintf (dest, destlen, fmt, ENCODING (aptr->content->encoding));
       }
       break;
+    case 'I':
+      if (!optional)
+      {
+         snprintf (dest, destlen, "%c",
+                 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
+      }
+      break;
     case 'm':
       if(!optional)
       {
diff --git a/send.c b/send.c
index 6eb5b1331fc8a78dd18e96d3f021dfcd9d8fc163..4196fec8cdedf5b2efe0a43a05dc29725f35bb9f 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1038,6 +1038,7 @@ ci_send_message (int flags,               /* send mode */
     msg->content->subtype = safe_strdup ("plain");
     msg->content->unlink = 1;
     msg->content->use_disp = 0;
+    msg->content->disposition = DISPINLINE;
     
     if (!tempfile)
     {
index 4ce2d873d83d7f1b93807c4252d6aa85e3b33eeb..e61b93969783727ab3560a4409273e191e2af91f 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -407,10 +407,10 @@ int mutt_write_mime_header (BODY *a, FILE *f)
   if (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))
       fn = a->filename;
     
@@ -427,10 +427,10 @@ int mutt_write_mime_header (BODY *a, FILE *f)
       rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials);
       fprintf (f, "; filename%s=%s", encode ? "*" : "", buffer);
     }
-
-    fputc ('\n', f);
   }
 
+  fputc ('\n', f);
+
   if (a->encoding != ENC7BIT)
     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)
   body->filename = safe_strdup (buffer);
   body->unlink = 1;
   body->use_disp = 0;
+  body->disposition = DISPINLINE;
 
   mutt_parse_mime_message (ctx, hdr);
 
@@ -1143,6 +1144,7 @@ BODY *mutt_make_multipart (BODY *b)
   new->encoding = get_toplevel_encoding (b);
   mutt_generate_boundary (&new->parameter);
   new->use_disp = 0;  
+  new->disposition = DISPINLINE;
   new->parts = b;
 
   return new;