diff options
Diffstat (limited to 'tools/idevicepair.c')
-rw-r--r-- | tools/idevicepair.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/tools/idevicepair.c b/tools/idevicepair.c index 5af95f0..8fc1148 100644 --- a/tools/idevicepair.c +++ b/tools/idevicepair.c @@ -30,6 +30,27 @@ static char *udid = NULL; +static void print_error_message(lockdownd_error_t err) +{ + switch (err) { + case LOCKDOWN_E_PASSWORD_PROTECTED: + printf("ERROR: Could not validate with device %s because a passcode is set. Please enter the passcode on the device and retry.\n", udid); + break; + case LOCKDOWN_E_INVALID_HOST_ID: + printf("ERROR: Device %s is not paired with this host\n", udid); + break; + case LOCKDOWN_E_PAIRING_DIALOG_PENDING: + printf("ERROR: Please accept the trust dialog on the screen of device %s, then attempt to pair again.\n", udid); + break; + case LOCKDOWN_E_USER_DENIED_PAIRING: + printf("ERROR: Device %s said that the user denied the trust dialog.\n", udid); + break; + default: + printf("ERROR: Device %s returned unhandled error code %d\n", udid, err); + break; + } +} + static void print_usage(int argc, char **argv) { char *name = NULL; @@ -232,11 +253,7 @@ int main(int argc, char **argv) printf("SUCCESS: Paired with device %s\n", udid); } else { result = EXIT_FAILURE; - if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) { - printf("ERROR: Could not pair with the device because a passcode is set. Please enter the passcode on the device and retry.\n"); - } else { - printf("ERROR: Pairing with device %s failed with unhandled error code %d\n", udid, lerr); - } + print_error_message(lerr); } break; @@ -246,13 +263,7 @@ int main(int argc, char **argv) printf("SUCCESS: Validated pairing with device %s\n", udid); } else { result = EXIT_FAILURE; - if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) { - printf("ERROR: Could not validate with the device because a passcode is set. Please enter the passcode on the device and retry.\n"); - } else if (lerr == LOCKDOWN_E_INVALID_HOST_ID) { - printf("ERROR: Device %s is not paired with this host\n", udid); - } else { - printf("ERROR: Pairing failed with unhandled error code %d\n", lerr); - } + print_error_message(lerr); } break; @@ -264,11 +275,7 @@ int main(int argc, char **argv) printf("SUCCESS: Unpaired with device %s\n", udid); } else { result = EXIT_FAILURE; - if (lerr == LOCKDOWN_E_INVALID_HOST_ID) { - printf("ERROR: Device %s is not paired with this host\n", udid); - } else { - printf("ERROR: Unpairing with device %s failed with unhandled error code %d\n", udid, lerr); - } + print_error_message(lerr); } break; } |