portal-impl.c (flatpak-1.15.1.tar.xz) | : | portal-impl.c (flatpak-1.15.2.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 53 | skipping to change at line 53 | |||
static GList *implementations = NULL; | static GList *implementations = NULL; | |||
static gboolean | static gboolean | |||
register_portal (const char *path, gboolean opt_verbose, GError **error) | register_portal (const char *path, gboolean opt_verbose, GError **error) | |||
{ | { | |||
g_autoptr(GKeyFile) keyfile = g_key_file_new (); | g_autoptr(GKeyFile) keyfile = g_key_file_new (); | |||
g_autoptr(PortalImplementation) impl = g_new0 (PortalImplementation, 1); | g_autoptr(PortalImplementation) impl = g_new0 (PortalImplementation, 1); | |||
int i; | int i; | |||
g_debug ("loading %s", path); | g_info ("loading %s", path); | |||
if (!g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, error)) | if (!g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, error)) | |||
return FALSE; | return FALSE; | |||
impl->source = g_path_get_basename (path); | impl->source = g_path_get_basename (path); | |||
impl->dbus_name = g_key_file_get_string (keyfile, "portal", "DBusName", error) ; | impl->dbus_name = g_key_file_get_string (keyfile, "portal", "DBusName", error) ; | |||
if (impl->dbus_name == NULL) | if (impl->dbus_name == NULL) | |||
return FALSE; | return FALSE; | |||
if (!g_dbus_is_name (impl->dbus_name)) | if (!g_dbus_is_name (impl->dbus_name)) | |||
{ | { | |||
skipping to change at line 95 | skipping to change at line 95 | |||
} | } | |||
} | } | |||
impl->use_in = g_key_file_get_string_list (keyfile, "portal", "UseIn", NULL, e rror); | impl->use_in = g_key_file_get_string_list (keyfile, "portal", "UseIn", NULL, e rror); | |||
if (impl->use_in == NULL) | if (impl->use_in == NULL) | |||
return FALSE; | return FALSE; | |||
if (opt_verbose) | if (opt_verbose) | |||
{ | { | |||
g_autofree char *uses = g_strjoinv (", ", impl->use_in); | g_autofree char *uses = g_strjoinv (", ", impl->use_in); | |||
g_debug ("portal implementation for %s", uses); | g_info ("portal implementation for %s", uses); | |||
for (i = 0; impl->interfaces[i]; i++) | for (i = 0; impl->interfaces[i]; i++) | |||
g_debug ("portal implementation supports %s", impl->interfaces[i]); | g_info ("portal implementation supports %s", impl->interfaces[i]); | |||
} | } | |||
implementations = g_list_prepend (implementations, impl); | implementations = g_list_prepend (implementations, impl); | |||
impl = NULL; | impl = NULL; | |||
return TRUE; | return TRUE; | |||
} | } | |||
static gint | static gint | |||
sort_impl_by_name (gconstpointer a, | sort_impl_by_name (gconstpointer a, | |||
skipping to change at line 128 | skipping to change at line 128 | |||
{ | { | |||
const char *portal_dir; | const char *portal_dir; | |||
g_autoptr(GFile) dir = NULL; | g_autoptr(GFile) dir = NULL; | |||
g_autoptr(GFileEnumerator) enumerator = NULL; | g_autoptr(GFileEnumerator) enumerator = NULL; | |||
/* We need to override this in the tests */ | /* We need to override this in the tests */ | |||
portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); | portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); | |||
if (portal_dir == NULL) | if (portal_dir == NULL) | |||
portal_dir = DATADIR "/xdg-desktop-portal/portals"; | portal_dir = DATADIR "/xdg-desktop-portal/portals"; | |||
g_debug ("load portals from %s", portal_dir); | g_info ("load portals from %s", portal_dir); | |||
dir = g_file_new_for_path (portal_dir); | dir = g_file_new_for_path (portal_dir); | |||
enumerator = g_file_enumerate_children (dir, "*", G_FILE_QUERY_INFO_NONE, NULL , NULL); | enumerator = g_file_enumerate_children (dir, "*", G_FILE_QUERY_INFO_NONE, NULL , NULL); | |||
if (enumerator == NULL) | if (enumerator == NULL) | |||
return; | return; | |||
while (TRUE) | while (TRUE) | |||
{ | { | |||
g_autoptr(GFileInfo) info = g_file_enumerator_next_file (enumerator, NULL, NULL); | g_autoptr(GFileInfo) info = g_file_enumerator_next_file (enumerator, NULL, NULL); | |||
skipping to change at line 202 | skipping to change at line 202 | |||
{ | { | |||
for (l = implementations; l != NULL; l = l->next) | for (l = implementations; l != NULL; l = l->next) | |||
{ | { | |||
PortalImplementation *impl = l->data; | PortalImplementation *impl = l->data; | |||
if (!g_strv_contains ((const char **)impl->interfaces, interface)) | if (!g_strv_contains ((const char **)impl->interfaces, interface)) | |||
continue; | continue; | |||
if (g_strv_case_contains ((const char **)impl->use_in, desktops[i])) | if (g_strv_case_contains ((const char **)impl->use_in, desktops[i])) | |||
{ | { | |||
g_debug ("Using %s for %s in %s", impl->source, interface, desktop s[i]); | g_info ("Using %s for %s in %s", impl->source, interface, desktops [i]); | |||
return impl; | return impl; | |||
} | } | |||
} | } | |||
} | } | |||
/* Fall back to *any* installed implementation */ | /* Fall back to *any* installed implementation */ | |||
for (l = implementations; l != NULL; l = l->next) | for (l = implementations; l != NULL; l = l->next) | |||
{ | { | |||
PortalImplementation *impl = l->data; | PortalImplementation *impl = l->data; | |||
if (!g_strv_contains ((const char **)impl->interfaces, interface)) | if (!g_strv_contains ((const char **)impl->interfaces, interface)) | |||
continue; | continue; | |||
g_debug ("Falling back to %s for %s", impl->source, interface); | g_info ("Falling back to %s for %s", impl->source, interface); | |||
return impl; | return impl; | |||
} | } | |||
return NULL; | return NULL; | |||
} | } | |||
End of changes. 6 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added |