From 0cf8b328c0bfa7f860ba54a484d28ec227d33efc Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Mon, 25 Jan 2010 23:36:24 +0100 Subject: Auto-pair devices within lockdownd_client_new_with_handshake() This brings back the automatic pairing feature if not yet paired. [#111 state:resolved] --- src/lockdown.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') 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; } -- cgit v1.1-32-gdbae