summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2009-07-24 23:51:53 +0200
committerGravatar Martin Szulecki2009-07-24 23:51:53 +0200
commit19a28b0ed18c8ca2f855e7d129ddcdb8c939a707 (patch)
treea8c3dbfd38705bbe73af53193d4c8cfa224ebee2
parent83529098fbf4b39b2643a7c0bf39828247d11f9a (diff)
downloadlibimobiledevice-19a28b0ed18c8ca2f855e7d129ddcdb8c939a707.tar.gz
libimobiledevice-19a28b0ed18c8ca2f855e7d129ddcdb8c939a707.tar.bz2
Use iphone_device_get_uuid() not lockdown, for less overhead where possible
-rw-r--r--dev/lckdclient.c13
-rw-r--r--dev/main.c14
-rw-r--r--include/libiphone/libiphone.h1
-rw-r--r--src/iphone.c12
-rw-r--r--src/lockdown.c21
-rw-r--r--swig/iphone.i2
6 files changed, 32 insertions, 31 deletions
diff --git a/dev/lckdclient.c b/dev/lckdclient.c
index 820d05f..9518a6e 100644
--- a/dev/lckdclient.c
+++ b/dev/lckdclient.c
@@ -41,17 +41,18 @@ int main(int argc, char *argv[])
return -1;
}
+ char *uuid = NULL;
+ if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) {
+ printf("DeviceUniqueID : %s\n", uuid);
+ }
+ if (uuid)
+ free(uuid);
+
if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) {
iphone_free_device(phone);
return -1;
}
- char *uid = NULL;
- if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) {
- printf("DeviceUniqueID : %s\n", uid);
- free(uid);
- }
-
using_history();
int loop = TRUE;
while (loop) {
diff --git a/dev/main.c b/dev/main.c
index 9c8b155..46c5557 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -80,19 +80,19 @@ int main(int argc, char *argv[])
return -1;
}
+ char *uuid = NULL;
+ if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) {
+ printf("DeviceUniqueID : %s\n", uuid);
+ }
+ if (uuid)
+ free(uuid);
+
if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) {
iphone_free_device(phone);
printf("Exiting.\n");
return -1;
}
- char *uid = NULL;
- if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) {
- printf("DeviceUniqueID : %s\n", uid);
- free(uid);
- }
-
-
char *nnn = NULL;
if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) {
printf("DeviceName : %s\n", nnn);
diff --git a/include/libiphone/libiphone.h b/include/libiphone/libiphone.h
index b8c1c59..9764a7e 100644
--- a/include/libiphone/libiphone.h
+++ b/include/libiphone/libiphone.h
@@ -71,6 +71,7 @@ iphone_error_t iphone_get_device(iphone_device_t *device);
iphone_error_t iphone_get_device_by_uuid(iphone_device_t *device, const char *uuid);
iphone_error_t iphone_free_device(iphone_device_t device);
uint32_t iphone_get_device_handle(iphone_device_t device);
+iphone_error_t iphone_device_get_uuid(iphone_device_t device, char **uuid);
#ifdef __cplusplus
}
diff --git a/src/iphone.c b/src/iphone.c
index 0e179e7..93d7b5d 100644
--- a/src/iphone.c
+++ b/src/iphone.c
@@ -104,13 +104,13 @@ uint32_t iphone_get_device_handle(iphone_device_t device)
}
}
-char* iphone_get_uuid(iphone_device_t device)
+iphone_error_t iphone_device_get_uuid(iphone_device_t device, char **uuid)
{
- if (device) {
- return device->serial_number;
- } else {
- return NULL;
- }
+ if (!device)
+ return IPHONE_E_INVALID_ARG;
+
+ *uuid = strdup(device->serial_number);
+ return IPHONE_E_SUCCESS;
}
/** Cleans up an iPhone structure, then frees the structure itself.
diff --git a/src/lockdown.c b/src/lockdown.c
index bfb44d0..3d2b04c 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -673,24 +673,24 @@ iphone_error_t lockdownd_new_client(iphone_device_t device, lockdownd_client_t *
ret = IPHONE_E_NOT_ENOUGH_DATA;
}
- char *uid = NULL;
- ret = lockdownd_get_device_uid(client_loc, &uid);
+ char *uuid = NULL;
+ ret = iphone_device_get_uuid(device, &uuid);
if (IPHONE_E_SUCCESS != ret) {
log_debug_msg("%s: failed to get device uuid.\n", __func__);
}
- log_debug_msg("%s: device uuid: %s\n", __func__, uid);
+ log_debug_msg("%s: device uuid: %s\n", __func__, uuid);
host_id = get_host_id();
if (IPHONE_E_SUCCESS == ret && !host_id) {
ret = IPHONE_E_INVALID_CONF;
}
- if (IPHONE_E_SUCCESS == ret && !is_device_known(uid))
- ret = lockdownd_pair(client_loc, uid, host_id);
+ if (IPHONE_E_SUCCESS == ret && !is_device_known(uuid))
+ ret = lockdownd_pair(client_loc, uuid, host_id);
- if (uid) {
- free(uid);
- uid = NULL;
+ if (uuid) {
+ free(uuid);
+ uuid = NULL;
}
if (IPHONE_E_SUCCESS == ret) {
@@ -779,9 +779,8 @@ iphone_error_t lockdownd_pair(lockdownd_client_t client, char *uid, char *host_i
/* store public key in config if pairing succeeded */
if (ret == IPHONE_E_SUCCESS) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair success\n", __func__);
- store_device_public_key(uid, public_key);
- ret = IPHONE_E_SUCCESS;
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair success\n", __func__);
+ store_device_public_key(uuid, public_key);
} else {
log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair failure\n", __func__);
ret = IPHONE_E_PAIRING_FAILED;
diff --git a/swig/iphone.i b/swig/iphone.i
index 59be4ef..64a8727 100644
--- a/swig/iphone.i
+++ b/swig/iphone.i
@@ -135,7 +135,7 @@ MobileSync* my_new_MobileSync(Lockdownd* lckd) {
%newobject get_uuid;
char* get_uuid(){
char* uuid = NULL;
- uuid = (char *)iphone_get_uuid($self->dev);
+ uuid = (char *)iphone_device_get_uuid($self->dev);
return uuid;
}