Commit 9c5d3a60 authored by Matthias Clasen's avatar Matthias Clasen Committed by Philip Withnall

portal: Add a getter for dconf access

Add method to find whether the sandbox provides
access to dconf. This will be used to tweak
the priorities for the keyfile settings backend.
parent 618d3e4a
......@@ -23,6 +23,7 @@
static gboolean flatpak_info_read;
static gboolean use_portal;
static gboolean network_available;
static gboolean dconf_access;
static void
read_flatpak_info (void)
......@@ -40,11 +41,13 @@ read_flatpak_info (void)
use_portal = TRUE;
network_available = FALSE;
dconf_access = FALSE;
keyfile = g_key_file_new ();
if (g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, NULL))
{
char **shared = NULL;
char *dconf_policy = NULL;
shared = g_key_file_get_string_list (keyfile, "Context", "shared", NULL, NULL);
if (shared)
......@@ -52,6 +55,14 @@ read_flatpak_info (void)
network_available = g_strv_contains ((const char * const *)shared, "network");
g_strfreev (shared);
}
dconf_policy = g_key_file_get_string (keyfile, "Session Bus Policy", "ca.desrt.dconf", NULL);
if (dconf_policy)
{
if (strcmp (dconf_policy, "talk") == 0)
dconf_access = TRUE;
g_free (dconf_policy);
}
}
g_key_file_unref (keyfile);
......@@ -64,6 +75,7 @@ read_flatpak_info (void)
if (var && var[0] == '1')
use_portal = TRUE;
network_available = TRUE;
dconf_access = TRUE;
}
}
......@@ -81,3 +93,9 @@ glib_network_available_in_sandbox (void)
return network_available;
}
gboolean
glib_has_dconf_access_in_sandbox (void)
{
read_flatpak_info ();
return dconf_access;
}
......@@ -24,6 +24,7 @@ G_BEGIN_DECLS
gboolean glib_should_use_portal (void);
gboolean glib_network_available_in_sandbox (void);
gboolean glib_has_dconf_access_in_sandbox (void);
G_END_DECLS
......
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