[balsa/drop-webkit1] Drop support for WebKit-1
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/drop-webkit1] Drop support for WebKit-1
- Date: Mon, 6 Aug 2018 14:39:14 +0000 (UTC)
commit 86eb7ce85c2c1e5ecc2370f0b143c424ee98d0a1
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Aug 6 10:37:16 2018 -0400
Drop support for WebKit-1
README | 7 +-
configure.ac | 25 +--
libbalsa/html.c | 602 ------------------------------------------------------
meson.build | 27 +--
meson_options.txt | 2 +-
5 files changed, 9 insertions(+), 654 deletions(-)
---
diff --git a/README b/README
index 701edd88e..e89a60f93 100644
--- a/README
+++ b/README
@@ -65,10 +65,9 @@ Note: requires GpgME version >= 1.5.0
This enables GSSAPI Kerberos based authentication scheme.
Specify the kerberos directory as the argument.
---with-html-widget=(no|gtkhtml4|webkit|webkit2)
- Choose preferred HTML renderer library. Note that webkit is
-not actively supported any more and thus not recommended.
-When using webkit or webkit2, in order to quote html-only messages
+--with-html-widget=(no|gtkhtml4|webkit2)
+ Choose preferred HTML renderer library.
+When using webkit2, in order to quote html-only messages
it is recommended to install a html-to-text conversion tool. Supported
tools are python-html2text, html2markdown, html2markdown.py2,
html2markdown.py3 and html2text.
diff --git a/configure.ac b/configure.ac
index 00947c67e..1b69e03ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,7 +82,7 @@ AC_ARG_WITH(gss,
[with_gss=$withval],[with_gss=no])
AC_ARG_WITH(html-widget,
- AC_HELP_STRING([--with-html-widget=(no|gtkhtml4|webkit|webkit2)],
+ AC_HELP_STRING([--with-html-widget=(no|gtkhtml4|webkit2)],
[select the HTML renderer (default webkit2)]),
[use_html_widget=$withval],
[use_html_widget=webkit2])
@@ -289,18 +289,9 @@ case "$use_html_widget" in
[AC_MSG_ERROR([*** You enabled gtkhtml4 but it was not found.])])])
AC_DEFINE(HAVE_GTKHTML4,1,[Defined when GtkHtml-4 can be used.])
;;
- webkit | webkit2)
+ webkit2)
AC_MSG_RESULT([$use_html_widget])
- if test $use_html_widget = webkit2 ; then
- PKG_CHECK_MODULES(HTML, [ webkit2gtk-4.0 ])
- AC_DEFINE(USE_WEBKIT2,1,[Defined when WebKit2 is requested.])
- else
- if $PKG_CONFIG --atleast-version=1.5.1 webkitgtk-3.0 ; then
- PKG_CHECK_MODULES(HTML, [webkitgtk-3.0 javascriptcoregtk-3.0])
- else
- PKG_CHECK_MODULES(HTML, [webkitgtk-3.0])
- fi
- fi
+ PKG_CHECK_MODULES(HTML, [ webkit2gtk-4.0 ])
AC_DEFINE(HAVE_WEBKIT,1,[Defined when WebKit can be used.])
AC_PATH_PROGS(HTML2TEXT,
[python-html2text \
@@ -760,13 +751,3 @@ if test x"$BALSA_FROM_GIT" = xyes ; then
echo "======================================================================"
echo ""
fi
-
-if test x"$use_html_widget" = xwebkit ; then
- AC_MSG_WARN([
-*** You have configured Balsa to use the old webkitgtk HTML widget.
-*** This widget is no longer being actively developed, and likely
-*** has security issues fixed in the newer webkit2 widget.
-*** Balsa will continue support for the old webkit widget only
-*** while needed by long-term-stable releases of major distributors.
- ])
-fi
diff --git a/libbalsa/html.c b/libbalsa/html.c
index 307194e0a..c4db0c462 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -140,12 +140,6 @@ html2text(gchar ** text, gsize len)
#endif
-# if defined(USE_WEBKIT2)
-
-/*
- * Experimental support for WebKit2.
- */
-
/* WebKitContextMenuItem uses GtkAction, which is deprecated.
* We don't use it, but it breaks the git-tree build, so we just mangle
* it: */
@@ -970,602 +964,6 @@ libbalsa_html_print(GtkWidget * widget)
}
}
-# else /* defined(USE_WEBKIT2) */
-#include <webkit/webkit.h>
-#include <JavaScriptCore/JavaScript.h>
-
-typedef struct {
- LibBalsaMessageBody *body;
- LibBalsaHtmlCallback hover_cb;
- LibBalsaHtmlCallback clicked_cb;
- WebKitWebFrame *frame;
- gboolean download_images;
- GtkWidget *vbox;
- gboolean has_info_bar;
- WebKitWebView *web_view;
-} LibBalsaWebKitInfo;
-
-/*
- * Callback for the "hovering-over-link" signal
- *
- * Pass the URI to the handler set by the caller
- */
-static void
-lbh_hovering_over_link_cb(GtkWidget * web_view,
- const gchar * title,
- const gchar * uri,
- gpointer data)
-{
- LibBalsaWebKitInfo *info = data;
-
- (*info->hover_cb)(uri);
-}
-
-/*
- * Callback for the "navigation-policy-decision-requested" signal
- *
- * If the reason is that the user clicked on a link, pass the URI to to
- * the handler set by the caller; slightly complicated by links that
- * are supposed to open in their own windows.
- */
-static gboolean
-lbh_navigation_policy_decision_requested_cb(WebKitWebView * web_view,
- WebKitWebFrame * frame,
- WebKitNetworkRequest * request,
- WebKitWebNavigationAction * action,
- WebKitWebPolicyDecision * decision,
- gpointer data)
-{
- WebKitWebNavigationReason reason;
- LibBalsaWebKitInfo *info = data;
-
- g_object_get(action, "reason", &reason, NULL);
-
- /* First request is for "about:blank"; we must allow it, but first
- * we store the main frame, so we can detect a new frame later. */
- if (!info->frame)
- info->frame = frame;
- else if (web_view == info->web_view
- && frame != info->frame
- && reason == WEBKIT_WEB_NAVIGATION_REASON_OTHER) {
- g_message("%s new frame ignored:\n URI=ā%sā", __func__,
- webkit_network_request_get_uri(request));
- webkit_web_policy_decision_ignore(decision);
- return TRUE;
- }
-
- if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED ||
- (web_view != info->web_view
- && reason == WEBKIT_WEB_NAVIGATION_REASON_OTHER)) {
- (*info->clicked_cb) (webkit_network_request_get_uri(request));
- webkit_web_policy_decision_ignore(decision);
- return TRUE;
- }
-
- return FALSE;
-}
-
-/*
- * Show the GtkInfoBar for asking about downloading images
- */
-
-static void
-lbh_info_bar_response_cb(GtkInfoBar * info_bar,
- gint response_id, gpointer user_data)
-{
- LibBalsaWebKitInfo *info = user_data;
-
- if (response_id == GTK_RESPONSE_OK) {
- gchar *text;
-
- if (lbh_get_body_content(info->body, &text) >= 0) {
- info->download_images = TRUE;
- webkit_web_view_reload_bypass_cache(info->web_view);
- webkit_web_view_load_string(info->web_view, text, "text/html",
- libbalsa_message_body_charset
- (info->body), NULL);
- g_free(text);
- }
- }
-
- gtk_widget_destroy(GTK_WIDGET(info_bar));
-}
-
-static void
-lbh_show_info_bar(LibBalsaWebKitInfo * info)
-{
- GtkWidget *info_bar_widget;
- GtkInfoBar *info_bar;
- GtkWidget *label;
- GtkWidget *content_area;
- gchar *text = _("This message part contains images "
- "from a remote server. "
- "To protect your privacy, "
- "Balsa has not downloaded them. "
- "You may choose to download them "
- "if you trust the server.");
-
- if (info->has_info_bar)
- return;
-
- info_bar_widget =
- gtk_info_bar_new_with_buttons(_("_Download images"),
- GTK_RESPONSE_OK,
- _("_Close"), GTK_RESPONSE_CLOSE,
- NULL);
- gtk_box_pack_start(GTK_BOX(info->vbox), info_bar_widget,
- FALSE, FALSE, 0);
-
- info_bar = GTK_INFO_BAR(info_bar_widget);
-
- label = gtk_label_new(text);
- gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-
- content_area = gtk_info_bar_get_content_area(info_bar);
- gtk_container_add(GTK_CONTAINER(content_area), label);
-
- g_signal_connect(info_bar, "response",
- G_CALLBACK(lbh_info_bar_response_cb), info);
- gtk_info_bar_set_default_response(info_bar, GTK_RESPONSE_CLOSE);
- gtk_info_bar_set_message_type(info_bar, GTK_MESSAGE_QUESTION);
-
- info->has_info_bar = TRUE;
- gtk_widget_show_all(info_bar_widget);
-}
-
-/*
- * Callback for the "resource-request-starting" signal
- *
- * Here we get to disallow all requests involving remote servers, and to
- * handle cid: requests by replacing them with file: requests.
- */
-
-static void
-lbh_resource_request_starting_cb(WebKitWebView * web_view,
- WebKitWebFrame * frame,
- WebKitWebResource * resource,
- WebKitNetworkRequest * request,
- WebKitNetworkResponse * response,
- gpointer data)
-{
- const gchar *uri = webkit_network_request_get_uri(request);
- LibBalsaWebKitInfo *info = data;
-
- if (!g_ascii_strcasecmp(uri, "about:blank"))
- return;
-
- if (g_ascii_strncasecmp(uri, "cid:", 4)) {
- /* Not a "cid:" request: disable loading. */
- static GHashTable *cache = NULL;
-
- if (!cache)
- cache = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, NULL);
-
- if (!g_hash_table_lookup(cache, uri)) {
- if (info->download_images) {
- g_hash_table_insert(cache, g_strdup(uri),
- GINT_TO_POINTER(TRUE));
- } else {
- webkit_network_request_set_uri(request, "about:blank");
- lbh_show_info_bar(info);
- }
- }
- } else {
- LibBalsaMessageBody *body;
-
- /* Replace "cid:" request with a "file:" request. */
- if ((body =
- libbalsa_message_get_part_by_id(info->body->message, uri + 4))
- && libbalsa_message_body_save_temporary(body, NULL)) {
- gchar *file_uri =
- g_strconcat("file://", body->temp_filename, NULL);
- webkit_network_request_set_uri(request, file_uri);
- g_free(file_uri);
- }
- }
-}
-
-/*
- * To handle a clicked link that is supposed to open in a new window
- * (specifically, has the attribute 'target="_blank"'), we must allow
- * WebKit to open one, but we destroy it after it has emitted the
- * "navigation-policy-decision-requested" signal.
- */
-
-/*
- * Allow the new window only if it is needed because a link was clicked.
- */
-static gboolean
-lbh_new_window_policy_decision_requested_cb(WebKitWebView * web_view,
- WebKitWebFrame * frame,
- WebKitNetworkRequest * request,
- WebKitWebNavigationAction * action,
- WebKitWebPolicyDecision * decision,
- gpointer data)
-{
- WebKitWebNavigationReason reason;
-
- g_object_get(action, "reason", &reason, NULL);
-
- if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED)
- return FALSE;
-
- webkit_web_policy_decision_ignore(decision);
- return TRUE;
-}
-
-/*
- * Idle handler to actually unref it.
- */
-static gboolean
-lbh_web_view_ready_idle(WebKitWebView * web_view)
-{
- g_object_unref(g_object_ref_sink(web_view));
-
- return FALSE;
-}
-
-/*
- * Window is ready, now we destroy it.
- */
-static gboolean
-lbh_web_view_ready_cb(WebKitWebView * web_view,
- gpointer data)
-{
- g_idle_add((GSourceFunc) lbh_web_view_ready_idle, web_view);
-
- return TRUE;
-}
-
-/*
- * WebKit wants a new window.
- */
-static WebKitWebView *
-lbh_create_web_view_cb(WebKitWebView * web_view,
- WebKitWebFrame * frame,
- gpointer data)
-{
- GtkWidget *widget;
-
- widget = webkit_web_view_new();
- g_signal_connect(widget, "navigation-policy-decision-requested",
- G_CALLBACK
- (lbh_navigation_policy_decision_requested_cb), data);
- g_signal_connect(widget, "web-view-ready", G_CALLBACK(lbh_web_view_ready_cb),
- NULL);
-
- return WEBKIT_WEB_VIEW(widget);
-}
-
-/* Create a new WebKitWebView widget:
- * text the HTML source;
- * len length of text;
- * body LibBalsaMessageBody that belongs to the
- * LibBalsaMessage from which to extract any
- * HTML objects (by url);
- * hover_cb callback for link-hover signal;
- * clicked_cb callback for the "link-clicked" signal;
- */
-
-GtkWidget *
-libbalsa_html_new(LibBalsaMessageBody * body,
- LibBalsaHtmlCallback hover_cb,
- LibBalsaHtmlCallback clicked_cb)
-{
- gchar *text;
- gssize len;
- GtkWidget *vbox;
- GtkWidget *widget;
- WebKitWebView *web_view;
- LibBalsaWebKitInfo *info;
-
- len = lbh_get_body_content(body, &text);
- if (len < 0)
- return NULL;
-
- info = g_new(LibBalsaWebKitInfo, 1);
- info->body = body;
- info->hover_cb = hover_cb;
- info->clicked_cb = clicked_cb;
- info->frame = NULL;
- info->download_images = FALSE;
- info->has_info_bar = FALSE;
- info->vbox = vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-
- widget = webkit_web_view_new();
- gtk_box_pack_end(GTK_BOX(vbox), widget, TRUE, TRUE, 0);
-
- info->web_view = web_view = WEBKIT_WEB_VIEW(widget);
- g_object_set_data(G_OBJECT(vbox), "libbalsa-html-web-view", web_view);
- g_object_set_data_full(G_OBJECT(web_view), "libbalsa-html-info", info,
- g_free);
-
- g_object_set(webkit_web_view_get_settings(web_view),
- "enable-scripts", FALSE,
- "enable-plugins", FALSE,
- NULL);
-
- g_signal_connect(web_view, "hovering-over-link",
- G_CALLBACK(lbh_hovering_over_link_cb), info);
- g_signal_connect(web_view, "navigation-policy-decision-requested",
- G_CALLBACK
- (lbh_navigation_policy_decision_requested_cb), info);
- g_signal_connect(web_view, "resource-request-starting",
- G_CALLBACK(lbh_resource_request_starting_cb), info);
- g_signal_connect(web_view, "new-window-policy-decision-requested",
- G_CALLBACK(lbh_new_window_policy_decision_requested_cb),
- info);
- g_signal_connect(web_view, "create-web-view",
- G_CALLBACK(lbh_create_web_view_cb), info);
-
- g_signal_connect(web_view, "notify::progress",
- G_CALLBACK(gtk_widget_queue_resize), NULL);
-
- webkit_web_view_load_string(web_view, text, "text/html",
- libbalsa_message_body_charset(body), NULL);
- g_free(text);
-
- return vbox;
-}
-
-void
-libbalsa_html_to_string(gchar ** text, size_t len)
-{
- /* this widget does not support conversion to a string. */
- html2text(text, len);
-}
-
-static gboolean
-lbh_get_web_view(GtkWidget * widget, WebKitWebView ** web_view)
-{
- *web_view =
- g_object_get_data(G_OBJECT(widget), "libbalsa-html-web-view");
-
- return *web_view && WEBKIT_IS_WEB_VIEW(*web_view);
-}
-
-/*
- * Does the widget support zoom?
- */
-gboolean
-libbalsa_html_can_zoom(GtkWidget * widget)
-{
- WebKitWebView *web_view;
-
- return lbh_get_web_view(widget, &web_view);
-}
-
-/*
- * Zoom the widget.
- */
-void
-libbalsa_html_zoom(GtkWidget * widget, gint in_out)
-{
- WebKitWebView *web_view;
-
- if (lbh_get_web_view(widget, &web_view)) {
- switch (in_out) {
- case +1:
- webkit_web_view_zoom_in(web_view);
- break;
- case -1:
- webkit_web_view_zoom_out(web_view);
- break;
- case 0:
- webkit_web_view_set_zoom_level(web_view, 1.0);
- break;
- default:
- break;
- }
- }
-}
-
-/*
- * Does the widget support selecting text?
- */
-gboolean
-libbalsa_html_can_select(GtkWidget * widget)
-{
- WebKitWebView *web_view;
-
- return lbh_get_web_view(widget, &web_view);
-}
-
-/*
- * Select all the text.
- */
-void
-libbalsa_html_select_all(GtkWidget * widget)
-{
- WebKitWebView *web_view;
-
- if (lbh_get_web_view(widget, &web_view))
- webkit_web_view_select_all(web_view);
-}
-
-/*
- * Copy selected text to the clipboard.
- */
-void
-libbalsa_html_copy(GtkWidget * widget)
-{
- WebKitWebView *web_view;
-
- if (lbh_get_web_view(widget, &web_view))
- webkit_web_view_copy_clipboard(web_view);
-}
-
-/*
- * Does the widget support searching text?
- */
-gboolean
-libbalsa_html_can_search(GtkWidget * widget)
-{
- WebKitWebView *web_view;
-
- return lbh_get_web_view(widget, &web_view);
-}
-
-/*
- * JavaScript-based helpers for text search
- */
-static JSGlobalContextRef
-lbh_js_get_global_context(WebKitWebView * web_view)
-{
- WebKitWebFrame *web_frame = webkit_web_view_get_main_frame(web_view);
- return webkit_web_frame_get_global_context(web_frame);
-}
-
-static JSValueRef
-lbh_js_run_script(JSContextRef ctx,
- const gchar * script)
-{
- JSStringRef str;
- JSValueRef value;
-
- str = JSStringCreateWithUTF8CString(script);
- value = JSEvaluateScript(ctx, str, NULL, NULL, 0, NULL);
- JSStringRelease(str);
-
- return value;
-}
-
-static gint
-lbh_js_object_get_property(JSContextRef ctx,
- JSObjectRef object,
- const gchar * property_name)
-{
- JSStringRef str = JSStringCreateWithUTF8CString(property_name);
- JSValueRef value = JSObjectGetProperty(ctx, object, str, NULL);
- JSStringRelease(str);
-
- return (gint) JSValueToNumber(ctx, value, NULL);
-}
-
-/*
- * Search for the text; if text is empty, return TRUE (for consistency
- * with GtkTextIter methods).
- */
-void
-libbalsa_html_search(GtkWidget * widget,
- const gchar * text,
- gboolean find_forward,
- gboolean wrap,
- LibBalsaHtmlSearchCallback search_cb,
- gpointer cb_data)
-{
- WebKitWebView *web_view;
- gboolean retval;
-
- if (!lbh_get_web_view(widget, &web_view))
- return;
-
- if (!*text) {
- gchar script[] = "window.getSelection().removeAllRanges()";
-
- lbh_js_run_script(lbh_js_get_global_context(web_view), script);
-
- (*search_cb)(text, TRUE, cb_data);
- return;
- }
-
- retval = webkit_web_view_search_text(web_view, text,
- FALSE, /* case-insensitive */
- find_forward, wrap);
- (*search_cb)(text, retval, cb_data);
-
- return;
-}
-
-/*
- * Get the rectangle containing the currently selected text, for
- * scrolling.
- */
-gboolean
-libbalsa_html_get_selection_bounds(GtkWidget * widget,
- GdkRectangle * selection_bounds)
-{
- WebKitWebView *web_view;
- JSGlobalContextRef ctx;
- gchar script[] =
- "window.getSelection().getRangeAt(0).getBoundingClientRect()";
- JSValueRef value;
-
- if (!lbh_get_web_view(widget, &web_view))
- return FALSE;
-
- ctx = lbh_js_get_global_context(web_view);
- value = lbh_js_run_script(ctx, script);
-
- if (value && JSValueIsObject(ctx, value)) {
- JSObjectRef object = JSValueToObject(ctx, value, NULL);
- gint x, y;
-
- x = lbh_js_object_get_property(ctx, object, "left");
- y = lbh_js_object_get_property(ctx, object, "top");
-
- gtk_widget_translate_coordinates(GTK_WIDGET(web_view), widget,
- x, y,
- &selection_bounds->x,
- &selection_bounds->y);
-
- selection_bounds->width =
- lbh_js_object_get_property(ctx, object, "width");
- selection_bounds->height =
- lbh_js_object_get_property(ctx, object, "height");
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/*
- * Get the WebKitWebView widget from the container; we need to connect
- * to its "populate-popup" signal.
- */
-GtkWidget *
-libbalsa_html_popup_menu_widget(GtkWidget * widget)
-{
- WebKitWebView *web_view;
-
- return lbh_get_web_view(widget, &web_view) ?
- GTK_WIDGET(web_view) : NULL;
-}
-
-GtkWidget *
-libbalsa_html_get_view_widget(GtkWidget * widget)
-{
- return libbalsa_html_popup_menu_widget(widget);
-}
-
-/*
- * Does the widget support printing?
- */
-gboolean
-libbalsa_html_can_print(GtkWidget * widget)
-{
- WebKitWebView *web_view;
-
- return lbh_get_web_view(widget, &web_view);
-}
-
-/*
- * Print the widget's content.
- */
-void
-libbalsa_html_print(GtkWidget * widget)
-{
- WebKitWebView *web_view;
-
- if (lbh_get_web_view(widget, &web_view)) {
- WebKitWebFrame *frame = webkit_web_view_get_main_frame(web_view);
- webkit_web_frame_print(frame);
- }
-}
-
-# endif /* defined(USE_WEBKIT2) */
# else /* defined(HAVE_WEBKIT) */
/* Code for GtkHTML-4 */
diff --git a/meson.build b/meson.build
index 19a511e21..70a268db0 100644
--- a/meson.build
+++ b/meson.build
@@ -190,21 +190,8 @@ if html_widget == 'gtkhtml4'
html_dep = dependency('libgtkhtml-4.0')
conf.set('HAVE_GTKHTML4', 1,
description : 'Defined when GtkHtml-4 can be used.')
-elif html_widget == 'webkit' or html_widget == 'webkit2'
- if html_widget == 'webkit2'
- html_dep = dependency('webkit2gtk-4.0')
- conf.set('USE_WEBKIT2', 1,
- description : 'Defined when WebKit2 is requested.')
- else
- html_dep = dependency('webkit2gtk-3.0',
- version : '>= 1.5.1',
- required : false)
- if html_dep.found()
- java_dep = dependency('javascriptcoregtk-3.0')
- else
- html_dep = dependency('webkit2gtk-3.0')
- endif
- endif
+elif html_widget == 'webkit2'
+ html_dep = dependency('webkit2gtk-4.0')
conf.set('HAVE_WEBKIT', 1,
description : 'Defined when WebKit can be used.')
@@ -672,16 +659,6 @@ or just plain not work. Use it at your own risk. You have been warned.
endif
-if html_widget == 'webkit'
- message('''
-*** You have configured Balsa to use the old webkitgtk HTML widget.
-*** This widget is no longer being actively developed, and likely
-*** has security issues fixed in the newer webkit2 widget.
-*** Balsa will continue support for the old webkit widget only
-*** while needed by long-term-stable releases of major distributors.
- ''')
-endif
-
top_include = include_directories('.')
libnetclient_include = include_directories('libnetclient')
libbalsa_include = include_directories('libbalsa')
diff --git a/meson_options.txt b/meson_options.txt
index 4b8b764d9..2d1f6ab50 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -35,7 +35,7 @@ option('gss',
option('html-widget',
type : 'combo',
- choices : ['webkit2', 'webkit', 'gtkhtml4'],
+ choices : ['webkit2', 'gtkhtml4'],
value : 'webkit2',
description : 'select the HTML renderer (default webkit2)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]