aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-07-05 20:16:13 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-07-05 23:31:01 +0800
commit17127fbee9fd1b0baecb4e305c005d6abbf8d880 (patch)
tree37d0b9ecc37a6685125b2d30567e5b420dacfc59 /em-format
parenta51ea9b9770660531d1d48da4c230e0af118f297 (diff)
downloadgsoc2013-evolution-17127fbee9fd1b0baecb4e305c005d6abbf8d880.tar.gz
gsoc2013-evolution-17127fbee9fd1b0baecb4e305c005d6abbf8d880.tar.zst
gsoc2013-evolution-17127fbee9fd1b0baecb4e305c005d6abbf8d880.zip
Prefer g_seekable_seek() over camel_stream_reset().
When a stream is obviously a file or memory stream (both of which implement the GSeekable interface), use g_seekable_seek() instead of camel_stream_reset(). This is helping me discover if it's safe to remove camel_stream_reset(). We want to eventually move to GIO streams, which have no reset method.
Diffstat (limited to 'em-format')
-rw-r--r--em-format/em-format-quote.c8
-rw-r--r--em-format/em-format.c3
-rw-r--r--em-format/em-inline-filter.c2
3 files changed, 10 insertions, 3 deletions
diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c
index a8f1bf329a..a5a8d0de65 100644
--- a/em-format/em-format-quote.c
+++ b/em-format/em-format-quote.c
@@ -94,8 +94,11 @@ emfq_format_clone (EMFormat *emf,
EM_FORMAT_CLASS (parent_class)->format_clone (
emf, folder, uid, msg, src, cancellable);
+ g_seekable_seek (
+ G_SEEKABLE (emfq->priv->stream),
+ 0, G_SEEK_SET, NULL, NULL);
+
gconf = gconf_client_get_default ();
- camel_stream_reset (emfq->priv->stream, NULL);
if (gconf_client_get_bool (
gconf, "/apps/evolution/mail/composer/top_signature", NULL))
camel_stream_printf (emfq->priv->stream, "<br>\n");
@@ -257,6 +260,9 @@ em_format_quote_new (const gchar *credits,
g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);
+ /* Steam must also be seekable so we can reset its position. */
+ g_return_val_if_fail (G_IS_SEEKABLE (stream), NULL);
+
emfq = g_object_new (EM_TYPE_FORMAT_QUOTE, NULL);
emfq->priv->credits = g_strdup (credits);
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 1f9634d29f..1c2624f1f6 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -1422,7 +1422,8 @@ em_format_format_text (EMFormat *emf,
(CamelStream *) filter_stream, cancellable, NULL);
camel_stream_flush ((CamelStream *) filter_stream, cancellable, NULL);
g_object_unref (filter_stream);
- camel_stream_reset (mem_stream, NULL);
+
+ g_seekable_seek (G_SEEKABLE (mem_stream), 0, G_SEEK_SET, NULL, NULL);
if (max == -1 || size == -1 || size < (max * 1024) || emf->composer) {
camel_stream_write_to_stream (
diff --git a/em-format/em-inline-filter.c b/em-format/em-inline-filter.c
index c7a8014f6b..1f9639540e 100644
--- a/em-format/em-inline-filter.c
+++ b/em-format/em-inline-filter.c
@@ -121,7 +121,7 @@ inline_filter_add_part (EMInlineFilter *emif, const gchar *data, gint len)
}
emif->data = g_byte_array_new ();
- camel_stream_reset (mem, NULL);
+ g_seekable_seek (G_SEEKABLE (mem), 0, G_SEEK_SET, NULL, NULL);
dw = camel_data_wrapper_new ();
if (encoding == emif->base_encoding && (encoding == CAMEL_TRANSFER_ENCODING_BASE64 || encoding == CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE)) {