1
0
forked from drath/libratbag

RatbagdDevice: add a Resync signal

This signal is emitted upon an internal error, signalling clients to
resync their values.

Related to #316.
This commit is contained in:
Jente Hidskes
2017-09-11 20:16:13 +02:00
committed by Peter Hutterer
parent 2473f66cb3
commit d990e3f027
3 changed files with 22 additions and 2 deletions

View File

@@ -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
===============================

View File

@@ -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);

View File

@@ -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);