diff options
| author | 2014-03-27 10:07:09 -0400 | |
|---|---|---|
| committer | 2014-03-27 21:40:43 -0400 | |
| commit | 2342dc5b4ef148b993fbe3816f3facdef8365546 (patch) | |
| tree | 69f812d91b2fc07db0fad5dcba6c80d2f8b6849e /include/libimobiledevice/mobilesync.h | |
| parent | ee82e861a8c942b5013accd7589cf898d1f97167 (diff) | |
| download | libimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.gz libimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.bz2 | |
Moved Doxygen comments from source files to public headers.
Conflicts:
include/libimobiledevice/afc.h
Diffstat (limited to 'include/libimobiledevice/mobilesync.h')
| -rw-r--r-- | include/libimobiledevice/mobilesync.h | 249 |
1 files changed, 249 insertions, 0 deletions
diff --git a/include/libimobiledevice/mobilesync.h b/include/libimobiledevice/mobilesync.h index 8e263ce..6ba197b 100644 --- a/include/libimobiledevice/mobilesync.h +++ b/include/libimobiledevice/mobilesync.h | |||
| @@ -68,35 +68,284 @@ typedef struct { | |||
| 68 | typedef mobilesync_anchors *mobilesync_anchors_t; /**< Anchors used by the device and computer. */ | 68 | typedef mobilesync_anchors *mobilesync_anchors_t; /**< Anchors used by the device and computer. */ |
| 69 | 69 | ||
| 70 | /* Interface */ | 70 | /* Interface */ |
| 71 | |||
| 72 | /** | ||
| 73 | * Connects to the mobilesync service on the specified device. | ||
| 74 | * | ||
| 75 | * @param device The device to connect to. | ||
| 76 | * @param service The service descriptor returned by lockdownd_start_service. | ||
| 77 | * @param client Pointer that will be set to a newly allocated | ||
| 78 | * #mobilesync_client_t upon successful return. | ||
| 79 | * | ||
| 80 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 81 | * @retval MOBILESYNC_E_INVALID_ARG if one or more parameters are invalid | ||
| 82 | * @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on | ||
| 83 | * the device is newer. | ||
| 84 | */ | ||
| 71 | mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client); | 85 | mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client); |
| 86 | |||
| 87 | /** | ||
| 88 | * Starts a new mobilesync service on the specified device and connects to it. | ||
| 89 | * | ||
| 90 | * @param device The device to connect to. | ||
| 91 | * @param client Pointer that will point to a newly allocated | ||
| 92 | * mobilesync_client_t upon successful return. Must be freed using | ||
| 93 | * mobilesync_client_free() after use. | ||
| 94 | * @param label The label to use for communication. Usually the program name. | ||
| 95 | * Pass NULL to disable sending the label in requests to lockdownd. | ||
| 96 | * | ||
| 97 | * @return MOBILESYNC_E_SUCCESS on success, or an MOBILESYNC_E_* error | ||
| 98 | * code otherwise. | ||
| 99 | */ | ||
| 72 | mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label); | 100 | mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label); |
| 101 | |||
| 102 | /** | ||
| 103 | * Disconnects a mobilesync client from the device and frees up the | ||
| 104 | * mobilesync client data. | ||
| 105 | * | ||
| 106 | * @param client The mobilesync client to disconnect and free. | ||
| 107 | * | ||
| 108 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 109 | * @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL. | ||
| 110 | */ | ||
| 73 | mobilesync_error_t mobilesync_client_free(mobilesync_client_t client); | 111 | mobilesync_error_t mobilesync_client_free(mobilesync_client_t client); |
| 74 | 112 | ||
| 113 | |||
| 114 | /** | ||
| 115 | * Polls the device for mobilesync data. | ||
| 116 | * | ||
| 117 | * @param client The mobilesync client | ||
| 118 | * @param plist A pointer to the location where the plist should be stored | ||
| 119 | * | ||
| 120 | * @return an error code | ||
| 121 | */ | ||
| 75 | mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist); | 122 | mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist); |
| 123 | |||
| 124 | /** | ||
| 125 | * Sends mobilesync data to the device | ||
| 126 | * | ||
| 127 | * @note This function is low-level and should only be used if you need to send | ||
| 128 | * a new type of message. | ||
| 129 | * | ||
| 130 | * @param client The mobilesync client | ||
| 131 | * @param plist The location of the plist to send | ||
| 132 | * | ||
| 133 | * @return an error code | ||
| 134 | */ | ||
| 76 | mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist); | 135 | mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist); |
| 77 | 136 | ||
| 137 | |||
| 138 | /** | ||
| 139 | * Requests starting synchronization of a data class with the device | ||
| 140 | * | ||
| 141 | * @param client The mobilesync client | ||
| 142 | * @param data_class The data class identifier to sync | ||
| 143 | * @param anchors The anchors required to exchange with the device. The anchors | ||
| 144 | * allow the device to tell if the synchronization information on the computer | ||
| 145 | * and device are consistent to determine what sync type is required. | ||
| 146 | * @param computer_data_class_version The version of the data class storage on the computer | ||
| 147 | * @param sync_type A pointer to store the sync type reported by the device_anchor | ||
| 148 | * @param device_data_class_version The version of the data class storage on the device | ||
| 149 | * @param error_description A pointer to store an error message if reported by the device | ||
| 150 | * | ||
| 151 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 152 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 153 | * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form | ||
| 154 | * @retval MOBILESYNC_E_SYNC_REFUSED if the device refused to sync | ||
| 155 | * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the | ||
| 156 | * sync request | ||
| 157 | */ | ||
| 78 | 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); | 158 | 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); |
| 159 | |||
| 160 | /** | ||
| 161 | * Cancels a running synchronization session with a device at any time. | ||
| 162 | * | ||
| 163 | * @param client The mobilesync client | ||
| 164 | * @param reason The reason to supply to the device for cancelling | ||
| 165 | * | ||
| 166 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 167 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 168 | */ | ||
| 79 | mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason); | 169 | mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason); |
| 170 | |||
| 171 | /** | ||
| 172 | * Finish a synchronization session of a data class on the device. | ||
| 173 | * A session must have previously been started using mobilesync_start(). | ||
| 174 | * | ||
| 175 | * @param client The mobilesync client | ||
| 176 | * | ||
| 177 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 178 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 179 | * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid | ||
| 180 | * form | ||
| 181 | */ | ||
| 80 | mobilesync_error_t mobilesync_finish(mobilesync_client_t client); | 182 | mobilesync_error_t mobilesync_finish(mobilesync_client_t client); |
| 81 | 183 | ||
| 184 | |||
| 185 | /** | ||
| 186 | * Requests to receive all records of the currently set data class from the device. | ||
| 187 | * The actually changes are retrieved using mobilesync_receive_changes() after this | ||
| 188 | * request has been successful. | ||
| 189 | * | ||
| 190 | * @param client The mobilesync client | ||
| 191 | * | ||
| 192 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 193 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 194 | */ | ||
| 82 | mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client); | 195 | mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client); |
| 196 | |||
| 197 | /** | ||
| 198 | * Requests to receive only changed records of the currently set data class from the device. | ||
| 199 | * The actually changes are retrieved using mobilesync_receive_changes() after this | ||
| 200 | * request has been successful. | ||
| 201 | * | ||
| 202 | * @param client The mobilesync client | ||
| 203 | * | ||
| 204 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 205 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 206 | */ | ||
| 83 | mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client); | 207 | mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client); |
| 208 | |||
| 209 | /** | ||
| 210 | * Requests the device to delete all records of the current data class | ||
| 211 | * | ||
| 212 | * @note The operation must be called after starting synchronization. | ||
| 213 | * | ||
| 214 | * @param client The mobilesync client | ||
| 215 | * | ||
| 216 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 217 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 218 | * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form | ||
| 219 | */ | ||
| 84 | mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client); | 220 | mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client); |
| 85 | 221 | ||
| 222 | |||
| 223 | /** | ||
| 224 | * Receives changed entitites of the currently set data class from the device | ||
| 225 | * | ||
| 226 | * @param client The mobilesync client | ||
| 227 | * @param entities A pointer to store the changed entity records as a PLIST_DICT | ||
| 228 | * @param is_last_record A pointer to store a flag indicating if this submission is the last one | ||
| 229 | * @param actions A pointer to additional flags the device is sending or NULL to ignore | ||
| 230 | * | ||
| 231 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 232 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 233 | * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the | ||
| 234 | * session | ||
| 235 | */ | ||
| 86 | mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions); | 236 | mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions); |
| 237 | |||
| 238 | /** | ||
| 239 | * Acknowledges to the device that the changes have been merged on the computer | ||
| 240 | * | ||
| 241 | * @param client The mobilesync client | ||
| 242 | * | ||
| 243 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 244 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 245 | */ | ||
| 87 | mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client); | 246 | mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client); |
| 88 | 247 | ||
| 248 | |||
| 249 | /** | ||
| 250 | * Verifies if the device is ready to receive changes from the computer. | ||
| 251 | * This call changes the synchronization direction so that mobilesync_send_changes() | ||
| 252 | * can be used to send changes to the device. | ||
| 253 | * | ||
| 254 | * @param client The mobilesync client | ||
| 255 | * | ||
| 256 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 257 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 258 | * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form | ||
| 259 | * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does | ||
| 260 | * not permit this call | ||
| 261 | * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the | ||
| 262 | * session | ||
| 263 | * @retval MOBILESYNC_E_NOT_READY if the device is not ready to start | ||
| 264 | * receiving any changes | ||
| 265 | */ | ||
| 89 | mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client); | 266 | mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client); |
| 90 | 267 | ||
| 268 | |||
| 269 | /** | ||
| 270 | * Sends changed entities of the currently set data class to the device | ||
| 271 | * | ||
| 272 | * @param client The mobilesync client | ||
| 273 | * @param entities The changed entity records as a PLIST_DICT | ||
| 274 | * @param is_last_record A flag indicating if this submission is the last one | ||
| 275 | * @param actions Additional actions for the device created with mobilesync_actions_new() | ||
| 276 | * or NULL if no actions should be passed | ||
| 277 | * | ||
| 278 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 279 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid, | ||
| 280 | * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does | ||
| 281 | * not permit this call | ||
| 282 | */ | ||
| 91 | mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions); | 283 | mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions); |
| 284 | |||
| 285 | /** | ||
| 286 | * Receives any remapped identifiers reported after the device merged submitted changes. | ||
| 287 | * | ||
| 288 | * @param client The mobilesync client | ||
| 289 | * @param mapping A pointer to an array plist containing a dict of identifier remappings | ||
| 290 | * | ||
| 291 | * @retval MOBILESYNC_E_SUCCESS on success | ||
| 292 | * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid | ||
| 293 | * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid | ||
| 294 | * form | ||
| 295 | * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does | ||
| 296 | * not permit this call | ||
| 297 | * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the | ||
| 298 | * session | ||
| 299 | */ | ||
| 92 | mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping); | 300 | mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping); |
| 93 | 301 | ||
| 94 | /* Helper */ | 302 | /* Helper */ |
| 303 | |||
| 304 | /** | ||
| 305 | * Allocates memory for a new anchors struct initialized with the passed anchors. | ||
| 306 | * | ||
| 307 | * @param device_anchor An anchor the device reported the last time or NULL | ||
| 308 | * if none is known yet which for instance is true on first synchronization. | ||
| 309 | * @param computer_anchor An arbitrary string to use as anchor for the computer. | ||
| 310 | * | ||
| 311 | * @return A new #mobilesync_anchors_t struct. Must be freed using mobilesync_anchors_free(). | ||
| 312 | */ | ||
| 95 | mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor); | 313 | mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor); |
| 314 | |||
| 315 | /** | ||
| 316 | * Free memory used by anchors. | ||
| 317 | * | ||
| 318 | * @param anchors The anchors to free. | ||
| 319 | */ | ||
| 96 | void mobilesync_anchors_free(mobilesync_anchors_t anchors); | 320 | void mobilesync_anchors_free(mobilesync_anchors_t anchors); |
| 97 | 321 | ||
| 322 | |||
| 323 | /** | ||
| 324 | * Create a new actions plist to use in mobilesync_send_changes(). | ||
| 325 | * | ||
| 326 | * @return A new plist_t of type PLIST_DICT. | ||
| 327 | */ | ||
| 98 | plist_t mobilesync_actions_new(); | 328 | plist_t mobilesync_actions_new(); |
| 329 | |||
| 330 | /** | ||
| 331 | * Add one or more new key:value pairs to the given actions plist. | ||
| 332 | * | ||
| 333 | * @param actions The actions to modify. | ||
| 334 | * @param ... KEY, VALUE, [KEY, VALUE], NULL | ||
| 335 | * | ||
| 336 | * @note The known keys so far are "SyncDeviceLinkEntityNamesKey" which expects | ||
| 337 | * an array of entity names, followed by a count paramter as well as | ||
| 338 | * "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey" which expects an | ||
| 339 | * integer to use as a boolean value indicating that the device should | ||
| 340 | * link submitted changes and report remapped identifiers. | ||
| 341 | */ | ||
| 99 | void mobilesync_actions_add(plist_t actions, ...); | 342 | void mobilesync_actions_add(plist_t actions, ...); |
| 343 | |||
| 344 | /** | ||
| 345 | * Free actions plist. | ||
| 346 | * | ||
| 347 | * @param actions The actions plist to free. Does nothing if NULL is passed. | ||
| 348 | */ | ||
| 100 | void mobilesync_actions_free(plist_t actions); | 349 | void mobilesync_actions_free(plist_t actions); |
| 101 | 350 | ||
| 102 | #ifdef __cplusplus | 351 | #ifdef __cplusplus |
