From 43353d48a30e60fd0b1a907826b538b910a6b49e Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Wed, 2 Nov 2022 18:09:14 +0100 Subject: [PATCH] mock-lfb-event: Emit "feedback-ended" signal This emulates lfb behaviour and the ringer will rely on this behaviour when ending feedbacks. --- tests/mock/lfb/lfb-event.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/mock/lfb/lfb-event.c b/tests/mock/lfb/lfb-event.c index 9a6da05..0e3b279 100644 --- a/tests/mock/lfb/lfb-event.c +++ b/tests/mock/lfb/lfb-event.c @@ -205,6 +205,16 @@ lfb_event_new (const char *event) /* mock libfeedback functions */ +static gboolean +emit_ended (LfbEvent *self) +{ + g_assert (LFB_IS_EVENT (self)); + + g_signal_emit (self, signals[SIGNAL_FEEDBACK_ENDED], 0); + + return G_SOURCE_REMOVE; +} + static gboolean on_mock_timeout (gpointer user_data) { @@ -217,9 +227,16 @@ on_mock_timeout (gpointer user_data) task = G_TASK (user_data); cancellable = g_task_get_cancellable (task); - if (!g_cancellable_is_cancelled (cancellable)) + if (!g_cancellable_is_cancelled (cancellable)) { + LfbEvent *event = g_task_get_source_object (task); + LfbEventState state = GPOINTER_TO_INT (g_task_get_task_data (task)); + g_task_return_boolean (task, TRUE); + if (state == LFB_EVENT_STATE_ENDED) + g_idle_add (G_SOURCE_FUNC (emit_ended), event); + } + return G_SOURCE_REMOVE; } @@ -281,6 +298,9 @@ lfb_event_end_feedback_finish (LfbEvent *self, { g_return_val_if_fail (g_task_is_valid (res, self), FALSE); + if (success) + g_idle_add (G_SOURCE_FUNC (emit_ended), self); + return success; }