Skip to content
Snippets Groups Projects
Commit 4fcdb931 authored by George Kiagiadakis's avatar George Kiagiadakis
Browse files

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
parent ede602a0
No related branches found
No related tags found
No related merge requests found
......@@ -18,12 +18,12 @@ enum {
PROP_LICENSE,
PROP_VERSION,
PROP_ORIGIN,
PROP_REGISTRY,
PROP_CORE,
PROP_METADATA,
};
typedef struct {
WpPluginRegistry *registry;
WpObject *core;
const WpPluginMetadata *metadata;
} WpPluginPrivate;
......@@ -40,7 +40,7 @@ wp_plugin_dispose (GObject * object)
WpPlugin *plugin = WP_PLUGIN (object);
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);
}
......@@ -53,8 +53,8 @@ wp_plugin_set_property (GObject * object, guint property_id,
WpPluginPrivate *priv = wp_plugin_get_instance_private (plugin);
switch (property_id) {
case PROP_REGISTRY:
priv->registry = g_value_get_object (value);
case PROP_CORE:
priv->core = g_value_get_object (value);
break;
case PROP_METADATA:
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:
g_value_set_string (value, priv->metadata->origin);
break;
case PROP_REGISTRY:
g_value_set_object (value, priv->registry);
case PROP_CORE:
g_value_set_object (value, priv->core);
break;
default:
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
default_handle_pw_proxy (WpPlugin * self, WpProxy * proxy)
{
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
switch (wp_proxy_get_spa_type (proxy)) {
case PW_TYPE_INTERFACE_Device:
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:
{
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));
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_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_REGISTRY,
g_param_spec_object ("registry", "Registry",
"The WpPluginRegistry that owns this plugin",
wp_plugin_registry_get_type (),
g_object_class_install_property (object_class, PROP_CORE,
g_param_spec_object ("core", "Core", "The WpCore that owns this plugin",
WP_TYPE_OBJECT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
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
*
* Returns: (transfer full): the registry where this plugin is registered
* Returns: (transfer full): the core where this plugin is registered
*/
WpPluginRegistry *
wp_plugin_get_registry (WpPlugin * self)
WpObject *
wp_plugin_get_core (WpPlugin * self)
{
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
g_object_ref (priv->registry);
return priv->registry;
return g_object_ref (priv->core);
}
/**
......
......@@ -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_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);
......
......@@ -14,7 +14,7 @@ struct _WpProxy
{
GObject parent;
WpProxyRegistry *registry;
WpObject *core;
struct pw_proxy *proxy;
guint32 id;
......@@ -38,7 +38,7 @@ enum {
PROP_SPA_TYPE,
PROP_SPA_TYPE_STRING,
PROP_INITIAL_PROPERTIES,
PROP_REGISTRY,
PROP_CORE,
PROP_PROXY,
};
......@@ -242,6 +242,7 @@ static void
wp_proxy_constructed (GObject * object)
{
WpProxy *self = WP_PROXY (object);
g_autoptr (WpProxyRegistry) pr = NULL;
GHashTable *properties;
struct pw_registry_proxy *reg_proxy;
const void *events = NULL;
......@@ -277,7 +278,8 @@ wp_proxy_constructed (GObject * object)
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);
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);
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);
}
......@@ -332,8 +334,8 @@ wp_proxy_set_property (GObject * object, guint property_id,
case PROP_INITIAL_PROPERTIES:
self->initial_properties = g_value_get_pointer (value);
break;
case PROP_REGISTRY:
self->registry = g_value_get_object (value);
case PROP_CORE:
self->core = g_value_get_object (value);
break;
default:
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:
g_value_set_string (value, self->type_string);
break;
case PROP_REGISTRY:
g_value_set_object (value, self->registry);
case PROP_CORE:
g_value_set_object (value, self->core);
break;
case PROP_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",
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_REGISTRY,
g_param_spec_object ("registry", "registry",
"The WpProxyRegistry that owns this proxy",
wp_proxy_registry_get_type (),
g_object_class_install_property (object_class, PROP_CORE,
g_param_spec_object ("core", "core", "The core that owns this proxy",
WP_TYPE_OBJECT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
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
*
* Returns: (transfer full): the #WpProxyRegistry
* Returns: (transfer full): the core #WpObject
*/
WpProxyRegistry *
wp_proxy_get_registry (WpProxy *self)
WpObject *
wp_proxy_get_core (WpProxy *self)
{
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);
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);
struct pw_proxy * wp_proxy_get_pw_proxy (WpProxy * self);
......
......@@ -139,8 +139,11 @@ wp_plugin_registry_impl_unload (WpPluginRegistryImpl * self)
static inline void
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,
"registry", self, "metadata", plugin_data->metadata, NULL);
"core", core, "metadata", plugin_data->metadata, NULL);
}
gboolean
......
......@@ -89,12 +89,15 @@ registry_global (void * data, uint32_t id, uint32_t parent_id,
WpProxyRegistryImpl *self = WP_PROXY_REGISTRY_IMPL (data);
WpProxy *proxy;
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,
"id", id,
"parent-id", parent_id,
"spa-type", type,
"initial-properties", props,
"core", core,
NULL);
map_insert (&self->globals, id, proxy);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment