diff options
author | Nikias Bassen | 2018-09-29 22:56:14 +0200 |
---|---|---|
committer | Nikias Bassen | 2018-09-29 22:56:14 +0200 |
commit | 05fefa6aeff45fc84665e8427444295d8414df98 (patch) | |
tree | 76ac70827e85fced512dfe04c568a97f82eaff8c /src | |
parent | fb71aeef10488ed7b0e60a1c8a553193301428c0 (diff) | |
download | libimobiledevice-05fefa6aeff45fc84665e8427444295d8414df98.tar.gz libimobiledevice-05fefa6aeff45fc84665e8427444295d8414df98.tar.bz2 |
idevice: Add usbmux device id (handle/mux id) to internal data structure
Diffstat (limited to 'src')
-rw-r--r-- | src/idevice.c | 19 | ||||
-rw-r--r-- | src/idevice.h | 1 |
2 files changed, 7 insertions, 13 deletions
diff --git a/src/idevice.c b/src/idevice.c index ead9b86..cb9bb5c 100644 --- a/src/idevice.c +++ b/src/idevice.c @@ -254,8 +254,9 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t * device, const char if (res > 0) { idevice_t dev = (idevice_t) malloc(sizeof(struct idevice_private)); dev->udid = strdup(muxdev.udid); + dev->mux_id = muxdev.handle; dev->conn_type = CONNECTION_USBMUXD; - dev->conn_data = (void*)(long)muxdev.handle; + dev->conn_data = NULL; dev->version = 0; *device = dev; return IDEVICE_E_SUCCESS; @@ -275,9 +276,6 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_free(idevice_t device) free(device->udid); - if (device->conn_type == CONNECTION_USBMUXD) { - device->conn_data = 0; - } if (device->conn_data) { free(device->conn_data); } @@ -292,7 +290,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t } if (device->conn_type == CONNECTION_USBMUXD) { - int sfd = usbmuxd_connect((uint32_t)(long)device->conn_data, port); + int sfd = usbmuxd_connect(device->mux_id, port); if (sfd < 0) { debug_info("ERROR: Connecting to usbmuxd failed: %d (%s)", sfd, strerror(-sfd)); return IDEVICE_E_UNKNOWN_ERROR; @@ -502,16 +500,11 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connectio LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) { - if (!device) + if (!device || !handle) return IDEVICE_E_INVALID_ARG; - if (device->conn_type == CONNECTION_USBMUXD) { - *handle = (uint32_t)(long)device->conn_data; - return IDEVICE_E_SUCCESS; - } else { - debug_info("Unknown connection type %d", device->conn_type); - } - return IDEVICE_E_UNKNOWN_ERROR; + *handle = device->mux_id; + return IDEVICE_E_SUCCESS; } LIBIMOBILEDEVICE_API idevice_error_t idevice_get_udid(idevice_t device, char **udid) diff --git a/src/idevice.h b/src/idevice.h index e46a7e5..94e828b 100644 --- a/src/idevice.h +++ b/src/idevice.h @@ -74,6 +74,7 @@ struct idevice_connection_private { struct idevice_private { char *udid; + uint32_t mux_id; enum connection_type conn_type; void *conn_data; int version; |