diff options
Diffstat (limited to 'src/idevice.c')
| -rw-r--r-- | src/idevice.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/idevice.c b/src/idevice.c index d23c5b5..31a8d3a 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -227,6 +227,62 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_event_unsubscribe(void) | |||
| 227 | return IDEVICE_E_SUCCESS; | 227 | return IDEVICE_E_SUCCESS; |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *count) | ||
| 231 | { | ||
| 232 | usbmuxd_device_info_t *dev_list; | ||
| 233 | |||
| 234 | *devices = NULL; | ||
| 235 | *count = 0; | ||
| 236 | |||
| 237 | if (usbmuxd_get_device_list(&dev_list) < 0) { | ||
| 238 | debug_info("ERROR: usbmuxd is not running!", __func__); | ||
| 239 | return IDEVICE_E_NO_DEVICE; | ||
| 240 | } | ||
| 241 | |||
| 242 | idevice_info_t *newlist = NULL; | ||
| 243 | int i, newcount = 0; | ||
| 244 | |||
| 245 | for (i = 0; dev_list[i].handle > 0; i++) { | ||
| 246 | newlist = realloc(*devices, sizeof(idevice_info_t) * (newcount+1)); | ||
| 247 | newlist[newcount] = malloc(sizeof(struct idevice_info)); | ||
| 248 | newlist[newcount]->udid = strdup(dev_list[i].udid); | ||
| 249 | if (dev_list[i].conn_type == CONNECTION_TYPE_USB) { | ||
| 250 | newlist[newcount]->conn_type = CONNECTION_USBMUXD; | ||
| 251 | newlist[newcount]->conn_data = NULL; | ||
| 252 | } else if (dev_list[i].conn_type == CONNECTION_TYPE_NETWORK) { | ||
| 253 | newlist[newcount]->conn_type = CONNECTION_NETWORK; | ||
| 254 | size_t addrlen = dev_list[i].conn_data[0]; | ||
| 255 | newlist[newcount]->conn_data = malloc(addrlen); | ||
| 256 | memcpy(newlist[newcount]->conn_data, dev_list[i].conn_data, addrlen); | ||
| 257 | } | ||
| 258 | newcount++; | ||
| 259 | *devices = newlist; | ||
| 260 | } | ||
| 261 | usbmuxd_device_list_free(&dev_list); | ||
| 262 | |||
| 263 | *count = newcount; | ||
| 264 | newlist = realloc(*devices, sizeof(idevice_info_t) * (newcount+1)); | ||
| 265 | newlist[newcount] = NULL; | ||
| 266 | *devices = newlist; | ||
| 267 | |||
| 268 | return IDEVICE_E_SUCCESS; | ||
| 269 | } | ||
| 270 | |||
| 271 | LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_extended_free(idevice_info_t *devices) | ||
| 272 | { | ||
| 273 | if (devices) { | ||
| 274 | int i = 0; | ||
| 275 | while (devices[i]) { | ||
| 276 | free(devices[i]->udid); | ||
| 277 | free(devices[i]->conn_data); | ||
| 278 | free(devices[i]); | ||
| 279 | i++; | ||
| 280 | } | ||
| 281 | free(devices); | ||
| 282 | } | ||
| 283 | return IDEVICE_E_SUCCESS; | ||
| 284 | } | ||
| 285 | |||
| 230 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list(char ***devices, int *count) | 286 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list(char ***devices, int *count) |
| 231 | { | 287 | { |
| 232 | usbmuxd_device_info_t *dev_list; | 288 | usbmuxd_device_info_t *dev_list; |
