diff options
| author | Charles Kerr <charles.kerr@canonical.com> | 2013-10-15 16:12:42 +0000 |
|---|---|---|
| committer | Tarmac <> | 2013-10-15 16:12:42 +0000 |
| commit | 08f4099365f311c4f94ce348902382987adc8f56 (patch) | |
| tree | fe4e36dd816d0a4a1977132b9ac14cb26b3594fc /src/bluetooth.vala | |
| parent | 5fb78027ee730e151d8307623ed0ffcfbac024f5 (diff) | |
| parent | 73cc5b06408e95c0401cb3cd3c2249f9376f2606 (diff) | |
| download | ayatana-indicator-bluetooth-08f4099365f311c4f94ce348902382987adc8f56.tar.gz ayatana-indicator-bluetooth-08f4099365f311c4f94ce348902382987adc8f56.tar.bz2 ayatana-indicator-bluetooth-08f4099365f311c4f94ce348902382987adc8f56.zip | |
When the user chooses to toggle bluetooth on or off, if /dev/rfkill isn't available, fall back to toggling org.bluez.Adapter's Powered property. Fixes: https://bugs.launchpad.net/bugs/1230275, https://bugs.launchpad.net/bugs/1236249.
Approved by Ted Gould, PS Jenkins bot.
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); -} |
