diff options
| -rw-r--r-- | include/libimobiledevice/libimobiledevice.h | 2 | ||||
| -rw-r--r-- | src/idevice.c | 19 | ||||
| -rw-r--r-- | src/idevice.h | 1 |
3 files changed, 8 insertions, 14 deletions
diff --git a/include/libimobiledevice/libimobiledevice.h b/include/libimobiledevice/libimobiledevice.h index 68eb511..5ec1a6d 100644 --- a/include/libimobiledevice/libimobiledevice.h +++ b/include/libimobiledevice/libimobiledevice.h | |||
| @@ -253,7 +253,7 @@ idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int * | |||
| 253 | /* misc */ | 253 | /* misc */ |
| 254 | 254 | ||
| 255 | /** | 255 | /** |
| 256 | * Gets the handle of the device. Depends on the connection type. | 256 | * Gets the handle or (usbmux device id) of the device. |
| 257 | */ | 257 | */ |
| 258 | idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle); | 258 | idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle); |
| 259 | 259 | ||
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 | |||
| 254 | if (res > 0) { | 254 | if (res > 0) { |
| 255 | idevice_t dev = (idevice_t) malloc(sizeof(struct idevice_private)); | 255 | idevice_t dev = (idevice_t) malloc(sizeof(struct idevice_private)); |
| 256 | dev->udid = strdup(muxdev.udid); | 256 | dev->udid = strdup(muxdev.udid); |
| 257 | dev->mux_id = muxdev.handle; | ||
| 257 | dev->conn_type = CONNECTION_USBMUXD; | 258 | dev->conn_type = CONNECTION_USBMUXD; |
| 258 | dev->conn_data = (void*)(long)muxdev.handle; | 259 | dev->conn_data = NULL; |
| 259 | dev->version = 0; | 260 | dev->version = 0; |
| 260 | *device = dev; | 261 | *device = dev; |
| 261 | return IDEVICE_E_SUCCESS; | 262 | return IDEVICE_E_SUCCESS; |
| @@ -275,9 +276,6 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_free(idevice_t device) | |||
| 275 | 276 | ||
| 276 | free(device->udid); | 277 | free(device->udid); |
| 277 | 278 | ||
| 278 | if (device->conn_type == CONNECTION_USBMUXD) { | ||
| 279 | device->conn_data = 0; | ||
| 280 | } | ||
| 281 | if (device->conn_data) { | 279 | if (device->conn_data) { |
| 282 | free(device->conn_data); | 280 | free(device->conn_data); |
| 283 | } | 281 | } |
| @@ -292,7 +290,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t | |||
| 292 | } | 290 | } |
| 293 | 291 | ||
| 294 | if (device->conn_type == CONNECTION_USBMUXD) { | 292 | if (device->conn_type == CONNECTION_USBMUXD) { |
| 295 | int sfd = usbmuxd_connect((uint32_t)(long)device->conn_data, port); | 293 | int sfd = usbmuxd_connect(device->mux_id, port); |
| 296 | if (sfd < 0) { | 294 | if (sfd < 0) { |
| 297 | debug_info("ERROR: Connecting to usbmuxd failed: %d (%s)", sfd, strerror(-sfd)); | 295 | debug_info("ERROR: Connecting to usbmuxd failed: %d (%s)", sfd, strerror(-sfd)); |
| 298 | return IDEVICE_E_UNKNOWN_ERROR; | 296 | return IDEVICE_E_UNKNOWN_ERROR; |
| @@ -502,16 +500,11 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connectio | |||
| 502 | 500 | ||
| 503 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) | 501 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) |
| 504 | { | 502 | { |
| 505 | if (!device) | 503 | if (!device || !handle) |
| 506 | return IDEVICE_E_INVALID_ARG; | 504 | return IDEVICE_E_INVALID_ARG; |
| 507 | 505 | ||
| 508 | if (device->conn_type == CONNECTION_USBMUXD) { | 506 | *handle = device->mux_id; |
| 509 | *handle = (uint32_t)(long)device->conn_data; | 507 | return IDEVICE_E_SUCCESS; |
| 510 | return IDEVICE_E_SUCCESS; | ||
| 511 | } else { | ||
| 512 | debug_info("Unknown connection type %d", device->conn_type); | ||
| 513 | } | ||
| 514 | return IDEVICE_E_UNKNOWN_ERROR; | ||
| 515 | } | 508 | } |
| 516 | 509 | ||
| 517 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_udid(idevice_t device, char **udid) | 510 | 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 { | |||
| 74 | 74 | ||
| 75 | struct idevice_private { | 75 | struct idevice_private { |
| 76 | char *udid; | 76 | char *udid; |
| 77 | uint32_t mux_id; | ||
| 77 | enum connection_type conn_type; | 78 | enum connection_type conn_type; |
| 78 | void *conn_data; | 79 | void *conn_data; |
| 79 | int version; | 80 | int version; |
