* revert of patches r3978 and r3979
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 4 Jan 2008 16:11:05 +0000 (16:11 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 4 Jan 2008 16:11:05 +0000 (16:11 +0000)
pmo-trunk-r3981

src/modest-tny-msg.c
src/modest-tny-msg.h
src/widgets/modest-attachments-view.c

index fb7e5a1..943f4bc 100644 (file)
@@ -409,9 +409,7 @@ modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_ht
        } 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) {
@@ -424,21 +422,15 @@ modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_ht
                                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);
-                       
-                       /* 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) {
+
+                       if (g_str_has_prefix (content_type, desired_mime_type) && !tny_mime_part_is_attachment (part)) {
                                /* we found the desired mime-type! */
                                g_free (content_type);
                                break;
                                /* we found the desired mime-type! */
                                g_free (content_type);
                                break;
@@ -636,18 +628,18 @@ modest_tny_msg_create_forward_msg (TnyMsg *msg,
 
 
 gchar*
 
 
 gchar*
-modest_tny_mime_part_get_header_value (TnyMimePart *part, const gchar *header)
+modest_tny_msg_get_header (TnyMsg *msg, const gchar *header)
 {
        TnyList *pairs;
        TnyIterator *iter;
        gchar *val;
        
 {
        TnyList *pairs;
        TnyIterator *iter;
        gchar *val;
        
-       g_return_val_if_fail (part && TNY_IS_MIME_PART(part), NULL);
+       g_return_val_if_fail (msg && TNY_IS_MSG(msg), 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 (part, pairs);
+
+       tny_mime_part_get_header_pairs (TNY_MIME_PART(msg), pairs);
        iter = tny_list_create_iterator (pairs);
 
        val = NULL;
        iter = tny_list_create_iterator (pairs);
 
        val = NULL;
@@ -668,57 +660,6 @@ modest_tny_mime_part_get_header_value (TnyMimePart *part, const gchar *header)
 }
 
 
 }
 
 
-/* we consider more things attachments than tinymail does...
- */
-gboolean
-modest_tny_mime_part_is_attachment_for_modest (TnyMimePart *part)
-{
-       gchar *content_disp;
-       gchar *content_type;
-       gboolean has_content_disp;
-
-       g_return_val_if_fail (part && TNY_IS_MIME_PART(part), FALSE);
-       
-       /* if tinymail thinks it's an attachment, it definitely is */
-       if (tny_mime_part_is_attachment (part))
-               return TRUE; 
-
-       /* if the mime part is a message itself (ie. embedded), it's an attachment */
-       if (TNY_IS_MSG (part))
-               return TRUE;
-
-       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 it doesn't have a content deposition, it's not an attachment */
-       if (!content_disp)
-               return FALSE;
-       
-       /* ok, it must be content-disposition "inline" then, because "attachment"
-        * is already handle above "...is_attachment". modest consider these "inline" things
-         * attachments as well, unless they are embedded images for html mail 
-        */
-       content_type = g_ascii_strdown (tny_mime_part_get_content_type (part), -1);
-       if (!g_str_has_prefix (content_type, "image/")) {
-               g_free (content_type);
-               return TRUE; /* it's not an image, so it must be an attachment */
-       }
-       g_free (content_type);
-
-
-       /* now, if it's an inline-image, and it has a content-id or location, we
-        * we guess it's an inline image, and not an attachment */
-       if (tny_mime_part_get_content_id (part) || tny_mime_part_get_content_location(part))
-               return FALSE;
-               
-       /* in other cases... */
-       return TRUE;
-}
-
-
-
-
 static gint
 count_addresses (const gchar* addresses)
 {
 static gint
 count_addresses (const gchar* addresses)
 {
@@ -753,16 +694,14 @@ 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
         */
         * 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_mime_part_get_header_value (TNY_MIME_PART(msg), 
-                                                                 "List-Help");
+       gchar* list_help = modest_tny_msg_get_header (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_mime_part_get_header_value (TNY_MIME_PART(msg), 
-                                                             "Reply-To"); 
+       old_reply_to = modest_tny_msg_get_header (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) {
index 09eeaa3..f83eb2f 100644 (file)
@@ -130,33 +130,16 @@ gchar*        modest_tny_msg_get_body        (TnyMsg *self, gboolean want_html,
 
 
 /**
 
 
 /**
- * modest_tny_mime_part_get_header_value:
- * @self: some #TnyMimePart
- * @header: the header to get the value for
+ * modest_tny_msg_get_header:
+ * @self: some #TnyMsg 
+ * @header: the header to get
  * 
  * 
- * gets the mail header value for a #TnyMimePart as a newly allocated string,
+ * gets the mail header for a #TnyMsg 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_mime_part_get_header_value (TnyMimePart *part, const gchar *header);
-
-
-/**
- * modest_tny_mime_part_is_attachment_for_modest:
- * @self: some #TnyMimePart
- *
- * determine whether the given mime part is an attachment; note modest considers
- * more things attachments than tinymail does; in particular, modest considers
- * non-image 'inline' things to be attachments; check the source for details
- * 
- * NOTE: this function should maybe in modest-tny-mime-part....
- *
- * Returns: TRUE if it's attachment for modest, or FALSE otherwise
+ * Returns: the header
  **/
  **/
-gboolean     modest_tny_mime_part_is_attachment_for_modest (TnyMimePart *part);
+gchar*       modest_tny_msg_get_header (TnyMsg *msg, const gchar *header);
 
 
 /**
 
 
 /**
index 0f11592..22d3b05 100644 (file)
@@ -39,7 +39,6 @@
 
 #include <modest-platform.h>
 #include <modest-runtime.h>
 
 #include <modest-platform.h>
 #include <modest-runtime.h>
-#include <modest-tny-msg.h>
 #include <modest-attachment-view.h>
 #include <modest-attachments-view.h>
 
 #include <modest-attachment-view.h>
 #include <modest-attachments-view.h>
 
@@ -102,10 +101,6 @@ modest_attachments_view_new (TnyMsg *msg)
        return GTK_WIDGET (self);
 }
 
        return GTK_WIDGET (self);
 }
 
-
-
-
-
 void
 modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, TnyMsg *msg)
 {
 void
 modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, TnyMsg *msg)
 {
@@ -140,6 +135,7 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
                return;
        }
 
                return;
        }
 
+       
        parts = TNY_LIST (tny_simple_list_new ());
        tny_mime_part_get_parts (TNY_MIME_PART (priv->msg), parts);
        iter = tny_list_create_iterator (parts);
        parts = TNY_LIST (tny_simple_list_new ());
        tny_mime_part_get_parts (TNY_MIME_PART (priv->msg), parts);
        iter = tny_list_create_iterator (parts);
@@ -148,7 +144,7 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
                TnyMimePart *part;
 
                part = TNY_MIME_PART (tny_iterator_get_current (iter));
                TnyMimePart *part;
 
                part = TNY_MIME_PART (tny_iterator_get_current (iter));
-               if (part && modest_tny_mime_part_is_attachment_for_modest(part)) {
+               if (part && (tny_mime_part_is_attachment (part) || TNY_IS_MSG (part))) {
                        modest_attachments_view_add_attachment (attachments_view, part);
                }
 
                        modest_attachments_view_add_attachment (attachments_view, part);
                }
 
@@ -159,7 +155,7 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
        }
 
        gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
        }
 
        gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
-       
+
 }
 
 void
 }
 
 void