summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2010-11-22 23:15:48 +0100
committerGravatar Martin Szulecki2011-04-11 17:05:57 +0200
commitae7013d7d8355da926c0818182dd500589b48ed6 (patch)
tree871f5c2f4ffd0db6d514d58cfcff7592055d1dcb
parentbd8d84245b4ca80858bf9b61682268e6c4095f34 (diff)
downloadlibimobiledevice-ae7013d7d8355da926c0818182dd500589b48ed6.tar.gz
libimobiledevice-ae7013d7d8355da926c0818182dd500589b48ed6.tar.bz2
mobilebackup2: small api changes
-rw-r--r--include/libimobiledevice/mobilebackup2.h2
-rw-r--r--src/mobilebackup2.c26
-rw-r--r--tools/idevicebackup4.c2
3 files changed, 23 insertions, 7 deletions
diff --git a/include/libimobiledevice/mobilebackup2.h b/include/libimobiledevice/mobilebackup2.h
index ea49602..a58dc00 100644
--- a/include/libimobiledevice/mobilebackup2.h
+++ b/include/libimobiledevice/mobilebackup2.h
@@ -53,7 +53,7 @@ mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t clien
mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes);
mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes);
mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client);
-mobilebackup2_error_t mobilebackup2_request_backup(mobilebackup2_client_t client, const char *uuid);
+mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options);
mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2);
#ifdef __cplusplus
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:
}
/**
- * TODO
+ * Send a request to the connected mobilebackup2 service.
+ *
+ * @param client
+ * @param request The request to send to the backup service.
+ * Currently, this is one of "Backup", "Restore", "Info", or "List".
+ * @param target_identifier UUID of the target device.
+ * @param source_identifier UUID of backup data?
+ * @param options Additional options in a plist of type PLIST_DICT.
+ *
+ * @return MOBILEBACKUP2_E_SUCCESS if the request was successfully sent,
+ * or a MOBILEBACKUP2_E_* error value otherwise.
*/
-mobilebackup2_error_t mobilebackup2_request_backup(mobilebackup2_client_t client, const char *uuid)
+mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options)
{
- if (!client || !client->parent)
+ if (!client || !client->parent || !request || !target_identifier)
return MOBILEBACKUP2_E_INVALID_ARG;
plist_t dict = plist_new_dict();
- plist_dict_insert_item(dict, "TargetIdentifier", plist_new_string(uuid));
- mobilebackup2_error_t err = internal_mobilebackup2_send_message(client, "Backup", dict);
+ plist_dict_insert_item(dict, "TargetIdentifier", plist_new_string(target_identifier));
+ if (source_identifier) {
+ plist_dict_insert_item(dict, "SourceIdentifier", plist_new_string(source_identifier));
+ }
+ if (options) {
+ plist_dict_insert_item(dict, "Options", plist_copy(options));
+ }
+ mobilebackup2_error_t err = internal_mobilebackup2_send_message(client, request, dict);
plist_free(dict);
return err;
diff --git a/tools/idevicebackup4.c b/tools/idevicebackup4.c
index 4b39510..a44abb6 100644
--- a/tools/idevicebackup4.c
+++ b/tools/idevicebackup4.c
@@ -1381,7 +1381,7 @@ checkpoint:
/* request backup from device with manifest from last backup */
printf("Requesting backup from device...\n");
- err = mobilebackup2_request_backup(mobilebackup2, uuid);
+ err = mobilebackup2_send_request(mobilebackup2, "Backup", uuid, NULL, NULL);
if (err == MOBILEBACKUP2_E_SUCCESS) {
/*if (is_full_backup)
printf("Full backup mode.\n");