mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-09 03:58:05 +02:00
permission-manager: Update permissions when a matched object has been collected or dropped
This is needed because the 'collection-name' gobject property changes if the object has been collected or dropped.
This commit is contained in:
parent
a713270769
commit
e78a28f5b6
1 changed files with 23 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "private/permission-manager.h"
|
||||
#include "permission-manager.h"
|
||||
#include "collection-manager.h"
|
||||
#include "proxy-interfaces.h"
|
||||
#include "object-manager.h"
|
||||
#include "json-utils.h"
|
||||
|
|
@ -80,6 +81,7 @@ struct _WpPermissionManager
|
|||
GHashTable *matches;
|
||||
|
||||
WpObjectManager *om;
|
||||
WpCollectionManager *cm;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (WpPermissionManager, wp_permission_manager, WP_TYPE_OBJECT)
|
||||
|
|
@ -366,6 +368,16 @@ update_permissions (WpPermissionManager *self)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_global_collected_or_dropped (WpCollectionManager *cm, WpGlobalProxy *global,
|
||||
const gchar *collection_name, gpointer *d)
|
||||
{
|
||||
WpPermissionManager * self = WP_PERMISSION_MANAGER (d);
|
||||
|
||||
if (has_object_match (self, global))
|
||||
update_permissions (self);
|
||||
}
|
||||
|
||||
static void
|
||||
on_object_added_or_removed (WpObjectManager *om, WpGlobalProxy *object,
|
||||
gpointer d)
|
||||
|
|
@ -395,6 +407,15 @@ wp_permission_manager_activate_execute_step (WpObject * object,
|
|||
|
||||
switch (step) {
|
||||
case STEP_LOAD: {
|
||||
/* Get the collection manager if any */
|
||||
self->cm = wp_collection_manager_find (core, NULL);
|
||||
if (self->cm) {
|
||||
g_signal_connect_object (self->cm, "global-collected",
|
||||
G_CALLBACK (on_global_collected_or_dropped), self, 0);
|
||||
g_signal_connect_object (self->cm, "global-dropped",
|
||||
G_CALLBACK (on_global_collected_or_dropped), self, 0);
|
||||
}
|
||||
|
||||
/* Install object manager */
|
||||
g_clear_object (&self->om);
|
||||
self->om = wp_object_manager_new ();
|
||||
|
|
@ -424,6 +445,7 @@ wp_permission_manager_deactivate (WpObject * object, WpObjectFeatures features)
|
|||
WpPermissionManager *self = WP_PERMISSION_MANAGER (object);
|
||||
|
||||
g_clear_object (&self->om);
|
||||
g_clear_object (&self->cm);
|
||||
|
||||
wp_object_update_features (WP_OBJECT (self), 0, WP_OBJECT_FEATURES_ALL);
|
||||
}
|
||||
|
|
@ -437,6 +459,7 @@ wp_permission_manager_finalize (GObject * object)
|
|||
g_clear_pointer (&self->matches, g_hash_table_unref);
|
||||
|
||||
g_clear_object (&self->om);
|
||||
g_clear_object (&self->cm);
|
||||
|
||||
G_OBJECT_CLASS (wp_permission_manager_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue