|
27 | 27 | #include <libimobiledevice/afc.h> |
28 | 28 | #include <libimobiledevice/misagent.h> |
29 | 29 | #include <libimobiledevice/mobile_image_mounter.h> |
| 30 | +#include <common/userpref.h> |
| 31 | +#include <libimobiledevice/service.h> |
30 | 32 |
|
31 | 33 | void ALTDeviceManagerUpdateStatus(plist_t command, plist_t status, void *udid); |
32 | 34 | void ALTDeviceManagerUpdateAppDeletionStatus(plist_t command, plist_t status, void *uuid); |
@@ -386,6 +388,38 @@ - (NSProgress *)installAppAtURL:(NSURL *)fileURL toDeviceWithUDID:(NSString *)ud |
386 | 388 |
|
387 | 389 | return progress; |
388 | 390 | } |
| 391 | +- (NSString *)getPairingPlistString:(NSString*)udid{ |
| 392 | + plist_t pair_record = NULL; |
| 393 | + char *buffer = NULL; |
| 394 | + uint32_t length; |
| 395 | + char* temp_udid = (char *)udid.UTF8String; |
| 396 | + userpref_read_pair_record(temp_udid, &pair_record); |
| 397 | + plist_dict_set_item(pair_record, "UDID", plist_new_string(temp_udid)); |
| 398 | + plist_to_xml(pair_record, &buffer, &length); |
| 399 | + return [NSString stringWithUTF8String:(buffer)]; |
| 400 | + } |
| 401 | + |
| 402 | +static void print_error_message(lockdownd_error_t err, const char *udid) |
| 403 | +{ |
| 404 | + switch (err) { |
| 405 | + case LOCKDOWN_E_PASSWORD_PROTECTED: |
| 406 | + fprintf(stderr, "ERROR: Could not validate with device %s because a passcode is set. Please enter the passcode on the device and retry.\n", udid); |
| 407 | + break; |
| 408 | + case LOCKDOWN_E_INVALID_CONF: |
| 409 | + case LOCKDOWN_E_INVALID_HOST_ID: |
| 410 | + fprintf(stderr, "ERROR: Device %s is not paired with this host\n", udid); |
| 411 | + break; |
| 412 | + case LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING: |
| 413 | + fprintf(stderr, "ERROR: Please accept the trust dialog on the screen of device %s, then attempt to pair again.\n", udid); |
| 414 | + break; |
| 415 | + case LOCKDOWN_E_USER_DENIED_PAIRING: |
| 416 | + fprintf(stderr, "ERROR: Device %s said that the user denied the trust dialog.\n", udid); |
| 417 | + break; |
| 418 | + default: |
| 419 | + fprintf(stderr, "ERROR: Device %s returned unhandled error code %d\n", udid, err); |
| 420 | + break; |
| 421 | + } |
| 422 | +} |
389 | 423 |
|
390 | 424 | - (BOOL)writeDirectory:(NSURL *)directoryURL toDestinationURL:(NSURL *)destinationURL client:(afc_client_t)afc progress:(NSProgress *)progress error:(NSError **)error |
391 | 425 | { |
|
0 commit comments