[evolution/wip/mcrha/webkit-jsc-api] Replace e_content_editor_insert_image_from_mime_part() with different approach



commit 80f3a048ef115dcb5dd81eb2e6106ca366a37d81
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jan 22 16:27:33 2020 +0100

    Replace e_content_editor_insert_image_from_mime_part() with different approach

 data/webkit/e-editor.js                     |  17 +-
 src/composer/e-msg-composer.c               |  18 +--
 src/e-util/e-content-editor.c               |  80 +++------
 src/e-util/e-content-editor.h               |  32 +---
 src/e-util/e-html-editor-private.h          |   1 +
 src/e-util/e-html-editor.c                  | 112 ++++++++++++-
 src/e-util/e-html-editor.h                  |  14 +-
 src/mail/e-cid-request.c                    |  68 +++++---
 src/mail/e-cid-request.h                    |  37 +++++
 src/mail/e-mail-display.c                   |  70 +++++++-
 src/mail/e-mail-notes.c                     |  11 +-
 src/modules/webkit-editor/e-webkit-editor.c | 243 ++++++++--------------------
 12 files changed, 400 insertions(+), 303 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 79fc9819dd..1b3c0c9a91 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -2106,9 +2106,9 @@ EvoEditor.GetContent = function(flags, cid_uid_prefix)
                                }
                        }
 
-                       images = document.querySelectorAll("[background]");
-                       for (ii = 0; ii < images.length; ii++) {
-                               var elem = images[ii];
+                       var backgrounds = document.querySelectorAll("[background]");
+                       for (ii = 0; ii < backgrounds.length; ii++) {
+                               var elem = backgrounds[ii];
                                var src = elem ? elem.getAttribute("background").toLowerCase() : "";
 
                                if (elem &&
@@ -3728,6 +3728,17 @@ EvoEditor.InsertSignature = function(content, isHTML, uid, fromMessage, checkCha
        return res;
 }
 
+// the body contains data, which should be converted into editable content;
+// preferredPlainText can be empty, if not, then it replaces body content
+EvoEditor.ConvertContent = function(preferredPlainText, startBottom, topSignature)
+{
+}
+
+// replaces current selection with the next plain text or HTML, quoted or normal DIV
+EvoEditor.PasteText = function(text, isHTML, quote)
+{
+}
+
 EvoEditor.onContextMenu = function(event)
 {
        var node = event.target;
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 5f20646fec..53f49b45ea 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -1608,7 +1608,7 @@ composer_build_message (EMsgComposer *composer,
                        for (link = inline_images_parts; link; link = g_slist_next (link)) {
                                CamelMimePart *part = link->data;
 
-                               camel_multipart_add_part (html_with_images, part);
+                               camel_multipart_add_part (html_with_images, g_object_ref (part));
                        }
 
                        context->top_level_part =
@@ -1617,7 +1617,6 @@ composer_build_message (EMsgComposer *composer,
                        context->top_level_part =
                                CAMEL_DATA_WRAPPER (body);
                }
-               g_slist_free_full (inline_images_parts, g_object_unref);
        }
 
        view = e_msg_composer_get_attachment_view (composer);
@@ -3141,7 +3140,6 @@ add_attachments_handle_mime_part (EMsgComposer *composer,
        CamelContentType *content_type;
        CamelDataWrapper *wrapper;
        EHTMLEditor *editor;
-       EContentEditor *cnt_editor;
 
        if (!mime_part)
                return;
@@ -3149,7 +3147,6 @@ add_attachments_handle_mime_part (EMsgComposer *composer,
        content_type = camel_mime_part_get_content_type (mime_part);
        wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
        editor = e_msg_composer_get_editor (composer);
-       cnt_editor = e_html_editor_get_content_editor (editor);
 
        if (CAMEL_IS_MULTIPART (wrapper)) {
                /* another layer of multipartness... */
@@ -3160,10 +3157,9 @@ add_attachments_handle_mime_part (EMsgComposer *composer,
                if (camel_content_type_is (content_type, "image", "*") && (
                    camel_mime_part_get_content_id (mime_part) ||
                    camel_mime_part_get_content_location (mime_part)))
-                       e_content_editor_insert_image_from_mime_part (
-                               cnt_editor, mime_part);
+                       e_html_editor_add_cid_part (editor, mime_part);
        } else if (related && camel_content_type_is (content_type, "image", "*")) {
-               e_content_editor_insert_image_from_mime_part (cnt_editor, mime_part);
+               e_html_editor_add_cid_part (editor, mime_part);
        } else if (camel_content_type_is (content_type, "text", "*") &&
                camel_mime_part_get_filename (mime_part) == NULL) {
                /* Do nothing if this is a text/anything without a
@@ -3583,12 +3579,10 @@ handle_multipart (EMsgComposer *composer,
                           camel_mime_part_get_content_location (mime_part))) {
                        /* special in-line attachment */
                        EHTMLEditor *editor;
-                       EContentEditor *cnt_editor;
 
                        editor = e_msg_composer_get_editor (composer);
-                       cnt_editor = e_html_editor_get_content_editor (editor);
 
-                       e_content_editor_insert_image_from_mime_part (cnt_editor, mime_part);
+                       e_html_editor_add_cid_part (editor, mime_part);
 
                        /* Add it to both, to not lose attachments not referenced in HTML body.
                           The inserted images are not included in the message when not referenced. */
@@ -4333,7 +4327,9 @@ e_msg_composer_prepare_content_hash (EMsgComposer *composer,
        g_return_if_fail (E_IS_MSG_COMPOSER (composer));
        g_return_if_fail (callback != NULL);
 
-       if (e_msg_composer_get_content_hash (composer)) {
+       /* Cannot use e_msg_composer_get_content_hash() here, because it prints
+          a runtime warning when the content_hash is NULL. */
+       if (composer->priv->content_hash) {
                composer->priv->content_hash_ref_count++;
 
                callback (composer, user_data, NULL);
diff --git a/src/e-util/e-content-editor.c b/src/e-util/e-content-editor.c
index 7ce8bff41c..089dcfc568 100644
--- a/src/e-util/e-content-editor.c
+++ b/src/e-util/e-content-editor.c
@@ -37,7 +37,7 @@ enum {
        REPLACE_ALL_DONE,
        DROP_HANDLED,
        CONTENT_CHANGED,
-       REQUEST_RESOURCE,
+       REF_MIME_PART,
        LAST_SIGNAL
 };
 
@@ -619,24 +619,24 @@ e_content_editor_default_init (EContentEditorInterface *iface)
                G_TYPE_NONE, 0);
 
        /**
-        * EContentEditor:request-resource
+        * EContentEditor:ref-mime-part
         *
         * This is used by the content editor, when it wants to get
-        * some resource. The listener to this signal should finish
-        * the call with e_content_editor_resource_loaded().
+        * a #CamelMimePart of given URI (aka "cid:..."). The returned
+        * object, if not %NULL, should be freed with g_object_unref(),
+        * when no longer needed.
         *
         * Since: 3.36
         */
-       signals[REQUEST_RESOURCE] = g_signal_new (
-               "request-resource",
+       signals[REF_MIME_PART] = g_signal_new (
+               "ref-mime-part",
                E_TYPE_CONTENT_EDITOR,
-               G_SIGNAL_RUN_LAST,
-               G_STRUCT_OFFSET (EContentEditorInterface, request_resource),
+               G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+               G_STRUCT_OFFSET (EContentEditorInterface, ref_mime_part),
                NULL, NULL,
                NULL,
-               G_TYPE_NONE, 2,
-               G_TYPE_STRING,
-               G_TYPE_CANCELLABLE);
+               CAMEL_TYPE_MIME_PART, 1,
+               G_TYPE_STRING);
 }
 
 ESpellChecker *
@@ -1809,10 +1809,14 @@ e_content_editor_util_create_data_mimepart (const gchar *uri,
                }
 
        /* files on the disk */
-       } else if (g_ascii_strncasecmp (uri, "file://", 7) == 0) {
+       } else if (g_ascii_strncasecmp (uri, "file://", 7) == 0 ||
+                  g_ascii_strncasecmp (uri, "evo-file://", 11) == 0) {
                GFileInputStream *file_stream;
                GFile *file;
 
+               if (g_ascii_strncasecmp (uri, "evo-", 4) == 0)
+                       uri += 4;
+
                file = g_file_new_for_uri (uri);
                file_stream = g_file_read (file, NULL, NULL);
                g_clear_object (&file);
@@ -1879,22 +1883,6 @@ e_content_editor_util_create_data_mimepart (const gchar *uri,
        return mime_part;
 }
 
-void
-e_content_editor_insert_image_from_mime_part (EContentEditor *editor,
-                                              CamelMimePart *part)
-{
-       EContentEditorInterface *iface;
-
-       g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
-       g_return_if_fail (part != NULL);
-
-       iface = E_CONTENT_EDITOR_GET_IFACE (editor);
-       g_return_if_fail (iface != NULL);
-       g_return_if_fail (iface->insert_image_from_mime_part != NULL);
-
-       iface->insert_image_from_mime_part (editor, part);
-}
-
 /**
  * e_content_editor_insert_image:
  * @editor: an #EContentEditor
@@ -3804,25 +3792,6 @@ e_content_editor_spell_check_prev_word (EContentEditor *editor,
        return iface->spell_check_prev_word (editor, word);
 }
 
-void
-e_content_editor_resource_loaded (EContentEditor *editor,
-                                 const gchar *uri,
-                                 GInputStream *stream,
-                                 gint64 stream_length,
-                                 const gchar *mime_type,
-                                 const GError *error)
-{
-       EContentEditorInterface *iface;
-
-       g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
-
-       iface = E_CONTENT_EDITOR_GET_IFACE (editor);
-       g_return_if_fail (iface != NULL);
-       g_return_if_fail (iface->resource_loaded != NULL);
-
-       iface->resource_loaded (editor, uri, stream, stream_length, mime_type, error);
-}
-
 void
 e_content_editor_emit_load_finished (EContentEditor *editor)
 {
@@ -3900,13 +3869,16 @@ e_content_editor_emit_content_changed (EContentEditor *editor)
        g_signal_emit (editor, signals[CONTENT_CHANGED], 0);
 }
 
-void
-e_content_editor_emit_request_resource (EContentEditor *editor,
-                                       const gchar *uri,
-                                       GCancellable *cancellable)
+CamelMimePart *
+e_content_editor_emit_ref_mime_part (EContentEditor *editor,
+                                    const gchar *uri)
 {
-       g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
-       g_return_if_fail (uri != NULL);
+       CamelMimePart *mime_part = NULL;
+
+       g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
+       g_return_val_if_fail (uri != NULL, NULL);
 
-       g_signal_emit (editor, signals[REQUEST_RESOURCE], 0, uri, cancellable);
+       g_signal_emit (editor, signals[REF_MIME_PART], 0, uri, &mime_part);
+
+       return mime_part;
 }
diff --git a/src/e-util/e-content-editor.h b/src/e-util/e-content-editor.h
index ecc305168a..245f2d58fc 100644
--- a/src/e-util/e-content-editor.h
+++ b/src/e-util/e-content-editor.h
@@ -82,10 +82,6 @@ struct _EContentEditorInterface {
        void            (*insert_image)                 (EContentEditor *editor,
                                                         const gchar *uri);
 
-       void            (*insert_image_from_mime_part)
-                                                       (EContentEditor *editor,
-                                                        CamelMimePart *part);
-
        void            (*insert_emoticon)              (EContentEditor *editor,
                                                         EEmoticon *emoticon);
 
@@ -409,13 +405,6 @@ struct _EContentEditorInterface {
        gchar *         (*spell_check_prev_word)        (EContentEditor *editor,
                                                         const gchar *word);
 
-       void            (*resource_loaded)              (EContentEditor *editor,
-                                                        const gchar *uri,
-                                                        GInputStream *stream,
-                                                        gint64 stream_length,
-                                                        const gchar *mime_type,
-                                                        const GError *error);
-
        /* Signals */
        void            (*load_finished)                (EContentEditor *editor);
        gboolean        (*paste_clipboard)              (EContentEditor *editor);
@@ -430,9 +419,8 @@ struct _EContentEditorInterface {
                                                         guint replaced_count);
        void            (*drop_handled)                 (EContentEditor *editor);
        void            (*content_changed)              (EContentEditor *editor);
-       void            (*request_resource)             (EContentEditor *editor,
-                                                        const gchar *uri,
-                                                        GCancellable *cancellable);
+       CamelMimePart * (*ref_mime_part)                (EContentEditor *editor,
+                                                        const gchar *uri);
 };
 
 /* Properties */
@@ -576,10 +564,6 @@ CamelMimePart *    e_content_editor_util_create_data_mimepart
                                                 const gchar *prefer_mime_type,
                                                 GCancellable *cancellable);
 
-void            e_content_editor_insert_image_from_mime_part
-                                               (EContentEditor *editor,
-                                                CamelMimePart *part);
-
 void           e_content_editor_insert_image   (EContentEditor *editor,
                                                 const gchar *uri);
 
@@ -992,13 +976,6 @@ void               e_content_editor_spell_check_replace_all
                                                 const gchar *word,
                                                 const gchar *replacement);
 
-void           e_content_editor_resource_loaded(EContentEditor *editor,
-                                                const gchar *uri,
-                                                GInputStream *stream,
-                                                gint64 stream_length,
-                                                const gchar *mime_type,
-                                                const GError *error);
-
 /* Signal helpers */
 
 void           e_content_editor_emit_load_finished
@@ -1021,10 +998,9 @@ void              e_content_editor_emit_drop_handled
                                                (EContentEditor *editor);
 void           e_content_editor_emit_content_changed
                                                (EContentEditor *editor);
-void           e_content_editor_emit_request_resource
+CamelMimePart *        e_content_editor_emit_ref_mime_part
                                                (EContentEditor *editor,
-                                                const gchar *uri,
-                                                GCancellable *cancellable);
+                                                const gchar *uri);
 
 G_END_DECLS
 
diff --git a/src/e-util/e-html-editor-private.h b/src/e-util/e-html-editor-private.h
index 00020f9e54..695ce0a72b 100644
--- a/src/e-util/e-html-editor-private.h
+++ b/src/e-util/e-html-editor-private.h
@@ -87,6 +87,7 @@ struct _EHTMLEditorPrivate {
 
        GtkWidget *emoji_chooser;
 
+       GHashTable *cid_parts; /* gchar *cid: URI ~> CamelMimePart * */
        GHashTable *content_editors;
        EContentEditor *use_content_editor;
 
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index 7de3acb899..66c298b7f3 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -962,6 +962,7 @@ html_editor_finalize (GObject *object)
 {
        EHTMLEditor *editor = E_HTML_EDITOR (object);
 
+       g_hash_table_destroy (editor->priv->cid_parts);
        g_hash_table_destroy (editor->priv->content_editors);
 
        /* Chain up to parent's method. */
@@ -1058,6 +1059,7 @@ e_html_editor_init (EHTMLEditor *editor)
        priv->language_actions = gtk_action_group_new ("language");
        priv->spell_check_actions = gtk_action_group_new ("spell-check");
        priv->suggestion_actions = gtk_action_group_new ("suggestion");
+       priv->cid_parts = g_hash_table_new_full (camel_strcase_hash, camel_strcase_equal, g_free, 
g_object_unref);
        priv->content_editors = g_hash_table_new_full (camel_strcase_hash, camel_strcase_equal, g_free, NULL);
 
        filename = html_editor_find_ui_file ("e-html-editor-manager.ui");
@@ -1205,8 +1207,12 @@ e_html_editor_get_content_editor (EHTMLEditor *editor)
                        }
                }
 
-               if (editor->priv->use_content_editor)
+               if (editor->priv->use_content_editor) {
                        e_content_editor_setup_editor (editor->priv->use_content_editor, editor);
+
+                       g_signal_connect_swapped (editor->priv->use_content_editor, "ref-mime-part",
+                               G_CALLBACK (e_html_editor_ref_cid_part), editor);
+               }
        }
 
        return editor->priv->use_content_editor;
@@ -1615,3 +1621,107 @@ e_html_editor_save_finish (EHTMLEditor *editor,
 
        return !e_simple_async_result_propagate_error (E_SIMPLE_ASYNC_RESULT (result), error);
 }
+
+/**
+ * e_html_editor_add_cid_part:
+ * @editor: an #EHTMLEditor
+ * @mime_part: a #CamelMimePart
+ *
+ * Add the @mime_part with its Content-ID (if not set, one is assigned),
+ * which can be later obtained with e_html_editor_ref_cid_part();
+ *
+ * Since: 3.36
+ **/
+void
+e_html_editor_add_cid_part (EHTMLEditor *editor,
+                           CamelMimePart *mime_part)
+{
+       const gchar *cid;
+       gchar *cid_uri;
+
+       g_return_if_fail (E_IS_HTML_EDITOR (editor));
+       g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
+
+       cid = camel_mime_part_get_content_id (mime_part);
+
+       if (!cid) {
+               camel_mime_part_set_content_id (mime_part, NULL);
+               cid = camel_mime_part_get_content_id (mime_part);
+       }
+
+       cid_uri = g_strconcat ("cid:", cid, NULL);
+
+       g_hash_table_insert (editor->priv->cid_parts, cid_uri, g_object_ref (mime_part));
+}
+
+/**
+ * e_html_editor_remove_cid_part:
+ * @editor: an #EHTMLEditor
+ * @cid_uri: a Content ID URI (starts with "cid:") to remove
+ *
+ * Removes CID part with given @cid_uri, previously added with
+ * e_html_editor_add_cid_part(). The function does nothing if no
+ * such part is stored.
+ *
+ * Since: 3.36
+ **/
+void
+e_html_editor_remove_cid_part (EHTMLEditor *editor,
+                              const gchar *cid_uri)
+{
+       g_return_if_fail (E_IS_HTML_EDITOR (editor));
+       g_return_if_fail (cid_uri != NULL);
+
+       g_hash_table_remove (editor->priv->cid_parts, cid_uri);
+}
+
+/**
+ * e_html_editor_remove_all_cid_parts:
+ * @editor: an #EHTMLEditor
+ *
+ * Removes all CID parts previously added with
+ * e_html_editor_add_cid_part().
+ *
+ * Since: 3.36
+ **/
+void
+e_html_editor_remove_all_cid_parts (EHTMLEditor *editor)
+{
+       g_return_if_fail (E_IS_HTML_EDITOR (editor));
+
+       g_hash_table_remove_all (editor->priv->cid_parts);
+}
+
+/**
+ * e_html_editor_ref_cid_part:
+ * @editor: an #EHTMLEditor
+ * @cid_uri: a Content ID URI (starts with "cid:") to obtain the part for
+ *
+ * References a #CamelMimePart with given @cid_uri as Content ID, if
+ * previously added with e_html_editor_add_cid_part(). The @cid_uri
+ * should start with "cid:".
+ *
+ * The returned non-%NULL object is references, thus it should be freed
+ * with g_object_unref(), when no longer needed.
+ *
+ * Returns: (transfer full) (nullable): a #CamelMimePart with given Content ID,
+ *    or %NULL, if not found.
+ *
+ * Since: 3.36
+ **/
+CamelMimePart *
+e_html_editor_ref_cid_part (EHTMLEditor *editor,
+                          const gchar *cid_uri)
+{
+       CamelMimePart *mime_part;
+
+       g_return_val_if_fail (E_IS_HTML_EDITOR (editor), NULL);
+       g_return_val_if_fail (cid_uri != NULL, NULL);
+
+       mime_part = g_hash_table_lookup (editor->priv->cid_parts, cid_uri);
+
+       if (mime_part)
+               g_object_ref (mime_part);
+
+       return mime_part;
+}
diff --git a/src/e-util/e-html-editor.h b/src/e-util/e-html-editor.h
index db0d9270af..ed3e078b66 100644
--- a/src/e-util/e-html-editor.h
+++ b/src/e-util/e-html-editor.h
@@ -105,12 +105,6 @@ void               e_html_editor_pack_above        (EHTMLEditor *editor,
                                                 GtkWidget *child);
 void           e_html_editor_update_spell_actions
                                                (EHTMLEditor *editor);
-
-
-/*****************************************************************************
- * High-Level Editing Interface
- *****************************************************************************/
-
 void           e_html_editor_save              (EHTMLEditor *editor,
                                                 const gchar *filename,
                                                 gboolean as_html,
@@ -120,6 +114,14 @@ void               e_html_editor_save              (EHTMLEditor *editor,
 gboolean       e_html_editor_save_finish       (EHTMLEditor *editor,
                                                 GAsyncResult *result,
                                                 GError **error);
+void           e_html_editor_add_cid_part      (EHTMLEditor *editor,
+                                                CamelMimePart *mime_part);
+void           e_html_editor_remove_cid_part   (EHTMLEditor *editor,
+                                                const gchar *cid_uri);
+void           e_html_editor_remove_all_cid_parts
+                                               (EHTMLEditor *editor);
+CamelMimePart * e_html_editor_ref_cid_part     (EHTMLEditor *editor,
+                                                const gchar *cid_uri);
 
 G_END_DECLS
 
diff --git a/src/mail/e-cid-request.c b/src/mail/e-cid-request.c
index 16d58ec73f..ef12b682a1 100644
--- a/src/mail/e-cid-request.c
+++ b/src/mail/e-cid-request.c
@@ -19,9 +19,49 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "e-mail-display.h"
 #include "e-cid-request.h"
 
+G_DEFINE_INTERFACE (ECidResolver, e_cid_resolver, G_TYPE_OBJECT)
+
+static void
+e_cid_resolver_default_init (ECidResolverInterface *iface)
+{
+}
+
+CamelMimePart *
+e_cid_resolver_ref_part (ECidResolver *resolver,
+                        const gchar *uri)
+{
+       ECidResolverInterface *iface;
+
+       g_return_val_if_fail (E_IS_CID_RESOLVER (resolver), NULL);
+       g_return_val_if_fail (uri != NULL, NULL);
+
+       iface = E_CID_RESOLVER_GET_INTERFACE (resolver);
+       g_return_val_if_fail (iface != NULL, NULL);
+       g_return_val_if_fail (iface->ref_part != NULL, NULL);
+
+       return iface->ref_part (resolver, uri);
+}
+
+gchar *
+e_cid_resolver_dup_mime_type (ECidResolver *resolver,
+                             const gchar *uri)
+{
+       ECidResolverInterface *iface;
+
+       g_return_val_if_fail (E_IS_CID_RESOLVER (resolver), NULL);
+       g_return_val_if_fail (uri != NULL, NULL);
+
+       iface = E_CID_RESOLVER_GET_INTERFACE (resolver);
+       g_return_val_if_fail (iface != NULL, NULL);
+
+       if (iface->dup_mime_type)
+               return iface->dup_mime_type (resolver, uri);
+
+       return NULL;
+}
+
 struct _ECidRequestPrivate {
        gint dummy;
 };
@@ -51,9 +91,6 @@ e_cid_request_process_sync (EContentRequest *request,
                            GCancellable *cancellable,
                            GError **error)
 {
-       EMailDisplay *display;
-       EMailPartList *part_list;
-       EMailPart *part;
        GByteArray *byte_array;
        CamelStream *output_stream;
        CamelDataWrapper *dw;
@@ -66,20 +103,13 @@ e_cid_request_process_sync (EContentRequest *request,
        if (g_cancellable_set_error_if_cancelled (cancellable, error))
                return FALSE;
 
-       if (!E_IS_MAIL_DISPLAY (requester))
+       if (!E_IS_CID_RESOLVER (requester))
                return FALSE;
 
-       display = E_MAIL_DISPLAY (requester);
-
-       part_list = e_mail_display_get_part_list (display);
-       if (!part_list)
+       mime_part = e_cid_resolver_ref_part (E_CID_RESOLVER (requester), uri);
+       if (!mime_part)
                return FALSE;
 
-       part = e_mail_part_list_ref_part (part_list, uri);
-       if (!part)
-               return FALSE;
-
-       mime_part = e_mail_part_ref_mime_part (part);
        dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
        g_return_val_if_fail (dw != NULL, FALSE);
@@ -102,11 +132,14 @@ e_cid_request_process_sync (EContentRequest *request,
                *out_stream_length = g_bytes_get_size (bytes);
 
                mime_type = camel_data_wrapper_get_mime_type (dw);
-               if (mime_type && *mime_type)
+               if (mime_type && *mime_type) {
                        *out_mime_type = mime_type;
-               else {
+               } else {
                        g_free (mime_type);
-                       *out_mime_type = g_strdup (e_mail_part_get_mime_type (part));
+                       *out_mime_type = e_cid_resolver_dup_mime_type (E_CID_RESOLVER (requester), uri);
+
+                       if (!*out_mime_type)
+                               *out_mime_type = g_strdup ("application/octet-stream");
                }
 
                g_bytes_unref (bytes);
@@ -116,7 +149,6 @@ e_cid_request_process_sync (EContentRequest *request,
 
        g_object_unref (output_stream);
        g_object_unref (mime_part);
-       g_object_unref (part);
 
        return success;
 }
diff --git a/src/mail/e-cid-request.h b/src/mail/e-cid-request.h
index 0ed6e4b242..15b12c7066 100644
--- a/src/mail/e-cid-request.h
+++ b/src/mail/e-cid-request.h
@@ -20,6 +20,24 @@
 #include <e-util/e-util.h>
 
 /* Standard GObject macros */
+#define E_TYPE_CID_RESOLVER \
+       (e_cid_resolver_get_type ())
+#define E_CID_RESOLVER(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), E_TYPE_CID_RESOLVER, ECidResolver))
+#define E_CID_RESOLVER_INTERFACE(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), E_TYPE_CID_RESOLVER, ECidResolverInterface))
+#define E_IS_CID_RESOLVER(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), E_TYPE_CID_RESOLVER))
+#define E_IS_CID_RESOLVER_INTERFACE(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), E_TYPE_CID_RESOLVER))
+#define E_CID_RESOLVER_GET_INTERFACE(obj) \
+       (G_TYPE_INSTANCE_GET_INTERFACE \
+       ((obj), E_TYPE_CID_RESOLVER, ECidResolverInterface))
+
 #define E_TYPE_CID_REQUEST \
        (e_cid_request_get_type ())
 #define E_CID_REQUEST(obj) \
@@ -40,6 +58,25 @@
 
 G_BEGIN_DECLS
 
+typedef struct _ECidResolver ECidResolver;
+typedef struct _ECidResolverInterface ECidResolverInterface;
+
+struct _ECidResolverInterface {
+       GTypeInterface parent_interface;
+
+       CamelMimePart * (* ref_part)            (ECidResolver *resolver,
+                                                const gchar *uri);
+
+       gchar *         (* dup_mime_type)       (ECidResolver *resolver,
+                                                const gchar *uri);
+};
+
+GType          e_cid_resolver_get_type         (void);
+CamelMimePart *        e_cid_resolver_ref_part         (ECidResolver *resolver,
+                                                const gchar *uri);
+gchar *                e_cid_resolver_dup_mime_type    (ECidResolver *resolver,
+                                                const gchar *uri);
+
 typedef struct _ECidRequest ECidRequest;
 typedef struct _ECidRequestClass ECidRequestClass;
 typedef struct _ECidRequestPrivate ECidRequestPrivate;
diff --git a/src/mail/e-mail-display.c b/src/mail/e-mail-display.c
index 95c7b6e21b..b12bd81020 100644
--- a/src/mail/e-mail-display.c
+++ b/src/mail/e-mail-display.c
@@ -111,7 +111,10 @@ enum {
 static guint signals[LAST_SIGNAL];
 static CamelDataCache *emd_global_http_cache = NULL;
 
-G_DEFINE_TYPE (EMailDisplay, e_mail_display, E_TYPE_WEB_VIEW)
+static void e_mail_display_cid_resolver_init (ECidResolverInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (EMailDisplay, e_mail_display, E_TYPE_WEB_VIEW,
+       G_IMPLEMENT_INTERFACE (E_TYPE_CID_RESOLVER, e_mail_display_cid_resolver_init))
 
 static const gchar *ui =
 "<ui>"
@@ -1969,6 +1972,71 @@ mail_display_web_process_crashed_cb (EMailDisplay *display)
                e_alert_submit (alert_sink, "mail:webkit-web-process-crashed", NULL);
 }
 
+static EMailPart *
+e_mail_display_ref_mail_part (EMailDisplay *mail_display,
+                             const gchar *uri)
+{
+       EMailPartList *part_list;
+
+       g_return_val_if_fail (E_IS_MAIL_DISPLAY (mail_display), NULL);
+       g_return_val_if_fail (uri != NULL, NULL);
+
+       part_list = e_mail_display_get_part_list (mail_display);
+       if (!part_list)
+               return NULL;
+
+       return e_mail_part_list_ref_part (part_list, uri);
+}
+
+static CamelMimePart *
+e_mail_display_cid_resolver_ref_part (ECidResolver *resolver,
+                                     const gchar *uri)
+{
+       EMailPart *mail_part;
+       CamelMimePart *mime_part;
+
+       g_return_val_if_fail (E_IS_MAIL_DISPLAY (resolver), NULL);
+       g_return_val_if_fail (uri != NULL, NULL);
+
+       mail_part = e_mail_display_ref_mail_part (E_MAIL_DISPLAY (resolver), uri);
+       if (!mail_part)
+               return NULL;
+
+       mime_part = e_mail_part_ref_mime_part (mail_part);
+
+       g_object_unref (mail_part);
+
+       return mime_part;
+}
+
+static gchar *
+e_mail_display_cid_resolver_dup_mime_type (ECidResolver *resolver,
+                                          const gchar *uri)
+{
+       EMailPart *mail_part;
+       gchar *mime_type;
+
+       g_return_val_if_fail (E_IS_MAIL_DISPLAY (resolver), NULL);
+       g_return_val_if_fail (uri != NULL, NULL);
+
+       mail_part = e_mail_display_ref_mail_part (E_MAIL_DISPLAY (resolver), uri);
+       if (!mail_part)
+               return NULL;
+
+       mime_type = g_strdup (e_mail_part_get_mime_type (mail_part));
+
+       g_object_unref (mail_part);
+
+       return mime_type;
+}
+
+static void
+e_mail_display_cid_resolver_init (ECidResolverInterface *iface)
+{
+       iface->ref_part = e_mail_display_cid_resolver_ref_part;
+       iface->dup_mime_type = e_mail_display_cid_resolver_dup_mime_type;
+}
+
 static void
 e_mail_display_class_init (EMailDisplayClass *class)
 {
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index 28aaefec86..648cd96a49 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -150,13 +150,11 @@ static void
 e_mail_notes_editor_extract_text_from_multipart_related (EMailNotesEditor *notes_editor,
                                                         CamelMultipart *multipart)
 {
-       EContentEditor *cnt_editor;
        guint ii, nparts;
 
        g_return_if_fail (E_IS_MAIL_NOTES_EDITOR (notes_editor));
        g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
 
-       cnt_editor = e_html_editor_get_content_editor (notes_editor->editor);
        nparts = camel_multipart_get_number (multipart);
 
        for (ii = 0; ii < nparts; ii++) {
@@ -173,11 +171,14 @@ e_mail_notes_editor_extract_text_from_multipart_related (EMailNotesEditor *notes
                        continue;
 
                if (camel_content_type_is (ct, "image", "*")) {
-                       e_content_editor_insert_image_from_mime_part (cnt_editor, part);
+                       e_html_editor_add_cid_part (notes_editor->editor, part);
                } else if (camel_content_type_is (ct, "multipart", "alternative")) {
                        content = camel_medium_get_content (CAMEL_MEDIUM (part));
-                       if (CAMEL_IS_MULTIPART (content))
-                               e_mail_notes_extract_text_from_multipart_alternative (cnt_editor, 
CAMEL_MULTIPART (content));
+
+                       if (CAMEL_IS_MULTIPART (content)) {
+                               e_mail_notes_extract_text_from_multipart_alternative (
+                                       e_html_editor_get_content_editor (notes_editor->editor), 
CAMEL_MULTIPART (content));
+                       }
                }
        }
 }
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 79af858b8d..69f52f0f9c 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -20,6 +20,7 @@
 
 #include "e-util/e-util.h"
 #include "composer/e-msg-composer.h"
+#include "mail/e-cid-request.h"
 #include "mail/e-http-request.h"
 
 #include <string.h>
@@ -76,8 +77,6 @@ struct _EWebKitEditorPrivate {
        gpointer initialized_user_data;
 
        GCancellable *cancellable;
-       EWebExtensionContainer *container;
-       GDBusProxy *web_extension_proxy;
 
        gboolean html_mode;
        gboolean changed;
@@ -184,14 +183,11 @@ typedef struct {
 } PostReloadOperation;
 
 static void e_webkit_editor_content_editor_init (EContentEditorInterface *iface);
+static void e_webkit_editor_cid_resolver_init (ECidResolverInterface *iface);
 
-G_DEFINE_TYPE_WITH_CODE (
-       EWebKitEditor,
-       e_webkit_editor,
-       WEBKIT_TYPE_WEB_VIEW,
-       G_IMPLEMENT_INTERFACE (
-               E_TYPE_CONTENT_EDITOR,
-               e_webkit_editor_content_editor_init));
+G_DEFINE_TYPE_WITH_CODE (EWebKitEditor, e_webkit_editor, WEBKIT_TYPE_WEB_VIEW,
+       G_IMPLEMENT_INTERFACE (E_TYPE_CONTENT_EDITOR, e_webkit_editor_content_editor_init)
+       G_IMPLEMENT_INTERFACE (E_TYPE_CID_RESOLVER, e_webkit_editor_cid_resolver_init));
 
 typedef struct _EWebKitEditorFlagClass {
        GObjectClass parent_class;
@@ -1156,25 +1152,6 @@ dispatch_pending_operations (EWebKitEditor *wk_editor)
        }
 }
 
-static guint64
-current_page_id (EWebKitEditor *wk_editor)
-{
-       return webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (wk_editor));
-}
-
-static void
-webkit_editor_call_simple_extension_function (EWebKitEditor *wk_editor,
-                                              const gchar *method_name)
-{
-       /*guint64 page_id;
-
-       page_id = current_page_id (wk_editor);
-
-       e_web_extension_container_call_simple (wk_editor->priv->container, page_id, wk_editor->priv->stamp,
-               method_name, g_variant_new ("(t)", page_id));*/
-       printf ("%s: '%s'\n", __FUNCTION__, method_name);
-}
-
 static void
 webkit_editor_queue_post_reload_operation (EWebKitEditor *wk_editor,
                                            PostReloadOperationFunc func,
@@ -1215,21 +1192,10 @@ webkit_editor_initialize (EContentEditor *content_editor,
                           EContentEditorInitializedCallback callback,
                           gpointer user_data)
 {
-       EWebKitEditor *wk_editor;
-
        g_return_if_fail (E_IS_WEBKIT_EDITOR (content_editor));
        g_return_if_fail (callback != NULL);
 
-       wk_editor = E_WEBKIT_EDITOR (content_editor);
-
-       if (wk_editor->priv->web_extension_proxy) {
-               callback (content_editor, user_data);
-       } else {
-               g_return_if_fail (wk_editor->priv->initialized_callback == NULL);
-
-               wk_editor->priv->initialized_callback = callback;
-               wk_editor->priv->initialized_user_data = user_data;
-       }
+       callback (content_editor, user_data);
 }
 
 static void
@@ -2071,38 +2037,11 @@ webkit_editor_insert_content (EContentEditor *editor,
                return;
        }
 
-       if (!wk_editor->priv->web_extension_proxy) {
-               /* If the operation needs a web extension and it is not ready yet
-                * we need to schedule the current operation again a dispatch it
-                * when the extension is ready */
-               if (!((flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) &&
-                     (flags & E_CONTENT_EDITOR_INSERT_TEXT_HTML) &&
-                     (strstr (content, "data-evo-draft") ||
-                      strstr (content, "data-evo-signature-plain-text-mode")))) {
-                       webkit_editor_queue_post_reload_operation (
-                               wk_editor,
-                               (PostReloadOperationFunc) webkit_editor_insert_content,
-                               g_strdup (content),
-                               g_free,
-                               flags);
-                       return;
-               }
-       }
-
        if ((flags & E_CONTENT_EDITOR_INSERT_CONVERT) &&
            !(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL)) {
-               /* e_html_editor_view_convert_and_insert_plain_text
-                  e_html_editor_view_convert_and_insert_html_to_plain_text
-                  e_html_editor_view_insert_text */
-               e_util_invoke_g_dbus_proxy_call_with_error_check (
-                       wk_editor->priv->web_extension_proxy,
-                       "DOMConvertAndInsertHTMLIntoSelection",
-                       g_variant_new (
-                               "(tsb)",
-                               current_page_id (wk_editor),
-                               content,
-                               (flags & E_CONTENT_EDITOR_INSERT_TEXT_HTML)),
-                       wk_editor->priv->cancellable);
+               e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+                       "EvoEditor.PasteText(%s, %x, %x);",
+                       content, (flags & E_CONTENT_EDITOR_INSERT_TEXT_HTML) != 0, FALSE);
        } else if ((flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) &&
                   (flags & E_CONTENT_EDITOR_INSERT_TEXT_HTML)) {
                if ((strstr (content, "data-evo-draft") ||
@@ -2112,12 +2051,6 @@ webkit_editor_insert_content (EContentEditor *editor,
                        return;
                }
 
-               if (strstr (content, "data-evo-draft") && !(wk_editor->priv->html_mode)) {
-                       wk_editor->priv->reload_in_progress = TRUE;
-                       e_webkit_editor_load_data (wk_editor, content);
-                       return;
-               }
-
                /* Only convert messages that are in HTML */
                if (!(wk_editor->priv->html_mode)) {
                        if (strstr (content, "<!-- text/html -->") &&
@@ -2135,43 +2068,30 @@ webkit_editor_insert_content (EContentEditor *editor,
                e_webkit_editor_load_data (wk_editor, content);
        } else if ((flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) &&
                   (flags & E_CONTENT_EDITOR_INSERT_TEXT_PLAIN)) {
-               e_util_invoke_g_dbus_proxy_call_with_error_check (
-                       wk_editor->priv->web_extension_proxy,
-                       "DOMConvertContent",
-                       g_variant_new ("(tsnn)", current_page_id (wk_editor), content,
-                               e_webkit_editor_three_state_to_bool (e_content_editor_get_start_bottom 
(editor), "composer-reply-start-bottom"),
-                               e_webkit_editor_three_state_to_bool (e_content_editor_get_top_signature 
(editor), "composer-top-signature")),
-                       wk_editor->priv->cancellable);
+               e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+                       "EvoEditor.ConvertContent(%s, %x, %x);",
+                       content,
+                       e_webkit_editor_three_state_to_bool (e_content_editor_get_start_bottom (editor), 
"composer-reply-start-bottom"),
+                       e_webkit_editor_three_state_to_bool (e_content_editor_get_top_signature (editor), 
"composer-top-signature"));
        } else if ((flags & E_CONTENT_EDITOR_INSERT_CONVERT) &&
-                   !(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) &&
-                   !(flags & E_CONTENT_EDITOR_INSERT_QUOTE_CONTENT)) {
-               /* e_html_editor_view_paste_as_text */
-               e_util_invoke_g_dbus_proxy_call_with_error_check (
-                       wk_editor->priv->web_extension_proxy,
-                       "DOMConvertAndInsertHTMLIntoSelection",
-                       g_variant_new (
-                               "(tsb)", current_page_id (wk_editor), content, TRUE),
-                       wk_editor->priv->cancellable);
+                 !(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) &&
+                 !(flags & E_CONTENT_EDITOR_INSERT_QUOTE_CONTENT)) {
+               e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+                       "EvoEditor.PasteText(%s, %x, %x);",
+                       content, TRUE, FALSE);
        } else if ((flags & E_CONTENT_EDITOR_INSERT_QUOTE_CONTENT) &&
                   !(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL)) {
-               /* e_html_editor_view_paste_clipboard_quoted */
-               e_util_invoke_g_dbus_proxy_call_with_error_check (
-                       wk_editor->priv->web_extension_proxy,
-                       "DOMQuoteAndInsertTextIntoSelection",
-                       g_variant_new (
-                               "(tsb)", current_page_id (wk_editor), content, (flags & 
E_CONTENT_EDITOR_INSERT_TEXT_HTML) != 0),
-                       wk_editor->priv->cancellable);
+               e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+                       "EvoEditor.PasteText(%s, %x, %x);",
+                       content, (flags & E_CONTENT_EDITOR_INSERT_TEXT_HTML) != 0, TRUE);
        } else if (!(flags & E_CONTENT_EDITOR_INSERT_CONVERT) &&
                   !(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL)) {
-               /* e_html_editor_view_insert_html */
-               e_util_invoke_g_dbus_proxy_call_with_error_check (
-                       wk_editor->priv->web_extension_proxy,
-                       "DOMInsertHTML",
-                       g_variant_new (
-                               "(ts)", current_page_id (wk_editor), content),
-                       wk_editor->priv->cancellable);
-       } else
-               g_warning ("Unsupported flags combination (%d) in (%s)", flags, G_STRFUNC);
+               e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+                       "EvoEditor.InsertHTML(%s, %s);",
+                       "InsertHTML", content);
+       } else {
+               g_warning ("%s: Unsupported flags combination (0x%x)", G_STRFUNC, flags);
+       }
 }
 
 static void
@@ -2286,10 +2206,15 @@ webkit_editor_get_content_finish (EContentEditor *editor,
                                                        cid = e_web_view_jsc_get_object_property_string 
(item_value, "cid", NULL);
 
                                                        if (src && *src && cid && *cid) {
-                                                               CamelMimePart *part;
+                                                               CamelMimePart *part = NULL;
 
-                                                               part = 
e_content_editor_util_create_data_mimepart (src, cid, TRUE, NULL, NULL,
-                                                                       E_WEBKIT_EDITOR 
(editor)->priv->cancellable);
+                                                               if (g_ascii_strncasecmp (src, "cid:", 4) == 0)
+                                                                       part = 
e_content_editor_emit_ref_mime_part (editor, src);
+
+                                                               if (!part) {
+                                                                       part = 
e_content_editor_util_create_data_mimepart (src, cid, TRUE, NULL, NULL,
+                                                                               E_WEBKIT_EDITOR 
(editor)->priv->cancellable);
+                                                               }
 
                                                                if (part)
                                                                        image_parts = g_slist_prepend 
(image_parts, part);
@@ -2416,64 +2341,6 @@ webkit_editor_insert_emoticon (EContentEditor *editor,
        g_free (image_uri);
 }
 
-static void
-webkit_editor_insert_image_from_mime_part (EContentEditor *editor,
-                                           CamelMimePart *part)
-{
-       CamelDataWrapper *dw;
-       CamelStream *stream;
-       EWebKitEditor *wk_editor;
-       GByteArray *byte_array;
-       gchar *src, *base64_encoded, *mime_type, *cid_uri;
-       const gchar *cid, *name;
-
-       wk_editor = E_WEBKIT_EDITOR (editor);
-       if (!wk_editor->priv->web_extension_proxy) {
-               printf ("EHTMLEditorWebExtension not ready at %s!\n", G_STRFUNC);
-               return;
-       }
-
-       dw = camel_medium_get_content (CAMEL_MEDIUM (part));
-       g_return_if_fail (dw);
-
-       stream = camel_stream_mem_new ();
-       camel_data_wrapper_decode_to_stream_sync (dw, stream, NULL, NULL);
-       camel_stream_close (stream, NULL, NULL);
-
-       byte_array = camel_stream_mem_get_byte_array (CAMEL_STREAM_MEM (stream));
-
-       if (!byte_array->data) {
-               g_object_unref (stream);
-               return;
-       }
-
-       base64_encoded = g_base64_encode ((const guchar *) byte_array->data, byte_array->len);
-
-       mime_type = camel_data_wrapper_get_mime_type (dw);
-       name = camel_mime_part_get_filename (part);
-       /* Insert file name before new src */
-       src = g_strconcat (name ? name : "", name ? ";data:" : "", mime_type, ";base64,", base64_encoded, 
NULL);
-
-       cid = camel_mime_part_get_content_id (part);
-       if (!cid) {
-               camel_mime_part_set_content_id (part, NULL);
-               cid = camel_mime_part_get_content_id (part);
-       }
-       cid_uri = g_strdup_printf ("cid:%s", cid);
-
-       e_util_invoke_g_dbus_proxy_call_with_error_check (
-               wk_editor->priv->web_extension_proxy,
-               "DOMAddNewInlineImageIntoList",
-               g_variant_new ("(tsss)", current_page_id (wk_editor), name ? name : "", cid_uri, src),
-               wk_editor->priv->cancellable);
-
-       g_free (base64_encoded);
-       g_free (mime_type);
-       g_free (cid_uri);
-       g_free (src);
-       g_object_unref (stream);
-}
-
 static void
 webkit_editor_select_all (EContentEditor *editor)
 {
@@ -2488,11 +2355,15 @@ webkit_editor_select_all (EContentEditor *editor)
 static void
 webkit_editor_selection_wrap (EContentEditor *editor)
 {
-       EWebKitEditor *wk_editor;
+       /*EWebKitEditor *wk_editor;
+       guint64 page_id;
 
        wk_editor = E_WEBKIT_EDITOR (editor);
 
-       webkit_editor_call_simple_extension_function (wk_editor, "DOMSelectionWrap");
+       page_id = current_page_id (wk_editor);          
+
+       e_web_extension_container_call_simple (wk_editor->priv->web_extension_proxy, page_id, 
wk_editor->priv->stamp,
+               "DOMSelectionWrap", g_variant_new ("(t)", page_id));*/
 }
 
 static gboolean
@@ -4162,10 +4033,8 @@ webkit_editor_constructed (GObject *object)
        webkit_web_context_set_spell_checking_languages (web_context, (const gchar * const *) languages);
        g_strfreev (languages);
 
-       content_request = e_http_request_new ();
-       webkit_web_context_register_uri_scheme (web_context, "evo-http", webkit_editor_process_uri_request_cb,
-               g_object_ref (content_request), g_object_unref);
-       webkit_web_context_register_uri_scheme (web_context, "evo-https", 
webkit_editor_process_uri_request_cb,
+       content_request = e_cid_request_new ();
+       webkit_web_context_register_uri_scheme (web_context, "cid", webkit_editor_process_uri_request_cb,
                g_object_ref (content_request), g_object_unref);
        g_object_unref (content_request);
 
@@ -4174,6 +4043,13 @@ webkit_editor_constructed (GObject *object)
                g_object_ref (content_request), g_object_unref);
        g_object_unref (content_request);
 
+       content_request = e_http_request_new ();
+       webkit_web_context_register_uri_scheme (web_context, "evo-http", webkit_editor_process_uri_request_cb,
+               g_object_ref (content_request), g_object_unref);
+       webkit_web_context_register_uri_scheme (web_context, "evo-https", 
webkit_editor_process_uri_request_cb,
+               g_object_ref (content_request), g_object_unref);
+       g_object_unref (content_request);
+
        webkit_web_view_set_editable (web_view, TRUE);
 
        web_settings = webkit_web_view_get_settings (web_view);
@@ -5213,6 +5089,15 @@ paste_primary_clipboard_quoted (EContentEditor *editor)
        }
 }
 
+static CamelMimePart *
+e_webkit_editor_cid_resolver_ref_part (ECidResolver *resolver,
+                                      const gchar *cid_uri)
+{
+       g_return_val_if_fail (E_IS_WEBKIT_EDITOR (resolver), NULL);
+
+       return e_content_editor_emit_ref_mime_part (E_CONTENT_EDITOR (resolver), cid_uri);
+}
+
 static gboolean
 webkit_editor_button_press_event (GtkWidget *widget,
                                   GdkEventButton *event)
@@ -5556,7 +5441,6 @@ e_webkit_editor_content_editor_init (EContentEditorInterface *iface)
        iface->get_content = webkit_editor_get_content;
        iface->get_content_finish = webkit_editor_get_content_finish;
        iface->insert_image = webkit_editor_insert_image;
-       iface->insert_image_from_mime_part = webkit_editor_insert_image_from_mime_part;
        iface->insert_emoticon = webkit_editor_insert_emoticon;
        iface->move_caret_on_coordinates = webkit_editor_move_caret_on_coordinates;
        iface->cut = webkit_editor_cut;
@@ -5675,3 +5559,10 @@ e_webkit_editor_content_editor_init (EContentEditorInterface *iface)
        iface->spell_check_next_word = webkit_editor_spell_check_next_word;
        iface->spell_check_prev_word = webkit_editor_spell_check_prev_word;
 }
+
+static void
+e_webkit_editor_cid_resolver_init (ECidResolverInterface *iface)
+{
+       iface->ref_part = e_webkit_editor_cid_resolver_ref_part;
+       /* iface->dup_mime_type = e_webkit_editor_cid_resolver_dup_mime_part; - not needed here */
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]