From 1c1912d0061bb59525b870767d08b16c09acc8da Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Sat, 15 May 2021 22:14:49 +1000 Subject: [PATCH] build: Remove explicit libsoup dependency Replace all uses of libsoup with their GLib equivalents, and remove the build dependency. See GNOME/gnome-build-meta#378 --- meson.build | 1 - src/client/components/components-web-view.vala | 5 +---- src/client/composer/composer-link-popover.vala | 10 +++++++--- .../conversation-viewer/conversation-message.vala | 8 ++++---- src/client/meson.build | 1 - src/client/plugin/meson.build | 1 - src/client/web-process/web-process-extension.vala | 7 ++++++- src/meson.build | 1 - 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/meson.build b/meson.build index d0af9eef..233e8c56 100644 --- a/meson.build +++ b/meson.build @@ -95,7 +95,6 @@ libpeas = dependency('libpeas-1.0', version: '>= 1.24.0') libpeas_gtk = dependency('libpeas-gtk-1.0', version: '>= 1.24.0') libsecret = dependency('libsecret-1', version: '>= 0.11') libstemmer_dep = cc.find_library('stemmer') -libsoup = dependency('libsoup-2.4', version: '>= 2.48') libunwind_dep = dependency( 'libunwind', version: '>= 1.1', required: get_option('libunwind') ) diff --git a/src/client/components/components-web-view.vala b/src/client/components/components-web-view.vala index fe3c036d..4ec857f9 100644 --- a/src/client/components/components-web-view.vala +++ b/src/client/components/components-web-view.vala @@ -696,7 +696,7 @@ public abstract class Components.WebView : WebKit.WebView, Geary.BaseInterface { } private bool handle_internal_response(WebKit.URISchemeRequest request) { - string name = soup_uri_decode(request.get_path()); + string name = GLib.Uri.unescape_string(request.get_path()); Geary.Memory.Buffer? buf = this.internal_resources[name]; bool handled = false; if (buf != null) { @@ -853,6 +853,3 @@ public abstract class Components.WebView : WebKit.WebView, Geary.BaseInterface { } } - -// XXX this needs to be moved into the libsoup bindings -extern string soup_uri_decode(string part); diff --git a/src/client/composer/composer-link-popover.vala b/src/client/composer/composer-link-popover.vala index 63ec71ee..c4bc3d96 100644 --- a/src/client/composer/composer-link-popover.vala +++ b/src/client/composer/composer-link-popover.vala @@ -52,7 +52,7 @@ public class Composer.LinkPopover : Gtk.Popover { /** Emitted when the link URL has changed. */ - public signal void link_changed(Soup.URI? uri, bool is_valid); + public signal void link_changed(GLib.Uri? uri, bool is_valid); /** Emitted when the link URL was activated. */ public signal void link_activate(); @@ -99,9 +99,13 @@ public class Composer.LinkPopover : Gtk.Popover { bool is_valid = false; bool is_nominal = false; bool is_mailto = false; - Soup.URI? url = null; + GLib.Uri? url = null; if (!is_empty) { - url = new Soup.URI(text); + try { + url = GLib.Uri.parse(text, PARSE_RELAXED); + } catch (GLib.UriError err) { + debug("Invalid link URI: %s", err.message); + } if (url != null) { is_valid = true; diff --git a/src/client/conversation-viewer/conversation-message.vala b/src/client/conversation-viewer/conversation-message.vala index c15f3f8f..d7492b9f 100644 --- a/src/client/conversation-viewer/conversation-message.vala +++ b/src/client/conversation-viewer/conversation-message.vala @@ -1335,16 +1335,16 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface { string href, Gdk.Rectangle location) { string text_href = text; - if (Uri.parse_scheme(text_href) == null) { + if (GLib.Uri.parse_scheme(text_href) == null) { text_href = "http://" + text_href; } - string text_label = Soup.URI.decode(text_href); + string? text_label = GLib.Uri.unescape_string(text_href) ?? _("(unknown)"); string anchor_href = href; - if (Uri.parse_scheme(anchor_href) == null) { + if (GLib.Uri.parse_scheme(anchor_href) == null) { anchor_href = "http://" + anchor_href; } - string anchor_label = Soup.URI.decode(anchor_href); + string anchor_label = GLib.Uri.unescape_string(anchor_href) ?? _("(unknown)"); Gtk.Builder builder = new Gtk.Builder.from_resource( "/org/gnome/Geary/conversation-message-link-popover.ui" diff --git a/src/client/meson.build b/src/client/meson.build index ff3c8a6d..ba151e42 100644 --- a/src/client/meson.build +++ b/src/client/meson.build @@ -168,7 +168,6 @@ client_dependencies = [ libpeas, libpeas_gtk, libsecret, - libsoup, libxml, posix, webkit2gtk, diff --git a/src/client/plugin/meson.build b/src/client/plugin/meson.build index e6db0853..b795237e 100644 --- a/src/client/plugin/meson.build +++ b/src/client/plugin/meson.build @@ -16,7 +16,6 @@ plugin_dependencies = [ libhandy, libmath, libpeas, - libsoup, webkit2gtk, ] diff --git a/src/client/web-process/web-process-extension.vala b/src/client/web-process/web-process-extension.vala index c36c4e28..dc686350 100644 --- a/src/client/web-process/web-process-extension.vala +++ b/src/client/web-process/web-process-extension.vala @@ -68,7 +68,12 @@ public class GearyWebExtension : Object { WebKit.URIRequest request, WebKit.URIResponse? response) { bool should_load = false; - Soup.URI? uri = new Soup.URI(request.get_uri()); + GLib.Uri? uri = null; + try { + uri = GLib.Uri.parse(request.get_uri(), NONE); + } catch (GLib.UriError err) { + warning("Invalid request URI: %s", err.message); + } if (uri != null && uri.get_scheme() in ALLOWED_SCHEMES) { // Always load internal resources should_load = true; diff --git a/src/meson.build b/src/meson.build index 5eded12e..4e7752ab 100644 --- a/src/meson.build +++ b/src/meson.build @@ -107,7 +107,6 @@ bin_dependencies = [ libhandy, libmath, libpeas, - libsoup, webkit2gtk, ]