forked from drath/libratbag
Reorder the initialisation of the ratbagd client
When the API version mismatches we want to fail early before performing any more complex initialisation. We do however have to check for devices first so that we can distinguish cases where we cannot access the daemon from those where it is too old to provide an API version.
This commit is contained in:
committed by
Filipe Laíns
parent
551b918ba8
commit
ceaa3c3ad5
@@ -250,13 +250,13 @@ class Ratbagd(_RatbagdDBus):
|
||||
|
||||
def __init__(self, api_version):
|
||||
super().__init__("Manager", None)
|
||||
result = self._get_dbus_property("Devices") or []
|
||||
self._devices = [RatbagdDevice(objpath) for objpath in result]
|
||||
self._proxy.connect("notify::g-name-owner", self._on_name_owner_changed)
|
||||
if self.api_version == None and not self._proxy.get_cached_property_names():
|
||||
result = self._get_dbus_property("Devices")
|
||||
if result is None and not self._proxy.get_cached_property_names():
|
||||
raise RatbagdUnavailable("Make sure it is running and your user is in the required groups.")
|
||||
if self.api_version != api_version:
|
||||
raise RatbagdIncompatible(self.api_version or -1, api_version)
|
||||
self._devices = [RatbagdDevice(objpath) for objpath in result or []]
|
||||
self._proxy.connect("notify::g-name-owner", self._on_name_owner_changed)
|
||||
|
||||
def _on_name_owner_changed(self, *kwargs):
|
||||
self.emit("daemon-disappeared")
|
||||
|
||||
Reference in New Issue
Block a user