]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.c
Print "part" markers for each MIME part (with Content-type).
[notmuch] / notmuch.c
index 201910841e717292f3973967c560fafe4c49f09b..0d08a54687ca97466aec96a01bcea1bf50842b27 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -904,6 +904,7 @@ show_message_part (GMimeObject *part)
     GMimeStream *stream;
     GMimeDataWrapper *wrapper;
     GMimeContentDisposition *disposition;
+    GMimeContentType *content_type;
 
     if (GMIME_IS_MULTIPART (part)) {
        GMimeMultipart *multipart = GMIME_MULTIPART (part);
@@ -943,13 +944,22 @@ show_message_part (GMimeObject *part)
        strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
     {
        const char *filename = g_mime_part_get_filename (GMIME_PART (part));
+       content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
+
+       printf ("%%attachment{ Content-type: %s\n",
+               g_mime_content_type_to_string (content_type));
+       printf ("%s\n", filename);
+       printf ("%%attachment}\n");
 
-       /* XXX: Need to print content type here as well. */
-       printf ("%%attachment{ %s %%attachment}\n", filename);
        return;
     }
 
     /* Stream the MIME part out to stdout. */
+    content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
+
+    printf ("%%part{ Content-type: %s\n",
+           g_mime_content_type_to_string (content_type));
+
     stream = g_mime_stream_file_new (stdout);
     g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE);
 
@@ -957,6 +967,8 @@ show_message_part (GMimeObject *part)
     if (wrapper)
        g_mime_data_wrapper_write_to_stream (wrapper, stream);
 
+    printf ("%%part}\n");
+
     g_object_unref (stream);
 }