diff options
| author | 2010-06-05 23:41:35 +0200 | |
|---|---|---|
| committer | 2010-06-05 23:41:35 +0200 | |
| commit | e5d4b8e126b0160c80103b814ef59a3f1319f22e (patch) | |
| tree | bbdd8dabd2c13e4f544848c4e0b57bf31d5155d3 /src/restore.c | |
| parent | 7a2811b76793b262237b4b61bc777edf9ec37257 (diff) | |
| download | libimobiledevice-e5d4b8e126b0160c80103b814ef59a3f1319f22e.tar.gz libimobiledevice-e5d4b8e126b0160c80103b814ef59a3f1319f22e.tar.bz2 | |
Added function to fetch device values from the QueryType response
Diffstat (limited to 'src/restore.c')
| -rw-r--r-- | src/restore.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/restore.c b/src/restore.c index 8acefef..ab14c28 100644 --- a/src/restore.c +++ b/src/restore.c | |||
| @@ -119,6 +119,10 @@ restored_error_t restored_client_free(restored_client_t client) | |||
| 119 | if (client->label) { | 119 | if (client->label) { |
| 120 | free(client->label); | 120 | free(client->label); |
| 121 | } | 121 | } |
| 122 | |||
| 123 | if (client->info) { | ||
| 124 | plist_free(client->info); | ||
| 125 | } | ||
| 122 | 126 | ||
| 123 | free(client); | 127 | free(client); |
| 124 | return ret; | 128 | return ret; |
| @@ -154,6 +158,7 @@ restored_error_t restored_receive(restored_client_t client, plist_t *plist) | |||
| 154 | { | 158 | { |
| 155 | if (!client || !plist || (plist && *plist)) | 159 | if (!client || !plist || (plist && *plist)) |
| 156 | return RESTORE_E_INVALID_ARG; | 160 | return RESTORE_E_INVALID_ARG; |
| 161 | |||
| 157 | restored_error_t ret = RESTORE_E_SUCCESS; | 162 | restored_error_t ret = RESTORE_E_SUCCESS; |
| 158 | property_list_service_error_t err; | 163 | property_list_service_error_t err; |
| 159 | 164 | ||
| @@ -229,6 +234,9 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint | |||
| 229 | 234 | ||
| 230 | ret = RESTORE_E_UNKNOWN_ERROR; | 235 | ret = RESTORE_E_UNKNOWN_ERROR; |
| 231 | if (restored_check_result(dict) == RESULT_SUCCESS) { | 236 | if (restored_check_result(dict) == RESULT_SUCCESS) { |
| 237 | /* save our device information info */ | ||
| 238 | client->info = dict; | ||
| 239 | |||
| 232 | /* return the type if requested */ | 240 | /* return the type if requested */ |
| 233 | if (type != NULL) { | 241 | if (type != NULL) { |
| 234 | plist_t type_node = plist_dict_get_item(dict, "Type"); | 242 | plist_t type_node = plist_dict_get_item(dict, "Type"); |
| @@ -247,13 +255,47 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint | |||
| 247 | ret = RESTORE_E_UNKNOWN_ERROR; | 255 | ret = RESTORE_E_UNKNOWN_ERROR; |
| 248 | 256 | ||
| 249 | } | 257 | } |
| 250 | plist_free(dict); | ||
| 251 | dict = NULL; | ||
| 252 | 258 | ||
| 253 | return ret; | 259 | return ret; |
| 254 | } | 260 | } |
| 255 | 261 | ||
| 256 | /** | 262 | /** |
| 263 | * Retrieves a value from information plist specified by a key. | ||
| 264 | * | ||
| 265 | * @param client An initialized restored client. | ||
| 266 | * @param key The key name to request or NULL to query for all keys | ||
| 267 | * @param value A plist node representing the result value node | ||
| 268 | * | ||
| 269 | * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found | ||
| 270 | */ | ||
| 271 | restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) | ||
| 272 | { | ||
| 273 | if (!client || !value || (value && *value)) | ||
| 274 | return RESTORE_E_INVALID_ARG; | ||
| 275 | |||
| 276 | if (!client->info) | ||
| 277 | return RESTORE_E_NOT_ENOUGH_DATA; | ||
| 278 | |||
| 279 | restored_error_t ret = RESTORE_E_SUCCESS; | ||
| 280 | plist_t item = NULL; | ||
| 281 | |||
| 282 | if (!key) { | ||
| 283 | *value = plist_copy(client->info); | ||
| 284 | return RESTORE_E_SUCCESS; | ||
| 285 | } else { | ||
| 286 | item = plist_dict_get_item(client->info, key); | ||
| 287 | } | ||
| 288 | |||
| 289 | if (item) { | ||
| 290 | *value = plist_copy(item); | ||
| 291 | } else { | ||
| 292 | ret = RESTORE_E_PLIST_ERROR; | ||
| 293 | } | ||
| 294 | |||
| 295 | return ret; | ||
| 296 | } | ||
| 297 | |||
| 298 | /** | ||
| 257 | * Creates a new restored client for the device. | 299 | * Creates a new restored client for the device. |
| 258 | * | 300 | * |
| 259 | * @param device The device to create a restored client for | 301 | * @param device The device to create a restored client for |
