summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2009-05-24 14:44:28 +0200
committerGravatar Martin Szulecki2009-05-24 14:44:28 +0200
commit735a3ab42d92a65a39ea6918aeb1ab784cad0da7 (patch)
tree15973568585031e4244b3a8863503767e4420fa4
parent36ea32e0064f33d6a285684c3069f4d75bbac7a8 (diff)
parent7272875df87f1feb2c16259880503812f6acbbf1 (diff)
downloadlibimobiledevice-735a3ab42d92a65a39ea6918aeb1ab784cad0da7.tar.gz
libimobiledevice-735a3ab42d92a65a39ea6918aeb1ab784cad0da7.tar.bz2
Merge branch 'master' of git://github.com/MattColyer/libiphone into martin
-rw-r--r--src/iphone.c14
-rw-r--r--src/iphone.h1
-rw-r--r--swig/iphone.i8
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);