summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-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 @@
30 30
31static char *udid = NULL; 31static char *udid = NULL;
32 32
33static void print_error_message(lockdownd_error_t err)
34{
35 switch (err) {
36 case LOCKDOWN_E_PASSWORD_PROTECTED:
37 printf("ERROR: Could not validate with device %s because a passcode is set. Please enter the passcode on the device and retry.\n", udid);
38 break;
39 case LOCKDOWN_E_INVALID_HOST_ID:
40 printf("ERROR: Device %s is not paired with this host\n", udid);
41 break;
42 case LOCKDOWN_E_PAIRING_DIALOG_PENDING:
43 printf("ERROR: Please accept the trust dialog on the screen of device %s, then attempt to pair again.\n", udid);
44 break;
45 case LOCKDOWN_E_USER_DENIED_PAIRING:
46 printf("ERROR: Device %s said that the user denied the trust dialog.\n", udid);
47 break;
48 default:
49 printf("ERROR: Device %s returned unhandled error code %d\n", udid, err);
50 break;
51 }
52}
53
33static void print_usage(int argc, char **argv) 54static void print_usage(int argc, char **argv)
34{ 55{
35 char *name = NULL; 56 char *name = NULL;
@@ -232,11 +253,7 @@ int main(int argc, char **argv)
232 printf("SUCCESS: Paired with device %s\n", udid); 253 printf("SUCCESS: Paired with device %s\n", udid);
233 } else { 254 } else {
234 result = EXIT_FAILURE; 255 result = EXIT_FAILURE;
235 if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) { 256 print_error_message(lerr);
236 printf("ERROR: Could not pair with the device because a passcode is set. Please enter the passcode on the device and retry.\n");
237 } else {
238 printf("ERROR: Pairing with device %s failed with unhandled error code %d\n", udid, lerr);
239 }
240 } 257 }
241 break; 258 break;
242 259
@@ -246,13 +263,7 @@ int main(int argc, char **argv)
246 printf("SUCCESS: Validated pairing with device %s\n", udid); 263 printf("SUCCESS: Validated pairing with device %s\n", udid);
247 } else { 264 } else {
248 result = EXIT_FAILURE; 265 result = EXIT_FAILURE;
249 if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) { 266 print_error_message(lerr);
250 printf("ERROR: Could not validate with the device because a passcode is set. Please enter the passcode on the device and retry.\n");
251 } else if (lerr == LOCKDOWN_E_INVALID_HOST_ID) {
252 printf("ERROR: Device %s is not paired with this host\n", udid);
253 } else {
254 printf("ERROR: Pairing failed with unhandled error code %d\n", lerr);
255 }
256 } 267 }
257 break; 268 break;
258 269
@@ -264,11 +275,7 @@ int main(int argc, char **argv)
264 printf("SUCCESS: Unpaired with device %s\n", udid); 275 printf("SUCCESS: Unpaired with device %s\n", udid);
265 } else { 276 } else {
266 result = EXIT_FAILURE; 277 result = EXIT_FAILURE;
267 if (lerr == LOCKDOWN_E_INVALID_HOST_ID) { 278 print_error_message(lerr);
268 printf("ERROR: Device %s is not paired with this host\n", udid);
269 } else {
270 printf("ERROR: Unpairing with device %s failed with unhandled error code %d\n", udid, lerr);
271 }
272 } 279 }
273 break; 280 break;
274 } 281 }