m-settings: trigger init of WpSettings object

After the creation of metadata with config data, m-settings will also need to
trigger the init of WpSettings Object/API. Earlier this was done in main.c as
part of init transition but the logic there is much more generalized now and so
it has been moved here.
This commit is contained in:
Ashok Sidipotu 2022-10-27 15:12:45 +05:30 committed by Julian Bouzas
parent d9d3a49f5a
commit c0905c233f
2 changed files with 22 additions and 9 deletions

View file

@ -154,6 +154,22 @@ is_persistent_settings_enabled (WpProperties *settings) {
return res;
}
static void
on_settings_ready (WpSettings *s, GAsyncResult *res, gpointer data)
{
WpSettingsPlugin *self = WP_SETTINGS_PLUGIN (data);
g_autoptr (GError) error = NULL;
wp_info_object (self, "wpsettings object ready");
if (!wp_object_activate_finish (WP_OBJECT (s), res, &error)) {
wp_debug_object (self, "wpsettings activation failed: %s", error->message);
return;
}
wp_object_update_features (WP_OBJECT (self), WP_PLUGIN_FEATURE_ENABLED, 0);
}
static void
on_metadata_activated (WpMetadata * m, GAsyncResult * res, gpointer user_data)
{
@ -212,7 +228,12 @@ on_metadata_activated (WpMetadata * m, GAsyncResult * res, gpointer user_data)
g_signal_connect_object (m, "changed", G_CALLBACK (on_metadata_changed),
self, 0);
wp_object_update_features (WP_OBJECT (self), WP_PLUGIN_FEATURE_ENABLED, 0);
g_autoptr (WpSettings) settings = wp_settings_get_instance (core,
self->metadata_name);
wp_object_activate (WP_OBJECT (settings), WP_OBJECT_FEATURES_ALL, NULL,
(GAsyncReadyCallback) on_settings_ready, self);
}
static void

View file

@ -50,8 +50,6 @@ script_run (ScriptRunnerFixture *f, gconstpointer data)
g_clear_object (&plugin);
{
g_autoptr (WpSettings) settings = NULL;
wp_core_load_component (f->base.core,
"libwireplumber-module-settings", "module",
g_variant_new_string (METADATA_NAME), &error);
@ -61,12 +59,6 @@ script_run (ScriptRunnerFixture *f, gconstpointer data)
wp_object_activate (WP_OBJECT (plugin), WP_PLUGIN_FEATURE_ENABLED,
NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f);
g_main_loop_run (f->base.loop);
settings = wp_settings_get_instance (f->base.core, METADATA_NAME);
wp_object_activate (WP_OBJECT (settings), WP_PLUGIN_FEATURE_ENABLED,
NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f);
g_main_loop_run (f->base.loop);
}
wp_core_load_component (f->base.core, (const gchar *) data, "script/lua",
NULL, &error);