summaryrefslogtreecommitdiffstats
path: root/src/mobilesync.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2011-03-16 21:35:56 +0100
committerGravatar Martin Szulecki2011-03-16 21:35:56 +0100
commitae4b7bacc40fe85fa3c2c023ca5a6a5b45b43c53 (patch)
tree259f8e05d2dd84b44aeb0fef8359efd5a754b20f /src/mobilesync.c
parent1ecd04355c0a135ef2c2244186977c5700390c96 (diff)
downloadlibimobiledevice-ae4b7bacc40fe85fa3c2c023ca5a6a5b45b43c53.tar.gz
libimobiledevice-ae4b7bacc40fe85fa3c2c023ca5a6a5b45b43c53.tar.bz2
mobilesync: Check for cancel message when attempting to clear all records on device
Furthermore the clearing must happen after starting synchronization and as we have the data class set already, we can obsolete that argument.
Diffstat (limited to 'src/mobilesync.c')
-rw-r--r--src/mobilesync.c22
1 files changed, 15 insertions, 7 deletions
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 */
530mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client, const char *data_class) 529mobilesync_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: