* src/modest-formatter.c
[modest] / src / modest-formatter.c
index f055b0a..932c99c 100644 (file)
@@ -32,8 +32,7 @@
 #include <tny-header.h>
 #include <tny-simple-list.h>
 #include <tny-gtk-text-buffer-stream.h>
-#include <tny-camel-stream.h>
-#include <camel/camel-stream-mem.h>
+#include <tny-camel-mem-stream.h>
 #include "modest-formatter.h"
 #include "modest-text-utils.h"
 #include "modest-tny-platform-factory.h"
@@ -76,7 +75,7 @@ extract_text (ModestFormatter *self, TnyMimePart *body)
        buf = gtk_text_buffer_new (NULL);
        stream = TNY_STREAM (tny_gtk_text_buffer_stream_new (buf));
        tny_stream_reset (stream);
-       tny_mime_part_decode_to_stream (body, stream);
+       tny_mime_part_decode_to_stream (body, stream, NULL);
        tny_stream_reset (stream);
 
        g_object_unref (G_OBJECT(stream));
@@ -108,13 +107,12 @@ construct_from_text (TnyMimePart *part,
        TnyStream *text_body_stream;
 
        /* Create the stream */
-       text_body_stream = TNY_STREAM (tny_camel_stream_new
-                                      (camel_stream_mem_new_with_buffer
-                                       (text, strlen(text))));
+       text_body_stream = TNY_STREAM (tny_camel_mem_stream_new_with_buffer
+                                       (text, strlen(text)));
 
        /* Construct MIME part */
        tny_stream_reset (text_body_stream);
-       tny_mime_part_construct_from_stream (part, text_body_stream, content_type);
+       tny_mime_part_construct (part, text_body_stream, content_type, "7bit");
        tny_stream_reset (text_body_stream);
 
        /* Clean */
@@ -179,9 +177,7 @@ modest_formatter_attach (ModestFormatter *self, TnyMsg *msg, TnyHeader *header)
        TnyMsg *new_msg = NULL;
        TnyMimePart *body_part = NULL;
        ModestFormatterPrivate *priv;
-       TnyPlatformFactory *fact;
 
-       fact = modest_runtime_get_platform_factory ();
        /* Build new part */
        new_msg     = modest_formatter_create_message (self, TRUE, TRUE, FALSE);
        body_part = modest_formatter_create_body_part (self, new_msg);
@@ -191,8 +187,10 @@ modest_formatter_attach (ModestFormatter *self, TnyMsg *msg, TnyHeader *header)
        construct_from_text (body_part, "", priv->content_type);
        g_object_unref (body_part);
 
-       /* Add parts */
-       tny_mime_part_add_part (TNY_MIME_PART (new_msg), TNY_MIME_PART (msg));
+       if (msg) {
+               /* Add parts */
+               tny_mime_part_add_part (TNY_MIME_PART (new_msg), TNY_MIME_PART (msg));
+       }
 
        return new_msg;
 }