diff options
author | Martin Szulecki | 2010-01-25 23:36:24 +0100 |
---|---|---|
committer | Martin Szulecki | 2010-01-26 02:03:59 +0100 |
commit | 57c883b7fe84d513c836270f681a9bf5a907de3e (patch) | |
tree | f5530ab58af30a3de437250520a602037c0cff90 /src/lockdown.c | |
parent | 762bf3d1589e2285945eb4eff1d79afbe0fc46c6 (diff) | |
download | libimobiledevice-57c883b7fe84d513c836270f681a9bf5a907de3e.tar.gz libimobiledevice-57c883b7fe84d513c836270f681a9bf5a907de3e.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/lockdown.c')
-rw-r--r-- | src/lockdown.c | 19 |
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; } |