summaryrefslogtreecommitdiffstats
path: root/src/restore.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-06 06:09:06 +0800
committerGravatar rcg4u2010-06-09 17:17:29 +0800
commit9279f889d7e296880fd7ea9d6c7cec499db62ea4 (patch)
treec039506ad319c2ec81f5a0aeb5ac4737b10d9389 /src/restore.c
parentc21f7031b44e4cd61c1a6e630f9681742923ffa0 (diff)
downloadidevicerestore-9279f889d7e296880fd7ea9d6c7cec499db62ea4.tar.gz
idevicerestore-9279f889d7e296880fd7ea9d6c7cec499db62ea4.tar.bz2
Changed the device type to a structure array for cleaner code and cross state access
Diffstat (limited to 'src/restore.c')
-rw-r--r--src/restore.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/restore.c b/src/restore.c
index ce9d41b..46a509a 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -80,6 +80,64 @@ int restore_check_mode(const char* uuid) {
return 0;
}
+int restore_check_device(const char* uuid) {
+ int i = 0;
+ char* type = NULL;
+ char* model = NULL;
+ plist_t node = NULL;
+ uint64_t version = 0;
+ idevice_t device = NULL;
+ restored_client_t restore = NULL;
+ idevice_error_t device_error = IDEVICE_E_SUCCESS;
+ restored_error_t restore_error = RESTORE_E_SUCCESS;
+
+ device_error = idevice_new(&device, uuid);
+ if (device_error != IDEVICE_E_SUCCESS) {
+ return -1;
+ }
+
+ restore_error = restored_client_new(device, &restore, "idevicerestore");
+ if (restore_error != RESTORE_E_SUCCESS) {
+ idevice_free(device);
+ return -1;
+ }
+
+ restore_error = restored_query_type(restore, &type, &version);
+ if (restore_error != RESTORE_E_SUCCESS) {
+ restored_client_free(restore);
+ idevice_free(device);
+ return -1;
+ }
+
+ restore_error = restored_get_value(restore, "HardwareModel", &node);
+ if(restore_error != RESTORE_E_SUCCESS) {
+ error("ERROR: Unable to get HardwareModel from restored\n");
+ restored_client_free(restore);
+ idevice_free(device);
+ return -1;
+ }
+
+ restored_client_free(restore);
+ idevice_free(device);
+ restore = NULL;
+ device = NULL;
+
+ if (!node || plist_get_node_type(node) != PLIST_STRING) {
+ error("ERROR: Unable to get HardwareModel information\n");
+ if(node) plist_free(node);
+ return -1;
+ }
+ plist_get_string_val(node, &model);
+
+ for(i = 0; idevicerestore_devices[i].model != NULL; i++) {
+ if(!strcasecmp(model, idevicerestore_devices[i].model)) {
+ break;
+ }
+ }
+
+ return idevicerestore_devices[i].device_id;
+}
+
void restore_device_callback(const idevice_event_t* event, void* user_data) {
if (event->event == IDEVICE_DEVICE_ADD) {
restore_device_connected = 1;