From 930f4b350474435e011b9dca18424dd1c42ea353 Mon Sep 17 00:00:00 2001 From: Joshua Hill Date: Mon, 21 Jun 2010 03:47:54 -0400 Subject: Finally fixed the out of control problem --- src/dfu.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/dfu.c') diff --git a/src/dfu.c b/src/dfu.c index b53803e..6fd2648 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -24,7 +24,7 @@ #include #include "dfu.h" -//#include "recovery.h" +#include "recovery.h" #include "idevicerestore.h" int dfu_progress_callback(irecv_client_t client, const irecv_event_t* event) { @@ -100,46 +100,51 @@ int dfu_open_with_timeout(struct idevicerestore_client_t* client, uint32_t timeo } irecv_event_subscribe(recovery, IRECV_PROGRESS, &dfu_progress_callback, NULL); - client->dfu = recovery; + client->dfu->client = recovery; return 0; } +int dfu_check_mode() { + return -1; +} + int dfu_enter_recovery(struct idevicerestore_client_t* client) { irecv_client_t dfu = NULL; const char* component = "iBSS"; irecv_error_t dfu_error = IRECV_E_SUCCESS; - if (recovery_open_with_timeout(&dfu) < 0 || dfu->mode != kDfuMode) { + if (recovery_open_with_timeout(client) < 0 || dfu->mode != kDfuMode) { error("ERROR: Unable to connect to DFU device\n"); if (dfu) irecv_close(dfu); return -1; } - if (recovery_send_signed_component(dfu, client->ipsw, client->tss, "iBSS") < 0) { + if (recovery_send_signed_component(client, "iBSS") < 0) { error("ERROR: Unable to send %s to device\n", component); irecv_close(dfu); return -1; } - dfu_error = irecv_reset(dfu); + dfu_error = irecv_reset(client->dfu->client); if (dfu_error != IRECV_E_SUCCESS) { error("ERROR: Unable to reset device\n"); irecv_close(dfu); return -1; } - irecv_close(dfu); - dfu = NULL; + irecv_close(client->dfu->client); + client->dfu->client = NULL; // Reconnect to device, but this time make sure we're not still in DFU mode - if (recovery_open_with_timeout(&dfu) < 0 || dfu->mode == kDfuMode) { + if (recovery_open_with_timeout(client) < 0 || client->mode->index != kDfuMode) { error("ERROR: Unable to connect to recovery device\n"); - if (dfu) - irecv_close(dfu); + if (client->dfu->client) + irecv_close(client->dfu->client); return -1; } client->mode = &idevicerestore_modes[MODE_RECOVERY]; - irecv_close(dfu); - dfu = NULL; + irecv_close(client->dfu->client); + client->dfu->client = NULL; return 0; } + -- cgit v1.1-32-gdbae