[evolution/webkit: 39/40] Don't store formatters directly in SoupSession's data
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 39/40] Don't store formatters directly in SoupSession's data
- Date: Fri, 7 Oct 2011 15:27:53 +0000 (UTC)
commit b4ef2b929285ef49f484c5378591078a924f48ca
Author: Dan VrÃtil <dvratil redhat com>
Date: Thu Oct 6 16:49:01 2011 +0200
Don't store formatters directly in SoupSession's data
Formatters are now stored in GHashTable which is stored in SoupSession
GObject data. This way all formatters can be safely iterated without
need to check if there are another data stored in the SoupSession.
mail/e-mail-reader.c | 13 ++++++++++---
mail/e-mail-request.c | 7 +++++--
2 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 0c4d59d..4e2e1df 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -2515,6 +2515,7 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
gint timeout_interval;
GError *error = NULL;
SoupSession *session;
+ GHashTable *formatters;
reader = closure->reader;
message_uid = closure->message_uid;
@@ -2568,16 +2569,22 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
mail_uri = em_format_build_mail_uri (folder, message_uid, NULL, NULL);
session = webkit_get_default_session ();
- if ((formatter = g_object_get_data (G_OBJECT (session), mail_uri)) == NULL) {
+ formatters = g_object_get_data (G_OBJECT (session), "formatters");
+ if (!formatters) {
+ formatters = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
+ g_object_set_data (G_OBJECT (session), "formatters", formatters);
+ }
+
+ if ((formatter = g_hash_table_lookup (formatters, mail_uri)) == NULL) {
formatter = em_format_html_display_new ();
EM_FORMAT (formatter)->message_uid = g_strdup (message_uid);
em_format_parse (EM_FORMAT (formatter), message, folder, NULL);
- g_object_set_data (G_OBJECT (session), mail_uri, formatter);
+ g_hash_table_insert (formatters, mail_uri, formatter);
}
e_mail_display_set_formatter (display, EM_FORMAT_HTML (formatter));
e_mail_display_load (display, mail_uri);
- g_free (mail_uri);
/* Reset the shell view icon. */
e_shell_event (shell, "mail-icon", (gpointer) "evolution-mail");
diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c
index 052d43b..7c52c00 100644
--- a/mail/e-mail-request.c
+++ b/mail/e-mail-request.c
@@ -175,6 +175,7 @@ mail_request_send_async (SoupRequest *request,
d(printf("received request for %s\n", soup_uri_to_string (uri, FALSE)));
if (g_strcmp0 (uri->scheme, "mail") == 0) {
+ GHashTable *formatters;
gchar *uri_str;
if (!uri->query) {
@@ -182,9 +183,11 @@ mail_request_send_async (SoupRequest *request,
g_return_if_fail (uri->query);
}
- uri_str = g_strdup_printf ("%s://%s%s", uri->scheme, uri->host, uri->path);
+ formatters = g_object_get_data (G_OBJECT (session), "formatters");
+ g_return_if_fail (formatters != NULL);
- emr->priv->efh = g_object_get_data (G_OBJECT (session), uri_str);
+ uri_str = g_strdup_printf ("%s://%s%s", uri->scheme, uri->host, uri->path);
+ emr->priv->efh = g_hash_table_lookup (formatters, uri_str);
g_free (uri_str);
g_return_if_fail (emr->priv->efh);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]