+
+ part_to_check = modest_tny_msg_get_attachments_parent (TNY_MSG (msg));
+ msg_content_type = modest_tny_mime_part_get_content_type (TNY_MIME_PART (part_to_check));
+ is_alternate = (msg_content_type != NULL) && !strcasecmp (msg_content_type, "multipart/alternative");
+
+ /* If the top mime part is a multipart/related, we don't show the attachments, as they're
+ * embedded images in body */
+ if ((msg_content_type != NULL) && !strcasecmp (msg_content_type, "multipart/related")) {
+ gchar *header_content_type;
+ gboolean application_multipart = FALSE;
+
+ g_free (msg_content_type);
+
+ header_content_type = modest_tny_mime_part_get_headers_content_type (TNY_MIME_PART (part_to_check));
+
+ if ((header_content_type != NULL) &&
+ !strstr (header_content_type, "application/")) {
+ application_multipart = TRUE;
+ }
+ g_free (header_content_type);
+
+ if (application_multipart) {
+ gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
+ g_object_unref (part_to_check);
+ return;
+ }
+ } else {
+ gboolean direct_attach;
+
+ direct_attach = (!g_str_has_prefix (msg_content_type, "message/rfc822") &&
+ !g_str_has_prefix (msg_content_type, "multipart") &&
+ !g_str_has_prefix (msg_content_type, "text/"));
+
+ g_free (msg_content_type);
+
+ if (direct_attach) {
+ modest_attachments_view_add_attachment (attachments_view, TNY_MIME_PART (part_to_check), TRUE, 0);
+ gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
+ g_object_unref (part_to_check);
+ return;
+ }