* cleanups, updates because of Tinymail changes
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Mon, 7 Aug 2006 12:28:33 +0000 (12:28 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Mon, 7 Aug 2006 12:28:33 +0000 (12:28 +0000)
pmo-trunk-r455

src/modest-tny-msg-actions.c
src/modest-tny-msg-actions.h
src/modest-tny-store-actions.c
src/modest-tny-transport-actions.c

index 2d60cd8..60b3efc 100644 (file)
 
 #include <gtk/gtk.h>
 #include <gtkhtml/gtkhtml.h>
-
-/* TODO: put in auto* */
 #include <tny-text-buffer-stream.h>
-#include <tny-msg-mime-part-iface.h>
+#include <tny-mime-part-iface.h>
 #include <tny-msg-iface.h>
 #include <tny-list-iface.h>
+#include <tny-list.h>
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #include "modest-tny-msg-actions.h"
 #include "modest-text-utils.h"
 
-
-/* private */
-static gchar *quote_msg (const TnyMsgIface * src, const gchar * from,
-                        time_t sent_date, gint limit);
-
 static gchar *
-quote_msg (const TnyMsgIface * src, const gchar * from, time_t sent_date, gint limit)
+quote_msg (TnyMsgIface* src, const gchar * from, time_t sent_date, gint limit)
 {
        TnyStreamIface *stream;
-       TnyMsgMimePartIface *body;
+       TnyMimePartIface *body;
        GtkTextBuffer *buf;
        GtkTextIter start, end;
        const gchar *to_quote;
        gchar *quoted;
 
-       /* the cast makes me uneasy... */
        body = modest_tny_msg_actions_find_body_part(src, FALSE);
        if (!body)
                return NULL;
@@ -67,9 +60,11 @@ quote_msg (const TnyMsgIface * src, const gchar * from, time_t sent_date, gint l
        buf = gtk_text_buffer_new (NULL);
        stream = TNY_STREAM_IFACE (tny_text_buffer_stream_new (buf));
        tny_stream_iface_reset (stream);
-       tny_msg_mime_part_iface_decode_to_stream (body, stream);
+       tny_mime_part_iface_decode_to_stream (body, stream);
        tny_stream_iface_reset (stream);
-       g_object_unref (stream);
+
+       g_object_unref (G_OBJECT(stream));
+       g_object_unref (G_OBJECT(body));
        
        gtk_text_buffer_get_bounds (buf, &start, &end);
        to_quote = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
@@ -81,7 +76,7 @@ quote_msg (const TnyMsgIface * src, const gchar * from, time_t sent_date, gint l
 
 
 gchar*
-modest_tny_msg_actions_quote (const TnyMsgIface * self, const gchar * from,
+modest_tny_msg_actions_quote (TnyMsgIface * self, const gchar * from,
                              time_t sent_date, gint limit,
                              const gchar * to_quote)
 {
@@ -98,66 +93,72 @@ modest_tny_msg_actions_quote (const TnyMsgIface * self, const gchar * from,
 
 
 
-TnyMsgMimePartIface *
-modest_tny_msg_actions_find_body_part (const TnyMsgIface *msg, gboolean want_html)
+TnyMimePartIface *
+modest_tny_msg_actions_find_body_part (TnyMsgIface *msg, gboolean want_html)
 {
        const gchar *mime_type = want_html ? "text/html" : "text/plain";
-       TnyMsgMimePartIface *part;
-       const TnyListIface *parts;
+       TnyMimePartIface *part;
+       TnyListIface *parts;
        TnyIteratorIface *iter;
-       gboolean found;
 
        if (!msg)
                return NULL;
 
-       found = FALSE;
-       parts =  tny_msg_iface_get_parts ((TnyMsgIface *)msg);
-       iter  = tny_list_iface_create_iterator ((TnyListIface*)parts);
+       parts = TNY_LIST_IFACE(tny_list_new());
+       tny_msg_iface_get_parts ((TnyMsgIface*)msg, parts);
+
+       iter  = tny_list_iface_create_iterator(parts);
 
        while (!tny_iterator_iface_is_done(iter)) {
-               part = TNY_MSG_MIME_PART_IFACE(tny_iterator_iface_current (iter));
+
+               part = TNY_MIME_PART_IFACE(tny_iterator_iface_current (iter));
                
-               if (tny_msg_mime_part_iface_content_type_is (part, mime_type) &&
-                   !tny_msg_mime_part_iface_is_attachment (part)) {
-                       found = TRUE;
+               if (tny_mime_part_iface_content_type_is (part, mime_type) &&
+                   !tny_mime_part_iface_is_attachment (part)) {
                        break;
-               }       
+               }
+               part = NULL;
                tny_iterator_iface_next (iter);
        }
 
+       /* did we find a matching part? */
+       if (part)
+               g_object_ref (G_OBJECT(part));
+
        g_object_unref (G_OBJECT(iter));
+       g_object_unref (G_OBJECT(parts));
 
-       /* if were trying to find an HTML part and could find it,
+       /* if were trying to find an HTML part and couldn't find it,
         * try to find a text/plain part instead
         */
-       if (!found && want_html) 
+       if (!part && want_html) 
                return modest_tny_msg_actions_find_body_part (msg, FALSE);
 
-       return found ? part : NULL;
+       return part ? part : NULL;
 }
 
 
 
-
-TnyMsgMimePartIface *
-modest_tny_msg_actions_find_nth_part (const TnyMsgIface *msg, gint index)
+TnyMimePartIface *
+modest_tny_msg_actions_find_nth_part (TnyMsgIface *msg, gint index)
 {
-       TnyMsgMimePartIface *part;
-       const TnyListIface *parts;
+       TnyMimePartIface *part;
+       TnyListIface *parts;
        TnyIteratorIface *iter;
 
        g_return_val_if_fail (msg, NULL);
        g_return_val_if_fail (index > 0, NULL);
                
-       parts =  tny_msg_iface_get_parts ((TnyMsgIface *)msg);
+       parts = TNY_LIST_IFACE(tny_list_new());
+       tny_msg_iface_get_parts ((TnyMsgIface*)msg, parts);
        iter  = tny_list_iface_create_iterator ((TnyListIface*)parts);
-
        if (!tny_iterator_iface_has_first(iter))
                return NULL;
 
-       part = tny_iterator_iface_nth (iter, index);
+       part = TNY_MIME_PART_IFACE(tny_iterator_iface_nth (iter, index));
 
        g_object_unref (G_OBJECT(iter));
+       g_object_unref (G_OBJECT(parts));
 
        return part;
 }
index cc62fb8..65c6d88 100644 (file)
@@ -30,8 +30,6 @@
 #ifndef __MODEST_TNY_MSG_ACTIONS_H__
 #define __MODEST_TNY_MSG_ACTIONS_H__
 
-/* public */
-
 /**
  * modest_tny_msg_actions_quote:
  * @self: the message to quote
  * 
  * Returns: a newly allocated string containing the quoted message
  */
-gchar *modest_tny_msg_actions_quote (const TnyMsgIface * self,
-                                    const gchar * from,
-                                    time_t sent_date,
-                                    gint limit,
+gchar *modest_tny_msg_actions_quote (TnyMsgIface * self, const gchar * from,
+                                    time_t sent_date, gint limit,
                                     const gchar *to_quote);
 
 /**
@@ -62,8 +58,7 @@ gchar *modest_tny_msg_actions_quote (const TnyMsgIface * self,
  * 
  * Returns: the TnyMsgMimePartIface for the found part, or NULL if no matching part is found
  */     
-TnyMsgMimePartIface *modest_tny_msg_actions_find_body_part (const TnyMsgIface * self,
-                                                           gboolean want_html);
+TnyMimePartIface *modest_tny_msg_actions_find_body_part (TnyMsgIface * self, gboolean want_html);
 
 
 /**
@@ -75,8 +70,7 @@ TnyMsgMimePartIface *modest_tny_msg_actions_find_body_part (const TnyMsgIface *
  * 
  * Returns: the TnyMsgMimePartIface for the found part, or NULL if no matching part is found
  */
-TnyMsgMimePartIface * modest_tny_msg_actions_find_nth_part (const TnyMsgIface *msg,
-                                                          gint index);
+TnyMimePartIface * modest_tny_msg_actions_find_nth_part (TnyMsgIface *msg, gint index);
 
 
 #endif /* __MODEST_TNY_MSG_ACTIONS_H__ */
index 208e7ff..605d397 100644 (file)
@@ -29,8 +29,8 @@
 
 #include <tny-msg.h>
 #include <tny-msg-iface.h>                     
-#include <tny-msg-header.h>
-#include <tny-msg-header-iface.h>
+#include <tny-header.h>
+#include <tny-header-iface.h>
 #include <tny-account-iface.h> 
 #include <tny-account-store-iface.h>
 #include <tny-store-account-iface.h>   
index d12f2d7..955ff1d 100644 (file)
 
 #include <tny-msg.h>
 #include <tny-msg-iface.h>                     
-#include <tny-msg-mime-part.h>
-#include <tny-msg-mime-part-iface.h>           
+#include <tny-mime-part.h>
+#include <tny-mime-part-iface.h>               
 #include <tny-stream-iface.h>
-#include <tny-msg-header.h>
-#include <tny-msg-header-iface.h>
+#include <tny-header.h>
+#include <tny-header-iface.h>
 #include <tny-account-iface.h> 
 #include <tny-account-store-iface.h>
 #include <tny-transport-account-iface.h>       
@@ -186,8 +186,8 @@ modest_tny_transport_actions_send_message (ModestTnyTransportActions *self,
                                           const GList *attachments_list)
 {
        TnyMsgIface *new_msg;
-       TnyMsgMimePartIface *attachment_part, *text_body_part;
-       TnyMsgHeaderIface *headers;
+       TnyMimePartIface *attachment_part, *text_body_part;
+       TnyHeaderIface *headers;
        TnyStreamIface *text_body_stream, *attachment_stream;
        ModestTnyAttachment *attachment;
        GList *pos;
@@ -196,33 +196,32 @@ modest_tny_transport_actions_send_message (ModestTnyTransportActions *self,
        const gchar *attachment_filename;
        
        new_msg          = TNY_MSG_IFACE(tny_msg_new ());
-       headers          = TNY_MSG_HEADER_IFACE(tny_msg_header_new ());
+       headers          = TNY_HEADER_IFACE(tny_header_new ());
        text_body_stream = TNY_STREAM_IFACE (tny_stream_camel_new
                                             (camel_stream_mem_new_with_buffer
                                              (body, strlen(body))));
        
-       tny_msg_header_iface_set_from (TNY_MSG_HEADER_IFACE (headers), from);
-       tny_msg_header_iface_set_to (TNY_MSG_HEADER_IFACE (headers), to);
-       tny_msg_header_iface_set_cc (TNY_MSG_HEADER_IFACE (headers), cc);
-       tny_msg_header_iface_set_bcc (TNY_MSG_HEADER_IFACE (headers), bcc);
-       tny_msg_header_iface_set_subject (TNY_MSG_HEADER_IFACE (headers), subject);
+       tny_header_iface_set_from (TNY_HEADER_IFACE (headers), from);
+       tny_header_iface_set_to (TNY_HEADER_IFACE (headers), to);
+       tny_header_iface_set_cc (TNY_HEADER_IFACE (headers), cc);
+       tny_header_iface_set_bcc (TNY_HEADER_IFACE (headers), bcc);
+       tny_header_iface_set_subject (TNY_HEADER_IFACE (headers), subject);
        tny_msg_iface_set_header (new_msg, headers);
 
-       
        content_type = get_content_type(body);
        
        if (attachments_list == NULL) {
                tny_stream_iface_reset (text_body_stream);
-               tny_msg_mime_part_iface_construct_from_stream (TNY_MSG_MIME_PART_IFACE(new_msg),
-                                                              text_body_stream, content_type);
+               tny_mime_part_iface_construct_from_stream (TNY_MIME_PART_IFACE(new_msg),
+                                                          text_body_stream, content_type);
                tny_stream_iface_reset (text_body_stream);
        } else {
-               text_body_part = TNY_MSG_MIME_PART_IFACE (tny_msg_mime_part_new(
-                                                         camel_mime_part_new()));
+               text_body_part = 
+                       TNY_MIME_PART_IFACE (tny_mime_part_new(camel_mime_part_new()));
                tny_stream_iface_reset (text_body_stream);
-               tny_msg_mime_part_iface_construct_from_stream (text_body_part,
-                                                              text_body_stream,
-                                                              content_type);
+               tny_mime_part_iface_construct_from_stream (text_body_part,
+                                                          text_body_stream,
+                                                          content_type);
                tny_stream_iface_reset (text_body_stream);
                tny_msg_iface_add_part(new_msg, text_body_part);
                //g_object_unref (G_OBJECT(text_body_part));
@@ -234,17 +233,17 @@ modest_tny_transport_actions_send_message (ModestTnyTransportActions *self,
                attachment = pos->data;
                attachment_filename = modest_tny_attachment_get_name(attachment);
                attachment_stream = modest_tny_attachment_get_stream(attachment);
-               attachment_part = TNY_MSG_MIME_PART_IFACE (tny_msg_mime_part_new (
-                                                               camel_mime_part_new()));
+               attachment_part = TNY_MIME_PART_IFACE (tny_mime_part_new (
+                                                              camel_mime_part_new()));
                
                attachment_content_type = modest_tny_attachment_get_mime_type(attachment);
                                 
-               tny_msg_mime_part_iface_construct_from_stream (attachment_part,
+               tny_mime_part_iface_construct_from_stream (attachment_part,
                                                               attachment_stream,
                                                               attachment_content_type);
                tny_stream_iface_reset (attachment_stream);
                
-               tny_msg_mime_part_iface_set_filename(attachment_part, attachment_filename);
+               tny_mime_part_iface_set_filename(attachment_part, attachment_filename);
                
                tny_msg_iface_add_part (new_msg, attachment_part);
                //g_object_unref(G_OBJECT(attachment_part));