Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package feedbackd for openSUSE:Factory checked in at 2022-12-05 18:02:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/feedbackd (Old) and /work/SRC/openSUSE:Factory/.feedbackd.new.1835 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "feedbackd" Mon Dec 5 18:02:20 2022 rev:2 rq:1040323 version:0.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/feedbackd/feedbackd.changes 2022-08-25 15:31:02.783655842 +0200 +++ /work/SRC/openSUSE:Factory/.feedbackd.new.1835/feedbackd.changes 2022-12-05 18:02:42.065071657 +0100 @@ -1,0 +2,62 @@ +Mon Dec 5 14:21:42 UTC 2022 - Bjørn Lie <bjorn....@gmail.com> + +- Update to version 0.0.1: + * spec: Clarify feedback noisiness. + The old wording could be interpreted as the feedback being + discarded if it's noisier than the currently selected profile + which is not the case. Also take the new per application + settings into account. + * lfb-event: Fix SPDX identifier. The library is LGPL-2.1+, not + GPL-3.0+ + * test-lfb-integration: Test event state in async callback + * lfb-event: Notify state change before completing async task + lfb_event_trigger_feedback_async() internally uses a GTask to + handle invocation of the user provided callback when + g_task_return_*() is called. + Currently GTask is completed first and only afterwards is the + state of the event being updated which can lead to suprising + behaviour. + * feedback-manager: Use guint for event id. + The ID is inserted into a hashtable below with GUINT_TO_POINTER + and is set using self->next_id++ with next_id also being a + guint, so change the type accordingly. + * run: Make it easy to run under gdb and document usage. + Having a fast and easy way to run the daemon under gdb can be + beneficial for debugging. For that start the run script with + FBD_GDB=1. + * tests/integration: Indicate that callback quits main loop + on_event_triggered() is renamed to on_event_triggered_quit() + as we will shortly introduce a variant that does not quit. + * tests/integration: Fix whitespace. + Remove all tabs in favour of spaces and align function + arguments. + * tests/integration: Test that "feedback-ended" is propagated + through LfbEvent. When no feedbacks are available (either + because the requested event does not exist in the theme or + because the system does not have required capabilities, e.g. no + vibration motor or LED) feedbackd will emit a "feedback-ended" + signal (with reason LFB_EVENT_STATE_REASON_NOT_FOUND) on DBus + _before_ completing the event triggering DBus call. Since the + DBus call was not completed yet, LfbEvent will not have learned + it's ID yet and therefore not emit it's own "feedback-ended" + GObject signal. In this case the test will timeout since the + main loop is never quit. + * feedback-manager: Complete DBus call before emitting + "feedback-ended" See previous commit adding the test (that now + passes) for the reasoning. + * data: Drop outdated comment. We use the hints since some time, + see lfb_event_set_feedback_profile(). + * lfb-event: Fix typo. It's LfbEvent + * lfb-event: Use consistent prefix. + Make async data use the same prefix. + * Use g_error() when library is not initalized. + This makes sure it still works when asserts are disabled. + * lfb-event: Untabify + * tests: Drop unused variable + * tests/integration: Check the state of the ended event + * manager: Use FEEDBACKD_UDEV_ATTR. + It was introduced in + a5b4f99 ("feedbackd: Support visual feedback via LEDs") + * fbd: Fix indentation + +------------------------------------------------------------------- Old: ---- feedbackd-0.0.0+git20211018.obscpio New: ---- feedbackd-0.0.1.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ feedbackd.spec ++++++ --- /var/tmp/diff_new_pack.UU7Kjb/_old 2022-12-05 18:02:42.549074293 +0100 +++ /var/tmp/diff_new_pack.UU7Kjb/_new 2022-12-05 18:02:42.557074337 +0100 @@ -1,7 +1,7 @@ # # spec file for package feedbackd # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -15,18 +15,19 @@ # Please submit bugfixes or comments via https://bugs.opensuse.org/ # + %define soname libfeedback-0_0-0 Name: feedbackd -Version: 0.0.0+git20211018 +Version: 0.0.1 Release: 0 Summary: Feedback library for GNOME License: GPL-3.0-only AND LGPL-2.1-only URL: https://source.puri.sm/Librem5/feedbackd Source0: %{name}-%{version}.tar.xz -BuildRequires: dbus-1 BuildRequires: c_compiler +BuildRequires: dbus-1 BuildRequires: meson BuildRequires: vala BuildRequires: pkgconfig(gio-2.0) >= 2.50.0 @@ -66,8 +67,8 @@ %package devel Summary: Development files for %{name} Requires: %{name} = %{version} -Requires: typelib-1_0-Lfb-0_0 = %{version} Requires: %{soname} = %{version} +Requires: typelib-1_0-Lfb-0_0 = %{version} %description devel The %{name}-devel package contains libraries and header files for ++++++ _service ++++++ --- /var/tmp/diff_new_pack.UU7Kjb/_old 2022-12-05 18:02:42.597074555 +0100 +++ /var/tmp/diff_new_pack.UU7Kjb/_new 2022-12-05 18:02:42.601074576 +0100 @@ -1,7 +1,7 @@ <services> - <service mode="disabled" name="obs_scm"> + <service mode="manual" name="obs_scm"> <param name="url">https://source.puri.sm/Librem5/feedbackd.git</param> - <param name="revision">refs/tags/v0.0.0+git20211018</param> + <param name="revision">refs/tags/v0.0.1</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> <param name="scm">git</param> @@ -11,6 +11,6 @@ <param name="file">*.tar</param> <param name="compression">xz</param> </service> - <service mode="disabled" name="set_version" /> + <service mode="manual" name="set_version" /> </services> ++++++ feedbackd-0.0.0+git20211018.obscpio -> feedbackd-0.0.1.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/Feedback-theme-spec-0.0.0.md new/feedbackd-0.0.1/Feedback-theme-spec-0.0.0.md --- old/feedbackd-0.0.0+git20211018/Feedback-theme-spec-0.0.0.md 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/Feedback-theme-spec-0.0.0.md 2022-11-11 11:02:17.000000000 +0100 @@ -25,14 +25,18 @@ # Implementation -When an application triggers feedback for an event in the feedback -daemon the daemon selects the provided feedback like this: +When an application requests feedback for an event via the feedback daemon +the daemon selects the provided feedback like this, +capping the noisiness for each limit: -1. feedbacks from a nosier profiles like the currently selected are - ignored +1. The currently selected profile provides the (global) upper limit for noisiness -2. All other feedbacks for this event are selected and run to provide - feedback to the user +2. Per application settings impose another upper limit + +3. Per event noisiness is the last noisiness constraint + +4. All feedback consistent with the resulting limit are selected + and run to provide the feedback to the user With the above a feedback theme in YAML format could look like: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/README.md new/feedbackd-0.0.1/README.md --- old/feedbackd-0.0.0+git20211018/README.md 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/README.md 2022-11-11 11:02:17.000000000 +0100 @@ -48,6 +48,13 @@ ```sh _build/run ``` + +To run under gdb use + +``` sh +FBD_GDB=1 _build/run +``` + You can introspect and get the current theme with ```sh @@ -95,6 +102,10 @@ $ sudo cp my_awesome_theme.json /usr/local/share/feedbackd/themes/ ``` +Upon reception of `SIGHUP` signal, the daemon process will proceed to retrigger +the above logic to find the themes, and reload the corresponding one. This can +be used to avoid having to restart the daemon in case of configuration changes. + Check out the companion [feedbackd-device-themes][1] repository for a selection of device-specific themes. In order for your theme to be recognized it must be named properly. Currently, theme names are based on the `compatible` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/data/org.sigxcpu.Feedback.xml new/feedbackd-0.0.1/data/org.sigxcpu.Feedback.xml --- old/feedbackd-0.0.0+git20211018/data/org.sigxcpu.Feedback.xml 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/data/org.sigxcpu.Feedback.xml 2022-11-11 11:02:17.000000000 +0100 @@ -20,8 +20,8 @@ TriggerFeedback: @app_id: The application id usually in "reverse DNS" format @event: The event name from the Event naming spec - @hints: Additional hints (e.g. to prefer haptic feedback over audio feedback on button press events, currently unused) - @timeout: When the feedbacks for this event should end latest. The special values '-1' (just run each feedback once) and '0' (endless loop) are also supported. + @hints: Additional hints (e.g. to prefer haptic feedback over audio feedback on button press events) + @timeout: When the feedbacks for this event should end latest in seconds. The special values '-1' (just run each feedback once) and '0' (endless loop) are also supported. @id: Event id for future reference Give user feedback for an event by triggering feedbacks diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/debian/changelog new/feedbackd-0.0.1/debian/changelog --- old/feedbackd-0.0.0+git20211018/debian/changelog 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/debian/changelog 2022-11-11 11:02:17.000000000 +0100 @@ -1,3 +1,112 @@ +feedbackd (0.0.1) byzantium; urgency=medium + + [ Evangelos Ribeiro Tzaras ] + * spec: Clarify feedback noisiness. + The old wording could be interpreted as the feedback being discarded if + it's noisier than the currently selected profile which is not the case. + Also take the new per application settings into account. + * lfb-event: Fix SPDX identifier. + The library is LGPL-2.1+, not GPL-3.0+ + * test-lfb-integration: Test event state in async callback + * lfb-event: Notify state change before completing async task + lfb_event_trigger_feedback_async() internally uses a GTask to handle + invocation of the user provided callback when g_task_return_*() is + called. + Currently GTask is completed first and only afterwards is the state of + the event being updated which can lead to suprising behaviour. + * feedback-manager: Use guint for event id. + The ID is inserted into a hashtable below with GUINT_TO_POINTER + and is set using self->next_id++ with next_id also being a guint, + so change the type accordingly. + * run: Make it easy to run under gdb and document usage. + Having a fast and easy way to run the daemon under gdb can be beneficial + for debugging. For that start the run script with FBD_GDB=1. + * tests/integration: Indicate that callback quits main loop + on_event_triggered() is renamed to on_event_triggered_quit() + as we will shortly introduce a variant that does not quit. + * tests/integration: Fix whitespace. + Remove all tabs in favour of spaces and align function arguments. + * tests/integration: Test that "feedback-ended" is propagated through LfbEvent. + When no feedbacks are available (either because the requested event does + not exist in the theme or because the system does not have required + capabilities, e.g. no vibration motor or LED) feedbackd will emit a + "feedback-ended" signal (with reason LFB_EVENT_STATE_REASON_NOT_FOUND) + on DBus _before_ completing the event triggering DBus call. + Since the DBus call was not completed yet, LfbEvent will not have + learned it's ID yet and therefore not emit it's own "feedback-ended" + GObject signal. + In this case the test will timeout since the main loop is never quit. + * feedback-manager: Complete DBus call before emitting "feedback-ended" + See previous commit adding the test (that now passes) for the reasoning. + Fixes: #62 + + [ Guido Günther ] + * data: Drop outdated comment. + We use the hints since some time, see lfb_event_set_feedback_profile(). + * lfb-event: Fix typo. It's LfbEvent + * lfb-event: Use consistent prefix. + Make async data use the same prefix. + * Use g_error() when library is not initalized. + This makes sure it still works when asserts are disabled. + * lfb-event: Untabify + * tests: Drop unused variable + * tests/integration: Check the state of the ended event + * manager: Use FEEDBACKD_UDEV_ATTR. + It was introduced in + a5b4f99 ("feedbackd: Support visual feedback via LEDs") + * fbd: Fix indentation + + -- Guido Günther <a...@sigxcpu.org> Thu, 10 Nov 2022 13:53:19 +0100 + +feedbackd (0.0.0+git20220520) byzantium; urgency=medium + + [ Guido Günther ] + * udev: Drop pre L5 pre 5.9 workaround. + Not neeed in 2022. + * udev: Use more generic comment. + Make it more obvious that this isn't device specific + + [ Dylan Van Assche ] + * fbd-dev-leds: use define for max_brightness. + All other attributes use a define, let's do the same for max_brightness. + * fbd-dev-leds: rename var to max_brightness_percentage. + Improve readability of the code. + + [ Luca Weiss ] + * fbd-dev-leds: support for multicolor LEDs. + Add support for multicolor LEDs as supported by the kernel. + Used by Qualcomm devices such as SHIFT 6mq, OnePlus 6, etc. + Co-Developed-by: Dylan Van Assche <m...@dylanvanassche.be> + + -- Guido Günther <a...@sigxcpu.org> Fri, 20 May 2022 10:55:13 +0200 + +feedbackd (0.0.0+git20220208) byzantium; urgency=medium + + [ Pablo Correa Gómez ] + * Reload theme on SIGHUP signal. + Allows for users/applications to request a theme reload + by sending SIGHUP signal to the daemon. + + [ Evangelos Ribeiro Tzaras ] + * lfb-event: Clarify docstring on lfb_event_set_feedback_profile + * fbd-event: Fix return value for fbd_event_get_sender + * doc: Clarify that the timeout is in seconds + + [ Guido Günther ] + * libfeedback: Remove unused variables + * tests: Remove unused variables + * manager: Set initial profile to unknown. + This makes sure we sync the profile with the DBus property after + fetching it from GSettings. + * manager: Sync profile with setting on startup. + On startup the GSetting is the relevant input for selecting the profle. + (Closes: #52) + * manager: Don't sync DBus profile property. + This will happen in on_feedbackd_setting_changed() once the + profile was adjusted. + + -- Guido Günther <a...@sigxcpu.org> Tue, 08 Feb 2022 11:29:41 +0100 + feedbackd (0.0.0+git20211018) byzantium; urgency=medium [ Evangelos Ribeiro Tzaras ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/debian/feedbackd.udev new/feedbackd-0.0.1/debian/feedbackd.udev --- old/feedbackd-0.0.0+git20211018/debian/feedbackd.udev 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/debian/feedbackd.udev 2022-11-11 11:02:17.000000000 +0100 @@ -6,11 +6,8 @@ SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT}=="1", ENV{ID_PATH}=="platform-vibrator", TAG+="uaccess", ENV{FEEDBACKD_TYPE}="vibra" -# Front leds of the Librem5 (pre 5.9) -SUBSYSTEM=="leds", DEVPATH=="*/phone:*:front", ENV{FEEDBACKD_TYPE}="led", RUN+="/usr/libexec/fbd-ledctrl -p %S%p -t pattern -G feedbackd" -# Front leds of the Librem5 (5.9 and later) +# See include/dt-bindings/leds/common.h in the linux kernel SUBSYSTEM=="leds", DEVPATH=="*/*:status", ENV{FEEDBACKD_TYPE}="led", RUN+="/usr/libexec/fbd-ledctrl -p %S%p -t pattern -G feedbackd" -# Front leds of the PinePhone SUBSYSTEM=="leds", DEVPATH=="*/*:indicator", ENV{FEEDBACKD_TYPE}="led", RUN+="/usr/libexec/fbd-ledctrl -p %S%p -t pattern -G feedbackd" LABEL="feedbackd_end" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/libfeedback/lfb-event.c new/feedbackd-0.0.1/libfeedback/lfb-event.c --- old/feedbackd-0.0.0+git20211018/libfeedback/lfb-event.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/libfeedback/lfb-event.c 2022-11-11 11:02:17.000000000 +0100 @@ -1,6 +1,6 @@ /* * Copyright (C) 2020 Purism SPC - * SPDX-License-Identifier: GPL-3.0+ + * SPDX-License-Identifier: LGPL-2.1+ * Author: Guido Günther <a...@sigxcpu.org> */ @@ -30,7 +30,7 @@ * * |[ * g_autoptr (GError) err = NULL; - * LpfEvent *event = lfb_event_new ("message-new-instant"); + * LfbEvent *event = lfb_event_new ("message-new-instant"); * lfb_event_set_timeout (event, 0); * if (!lfb_event_trigger_feedback (event, &err)) * g_warning ("Failed to trigger feedback: %s", err->message); @@ -104,10 +104,10 @@ G_DEFINE_TYPE (LfbEvent, lfb_event, G_TYPE_OBJECT); -typedef struct _LpfAsyncData { +typedef struct _LfbAsyncData { LfbEvent *event; GTask *task; -} LpfAsyncData; +} LfbAsyncData; static void lfb_event_set_state (LfbEvent *self, LfbEventState state) @@ -143,14 +143,13 @@ static void on_trigger_feedback_finished (LfbGdbusFeedback *proxy, GAsyncResult *res, - LpfAsyncData *data) + LfbAsyncData *data) { GTask *task = data->task; LfbEvent *self = data->event; g_autoptr (GError) err = NULL; gboolean success; - LfbEventState state; g_return_if_fail (G_IS_TASK (task)); g_return_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy)); @@ -160,16 +159,15 @@ &self->id, res, &err); + + lfb_event_set_state (self, success ? LFB_EVENT_STATE_RUNNING : LFB_EVENT_STATE_ERRORED); if (!success) { g_task_return_error (task, g_steal_pointer (&err)); - state = LFB_EVENT_STATE_ERRORED; } else { g_task_return_boolean (task, TRUE); - state = LFB_EVENT_STATE_RUNNING; _lfb_active_add_id (self->id); } - lfb_event_set_state (self, state); g_free (data); g_object_unref (task); g_object_unref (self); @@ -178,7 +176,7 @@ static void on_end_feedback_finished (LfbGdbusFeedback *proxy, GAsyncResult *res, - LpfAsyncData *data) + LfbAsyncData *data) { GTask *task = data->task; @@ -191,8 +189,8 @@ g_return_if_fail (LFB_IS_EVENT (self)); success = lfb_gdbus_feedback_call_end_feedback_finish (proxy, - res, - &err); + res, + &err); if (!success) { g_task_return_error (task, g_steal_pointer (&err)); } else @@ -294,7 +292,7 @@ /** * LfbEvent:timeout: * - * How long feedback should be provided in milliseconds. The special value + * How long feedback should be provided in seconds. The special value * %-1 uses the natural length of each feedback while %0 plays each feedback * in a loop until ended explicitly via e.g. #lfb_event_end_feedback(). */ @@ -417,10 +415,8 @@ g_return_val_if_fail (LFB_IS_EVENT (self), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before triggering events"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before triggering events."); proxy = _lfb_get_proxy (); g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), FALSE); @@ -464,27 +460,25 @@ GAsyncReadyCallback callback, gpointer user_data) { - LpfAsyncData *data; + LfbAsyncData *data; LfbGdbusFeedback *proxy; g_return_if_fail (LFB_IS_EVENT (self)); - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before triggering events"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before triggering events."); 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); + "feedback-ended", + G_CALLBACK (on_feedback_ended), + self, + G_CONNECT_SWAPPED); } - data = g_new0 (LpfAsyncData, 1); + data = g_new0 (LfbAsyncData, 1); data->task = g_task_new (self, cancellable, callback, user_data); data->event = g_object_ref (self); lfb_gdbus_feedback_call_trigger_feedback (proxy, @@ -539,10 +533,8 @@ g_return_val_if_fail (LFB_IS_EVENT (self), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before ending events"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before ending events."); proxy = _lfb_get_proxy (); g_return_val_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy), FALSE); @@ -567,8 +559,8 @@ */ gboolean lfb_event_end_feedback_finish (LfbEvent *self, - GAsyncResult *res, - GError **error) + GAsyncResult *res, + GError **error) { g_return_val_if_fail (g_task_is_valid (res, self), FALSE); @@ -587,23 +579,21 @@ */ void lfb_event_end_feedback_async (LfbEvent *self, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { - LpfAsyncData *data; + LfbAsyncData *data; LfbGdbusFeedback *proxy; g_return_if_fail (LFB_IS_EVENT (self)); - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before ending events"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before ending events."); proxy = _lfb_get_proxy (); g_return_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy)); - data = g_new0 (LpfAsyncData, 1); + data = g_new0 (LfbAsyncData, 1); data->task = g_task_new (self, cancellable, callback, user_data); data->event = g_object_ref (self); lfb_gdbus_feedback_call_end_feedback (proxy, @@ -705,9 +695,9 @@ * @profile: The feedback profile to use * * Tells the feedback server to use the given feedback profile for - * this event. The server might ignore this request. Valid profile - * names and their 'noisiness' are specified in the [Feedback theme - * specification](https://source.puri.sm/Librem5/feedbackd/-/blob/master/Feedback-theme-spec-0.0.0.md). + * this event when it is submitted. The server might ignore this + * request. Valid profile names and their 'noisiness' are specified + * in the [Feedback theme specification](https://source.puri.sm/Librem5/feedbackd/-/blob/master/Feedback-theme-spec-0.0.0.md). * * A value of %NULL (the default) lets the server pick the profile. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/libfeedback/lfb-event.h new/feedbackd-0.0.1/libfeedback/lfb-event.h --- old/feedbackd-0.0.0+git20211018/libfeedback/lfb-event.h 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/libfeedback/lfb-event.h 2022-11-11 11:02:17.000000000 +0100 @@ -1,7 +1,7 @@ /* * Copyright (C) 2020 Purism SPC * - * SPDX-License-Identifier: GPL-3.0+ + * SPDX-License-Identifier: LGPL-2.1+ */ #pragma once diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/libfeedback/libfeedback.c new/feedbackd-0.0.1/libfeedback/libfeedback.c --- old/feedbackd-0.0.0+git20211018/libfeedback/libfeedback.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/libfeedback/libfeedback.c 2022-11-11 11:02:17.000000000 +0100 @@ -191,13 +191,9 @@ lfb_get_feedback_profile (void) { LfbGdbusFeedback *proxy; - g_autofree gchar *profile = NULL; - g_autoptr(GVariant) var = NULL; - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before getting the profile"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before ending events."); proxy = _lfb_get_proxy (); g_return_val_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy), NULL); @@ -220,10 +216,8 @@ { LfbGdbusFeedback *proxy; - if (!lfb_is_initted ()) { - g_warning ("you must call lfb_init() before setting the profile"); - g_assert_not_reached (); - } + if (!lfb_is_initted ()) + g_error ("You must call lfb_init() before ending events."); proxy = _lfb_get_proxy (); g_return_if_fail (LFB_GDBUS_IS_FEEDBACK (proxy)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/meson.build new/feedbackd-0.0.1/meson.build --- old/feedbackd-0.0.0+git20211018/meson.build 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/meson.build 2022-11-11 11:02:17.000000000 +0100 @@ -1,5 +1,5 @@ project('feedbackd', 'c', - version : '0.0.0', + version : '0.0.1', license : 'LGPLv3+', meson_version : '>= 0.49.0', default_options : [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/run.in new/feedbackd-0.0.1/run.in --- old/feedbackd-0.0.0+git20211018/run.in 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/run.in 2022-11-11 11:02:17.000000000 +0100 @@ -8,5 +8,10 @@ export FEEDBACK_THEME export GSETTINGS_SCHEMA_DIR="${ABS_BUILDDIR}/data" +if [ "${FBD_GDB}" = 1 ]; then + echo "Running calls under gdb" + WRAPPER="gdb --args" +fi + set -x -exec "${ABS_BUILDDIR}/src/feedbackd" "$@" +exec ${WRAPPER} "${ABS_BUILDDIR}/src/feedbackd" "$@" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/src/fbd-dev-leds.c new/feedbackd-0.0.1/src/fbd-dev-leds.c --- old/feedbackd-0.0.0+git20211018/src/fbd-dev-leds.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/src/fbd-dev-leds.c 2022-11-11 11:02:17.000000000 +0100 @@ -25,13 +25,22 @@ * It currently only supports one pattern per led at a time. */ -#define LED_BRIGHTNESS_ATTR "brightness" -#define LED_PATTERN_ATTR "pattern" -#define LED_SUBSYSTEM "leds" +#define LED_BRIGHTNESS_ATTR "brightness" +#define LED_MAX_BRIGHTNESS_ATTR "max_brightness" +#define LED_MULTI_INDEX_ATTR "multi_index" +#define LED_MULTI_INTENSITY_ATTR "multi_intensity" +#define LED_MULTI_INDEX_RED "red" +#define LED_MULTI_INDEX_GREEN "green" +#define LED_MULTI_INDEX_BLUE "blue" +#define LED_PATTERN_ATTR "pattern" +#define LED_SUBSYSTEM "leds" typedef struct _FbdDevLed { GUdevDevice *dev; guint max_brightness; + guint red_index; + guint green_index; + guint blue_index; /* * We just use the colors from the feedback until we * do rgb mixing, etc @@ -79,7 +88,7 @@ for (GSList *l = self->leds; l != NULL; l = l->next) { FbdDevLed *led = l->data; - if (led->color == color) + if (led->color == FBD_FEEDBACK_LED_COLOR_RGB || led->color == color) return led; } @@ -118,6 +127,8 @@ for (int i = 0; i <= FBD_FEEDBACK_LED_COLOR_LAST; i++) { g_autofree char *color = NULL; g_autofree char *enum_name = NULL; + const gchar * const *index; + guint counter = 0; gchar *c; enum_name = g_enum_to_string (FBD_TYPE_FEEDBACK_LED_COLOR, i); @@ -125,7 +136,8 @@ color = g_ascii_strdown (c+1, -1); if (g_strstr_len (name, -1, color)) { g_autoptr (GError) err = NULL; - guint brightness = g_udev_device_get_sysfs_attr_as_int (dev, "max_brightness"); + guint brightness = g_udev_device_get_sysfs_attr_as_int (dev, LED_MAX_BRIGHTNESS_ATTR); + index = g_udev_device_get_sysfs_attr_as_strv (dev, LED_MULTI_INDEX_ATTR); if (!brightness) continue; @@ -134,6 +146,25 @@ led->dev = g_object_ref (dev); led->color = i; led->max_brightness = brightness; + + if (index) { + for (int j = 0; j < g_strv_length ((gchar **) index); j++) { + g_debug ("Index: %s", index[j]); + if (g_strcmp0 (index[j], LED_MULTI_INDEX_RED) == 0) { + led->red_index = counter; + counter++; + } else if (g_strcmp0 (index[j], LED_MULTI_INDEX_GREEN) == 0) { + led->green_index = counter; + counter++; + } else if (g_strcmp0 (index[j], LED_MULTI_INDEX_BLUE) == 0) { + led->blue_index = counter; + counter++; + } else { + g_warning ("Unsupport LED color index: %d %s", counter, index[j]); + } + } + } + path = g_udev_device_get_sysfs_path (dev); g_debug ("LED at '%s' usable", path); self->leds = g_slist_append (self->leds, led); @@ -198,14 +229,14 @@ * fbd_dev_leds_start_periodic: * @self: The #FbdDevLeds * @color: The color to use for the LED pattern - * @max_brightness: The max brightness (in percent) to use for the pattern + * @max_brightness_percentage: The max brightness (in percent) to use for the pattern * @freq: The pattern's frequency in mHz * * Start periodic feedback. */ gboolean fbd_dev_leds_start_periodic (FbdDevLeds *self, FbdFeedbackLedColor color, - guint max_brightness, guint freq) + guint max_brightness_percentage, guint freq) { FbdDevLed *led; gdouble max; @@ -216,14 +247,52 @@ gboolean success; g_return_val_if_fail (FBD_IS_DEV_LEDS (self), FALSE); + g_return_val_if_fail (max_brightness_percentage <= 100.0, FALSE); led = find_led_by_color (self, color); g_return_val_if_fail (led, FALSE); - max = led->max_brightness * (max_brightness / 100.0); + if (led->color == FBD_FEEDBACK_LED_COLOR_RGB) { + g_autofree char *intensity = NULL; + guint colors[] = { 0, 0, 0 }; + switch (color) { + case FBD_FEEDBACK_LED_COLOR_WHITE: + colors[led->red_index] = led->max_brightness; + colors[led->green_index] = led->max_brightness; + colors[led->blue_index] = led->max_brightness; + break; + case FBD_FEEDBACK_LED_COLOR_RED: + colors[led->red_index] = led->max_brightness; + colors[led->green_index] = 0; + colors[led->blue_index] = 0; + break; + case FBD_FEEDBACK_LED_COLOR_GREEN: + colors[led->red_index] = 0; + colors[led->green_index] = led->max_brightness; + colors[led->blue_index] = 0; + break; + case FBD_FEEDBACK_LED_COLOR_BLUE: + colors[led->red_index] = 0; + colors[led->green_index] = 0; + colors[led->blue_index] = led->max_brightness; + break; + default: + g_warning("Unhandled color: %d\n", color); + return FALSE; + } + intensity = g_strdup_printf ("%d %d %d\n", colors[0], colors[1], colors[2]); + fbd_dev_led_set_brightness (led, led->max_brightness); + success = fbd_udev_set_sysfs_path_attr_as_string (led->dev, LED_MULTI_INTENSITY_ATTR, intensity, &err); + if (!success) { + g_warning ("Failed to set multi intensity: %s", err->message); + g_clear_error (&err); + } + } + + max = led->max_brightness * (max_brightness_percentage / 100.0); /* ms mHz T/2 */ t = 1000.0 * 1000.0 / freq / 2.0; str = g_strdup_printf ("0 %d %d %d\n", (gint)t, (gint)max, (gint)t); - g_debug ("Freq %d mHz, Brightness: %d%%, Blink pattern: %s", freq, max_brightness, str); + g_debug ("Freq %d mHz, Brightness: %d%%, Blink pattern: %s", freq, max_brightness_percentage, str); success = fbd_udev_set_sysfs_path_attr_as_string (led->dev, LED_PATTERN_ATTR, str, &err); if (!success) g_warning ("Failed to set led pattern: %s", err->message); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/src/fbd-event.c new/feedbackd-0.0.1/src/fbd-event.c --- old/feedbackd-0.0.0+git20211018/src/fbd-event.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/src/fbd-event.c 2022-11-11 11:02:17.000000000 +0100 @@ -481,7 +481,7 @@ const char * fbd_event_get_sender (FbdEvent *self) { - g_return_val_if_fail (FBD_IS_EVENT (self), FBD_EVENT_END_REASON_NATURAL); + g_return_val_if_fail (FBD_IS_EVENT (self), NULL); return self->sender; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/src/fbd-feedback-led.h new/feedbackd-0.0.1/src/fbd-feedback-led.h --- old/feedbackd-0.0.0+git20211018/src/fbd-feedback-led.h 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/src/fbd-feedback-led.h 2022-11-11 11:02:17.000000000 +0100 @@ -14,7 +14,8 @@ FBD_FEEDBACK_LED_COLOR_RED = 1, FBD_FEEDBACK_LED_COLOR_GREEN = 2, FBD_FEEDBACK_LED_COLOR_BLUE = 3, - FBD_FEEDBACK_LED_COLOR_LAST = FBD_FEEDBACK_LED_COLOR_BLUE, + FBD_FEEDBACK_LED_COLOR_RGB = 4, + FBD_FEEDBACK_LED_COLOR_LAST = FBD_FEEDBACK_LED_COLOR_RGB, } FbdFeedbackLedColor; #define FBD_TYPE_FEEDBACK_LED (fbd_feedback_led_get_type ()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/src/fbd-feedback-manager.c new/feedbackd-0.0.1/src/fbd-feedback-manager.c --- old/feedbackd-0.0.0+git20211018/src/fbd-feedback-manager.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/src/fbd-feedback-manager.c 2022-11-11 11:02:17.000000000 +0100 @@ -84,7 +84,7 @@ g_clear_object (&self->vibra); } } else if (g_strcmp0 (action, "add") == 0) { - if (!g_strcmp0 (g_udev_device_get_property (device, "FEEDBACKD_TYPE"), "vibra")) { + if (!g_strcmp0 (g_udev_device_get_property (device, FEEDBACKD_UDEV_ATTR), "vibra")) { g_autoptr (GError) err = NULL; g_debug ("Found hotplugged vibra device at %s", g_udev_device_get_sysfs_path (device)); @@ -139,7 +139,7 @@ for (l = devices; l != NULL; l = l->next) { GUdevDevice *dev = l->data; - if (!g_strcmp0 (g_udev_device_get_property (dev, "FEEDBACKD_TYPE"), "vibra")) { + if (!g_strcmp0 (g_udev_device_get_property (dev, FEEDBACKD_UDEV_ATTR), "vibra")) { g_debug ("Found vibra device"); self->vibra = fbd_dev_vibra_new (dev, &err); if (!self->vibra) { @@ -323,7 +323,7 @@ FbdFeedbackManager *self; FbdEvent *event; GSList *feedbacks, *l; - gint event_id; + guint event_id; const gchar *sender; FbdFeedbackProfileLevel app_level, level, hint_level = FBD_FEEDBACK_PROFILE_LEVEL_FULL; gboolean found_fb = FALSE; @@ -384,6 +384,8 @@ found_fb = FALSE; } + lfb_gdbus_feedback_complete_trigger_feedback (object, invocation, event_id); + if (found_fb) { g_signal_connect_object (event, "feedbacks-ended", (GCallback) on_event_feedbacks_ended, @@ -397,7 +399,6 @@ FBD_EVENT_END_REASON_NOT_FOUND); } - lfb_gdbus_feedback_complete_trigger_feedback (object, invocation, event_id); return TRUE; } @@ -492,37 +493,18 @@ static void fbd_feedback_manager_constructed (GObject *object) { - g_autoptr (GError) err = NULL; FbdFeedbackManager *self = FBD_FEEDBACK_MANAGER (object); - const gchar *themefile; G_OBJECT_CLASS (fbd_feedback_manager_parent_class)->constructed (object); - // Overide themefile with environment variable if requested - themefile = g_getenv (FEEDBACKD_THEME_VAR); - - // Search for device-specific configuration - if (!themefile) - themefile = find_themefile (); - - // Fallback to default configuration if needed - if (!themefile) - themefile = FEEDBACKD_THEME_DIR "/default.json"; - g_info ("Using themefile: %s", themefile); - - self->theme = fbd_feedback_theme_new_from_file (themefile, &err); - if (!self->theme) { - /* No point to carry on */ - g_error ("Failed to load theme: %s", err->message); - } + fbd_feedback_manager_load_theme(self); g_signal_connect (self, "notify::profile", (GCallback)on_profile_changed, NULL); - lfb_gdbus_feedback_set_profile (LFB_GDBUS_FEEDBACK (self), - fbd_feedback_profile_level_to_string (self->level)); self->settings = g_settings_new (FEEDBACKD_SCHEMA_ID); g_signal_connect_swapped (self->settings, "changed::" FEEDBACKD_KEY_PROFILE, G_CALLBACK (on_feedbackd_setting_changed), self); + on_feedbackd_setting_changed (self, FEEDBACKD_KEY_PROFILE, self->settings); } static void @@ -564,7 +546,7 @@ const gchar * const subsystems[] = { "input", NULL }; self->next_id = 1; - self->level = FBD_FEEDBACK_PROFILE_LEVEL_FULL; + self->level = FBD_FEEDBACK_PROFILE_LEVEL_UNKNOWN; self->client = g_udev_client_new (subsystems); g_signal_connect_swapped (G_OBJECT (self->client), "uevent", @@ -617,6 +599,34 @@ return self->leds; } +void fbd_feedback_manager_load_theme (FbdFeedbackManager *self) { + g_autoptr (GError) err = NULL; + g_autoptr (FbdFeedbackTheme) theme = NULL; + const gchar *themefile; + + // Overide themefile with environment variable if requested + themefile = g_getenv (FEEDBACKD_THEME_VAR); + + // Search for device-specific configuration + if (!themefile) + themefile = find_themefile (); + + // Fallback to default configuration if needed + if (!themefile) + themefile = FEEDBACKD_THEME_DIR "/default.json"; + g_info ("Using themefile: %s", themefile); + + theme = fbd_feedback_theme_new_from_file (themefile, &err); + if (theme) { + g_set_object(&self->theme, theme); + } else { + if (self->theme) + g_warning ("Failed to reload theme: %s", err->message); + else + g_error ("Failed to load theme: %s", err->message); // No point to carry on + } +} + gboolean fbd_feedback_manager_set_profile (FbdFeedbackManager *self, const gchar *profile) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/src/fbd-feedback-manager.h new/feedbackd-0.0.1/src/fbd-feedback-manager.h --- old/feedbackd-0.0.0+git20211018/src/fbd-feedback-manager.h 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/src/fbd-feedback-manager.h 2022-11-11 11:02:17.000000000 +0100 @@ -22,6 +22,7 @@ FbdDevVibra *fbd_feedback_manager_get_dev_vibra (FbdFeedbackManager *self); FbdDevSound *fbd_feedback_manager_get_dev_sound (FbdFeedbackManager *self); FbdDevLeds *fbd_feedback_manager_get_dev_leds (FbdFeedbackManager *self); +void fbd_feedback_manager_load_theme (FbdFeedbackManager *self); gboolean fbd_feedback_manager_set_profile (FbdFeedbackManager *self, const gchar *profile); G_END_DECLS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/src/fbd-ledctrl.c new/feedbackd-0.0.1/src/fbd-ledctrl.c --- old/feedbackd-0.0.0+git20211018/src/fbd-ledctrl.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/src/fbd-ledctrl.c 2022-11-11 11:02:17.000000000 +0100 @@ -17,6 +17,7 @@ #include <unistd.h> #define LED_BRIGHTNESS_ATTR "brightness" +#define LED_MULTI_INTENSITY_ATTR "multi_intensity" #define LED_PATTERN_ATTR "pattern" #define LED_REPEAT_ATTR "repeat" #define LED_TRIGGER_ATTR "trigger" @@ -126,6 +127,9 @@ if (!set_sysfs_attr_perm (sysfs_path, LED_BRIGHTNESS_ATTR, group->gr_gid)) return FALSE; + // Attribute is optional + set_sysfs_attr_perm (sysfs_path, LED_MULTI_INTENSITY_ATTR, group->gr_gid); + if (!g_strcmp0 (trigger, LED_TRIGGER_PATTERN)) { if (!set_sysfs_attr_perm (sysfs_path, LED_PATTERN_ATTR, group->gr_gid)) success = FALSE; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/src/fbd.c new/feedbackd-0.0.1/src/fbd.c --- old/feedbackd-0.0.0+git20211018/src/fbd.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/src/fbd.c 2022-11-11 11:02:17.000000000 +0100 @@ -18,30 +18,43 @@ static GMainLoop *loop; -GQuark fbd_error_quark(void) +GQuark +fbd_error_quark (void) { - static GQuark quark = 0; + static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string("fbd"); + if (!quark) + quark = g_quark_from_static_string("fbd"); - return quark; + return quark; } static gboolean quit_cb (gpointer user_data) { - g_info ("Caught signal, shutting down..."); + g_info ("Caught signal, shutting down..."); - if (loop) - g_idle_add ((GSourceFunc) g_main_loop_quit, loop); - else - exit (0); + if (loop) + g_idle_add ((GSourceFunc) g_main_loop_quit, loop); + else + exit (0); - return FALSE; + return FALSE; } +static gboolean +reload_cb (gpointer user_data) +{ + FbdFeedbackManager *manager = fbd_feedback_manager_get_default(); + + g_return_val_if_fail (FBD_IS_FEEDBACK_MANAGER (manager), FALSE); + + g_debug ("Caught signal, reloading feedback theme..."); + fbd_feedback_manager_load_theme (manager); + + return TRUE; +} static void bus_acquired_cb (GDBusConnection *connection, @@ -102,6 +115,7 @@ g_unix_signal_add (SIGTERM, quit_cb, NULL); g_unix_signal_add (SIGINT, quit_cb, NULL); + g_unix_signal_add (SIGHUP, reload_cb, NULL); loop = g_main_loop_new (NULL, FALSE); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/tests/test-lfb-event.c new/feedbackd-0.0.1/tests/test-lfb-event.c --- old/feedbackd-0.0.0+git20211018/tests/test-lfb-event.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/tests/test-lfb-event.c 2022-11-11 11:02:17.000000000 +0100 @@ -47,7 +47,6 @@ test_lfb_event_trigger (void) { g_autoptr(LfbEvent) event = NULL; - g_autofree gchar *evname = NULL; g_autoptr (GError) err = NULL; g_assert_true (lfb_init (TEST_APP_ID, NULL)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/feedbackd-0.0.0+git20211018/tests/test-lfb-integration.c new/feedbackd-0.0.1/tests/test-lfb-integration.c --- old/feedbackd-0.0.0+git20211018/tests/test-lfb-integration.c 2021-10-19 13:15:28.000000000 +0200 +++ new/feedbackd-0.0.1/tests/test-lfb-integration.c 2022-11-11 11:02:17.000000000 +0100 @@ -60,6 +60,8 @@ lfb_event_get_event (event), lfb_event_get_end_reason (event)); + g_assert_cmpint (lfb_event_get_state (event), ==, LFB_EVENT_STATE_ENDED); + /* "Return" event */ *cmp = event; } @@ -68,9 +70,7 @@ test_lfb_integration_event_sync (void) { g_autoptr(LfbEvent) event0 = NULL; - g_autoptr(LfbEvent) event1 = NULL; g_autoptr(LfbEvent) event10 = NULL; - g_autofree gchar *evname = NULL; g_autoptr (GError) err = NULL; LfbEvent *cmp = NULL; gboolean success; @@ -103,7 +103,6 @@ test_lfb_integration_event_not_found (void) { g_autoptr(LfbEvent) event0 = NULL; - g_autofree gchar *evname = NULL; g_autoptr (GError) err = NULL; LfbEvent *cmp = NULL; gboolean success; @@ -125,8 +124,8 @@ static void on_event_triggered (LfbEvent *event, - GAsyncResult *res, - LfbEvent **cmp) + GAsyncResult *res, + LfbEvent **cmp) { g_autoptr (GError) err = NULL; gboolean success; @@ -139,6 +138,30 @@ g_assert_no_error (err); g_assert_true (success); + g_assert_cmpint (lfb_event_get_state (event), ==, LFB_EVENT_STATE_RUNNING); + + /* "Return" event */ + *cmp = event; +} + +static void +on_event_triggered_quit (LfbEvent *event, + GAsyncResult *res, + LfbEvent **cmp) +{ + g_autoptr (GError) err = NULL; + gboolean success; + + g_assert_true (LFB_IS_EVENT (event)); + g_assert_null (*cmp); + + 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); + + g_assert_cmpint (lfb_event_get_state (event), ==, LFB_EVENT_STATE_RUNNING); + /* "Return" event */ *cmp = event; g_main_loop_quit (mainloop); @@ -160,25 +183,52 @@ g_assert_no_error (err); g_assert_true (success); + /* This is not guaranteed for all types of feedback, see `feedback-ended` */ + g_assert_cmpint (lfb_event_get_state (event), ==, LFB_EVENT_STATE_ENDED); + /* "Return" event */ *cmp = event; g_main_loop_quit (mainloop); } static void +test_lfb_integration_event_not_found_async (void) +{ + g_autoptr(LfbEvent) event0 = NULL; + LfbEvent *cmp = NULL; + LfbEvent *cmp2 = NULL; + + event0 = lfb_event_new ("test-does-not-exist"); + g_signal_connect (event0, "feedback-ended", (GCallback)on_feedback_ended, &cmp2); + + /* The main loop will only quit if the "feedback-ended" signal actually gets emitted */ + g_signal_connect_swapped (event0, "feedback-ended", (GCallback)g_main_loop_quit, mainloop); + + lfb_event_trigger_feedback_async (event0, + NULL, + (GAsyncReadyCallback)on_event_triggered, + &cmp); + g_main_loop_run (mainloop); + + /* If the signal fired cmp will match event */ + g_assert_true (event0 == cmp); + g_assert_true (event0 == cmp2); + g_assert_cmpint (lfb_event_get_state (event0), ==, LFB_EVENT_STATE_ENDED); + g_assert_cmpint (lfb_event_get_end_reason (event0), ==, LFB_EVENT_END_REASON_NOT_FOUND); +} + +static void test_lfb_integration_event_async (void) { g_autoptr(LfbEvent) event0 = NULL; g_autoptr(LfbEvent) event10 = NULL; - g_autofree gchar *evname = NULL; - g_autoptr (GError) err = NULL; 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, - &cmp1); + NULL, + (GAsyncReadyCallback)on_event_triggered_quit, + &cmp1); g_main_loop_run (mainloop); /* The async finish callback saw the right event */ g_assert_true (event0 == cmp1); @@ -192,16 +242,16 @@ /* The async callback ends the main loop */ lfb_event_trigger_feedback_async (event10, - NULL, - (GAsyncReadyCallback)on_event_triggered, - &cmp2); + NULL, + (GAsyncReadyCallback)on_event_triggered_quit, + &cmp2); g_main_loop_run (mainloop); /* The async callback ends the main loop */ lfb_event_end_feedback_async (event10, - NULL, - (GAsyncReadyCallback)on_event_end_finished, - &cmp3); + NULL, + (GAsyncReadyCallback)on_event_end_finished, + &cmp3); g_main_loop_run (mainloop); /* Check if callbacks saw the right event */ @@ -244,9 +294,9 @@ /* Empty event names are invalid */ event0 = lfb_event_new (""); lfb_event_trigger_feedback_async (event0, - NULL, - (GAsyncReadyCallback)on_event_with_error_triggered, - &cmp1); + NULL, + (GAsyncReadyCallback)on_event_with_error_triggered, + &cmp1); g_main_loop_run (mainloop); /* The async finish callback saw the right event */ g_assert_true (event0 == cmp1); @@ -266,7 +316,6 @@ static void test_lfb_integration_profile (void) { - g_autoptr (GError) err = NULL; LfbGdbusFeedback *proxy; gchar *cmp = NULL; @@ -287,29 +336,34 @@ g_test_init (&argc, &argv, NULL); g_test_add("/feedbackd/lfb-integration/event_sync", TestFixture, NULL, - (gpointer)fixture_setup, - (gpointer)test_lfb_integration_event_sync, - (gpointer)fixture_teardown); + (gpointer)fixture_setup, + (gpointer)test_lfb_integration_event_sync, + (gpointer)fixture_teardown); g_test_add("/feedbackd/lfb-integration/event_async/success", TestFixture, NULL, - (gpointer)fixture_setup, - (gpointer)test_lfb_integration_event_async, - (gpointer)fixture_teardown); + (gpointer)fixture_setup, + (gpointer)test_lfb_integration_event_async, + (gpointer)fixture_teardown); g_test_add("/feedbackd/lfb-integration/event_async/error", TestFixture, NULL, - (gpointer)fixture_setup, - (gpointer)test_lfb_integration_event_async_error, - (gpointer)fixture_teardown); + (gpointer)fixture_setup, + (gpointer)test_lfb_integration_event_async_error, + (gpointer)fixture_teardown); g_test_add("/feedbackd/lfb-integration/event_not_found", TestFixture, NULL, - (gpointer)fixture_setup, - (gpointer)test_lfb_integration_event_not_found, - (gpointer)fixture_teardown); + (gpointer)fixture_setup, + (gpointer)test_lfb_integration_event_not_found, + (gpointer)fixture_teardown); + + g_test_add("/feedbackd/lfb-integration/event_not_found_async", TestFixture, NULL, + (gpointer)fixture_setup, + (gpointer)test_lfb_integration_event_not_found_async, + (gpointer)fixture_teardown); g_test_add("/feedbackd/lfb-integration/profile", TestFixture, NULL, - (gpointer)fixture_setup, - (gpointer)test_lfb_integration_profile, - (gpointer)fixture_teardown); + (gpointer)fixture_setup, + (gpointer)test_lfb_integration_profile, + (gpointer)fixture_teardown); return g_test_run(); } ++++++ feedbackd.obsinfo ++++++ --- /var/tmp/diff_new_pack.UU7Kjb/_old 2022-12-05 18:02:42.769075491 +0100 +++ /var/tmp/diff_new_pack.UU7Kjb/_new 2022-12-05 18:02:42.773075513 +0100 @@ -1,5 +1,5 @@ name: feedbackd -version: 0.0.0+git20211018 -mtime: 1634642128 -commit: 753fff3e7ae1d0bce4f58cef721e45c50c404786 +version: 0.0.1 +mtime: 1668160937 +commit: 99c12e77d830ac8b0316c032bddd3ef082c66c72