aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2012-06-14 18:01:41 +0800
committerDan Vrátil <dvratil@redhat.com>2012-06-14 18:14:45 +0800
commit4f47f662f6daa7b9a3daed77d66b2022ae8398ab (patch)
tree24fe8456d16c4c42145771780c575f9ca9c7c126 /em-format
parent50ad565a15f4e630c06f78dddc6b3d00ea7ee34a (diff)
downloadgsoc2013-evolution-4f47f662f6daa7b9a3daed77d66b2022ae8398ab.tar.gz
gsoc2013-evolution-4f47f662f6daa7b9a3daed77d66b2022ae8398ab.tar.zst
gsoc2013-evolution-4f47f662f6daa7b9a3daed77d66b2022ae8398ab.zip
Bug #674887 - Hang on sender's photo lookup
Diffstat (limited to 'em-format')
-rw-r--r--em-format/e-mail-formatter-headers.c38
-rw-r--r--em-format/e-mail-parser-headers.c26
2 files changed, 43 insertions, 21 deletions
diff --git a/em-format/e-mail-formatter-headers.c b/em-format/e-mail-formatter-headers.c
index 24d27139b5..8971adf897 100644
--- a/em-format/e-mail-formatter-headers.c
+++ b/em-format/e-mail-formatter-headers.c
@@ -248,9 +248,6 @@ format_full_headers (EMailFormatter *formatter,
struct _camel_header_raw *header;
gboolean have_icon = FALSE;
const gchar *photo_name = NULL;
- CamelInternetAddress *cia = NULL;
- EShell *shell;
- ESourceRegistry *registry;
gboolean face_decoded = FALSE, contact_has_photo = FALSE;
guchar *face_header_value = NULL;
gsize face_header_len = 0;
@@ -262,9 +259,6 @@ format_full_headers (EMailFormatter *formatter,
if (g_cancellable_is_cancelled (cancellable))
return;
- shell = e_shell_get_default ();
- registry = e_shell_get_registry (shell);
-
ct = camel_mime_part_get_content_type ((CamelMimePart *) part);
charset = camel_content_type_param (ct, "charset");
charset = camel_iconv_charset_name (charset);
@@ -327,7 +321,7 @@ format_full_headers (EMailFormatter *formatter,
g_string_append (
buffer,
- "<tr><td><table border=1 width=\"100%%\" "
+ "<tr valign=\"top\"><td><table border=1 width=\"100%%\" "
"cellspacing=2 cellpadding=2><tr>");
if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
g_string_append (
@@ -352,7 +346,10 @@ format_full_headers (EMailFormatter *formatter,
g_free (header_sender);
g_free (header_from);
- g_string_append (buffer, "<tr><td width=\"100%%\"><table border=0 cellpadding=\"0\">\n");
+ g_string_append (
+ buffer,
+ "<tr valign=\"top\"><td width=\"100%%\">"
+ "<table border=0 cellpadding=\"0\">\n");
g_free (evolution_imagesdir);
@@ -446,22 +443,20 @@ format_full_headers (EMailFormatter *formatter,
g_string_append (buffer, "</table></td>");
if (photo_name) {
- CamelMimePart *photopart;
gboolean only_local_photo;
+ gchar *name;
- cia = camel_internet_address_new ();
- camel_address_decode ((CamelAddress *) cia, (const gchar *) photo_name);
+ name = g_uri_escape_string (photo_name, NULL, FALSE);
only_local_photo = e_mail_formatter_get_only_local_photos (formatter);
- photopart = em_utils_contact_photo (
- registry, cia, only_local_photo);
+ g_string_append (buffer, "<td align=\"right\" valign=\"top\">");
- if (photopart) {
- g_string_append (buffer, "<td align=\"right\" valign=\"top\">");
- write_contact_picture (photopart, -1, buffer);
- g_string_append (buffer, "</td>");
- g_object_unref (photopart);
- }
- g_object_unref (cia);
+ g_string_append_printf (buffer,
+ "<img src=\"mail://contact-photo?mailaddr=&only-local-photo=1\" "
+ "data-mailaddr=\"%s\" %s id=\"__evo-contact-photo\"/>",
+ name, only_local_photo ? "data-onlylocal=1" : "");
+ g_string_append (buffer, "</td>");
+
+ g_free (name);
}
if (!contact_has_photo && face_decoded) {
@@ -536,10 +531,11 @@ emfe_headers_format (EMailFormatterExtension *extension,
g_string_append_printf (
buffer,
- "<div class=\"headers\" style=\"background: #%06x;\">"
+ "<div class=\"headers\" style=\"background: #%06x;\" id=\"%s\">"
"<table border=\"0\" width=\"100%%\" style=\"color: #%06x;\">\n"
"<tr><td valign=\"top\" width=\"16\">\n",
bg_color,
+ part->id,
e_color_to_value ((GdkColor *)
e_mail_formatter_get_color (
formatter,
diff --git a/em-format/e-mail-parser-headers.c b/em-format/e-mail-parser-headers.c
index 06f28746f0..0a2c2bd40e 100644
--- a/em-format/e-mail-parser-headers.c
+++ b/em-format/e-mail-parser-headers.c
@@ -58,6 +58,31 @@ G_DEFINE_TYPE_EXTENDED (
static const gchar *parser_mime_types[] = { "application/vnd.evolution.headers", NULL };
+static void
+empe_headers_bind_dom (EMailPart *part,
+ WebKitDOMElement *element)
+{
+ WebKitDOMDocument *document;
+ WebKitDOMElement *photo;
+ gchar *addr, *uri;
+ gboolean only_local;
+
+ document = webkit_dom_node_get_owner_document (WEBKIT_DOM_NODE (element));
+ photo = webkit_dom_document_get_element_by_id (document, "__evo-contact-photo");
+
+ addr = webkit_dom_element_get_attribute (photo, "data-mailaddr");
+ only_local = webkit_dom_element_has_attribute (photo, "data-onlylocal");
+
+ uri = g_strdup_printf ("mail://contact-photo?mailaddr=%s%s",
+ addr, only_local ? "&only-local-photo=1" : "");
+
+ webkit_dom_html_image_element_set_src (
+ WEBKIT_DOM_HTML_IMAGE_ELEMENT (photo), uri);
+
+ g_free (addr);
+ g_free (uri);
+}
+
static GSList *
empe_headers_parse (EMailParserExtension *extension,
EMailParser *parser,
@@ -76,6 +101,7 @@ empe_headers_parse (EMailParserExtension *extension,
mail_part = e_mail_part_new (part, part_id->str);
mail_part->mime_type = g_strdup ("application/vnd.evolution.headers");
+ mail_part->bind_func = empe_headers_bind_dom;
g_string_truncate (part_id, len);
return g_slist_append (NULL, mail_part);