diff options
| author | 2009-05-23 16:56:36 -0700 | |
|---|---|---|
| committer | 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 | |||
| 43 | { | 43 | { |
| 44 | iphone_device_t phone; | 44 | iphone_device_t phone; |
| 45 | uint32_t handle = 0; | 45 | uint32_t handle = 0; |
| 46 | char *serial_number = malloc(41); | ||
| 46 | usbmuxd_scan_result *dev_list = NULL; | 47 | usbmuxd_scan_result *dev_list = NULL; |
| 47 | int i; | 48 | int i; |
| 48 | 49 | ||
| @@ -53,12 +54,14 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u | |||
| 53 | if (!uuid) { | 54 | if (!uuid) { |
| 54 | // select first device found if no UUID specified | 55 | // select first device found if no UUID specified |
| 55 | handle = dev_list[0].handle; | 56 | handle = dev_list[0].handle; |
| 57 | strcpy(serial_number, dev_list[0].serial_number); | ||
| 56 | } else { | 58 | } else { |
| 57 | // otherwise walk through the list | 59 | // otherwise walk through the list |
| 58 | for (i = 0; dev_list[i].handle > 0; i++) { | 60 | for (i = 0; dev_list[i].handle > 0; i++) { |
| 59 | log_debug_msg("%s: device handle=%d, uuid=%s\n", __func__, dev_list[i].handle, dev_list[i].serial_number); | 61 | log_debug_msg("%s: device handle=%d, uuid=%s\n", __func__, dev_list[i].handle, dev_list[i].serial_number); |
| 60 | if (strcasecmp(uuid, dev_list[i].serial_number) == 0) { | 62 | if (strcasecmp(uuid, dev_list[i].serial_number) == 0) { |
| 61 | handle = dev_list[i].handle; | 63 | handle = dev_list[i].handle; |
| 64 | strcpy(serial_number, dev_list[i].serial_number); | ||
| 62 | break; | 65 | break; |
| 63 | } | 66 | } |
| 64 | } | 67 | } |
| @@ -68,6 +71,7 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u | |||
| 68 | if (handle > 0) { | 71 | if (handle > 0) { |
| 69 | phone = (iphone_device_t) malloc(sizeof(struct iphone_device_int)); | 72 | phone = (iphone_device_t) malloc(sizeof(struct iphone_device_int)); |
| 70 | phone->handle = handle; | 73 | phone->handle = handle; |
| 74 | phone->serial_number = serial_number; | ||
| 71 | *device = phone; | 75 | *device = phone; |
| 72 | return IPHONE_E_SUCCESS; | 76 | return IPHONE_E_SUCCESS; |
| 73 | } | 77 | } |
| @@ -100,6 +104,15 @@ uint32_t iphone_get_device_handle(iphone_device_t device) | |||
| 100 | } | 104 | } |
| 101 | } | 105 | } |
| 102 | 106 | ||
| 107 | char* iphone_get_uuid(iphone_device_t device) | ||
| 108 | { | ||
| 109 | if (device) { | ||
| 110 | return device->serial_number; | ||
| 111 | } else { | ||
| 112 | return NULL; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 103 | /** Cleans up an iPhone structure, then frees the structure itself. | 116 | /** Cleans up an iPhone structure, then frees the structure itself. |
| 104 | * This is a library-level function; deals directly with the iPhone to tear | 117 | * This is a library-level function; deals directly with the iPhone to tear |
| 105 | * down relations, but otherwise is mostly internal. | 118 | * down relations, but otherwise is mostly internal. |
| @@ -114,6 +127,7 @@ iphone_error_t iphone_free_device(iphone_device_t device) | |||
| 114 | 127 | ||
| 115 | ret = IPHONE_E_SUCCESS; | 128 | ret = IPHONE_E_SUCCESS; |
| 116 | 129 | ||
| 130 | free(device->serial_number); | ||
| 117 | free(device); | 131 | free(device); |
| 118 | return ret; | 132 | return ret; |
| 119 | } | 133 | } |
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 @@ | |||
| 27 | struct iphone_device_int { | 27 | struct iphone_device_int { |
| 28 | char *buffer; | 28 | char *buffer; |
| 29 | uint32_t handle; | 29 | uint32_t handle; |
| 30 | char *serial_number; | ||
| 30 | }; | 31 | }; |
| 31 | 32 | ||
| 32 | #endif | 33 | #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) { | |||
| 121 | return 0; | 121 | return 0; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | int init_specific_device(int busnumber, int devicenumber) { | 124 | char* serial_number(){ |
| 125 | if (IPHONE_E_SUCCESS == iphone_get_specific_device ( busnumber, devicenumber, &($self->dev))) | 125 | return iphone_get_uuid($self->dev); |
| 126 | return 1; | 126 | } |
| 127 | return 0; | ||
| 128 | } | ||
| 129 | 127 | ||
| 130 | Lockdownd* get_lockdown_client() { | 128 | Lockdownd* get_lockdown_client() { |
| 131 | return my_new_Lockdownd($self); | 129 | return my_new_Lockdownd($self); |
