forked from drath/libratbag
Drop the Device.Id from the DBus interface
The Device is an object on DBus, there is no need for another opaque ID, we can just emulate this in the client. In our case by using the object path and generating a sha1 from it. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
cac289119d
commit
391a0e923e
10
doc/dbus.rst
10
doc/dbus.rst
@@ -98,16 +98,6 @@ org.freedesktop.ratbag1.Device
|
||||
The **org.freedesktop.ratbag1.Device** interface describes a single device
|
||||
known to ratbagd.
|
||||
|
||||
.. attribute:: Id
|
||||
|
||||
:type: as
|
||||
:flags: read-only, constant
|
||||
|
||||
A unique ID describing this device. This ID should not be used for presentation to
|
||||
the user. This ID may be recycled when the device is removed. The
|
||||
content of the ID is undefined, the client should treat it as an
|
||||
opaque string.
|
||||
|
||||
.. attribute:: Model
|
||||
|
||||
:type: s
|
||||
|
||||
@@ -217,7 +217,6 @@ ratbag_device_get_model(sd_bus *bus,
|
||||
|
||||
const sd_bus_vtable ratbagd_device_vtable[] = {
|
||||
SD_BUS_VTABLE_START(0),
|
||||
SD_BUS_PROPERTY("Id", "s", NULL, offsetof(struct ratbagd_device, sysname), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("Model", "s", ratbag_device_get_model, 0, SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("Name", "s", ratbagd_device_get_device_name, 0, SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("Profiles", "ao", ratbagd_device_get_profiles, 0, SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
|
||||
@@ -61,7 +61,7 @@ def list_devices(r, args):
|
||||
print("No devices available.")
|
||||
|
||||
for d in r.devices:
|
||||
print("{:10s} {:32s}".format(d.id + ":", d.name))
|
||||
print("{:20s} {:32s}".format(d.id + ":", d.name))
|
||||
|
||||
|
||||
def find_device(r, args):
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import hashlib
|
||||
|
||||
from enum import IntEnum
|
||||
from evdev import ecodes
|
||||
@@ -299,6 +300,9 @@ class RatbagdDevice(_RatbagdDBus):
|
||||
for profile in self._profiles:
|
||||
profile.connect("notify::is-active", self._on_active_profile_changed)
|
||||
|
||||
# Use a SHA1 of our object path as our device's ID
|
||||
self._id = hashlib.sha1(object_path.encode('utf-8')).hexdigest()
|
||||
|
||||
def _on_signal_received(self, proxy, sender_name, signal_name, parameters):
|
||||
if signal_name == "Resync":
|
||||
self.emit("resync")
|
||||
@@ -309,8 +313,7 @@ class RatbagdDevice(_RatbagdDBus):
|
||||
|
||||
@GObject.Property
|
||||
def id(self):
|
||||
"""The unique identifier of this device."""
|
||||
return self._get_dbus_property("Id")
|
||||
return self._id
|
||||
|
||||
@GObject.Property
|
||||
def model(self):
|
||||
|
||||
Reference in New Issue
Block a user