aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-format.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-format.c')
-rw-r--r--mail/mail-format.c1023
1 files changed, 326 insertions, 697 deletions
diff --git a/mail/mail-format.c b/mail/mail-format.c
index f94e5c0935..7c71d293b1 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -40,6 +40,7 @@
#include <camel/camel-stream-null.h>
#include <camel/camel-stream-filter.h>
#include <camel/camel-multipart-signed.h>
+#include <camel/camel-mime-filter-enriched.h>
#include <camel/camel-mime-filter-tohtml.h>
#include <e-util/e-trie.h>
@@ -48,70 +49,48 @@
#include "mail.h"
#include "mail-tools.h"
#include "mail-display.h"
-#include "mail-stream-gtkhtml.h"
#include "mail-mt.h"
#include "mail-crypto.h"
-static const char *try_uudecoding (const char *start, CamelMimePart *part, guint offset,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static const char *try_inline_binhex (const char *start, CamelMimePart *part, guint offset,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-
-static ssize_t mail_format_data_wrapper_write_to_stream (CamelDataWrapper *wrapper, MailDisplay *mail_display,
+static ssize_t mail_format_data_wrapper_write_to_stream (CamelDataWrapper *wrapper,
+ MailDisplay *mail_display,
CamelStream *stream);
-static gboolean handle_text_plain (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_text_plain_flowed (char *text, CamelMimePart *part,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_text_enriched (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_text_html (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_image (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_multipart_mixed (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_multipart_related (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_multipart_alternative (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_multipart_appledouble (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_multipart_encrypted (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_multipart_signed (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_message_rfc822 (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-static gboolean handle_message_external_body (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-
-static gboolean handle_via_bonobo (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
+static gboolean handle_text_plain (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_text_enriched (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_text_html (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_image (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_multipart_mixed (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_multipart_related (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_multipart_alternative (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_multipart_appledouble (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_multipart_encrypted (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_multipart_signed (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_message_rfc822 (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+static gboolean handle_message_external_body (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
+
+static gboolean handle_via_bonobo (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
/* writes the header info for a mime message into an html stream */
-static void write_headers (CamelMimeMessage *message, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream);
+static void write_headers (MailDisplayStream *stream, MailDisplay *md, CamelMimeMessage *message);
/* dispatch html printing via mimetype */
-static gboolean format_mime_part (CamelMimePart *part, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream);
+static gboolean format_mime_part (CamelMimePart *part, MailDisplay *md, MailDisplayStream *stream);
static void
free_url (gpointer key, gpointer value, gpointer data)
@@ -144,7 +123,7 @@ free_data_urls (gpointer urls)
**/
void
mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplayStream *stream)
{
GHashTable *hash;
@@ -176,8 +155,8 @@ mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md,
(GDestroyNotify) g_hash_table_destroy);
}
- write_headers (mime_message, md, html, stream);
- format_mime_part (CAMEL_MIME_PART (mime_message), md, html, stream);
+ write_headers (stream, md, mime_message);
+ format_mime_part (CAMEL_MIME_PART (mime_message), md, stream);
}
@@ -190,22 +169,20 @@ mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md,
**/
void
mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplayStream *stream)
{
CamelStreamFilter *filtered_stream;
CamelMimeFilter *html_filter;
CamelDataWrapper *wrapper;
- CamelStream *mail_stream;
guint32 flags;
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (mime_message));
wrapper = CAMEL_DATA_WRAPPER (mime_message);
- if (!mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL))
+ if (!mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL))
return;
- mail_stream = mail_stream_gtkhtml_new (html, stream);
- filtered_stream = camel_stream_filter_new_with_stream (mail_stream);
+ filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream);
flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
CAMEL_MIME_FILTER_TOHTML_ESCAPE_8BIT;
@@ -213,11 +190,12 @@ mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md,
camel_stream_filter_add (filtered_stream, html_filter);
camel_object_unref (html_filter);
- camel_stream_write (mail_stream, "<tt>", 4);
+ camel_stream_write ((CamelStream *) stream, "<tt>", 4);
+
mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream);
camel_object_unref (filtered_stream);
- camel_stream_write (mail_stream, "</tt>", 5);
- camel_object_unref (mail_stream);
+
+ camel_stream_write ((CamelStream *) stream, "</tt>", 5);
}
static const char *
@@ -442,7 +420,7 @@ mail_lookup_handler (const char *mime_type)
handler->generic = FALSE;
goto reg;
}
-
+
/* Try for the first matching component. (we don't use get_short_list_comps
* as that will return NULL if the oaf files don't have the short_list properties
* defined). */
@@ -632,36 +610,35 @@ mail_part_set_default_displayed_inline (CamelMimePart *part, MailDisplay *md,
static void
attachment_header (CamelMimePart *part, const char *mime_type, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplayStream *stream)
{
char *htmlinfo;
const char *info;
/* Start the table, create the pop-up object. */
- mail_html_write (html, stream,
- "<table cellspacing=0 cellpadding=0>"
- "<tr><td><table width=10 cellspacing=0 cellpadding=0><tr><td></td></tr></table></td>");
+ camel_stream_write_string ((CamelStream *) stream, "<table cellspacing=0 cellpadding=0><tr><td>"
+ "<table width=10 cellspacing=0 cellpadding=0>"
+ "<tr><td></td></tr></table></td>");
if (!md->printing) {
- gtk_html_stream_printf (stream, "<td><object classid=\"popup:%s\" type=\"%s\"></object></td>",
- get_cid (part, md), mime_type);
+ camel_stream_printf ((CamelStream *) stream, "<td><object classid=\"popup:%s\""
+ "type=\"%s\"></object></td>", get_cid (part, md), mime_type);
}
- mail_html_write (html, stream,
- "<td><table width=3 cellspacing=0 cellpadding=0><tr><td></td></tr></table></td>"
- "<td><font size=-1>");
+ camel_stream_write_string ((CamelStream *) stream, "<td><table width=3 cellspacing=0 cellpadding=0>"
+ "<tr><td></td></tr></table></td><td><font size=-1>");
/* Write the MIME type */
info = gnome_vfs_mime_get_description (mime_type);
htmlinfo = e_text_to_html (info ? info : mime_type, 0);
- gtk_html_stream_printf (stream, _("%s attachment"), htmlinfo);
+ 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);
- gtk_html_stream_printf (stream, " (%s)", htmlinfo);
+ camel_stream_printf ((CamelStream *) stream, " (%s)", htmlinfo);
g_free (htmlinfo);
}
@@ -669,18 +646,18 @@ attachment_header (CamelMimePart *part, const char *mime_type, MailDisplay *md,
info = camel_mime_part_get_description (part);
if (info) {
htmlinfo = e_text_to_html (info, md->printing ? 0 : E_TEXT_TO_HTML_CONVERT_URLS);
- gtk_html_stream_printf (stream, ", \"%s\"", htmlinfo);
+ camel_stream_printf ((CamelStream *) stream, ", \"%s\"", htmlinfo);
g_free (htmlinfo);
}
- mail_html_write (html, stream, "</font></td></tr><tr>"
- "<td height=10><table cellspacing=0 cellpadding=0>"
- "<tr><td height=10><a name=\"glue\"></td></tr></table></td></tr></table>\n");
+ camel_stream_write_string ((CamelStream *) stream, "</font></td></tr><tr><td height=10>"
+ "<table cellspacing=0 cellpadding=0><tr><td height=10>"
+ "<a name=\"glue\"></td></tr></table></td></tr></table>\n");
}
static gboolean
format_mime_part (CamelMimePart *part, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplayStream *stream)
{
CamelDataWrapper *wrapper;
char *mime_type, *tmp;
@@ -696,9 +673,9 @@ format_mime_part (CamelMimePart *part, MailDisplay *md,
if (CAMEL_IS_MULTIPART (wrapper) &&
camel_multipart_get_number (CAMEL_MULTIPART (wrapper)) == 0) {
- mail_error_printf (html, stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
- if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL))
- handle_text_plain (part, "text/plain", md, html, stream);
+ mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
+ if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL))
+ handle_text_plain (part, "text/plain", md, stream);
return TRUE;
}
@@ -731,11 +708,11 @@ format_mime_part (CamelMimePart *part, MailDisplay *md,
/* No header for anonymous inline parts. */
if (!((inline_flags & I_ACTUALLY) && is_anonymous (part, mime_type)))
- attachment_header (part, mime_type, md, html, stream);
+ attachment_header (part, mime_type, md, stream);
if (handler && handler->builtin && inline_flags & I_DISPLAYED &&
- mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL))
- output = (*handler->builtin) (part, mime_type, md, html, stream);
+ mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL))
+ output = (*handler->builtin) (part, mime_type, md, stream);
else
output = TRUE;
@@ -750,55 +727,55 @@ enum {
};
static void
-write_field_row_begin (const char *name, int flags, GtkHTML *html, GtkHTMLStream *stream)
+write_field_row_begin (MailDisplayStream *stream, const char *name, int flags)
{
gboolean bold = (flags & WRITE_BOLD);
gboolean nocolumns = (flags & WRITE_NOCOLUMNS);
if (nocolumns) {
- gtk_html_stream_printf (stream, "<tr><td>%s%s:%s ",
- bold ? "<b>" : "", name,
- bold ? "</b>" : "");
+ camel_stream_printf ((CamelStream *) stream, "<tr><td>%s%s:%s ",
+ bold ? "<b>" : "", name, bold ? "</b>" : "");
} else {
- gtk_html_stream_printf (stream, "<tr><%s align=\"right\" valign=\"top\">%s:"
- "<b>&nbsp;</%s><td>", bold ? "th" : "td",
- name, bold ? "th" : "td");
+ camel_stream_printf ((CamelStream *) stream,
+ "<tr><%s align=\"right\" valign=\"top\">%s:"
+ "<b>&nbsp;</%s><td>", bold ? "th" : "td",
+ name, bold ? "th" : "td");
}
}
static void
-write_date (CamelMimeMessage *message, int flags, GtkHTML *html, GtkHTMLStream *stream)
+write_date (MailDisplayStream *stream, CamelMimeMessage *message, int flags)
{
const char *datestr;
datestr = camel_medium_get_header (CAMEL_MEDIUM (message), "Date");
if (datestr) {
- write_field_row_begin (_("Date"), flags, html, stream);
- gtk_html_stream_printf (stream, "%s</td> </tr>", datestr);
+ write_field_row_begin (stream, _("Date"), flags);
+ camel_stream_printf ((CamelStream *) stream, "%s</td> </tr>", datestr);
}
}
static void
-write_text_header (const char *name, const char *value, int flags, GtkHTML *html, GtkHTMLStream *stream)
+write_text_header (MailDisplayStream *stream, const char *name, const char *value, int flags)
{
char *encoded;
-
+
if (value && *value)
encoded = e_text_to_html (value, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS);
else
encoded = "";
- write_field_row_begin (name, flags, html, stream);
+ write_field_row_begin (stream, name, flags);
- gtk_html_stream_printf (stream, "%s</td> </tr>", encoded);
+ camel_stream_printf ((CamelStream *) stream, "%s</td></tr>", encoded);
if (value && *value)
g_free (encoded);
}
static void
-write_address (MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream,
+write_address (MailDisplay *md, MailDisplayStream *stream,
const CamelInternetAddress *addr, const char *field_name, int flags)
{
const char *name, *email;
@@ -807,16 +784,16 @@ write_address (MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream,
if (addr == NULL || !camel_internet_address_get (addr, 0, NULL, NULL))
return;
- write_field_row_begin (field_name, flags, html, stream);
+ write_field_row_begin (stream, field_name, flags);
i = 0;
while (camel_internet_address_get (addr, i, &name, &email)) {
CamelInternetAddress *subaddr;
- gchar *addr_txt, *addr_url;
+ char *addr_txt, *addr_url;
gboolean have_name = name && *name;
gboolean have_email = email && *email;
- gchar *name_disp = NULL;
- gchar *email_disp = NULL;
+ char *name_disp = NULL;
+ char *email_disp = NULL;
subaddr = camel_internet_address_new ();
camel_internet_address_add (subaddr, name, email);
@@ -833,32 +810,32 @@ write_address (MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream,
}
if (i)
- mail_html_write (html, stream, ", ");
+ camel_stream_write_string ((CamelStream *) stream, ", ");
if (have_email || have_name) {
- if (!have_email) {
+ if (!have_email)
email_disp = g_strdup ("???");
- }
if (have_name) {
if (md->printing) {
- gtk_html_stream_printf (stream, "%s &lt;%s&gt;", name_disp, email_disp);
+ camel_stream_printf ((CamelStream *) stream,
+ "%s &lt;%s&gt;", name_disp, email_disp);
} else {
- gtk_html_stream_printf (stream,
- "%s &lt;<a href=\"mailto:%s\">%s</a>&gt;",
- name_disp, addr_url, email_disp);
+ camel_stream_printf ((CamelStream *) stream,
+ "%s &lt;<a href=\"mailto:%s\">%s</a>&gt;",
+ name_disp, addr_url, email_disp);
}
} else {
if (md->printing) {
- mail_html_write (html, stream, email_disp);
+ camel_stream_write_string ((CamelStream *) stream, email_disp);
} else {
- gtk_html_stream_printf (stream,
- "<a href=\"mailto:%s\">%s</a>",
- addr_url, email_disp);
+ camel_stream_printf ((CamelStream *) stream,
+ "<a href=\"mailto:%s\">%s</a>",
+ addr_url, email_disp);
}
}
} else {
- gtk_html_stream_printf (stream, "<i>%s</i>", _("Bad Address"));
+ camel_stream_printf ((CamelStream *) stream, "<i>%s</i>", _("Bad Address"));
}
g_free (name_disp);
@@ -869,7 +846,7 @@ write_address (MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream,
i++;
}
- mail_html_write (html, stream, "</td></tr>");
+ camel_stream_write_string ((CamelStream *) stream, "</td></tr>");
}
/* order of these must match write_header code */
@@ -893,39 +870,39 @@ default_header_index (const char *name)
/* index is index of header in default_headers array */
static void
write_default_header (CamelMimeMessage *message, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream,
+ MailDisplayStream *stream,
int index, int flags)
{
switch (index) {
case 0:
- write_address (md, html, stream,
+ write_address (md, stream,
camel_mime_message_get_from (message), _("From"), flags | WRITE_BOLD);
break;
case 1:
- write_address (md, html, stream,
+ write_address (md, stream,
camel_mime_message_get_reply_to (message), _("Reply-To"), flags | WRITE_BOLD);
break;
case 2:
- write_address (md, html, stream,
+ write_address (md, stream,
camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO),
_("To"), flags | WRITE_BOLD);
break;
case 3:
- write_address (md, html, stream,
+ write_address (md, stream,
camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC),
_("Cc"), flags | WRITE_BOLD);
break;
case 4:
- write_address (md, html, stream,
+ write_address (md, stream,
camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC),
_("Bcc"), flags | WRITE_BOLD);
break;
case 5:
- write_text_header (_("Subject"), camel_mime_message_get_subject (message),
- flags | WRITE_BOLD, html, stream);
+ write_text_header (stream, _("Subject"), camel_mime_message_get_subject (message),
+ flags | WRITE_BOLD);
break;
case 6:
- write_date (message, flags | WRITE_BOLD, html, stream);
+ write_date (stream, message, flags | WRITE_BOLD);
break;
default:
g_assert_not_reached ();
@@ -934,7 +911,7 @@ write_default_header (CamelMimeMessage *message, MailDisplay *md,
static gboolean
write_xmailer_header (CamelMimeMessage *message, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream,
+ MailDisplayStream *stream,
MailConfigXMailerDisplayStyle xm)
{
const char *xmailer, *evolution;
@@ -949,7 +926,7 @@ write_xmailer_header (CamelMimeMessage *message, MailDisplay *md,
evolution = strstr (xmailer, "Evolution");
if ((xm & MAIL_CONFIG_XMAILER_OTHER) ||
(evolution && (xm & MAIL_CONFIG_XMAILER_EVO)))
- write_text_header (_("Mailer"), xmailer, WRITE_BOLD, html, stream);
+ write_text_header (stream, _("Mailer"), xmailer, WRITE_BOLD);
return evolution != NULL && (xm & MAIL_CONFIG_XMAILER_RUPERT_APPROVED);
}
@@ -957,8 +934,7 @@ write_xmailer_header (CamelMimeMessage *message, MailDisplay *md,
#define COLOR_IS_LIGHT(r, g, b) ((r + g + b) > (128 * 3))
static void
-write_headers (CamelMimeMessage *message, MailDisplay *md,
- GtkHTML *html, GtkHTMLStream *stream)
+write_headers (MailDisplayStream *stream, MailDisplay *md, CamelMimeMessage *message)
{
MailConfigXMailerDisplayStyle xm = mail_config_get_x_mailer_display_style ();
gboolean full = (md->display_style == MAIL_CONFIG_DISPLAY_FULL_HEADERS);
@@ -970,9 +946,9 @@ write_headers (CamelMimeMessage *message, MailDisplay *md,
/* My favorite thing to do... muck around with colors so we respect people's stupid themes.
However, we only do this if we are rendering to the screen -- we ignore the theme
when we are printing. */
- style = gtk_widget_get_style (GTK_WIDGET (html));
+ style = gtk_widget_get_style (GTK_WIDGET (md->html));
if (style && !md->printing) {
- int state = GTK_WIDGET_STATE (GTK_WIDGET (html));
+ int state = GTK_WIDGET_STATE (GTK_WIDGET (md->html));
gushort r, g, b;
r = style->base[state].red / 256;
@@ -1001,20 +977,28 @@ write_headers (CamelMimeMessage *message, MailDisplay *md,
strcpy (fontcolor, "000000");
}
- gtk_html_stream_printf (
- stream,
- "<table width=\"100%%\" cellpadding=0 cellspacing=0>"
- /* Top margin */
- "<tr><td colspan=3 height=10><table cellpadding=0 cellspacing=0><tr><td height=10><a name=\"glue\"></td></tr></table></td></tr>"
- /* Left margin */
- "<tr><td><table width=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>"
- /* Black border */
- "<td width=\"100%%\"><table bgcolor=\"#000000\" width=\"100%%\" cellspacing=0 cellpadding=1>"
- /* Main header box */
- "<tr><td><table bgcolor=\"#%s\" width=\"100%%\" cellpadding=0 cellspacing=0>"
- /* Internal header table */
- "<tr valign=top><td><table><font color=\"#%s\">\n",
- bgcolor, fontcolor);
+ camel_stream_write_string ((CamelStream *) stream,
+ "<table width=\"100%\" cellpadding=0 cellspacing=0>");
+
+ /* Top margin */
+ camel_stream_write_string ((CamelStream *) stream, "<tr><td colspan=3 height=10>"
+ "<table cellpadding=0 cellspacing=0><tr><td height=10>"
+ "<a name=\"glue\"></td></tr></table></td></tr>");
+
+ /* Left margin */
+ camel_stream_write_string ((CamelStream *) stream, "<tr><td><table width=10 "
+ "cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>");
+
+ /* Black border */
+ camel_stream_write_string ((CamelStream *) stream, "<td width=\"100%\"><table bgcolor=\"#000000\" "
+ "width=\"100%\" cellspacing=0 cellpadding=1>");
+
+ /* Main header box */
+ camel_stream_printf ((CamelStream *) stream, "<tr><td><table bgcolor=\"#%s\" width=\"100%%\" "
+ "cellpadding=0 cellspacing=0>"
+ /* Internal header table */
+ "<tr valign=top><td><table><font color=\"#%s\">\n",
+ bgcolor, fontcolor);
if (full) {
struct _header_raw *header;
@@ -1031,38 +1015,37 @@ write_headers (CamelMimeMessage *message, MailDisplay *md,
i = default_header_index (header->name);
if (i == -1) {
value = header_decode_string (header->value, charset);
- write_text_header (header->name, value, WRITE_NOCOLUMNS, html, stream);
+ write_text_header (stream, header->name, value, WRITE_NOCOLUMNS);
g_free (value);
} else
- write_default_header (message, md, html, stream, i, WRITE_NOCOLUMNS);
+ write_default_header (message, md, stream, i, WRITE_NOCOLUMNS);
header = header->next;
}
} else {
for (i = 0; i < sizeof (default_headers) / sizeof (default_headers[0]); i++)
- write_default_header (message, md, html, stream, i, 0);
+ write_default_header (message, md, stream, i, 0);
if (xm != MAIL_CONFIG_XMAILER_NONE)
- evo_icon = write_xmailer_header (message, md, html, stream, xm);
+ evo_icon = write_xmailer_header (message, md, stream, xm);
}
/* Close off the internal header table */
- mail_html_write (html, stream, "</font></table></td>");
+ camel_stream_write_string ((CamelStream *) stream, "</font></table></td>");
if (!md->printing && evo_icon) {
- gtk_html_stream_printf (stream,
- "<td align=right><table><tr><td width=16>"
- "<img src=\"%s\">"
- "</td></tr></table></td>",
- mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/monkey-16.png"));
+ camel_stream_printf ((CamelStream *) stream, "<td align=right><table><tr><td width=16>"
+ "<img src=\"%s\"></td></tr></table></td>",
+ mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/monkey-16.png"));
}
- mail_html_write (html, stream,
- /* Main header box */
- "</tr></table>"
- /* Black border */
- "</td></tr></table></td>"
- /* Right margin */
- "<td><table width=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>"
- "</tr></table>\n");
+ camel_stream_write_string ((CamelStream *) stream,
+ /* Main header box */
+ "</tr></table>"
+ /* Black border */
+ "</td></tr></table></td>"
+ /* Right margin */
+ "<td><table width=10 cellpadding=0 cellspacing=0>"
+ "<tr><td></td></tr></table></td>"
+ "</tr></table>\n");
}
static void
@@ -1078,17 +1061,20 @@ load_offline_content (MailDisplay *md, gpointer data)
}
gboolean
-mail_content_loaded (CamelDataWrapper *wrapper, MailDisplay *md, gboolean redisplay, const gchar *url,
- GtkHTML *html, GtkHTMLStream *handle)
+mail_content_loaded (CamelDataWrapper *wrapper, MailDisplay *md, gboolean redisplay, const char *url,
+ GtkHTML *html, GtkHTMLStream *stream)
{
if (!camel_data_wrapper_is_offline (wrapper))
return TRUE;
camel_object_ref (wrapper);
- if (redisplay)
- mail_display_redisplay_when_loaded (md, wrapper, load_offline_content, html, wrapper);
- else
- mail_display_stream_write_when_loaded (md, wrapper, url, load_offline_content, html, handle, wrapper);
+ if (redisplay) {
+ mail_display_redisplay_when_loaded (md, wrapper, load_offline_content,
+ html, wrapper);
+ } else {
+ mail_display_stream_write_when_loaded (md, wrapper, url, load_offline_content,
+ html, stream, wrapper);
+ }
return FALSE;
}
@@ -1179,216 +1165,55 @@ mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_
}
static void
-write_hr (GtkHTML *html, GtkHTMLStream *stream)
+write_hr (MailDisplayStream *stream)
{
- mail_html_write (html, stream,
- "<table cellspacing=0 cellpadding=10 width=\"100%\"><tr><td width=\"100%\">"
- "<hr noshadow size=1></td></tr></table>\n");
+ camel_stream_write_string ((CamelStream *) stream, "<table cellspacing=0 cellpadding=10 "
+ "width=\"100%\"><tr><td width=\"100%\"><hr noshadow size=1>"
+ "</td></tr></table>\n");
}
/*----------------------------------------------------------------------*
* Mime handling functions
*----------------------------------------------------------------------*/
-struct {
- const char *start;
- const char * (*handler) (const char *start, CamelMimePart *part, guint offset,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
-} text_specials[] = {
- { "\nbegin ", try_uudecoding },
- { "\n(This file must be converted with BinHex 4.0)\n", try_inline_binhex }
-};
-
-static int num_specials = (sizeof (text_specials) / sizeof (text_specials[0]));
-
-static void
-write_one_text_plain_chunk (MailDisplay *md, CamelMimePart *part, gint idx, const char *text, int len, GtkHTML *html, GtkHTMLStream *stream, gboolean printing)
-{
- char *buf;
-
- buf = g_strndup (text, len);
- mail_text_write (html, stream, md, part, idx, printing, buf);
- g_free (buf);
-}
-
static gboolean
handle_text_plain (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
- const char *format, *start, *p;
+ CamelStreamFilter *filtered_stream;
+ CamelMimeFilter *html_filter;
CamelDataWrapper *wrapper;
+ guint32 flags, colour = 0;
CamelContentType *type;
- gboolean check_specials;
- GByteArray *bytes;
- int i, idx = 0;
- char *text;
-
- wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
-
- bytes = mail_format_get_data_wrapper_text (wrapper, md);
- if (!bytes)
- return FALSE;
+ const char *format;
- g_byte_array_append (bytes, "", 1);
- text = bytes->data;
- g_byte_array_free (bytes, FALSE);
-
- /* Check to see if this is a broken text/html part with content-type text/plain */
- /* NOTE: isn't this done in camel now ? */
- start = text;
- while (isspace ((unsigned) *start))
- start++;
- if (!strncasecmp (start, "<html>", 6) || !strncasecmp (start, "<!DOCTYPE HTML", 14)) {
- g_free (text);
- return handle_text_html (part, "text/html", md, html, stream);
+ flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES;
+ if (!md->printing) {
+ flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES;
+ if (mail_config_get_citation_highlight ()) {
+ flags |= CAMEL_MIME_FILTER_TOHTML_MARK_CITATION;
+ colour = mail_config_get_citation_color ();
+ }
}
/* Check for RFC 2646 flowed text. */
type = camel_mime_part_get_content_type (part);
format = header_content_type_param (type, "format");
if (format && !strcasecmp (format, "flowed"))
- return handle_text_plain_flowed (text, part, md, html, stream);
-
- /* Only look for binhex and stuff if this is real text/plain.
- * (and not, say, application/mac-binhex40 that mail-identify
- * has decided to call text/plain because it starts with English
- * text...)
- */
- check_specials = !strcasecmp (mime_type, "text/plain");
-
- p = text;
- while (p && check_specials) {
- /* Look for special cases. */
- for (i = 0; i < num_specials; i++) {
- start = strstr (p, text_specials[i].start);
- if (start && (start == p || start[-1] == '\n'))
- break;
- }
- if (i == num_specials)
- break;
-
- /* Deal with special case */
- if (start != p)
- write_one_text_plain_chunk (md, part, idx ++, p, start - p, html, stream, md->printing);
-
- p = text_specials[i].handler (start, part, start - text, md, html, stream);
- if (p == start) {
- /* Oops. That failed. Output this line normally and
- * skip over it.
- */
- p = strchr (start, '\n');
- /* Last line, drop out, and dump */
- if (p == NULL) {
- p = start;
- break;
- }
- p++;
- write_one_text_plain_chunk (md, part, idx ++, start, p - start, html, stream, md->printing);
- } else if (p)
- write_hr (html, stream);
- }
- /* Finish up (or do the whole thing if there were no specials). */
- if (p)
- write_one_text_plain_chunk (md, part, idx ++, p, strlen (p), html, stream, md->printing);
+ flags |= 0 /*CAMEL_MIME_FILTER_TOHTML_FORMAT_FLOWED*/;
- g_free (text);
-
- return TRUE;
-}
-
-static gboolean
-handle_text_plain_flowed (char *buf, CamelMimePart *part, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
-{
- char *iframe, *text, *line, *eol, *xed, *p;
- int prevquoting = 0, quoting, len, br_pending = 0;
- guint32 citation_color = mail_config_get_citation_color ();
- GByteArray *ba;
-
- ba = g_byte_array_new ();
- g_byte_array_append (ba, "\n<!-- text/plain, flowed -->\n<tt>\n", 34);
-
- for (line = buf; *line; line = eol + 1) {
- /* Process next line */
- eol = strchr (line, '\n');
- if (eol)
- *eol = '\0';
-
- quoting = 0;
- for (p = line; *p == '>'; p++)
- quoting++;
- if (quoting != prevquoting) {
- if (prevquoting == 0) {
- if (md->printing)
- g_byte_array_append (ba, "<i>", 3);
- else {
- char num[7];
-
- g_byte_array_append (ba, "<font color=\"#", 14);
- g_snprintf (num, 6, "%06x", citation_color);
- g_byte_array_append (ba, num, 6);
- g_byte_array_append (ba, "\">", 2);
- }
- if (br_pending)
- br_pending--;
- }
- while (quoting > prevquoting) {
- g_byte_array_append (ba, "<blockquote type=\"cite\">", 24);
- prevquoting++;
- }
- while (quoting < prevquoting) {
- g_byte_array_append (ba, "</blockquote>", 13);
- prevquoting--;
- }
- if (quoting == 0) {
- if (md->printing)
- g_byte_array_append (ba, "</i>", 4);
- else
- g_byte_array_append (ba, "</font>\n", 8);
- if (br_pending)
- br_pending--;
- }
- }
-
- if (*p == ' ')
- p++;
- len = strlen (p);
- if (len == 0) {
- br_pending++;
- if (!eol)
- break;
- continue;
- }
-
- while (br_pending) {
- g_byte_array_append (ba, "<br>\n", 5);
- br_pending--;
- }
-
- /* replace '<' with '&lt;', etc. */
- text = e_text_to_html (p,
- md->printing ?
- E_TEXT_TO_HTML_CONVERT_SPACES :
- E_TEXT_TO_HTML_CONVERT_SPACES | E_TEXT_TO_HTML_CONVERT_URLS);
- if (text && *text)
- g_byte_array_append (ba, text, strlen (text));
- g_free (text);
-
- if ((len > 0 && p[len - 1]) != ' ' || !strcmp (p, "-- "))
- br_pending++;
-
- if (!eol)
- break;
- }
+ html_filter = camel_mime_filter_tohtml_new (flags, colour);
+ filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream);
+ camel_stream_filter_add (filtered_stream, html_filter);
+ camel_object_unref (html_filter);
- g_free (buf);
+ camel_stream_write ((CamelStream *) stream, "<tt>\n", 5);
- g_byte_array_append (ba, "</tt>\n", 6);
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+ mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream);
- xed = g_strdup_printf ("x-evolution-data:%p", part);
- 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);
- mail_html_write (html, stream, iframe);
- g_free (iframe);
+ camel_stream_write ((CamelStream *) stream, "</tt>\n", 6);
+ camel_object_unref (filtered_stream);
return TRUE;
}
@@ -1426,247 +1251,48 @@ destroy_part (CamelObject *root, gpointer event_data, gpointer user_data)
camel_object_unref (user_data);
}
-static const char *
-try_uudecoding (const char *start, CamelMimePart *mime_part,
- guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
-{
- int mode, len, state = CAMEL_UUDECODE_STATE_INIT;
- char *filename, *estart, *p, *out;
- CamelMimePart *part;
- guint32 save = 0;
-
- /* Make sure it's a real uudecode begin line:
- * begin [0-7]+ .*
- */
- mode = strtoul (start + 6, &p, 8);
- if (p == start + 6 || *p != ' ')
- return start;
-
- estart = strchr (start, '\n');
- if (!estart)
- return start;
-
- while (isspace ((unsigned char)*p))
- p++;
-
- filename = g_strndup (p, estart++ - p);
-
- /* Make sure there's an end line. */
- p = strstr (p, "\nend\n");
- if (!p) {
- g_free (filename);
- return start;
- }
-
- out = g_malloc (p - estart);
- len = uudecode_step (estart, p - estart, out, &state, &save);
-
- part = fake_mime_part_from_data (out, len, "application/octet-stream",
- offset, md);
- g_free (out);
- camel_mime_part_set_filename (part, filename);
- g_free (filename);
- camel_object_hook_event (md->current_message, "finalize", destroy_part, part);
-
- write_hr (html, stream);
- format_mime_part (part, md, html, stream);
-
- return p + 4;
-}
-
-static const char *
-try_inline_binhex (const char *start, CamelMimePart *mime_part,
- guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
-{
- char *p;
- CamelMimePart *part;
-
- /* Find data start. */
- p = strstr (start, "\n:");
- if (!p)
- return start;
-
- /* And data end. */
- p = strchr (p + 2, ':');
- if (!p || (*(p + 1) != '\n' && *(p + 1) != '\0'))
- return start;
- p += 2;
-
- part = fake_mime_part_from_data (start, p - start,
- "application/mac-binhex40",
- offset, md);
- camel_object_hook_event (md->current_message, "finalize", destroy_part, part);
-
- write_hr (html, stream);
- format_mime_part (part, md, html, stream);
-
- return p;
-}
-
/* text/enriched (RFC 1896) or text/richtext (included in RFC 1341) */
static gboolean
handle_text_enriched (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
- static GHashTable *translations = NULL;
- CamelDataWrapper *wrapper =
- camel_medium_get_content_object (CAMEL_MEDIUM (part));
- GByteArray *ba, *bytes;
- char *text, *p, *xed;
- int len, nofill = 0;
- gboolean enriched;
- GString *string;
-
- if (!translations) {
- translations = g_hash_table_new (g_strcase_hash, g_strcase_equal);
-
- /* FIXME: this should be read from a table */
- g_hash_table_insert (translations, "bold", "<b>");
- g_hash_table_insert (translations, "/bold", "</b>");
- g_hash_table_insert (translations, "italic", "<i>");
- g_hash_table_insert (translations, "/italic", "</i>");
- g_hash_table_insert (translations, "fixed", "<tt>");
- g_hash_table_insert (translations, "/fixed", "</tt>");
- g_hash_table_insert (translations, "smaller", "<font size=-1>");
- g_hash_table_insert (translations, "/smaller", "</font>");
- g_hash_table_insert (translations, "bigger", "<font size=+1>");
- g_hash_table_insert (translations, "/bigger", "</font>");
- g_hash_table_insert (translations, "underline", "<u>");
- g_hash_table_insert (translations, "/underline", "</u>");
- g_hash_table_insert (translations, "center", "<p align=center>");
- g_hash_table_insert (translations, "/center", "</p>");
- g_hash_table_insert (translations, "flushleft", "<p align=left>");
- g_hash_table_insert (translations, "/flushleft", "</p>");
- g_hash_table_insert (translations, "flushright", "<p align=right>");
- g_hash_table_insert (translations, "/flushright", "</p>");
- g_hash_table_insert (translations, "excerpt", "<blockquote>");
- g_hash_table_insert (translations, "/excerpt", "</blockquote>");
- g_hash_table_insert (translations, "paragraph", "<p>");
- g_hash_table_insert (translations, "signature", "<address>");
- g_hash_table_insert (translations, "/signature", "</address>");
- g_hash_table_insert (translations, "comment", "<!-- ");
- g_hash_table_insert (translations, "/comment", " -->");
- g_hash_table_insert (translations, "param", "<!-- ");
- g_hash_table_insert (translations, "/param", " -->");
- g_hash_table_insert (translations, "np", "<hr>");
- }
+ CamelStreamFilter *filtered_stream;
+ CamelMimeFilter *enriched;
+ CamelDataWrapper *wrapper;
+ guint32 flags = 0;
- bytes = mail_format_get_data_wrapper_text (wrapper, md);
- if (!bytes)
- return FALSE;
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
if (!strcasecmp (mime_type, "text/richtext")) {
- enriched = FALSE;
- mail_html_write (html, stream,
- "\n<!-- text/richtext -->\n");
+ flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT;
+ camel_stream_write_string ((CamelStream *) stream, "\n<!-- text/richtext -->\n");
} else {
- enriched = TRUE;
- mail_html_write (html, stream,
- "\n<!-- text/enriched -->\n");
+ camel_stream_write_string ((CamelStream *) stream, "\n<!-- text/enriched -->\n");
}
- /* This is not great code, but I don't feel like fixing it right
- * now. I mean, it's just text/enriched...
- */
- string = g_string_sized_new (2 * bytes->len);
- g_byte_array_append (bytes, "", 1);
- p = text = bytes->data;
- g_byte_array_free (bytes, FALSE);
-
- while (p) {
- len = strcspn (p, " <>&\n");
- if (len)
- g_string_append_len (string, p, len);
-
- p += len;
- if (!*p)
- break;
-
- switch (*p++) {
- case ' ':
- while (*p == ' ') {
- g_string_append (string, "&nbsp;");
- p++;
- }
- g_string_append (string, " ");
- break;
- case '\n':
- g_string_append (string, " ");
- if (enriched && nofill <= 0) {
- while (*p == '\n') {
- g_string_append (string, "<br>");
- p++;
- }
- }
- break;
- case '>':
- g_string_append (string, "&gt;");
- break;
- case '&':
- g_string_append (string, "&amp;");
- break;
- case '<':
- if (enriched) {
- if (*p == '<') {
- g_string_append (string, "&lt;");
- p++;
- break;
- }
- } else {
- if (strncmp (p, "lt>", 3) == 0) {
- g_string_append (string, "&lt;");
- p += 3;
- break;
- } else if (strncmp (p, "nl>", 3) == 0) {
- g_string_append (string, "<br>");
- p += 3;
- break;
- }
- }
-
- if (strncmp (p, "nofill>", 7) == 0) {
- nofill++;
- g_string_append (string, "<pre>");
- } else if (strncmp (p, "/nofill>", 8) == 0) {
- nofill--;
- g_string_append (string, "</pre>");
- } else {
- char *copy, *match;
-
- len = strcspn (p, ">");
- copy = g_strndup (p, len);
- match = g_hash_table_lookup (translations,
- copy);
- g_free (copy);
- if (match)
- g_string_append (string, match);
- }
-
- p = strchr (p, '>');
- if (p)
- p++;
- }
- }
- g_free (text);
+ enriched = camel_mime_filter_enriched_new (flags);
+ filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream);
+ camel_stream_filter_add (filtered_stream, enriched);
+ camel_object_unref (enriched);
- ba = g_byte_array_new ();
- g_byte_array_append (ba, (const guint8 *)string->str, string->len);
- g_string_free (string, TRUE);
+ camel_stream_write ((CamelStream *) stream, "<tt>\n", 5);
- xed = g_strdup_printf ("x-evolution-data:%p", part);
- gtk_html_stream_printf (stream, "<iframe src=\"%s\" frameborder=0 scrolling=no>could not get %s</iframe>", xed, xed);
- mail_display_add_url (md, "data_urls", xed, ba);
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+ mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream);
+
+ camel_stream_write ((CamelStream *) stream, "</tt>\n", 6);
+ camel_object_unref (filtered_stream);
return TRUE;
}
static gboolean
handle_text_html (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
const char *location, *base;
- mail_html_write (html, stream, "\n<!-- text/html -->\n");
+ camel_stream_write_string ((CamelStream *) stream, "\n<!-- text/html -->\n");
if ((base = camel_medium_get_header (CAMEL_MEDIUM (part), "Content-Base"))) {
char *base_url;
@@ -1682,27 +1308,30 @@ handle_text_html (CamelMimePart *part, const char *mime_type,
base = base_url;
}
- gtk_html_set_base (html, base);
+ gtk_html_set_base (md->html, base);
}
location = get_location (part, md);
if (!location)
location = get_cid (part, md);
- gtk_html_stream_printf (stream, "<iframe src=\"%s\" frameborder=0 scrolling=no>could not get %s</iframe>", location, location);
+
+ camel_stream_printf ((CamelStream *) stream, "<iframe src=\"%s\" frameborder=0 "
+ "scrolling=no>could not get %s</iframe>", location, location);
+
return TRUE;
}
static gboolean
-handle_image (CamelMimePart *part, const char *mime_type, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+handle_image (CamelMimePart *part, const char *mime_type, MailDisplay *md, MailDisplayStream *stream)
{
- gtk_html_stream_printf (stream, "<img hspace=10 vspace=10 src=\"%s\">",
- get_cid (part, md));
+ camel_stream_printf ((CamelStream *) stream, "<img hspace=10 vspace=10 src=\"%s\">",
+ get_cid (part, md));
return TRUE;
}
static gboolean
handle_multipart_mixed (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
CamelDataWrapper *wrapper =
camel_medium_get_content_object (CAMEL_MEDIUM (part));
@@ -1711,30 +1340,30 @@ handle_multipart_mixed (CamelMimePart *part, const char *mime_type,
gboolean output = FALSE;
if (!CAMEL_IS_MULTIPART (wrapper)) {
- mail_error_printf (html, stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
- if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL))
- handle_text_plain (part, "text/plain", md, html, stream);
+ mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
+ if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL))
+ handle_text_plain (part, "text/plain", md, stream);
return TRUE;
}
-
+
mp = CAMEL_MULTIPART (wrapper);
-
+
nparts = camel_multipart_get_number (mp);
for (i = 0; i < nparts; i++) {
if (i != 0 && output)
- write_hr (html, stream);
-
+ write_hr (stream);
+
part = camel_multipart_get_part (mp, i);
- output = format_mime_part (part, md, html, stream);
+ output = format_mime_part (part, md, stream);
}
-
+
return TRUE;
}
static gboolean
handle_multipart_encrypted (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
CamelMultipartEncrypted *mpe;
CamelMimePart *mime_part;
@@ -1745,7 +1374,7 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type,
/* Currently we only handle RFC2015-style PGP encryption. */
if (!camel_pgp_mime_is_rfc2015_encrypted (part))
- return handle_multipart_mixed (part, mime_type, md, html, stream);
+ return handle_multipart_mixed (part, mime_type, md, stream);
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
@@ -1757,12 +1386,12 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type,
camel_object_unref (cipher);
if (camel_exception_is_set (&ex)) {
- mail_error_printf (html, stream, "\n%s\n", camel_exception_get_description(&ex));
+ mail_error_printf (stream, "\n%s\n", camel_exception_get_description (&ex));
camel_exception_clear (&ex);
return TRUE;
}
- handled = format_mime_part (mime_part, md, html, stream);
+ handled = format_mime_part (mime_part, md, stream);
camel_object_unref (mime_part);
return handled;
@@ -1770,7 +1399,7 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type,
static gboolean
handle_multipart_signed (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
CamelMimePart *subpart;
CamelDataWrapper *wrapper;
@@ -1780,12 +1409,12 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type,
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
if (!CAMEL_IS_MULTIPART_SIGNED (wrapper)) {
- mail_error_printf (html, stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
- if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL))
- handle_text_plain (part, "text/plain", md, html, stream);
+ mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
+ if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL))
+ handle_text_plain (part, "text/plain", md, stream);
return TRUE;
}
-
+
mps = CAMEL_MULTIPART_SIGNED (wrapper);
/* if subpart & signature is null, what do we do? just write it out raw?
@@ -1793,18 +1422,18 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type,
this includes: more or less than 2 parts */
/* output the content */
- subpart = camel_multipart_get_part((CamelMultipart *)mps, CAMEL_MULTIPART_SIGNED_CONTENT);
+ subpart = camel_multipart_get_part ((CamelMultipart *) mps, CAMEL_MULTIPART_SIGNED_CONTENT);
if (subpart == NULL)
return FALSE;
- output = format_mime_part (subpart, md, html, stream);
+ output = format_mime_part (subpart, md, stream);
/* now handle the signature */
- subpart = camel_multipart_get_part((CamelMultipart *)mps, CAMEL_MULTIPART_SIGNED_SIGNATURE);
+ subpart = camel_multipart_get_part ((CamelMultipart *) mps, CAMEL_MULTIPART_SIGNED_SIGNATURE);
if (subpart == NULL)
return FALSE;
- mail_part_set_default_displayed_inline(subpart, md, FALSE);
+ mail_part_set_default_displayed_inline (subpart, md, FALSE);
if (!mail_part_is_displayed_inline (subpart, md) && !md->printing) {
char *url;
@@ -1812,23 +1441,24 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type,
/* Write out the click-for-info object */
url = g_strdup_printf ("signature:%p/%lu", subpart,
(unsigned long)time (NULL));
- gtk_html_stream_printf (stream,
- "<br><table cellspacing=0 cellpadding=0>"
- "<tr><td><table width=10 cellspacing=0 cellpadding=0>"
- "<tr><td></td></tr></table></td>"
- "<td><object classid=\"%s\"></object></td>"
- "<td><table width=3 cellspacing=0 cellpadding=0>"
- "<tr><td></td></tr></table></td>"
- "<td><font size=-1>", url);
+ camel_stream_printf ((CamelStream *) stream,
+ "<br><table cellspacing=0 cellpadding=0>"
+ "<tr><td><table width=10 cellspacing=0 cellpadding=0>"
+ "<tr><td></td></tr></table></td>"
+ "<td><object classid=\"%s\"></object></td>"
+ "<td><table width=3 cellspacing=0 cellpadding=0>"
+ "<tr><td></td></tr></table></td>"
+ "<td><font size=-1>", url);
mail_display_add_url (md, "part_urls", url, subpart);
- mail_html_write (html, stream,
- _("This message is digitally signed. "
- "Click the lock icon for more information."));
+ camel_stream_write_string ((CamelStream *) stream,
+ _("This message is digitally signed. "
+ "Click the lock icon for more information."));
- mail_html_write (html, stream,
- "</font></td></tr><tr><td height=10><table cellspacing=0 cellpadding=0>"
- "<tr><td height=10 ><a name=\"glue\"></td></tr></table></td></tr></table>\n");
+ camel_stream_write_string ((CamelStream *) stream, "</font></td></tr><tr><td height=10>"
+ "<table cellspacing=0 cellpadding=0><tr>"
+ "<td height=10><a name=\"glue\"></td></tr>"
+ "</table></td></tr></table>\n");
} else {
CamelCipherValidity *valid = NULL;
CamelException ex;
@@ -1854,41 +1484,40 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type,
}
if (good) {
- gtk_html_stream_printf (stream,
- "<table><tr valign=top>"
- "<td><img src=\"%s\"></td>"
- "<td>%s<br><br>",
- mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/pgp-signature-ok.png"),
- _("This message is digitally signed and "
- "has been found to be authentic."));
+ camel_stream_printf ((CamelStream *) stream, "<table><tr valign=top><td>"
+ "<img src=\"%s\"></td><td>%s<br><br>",
+ mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR
+ "/pgp-signature-ok.png"),
+ _("This message is digitally signed and "
+ "has been found to be authentic."));
} else {
- gtk_html_stream_printf (stream,
- "<table><tr valign=top>"
- "<td><img src=\"%s\"></td>"
- "<td>%s<br><br>",
- mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/pgp-signature-bad.png"),
- _("This message is digitally signed but can "
- "not be proven to be authentic."));
+ camel_stream_printf ((CamelStream *) stream, "<table><tr valign=top><td>"
+ "<img src=\"%s\"></td><td>%s<br><br>",
+ mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR
+ "/pgp-signature-bad.png"),
+ _("This message is digitally signed but can "
+ "not be proven to be authentic."));
}
if (message) {
- gtk_html_stream_printf (stream, "<font size=-1 %s>", good || md->printing ? "" : "color=red");
- mail_text_write (html, stream, md, part, 0, md->printing, message);
- mail_html_write (html, stream, "</font>");
+ camel_stream_printf ((CamelStream *) stream, "<font size=-1%s>", good ||
+ md->printing ? "" : " color=red");
+ mail_text_write (stream, md, part, 0, md->printing, message);
+ camel_stream_write_string ((CamelStream *) stream, "</font>");
}
- mail_html_write (html, stream, "</td></tr></table>");
+ camel_stream_write_string ((CamelStream *) stream, "</td></tr></table>");
camel_exception_clear (&ex);
camel_cipher_validity_free (valid);
}
-
+
return TRUE;
}
/* As seen in RFC 2387! */
static gboolean
handle_multipart_related (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
CamelMultipart *mp;
@@ -1900,12 +1529,12 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type,
int ret;
if (!CAMEL_IS_MULTIPART (wrapper)) {
- mail_error_printf (html, stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
- if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL))
- handle_text_plain (part, "text/plain", md, html, stream);
+ mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
+ if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL))
+ handle_text_plain (part, "text/plain", md, stream);
return TRUE;
}
-
+
mp = CAMEL_MULTIPART (wrapper);
nparts = camel_multipart_get_number (mp);
@@ -1925,8 +1554,7 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type,
body_part = camel_multipart_get_part (mp, i);
cid = camel_mime_part_get_content_id (body_part);
- if (cid && !strncmp (cid, start + 1, len) &&
- strlen (cid) == len) {
+ if (cid && !strncmp (cid, start + 1, len) && strlen (cid) == len) {
display_part = body_part;
break;
}
@@ -1938,7 +1566,7 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type,
if (!display_part) {
/* Oops. Hrmph. */
- return handle_multipart_mixed (part, mime_type, md, html, stream);
+ return handle_multipart_mixed (part, mime_type, md, stream);
}
/* setup a 'stack' of related parts */
@@ -1957,11 +1585,11 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type,
get_cid (body_part, md);
get_location (body_part, md);
- g_hash_table_insert(md->related, body_part, body_part);
+ g_hash_table_insert (md->related, body_part, body_part);
}
/* Now, display the displayed part. */
- ret = format_mime_part (display_part, md, html, stream);
+ ret = format_mime_part (display_part, md, stream);
/* FIXME: flush html stream via gtkhtml_stream_flush which doens't exist yet ... */
while (gtk_events_pending ())
@@ -1973,10 +1601,10 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type,
if (body_part == display_part)
continue;
- if (g_hash_table_lookup(md->related, body_part)) {
+ if (g_hash_table_lookup (md->related, body_part)) {
if (ret)
- write_hr (html, stream);
- ret |= format_mime_part (body_part, md, html, stream);
+ write_hr (stream);
+ ret |= format_mime_part (body_part, md, stream);
}
}
@@ -1996,13 +1624,13 @@ find_preferred_alternative (CamelMultipart *multipart, gboolean want_plain)
int i, nparts;
CamelMimePart *preferred_part = NULL;
MailMimeHandler *handler;
-
+
nparts = camel_multipart_get_number (multipart);
for (i = 0; i < nparts; i++) {
CamelMimePart *part = camel_multipart_get_part (multipart, i);
CamelContentType *type = camel_mime_part_get_content_type (part);
char *mime_type = header_content_type_simple (type);
-
+
g_strdown (mime_type);
if (want_plain && !strcmp (mime_type, "text/plain"))
return part;
@@ -2011,13 +1639,13 @@ find_preferred_alternative (CamelMultipart *multipart, gboolean want_plain)
preferred_part = part;
g_free (mime_type);
}
-
+
return preferred_part;
}
static gboolean
handle_multipart_alternative (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
CamelDataWrapper *wrapper =
camel_medium_get_content_object (CAMEL_MEDIUM (part));
@@ -2025,9 +1653,9 @@ handle_multipart_alternative (CamelMimePart *part, const char *mime_type,
CamelMimePart *mime_part;
if (!CAMEL_IS_MULTIPART (wrapper)) {
- mail_error_printf (html, stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
- if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL))
- handle_text_plain (part, "text/plain", md, html, stream);
+ mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
+ if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL))
+ handle_text_plain (part, "text/plain", md, stream);
return TRUE;
}
@@ -2035,68 +1663,68 @@ handle_multipart_alternative (CamelMimePart *part, const char *mime_type,
mime_part = find_preferred_alternative (multipart, FALSE);
if (mime_part)
- return format_mime_part (mime_part, md, html, stream);
+ return format_mime_part (mime_part, md, stream);
else
- return handle_multipart_mixed (part, mime_type, md, html, stream);
+ return handle_multipart_mixed (part, mime_type, md, stream);
}
/* RFC 1740 */
static gboolean
handle_multipart_appledouble (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
CamelDataWrapper *wrapper =
camel_medium_get_content_object (CAMEL_MEDIUM (part));
CamelMultipart *multipart;
-
+
if (!CAMEL_IS_MULTIPART (wrapper)) {
- mail_error_printf (html, stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
- if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL))
- handle_text_plain (part, "text/plain", md, html, stream);
+ mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source."));
+ if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL))
+ handle_text_plain (part, "text/plain", md, stream);
return TRUE;
}
-
+
multipart = CAMEL_MULTIPART (wrapper);
-
+
/* The first part is application/applefile and is not useful
* to us. The second part _may_ be displayable data. Most
* likely it's application/octet-stream though.
*/
part = camel_multipart_get_part (multipart, 1);
- return format_mime_part (part, md, html, stream);
+ return format_mime_part (part, md, stream);
}
static gboolean
handle_message_rfc822 (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
CamelDataWrapper *wrapper =
camel_medium_get_content_object (CAMEL_MEDIUM (part));
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (wrapper), FALSE);
- mail_html_write (html, stream, "<blockquote>");
- mail_format_mime_message (CAMEL_MIME_MESSAGE (wrapper), md, html, stream);
- mail_html_write (html, stream, "</blockquote>");
+ camel_stream_write_string ((CamelStream *) stream, "<blockquote>");
+ mail_format_mime_message (CAMEL_MIME_MESSAGE (wrapper), md, stream);
+ camel_stream_write_string ((CamelStream *) stream, "</blockquote>");
return TRUE;
}
static gboolean
handle_message_external_body (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
CamelContentType *type;
const char *access_type;
char *url = NULL, *desc = NULL;
-
+
type = camel_mime_part_get_content_type (part);
access_type = header_content_type_param (type, "access-type");
if (!access_type)
goto fallback;
- if (!g_ascii_strcasecmp (access_type, "ftp") ||
- !g_ascii_strcasecmp (access_type, "anon-ftp")) {
+ if (!strcasecmp (access_type, "ftp") ||
+ !strcasecmp (access_type, "anon-ftp")) {
const char *name, *site, *dir, *mode, *ftype;
char *path;
@@ -2140,15 +1768,14 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type,
goto fallback;
site = header_content_type_param (type, "site");
- url = g_strdup_printf ("file://%s%s", *name == '/' ? "" : "/",
- name);
+ url = g_strdup_printf ("file://%s%s", *name == '/' ? "" : "/", name);
if (site) {
desc = g_strdup_printf(_("Pointer to local file (%s) "
"valid at site \"%s\""), name, site);
} else {
desc = g_strdup_printf(_("Pointer to local file (%s)"), name);
}
- } else if (!g_ascii_strcasecmp (access_type, "URL")) {
+ } else if (!strcasecmp (access_type, "URL")) {
const char *urlparam;
char *s, *d;
@@ -2173,7 +1800,7 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type,
}
*d = *s;
- desc = g_strdup_printf(_("Pointer to remote data (%s)"), url);
+ desc = g_strdup_printf (_("Pointer to remote data (%s)"), url);
}
fallback:
@@ -2181,7 +1808,7 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type,
if (access_type)
desc = g_strdup_printf (_("Pointer to unknown external data (\"%s\" type)"), access_type);
else
- desc = g_strdup(_("Malformed external-body part."));
+ desc = g_strdup (_("Malformed external-body part."));
}
#if 0 /* FIXME */
@@ -2191,19 +1818,20 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type,
g_free (desc);
g_free (url);
+
return TRUE;
}
static gboolean
handle_via_bonobo (CamelMimePart *part, const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+ MailDisplay *md, MailDisplayStream *stream)
{
- if (! md->printing) {
- gtk_html_stream_printf (stream,
- "<object classid=\"%s\" type=\"%s\"></object>",
- get_cid (part, md), mime_type);
+ if (!md->printing) {
+ camel_stream_printf ((CamelStream *) stream,
+ "<object classid=\"%s\" type=\"%s\"></object>",
+ get_cid (part, md), mime_type);
}
-
+
return TRUE;
}
@@ -2226,21 +1854,21 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea
char *text, *citation, *buf, *html;
time_t date_val;
int offset;
-
+
contents = camel_medium_get_content_object (CAMEL_MEDIUM (message));
text = mail_get_message_body (contents, want_plain, cite);
if (!text)
text = g_strdup ("");
citation = cite ? "&gt; " : "";
retval = g_string_new (NULL);
-
+
/* Kludge: if text starts with "<PRE>", wrap it around the
* headers too so we won't get a blank line between them for the
* <P> to <PRE> switch.
*/
if (!strncasecmp (text, "<pre>", 5))
g_string_sprintfa (retval, "<PRE>");
-
+
/* create credits */
cia = camel_mime_message_get_from (message);
buf = camel_address_format (CAMEL_ADDRESS (cia));
@@ -2251,7 +1879,7 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea
g_free (html);
g_free (buf);
}
-
+
cia = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO);
buf = camel_address_format (CAMEL_ADDRESS (cia));
if (buf) {
@@ -2261,7 +1889,7 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea
g_free (html);
g_free (buf);
}
-
+
cia = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC);
buf = camel_address_format (CAMEL_ADDRESS (cia));
if (buf) {
@@ -2271,7 +1899,7 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea
g_free (html);
g_free (buf);
}
-
+
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);
@@ -2279,7 +1907,7 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea
citation, html);
g_free (html);
}
-
+
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);
@@ -2292,9 +1920,10 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea
else
g_string_sprintfa (retval, "%s<br>%s", citation, text);
g_free (text);
-
+
buf = retval->str;
g_string_free (retval, FALSE);
+
return buf;
}