From f631e8e055dfcdae440631902ed8a38eb5109cb8 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 19 Sep 2013 07:45:02 +0200 Subject: added preflight worker implementation to handle initial device pairing --- src/device.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/device.c') diff --git a/src/device.c b/src/device.c index 91712be..27e25d5 100644 --- a/src/device.c +++ b/src/device.c @@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include "device.h" #include "client.h" +#include "preflight.h" #include "usb.h" #include "log.h" @@ -106,6 +107,7 @@ struct mux_device struct usb_device *usbdev; int id; enum mux_dev_state state; + int visible; struct collection connections; uint16_t next_sport; unsigned char *pktbuf; @@ -461,7 +463,7 @@ static void device_version_input(struct mux_device *dev, struct version_header * info.location = usb_get_location(dev->usbdev); info.serial = usb_get_serial(dev->usbdev); info.pid = usb_get_pid(dev->usbdev); - client_device_add(&info); + preflight_worker_device_add(&info); } static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned char *payload, uint32_t payload_length) @@ -642,6 +644,7 @@ int device_add(struct usb_device *usbdev) dev->id = id; dev->usbdev = usbdev; dev->state = MUXDEV_INIT; + dev->visible = 0; dev->next_sport = 1; dev->pktbuf = malloc(DEV_MRU); dev->pktlen = 0; @@ -680,11 +683,21 @@ void device_remove(struct usb_device *usbdev) usbmuxd_log(LL_WARNING, "Cannot find device entry while removing USB device %p on location 0x%x", usbdev, usb_get_location(usbdev)); } +void device_set_visible(int device_id) +{ + FOREACH(struct mux_device *dev, &device_list) { + if(dev->id == device_id) { + dev->visible = 1; + break; + } + } ENDFOREACH +} + int device_get_count(void) { int count = 0; FOREACH(struct mux_device *dev, &device_list) { - if(dev->state == MUXDEV_ACTIVE) + if((dev->state == MUXDEV_ACTIVE) && dev->visible) count++; } ENDFOREACH return count; @@ -694,7 +707,7 @@ int device_get_list(struct device_info *p) { int count = 0; FOREACH(struct mux_device *dev, &device_list) { - if(dev->state == MUXDEV_ACTIVE) { + if((dev->state == MUXDEV_ACTIVE) && dev->visible) { p->id = dev->id; p->serial = usb_get_serial(dev->usbdev); p->location = usb_get_location(dev->usbdev); -- cgit v1.1-32-gdbae