1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright 2016 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "gportalsupport.h"
23 static gboolean use_portal;
24 static gboolean network_available;
25 static gboolean dconf_access;
28 read_flatpak_info (void)
30 static gsize flatpak_info_read = 0;
31 const gchar *path = "/.flatpak-info";
33 if (!g_once_init_enter (&flatpak_info_read))
36 if (g_file_test (path, G_FILE_TEST_EXISTS))
41 network_available = FALSE;
44 keyfile = g_key_file_new ();
45 if (g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, NULL))
48 char *dconf_policy = NULL;
50 shared = g_key_file_get_string_list (keyfile, "Context", "shared", NULL, NULL);
53 network_available = g_strv_contains ((const char * const *)shared, "network");
57 dconf_policy = g_key_file_get_string (keyfile, "Session Bus Policy", "ca.desrt.dconf", NULL);
60 if (strcmp (dconf_policy, "talk") == 0)
62 g_free (dconf_policy);
66 g_key_file_unref (keyfile);
72 var = g_getenv ("GTK_USE_PORTAL");
73 if (var && var[0] == '1')
75 network_available = TRUE;
79 g_once_init_leave (&flatpak_info_read, 1);
83 glib_should_use_portal (void)
90 glib_network_available_in_sandbox (void)
93 return network_available;
97 glib_has_dconf_access_in_sandbox (void)