diff options
| author | Muhammad Asif <thevancedgamer@mentallysanemainliners.org> | 2025-05-19 22:22:08 +0200 |
|---|---|---|
| committer | Muhammad <thevancedgamer@mentallysanemainliners.org> | 2025-06-23 23:56:57 +0500 |
| commit | 5b45748c5dc9c2d1718b6219e30a64e07e5ca313 (patch) | |
| tree | e97a51abc7a8e6226975740470a24c05abcb13ce /src/service.vala | |
| parent | cd978f758a34f636a375383b1456f4a636a97be5 (diff) | |
| download | ayatana-indicator-bluetooth-5b45748c5dc9c2d1718b6219e30a64e07e5ca313.tar.gz ayatana-indicator-bluetooth-5b45748c5dc9c2d1718b6219e30a64e07e5ca313.tar.bz2 ayatana-indicator-bluetooth-5b45748c5dc9c2d1718b6219e30a64e07e5ca313.zip | |
ayatana-indicator-bluetooth: add initial pairing agent
Co-authored-by: Robert Tari <robert@tari.in>
Signed-off-by: Muhammad Asif <thevancedgamer@mentallysanemainliners.org>
Diffstat (limited to 'src/service.vala')
| -rw-r--r-- | src/service.vala | 22 |
1 files changed, 22 insertions, 0 deletions
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<string,Profile> 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<string,Profile> (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"); |
