Skip to content

Commit

Permalink
Handle 'Paired' message and pass event to client through callback
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Jul 14, 2016
1 parent 7f36c93 commit 75c6f68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/usbmuxd.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ typedef struct {
*/
enum usbmuxd_event_type {
UE_DEVICE_ADD = 1,
UE_DEVICE_REMOVE
UE_DEVICE_REMOVE,
UE_DEVICE_PAIRED
};

/**
Expand Down
12 changes: 12 additions & 0 deletions src/libusbmuxd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 75c6f68

Please sign in to comment.