From f8b0de37a80b636defa01a8fdcb505b115207e6b Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Sun, 2 Jul 2017 19:20:45 -0700 Subject: [PATCH] add 'disallow_device()' function to devicemanager.vala and devicemanager-proxy.vala --- src/mconnect/devicemanager-proxy.vala | 21 ++++++++++++++++++++- src/mconnect/devicemanager.vala | 15 ++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 061f4e5..22de62c 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -68,6 +68,25 @@ class DeviceManagerDBusProxy : Object this.manager.allow_device(dev_proxy.device); } + /** + * disallow_device: + * @path: device object path + * + * Disallow given device + */ + public void disallow_device(string path) { + debug("disallow device %s", path); + + var dev_proxy = this.devices.@get(path); + + if (dev_proxy == null) { + warning("no device under path %s", path); + return; + } + + this.manager.disallow_device(dev_proxy.device); + } + /** * list_devices: * @@ -143,4 +162,4 @@ class DeviceManagerDBusProxy : Object return path; } -} \ No newline at end of file +} diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index df01a50..4463f37 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -252,4 +252,17 @@ class DeviceManager : GLib.Object // maybe activate if needed activate_device(dev); } -} \ No newline at end of file + + /** + * disallow_device: + * @path: device object path + * + * Disallow given device + */ + public void disallow_device(Device dev) { + dev.allowed = false; + + // update device cache + update_cache(); + } +}