diff options
| author | 2014-06-13 10:29:01 +0200 | |
|---|---|---|
| committer | 2014-06-13 10:29:01 +0200 | |
| commit | fe5bb14d06879e132e4afab53e7d7289320a20fc (patch) | |
| tree | 151eeb28ce44b2c08cd2c6d03276755a8035119a | |
| parent | b2c9eede175c2e4ea054fbc0e4514560c2bab39c (diff) | |
| download | libimobiledevice-fe5bb14d06879e132e4afab53e7d7289320a20fc.tar.gz libimobiledevice-fe5bb14d06879e132e4afab53e7d7289320a20fc.tar.bz2 | |
mobile_image_mounter: Change upload method to accept optional image signature
| -rw-r--r-- | include/libimobiledevice/mobile_image_mounter.h | 14 | ||||
| -rw-r--r-- | src/mobile_image_mounter.c | 11 |
2 files changed, 16 insertions, 9 deletions
diff --git a/include/libimobiledevice/mobile_image_mounter.h b/include/libimobiledevice/mobile_image_mounter.h index 569b288..7fe2c2a 100644 --- a/include/libimobiledevice/mobile_image_mounter.h +++ b/include/libimobiledevice/mobile_image_mounter.h | |||
| @@ -112,11 +112,15 @@ mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_clie | |||
| 112 | mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result); | 112 | mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result); |
| 113 | 113 | ||
| 114 | /** | 114 | /** |
| 115 | * Uploads an image to the device. | 115 | * Uploads an image with an optional signature to the device. |
| 116 | * | 116 | * |
| 117 | * @param client The connected mobile_image_mounter client. | 117 | * @param client The connected mobile_image_mounter client. |
| 118 | * @param image_type Type of image that is being uploaded. | 118 | * @param image_type Type of image that is being uploaded. |
| 119 | * @param image_size Total size of the image. | 119 | * @param image_size Total size of the image. |
| 120 | * @param signature Buffer with a signature of the image being uploaded. If | ||
| 121 | * NULL, no signature will be used. | ||
| 122 | * @param signature_size Total size of the image signature buffer. If 0, no | ||
| 123 | * signature will be used. | ||
| 120 | * @param upload_cb Callback function that gets the data chunks for uploading | 124 | * @param upload_cb Callback function that gets the data chunks for uploading |
| 121 | * the image. | 125 | * the image. |
| 122 | * @param userdata User defined data for the upload callback function. | 126 | * @param userdata User defined data for the upload callback function. |
| @@ -124,7 +128,7 @@ mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_moun | |||
| 124 | * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a | 128 | * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a |
| 125 | * MOBILE_IMAGE_MOUNTER_E_* error code otherwise. | 129 | * MOBILE_IMAGE_MOUNTER_E_* error code otherwise. |
| 126 | */ | 130 | */ |
| 127 | mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata); | 131 | mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata); |
| 128 | 132 | ||
| 129 | /** | 133 | /** |
| 130 | * Mounts an image on the device. | 134 | * Mounts an image on the device. |
| @@ -132,8 +136,8 @@ mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_moun | |||
| 132 | * @param client The connected mobile_image_mounter client. | 136 | * @param client The connected mobile_image_mounter client. |
| 133 | * @param image_path The absolute path of the image to mount. The image must | 137 | * @param image_path The absolute path of the image to mount. The image must |
| 134 | * be present before calling this function. | 138 | * be present before calling this function. |
| 135 | * @param image_signature Pointer to a buffer holding the images' signature | 139 | * @param signature Pointer to a buffer holding the images' signature |
| 136 | * @param signature_length Length of the signature image_signature points to | 140 | * @param signature_size Length of the signature image_signature points to |
| 137 | * @param image_type Type of image to mount | 141 | * @param image_type Type of image to mount |
| 138 | * @param result Pointer to a plist that will receive the result of the | 142 | * @param result Pointer to a plist that will receive the result of the |
| 139 | * operation. | 143 | * operation. |
| @@ -147,7 +151,7 @@ mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_moun | |||
| 147 | * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are | 151 | * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are |
| 148 | * invalid, or another error code otherwise. | 152 | * invalid, or another error code otherwise. |
| 149 | */ | 153 | */ |
| 150 | mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result); | 154 | mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result); |
| 151 | 155 | ||
| 152 | /** | 156 | /** |
| 153 | * Hangs up the connection to the mobile_image_mounter service. | 157 | * Hangs up the connection to the mobile_image_mounter service. |
diff --git a/src/mobile_image_mounter.c b/src/mobile_image_mounter.c index 7133b8b..ab32cac 100644 --- a/src/mobile_image_mounter.c +++ b/src/mobile_image_mounter.c | |||
| @@ -141,7 +141,7 @@ leave_unlock: | |||
| 141 | return res; | 141 | return res; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata) | 144 | mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata) |
| 145 | { | 145 | { |
| 146 | if (!client || !image_type || (image_size == 0) || !upload_cb) { | 146 | if (!client || !image_type || (image_size == 0) || !upload_cb) { |
| 147 | return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG; | 147 | return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG; |
| @@ -151,6 +151,8 @@ mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_moun | |||
| 151 | 151 | ||
| 152 | plist_t dict = plist_new_dict(); | 152 | plist_t dict = plist_new_dict(); |
| 153 | plist_dict_set_item(dict, "Command", plist_new_string("ReceiveBytes")); | 153 | plist_dict_set_item(dict, "Command", plist_new_string("ReceiveBytes")); |
| 154 | if (signature && signature_size != 0) | ||
| 155 | plist_dict_set_item(dict, "ImageSignature", plist_new_data(signature, signature_size)); | ||
| 154 | plist_dict_set_item(dict, "ImageSize", plist_new_uint(image_size)); | 156 | plist_dict_set_item(dict, "ImageSize", plist_new_uint(image_size)); |
| 155 | plist_dict_set_item(dict, "ImageType", plist_new_string(image_type)); | 157 | plist_dict_set_item(dict, "ImageType", plist_new_string(image_type)); |
| 156 | 158 | ||
| @@ -250,9 +252,9 @@ leave_unlock: | |||
| 250 | 252 | ||
| 251 | } | 253 | } |
| 252 | 254 | ||
| 253 | mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result) | 255 | mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result) |
| 254 | { | 256 | { |
| 255 | if (!client || !image_path || !image_signature || (signature_length == 0) || !image_type || !result) { | 257 | if (!client || !image_path || !image_type || !result) { |
| 256 | return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG; | 258 | return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG; |
| 257 | } | 259 | } |
| 258 | mobile_image_mounter_lock(client); | 260 | mobile_image_mounter_lock(client); |
| @@ -260,7 +262,8 @@ mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mount | |||
| 260 | plist_t dict = plist_new_dict(); | 262 | plist_t dict = plist_new_dict(); |
| 261 | plist_dict_set_item(dict, "Command", plist_new_string("MountImage")); | 263 | plist_dict_set_item(dict, "Command", plist_new_string("MountImage")); |
| 262 | plist_dict_set_item(dict, "ImagePath", plist_new_string(image_path)); | 264 | plist_dict_set_item(dict, "ImagePath", plist_new_string(image_path)); |
| 263 | plist_dict_set_item(dict, "ImageSignature", plist_new_data(image_signature, signature_length)); | 265 | if (signature && signature_size != 0) |
| 266 | plist_dict_set_item(dict, "ImageSignature", plist_new_data(signature, signature_size)); | ||
| 264 | plist_dict_set_item(dict, "ImageType", plist_new_string(image_type)); | 267 | plist_dict_set_item(dict, "ImageType", plist_new_string(image_type)); |
| 265 | 268 | ||
| 266 | mobile_image_mounter_error_t res = mobile_image_mounter_error(property_list_service_send_xml_plist(client->parent, dict)); | 269 | mobile_image_mounter_error_t res = mobile_image_mounter_error(property_list_service_send_xml_plist(client->parent, dict)); |
