Compare commits

...

Author SHA1 Message Date
  Maciek Borzecki 4ac4102d3d incoming/outgoing interfaces WIP 8 years ago
4 changed files with 37 additions and 1 deletions
Split View
  1. +15
    -0
      src/mconnect/device-proxy.vala
  2. +4
    -0
      src/mconnect/device.vala
  3. +2
    -1
      src/mconnect/devicemanager.vala
  4. +16
    -0
      src/mconnect/discovereddevice.vala

+ 15
- 0
src/mconnect/device-proxy.vala View File

@ -62,6 +62,16 @@ class DeviceDBusProxy : Object {
default = false;
}
public string[] incoming_capabilities {
get { return device.incoming_capabilities; }
private set {}
}
public string[] outgoing_capabilities {
get { return device.outgoing_capabilities; }
private set {}
}
[DBus (visible = false)]
public Device device {get; private set; default = null; }
@ -69,5 +79,10 @@ class DeviceDBusProxy : Object {
this.device = device;
this.address = "%s:%u".printf(device.host.to_string(),
device.tcp_port);
this.device.notify.connect(this.update_properties);
}
private void update_properties(ParamSpec param) {
debug("param %s changed", param.name);
}
}

+ 4
- 0
src/mconnect/device.vala View File

@ -41,6 +41,8 @@ class Device : Object {
set {}
default = false;
}
public string[] outgoing_capabilities { get; private set; default = null; }
public string[] incoming_capabilities { get; private set; default = null; }
// set to true if pair request was sent
private bool _pair_in_progress = false;
@ -64,6 +66,8 @@ class Device : Object {
this.device_type = disc.device_type;
this.protocol_version = disc.protocol_version;
this.tcp_port = disc.tcp_port;
this.outgoing_capabilities = disc.outgoing_capabilities;
this.incoming_capabilities = disc.incoming_capabilities;
debug("new device: %s", this.to_string());
}


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

@ -147,7 +147,8 @@ class DeviceManager : GLib.Object
}
private void activate_device(Device dev) {
info("activating device %s", dev.to_string());
info("activating device %s, active: %s", dev.to_string(),
dev.is_active.to_string());
if (!dev.is_active) {
dev.paired.connect(this.device_paired);


+ 16
- 0
src/mconnect/discovereddevice.vala View File

@ -29,6 +29,8 @@ class DiscoveredDevice : Object {
public uint protocol_version {get; private set; default = 5; }
public uint tcp_port {get; private set; default = 1714; }
public InetAddress host { get; private set; default = null; }
public string[] outgoing_capabilities { get; private set; default = null; }
public string[] incoming_capabilities { get; private set; default = null; }
/**
* Constructs DiscoveredDevice based on identity packet.
@ -48,6 +50,20 @@ class DiscoveredDevice : Object {
this.protocol_version = (int) body.get_int_member("protocolVersion");
this.tcp_port = (uint) body.get_int_member("tcpPort");
var incoming = body.get_array_member("incomingCapabilities");
var outgoing = body.get_array_member("outgoingCapabilities");
this.outgoing_capabilities = new string[outgoing.get_length()];
this.incoming_capabilities = new string[incoming.get_length()];
incoming.foreach_element((a, i, n) => {
debug("in: %s", n.get_string());
this.incoming_capabilities[i] = n.get_string();
});
outgoing.foreach_element((a, i, n) => {
debug("out: %s", n.get_string());
this.outgoing_capabilities[i] = n.get_string();
});
debug("discovered new device: %s", this.to_string());
}


Loading…
Cancel
Save