aboutsummaryrefslogtreecommitdiff
path: root/src/killswitch.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/killswitch.vala')
-rw-r--r--src/killswitch.vala23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/killswitch.vala b/src/killswitch.vala
index 92b1a3c..cf5c6c8 100644
--- a/src/killswitch.vala
+++ b/src/killswitch.vala
@@ -20,13 +20,24 @@
/**
* Monitors whether or not bluetooth is blocked,
* either by software (e.g., a session configuration setting)
- * or by hardware (e.g., user disabled it via a physical switch on her laptop)
+ * or by hardware (e.g., user disabled it via a physical switch on her laptop).
+ *
+ * The Bluetooth class uses this as a backend for its 'blocked' property.
+ * Other code can't even see this, so use Bluetooth.blocked instead. :)
*/
public class KillSwitch: Object
{
public bool blocked { get; protected set; default = false; }
- public void try_set_blocked (bool blocked)
+ public virtual void try_set_blocked (bool blocked) {}
+}
+
+/**
+ * On Linux systems, monitors /dev/rfkill to watch for bluetooth blockage
+ */
+public class RfKillSwitch: KillSwitch
+{
+ public override void try_set_blocked (bool blocked)
{
return_if_fail (this.blocked != blocked);
@@ -42,10 +53,6 @@ public class KillSwitch: Object
warning ("Could not write rfkill event: %s", strerror(errno));
}
- /***
- **** Past this point, it's all RfKill implementation details...
- ***/
-
private class Entry
{
public uint32 idx;
@@ -68,13 +75,13 @@ public class KillSwitch: Object
return false;
}
- ~KillSwitch ()
+ ~RfKillSwitch ()
{
Source.remove (watch);
Posix.close (fd);
}
- public KillSwitch ()
+ public RfKillSwitch ()
{
entries = new HashTable<uint32,Entry>(direct_hash, direct_equal);