[evolution/gnome-3-22] Attached meeting invitations not shown properly
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-22] Attached meeting invitations not shown properly
- Date: Thu, 15 Dec 2016 14:05:48 +0000 (UTC)
commit 411e4e46300d590ea4bfbb9a1cca76f4ff08359b
Author: Milan Crha <mcrha redhat com>
Date: Thu Dec 15 15:05:27 2016 +0100
Attached meeting invitations not shown properly
The problem was with the itip-view trying to attach to the DOM
too early, possibly when the attachment had been still collapsed,
thus not part of the DOM at all.
em-format/e-mail-formatter-attachment.c | 6 +-
em-format/e-mail-part-headers.c | 4 +-
em-format/e-mail-part.c | 6 +-
em-format/e-mail-part.h | 4 +-
mail/e-mail-display.c | 87 +++++++++++++++++++++++++++--
modules/itip-formatter/e-mail-part-itip.c | 26 ++++-----
modules/vcard-inline/e-mail-part-vcard.c | 32 +++++++----
web-extensions/e-web-extension.c | 29 ++++++++++
8 files changed, 152 insertions(+), 42 deletions(-)
---
diff --git a/em-format/e-mail-formatter-attachment.c b/em-format/e-mail-formatter-attachment.c
index 86a39ef..e002364 100644
--- a/em-format/e-mail-formatter-attachment.c
+++ b/em-format/e-mail-formatter-attachment.c
@@ -306,10 +306,8 @@ emfe_attachment_format (EMailFormatterExtension *extension,
inner_html_data = g_markup_escape_text (data, size);
- g_string_append_printf (
- buffer,
- " inner-html-data=\"%s\">",
- inner_html_data);
+ g_string_append_printf (buffer, " related-part-id=\"%s\" inner-html-data=\"%s\">",
+ attachment_part_id, inner_html_data);
g_free (inner_html_data);
}
diff --git a/em-format/e-mail-part-headers.c b/em-format/e-mail-part-headers.c
index 1908c77..a0f13fb 100644
--- a/em-format/e-mail-part-headers.c
+++ b/em-format/e-mail-part-headers.c
@@ -218,10 +218,12 @@ mail_part_headers_constructed (GObject *object)
static void
mail_part_headers_bind_dom_element (EMailPart *part,
- GDBusProxy *web_extension,
+ EWebView *web_view,
guint64 page_id,
const gchar *element_id)
{
+ GDBusProxy *web_extension = e_web_view_get_web_extension_proxy (web_view);
+
if (web_extension) {
e_util_invoke_g_dbus_proxy_call_with_error_check (
web_extension,
diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c
index fbfb332..05b0c84 100644
--- a/em-format/e-mail-part.c
+++ b/em-format/e-mail-part.c
@@ -585,21 +585,21 @@ e_mail_part_set_is_attachment (EMailPart *part,
void
e_mail_part_bind_dom_element (EMailPart *part,
- GDBusProxy *web_extension,
+ EWebView *web_view,
guint64 page_id,
const gchar *element_id)
{
EMailPartClass *class;
g_return_if_fail (E_IS_MAIL_PART (part));
- g_return_if_fail (web_extension);
+ g_return_if_fail (E_IS_WEB_VIEW (web_view));
g_return_if_fail (page_id != 0);
g_return_if_fail (element_id && *element_id);
class = E_MAIL_PART_GET_CLASS (part);
if (class->bind_dom_element != NULL)
- class->bind_dom_element (part, web_extension, page_id, element_id);
+ class->bind_dom_element (part, web_view, page_id, element_id);
}
void
diff --git a/em-format/e-mail-part.h b/em-format/e-mail-part.h
index 72e17ad..db13f05 100644
--- a/em-format/e-mail-part.h
+++ b/em-format/e-mail-part.h
@@ -86,7 +86,7 @@ struct _EMailPartClass {
GObjectClass parent_class;
void (*bind_dom_element) (EMailPart *part,
- GDBusProxy *web_extension,
+ EWebView *web_view,
guint64 page_id,
const gchar *element_id);
void (*web_view_loaded) (EMailPart *part,
@@ -124,7 +124,7 @@ gboolean e_mail_part_get_is_attachment (EMailPart *part);
void e_mail_part_set_is_attachment (EMailPart *part,
gboolean is_attachment);
void e_mail_part_bind_dom_element (EMailPart *part,
- GDBusProxy *web_extension,
+ EWebView *web_view,
guint64 page_id,
const gchar *element_id);
void e_mail_part_web_view_loaded (EMailPart *part,
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 8b40406..957b3dd 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -85,6 +85,7 @@ struct _EMailDisplayPrivate {
GHashTable *skipped_remote_content_sites;
guint web_extension_headers_collapsed_signal_id;
+ guint web_extension_mail_part_appeared_signal_id;
GtkAllocation attachment_popup_position;
@@ -536,6 +537,41 @@ headers_collapsed_signal_cb (GDBusConnection *connection,
}
static void
+mail_display_mail_part_appeared_signal_cb (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ EMailDisplay *display = user_data;
+ const gchar *part_id = NULL;
+ guint64 page_id = 0;
+ EMailPart *part;
+
+ if (g_strcmp0 (signal_name, "MailPartAppeared") != 0)
+ return;
+
+ g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+ if (!parameters || !display->priv->part_list)
+ return;
+
+ g_variant_get (parameters, "(t&s)", &page_id, &part_id);
+
+ if (!part_id || !*part_id || page_id != webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (display)))
+ return;
+
+ part = e_mail_part_list_ref_part (display->priv->part_list, part_id);
+ if (part && g_strcmp0 (e_mail_part_get_id (part), part_id) == 0) {
+ e_mail_part_bind_dom_element (part, E_WEB_VIEW (display), page_id, part_id);
+ }
+
+ g_clear_object (&part);
+}
+
+static void
setup_dom_bindings (EMailDisplay *display)
{
GDBusProxy *web_extension;
@@ -558,6 +594,21 @@ setup_dom_bindings (EMailDisplay *display)
NULL);
}
+ if (display->priv->web_extension_mail_part_appeared_signal_id == 0) {
+ display->priv->web_extension_mail_part_appeared_signal_id =
+ g_dbus_connection_signal_subscribe (
+ g_dbus_proxy_get_connection (web_extension),
+ g_dbus_proxy_get_name (web_extension),
+ E_WEB_EXTENSION_INTERFACE,
+ "MailPartAppeared",
+ E_WEB_EXTENSION_OBJECT_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ mail_display_mail_part_appeared_signal_cb,
+ display,
+ NULL);
+ }
+
e_util_invoke_g_dbus_proxy_call_with_error_check (
web_extension,
"EMailDisplayBindDOM",
@@ -1092,19 +1143,25 @@ mail_display_attachment_removed_cb (EAttachmentStore *store,
g_hash_table_remove (display->priv->attachment_flags, attachment);
}
+typedef struct _MailElementExistsData {
+ EWebView *web_view;
+ EMailPart *part;
+} MailElementExistsData;
+
static void
mail_element_exists_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
GDBusProxy *web_extension;
- EMailPart *part = user_data;
+ MailElementExistsData *meed = user_data;
gboolean element_exists = FALSE;
GVariant *result_variant;
guint64 page_id;
GError *error = NULL;
g_return_if_fail (G_IS_DBUS_PROXY (source_object));
+ g_return_if_fail (meed != NULL);
web_extension = G_DBUS_PROXY (source_object);
@@ -1116,12 +1173,14 @@ mail_element_exists_cb (GObject *source_object,
if (element_exists)
e_mail_part_bind_dom_element (
- part,
- web_extension,
+ meed->part,
+ meed->web_view,
page_id,
- e_mail_part_get_id (part));
+ e_mail_part_get_id (meed->part));
- g_object_unref (part);
+ g_object_unref (meed->web_view);
+ g_object_unref (meed->part);
+ g_free (meed);
if (error)
g_dbus_error_strip_remote_error (error);
@@ -1156,6 +1215,7 @@ mail_parts_bind_dom (EMailDisplay *display)
head = g_queue_peek_head_link (&queue);
for (link = head; link != NULL; link = g_list_next (link)) {
+ MailElementExistsData *meed;
EMailPart *part = E_MAIL_PART (link->data);
const gchar *part_id;
@@ -1165,6 +1225,10 @@ mail_parts_bind_dom (EMailDisplay *display)
e_mail_part_web_view_loaded (part, web_view);
+ meed = g_new0 (MailElementExistsData, 1);
+ meed->web_view = g_object_ref (web_view);
+ meed->part = g_object_ref (part);
+
g_dbus_proxy_call (
web_extension,
"ElementExists",
@@ -1177,7 +1241,7 @@ mail_parts_bind_dom (EMailDisplay *display)
-1,
NULL,
mail_element_exists_cb,
- g_object_ref (part));
+ meed);
}
while (!g_queue_is_empty (&queue))
@@ -1351,6 +1415,17 @@ mail_display_dispose (GObject *object)
priv->web_extension_headers_collapsed_signal_id = 0;
}
+ if (priv->web_extension_mail_part_appeared_signal_id > 0) {
+ GDBusProxy *web_extension = e_web_view_get_web_extension_proxy (E_WEB_VIEW (object));
+
+ if (web_extension != NULL) {
+ g_dbus_connection_signal_unsubscribe (
+ g_dbus_proxy_get_connection (web_extension),
+ priv->web_extension_mail_part_appeared_signal_id);
+ }
+ priv->web_extension_mail_part_appeared_signal_id = 0;
+ }
+
if (priv->attachment_store) {
/* To have called the mail_display_attachment_removed_cb() before it's disconnected */
e_attachment_store_remove_all (priv->attachment_store);
diff --git a/modules/itip-formatter/e-mail-part-itip.c b/modules/itip-formatter/e-mail-part-itip.c
index fbb4ffb..e3e3209 100644
--- a/modules/itip-formatter/e-mail-part-itip.c
+++ b/modules/itip-formatter/e-mail-part-itip.c
@@ -72,29 +72,25 @@ mail_part_itip_finalize (GObject *object)
}
static void
-mail_part_itip_web_view_loaded (EMailPart *mail_part,
- EWebView *web_view)
+mail_part_itip_bind_dom_element (EMailPart *part,
+ EWebView *web_view,
+ guint64 page_id,
+ const gchar *element_id)
{
EMailPartItip *pitip;
ItipView *itip_view;
- g_return_if_fail (E_IS_MAIL_PART_ITIP (mail_part));
+ g_return_if_fail (E_IS_MAIL_PART_ITIP (part));
g_return_if_fail (E_IS_WEB_VIEW (web_view));
- pitip = E_MAIL_PART_ITIP (mail_part);
+ if (g_strcmp0 (element_id, e_mail_part_get_id (part)) != 0)
+ return;
- /* FIXME WK2 - it can sometimes happen that the pitip members, like the folder, message_uid and
message,
- are not initialized yet, because the internal frame in the main EWebView is not passed
- through the EMailFormatter, where these are set. This requires a new signal on the WebKitWebView,
- ideally, to call this only after the iframe is truly loaded (these pitip members are only a side
- effect of a whole issue with non-knowing that a particular iframe was fully loaded).
+ pitip = E_MAIL_PART_ITIP (part);
- Also retest what happens when the same meeting is opened in multiple windows; it could crash in
gtk+
- when a button was clicked in one or the other, but also not always.
- */
itip_view = itip_view_new (
- webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (web_view)),
- e_mail_part_get_id (mail_part),
+ page_id,
+ e_mail_part_get_id (part),
pitip,
pitip->folder,
pitip->message_uid,
@@ -121,7 +117,7 @@ e_mail_part_itip_class_init (EMailPartItipClass *class)
object_class->finalize = mail_part_itip_finalize;
mail_part_class = E_MAIL_PART_CLASS (class);
- mail_part_class->web_view_loaded = mail_part_itip_web_view_loaded;
+ mail_part_class->bind_dom_element = mail_part_itip_bind_dom_element;
}
static void
diff --git a/modules/vcard-inline/e-mail-part-vcard.c b/modules/vcard-inline/e-mail-part-vcard.c
index f38d22f..7e4ec04 100644
--- a/modules/vcard-inline/e-mail-part-vcard.c
+++ b/modules/vcard-inline/e-mail-part-vcard.c
@@ -252,6 +252,8 @@ mail_part_vcard_dispose (GObject *object)
part->priv->save_vcard_button_pressed_signal_id = 0;
}
+ g_clear_object (&part->priv->web_extension);
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_mail_part_vcard_parent_class)->dispose (object);
}
@@ -294,24 +296,32 @@ mail_part_vcard_constructed (GObject *object)
static void
mail_part_vcard_bind_dom_element (EMailPart *part,
- GDBusProxy *evolution_web_extension,
+ EWebView *web_view,
guint64 page_id,
const gchar *element_id)
{
EMailPartVCard *vcard_part;
+ GDBusProxy *web_extension;
+
+ g_return_if_fail (E_IS_WEB_VIEW (web_view));
+ g_return_if_fail (E_IS_MAIL_PART_VCARD (part));
+
+ web_extension = e_web_view_get_web_extension_proxy (web_view);
+ if (!web_extension)
+ return;
vcard_part = E_MAIL_PART_VCARD (part);
- vcard_part->priv->web_extension = evolution_web_extension;
+ vcard_part->priv->web_extension = g_object_ref (web_extension);
vcard_part->priv->page_id = page_id;
vcard_part->priv->display_mode_toggled_signal_id =
g_dbus_connection_signal_subscribe (
- g_dbus_proxy_get_connection (evolution_web_extension),
- g_dbus_proxy_get_name (evolution_web_extension),
- g_dbus_proxy_get_interface_name (evolution_web_extension),
+ g_dbus_proxy_get_connection (web_extension),
+ g_dbus_proxy_get_name (web_extension),
+ g_dbus_proxy_get_interface_name (web_extension),
"VCardInlineDisplayModeToggled",
- g_dbus_proxy_get_object_path (evolution_web_extension),
+ g_dbus_proxy_get_object_path (web_extension),
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
(GDBusSignalCallback) display_mode_toggle_cb,
@@ -320,11 +330,11 @@ mail_part_vcard_bind_dom_element (EMailPart *part,
vcard_part->priv->save_vcard_button_pressed_signal_id =
g_dbus_connection_signal_subscribe (
- g_dbus_proxy_get_connection (evolution_web_extension),
- g_dbus_proxy_get_name (evolution_web_extension),
- g_dbus_proxy_get_interface_name (evolution_web_extension),
+ g_dbus_proxy_get_connection (web_extension),
+ g_dbus_proxy_get_name (web_extension),
+ g_dbus_proxy_get_interface_name (web_extension),
"VCardInlineSaveButtonPressed",
- g_dbus_proxy_get_object_path (evolution_web_extension),
+ g_dbus_proxy_get_object_path (web_extension),
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
(GDBusSignalCallback) save_vcard_cb,
@@ -332,7 +342,7 @@ mail_part_vcard_bind_dom_element (EMailPart *part,
NULL);
e_util_invoke_g_dbus_proxy_call_with_error_check (
- vcard_part->priv->web_extension,
+ web_extension,
"VCardInlineBindDOM",
g_variant_new (
"(ts)",
diff --git a/web-extensions/e-web-extension.c b/web-extensions/e-web-extension.c
index b18862b..d464018 100644
--- a/web-extensions/e-web-extension.c
+++ b/web-extensions/e-web-extension.c
@@ -193,6 +193,10 @@ static const char introspection_xml[] =
" <arg type='t' name='page_id' direction='out'/>"
" <arg type='u' name='flags' direction='out'/>"
" </signal>"
+" <signal name='MailPartAppeared'>"
+" <arg type='t' name='page_id' direction='out'/>"
+" <arg type='s' name='part_id' direction='out'/>"
+" </signal>"
" </interface>"
"</node>";
@@ -570,8 +574,33 @@ handle_method_call (GDBusConnection *connection,
inner_html_data = webkit_dom_element_get_attribute (element,
"inner-html-data");
if (inner_html_data && *inner_html_data) {
+ gchar *related_part_id;
+
webkit_dom_element_set_inner_html (element, inner_html_data,
NULL);
webkit_dom_element_remove_attribute (element,
"inner-html-data");
+
+ related_part_id = webkit_dom_element_get_attribute (element,
"related-part-id");
+ webkit_dom_element_remove_attribute (element,
"related-part-id");
+
+ if (related_part_id && *related_part_id) {
+ GError *error = NULL;
+
+ g_dbus_connection_emit_signal (
+ extension->priv->dbus_connection,
+ NULL,
+ E_WEB_EXTENSION_OBJECT_PATH,
+ E_WEB_EXTENSION_INTERFACE,
+ "MailPartAppeared",
+ g_variant_new ("(ts)", page_id,
related_part_id),
+ &error);
+
+ if (error) {
+ g_warning ("Error emitting signal
MailPartAppeared: %s", error->message);
+ g_error_free (error);
+ }
+ }
+
+ g_free (related_part_id);
}
g_free (inner_html_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]