From 5b45748c5dc9c2d1718b6219e30a64e07e5ca313 Mon Sep 17 00:00:00 2001 From: Muhammad Asif Date: Mon, 19 May 2025 22:22:08 +0200 Subject: ayatana-indicator-bluetooth: add initial pairing agent Co-authored-by: Robert Tari Signed-off-by: Muhammad Asif --- src/service.vala | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 80ccea6..b79056e 100644 --- a/src/service.vala +++ b/src/service.vala @@ -29,6 +29,7 @@ public class Service: Object private MainLoop loop; private SimpleActionGroup actions; private HashTable profiles; + private Bluetooth bluez; private DBusConnection connection; private uint exported_action_id; private const string OBJECT_PATH = "/org/ayatana/indicator/bluetooth"; @@ -52,6 +53,7 @@ public class Service: Object public Service (Bluetooth bluetooth) { actions = new SimpleActionGroup (); + bluez = bluetooth; profiles = new HashTable (str_hash, str_equal); profiles.insert ("phone", new Phone (bluetooth, actions)); @@ -74,15 +76,35 @@ public class Service: Object null, on_name_lost); + var system_name_id = Bus.own_name (BusType.SYSTEM, + "org.ayatana.indicator.bluetooth", + BusNameOwnerFlags.NONE, + on_system_bus_acquired, + null, + null); + loop = new MainLoop (null, false); loop.run (); // cleanup unexport (); Bus.unown_name (own_name_id); + Bus.unown_name (system_name_id); return Posix.EXIT_SUCCESS; } + void on_system_bus_acquired (DBusConnection connection, string name) + { + try + { + connection.register_object ("/agent", new Agent (bluez)); + } + catch (GLib.IOError pError) + { + warning ("Panic: Failed registering pairing agent: %s", pError.message); + } + } + void on_bus_acquired (DBusConnection connection, string name) { debug (@"bus acquired: $name"); -- cgit v1.2.3