summaryrefslogtreecommitdiffstats
path: root/src/mobilebackup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mobilebackup.c')
-rw-r--r--src/mobilebackup.c157
1 files changed, 0 insertions, 157 deletions
diff --git a/src/mobilebackup.c b/src/mobilebackup.c
index 66e590a..7107d12 100644
--- a/src/mobilebackup.c
+++ b/src/mobilebackup.c
@@ -60,18 +60,6 @@ static mobilebackup_error_t mobilebackup_error(device_link_service_error_t err)
60 return MOBILEBACKUP_E_UNKNOWN_ERROR; 60 return MOBILEBACKUP_E_UNKNOWN_ERROR;
61} 61}
62 62
63/**
64 * Connects to the mobilebackup service on the specified device.
65 *
66 * @param device The device to connect to.
67 * @param service The service descriptor returned by lockdownd_start_service.
68 * @param client Pointer that will be set to a newly allocated
69 * mobilebackup_client_t upon successful return.
70 *
71 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID ARG if one
72 * or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if
73 * the mobilebackup version on the device is newer.
74 */
75mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client) 63mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client)
76{ 64{
77 if (!device || !service || service->port == 0 || !client || *client) 65 if (!device || !service || service->port == 0 || !client || *client)
@@ -99,19 +87,6 @@ mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service
99 return ret; 87 return ret;
100} 88}
101 89
102/**
103 * Starts a new mobilebackup service on the specified device and connects to it.
104 *
105 * @param device The device to connect to.
106 * @param client Pointer that will point to a newly allocated
107 * mobilebackup_client_t upon successful return. Must be freed using
108 * mobilebackup_client_free() after use.
109 * @param label The label to use for communication. Usually the program name.
110 * Pass NULL to disable sending the label in requests to lockdownd.
111 *
112 * @return MOBILEBACKUP_E_SUCCESS on success, or an MOBILEBACKUP_E_* error
113 * code otherwise.
114 */
115mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t * client, const char* label) 90mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t * client, const char* label)
116{ 91{
117 mobilebackup_error_t err = MOBILEBACKUP_E_UNKNOWN_ERROR; 92 mobilebackup_error_t err = MOBILEBACKUP_E_UNKNOWN_ERROR;
@@ -119,15 +94,6 @@ mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobileb
119 return err; 94 return err;
120} 95}
121 96
122/**
123 * Disconnects a mobilebackup client from the device and frees up the
124 * mobilebackup client data.
125 *
126 * @param client The mobilebackup client to disconnect and free.
127 *
128 * @return MOBILEBACKUP_E_SUCCESS on success, or MOBILEBACKUP_E_INVALID_ARG
129 * if client is NULL.
130 */
131mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client) 97mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client)
132{ 98{
133 if (!client) 99 if (!client)
@@ -141,14 +107,6 @@ mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client)
141 return err; 107 return err;
142} 108}
143 109
144/**
145 * Polls the device for mobilebackup data.
146 *
147 * @param client The mobilebackup client
148 * @param plist A pointer to the location where the plist should be stored
149 *
150 * @return an error code
151 */
152mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * plist) 110mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * plist)
153{ 111{
154 if (!client) 112 if (!client)
@@ -157,17 +115,6 @@ mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t
157 return ret; 115 return ret;
158} 116}
159 117
160/**
161 * Sends mobilebackup data to the device
162 *
163 * @note This function is low-level and should only be used if you need to send
164 * a new type of message.
165 *
166 * @param client The mobilebackup client
167 * @param plist The location of the plist to send
168 *
169 * @return an error code
170 */
171mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist) 118mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist)
172{ 119{
173 if (!client || !plist) 120 if (!client || !plist)
@@ -285,23 +232,6 @@ leave:
285 return err; 232 return err;
286} 233}
287 234
288/**
289 * Request a backup from the connected device.
290 *
291 * @param client The connected MobileBackup client to use.
292 * @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
293 * containing the backup state of the last backup. For a first-time backup
294 * set this parameter to NULL.
295 * @param base_path The base path on the device to use for the backup
296 * operation, usually "/".
297 * @param proto_version A string denoting the version of the backup protocol
298 * to use. Latest known version is "1.6"
299 *
300 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
301 * one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
302 * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
303 * if a communication error occurs, MOBILEBACKUP_E_REPLY_NOT_OK
304 */
305mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version) 235mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version)
306{ 236{
307 if (!client || !client->parent || !base_path || !proto_version) 237 if (!client || !client->parent || !base_path || !proto_version)
@@ -362,41 +292,11 @@ leave:
362 return err; 292 return err;
363} 293}
364 294
365/**
366 * Sends a confirmation to the device that a backup file has been received.
367 *
368 * @param client The connected MobileBackup client to use.
369 *
370 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
371 * client is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication error
372 * occurs.
373 */
374mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client) 295mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client)
375{ 296{
376 return mobilebackup_send_message(client, "kBackupMessageBackupFileReceived", NULL); 297 return mobilebackup_send_message(client, "kBackupMessageBackupFileReceived", NULL);
377} 298}
378 299
379/**
380 * Request that a backup should be restored to the connected device.
381 *
382 * @param client The connected MobileBackup client to use.
383 * @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
384 * containing the backup state to be restored.
385 * @param flags Flags to send with the request. Currently this is a combination
386 * of the following mobilebackup_flags_t:
387 * MB_RESTORE_NOTIFY_SPRINGBOARD - let SpringBoard show a 'Restore' screen
388 * MB_RESTORE_PRESERVE_SETTINGS - do not overwrite any settings
389 * MB_RESTORE_PRESERVE_CAMERA_ROLL - preserve the photos of the camera roll
390 * @param proto_version A string denoting the version of the backup protocol
391 * to use. Latest known version is "1.6". Ideally this value should be
392 * extracted from the given manifest plist.
393 *
394 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
395 * one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
396 * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
397 * if a communication error occurs, or MOBILEBACKUP_E_REPLY_NOT_OK
398 * if the device did not accept the request.
399 */
400mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version) 300mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version)
401{ 301{
402 if (!client || !client->parent || !backup_manifest || !proto_version) 302 if (!client || !client->parent || !backup_manifest || !proto_version)
@@ -451,63 +351,16 @@ leave:
451 return err; 351 return err;
452} 352}
453 353
454/**
455 * Receive a confirmation from the device that it successfully received
456 * a restore file.
457 *
458 * @param client The connected MobileBackup client to use.
459 * @param result Pointer to a plist_t that will be set to the received plist
460 * for further processing. The caller has to free it using plist_free().
461 * Note that it will be set to NULL if the operation itself fails due to
462 * a communication or plist error.
463 * If this parameter is NULL, it will be ignored.
464 *
465 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
466 * client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
467 * 'BackupMessageRestoreFileReceived' message could not be received,
468 * MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
469 * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
470 * occurs.
471 */
472mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result) 354mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result)
473{ 355{
474 return mobilebackup_receive_message(client, "BackupMessageRestoreFileReceived", result); 356 return mobilebackup_receive_message(client, "BackupMessageRestoreFileReceived", result);
475} 357}
476 358
477/**
478 * Receive a confirmation from the device that it successfully received
479 * application data file.
480 *
481 * @param client The connected MobileBackup client to use.
482 * @param result Pointer to a plist_t that will be set to the received plist
483 * for further processing. The caller has to free it using plist_free().
484 * Note that it will be set to NULL if the operation itself fails due to
485 * a communication or plist error.
486 * If this parameter is NULL, it will be ignored.
487 *
488 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
489 * client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
490 * 'BackupMessageRestoreApplicationReceived' message could not be received,
491 * MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
492 * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
493 * occurs.
494 */
495mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result) 359mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result)
496{ 360{
497 return mobilebackup_receive_message(client, "BackupMessageRestoreApplicationReceived", result); 361 return mobilebackup_receive_message(client, "BackupMessageRestoreApplicationReceived", result);
498} 362}
499 363
500/**
501 * Tells the device that the restore process is complete and waits for the
502 * device to close the connection. After that, the device should reboot.
503 *
504 * @param client The connected MobileBackup client to use.
505 *
506 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
507 * client is invalid, MOBILEBACKUP_E_PLIST_ERROR if the received disconnect
508 * message plist is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication
509 * error occurs.
510 */
511mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client) 364mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client)
512{ 365{
513 mobilebackup_error_t err = mobilebackup_send_message(client, "BackupMessageRestoreComplete", NULL); 366 mobilebackup_error_t err = mobilebackup_send_message(client, "BackupMessageRestoreComplete", NULL);
@@ -553,16 +406,6 @@ mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t cl
553 return err; 406 return err;
554} 407}
555 408
556/**
557 * Sends a backup error message to the device.
558 *
559 * @param client The connected MobileBackup client to use.
560 * @param reason A string describing the reason for the error message.
561 *
562 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
563 * one of the parameters is invalid, or MOBILEBACKUP_E_MUX_ERROR if a
564 * communication error occurs.
565 */
566mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason) 409mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason)
567{ 410{
568 if (!client || !client->parent || !reason) 411 if (!client || !client->parent || !reason)