[evolution-mapi] Bug #691834 - Body of attached message not shown



commit dcee5c3e3e68bc5a9ff0988fdcc0c5c95381c10a
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jan 17 19:31:19 2013 +0100

    Bug #691834 - Body of attached message not shown

 src/libexchangemapi/e-mapi-connection.c |   24 ++++++++----------------
 src/libexchangemapi/e-mapi-mail-utils.c |   21 +++++++++++++++++----
 2 files changed, 25 insertions(+), 20 deletions(-)
---
diff --git a/src/libexchangemapi/e-mapi-connection.c b/src/libexchangemapi/e-mapi-connection.c
index e41222c..4c7475f 100644
--- a/src/libexchangemapi/e-mapi-connection.c
+++ b/src/libexchangemapi/e-mapi-connection.c
@@ -2121,7 +2121,7 @@ e_mapi_connection_list_objects (EMapiConnection *conn,
 }
 
 static gboolean
-has_embedded_message_with_html (EMapiObject *object)
+has_embedded_message_without_body (EMapiObject *object)
 {
 	EMapiAttachment *attach;
 
@@ -2132,11 +2132,10 @@ has_embedded_message_with_html (EMapiObject *object)
 		if (!attach->embedded_object)
 			continue;
 
-		if (e_mapi_object_contains_prop (attach->embedded_object, PidTagHtml) &&
-		    !e_mapi_object_contains_prop (attach->embedded_object, PidTagBody))
+		if (!e_mapi_object_contains_prop (attach->embedded_object, PidTagBody))
 			return TRUE;
 
-		if (has_embedded_message_with_html (attach->embedded_object))
+		if (has_embedded_message_without_body (attach->embedded_object))
 			return TRUE;
 	}
 
@@ -2215,9 +2214,6 @@ traverse_attachments_for_body (EMapiConnection *conn,
 	g_return_if_fail (mem_ctx != NULL);
 	g_return_if_fail (obj_message != NULL);
 
-	if (!has_embedded_message_with_html (object))
-		return;
-
 	for (attach = object->attachments; attach && !g_cancellable_is_cancelled (cancellable); attach = attach->next) {
 		if (attach->embedded_object) {
 			const uint32_t *pattach_num;
@@ -2232,8 +2228,7 @@ traverse_attachments_for_body (EMapiConnection *conn,
 			mapi_object_init (&obj_attach);
 			mapi_object_init (&obj_embedded);
 
-			if (e_mapi_object_contains_prop (attach->embedded_object, PidTagHtml) &&
-			    !e_mapi_object_contains_prop (attach->embedded_object, PidTagBody)) {
+			if (!e_mapi_object_contains_prop (attach->embedded_object, PidTagBody)) {
 				struct SPropTagArray *tags;
 
 				if (OpenAttach (obj_message, *pattach_num, &obj_attach) != MAPI_E_SUCCESS)
@@ -2253,7 +2248,7 @@ traverse_attachments_for_body (EMapiConnection *conn,
 				talloc_free (tags);
 			}
 
-			if (has_embedded_message_with_html (attach->embedded_object)) {
+			if (has_embedded_message_without_body (attach->embedded_object)) {
 				if (!have_embedded) {
 					if (OpenAttach (obj_message, *pattach_num, &obj_attach) != MAPI_E_SUCCESS)
 						continue;
@@ -2302,7 +2297,7 @@ ensure_additional_properties_cb (EMapiConnection *conn,
 		{ PidNameContentClass, MAPI_E_RESERVED }
 	};
 	struct EnsureAdditionalPropertiesData *eap = user_data;
-	gboolean need_any = FALSE, need_attachments;
+	gboolean need_any = FALSE;
 	uint32_t ii;
 
 	g_return_val_if_fail (eap != NULL, FALSE);
@@ -2324,10 +2319,8 @@ ensure_additional_properties_cb (EMapiConnection *conn,
 		need_any = need_any || prop != MAPI_E_RESERVED;
 	}
 
-	need_attachments = has_embedded_message_with_html (object);
-
 	/* Fast-transfer transfers only Html or Body, never both */
-	if (need_any || need_attachments) {
+	if (need_any || has_embedded_message_without_body (object)) {
 		const mapi_id_t *mid;
 
 		mid = e_mapi_util_find_array_propval (&object->properties, PidTagMid);
@@ -2375,8 +2368,7 @@ ensure_additional_properties_cb (EMapiConnection *conn,
 					talloc_free (tags);
 				}
 
-				if (need_attachments)
-					traverse_attachments_for_body (conn, mem_ctx, object, &obj_message, cancellable, perror);
+				traverse_attachments_for_body (conn, mem_ctx, object, &obj_message, cancellable, perror);
 			}
 
 			mapi_object_release (&obj_message);
diff --git a/src/libexchangemapi/e-mapi-mail-utils.c b/src/libexchangemapi/e-mapi-mail-utils.c
index fd522b7..7b97e10 100644
--- a/src/libexchangemapi/e-mapi-mail-utils.c
+++ b/src/libexchangemapi/e-mapi-mail-utils.c
@@ -358,7 +358,12 @@ build_ical_string (EMapiConnection *conn,
 }
 
 static void
-classify_attachments (EMapiConnection *conn, EMapiAttachment *attachments, const gchar *msg_class, GSList **inline_attachments, GSList **noninline_attachments)
+classify_attachments (EMapiConnection *conn,
+		      EMapiAttachment *attachments,
+		      gboolean can_inline_attachments,
+		      const gchar *msg_class,
+		      GSList **inline_attachments,
+		      GSList **noninline_attachments)
 {
 	EMapiAttachment *attach;
 	gboolean is_smime = msg_class && strstr (msg_class, ".SMIME.") > msg_class;
@@ -588,8 +593,10 @@ classify_attachments (EMapiConnection *conn, EMapiAttachment *attachments, const
 
 		/* Content-ID */
 		content_id = e_mapi_util_find_array_propval (&attach->properties, PidTagAttachContentId);
-		if (content_id && !is_apple && !is_smime) {
+		if (content_id)
 			camel_mime_part_set_content_id (part, content_id);
+
+		if (content_id && !is_apple && !is_smime && can_inline_attachments) {
 			*inline_attachments = g_slist_append (*inline_attachments, part);
 		} else
 			*noninline_attachments = g_slist_append (*noninline_attachments, part);
@@ -851,7 +858,7 @@ e_mapi_mail_utils_object_to_message (EMapiConnection *conn, /* const */ EMapiObj
 	inline_attachments = NULL;
 	noninline_attachments = NULL;
 	msg_class = e_mapi_util_find_array_propval (&object->properties, PidTagMessageClass);
-	classify_attachments (conn, object->attachments, msg_class, &inline_attachments, &noninline_attachments);
+	classify_attachments (conn, object->attachments, e_mapi_object_contains_prop (object, PidTagHtml), msg_class, &inline_attachments, &noninline_attachments);
 
 	build_calendar = msg_class && g_str_has_prefix (msg_class, IPM_SCHEDULE_MEETING_PREFIX);
 	if (build_calendar) {
@@ -863,7 +870,13 @@ e_mapi_mail_utils_object_to_message (EMapiConnection *conn, /* const */ EMapiObj
 	build_alternative = !build_calendar
 		&& e_mapi_object_contains_prop (object, PidTagHtml)
 		&& e_mapi_object_contains_prop (object, PidTagBody);
-	build_related = !build_calendar && !build_alternative && inline_attachments;
+	build_related = !build_calendar && !build_alternative && inline_attachments
+		&& e_mapi_object_contains_prop (object, PidTagHtml);
+
+	if (!build_alternative && !build_related && inline_attachments) {
+		noninline_attachments = g_slist_concat (noninline_attachments, inline_attachments);
+		inline_attachments = NULL;
+	}
 
 	if (build_calendar) {
 		g_return_val_if_fail (ical_string != NULL, msg);



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