2007-06-11 Murray Cumming <murrayc@murrayc.com>
[modest] / src / modest-formatter.c
index a24f6b7..8fcbf0d 100644 (file)
 #include "modest-formatter.h"
 #include "modest-text-utils.h"
 #include "modest-tny-platform-factory.h"
+#include <modest-runtime.h>
 
 typedef struct _ModestFormatterPrivate ModestFormatterPrivate;
 struct _ModestFormatterPrivate {
        gchar *content_type;
+       gchar *signature;
 };
 #define MODEST_FORMATTER_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE((o), \
                                           MODEST_TYPE_FORMATTER, \
@@ -119,15 +121,13 @@ modest_formatter_do (ModestFormatter *self, TnyMimePart *body, TnyHeader *header
        TnyMsg *new_msg = NULL;
        gchar *body_text = NULL, *txt = NULL;
        ModestFormatterPrivate *priv;
-       TnyPlatformFactory *fact;
 
        g_return_val_if_fail (self, NULL);
        g_return_val_if_fail (header, NULL);
        g_return_val_if_fail (func, NULL);
 
        /* Build new part */
-       fact = modest_tny_platform_factory_get_instance ();
-       new_msg = tny_platform_factory_new_msg (fact);
+       new_msg = tny_platform_factory_new_msg (modest_runtime_get_platform_factory());
 
        if (body)
                body_text = extract_text (self, body);
@@ -173,7 +173,7 @@ modest_formatter_attach (ModestFormatter *self, TnyMimePart *body, TnyHeader *he
        ModestFormatterPrivate *priv;
        TnyPlatformFactory *fact;
 
-       fact = modest_tny_platform_factory_get_instance ();
+       fact = modest_runtime_get_platform_factory ();
        /* Build new part */
        new_msg     = tny_platform_factory_new_msg (fact);
        body_part   = tny_platform_factory_new_mime_part (fact);
@@ -198,7 +198,7 @@ modest_formatter_attach (ModestFormatter *self, TnyMimePart *body, TnyHeader *he
 }
 
 ModestFormatter*
-modest_formatter_new (const gchar *content_type)
+modest_formatter_new (const gchar *content_type, const gchar *signature)
 {
        ModestFormatter *formatter;
        ModestFormatterPrivate *priv;
@@ -206,6 +206,7 @@ modest_formatter_new (const gchar *content_type)
        formatter = g_object_new (MODEST_TYPE_FORMATTER, NULL);
        priv = MODEST_FORMATTER_GET_PRIVATE (formatter);
        priv->content_type = g_strdup (content_type);
+       priv->signature = g_strdup (signature);
 
        return formatter;
 }
@@ -228,6 +229,9 @@ modest_formatter_finalize (GObject *object)
        if (priv->content_type)
                g_free (priv->content_type);
 
+       if (priv->signature)
+               g_free (priv->signature);
+
        (*parent_class->finalize) (object);
 }
 
@@ -279,6 +283,7 @@ modest_formatter_wrapper_cite (ModestFormatter *self, const gchar *text, TnyHead
 
        return modest_text_utils_cite (text, 
                                       priv->content_type, 
+                                      priv->signature,
                                       tny_header_get_from (header), 
                                       tny_header_get_date_sent (header));
 }
@@ -290,6 +295,7 @@ modest_formatter_wrapper_inline (ModestFormatter *self, const gchar *text, TnyHe
 
        return modest_text_utils_inline (text, 
                                         priv->content_type, 
+                                        priv->signature,
                                         tny_header_get_from (header), 
                                         tny_header_get_date_sent (header),
                                         tny_header_get_to (header),
@@ -304,6 +310,7 @@ modest_formatter_wrapper_quote (ModestFormatter *self, const gchar *text, TnyHea
        /* TODO: get 80 from the configuration */
        return modest_text_utils_quote (text, 
                                        priv->content_type, 
+                                       priv->signature,
                                        tny_header_get_from (header), 
                                        tny_header_get_date_sent (header),
                                        80);