bridge (dbus): export the D-Bus name only once the plugins are loaded:

client connecting too early were seeing an incomplete plugin interface.
This commit is contained in:
Goffi 2026-10-08 16:25:07 +02:00
commit b4f88480db
3 changed files with 13 additions and 6 deletions

View file

@ -123,7 +123,7 @@ class bridge:
async def post_init(self):
try:
conn = await client.connect(reactor)
self.conn = await client.connect(reactor)
except error.DBusException as e:
if e.errName == "org.freedesktop.DBus.Error.NotSupported":
log.error(
@ -134,8 +134,9 @@ class bridge:
)
raise BridgeInitError(str(e))
conn.exportObject(self._obj)
await conn.requestBusName(const_INT_PREFIX)
async def export(self):
self.conn.exportObject(self._obj)
await self.conn.requestBusName(const_INT_PREFIX)
##SIGNALS_PART##
def register_method(self, name, callback):

View file

@ -571,7 +571,7 @@ class bridge:
async def post_init(self):
try:
conn = await client.connect(reactor)
self.conn = await client.connect(reactor)
except error.DBusException as e:
if e.errName == "org.freedesktop.DBus.Error.NotSupported":
log.error(
@ -582,8 +582,9 @@ class bridge:
)
raise BridgeInitError(str(e))
conn.exportObject(self._obj)
await conn.requestBusName(const_INT_PREFIX)
async def export(self):
self.conn.exportObject(self._obj)
await self.conn.requestBusName(const_INT_PREFIX)
def _debug(self, action, params, profile):
self._obj.emitSignal("_debug", action, params, profile)

View file

@ -305,6 +305,11 @@ class LiberviaBackend(service.Service):
log.exception(f"Could not initialize backend")
self.stop(exit_code=C.EXIT_ERROR)
return
# the bridge must be exported only once the plugins have been imported, so
# that clients can introspect the whole plugin interface
if hasattr(self.bridge, "export"):
await self.bridge.export()
self._add_base_menus()
self.init_pre_script.callback(None)