aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-07-06 02:02:01 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-07-06 02:40:10 +0800
commit005a26de4534cfaf534e8e4828366b619a3b21d1 (patch)
treee9247d1dfa10750a07335647cf37f43b158a8817 /em-format
parent17127fbee9fd1b0baecb4e305c005d6abbf8d880 (diff)
downloadgsoc2013-evolution-005a26de4534cfaf534e8e4828366b619a3b21d1.tar
gsoc2013-evolution-005a26de4534cfaf534e8e4828366b619a3b21d1.tar.gz
gsoc2013-evolution-005a26de4534cfaf534e8e4828366b619a3b21d1.tar.bz2
gsoc2013-evolution-005a26de4534cfaf534e8e4828366b619a3b21d1.tar.lz
gsoc2013-evolution-005a26de4534cfaf534e8e4828366b619a3b21d1.tar.xz
gsoc2013-evolution-005a26de4534cfaf534e8e4828366b619a3b21d1.tar.zst
gsoc2013-evolution-005a26de4534cfaf534e8e4828366b619a3b21d1.zip
Avoid camel_stream_printf().
camel_stream_printf() is next on the chopping block. Use g_strdup_printf() or a GString to construct a formatted string in memory, pass it to camel_stream_write() in one go, and then check for errors (unless it's a memory stream).
Diffstat (limited to 'em-format')
-rw-r--r--em-format/em-format-quote.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c
index a5a8d0de65..c11476a6d5 100644
--- a/em-format/em-format-quote.c
+++ b/em-format/em-format-quote.c
@@ -101,7 +101,8 @@ emfq_format_clone (EMFormat *emf,
gconf = gconf_client_get_default ();
if (gconf_client_get_bool (
gconf, "/apps/evolution/mail/composer/top_signature", NULL))
- camel_stream_printf (emfq->priv->stream, "<br>\n");
+ camel_stream_write_string (
+ emfq->priv->stream, "<br>\n", cancellable, NULL);
g_object_unref (gconf);
handle = em_format_find_handler(emf, "x-evolution/message/prefix");
if (handle)
@@ -274,7 +275,7 @@ em_format_quote_new (const gchar *credits,
static void
emfq_format_text_header (EMFormatQuote *emfq,
- CamelStream *stream,
+ GString *buffer,
const gchar *label,
const gchar *value,
guint32 flags,
@@ -295,9 +296,11 @@ emfq_format_text_header (EMFormatQuote *emfq,
html = value;
if (flags & EM_FORMAT_HEADER_BOLD)
- camel_stream_printf (stream, "<b>%s</b>: %s<br>", label, html);
+ g_string_append_printf (
+ buffer, "<b>%s</b>: %s<br>", label, html);
else
- camel_stream_printf (stream, "%s: %s<br>", label, html);
+ g_string_append_printf (
+ buffer, "%s: %s<br>", label, html);
g_free (mhtml);
}
@@ -399,7 +402,7 @@ canon_header_name (gchar *name)
static void
emfq_format_header (EMFormat *emf,
- CamelStream *stream,
+ GString *buffer,
CamelMedium *part,
const gchar *namein,
guint32 flags,
@@ -482,14 +485,14 @@ emfq_format_header (EMFormat *emf,
g_free (buf);
}
- emfq_format_text_header (emfq, stream, label, txt, flags, is_html);
+ emfq_format_text_header (emfq, buffer, label, txt, flags, is_html);
g_free (value);
}
static void
emfq_format_headers (EMFormatQuote *emfq,
- CamelStream *stream,
+ GString *buffer,
CamelMedium *part)
{
EMFormat *emf = (EMFormat *) emfq;
@@ -509,11 +512,11 @@ emfq_format_headers (EMFormatQuote *emfq,
while (link != NULL) {
EMFormatHeader *h = link->data;
emfq_format_header (
- emf, stream, part, h->name, h->flags, charset);
+ emf, buffer, part, h->name, h->flags, charset);
link = g_list_next (link);
}
- camel_stream_printf(stream, "<br>\n");
+ g_string_append (buffer, "<br>\n");
}
static void
@@ -526,9 +529,12 @@ emfq_format_message_prefix (EMFormat *emf,
{
EMFormatQuote *emfq = (EMFormatQuote *) emf;
- if (emfq->priv->credits != NULL)
- camel_stream_printf (
- stream, "%s<br>\n", emfq->priv->credits);
+ if (emfq->priv->credits != NULL) {
+ camel_stream_write_string (
+ stream, emfq->priv->credits, NULL, NULL);
+ camel_stream_write_string (
+ stream, "<br>\n", NULL, NULL);
+ }
}
static void
@@ -540,20 +546,28 @@ emfq_format_message (EMFormat *emf,
gboolean is_fallback)
{
EMFormatQuote *emfq = (EMFormatQuote *) emf;
+ GString *buffer;
+
+ buffer = g_string_sized_new (1024);
if (emfq->priv->flags & EM_FORMAT_QUOTE_CITE)
- camel_stream_printf (
- stream, "<!--+GtkHTML:<DATA class=\"ClueFlow\" "
+ g_string_append (
+ buffer,
+ "<!--+GtkHTML:<DATA class=\"ClueFlow\" "
"key=\"orig\" value=\"1\">-->\n"
"<blockquote type=cite>\n");
if (((CamelMimePart *) emf->message) != part) {
- camel_stream_printf (
- stream, "%s</br>\n",
+ g_string_append_printf (
+ buffer,
+ "%s</br>\n",
_("-------- Forwarded Message --------"));
- emfq_format_headers (emfq, stream, (CamelMedium *) part);
+ emfq_format_headers (emfq, buffer, (CamelMedium *) part);
} else if (emfq->priv->flags & EM_FORMAT_QUOTE_HEADERS)
- emfq_format_headers (emfq, stream, (CamelMedium *) part);
+ emfq_format_headers (emfq, buffer, (CamelMedium *) part);
+
+ camel_stream_write (
+ stream, buffer->str, buffer->len, cancellable, NULL);
em_format_part (emf, stream, part, cancellable);