aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-04-01 00:08:36 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-04-01 03:48:01 +0800
commit9ed9a99baddcb87eab366e4f939dc146f2db9401 (patch)
treeb4fb0824904a261fa671973d9a499ed4328c0689 /mail
parentd15cd735886c38ac4c14faa816c307ce8f388844 (diff)
downloadgsoc2013-evolution-9ed9a99baddcb87eab366e4f939dc146f2db9401.tar
gsoc2013-evolution-9ed9a99baddcb87eab366e4f939dc146f2db9401.tar.gz
gsoc2013-evolution-9ed9a99baddcb87eab366e4f939dc146f2db9401.tar.bz2
gsoc2013-evolution-9ed9a99baddcb87eab366e4f939dc146f2db9401.tar.lz
gsoc2013-evolution-9ed9a99baddcb87eab366e4f939dc146f2db9401.tar.xz
gsoc2013-evolution-9ed9a99baddcb87eab366e4f939dc146f2db9401.tar.zst
gsoc2013-evolution-9ed9a99baddcb87eab366e4f939dc146f2db9401.zip
EMFormat: Add "session" as a constructor property.
Pass it in instead of digging it out of EShellSettings.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-reader.c9
-rw-r--r--mail/em-composer-utils.c42
-rw-r--r--mail/em-composer-utils.h4
-rw-r--r--mail/em-format-html-display.c8
-rw-r--r--mail/em-format-html-display.h2
-rw-r--r--mail/em-format-html-print.c9
-rw-r--r--mail/em-utils.c15
-rw-r--r--mail/em-utils.h2
8 files changed, 68 insertions, 23 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 0106b6ed53..4940fbe321 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -3099,6 +3099,8 @@ mail_reader_set_display_formatter_for_message (EMailReader *reader,
}
if ((formatter = g_hash_table_lookup (formatters, mail_uri)) == NULL) {
+ EMailBackend *mail_backend;
+ EMailSession *mail_session;
struct _formatter_weak_ref_closure *formatter_data =
g_new0 (struct _formatter_weak_ref_closure, 1);
@@ -3107,7 +3109,12 @@ mail_reader_set_display_formatter_for_message (EMailReader *reader,
formatter_data->formatters = g_hash_table_ref (formatters);
formatter_data->mail_uri = g_strdup (mail_uri);
- formatter = EM_FORMAT (em_format_html_display_new ());
+ mail_backend = e_mail_reader_get_backend (reader);
+ mail_session = e_mail_backend_get_session (mail_backend);
+
+ formatter = EM_FORMAT (
+ em_format_html_display_new (
+ CAMEL_SESSION (mail_session)));
/* When no EMailDisplay holds reference to the formatter, then
* the formatter can be destroyed. */
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index f4b8560f81..acff5e9b4f 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -950,9 +950,12 @@ em_utils_composer_print_cb (EMsgComposer *composer,
{
EMailPrinter *emp;
EMFormatHTMLDisplay *efhd;
+ const gchar *message_id;
- efhd = em_format_html_display_new ();
- ((EMFormat *) efhd)->message_uid = g_strdup (camel_mime_message_get_message_id (message));
+ efhd = em_format_html_display_new (CAMEL_SESSION (session));
+
+ message_id = camel_mime_message_get_message_id (message);
+ ((EMFormat *) efhd)->message_uid = g_strdup (message_id);
/* Parse the message */
em_format_parse ((EMFormat *) efhd, message, NULL, NULL);
@@ -1651,6 +1654,7 @@ forward_attached_cb (CamelFolder *folder,
static EMsgComposer *
forward_non_attached (EShell *shell,
+ CamelSession *session,
CamelFolder *folder,
const gchar *uid,
CamelMimeMessage *message,
@@ -1667,7 +1671,7 @@ forward_non_attached (EShell *shell,
forward = quoting_text (QUOTING_FORWARD);
text = em_utils_message_to_html (
- message, forward, flags, NULL, NULL, &validity_found);
+ session, message, forward, flags, NULL, NULL, &validity_found);
if (text != NULL) {
CamelDataWrapper *content;
@@ -1713,6 +1717,7 @@ forward_non_attached (EShell *shell,
/**
* em_utils_forward_message:
* @shell: an #EShell
+ * @session: a #CamelSession
* @message: a #CamelMimeMessage to forward
* @style: the forward style to use
* @folder: a #CamelFolder, or %NULL
@@ -1723,6 +1728,7 @@ forward_non_attached (EShell *shell,
**/
EMsgComposer *
em_utils_forward_message (EShell *shell,
+ CamelSession *session,
CamelMimeMessage *message,
EMailForwardStyle style,
CamelFolder *folder,
@@ -1733,6 +1739,7 @@ em_utils_forward_message (EShell *shell,
EMsgComposer *composer = NULL;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
switch (style) {
@@ -1751,7 +1758,7 @@ em_utils_forward_message (EShell *shell,
case E_MAIL_FORWARD_STYLE_INLINE:
case E_MAIL_FORWARD_STYLE_QUOTED:
composer = forward_non_attached (
- shell, folder, uid, message, style);
+ shell, session, folder, uid, message, style);
break;
}
@@ -1765,6 +1772,7 @@ forward_got_messages_cb (CamelFolder *folder,
{
EShell *shell;
EMailBackend *backend;
+ EMailSession *session;
EAlertSink *alert_sink;
GHashTable *hash_table;
GHashTableIter iter;
@@ -1798,6 +1806,7 @@ forward_got_messages_cb (CamelFolder *folder,
g_return_if_fail (hash_table != NULL);
backend = e_mail_reader_get_backend (context->reader);
+ session = e_mail_backend_get_session (backend);
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
/* Create a new composer window for each message. */
@@ -1806,7 +1815,8 @@ forward_got_messages_cb (CamelFolder *folder,
while (g_hash_table_iter_next (&iter, &key, &value))
em_utils_forward_message (
- shell, value, context->style, folder, key);
+ shell, CAMEL_SESSION (session),
+ value, context->style, folder, key);
g_hash_table_unref (hash_table);
@@ -2674,10 +2684,13 @@ composer_set_body (EMsgComposer *composer,
{
gchar *text, *credits, *original;
CamelMimePart *part;
+ CamelSession *session;
GSettings *settings;
gboolean start_bottom, has_body_text = FALSE;
guint32 validity_found = 0;
+ session = e_msg_composer_get_session (composer);
+
settings = g_settings_new ("org.gnome.evolution.mail");
start_bottom = g_settings_get_boolean (settings, "composer-reply-start-bottom");
@@ -2695,8 +2708,8 @@ composer_set_body (EMsgComposer *composer,
case E_MAIL_REPLY_STYLE_OUTLOOK:
original = quoting_text (QUOTING_ORIGINAL);
text = em_utils_message_to_html (
- message, original, EM_FORMAT_QUOTE_HEADERS, source,
- start_bottom ? "<BR>" : NULL, &validity_found);
+ session, message, original, EM_FORMAT_QUOTE_HEADERS,
+ source, start_bottom ? "<BR>" : NULL, &validity_found);
e_msg_composer_set_body_text (composer, text, TRUE);
has_body_text = text && *text;
g_free (text);
@@ -2709,8 +2722,8 @@ composer_set_body (EMsgComposer *composer,
/* do what any sane user would want when replying... */
credits = attribution_format (message);
text = em_utils_message_to_html (
- message, credits, EM_FORMAT_QUOTE_CITE, source,
- start_bottom ? "<BR>" : NULL, &validity_found);
+ session, message, credits, EM_FORMAT_QUOTE_CITE,
+ source, start_bottom ? "<BR>" : NULL, &validity_found);
g_free (credits);
e_msg_composer_set_body_text (composer, text, TRUE);
has_body_text = text && *text;
@@ -2747,18 +2760,21 @@ composer_set_body (EMsgComposer *composer,
}
gchar *
-em_utils_construct_composer_text (CamelMimeMessage *message,
+em_utils_construct_composer_text (CamelSession *session,
+ CamelMimeMessage *message,
EMFormat *source)
{
gchar *text, *credits;
gboolean start_bottom = 0;
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
+
credits = attribution_format (message);
text = em_utils_message_to_html (
- message, credits, EM_FORMAT_QUOTE_CITE, source,
- start_bottom ? "<BR>" : NULL, NULL);
-
+ session, message, credits, EM_FORMAT_QUOTE_CITE,
+ source, start_bottom ? "<BR>" : NULL, NULL);
g_free (credits);
+
return text;
}
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index 5b3d3a469a..865254ca31 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -47,6 +47,7 @@ void em_utils_edit_messages (EMailReader *reader,
GPtrArray *uids,
gboolean replace);
EMsgComposer * em_utils_forward_message (EShell *shell,
+ CamelSession *session,
CamelMimeMessage *msg,
EMailForwardStyle style,
CamelFolder *folder,
@@ -59,7 +60,8 @@ void em_utils_forward_messages (EMailReader *reader,
void em_utils_redirect_message (EShell *shell,
CamelMimeMessage *message);
gchar * em_utils_construct_composer_text
- (CamelMimeMessage *message,
+ (CamelSession *session,
+ CamelMimeMessage *message,
EMFormat *source_formatter);
gboolean em_utils_is_munged_list_message (CamelMimeMessage *message);
void em_utils_get_reply_sender (CamelMimeMessage *message,
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 8f20169636..2a42beb943 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -916,9 +916,13 @@ em_format_html_display_get_type (void)
}
EMFormatHTMLDisplay *
-em_format_html_display_new (void)
+em_format_html_display_new (CamelSession *session)
{
- return g_object_new (EM_TYPE_FORMAT_HTML_DISPLAY, NULL);
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
+
+ return g_object_new (
+ EM_TYPE_FORMAT_HTML_DISPLAY,
+ "session", session, NULL);
}
/* ********************************************************************** */
diff --git a/mail/em-format-html-display.h b/mail/em-format-html-display.h
index c1b22eec58..7c0d7a9fd5 100644
--- a/mail/em-format-html-display.h
+++ b/mail/em-format-html-display.h
@@ -111,7 +111,7 @@ struct _EMFormatHTMLDisplayClass {
GType em_format_html_display_get_type (void);
EMFormatHTMLDisplay *
- em_format_html_display_new (void);
+ em_format_html_display_new (CamelSession *session);
G_END_DECLS
#endif /* EM_FORMAT_HTML_DISPLAY_H */
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index 2f9e556d9e..ed64a9ea07 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -618,8 +618,15 @@ EMFormatHTMLPrint *
em_format_html_print_new (EMFormatHTML *source)
{
EMFormatHTMLPrint *efhp;
+ CamelSession *session;
- efhp = g_object_new (EM_TYPE_FORMAT_HTML_PRINT,
+ g_return_val_if_fail (EM_IS_FORMAT_HTML (source), NULL);
+
+ session = em_format_get_session (EM_FORMAT (source));
+
+ efhp = g_object_new (
+ EM_TYPE_FORMAT_HTML_PRINT,
+ "session", session,
"original-formatter", source,
NULL);
diff --git a/mail/em-utils.c b/mail/em-utils.c
index a9b57125a2..52856865b9 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -646,12 +646,17 @@ em_utils_print_messages_to_file (CamelFolder *folder,
{
EMFormatHTMLDisplay *efhd;
CamelMimeMessage *message;
+ CamelStore *parent_store;
+ CamelSession *session;
message = camel_folder_get_message_sync (folder, uid, NULL, NULL);
if (message == NULL)
return FALSE;
- efhd = em_format_html_display_new ();
+ parent_store = camel_folder_get_parent_store (folder);
+ session = camel_service_get_session (CAMEL_SERVICE (parent_store));
+
+ efhd = em_format_html_display_new (session);
((EMFormat *) efhd)->message_uid = g_strdup (uid);
em_format_parse_async ((EMFormat *) efhd, message, folder, NULL,
@@ -1162,6 +1167,7 @@ em_utils_get_proxy (void)
/**
* em_utils_message_to_html:
+ * @session: a #CamelSession
* @message:
* @credits:
* @flags: EMFormatQuote flags
@@ -1177,7 +1183,8 @@ em_utils_get_proxy (void)
* Return value: The html version as a NULL terminated string.
**/
gchar *
-em_utils_message_to_html (CamelMimeMessage *message,
+em_utils_message_to_html (CamelSession *session,
+ CamelMimeMessage *message,
const gchar *credits,
guint32 flags,
EMFormat *source,
@@ -1188,11 +1195,13 @@ em_utils_message_to_html (CamelMimeMessage *message,
CamelStream *mem;
GByteArray *buf;
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
+
buf = g_byte_array_new ();
mem = camel_stream_mem_new ();
camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (mem), buf);
- emfq = em_format_quote_new (credits, mem, flags);
+ emfq = em_format_quote_new (session, credits, mem, flags);
em_format_set_composer ((EMFormat *) emfq, TRUE);
if (!source) {
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 09ae4a56eb..bce64eebc3 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -68,7 +68,7 @@ void em_utils_selection_get_urilist (GtkSelectionData *data, CamelFolder *folder
EProxy * em_utils_get_proxy (void);
/* FIXME: should this have an override charset? */
-gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, guint32 flags, struct _EMFormat *source, const gchar *append, guint32 *validity_found);
+gchar *em_utils_message_to_html (CamelSession *session, CamelMimeMessage *msg, const gchar *credits, guint32 flags, struct _EMFormat *source, const gchar *append, guint32 *validity_found);
void em_utils_empty_trash (GtkWidget *parent,
EMailSession *session);