From 2cd3b8a2a1c040ea643c5b08e63e2c26addc5ee3 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 27 Oct 2024 01:17:28 +0200 Subject: docs(bluetooth): doc comments --- lib/bluetooth/bluetooth.vala | 50 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'lib/bluetooth/bluetooth.vala') diff --git a/lib/bluetooth/bluetooth.vala b/lib/bluetooth/bluetooth.vala index ce086ba..6eb6b76 100644 --- a/lib/bluetooth/bluetooth.vala +++ b/lib/bluetooth/bluetooth.vala @@ -1,11 +1,21 @@ namespace AstalBluetooth { -public Bluetooth get_default() { - return Bluetooth.get_default(); + /** + * Gets the default singleton Bluetooth object. + */ + public Bluetooth get_default() { + return Bluetooth.get_default(); + } } -public class Bluetooth : Object { +/** + * Manager object for `org.bluez`. + */ +public class AstalBluetooth.Bluetooth : Object { private static Bluetooth _instance; + /** + * Gets the default singleton Bluetooth object. + */ public static Bluetooth get_default() { if (_instance == null) _instance = new Bluetooth(); @@ -21,30 +31,59 @@ public class Bluetooth : Object { private HashTable _devices = new HashTable(str_hash, str_equal); + /** + * Emitted when a new device is registered on the `org.bluez` bus. + */ public signal void device_added (Device device) { notify_property("devices"); } + /** + * Emitted when a device is unregistered on the `org.bluez` bus. + */ public signal void device_removed (Device device) { notify_property("devices"); } + /** + * Emitted when an adapter is registered on the `org.bluez` bus. + */ public signal void adapter_added (Adapter adapter) { notify_property("adapters"); } + /** + * Emitted when an adapter is unregistered on the `org.bluez` bus. + */ public signal void adapter_removed (Adapter adapter) { notify_property("adapters"); } + /** + * `true` if any of the [property@AstalBluetooth.Bluetooth:adapters] are powered. + */ public bool is_powered { get; private set; default = false; } + + /** + * `true` if any of the [property@AstalBluetooth.Bluetooth:devices] is connected. + */ public bool is_connected { get; private set; default = false; } + + /** + * The first registered adapter which is usually the only adapter. + */ public Adapter? adapter { get { return adapters.nth_data(0); } } + /** + * List of adapters available on the host device. + */ public List adapters { owned get { return _adapters.get_values(); } } + /** + * List of registered devices on the `org.bluez` bus. + */ public List devices { owned get { return _devices.get_values(); } } @@ -85,6 +124,10 @@ public class Bluetooth : Object { } } + /** + * Toggle the [property@AstalBluetooth.Adapter:powered] + * property of the [property@AstalBluetooth.Bluetooth:adapter]. + */ public void toggle() { adapter.powered = !adapter.powered; } @@ -178,4 +221,3 @@ public class Bluetooth : Object { return false; } } -} -- cgit v1.2.3