aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog9
-rw-r--r--mail/mail-display.c20
-rw-r--r--mail/mail-display.h3
-rw-r--r--mail/mail-format.c100
4 files changed, 89 insertions, 43 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 9b153034e7..40b9b3e42e 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,12 @@
+2002-08-30 Radek Doulik <rodo@ximian.com>
+
+ * mail-format.c (mail_format_raw_message): as below
+ (handle_text_plain_flowed): as below
+
+ * mail-display.c (mail_text_write): put text in iframe, so it has
+ margins and should not be placed in table which changes wrapping
+ behavior
+
2002-08-29 Peter Williams <peterw@ximian.com>
* folder-browser-ui.c: Add HAS_FLAGS to a few miscellaneous commands
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 9f3ad1c84b..0cace663ff 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -1624,8 +1624,13 @@ mail_display_redisplay_when_loaded (MailDisplay *md,
}
void
-mail_text_write (GtkHTML *html, GtkHTMLStream *stream, gboolean printing, const char *text)
+mail_text_write (GtkHTML *html, GtkHTMLStream *stream, MailDisplay *md, CamelMimePart *part, gint idx, gboolean printing, const char *text)
{
+ GByteArray *ba;
+ gchar *xed, *iframe;
+ gchar *btt = "<tt>\n";
+ gchar *ett = "</tt>\n";
+
guint flags;
char *htmltext;
@@ -1639,10 +1644,17 @@ mail_text_write (GtkHTML *html, GtkHTMLStream *stream, gboolean printing, const
htmltext = e_text_to_html_full (text, flags, mail_config_get_citation_color ());
- gtk_html_write (html, stream, "<tt>", 4);
- gtk_html_write (html, stream, htmltext, strlen (htmltext));
- gtk_html_write (html, stream, "</tt>", 5);
+ ba = g_byte_array_new ();
+ g_byte_array_append (ba, (const guint8 *) btt, strlen (btt) + 1);
+ g_byte_array_append (ba, (const guint8 *) htmltext, strlen (htmltext) + 1);
+ g_byte_array_append (ba, (const guint8 *) ett, strlen (ett) + 1);
g_free (htmltext);
+
+ xed = g_strdup_printf ("x-evolution-data:%p-%d", part, idx);
+ iframe = g_strdup_printf ("<iframe src=\"%s\" frameborder=0 scrolling=no></iframe>", xed);
+ mail_display_add_url (md, "data_urls", xed, ba);
+ gtk_html_write (html, stream, iframe, strlen (iframe));
+ g_free (iframe);
}
void
diff --git a/mail/mail-display.h b/mail/mail-display.h
index bd27001150..c192d818c3 100644
--- a/mail/mail-display.h
+++ b/mail/mail-display.h
@@ -100,6 +100,9 @@ void mail_display_load_images (MailDisplay *mail_display);
void mail_text_write (GtkHTML *html,
GtkHTMLStream *stream,
+ MailDisplay *md,
+ CamelMimePart *part,
+ gint idx,
gboolean printing,
const char *text);
void mail_error_printf (GtkHTML *html,
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 12cd41dc90..731c00be79 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -64,7 +64,7 @@ static char *try_inline_binhex (char *start, CamelMimePart *part,
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,
+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,
@@ -200,21 +200,33 @@ mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md,
TRUE, NULL, html, NULL))
return;
- mail_html_write (html, stream,
- "<table cellspacing=0 cellpadding=10 width=\"100%\"><tr><td><tt>\n");
-
bytes = mail_format_get_data_wrapper_text (CAMEL_DATA_WRAPPER (mime_message), md);
if (bytes) {
+ GByteArray *ba;
+ gchar *xed, *iframe;
+ gchar *btt = "<tt>\n";
+ gchar *ett = "</tt>\n";
+
g_byte_array_append (bytes, "", 1);
html_str = e_text_to_html (bytes->data, E_TEXT_TO_HTML_CONVERT_NL |
E_TEXT_TO_HTML_CONVERT_SPACES | E_TEXT_TO_HTML_ESCAPE_8BIT);
g_byte_array_free (bytes, TRUE);
- mail_html_write (html, stream, html_str);
+ //mail_html_write (html, stream, html_str);
+ //g_free (html_str);
+
+ ba = g_byte_array_new ();
+ g_byte_array_append (ba, (const guint8 *) btt, strlen (btt) + 1);
+ g_byte_array_append (ba, (const guint8 *) html_str, strlen (html_str) + 1);
+ g_byte_array_append (ba, (const guint8 *) ett, strlen (ett) + 1);
g_free (html_str);
+
+ xed = g_strdup_printf ("x-evolution-data:%p", mime_message);
+ iframe = g_strdup_printf ("<iframe src=\"%s\" frameborder=0 scrolling=no></iframe>", xed);
+ mail_display_add_url (md, "data_urls", xed, ba);
+ mail_html_write (html, stream, iframe);
+ g_free (iframe);
}
-
- mail_html_write (html, stream, "</tt></td></tr></table>");
}
static const char *
@@ -669,8 +681,8 @@ attachment_header (CamelMimePart *part, const char *mime_type, MailDisplay *md,
}
mail_html_write (html, stream, "</font></td></tr><tr>"
- "<td height=10><table height=10 cellspacing=0 cellpadding=0>"
- "<tr><td></td></tr></table></td></tr></table>\n");
+ "<td height=10><table cellspacing=0 cellpadding=0>"
+ "<tr><td height=10><a name=\"glue\"></td></tr></table></td></tr></table>\n");
}
static gboolean
@@ -1013,7 +1025,7 @@ write_headers (CamelMimeMessage *message, MailDisplay *md,
stream,
"<table width=\"100%%\" cellpadding=0 cellspacing=0>"
/* Top margin */
- "<tr><td colspan=3 height=10><table height=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td></tr>"
+ "<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 */
@@ -1201,18 +1213,13 @@ struct {
static int num_specials = (sizeof (text_specials) / sizeof (text_specials[0]));
static void
-write_one_text_plain_chunk (const char *text, int len, GtkHTML *html, GtkHTMLStream *stream, gboolean printing)
+write_one_text_plain_chunk (MailDisplay *md, CamelMimePart *part, gint idx, const char *text, int len, GtkHTML *html, GtkHTMLStream *stream, gboolean printing)
{
char *buf;
- mail_html_write (html, stream,
- "<table cellspacing=0 cellpadding=10 width=\"100%\"><tr><td>\n");
-
buf = g_strndup (text, len);
- mail_text_write (html, stream, printing, buf);
+ mail_text_write (html, stream, md, part, idx, printing, buf);
g_free (buf);
-
- mail_html_write (html, stream, "</td></tr></table>\n");
}
static gboolean
@@ -1226,7 +1233,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type,
char *p, *start, *text;
const char *format;
GByteArray *bytes;
- int i;
+ int i, idx = 0;
bytes = mail_format_get_data_wrapper_text (wrapper, md);
if (!bytes)
@@ -1249,7 +1256,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type,
type = camel_mime_part_get_content_type (part);
format = header_content_type_param (type, "format");
if (format && !g_strcasecmp (format, "flowed"))
- return handle_text_plain_flowed (text, md, html, stream);
+ 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
@@ -1271,7 +1278,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type,
/* Deal with special case */
if (start != p)
- write_one_text_plain_chunk (p, start - p, html, stream, md->printing);
+ 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) {
@@ -1285,13 +1292,13 @@ handle_text_plain (CamelMimePart *part, const char *mime_type,
break;
}
p++;
- write_one_text_plain_chunk (start, p - start, html, stream, md->printing);
+ 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 (p, strlen (p), html, stream, md->printing);
+ write_one_text_plain_chunk (md, part, idx ++, p, strlen (p), html, stream, md->printing);
g_free (text);
@@ -1299,15 +1306,16 @@ handle_text_plain (CamelMimePart *part, const char *mime_type,
}
static gboolean
-handle_text_plain_flowed (char *buf, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
+handle_text_plain_flowed (char *buf, CamelMimePart *part, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
{
char *text, *line, *eol, *p;
int prevquoting = 0, quoting, len, br_pending = 0;
guint32 citation_color = mail_config_get_citation_color ();
-
- mail_html_write (html, stream,
- "\n<!-- text/plain, flowed -->\n"
- "<table cellspacing=0 cellpadding=10 width=\"100%\"><tr><td>\n<tt>\n");
+ GByteArray *ba;
+ gchar *iframe, *xed;
+
+ 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 */
@@ -1321,22 +1329,30 @@ handle_text_plain_flowed (char *buf, MailDisplay *md, GtkHTML *html, GtkHTMLStre
if (quoting != prevquoting) {
if (prevquoting == 0) {
if (md->printing)
- mail_html_write (html, stream, "<i>");
- else
- gtk_html_stream_printf (stream, "<font color=\"#%06x\">", citation_color);
+ g_byte_array_append (ba, "<i>", 3);
+ else {
+ gchar 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) {
- mail_html_write (html, stream, "<blockquote type=\"cite\">");
+ g_byte_array_append (ba, "<blockquote type=\"cite\">", 24);
prevquoting++;
}
while (quoting < prevquoting) {
- mail_html_write (html, stream, "</blockquote>");
+ g_byte_array_append (ba, "</blockquote>", 13);
prevquoting--;
}
if (quoting == 0) {
- mail_html_write (html, stream, md->printing ? "</i>" : "</font>\n");
+ if (md->printing)
+ g_byte_array_append (ba, "</i>", 4);
+ else
+ g_byte_array_append (ba, "</font>\n", 8);
if (br_pending)
br_pending--;
}
@@ -1353,7 +1369,7 @@ handle_text_plain_flowed (char *buf, MailDisplay *md, GtkHTML *html, GtkHTMLStre
}
while (br_pending) {
- mail_html_write (html, stream, "<br>\n");
+ g_byte_array_append (ba, "<br>\n", 5);
br_pending--;
}
@@ -1363,7 +1379,7 @@ handle_text_plain_flowed (char *buf, MailDisplay *md, GtkHTML *html, GtkHTMLStre
E_TEXT_TO_HTML_CONVERT_SPACES :
E_TEXT_TO_HTML_CONVERT_SPACES | E_TEXT_TO_HTML_CONVERT_URLS);
if (text && *text)
- mail_html_write (html, stream, text);
+ g_byte_array_append (ba, text, strlen (text));
g_free (text);
if ((len > 0 && p[len - 1]) != ' ' || !strcmp (p, "-- "))
@@ -1375,7 +1391,13 @@ handle_text_plain_flowed (char *buf, MailDisplay *md, GtkHTML *html, GtkHTMLStre
g_free (buf);
- mail_html_write (html, stream, "</tt>\n</td></tr></table>\n");
+ g_byte_array_append (ba, "</tt>\n", 6);
+
+ xed = g_strdup_printf ("x-evolution-data:%p", part);
+ iframe = g_strdup_printf ("<iframe src=\"%s\" frameborder=0 scrolling=no></iframe>", xed);
+ mail_display_add_url (md, "data_urls", xed, ba);
+ mail_html_write (html, stream, iframe);
+ g_free (iframe);
return TRUE;
}
@@ -1835,8 +1857,8 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type,
"Click the lock icon for more information."));
mail_html_write (html, stream,
- "</font></td></tr><tr><td height=10><table height=10 cellspacing=0 cellpadding=0>"
- "<tr><td></td></tr></table></td></tr></table>\n");
+ "</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;
@@ -1881,7 +1903,7 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type,
if (message) {
gtk_html_stream_printf (stream, "<font size=-1 %s>", good || md->printing ? "" : "color=red");
- mail_text_write (html, stream, md->printing, message);
+ mail_text_write (html, stream, md, part, 0, md->printing, message);
mail_html_write (html, stream, "</font>");
}