aboutsummaryrefslogtreecommitdiffstats
path: root/modules
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 /modules
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 'modules')
-rw-r--r--modules/itip-formatter/e-mail-formatter-itip.c5
-rw-r--r--modules/text-highlight/e-mail-formatter-text-highlight.c34
-rw-r--r--modules/vcard-inline/e-mail-formatter-vcard.c39
3 files changed, 38 insertions, 40 deletions
diff --git a/modules/itip-formatter/e-mail-formatter-itip.c b/modules/itip-formatter/e-mail-formatter-itip.c
index 9b515961c1..1439cf1672 100644
--- a/modules/itip-formatter/e-mail-formatter-itip.c
+++ b/modules/itip-formatter/e-mail-formatter-itip.c
@@ -55,7 +55,7 @@ emfe_itip_format (EMailFormatterExtension *extension,
EMailFormatter *formatter,
EMailFormatterContext *context,
EMailPart *part,
- CamelStream *stream,
+ GOutputStream *stream,
GCancellable *cancellable)
{
GString *buffer;
@@ -135,7 +135,8 @@ emfe_itip_format (EMailFormatterExtension *extension,
g_free (uri);
}
- camel_stream_write_string (stream, buffer->str, cancellable, NULL);
+ g_output_stream_write_all (
+ stream, buffer->str, buffer->len, NULL, cancellable, NULL);
g_string_free (buffer, TRUE);
diff --git a/modules/text-highlight/e-mail-formatter-text-highlight.c b/modules/text-highlight/e-mail-formatter-text-highlight.c
index cbf56ad817..4f171ee957 100644
--- a/modules/text-highlight/e-mail-formatter-text-highlight.c
+++ b/modules/text-highlight/e-mail-formatter-text-highlight.c
@@ -148,7 +148,7 @@ text_highlight_output_spliced (GObject *source_object,
}
static gboolean
-text_highlight_feed_data (CamelStream *stream,
+text_highlight_feed_data (GOutputStream *output_stream,
CamelDataWrapper *data_wrapper,
gint pipe_stdin,
gint pipe_stdout,
@@ -157,13 +157,12 @@ text_highlight_feed_data (CamelStream *stream,
{
TextHighlightClosure closure;
GInputStream *input_stream = NULL;
- GOutputStream *output_stream = NULL;
+ GOutputStream *temp_stream = NULL;
GInputStream *stdout_stream = NULL;
GOutputStream *stdin_stream = NULL;
GMainContext *main_context;
gchar *utf8_data;
gconstpointer data;
- gssize bytes_written;
gsize size;
gboolean success;
@@ -173,10 +172,10 @@ text_highlight_feed_data (CamelStream *stream,
/* FIXME Use GSubprocess once we can require GLib 2.40. */
- output_stream = g_memory_output_stream_new_resizable ();
+ temp_stream = g_memory_output_stream_new_resizable ();
success = camel_data_wrapper_decode_to_output_stream_sync (
- data_wrapper, output_stream, cancellable, error);
+ data_wrapper, temp_stream, cancellable, error);
if (!success)
goto exit;
@@ -190,23 +189,21 @@ text_highlight_feed_data (CamelStream *stream,
g_main_context_push_thread_default (main_context);
data = g_memory_output_stream_get_data (
- G_MEMORY_OUTPUT_STREAM (output_stream));
+ G_MEMORY_OUTPUT_STREAM (temp_stream));
size = g_memory_output_stream_get_data_size (
- G_MEMORY_OUTPUT_STREAM (output_stream));
+ G_MEMORY_OUTPUT_STREAM (temp_stream));
/* FIXME Write a GConverter that does this so we can decode
* straight to the stdin pipe and skip all this extra
* buffering. */
utf8_data = e_util_utf8_data_make_valid ((gchar *) data, size);
- g_clear_object (&output_stream);
+ g_clear_object (&temp_stream);
/* Takes ownership of the UTF-8 string. */
input_stream = g_memory_input_stream_new_from_data (
utf8_data, -1, (GDestroyNotify) g_free);
- output_stream = g_memory_output_stream_new_resizable ();
-
stdin_stream = g_unix_output_stream_new (pipe_stdin, TRUE);
stdout_stream = g_unix_input_stream_new (pipe_stdout, TRUE);
@@ -255,17 +252,8 @@ text_highlight_feed_data (CamelStream *stream,
goto exit;
}
- data = g_memory_output_stream_get_data (
- G_MEMORY_OUTPUT_STREAM (output_stream));
- size = g_memory_output_stream_get_data_size (
- G_MEMORY_OUTPUT_STREAM (output_stream));
-
- bytes_written = camel_stream_write (
- stream, data, size, cancellable, error);
- success = (bytes_written >= 0);
-
exit:
- g_clear_object (&output_stream);
+ g_clear_object (&temp_stream);
return success;
}
@@ -275,7 +263,7 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
EMailFormatter *formatter,
EMailFormatterContext *context,
EMailPart *part,
- CamelStream *stream,
+ GOutputStream *stream,
GCancellable *cancellable)
{
CamelMimePart *mime_part;
@@ -471,7 +459,9 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
e_mail_part_get_id (part),
uri);
- camel_stream_write_string (stream, str, cancellable, NULL);
+ g_output_stream_write_all (
+ stream, str, strlen (str),
+ NULL, cancellable, NULL);
g_free (str);
g_free (uri);
diff --git a/modules/vcard-inline/e-mail-formatter-vcard.c b/modules/vcard-inline/e-mail-formatter-vcard.c
index 773bf68295..f13d677c29 100644
--- a/modules/vcard-inline/e-mail-formatter-vcard.c
+++ b/modules/vcard-inline/e-mail-formatter-vcard.c
@@ -60,7 +60,7 @@ mail_formatter_vcard_format (EMailFormatterExtension *extension,
EMailFormatter *formatter,
EMailFormatterContext *context,
EMailPart *part,
- CamelStream *stream,
+ GOutputStream *stream,
GCancellable *cancellable)
{
EMailPartVCard *vcard_part;
@@ -80,8 +80,10 @@ mail_formatter_vcard_format (EMailFormatterExtension *extension,
eab_contact_formatter_format_contact (
vcard_part->formatter, contact, buffer);
- camel_stream_write_string (
- stream, buffer->str, cancellable, NULL);
+
+ g_output_stream_write_all (
+ stream, buffer->str, buffer->len,
+ NULL, cancellable, NULL);
g_string_free (buffer, TRUE);
@@ -94,7 +96,8 @@ mail_formatter_vcard_format (EMailFormatterExtension *extension,
const gchar *label = NULL;
EABContactDisplayMode mode;
const gchar *info = NULL;
- gchar *html_label, *access_key;
+ gchar *access_key = NULL;
+ gchar *html_label;
length = g_slist_length (vcard_part->contact_list);
@@ -134,11 +137,12 @@ mail_formatter_vcard_format (EMailFormatterExtension *extension,
str = g_strdup_printf (
"<div id=\"%s\">",
e_mail_part_get_id (part));
- camel_stream_write_string (stream, str, cancellable, NULL);
+ g_output_stream_write_all (
+ stream, str, strlen (str), NULL, cancellable, NULL);
g_free (str);
html_label = e_mail_formatter_parse_html_mnemonics (
- label, &access_key);
+ label, &access_key);
str = g_strdup_printf (
"<button type=\"button\" "
"name=\"set-display-mode\" "
@@ -146,11 +150,13 @@ mail_formatter_vcard_format (EMailFormatterExtension *extension,
"value=\"%d\" "
"accesskey=\"%s\">%s</button>",
mode, access_key, html_label);
- camel_stream_write_string (stream, str, cancellable, NULL);
+ g_output_stream_write_all (
+ stream, str, strlen (str), NULL, cancellable, NULL);
g_free (str);
g_free (html_label);
- if (access_key)
- g_free (access_key);
+
+ g_free (access_key);
+ access_key = NULL;
html_label = e_mail_formatter_parse_html_mnemonics (
_("Save _To Addressbook"), &access_key);
@@ -166,18 +172,18 @@ mail_formatter_vcard_format (EMailFormatterExtension *extension,
e_mail_part_get_id (part),
access_key, html_label, uri,
e_mail_part_get_id (part));
- camel_stream_write_string (stream, str, cancellable, NULL);
+ g_output_stream_write_all (
+ stream, str, strlen (str), NULL, cancellable, NULL);
g_free (str);
g_free (html_label);
- if (access_key)
- g_free (access_key);
- if (length == 2) {
+ g_free (access_key);
+ access_key = NULL;
+ if (length == 2) {
info = _("There is one other contact.");
} else if (length > 2) {
-
/* Translators: This will always be two or more. */
info = g_strdup_printf (ngettext (
"There is %d other contact.",
@@ -186,12 +192,13 @@ mail_formatter_vcard_format (EMailFormatterExtension *extension,
}
if (info) {
-
str = g_strdup_printf (
"<div class=\"attachment-info\">%s</div>",
info);
- camel_stream_write_string (stream, str, cancellable, NULL);
+ g_output_stream_write_all (
+ stream, str, strlen (str),
+ NULL, cancellable, NULL);
g_free (str);
}