summaryrefslogtreecommitdiffstats
path: root/src/mobilesync.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-02-11 04:00:38 +0100
committerGravatar Martin Szulecki2013-02-11 04:00:38 +0100
commit370ba8c119e05ab0121559fd22848b7d7083189e (patch)
tree4882a6b191ae050ad883fd465c4419c506418b53 /src/mobilesync.c
parent499fae9c5116d74f72025954f54c0bc5e741386e (diff)
downloadlibimobiledevice-370ba8c119e05ab0121559fd22848b7d7083189e.tar.gz
libimobiledevice-370ba8c119e05ab0121559fd22848b7d7083189e.tar.bz2
mobilesync: Add new error_description argument to grab device error messages
Diffstat (limited to 'src/mobilesync.c')
-rw-r--r--src/mobilesync.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/mobilesync.c b/src/mobilesync.c
index f7ccea3..39b1da8 100644
--- a/src/mobilesync.c
+++ b/src/mobilesync.c
@@ -172,6 +172,7 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
* @param computer_data_class_version The version of the data class storage on the computer
* @param sync_type A pointer to store the sync type reported by the device_anchor
* @param device_data_class_version The version of the data class storage on the device
+ * @param error_description A pointer to store an error message if reported by the device
*
* @retval MOBILESYNC_E_SUCCESS on success
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
@@ -180,7 +181,7 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
* @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
* sync request
*/
-mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version)
+mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description)
{
if (!client || client->data_class || !data_class ||
!anchors || !anchors->computer_anchor) {
@@ -193,6 +194,8 @@ mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data
plist_t msg = NULL;
plist_t response_type_node = NULL;
+ *error_description = NULL;
+
msg = plist_new_array();
plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice"));
plist_array_append_item(msg, plist_new_string(data_class));
@@ -232,23 +235,19 @@ mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data
goto out;
}
+ // did the device refuse to sync with the computer?
if (!strcmp(response_type, "SDMessageRefuseToSyncDataClassWithComputer")) {
- char *reason = NULL;
err = MOBILESYNC_E_SYNC_REFUSED;
- plist_get_string_val(plist_array_get_item(msg, 2), &reason);
- debug_info("Device refused sync: %s", reason);
- free(reason);
- reason = NULL;
+ plist_get_string_val(plist_array_get_item(msg, 2), error_description);
+ debug_info("Device refused sync: %s", error_description);
goto out;
}
+ // did the device cancel the session?
if (!strcmp(response_type, "SDMessageCancelSession")) {
- char *reason = NULL;
err = MOBILESYNC_E_CANCELLED;
- plist_get_string_val(plist_array_get_item(msg, 2), &reason);
- debug_info("Device cancelled: %s", reason);
- free(reason);
- reason = NULL;
+ plist_get_string_val(plist_array_get_item(msg, 2), error_description);
+ debug_info("Device cancelled: %s", error_description);
goto out;
}