* Added a new account key called type for server accounts
[modest] / src / modest-formatter.c
index 2e175a6..7a23329 100644 (file)
 #include <glib/gi18n.h>
 #include <string.h>
 #include <tny-header.h>
+#include <tny-gtk-text-buffer-stream.h>
+#include <tny-camel-stream.h>
+#include <camel/camel-stream-mem.h>
 #include "modest-formatter.h"
 #include "modest-text-utils.h"
+#include "modest-tny-platform-factory.h"
 
 typedef struct _ModestFormatterPrivate ModestFormatterPrivate;
 struct _ModestFormatterPrivate {
@@ -83,7 +87,8 @@ extract_text (ModestFormatter *self, TnyMimePart *body)
        if (strcmp (tny_mime_part_get_content_type (body), priv->content_type)) {
                if (!strcmp (priv->content_type, "text/html"))
                        converted_text = modest_text_utils_convert_to_html  (text);
-/*             else */
+               else
+                       converted_text = g_strdup (text);
 /*                     converted_text = modest_text_utils_convert_to_plain (text); */
 
                g_free (text);
@@ -123,9 +128,16 @@ modest_formatter_do (ModestFormatter *self,
        TnyMsg *new_msg;
        gchar *body_text = NULL, *txt = NULL;
        ModestFormatterPrivate *priv;
+       TnyPlatformFactory *fact;
+
+       g_return_val_if_fail (self, NULL);
+       g_return_val_if_fail (body, NULL);
+       g_return_val_if_fail (header, NULL);
+       g_return_val_if_fail (func, NULL);
 
        /* Build new part */
-       new_msg = TNY_MSG (tny_camel_msg_new ());
+       fact = modest_tny_platform_factory_get_instance ();
+       new_msg = tny_platform_factory_new_msg (fact);
        body_text = extract_text (self, body);
        txt = (gchar *) func (self, (const gchar*) body_text, header);
        priv = MODEST_FORMATTER_GET_PRIVATE (self);
@@ -141,19 +153,19 @@ modest_formatter_do (ModestFormatter *self,
 TnyMsg *
 modest_formatter_cite (ModestFormatter *self, TnyMimePart *body, TnyHeader *header)
 {
-       modest_formatter_do (self, body, header, modest_formatter_wrapper_cite);
+       return modest_formatter_do (self, body, header, modest_formatter_wrapper_cite);
 }
 
 TnyMsg *
 modest_formatter_quote (ModestFormatter *self, TnyMimePart *body, TnyHeader *header)
 {
-       modest_formatter_do (self, body, header, modest_formatter_wrapper_quote);
+       return modest_formatter_do (self, body, header, modest_formatter_wrapper_quote);
 }
 
 TnyMsg *
 modest_formatter_inline (ModestFormatter *self, TnyMimePart *body, TnyHeader *header)
 {
-       modest_formatter_do (self, body, header, modest_formatter_wrapper_inline);
+       return modest_formatter_do (self, body, header, modest_formatter_wrapper_inline);
 }
 
 TnyMsg *
@@ -163,11 +175,13 @@ modest_formatter_attach (ModestFormatter *self, TnyMimePart *body, TnyHeader *he
        gchar *attach_text = NULL;
        TnyMimePart *body_part = NULL, *attach_part = NULL;
        ModestFormatterPrivate *priv;
+       TnyPlatformFactory *fact;
 
+       fact = modest_tny_platform_factory_get_instance ();
        /* Build new part */
-       new_msg     = TNY_MSG (tny_camel_msg_new ());
-       body_part   = TNY_MIME_PART (tny_camel_mime_part_new (camel_mime_part_new()));
-       attach_part = TNY_MIME_PART (tny_camel_mime_part_new (camel_mime_part_new()));
+       new_msg     = tny_platform_factory_new_msg (fact);
+       body_part   = tny_platform_factory_new_mime_part (fact);
+       attach_part = tny_platform_factory_new_mime_part (fact);
 
        /* Create the two parts */
        priv = MODEST_FORMATTER_GET_PRIVATE (self);
@@ -227,7 +241,8 @@ modest_formatter_class_init (ModestFormatterClass *class)
 
        parent_class = g_type_class_peek_parent (class);
        object_class = (GObjectClass*) class;
-   
+       object_class->finalize = modest_formatter_finalize;
+
        g_type_class_add_private (object_class, sizeof (ModestFormatterPrivate));
 }