]> granicus.if.org Git - mutt/commitdiff
A message/external-body handler. From Byrial Jensen.
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 9 Nov 1998 10:58:45 +0000 (10:58 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 9 Nov 1998 10:58:45 +0000 (10:58 +0000)
handler.c
parse.c

index e5fd88365b740c239ee2e370f891643edd2ac9b0..7a0e2e21ce1c014485cbf0e53baac254c05444b0 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1237,6 +1237,60 @@ void autoview_handler (BODY *a, STATE *s)
   rfc1524_free_entry (&entry);
 }
 
+static void external_body_handler (BODY *b, STATE *s)
+{
+  const char *access_type;
+  const char *expiration;
+  time_t expire;
+
+  access_type = mutt_get_parameter ("access-type", b->parameter);
+  if (!access_type)
+  {
+    if (s->flags & M_DISPLAY)
+      state_puts (_("[-- Error: message/external-body has no access-type parameter --]\n"), s);
+    return;
+  }
+
+  expiration = mutt_get_parameter ("expiration", b->parameter);
+  if (expiration) 
+  {
+    /* mutt_parse_date() will alter its argument, so we need a copy */
+    char *e = safe_strdup (expiration);
+
+    expire = mutt_parse_date (e, NULL);
+    free (e);
+  }
+  else
+    expire = -1;
+
+  if (!strcasecmp (access_type, "x-mutt-deleted"))
+  {
+    if (s->flags & M_DISPLAY)
+    {
+      fprintf (s->fpout, _("[-- This %s/%s attachment is deleted --]\n"),
+              TYPE(b->parts), b->parts->subtype);
+      if (expire != -1)
+       fprintf (s->fpout, _("[-- on %s --]\n"), expiration);
+      mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
+                    (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
+                    CH_DECODE , NULL);
+    }
+  }
+  else
+  {
+    if (s->flags & M_DISPLAY)
+    {
+      fprintf (s->fpout,
+              _("[-- This %s/%s attachment is not included --]\n"
+                "[-- and the indicated access-type %s is unsupported --]\n"),
+              TYPE(b->parts), b->parts->subtype, access_type);
+      mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
+                    (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
+                    CH_DECODE , NULL);
+    }
+  }
+}
+
 void mutt_decode_attachment (BODY *b, STATE *s)
 {
   fseek (s->fpin, b->offset, 0);
@@ -1299,6 +1353,8 @@ void mutt_body_handler (BODY *b, STATE *s)
       handler = message_handler;
     else if (!strcasecmp ("delivery-status", b->subtype))
       plaintext = 1;
+    else if (!strcasecmp ("external-body", b->subtype))
+      handler = external_body_handler;
   }
   else if (b->type == TYPEMULTIPART)
   {
diff --git a/parse.c b/parse.c
index a76d65bd7a848300217bbefc631aac7bfee628d4..d6da5c66d89f8d41fe27605e1cd3eebe62886633 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -543,12 +543,14 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di
        break;
 
       case TYPEMESSAGE:
-       if (last->subtype &&
-           (strcasecmp (last->subtype, "rfc822") == 0 ||
-            strcasecmp (last->subtype, "news") == 0))
+       if (last->subtype)
        {
-         fseek (fp, last->offset, 0);
-         last->parts = mutt_parse_messageRFC822 (fp, last);
+         fseek (fp, last->offset, SEEK_SET);
+         if (strcasecmp (last->subtype, "rfc822") == 0 ||
+             strcasecmp (last->subtype, "news") == 0)
+           last->parts = mutt_parse_messageRFC822 (fp, last);
+         else if (strcasecmp (last->subtype, "external-body") == 0)
+           last->parts = mutt_read_mime_header (fp, 0);
        }
        break;
     }