Commit 7dcc09e5 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

gproxyresolverportal: do not connect to session bus when not under flatpak

While gio module extension is loaded a new GProxyResolverPortal is
created to query whether it's supported. We always return FALSE when not
aunder flatpak, so we don't need to connect to the session bus in that
case. Add a helper ensure_resolver_proxy() that returns TRUE when the
proxy is created and use it in is_supported() instead of creating the
proxy unconditionally in the instance initialization.

https://bugzilla.gnome.org/show_bug.cgi?id=790894
parent d44afbad
......@@ -42,9 +42,15 @@ G_DEFINE_TYPE_WITH_CODE (GProxyResolverPortal, g_proxy_resolver_portal, G_TYPE_O
"portal",
90))
static void
g_proxy_resolver_portal_init (GProxyResolverPortal *resolver)
static gboolean
ensure_resolver_proxy (GProxyResolverPortal *resolver)
{
if (resolver->resolver)
return TRUE;
if (!glib_should_use_portal ())
return FALSE;
resolver->resolver = gxdp_proxy_resolver_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
"org.freedesktop.portal.Desktop",
......@@ -53,6 +59,13 @@ g_proxy_resolver_portal_init (GProxyResolverPortal *resolver)
NULL);
resolver->network_available = glib_network_available_in_sandbox ();
return resolver->resolver != NULL;
}
static void
g_proxy_resolver_portal_init (GProxyResolverPortal *resolver)
{
}
static gboolean
......@@ -62,7 +75,7 @@ g_proxy_resolver_portal_is_supported (GProxyResolver *object)
char *name_owner;
gboolean has_portal;
if (!glib_should_use_portal () || !resolver->resolver)
if (!ensure_resolver_proxy (resolver))
return FALSE;
name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (resolver->resolver));
......@@ -83,6 +96,9 @@ g_proxy_resolver_portal_lookup (GProxyResolver *proxy_resolver,
GProxyResolverPortal *resolver = G_PROXY_RESOLVER_PORTAL (proxy_resolver);
char **proxy = NULL;
ensure_resolver_proxy (resolver);
g_assert (resolver->resolver);
if (!gxdp_proxy_resolver_call_lookup_sync (resolver->resolver,
uri,
&proxy,
......@@ -129,6 +145,9 @@ g_proxy_resolver_portal_lookup_async (GProxyResolver *proxy_resolver,
GProxyResolverPortal *resolver = G_PROXY_RESOLVER_PORTAL (proxy_resolver);
GTask *task;
ensure_resolver_proxy (resolver);
g_assert (resolver->resolver);
task = g_task_new (proxy_resolver, cancellable, callback, user_data);
gxdp_proxy_resolver_call_lookup (resolver->resolver,
uri,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment