aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2013-01-19 01:34:56 +0800
committerMilan Crha <mcrha@redhat.com>2013-01-19 01:34:56 +0800
commit722a27e8507541e64ca2a436a7f10069b9e01223 (patch)
treeeefaf16cd84524a8c3ee68ad4edd5937b8a16f1d
parent590b4711b78b94cac68a6c52e09a62628b5648d8 (diff)
downloadgsoc2013-evolution-722a27e8507541e64ca2a436a7f10069b9e01223.tar
gsoc2013-evolution-722a27e8507541e64ca2a436a7f10069b9e01223.tar.gz
gsoc2013-evolution-722a27e8507541e64ca2a436a7f10069b9e01223.tar.bz2
gsoc2013-evolution-722a27e8507541e64ca2a436a7f10069b9e01223.tar.lz
gsoc2013-evolution-722a27e8507541e64ca2a436a7f10069b9e01223.tar.xz
gsoc2013-evolution-722a27e8507541e64ca2a436a7f10069b9e01223.tar.zst
gsoc2013-evolution-722a27e8507541e64ca2a436a7f10069b9e01223.zip
Bug #692005 - Changing character encoding doesn't work
-rw-r--r--em-format/e-mail-formatter-message-rfc822.c10
-rw-r--r--em-format/e-mail-formatter-text-html.c10
-rw-r--r--em-format/e-mail-formatter-text-plain.c10
-rw-r--r--mail/e-mail-display.c52
-rw-r--r--mail/e-mail-display.h2
-rw-r--r--mail/e-mail-printer.c24
-rw-r--r--mail/e-mail-printer.h2
-rw-r--r--mail/e-mail-reader-utils.c7
-rw-r--r--mail/e-mail-request.c9
-rw-r--r--mail/em-composer-utils.c2
-rw-r--r--mail/em-utils.c4
-rw-r--r--modules/itip-formatter/e-mail-formatter-itip.c11
-rw-r--r--modules/text-highlight/e-mail-formatter-text-highlight.c10
-rw-r--r--modules/vcard-inline/e-mail-formatter-vcard-inline.c10
14 files changed, 153 insertions, 10 deletions
diff --git a/em-format/e-mail-formatter-message-rfc822.c b/em-format/e-mail-formatter-message-rfc822.c
index c0179ab848..9e88986e98 100644
--- a/em-format/e-mail-formatter-message-rfc822.c
+++ b/em-format/e-mail-formatter-message-rfc822.c
@@ -183,6 +183,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension,
EMailPart *p;
CamelFolder *folder;
const gchar *message_uid;
+ const gchar *default_charset, *charset;
gchar *str;
gchar *uri;
@@ -192,12 +193,21 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension,
folder = e_mail_part_list_get_folder (context->part_list);
message_uid = e_mail_part_list_get_message_uid (context->part_list);
+ default_charset = e_mail_formatter_get_default_charset (formatter);
+ charset = e_mail_formatter_get_charset (formatter);
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
uri = e_mail_part_build_uri (
folder, message_uid,
"part_id", G_TYPE_STRING, p->id,
"mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW,
"headers_collapsable", G_TYPE_INT, 0,
+ "formatter_default_charset", G_TYPE_STRING, default_charset,
+ "formatter_charset", G_TYPE_STRING, charset,
NULL);
str = g_strdup_printf (
diff --git a/em-format/e-mail-formatter-text-html.c b/em-format/e-mail-formatter-text-html.c
index e32c48bab8..a70ec2b2f2 100644
--- a/em-format/e-mail-formatter-text-html.c
+++ b/em-format/e-mail-formatter-text-html.c
@@ -299,15 +299,25 @@ emfe_text_html_format (EMailFormatterExtension *extension,
} else {
CamelFolder *folder;
const gchar *message_uid;
+ const gchar *default_charset, *charset;
gchar *uri, *str;
folder = e_mail_part_list_get_folder (context->part_list);
message_uid = e_mail_part_list_get_message_uid (context->part_list);
+ default_charset = e_mail_formatter_get_default_charset (formatter);
+ charset = e_mail_formatter_get_charset (formatter);
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
uri = e_mail_part_build_uri (
folder, message_uid,
"part_id", G_TYPE_STRING, part->id,
"mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW,
+ "formatter_default_charset", G_TYPE_STRING, default_charset,
+ "formatter_charset", G_TYPE_STRING, charset,
NULL);
str = g_strdup_printf (
diff --git a/em-format/e-mail-formatter-text-plain.c b/em-format/e-mail-formatter-text-plain.c
index 3d0de8215c..278353b40b 100644
--- a/em-format/e-mail-formatter-text-plain.c
+++ b/em-format/e-mail-formatter-text-plain.c
@@ -135,14 +135,24 @@ emfe_text_plain_format (EMailFormatterExtension *extension,
CamelFolder *folder;
const gchar *message_uid;
gchar *uri, *str;
+ const gchar *default_charset, *charset;
folder = e_mail_part_list_get_folder (context->part_list);
message_uid = e_mail_part_list_get_message_uid (context->part_list);
+ default_charset = e_mail_formatter_get_default_charset (formatter);
+ charset = e_mail_formatter_get_charset (formatter);
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
uri = e_mail_part_build_uri (
folder, message_uid,
"part_id", G_TYPE_STRING, part->id,
"mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW,
+ "formatter_default_charset", G_TYPE_STRING, default_charset,
+ "formatter_charset", G_TYPE_STRING, charset,
NULL);
str = g_strdup_printf (
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 3181a90c27..f2a3035d0a 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -76,6 +76,7 @@ enum {
PROP_PART_LIST,
PROP_HEADERS_COLLAPSABLE,
PROP_HEADERS_COLLAPSED,
+ PROP_FORMATTER
};
static CamelDataCache *emd_global_http_cache = NULL;
@@ -1282,6 +1283,11 @@ mail_display_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_FORMATTER:
+ g_value_set_object (
+ value, e_mail_display_get_formatter (
+ E_MAIL_DISPLAY (object)));
+ return;
case PROP_PART_LIST:
g_value_set_pointer (
value, e_mail_display_get_parts_list (
@@ -1488,6 +1494,16 @@ e_mail_display_class_init (EMailDisplayClass *class)
g_object_class_install_property (
object_class,
+ PROP_FORMATTER,
+ g_param_spec_pointer (
+ "formatter",
+ "Mail Formatter",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_PART_LIST,
g_param_spec_pointer (
"part-list",
@@ -1703,6 +1719,14 @@ e_mail_display_set_mode (EMailDisplay *display,
g_object_notify (G_OBJECT (display), "mode");
}
+EMailFormatter *
+e_mail_display_get_formatter (EMailDisplay *display)
+{
+ g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), NULL);
+
+ return display->priv->formatter;
+}
+
EMailPartList *
e_mail_display_get_parts_list (EMailDisplay *display)
{
@@ -1788,6 +1812,7 @@ e_mail_display_load (EMailDisplay *display,
EMailPartList *part_list;
CamelFolder *folder;
const gchar *message_uid;
+ const gchar *default_charset, *charset;
gchar *uri;
g_return_if_fail (E_IS_MAIL_DISPLAY (display));
@@ -1802,14 +1827,21 @@ e_mail_display_load (EMailDisplay *display,
folder = e_mail_part_list_get_folder (part_list);
message_uid = e_mail_part_list_get_message_uid (part_list);
+ default_charset = e_mail_formatter_get_default_charset (display->priv->formatter);
+ charset = e_mail_formatter_get_charset (display->priv->formatter);
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
uri = e_mail_part_build_uri (
folder, message_uid,
"mode", G_TYPE_INT, display->priv->mode,
- "headers_collapsable", G_TYPE_BOOLEAN,
- display->priv->headers_collapsable,
- "headers_collapsed", G_TYPE_BOOLEAN,
- display->priv->headers_collapsed,
+ "headers_collapsable", G_TYPE_BOOLEAN, display->priv->headers_collapsable,
+ "headers_collapsed", G_TYPE_BOOLEAN, display->priv->headers_collapsed,
+ "formatter_default_charset", G_TYPE_STRING, default_charset,
+ "formatter_charset", G_TYPE_STRING, charset,
NULL);
e_web_view_load_uri (E_WEB_VIEW (display), uri);
@@ -1825,6 +1857,7 @@ do_reload_display (EMailDisplay *display)
GHashTable *table;
SoupURI *soup_uri;
gchar *mode, *collapsable, *collapsed;
+ const gchar *default_charset, *charset;
web_view = E_WEB_VIEW (display);
uri = (gchar *) e_web_view_get_uri (web_view);
@@ -1844,6 +1877,13 @@ do_reload_display (EMailDisplay *display)
mode = g_strdup_printf ("%d", display->priv->mode);
collapsable = g_strdup_printf ("%d", display->priv->headers_collapsable);
collapsed = g_strdup_printf ("%d", display->priv->headers_collapsed);
+ default_charset = e_mail_formatter_get_default_charset (display->priv->formatter);
+ charset = e_mail_formatter_get_charset (display->priv->formatter);
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
table = soup_form_decode (soup_uri->query);
g_hash_table_replace (
@@ -1852,6 +1892,10 @@ do_reload_display (EMailDisplay *display)
table, g_strdup ("headers_collapsable"), collapsable);
g_hash_table_replace (
table, g_strdup ("headers_collapsed"), collapsed);
+ g_hash_table_replace (
+ table, g_strdup ("formatter_default_charset"), g_strdup (default_charset));
+ g_hash_table_replace (
+ table, g_strdup ("formatter_charset"), g_strdup (charset));
query = soup_form_encode_hash (table);
diff --git a/mail/e-mail-display.h b/mail/e-mail-display.h
index 7bf4aeed74..1acae83c8d 100644
--- a/mail/e-mail-display.h
+++ b/mail/e-mail-display.h
@@ -67,6 +67,8 @@ void e_mail_display_set_mode (EMailDisplay *display,
EMailFormatterMode mode);
EMailFormatterMode e_mail_display_get_mode (EMailDisplay *display);
+EMailFormatter * e_mail_display_get_formatter (EMailDisplay *display);
+
EMailPartList * e_mail_display_get_parts_list (EMailDisplay *display);
void e_mail_display_set_parts_list (EMailDisplay *display,
diff --git a/mail/e-mail-printer.c b/mail/e-mail-printer.c
index 2f7e1366b4..8da529f1b1 100644
--- a/mail/e-mail-printer.c
+++ b/mail/e-mail-printer.c
@@ -198,25 +198,38 @@ emp_start_printing (GObject *object,
}
static void
-emp_run_print_operation (EMailPrinter *emp)
+emp_run_print_operation (EMailPrinter *emp,
+ EMailFormatter *formatter)
{
EMailPartList *part_list;
CamelFolder *folder;
const gchar *message_uid;
+ const gchar *default_charset, *charset;
gchar *mail_uri;
part_list = emp->priv->parts_list;
folder = e_mail_part_list_get_folder (part_list);
message_uid = e_mail_part_list_get_message_uid (part_list);
+ default_charset = formatter ? e_mail_formatter_get_default_charset (formatter) : NULL;
+ charset = formatter ? e_mail_formatter_get_charset (formatter) : NULL;
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
mail_uri = e_mail_part_build_uri (
folder, message_uid,
"__evo-load-image", G_TYPE_BOOLEAN, TRUE,
"mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_PRINTING,
+ "formatter_default_charset", G_TYPE_STRING, default_charset,
+ "formatter_charset", G_TYPE_STRING, charset,
NULL);
/* Print_layout is a special EMPart created by EMFormatHTMLPrint */
if (emp->priv->webview == NULL) {
+ EMailFormatter *emp_formatter;
+
emp->priv->webview = g_object_new (
E_TYPE_MAIL_DISPLAY,
"mode", E_MAIL_FORMATTER_MODE_PRINTING, NULL);
@@ -224,6 +237,12 @@ emp_run_print_operation (EMailPrinter *emp)
e_mail_display_set_force_load_images (
E_MAIL_DISPLAY (emp->priv->webview), TRUE);
+ emp_formatter = e_mail_display_get_formatter (E_MAIL_DISPLAY (emp->priv->webview));
+ if (default_charset && *default_charset)
+ e_mail_formatter_set_default_charset (emp_formatter, default_charset);
+ if (charset && *charset)
+ e_mail_formatter_set_charset (emp_formatter, charset);
+
g_object_ref_sink (emp->priv->webview);
g_signal_connect (
emp->priv->webview, "notify::load-status",
@@ -831,6 +850,7 @@ e_mail_printer_new (EMailPartList *source)
void
e_mail_printer_print (EMailPrinter *emp,
GtkPrintOperationAction action,
+ EMailFormatter *formatter,
GCancellable *cancellable)
{
g_return_if_fail (E_IS_MAIL_PRINTER (emp));
@@ -857,7 +877,7 @@ e_mail_printer_print (EMailPrinter *emp,
cancellable, "cancelled",
G_CALLBACK (gtk_print_operation_cancel), emp->priv->operation);
- emp_run_print_operation (emp);
+ emp_run_print_operation (emp, formatter);
}
const gchar *
diff --git a/mail/e-mail-printer.h b/mail/e-mail-printer.h
index c177bfe253..01c32f3754 100644
--- a/mail/e-mail-printer.h
+++ b/mail/e-mail-printer.h
@@ -21,6 +21,7 @@
#define E_MAIL_PRINTER_H
#include <em-format/e-mail-part-list.h>
+#include <em-format/e-mail-formatter.h>
/* Standard GObject macros */
#define E_TYPE_MAIL_PRINTER \
@@ -67,6 +68,7 @@ EMailPrinter * e_mail_printer_new (EMailPartList *source);
void e_mail_printer_print (EMailPrinter *printer,
GtkPrintOperationAction action,
+ EMailFormatter *formatter,
GCancellable *cancellable);
void e_mail_printer_set_export_filename
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index cce0046658..11ac330e3a 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -951,6 +951,7 @@ mail_reader_do_print_message (GObject *object,
gpointer user_data)
{
EMailReader *reader = E_MAIL_READER (object);
+ EMailDisplay *mail_display;
EActivity *activity;
GCancellable *cancellable;
EMailPrinter *printer;
@@ -969,7 +970,11 @@ mail_reader_do_print_message (GObject *object,
printer, "done",
G_CALLBACK (printing_done_cb), activity);
- e_mail_printer_print (printer, context->action, cancellable);
+ mail_display = e_mail_reader_get_mail_display (reader);
+
+ e_mail_printer_print (printer, context->action,
+ e_mail_display_get_formatter (mail_display),
+ cancellable);
free_message_printing_context (context);
}
diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c
index 000a0b0516..c3f0b8552d 100644
--- a/mail/e-mail-request.c
+++ b/mail/e-mail-request.c
@@ -71,6 +71,7 @@ handle_mail_request (GSimpleAsyncResult *res,
GByteArray *ba;
gchar *part_id;
gchar *val;
+ const gchar *default_charset, *charset;
EMailFormatterContext context = { 0 };
@@ -99,6 +100,9 @@ handle_mail_request (GSimpleAsyncResult *res,
if (val)
context.mode = atoi (val);
+ default_charset = g_hash_table_lookup (request->priv->uri_query, "formatter_default_charset");
+ charset = g_hash_table_lookup (request->priv->uri_query, "formatter_charset");
+
context.part_list = g_object_ref (part_list);
context.uri = request->priv->full_uri;
@@ -107,6 +111,11 @@ handle_mail_request (GSimpleAsyncResult *res,
else
formatter = e_mail_formatter_new ();
+ if (default_charset && *default_charset)
+ e_mail_formatter_set_default_charset (formatter, default_charset);
+ if (charset && *charset)
+ e_mail_formatter_set_charset (formatter, charset);
+
part_id = g_hash_table_lookup (request->priv->uri_query, "part_id");
if (part_id) {
EMailPart *part;
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 204188f4e4..9962101f49 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -974,7 +974,7 @@ em_utils_composer_print_cb (EMsgComposer *composer,
emp, "done",
G_CALLBACK (composer_print_done_cb), NULL);
- e_mail_printer_print (emp, action, NULL);
+ e_mail_printer_print (emp, action, NULL, NULL);
g_object_unref (parts);
}
diff --git a/mail/em-utils.c b/mail/em-utils.c
index fc6568d1ea..b0dc4ba509 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -622,7 +622,7 @@ do_print_msg_to_file (GObject *source,
printer, "done",
G_CALLBACK (g_object_unref), printer);
- e_mail_printer_print (printer, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL);
+ e_mail_printer_print (printer, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, NULL);
g_object_unref (parser);
}
@@ -1143,7 +1143,7 @@ em_utils_selection_set_urilist (GtkSelectionData *data,
}
/**
- * em_utils_selection_set_urilist:
+ * em_utils_selection_get_urilist:
* @data:
* @folder:
* @uids:
diff --git a/modules/itip-formatter/e-mail-formatter-itip.c b/modules/itip-formatter/e-mail-formatter-itip.c
index ca2a0c6f24..500810b639 100644
--- a/modules/itip-formatter/e-mail-formatter-itip.c
+++ b/modules/itip-formatter/e-mail-formatter-itip.c
@@ -82,6 +82,7 @@ emfe_itip_format (EMailFormatterExtension *extension,
CamelFolder *folder;
CamelMimeMessage *message;
const gchar *message_uid;
+ const gchar *default_charset, *charset;
gchar *uri;
folder = e_mail_part_list_get_folder (context->part_list);
@@ -102,10 +103,20 @@ emfe_itip_format (EMailFormatterExtension *extension,
itip_part->uid = g_strdup (message_uid);
itip_part->msg = g_object_ref (message);
+ default_charset = e_mail_formatter_get_default_charset (formatter);
+ charset = e_mail_formatter_get_charset (formatter);
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
+
uri = e_mail_part_build_uri (
folder, message_uid,
"part_id", G_TYPE_STRING, part->id,
"mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW,
+ "formatter_default_charset", G_TYPE_STRING, default_charset,
+ "formatter_charset", G_TYPE_STRING, charset,
NULL);
buffer = g_string_sized_new (256);
diff --git a/modules/text-highlight/e-mail-formatter-text-highlight.c b/modules/text-highlight/e-mail-formatter-text-highlight.c
index d180d60af7..5e8c15c16c 100644
--- a/modules/text-highlight/e-mail-formatter-text-highlight.c
+++ b/modules/text-highlight/e-mail-formatter-text-highlight.c
@@ -312,11 +312,19 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
} else {
CamelFolder *folder;
const gchar *message_uid;
+ const gchar *default_charset, *charset;
gchar *uri, *str;
gchar *syntax;
folder = e_mail_part_list_get_folder (context->part_list);
message_uid = e_mail_part_list_get_message_uid (context->part_list);
+ default_charset = e_mail_formatter_get_default_charset (formatter);
+ charset = e_mail_formatter_get_charset (formatter);
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
syntax = get_syntax (part, NULL);
@@ -325,6 +333,8 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
"part_id", G_TYPE_STRING, part->id,
"mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW,
"__formatas", G_TYPE_STRING, syntax,
+ "formatter_default_charset", G_TYPE_STRING, default_charset,
+ "formatter_charset", G_TYPE_STRING, charset,
NULL);
g_free (syntax);
diff --git a/modules/vcard-inline/e-mail-formatter-vcard-inline.c b/modules/vcard-inline/e-mail-formatter-vcard-inline.c
index f7dc88e5b0..bcced23351 100644
--- a/modules/vcard-inline/e-mail-formatter-vcard-inline.c
+++ b/modules/vcard-inline/e-mail-formatter-vcard-inline.c
@@ -84,6 +84,7 @@ emfe_vcard_inline_format (EMailFormatterExtension *extension,
} else {
CamelFolder *folder;
const gchar *message_uid;
+ const gchar *default_charset, *charset;
gchar *str, *uri;
gint length;
const gchar *label = NULL;
@@ -97,6 +98,13 @@ emfe_vcard_inline_format (EMailFormatterExtension *extension,
folder = e_mail_part_list_get_folder (context->part_list);
message_uid = e_mail_part_list_get_message_uid (context->part_list);
+ default_charset = e_mail_formatter_get_default_charset (formatter);
+ charset = e_mail_formatter_get_charset (formatter);
+
+ if (!default_charset)
+ default_charset = "";
+ if (!charset)
+ charset = "";
if (vcard_part->message_uid == NULL && message_uid != NULL)
vcard_part->message_uid = g_strdup (message_uid);
@@ -108,6 +116,8 @@ emfe_vcard_inline_format (EMailFormatterExtension *extension,
folder, message_uid,
"part_id", G_TYPE_STRING, part->id,
"mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW,
+ "formatter_default_charset", G_TYPE_STRING, default_charset,
+ "formatter_charset", G_TYPE_STRING, charset,
NULL);
mode = eab_contact_formatter_get_display_mode (vcard_part->formatter);