Skip to content

Commit

Permalink
Added SchemeSupported to the OpenURI portal
Browse files Browse the repository at this point in the history
  • Loading branch information
xhorak committed Jan 22, 2024
1 parent 1e6c910 commit 579f56d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
13 changes: 0 additions & 13 deletions data/org.freedesktop.impl.portal.AppChooser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,5 @@
<arg type="o" name="handle" direction="in"/>
<arg type="as" name="choices" direction="in"/>
</method>

<!--
SchemeSupported:
@scheme: the uri scheme to check
This method checks whenever system supports specific scheme handler.
Browsers use this to decide whenever pass the uri to the system uri handler
or open it internally.
-->
<method name="SchemeSupported">
<arg type="s" name="scheme" direction="in"/>
<arg type="b" name="supported" direction="out"/>
</method>
</interface>
</node>
14 changes: 14 additions & 0 deletions data/org.freedesktop.portal.OpenURI.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@
<arg type="o" name="handle" direction="out"/>
</method>

<!--
SchemeSupported:
@scheme: The URI protocol scheme to check
@supported: True when URI scheme is supported on the host system
Asks whenever host system supports the protocol scheme.
The SchemeSupported method was introduced in version 4 of the OpenURI portal API.
-->
<method name="SchemeSupported">
<arg type="s" name="scheme" direction="in"/>
<arg type="b" name="supported" direction="out"/>
</method>

<property name="version" type="u" access="read"/>
</interface>
</node>
25 changes: 24 additions & 1 deletion src/open-uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,28 @@ 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)
{
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;
}
GAppInfo* 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,
Expand Down Expand Up @@ -1088,12 +1110,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), 3);
xdp_dbus_open_uri_set_version (XDP_DBUS_OPEN_URI (openuri), 4);
}

static void
Expand Down

0 comments on commit 579f56d

Please sign in to comment.