aboutsummaryrefslogtreecommitdiffstats
path: root/em-format/e-mail-formatter-source.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2014-02-25 23:23:11 +0800
committerMatthew Barnes <mbarnes@redhat.com>2014-03-01 03:38:11 +0800
commitf4bb7d7748f3c407858e9c844d365411c586d861 (patch)
tree5946af137b2439857433fd9729ba758e9cd3c05d /em-format/e-mail-formatter-source.c
parentc3f8c95322ca7e461444820c7469d5527c239b05 (diff)
downloadgsoc2013-evolution-f4bb7d7748f3c407858e9c844d365411c586d861.tar
gsoc2013-evolution-f4bb7d7748f3c407858e9c844d365411c586d861.tar.gz
gsoc2013-evolution-f4bb7d7748f3c407858e9c844d365411c586d861.tar.bz2
gsoc2013-evolution-f4bb7d7748f3c407858e9c844d365411c586d861.tar.lz
gsoc2013-evolution-f4bb7d7748f3c407858e9c844d365411c586d861.tar.xz
gsoc2013-evolution-f4bb7d7748f3c407858e9c844d365411c586d861.tar.zst
gsoc2013-evolution-f4bb7d7748f3c407858e9c844d365411c586d861.zip
EMailFormatter: Use GOutputStream instead of CamelStream.
Diffstat (limited to 'em-format/e-mail-formatter-source.c')
-rw-r--r--em-format/e-mail-formatter-source.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/em-format/e-mail-formatter-source.c b/em-format/e-mail-formatter-source.c
index 217e9b3172..4c80114bb2 100644
--- a/em-format/e-mail-formatter-source.c
+++ b/em-format/e-mail-formatter-source.c
@@ -46,62 +46,66 @@ emfe_source_format (EMailFormatterExtension *extension,
EMailFormatter *formatter,
EMailFormatterContext *context,
EMailPart *part,
- CamelStream *stream,
+ GOutputStream *stream,
GCancellable *cancellable)
{
GString *buffer;
- CamelStream *filtered_stream;
+ GOutputStream *filtered_stream;
CamelMimeFilter *filter;
CamelMimePart *mime_part;
mime_part = e_mail_part_ref_mime_part (part);
- filtered_stream = camel_stream_filter_new (stream);
-
- filter = camel_mime_filter_tohtml_new (
- CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
- CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
- CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT, 0);
- camel_stream_filter_add (
- CAMEL_STREAM_FILTER (filtered_stream), filter);
- g_object_unref (filter);
-
buffer = g_string_new ("");
if (CAMEL_IS_MIME_MESSAGE (mime_part)) {
g_string_append (
buffer,
- "<div class=\"part-container -e-mail-formatter-body-color "
- "-e-web-view-text-color\" style=\"border: 0;\" >");
+ "<div class=\"part-container "
+ "-e-mail-formatter-body-color "
+ "-e-web-view-text-color\" "
+ "style=\"border: 0;\" >");
} else {
g_string_append (
buffer,
- "<div class=\"part-container -e-mail-formatter-body-color "
- " -e-web-view-text-color -e-mail-formatter-frame-color\">"
+ "<div class=\"part-container "
+ "-e-mail-formatter-body-color "
+ "-e-web-view-text-color "
+ "-e-mail-formatter-frame-color\">"
"<div class=\"part-container-inner-margin pre\">\n");
}
- camel_stream_write_string (
- stream, buffer->str, cancellable, NULL);
- camel_stream_write_string (
- stream, "<code class=\"pre\">", cancellable, NULL);
+ g_string_append (buffer, "<code class=\"pre\">");
+
+ g_output_stream_write_all (
+ stream, buffer->str, buffer->len, NULL, cancellable, NULL);
- camel_data_wrapper_write_to_stream_sync (
+ filter = camel_mime_filter_tohtml_new (
+ CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
+ CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
+ CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT, 0);
+ filtered_stream = camel_filter_output_stream_new (stream, filter);
+ g_object_unref (filter);
+
+ camel_data_wrapper_write_to_output_stream_sync (
CAMEL_DATA_WRAPPER (mime_part),
filtered_stream, cancellable, NULL);
- camel_stream_flush (filtered_stream, cancellable, NULL);
+ g_output_stream_flush (filtered_stream, cancellable, NULL);
+
g_object_unref (filtered_stream);
- camel_stream_write_string (
- stream, "</code>", cancellable, NULL);
+ /* Resets the string buffer. */
+ g_string_assign (buffer, "</code>");
- g_string_free (buffer, TRUE);
+ if (CAMEL_IS_MIME_MESSAGE (mime_part))
+ g_string_append (buffer, "</div>");
+ else
+ g_string_append (buffer, "</div></div>");
- if (CAMEL_IS_MIME_MESSAGE (mime_part)) {
- camel_stream_write_string (stream, "</div>", cancellable, NULL);
- } else {
- camel_stream_write_string (stream, "</div></div>", cancellable, NULL);
- }
+ g_output_stream_write_all (
+ stream, buffer->str, buffer->len, NULL, cancellable, NULL);
+
+ g_string_free (buffer, TRUE);
g_object_unref (mime_part);