Commit 332789ff authored by Tomas Popela's avatar Tomas Popela Committed by Milan Crha

Bug 751588 - Port to WebKit2

parent 76c34f7d
...@@ -71,6 +71,7 @@ SUBDIRS = \ ...@@ -71,6 +71,7 @@ SUBDIRS = \
mail \ mail \
calendar \ calendar \
art \ art \
web-extensions \
plugins \ plugins \
modules \ modules \
$(MAINT_SUBDIR) \ $(MAINT_SUBDIR) \
......
...@@ -995,7 +995,7 @@ fill_in_email (EContactEditor *editor) ...@@ -995,7 +995,7 @@ fill_in_email (EContactEditor *editor)
email_location = eab_get_email_type_index (attr); email_location = eab_get_email_type_index (attr);
slot = get_ui_slot (attr); slot = get_ui_slot (attr);
if (slot < 1) if (slot < 1)
slot = EMAIL_SLOTS + 1; //add at the end slot = EMAIL_SLOTS + 1; /* add at the end */
gtk_list_store_append (data_store, &iter); gtk_list_store_append (data_store, &iter);
gtk_list_store_set (data_store, &iter, gtk_list_store_set (data_store, &iter,
...@@ -2103,7 +2103,7 @@ fill_in_im (EContactEditor *editor) ...@@ -2103,7 +2103,7 @@ fill_in_im (EContactEditor *editor)
slot = get_ui_slot (attr); slot = get_ui_slot (attr);
if (slot < 0) if (slot < 0)
slot = IM_SLOTS + 1; //attach at the end slot = IM_SLOTS + 1; /* attach at the end */
gtk_list_store_append (data_store, &iter); gtk_list_store_append (data_store, &iter);
gtk_list_store_set (data_store, &iter, gtk_list_store_set (data_store, &iter,
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <string.h> #include <string.h>
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <webkit/webkit.h> #include <webkit2/webkit2.h>
#include "e-contact-map.h" #include "e-contact-map.h"
#include "eab-contact-formatter.h" #include "eab-contact-formatter.h"
...@@ -386,19 +386,31 @@ contact_display_object_requested (WebKitWebView *web_view, ...@@ -386,19 +386,31 @@ contact_display_object_requested (WebKitWebView *web_view,
#endif #endif
static void static void
contact_display_load_status_changed (WebKitWebView *web_view, contact_display_load_changed (WebKitWebView *web_view,
GParamSpec *pspec, WebKitLoadEvent load_event,
gpointer user_data) gpointer user_data)
{ {
WebKitLoadStatus load_status; GDBusProxy *web_extension;
WebKitDOMDocument *document; GVariant* result;
load_status = webkit_web_view_get_load_status (web_view); if (load_event != WEBKIT_LOAD_FINISHED)
if (load_status != WEBKIT_LOAD_FINISHED)
return; return;
document = webkit_web_view_get_dom_document (web_view); web_extension = e_web_view_get_web_extension_proxy (E_WEB_VIEW (web_view));
eab_contact_formatter_bind_dom (document); if (web_extension) {
result = g_dbus_proxy_call_sync (
web_extension,
"EABContactFormatterBindDOM",
g_variant_new (
"(t)",
webkit_web_view_get_page_id (web_view)),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, /* cancellable */
NULL);
if (result)
g_variant_unref (result);
}
} }
static void static void
...@@ -514,15 +526,12 @@ eab_contact_display_init (EABContactDisplay *display) ...@@ -514,15 +526,12 @@ eab_contact_display_init (EABContactDisplay *display)
G_CALLBACK (contact_display_object_requested), display); G_CALLBACK (contact_display_object_requested), display);
#endif #endif
e_signal_connect_notify ( e_signal_connect_notify (
web_view, "notify::load-status", web_view, "notify::load-changed",
G_CALLBACK (contact_display_load_status_changed), NULL); G_CALLBACK (contact_display_load_changed), NULL);
g_signal_connect ( g_signal_connect (
web_view, "style-updated", web_view, "style-updated",
G_CALLBACK (load_contact), NULL); G_CALLBACK (load_contact), NULL);
e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_FILE_REQUEST);
e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_STOCK_REQUEST);
action_group = gtk_action_group_new ("internal-mailto"); action_group = gtk_action_group_new ("internal-mailto");
gtk_action_group_set_translation_domain (action_group, domain); gtk_action_group_set_translation_domain (action_group, domain);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
......
...@@ -1383,64 +1383,3 @@ eab_contact_formatter_format_contact (EABContactFormatter *formatter, ...@@ -1383,64 +1383,3 @@ eab_contact_formatter_format_contact (EABContactFormatter *formatter,
else else
render_compact (formatter, contact, output_buffer); render_compact (formatter, contact, output_buffer);
} }
static void
collapse_contacts_list (WebKitDOMEventTarget *event_target,
WebKitDOMEvent *event,
gpointer user_data)
{
WebKitDOMDocument *document;
WebKitDOMElement *list;
gchar *id, *list_id;
gchar *imagesdir, *src;
gboolean hidden;
document = user_data;
id = webkit_dom_element_get_id (WEBKIT_DOM_ELEMENT (event_target));
list_id = g_strconcat ("list-", id, NULL);
list = webkit_dom_document_get_element_by_id (document, list_id);
g_free (id);
g_free (list_id);
if (list == NULL)
return;
imagesdir = g_filename_to_uri (EVOLUTION_IMAGESDIR, NULL, NULL);
hidden = webkit_dom_html_element_get_hidden (WEBKIT_DOM_HTML_ELEMENT (list));
if (hidden)
src = g_strdup_printf ("evo-file://%s/minus.png", imagesdir);
else
src = g_strdup_printf ("evo-file://%s/plus.png", imagesdir);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (list), !hidden);
webkit_dom_html_image_element_set_src (
WEBKIT_DOM_HTML_IMAGE_ELEMENT (event_target), src);
g_free (src);
g_free (imagesdir);
}
void
eab_contact_formatter_bind_dom (WebKitDOMDocument *document)
{
WebKitDOMNodeList *nodes;
gulong ii, length;
nodes = webkit_dom_document_get_elements_by_class_name (
document, "_evo_collapse_button");
length = webkit_dom_node_list_get_length (nodes);
for (ii = 0; ii < length; ii++) {
WebKitDOMNode *node;
node = webkit_dom_node_list_item (nodes, ii);
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (node), "click",
G_CALLBACK (collapse_contacts_list), FALSE, document);
}
g_object_unref (nodes);
}
...@@ -75,7 +75,6 @@ void eab_contact_formatter_format_contact ...@@ -75,7 +75,6 @@ void eab_contact_formatter_format_contact
(EABContactFormatter *formatter, (EABContactFormatter *formatter,
EContact *contact, EContact *contact,
GString *output_buffer); GString *output_buffer);
void eab_contact_formatter_bind_dom (WebKitDOMDocument *document);
G_END_DECLS G_END_DECLS
......
...@@ -177,17 +177,7 @@ ecep_attachments_attachment_loaded_cb (EAttachment *attachment, ...@@ -177,17 +177,7 @@ ecep_attachments_attachment_loaded_cb (EAttachment *attachment,
} }
if (!e_attachment_load_finish (attachment, result, &error)) { if (!e_attachment_load_finish (attachment, result, &error)) {
GtkTreeRowReference *reference; g_signal_emit_by_name (attachment, "load-failed", NULL);
reference = e_attachment_get_reference (attachment);
if (gtk_tree_row_reference_valid (reference)) {
GtkTreeModel *model;
model = gtk_tree_row_reference_get_model (reference);
e_attachment_store_remove_attachment (
E_ATTACHMENT_STORE (model), attachment);
}
/* Ignore cancellations. */ /* Ignore cancellations. */
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
......
...@@ -1639,17 +1639,18 @@ find_enabled_identity (ESourceRegistry *registry, ...@@ -1639,17 +1639,18 @@ find_enabled_identity (ESourceRegistry *registry,
return mail_identity; return mail_identity;
} }
static void static gchar *
setup_from (ECalComponentItipMethod method, get_identity_uid_for_from (EShell *shell,
ECalComponent *comp, ECalComponentItipMethod method,
ECalClient *cal_client, ECalComponent *comp,
EComposerHeaderTable *table) ECalClient *cal_client)
{ {
EClientCache *client_cache; EClientCache *client_cache;
ESourceRegistry *registry; ESourceRegistry *registry;
ESource *source = NULL; ESource *source = NULL;
gchar *identity_uid = NULL;
client_cache = e_composer_header_table_ref_client_cache (table); client_cache = e_shell_get_client_cache (shell);
registry = e_client_cache_ref_registry (client_cache); registry = e_client_cache_ref_registry (client_cache);
/* always use organizer's email when user is an organizer */ /* always use organizer's email when user is an organizer */
...@@ -1673,16 +1674,14 @@ setup_from (ECalComponentItipMethod method, ...@@ -1673,16 +1674,14 @@ setup_from (ECalComponentItipMethod method,
} }
if (source != NULL) { if (source != NULL) {
const gchar *uid; identity_uid = g_strdup (e_source_get_uid (source));
uid = e_source_get_uid (source);
e_composer_header_table_set_identity_uid (table, uid);
g_object_unref (source); g_object_unref (source);
} }
g_object_unref (client_cache);
g_object_unref (registry); g_object_unref (registry);
return identity_uid;
} }
typedef struct { typedef struct {
...@@ -1771,83 +1770,64 @@ itip_send_component_begin (ItipSendComponentData *isc, ...@@ -1771,83 +1770,64 @@ itip_send_component_begin (ItipSendComponentData *isc,
} }
} }
typedef struct _CreateComposerData {
gchar *identity_uid;
EDestination **destinations;
gchar *subject;
gchar *ical_string;
gchar *content_type;
gchar *event_body_text;
GSList *attachments_list;
ECalComponent *comp;
gboolean show_only;
} CreateComposerData;
static void static void
itip_send_component_complete (ItipSendComponentData *isc) itip_send_component_composer_created_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{ {
GSettings *settings; CreateComposerData *ccd = user_data;
EMsgComposer *composer;
EComposerHeaderTable *table; EComposerHeaderTable *table;
EDestination **destinations; EMsgComposer *composer;
ECalComponent *comp = NULL; GSettings *settings;
icalcomponent *top_level = NULL;
icaltimezone *default_zone;
gchar *ical_string = NULL;
gchar *content_type = NULL;
gchar *subject = NULL;
gboolean use_24hour_format; gboolean use_24hour_format;
GError *error = NULL;
g_return_if_fail (isc != NULL); g_return_if_fail (ccd != NULL);
if (isc->completed) composer = e_msg_composer_new_finish (result, &error);
if (error) {
g_warning ("%s: Failed to create msg composer: %s", G_STRFUNC, error->message);
g_clear_error (&error);
return; return;
}
isc->success = FALSE;
settings = e_util_ref_settings ("org.gnome.evolution.calendar"); settings = e_util_ref_settings ("org.gnome.evolution.calendar");
use_24hour_format = g_settings_get_boolean (settings, "use-24hour-format"); use_24hour_format = g_settings_get_boolean (settings, "use-24hour-format");
g_object_unref (settings); g_object_unref (settings);
default_zone = calendar_config_get_icaltimezone ();
/* Tidy up the comp */
comp = comp_compliant (
isc->registry, isc->method, isc->send_comp, isc->cal_client,
isc->zones, default_zone, isc->strip_alarms);
if (comp == NULL)
goto cleanup;
/* Recipients */
destinations = comp_to_list (
isc->registry, isc->method, comp, isc->users, FALSE,
isc->only_new_attendees ? g_object_get_data (
G_OBJECT (isc->send_comp), "new-attendees") : NULL);
if (isc->method != E_CAL_COMPONENT_METHOD_PUBLISH) {
if (destinations == NULL) {
/* We sent them all via the server */
isc->success = TRUE;
goto cleanup;
}
}
/* Subject information */
subject = comp_subject (isc->registry, isc->method, comp);
composer = e_msg_composer_new (e_shell_get_default ());
table = e_msg_composer_get_header_table (composer); table = e_msg_composer_get_header_table (composer);
setup_from (isc->method, isc->send_comp, isc->cal_client, table); if (ccd->identity_uid)
e_composer_header_table_set_subject (table, subject); e_composer_header_table_set_identity_uid (table, ccd->identity_uid);
e_composer_header_table_set_destinations_to (table, destinations);
e_destination_freev (destinations);
/* Content type */ e_composer_header_table_set_subject (table, ccd->subject);
content_type = comp_content_type (comp, isc->method); e_composer_header_table_set_destinations_to (table, ccd->destinations);
top_level = comp_toplevel_with_zones (isc->method, comp, isc->cal_client, isc->zones); if (e_cal_component_get_vtype (ccd->comp) == E_CAL_COMPONENT_EVENT) {
ical_string = icalcomponent_as_ical_string_r (top_level); if (ccd->event_body_text)
e_msg_composer_set_body_text (composer, ccd->event_body_text, TRUE);
if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) { else
e_msg_composer_set_body (composer, ical_string, content_type); e_msg_composer_set_body (composer, ccd->ical_string, ccd->content_type);
} else { } else {
CamelMimePart *attachment; CamelMimePart *attachment;
const gchar *filename; const gchar *filename;
gchar *description; gchar *description;
gchar *body; gchar *body;
filename = comp_filename (comp); filename = comp_filename (ccd->comp);
description = comp_description (comp, use_24hour_format); description = comp_description (ccd->comp, use_24hour_format);
body = camel_text_to_html (description, CAMEL_MIME_FILTER_TOHTML_PRE, 0); body = camel_text_to_html (description, CAMEL_MIME_FILTER_TOHTML_PRE, 0);
e_msg_composer_set_body_text (composer, body, TRUE); e_msg_composer_set_body_text (composer, body, TRUE);
...@@ -1855,8 +1835,8 @@ itip_send_component_complete (ItipSendComponentData *isc) ...@@ -1855,8 +1835,8 @@ itip_send_component_complete (ItipSendComponentData *isc)
attachment = camel_mime_part_new (); attachment = camel_mime_part_new ();
camel_mime_part_set_content ( camel_mime_part_set_content (
attachment, ical_string, attachment, ccd->ical_string,
strlen (ical_string), content_type); strlen (ccd->ical_string), ccd->content_type);
if (filename != NULL && *filename != '\0') if (filename != NULL && *filename != '\0')
camel_mime_part_set_filename (attachment, filename); camel_mime_part_set_filename (attachment, filename);
if (description != NULL && *description != '\0') if (description != NULL && *description != '\0')
...@@ -1868,23 +1848,89 @@ itip_send_component_complete (ItipSendComponentData *isc) ...@@ -1868,23 +1848,89 @@ itip_send_component_complete (ItipSendComponentData *isc)
g_free (description); g_free (description);
} }
append_cal_attachments (composer, comp, isc->attachments_list); append_cal_attachments (composer, ccd->comp, ccd->attachments_list);
isc->attachments_list = NULL; ccd->attachments_list = NULL;
if (isc->method == E_CAL_COMPONENT_METHOD_PUBLISH && !isc->users) if (ccd->show_only)
gtk_widget_show (GTK_WIDGET (composer)); gtk_widget_show (GTK_WIDGET (composer));
else else
e_msg_composer_send (composer); e_msg_composer_send (composer);
e_destination_freev (ccd->destinations);
g_clear_object (&ccd->comp);
g_free (ccd->identity_uid);
g_free (ccd->subject);
g_free (ccd->ical_string);
g_free (ccd->content_type);
g_free (ccd->event_body_text);
g_free (ccd);
}
static void
itip_send_component_complete (ItipSendComponentData *isc)
{
CreateComposerData *ccd;
EDestination **destinations;
ECalComponent *comp = NULL;
EShell *shell;
icalcomponent *top_level = NULL;
icaltimezone *default_zone;
g_return_if_fail (isc != NULL);
if (isc->completed)
return;
isc->success = FALSE;
default_zone = calendar_config_get_icaltimezone ();
/* Tidy up the comp */
comp = comp_compliant (
isc->registry, isc->method, isc->send_comp, isc->cal_client,
isc->zones, default_zone, isc->strip_alarms);
if (comp == NULL)
goto cleanup;
/* Recipients */
destinations = comp_to_list (
isc->registry, isc->method, comp, isc->users, FALSE,
isc->only_new_attendees ? g_object_get_data (
G_OBJECT (isc->send_comp), "new-attendees") : NULL);
if (isc->method != E_CAL_COMPONENT_METHOD_PUBLISH) {
if (destinations == NULL) {
/* We sent them all via the server */
isc->success = TRUE;
goto cleanup;
}
}
shell = e_shell_get_default ();
top_level = comp_toplevel_with_zones (isc->method, comp, isc->cal_client, isc->zones);
ccd = g_new0 (CreateComposerData, 1);
ccd->identity_uid = get_identity_uid_for_from (shell, isc->method, isc->send_comp, isc->cal_client);
ccd->destinations = destinations;
ccd->subject = comp_subject (isc->registry, isc->method, comp);
ccd->ical_string = icalcomponent_as_ical_string_r (top_level);
ccd->content_type = comp_content_type (comp, isc->method);
ccd->event_body_text = NULL;
ccd->attachments_list = isc->attachments_list;
ccd->comp = comp;
ccd->show_only = isc->method == E_CAL_COMPONENT_METHOD_PUBLISH && !isc->users;
isc->attachments_list = NULL;
comp = NULL;
e_msg_composer_new (shell, itip_send_component_composer_created_cb, ccd);
isc->success = TRUE; isc->success = TRUE;
cleanup: cleanup:
g_clear_object (&comp); g_clear_object (&comp);
if (top_level != NULL) if (top_level != NULL)
icalcomponent_free (top_level); icalcomponent_free (top_level);
g_free (content_type);
g_free (subject);
g_free (ical_string);
} }
static void static void
...@@ -2119,15 +2165,11 @@ reply_to_calendar_comp (ESourceRegistry *registry, ...@@ -2119,15 +2165,11 @@ reply_to_calendar_comp (ESourceRegistry *registry,
GSList *attachments_list) GSList *attachments_list)
{ {
EShell *shell; EShell *shell;
EMsgComposer *composer;
EComposerHeaderTable *table;
EDestination **destinations;
ECalComponent *comp = NULL; ECalComponent *comp = NULL;
icalcomponent *top_level = NULL; icalcomponent *top_level = NULL;
icaltimezone *default_zone; icaltimezone *default_zone;
gchar *subject = NULL;
gchar *ical_string = NULL;
gboolean retval = FALSE; gboolean retval = FALSE;
CreateComposerData *ccd;
g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE); g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
...@@ -2143,24 +2185,15 @@ reply_to_calendar_comp (ESourceRegistry *registry, ...@@ -2143,24 +2185,15 @@ reply_to_calendar_comp (ESourceRegistry *registry,
if (comp == NULL) if (comp == NULL)
goto cleanup; goto cleanup;
/* Recipients */
destinations = comp_to_list (
registry, method, comp, NULL, reply_all, NULL);
/* Subject information */
subject = comp_subject (registry, method, comp);
composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
setup_from (method, send_comp, cal_client, table);
e_composer_header_table_set_subject (table, subject);
e_composer_header_table_set_destinations_to (table, destinations);
e_destination_freev (destinations);
top_level = comp_toplevel_with_zones (method, comp, cal_client, zones); top_level = comp_toplevel_with_zones (method, comp, cal_client, zones);
ical_string = icalcomponent_as_ical_string_r (top_level);
ccd = g_new0 (CreateComposerData, 1);
ccd->identity_uid = get_identity_uid_for_from (shell, method, send_comp, cal_client);
ccd->destinations = comp_to_list (registry, method, comp, NULL, reply_all, NULL);
ccd->subject = comp_subject (registry, method, comp);
ccd->ical_string = icalcomponent_as_ical_string_r (top_level);
ccd->comp = comp;
ccd->show_only = TRUE;
if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) { if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) {
...@@ -2268,11 +2301,12 @@ reply_to_calendar_comp (ESourceRegistry *registry, ...@@ -2268,11 +2301,12 @@ reply_to_calendar_comp (ESourceRegistry *registry,
g_string_append (body, html_description); g_string_append (body, html_description);
g_free (html_description); g_free (html_description);
e_msg_composer_set_body_text (composer, body->str, TRUE); ccd->event_body_text = g_string_free (body, FALSE);
g_string_free (body, TRUE);
} }
gtk_widget_show (GTK_WIDGET (composer)); comp = NULL;