summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2016-12-01 03:43:05 +0100
committerGravatar Nikias Bassen2016-12-01 03:43:05 +0100
commit2a9e6fe37467bfb13b415d7654f825269e08603f (patch)
treebdceaae3831e2e15ddee69e1d3b4d85dc961760b
parenta1c728578930fb49e45497d1be7c9bc0c83607f1 (diff)
downloadlibimobiledevice-2a9e6fe37467bfb13b415d7654f825269e08603f.tar.gz
libimobiledevice-2a9e6fe37467bfb13b415d7654f825269e08603f.tar.bz2
misagent: Add new misagent_copy_all() function (introduced in iOS 9.3)
-rw-r--r--include/libimobiledevice/misagent.h24
-rw-r--r--src/misagent.c40
2 files changed, 63 insertions, 1 deletions
diff --git a/include/libimobiledevice/misagent.h b/include/libimobiledevice/misagent.h
index 92165f2..09af57a 100644
--- a/include/libimobiledevice/misagent.h
+++ b/include/libimobiledevice/misagent.h
@@ -101,7 +101,7 @@ misagent_error_t misagent_client_free(misagent_client_t client);
101misagent_error_t misagent_install(misagent_client_t client, plist_t profile); 101misagent_error_t misagent_install(misagent_client_t client, plist_t profile);
102 102
103/** 103/**
104 * Retrieves an array of all installed provisioning profiles. 104 * Retrieves all installed provisioning profiles (iOS 9.2.1 or below).
105 * 105 *
106 * @param client The connected misagent to use. 106 * @param client The connected misagent to use.
107 * @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY 107 * @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY
@@ -110,6 +110,9 @@ misagent_error_t misagent_install(misagent_client_t client, plist_t profile);
110 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when 110 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
111 * client is invalid, or an MISAGENT_E_* error code otherwise. 111 * client is invalid, or an MISAGENT_E_* error code otherwise.
112 * 112 *
113 * @note This API call only works with iOS 9.2.1 or below.
114 * For newer iOS versions use misagent_copy_all() instead.
115 *
113 * @note If no provisioning profiles are installed on the device, this function 116 * @note If no provisioning profiles are installed on the device, this function
114 * still returns MISAGENT_E_SUCCESS and profiles will just point to an 117 * still returns MISAGENT_E_SUCCESS and profiles will just point to an
115 * empty array. 118 * empty array.
@@ -117,6 +120,25 @@ misagent_error_t misagent_install(misagent_client_t client, plist_t profile);
117misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles); 120misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles);
118 121
119/** 122/**
123 * Retrieves all installed provisioning profiles (iOS 9.3 or higher).
124 *
125 * @param client The connected misagent to use.
126 * @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY
127 * if the function is successful.
128 *
129 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
130 * client is invalid, or an MISAGENT_E_* error code otherwise.
131 *
132 * @note This API call only works with iOS 9.3 or higher.
133 * For older iOS versions use misagent_copy() instead.
134 *
135 * @note If no provisioning profiles are installed on the device, this function
136 * still returns MISAGENT_E_SUCCESS and profiles will just point to an
137 * empty array.
138 */
139misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles);
140
141/**
120 * Removes a given provisioning profile. 142 * Removes a given provisioning profile.
121 * 143 *
122 * @param client The connected misagent to use. 144 * @param client The connected misagent to use.
diff --git a/src/misagent.c b/src/misagent.c
index 2dd3451..095edba 100644
--- a/src/misagent.c
+++ b/src/misagent.c
@@ -202,6 +202,46 @@ LIBIMOBILEDEVICE_API misagent_error_t misagent_copy(misagent_client_t client, pl
202 202
203} 203}
204 204
205LIBIMOBILEDEVICE_API misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles)
206{
207 if (!client || !client->parent || !profiles)
208 return MISAGENT_E_INVALID_ARG;
209
210 client->last_error = MISAGENT_E_UNKNOWN_ERROR;
211
212 plist_t dict = plist_new_dict();
213 plist_dict_set_item(dict, "MessageType", plist_new_string("CopyAll"));
214 plist_dict_set_item(dict, "ProfileType", plist_new_string("Provisioning"));
215
216 misagent_error_t res = misagent_error(property_list_service_send_xml_plist(client->parent, dict));
217 plist_free(dict);
218 dict = NULL;
219
220 if (res != MISAGENT_E_SUCCESS) {
221 debug_info("could not send plist, error %d", res);
222 return res;
223 }
224
225 res = misagent_error(property_list_service_receive_plist(client->parent, &dict));
226 if (res != MISAGENT_E_SUCCESS) {
227 debug_info("could not receive response, error %d", res);
228 return res;
229 }
230 if (!dict) {
231 debug_info("could not get response plist");
232 return MISAGENT_E_UNKNOWN_ERROR;
233 }
234
235 res = misagent_check_result(dict, &client->last_error);
236 if (res == MISAGENT_E_SUCCESS) {
237 *profiles = plist_copy(plist_dict_get_item(dict, "Payload"));
238 }
239 plist_free(dict);
240
241 return res;
242
243}
244
205LIBIMOBILEDEVICE_API misagent_error_t misagent_remove(misagent_client_t client, const char* profileID) 245LIBIMOBILEDEVICE_API misagent_error_t misagent_remove(misagent_client_t client, const char* profileID)
206{ 246{
207 if (!client || !client->parent || !profileID) 247 if (!client || !client->parent || !profileID)