Commit 8093830e authored by Arnaud Ferraris's avatar Arnaud Ferraris
Browse files

New upstream version 0.0.0+git20200714

parents 762f3509 7d22b362
......@@ -79,7 +79,7 @@ print help and exit
<term><option>-w=<replaceable>TIMEOUT</replaceable></option></term>
<term><option>--watch=<replaceable>TIMEOUT</replaceable></option></term>
<para>
Maximum timout to wait for the feedback for the given event to end and
Maximum timeout to wait for the feedback for the given event to end and
<command>fbcli</command> to exit.
</para>
</varlistentry>
......
......@@ -20,7 +20,7 @@
<refnamediv>
<refname>feedbackd</refname>
<refpurpose></refpurpose>
<refpurpose>A daemon to provide feedback on events</refpurpose>
</refnamediv>
<refsynopsisdiv>
......@@ -37,7 +37,7 @@
a haptic motor or blink a LED.
</para>
<para>
The feedback triggerd by a given event is determined by the feedback
The feedback triggered by a given event is determined by the feedback
them in use. Events are submitted via a DBus API. For details
refer to the event and feedback theme specs at
<ulink url="https://source.puri.sm/Librem5/feedbackd/"/>
......
......@@ -476,6 +476,14 @@ lfb_event_trigger_feedback_async (LfbEvent *self,
proxy = _lfb_get_proxy ();
g_return_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy));
if (self->handler_id == 0) {
self->handler_id = g_signal_connect_object (proxy,
"feedback-ended",
G_CALLBACK (on_feedback_ended),
self,
G_CONNECT_SWAPPED);
}
data = g_new0 (LpfAsyncData, 1);
data->task = g_task_new (self, cancellable, callback, user_data);
data->event = g_object_ref (self);
......@@ -500,7 +508,7 @@ lfb_event_trigger_feedback_async (LfbEvent *self,
* must call this function in the callback to free memory and receive any
* errors which occurred.
*
* Returns: %TRUE if playing finished successfully
* Returns: %TRUE if triggering the feedbacks was successful
*/
gboolean
lfb_event_trigger_feedback_finish (LfbEvent *self,
......@@ -552,7 +560,10 @@ lfb_event_end_feedback (LfbEvent *self, GError **error)
* must call this function in the callback to free memory and receive any
* errors which occurred.
*
* Returns: %TRUE if playing finished successfully
* This does not mean that the feedbacks finished right away. Connect to the
* #LfbEvent::feedback-ended signal for this.
*
* Returns: %TRUE if ending the feedbacks was successful
*/
gboolean
lfb_event_end_feedback_finish (LfbEvent *self,
......
......@@ -177,7 +177,7 @@ int main(int argc, char *argv[])
return FBD_LEDCTRL_ERR_TRIGGER;
if (group) {
g_debug ("Setting permision of %s to %s", sysfs_path, group);
g_debug ("Setting permission of %s to %s", sysfs_path, group);
if (!set_perms (sysfs_path, trigger, group))
return FBD_LEDCTRL_ERR_PERMS;
}
......
......@@ -61,7 +61,6 @@ on_feedback_ended (LfbEvent *event, LfbEvent **cmp)
/* "Return" event */
*cmp = event;
g_main_loop_quit (mainloop);
}
static void
......@@ -82,6 +81,7 @@ test_lfb_integration_event_sync (void)
event10 = lfb_event_new ("test-dummy-10");
g_signal_connect (event10, "feedback-ended", (GCallback)on_feedback_ended, &cmp);
g_signal_connect_swapped (event10, "feedback-ended", (GCallback)g_main_loop_quit, mainloop);
success = lfb_event_trigger_feedback (event10, &err);
g_assert_no_error (err);
g_assert_true (success);
......@@ -109,7 +109,7 @@ on_event_triggered (LfbEvent *event,
g_assert_true (LFB_IS_EVENT (event));
g_assert_null (*cmp);
g_debug ("%s", __func__);
g_debug ("%s: %p, %s", __func__, event, lfb_event_get_event (event));
success = lfb_event_trigger_feedback_finish (event, res, &err);
g_assert_no_error (err);
g_assert_true (success);
......@@ -120,14 +120,14 @@ on_event_triggered (LfbEvent *event,
}
static void
on_event_ended (LfbEvent *event,
GAsyncResult *res,
LfbEvent **cmp)
on_event_end_finished (LfbEvent *event,
GAsyncResult *res,
LfbEvent **cmp)
{
g_autoptr (GError) err = NULL;
gboolean success;
g_debug ("%s", __func__);
g_debug ("%s: %p, %s", __func__, event, lfb_event_get_event (event));
g_assert_true (LFB_IS_EVENT (event));
g_assert_null (*cmp);
......@@ -147,34 +147,42 @@ test_lfb_integration_event_async (void)
g_autoptr(LfbEvent) event10 = NULL;
g_autofree gchar *evname = NULL;
g_autoptr (GError) err = NULL;
LfbEvent *cmp = NULL;
gboolean success;
LfbEvent *cmp1 = NULL, *cmp2 = NULL, *cmp3 = NULL;
event0 = lfb_event_new ("test-dummy-0");
lfb_event_trigger_feedback_async (event0,
NULL,
(GAsyncReadyCallback)on_event_triggered,
&cmp);
&cmp1);
g_main_loop_run (mainloop);
/* The async finish callback saw the right event */
g_assert_true (event0 == cmp);
cmp = NULL;
g_assert_true (event0 == cmp1);
cmp1 = NULL;
event10 = lfb_event_new ("test-dummy-10");
lfb_event_set_feedback_profile (event10, "quiet");
success = lfb_event_trigger_feedback (event10, &err);
g_assert_no_error (err);
g_assert_true (success);
g_signal_connect (event10, "feedback-ended", (GCallback)on_feedback_ended, &cmp1);
/* The async callback ends the main loop */
lfb_event_trigger_feedback_async (event10,
NULL,
(GAsyncReadyCallback)on_event_triggered,
&cmp2);
g_main_loop_run (mainloop);
/* The async callback ends the main loop */
lfb_event_end_feedback_async (event10,
NULL,
(GAsyncReadyCallback)on_event_ended,
&cmp);
(GAsyncReadyCallback)on_event_end_finished,
&cmp3);
g_main_loop_run (mainloop);
/* The async finish callback saw the right event */
g_assert_true (event10 == cmp);
/* Check if callbacks saw the right event */
g_assert_true (event10 == cmp1);
g_assert_true (event10 == cmp2);
g_assert_true (event10 == cmp3);
g_assert_cmpint (lfb_event_get_state (event10), ==, LFB_EVENT_STATE_ENDED);
g_assert_cmpint (lfb_event_get_end_reason (event10), ==, LFB_EVENT_END_REASON_EXPLICIT);
}
static void
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment