diff options
| author | 2015-07-15 07:22:37 +0200 | |
|---|---|---|
| committer | 2015-07-15 07:22:37 +0200 | |
| commit | f268393d4e447ac901879bee751d7350c495fed2 (patch) | |
| tree | 63ba8aef9ddc77f98c4432241692f14f81afc439 /src/lockdown.c | |
| parent | e1cac25e632955da0c3aeb2f16f49c5a1687f81c (diff) | |
| download | libimobiledevice-f268393d4e447ac901879bee751d7350c495fed2.tar.gz libimobiledevice-f268393d4e447ac901879bee751d7350c495fed2.tar.bz2 | |
lockdown: Add new lockdownd_pair_with_options() function
Diffstat (limited to 'src/lockdown.c')
| -rw-r--r-- | src/lockdown.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/lockdown.c b/src/lockdown.c index 026d1d1..85124bd 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -848,6 +848,8 @@ leave: | |||
| 848 | * the pair records from the current machine are used. New records will be | 848 | * the pair records from the current machine are used. New records will be |
| 849 | * generated automatically when pairing is done for the first time. | 849 | * generated automatically when pairing is done for the first time. |
| 850 | * @param verb This is either "Pair", "ValidatePair" or "Unpair". | 850 | * @param verb This is either "Pair", "ValidatePair" or "Unpair". |
| 851 | * @param options The pairing options to pass. | ||
| 852 | * @param response If non-NULL a pointer to lockdownd's response dictionary is returned. | ||
| 851 | * | 853 | * |
| 852 | * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, | 854 | * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, |
| 853 | * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong, | 855 | * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong, |
| @@ -855,7 +857,7 @@ leave: | |||
| 855 | * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, | 857 | * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, |
| 856 | * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id | 858 | * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id |
| 857 | */ | 859 | */ |
| 858 | static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record, const char *verb) | 860 | static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record, const char *verb, plist_t options, plist_t *result) |
| 859 | { | 861 | { |
| 860 | if (!client) | 862 | if (!client) |
| 861 | return LOCKDOWN_E_INVALID_ARG; | 863 | return LOCKDOWN_E_INVALID_ARG; |
| @@ -915,9 +917,9 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_ | |||
| 915 | plist_dict_set_item(dict, "Request", plist_new_string(verb)); | 917 | plist_dict_set_item(dict, "Request", plist_new_string(verb)); |
| 916 | plist_dict_set_item(dict, "ProtocolVersion", plist_new_string(LOCKDOWN_PROTOCOL_VERSION)); | 918 | plist_dict_set_item(dict, "ProtocolVersion", plist_new_string(LOCKDOWN_PROTOCOL_VERSION)); |
| 917 | 919 | ||
| 918 | plist_t options = plist_new_dict(); | 920 | if (options) { |
| 919 | plist_dict_set_item(options, "ExtendedPairingErrors", plist_new_bool(1)); | 921 | plist_dict_set_item(dict, "PairingOptions", plist_copy(options)); |
| 920 | plist_dict_set_item(dict, "PairingOptions", options); | 922 | } |
| 921 | 923 | ||
| 922 | /* send to device */ | 924 | /* send to device */ |
| 923 | ret = lockdownd_send(client, dict); | 925 | ret = lockdownd_send(client, dict); |
| @@ -1010,25 +1012,42 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_ | |||
| 1010 | wifi_node = NULL; | 1012 | wifi_node = NULL; |
| 1011 | } | 1013 | } |
| 1012 | 1014 | ||
| 1013 | plist_free(dict); | 1015 | if (result) { |
| 1014 | dict = NULL; | 1016 | *result = dict; |
| 1017 | } else { | ||
| 1018 | plist_free(dict); | ||
| 1019 | dict = NULL; | ||
| 1020 | } | ||
| 1015 | 1021 | ||
| 1016 | return ret; | 1022 | return ret; |
| 1017 | } | 1023 | } |
| 1018 | 1024 | ||
| 1019 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) | 1025 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) |
| 1020 | { | 1026 | { |
| 1021 | return lockdownd_do_pair(client, pair_record, "Pair"); | 1027 | |
| 1028 | plist_t options = plist_new_dict(); | ||
| 1029 | plist_dict_set_item(options, "ExtendedPairingErrors", plist_new_bool(1)); | ||
| 1030 | |||
| 1031 | lockdownd_error_t ret = lockdownd_do_pair(client, pair_record, "Pair", options, NULL); | ||
| 1032 | |||
| 1033 | plist_free(options); | ||
| 1034 | |||
| 1035 | return ret; | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response) | ||
| 1039 | { | ||
| 1040 | return lockdownd_do_pair(client, pair_record, "Pair", options, response); | ||
| 1022 | } | 1041 | } |
| 1023 | 1042 | ||
| 1024 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) | 1043 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) |
| 1025 | { | 1044 | { |
| 1026 | return lockdownd_do_pair(client, pair_record, "ValidatePair"); | 1045 | return lockdownd_do_pair(client, pair_record, "ValidatePair", NULL, NULL); |
| 1027 | } | 1046 | } |
| 1028 | 1047 | ||
| 1029 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) | 1048 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) |
| 1030 | { | 1049 | { |
| 1031 | return lockdownd_do_pair(client, pair_record, "Unpair"); | 1050 | return lockdownd_do_pair(client, pair_record, "Unpair", NULL, NULL); |
| 1032 | } | 1051 | } |
| 1033 | 1052 | ||
| 1034 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client) | 1053 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client) |
