modest-tny-account.h\
modest-tny-folder.c \
modest-tny-folder.h \
- modest-tny-msg-actions.c\
- modest-tny-msg-actions.h\
+ modest-tny-msg.c\
+ modest-tny-msg.h\
modest-tny-platform-factory.c \
modest-tny-platform-factory.h \
modest-tny-send-queue.c\
#include <tny-simple-list.h>
#include <modest-conf.h>
#include <modest-runtime.h>
-
-#include "modest-account-mgr.h"
-#include "modest-account-mgr-helpers.h"
-#include "modest-edit-msg-window.h"
-#include "modest-edit-msg-window-ui.h"
-#include "modest-icon-names.h"
-#include "modest-icon-factory.h"
-#include "modest-mail-operation.h"
-#include "modest-text-utils.h"
-#include "modest-tny-platform-factory.h"
-#include "modest-tny-msg-actions.h"
-#include "modest-ui-actions.h"
-#include "modest-widget-memory.h"
-#include "modest-window-priv.h"
+#include <modest-tny-msg.h>
+#include <modest-window-priv.h>
+#include <modest-edit-msg-window.h>
+#include <modest-widget-memory.h>
+#include <widgets/modest-edit-msg-window-ui.h>
+#include <modest-icon-factory.h>
+#include <modest-account-mgr-helpers.h>
static void modest_edit_msg_window_class_init (ModestEditMsgWindowClass *klass);
static void modest_edit_msg_window_init (ModestEditMsgWindow *obj);
GtkTextBuffer *buf;
const gchar *to, *cc, *bcc, *subject;
ModestEditMsgWindowPrivate *priv;
-
+ gchar *body;
+
g_return_if_fail (MODEST_IS_EDIT_MSG_WINDOW (self));
g_return_if_fail (TNY_IS_MSG (msg));
if (subject)
gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject);
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(priv->msg_body));
- gtk_text_buffer_set_text (buf,
- (const gchar *) modest_tny_msg_actions_find_body (msg, FALSE),
- -1);
-
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(priv->msg_body));
+ body = modest_tny_msg_get_body (msg, FALSE);
+ if (body)
+ gtk_text_buffer_set_text (buf, body, -1);
+ g_free (body);
+
/* TODO: lower priority, select in the From: combo to the
value that comes from msg <- not sure, should it be
allowed? */
#include "modest-account-mgr.h"
#include "modest-conf.h"
#include "modest-edit-msg-window.h"
-#include "modest-tny-msg-actions.h"
+#include <modest-tny-msg.h>
#include "modest-mail-operation.h"
#include "modest-icon-names.h"
typedef gchar* FormatterFunc (ModestFormatter *self, const gchar *text, TnyHeader *header);
-static TnyMsg *modest_formatter_do (ModestFormatter *self,
- TnyMimePart *body,
- TnyHeader *header,
+static TnyMsg *modest_formatter_do (ModestFormatter *self, TnyMimePart *body, TnyHeader *header,
FormatterFunc func);
static gchar* modest_formatter_wrapper_cite (ModestFormatter *self, const gchar *text, TnyHeader *header);
tny_stream_reset (stream);
g_object_unref (G_OBJECT(stream));
- g_object_unref (G_OBJECT(body));
gtk_text_buffer_get_bounds (buf, &start, &end);
text = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
- g_object_unref (buf);
+ g_object_unref (G_OBJECT(buf));
/* Convert to desired content type if needed */
priv = MODEST_FORMATTER_GET_PRIVATE (self);
- if (strcmp (tny_mime_part_get_content_type (body), priv->content_type)) {
+ if (strcmp (tny_mime_part_get_content_type (body), priv->content_type) == 0) {
if (!strcmp (priv->content_type, "text/html"))
converted_text = modest_text_utils_convert_to_html (text);
else
converted_text = g_strdup (text);
-/* converted_text = modest_text_utils_convert_to_plain (text); */
g_free (text);
text = converted_text;
}
-
return text;
}
}
static TnyMsg *
-modest_formatter_do (ModestFormatter *self,
- TnyMimePart *body,
- TnyHeader *header,
- FormatterFunc func)
+modest_formatter_do (ModestFormatter *self, TnyMimePart *body, TnyHeader *header, FormatterFunc func)
{
TnyMsg *new_msg = NULL;
gchar *body_text = NULL, *txt = NULL;
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 */
fact = modest_tny_platform_factory_get_instance ();
new_msg = tny_platform_factory_new_msg (fact);
- body_text = extract_text (self, body);
+
+ if (body)
+ body_text = extract_text (self, body);
+ else
+ body_text = g_strdup ("");
+
txt = (gchar *) func (self, (const gchar*) body_text, header);
priv = MODEST_FORMATTER_GET_PRIVATE (self);
construct_from_text (TNY_MIME_PART (new_msg), (const gchar*) txt, priv->content_type);
#include <glib/gi18n.h>
#include <modest-tny-account.h>
#include "modest-text-utils.h"
-#include "modest-tny-msg-actions.h"
+#include "modest-tny-msg.h"
#include "modest-tny-platform-factory.h"
#include "modest-marshal.h"
#include "modest-formatter.h"
/* Get body from original msg. Always look for the text/plain
part of the message to create the reply/forwarded mail */
header = tny_msg_get_header (msg);
- body = modest_tny_msg_actions_find_body_part (msg, FALSE);
+ body = modest_tny_msg_find_body_part (msg, FALSE);
/* TODO: select the formatter from account prefs */
formatter = modest_formatter_new ("text/plain");
break;
}
}
- g_object_unref (G_OBJECT (formatter));
-
+ g_object_unref (G_OBJECT(formatter));
+ g_object_unref (G_OBJECT(body));
+
/* Fill the header */
fact = modest_tny_platform_factory_get_instance ();
new_header = TNY_HEADER (tny_platform_factory_new_header (fact));
} else {
do {
breakpoint =
- get_breakpoint (remaining-> str,
+ get_breakpoint (remaining->str,
rem_indent,
limit);
append_quoted (q, rem_indent,
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Nokia Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <gtkhtml/gtkhtml.h>
-#include <tny-gtk-text-buffer-stream.h>
-#include <tny-simple-list.h>
-#include <tny-folder.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /*HAVE_CONFIG_H */
-
-#include "modest-tny-msg-actions.h"
-#include "modest-text-utils.h"
-
-static const gchar *
-get_body_text (TnyMsg *msg, gboolean want_html)
-{
- TnyStream *stream;
- TnyMimePart *body;
- GtkTextBuffer *buf;
- GtkTextIter start, end;
- const gchar *to_quote;
-
- body = modest_tny_msg_actions_find_body_part(msg, want_html);
- if (!body)
- return NULL;
-
- 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_stream_reset (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);
- g_object_unref (buf);
-
- return to_quote;
-}
-
-static TnyMimePart*
-modest_tny_msg_actions_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_html)
-{
- const gchar *mime_type = want_html ? "text/html" : "text/plain";
- TnyMimePart *part = NULL;
- TnyList *parts;
- TnyIterator *iter;
-
- if (!msg)
- return NULL;
-
- parts = TNY_LIST (tny_simple_list_new());
- tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
-
- iter = tny_list_create_iterator(parts);
-
- /* no parts? assume it's single-part message */
- if (tny_iterator_is_done(iter))
- return TNY_MIME_PART (g_object_ref(G_OBJECT(msg)));
- else {
- do {
- const gchar *ct;
- gchar *content_type;
- part = TNY_MIME_PART(tny_iterator_get_current (iter));
-
- /* we need to strdown the content type, because
- * tny_mime_part_has_content_type does not do it...
- */
- ct = tny_mime_part_get_content_type (part);
- content_type = g_ascii_strdown (ct, strlen(ct));
-
- if (g_str_has_prefix (content_type, mime_type) &&
- !tny_mime_part_is_attachment (part)) {
- g_free (content_type);
- break;
- }
-
- if (g_str_has_prefix(content_type, "multipart")) {
- part = modest_tny_msg_actions_find_body_part_from_mime_part (part,
- want_html);
- g_free (content_type);
- if (part)
- break;
- }
-
- g_free (content_type);
- part = NULL;
- tny_iterator_next (iter);
-
- } while (!tny_iterator_is_done(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 couldn't find it,
- * try to find a text/plain part instead
- */
- if (!part && want_html)
- return modest_tny_msg_actions_find_body_part_from_mime_part (msg, FALSE);
-
- if (!part)
- g_printerr ("modest: cannot find body part\n");
-
- return part ? part : NULL;
-}
-
-
-TnyMimePart*
-modest_tny_msg_actions_find_body_part (TnyMsg *msg, gboolean want_html)
-{
- return modest_tny_msg_actions_find_body_part_from_mime_part (TNY_MIME_PART(msg),
- want_html);
-}
-
-
-TnyMimePart *
-modest_tny_msg_actions_find_nth_part (TnyMsg *msg, gint index)
-{
- TnyMimePart *part;
- TnyList *parts;
- TnyIterator *iter;
-
- g_return_val_if_fail (msg, NULL);
- g_return_val_if_fail (index > 0, NULL);
-
- parts = TNY_LIST(tny_simple_list_new());
- tny_mime_part_get_parts (TNY_MIME_PART(msg), parts);
- iter = tny_list_create_iterator (parts);
-
- part = NULL;
-
- if (!tny_iterator_is_done(iter)) {
- tny_iterator_nth (iter, index);
- part = TNY_MIME_PART(tny_iterator_get_current (iter));
- }
-
- g_object_unref (G_OBJECT(iter));
- g_object_unref (G_OBJECT(parts));
-
- return part;
-}
-
-gchar *
-modest_tny_msg_actions_find_body (TnyMsg *msg, gboolean want_html)
-{
- const gchar *body;
-
- body = get_body_text (msg, want_html);
-
- if (body)
- return g_strdup (body);
- else
- return NULL;
-}
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Nokia Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MODEST_TNY_MSG_ACTIONS_H__
-#define __MODEST_TNY_MSG_ACTIONS_H__
-
-/**
- * modest_tny_msg_actions_find_body_part:
- * @self: a message
- * @want_html: prefer HTML-part when there are multiple body parts?
- *
- * search a message for the body part. if @want_html is true, try HTML mail
- * first.
- *
- * Returns: the TnyMsgMimePart for the found part, or NULL if no matching part is found
- */
-TnyMimePart *modest_tny_msg_actions_find_body_part (TnyMsg * self, gboolean want_html);
-
-
-/**
- * modest_tny_msg_actions_get_nth_part:
- * @self: a message
- * @index: number (1-based) of the part to retrieve
- *
- * search for the nth (mime) part in the message
- *
- * Returns: the TnyMsgMimePart for the found part, or NULL if no
- * matching part is foundi; must be unref'd
- */
-TnyMimePart* modest_tny_msg_actions_find_nth_part (TnyMsg *msg, gint index);
-
-
-/**
- * modest_tny_msg_actions_find_body:
- * @self:
- * @want_html:
- *
- * gets the body of a message as text, if @want_html is true, try HTML mail
- * first.
- *
- * Returns: the body of the message as text
- **/
-gchar* modest_tny_msg_actions_find_body (TnyMsg *self, gboolean want_html);
-
-#endif /* __MODEST_TNY_MSG_ACTIONS_H__ */
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <gtkhtml/gtkhtml.h>
+#include <tny-gtk-text-buffer-stream.h>
+#include <tny-simple-list.h>
+#include <tny-folder.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /*HAVE_CONFIG_H */
+
+#include <modest-tny-msg.h>
+#include "modest-text-utils.h"
+
+
+gchar *
+modest_tny_msg_get_body (TnyMsg *msg, gboolean want_html)
+{
+ TnyStream *stream;
+ TnyMimePart *body;
+ GtkTextBuffer *buf;
+ GtkTextIter start, end;
+ gchar *to_quote;
+
+ body = modest_tny_msg_find_body_part(msg, want_html);
+ if (!body)
+ return NULL;
+
+ 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_stream_reset (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);
+ g_object_unref (buf);
+
+ return to_quote;
+}
+
+
+TnyMimePart*
+modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_html)
+{
+ const gchar *mime_type = want_html ? "text/html" : "text/plain";
+ TnyMimePart *part = NULL;
+ TnyList *parts;
+ TnyIterator *iter;
+
+ if (!msg)
+ return NULL;
+
+ parts = TNY_LIST (tny_simple_list_new());
+ tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
+
+ iter = tny_list_create_iterator(parts);
+
+ /* no parts? assume it's single-part message */
+ if (tny_iterator_is_done(iter))
+ return TNY_MIME_PART (g_object_ref(G_OBJECT(msg)));
+ else {
+ gchar *content_type = NULL;
+ do {
+ part = TNY_MIME_PART(tny_iterator_get_current (iter));
+
+ /* 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);
+
+ if (g_str_has_prefix (content_type, mime_type) &&
+ !tny_mime_part_is_attachment (part))
+ break;
+
+ if (g_str_has_prefix(content_type, "multipart")) {
+ part = modest_tny_msg_find_body_part_from_mime_part (part, want_html);
+ if (part)
+ break;
+ }
+ if (part)
+ g_object_unref (G_OBJECT(part));
+
+ part = NULL;
+
+ g_free (content_type);
+ content_type = NULL;
+
+ tny_iterator_next (iter);
+
+ } while (!tny_iterator_is_done(iter));
+ g_free (content_type);
+ }
+
+ g_object_unref (G_OBJECT(iter));
+ g_object_unref (G_OBJECT(parts));
+
+ /* if were trying to find an HTML part and couldn't find it,
+ * try to find a text/plain part instead
+ */
+ if (!part && want_html)
+ return modest_tny_msg_find_body_part_from_mime_part (msg, FALSE);
+ else
+ return part; /* this maybe NULL, this is not an error; some message just don't have a body
+ * part */
+}
+
+
+TnyMimePart*
+modest_tny_msg_find_body_part (TnyMsg *msg, gboolean want_html)
+{
+ return modest_tny_msg_find_body_part_from_mime_part (TNY_MIME_PART(msg),
+ want_html);
+}
+
+
+TnyMimePart *
+modest_tny_msg_find_nth_part (TnyMsg *msg, gint index)
+{
+ TnyMimePart *part;
+ TnyList *parts;
+ TnyIterator *iter;
+
+ g_return_val_if_fail (msg, NULL);
+ g_return_val_if_fail (index > 0, NULL);
+
+ parts = TNY_LIST(tny_simple_list_new());
+ tny_mime_part_get_parts (TNY_MIME_PART(msg), parts);
+ iter = tny_list_create_iterator (parts);
+
+ part = NULL;
+
+ if (!tny_iterator_is_done(iter)) {
+ tny_iterator_nth (iter, index);
+ part = TNY_MIME_PART(tny_iterator_get_current (iter));
+ }
+
+ g_object_unref (G_OBJECT(iter));
+ g_object_unref (G_OBJECT(parts));
+
+ return part;
+}
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __MODEST_TNY_MSG_H__
+#define __MODEST_TNY_MSG_H__
+
+/**
+ * modest_tny_msg_find_body_part:
+ * @self: a message
+ * @want_html: prefer HTML-part when there are multiple body parts?
+ *
+ * search a message for the body part. if @want_html is true, try HTML mail
+ * first.
+ *
+ * Returns: the TnyMsgMimePart for the found part, or NULL if no matching part is found
+ */
+TnyMimePart *modest_tny_msg_find_body_part (TnyMsg * self, gboolean want_html);
+
+
+/**
+ * modest_tny_msg_get_nth_part:
+ * @self: a message
+ * @index: number (1-based) of the part to retrieve
+ *
+ * search for the nth (mime) part in the message
+ *
+ * Returns: the TnyMsgMimePart for the found part, or NULL if no
+ * matching part is foundi; must be unref'd
+ */
+TnyMimePart* modest_tny_msg_find_nth_part (TnyMsg *msg, gint index);
+
+
+/**
+ * modest_tny_msg_find_body:
+ * @self:
+ * @want_html:
+ *
+ * gets the body of a message as text, if @want_html is true, try HTML mail
+ * first.
+ *
+ * Returns: the body of the message as text, or NULL if it is not found
+ * the text should be freed with
+ **/
+gchar* modest_tny_msg_get_body (TnyMsg *self, gboolean want_html);
+
+#endif /* __MODEST_TNY_MSG_H__ */
#include <tny-list.h>
#include <tny-simple-list.h>
-#include <modest-tny-msg-actions.h>
+#include <modest-tny-msg.h>
#include <modest-text-utils.h>
#include "modest-msg-view.h"
#include "modest-tny-stream-gtkhtml.h"
(GInstanceInitFunc) modest_msg_view_init,
NULL
};
- my_type = g_type_register_static (GTK_TYPE_SCROLLED_WINDOW,
+ my_type = g_type_register_static (GTK_TYPE_SCROLLED_WINDOW,
"ModestMsgView",
&my_info, 0);
}
while (!tny_iterator_is_done(iter)) {
TnyMimePart *part;
- ++index; /* attachment numbers are 1-based */
-
+ ++index; /* attachment numbers are 1-based */
part = TNY_MIME_PART(tny_iterator_get_current (iter));
if (tny_mime_part_is_attachment (part)) {
g_string_append_printf (appendix, "<a href=\"%s%d\">%s</a> \n",
ATT_PREFIX, index, filename);
}
+
+ g_object_unref (G_OBJECT(part));
tny_iterator_next (iter);
}
g_object_unref (G_OBJECT(iter));
+ g_object_unref (G_OBJECT(parts));
if (appendix->len == 0)
return g_string_free (appendix, TRUE);
set_html_message (ModestMsgView *self, TnyMimePart *tny_body, TnyMsg *msg)
{
gchar *html_attachments;
- TnyStream *gtkhtml_stream;
+ GtkHTMLStream *gtkhtml_stream;
+ TnyStream *tny_stream;
ModestMsgViewPrivate *priv;
g_return_val_if_fail (self, FALSE);
priv = MODEST_MSG_VIEW_GET_PRIVATE(self);
- gtkhtml_stream =
- TNY_STREAM(modest_tny_stream_gtkhtml_new
- (gtk_html_begin(GTK_HTML(priv->gtkhtml))));
-
- tny_stream_reset (gtkhtml_stream);
+ gtkhtml_stream = gtk_html_begin(GTK_HTML(priv->gtkhtml));
+
+ tny_stream = TNY_STREAM(modest_tny_stream_gtkhtml_new (gtkhtml_stream));
+ tny_stream_reset (tny_stream);
html_attachments = attachments_as_html(self, msg);
if (html_attachments) {
- tny_stream_write (gtkhtml_stream, html_attachments,
- strlen(html_attachments));
- tny_stream_reset (gtkhtml_stream);
+ tny_stream_write (tny_stream, html_attachments, strlen(html_attachments));
+ tny_stream_reset (tny_stream);
g_free (html_attachments);
}
- // FIXME: tinymail
- tny_mime_part_decode_to_stream ((TnyMimePart*)tny_body,
- gtkhtml_stream);
-
- g_object_unref (G_OBJECT(gtkhtml_stream));
+ tny_mime_part_decode_to_stream ((TnyMimePart*)tny_body, tny_stream);
+ g_object_unref (G_OBJECT(tny_stream));
+
+ gtk_html_stream_destroy (gtkhtml_stream);
return TRUE;
}
return;
}
- body = modest_tny_msg_actions_find_body_part (msg, TRUE);
+ body = modest_tny_msg_find_body_part (msg, TRUE);
if (body) {
if (tny_mime_part_content_type_is (body, "text/html"))
set_html_message (self, body, msg);