aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-09-12 18:41:22 +0800
committerMilan Crha <mcrha@redhat.com>2012-09-12 18:41:22 +0800
commitea33b6c60d56bbe23f8e5def7e237fcadfdbc46b (patch)
tree40a683d2ae5ade0e66ebe9b05b01195d4050c15e
parentabc10da2ae623b381e6abe171a9e81ea916c8e33 (diff)
downloadgsoc2013-evolution-ea33b6c60d56bbe23f8e5def7e237fcadfdbc46b.tar
gsoc2013-evolution-ea33b6c60d56bbe23f8e5def7e237fcadfdbc46b.tar.gz
gsoc2013-evolution-ea33b6c60d56bbe23f8e5def7e237fcadfdbc46b.tar.bz2
gsoc2013-evolution-ea33b6c60d56bbe23f8e5def7e237fcadfdbc46b.tar.lz
gsoc2013-evolution-ea33b6c60d56bbe23f8e5def7e237fcadfdbc46b.tar.xz
gsoc2013-evolution-ea33b6c60d56bbe23f8e5def7e237fcadfdbc46b.tar.zst
gsoc2013-evolution-ea33b6c60d56bbe23f8e5def7e237fcadfdbc46b.zip
Bug #681279 - Reply on selection doesn't work (re-fix)
-rw-r--r--mail/em-utils.c72
1 files changed, 59 insertions, 13 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 4dc130c60b..a5e8c0534e 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1228,6 +1228,41 @@ em_utils_get_proxy (void)
return emu_proxy;
}
+static gboolean
+is_only_text_part_in_this_level (GSList *parts,
+ EMailPart *text_html_part)
+{
+ const gchar *dot;
+ gint level_len;
+ GSList *iter;
+
+ g_return_val_if_fail (parts != NULL, FALSE);
+ g_return_val_if_fail (text_html_part != NULL, FALSE);
+
+ dot = strrchr (text_html_part->id, '.');
+ if (!dot)
+ return FALSE;
+
+ level_len = dot - text_html_part->id;
+ for (iter = parts; iter; iter = iter->next) {
+ EMailPart *part = iter->data;
+
+ if (!part || !part->mime_type || part == text_html_part ||
+ part->is_hidden || part->is_attachment)
+ continue;
+
+ dot = strrchr (part->id, '.');
+ if (dot - part->id != level_len ||
+ strncmp (text_html_part->id, part->id, level_len) != 0)
+ continue;
+
+ if (g_ascii_strncasecmp (part->mime_type, "text/", 5) == 0)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/**
* em_utils_message_to_html:
* @session: a #CamelSession
@@ -1260,6 +1295,9 @@ em_utils_message_to_html (CamelSession *session,
GByteArray *buf;
EShell *shell;
GtkWindow *window;
+ EMailPart *hidden_text_html_part = NULL;
+ guint32 is_validity_found = 0;
+ GSList *iter;
shell = e_shell_get_default ();
window = e_shell_get_active_window (shell);
@@ -1292,30 +1330,38 @@ em_utils_message_to_html (CamelSession *session,
parts_list = e_mail_parser_parse_sync (parser, NULL, NULL, message, NULL);
}
- if (validity_found) {
- GSList *iter;
-
- if (validity_found)
- *validity_found = 0;
+ /* Return all found validities and possibly show hidden prefer-plain part */
+ for (iter = parts_list->list; iter; iter = iter->next) {
- /* Return all found validities */
- for (iter = parts_list->list; iter; iter = iter->next) {
-
- EMailPart *part = iter->data;
- if (!part)
- continue;
+ EMailPart *part = iter->data;
+ if (!part)
+ continue;
- if (*validity_found && part->validity_type)
- *validity_found |= part->validity_type;
+ /* prefer-plain can hide HTML parts, even when it's the only
+ text part in the email, thus show it (and hide again later) */
+ if (part->is_hidden && !hidden_text_html_part &&
+ part->mime_type && !part->is_attachment &&
+ g_ascii_strcasecmp (part->mime_type, "text/html") == 0 &&
+ is_only_text_part_in_this_level (parts_list->list, part)) {
+ part->is_hidden = FALSE;
+ hidden_text_html_part = part;
}
+ if (part->validity_type)
+ is_validity_found |= part->validity_type;
}
+ if (validity_found)
+ *validity_found = is_validity_found;
+
e_mail_formatter_format_sync (
formatter, parts_list, mem, 0,
E_MAIL_FORMATTER_MODE_PRINTING, NULL);
g_object_unref (formatter);
+ if (hidden_text_html_part)
+ hidden_text_html_part->is_hidden = TRUE;
+
if (append && *append)
camel_stream_write_string (mem, append, NULL, NULL);