[evolution/webkit: 195/196] Fix various printing bugs
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 195/196] Fix various printing bugs
- Date: Tue, 27 Mar 2012 16:17:06 +0000 (UTC)
commit 14cf3b6d22e0aa23b0723b7e3acea2573c5dd1b4
Author: Dan VrÃtil <dvratil redhat com>
Date: Tue Mar 27 17:27:58 2012 +0200
Fix various printing bugs
mail/e-mail-printer.c | 2 +-
mail/em-format-html-print.c | 48 ++++++++++++++++++++++++++++++++++--------
mail/em-format-html.c | 18 +++++++++++++--
3 files changed, 55 insertions(+), 13 deletions(-)
---
diff --git a/mail/e-mail-printer.c b/mail/e-mail-printer.c
index d5638ab..aaa8609 100644
--- a/mail/e-mail-printer.c
+++ b/mail/e-mail-printer.c
@@ -45,7 +45,7 @@ enum {
BUTTONS_COUNT
};
-#define w(x)
+#define w(x) x
struct _EMailPrinterPrivate {
EMFormatHTMLPrint *efhp;
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index 4df837e..6364177 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -39,7 +39,7 @@
#include "em-format-html-print.h"
-#define d(x)
+#define d(x) x
static gpointer parent_class = NULL;
@@ -232,15 +232,23 @@ efhp_write_headers (EMFormat *emf,
/* Count attachments and display the number as a header */
attachments_count = 0;
- for (iter = emf->mail_part_list; iter; iter = iter->next) {
+ for (iter = emf->mail_part_list; iter; iter = iter ? iter->next : iter) {
p = iter->data;
if (!g_str_has_prefix (p->uri, puri_prefix))
continue;
- if (p->is_attachment || g_str_has_suffix(p->uri, ".attachment"))
+ if ((p->is_attachment || g_str_has_suffix(p->uri, ".attachment")) &&
+ (!p->cid)) {
attachments_count++;
+ /* EFHD sometimes creates two PURIs per attachment! */
+ if (iter->next && iter->next->data) {
+ EMFormatPURI *p2 = iter->next->data;
+ if (g_str_has_prefix (p2->uri, p->uri))
+ iter = iter->next;
+ }
+ }
}
if (attachments_count > 0) {
raw_header.name = _("Attachments");
@@ -284,8 +292,6 @@ efhp_write_inline_attachment (EMFormat *emf,
camel_stream_write_string (stream, name, cancellable, NULL);
g_free (name);
-
- puri->write_func (emf, puri, stream, info, cancellable);
}
static void
@@ -313,7 +319,7 @@ efhp_write_print_layout (EMFormat *emf,
"<body style=\"background: #FFF; color: #000;\">",
cancellable, NULL);
- for (iter = emf->mail_part_list; iter != NULL; iter = iter->next) {
+ for (iter = emf->mail_part_list; iter != NULL; iter = iter ? iter->next : iter) {
EMFormatPURI *puri = iter->data;
@@ -344,12 +350,17 @@ efhp_write_print_layout (EMFormat *emf,
if (puri->is_attachment || g_str_has_suffix (puri->uri, ".attachment")) {
const EMFormatHandler *handler;
+ CamelContentType *ct;
+ gchar *mime_type;
- CamelContentType *ct = camel_mime_part_get_content_type (puri->part);
- gchar *mime_type = camel_content_type_simple (ct);
+ if (puri->cid && g_ascii_strncasecmp (puri->cid, "cid:", 4) == 0)
+ continue;
+
+ ct = camel_mime_part_get_content_type (puri->part);
+ mime_type = camel_content_type_simple (ct);
handler = em_format_find_handler (puri->emf, mime_type);
- d(printf("Handler for PURI %s (%s): %s", puri->uri, mime_type,
+ d(printf("Handler for PURI %s (%s): %s\n", puri->uri, mime_type,
handler ? handler->mime_type : "(null)"));
g_free (mime_type);
@@ -360,6 +371,25 @@ efhp_write_print_layout (EMFormat *emf,
if (handler && puri->write_func) {
efhp_write_inline_attachment (puri->emf, puri,
stream, &print_info, cancellable);
+
+ if (iter->next && iter->next->data) {
+ EMFormatPURI *p;
+ p = iter->next->data;
+
+ /* Has the next PURI the same prefix? */
+ if (p->write_func &&
+ g_str_has_prefix (p->uri, puri->uri)) {
+ p->write_func (emf, p, stream,
+ &print_info, cancellable);
+ iter = iter->next;
+ } else {
+ if (puri->write_func) {
+ puri->write_func (emf, puri,
+ stream, &print_info,
+ cancellable);
+ }
+ }
+ }
}
continue;
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 4ef2dba..2623db2 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -865,12 +865,18 @@ efh_write_text_html (EMFormat *emf,
const gchar *document_end;
gint length;
gint i;
+ CamelStream *decoded_stream;
- dw = camel_medium_get_content ((CamelMedium *) puri->part);
- ba = camel_data_wrapper_get_byte_array (dw);
+ decoded_stream = camel_stream_mem_new ();
+ em_format_format_text (emf, decoded_stream,
+ (CamelDataWrapper *) puri->part, cancellable);
+ g_seekable_seek (G_SEEKABLE (decoded_stream), 0, G_SEEK_SET, cancellable, NULL);
+ ba = camel_stream_mem_get_byte_array (CAMEL_STREAM_MEM (decoded_stream));
string = g_string_new_len ((gchar *) ba->data, ba->len);
+ g_object_unref (decoded_stream);
+
tags = NULL;
pos = string->str;
valid = FALSE;
@@ -936,13 +942,19 @@ efh_write_text_html (EMFormat *emf,
i = 0;
valid = FALSE;
while (i < length - 1) {
+ gchar c;
if (g_ascii_isspace (*tag)) {
tag--;
continue;
}
- if (*tag == document_end[i]) {
+ if ((*tag >= 'A') && (*tag <= 'Z'))
+ c = *tag + 32;
+ else
+ c = *tag;
+
+ if (c == document_end[i]) {
tag--;
i++;
valid = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]