aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-display.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-12-17 00:47:51 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-12-17 00:47:51 +0800
commit2f1a1a22feb83e27635bb25658ae6b4103285878 (patch)
treecd8f956f8ba6f401e00fd9b1c9623844d5cec8dd /mail/mail-display.c
parent8740d35feedeeae19b137a723a2d2fac5cae5fa5 (diff)
downloadgsoc2013-evolution-2f1a1a22feb83e27635bb25658ae6b4103285878.tar
gsoc2013-evolution-2f1a1a22feb83e27635bb25658ae6b4103285878.tar.gz
gsoc2013-evolution-2f1a1a22feb83e27635bb25658ae6b4103285878.tar.bz2
gsoc2013-evolution-2f1a1a22feb83e27635bb25658ae6b4103285878.tar.lz
gsoc2013-evolution-2f1a1a22feb83e27635bb25658ae6b4103285878.tar.xz
gsoc2013-evolution-2f1a1a22feb83e27635bb25658ae6b4103285878.tar.zst
gsoc2013-evolution-2f1a1a22feb83e27635bb25658ae6b4103285878.zip
Re-implemented to use streams. Also no need to check for html since
2002-12-16 Jeffrey Stedfast <fejj@ximian.com> * mail-format.c (handle_text_plain): Re-implemented to use streams. Also no need to check for html since camel-mime-part-utils.c now does this for us and will re-tag the mime-type as text/html thus the UI can be completely ignorant of this process. (handle_text_plain_flowed): Removed. (write_one_text_plain_chunk): Removed. (try_uudecoding): Removed. (try_inline_binhex): Removed. (handle_text_enriched): Re-implemented to use streams too. 2002-12-15 Jeffrey Stedfast <fejj@ximian.com> * mail-format.c (write_text_header): Change the order of the args to be consistant with other write functions. (write_date): Same. (write_field_row_begin): Here too. (write_headers): Here too. (write_one_text_plain_chunk): Don't strdup just to pass it to mail_text_write() so that it can dup it yet again into html text and dup it yet a 3rd time into a GByteArray. Instead just write it to gtkhtml. (handle_*): Fixed arguments to take a MailDisplayStream instead of a GtkHTML widget and a GtkHMLStream. * mail-display.c (mail_display_render): Create a MailDisplayStream to pass to mail_format_mime_message() and mail_format_raw_message(). * mail-display-stream.[c,h]: New stream to replace mail-stream-gtkhtml.c * mail-stream-gtkhtml.[c,h]: Removed. svn path=/trunk/; revision=19126
Diffstat (limited to 'mail/mail-display.c')
-rw-r--r--mail/mail-display.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 43df9e44a4..f21568fbe2 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -65,7 +65,7 @@
#include "e-searching-tokenizer.h"
#include "folder-browser-factory.h"
-#include "mail-stream-gtkhtml.h"
+#include "mail-display-stream.h"
#include "folder-browser.h"
#include "mail-display.h"
#include "mail-config.h"
@@ -1228,7 +1228,7 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
} else {
CamelStream *html_stream;
- html_stream = mail_stream_gtkhtml_new (html, handle);
+ html_stream = mail_display_stream_new (html, handle);
camel_data_wrapper_write_to_stream (data, html_stream);
camel_object_unref (html_stream);
}
@@ -1525,7 +1525,7 @@ try_part_urls (struct _load_content_msg *m)
return TRUE;
}
- html_stream = mail_stream_gtkhtml_new (m->html, m->handle);
+ html_stream = mail_display_stream_new (m->html, m->handle);
camel_data_wrapper_write_to_stream (data, html_stream);
camel_object_unref (html_stream);
@@ -1664,15 +1664,15 @@ mail_display_redisplay_when_loaded (MailDisplay *md,
}
void
-mail_text_write (GtkHTML *html, GtkHTMLStream *stream, MailDisplay *md, CamelMimePart *part, gint idx, gboolean printing, const char *text)
+mail_text_write (MailDisplayStream *stream, MailDisplay *md, CamelMimePart *part,
+ int idx, gboolean printing, const char *text)
{
GByteArray *ba;
- gchar *xed, *iframe;
- gchar *btt = "<tt>\n";
- gchar *ett = "</tt>\n";
-
- guint flags;
+ char *xed, *iframe;
+ char *btt = "<tt>\n";
+ char *ett = "</tt>\n";
char *htmltext;
+ guint32 flags;
flags = E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_SPACES;
@@ -1693,13 +1693,12 @@ mail_text_write (GtkHTML *html, GtkHTMLStream *stream, MailDisplay *md, CamelMim
xed = g_strdup_printf ("x-evolution-data:%p-%d", part, idx);
iframe = g_strdup_printf ("<iframe src=\"%s\" frameborder=0 scrolling=no>could not get %s</iframe>", xed, xed);
mail_display_add_url (md, "data_urls", xed, ba);
- gtk_html_write (html, stream, iframe, strlen (iframe));
+ camel_stream_write ((CamelStream *) stream, iframe, strlen (iframe));
g_free (iframe);
}
void
-mail_error_printf (GtkHTML *html, GtkHTMLStream *stream,
- const char *format, ...)
+mail_error_printf (MailDisplayStream *stream, const char *format, ...)
{
char *buf, *htmltext;
va_list ap;
@@ -1711,9 +1710,9 @@ mail_error_printf (GtkHTML *html, GtkHTMLStream *stream,
htmltext = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS);
g_free (buf);
- gtk_html_stream_printf (stream, "<em><font color=red>");
- gtk_html_stream_write (stream, htmltext, strlen (htmltext));
- gtk_html_stream_printf (stream, "</font></em>");
+ camel_stream_printf ((CamelStream *) stream, "<em><font color=red>");
+ camel_stream_write ((CamelStream *) stream, htmltext, strlen (htmltext));
+ camel_stream_printf ((CamelStream *) stream, "</font></em>");
g_free (htmltext);
}
@@ -1721,29 +1720,31 @@ mail_error_printf (GtkHTML *html, GtkHTMLStream *stream,
#define COLOR_IS_LIGHT(r, g, b) ((r + g + b) > (128 * 3))
+#define HTML_HEADER "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n" \
+ "<head>\n<meta name=\"generator\" content=\"Evolution Mail Component\">\n</head>\n"
+
void
mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll)
{
const char *flag, *completed;
- GtkHTMLStream *stream;
+ GtkHTMLStream *html_stream;
+ MailDisplayStream *stream;
g_return_if_fail (IS_MAIL_DISPLAY (md));
g_return_if_fail (GTK_IS_HTML (html));
- stream = gtk_html_begin (html);
+ html_stream = gtk_html_begin (html);
if (!reset_scroll) {
/* This is a hack until there's a clean way to do this. */
GTK_HTML (md->html)->engine->newPage = FALSE;
}
- mail_html_write (html, stream,
- "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n"
- "<html>\n"
- "<head>\n<meta name=\"generator\" content=\"Evolution Mail Component\">\n</head>\n");
+ gtk_html_stream_write (html_stream, HTML_HEADER, sizeof (HTML_HEADER) - 1);
+
if (md->current_message && md->display_style == MAIL_CONFIG_DISPLAY_SOURCE)
- mail_html_write (html, stream, "<body>\n");
+ gtk_html_stream_write (html_stream, "<body>\n", 7);
else
- mail_html_write (html, stream, "<body marginwidth=0 marginheight=0>\n");
+ gtk_html_stream_write (html_stream, "<body marginwidth=0 marginheight=0>\n", 36);
flag = md->info ? camel_tag_get (&md->info->user_tags, "follow-up") : NULL;
completed = md->info ? camel_tag_get (&md->info->user_tags, "completed-on") : NULL;
@@ -1803,7 +1804,7 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll)
due_date[0] = '\0';
}
- gtk_html_stream_printf (stream, "<font color=\"#%s\">"
+ gtk_html_stream_printf (html_stream, "<font color=\"#%s\">"
"<table width=\"100%%\" cellpadding=0 cellspacing=0><tr><td colspan=3 height=10></td></tr>"
"<tr><td width=10></td><td>"
"<table cellspacing=1 cellpadding=1 bgcolor=\"#000000\" width=\"100%%\"><tr><td>"
@@ -1817,14 +1818,18 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll)
}
if (md->current_message) {
+ stream = (MailDisplayStream *) mail_display_stream_new (html, html_stream);
+
if (md->display_style == MAIL_CONFIG_DISPLAY_SOURCE)
- mail_format_raw_message (md->current_message, md, html, stream);
+ mail_format_raw_message (md->current_message, md, stream);
else
- mail_format_mime_message (md->current_message, md, html, stream);
+ mail_format_mime_message (md->current_message, md, stream);
+
+ camel_object_unref (stream);
}
- mail_html_write (html, stream, "</body></html>\n");
- gtk_html_end (html, stream, GTK_HTML_STREAM_OK);
+ gtk_html_stream_write (html_stream, "</body></html>\n", 15);
+ gtk_html_end (html, html_stream, GTK_HTML_STREAM_OK);
}
/**