summaryrefslogtreecommitdiffstats
path: root/src/mobilesync.c
diff options
context:
space:
mode:
authorGravatar Aaron Burghardt2014-03-27 10:07:09 -0400
committerGravatar Aaron Burghardt2014-03-27 21:40:43 -0400
commit2342dc5b4ef148b993fbe3816f3facdef8365546 (patch)
tree69f812d91b2fc07db0fad5dcba6c80d2f8b6849e /src/mobilesync.c
parentee82e861a8c942b5013accd7589cf898d1f97167 (diff)
downloadlibimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.gz
libimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.bz2
Moved Doxygen comments from source files to public headers.
Conflicts: include/libimobiledevice/afc.h
Diffstat (limited to 'src/mobilesync.c')
-rw-r--r--src/mobilesync.c228
1 files changed, 0 insertions, 228 deletions
diff --git a/src/mobilesync.c b/src/mobilesync.c
index fd64e63..f0fc4b2 100644
--- a/src/mobilesync.c
+++ b/src/mobilesync.c
@@ -65,19 +65,6 @@ static mobilesync_error_t mobilesync_error(device_link_service_error_t err)
65 return MOBILESYNC_E_UNKNOWN_ERROR; 65 return MOBILESYNC_E_UNKNOWN_ERROR;
66} 66}
67 67
68/**
69 * Connects to the mobilesync service on the specified device.
70 *
71 * @param device The device to connect to.
72 * @param service The service descriptor returned by lockdownd_start_service.
73 * @param client Pointer that will be set to a newly allocated
74 * #mobilesync_client_t upon successful return.
75 *
76 * @retval MOBILESYNC_E_SUCCESS on success
77 * @retval MOBILESYNC_E_INVALID_ARG if one or more parameters are invalid
78 * @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on
79 * the device is newer.
80 */
81mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, 68mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service,
82 mobilesync_client_t * client) 69 mobilesync_client_t * client)
83{ 70{
@@ -108,19 +95,6 @@ mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_des
108 return ret; 95 return ret;
109} 96}
110 97
111/**
112 * Starts a new mobilesync service on the specified device and connects to it.
113 *
114 * @param device The device to connect to.
115 * @param client Pointer that will point to a newly allocated
116 * mobilesync_client_t upon successful return. Must be freed using
117 * mobilesync_client_free() after use.
118 * @param label The label to use for communication. Usually the program name.
119 * Pass NULL to disable sending the label in requests to lockdownd.
120 *
121 * @return MOBILESYNC_E_SUCCESS on success, or an MOBILESYNC_E_* error
122 * code otherwise.
123 */
124mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t * client, const char* label) 98mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t * client, const char* label)
125{ 99{
126 mobilesync_error_t err = MOBILESYNC_E_UNKNOWN_ERROR; 100 mobilesync_error_t err = MOBILESYNC_E_UNKNOWN_ERROR;
@@ -128,15 +102,6 @@ mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_
128 return err; 102 return err;
129} 103}
130 104
131/**
132 * Disconnects a mobilesync client from the device and frees up the
133 * mobilesync client data.
134 *
135 * @param client The mobilesync client to disconnect and free.
136 *
137 * @retval MOBILESYNC_E_SUCCESS on success
138 * @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL.
139 */
140mobilesync_error_t mobilesync_client_free(mobilesync_client_t client) 105mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
141{ 106{
142 if (!client) 107 if (!client)
@@ -147,14 +112,6 @@ mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
147 return err; 112 return err;
148} 113}
149 114
150/**
151 * Polls the device for mobilesync data.
152 *
153 * @param client The mobilesync client
154 * @param plist A pointer to the location where the plist should be stored
155 *
156 * @return an error code
157 */
158mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plist) 115mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plist)
159{ 116{
160 if (!client) 117 if (!client)
@@ -163,17 +120,6 @@ mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plis
163 return ret; 120 return ret;
164} 121}
165 122
166/**
167 * Sends mobilesync data to the device
168 *
169 * @note This function is low-level and should only be used if you need to send
170 * a new type of message.
171 *
172 * @param client The mobilesync client
173 * @param plist The location of the plist to send
174 *
175 * @return an error code
176 */
177mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist) 123mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
178{ 124{
179 if (!client || !plist) 125 if (!client || !plist)
@@ -181,26 +127,6 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
181 return mobilesync_error(device_link_service_send(client->parent, plist)); 127 return mobilesync_error(device_link_service_send(client->parent, plist));
182} 128}
183 129
184/**
185 * Requests starting synchronization of a data class with the device
186 *
187 * @param client The mobilesync client
188 * @param data_class The data class identifier to sync
189 * @param anchors The anchors required to exchange with the device. The anchors
190 * allow the device to tell if the synchronization information on the computer
191 * and device are consistent to determine what sync type is required.
192 * @param computer_data_class_version The version of the data class storage on the computer
193 * @param sync_type A pointer to store the sync type reported by the device_anchor
194 * @param device_data_class_version The version of the data class storage on the device
195 * @param error_description A pointer to store an error message if reported by the device
196 *
197 * @retval MOBILESYNC_E_SUCCESS on success
198 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
199 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
200 * @retval MOBILESYNC_E_SYNC_REFUSED if the device refused to sync
201 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
202 * sync request
203 */
204mobilesync_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) 130mobilesync_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)
205{ 131{
206 if (!client || client->data_class || !data_class || 132 if (!client || client->data_class || !data_class ||
@@ -327,17 +253,6 @@ mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data
327 return err; 253 return err;
328} 254}
329 255
330/**
331 * Finish a synchronization session of a data class on the device.
332 * A session must have previously been started using mobilesync_start().
333 *
334 * @param client The mobilesync client
335 *
336 * @retval MOBILESYNC_E_SUCCESS on success
337 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
338 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
339 * form
340 */
341mobilesync_error_t mobilesync_finish(mobilesync_client_t client) 256mobilesync_error_t mobilesync_finish(mobilesync_client_t client)
342{ 257{
343 if (!client || !client->data_class) { 258 if (!client || !client->data_class) {
@@ -423,49 +338,16 @@ static mobilesync_error_t mobilesync_get_records(mobilesync_client_t client, con
423 return err; 338 return err;
424} 339}
425 340
426/**
427 * Requests to receive all records of the currently set data class from the device.
428 * The actually changes are retrieved using mobilesync_receive_changes() after this
429 * request has been successful.
430 *
431 * @param client The mobilesync client
432 *
433 * @retval MOBILESYNC_E_SUCCESS on success
434 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
435 */
436mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client) 341mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client)
437{ 342{
438 return mobilesync_get_records(client, "SDMessageGetAllRecordsFromDevice"); 343 return mobilesync_get_records(client, "SDMessageGetAllRecordsFromDevice");
439} 344}
440 345
441/**
442 * Requests to receive only changed records of the currently set data class from the device.
443 * The actually changes are retrieved using mobilesync_receive_changes() after this
444 * request has been successful.
445 *
446 * @param client The mobilesync client
447 *
448 * @retval MOBILESYNC_E_SUCCESS on success
449 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
450 */
451mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client) 346mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client)
452{ 347{
453 return mobilesync_get_records(client, "SDMessageGetChangesFromDevice"); 348 return mobilesync_get_records(client, "SDMessageGetChangesFromDevice");
454} 349}
455 350
456/**
457 * Receives changed entitites of the currently set data class from the device
458 *
459 * @param client The mobilesync client
460 * @param entities A pointer to store the changed entity records as a PLIST_DICT
461 * @param is_last_record A pointer to store a flag indicating if this submission is the last one
462 * @param actions A pointer to additional flags the device is sending or NULL to ignore
463 *
464 * @retval MOBILESYNC_E_SUCCESS on success
465 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
466 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
467 * session
468 */
469mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions) 351mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions)
470{ 352{
471 if (!client || !client->data_class) { 353 if (!client || !client->data_class) {
@@ -533,17 +415,6 @@ mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_
533 return err; 415 return err;
534} 416}
535 417
536/**
537 * Requests the device to delete all records of the current data class
538 *
539 * @note The operation must be called after starting synchronization.
540 *
541 * @param client The mobilesync client
542 *
543 * @retval MOBILESYNC_E_SUCCESS on success
544 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
545 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
546 */
547mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client) 418mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client)
548{ 419{
549 if (!client || !client->data_class) { 420 if (!client || !client->data_class) {
@@ -613,14 +484,6 @@ mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t cl
613 return err; 484 return err;
614} 485}
615 486
616/**
617 * Acknowledges to the device that the changes have been merged on the computer
618 *
619 * @param client The mobilesync client
620 *
621 * @retval MOBILESYNC_E_SUCCESS on success
622 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
623 */
624mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client) 487mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client)
625{ 488{
626 if (!client || !client->data_class) { 489 if (!client || !client->data_class) {
@@ -655,23 +518,6 @@ static plist_t create_process_changes_message(const char *data_class, plist_t en
655 return msg; 518 return msg;
656} 519}
657 520
658/**
659 * Verifies if the device is ready to receive changes from the computer.
660 * This call changes the synchronization direction so that mobilesync_send_changes()
661 * can be used to send changes to the device.
662 *
663 * @param client The mobilesync client
664 *
665 * @retval MOBILESYNC_E_SUCCESS on success
666 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
667 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
668 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
669 * not permit this call
670 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
671 * session
672 * @retval MOBILESYNC_E_NOT_READY if the device is not ready to start
673 * receiving any changes
674 */
675mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client) 521mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client)
676{ 522{
677 if (!client || !client->data_class) { 523 if (!client || !client->data_class) {
@@ -739,20 +585,6 @@ mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_cli
739 return err; 585 return err;
740} 586}
741 587
742/**
743 * Sends changed entities of the currently set data class to the device
744 *
745 * @param client The mobilesync client
746 * @param entities The changed entity records as a PLIST_DICT
747 * @param is_last_record A flag indicating if this submission is the last one
748 * @param actions Additional actions for the device created with mobilesync_actions_new()
749 * or NULL if no actions should be passed
750 *
751 * @retval MOBILESYNC_E_SUCCESS on success
752 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid,
753 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
754 * not permit this call
755 */
756mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions) 588mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions)
757{ 589{
758 if (!client || !client->data_class || !entities) { 590 if (!client || !client->data_class || !entities) {
@@ -781,21 +613,6 @@ mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t e
781 return err; 613 return err;
782} 614}
783 615
784/**
785 * Receives any remapped identifiers reported after the device merged submitted changes.
786 *
787 * @param client The mobilesync client
788 * @param mapping A pointer to an array plist containing a dict of identifier remappings
789 *
790 * @retval MOBILESYNC_E_SUCCESS on success
791 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
792 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
793 * form
794 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
795 * not permit this call
796 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
797 * session
798 */
799mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping) 616mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping)
800{ 617{
801 if (!client || !client->data_class) { 618 if (!client || !client->data_class) {
@@ -865,15 +682,6 @@ mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plis
865 return err; 682 return err;
866} 683}
867 684
868/**
869 * Cancels a running synchronization session with a device at any time.
870 *
871 * @param client The mobilesync client
872 * @param reason The reason to supply to the device for cancelling
873 *
874 * @retval MOBILESYNC_E_SUCCESS on success
875 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
876 */
877mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason) 685mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason)
878{ 686{
879 if (!client || !client->data_class || !reason) { 687 if (!client || !client->data_class || !reason) {
@@ -900,15 +708,6 @@ mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* rea
900 return err; 708 return err;
901} 709}
902 710
903/**
904 * Allocates memory for a new anchors struct initialized with the passed anchors.
905 *
906 * @param device_anchor An anchor the device reported the last time or NULL
907 * if none is known yet which for instance is true on first synchronization.
908 * @param computer_anchor An arbitrary string to use as anchor for the computer.
909 *
910 * @return A new #mobilesync_anchors_t struct. Must be freed using mobilesync_anchors_free().
911 */
912mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor) 711mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor)
913{ 712{
914 mobilesync_anchors_t anchors = (mobilesync_anchors_t) malloc(sizeof(mobilesync_anchors)); 713 mobilesync_anchors_t anchors = (mobilesync_anchors_t) malloc(sizeof(mobilesync_anchors));
@@ -926,11 +725,6 @@ mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const cha
926 return anchors; 725 return anchors;
927} 726}
928 727
929/**
930 * Free memory used by anchors.
931 *
932 * @param anchors The anchors to free.
933 */
934void mobilesync_anchors_free(mobilesync_anchors_t anchors) 728void mobilesync_anchors_free(mobilesync_anchors_t anchors)
935{ 729{
936 if (anchors->device_anchor != NULL) { 730 if (anchors->device_anchor != NULL) {
@@ -945,28 +739,11 @@ void mobilesync_anchors_free(mobilesync_anchors_t anchors)
945 anchors = NULL; 739 anchors = NULL;
946} 740}
947 741
948/**
949 * Create a new actions plist to use in mobilesync_send_changes().
950 *
951 * @return A new plist_t of type PLIST_DICT.
952 */
953plist_t mobilesync_actions_new() 742plist_t mobilesync_actions_new()
954{ 743{
955 return plist_new_dict(); 744 return plist_new_dict();
956} 745}
957 746
958/**
959 * Add one or more new key:value pairs to the given actions plist.
960 *
961 * @param actions The actions to modify.
962 * @param ... KEY, VALUE, [KEY, VALUE], NULL
963 *
964 * @note The known keys so far are "SyncDeviceLinkEntityNamesKey" which expects
965 * an array of entity names, followed by a count paramter as well as
966 * "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey" which expects an
967 * integer to use as a boolean value indicating that the device should
968 * link submitted changes and report remapped identifiers.
969 */
970void mobilesync_actions_add(plist_t actions, ...) 747void mobilesync_actions_add(plist_t actions, ...)
971{ 748{
972 if (!actions) 749 if (!actions)
@@ -999,11 +776,6 @@ void mobilesync_actions_add(plist_t actions, ...)
999 va_end(args); 776 va_end(args);
1000} 777}
1001 778
1002/**
1003 * Free actions plist.
1004 *
1005 * @param actions The actions plist to free. Does nothing if NULL is passed.
1006 */
1007void mobilesync_actions_free(plist_t actions) 779void mobilesync_actions_free(plist_t actions)
1008{ 780{
1009 if (actions) { 781 if (actions) {