diff --git a/data/org.freedesktop.portal.OpenURI.xml b/data/org.freedesktop.portal.OpenURI.xml
index dd1d326a0..aeb0713d4 100644
--- a/data/org.freedesktop.portal.OpenURI.xml
+++ b/data/org.freedesktop.portal.OpenURI.xml
@@ -29,7 +29,7 @@
URIs (e.g. a http: link to the applications homepage)
under the control of the user.
- This documentation describes version 4 of this interface.
+ This documentation describes version 5 of this interface.
-->
+
+
+
+
+
+
diff --git a/src/open-uri.c b/src/open-uri.c
index 2b106657e..da46d909d 100644
--- a/src/open-uri.c
+++ b/src/open-uri.c
@@ -925,6 +925,31 @@ handle_open_in_thread_func (GTask *task,
g_object_ref (request));
}
+static gboolean
+handle_scheme_supported (XdpDbusOpenURI *object,
+ GDBusMethodInvocation *invocation,
+ const gchar *arg_scheme,
+ GVariant *arg_options)
+{
+ g_autoptr(GAppInfo) app_info = NULL;
+
+ if (arg_scheme == NULL || *arg_scheme == '\0')
+ {
+ g_dbus_method_invocation_return_error (invocation,
+ XDG_DESKTOP_PORTAL_ERROR,
+ XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENT,
+ "Scheme not specified");
+ return G_DBUS_METHOD_INVOCATION_HANDLED;
+ }
+
+ app_info = g_app_info_get_default_for_uri_scheme (arg_scheme);
+
+ g_debug ("Handler for scheme: %s%s found.", arg_scheme, app_info ? "" : " not");
+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", app_info != NULL));
+
+ return G_DBUS_METHOD_INVOCATION_HANDLED;
+}
+
static gboolean
handle_open_uri (XdpDbusOpenURI *object,
GDBusMethodInvocation *invocation,
@@ -1094,12 +1119,13 @@ open_uri_iface_init (XdpDbusOpenURIIface *iface)
iface->handle_open_uri = handle_open_uri;
iface->handle_open_file = handle_open_file;
iface->handle_open_directory = handle_open_directory;
+ iface->handle_scheme_supported = handle_scheme_supported;
}
static void
open_uri_init (OpenURI *openuri)
{
- xdp_dbus_open_uri_set_version (XDP_DBUS_OPEN_URI (openuri), 4);
+ xdp_dbus_open_uri_set_version (XDP_DBUS_OPEN_URI (openuri), 5);
}
static void
diff --git a/tests/openuri.c b/tests/openuri.c
index b78b37eaf..4e7f16701 100644
--- a/tests/openuri.c
+++ b/tests/openuri.c
@@ -5,6 +5,7 @@
#include
#include "xdp-utils.h"
#include "xdp-impl-dbus.h"
+#include "xdp-dbus.h"
#include "utils.h"
@@ -478,3 +479,56 @@ test_open_directory (void)
while (!got_info)
g_main_context_iteration (NULL, TRUE);
}
+
+void
+test_scheme_supported (void)
+{
+ gboolean supported;
+ GVariantBuilder builder;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GVariant) options = NULL;
+ g_autoptr(GDBusConnection) session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+
+ XdpDbusOpenURI *proxy = xdp_dbus_open_uri_proxy_new_sync (session_bus,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "org.freedesktop.portal.Desktop",
+ "/org/freedesktop/portal/desktop",
+ NULL,
+ &error);
+
+ g_assert_no_error (error);
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
+ options = g_variant_ref_sink (g_variant_builder_end (&builder));
+ /* Existing scheme */
+ xdp_dbus_open_uri_call_scheme_supported_sync (proxy,
+ "https",
+ options,
+ &supported,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert_true (supported);
+
+ /* Non existing scheme */
+ xdp_dbus_open_uri_call_scheme_supported_sync (proxy,
+ "bogusnonexistanthandler",
+ options,
+ &supported,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert_false (supported);
+
+ /* Missing scheme name */
+ xdp_dbus_open_uri_call_scheme_supported_sync (proxy,
+ "",
+ options,
+ &supported,
+ NULL,
+ &error);
+ g_assert_error (error,
+ XDG_DESKTOP_PORTAL_ERROR,
+ XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENT);
+ g_object_unref (proxy);
+}
diff --git a/tests/openuri.h b/tests/openuri.h
index f5dcf87db..c6e19ba78 100644
--- a/tests/openuri.h
+++ b/tests/openuri.h
@@ -8,3 +8,4 @@ void test_open_uri_close (void);
void test_open_uri_cancel (void);
void test_open_uri_lockdown (void);
void test_open_directory (void);
+void test_scheme_supported (void);
diff --git a/tests/test-portals.c b/tests/test-portals.c
index 8fd78ea78..8fcaf8e76 100644
--- a/tests/test-portals.c
+++ b/tests/test-portals.c
@@ -448,7 +448,7 @@ DEFINE_TEST_EXISTS(inhibit, INHIBIT, 3)
DEFINE_TEST_EXISTS(location, LOCATION, 1)
DEFINE_TEST_EXISTS(network_monitor, NETWORK_MONITOR, 3)
DEFINE_TEST_EXISTS(notification, NOTIFICATION, 1)
-DEFINE_TEST_EXISTS(open_uri, OPEN_URI, 4)
+DEFINE_TEST_EXISTS(open_uri, OPEN_URI, 5)
DEFINE_TEST_EXISTS(print, PRINT, 3)
DEFINE_TEST_EXISTS(proxy_resolver, PROXY_RESOLVER, 1)
DEFINE_TEST_EXISTS(screenshot, SCREENSHOT, 2)
@@ -585,6 +585,7 @@ main (int argc, char **argv)
g_test_add_func ("/portal/openuri/cancel", test_open_uri_cancel);
g_test_add_func ("/portal/openuri/lockdown", test_open_uri_lockdown);
g_test_add_func ("/portal/openuri/directory", test_open_directory);
+ g_test_add_func ("/portal/openuri/scheme-supported", test_scheme_supported);
g_test_add_func ("/portal/wallpaper/basic", test_wallpaper_basic);
g_test_add_func ("/portal/wallpaper/delay", test_wallpaper_delay);