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
} else {
do {
gchar *content_type = NULL;
} else {
do {
gchar *content_type = NULL;
+ gchar *content_disp;
+ gboolean has_content_disp;
+
part = TNY_MIME_PART(tny_iterator_get_current (iter));
if (!part) {
part = TNY_MIME_PART(tny_iterator_get_current (iter));
if (!part) {
g_object_unref (part);
tny_iterator_next (iter);
continue;
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);
/* 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;
/* we found the desired mime-type! */
g_free (content_type);
break;
-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;
{
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 ();
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;
iter = tny_list_create_iterator (pairs);
val = NULL;
* for mailing lists, both the Reply-To: and From: should be included
* in the new To:; for now, we're ignoring List-Post
*/
* 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);
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) {
old_from = tny_header_get_from (header);
if (!old_from && !old_reply_to) {
- * 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
*
* or NULL if it cannot be found
*
+ * 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);