diff options
author | Martin Szulecki | 2010-01-25 23:36:24 +0100 |
---|---|---|
committer | Matt Colyer | 2010-01-26 08:16:17 -0800 |
commit | 0cf8b328c0bfa7f860ba54a484d28ec227d33efc (patch) | |
tree | b85b9a9a45a1a3091739315ad71ee061c134c3f7 | |
parent | b42576baef5775d46a477219de572f68024b1aac (diff) | |
download | libimobiledevice-0cf8b328c0bfa7f860ba54a484d28ec227d33efc.tar.gz libimobiledevice-0cf8b328c0bfa7f860ba54a484d28ec227d33efc.tar.bz2 |
Auto-pair devices within lockdownd_client_new_with_handshake()
This brings back the automatic pairing feature if not yet paired.
[#111 state:resolved]
-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; } |