diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-12-12 00:52:40 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-12-12 00:52:40 +0800 |
commit | cf5946baf722af0e701284a807ae3b3642d8582b (patch) | |
tree | 94cfd4c78ec3457746de863b4531b69e729bb27d /mail | |
parent | 8d8578a64dda64c7bc4e05d687026f977e370aa4 (diff) | |
download | gsoc2013-evolution-cf5946baf722af0e701284a807ae3b3642d8582b.tar.gz gsoc2013-evolution-cf5946baf722af0e701284a807ae3b3642d8582b.tar.zst gsoc2013-evolution-cf5946baf722af0e701284a807ae3b3642d8582b.zip |
New function to handle a lot of the filtering/etc that was done in
2002-12-11 Jeffrey Stedfast <fejj@ximian.com>
* mail-format.c (mail_format_data_wrapper_write_to_stream): New
function to handle a lot of the filtering/etc that was done in
mail_format_get_data_wrapper_text(). This is the first step toward
getting rid of e-text-to-html crap and using my tohtml stream
filter instead.
(mail_format_get_data_wrapper_text): Use the new function.
(mail_format_raw_message): Use camel streams to write the content
to gtkhtml rather than using get_data_wrapper_text() and then
converting that to html and then writing it to the gtkhtml stream.
svn path=/trunk/; revision=19098
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 12 | ||||
-rw-r--r-- | mail/mail-display.c | 2 | ||||
-rw-r--r-- | mail/mail-format.c | 71 | ||||
-rw-r--r-- | mail/mail-stream-gtkhtml.h | 2 |
4 files changed, 57 insertions, 30 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index adbcc393d1..188b0ec1bc 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,15 @@ +2002-12-11 Jeffrey Stedfast <fejj@ximian.com> + + * mail-format.c (mail_format_data_wrapper_write_to_stream): New + function to handle a lot of the filtering/etc that was done in + mail_format_get_data_wrapper_text(). This is the first step toward + getting rid of e-text-to-html crap and using my tohtml stream + filter instead. + (mail_format_get_data_wrapper_text): Use the new function. + (mail_format_raw_message): Use camel streams to write the content + to gtkhtml rather than using get_data_wrapper_text() and then + converting that to html and then writing it to the gtkhtml stream. + 2002-12-10 Not Zed <NotZed@Ximian.com> * mail-composer-prefs.c (mail_composer_prefs_construct): language diff --git a/mail/mail-display.c b/mail/mail-display.c index 88fb1dc6eb..f4b1ce61f1 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -1659,7 +1659,7 @@ mail_text_write (GtkHTML *html, GtkHTMLStream *stream, MailDisplay *md, CamelMim if (!printing) flags |= E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_CONVERT_ADDRESSES; - if (mail_config_get_citation_highlight () && ! printing) + if (!printing && mail_config_get_citation_highlight ()) flags |= E_TEXT_TO_HTML_MARK_CITATION; htmltext = e_text_to_html_full (text, flags, mail_config_get_citation_color ()); diff --git a/mail/mail-format.c b/mail/mail-format.c index 3104183efe..ad32250fee 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -187,8 +187,9 @@ void mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { - GByteArray *bytes; - char *html_str; + CamelStream *mail_stream, *filtered_stream; + CamelMimeFilter *html_filter; + guint32 flags; g_return_if_fail (CAMEL_IS_MIME_MESSAGE (mime_message)); @@ -196,17 +197,20 @@ mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md, TRUE, NULL, html, NULL)) return; - bytes = mail_format_get_data_wrapper_text (CAMEL_DATA_WRAPPER (mime_message), md); - if (bytes) { - g_byte_array_append (bytes, "", 1); - html_str = e_text_to_html (bytes->data, E_TEXT_TO_HTML_CONVERT_NL | - E_TEXT_TO_HTML_CONVERT_SPACES | E_TEXT_TO_HTML_ESCAPE_8BIT); - g_byte_array_free (bytes, TRUE); - mail_html_write (html, stream, "<tt>"); - mail_html_write (html, stream, html_str); - g_free (html_str); - mail_html_write (html, stream, "</tt>"); - } + mail_stream = mail_stream_gtkhtml_new (html, stream); + filtered_stream = camel_stream_filter_new_with_stream (mail_stream); + + flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | + CAMEL_MIME_FILTER_TOHTML_ESCAPE_8BIT; + html_filter = camel_mime_filter_tohtml_new (flags, 0); + camel_stream_filter_add ((CamelStreamFilter *) filtered_stream, html_filter); + camel_object_unref (html_filter); + + camel_stream_write (mail_stream, "<tt>", 4); + mail_format_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (mime_message), md, filtered_stream); + camel_object_unref (filtered_stream); + camel_stream_write (mail_stream, "</tt>", 5); + camel_object_unref (mail_stream); } static const char * @@ -1086,23 +1090,14 @@ mail_content_loaded (CamelDataWrapper *wrapper, MailDisplay *md, gboolean redisp return FALSE; } -/* Return the contents of a data wrapper, or %NULL if it contains only - * whitespace. - */ -GByteArray * -mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_display) + +static ssize_t +mail_format_data_wrapper_write_to_stream (CamelDataWrapper *wrapper, MailDisplay *mail_display, CamelStream *stream) { - CamelStream *memstream; CamelStreamFilter *filtered_stream; - GByteArray *ba; - char *text, *end; + ssize_t written; - memstream = camel_stream_mem_new (); - ba = g_byte_array_new (); - camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (memstream), ba); - - filtered_stream = camel_stream_filter_new_with_stream (memstream); - camel_object_unref (memstream); + filtered_stream = camel_stream_filter_new_with_stream (stream); if (wrapper->rawtext || (mail_display && mail_display->charset)) { CamelMimeFilterCharset *filter; @@ -1143,10 +1138,30 @@ mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_ } } - camel_data_wrapper_write_to_stream (wrapper, CAMEL_STREAM (filtered_stream)); + written = camel_data_wrapper_write_to_stream (wrapper, CAMEL_STREAM (filtered_stream)); camel_stream_flush (CAMEL_STREAM (filtered_stream)); camel_object_unref (filtered_stream); + return written; +} + +/* Return the contents of a data wrapper, or %NULL if it contains only + * whitespace. + */ +GByteArray * +mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_display) +{ + CamelStream *memstream; + GByteArray *ba; + char *text, *end; + + memstream = camel_stream_mem_new (); + ba = g_byte_array_new (); + camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (memstream), ba); + + mail_format_data_wrapper_write_to_stream (wrapper, mail_display, memstream); + camel_object_unref (memstream); + for (text = ba->data, end = text + ba->len; text < end; text++) { if (!isspace ((unsigned char) *text)) break; diff --git a/mail/mail-stream-gtkhtml.h b/mail/mail-stream-gtkhtml.h index c22dda7b27..fa3fb104b9 100644 --- a/mail/mail-stream-gtkhtml.h +++ b/mail/mail-stream-gtkhtml.h @@ -27,7 +27,7 @@ #ifdef __cplusplus extern "C" { #pragma } -#endif /* __cplusplus } */ +#endif /* __cplusplus */ #include <camel/camel-stream.h> #include <gtkhtml/gtkhtml.h> |