Files
wireplumber/modules/module-client-permissions.c
George Kiagiadakis 753e708544 object-manager: refactor to be able to track locally created proxies
There are 3 kinds of WpProxy objects:
 * the ones that are created as a result of binding a global
   from the registry
 * the ones that are created as a result of calling into a remote
   factory (wp_node_new_from_factory, etc...)
 * the ones that are a local implementation of an object
   (WpImplNode, etc...) and are exported

Previously the object manager was only able to track the first kind.
With these changes we can now also have globals associated with
WpProxies that were created earlier (and caused the creation of the global).
This saves some resources and reduces round-trips (in case client
code wants to change properties of an object that is locally
implemented, it shouldn't need to do a round-trip through the server)
2020-02-14 17:12:23 +02:00

44 lines
1.2 KiB
C

/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#include <wp/wp.h>
#include <pipewire/pipewire.h>
static void
client_added (WpObjectManager * om, WpClient *client, gpointer data)
{
g_autoptr (WpProperties) properties = NULL;
const char *access;
guint32 id = wp_proxy_get_bound_id (WP_PROXY (client));
g_debug ("Client added: %d", id);
properties = wp_proxy_get_properties (WP_PROXY (client));
access = wp_properties_get (properties, PW_KEY_ACCESS);
if (!g_strcmp0 (access, "flatpak") || !g_strcmp0 (access, "restricted")) {
g_debug ("Granting full access to client %d", id);
wp_client_update_permissions (client, 1, -1, PW_PERM_RWX);
}
}
WP_PLUGIN_EXPORT void
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
{
WpObjectManager *om;
om = wp_object_manager_new ();
wp_object_manager_add_interest (om, WP_TYPE_CLIENT, NULL,
WP_PROXY_FEATURES_STANDARD);
g_signal_connect (om, "object-added", (GCallback) client_added, NULL);
wp_core_install_object_manager (core, om);
wp_module_set_destroy_callback (module, g_object_unref, om);
}