summaryrefslogtreecommitdiffstats
path: root/src/recovery.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-20 22:02:18 -0400
committerGravatar Joshua Hill2010-06-21 03:59:31 -0400
commit24afafe06f902bfd9f5652beb8797f24033c68bc (patch)
treec998387441a8e044a07cb3a5ae1282543ddaebad /src/recovery.c
parent2a2934ca1568dffe69da9a20420c7c0c71376bce (diff)
downloadidevicerestore-24afafe06f902bfd9f5652beb8797f24033c68bc.tar.gz
idevicerestore-24afafe06f902bfd9f5652beb8797f24033c68bc.tar.bz2
Archived for historical reasons
Diffstat (limited to 'src/recovery.c')
-rw-r--r--src/recovery.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/src/recovery.c b/src/recovery.c
index 88d385f..bacfac7 100644
--- a/src/recovery.c
+++ b/src/recovery.c
@@ -28,16 +28,51 @@
#include "tss.h"
#include "img3.h"
+#include "common.h"
#include "recovery.h"
#include "idevicerestore.h"
int recovery_progress_callback(irecv_client_t client, const irecv_event_t* event) {
if (event->type == IRECV_PROGRESS) {
- print_progress_bar(event->data, event->progress);
+ print_progress_bar(event->progress);
}
return 0;
}
+int recovery_client_new(struct idevicerestore_client_t* client) {
+ struct recovery_client_t* recovery = (struct recovery_client_t*) malloc(sizeof(struct recovery_client_t));
+ if (recovery == NULL) {
+ error("ERROR: Out of memory\n");
+ return -1;
+ }
+
+ if (recovery_open_with_timeout(recovery) < 0) {
+ recovery_client_free(recovery);
+ return -1;
+ }
+
+ if(recovery_check_mode(recovery) < 0) {
+ recovery_client_free(recovery);
+ return -1;
+ }
+
+ client->recovery = recovery;
+ return 0;
+}
+
+void recovery_client_free(struct idevicerestore_client_t* client) {
+ struct recovery_client_t* recovery = client->recovery;
+ if (recovery) {
+ if(recovery->client) {
+ irecv_close(recovery);
+ recovery = NULL;
+ }
+ free(recovery);
+ client->recovery = NULL;
+
+ }
+}
+
int recovery_check_mode() {
irecv_client_t recovery = NULL;
irecv_error_t recovery_error = IRECV_E_SUCCESS;
@@ -101,11 +136,11 @@ int recovery_enter_restore(const char* uuid, const char* ipsw, plist_t tss) {
}
restore_close(device, restore);
- idevicerestore_mode = MODE_RESTORE;
+ client->mode = &idevicerestore_modes[MODE_RESTORE];
return 0;
}
-int recovery_send_signed_component(irecv_client_t client, const char* ipsw, plist_t tss, char* component) {
+int recovery_send_signed_component(struct idevicerestore_client_t client, const char* ipsw, plist_t tss, char* component) {
int size = 0;
char* data = NULL;
char* path = NULL;
@@ -117,7 +152,7 @@ int recovery_send_signed_component(irecv_client_t client, const char* ipsw, plis
return -1;
}
- if (get_signed_component(ipsw, tss, path, &data, &size) < 0) {
+ if (get_signed_component(client, ipsw, tss, path, &data, &size) < 0) {
error("ERROR: Unable to get signed component: %s\n", component);
free(path);
return -1;
@@ -157,10 +192,6 @@ int recovery_open_with_timeout(irecv_client_t* client) {
debug("Retrying connection...\n");
}
- if (idevicerestore_debug) {
- irecv_set_debug_level(idevicerestore_debug);
- }
-
irecv_event_subscribe(recovery, IRECV_PROGRESS, &recovery_progress_callback, NULL);
*client = recovery;
return 0;