aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog36
-rw-r--r--mail/Makefile.am4
-rw-r--r--mail/mail-display-stream.c (renamed from mail/mail-stream-gtkhtml.c)84
-rw-r--r--mail/mail-display-stream.h (renamed from mail/mail-stream-gtkhtml.h)24
-rw-r--r--mail/mail-display.c61
-rw-r--r--mail/mail-display.h31
-rw-r--r--mail/mail-format.c1023
-rw-r--r--mail/mail.h13
8 files changed, 485 insertions, 791 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 8b66aa6bad..9ec8318aca 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,39 @@
+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.
+
2002-12-13 Jeffrey Stedfast <fejj@ximian.com>
* mail-callbacks.c (check_send_configuration): Make sure the
diff --git a/mail/Makefile.am b/mail/Makefile.am
index b1f5864174..c819ad4310 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -90,6 +90,8 @@ evolution_mail_SOURCES = \
mail-preferences.h \
mail-display.c \
mail-display.h \
+ mail-display-stream.c \
+ mail-display-stream.h \
mail-folder-cache.c \
mail-folder-cache.h \
mail-format.c \
@@ -114,8 +116,6 @@ evolution_mail_SOURCES = \
mail-session.h \
mail-signature-editor.c \
mail-signature-editor.h \
- mail-stream-gtkhtml.c \
- mail-stream-gtkhtml.h \
mail-tools.c \
mail-tools.h \
mail-types.h \
diff --git a/mail/mail-stream-gtkhtml.c b/mail/mail-display-stream.c
index db5726aab6..ae81401680 100644
--- a/mail/mail-stream-gtkhtml.c
+++ b/mail/mail-display-stream.c
@@ -25,74 +25,80 @@
#include <config.h>
#endif
-#include "mail-stream-gtkhtml.h"
+#include "mail-display-stream.h"
-static CamelStreamClass *parent_class = NULL;
+
+static void mail_display_stream_class_init (MailDisplayStreamClass *klass);
+static void mail_display_stream_init (CamelObject *object);
+static void mail_display_stream_finalize (CamelObject *object);
static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n);
+
+static CamelStreamClass *parent_class = NULL;
+
+
+CamelType
+mail_display_stream_get_type (void)
+{
+ static CamelType type = CAMEL_INVALID_TYPE;
+
+ if (type == CAMEL_INVALID_TYPE) {
+ type = camel_type_register (CAMEL_STREAM_TYPE,
+ "MailDisplayStream",
+ sizeof (MailDisplayStream),
+ sizeof (MailDisplayStreamClass),
+ (CamelObjectClassInitFunc) mail_display_stream_class_init,
+ NULL,
+ (CamelObjectInitFunc) mail_display_stream_init,
+ (CamelObjectFinalizeFunc) mail_display_stream_finalize);
+ }
+
+ return type;
+}
+
static void
-mail_stream_gtkhtml_class_init (MailStreamGtkHTMLClass *mail_stream_gtkhtml_class)
+mail_display_stream_class_init (MailDisplayStreamClass *klass)
{
- CamelStreamClass *camel_stream_class =
- CAMEL_STREAM_CLASS (mail_stream_gtkhtml_class);
+ CamelStreamClass *stream_class = CAMEL_STREAM_CLASS (klass);
- parent_class = (CamelStreamClass *)CAMEL_STREAM_TYPE;
+ parent_class = (CamelStreamClass *) CAMEL_STREAM_TYPE;
/* virtual method overload */
- camel_stream_class->write = stream_write;
+ stream_class->write = stream_write;
}
static void
-mail_stream_gtkhtml_init (CamelObject *object)
+mail_display_stream_init (CamelObject *object)
{
;
}
static void
-mail_stream_gtkhtml_finalize (CamelObject *object)
+mail_display_stream_finalize (CamelObject *object)
{
;
}
-CamelType
-mail_stream_gtkhtml_get_type (void)
+static ssize_t
+stream_write (CamelStream *stream, const char *buffer, size_t n)
{
- static CamelType type = CAMEL_INVALID_TYPE;
+ MailDisplayStream *dstream = MAIL_DISPLAY_STREAM (stream);
- if (type == CAMEL_INVALID_TYPE) {
- type = camel_type_register (CAMEL_STREAM_TYPE,
- "MailStreamGtkHTML",
- sizeof (MailStreamGtkHTML),
- sizeof (MailStreamGtkHTMLClass),
- (CamelObjectClassInitFunc) mail_stream_gtkhtml_class_init,
- NULL,
- (CamelObjectInitFunc) mail_stream_gtkhtml_init,
- (CamelObjectFinalizeFunc) mail_stream_gtkhtml_finalize);
- }
+ gtk_html_write (dstream->html, dstream->html_stream, buffer, n);
- return type;
+ return (ssize_t) n;
}
CamelStream *
-mail_stream_gtkhtml_new (GtkHTML *html, GtkHTMLStream *html_stream)
+mail_display_stream_new (GtkHTML *html, GtkHTMLStream *html_stream)
{
- MailStreamGtkHTML *stream_gtkhtml;
+ MailDisplayStream *new;
- stream_gtkhtml = MAIL_STREAM_GTKHTML (camel_object_new (MAIL_STREAM_GTKHTML_TYPE));
- stream_gtkhtml->html = html;
- stream_gtkhtml->html_stream = html_stream;
-
- return CAMEL_STREAM (stream_gtkhtml);
-}
-
-static ssize_t
-stream_write (CamelStream *stream, const char *buffer, size_t n)
-{
- MailStreamGtkHTML *stream_gtkhtml = MAIL_STREAM_GTKHTML (stream);
+ new = MAIL_DISPLAY_STREAM (camel_object_new (MAIL_DISPLAY_STREAM_TYPE));
+ new->html = html;
+ new->html_stream = html_stream;
- gtk_html_write (stream_gtkhtml->html, stream_gtkhtml->html_stream,
- buffer, n);
- return n;
+ return CAMEL_STREAM (new);
}
diff --git a/mail/mail-stream-gtkhtml.h b/mail/mail-display-stream.h
index fa3fb104b9..943398c49a 100644
--- a/mail/mail-stream-gtkhtml.h
+++ b/mail/mail-display-stream.h
@@ -21,8 +21,8 @@
*/
-#ifndef MAIL_STREAM_GTKHTML_H
-#define MAIL_STREAM_GTKHTML_H
+#ifndef MAIL_DISPLAY_STREAM_H
+#define MAIL_DISPLAY_STREAM_H
#ifdef __cplusplus
extern "C" {
@@ -32,31 +32,31 @@ extern "C" {
#include <camel/camel-stream.h>
#include <gtkhtml/gtkhtml.h>
-#define MAIL_STREAM_GTKHTML_TYPE (mail_stream_gtkhtml_get_type ())
-#define MAIL_STREAM_GTKHTML(obj) (CAMEL_CHECK_CAST((obj), MAIL_STREAM_GTKHTML_TYPE, MailStreamGtkHTML))
-#define MAIL_STREAM_GTKHTML_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), MAIL_STREAM_GTKHTML_TYPE, MailStreamGtkhTMLClass))
-#define MAIL_IS_STREAM_GTKHTML(o) (CAMEL_CHECK_TYPE((o), MAIL_STREAM_GTKHTML_TYPE))
+#define MAIL_DISPLAY_STREAM_TYPE (mail_display_stream_get_type ())
+#define MAIL_DISPLAY_STREAM(obj) (CAMEL_CHECK_CAST((obj), MAIL_DISPLAY_STREAM_TYPE, MailDisplayStream))
+#define MAIL_DISPLAY_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), MAIL_DISPLAY_STREAM_TYPE, MailDisplayStreamClass))
+#define MAIL_IS_DISPLAY_STREAM(o) (CAMEL_CHECK_TYPE((o), MAIL_DISPLAY_STREAM_TYPE))
-typedef struct _MailStreamGtkHTML {
+typedef struct _MailDisplayStream {
CamelStream parent_stream;
GtkHTML *html;
GtkHTMLStream *html_stream;
-} MailStreamGtkHTML;
+} MailDisplayStream;
typedef struct {
CamelStreamClass parent_class;
-} MailStreamGtkHTMLClass;
+} MailDisplayStreamClass;
-CamelType mail_stream_gtkhtml_get_type (void);
+CamelType mail_display_stream_get_type (void);
/* Note: stream does not ref these objects! */
-CamelStream *mail_stream_gtkhtml_new (GtkHTML *html, GtkHTMLStream *html_stream);
+CamelStream *mail_display_stream_new (GtkHTML *html, GtkHTMLStream *html_stream);
#ifdef __cplusplus
}
#endif /* __cplusplus */
-#endif /* MAIL_STREAM_GTKHTML_H */
+#endif /* MAIL_DISPLAY_STREAM_H */
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);
}
/**
diff --git a/mail/mail-display.h b/mail/mail-display.h
index 4bb9a3a017..c9fefb7e6a 100644
--- a/mail/mail-display.h
+++ b/mail/mail-display.h
@@ -1,4 +1,25 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors: Jeffrey Stedfast <fejj@ximian.com>
+ *
+ * Copyright 2002 Ximian, Inc. (www.ximian.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
#ifndef _MAIL_DISPLAY_H_
#define _MAIL_DISPLAY_H_
@@ -16,6 +37,7 @@
#include "mail-types.h"
#include "mail-config.h" /*display_style*/
+#include "mail-display-stream.h"
#define MAIL_DISPLAY_TYPE (mail_display_get_type ())
#define MAIL_DISPLAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_DISPLAY_TYPE, MailDisplay))
@@ -95,18 +117,13 @@ void mail_display_set_charset (MailDisplay *mail_display,
void mail_display_load_images (MailDisplay *mail_display);
-
-#define mail_html_write(html, stream, string) gtk_html_write (html, stream, string, strlen (string))
-
-void mail_text_write (GtkHTML *html,
- GtkHTMLStream *stream,
+void mail_text_write (MailDisplayStream *stream,
MailDisplay *md,
CamelMimePart *part,
gint idx,
gboolean printing,
const char *text);
-void mail_error_printf (GtkHTML *html,
- GtkHTMLStream *stream,
+void mail_error_printf (MailDisplayStream *stream,
const char *format, ...);
char *mail_display_add_url (MailDisplay *md, const char *kind, char *url, gpointer data);
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;
}
diff --git a/mail/mail.h b/mail/mail.h
index d303bef845..627ca3526d 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -29,7 +29,7 @@
#include "mail-callbacks.h"
#include "mail-config.h"
#include "mail-config-druid.h"
-/*#include "folder-browser.h"*/
+#include "mail-display-stream.h"
#include "mail-session.h"
#include "mail-types.h"
@@ -40,9 +40,10 @@ GByteArray *mail_format_get_data_wrapper_text (CamelDataWrapper *data,
MailDisplay *mail_display);
void mail_format_mime_message (CamelMimeMessage *mime_message,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
+ MailDisplay *md, MailDisplayStream *stream);
void mail_format_raw_message (CamelMimeMessage *mime_message,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
+ MailDisplay *md, MailDisplayStream *stream);
+
gboolean mail_content_loaded (CamelDataWrapper *wrapper,
MailDisplay *display,
gboolean redisplay,
@@ -50,15 +51,15 @@ gboolean mail_content_loaded (CamelDataWrapper *wrapper,
GtkHTML *html,
GtkHTMLStream *handle);
-typedef gboolean (*MailMimeHandlerFn) (CamelMimePart *part,
- const char *mime_type,
- MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream);
+typedef gboolean (*MailMimeHandlerFn) (CamelMimePart *part, const char *mime_type,
+ MailDisplay *md, MailDisplayStream *stream);
typedef struct {
gboolean generic;
Bonobo_ServerInfo *component;
GList *applications;
MailMimeHandlerFn builtin;
} MailMimeHandler;
+
MailMimeHandler *mail_lookup_handler (const char *mime_type);
gboolean mail_part_is_inline (CamelMimePart *part);