Blame SOURCES/evolution-3.12.11-parse-attachments-on-demand.patch

4b6d7b
diff -up evolution-3.12.11/em-format/e-mail-formatter-attachment.c.parse-attachments-on-demand evolution-3.12.11/em-format/e-mail-formatter-attachment.c
4b6d7b
--- evolution-3.12.11/em-format/e-mail-formatter-attachment.c.parse-attachments-on-demand	2014-03-24 10:25:23.000000000 +0100
4b6d7b
+++ evolution-3.12.11/em-format/e-mail-formatter-attachment.c	2015-08-19 16:17:57.887545211 +0200
4b6d7b
@@ -335,13 +335,29 @@ emfe_attachment_format (EMailFormatterEx
4b6d7b
 			g_string_append_printf (
4b6d7b
 				buffer,
4b6d7b
 				""
4b6d7b
-				"
",
4b6d7b
+				"
4b6d7b
 				wrapper_element_id);
4b6d7b
 
4b6d7b
-			g_string_append_len (buffer, data, size);
4b6d7b
+			if (e_mail_part_should_show_inline (part)) {
4b6d7b
+				g_string_append (buffer, ">");
4b6d7b
+				g_string_append_len (buffer, data, size);
4b6d7b
+			} else {
4b6d7b
+				gchar *inner_html_data;
4b6d7b
+
4b6d7b
+				inner_html_data = g_markup_escape_text (data, size);
4b6d7b
+
4b6d7b
+				g_string_append_printf (
4b6d7b
+					buffer,
4b6d7b
+					" inner-html-data=\"%s\">",
4b6d7b
+					inner_html_data);
4b6d7b
+
4b6d7b
+				g_free (inner_html_data);
4b6d7b
+			}
4b6d7b
 
4b6d7b
 			g_string_append (buffer, "");
4b6d7b
 
4b6d7b
+			e_mail_part_attachment_set_expandable (empa, TRUE);
4b6d7b
+
4b6d7b
 			g_free (wrapper_element_id);
4b6d7b
 		}
4b6d7b
 
4b6d7b
diff -up evolution-3.12.11/em-format/e-mail-part-attachment.c.parse-attachments-on-demand evolution-3.12.11/em-format/e-mail-part-attachment.c
4b6d7b
--- evolution-3.12.11/em-format/e-mail-part-attachment.c.parse-attachments-on-demand	2014-07-17 12:48:14.000000000 +0200
4b6d7b
+++ evolution-3.12.11/em-format/e-mail-part-attachment.c	2015-08-19 16:16:41.520548446 +0200
4b6d7b
@@ -23,11 +23,13 @@
4b6d7b
 
4b6d7b
 struct _EMailPartAttachmentPrivate {
4b6d7b
 	EAttachment *attachment;
4b6d7b
+	gboolean expandable;
4b6d7b
 };
4b6d7b
 
4b6d7b
 enum {
4b6d7b
 	PROP_0,
4b6d7b
-	PROP_ATTACHMENT
4b6d7b
+	PROP_ATTACHMENT,
4b6d7b
+	PROP_EXPANDABLE
4b6d7b
 };
4b6d7b
 
4b6d7b
 G_DEFINE_TYPE (
4b6d7b
@@ -36,6 +38,23 @@ G_DEFINE_TYPE (
4b6d7b
 	E_TYPE_MAIL_PART)
4b6d7b
 
4b6d7b
 static void
4b6d7b
+mail_part_attachment_set_property (GObject *object,
4b6d7b
+				   guint property_id,
4b6d7b
+				   const GValue *value,
4b6d7b
+				   GParamSpec *pspec)
4b6d7b
+{
4b6d7b
+	switch (property_id) {
4b6d7b
+		case PROP_EXPANDABLE:
4b6d7b
+			e_mail_part_attachment_set_expandable (
4b6d7b
+				E_MAIL_PART_ATTACHMENT (object),
4b6d7b
+				g_value_get_boolean (value));
4b6d7b
+			return;
4b6d7b
+	}
4b6d7b
+
4b6d7b
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4b6d7b
+}
4b6d7b
+
4b6d7b
+static void
4b6d7b
 mail_part_attachment_get_property (GObject *object,
4b6d7b
                                    guint property_id,
4b6d7b
                                    GValue *value,
4b6d7b
@@ -48,6 +67,13 @@ mail_part_attachment_get_property (GObje
4b6d7b
 				e_mail_part_attachment_ref_attachment (
4b6d7b
 				E_MAIL_PART_ATTACHMENT (object)));
4b6d7b
 			return;
4b6d7b
+
4b6d7b
+		case PROP_EXPANDABLE:
4b6d7b
+			g_value_set_boolean (
4b6d7b
+				value,
4b6d7b
+				e_mail_part_attachment_get_expandable (
4b6d7b
+				E_MAIL_PART_ATTACHMENT (object)));
4b6d7b
+			return;
4b6d7b
 	}
4b6d7b
 
4b6d7b
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4b6d7b
@@ -125,6 +151,7 @@ e_mail_part_attachment_class_init (EMail
4b6d7b
 
4b6d7b
 	object_class = G_OBJECT_CLASS (class);
4b6d7b
 	object_class->get_property = mail_part_attachment_get_property;
4b6d7b
+	object_class->set_property = mail_part_attachment_set_property;
4b6d7b
 	object_class->dispose = mail_part_attachment_dispose;
4b6d7b
 	object_class->finalize = mail_part_attachment_finalize;
4b6d7b
 	object_class->constructed = mail_part_attachment_constructed;
4b6d7b
@@ -139,12 +166,24 @@ e_mail_part_attachment_class_init (EMail
4b6d7b
 			E_TYPE_ATTACHMENT,
4b6d7b
 			G_PARAM_READABLE |
4b6d7b
 			G_PARAM_STATIC_STRINGS));
4b6d7b
+
4b6d7b
+	g_object_class_install_property (
4b6d7b
+		object_class,
4b6d7b
+		PROP_EXPANDABLE,
4b6d7b
+		g_param_spec_boolean (
4b6d7b
+			"expandable",
4b6d7b
+			"Expandable",
4b6d7b
+			"Whether the attachment can be expanded",
4b6d7b
+			FALSE,
4b6d7b
+			G_PARAM_READWRITE |
4b6d7b
+			G_PARAM_STATIC_STRINGS));
4b6d7b
 }
4b6d7b
 
4b6d7b
 static void
4b6d7b
 e_mail_part_attachment_init (EMailPartAttachment *part)
4b6d7b
 {
4b6d7b
 	part->priv = E_MAIL_PART_ATTACHMENT_GET_PRIVATE (part);
4b6d7b
+	part->priv->expandable = FALSE;
4b6d7b
 }
4b6d7b
 
4b6d7b
 EMailPartAttachment *
4b6d7b
@@ -166,3 +205,24 @@ e_mail_part_attachment_ref_attachment (E
4b6d7b
 	return g_object_ref (part->priv->attachment);
4b6d7b
 }
4b6d7b
 
4b6d7b
+void
4b6d7b
+e_mail_part_attachment_set_expandable (EMailPartAttachment *part,
4b6d7b
+				       gboolean expandable)
4b6d7b
+{
4b6d7b
+	g_return_if_fail (E_IS_MAIL_PART_ATTACHMENT (part));
4b6d7b
+
4b6d7b
+	if ((part->priv->expandable ? 1 : 0) == (expandable ? 1 : 0))
4b6d7b
+		return;
4b6d7b
+
4b6d7b
+	part->priv->expandable = expandable;
4b6d7b
+
4b6d7b
+	g_object_notify (G_OBJECT (part), "expandable");
4b6d7b
+}
4b6d7b
+
4b6d7b
+gboolean
4b6d7b
+e_mail_part_attachment_get_expandable (EMailPartAttachment *part)
4b6d7b
+{
4b6d7b
+	g_return_val_if_fail (E_IS_MAIL_PART_ATTACHMENT (part), FALSE);
4b6d7b
+
4b6d7b
+	return part->priv->expandable;
4b6d7b
+}
4b6d7b
diff -up evolution-3.12.11/em-format/e-mail-part-attachment.h.parse-attachments-on-demand evolution-3.12.11/em-format/e-mail-part-attachment.h
4b6d7b
--- evolution-3.12.11/em-format/e-mail-part-attachment.h.parse-attachments-on-demand	2014-03-24 10:25:23.000000000 +0100
4b6d7b
+++ evolution-3.12.11/em-format/e-mail-part-attachment.h	2015-08-19 16:16:41.521548446 +0200
4b6d7b
@@ -68,6 +68,11 @@ EMailPartAttachment *
4b6d7b
 						 const gchar *id);
4b6d7b
 EAttachment *	e_mail_part_attachment_ref_attachment
4b6d7b
 						(EMailPartAttachment *part);
4b6d7b
+void		e_mail_part_attachment_set_expandable
4b6d7b
+						(EMailPartAttachment *part,
4b6d7b
+						 gboolean expandable);
4b6d7b
+gboolean	e_mail_part_attachment_get_expandable
4b6d7b
+						(EMailPartAttachment *part);
4b6d7b
 
4b6d7b
 G_END_DECLS
4b6d7b
 
4b6d7b
diff -up evolution-3.12.11/em-format/e-mail-part.c.parse-attachments-on-demand evolution-3.12.11/em-format/e-mail-part.c
4b6d7b
--- evolution-3.12.11/em-format/e-mail-part.c.parse-attachments-on-demand	2015-08-19 16:17:48.230545620 +0200
4b6d7b
+++ evolution-3.12.11/em-format/e-mail-part.c	2015-08-19 16:17:57.887545211 +0200
4b6d7b
@@ -26,10 +26,15 @@
4b6d7b
  * message.
4b6d7b
  */
4b6d7b
 
4b6d7b
+#ifdef HAVE_CONFIG_H
4b6d7b
+#include <config.h>
4b6d7b
+#endif
4b6d7b
+
4b6d7b
 #include "e-mail-part.h"
4b6d7b
 
4b6d7b
 #include <string.h>
4b6d7b
 
4b6d7b
+#include "e-mail-part-attachment.h"
4b6d7b
 #include "e-mail-part-list.h"
4b6d7b
 
4b6d7b
 #define E_MAIL_PART_GET_PRIVATE(obj) \
4b6d7b
@@ -441,6 +446,46 @@ e_mail_part_set_mime_type (EMailPart *pa
4b6d7b
 	g_object_notify (G_OBJECT (part), "mime-type");
4b6d7b
 }
4b6d7b
 
4b6d7b
+gboolean
4b6d7b
+e_mail_part_should_show_inline (EMailPart *part)
4b6d7b
+{
4b6d7b
+	CamelMimePart *mime_part;
4b6d7b
+	const CamelContentDisposition *disposition;
4b6d7b
+	gboolean res = FALSE;
4b6d7b
+
4b6d7b
+	g_return_val_if_fail (E_IS_MAIL_PART (part), FALSE);
4b6d7b
+
4b6d7b
+	/* Automatically expand attachments that have inline
4b6d7b
+	 * disposition or the EMailParts have specific
4b6d7b
+	 * force_inline flag set. */
4b6d7b
+
4b6d7b
+	if (part->force_collapse)
4b6d7b
+		return FALSE;
4b6d7b
+
4b6d7b
+	if (part->force_inline)
4b6d7b
+		return TRUE;
4b6d7b
+
4b6d7b
+	if (E_IS_MAIL_PART_ATTACHMENT (part)) {
4b6d7b
+		EMailPartAttachment *empa = E_MAIL_PART_ATTACHMENT (part);
4b6d7b
+
4b6d7b
+		if (g_strcmp0 (empa->snoop_mime_type, "message/rfc822") == 0)
4b6d7b
+			return TRUE;
4b6d7b
+	}
4b6d7b
+
4b6d7b
+	mime_part = e_mail_part_ref_mime_part (part);
4b6d7b
+	if (!mime_part)
4b6d7b
+		return FALSE;
4b6d7b
+
4b6d7b
+	disposition = camel_mime_part_get_content_disposition (mime_part);
4b6d7b
+	if (disposition && disposition->disposition &&
4b6d7b
+	    g_ascii_strncasecmp (disposition->disposition, "inline", 6) == 0)
4b6d7b
+		res = TRUE;
4b6d7b
+
4b6d7b
+	g_object_unref (mime_part);
4b6d7b
+
4b6d7b
+	return res;
4b6d7b
+}
4b6d7b
+
4b6d7b
 EMailPartList *
4b6d7b
 e_mail_part_ref_part_list (EMailPart *part)
4b6d7b
 {
4b6d7b
diff -up evolution-3.12.11/em-format/e-mail-part.h.parse-attachments-on-demand evolution-3.12.11/em-format/e-mail-part.h
4b6d7b
--- evolution-3.12.11/em-format/e-mail-part.h.parse-attachments-on-demand	2015-08-19 16:17:41.783545893 +0200
4b6d7b
+++ evolution-3.12.11/em-format/e-mail-part.h	2015-08-19 16:17:57.887545211 +0200
4b6d7b
@@ -107,6 +107,7 @@ CamelMimePart *	e_mail_part_ref_mime_par
4b6d7b
 const gchar *	e_mail_part_get_mime_type	(EMailPart *part);
4b6d7b
 void		e_mail_part_set_mime_type	(EMailPart *part,
4b6d7b
 						 const gchar *mime_type);
4b6d7b
+gboolean	e_mail_part_should_show_inline	(EMailPart *part);
4b6d7b
 struct _EMailPartList *
4b6d7b
 		e_mail_part_ref_part_list	(EMailPart *part);
4b6d7b
 void		e_mail_part_set_part_list	(EMailPart *part,
4b6d7b
diff -up evolution-3.12.11/mail/e-mail-display.c.parse-attachments-on-demand evolution-3.12.11/mail/e-mail-display.c
4b6d7b
--- evolution-3.12.11/mail/e-mail-display.c.parse-attachments-on-demand	2014-06-18 14:11:40.000000000 +0200
4b6d7b
+++ evolution-3.12.11/mail/e-mail-display.c	2015-08-19 16:17:57.888545210 +0200
4b6d7b
@@ -459,6 +459,23 @@ attachment_button_expanded (GObject *obj
4b6d7b
 		return;
4b6d7b
 	}
4b6d7b
 
4b6d7b
+	if (WEBKIT_DOM_IS_HTML_ELEMENT (element) && expanded &&
4b6d7b
+	    webkit_dom_element_get_child_element_count (element) == 0) {
4b6d7b
+		gchar *inner_html_data;
4b6d7b
+
4b6d7b
+		inner_html_data = webkit_dom_element_get_attribute (element, "inner-html-data");
4b6d7b
+		if (inner_html_data && *inner_html_data) {
4b6d7b
+			WebKitDOMHTMLElement *html_element;
4b6d7b
+
4b6d7b
+			html_element = WEBKIT_DOM_HTML_ELEMENT (element);
4b6d7b
+			webkit_dom_html_element_set_inner_html (html_element, inner_html_data, NULL);
4b6d7b
+
4b6d7b
+			webkit_dom_element_remove_attribute (element, "inner-html-data");
4b6d7b
+		}
4b6d7b
+
4b6d7b
+		g_free (inner_html_data);
4b6d7b
+	}
4b6d7b
+
4b6d7b
 	/* Show or hide the DIV which contains
4b6d7b
 	 * the attachment (iframe, image...). */
4b6d7b
 	css = webkit_dom_element_get_style (element);
4b6d7b
@@ -644,37 +661,12 @@ mail_display_plugin_widget_requested (We
4b6d7b
 		/* Bind visibility of DOM element containing related
4b6d7b
 		 * attachment with 'expanded' property of this
4b6d7b
 		 * attachment button. */
4b6d7b
-		WebKitDOMElement *attachment;
4b6d7b
-		WebKitDOMDocument *document;
4b6d7b
 		EMailPartAttachment *empa = (EMailPartAttachment *) part;
4b6d7b
-		gchar *attachment_part_id;
4b6d7b
-		gchar *wrapper_element_id;
4b6d7b
-
4b6d7b
-		if (empa->attachment_view_part_id)
4b6d7b
-			attachment_part_id = empa->attachment_view_part_id;
4b6d7b
-		else
4b6d7b
-			attachment_part_id = part_id;
4b6d7b
 
4b6d7b
-		/* Find attachment-wrapper div which contains
4b6d7b
-		 * the content of the attachment (iframe). */
4b6d7b
-		document = webkit_web_view_get_dom_document (
4b6d7b
-			WEBKIT_WEB_VIEW (display));
4b6d7b
-		wrapper_element_id = g_strconcat (
4b6d7b
-			attachment_part_id, ".wrapper", NULL);
4b6d7b
-		attachment = find_element_by_id (document, wrapper_element_id);
4b6d7b
-		g_free (wrapper_element_id);
4b6d7b
-
4b6d7b
-		/* None found? Attachment cannot be expanded */
4b6d7b
-		if (attachment == NULL) {
4b6d7b
-			e_attachment_button_set_expandable (
4b6d7b
-				E_ATTACHMENT_BUTTON (widget), FALSE);
4b6d7b
-		} else {
4b6d7b
-			CamelMimePart *mime_part;
4b6d7b
-			const CamelContentDisposition *disposition;
4b6d7b
-
4b6d7b
-			e_attachment_button_set_expandable (
4b6d7b
-				E_ATTACHMENT_BUTTON (widget), TRUE);
4b6d7b
+		e_attachment_button_set_expandable (E_ATTACHMENT_BUTTON (widget),
4b6d7b
+			e_mail_part_attachment_get_expandable (empa));
4b6d7b
 
4b6d7b
+		if (e_mail_part_attachment_get_expandable (empa)) {
4b6d7b
 			/* Show/hide the attachment when the EAttachmentButton
4b6d7b
 			 * is expanded/collapsed or shown/hidden. */
4b6d7b
 			g_signal_connect (
4b6d7b
@@ -686,20 +678,7 @@ mail_display_plugin_widget_requested (We
4b6d7b
 				G_CALLBACK (attachment_button_expanded),
4b6d7b
 				display);
4b6d7b
 
4b6d7b
-			mime_part = e_mail_part_ref_mime_part (part);
4b6d7b
-
4b6d7b
-			/* Automatically expand attachments that have inline
4b6d7b
-			 * disposition or the EMailParts have specific
4b6d7b
-			 * force_inline flag set. */
4b6d7b
-			disposition =
4b6d7b
-				camel_mime_part_get_content_disposition (mime_part);
4b6d7b
-			if (!part->force_collapse &&
4b6d7b
-			    (part->force_inline ||
4b6d7b
-			    (g_strcmp0 (empa->snoop_mime_type, "message/rfc822") == 0) ||
4b6d7b
-			     (disposition && disposition->disposition &&
4b6d7b
-				g_ascii_strncasecmp (
4b6d7b
-					disposition->disposition, "inline", 6) == 0))) {
4b6d7b
-
4b6d7b
+			if (e_mail_part_should_show_inline (part)) {
4b6d7b
 				e_attachment_button_set_expanded (
4b6d7b
 					E_ATTACHMENT_BUTTON (widget), TRUE);
4b6d7b
 			} else {
4b6d7b
@@ -708,8 +687,6 @@ mail_display_plugin_widget_requested (We
4b6d7b
 				attachment_button_expanded (
4b6d7b
 					G_OBJECT (widget), NULL, display);
4b6d7b
 			}
4b6d7b
-
4b6d7b
-			g_object_unref (mime_part);
4b6d7b
 		}
4b6d7b
 	}
4b6d7b