diff options
author | Nikias Bassen | 2016-07-14 03:09:44 +0200 |
---|---|---|
committer | Nikias Bassen | 2016-07-14 03:09:44 +0200 |
commit | 75c6f68dde6ddaa7b7e0579d5f62eaf0d661511b (patch) | |
tree | 6bb1b3e1e48b8a075485ba810fb79dbc8e04b002 | |
parent | 7f36c93678f001abb2fc69e2cce048468af620d1 (diff) | |
download | libusbmuxd-75c6f68dde6ddaa7b7e0579d5f62eaf0d661511b.tar.gz libusbmuxd-75c6f68dde6ddaa7b7e0579d5f62eaf0d661511b.tar.bz2 |
Handle 'Paired' message and pass event to client through callback
-rw-r--r-- | include/usbmuxd.h | 3 | ||||
-rw-r--r-- | src/libusbmuxd.c | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/include/usbmuxd.h b/include/usbmuxd.h index d413eab..f345be2 100644 --- a/include/usbmuxd.h +++ b/include/usbmuxd.h @@ -45,7 +45,8 @@ typedef struct { */ enum usbmuxd_event_type { UE_DEVICE_ADD = 1, - UE_DEVICE_REMOVE + UE_DEVICE_REMOVE, + UE_DEVICE_PAIRED }; /** diff --git a/src/libusbmuxd.c b/src/libusbmuxd.c index 90ae6e6..327746b 100644 --- a/src/libusbmuxd.c +++ b/src/libusbmuxd.c @@ -711,6 +711,18 @@ static int get_next_event(int sfd, usbmuxd_event_cb_t callback, void *user_data) collection_remove(&devices, devinfo); free(devinfo); } + } else if (hdr.message == MESSAGE_DEVICE_PAIRED) { + uint32_t handle; + usbmuxd_device_info_t *devinfo; + + memcpy(&handle, payload, sizeof(uint32_t)); + + devinfo = devices_find(handle); + if (!devinfo) { + DEBUG(1, "%s: WARNING: got paired message for device handle %d, but couldn't find the corresponding handle in the device list. This event will be ignored.\n", __func__, handle); + } else { + generate_event(callback, devinfo, UE_DEVICE_PAIRED, user_data); + } } else if (hdr.length > 0) { DEBUG(1, "%s: Unexpected message type %d length %d received!\n", __func__, hdr.message, hdr.length); } |