1 /* 2 * Copyright (C) 2020 Purism SPC 3 * 4 * SPDX-License-Identifier: GPL-3.0+ 5 */ 6 #pragma once 7 8 #include <gio/gio.h> 9 #include <glib-object.h> 10 11 #if !defined (__LIBFEEDBACK_H_INSIDE__) && !defined (LIBFEEDBACK_COMPILATION) 12 #error "Only <libfeedback.h> can be included directly." 13 #endif 14 15 G_BEGIN_DECLS 16 17 /** 18 * LfbEventState: 19 * @LFB_EVENT_STATE_ERRORED: An error occurred triggering feedbacks 20 * @LFB_EVENT_STATE_NONE: No state information yet 21 * @LFB_EVENT_STATE_RUNNING: The feedbacks for this event are currently running 22 * @LFB_EVENT_STATE_ENDED: All feedbacks for this event ended 23 * 24 * Enum values to indicate the current state of the feedbacks 25 * triggered by an event. 26 */ 27 28 typedef enum _LfbEventState { 29 LFB_EVENT_STATE_ERRORED = -1, 30 LFB_EVENT_STATE_NONE = 0, 31 LFB_EVENT_STATE_RUNNING = 1, 32 LFB_EVENT_STATE_ENDED = 2, 33 } LfbEventState; 34 35 /** 36 * LfbEventEndReason: 37 * @LFB_EVENT_END_REASON_NOT_FOUND: There was no feedback in the current theme for this event 38 * so no feedback was provided to the user. 39 * @LFB_EVENT_END_REASON_NATURAL: All feedbacks finished playing their natural length 40 * @LFB_EVENT_END_REASON_EXPIRED: Feedbacks ran until the set timeout expired 41 * @LFB_EVENT_END_REASON_EXPLICIT: The feedbacks were ended explicitly 42 * 43 * Enum values used to indicate why the feedbacks for an event ended. 44 **/ 45 typedef enum _LfbEventEndReason { 46 47 LFB_EVENT_END_REASON_NOT_FOUND = -1, 48 LFB_EVENT_END_REASON_NATURAL = 0, 49 LFB_EVENT_END_REASON_EXPIRED = 1, 50 LFB_EVENT_END_REASON_EXPLICIT = 2, 51 } LfbEventEndReason; 52 53 #define LFB_TYPE_EVENT (lfb_event_get_type()) 54 55 G_DECLARE_FINAL_TYPE (LfbEvent, lfb_event, LFB, EVENT, GObject) 56 57 LfbEvent* lfb_event_new (const char *event); 58 gboolean lfb_event_trigger_feedback (LfbEvent *self, GError **error); 59 void lfb_event_trigger_feedback_async (LfbEvent *self, 60 GCancellable *cancellable, 61 GAsyncReadyCallback callback, 62 gpointer user_data); 63 gboolean lfb_event_trigger_feedback_finish (LfbEvent *self, 64 GAsyncResult *res, 65 GError **error); 66 gboolean lfb_event_end_feedback (LfbEvent *self, GError **error); 67 void lfb_event_end_feedback_async (LfbEvent *self, 68 GCancellable *cancellable, 69 GAsyncReadyCallback callback, 70 gpointer user_data); 71 gboolean lfb_event_end_feedback_finish (LfbEvent *self, 72 GAsyncResult *res, 73 GError **error); 74 void lfb_event_set_timeout (LfbEvent *self, gint timeout); 75 gint lfb_event_get_timeout (LfbEvent *self); 76 void lfb_event_set_feedback_profile (LfbEvent *self, const char *profile); 77 char *lfb_event_get_feedback_profile (LfbEvent *self); 78 const char *lfb_event_get_event (LfbEvent *self); 79 LfbEventState lfb_event_get_state (LfbEvent *self); 80 LfbEventEndReason lfb_event_get_end_reason (LfbEvent *self); 81 82 G_END_DECLS 83