diff options
author | Matt Colyer | 2009-05-23 16:56:36 -0700 |
---|---|---|
committer | Matt Colyer | 2009-05-23 16:56:36 -0700 |
commit | 7272875df87f1feb2c16259880503812f6acbbf1 (patch) | |
tree | 347bbff72e8a2024cb2d61c226e288afca613cd5 | |
parent | 435f5feb4b5c501db52743a170908687d3ba6f60 (diff) | |
download | libimobiledevice-7272875df87f1feb2c16259880503812f6acbbf1.tar.gz libimobiledevice-7272875df87f1feb2c16259880503812f6acbbf1.tar.bz2 |
Add a method to support fetching the UUID of the phone.
-rw-r--r-- | src/iphone.c | 14 | ||||
-rw-r--r-- | src/iphone.h | 1 | ||||
-rw-r--r-- | swig/iphone.i | 8 |
3 files changed, 18 insertions, 5 deletions
diff --git a/src/iphone.c b/src/iphone.c index 9551173..0e179e7 100644 --- a/src/iphone.c +++ b/src/iphone.c @@ -43,6 +43,7 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u { iphone_device_t phone; uint32_t handle = 0; + char *serial_number = malloc(41); usbmuxd_scan_result *dev_list = NULL; int i; @@ -53,12 +54,14 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u if (!uuid) { // select first device found if no UUID specified handle = dev_list[0].handle; + strcpy(serial_number, dev_list[0].serial_number); } else { // otherwise walk through the list for (i = 0; dev_list[i].handle > 0; i++) { log_debug_msg("%s: device handle=%d, uuid=%s\n", __func__, dev_list[i].handle, dev_list[i].serial_number); if (strcasecmp(uuid, dev_list[i].serial_number) == 0) { handle = dev_list[i].handle; + strcpy(serial_number, dev_list[i].serial_number); break; } } @@ -68,6 +71,7 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u if (handle > 0) { phone = (iphone_device_t) malloc(sizeof(struct iphone_device_int)); phone->handle = handle; + phone->serial_number = serial_number; *device = phone; return IPHONE_E_SUCCESS; } @@ -100,6 +104,15 @@ uint32_t iphone_get_device_handle(iphone_device_t device) } } +char* iphone_get_uuid(iphone_device_t device) +{ + if (device) { + return device->serial_number; + } else { + return NULL; + } +} + /** Cleans up an iPhone structure, then frees the structure itself. * This is a library-level function; deals directly with the iPhone to tear * down relations, but otherwise is mostly internal. @@ -114,6 +127,7 @@ iphone_error_t iphone_free_device(iphone_device_t device) ret = IPHONE_E_SUCCESS; + free(device->serial_number); free(device); return ret; } diff --git a/src/iphone.h b/src/iphone.h index 94d2f9f..2ed0fba 100644 --- a/src/iphone.h +++ b/src/iphone.h @@ -27,6 +27,7 @@ struct iphone_device_int { char *buffer; uint32_t handle; + char *serial_number; }; #endif diff --git a/swig/iphone.i b/swig/iphone.i index 4e604e0..7a003d4 100644 --- a/swig/iphone.i +++ b/swig/iphone.i @@ -121,11 +121,9 @@ MobileSync* my_new_MobileSync(Lockdownd* lckd) { return 0; } - int init_specific_device(int busnumber, int devicenumber) { - if (IPHONE_E_SUCCESS == iphone_get_specific_device ( busnumber, devicenumber, &($self->dev))) - return 1; - return 0; - } + char* serial_number(){ + return iphone_get_uuid($self->dev); + } Lockdownd* get_lockdown_client() { return my_new_Lockdownd($self); |