[evolution/webkit: 78/100] EMFormat and EMFormatHTML cleanup



commit 22e2cac7aa20fa5a84ec485ad0111429b9429dbc
Author: Dan VrÃtil <dvratil redhat com>
Date:   Wed Dec 14 20:23:49 2011 +0100

    EMFormat and EMFormatHTML cleanup
    
     - resolved some FIXMEs
     - fixed compilation warnings
     - removed unused parts, renamed some functions from pre-webkit era

 em-format/em-format-quote.c   |   71 ++--------
 em-format/em-format.c         |  233 ++++++++++++++------------------
 em-format/em-format.h         |   24 +---
 mail/em-format-html-display.c |  105 +++++---------
 mail/em-format-html.c         |  301 +++++++++++++++++------------------------
 widgets/misc/e-web-view.c     |    2 +-
 6 files changed, 273 insertions(+), 463 deletions(-)
---
diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c
index 38d9a06..22ddc21 100644
--- a/em-format/em-format-quote.c
+++ b/em-format/em-format-quote.c
@@ -376,60 +376,6 @@ emfq_finalize (GObject *object)
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
-static void
-emfq_parse (EMFormat *emf,
-	    CamelMimeMessage *msg,
-	    CamelFolder *folder,
-	    GCancellable *cancellable)
-{
-        EM_FORMAT_CLASS (parent_class)->parse (emf, msg, folder, cancellable);
-
-        /* emfq_parse parses only body part, not the whole message. */
-        /*
-        CamelMimePart *part;
-        const EMFormatHandler *handler;
-        CamelContentType *ct;
-        gchar *mime_type;
-        EMFormatParserInfo info = { 0 };
-        GString *part_id;
-
-        part = CAMEL_MIME_PART (msg);
-
-        ct = camel_mime_part_get_content_type (part);
-        if (!ct) {
-                mime_type = g_strdup (em_format_snoop_type (part));
-                if (!mime_type)
-                        return;
-        } else {
-                mime_type = camel_content_type_simple (ct);
-        }
-
-        part_id = g_string_new (".part");
-        handler = em_format_find_handler (emf, mime_type);
-        if (handler && handler->parse_func) {
-                info.handler = handler;
-                handler->parse_func (emf, part, part_id, &info, cancellable);
-
-        } else {
-                handler = em_format_find_handler (emf, "x-evolution/message/attachment");
-                info.handler = handler;
-
-                if (handler && handler->parse_func)
-                        handler->parse_func (emf, part, part_id, &info, cancellable);
-        }
-
-        g_string_free (part_id, TRUE);
-        g_free (mime_type);
-        */
-}
-
-static void
-emfq_format_error (EMFormat *emf,
-                   const gchar *errmsg)
-{
-	/* Nothing to do. */
-}
-
 /******************************************************************************/
 static void
 emfq_parse_text_plain (EMFormat* emf,
@@ -439,11 +385,22 @@ emfq_parse_text_plain (EMFormat* emf,
                        GCancellable* cancellable)
 {
         EMFormatPURI *puri;
+		CamelMimePart *mp;
         gint len;
 
         len = part_id->len;
         g_string_append (part_id, ".text_plain");
 
+		mp = decode_inline_parts (part, cancellable);
+		if (mp) {
+
+			if (CAMEL_IS_MULTIPART (camel_medium_get_content (CAMEL_MEDIUM (mp)))) {
+				em_format_parse_part (emf, mp, part_id, info, cancellable);
+			}
+
+			g_object_unref (mp);
+		}
+
         puri = em_format_puri_new (emf, sizeof (EMFormatPURI), part, part_id->str);
         puri->write_func = emfq_write_text_plain;
         puri->mime_type = g_strdup ("text/html");
@@ -578,7 +535,6 @@ static void
 emfq_class_init (EMFormatQuoteClass *klass)
 {
 	GObjectClass *object_class;
-	EMFormatClass *format_class;
 
 	parent_class = g_type_class_peek_parent (klass);
 	g_type_class_add_private (klass, sizeof (EMFormatQuotePrivate));
@@ -586,11 +542,6 @@ emfq_class_init (EMFormatQuoteClass *klass)
 	object_class = G_OBJECT_CLASS (klass);
 	object_class->dispose = emfq_dispose;
 	object_class->finalize = emfq_finalize;
-
-	format_class = EM_FORMAT_CLASS (klass);
-	format_class->parse = emfq_parse;
-
-        format_class->format_error = emfq_format_error;
 }
 
 static void
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 4172025..0b550c4 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -34,7 +34,7 @@
 #include "shell/e-shell.h"
 #include "shell/e-shell-settings.h"
 
-#define d(x) x
+#define d(x)
 
 struct _EMFormatPrivate {
 	GNode *current_node;
@@ -79,11 +79,9 @@ static void emf_parse_post_headers		(EMFormat *emf, CamelMimePart *part, GString
 static void emf_parse_source			(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
 
 /* WRITERS */
-static void emf_write_text			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable) {};
-static void emf_write_source			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable) {};
-
-static void emf_error				(EMFormat *emf, const gchar *message) {};
-static void emf_source				(EMFormat *emf, CamelStream *stream, GCancellable *cancellable);
+static void emf_write_text			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
+static void emf_write_source			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
+static void emf_write_error			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
 
 /**************************************************************************/
 
@@ -364,7 +362,7 @@ emf_parse_multipart_alternative (EMFormat *emf,
 		CamelStream *null_stream;
 		gchar *mime_type;
 		gsize content_size;
-		/* GByteArray *ba; */
+		 GByteArray *ba;
 
 		if (g_cancellable_is_cancelled (cancellable))
 			return;
@@ -388,14 +386,10 @@ emf_parse_multipart_alternative (EMFormat *emf,
 		if (content_size == 0)
 			continue;
 
-		/* FIXME WEBKIT: This SHOULD do the same as the previous block of
-		 * code, thought it seems to somehow corrupt/disable/remove the
-		 * other mime part, so that has no content
 		data_wrapper = camel_medium_get_content ((CamelMedium *) mpart);
 		ba = camel_data_wrapper_get_byte_array (data_wrapper);
 		if (ba->len == 0)
 			continue;
-		*/
 
 		type = camel_mime_part_get_content_type (mpart);
 		mime_type = camel_content_type_simple (type);
@@ -475,18 +469,6 @@ emf_parse_multipart_encrypted (EMFormat *emf,
 	if (g_cancellable_is_cancelled (cancellable))
 		return;
 
-	/* should this perhaps run off a key of ".secured" ? */
-	/* FIXME WEBKIT what do we do about this?
-	emfc = g_hash_table_lookup (emf->inline_table, emf->part_id->str);
-	if (emfc && emfc->valid) {
-		em_format_format_secure (
-			emf, stream, emfc->secured,
-			camel_cipher_validity_clone (emfc->valid),
-			cancellable);
-		return;
-	}
-	*/
-
 	mpe = (CamelMultipartEncrypted*) camel_medium_get_content ((CamelMedium *) part);
 	if (!CAMEL_IS_MULTIPART_ENCRYPTED (mpe)) {
 		em_format_format_error (
@@ -603,18 +585,6 @@ emf_parse_multipart_signed (EMFormat *emf,
 	if (g_cancellable_is_cancelled (cancellable))
 		return;
 
-	/* should this perhaps run off a key of ".secured" ? */
-	/* FIXME WEBKIT: What do we do with this?
-	emfc = g_hash_table_lookup (emf->inline_table, emf->part_id->str);
-	if (emfc && emfc->valid) {
-		em_format_format_secure (
-			emf, stream, emfc->secured,
-			camel_cipher_validity_clone (emfc->valid),
-			cancellable);
-		return;
-	}
-	*/
-
 	mps = (CamelMultipartSigned *) camel_medium_get_content ((CamelMedium *) part);
 	if (!CAMEL_IS_MULTIPART_SIGNED (mps)
 	    || (cpart = camel_multipart_get_part ((CamelMultipart *) mps,
@@ -830,7 +800,7 @@ emf_parse_message_deliverystatus (EMFormat *emf,
 	puri->write_func = emf_write_text;
 	puri->mime_type = g_strdup ("text/html");
 	puri->validity = info->validity ? camel_cipher_validity_clone (info->validity) : NULL;
-	puri->validity_type = info->validity_type;	
+	puri->validity_type = info->validity_type;
 
 	g_string_truncate (part_id, len);
 
@@ -1132,73 +1102,58 @@ em_format_empty_writer (EMFormat *emf,
 	/* DO NOTHING */
 }
 
-/**************************************************************************/
-
 static void
-emf_source (EMFormat *emf,
-	    CamelStream *stream,
-	    GCancellable *cancellable)
+emf_write_error (EMFormat* emf,
+		 EMFormatPURI* puri,
+		 CamelStream* stream,
+		 EMFormatWriterInfo* info,
+		 GCancellable* cancellable)
 {
-	GByteArray *ba;
-	gchar *data;
-
-	g_return_if_fail (EM_IS_FORMAT (emf));
-
-	ba = camel_data_wrapper_get_byte_array ((CamelDataWrapper *) emf->message);
-
-	data = g_strndup ((gchar *) ba->data, ba->len);
-	camel_stream_write_string (stream, data, cancellable, NULL);
-	g_free (data);
+	camel_data_wrapper_decode_to_stream_sync ((CamelDataWrapper *) puri->part,
+		stream, cancellable, NULL);
 }
 
-/**************************************************************************/
-
 static void
-emf_parse (EMFormat *emf,
-	   CamelMimeMessage *message,
-	   CamelFolder *folder,
-	   GCancellable *cancellable)
+emf_write_text (EMFormat *emf,
+		EMFormatPURI *puri,
+		CamelStream *stream,
+		EMFormatWriterInfo *info,
+		GCancellable *cancellable)
 {
-	GString *part_id;
-	EMFormatPURI *puri;
-	EMFormatParserInfo info = { 0 };
-
-	g_return_if_fail (EM_IS_FORMAT (emf));
+	CamelContentType *ct;
 
-	if (g_cancellable_is_cancelled (cancellable))
+	ct = camel_mime_part_get_content_type (puri->part);
+	if (!camel_content_type_is (ct, "text", "plain")) {
+		camel_stream_write_string (stream, _("Cannot proccess non-text mime/part"),
+			cancellable, NULL);
 		return;
-
-	if (message) {
-		g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
-
-		if (emf->message)
-			g_object_unref (emf->message);
-		emf->message = g_object_ref (message);
 	}
 
-	if (folder) {
-		g_return_if_fail (CAMEL_IS_FOLDER  (folder));
-
-		if (emf->folder)
-			g_object_unref (emf->folder);
-		emf->folder = g_object_ref (folder);
-	}
+	camel_data_wrapper_decode_to_stream_sync ((CamelDataWrapper *) puri->part,
+		stream, cancellable, NULL);
+}
 
-	part_id = g_string_new (".message");
+static void
+emf_write_source (EMFormat *emf,
+		  EMFormatPURI *puri,
+		  CamelStream *stream,
+		  EMFormatWriterInfo *info,
+		  GCancellable *cancellable)
+{
+	GByteArray *ba;
+	gchar *data;
 
-	/* Create a special PURI with entire message */
-	puri = em_format_puri_new (emf, sizeof (EMFormatPURI),
-		(CamelMimePart *) message, part_id->str);
-	puri->mime_type = g_strdup ("text/html");
-	em_format_add_puri (emf, puri);
+	g_return_if_fail (EM_IS_FORMAT (emf));
 
-        info.force_handler = TRUE;
-	em_format_parse_part_as (emf, CAMEL_MIME_PART (message), part_id, &info,
-			"x-evolution/message", cancellable);
+	ba = camel_data_wrapper_get_byte_array ((CamelDataWrapper *) puri->part);
 
-	g_string_free (part_id, TRUE);
+	data = g_strndup ((gchar *) ba->data, ba->len);
+	camel_stream_write_string (stream, data, cancellable, NULL);
+	g_free (data);
 }
 
+/**************************************************************************/
+
 static gboolean
 emf_is_inline (EMFormat *emf,
                const gchar *part_id,
@@ -1211,12 +1166,6 @@ emf_is_inline (EMFormat *emf,
 	if (handle == NULL)
 		return FALSE;
 
-	/* WEBKIT FIXME
-	emfc = g_hash_table_lookup (emf->inline_table, part_id);
-	if (emfc && emfc->state != INLINE_UNSET)
-		return emfc->state & 1;
-	*/
-
 	/* Some types need to override the disposition.
 	 * e.g. application/x-pkcs7-mime */
 	if (handle->flags & EM_FORMAT_HANDLER_INLINE_DISPOSITION)
@@ -1245,6 +1194,7 @@ static EMFormatHandler type_handlers[] = {
 		{ (gchar *) "multipart/related", emf_parse_multipart_related, },
 		{ (gchar *) "multipart/digest", emf_parse_multipart_digest, 0, EM_FORMAT_HANDLER_COMPOUND_TYPE },
 		{ (gchar *) "multipart/*", emf_parse_multipart_mixed, 0, EM_FORMAT_HANDLER_COMPOUND_TYPE },
+		{ (gchar *) "message/deliverystatus", emf_parse_message_deliverystatus, 0, },
 
 		/* Ignore PGP signature part */
 		{ (gchar *) "application/pgp-signature", em_format_empty_parser, },
@@ -1417,9 +1367,6 @@ em_format_class_init (EMFormatClass *class)
 
 	g_type_class_add_private (class, sizeof (EMFormatPrivate));
 
-	class->format_error = emf_error;
-	class->format_source = emf_source;
-	class->parse = emf_parse;
 	class->is_inline = emf_is_inline;
 
 	object_class = G_OBJECT_CLASS (class);
@@ -1887,15 +1834,44 @@ em_format_parse (EMFormat *emf,
 		 CamelFolder *folder,
 		 GCancellable *cancellable)
 {
-	EMFormatClass *class;
+	GString *part_id;
+	EMFormatPURI *puri;
+	EMFormatParserInfo info = { 0 };
 
 	g_return_if_fail (EM_IS_FORMAT (emf));
-	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 
-	class = EM_FORMAT_GET_CLASS (emf);
-	g_return_if_fail (class->parse != NULL);
+	if (g_cancellable_is_cancelled (cancellable))
+		return;
+
+	if (message) {
+		g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
+
+		if (emf->message)
+			g_object_unref (emf->message);
+		emf->message = g_object_ref (message);
+	}
+
+	if (folder) {
+		g_return_if_fail (CAMEL_IS_FOLDER  (folder));
+
+		if (emf->folder)
+			g_object_unref (emf->folder);
+		emf->folder = g_object_ref (folder);
+	}
+
+	part_id = g_string_new (".message");
+
+	/* Create a special PURI with entire message */
+	puri = em_format_puri_new (emf, sizeof (EMFormatPURI),
+		(CamelMimePart *) message, part_id->str);
+	puri->mime_type = g_strdup ("text/html");
+	em_format_add_puri (emf, puri);
 
-	class->parse (emf, message, folder, cancellable);
+        info.force_handler = TRUE;
+	em_format_parse_part_as (emf, CAMEL_MIME_PART (message), part_id, &info,
+			"x-evolution/message", cancellable);
+
+	g_string_free (part_id, TRUE);
 }
 
 void
@@ -1989,51 +1965,44 @@ em_format_is_inline (EMFormat *emf,
 
 }
 
-gchar*
-em_format_get_error_id (EMFormat *emf)
-{
-	g_return_val_if_fail (EM_IS_FORMAT (emf), NULL);
-
-	emf->priv->last_error++;
-	return g_strdup_printf (".error.%d", emf->priv->last_error);
-}
-
 void
 em_format_format_error (EMFormat *emf,
                         const gchar *format,
                         ...)
 {
-	EMFormatClass *class;
+	EMFormatPURI *puri;
+	CamelMimePart *part;
+	const EMFormatHandler *handler;
 	gchar *errmsg;
+	gchar *uri;
 	va_list ap;
 
 	g_return_if_fail (EM_IS_FORMAT (emf));
 	g_return_if_fail (format != NULL);
 
-	class = EM_FORMAT_GET_CLASS (emf);
-	g_return_if_fail (class->format_error != NULL);
-
 	va_start (ap, format);
 	errmsg = g_strdup_vprintf (format, ap);
-	class->format_error (emf, errmsg);
+
+	part = camel_mime_part_new ();
+	camel_mime_part_set_content (part, errmsg, strlen (errmsg), "text/plain");
 	g_free (errmsg);
 	va_end (ap);
-}
 
-void
-em_format_format_source (EMFormat *emf,
-			 CamelStream *stream,
-			 GCancellable *cancellable)
-{
-	EMFormatClass *class;
+	handler = em_format_find_handler (emf, "x-evolution/error");
 
-	g_return_if_fail (EM_IS_FORMAT (emf));
-	g_return_if_fail (CAMEL_IS_STREAM (stream));
+	emf->priv->last_error++;
+	uri = g_strdup_printf (".error.%d", emf->priv->last_error);
+	puri = em_format_puri_new (emf, sizeof (EMFormatPURI), part, uri);
+	puri->mime_type = g_strdup ("text/html");
+	if (handler && handler->write_func)
+		puri->write_func = handler->write_func;
+	else
+		puri->write_func = emf_write_error;
 
-	class = EM_FORMAT_GET_CLASS (emf);
-	g_return_if_fail (class->format_source != NULL);
+	em_format_add_puri (emf, puri);
 
-	class->format_source (emf, stream, cancellable);
+	g_free (uri);
+	g_object_unref (part);
 }
 
 /**
@@ -2127,11 +2096,7 @@ em_format_format_text (EMFormat *emf,
 			mem_stream, (CamelStream *) stream, cancellable, NULL);
 		camel_stream_flush ((CamelStream *) mem_stream, cancellable, NULL);
 	} else {
-		/* FIXME WEBKIT
-		EM_FORMAT_GET_CLASS (emf)->format_optional (
-			emf, stream, (CamelMimePart *) dw,
-			mem_stream, cancellable);
-		*/
+		/* FIXME WEBKIT */
 	}
 
 	if (windows)
@@ -2327,10 +2292,10 @@ em_format_snoop_type (CamelMimePart *part)
 
 /**
  * Construct a URI for message.
- * 
+ *
  * The URI can contain multiple query parameters. The list of parameters must be
  * NULL-terminated. Each query must contain name, GType of value and value.
- * 
+ *
  * @param folder Folder wit the message
  * @param message_uid ID of message within the \p folder
  * @param first_param_name Name of first query parameter followed by GType of it's value and value.
diff --git a/em-format/em-format.h b/em-format/em-format.h
index 7e5fbed..0007579 100644
--- a/em-format/em-format.h
+++ b/em-format/em-format.h
@@ -123,7 +123,7 @@ struct _EMFormatWriterInfo {
 	EMFormatWriteMode mode;
 	gboolean headers_collapsable;
 	gboolean headers_collapsed;
-	
+
 	/* When TRUE, EMFormatWriteFunc's will put the content of the PURI part
 	   between EFH_HTML_HEADER and EFH_HTML_FOOTER */
 	gboolean with_html_header;
@@ -182,29 +182,10 @@ struct _EMFormatClass {
 
 	GHashTable *type_handlers;
 
-	void 		(*format_error) 		(EMFormat *emf,
-							 const gchar *message);
-	void		(*parse)			(EMFormat *emf,
-							 CamelMimeMessage *message,
-							 CamelFolder *folder,
-							 GCancellable *cancellable);
 	gboolean 	(*is_inline)			(EMFormat *emf,
 							 const gchar *part_id,
 							 CamelMimePart *part,
 							 const EMFormatHandler *handler);
-	void		(*format_attachment)		(EMFormat *emf,
-							 EMFormatPURI *puri,
-							 GCancellable *cancellable);
-	void		(*format_optional)		(EMFormat *emf,
-							 EMFormatPURI *puri,
-							 CamelStream *mstream,
-							 GCancellable *cancellable);
-	void		(*format_secure)		(EMFormat *emf,
-						 	 EMFormatPURI *puri,
-							 GCancellable *cancellable);
-	void		(*format_source)		(EMFormat *emf,
-				 			 CamelStream *stream,
-							 GCancellable *cancellable);
 };
 
 EMFormat*		em_format_new 			(void);
@@ -287,9 +268,6 @@ void			em_format_format_text		(EMFormat *emf,
 							 CamelStream *stream,
 							 CamelDataWrapper *dw,
 							 GCancellable *cancellable);
-void			em_format_format_source		(EMFormat *emf,
-							 CamelStream *stream,
-							 GCancellable *cancellable);
 gchar*			em_format_describe_part		(CamelMimePart *part,
 							 const gchar *mime_type);
 gint			em_format_is_attachment 	(EMFormat *emf,
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 55d219a..49d28c4 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -105,6 +105,7 @@ static void efhd_message_prefix 	(EMFormat *emf, CamelMimePart *part, GString *p
 static void efhd_message_add_bar	(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
 static void efhd_parse_attachment	(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
 static void efhd_parse_secure		(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
+static void efhd_parse_optional		(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
 
 static GtkWidget* efhd_attachment_bar		(EMFormat *emf, EMFormatPURI *puri, GCancellable *cancellable);
 static GtkWidget* efhd_attachment_button	(EMFormat *emf, EMFormatPURI *puri, GCancellable *cancellable);
@@ -120,7 +121,6 @@ find_parent_attachment_store (EMFormatHTMLDisplay *efhd, GString *part_id)
 {
 	EMFormat *emf = (EMFormat *) efhd;
 	EMFormatAttachmentBarPURI *abp;
-	EMFormatPURI *puri;
 	gchar *tmp, *pos;
         GList *item;
 
@@ -401,26 +401,6 @@ efhd_xpkcs7mime_button (EMFormat *emf,
 }
 
 static void
-efhd_parse (EMFormat *emf,
-	    CamelMimeMessage *msg,
-	    CamelFolder *folder,
-	    GCancellable *cancellable)
-{
-	EMFormatHTMLDisplay *efhd;
-
-	efhd = EM_FORMAT_HTML_DISPLAY (emf);
-	g_return_if_fail (efhd != NULL);
-
-	/* FIXME WEBKIT Duh?
-	if (emf != src)
-		EM_FORMAT_HTML (emf)->header_wrap_flags = 0;
-	 */
-
-	/* Chain up to parent's format_clone() method. */
-	EM_FORMAT_CLASS (parent_class)->parse (emf, msg, folder, cancellable);
-}
-
-static void
 efhd_parse_attachment (EMFormat *emf,
                        CamelMimePart *part,
                        GString *part_id,
@@ -482,7 +462,7 @@ efhd_parse_attachment (EMFormat *emf,
                 puri->puri.write_func = handler->write_func;
 
                 /* This mime_type is important for WebKit to determine content type.
-                 * We have converted text/* to text/html, other (binary) formats remained
+                 * We have converted text/ * to text/html, other (binary) formats remained
                  * untouched. */
                 ct = camel_content_type_decode (handler->mime_type);
                 if (g_strcmp0 (ct->type, "text") == 0)
@@ -551,49 +531,46 @@ efhd_parse_attachment (EMFormat *emf,
 		e_attachment_set_file_info (puri->attachment, fileinfo);
 	}
 
-	if (info->validity) {
-		puri->sign = info->validity->sign.status;
-		puri->encrypt = info->validity->encrypt.status;
-	}
-
 	g_string_truncate (part_id, len);
 }
 
 static void
-efhd_format_optional (EMFormat *emf,
-                      EMFormatPURI *puri,
-                      CamelStream *mstream,
-                      GCancellable *cancellable)
+efhd_parse_optional (EMFormat *emf,
+                     CamelMimePart *part,
+                     GString *part_id,
+                     EMFormatParserInfo *info,
+                     GCancellable *cancellable)
 {
-	gchar *classid;
-	EMFormatAttachmentPURI *info;
-
-	classid = g_strdup_printf ("optional%s", puri->uri);
-
-	info = (EMFormatAttachmentPURI *) em_format_puri_new (
-			emf, sizeof (EMFormatAttachmentPURI), puri->part, classid);
-	info->puri.free = efhd_free_attach_puri_data;
-	info->attachment_view_part_id = g_strdup (puri->uri);
-	info->handle = em_format_find_handler (emf, "text/plain");
-	info->shown = FALSE;
-	info->snoop_mime_type = "text/plain";
-	info->attachment = e_attachment_new ();
-	e_attachment_set_mime_part (info->attachment, info->puri.part);
-	info->description = g_strdup(_("Evolution cannot render this email as it is too "
+	EMFormatAttachmentPURI *puri;
+        gint len;
+
+        len = part_id->len;
+        g_string_append (part_id, ".optional");
+
+	puri = (EMFormatAttachmentPURI *) em_format_puri_new (
+			emf, sizeof (EMFormatAttachmentPURI), part, part_id->str);
+	puri->puri.free = efhd_free_attach_puri_data;
+	puri->attachment_view_part_id = g_strdup (part_id->str);
+	puri->handle = em_format_find_handler (emf, "text/plain");
+	puri->shown = FALSE;
+	puri->snoop_mime_type = "text/plain";
+	puri->attachment = e_attachment_new ();
+	e_attachment_set_mime_part (puri->attachment, puri->puri.part);
+	puri->description = g_strdup(_("Evolution cannot render this email as it is too "
 				       "large to process. You can view it unformatted or "
 				       "with an external text editor."));
+	
+	puri->mstream = CAMEL_STREAM_MEM (camel_stream_mem_new ());
+	camel_data_wrapper_decode_to_stream_sync ((CamelDataWrapper *) part, 
+		(CamelStream *) puri->mstream, cancellable, NULL);
 
-	/* MStream holds content of the 'attachment' to be displayed */
-	info->mstream = (CamelStreamMem *) g_object_ref (mstream);
-
-	if (puri->validity) {
-		info->sign = puri->validity->sign.status;
-		info->encrypt = puri->validity->encrypt.status;
+	if (info->validity) {
+		puri->puri.validity = camel_cipher_validity_clone (info->validity);
 	}
 
-	em_format_add_puri (emf, (EMFormatPURI *) info);
+	em_format_add_puri (emf, (EMFormatPURI *) puri);
 
-	g_free (classid);
+	g_string_truncate (part_id, len);
 }
 
 static void
@@ -824,7 +801,6 @@ static void
 efhd_class_init (EMFormatHTMLDisplayClass *class)
 {
 	GObjectClass *object_class;
-	EMFormatClass *format_class;
 	EMFormatHTMLClass *format_html_class;
 
 	parent_class = g_type_class_peek_parent (class);
@@ -833,13 +809,6 @@ efhd_class_init (EMFormatHTMLDisplayClass *class)
 	object_class = G_OBJECT_CLASS (class);
 	object_class->finalize = efhd_finalize;
 
-	format_class = EM_FORMAT_CLASS (class);
-	format_class->parse = efhd_parse;
-/* FIXME WEBKIT format attachment?
-	format_class->format_attachment = efhd_format_attachment;
-*/
-	format_class->format_optional = efhd_format_optional;
-
 	format_html_class = EM_FORMAT_HTML_CLASS (class);
 	format_html_class->html_widget_type = E_TYPE_MAIL_DISPLAY;
 
@@ -925,6 +894,7 @@ static EMFormatHandler type_builtin_table[] = {
 	{ (gchar *) "x-evolution/message/attachment-bar", (EMFormatParseFunc) efhd_message_add_bar, },
 	{ (gchar *) "x-evolution/message/attachment", efhd_parse_attachment, },
 	{ (gchar *) "x-evolution/message/x-secure-button", efhd_parse_secure, },
+	{ (gchar *) "x-evolution/message/optional", efhd_parse_optional, },
 };
 
 static void
@@ -1044,12 +1014,6 @@ efhd_attachment_button (EMFormat *emf,
 	gtk_widget_set_can_focus (widget, TRUE);
 	gtk_widget_show (widget);
 
-	/* FIXME Not sure why the expanded callback can't just use
-	 *       info->puri.format, but there seems to be lifecycle
-	 *       issues with the PURI struct.  Maybe it should have
-	 *       a reference count? */
-	g_object_set_data (G_OBJECT (widget), "efh", efh);
-
 	return widget;
 }
 
@@ -1280,4 +1244,9 @@ efhd_free_attach_puri_data (EMFormatPURI *puri)
 		g_free (info->attachment_view_part_id);
 		info->attachment_view_part_id = NULL;
 	}
+
+	if (info->mstream) {
+		g_object_unref (info->mstream);
+		info->mstream = NULL;
+	}
 }
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 6b1f849..d124f36 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -107,7 +107,7 @@ enum {
 		"<style type=\"text/css\">\n" \
 		"  table th { color: #000; font-weight: bold; }\n" \
 		"</style>\n" \
-		"</head>\n"
+		"</head><body>"
 #define EFH_HTML_FOOTER "</body></html>"
 
 static void efh_parse_image			(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
@@ -124,6 +124,8 @@ static void efh_write_text_plain		(EMFormat *emf, EMFormatPURI *puri, CamelStrea
 static void efh_write_text_html			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
 static void efh_write_source			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
 static void efh_write_headers			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
+static void efh_write_attachment		(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
+static void efh_write_error			(EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
 
 static GtkWidget* efh_widget_message_rfc822     (EMFormat *emf, EMFormatPURI *puri, GCancellable *cancellable);
 
@@ -184,7 +186,7 @@ efh_parse_image (EMFormat *emf,
 	puri->mime_type = g_strdup (info->handler->mime_type);
 	puri->is_attachment = TRUE;
 	puri->validity = info->validity ? camel_cipher_validity_clone (info->validity) : NULL;
-	puri->validity_type = info->validity_type;	
+	puri->validity_type = info->validity_type;
 
 	em_format_add_puri (emf, puri);
 	g_string_truncate (part_id, len);
@@ -233,13 +235,15 @@ efh_parse_text_plain (EMFormat *emf,
 		      EMFormatParserInfo *info,
 		      GCancellable *cancellable)
 {
-	EMFormatHTML *efh = EM_FORMAT_HTML (emf);
 	EMFormatPURI *puri;
-	CamelStream *filtered_stream;
+	CamelStream *filtered_stream, *null;
 	CamelMultipart *mp;
 	CamelDataWrapper *dw;
 	CamelContentType *type;
 	gint i, count, len;
+	EMInlineFilter *inline_filter;
+	gboolean charset_added = FALSE;
+	const gchar *snoop_type = NULL;
 
 	if (g_cancellable_is_cancelled (cancellable))
 		return;
@@ -259,63 +263,43 @@ efh_parse_text_plain (EMFormat *emf,
 	   filters a bit.  Perhaps the superclass should just deal with
 	   html anyway and be done with it ... */
 
-	/* FIXME WEBKIT no cache
-	efhc = g_hash_table_lookup (
-		efh->priv->text_inline_parts,
-		emf->part_id->str);
+	if (!dw->mime_type)
+		snoop_type = em_format_snoop_type (part);
 
-	if (efhc == NULL || (mp = efhc->textmp) == NULL) {
-	*/
-	if (TRUE) {
-		EMInlineFilter *inline_filter;
-		CamelStream *null;
-		CamelContentType *ct;
-		gboolean charset_added = FALSE;
-		const gchar *snoop_type = NULL;
-
-                if (!dw->mime_type)
-                        snoop_type = em_format_snoop_type (part);
-
-		/* if we had to snoop the part type to get here, then
-		 * use that as the base type, yuck */
-		if (snoop_type == NULL
-		    || (ct = camel_content_type_decode (snoop_type)) == NULL) {
-			ct = dw->mime_type;
-			camel_content_type_ref (ct);
-		}
+	/* if we had to snoop the part type to get here, then
+		* use that as the base type, yuck */
+	if (snoop_type == NULL
+		|| (type = camel_content_type_decode (snoop_type)) == NULL) {
+		type = dw->mime_type;
+		camel_content_type_ref (type);
+	}
 
-		if (dw->mime_type && ct != dw->mime_type && camel_content_type_param (dw->mime_type, "charset")) {
-			camel_content_type_set_param (ct, "charset", camel_content_type_param (dw->mime_type, "charset"));
-			charset_added = TRUE;
-		}
+	if (dw->mime_type && type != dw->mime_type && camel_content_type_param (dw->mime_type, "charset")) {
+		camel_content_type_set_param (type, "charset", camel_content_type_param (dw->mime_type, "charset"));
+		charset_added = TRUE;
+	}
 
-		null = camel_stream_null_new ();
-		filtered_stream = camel_stream_filter_new (null);
-		g_object_unref (null);
-		inline_filter = em_inline_filter_new (camel_mime_part_get_encoding (part), ct);
-		camel_stream_filter_add (
-			CAMEL_STREAM_FILTER (filtered_stream),
-			CAMEL_MIME_FILTER (inline_filter));
-		camel_data_wrapper_decode_to_stream_sync (
-			dw, (CamelStream *) filtered_stream, cancellable, NULL);
-		camel_stream_close ((CamelStream *) filtered_stream, cancellable, NULL);
-		g_object_unref (filtered_stream);
-
-		mp = em_inline_filter_get_multipart (inline_filter);
-		/* FIXME WEBKIT
-		if (efhc == NULL)
-			efhc = efh_insert_cache (efh, emf->part_id->str);
-		efhc->textmp = mp;
-		*/
-
-		if (charset_added) {
-			camel_content_type_set_param (ct, "charset", NULL);
-		}
+	null = camel_stream_null_new ();
+	filtered_stream = camel_stream_filter_new (null);
+	g_object_unref (null);
+	inline_filter = em_inline_filter_new (camel_mime_part_get_encoding (part), type);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream),
+		CAMEL_MIME_FILTER (inline_filter));
+	camel_data_wrapper_decode_to_stream_sync (
+		dw, (CamelStream *) filtered_stream, cancellable, NULL);
+	camel_stream_close ((CamelStream *) filtered_stream, cancellable, NULL);
+	g_object_unref (filtered_stream);
+
+	mp = em_inline_filter_get_multipart (inline_filter);
 
-		g_object_unref (inline_filter);
-		camel_content_type_unref (ct);
+	if (charset_added) {
+		camel_content_type_set_param (type, "charset", NULL);
 	}
 
+	g_object_unref (inline_filter);
+	camel_content_type_unref (type);
+
 	/* We handle our made-up multipart here, so we don't recursively call ourselves */
 	len = part_id->len;
 	count = camel_multipart_get_number (mp);
@@ -554,8 +538,7 @@ efh_parse_message_rfc822 (EMFormat *emf,
 	CamelMimeParser *parser;
 	gint len;
 	EMFormatParserInfo oinfo = *info;
-        EMFormatPURI *puri;
-        EMFormatWriteFunc write_func;
+	EMFormatPURI *puri;
 
 	len = part_id->len;
 	g_string_append (part_id, ".rfc822");
@@ -627,16 +610,14 @@ efh_write_image (EMFormat *emf,
 	   This is because when rendering emails the normal way (=TRUE), images are always embedded
 	   either in <img> or in their own webview. When printing (=FALSE), we want the entire
 	   image. */
-	/* FIXME WEBKIT We should use another more intuitive way to determine wheter
-	 		use HTML or not */
 	if (!info->with_html_header) {
 		gchar *buffer;
-		
-		/* The image is already base64-encrypted so we can directly 
+
+		/* The image is already base64-encrypted so we can directly
 		   paste it to the output */
 		buffer = g_strdup_printf ("<img src=\"data:%s;base64,%s\" style=\"max-width: 100%%;\" />",
 			puri->mime_type, content);
-		
+
 		camel_stream_write_string (stream, buffer, cancellable, NULL);
 
 		g_free (buffer);
@@ -723,7 +704,7 @@ efh_write_text_enriched (EMFormat *emf,
 
 	camel_stream_write_string (stream, buffer->str, cancellable, NULL);
 	g_string_free (buffer, TRUE);
-	
+
 	em_format_format_text (
 		emf, (CamelStream *) filtered_stream,
 		(CamelDataWrapper *) puri->part, cancellable);
@@ -806,7 +787,7 @@ efh_write_text_html (EMFormat *emf,
 		return;
 
 	if (info->with_html_header) {
-		em_format_format_text (emf, stream, 
+		em_format_format_text (emf, stream,
 			(CamelDataWrapper *) puri->part, cancellable);
 
 	} else {
@@ -869,7 +850,7 @@ efh_write_source (EMFormat *emf,
 		CAMEL_STREAM_FILTER (filtered_stream), filter);
 	g_object_unref (filter);
 
-	buffer = g_string_new ("");	
+	buffer = g_string_new ("");
 	if (info->with_html_header)
 		g_string_append (buffer, EFH_HTML_HEADER);
 
@@ -920,32 +901,33 @@ efh_write_headers (EMFormat *emf,
 	} else {
 		bg_color = e_color_to_value (&efh->priv->colors[EM_FORMAT_HTML_COLOR_BODY]);
 	}
-	
+
 	if (info->with_html_header)
 		g_string_append_printf (buffer, EFH_HTML_HEADER);
 
 	/* Headers need some fancy JavaScript */
 	g_string_append_printf (
 		buffer,
-		"<script type=\"text/javascript\">\n" \
-		"function collapse_addresses(field) {\n" \
-		"  var e=window.document.getElementById(\"moreaddr-\"+field).style;\n" \
-		"  var f=window.document.getElementById(\"moreaddr-ellipsis-\"+field).style;\n" \
-		"  var g=window.document.getElementById(\"moreaddr-img-\"+field);\n" \
-		"  if (e.display==\"inline\") { e.display=\"none\"; f.display=\"inline\"; g.src=g.src.substr(0,g.src.lastIndexOf(\"/\"))+\"/plus.png\"; }\n" \
-		"  else { e.display=\"inline\"; f.display=\"none\"; g.src=g.src.substr(0,g.src.lastIndexOf(\"/\"))+\"/minus.png\"; }\n" \
-		"}\n" \
-		"function collapse_headers() {\n" \
-		"  var f=window.document.getElementById(\"full-headers\").style;\n" \
-		"  var s=window.document.getElementById(\"short-headers\").style;\n" \
-		"  var i=window.document.getElementById(\"collapse-headers-img\");\n" \
-		"  if (f.display==\"block\") { f.display=\"none\"; s.display=\"block\";\n" \
-		"	i.src=i.src.substr(0,i.src.lastIndexOf(\"/\"))+\"/plus.png\"; window.headers_collapsed(true, window.em_format_html); }\n" \
-		"  else { f.display=\"block\"; s.display=\"none\";\n" \
-		"	 i.src=i.src.substr(0,i.src.lastIndexOf(\"/\"))+\"/minus.png\"; window.headers_collapsed(false, window.em_format_html); }\n" \
-		"}\n" \
-		"</script>\n" \
-		"<table border=\"0\" width=\"100%\" height=\"100%\" style=\"background: #%06x; color: #%06x;\">\n" \
+		"<script type=\"text/javascript\">\n"
+		"function collapse_addresses(field) {\n"
+		"  var e=window.document.getElementById(\"moreaddr-\"+field).style;\n"
+		"  var f=window.document.getElementById(\"moreaddr-ellipsis-\"+field).style;\n"
+		"  var g=window.document.getElementById(\"moreaddr-img-\"+field);\n"
+		"  if (e.display==\"inline\") { e.display=\"none\"; f.display=\"inline\"; g.src=g.src.substr(0,g.src.lastIndexOf(\"/\"))+\"/plus.png\"; }\n"
+		"  else { e.display=\"inline\"; f.display=\"none\"; g.src=g.src.substr(0,g.src.lastIndexOf(\"/\"))+\"/minus.png\"; }\n"
+		"}\n"
+		"function collapse_headers() {\n"
+		"  var f=window.document.getElementById(\"full-headers\").style;\n"
+		"  var s=window.document.getElementById(\"short-headers\").style;\n"
+		"  var i=window.document.getElementById(\"collapse-headers-img\");\n"
+		"  if (f.display==\"block\") { f.display=\"none\"; s.display=\"block\";\n"
+		"	i.src=i.src.substr(0,i.src.lastIndexOf(\"/\"))+\"/plus.png\"; window.headers_collapsed(true, window.em_format_html); }\n"
+		"  else { f.display=\"block\"; s.display=\"none\";\n"
+		"	 i.src=i.src.substr(0,i.src.lastIndexOf(\"/\"))+\"/minus.png\"; window.headers_collapsed(false, window.em_format_html); }\n"
+		"}\n"
+		"</script>\n"
+		"<style type=\"text/css\">body { background: #%06x; }</style>"
+		"<table border=\"0\" width=\"100%%\" height=\"100%%\" style=\"color: #%06x;\">\n"
 		"<tr><td valign=\"top\" width=\"16\">\n",
 		bg_color,
 		e_color_to_value (&efh->priv->colors[EM_FORMAT_HTML_COLOR_HEADER]));
@@ -966,7 +948,7 @@ efh_write_headers (EMFormat *emf,
 		!info->headers_collapsed,
 		cancellable);
 
-	g_string_append (buffer, "</td></tr></table></div>");
+	g_string_append (buffer, "</td></tr></table>");
 
 	if (info->with_html_header)
 		g_string_append (buffer, EFH_HTML_FOOTER);
@@ -976,6 +958,40 @@ efh_write_headers (EMFormat *emf,
 	g_string_free (buffer, true);
 }
 
+static void
+efh_write_error (EMFormat *emf,
+		 EMFormatPURI *puri,
+		 CamelStream *stream,
+		 EMFormatWriterInfo *info,
+		 GCancellable *cancellable)
+{
+	CamelStream *filtered_stream;
+	CamelMimeFilter *filter;
+	CamelDataWrapper *dw;
+
+	if (info->with_html_header)
+		camel_stream_write_string (stream, EFH_HTML_HEADER, cancellable, NULL);
+
+	dw = camel_medium_get_content ((CamelMedium *) puri->part);
+
+	camel_stream_write_string (stream, "<em><font color=\"red\">", cancellable, NULL);
+
+	filtered_stream = camel_stream_filter_new (stream);
+	filter = camel_mime_filter_tohtml_new (CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
+		CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0);
+	camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered_stream), filter);
+	g_object_unref (filter);
+
+	camel_data_wrapper_decode_to_stream_sync (dw, filtered_stream, cancellable, NULL);
+
+	g_object_unref (filtered_stream);
+
+	camel_stream_write_string (stream, "</font></em><br>", cancellable, NULL);
+
+	if (info->with_html_header)
+		camel_stream_write_string (stream, EFH_HTML_FOOTER, cancellable, NULL);
+}
+
 /*****************************************************************************/
 
 /* Notes:
@@ -1024,6 +1040,8 @@ static EMFormatHandler type_builtin_table[] = {
 	{ (gchar *) "x-evolution/message/rfc822", 0, efh_write_text_plain, },
 	{ (gchar *) "x-evolution/message/headers", 0, efh_write_headers, },
 	{ (gchar *) "x-evolution/message/source", 0, efh_write_source, },
+	{ (gchar *) "x-evolution/message/attachment", 0, efh_write_attachment, },
+	{ (gchar *) "x-evolution/message/error", 0, efh_write_error, },
 };
 
 static void
@@ -1217,84 +1235,22 @@ efh_get_property (GObject *object,
 static void
 efh_finalize (GObject *object)
 {
-	EMFormatHTML *efh = EM_FORMAT_HTML (object);
-
 	/* Chain up to parent's finalize() method. */
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
-static void
-efh_format_error (EMFormat *emf,
-                  const gchar *message)
-{
-	EMFormatPURI *puri;
-	CamelMimePart *part;
-	GString *buffer;
-	gchar *html;
 
-	buffer = g_string_new ("<em><font color=\"red\">");
-
-	html = camel_text_to_html (
-		message, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
-		CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0);
-	g_string_append (buffer, html);
-	g_free (html);
-
-	g_string_append (buffer, "</font></em><br>");
-
-	part = camel_mime_part_new ();
-	camel_mime_part_set_content (part, buffer->str, buffer->len, "text/html");
-
-	puri = em_format_puri_new (emf, sizeof (EMFormatPURI), part, em_format_get_error_id (emf));
-	puri->write_func = efh_write_text_html;
-	puri->mime_type = g_strdup ("text/html");
-
-	em_format_add_puri (emf, puri);
-
-	g_string_free (buffer, TRUE);
-}
-
-static void
-efh_format_source (EMFormat *emf,
-		   CamelStream *stream,
-		   CamelMimePart *part,
-		   GCancellable *cancellable)
-{
-	CamelStream *filtered_stream;
-	CamelMimeFilter *filter;
-	CamelDataWrapper *dw = (CamelDataWrapper *) part;
-
-	filtered_stream = camel_stream_filter_new (stream);
-
-	filter = camel_mime_filter_tohtml_new (
-		CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
-		CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
-		CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT, 0);
-	camel_stream_filter_add (
-		CAMEL_STREAM_FILTER (filtered_stream), filter);
-	g_object_unref (filter);
-
-	camel_stream_write_string (
-		stream, EFH_HTML_HEADER "<code class=\"pre\">", cancellable, NULL);
-	em_format_format_text (emf, filtered_stream, dw, cancellable);
-	camel_stream_write_string (
-		stream, "</code>" EFH_HTML_FOOTER, cancellable, NULL);
-
-	g_object_unref (filtered_stream);
-}
-
-/* FIXME WEBKIT: This should only create EMFormatPURI that will be then
- * processed to EAttachment (or whatever) widget!
- */
 static void
-efh_format_attachment (EMFormat *emf,
-                       CamelStream *stream,
-                       CamelMimePart *part,
-                       const gchar *mime_type,
-                       const EMFormatHandler *handle,
-                       GCancellable *cancellable)
+efh_write_attachment (EMFormat *emf,
+					  EMFormatPURI *puri,
+					  CamelStream *stream,
+					  EMFormatWriterInfo *info,
+                      GCancellable *cancellable)
 {
 	gchar *text, *html;
+	CamelContentType *ct;
+	gchar *mime_type;
+	const EMFormatHandler *handler;
 
 	/* we display all inlined attachments only */
 
@@ -1308,8 +1264,11 @@ efh_format_attachment (EMFormat *emf,
 		"<tr><td></td></tr></table></td><td><font size=-1>\n",
 		cancellable, NULL);
 
+	ct = camel_mime_part_get_content_type (puri->part);
+	mime_type = camel_content_type_simple (ct);
+
 	/* output some info about it */
-	text = em_format_describe_part (part, mime_type);
+	text = em_format_describe_part (puri->part, mime_type);
 	html = camel_text_to_html (
 		text, ((EMFormatHTML *) emf)->text_html_flags &
 		CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0);
@@ -1319,10 +1278,14 @@ efh_format_attachment (EMFormat *emf,
 
 	camel_stream_write_string (
 		stream, "</font></td></tr><tr></table>", cancellable, NULL);
-/*
-	if (handle && em_format_is_inline (emf, part_id->str, part, handle))
-			handle->write_func (emf, part, stream, cancellable);
-*/
+
+	handler = em_format_find_handler (emf, mime_type);
+	if (handler && handler->write_func && handler->write_func != efh_write_attachment) {
+		if (em_format_is_inline (emf, puri->uri, puri->part, handler))
+			handler->write_func (emf, puri, stream, info, cancellable);
+	}
+
+	g_free (mime_type);
 }
 
 static void
@@ -1335,8 +1298,6 @@ static void
 efh_class_init (EMFormatHTMLClass *class)
 {
 	GObjectClass *object_class;
-	EMFormatClass *format_class;
-	const gchar *user_cache_dir;
 
 	parent_class = g_type_class_peek_parent (class);
 	g_type_class_add_private (class, sizeof (EMFormatHTMLPrivate));
@@ -1346,12 +1307,6 @@ efh_class_init (EMFormatHTMLClass *class)
 	object_class->get_property = efh_get_property;
 	object_class->finalize = efh_finalize;
 
-	format_class = EM_FORMAT_CLASS (class);
-	format_class->format_error = efh_format_error;
-	/*format_class->format_source = efh_format_source;
-	format_class->format_attachment = efh_format_attachment;
-	format_class->format_secure = efh_format_secure;
-	*/
 	g_object_class_install_property (
 		object_class,
 		PROP_BODY_COLOR,
@@ -1487,13 +1442,6 @@ efh_init (EMFormatHTML *efh,
 
 	efh->priv = EM_FORMAT_HTML_GET_PRIVATE (efh);
 
-	/* FIXME WEBKIT
-	efh->priv->text_inline_parts = g_hash_table_new_full (
-		g_str_hash, g_str_equal,
-		(GDestroyNotify) NULL,
-		(GDestroyNotify) efh_free_cache);
-	*/
-
 	g_queue_init (&efh->pending_object_list);
 
 	color = &efh->priv->colors[EM_FORMAT_HTML_COLOR_BODY];
@@ -1683,7 +1631,6 @@ em_format_html_set_mark_citations (EMFormatHTML *efh,
 {
 	g_return_if_fail (EM_IS_FORMAT_HTML (efh));
 
-	/* FIXME WEBKIT: Make this thread safe */
 	if (mark_citations)
 		efh->text_html_flags |=
 			CAMEL_MIME_FILTER_TOHTML_MARK_CITATION;
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index 924a278..0bdd4ac 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -2066,7 +2066,7 @@ e_web_view_set_enable_frame_flattening (EWebView* web_view,
         g_return_if_fail (settings != NULL);
 
         g_object_set (G_OBJECT (settings), "enable-frame-flattening",
-                &enable_frame_flattening, NULL);
+                enable_frame_flattening, NULL);
 }
 
 



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