m-reserve-device: use WpDbus API

This commit is contained in:
Julian Bouzas 2022-05-06 09:57:37 -04:00
parent 69b559399d
commit 46e7c5c144
6 changed files with 142 additions and 180 deletions

View file

@ -10,8 +10,6 @@
#include "reserve-device.h"
#include "reserve-device-enums.h"
static void setup_connection (WpReserveDevicePlugin *self);
G_DEFINE_TYPE (WpReserveDevicePlugin, wp_reserve_device_plugin, WP_TYPE_PLUGIN)
enum
@ -19,6 +17,7 @@ enum
ACTION_CREATE_RESERVATION,
ACTION_DESTROY_RESERVATION,
ACTION_GET_RESERVATION,
ACTION_GET_DBUS,
LAST_SIGNAL
};
@ -38,12 +37,60 @@ rd_unref (gpointer data)
g_object_unref (rd);
}
static void
clear_reservation (WpReserveDevicePlugin *self)
{
g_hash_table_remove_all (self->reserve_devices);
g_clear_object (&self->manager);
}
static void
on_dbus_state_changed (GObject * obj, GParamSpec * spec,
WpReserveDevicePlugin *self)
{
WpDBusState state = wp_dbus_get_state (self->dbus);
switch (state) {
case WP_DBUS_STATE_CONNECTED: {
g_autoptr (GDBusConnection) conn = NULL;
conn = wp_dbus_get_connection (self->dbus);
g_return_if_fail (conn);
self->manager = g_dbus_object_manager_server_new (
FDO_RESERVE_DEVICE1_PATH);
g_dbus_object_manager_server_set_connection (self->manager, conn);
break;
}
case WP_DBUS_STATE_CONNECTING:
case WP_DBUS_STATE_CLOSED:
clear_reservation (self);
break;
default:
break;
}
}
static void
wp_reserve_device_plugin_init (WpReserveDevicePlugin * self)
{
self->cancellable = g_cancellable_new ();
}
static void
wp_reserve_device_plugin_constructed (GObject *object)
{
WpReserveDevicePlugin *self = WP_RESERVE_DEVICE_PLUGIN (object);
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self));
self->reserve_devices = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, rd_unref);
self->dbus = wp_dbus_get_instance (core, G_BUS_TYPE_SESSION);
g_signal_connect_object (self->dbus, "notify::state",
G_CALLBACK (on_dbus_state_changed), self, 0);
G_OBJECT_CLASS (wp_reserve_device_plugin_parent_class)->constructed (object);
}
static void
@ -52,126 +99,23 @@ wp_reserve_device_plugin_finalize (GObject * object)
WpReserveDevicePlugin *self = WP_RESERVE_DEVICE_PLUGIN (object);
g_clear_pointer (&self->reserve_devices, g_hash_table_unref);
g_clear_object (&self->cancellable);
g_clear_object (&self->dbus);
G_OBJECT_CLASS (wp_reserve_device_plugin_parent_class)->finalize (object);
}
static void
clear_connection (WpReserveDevicePlugin *self)
on_dbus_activated (GObject * obj, GAsyncResult * res, gpointer user_data)
{
g_hash_table_remove_all (self->reserve_devices);
g_clear_object (&self->manager);
g_clear_object (&self->connection);
if (self->state != WP_DBUS_CONNECTION_STATE_CLOSED) {
self->state = WP_DBUS_CONNECTION_STATE_CLOSED;
g_object_notify (G_OBJECT (self), "state");
}
}
static gboolean
do_connect (WpReserveDevicePlugin *self, GAsyncReadyCallback callback,
gpointer data, GError **error)
{
g_autofree gchar *address = NULL;
address = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SESSION, NULL, error);
if (!address) {
g_prefix_error (error, "Error acquiring session bus address: ");
return FALSE;
}
wp_debug_object (self, "Connecting to bus: %s", address);
self->state = WP_DBUS_CONNECTION_STATE_CONNECTING;
g_object_notify (G_OBJECT (self), "state");
g_dbus_connection_new_for_address (address,
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
NULL, self->cancellable, callback, data);
return TRUE;
}
static void
on_reconnect_got_bus (GObject * obj, GAsyncResult * res, gpointer data)
{
WpReserveDevicePlugin *self = WP_RESERVE_DEVICE_PLUGIN (data);
WpTransition * transition = WP_TRANSITION (user_data);
WpReserveDevicePlugin * self = wp_transition_get_source_object (transition);
g_autoptr (GError) error = NULL;
self->connection = g_dbus_connection_new_for_address_finish (res, &error);
if (!self->connection) {
clear_connection (self);
wp_info_object (self, "Could not reconnect to session bus: %s",
error->message);
return;
}
wp_debug_object (self, "Reconnected to bus");
setup_connection (self);
}
static gboolean
idle_connect (WpReserveDevicePlugin * self)
{
g_autoptr (GError) error = NULL;
if (!do_connect (self, on_reconnect_got_bus, self, &error))
wp_info_object (self, "Cannot reconnect: %s", error->message);
return G_SOURCE_REMOVE;
}
static void
on_connection_closed (GDBusConnection *connection,
gboolean remote_peer_vanished, GError *error, gpointer data)
{
WpReserveDevicePlugin *self = WP_RESERVE_DEVICE_PLUGIN (data);
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self));
wp_info_object (self, "D-Bus connection closed: %s", error->message);
clear_connection (self);
/* try to reconnect on idle if connection was closed */
if (core)
wp_core_idle_add_closure (core, NULL, g_cclosure_new_object (
G_CALLBACK (idle_connect), G_OBJECT (self)));
}
static void
setup_connection (WpReserveDevicePlugin *self)
{
g_signal_connect_object (self->connection, "closed",
G_CALLBACK (on_connection_closed), self, 0);
g_dbus_connection_set_exit_on_close (self->connection, FALSE);
self->manager = g_dbus_object_manager_server_new (FDO_RESERVE_DEVICE1_PATH);
g_dbus_object_manager_server_set_connection (self->manager, self->connection);
self->state = WP_DBUS_CONNECTION_STATE_CONNECTED;
g_object_notify (G_OBJECT (self), "state");
}
static void
on_enable_got_bus (GObject * obj, GAsyncResult * res, gpointer data)
{
WpTransition *transition = WP_TRANSITION (data);
WpReserveDevicePlugin *self = wp_transition_get_source_object (transition);
g_autoptr (GError) error = NULL;
self->connection = g_dbus_connection_new_for_address_finish (res, &error);
if (!self->connection) {
clear_connection (self);
g_prefix_error (&error, "Failed to connect to session bus: ");
if (!wp_object_activate_finish (WP_OBJECT (obj), res, &error)) {
wp_transition_return_error (transition, g_steal_pointer (&error));
return;
}
wp_debug_object (self, "Connected to bus");
setup_connection (self);
wp_object_update_features (WP_OBJECT (self), WP_PLUGIN_FEATURE_ENABLED, 0);
}
@ -179,14 +123,11 @@ static void
wp_reserve_device_plugin_enable (WpPlugin * plugin, WpTransition * transition)
{
WpReserveDevicePlugin *self = WP_RESERVE_DEVICE_PLUGIN (plugin);
g_autoptr (GError) error = NULL;
g_return_if_fail (self->state == WP_DBUS_CONNECTION_STATE_CLOSED);
if (!do_connect (self, on_enable_got_bus, transition, &error)) {
wp_transition_return_error (transition, g_steal_pointer (&error));
return;
}
/* make sure dbus always activated */
g_return_if_fail (self->dbus);
wp_object_activate (WP_OBJECT (self->dbus), WP_OBJECT_FEATURES_ALL, NULL,
(GAsyncReadyCallback) on_dbus_activated, transition);
}
static void
@ -194,10 +135,7 @@ wp_reserve_device_plugin_disable (WpPlugin * plugin)
{
WpReserveDevicePlugin *self = WP_RESERVE_DEVICE_PLUGIN (plugin);
g_cancellable_cancel (self->cancellable);
clear_connection (self);
g_clear_object (&self->cancellable);
self->cancellable = g_cancellable_new ();
clear_reservation (self);
wp_object_update_features (WP_OBJECT (self), 0, WP_PLUGIN_FEATURE_ENABLED);
}
@ -207,7 +145,8 @@ wp_reserve_device_plugin_create_reservation (WpReserveDevicePlugin *self,
const gchar *name, const gchar *app_name, const gchar *app_dev_name,
gint priority)
{
if (self->state != WP_DBUS_CONNECTION_STATE_CONNECTED) {
WpDBusState state = wp_dbus_get_state (self->dbus);
if (state != WP_DBUS_STATE_CONNECTED) {
wp_message_object (self, "not connected to D-Bus");
return NULL;
}
@ -230,7 +169,8 @@ static void
wp_reserve_device_plugin_destroy_reservation (WpReserveDevicePlugin *self,
const gchar *name)
{
if (self->state != WP_DBUS_CONNECTION_STATE_CONNECTED) {
WpDBusState state = wp_dbus_get_state (self->dbus);
if (state != WP_DBUS_STATE_CONNECTED) {
wp_message_object (self, "not connected to D-Bus");
return;
}
@ -241,7 +181,8 @@ static gpointer
wp_reserve_device_plugin_get_reservation (WpReserveDevicePlugin *self,
const gchar *name)
{
if (self->state != WP_DBUS_CONNECTION_STATE_CONNECTED) {
WpDBusState state = wp_dbus_get_state (self->dbus);
if (state != WP_DBUS_STATE_CONNECTED) {
wp_message_object (self, "not connected to D-Bus");
return NULL;
}
@ -250,20 +191,10 @@ wp_reserve_device_plugin_get_reservation (WpReserveDevicePlugin *self,
return rd ? g_object_ref (rd) : NULL;
}
static void
wp_reserve_device_plugin_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
static gpointer
wp_reserve_device_plugin_get_dbus (WpReserveDevicePlugin *self)
{
WpReserveDevicePlugin *self = WP_RESERVE_DEVICE_PLUGIN (object);
switch (property_id) {
case PROP_STATE:
g_value_set_enum (value, self->state);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
return self->dbus ? g_object_ref (self->dbus) : NULL;
}
static void
@ -272,17 +203,12 @@ wp_reserve_device_plugin_class_init (WpReserveDevicePluginClass * klass)
GObjectClass *object_class = (GObjectClass *) klass;
WpPluginClass *plugin_class = (WpPluginClass *) klass;
object_class->constructed = wp_reserve_device_plugin_constructed;
object_class->finalize = wp_reserve_device_plugin_finalize;
object_class->get_property = wp_reserve_device_plugin_get_property;
plugin_class->enable = wp_reserve_device_plugin_enable;
plugin_class->disable = wp_reserve_device_plugin_disable;
g_object_class_install_property (object_class, PROP_STATE,
g_param_spec_enum ("state", "state", "The state",
WP_TYPE_DBUS_CONNECTION_STATE, WP_DBUS_CONNECTION_STATE_CLOSED,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* WpReserveDevicePlugin::create-reservation:
*
@ -330,6 +256,18 @@ wp_reserve_device_plugin_class_init (WpReserveDevicePluginClass * klass)
NULL, NULL, NULL,
G_TYPE_OBJECT, 1, G_TYPE_STRING);
/**
* WpReserveDevicePlugin::get-dbus:
*
* Returns: (transfer full): the dbus object
*/
signals[ACTION_GET_DBUS] = g_signal_new_class_handler (
"get-dbus", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
(GCallback) wp_reserve_device_plugin_get_dbus,
NULL, NULL, NULL,
G_TYPE_OBJECT, 0);
}
WP_PLUGIN_EXPORT gboolean

View file

@ -29,11 +29,8 @@ struct _WpReserveDevicePlugin
{
WpPlugin parent;
WpDBusConnectionState state;
WpDbus *dbus;
GHashTable *reserve_devices;
GCancellable *cancellable;
GDBusConnection *connection;
GDBusObjectManagerServer *manager;
};

View file

@ -76,7 +76,8 @@ update_owner_app_name (WpReserveDevice *self)
if (self->state == WP_RESERVE_DEVICE_STATE_BUSY && !self->owner_app_name) {
/* create proxy */
g_autoptr (WpReserveDevicePlugin) plugin = g_weak_ref_get (&self->plugin);
wp_org_freedesktop_reserve_device1_proxy_new (plugin->connection,
g_autoptr (GDBusConnection) conn = wp_dbus_get_connection (plugin->dbus);
wp_org_freedesktop_reserve_device1_proxy_new (conn,
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
self->service_name, self->object_path, NULL,
@ -123,6 +124,7 @@ wp_reserve_device_constructed (GObject * object)
{
WpReserveDevice *self = WP_RESERVE_DEVICE (object);
g_autoptr (WpReserveDevicePlugin) plugin = g_weak_ref_get (&self->plugin);
g_autoptr (GDBusConnection) conn = wp_dbus_get_connection (plugin->dbus);
self->service_name =
g_strdup_printf (FDO_RESERVE_DEVICE1_SERVICE ".%s", self->name);
@ -130,7 +132,7 @@ wp_reserve_device_constructed (GObject * object)
g_strdup_printf (FDO_RESERVE_DEVICE1_PATH "/%s", self->name);
/* Watch for the name */
self->watcher_id = g_bus_watch_name_on_connection (plugin->connection,
self->watcher_id = g_bus_watch_name_on_connection (conn,
self->service_name, G_BUS_NAME_WATCHER_FLAGS_NONE,
on_name_appeared, on_name_vanished, self, NULL);
@ -189,7 +191,7 @@ wp_reserve_device_acquire (WpReserveDevice * self)
g_autoptr (WpReserveDevicePlugin) plugin = g_weak_ref_get (&self->plugin);
WpTransition *transition = wp_reserve_device_acquire_transition_new (self,
plugin->cancellable, on_acquire_transition_done, self);
NULL, on_acquire_transition_done, self);
g_weak_ref_set (&self->transition, transition);
wp_transition_advance (transition);
}
@ -496,6 +498,7 @@ wp_reserve_device_own_name (WpReserveDevice * self, gboolean force)
g_autoptr (WpReserveDevicePlugin) plugin = g_weak_ref_get (&self->plugin);
if (plugin) {
g_autoptr (GDBusConnection) conn = wp_dbus_get_connection (plugin->dbus);
GBusNameOwnerFlags flags = G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE;
if (self->priority != G_MAXINT32)
flags |= G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT;
@ -504,7 +507,7 @@ wp_reserve_device_own_name (WpReserveDevice * self, gboolean force)
wp_debug_object (self, "request ownership of %s", self->service_name);
self->owner_id = g_bus_own_name_on_connection (plugin->connection,
self->owner_id = g_bus_own_name_on_connection (conn,
self->service_name, flags, on_name_acquired, on_name_lost, self, NULL);
}
}

View file

@ -173,14 +173,16 @@ wp_reserve_device_acquire_transition_execute_step (
wp_reserve_device_own_name (rd, FALSE);
break;
case STEP_GET_PROXY:
wp_org_freedesktop_reserve_device1_proxy_new (plugin->connection,
case STEP_GET_PROXY: {
g_autoptr (GDBusConnection) conn = wp_dbus_get_connection (plugin->dbus);
wp_org_freedesktop_reserve_device1_proxy_new (conn,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
rd->service_name, rd->object_path, NULL,
(GAsyncReadyCallback) on_got_proxy, self);
break;
}
case STEP_REQUEST_RELEASE:
self->owner_state = OWNER_STATE_NONE;

View file

@ -383,8 +383,9 @@ end
-- handle rd_plugin state changes to destroy and re-create the ALSA monitor in
-- case D-Bus service is restarted
if rd_plugin then
rd_plugin:connect("notify::state", function (p, pspec)
local state = p["state"]
local dbus = rd_plugin:call("get-dbus")
dbus:connect("notify::state", function (b, pspec)
local state = b["state"]
Log.info ("rd-plugin state changed to " .. state)
if state == "connected" then
Log.info ("Creating ALSA monitor")

View file

@ -6,6 +6,8 @@
* SPDX-License-Identifier: MIT
*/
#include <wp/wp.h>
#include "../common/base-test-fixture.h"
typedef struct {
@ -13,6 +15,8 @@ typedef struct {
GTestDBus *test_dbus;
WpPlugin *rd_plugin_1;
WpPlugin *rd_plugin_2;
WpDbus *dbus_1;
WpDbus *dbus_2;
gint expected_rd1_state;
gint expected_rd2_state;
} RdTestFixture;
@ -44,11 +48,19 @@ test_rd_setup (RdTestFixture *f, gconstpointer data)
f->rd_plugin_2 = wp_plugin_find (f->base.client_core, "reserve-device");
g_assert_nonnull (f->rd_plugin_2);
g_signal_emit_by_name (f->rd_plugin_1, "get-dbus", &f->dbus_1);
g_assert_nonnull (f->dbus_1);
g_signal_emit_by_name (f->rd_plugin_2, "get-dbus", &f->dbus_2);
g_assert_nonnull (f->dbus_2);
}
static void
test_rd_teardown (RdTestFixture *f, gconstpointer data)
{
g_clear_object (&f->dbus_1);
g_clear_object (&f->dbus_2);
g_clear_object (&f->rd_plugin_1);
g_clear_object (&f->rd_plugin_2);
g_test_dbus_down (f->test_dbus);
@ -70,8 +82,8 @@ static void
ensure_plugins_stable_state (GObject * obj, GParamSpec * spec, RdTestFixture *f)
{
gint state1 = 0, state2 = 0;
g_object_get (f->rd_plugin_1, "state", &state1, NULL);
g_object_get (f->rd_plugin_2, "state", &state2, NULL);
g_object_get (f->dbus_1, "state", &state1, NULL);
g_object_get (f->dbus_2, "state", &state2, NULL);
if (state1 != 1 && state2 != 1 && state1 == state2)
g_main_loop_quit (f->base.loop);
}
@ -83,9 +95,9 @@ test_rd_plugin (RdTestFixture *f, gconstpointer data)
gint state = 0xffff;
gchar *str;
g_object_get (f->rd_plugin_1, "state", &state, NULL);
g_object_get (f->dbus_1, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
g_object_get (f->rd_plugin_2, "state", &state, NULL);
g_object_get (f->dbus_2, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
wp_object_activate (WP_OBJECT (f->rd_plugin_1), WP_PLUGIN_FEATURE_ENABLED,
@ -93,15 +105,15 @@ test_rd_plugin (RdTestFixture *f, gconstpointer data)
wp_object_activate (WP_OBJECT (f->rd_plugin_2), WP_PLUGIN_FEATURE_ENABLED,
NULL, (GAsyncReadyCallback) on_plugin_activated, f);
g_signal_connect (f->rd_plugin_1, "notify::state",
g_signal_connect (f->dbus_1, "notify::state",
G_CALLBACK (ensure_plugins_stable_state), f);
g_signal_connect (f->rd_plugin_2, "notify::state",
g_signal_connect (f->dbus_2, "notify::state",
G_CALLBACK (ensure_plugins_stable_state), f);
g_main_loop_run (f->base.loop);
g_object_get (f->rd_plugin_1, "state", &state, NULL);
g_object_get (f->dbus_1, "state", &state, NULL);
g_assert_cmpint (state, ==, 2);
g_object_get (f->rd_plugin_2, "state", &state, NULL);
g_object_get (f->dbus_2, "state", &state, NULL);
g_assert_cmpint (state, ==, 2);
g_signal_emit_by_name (f->rd_plugin_1, "create-reservation",
@ -158,9 +170,12 @@ test_rd_plugin (RdTestFixture *f, gconstpointer data)
wp_object_deactivate (WP_OBJECT (f->rd_plugin_1), WP_PLUGIN_FEATURE_ENABLED);
wp_object_deactivate (WP_OBJECT (f->rd_plugin_2), WP_PLUGIN_FEATURE_ENABLED);
g_object_get (f->rd_plugin_1, "state", &state, NULL);
wp_object_deactivate (WP_OBJECT (f->dbus_1), WP_DBUS_FEATURE_ENABLED);
wp_object_deactivate (WP_OBJECT (f->dbus_2), WP_DBUS_FEATURE_ENABLED);
g_object_get (f->dbus_1, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
g_object_get (f->rd_plugin_2, "state", &state, NULL);
g_object_get (f->dbus_2, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
}
@ -170,9 +185,9 @@ test_rd_conn_closed (RdTestFixture *f, gconstpointer data)
GObject *rd1 = NULL;
gint state = 0xffff;
g_object_get (f->rd_plugin_1, "state", &state, NULL);
g_object_get (f->dbus_1, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
g_object_get (f->rd_plugin_2, "state", &state, NULL);
g_object_get (f->dbus_2, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
wp_object_activate (WP_OBJECT (f->rd_plugin_1), WP_PLUGIN_FEATURE_ENABLED,
@ -180,15 +195,15 @@ test_rd_conn_closed (RdTestFixture *f, gconstpointer data)
wp_object_activate (WP_OBJECT (f->rd_plugin_2), WP_PLUGIN_FEATURE_ENABLED,
NULL, (GAsyncReadyCallback) on_plugin_activated, f);
g_signal_connect (f->rd_plugin_1, "notify::state",
g_signal_connect (f->dbus_1, "notify::state",
G_CALLBACK (ensure_plugins_stable_state), f);
g_signal_connect (f->rd_plugin_2, "notify::state",
g_signal_connect (f->dbus_2, "notify::state",
G_CALLBACK (ensure_plugins_stable_state), f);
g_main_loop_run (f->base.loop);
g_object_get (f->rd_plugin_1, "state", &state, NULL);
g_object_get (f->dbus_1, "state", &state, NULL);
g_assert_cmpint (state, ==, 2);
g_object_get (f->rd_plugin_2, "state", &state, NULL);
g_object_get (f->dbus_2, "state", &state, NULL);
g_assert_cmpint (state, ==, 2);
g_signal_emit_by_name (f->rd_plugin_1, "create-reservation",
@ -201,13 +216,16 @@ test_rd_conn_closed (RdTestFixture *f, gconstpointer data)
g_test_dbus_stop (f->test_dbus);
g_main_loop_run (f->base.loop);
g_object_get (f->rd_plugin_1, "state", &state, NULL);
g_object_get (f->dbus_1, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
g_object_get (f->rd_plugin_2, "state", &state, NULL);
g_object_get (f->dbus_2, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
g_signal_emit_by_name (f->rd_plugin_1, "get-reservation", "Audio0", &rd1);
g_assert_null (rd1);
wp_object_deactivate (WP_OBJECT (f->dbus_1), WP_DBUS_FEATURE_ENABLED);
wp_object_deactivate (WP_OBJECT (f->dbus_2), WP_DBUS_FEATURE_ENABLED);
}
static void
@ -245,9 +263,9 @@ test_rd_acquire_release (RdTestFixture *f, gconstpointer data)
gint state = 0xffff;
gchar *str = NULL;
g_object_get (f->rd_plugin_1, "state", &state, NULL);
g_object_get (f->dbus_1, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
g_object_get (f->rd_plugin_2, "state", &state, NULL);
g_object_get (f->dbus_2, "state", &state, NULL);
g_assert_cmpint (state, ==, 0);
wp_object_activate (WP_OBJECT (f->rd_plugin_1), WP_PLUGIN_FEATURE_ENABLED,
@ -255,15 +273,15 @@ test_rd_acquire_release (RdTestFixture *f, gconstpointer data)
wp_object_activate (WP_OBJECT (f->rd_plugin_2), WP_PLUGIN_FEATURE_ENABLED,
NULL, (GAsyncReadyCallback) on_plugin_activated, f);
g_signal_connect (f->rd_plugin_1, "notify::state",
g_signal_connect (f->dbus_1, "notify::state",
G_CALLBACK (ensure_plugins_stable_state), f);
g_signal_connect (f->rd_plugin_2, "notify::state",
g_signal_connect (f->dbus_2, "notify::state",
G_CALLBACK (ensure_plugins_stable_state), f);
g_main_loop_run (f->base.loop);
g_object_get (f->rd_plugin_1, "state", &state, NULL);
g_object_get (f->dbus_1, "state", &state, NULL);
g_assert_cmpint (state, ==, 2);
g_object_get (f->rd_plugin_2, "state", &state, NULL);
g_object_get (f->dbus_2, "state", &state, NULL);
g_assert_cmpint (state, ==, 2);
g_signal_emit_by_name (f->rd_plugin_1, "create-reservation",
@ -351,6 +369,9 @@ test_rd_acquire_release (RdTestFixture *f, gconstpointer data)
wp_object_deactivate (WP_OBJECT (f->rd_plugin_1), WP_PLUGIN_FEATURE_ENABLED);
wp_object_deactivate (WP_OBJECT (f->rd_plugin_2), WP_PLUGIN_FEATURE_ENABLED);
wp_object_deactivate (WP_OBJECT (f->dbus_1), WP_DBUS_FEATURE_ENABLED);
wp_object_deactivate (WP_OBJECT (f->dbus_2), WP_DBUS_FEATURE_ENABLED);
}
gint