Browse Source

devicemanager, proxy: proper 'new device' signal

bboozzoo/dbus-support-interfaces
Maciek Borzecki 8 years ago
parent
commit
bb45b12751
2 changed files with 8 additions and 3 deletions
  1. +1
    -1
      src/mconnect/devicemanager-proxy.vala
  2. +7
    -2
      src/mconnect/devicemanager.vala

+ 1
- 1
src/mconnect/devicemanager-proxy.vala View File

@ -36,7 +36,7 @@ class DeviceManagerDBusProxy : Object
this.bus = bus; this.bus = bus;
this.devices = new HashMap<string, DeviceDBusProxy>(); this.devices = new HashMap<string, DeviceDBusProxy>();
manager.found_device.connect((d) => {
manager.found_new_device.connect((d) => {
this.add_device(d); this.add_device(d);
}); });
} }


+ 7
- 2
src/mconnect/devicemanager.vala View File

@ -21,7 +21,7 @@ using Gee;
class DeviceManager : GLib.Object class DeviceManager : GLib.Object
{ {
public signal void found_device(Device dev);
public signal void found_new_device(Device dev);
public const string DEVICES_CACHE_FILE = "devices"; public const string DEVICES_CACHE_FILE = "devices";
@ -67,7 +67,7 @@ class DeviceManager : GLib.Object
var dev = Device.new_from_cache(kf, group); var dev = Device.new_from_cache(kf, group);
if (dev != null) { if (dev != null) {
debug("device %s from cache", dev.to_string()); debug("device %s from cache", dev.to_string());
found_device(dev);
handle_new_device(dev);
} }
} }
} catch (Error e) { } catch (Error e) {
@ -133,6 +133,11 @@ class DeviceManager : GLib.Object
} else { } else {
message("skipping device %s activation, device not allowed", dev.to_string()); message("skipping device %s activation, device not allowed", dev.to_string());
} }
// notify everyone that a new device appeared
if (is_new) {
found_new_device(dev);
}
} }
private void activate_device(Device dev) { private void activate_device(Device dev) {


Loading…
Cancel
Save