[Mail] Cached remote content not always found in cache
The URL being used to check whether the image is already locally cached and the URL which was used to actually download the remote content did not match, thus the file were not found in the local cache. While I've been in it I also noticed that the remote content is not shown in the composer, even when it's downloaded locally, thus I fixed that as well. Reported downstream at: https://bugzilla.redhat.com/show_bug.cgi?id=1435288
This commit is contained in:
@ -184,7 +184,7 @@ e_http_request_process_sync (EContentRequest *request,
|
||||
GError **error)
|
||||
{
|
||||
SoupURI *soup_uri;
|
||||
gchar *evo_uri, *use_uri;
|
||||
gchar *evo_uri = NULL, *use_uri;
|
||||
gchar *mail_uri = NULL;
|
||||
GInputStream *stream;
|
||||
gboolean force_load_images = FALSE;
|
||||
@ -219,6 +219,14 @@ e_http_request_process_sync (EContentRequest *request,
|
||||
|
||||
g_hash_table_remove (query, "__evo-mail");
|
||||
|
||||
/* Required, because soup_uri_set_query_from_form() can change
|
||||
order of arguments, then the URL checksum doesn't match. */
|
||||
evo_uri = g_hash_table_lookup (query, "__evo-original-uri");
|
||||
if (evo_uri)
|
||||
evo_uri = g_strdup (evo_uri);
|
||||
|
||||
g_hash_table_remove (query, "__evo-original-uri");
|
||||
|
||||
/* Remove __evo-load-images if present (and in such case set
|
||||
* force_load_images to TRUE) */
|
||||
force_load_images = g_hash_table_remove (query, "__evo-load-images");
|
||||
@ -227,7 +235,8 @@ e_http_request_process_sync (EContentRequest *request,
|
||||
g_hash_table_unref (query);
|
||||
}
|
||||
|
||||
evo_uri = soup_uri_to_string (soup_uri, FALSE);
|
||||
if (!evo_uri)
|
||||
evo_uri = soup_uri_to_string (soup_uri, FALSE);
|
||||
|
||||
if (camel_debug_start ("emformat:requests")) {
|
||||
printf (
|
||||
|
||||
@ -1739,6 +1739,10 @@ mail_display_uri_requested_cb (EWebView *web_view,
|
||||
enc = soup_uri_encode (mail_uri, NULL);
|
||||
g_hash_table_insert (query, g_strdup ("__evo-mail"), enc);
|
||||
|
||||
/* Required, because soup_uri_set_query_from_form() can change
|
||||
order of arguments, then the URL checksum doesn't match. */
|
||||
g_hash_table_insert (query, g_strdup ("__evo-original-uri"), g_strdup (uri));
|
||||
|
||||
if (display->priv->force_image_load || can_download_uri) {
|
||||
g_hash_table_insert (
|
||||
query,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
set(extra_deps
|
||||
evolution-mail
|
||||
evolution-mail-composer
|
||||
)
|
||||
set(sources
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
|
||||
#include "e-util/e-util.h"
|
||||
#include "composer/e-msg-composer.h"
|
||||
#include "mail/e-http-request.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -4988,10 +4989,59 @@ webkit_editor_get_web_extension (EWebKitEditor *wk_editor)
|
||||
return wk_editor->priv->web_extension;
|
||||
}
|
||||
|
||||
static void
|
||||
webkit_editor_uri_request_done_cb (GObject *source_object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
WebKitURISchemeRequest *request = user_data;
|
||||
GInputStream *stream = NULL;
|
||||
gint64 stream_length = -1;
|
||||
gchar *mime_type = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (E_IS_CONTENT_REQUEST (source_object));
|
||||
g_return_if_fail (WEBKIT_IS_URI_SCHEME_REQUEST (request));
|
||||
|
||||
if (!e_content_request_process_finish (E_CONTENT_REQUEST (source_object),
|
||||
result, &stream, &stream_length, &mime_type, &error)) {
|
||||
webkit_uri_scheme_request_finish_error (request, error);
|
||||
g_clear_error (&error);
|
||||
} else {
|
||||
webkit_uri_scheme_request_finish (request, stream, stream_length, mime_type);
|
||||
|
||||
g_clear_object (&stream);
|
||||
g_free (mime_type);
|
||||
}
|
||||
|
||||
g_object_unref (request);
|
||||
}
|
||||
|
||||
static void
|
||||
webkit_editor_process_uri_request_cb (WebKitURISchemeRequest *request,
|
||||
gpointer user_data)
|
||||
{
|
||||
EContentRequest *content_request = user_data;
|
||||
const gchar *uri;
|
||||
GObject *requester;
|
||||
|
||||
g_return_if_fail (WEBKIT_IS_URI_SCHEME_REQUEST (request));
|
||||
g_return_if_fail (E_IS_CONTENT_REQUEST (content_request));
|
||||
|
||||
uri = webkit_uri_scheme_request_get_uri (request);
|
||||
requester = G_OBJECT (webkit_uri_scheme_request_get_web_view (request));
|
||||
|
||||
g_return_if_fail (e_content_request_can_process_uri (content_request, uri));
|
||||
|
||||
e_content_request_process (content_request, uri, requester, NULL,
|
||||
webkit_editor_uri_request_done_cb, g_object_ref (request));
|
||||
}
|
||||
|
||||
static void
|
||||
webkit_editor_constructed (GObject *object)
|
||||
{
|
||||
EWebKitEditor *wk_editor;
|
||||
EContentRequest *content_request;
|
||||
gchar **languages;
|
||||
WebKitWebContext *web_context;
|
||||
WebKitSettings *web_settings;
|
||||
@ -5012,6 +5062,13 @@ 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,
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user