m-std-event-source: fix state names in node-state-changed event

We need to use the enum nicknames ("idle"), not the enum names
("WP_NODE_STATE_IDLE"). This makes suspend-node work again.
This commit is contained in:
George Kiagiadakis
2023-01-05 11:35:08 +02:00
committed by Julian Bouzas
parent 26e47db4b4
commit dc196df239
2 changed files with 8 additions and 2 deletions

View File

@@ -274,9 +274,13 @@ static void
on_node_state_changed (WpNode *obj, WpNodeState old_state, on_node_state_changed (WpNode *obj, WpNodeState old_state,
WpNodeState new_state, WpStandardEventSource *self) WpNodeState new_state, WpStandardEventSource *self)
{ {
g_autoptr (GEnumClass) klass = g_type_class_ref (WP_TYPE_NODE_STATE);
GEnumValue *old_value = g_enum_get_value (klass, old_state);
GEnumValue *new_value = g_enum_get_value (klass, new_state);
g_autoptr (WpProperties) properties = wp_properties_new ( g_autoptr (WpProperties) properties = wp_properties_new (
"event.subject.old-state", g_enum_to_string (WP_TYPE_NODE_STATE, old_state), "event.subject.old-state", old_value ? old_value->value_nick : NULL,
"event.subject.new-state", g_enum_to_string (WP_TYPE_NODE_STATE, new_state), "event.subject.new-state", new_value ? new_value->value_nick : NULL,
NULL); NULL);
wp_standard_event_source_push_event (self, "state-changed", obj, wp_standard_event_source_push_event (self, "state-changed", obj,
properties); properties);

View File

@@ -23,6 +23,8 @@ SimpleEventHook {
local node = event:get_subject () local node = event:get_subject ()
local new_state = event:get_properties ()["event.subject.new-state"] local new_state = event:get_properties ()["event.subject.new-state"]
Log.debug (node, "changed state to " .. new_state)
-- Always clear the current source if any -- Always clear the current source if any
local id = node["bound-id"] local id = node["bound-id"]
if sources[id] then if sources[id] then