From: Dirk-Jan C. Binnema Date: Fri, 4 Jan 2008 13:53:21 +0000 (+0000) Subject: * show the right body part for the message (this partly fixes NB#78955) X-Git-Tag: git_migration_finished~1864 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=1efb1db9e17b7fadca699f0f3722282a65d7b0b5 * show the right body part for the message (this partly fixes NB#78955) by excluding any parts with some Content-Disposition to be 'body-candidates' * rename modest_tny_msg_get_header into the better modest_tny_mime_part_get_header_value pmo-trunk-r3979 --- diff --git a/src/modest-tny-msg.c b/src/modest-tny-msg.c index 943f4bc..ef0cb28 100644 --- a/src/modest-tny-msg.c +++ b/src/modest-tny-msg.c @@ -409,7 +409,9 @@ modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_ht } else { do { gchar *content_type = NULL; - + gchar *content_disp; + gboolean has_content_disp; + part = TNY_MIME_PART(tny_iterator_get_current (iter)); if (!part) { @@ -422,15 +424,21 @@ modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_ht g_object_unref (part); tny_iterator_next (iter); continue; - } - + } /* we need to strdown the content type, because * tny_mime_part_has_content_type does not do it... */ content_type = g_ascii_strdown (tny_mime_part_get_content_type (part), -1); - - if (g_str_has_prefix (content_type, desired_mime_type) && !tny_mime_part_is_attachment (part)) { + + /* mime-parts with a content-disposition header (either 'inline' or 'attachment') + * cannot be body parts + */ + content_disp = modest_tny_mime_part_get_header_value (part, "Content-Disposition"); + has_content_disp = content_disp && strlen (content_disp) != 0; + g_free (content_disp); + + if (g_str_has_prefix (content_type, desired_mime_type) && !has_content_disp) { /* we found the desired mime-type! */ g_free (content_type); break; @@ -628,18 +636,18 @@ modest_tny_msg_create_forward_msg (TnyMsg *msg, gchar* -modest_tny_msg_get_header (TnyMsg *msg, const gchar *header) +modest_tny_mime_part_get_header_value (TnyMimePart *part, const gchar *header) { TnyList *pairs; TnyIterator *iter; gchar *val; - g_return_val_if_fail (msg && TNY_IS_MSG(msg), NULL); + g_return_val_if_fail (part && TNY_IS_MIME_PART(part), NULL); g_return_val_if_fail (header, NULL); pairs = tny_simple_list_new (); - - tny_mime_part_get_header_pairs (TNY_MIME_PART(msg), pairs); + + tny_mime_part_get_header_pairs (part, pairs); iter = tny_list_create_iterator (pairs); val = NULL; @@ -694,14 +702,16 @@ get_new_to (TnyMsg *msg, TnyHeader *header, const gchar* from, * for mailing lists, both the Reply-To: and From: should be included * in the new To:; for now, we're ignoring List-Post */ - gchar* list_help = modest_tny_msg_get_header (msg, "List-Help"); + gchar* list_help = modest_tny_mime_part_get_header_value (TNY_MIME_PART(msg), + "List-Help"); gboolean is_mailing_list = (list_help != NULL); g_free (list_help); /* reply to sender, use ReplyTo or From */ //old_reply_to = tny_header_get_replyto (header); - old_reply_to = modest_tny_msg_get_header (msg, "Reply-To"); + old_reply_to = modest_tny_mime_part_get_header_value (TNY_MIME_PART(msg), + "Reply-To"); old_from = tny_header_get_from (header); if (!old_from && !old_reply_to) { diff --git a/src/modest-tny-msg.h b/src/modest-tny-msg.h index f83eb2f..d24af7d 100644 --- a/src/modest-tny-msg.h +++ b/src/modest-tny-msg.h @@ -130,16 +130,18 @@ gchar* modest_tny_msg_get_body (TnyMsg *self, gboolean want_html, /** - * modest_tny_msg_get_header: - * @self: some #TnyMsg - * @header: the header to get + * modest_tny_mime_part_get_header_value: + * @self: some #TnyMimePart + * @header: the header to get the value for * - * gets the mail header for a #TnyMsg as a newly allocated string, + * gets the mail header value for a #TnyMimePart as a newly allocated string, * or NULL if it cannot be found * - * Returns: the header + * NOTE: this function should be part of tinymail, or maybe modest-tny-mime-part.... + * + * Returns: the header value or NULL **/ -gchar* modest_tny_msg_get_header (TnyMsg *msg, const gchar *header); +gchar* modest_tny_mime_part_get_header_value (TnyMimePart *part, const gchar *header); /**