summaryrefslogtreecommitdiffstats
path: root/tools/idevicepair.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2014-03-21 21:52:35 +0100
committerGravatar Martin Szulecki2014-03-21 21:52:35 +0100
commite621f084bcae8a6d3ab6431c9cfb144bd6218992 (patch)
treeb321d02c56920ebabb15108f7c9c6497ac87fa82 /tools/idevicepair.c
parent1959bdaa9d847dab689757643bb94c52afe0716a (diff)
downloadlibimobiledevice-e621f084bcae8a6d3ab6431c9cfb144bd6218992.tar.gz
libimobiledevice-e621f084bcae8a6d3ab6431c9cfb144bd6218992.tar.bz2
idevicepair: Refactor error message reporting to handle a pending trust dialog
Diffstat (limited to 'tools/idevicepair.c')
-rw-r--r--tools/idevicepair.c41
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;
}