diff --git a/blueman/bluez/AgentManager.py b/blueman/bluez/AgentManager.py index 9f266e1b5..fc891054f 100644 --- a/blueman/bluez/AgentManager.py +++ b/blueman/bluez/AgentManager.py @@ -11,12 +11,16 @@ class AgentManager(Base): def __init__(self) -> None: super().__init__(obj_path=self._obj_path) - def register_agent(self, agent_path: str, capability: str = "", default: bool = False) -> None: + def register_agent(self, agent_path: ObjectPath, capability: str = "") -> None: + def on_reply() -> None: + self.request_default_agent(agent_path) + param = GLib.Variant('(os)', (agent_path, capability)) - self._call('RegisterAgent', param) - if default: - default_param = GLib.Variant('(o)', (agent_path,)) - self._call('RequestDefaultAgent', default_param) + self._call('RegisterAgent', param=param, reply_handler=on_reply) + + def request_default_agent(self, agent_path: ObjectPath) -> None: + default_param = GLib.Variant('(o)', (agent_path,)) + self._call('RequestDefaultAgent', default_param) def unregister_agent(self, agent_path: str) -> None: param = GLib.Variant('(o)', (agent_path,)) diff --git a/blueman/main/applet/BluezAgent.py b/blueman/main/applet/BluezAgent.py index 121b59a50..93a9c56f6 100644 --- a/blueman/main/applet/BluezAgent.py +++ b/blueman/main/applet/BluezAgent.py @@ -30,7 +30,7 @@ class BluezErrorRejected(DbusError): class BluezAgent(DbusService): - __agent_path = '/org/bluez/agent/blueman' + __agent_path = ObjectPath('/org/bluez/agent/blueman') def __init__(self) -> None: super().__init__(None, "org.bluez.Agent1", self.__agent_path, Gio.BusType.SYSTEM) @@ -52,12 +52,12 @@ def __init__(self) -> None: self._service_notifications: list[_NotificationBubble | _NotificationDialog] = [] def register_agent(self) -> None: - logging.info("Register Agent") + logging.debug(self.__agent_path) self.register() - AgentManager().register_agent(self.__agent_path, "KeyboardDisplay", default=True) + AgentManager().register_agent(self.__agent_path, "KeyboardDisplay") def unregister_agent(self) -> None: - logging.info("Unregister Agent") + logging.debug(self.__agent_path) self.unregister() AgentManager().unregister_agent(self.__agent_path)