### Class

# Lfb Event

#### Description [src]

    final class Lfb.Event : GObject.Object
    {
      /* No available fields */
    }

An event triggering feedback to the user

`LfbEvent` represents an event that should trigger audio, haptic and/or visual feedback to the user by triggering feedback on a feedback daemon. Valid event names are specified in the Event naming specification.

One event can trigger multiple feedbacks at once (e.g. audio and haptic feedback). This is determined by the feedback theme in use (which is not under the appliction’s control) and the active feedback profile (see `lfb_set_feedback_profile()`.

After initializing the library via `lfb_init()` feedback can be triggered like:

      g_autoptr (GError) err = NULL;
      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);

When all feedback for this event has ended the `LfbEvent::feedback-ended` signal is emitted. If you want to end the feedback ahead of time use `lfb_event_end_feedback()`:

      if (!lfb_event_end_feedback (event, &err))
        g_warning ("Failed to end feedback: %s", err->message);

Since these methods involve DBus calls there are asynchronous variants available, e.g. `lfb_event_trigger_feedback_async()`:

      static void
      on_feedback_triggered (LfbEvent      *event,
                             GAsyncResult  *res,
                             gpointer      unused)
      {
         g_autoptr (GError) err = NULL;
         if (!lfb_event_trigger_feedback_finish (event, res, &err)) {
            g_warning ("Failed to trigger feedback for %s: %s",
                       lfb_event_get_event (event), err->message);
         }
      }

      static void
      my_function ()
      {
        LfbEvent *event = lfb_event_new ("message-new-instant");
        lfb_event_trigger_feedback_async (event, NULL,
                                         (GAsyncReadyCallback)on_feedback_triggered,
                                         NULL);
      }

#### Ancestors

- GObject

#### Constructors

###### lfb_event_new

Creates a new `LfbEvent` based on the given event name. See `LfbEvent:event` for details.

#### Instance methods

###### lfb_event_end_feedback

Tells the feedback server to end all feedback for the given event as soon as possible.

###### lfb_event_end_feedback_async

Tells the feedback server to end all feedback for the given event as soon as possible.

###### lfb_event_end_feedback_finish

Finish an async operation started by lfb_event_end_feedback_async. You must call this function in the callback to free memory and receive any errors which occurred.

###### lfb_event_get_app_id

Returns the app-id for this event. If no app-id has been explicitly set, `NULL` is returned. The event uses the app-id returned by `lfb_get_app_id()` in this case.

###### lfb_event_get_end_reason

Get the reason why the feadback ended.

###### lfb_event_get_event

Get the event’s name according to the event naming spec.

###### lfb_event_get_feedback_profile

Gets the set feedback profile. If no profile was set it returns `NULL`. The event uses the system wide profile in this case.

###### lfb_event_get_important

Gets the set feedback profile. If no profile was set it returns `NULL`. The event uses the system wide profile in this case.

###### lfb_event_get_sound_file

Returns the sound file for this event if set.

###### lfb_event_get_state

Get the current event state (e.g. if triggered feeedback is currently running.

###### lfb_event_get_timeout

Get the currently set timeout.

###### lfb_event_set_app_id

Tells the feedback server to use the given application id for this event when it is submitted. The server might ignore this request. This can be used by notification daemons to honor per application settings automatically.

###### lfb_event_set_feedback_profile

Tells the feedback server to use the given feedback profile for 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.

###### lfb_event_set_important

Tells the feedback server that the sender deems this to be an important event. A feedback server might allow the sender to override the current global feedback level when this is set.

###### lfb_event_set_sound_file

Tells the feedback server to use the given sound file if a sound is to be played. It will only be used if sound is suitable for the events feedback level.

###### lfb_event_set_timeout

Tells the feedback server to end feedback after #timeout seconds. The value -1 indicates to not set a timeout and let feedbacks stop on their own while 0 indicates to loop all feedbacks endlessly. They must be stopped via `lfb_event_end_feedback()` in this case.

###### lfb_event_trigger_feedback

Tells the feedback server to provide proper feedback for the give event to the user.

###### lfb_event_trigger_feedback_async

Tells the feedback server to provide proper feedback for the give event to the user. This is the sync version of `lfb_event_trigger_feedback()`.

###### lfb_event_trigger_feedback_finish

Finish an async operation started by `lfb_event_trigger_feedback_async()`. You must call this function in the callback to free memory and receive any errors which occurred.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Lfb.Event:app-id

The application id to use for the event. `lfb_event_set_feedback_profile()` for details.

###### Lfb.Event:end-reason

No description available.

###### Lfb.Event:event

The type of event from the Event naming spec, e.g. ‘message-new-instant’.

###### Lfb.Event:feedback-profile

The name of the feedback profile to use for this event. See `lfb_event_set_feedback_profile()` for details.

###### Lfb.Event:important

Whether to flag this event as important. `lfb_event_set_important()` for details.

###### Lfb.Event:sound-file

A custom sound-file to play. See `lfb_event_set_sound_file()` for details.

###### Lfb.Event:state

No description available.

###### Lfb.Event:timeout

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()`.

#### Signals

###### Lfb.Event::feedback-ended

Emitted when all feedbacks triggered by the event have ended.

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct LfbEventClass {
      GObjectClass parent_class;

    }

No description available.

###### Class members

`parent_class: GObjectClass`

  No description available.