summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--include/libimobiledevice/mobilesync.h2
-rw-r--r--src/mobilesync.c21
3 files changed, 12 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac
index 9c790dc..52a14da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@ dnl libtool versioning
# changes to the signature and the semantic)
# ? :+1 : ? == just internal changes
# CURRENT : REVISION : AGE
-LIBIMOBILEDEVICE_SO_VERSION=3:1:0
+LIBIMOBILEDEVICE_SO_VERSION=4:1:0
AC_SUBST(LIBIMOBILEDEVICE_SO_VERSION)
diff --git a/include/libimobiledevice/mobilesync.h b/include/libimobiledevice/mobilesync.h
index bd717ee..cfab8d9 100644
--- a/include/libimobiledevice/mobilesync.h
+++ b/include/libimobiledevice/mobilesync.h
@@ -71,7 +71,7 @@ mobilesync_error_t mobilesync_client_free(mobilesync_client_t client);
mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist);
mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist);
-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);
mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason);
mobilesync_error_t mobilesync_finish(mobilesync_client_t client);
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;
}