From a4a43fe1fc888b7bdd4f665157f1d7911434b660 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 16 Dec 2002 20:11:36 +0000 Subject: Use camel_text_to_html() instead of e_text_to_html(). (mail_text_write): 2002-12-16 Jeffrey Stedfast * mail-display.c (mail_error_printf): Use camel_text_to_html() instead of e_text_to_html(). (mail_text_write): Write the content directly to gtkhtml through an html stream filter. * mail-format.c (attachment_header): Use camel_text_to_html() instead of e_text_to_html(). (write_text_header): Same. (write_address): Here too. (mail_get_message_rfc822): And here. (mail_get_message_body): And finally here. svn path=/trunk/; revision=19133 --- mail/ChangeLog | 14 ++++++++++++++ mail/mail-config.c | 1 - mail/mail-display.c | 39 +++++++++++++++++++++++++++++++++------ mail/mail-format.c | 29 +++++++++++++++-------------- mail/mail-ops.c | 1 - mail/mail-tools.c | 1 - 6 files changed, 62 insertions(+), 23 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 9ec8318aca..cf0bf9a72a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,17 @@ +2002-12-16 Jeffrey Stedfast + + * mail-display.c (mail_error_printf): Use camel_text_to_html() + instead of e_text_to_html(). + (mail_text_write): Write the content directly to gtkhtml through + an html stream filter. + + * mail-format.c (attachment_header): Use camel_text_to_html() + instead of e_text_to_html(). + (write_text_header): Same. + (write_address): Here too. + (mail_get_message_rfc822): And here. + (mail_get_message_body): And finally here. + 2002-12-16 Jeffrey Stedfast * mail-format.c (handle_text_plain): Re-implemented to use diff --git a/mail/mail-config.c b/mail/mail-config.c index b7f5ce8356..1b02e462f1 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -49,7 +49,6 @@ #include #include -#include #include #include #include "mail.h" diff --git a/mail/mail-display.c b/mail/mail-display.c index f21568fbe2..c9da2e4ed9 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -59,7 +59,6 @@ #include -#include "e-util/e-html-utils.h" #include "e-util/e-mktemp.h" #include "addressbook/backend/ebook/e-book-util.h" @@ -1667,6 +1666,31 @@ void mail_text_write (MailDisplayStream *stream, MailDisplay *md, CamelMimePart *part, int idx, gboolean printing, const char *text) { + CamelStreamFilter *filtered_stream; + CamelMimeFilter *html_filter; + guint32 flags; + + flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES; + + if (!printing) + flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; + + if (!printing && mail_config_get_citation_highlight ()) + flags |= CAMEL_MIME_FILTER_TOHTML_MARK_CITATION; + + html_filter = camel_mime_filter_tohtml_new (flags, mail_config_get_citation_color ()); + filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream); + camel_stream_filter_add (filtered_stream, html_filter); + camel_object_unref (html_filter); + + camel_stream_write ((CamelStream *) stream, "\n", 5); + camel_stream_write ((CamelStream *) filtered_stream, text, strlen (text)); + camel_stream_flush ((CamelStream *) filtered_stream); + camel_stream_write ((CamelStream *) stream, "\n", 6); + camel_object_unref (filtered_stream); + +#if 0 + /* this was the old way of doing it, I don't understand why we need iframes... */ GByteArray *ba; char *xed, *iframe; char *btt = "\n"; @@ -1674,15 +1698,15 @@ mail_text_write (MailDisplayStream *stream, MailDisplay *md, CamelMimePart *part char *htmltext; guint32 flags; - flags = E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_SPACES; + flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES; if (!printing) - flags |= E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_CONVERT_ADDRESSES; + flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; if (!printing && mail_config_get_citation_highlight ()) - flags |= E_TEXT_TO_HTML_MARK_CITATION; + flags |= CAMEL_MIME_FILTER_TOHTML_MARK_CITATION; - htmltext = e_text_to_html_full (text, flags, mail_config_get_citation_color ()); + htmltext = camel_text_to_html (text, flags, mail_config_get_citation_color ()); ba = g_byte_array_new (); g_byte_array_append (ba, (const guint8 *) btt, strlen (btt) + 1); @@ -1695,11 +1719,13 @@ mail_text_write (MailDisplayStream *stream, MailDisplay *md, CamelMimePart *part mail_display_add_url (md, "data_urls", xed, ba); camel_stream_write ((CamelStream *) stream, iframe, strlen (iframe)); g_free (iframe); +#endif } void mail_error_printf (MailDisplayStream *stream, const char *format, ...) { + /* FIXME: it'd be nice if camel-stream had a vprintf method... */ char *buf, *htmltext; va_list ap; @@ -1707,7 +1733,8 @@ mail_error_printf (MailDisplayStream *stream, const char *format, ...) buf = g_strdup_vprintf (format, ap); va_end (ap); - htmltext = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); + htmltext = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | + CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); g_free (buf); camel_stream_printf ((CamelStream *) stream, ""); diff --git a/mail/mail-format.c b/mail/mail-format.c index 7c71d293b1..7b7eabd2ee 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -44,7 +44,6 @@ #include #include -#include #include "mail.h" #include "mail-tools.h" @@ -630,14 +629,14 @@ attachment_header (CamelMimePart *part, const char *mime_type, MailDisplay *md, /* Write the MIME type */ info = gnome_vfs_mime_get_description (mime_type); - htmlinfo = e_text_to_html (info ? info : mime_type, 0); + htmlinfo = camel_text_to_html (info ? info : mime_type, 0, 0); camel_stream_printf ((CamelStream *) stream, _("%s attachment"), htmlinfo); g_free (htmlinfo); /* Write the name, if we have it. */ info = camel_mime_part_get_filename (part); if (info) { - htmlinfo = e_text_to_html (info, 0); + htmlinfo = camel_text_to_html (info, 0, 0); camel_stream_printf ((CamelStream *) stream, " (%s)", htmlinfo); g_free (htmlinfo); } @@ -645,7 +644,7 @@ attachment_header (CamelMimePart *part, const char *mime_type, MailDisplay *md, /* Write a description, if we have one. */ info = camel_mime_part_get_description (part); if (info) { - htmlinfo = e_text_to_html (info, md->printing ? 0 : E_TEXT_TO_HTML_CONVERT_URLS); + htmlinfo = camel_text_to_html (info, md->printing ? 0 : CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); camel_stream_printf ((CamelStream *) stream, ", \"%s\"", htmlinfo); g_free (htmlinfo); } @@ -762,7 +761,7 @@ write_text_header (MailDisplayStream *stream, const char *name, const char *valu char *encoded; if (value && *value) - encoded = e_text_to_html (value, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); + encoded = camel_text_to_html (value, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); else encoded = ""; @@ -802,11 +801,11 @@ write_address (MailDisplay *md, MailDisplayStream *stream, camel_object_unref (subaddr); if (have_name) { - name_disp = e_text_to_html (name, 0); + name_disp = camel_text_to_html (name, 0, 0); } if (have_email) { - email_disp = e_text_to_html (email, 0); + email_disp = camel_text_to_html (email, 0, 0); } if (i) @@ -1873,7 +1872,7 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea cia = camel_mime_message_get_from (message); buf = camel_address_format (CAMEL_ADDRESS (cia)); if (buf) { - html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL); + html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); g_string_sprintfa (retval, "%sFrom: %s
", citation, html); g_free (html); @@ -1883,7 +1882,7 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea cia = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); buf = camel_address_format (CAMEL_ADDRESS (cia)); if (buf) { - html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL); + html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); g_string_sprintfa (retval, "%sTo: %s
", citation, html); g_free (html); @@ -1893,7 +1892,7 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea cia = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); buf = camel_address_format (CAMEL_ADDRESS (cia)); if (buf) { - html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL); + html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); g_string_sprintfa (retval, "%sCc: %s
", citation, html); g_free (html); @@ -1902,7 +1901,8 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea buf = (char *) camel_mime_message_get_subject (message); if (buf) { - html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); + html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | + CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); g_string_sprintfa (retval, "%sSubject: %s
", citation, html); g_free (html); @@ -1910,7 +1910,7 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea date_val = camel_mime_message_get_date (message, &offset); buf = header_format_date (date_val, offset); - html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL); + html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); g_string_sprintfa (retval, "%sDate: %s
", citation, html); g_free (html); g_free (buf); @@ -1982,8 +1982,9 @@ mail_get_message_body (CamelDataWrapper *data, gboolean want_plain, gboolean cit if (text && !header_content_type_is (mime_type, "text", "html")) { char *html; - html = e_text_to_html (text, E_TEXT_TO_HTML_PRE | E_TEXT_TO_HTML_CONVERT_URLS | - (cite ? E_TEXT_TO_HTML_CITE : 0)); + html = camel_text_to_html (text, CAMEL_MIME_FILTER_TOHTML_PRE | + CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | + (cite ? CAMEL_MIME_FILTER_TOHTML_CITE : 0), 0); g_free (text); text = html; } diff --git a/mail/mail-ops.c b/mail/mail-ops.c index dd5717757d..81c5447f5d 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -45,7 +45,6 @@ #include "mail-session.h" #include "composer/e-msg-composer.h" #include "folder-browser.h" -#include "e-util/e-html-utils.h" #include "filter/filter-filter.h" diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 79abe80523..b219d744ee 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -44,7 +44,6 @@ #include "mail-local.h" #include "mail-mt.h" #include "mail-folder-cache.h" -#include "e-util/e-html-utils.h" /* **************************************** */ -- cgit v1.2.3