diff --git a/DBusInterface.md b/DBusInterface.md index 7f46b5da..dd2ab726 100644 --- a/DBusInterface.md +++ b/DBusInterface.md @@ -20,8 +20,8 @@ unless otherwise specified. All setters (whether implicit for read-write properties or explicit) return success instead of the internal return value because DBus does not like -non-standard error values. This means that clients should check for capabilities -beforehand and that the `Commit()` method (see below) signals an error. +non-standard error values. Upon a ratbag error, the `Resync` signal is emitted +on the device, indicating that clients should resync their values. org.freedesktop.ratbag1.Manager =============================== @@ -105,6 +105,13 @@ guaranteed to be available. ratbagd may return the path to a file that doesn't exist. This is the case if the device has SVGs available but not for the given theme. +### Signals: + +#### `Resync()` + +Emitted when an internal error occurs. Upon receiving this signal, clients are +expected to resync their values with ratbagd. + org.freedesktop.ratbag1.Profile =============================== diff --git a/ratbagd/ratbagd-device.c b/ratbagd/ratbagd-device.c index 47d44f93..7f33eab2 100644 --- a/ratbagd/ratbagd-device.c +++ b/ratbagd/ratbagd-device.c @@ -278,6 +278,7 @@ const sd_bus_vtable ratbagd_device_vtable[] = { SD_BUS_PROPERTY("Profiles", "ao", ratbagd_device_get_profiles, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_METHOD("GetSvg", "s", "s", ratbagd_device_get_theme_svg, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Commit", "", "u", ratbagd_device_commit, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_SIGNAL("Resync", "", 0), SD_BUS_VTABLE_END, }; @@ -384,6 +385,17 @@ unsigned int ratbagd_device_get_num_leds(struct ratbagd_device *device) return ratbag_device_get_num_leds(device->lib_device); } +int ratbagd_device_resync(struct ratbagd_device *device, sd_bus *bus) +{ + assert(device); + assert(bus); + return sd_bus_emit_signal(bus, + device->path, + RATBAGD_NAME_ROOT ".Device", + "Resync", + NULL); +} + bool ratbagd_device_linked(struct ratbagd_device *device) { return device && rbnode_linked(&device->node); diff --git a/ratbagd/ratbagd.h b/ratbagd/ratbagd.h index 75eb9a1a..ebdabdde 100644 --- a/ratbagd/ratbagd.h +++ b/ratbagd/ratbagd.h @@ -152,6 +152,7 @@ const char *ratbagd_device_get_name(struct ratbagd_device *device); const char *ratbagd_device_get_path(struct ratbagd_device *device); unsigned int ratbagd_device_get_num_buttons(struct ratbagd_device *device); unsigned int ratbagd_device_get_num_leds(struct ratbagd_device *device); +int ratbagd_device_resync(struct ratbagd_device *device, sd_bus *bus); bool ratbagd_device_linked(struct ratbagd_device *device); void ratbagd_device_link(struct ratbagd_device *device);