[evolution/webkit: 59/196] Add EM_FORMAT_HANDLER_COMPOUND_TYPE flag to EMFormatHandler



commit be660262c1594bc1eb3e6d48e99d0f4011882d14
Author: Dan VrÃtil <dvratil redhat com>
Date:   Fri Nov 25 16:08:29 2011 +0100

    Add EM_FORMAT_HANDLER_COMPOUND_TYPE flag to EMFormatHandler
    
    This flag says, that the particular mime type is compound
    (application/mbox, message/rfc822) and that we should attempt
    to parse it even though it's an attachment

 em-format/em-format.c         |    8 ++++----
 em-format/em-format.h         |    3 ++-
 mail/em-format-html-display.c |    5 +++++
 mail/em-format-html.c         |    4 ++--
 4 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 4ed5ed4..a354ed8 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -1243,15 +1243,15 @@ static EMFormatHandler type_handlers[] = {
 #ifdef ENABLE_SMIME
 		{ (gchar *) "application/x-pkcs7-mime", emf_parse_application_xpkcs7mime, 0, EM_FORMAT_HANDLER_INLINE_DISPOSITION },
 #endif
-		{ (gchar *) "application/mbox", emf_parse_application_mbox, 0, EM_FORMAT_HANDLER_INLINE },
+		{ (gchar *) "application/mbox", emf_parse_application_mbox, 0, EM_FORMAT_HANDLER_INLINE | EM_FORMAT_HANDLER_COMPOUND_TYPE },
 		{ (gchar *) "multipart/alternative", emf_parse_multipart_alternative, },
 		{ (gchar *) "multipart/appledouble", emf_parse_multipart_appledouble, },
 		{ (gchar *) "multipart/encrypted", emf_parse_multipart_encrypted, },
 		{ (gchar *) "multipart/mixed", emf_parse_multipart_mixed, },
 		{ (gchar *) "multipart/signed", emf_parse_multipart_signed, },
 		{ (gchar *) "multipart/related", emf_parse_multipart_related, },
-		{ (gchar *) "multipart/digest", emf_parse_multipart_digest, },
-		{ (gchar *) "multipart/*", emf_parse_multipart_mixed, },
+		{ (gchar *) "multipart/digest", emf_parse_multipart_digest, EM_FORMAT_HANDLER_COMPOUND_TYPE },
+		{ (gchar *) "multipart/*", emf_parse_multipart_mixed, 0, EM_FORMAT_HANDLER_COMPOUND_TYPE },
 
 		/* Ignore PGP signature part */
 		{ (gchar *) "application/pgp-signature", em_format_empty_parser, },
@@ -1264,7 +1264,7 @@ static EMFormatHandler type_handlers[] = {
 		/* internal types */
 		{ (gchar *) "application/x-inlinepgp-signed", emf_parse_inlinepgp_signed, },
 		{ (gchar *) "application/x-inlinepgp-encrypted", emf_parse_inlinepgp_encrypted, },
-		{ (gchar *) "x-evolution/message", emf_parse_message, },
+		{ (gchar *) "x-evolution/message", emf_parse_message, 0, EM_FORMAT_HANDLER_COMPOUND_TYPE },
 		{ (gchar *) "x-evolution/message/headers", emf_parse_headers, },
 		{ (gchar *) "x-evolution/message/post-headers", emf_parse_post_headers, },
 		{ (gchar *) "x-evolution/message/source", emf_parse_source, emf_write_source },
diff --git a/em-format/em-format.h b/em-format/em-format.h
index dacf7b0..7e5fbed 100644
--- a/em-format/em-format.h
+++ b/em-format/em-format.h
@@ -83,7 +83,8 @@ typedef GtkWidget*	(*EMFormatWidgetFunc)	(EMFormat *emf,
 
 typedef enum {
 	EM_FORMAT_HANDLER_INLINE = 1 << 0,
-	EM_FORMAT_HANDLER_INLINE_DISPOSITION = 1 << 1
+	EM_FORMAT_HANDLER_INLINE_DISPOSITION = 1 << 1,
+	EM_FORMAT_HANDLER_COMPOUND_TYPE = 1 << 2
 } EMFormatHandlerFlags;
 
 typedef enum {
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 48a81d7..ab4e853 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -495,6 +495,11 @@ efhd_parse_attachment (EMFormat *emf,
 
 	em_format_add_puri (emf, (EMFormatPURI *) puri);
 
+        /* Though it is an attachment, we still might be able to parse it and
+         * so discover some parts that we might be event able to display. */
+        if (handler && handler->parse_func && (handler->flags & EM_FORMAT_HANDLER_COMPOUND_TYPE))
+                handler->parse_func (emf, puri->puri.part, part_id, info, cancellable);
+
 	e_attachment_set_mime_part (puri->attachment, part);
 	e_attachment_set_shown (puri->attachment, puri->shown);
 	e_attachment_set_signed (puri->attachment, puri->sign);
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 1ed939d..c23f846 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -971,8 +971,8 @@ static EMFormatHandler type_builtin_table[] = {
 	{ (gchar *) "text/html", efh_parse_text_html, efh_write_text_html, },
 	{ (gchar *) "text/richtext", efh_parse_text_enriched, efh_write_text_enriched, },
 	{ (gchar *) "text/*", efh_parse_text_plain, efh_write_text_plain, },
-        { (gchar *) "message/rfc822", efh_parse_message_rfc822, 0, EM_FORMAT_HANDLER_INLINE },
-        { (gchar *) "message/news", efh_parse_message_rfc822, 0, EM_FORMAT_HANDLER_INLINE },
+        { (gchar *) "message/rfc822", efh_parse_message_rfc822, 0, EM_FORMAT_HANDLER_INLINE | EM_FORMAT_HANDLER_COMPOUND_TYPE }, 
+        { (gchar *) "message/news", efh_parse_message_rfc822, 0, EM_FORMAT_HANDLER_INLINE | EM_FORMAT_HANDLER_COMPOUND_TYPE },
         { (gchar *) "message/delivery-status", efh_parse_message_deliverystatus, efh_write_text_plain, },
 	{ (gchar *) "message/external-body", efh_parse_message_external, efh_write_text_plain, },
         { (gchar *) "message/*", efh_parse_message_rfc822, 0, EM_FORMAT_HANDLER_INLINE },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]