mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-12 13:30:15 -05:00
flatpak: also check for client property changes
If a client changes the "pipewire.access" property to "flatpak", start handling the client as a flatpak client and do portal checks. This is useful when the portal makes a connection for the client and needs to for portal checks.
This commit is contained in:
parent
1f5fec5983
commit
6f918561c9
1 changed files with 39 additions and 9 deletions
|
|
@ -56,8 +56,10 @@ struct client_info {
|
||||||
struct spa_list link;
|
struct spa_list link;
|
||||||
struct impl *impl;
|
struct impl *impl;
|
||||||
struct pw_client *client;
|
struct pw_client *client;
|
||||||
|
struct spa_hook client_listener;
|
||||||
struct spa_list resources;
|
struct spa_list resources;
|
||||||
struct spa_list async_pending;
|
struct spa_list async_pending;
|
||||||
|
bool checked;
|
||||||
bool camera_allowed;
|
bool camera_allowed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -128,6 +130,7 @@ static void client_info_free(struct client_info *cinfo)
|
||||||
spa_list_for_each_safe(p, tp, &cinfo->async_pending, link)
|
spa_list_for_each_safe(p, tp, &cinfo->async_pending, link)
|
||||||
free_pending(p);
|
free_pending(p);
|
||||||
|
|
||||||
|
spa_hook_remove(&cinfo->client_listener);
|
||||||
spa_list_remove(&cinfo->link);
|
spa_list_remove(&cinfo->link);
|
||||||
free(cinfo);
|
free(cinfo);
|
||||||
}
|
}
|
||||||
|
|
@ -279,6 +282,7 @@ portal_response(DBusConnection *connection, DBusMessage *msg, void *user_data)
|
||||||
cinfo->camera_allowed = false;
|
cinfo->camera_allowed = false;
|
||||||
pw_log_debug("camera access not allowed");
|
pw_log_debug("camera access not allowed");
|
||||||
}
|
}
|
||||||
|
cinfo->checked = true;
|
||||||
pw_core_for_each_global(cinfo->impl->core, set_global_permissions, cinfo);
|
pw_core_for_each_global(cinfo->impl->core, set_global_permissions, cinfo);
|
||||||
|
|
||||||
free_pending(p);
|
free_pending(p);
|
||||||
|
|
@ -380,6 +384,32 @@ static void do_portal_check(struct client_info *cinfo)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void client_info_changed(void *data, struct pw_client_info *info)
|
||||||
|
{
|
||||||
|
struct client_info *cinfo = data;
|
||||||
|
const char *str;
|
||||||
|
|
||||||
|
if (info->props == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((str = spa_dict_lookup(info->props, "pipewire.access")) == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (strcmp(str, "flatpak") != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cinfo->checked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pw_log_debug("module %p: client %p set to flatpak access", cinfo->impl, cinfo->client);
|
||||||
|
do_portal_check(cinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct pw_client_events client_events = {
|
||||||
|
PW_VERSION_CLIENT_EVENTS,
|
||||||
|
.info_changed = client_info_changed
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
core_global_added(void *data, struct pw_global *global)
|
core_global_added(void *data, struct pw_global *global)
|
||||||
{
|
{
|
||||||
|
|
@ -390,6 +420,15 @@ core_global_added(void *data, struct pw_global *global)
|
||||||
if (pw_global_get_type(global) == impl->type->client) {
|
if (pw_global_get_type(global) == impl->type->client) {
|
||||||
struct pw_client *client = pw_global_get_object(global);
|
struct pw_client *client = pw_global_get_object(global);
|
||||||
|
|
||||||
|
/* clients are placed in a list and we do a portal check when needed */
|
||||||
|
cinfo = calloc(1, sizeof(struct client_info));
|
||||||
|
cinfo->impl = impl;
|
||||||
|
cinfo->client = client;
|
||||||
|
spa_list_init(&cinfo->async_pending);
|
||||||
|
pw_client_add_listener(client, &cinfo->client_listener, &client_events, cinfo);
|
||||||
|
|
||||||
|
spa_list_append(&impl->client_list, &cinfo->link);
|
||||||
|
|
||||||
res = check_sandboxed(client);
|
res = check_sandboxed(client);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
pw_log_debug("module %p: non sandboxed client %p", impl, client);
|
pw_log_debug("module %p: non sandboxed client %p", impl, client);
|
||||||
|
|
@ -404,15 +443,6 @@ core_global_added(void *data, struct pw_global *global)
|
||||||
pw_log_debug("module %p: sandboxed client %p added", impl, client);
|
pw_log_debug("module %p: sandboxed client %p added", impl, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sandboxed clients are placed in a list and we do a portal check */
|
|
||||||
cinfo = calloc(1, sizeof(struct client_info));
|
|
||||||
cinfo->impl = impl;
|
|
||||||
cinfo->client = client;
|
|
||||||
|
|
||||||
spa_list_init(&cinfo->async_pending);
|
|
||||||
|
|
||||||
spa_list_append(&impl->client_list, &cinfo->link);
|
|
||||||
|
|
||||||
do_portal_check(cinfo);
|
do_portal_check(cinfo);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue