From 5a14c4f435040a77f4fda33a537e0029e7e678fe Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 14 Oct 2013 12:50:05 -0500 Subject: if killswitch exists and is valid, prefer its use over toggling org.bluez.Adapter's Powered property --- src/bluez.vala | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src') 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 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)"); + } } } } -- cgit v1.2.3