* Fixes NB#95888, replaced a logical id by the new one
[modest] / src / modest-tny-msg.c
index 8137add..40ecc2f 100644 (file)
@@ -465,19 +465,14 @@ modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_ht
        /* no parts? assume it's single-part message */
        if (tny_iterator_is_done(iter)) {
                gchar *content_type;
-               gchar *content_type_lower;
                gboolean is_text_part;
                g_object_unref (G_OBJECT(iter));
-               content_type = g_strdup (tny_mime_part_get_content_type (msg));
+               content_type = modest_tny_mime_part_get_content_type (msg);
                if (content_type == NULL)
                        return NULL;
-               content_type = g_strstrip (content_type);
-               content_type_lower = g_ascii_strdown (content_type, -1);
-               g_free (content_type);
                is_text_part = 
-                       g_str_has_prefix (content_type_lower, "text/") ||
-                       g_str_has_prefix (content_type_lower, "message/rfc822");
-               g_free (content_type_lower);
+                       g_str_has_prefix (content_type, "text/");
+               g_free (content_type);
                /* if this part cannot be a supported body return NULL */
                if (!is_text_part) {
                        return NULL;
@@ -755,7 +750,7 @@ static gchar*
 get_new_to (TnyMsg *msg, TnyHeader *header, const gchar* from,
            ModestTnyMsgReplyMode reply_mode)
 {
-       const gchar* old_reply_to;
+       gchar* old_reply_to;
        gchar* old_from;
        gchar* new_to;
        
@@ -771,12 +766,11 @@ get_new_to (TnyMsg *msg, TnyHeader *header, const gchar* from,
 
 
        /* reply to sender, use ReplyTo or From */
-       //old_reply_to = tny_header_get_replyto (header);
        old_reply_to = modest_tny_mime_part_get_header_value (TNY_MIME_PART(msg), 
                                                              "Reply-To"); 
        old_from     = tny_header_dup_from (header);
        
-       if (!old_from &&  !old_reply_to) {
+       if (!old_from && !old_reply_to) {
                g_warning ("%s: failed to get either Reply-To: or From: from header",
                           __FUNCTION__);
                return NULL;
@@ -792,6 +786,7 @@ get_new_to (TnyMsg *msg, TnyHeader *header, const gchar* from,
                /* otherwise use either Reply-To: (preferred) or From: */
                new_to = g_strdup (old_reply_to ? old_reply_to : old_from);
        g_free (old_from);
+       g_free (old_reply_to);
 
        /* in case of ReplyAll, we need to add the Recipients in the old To: */
        if (reply_mode == MODEST_TNY_MSG_REPLY_MODE_ALL) {
@@ -962,3 +957,41 @@ modest_tny_msg_estimate_size (const gchar *plain_body, const gchar *html_body,
 
        return result;
 }
+
+GSList *
+modest_tny_msg_get_all_recipients_list (TnyMsg *msg)
+{
+       TnyHeader *header = NULL;
+       GSList *recipients = NULL;
+       gchar *from = NULL, *to = NULL, *cc = NULL, *bcc = NULL;
+
+       if (msg == NULL)
+               return NULL;
+
+       header = tny_msg_get_header (msg);
+       if (header == NULL)
+               return NULL;
+
+       from = tny_header_dup_from (header);
+       to = tny_header_dup_to (header);
+       cc = tny_header_dup_cc (header);
+       bcc = tny_header_dup_bcc (header);
+
+       recipients = NULL;
+       if (from)
+               recipients = g_slist_concat (recipients, modest_text_utils_split_addresses_list (from));
+       if (to)
+               recipients = g_slist_concat (recipients, modest_text_utils_split_addresses_list (to));
+       if (cc)
+               recipients = g_slist_concat (recipients, modest_text_utils_split_addresses_list (cc));
+       if (bcc)
+               recipients = g_slist_concat (recipients, modest_text_utils_split_addresses_list (bcc));
+
+       g_free (from);
+       g_free (to);
+       g_free (cc);
+       g_free (bcc);
+
+       return recipients;
+}
+