diff options
| author | 2009-07-24 23:51:53 +0200 | |
|---|---|---|
| committer | 2009-07-24 23:51:53 +0200 | |
| commit | 19a28b0ed18c8ca2f855e7d129ddcdb8c939a707 (patch) | |
| tree | a8c3dbfd38705bbe73af53193d4c8cfa224ebee2 | |
| parent | 83529098fbf4b39b2643a7c0bf39828247d11f9a (diff) | |
| download | libimobiledevice-19a28b0ed18c8ca2f855e7d129ddcdb8c939a707.tar.gz libimobiledevice-19a28b0ed18c8ca2f855e7d129ddcdb8c939a707.tar.bz2 | |
Use iphone_device_get_uuid() not lockdown, for less overhead where possible
| -rw-r--r-- | dev/lckdclient.c | 13 | ||||
| -rw-r--r-- | dev/main.c | 14 | ||||
| -rw-r--r-- | include/libiphone/libiphone.h | 1 | ||||
| -rw-r--r-- | src/iphone.c | 12 | ||||
| -rw-r--r-- | src/lockdown.c | 21 | ||||
| -rw-r--r-- | swig/iphone.i | 2 |
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[]) | |||
| 41 | return -1; | 41 | return -1; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | char *uuid = NULL; | ||
| 45 | if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) { | ||
| 46 | printf("DeviceUniqueID : %s\n", uuid); | ||
| 47 | } | ||
| 48 | if (uuid) | ||
| 49 | free(uuid); | ||
| 50 | |||
| 44 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 51 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { |
| 45 | iphone_free_device(phone); | 52 | iphone_free_device(phone); |
| 46 | return -1; | 53 | return -1; |
| 47 | } | 54 | } |
| 48 | 55 | ||
| 49 | char *uid = NULL; | ||
| 50 | if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { | ||
| 51 | printf("DeviceUniqueID : %s\n", uid); | ||
| 52 | free(uid); | ||
| 53 | } | ||
| 54 | |||
| 55 | using_history(); | 56 | using_history(); |
| 56 | int loop = TRUE; | 57 | int loop = TRUE; |
| 57 | while (loop) { | 58 | while (loop) { |
| @@ -80,19 +80,19 @@ int main(int argc, char *argv[]) | |||
| 80 | return -1; | 80 | return -1; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | char *uuid = NULL; | ||
| 84 | if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) { | ||
| 85 | printf("DeviceUniqueID : %s\n", uuid); | ||
| 86 | } | ||
| 87 | if (uuid) | ||
| 88 | free(uuid); | ||
| 89 | |||
| 83 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 90 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { |
| 84 | iphone_free_device(phone); | 91 | iphone_free_device(phone); |
| 85 | printf("Exiting.\n"); | 92 | printf("Exiting.\n"); |
| 86 | return -1; | 93 | return -1; |
| 87 | } | 94 | } |
| 88 | 95 | ||
| 89 | char *uid = NULL; | ||
| 90 | if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { | ||
| 91 | printf("DeviceUniqueID : %s\n", uid); | ||
| 92 | free(uid); | ||
| 93 | } | ||
| 94 | |||
| 95 | |||
| 96 | char *nnn = NULL; | 96 | char *nnn = NULL; |
| 97 | if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { | 97 | if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { |
| 98 | printf("DeviceName : %s\n", nnn); | 98 | 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); | |||
| 71 | iphone_error_t iphone_get_device_by_uuid(iphone_device_t *device, const char *uuid); | 71 | iphone_error_t iphone_get_device_by_uuid(iphone_device_t *device, const char *uuid); |
| 72 | iphone_error_t iphone_free_device(iphone_device_t device); | 72 | iphone_error_t iphone_free_device(iphone_device_t device); |
| 73 | uint32_t iphone_get_device_handle(iphone_device_t device); | 73 | uint32_t iphone_get_device_handle(iphone_device_t device); |
| 74 | iphone_error_t iphone_device_get_uuid(iphone_device_t device, char **uuid); | ||
| 74 | 75 | ||
| 75 | #ifdef __cplusplus | 76 | #ifdef __cplusplus |
| 76 | } | 77 | } |
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) | |||
| 104 | } | 104 | } |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | char* iphone_get_uuid(iphone_device_t device) | 107 | iphone_error_t iphone_device_get_uuid(iphone_device_t device, char **uuid) |
| 108 | { | 108 | { |
| 109 | if (device) { | 109 | if (!device) |
| 110 | return device->serial_number; | 110 | return IPHONE_E_INVALID_ARG; |
| 111 | } else { | 111 | |
| 112 | return NULL; | 112 | *uuid = strdup(device->serial_number); |
| 113 | } | 113 | return IPHONE_E_SUCCESS; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | /** Cleans up an iPhone structure, then frees the structure itself. | 116 | /** 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 * | |||
| 673 | ret = IPHONE_E_NOT_ENOUGH_DATA; | 673 | ret = IPHONE_E_NOT_ENOUGH_DATA; |
| 674 | } | 674 | } |
| 675 | 675 | ||
| 676 | char *uid = NULL; | 676 | char *uuid = NULL; |
| 677 | ret = lockdownd_get_device_uid(client_loc, &uid); | 677 | ret = iphone_device_get_uuid(device, &uuid); |
| 678 | if (IPHONE_E_SUCCESS != ret) { | 678 | if (IPHONE_E_SUCCESS != ret) { |
| 679 | log_debug_msg("%s: failed to get device uuid.\n", __func__); | 679 | log_debug_msg("%s: failed to get device uuid.\n", __func__); |
| 680 | } | 680 | } |
| 681 | log_debug_msg("%s: device uuid: %s\n", __func__, uid); | 681 | log_debug_msg("%s: device uuid: %s\n", __func__, uuid); |
| 682 | 682 | ||
| 683 | host_id = get_host_id(); | 683 | host_id = get_host_id(); |
| 684 | if (IPHONE_E_SUCCESS == ret && !host_id) { | 684 | if (IPHONE_E_SUCCESS == ret && !host_id) { |
| 685 | ret = IPHONE_E_INVALID_CONF; | 685 | ret = IPHONE_E_INVALID_CONF; |
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | if (IPHONE_E_SUCCESS == ret && !is_device_known(uid)) | 688 | if (IPHONE_E_SUCCESS == ret && !is_device_known(uuid)) |
| 689 | ret = lockdownd_pair(client_loc, uid, host_id); | 689 | ret = lockdownd_pair(client_loc, uuid, host_id); |
| 690 | 690 | ||
| 691 | if (uid) { | 691 | if (uuid) { |
| 692 | free(uid); | 692 | free(uuid); |
| 693 | uid = NULL; | 693 | uuid = NULL; |
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | if (IPHONE_E_SUCCESS == ret) { | 696 | if (IPHONE_E_SUCCESS == ret) { |
| @@ -779,9 +779,8 @@ iphone_error_t lockdownd_pair(lockdownd_client_t client, char *uid, char *host_i | |||
| 779 | 779 | ||
| 780 | /* store public key in config if pairing succeeded */ | 780 | /* store public key in config if pairing succeeded */ |
| 781 | if (ret == IPHONE_E_SUCCESS) { | 781 | if (ret == IPHONE_E_SUCCESS) { |
| 782 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair success\n", __func__); | 782 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair success\n", __func__); |
| 783 | store_device_public_key(uid, public_key); | 783 | store_device_public_key(uuid, public_key); |
| 784 | ret = IPHONE_E_SUCCESS; | ||
| 785 | } else { | 784 | } else { |
| 786 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair failure\n", __func__); | 785 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair failure\n", __func__); |
| 787 | ret = IPHONE_E_PAIRING_FAILED; | 786 | 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) { | |||
| 135 | %newobject get_uuid; | 135 | %newobject get_uuid; |
| 136 | char* get_uuid(){ | 136 | char* get_uuid(){ |
| 137 | char* uuid = NULL; | 137 | char* uuid = NULL; |
| 138 | uuid = (char *)iphone_get_uuid($self->dev); | 138 | uuid = (char *)iphone_device_get_uuid($self->dev); |
| 139 | return uuid; | 139 | return uuid; |
| 140 | } | 140 | } |
| 141 | 141 | ||
