summaryrefslogtreecommitdiffstats
path: root/src/mobilebackup2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mobilebackup2.c')
-rw-r--r--src/mobilebackup2.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/mobilebackup2.c b/src/mobilebackup2.c
index 7b6ea33..2fbadd2 100644
--- a/src/mobilebackup2.c
+++ b/src/mobilebackup2.c
@@ -355,16 +355,32 @@ leave:
355} 355}
356 356
357/** 357/**
358 * TODO 358 * Send a request to the connected mobilebackup2 service.
359 *
360 * @param client
361 * @param request The request to send to the backup service.
362 * Currently, this is one of "Backup", "Restore", "Info", or "List".
363 * @param target_identifier UUID of the target device.
364 * @param source_identifier UUID of backup data?
365 * @param options Additional options in a plist of type PLIST_DICT.
366 *
367 * @return MOBILEBACKUP2_E_SUCCESS if the request was successfully sent,
368 * or a MOBILEBACKUP2_E_* error value otherwise.
359 */ 369 */
360mobilebackup2_error_t mobilebackup2_request_backup(mobilebackup2_client_t client, const char *uuid) 370mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options)
361{ 371{
362 if (!client || !client->parent) 372 if (!client || !client->parent || !request || !target_identifier)
363 return MOBILEBACKUP2_E_INVALID_ARG; 373 return MOBILEBACKUP2_E_INVALID_ARG;
364 374
365 plist_t dict = plist_new_dict(); 375 plist_t dict = plist_new_dict();
366 plist_dict_insert_item(dict, "TargetIdentifier", plist_new_string(uuid)); 376 plist_dict_insert_item(dict, "TargetIdentifier", plist_new_string(target_identifier));
367 mobilebackup2_error_t err = internal_mobilebackup2_send_message(client, "Backup", dict); 377 if (source_identifier) {
378 plist_dict_insert_item(dict, "SourceIdentifier", plist_new_string(source_identifier));
379 }
380 if (options) {
381 plist_dict_insert_item(dict, "Options", plist_copy(options));
382 }
383 mobilebackup2_error_t err = internal_mobilebackup2_send_message(client, request, dict);
368 plist_free(dict); 384 plist_free(dict);
369 385
370 return err; 386 return err;