diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-10-14 12:50:05 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-10-14 12:50:05 -0500 |
commit | 5a14c4f435040a77f4fda33a537e0029e7e678fe (patch) | |
tree | be727e6fce49f31b1141a39ab5e01e3fe9efd412 /src | |
parent | f7ca11b202e442e759cca86a70d9c6d027e82e76 (diff) | |
download | ayatana-indicator-bluetooth-5a14c4f435040a77f4fda33a537e0029e7e678fe.tar.gz ayatana-indicator-bluetooth-5a14c4f435040a77f4fda33a537e0029e7e678fe.tar.bz2 ayatana-indicator-bluetooth-5a14c4f435040a77f4fda33a537e0029e7e678fe.zip |
if killswitch exists and is valid, prefer its use over toggling org.bluez.Adapter's Powered property
Diffstat (limited to 'src')
-rw-r--r-- | src/bluez.vala | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/bluez.vala b/src/bluez.vala index 82f34f4..472a16d 100644 --- a/src/bluez.vala +++ b/src/bluez.vala @@ -53,7 +53,7 @@ public class Bluez: Bluetooth, Object /* maps our arbitrary unique id to a Bluetooth.Device struct for public consumption */ HashTable<uint,Device> id_to_device; - public Bluez (KillSwitch killswitch) + public Bluez (KillSwitch? killswitch) { try { @@ -64,7 +64,7 @@ public class Bluez: Bluetooth, Object critical (@"$(e.message)"); } - if (killswitch.is_valid()) + if ((killswitch != null) && (killswitch.is_valid())) { this.killswitch = killswitch; killswitch.notify["blocked"].connect (() => update_enabled()); @@ -475,16 +475,18 @@ public class Bluez: Bluetooth, Object debug (@"setting killswitch blocked to $(!b)"); killswitch.try_set_blocked (!b); } - - if (default_adapter != null) try - { - debug (@"setting bluez Adapter's Powered property to $b"); - default_adapter.set_property ("Powered", new Variant.boolean (b)); - powered = b; - } - catch (Error e) + else { - critical (@"$(e.message)"); + if (default_adapter != null) try + { + debug (@"setting bluez Adapter's Powered property to $b"); + default_adapter.set_property ("Powered", new Variant.boolean (b)); + powered = b; + } + catch (Error e) + { + critical (@"$(e.message)"); + } } } } |