Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback implementation is used if preferred value of none #1255

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion src/portal-impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,51 @@ load_portal_configuration (gboolean opt_verbose)
return;
}

PortalInterface *
find_matching_iface_config (const char *interface)
{
if (config == NULL)
return NULL;

for (size_t i = 0; i < config->n_ifaces; i++)
{
PortalInterface *iface = config->interfaces[i];

if (g_strcmp0 (iface->dbus_name, interface) == 0)
return iface;
}

return NULL;
}

static gboolean
portal_default_prefers_none (void)
{
if (config != NULL && g_strv_contains ((const char * const *) config->default_portal->portals, "none"))
{
g_debug ("Found 'none' in configuration for default");
return TRUE;
}

return FALSE;
}

static gboolean
portal_interface_prefers_none (const char *interface)
{
const PortalInterface *iface = find_matching_iface_config (interface);
if (iface == NULL)
return portal_default_prefers_none ();

if (g_strv_contains ((const char * const *) iface->portals, "none"))
{
g_debug ("Found 'none' in configuration for %s", iface->dbus_name);
return TRUE;
}

return FALSE;
}

static gboolean
portal_impl_name_matches (const PortalImplementation *impl,
const PortalInterface *iface)
Expand All @@ -507,7 +552,7 @@ portal_impl_name_matches (const PortalImplementation *impl,
}

/* No portal */
if (g_strv_contains ((const char * const *) iface->portals, "none"))
if (portal_interface_prefers_none (iface->dbus_name))
{
g_debug ("Found 'none' in configuration for %s", iface->dbus_name);
return FALSE;
Expand Down Expand Up @@ -555,6 +600,9 @@ find_portal_implementation (const char *interface)
GList *l;
int i;

if (portal_interface_prefers_none (interface))
return NULL;

for (l = implementations; l != NULL; l = l->next)
{
PortalImplementation *impl = l->data;
Expand Down Expand Up @@ -625,6 +673,9 @@ find_all_portal_implementations (const char *interface)

impls = g_ptr_array_new ();

if (portal_interface_prefers_none (interface))
return impls;

for (l = implementations; l != NULL; l = l->next)
{
PortalImplementation *impl = l->data;
Expand Down
Loading