diff options
Diffstat (limited to 'lib/bluetooth/device.vala')
-rw-r--r-- | lib/bluetooth/device.vala | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/bluetooth/device.vala b/lib/bluetooth/device.vala index 3f00cd9..b38a5ce 100644 --- a/lib/bluetooth/device.vala +++ b/lib/bluetooth/device.vala @@ -3,6 +3,7 @@ */ public class AstalBluetooth.Device : Object { private IDevice proxy; + private Battery battery; internal ObjectPath object_path { owned get; private set; } @@ -20,6 +21,15 @@ public class AstalBluetooth.Device : Object { }); } + internal void set_battery(Battery battery) { + this.battery = battery; + + notify_property("battery_percentage"); + battery.notify["percentage"].connect((obj, pspec) => { + notify_property("battery_percentage"); + }); + } + /** * List of 128-bit UUIDs that represents the available remote services. */ @@ -104,6 +114,16 @@ public class AstalBluetooth.Device : Object { } /** + * The percentage of battery left on the device if it has one, else -1. + */ + public double battery_percentage { + get { + if (battery != null) return battery.percentage * 0.01; + else return -1; + } + } + + /** * The name alias for the remote device. * * In case no alias is set, it will return the remote device [[email protected]:name]. @@ -137,6 +157,7 @@ public class AstalBluetooth.Device : Object { yield proxy.disconnect(); } + /** * This method connects a specific profile of this device. * The UUID provided is the remote service UUID for the profile. |