From c72aba8f7c13cdc68b1f3dbc1d381be45e0c4cb8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 5 Jul 2011 08:16:13 -0400 Subject: 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. --- em-format/em-format-quote.c | 8 +++++++- em-format/em-format.c | 3 ++- em-format/em-inline-filter.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'em-format') 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, "
\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)) { -- cgit v1.2.3