summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-25 23:36:24 +0100
committerGravatar Martin Szulecki2010-01-25 23:36:24 +0100
commit90af94845ba841c693e80ac0eec317130c1c416e (patch)
treea09194df6ba77b8023ff04f90a24fb26d138b252 /src
parent4f5b839827625adaf444a4c5fbfd6145367da473 (diff)
downloadlibimobiledevice-90af94845ba841c693e80ac0eec317130c1c416e.tar.gz
libimobiledevice-90af94845ba841c693e80ac0eec317130c1c416e.tar.bz2
Auto-pair devices within lockdownd_client_new_with_handshake()
This brings back the automatic pairing feature if not yet paired.
Diffstat (limited to 'src')
-rw-r--r--src/lockdown.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index 792dd33..108b558 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -661,6 +661,14 @@ lockdownd_error_t lockdownd_client_new_with_handshake(iphone_device_t device, lo
/* in any case, we need to validate pairing to receive trusted host status */
ret = lockdownd_validate_pair(client_loc, NULL);
+ /* if not paired yet, let's do it now */
+ if (LOCKDOWN_E_INVALID_HOST_ID == ret) {
+ ret = lockdownd_pair(client_loc, NULL);
+ if (LOCKDOWN_E_SUCCESS == ret) {
+ ret = lockdownd_validate_pair(client_loc, NULL);
+ }
+ }
+
if (LOCKDOWN_E_SUCCESS == ret) {
ret = lockdownd_start_session(client_loc, host_id, NULL, NULL);
if (LOCKDOWN_E_SUCCESS != ret) {
@@ -825,11 +833,16 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_
if (error_node) {
char *value = NULL;
plist_get_string_val(error_node, &value);
- /* the first pairing fails if the device is password protected */
- if (value && !strcmp(value, "PasswordProtected")) {
- ret = LOCKDOWN_E_PASSWORD_PROTECTED;
+ if (value) {
+ /* the first pairing fails if the device is password protected */
+ if (!strcmp(value, "PasswordProtected")) {
+ ret = LOCKDOWN_E_PASSWORD_PROTECTED;
+ } else if (!strcmp(value, "InvalidHostID")) {
+ ret = LOCKDOWN_E_INVALID_HOST_ID;
+ }
free(value);
}
+
plist_free(error_node);
error_node = NULL;
}