plugin: add name property
This commit is contained in:
@@ -18,12 +18,14 @@
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_MODULE,
|
||||
};
|
||||
|
||||
typedef struct _WpPluginPrivate WpPluginPrivate;
|
||||
struct _WpPluginPrivate
|
||||
{
|
||||
gchar *name;
|
||||
GWeakRef module;
|
||||
};
|
||||
|
||||
@@ -65,6 +67,7 @@ wp_plugin_finalize (GObject * object)
|
||||
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
|
||||
|
||||
g_weak_ref_clear (&priv->module);
|
||||
g_clear_pointer (&priv->name, g_free);
|
||||
|
||||
G_OBJECT_CLASS (wp_plugin_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -77,6 +80,10 @@ wp_plugin_set_property (GObject * object, guint property_id,
|
||||
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_NAME:
|
||||
g_clear_pointer (&priv->name, g_free);
|
||||
priv->name = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_MODULE:
|
||||
g_weak_ref_set (&priv->module, g_value_get_object (value));
|
||||
break;
|
||||
@@ -94,6 +101,9 @@ wp_plugin_get_property (GObject * object, guint property_id,
|
||||
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, priv->name);
|
||||
break;
|
||||
case PROP_MODULE:
|
||||
g_value_take_object (value, g_weak_ref_get (&priv->module));
|
||||
break;
|
||||
@@ -113,6 +123,16 @@ wp_plugin_class_init (WpPluginClass * klass)
|
||||
object_class->set_property = wp_plugin_set_property;
|
||||
object_class->get_property = wp_plugin_get_property;
|
||||
|
||||
/**
|
||||
* WpPlugin:name:
|
||||
* The name of this plugin.
|
||||
* Implementations should initialize this in the constructor.
|
||||
*/
|
||||
g_object_class_install_property (object_class, PROP_NAME,
|
||||
g_param_spec_string ("name", "name",
|
||||
"The name of this plugin", NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* WpPlugin:module:
|
||||
* The module that created this plugin.
|
||||
@@ -139,6 +159,21 @@ wp_plugin_register (WpPlugin * plugin)
|
||||
wp_registry_register_object (wp_core_get_registry (core), plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_plugin_get_name:
|
||||
* @self: the plugin
|
||||
*
|
||||
* Returns: the name of this plugin
|
||||
*/
|
||||
const gchar *
|
||||
wp_plugin_get_name (WpPlugin * self)
|
||||
{
|
||||
g_return_val_if_fail (WP_IS_PLUGIN (self), NULL);
|
||||
|
||||
WpPluginPrivate *priv = wp_plugin_get_instance_private (self);
|
||||
return priv->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_plugin_get_module:
|
||||
* @self: the plugin
|
||||
|
@@ -38,6 +38,9 @@ struct _WpPluginClass
|
||||
WP_API
|
||||
void wp_plugin_register (WpPlugin * plugin);
|
||||
|
||||
WP_API
|
||||
const gchar * wp_plugin_get_name (WpPlugin * self);
|
||||
|
||||
WP_API
|
||||
WpModule * wp_plugin_get_module (WpPlugin * self);
|
||||
|
||||
|
@@ -77,6 +77,7 @@ WP_PLUGIN_EXPORT void
|
||||
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
{
|
||||
wp_plugin_register (g_object_new (wp_client_permissions_get_type (),
|
||||
"name", "client-permissions",
|
||||
"module", module,
|
||||
NULL));
|
||||
}
|
||||
|
@@ -358,6 +358,7 @@ WpConfigPolicyContext *
|
||||
wp_config_policy_context_new (WpModule * module)
|
||||
{
|
||||
return g_object_new (wp_config_policy_context_get_type (),
|
||||
"name", "config-policy",
|
||||
"module", module,
|
||||
NULL);
|
||||
}
|
||||
|
@@ -240,6 +240,7 @@ WpConfigStaticObjectsContext *
|
||||
wp_config_static_objects_context_new (WpModule * module)
|
||||
{
|
||||
return g_object_new (wp_config_static_objects_context_get_type (),
|
||||
"name", "config-static-objects",
|
||||
"module", module,
|
||||
NULL);
|
||||
}
|
||||
|
@@ -344,6 +344,7 @@ wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
g_variant_lookup (args, "mode", "s", &mode);
|
||||
|
||||
wp_plugin_register (g_object_new (wp_device_activation_get_type (),
|
||||
"name", "device-activation",
|
||||
"module", module,
|
||||
"mode", mode,
|
||||
NULL));
|
||||
|
@@ -188,6 +188,7 @@ WP_PLUGIN_EXPORT void
|
||||
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
{
|
||||
wp_plugin_register (g_object_new (wp_endpoint_creation_get_type (),
|
||||
"name", "endpoint-creation",
|
||||
"module", module,
|
||||
NULL));
|
||||
}
|
||||
|
@@ -58,6 +58,7 @@ WP_PLUGIN_EXPORT void
|
||||
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
{
|
||||
wp_plugin_register (g_object_new (wp_metadata_plugin_get_type (),
|
||||
"name", "metadata",
|
||||
"module", module,
|
||||
NULL));
|
||||
}
|
||||
|
@@ -506,6 +506,7 @@ wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
/* Register all monitors */
|
||||
g_variant_iter_init (&iter, args);
|
||||
while (g_variant_iter_next (&iter, "{&sv}", &key, &value)) {
|
||||
g_autofree char *plugin_name = NULL;
|
||||
const gchar *factory = NULL;
|
||||
MonitorFlags flags = 0;
|
||||
|
||||
@@ -526,7 +527,9 @@ wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
}
|
||||
|
||||
/* Register */
|
||||
plugin_name = g_strdup_printf ("monitor-%s", factory);
|
||||
wp_plugin_register (g_object_new (wp_monitor_get_type (),
|
||||
"name", plugin_name,
|
||||
"module", module,
|
||||
"local-core", local_core,
|
||||
"factory", factory,
|
||||
|
@@ -132,6 +132,7 @@ WP_PLUGIN_EXPORT void
|
||||
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
{
|
||||
wp_plugin_register (g_object_new (wp_node_suspension_get_type (),
|
||||
"name", "node-suspension",
|
||||
"module", module,
|
||||
NULL));
|
||||
}
|
||||
|
@@ -258,6 +258,7 @@ WP_PLUGIN_EXPORT void
|
||||
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
{
|
||||
wp_plugin_register (g_object_new (wp_session_settings_get_type (),
|
||||
"name", "session-settings",
|
||||
"module", module,
|
||||
NULL));
|
||||
}
|
||||
|
Reference in New Issue
Block a user