aboutsummaryrefslogtreecommitdiffstats
path: root/em-format/e-mail-formatter-audio.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-audio.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-audio.c')
-rw-r--r--em-format/e-mail-formatter-audio.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/em-format/e-mail-formatter-audio.c b/em-format/e-mail-formatter-audio.c
index 228f238a1c..cf980f8e78 100644
--- a/em-format/e-mail-formatter-audio.c
+++ b/em-format/e-mail-formatter-audio.c
@@ -71,14 +71,13 @@ mail_formatter_audio_format (EMailFormatterExtension *extension,
EMailFormatter *formatter,
EMailFormatterContext *context,
EMailPart *part,
- CamelStream *stream,
+ GOutputStream *stream,
GCancellable *cancellable)
{
CamelMimePart *mime_part;
CamelDataWrapper *content;
CamelTransferEncoding encoding;
- CamelStream *mem_stream;
- GByteArray *byte_array;
+ GOutputStream *mem_stream;
const gchar *mime_type;
gchar *html;
GError *local_error = NULL;
@@ -91,28 +90,37 @@ mail_formatter_audio_format (EMailFormatterExtension *extension,
if (mime_type == NULL)
mime_type = "audio/*";
- mem_stream = camel_stream_mem_new ();
- byte_array = camel_stream_mem_get_byte_array (
- CAMEL_STREAM_MEM (mem_stream));
+ mem_stream = g_memory_output_stream_new_resizable ();
if (encoding == CAMEL_TRANSFER_ENCODING_BASE64) {
- camel_data_wrapper_write_to_stream_sync (
+ const gchar *data;
+
+ camel_data_wrapper_write_to_output_stream_sync (
content, mem_stream, cancellable, &local_error);
+ data = g_memory_output_stream_get_data (
+ G_MEMORY_OUTPUT_STREAM (mem_stream));
+
html = g_strdup_printf (
"<audio controls>"
"<source src=\"data:%s;base64,%s\"/>"
"</audio>",
- mime_type, (gchar *) byte_array->data);
+ mime_type, data);
} else {
+ const guchar *data;
gchar *base64;
+ gsize size;
- camel_data_wrapper_decode_to_stream_sync (
+ camel_data_wrapper_decode_to_output_stream_sync (
content, mem_stream, cancellable, &local_error);
- base64 = g_base64_encode (
- (guchar *) byte_array->data, byte_array->len);
+ data = g_memory_output_stream_get_data (
+ G_MEMORY_OUTPUT_STREAM (mem_stream));
+ size = g_memory_output_stream_get_data_size (
+ G_MEMORY_OUTPUT_STREAM (mem_stream));
+
+ base64 = g_base64_encode (data, size);
html = g_strdup_printf (
"<audio controls>"
"<source src=\"data:%s;base64,%s\"/>"
@@ -127,7 +135,8 @@ mail_formatter_audio_format (EMailFormatterExtension *extension,
g_error_free (local_error);
}
- camel_stream_write_string (stream, html, NULL, NULL);
+ g_output_stream_write_all (
+ stream, html, strlen (html), NULL, cancellable, NULL);
g_free (html);