diff options
Diffstat (limited to 'src/mobilesync.c')
| -rw-r--r-- | src/mobilesync.c | 21 |
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) | |||
| 172 | * @param computer_data_class_version The version of the data class storage on the computer | 172 | * @param computer_data_class_version The version of the data class storage on the computer |
| 173 | * @param sync_type A pointer to store the sync type reported by the device_anchor | 173 | * @param sync_type A pointer to store the sync type reported by the device_anchor |
| 174 | * @param device_data_class_version The version of the data class storage on the device | 174 | * @param device_data_class_version The version of the data class storage on the device |
| 175 | * @param error_description A pointer to store an error message if reported by the device | ||
| 175 | * | 176 | * |
| 176 | * @retval MOBILESYNC_E_SUCCESS on success | 177 | * @retval MOBILESYNC_E_SUCCESS on success |
| 177 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | 178 | * @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) | |||
| 180 | * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the | 181 | * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the |
| 181 | * sync request | 182 | * sync request |
| 182 | */ | 183 | */ |
| 183 | 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) | 184 | 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) |
| 184 | { | 185 | { |
| 185 | if (!client || client->data_class || !data_class || | 186 | if (!client || client->data_class || !data_class || |
| 186 | !anchors || !anchors->computer_anchor) { | 187 | !anchors || !anchors->computer_anchor) { |
| @@ -193,6 +194,8 @@ mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data | |||
| 193 | plist_t msg = NULL; | 194 | plist_t msg = NULL; |
| 194 | plist_t response_type_node = NULL; | 195 | plist_t response_type_node = NULL; |
| 195 | 196 | ||
| 197 | *error_description = NULL; | ||
| 198 | |||
| 196 | msg = plist_new_array(); | 199 | msg = plist_new_array(); |
| 197 | plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice")); | 200 | plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice")); |
| 198 | plist_array_append_item(msg, plist_new_string(data_class)); | 201 | 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 | |||
| 232 | goto out; | 235 | goto out; |
| 233 | } | 236 | } |
| 234 | 237 | ||
| 238 | // did the device refuse to sync with the computer? | ||
| 235 | if (!strcmp(response_type, "SDMessageRefuseToSyncDataClassWithComputer")) { | 239 | if (!strcmp(response_type, "SDMessageRefuseToSyncDataClassWithComputer")) { |
| 236 | char *reason = NULL; | ||
| 237 | err = MOBILESYNC_E_SYNC_REFUSED; | 240 | err = MOBILESYNC_E_SYNC_REFUSED; |
| 238 | plist_get_string_val(plist_array_get_item(msg, 2), &reason); | 241 | plist_get_string_val(plist_array_get_item(msg, 2), error_description); |
| 239 | debug_info("Device refused sync: %s", reason); | 242 | debug_info("Device refused sync: %s", error_description); |
| 240 | free(reason); | ||
| 241 | reason = NULL; | ||
| 242 | goto out; | 243 | goto out; |
| 243 | } | 244 | } |
| 244 | 245 | ||
| 246 | // did the device cancel the session? | ||
| 245 | if (!strcmp(response_type, "SDMessageCancelSession")) { | 247 | if (!strcmp(response_type, "SDMessageCancelSession")) { |
| 246 | char *reason = NULL; | ||
| 247 | err = MOBILESYNC_E_CANCELLED; | 248 | err = MOBILESYNC_E_CANCELLED; |
| 248 | plist_get_string_val(plist_array_get_item(msg, 2), &reason); | 249 | plist_get_string_val(plist_array_get_item(msg, 2), error_description); |
| 249 | debug_info("Device cancelled: %s", reason); | 250 | debug_info("Device cancelled: %s", error_description); |
| 250 | free(reason); | ||
| 251 | reason = NULL; | ||
| 252 | goto out; | 251 | goto out; |
| 253 | } | 252 | } |
| 254 | 253 | ||
