proxy/plugin: hold a pointer to the core instead of the respective registry
This makes it more intuitive to get other attached interfaces from the core
This commit is contained in:
@@ -18,12 +18,12 @@ enum {
|
|||||||
PROP_LICENSE,
|
PROP_LICENSE,
|
||||||
PROP_VERSION,
|
PROP_VERSION,
|
||||||
PROP_ORIGIN,
|
PROP_ORIGIN,
|
||||||
PROP_REGISTRY,
|
PROP_CORE,
|
||||||
PROP_METADATA,
|
PROP_METADATA,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WpPluginRegistry *registry;
|
WpObject *core;
|
||||||
const WpPluginMetadata *metadata;
|
const WpPluginMetadata *metadata;
|
||||||
} WpPluginPrivate;
|
} WpPluginPrivate;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ wp_plugin_dispose (GObject * object)
|
|||||||
WpPlugin *plugin = WP_PLUGIN (object);
|
WpPlugin *plugin = WP_PLUGIN (object);
|
||||||
WpPluginPrivate *priv = wp_plugin_get_instance_private (plugin);
|
WpPluginPrivate *priv = wp_plugin_get_instance_private (plugin);
|
||||||
|
|
||||||
g_clear_object (&priv->registry);
|
g_clear_object (&priv->core);
|
||||||
|
|
||||||
G_OBJECT_CLASS (wp_plugin_parent_class)->dispose (object);
|
G_OBJECT_CLASS (wp_plugin_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@@ -53,8 +53,8 @@ wp_plugin_set_property (GObject * object, guint property_id,
|
|||||||
WpPluginPrivate *priv = wp_plugin_get_instance_private (plugin);
|
WpPluginPrivate *priv = wp_plugin_get_instance_private (plugin);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
case PROP_REGISTRY:
|
case PROP_CORE:
|
||||||
priv->registry = g_value_get_object (value);
|
priv->core = g_value_get_object (value);
|
||||||
break;
|
break;
|
||||||
case PROP_METADATA:
|
case PROP_METADATA:
|
||||||
priv->metadata = g_value_get_pointer (value);
|
priv->metadata = g_value_get_pointer (value);
|
||||||
@@ -94,8 +94,8 @@ wp_plugin_get_property (GObject * object, guint property_id, GValue * value,
|
|||||||
case PROP_ORIGIN:
|
case PROP_ORIGIN:
|
||||||
g_value_set_string (value, priv->metadata->origin);
|
g_value_set_string (value, priv->metadata->origin);
|
||||||
break;
|
break;
|
||||||
case PROP_REGISTRY:
|
case PROP_CORE:
|
||||||
g_value_set_object (value, priv->registry);
|
g_value_set_object (value, priv->core);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
@@ -106,6 +106,8 @@ wp_plugin_get_property (GObject * object, guint property_id, GValue * value,
|
|||||||
static gboolean
|
static gboolean
|
||||||
default_handle_pw_proxy (WpPlugin * self, WpProxy * proxy)
|
default_handle_pw_proxy (WpPlugin * self, WpProxy * proxy)
|
||||||
{
|
{
|
||||||
|
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
|
||||||
|
|
||||||
switch (wp_proxy_get_spa_type (proxy)) {
|
switch (wp_proxy_get_spa_type (proxy)) {
|
||||||
case PW_TYPE_INTERFACE_Device:
|
case PW_TYPE_INTERFACE_Device:
|
||||||
return wp_plugin_handle_pw_device (self, proxy);
|
return wp_plugin_handle_pw_device (self, proxy);
|
||||||
@@ -116,8 +118,9 @@ default_handle_pw_proxy (WpPlugin * self, WpProxy * proxy)
|
|||||||
case PW_TYPE_INTERFACE_Node:
|
case PW_TYPE_INTERFACE_Node:
|
||||||
{
|
{
|
||||||
g_autoptr (WpProxy) parent;
|
g_autoptr (WpProxy) parent;
|
||||||
g_autoptr (WpProxyRegistry) reg = wp_proxy_get_registry (proxy);
|
g_autoptr (WpProxyRegistry) reg;
|
||||||
|
|
||||||
|
reg = wp_object_get_interface (priv->core, WP_TYPE_PROXY_REGISTRY);
|
||||||
parent = wp_proxy_registry_get_proxy (reg, wp_proxy_get_parent_id (proxy));
|
parent = wp_proxy_registry_get_proxy (reg, wp_proxy_get_parent_id (proxy));
|
||||||
|
|
||||||
switch (wp_proxy_get_spa_type (parent)) {
|
switch (wp_proxy_get_spa_type (parent)) {
|
||||||
@@ -174,10 +177,9 @@ wp_plugin_class_init (WpPluginClass * klass)
|
|||||||
g_param_spec_string ("origin", "Origin", "The plugin's origin", NULL,
|
g_param_spec_string ("origin", "Origin", "The plugin's origin", NULL,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_REGISTRY,
|
g_object_class_install_property (object_class, PROP_CORE,
|
||||||
g_param_spec_object ("registry", "Registry",
|
g_param_spec_object ("core", "Core", "The WpCore that owns this plugin",
|
||||||
"The WpPluginRegistry that owns this plugin",
|
WP_TYPE_OBJECT,
|
||||||
wp_plugin_registry_get_type (),
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_METADATA,
|
g_object_class_install_property (object_class, PROP_METADATA,
|
||||||
@@ -259,17 +261,16 @@ wp_plugin_provide_interfaces (WpPlugin * self, WpObject * object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wp_plugin_get_registry: (method)
|
* wp_plugin_get_core: (method)
|
||||||
* @self: the plugin
|
* @self: the plugin
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): the registry where this plugin is registered
|
* Returns: (transfer full): the core where this plugin is registered
|
||||||
*/
|
*/
|
||||||
WpPluginRegistry *
|
WpObject *
|
||||||
wp_plugin_get_registry (WpPlugin * self)
|
wp_plugin_get_core (WpPlugin * self)
|
||||||
{
|
{
|
||||||
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
|
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
|
||||||
g_object_ref (priv->registry);
|
return g_object_ref (priv->core);
|
||||||
return priv->registry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -173,7 +173,7 @@ gboolean wp_plugin_handle_pw_client (WpPlugin * self, WpProxy * proxy);
|
|||||||
gboolean wp_plugin_handle_pw_client_node (WpPlugin * self, WpProxy * proxy);
|
gboolean wp_plugin_handle_pw_client_node (WpPlugin * self, WpProxy * proxy);
|
||||||
gboolean wp_plugin_provide_interfaces (WpPlugin * self, WpObject * object);
|
gboolean wp_plugin_provide_interfaces (WpPlugin * self, WpObject * object);
|
||||||
|
|
||||||
WpPluginRegistry * wp_plugin_get_registry (WpPlugin * self);
|
WpObject * wp_plugin_get_core (WpPlugin * self);
|
||||||
const WpPluginMetadata * wp_plugin_get_metadata (WpPlugin * self);
|
const WpPluginMetadata * wp_plugin_get_metadata (WpPlugin * self);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ struct _WpProxy
|
|||||||
{
|
{
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
WpProxyRegistry *registry;
|
WpObject *core;
|
||||||
|
|
||||||
struct pw_proxy *proxy;
|
struct pw_proxy *proxy;
|
||||||
guint32 id;
|
guint32 id;
|
||||||
@@ -38,7 +38,7 @@ enum {
|
|||||||
PROP_SPA_TYPE,
|
PROP_SPA_TYPE,
|
||||||
PROP_SPA_TYPE_STRING,
|
PROP_SPA_TYPE_STRING,
|
||||||
PROP_INITIAL_PROPERTIES,
|
PROP_INITIAL_PROPERTIES,
|
||||||
PROP_REGISTRY,
|
PROP_CORE,
|
||||||
PROP_PROXY,
|
PROP_PROXY,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -242,6 +242,7 @@ static void
|
|||||||
wp_proxy_constructed (GObject * object)
|
wp_proxy_constructed (GObject * object)
|
||||||
{
|
{
|
||||||
WpProxy *self = WP_PROXY (object);
|
WpProxy *self = WP_PROXY (object);
|
||||||
|
g_autoptr (WpProxyRegistry) pr = NULL;
|
||||||
GHashTable *properties;
|
GHashTable *properties;
|
||||||
struct pw_registry_proxy *reg_proxy;
|
struct pw_registry_proxy *reg_proxy;
|
||||||
const void *events = NULL;
|
const void *events = NULL;
|
||||||
@@ -277,7 +278,8 @@ wp_proxy_constructed (GObject * object)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_proxy = wp_proxy_registry_get_pw_registry_proxy (self->registry);
|
pr = wp_object_get_interface (self->core, WP_TYPE_PROXY_REGISTRY);
|
||||||
|
reg_proxy = wp_proxy_registry_get_pw_registry_proxy (pr);
|
||||||
g_warn_if_fail (reg_proxy != NULL);
|
g_warn_if_fail (reg_proxy != NULL);
|
||||||
|
|
||||||
self->proxy = pw_registry_proxy_bind (reg_proxy, self->id, self->type, ver, 0);
|
self->proxy = pw_registry_proxy_bind (reg_proxy, self->id, self->type, ver, 0);
|
||||||
@@ -308,7 +310,7 @@ wp_proxy_finalize (GObject * object)
|
|||||||
WpProxy *self = WP_PROXY (object);
|
WpProxy *self = WP_PROXY (object);
|
||||||
|
|
||||||
g_hash_table_unref (self->properties);
|
g_hash_table_unref (self->properties);
|
||||||
g_clear_object (&self->registry);
|
g_clear_object (&self->core);
|
||||||
|
|
||||||
G_OBJECT_CLASS (wp_proxy_parent_class)->finalize (object);
|
G_OBJECT_CLASS (wp_proxy_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@@ -332,8 +334,8 @@ wp_proxy_set_property (GObject * object, guint property_id,
|
|||||||
case PROP_INITIAL_PROPERTIES:
|
case PROP_INITIAL_PROPERTIES:
|
||||||
self->initial_properties = g_value_get_pointer (value);
|
self->initial_properties = g_value_get_pointer (value);
|
||||||
break;
|
break;
|
||||||
case PROP_REGISTRY:
|
case PROP_CORE:
|
||||||
self->registry = g_value_get_object (value);
|
self->core = g_value_get_object (value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
@@ -360,8 +362,8 @@ wp_proxy_get_property (GObject * object, guint property_id, GValue * value,
|
|||||||
case PROP_SPA_TYPE_STRING:
|
case PROP_SPA_TYPE_STRING:
|
||||||
g_value_set_string (value, self->type_string);
|
g_value_set_string (value, self->type_string);
|
||||||
break;
|
break;
|
||||||
case PROP_REGISTRY:
|
case PROP_CORE:
|
||||||
g_value_set_object (value, self->registry);
|
g_value_set_object (value, self->core);
|
||||||
break;
|
break;
|
||||||
case PROP_PROXY:
|
case PROP_PROXY:
|
||||||
g_value_set_pointer (value, self->proxy);
|
g_value_set_pointer (value, self->proxy);
|
||||||
@@ -407,10 +409,9 @@ wp_proxy_class_init (WpProxyClass * klass)
|
|||||||
"The initial set of properties of the proxy",
|
"The initial set of properties of the proxy",
|
||||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_REGISTRY,
|
g_object_class_install_property (object_class, PROP_CORE,
|
||||||
g_param_spec_object ("registry", "registry",
|
g_param_spec_object ("core", "core", "The core that owns this proxy",
|
||||||
"The WpProxyRegistry that owns this proxy",
|
WP_TYPE_OBJECT,
|
||||||
wp_proxy_registry_get_type (),
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_PROXY,
|
g_object_class_install_property (object_class, PROP_PROXY,
|
||||||
@@ -496,16 +497,16 @@ wp_proxy_get_spa_type_string (WpProxy * self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wp_proxy_get_registry: (method)
|
* wp_proxy_get_core: (method)
|
||||||
* @self: the proxy
|
* @self: the proxy
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): the #WpProxyRegistry
|
* Returns: (transfer full): the core #WpObject
|
||||||
*/
|
*/
|
||||||
WpProxyRegistry *
|
WpObject *
|
||||||
wp_proxy_get_registry (WpProxy *self)
|
wp_proxy_get_core (WpProxy *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (WP_IS_PROXY (self), NULL);
|
g_return_val_if_fail (WP_IS_PROXY (self), NULL);
|
||||||
return g_object_ref (self->registry);
|
return g_object_ref (self->core);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -24,7 +24,7 @@ guint32 wp_proxy_get_parent_id (WpProxy * self);
|
|||||||
guint32 wp_proxy_get_spa_type (WpProxy * self);
|
guint32 wp_proxy_get_spa_type (WpProxy * self);
|
||||||
const gchar * wp_proxy_get_spa_type_string (WpProxy * self);
|
const gchar * wp_proxy_get_spa_type_string (WpProxy * self);
|
||||||
|
|
||||||
WpProxyRegistry * wp_proxy_get_registry (WpProxy *self);
|
WpObject * wp_proxy_get_core (WpProxy *self);
|
||||||
|
|
||||||
gboolean wp_proxy_is_destroyed (WpProxy * self);
|
gboolean wp_proxy_is_destroyed (WpProxy * self);
|
||||||
struct pw_proxy * wp_proxy_get_pw_proxy (WpProxy * self);
|
struct pw_proxy * wp_proxy_get_pw_proxy (WpProxy * self);
|
||||||
|
@@ -139,8 +139,11 @@ wp_plugin_registry_impl_unload (WpPluginRegistryImpl * self)
|
|||||||
static inline void
|
static inline void
|
||||||
make_plugin (WpPluginRegistryImpl * self, PluginData * plugin_data)
|
make_plugin (WpPluginRegistryImpl * self, PluginData * plugin_data)
|
||||||
{
|
{
|
||||||
|
g_autoptr (WpObject) core =
|
||||||
|
wp_interface_impl_get_object (WP_INTERFACE_IMPL (self));
|
||||||
|
|
||||||
plugin_data->instance = g_object_new (plugin_data->gtype,
|
plugin_data->instance = g_object_new (plugin_data->gtype,
|
||||||
"registry", self, "metadata", plugin_data->metadata, NULL);
|
"core", core, "metadata", plugin_data->metadata, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@@ -89,12 +89,15 @@ registry_global (void * data, uint32_t id, uint32_t parent_id,
|
|||||||
WpProxyRegistryImpl *self = WP_PROXY_REGISTRY_IMPL (data);
|
WpProxyRegistryImpl *self = WP_PROXY_REGISTRY_IMPL (data);
|
||||||
WpProxy *proxy;
|
WpProxy *proxy;
|
||||||
g_autoptr (WpPluginRegistry) plugin_registry = NULL;
|
g_autoptr (WpPluginRegistry) plugin_registry = NULL;
|
||||||
|
g_autoptr (WpObject) core =
|
||||||
|
wp_interface_impl_get_object (WP_INTERFACE_IMPL (self));
|
||||||
|
|
||||||
proxy = g_object_new (WP_TYPE_PROXY,
|
proxy = g_object_new (WP_TYPE_PROXY,
|
||||||
"id", id,
|
"id", id,
|
||||||
"parent-id", parent_id,
|
"parent-id", parent_id,
|
||||||
"spa-type", type,
|
"spa-type", type,
|
||||||
"initial-properties", props,
|
"initial-properties", props,
|
||||||
|
"core", core,
|
||||||
NULL);
|
NULL);
|
||||||
map_insert (&self->globals, id, proxy);
|
map_insert (&self->globals, id, proxy);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user