Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions blueman/bluez/AgentManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))
Expand Down
8 changes: 4 additions & 4 deletions blueman/main/applet/BluezAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
Loading