From 8db2cc923b3c17fbdfbfdaab9d1ec13985f98a00 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 15 Jan 2015 20:19:21 +0100 Subject: [PATCH] devicemanager: device activation --- src/devicemanager.vala | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/devicemanager.vala b/src/devicemanager.vala index 45ee5ce..10d132b 100644 --- a/src/devicemanager.vala +++ b/src/devicemanager.vala @@ -25,10 +25,24 @@ class DeviceManager : GLib.Object public DeviceManager() { debug("device manager.."); + + this.devices = new HashMap(); } public void found_device(Device dev) { - debug("new device: %s", dev.to_string()); + debug("found device: %s", dev.to_string()); + + string unique = dev.to_unique_string(); + if (this.devices.has_key(unique) == false) { + debug("adding new device with key: %s", unique); + this.devices.@set(unique, dev); + + dev.activate(); + } else { + var known_dev = this.devices.@get(unique); + known_dev.activate_from_device(dev); + } + } } \ No newline at end of file