diff options
| -rw-r--r-- | include/libimobiledevice/mobilesync.h | 2 | ||||
| -rw-r--r-- | src/mobilesync.c | 22 |
2 files changed, 16 insertions, 8 deletions
diff --git a/include/libimobiledevice/mobilesync.h b/include/libimobiledevice/mobilesync.h index 2cd6d30..7658b7d 100644 --- a/include/libimobiledevice/mobilesync.h +++ b/include/libimobiledevice/mobilesync.h | |||
| @@ -78,7 +78,7 @@ mobilesync_error_t mobilesync_finish(mobilesync_client_t client); | |||
| 78 | 78 | ||
| 79 | mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client); | 79 | mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client); |
| 80 | mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client); | 80 | mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client); |
| 81 | mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client, const char *data_class); | 81 | mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client); |
| 82 | 82 | ||
| 83 | mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions); | 83 | mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions); |
| 84 | mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client); | 84 | mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client); |
diff --git a/src/mobilesync.c b/src/mobilesync.c index 475e46c..7f20e16 100644 --- a/src/mobilesync.c +++ b/src/mobilesync.c | |||
| @@ -516,18 +516,17 @@ mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_ | |||
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | /** | 518 | /** |
| 519 | * Requests the device to delete all records of the supplied data class | 519 | * Requests the device to delete all records of the current data class |
| 520 | * | 520 | * |
| 521 | * @note The operation must be called outside of the regular synchronization loop. | 521 | * @note The operation must be called after starting synchronization. |
| 522 | * | 522 | * |
| 523 | * @param client The mobilesync client | 523 | * @param client The mobilesync client |
| 524 | * @param data_class The data class identifier | ||
| 525 | * | 524 | * |
| 526 | * @retval MOBILESYNC_E_SUCCESS on success | 525 | * @retval MOBILESYNC_E_SUCCESS on success |
| 527 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | 526 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid |
| 528 | * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form | 527 | * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form |
| 529 | */ | 528 | */ |
| 530 | mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client, const char *data_class) | 529 | mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client) |
| 531 | { | 530 | { |
| 532 | if (!client || !client->data_class) { | 531 | if (!client || !client->data_class) { |
| 533 | return MOBILESYNC_E_INVALID_ARG; | 532 | return MOBILESYNC_E_INVALID_ARG; |
| @@ -540,7 +539,7 @@ mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t cl | |||
| 540 | 539 | ||
| 541 | msg = plist_new_array(); | 540 | msg = plist_new_array(); |
| 542 | plist_array_append_item(msg, plist_new_string("SDMessageClearAllRecordsOnDevice")); | 541 | plist_array_append_item(msg, plist_new_string("SDMessageClearAllRecordsOnDevice")); |
| 543 | plist_array_append_item(msg, plist_new_string(data_class)); | 542 | plist_array_append_item(msg, plist_new_string(client->data_class)); |
| 544 | plist_array_append_item(msg, plist_new_string(EMPTY_PARAMETER_STRING)); | 543 | plist_array_append_item(msg, plist_new_string(EMPTY_PARAMETER_STRING)); |
| 545 | 544 | ||
| 546 | err = mobilesync_send(client, msg); | 545 | err = mobilesync_send(client, msg); |
| @@ -570,8 +569,17 @@ mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t cl | |||
| 570 | goto out; | 569 | goto out; |
| 571 | } | 570 | } |
| 572 | 571 | ||
| 573 | if (!strcmp(response_type, "SDMessageDeviceWillClearAllRecords")) { | 572 | if (!strcmp(response_type, "SDMessageCancelSession")) { |
| 574 | err = MOBILESYNC_E_SUCCESS; | 573 | char *reason = NULL; |
| 574 | err = MOBILESYNC_E_CANCELLED; | ||
| 575 | plist_get_string_val(plist_array_get_item(msg, 2), &reason); | ||
| 576 | debug_info("Device cancelled: %s", reason); | ||
| 577 | free(reason); | ||
| 578 | goto out; | ||
| 579 | } | ||
| 580 | |||
| 581 | if (strcmp(response_type, "SDMessageDeviceWillClearAllRecords")) { | ||
| 582 | err = MOBILESYNC_E_PLIST_ERROR; | ||
| 575 | } | 583 | } |
| 576 | 584 | ||
| 577 | out: | 585 | out: |
