diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-10-11 08:38:51 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-10-11 08:38:51 -0500 |
commit | f7ca11b202e442e759cca86a70d9c6d027e82e76 (patch) | |
tree | 144aabb1f6df9fa060bd4418fb26857d5055dc75 /src/bluetooth.vala | |
parent | 3145f10632a3ce7ee33e8cdaa78401d7eb881f4e (diff) | |
download | ayatana-indicator-bluetooth-f7ca11b202e442e759cca86a70d9c6d027e82e76.tar.gz ayatana-indicator-bluetooth-f7ca11b202e442e759cca86a70d9c6d027e82e76.tar.bz2 ayatana-indicator-bluetooth-f7ca11b202e442e759cca86a70d9c6d027e82e76.zip |
if /dev/rfkill doesn't exist or isn't writable, then try to handle bluetooth toggles simply by toggling bluez Adapters' Powered property
Diffstat (limited to 'src/bluetooth.vala')
-rw-r--r-- | src/bluetooth.vala | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/src/bluetooth.vala b/src/bluetooth.vala index 100bdf2..b268701 100644 --- a/src/bluetooth.vala +++ b/src/bluetooth.vala @@ -27,22 +27,19 @@ public interface Bluetooth: Object This work as a proxy for "does this hardware support bluetooth?" */ public abstract bool supported { get; protected set; } - /* True if there are any bluetooth adapters powered up on the system. - In short, whether or not this system's bluetooth is "on". */ - public abstract bool powered { get; protected set; } + /* True if bluetooth's enabled on this system. + Bluetooth can be soft-blocked by software and hard-blocked physically, + eg by a laptop's network killswitch */ + public abstract bool enabled { get; protected set; } + + /* Try to enable/disable bluetooth. This can fail if it's overridden + by the system, eg by a laptop's network killswitch */ + public abstract void try_set_enabled (bool b); /* True if our system can be seen by other bluetooth devices */ public abstract bool discoverable { get; protected set; } public abstract void try_set_discoverable (bool discoverable); - /* True if bluetooth's blocked. This can be soft-blocked by software and - * hard-blocked physically, eg by a laptop's network killswitch */ - public abstract bool blocked { get; protected set; } - - /* Try to block/unblock bluetooth. This can fail if it's overridden - by the system, eg by a laptop's network killswitch */ - public abstract void try_set_blocked (bool b); - /* Get a list of the Device structs that we know about */ public abstract List<unowned Device> get_devices (); @@ -53,33 +50,3 @@ public interface Bluetooth: Object The device_key argument comes from the Device struct */ public abstract void set_device_connected (uint device_key, bool connected); } - - - -/** - * Base class for Bluetooth objects that use a killswitch to implement - * the 'discoverable' property. - */ -public abstract class KillswitchBluetooth: Object, Bluetooth -{ - private KillSwitch killswitch; - - public KillswitchBluetooth (KillSwitch killswitch) - { - // always sync our 'blocked' property with the one in killswitch - this.killswitch = killswitch; - blocked = killswitch.blocked; - killswitch.notify["blocked"].connect (() => blocked = killswitch.blocked ); - } - - public bool supported { get; protected set; default = false; } - public bool powered { get; protected set; default = false; } - public bool discoverable { get; protected set; default = false; } - public bool blocked { get; protected set; default = true; } - public void try_set_blocked (bool b) { killswitch.try_set_blocked (b); } - - // empty implementations - public abstract void try_set_discoverable (bool b); - public abstract List<unowned Device> get_devices (); - public abstract void set_device_connected (uint device_key, bool connected); -} |