diff options
author | Joshua Hill | 2010-06-07 02:24:08 -0400 |
---|---|---|
committer | Joshua Hill | 2010-06-07 02:24:08 -0400 |
commit | a91e336c24a0d741e47be7adf0cd0b2beb20e5ab (patch) | |
tree | b114cc3ab2369805ece1c169684a7f95ffdf7d3b /src | |
parent | 255b285d22056dde283d33511c14387ea92e28c0 (diff) | |
download | idevicerestore-a91e336c24a0d741e47be7adf0cd0b2beb20e5ab.tar.gz idevicerestore-a91e336c24a0d741e47be7adf0cd0b2beb20e5ab.tar.bz2 |
I really need to put more descriptive messages here, but im doing stuff all over the place
Diffstat (limited to 'src')
-rw-r--r-- | src/idevicerestore.c | 7 | ||||
-rw-r--r-- | src/idevicerestore.h | 14 | ||||
-rw-r--r-- | src/ipsw.c | 8 | ||||
-rw-r--r-- | src/recovery.c | 11 | ||||
-rw-r--r-- | src/restore.c | 2 |
5 files changed, 35 insertions, 7 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 0e77447..a1faeac 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -137,11 +137,12 @@ int main(int argc, char* argv[]) { } // discover the device type - idevicerestore_device = check_device(uuid); - if (idevicerestore_device < 0) { + int id = check_device(uuid); + if (id < 0) { error("ERROR: Unable to discover device type\n"); return -1; } + idevicerestore_device = &idevicerestore_devices[id]; // extract buildmanifest plist_t buildmanifest = NULL; @@ -178,7 +179,7 @@ int main(int argc, char* argv[]) { // devices that come after iPod2g require personalized firmwares plist_t tss_request = NULL; plist_t tss = NULL; - if (idevicerestore_device > DEVICE_IPOD2G) { + if (idevicerestore_device->device_id > DEVICE_IPOD2G) { info("Creating TSS request\n"); // fetch the device's ECID for the TSS request if (get_ecid(uuid, &ecid) < 0 || ecid == 0) { diff --git a/src/idevicerestore.h b/src/idevicerestore.h index af66892..f92aad2 100644 --- a/src/idevicerestore.h +++ b/src/idevicerestore.h @@ -111,4 +111,18 @@ inline static void debug_plist(plist_t plist) { free(data); } +inline static void print_progress_bar(const char* operation, double progress) { + int i = 0; + if(progress < 0) return; + if(progress > 100) progress = 100; + info("\r%s [", operation); + for(i = 0; i < 50; i++) { + if(i < progress / 2) info("="); + else info(" "); + } + info("] %3.1f%%", progress); + if(progress == 100) info("\n"); + fflush(stdout); +} + #endif @@ -95,7 +95,9 @@ int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfi int i = 0; int size = 0; + int bytes = 0; int count = 0; + double progress = 0; for (i = zstat.size; i > 0; i -= count) { if (i < BUFSIZE) size = i; @@ -109,9 +111,11 @@ int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfi return -1; } fwrite(buffer, 1, count, fd); - debug("."); + + bytes += size; + progress = ((double) bytes/ (double) zstat.size) * 100.0; + print_progress_bar("Extracting", progress); } - debug("\n"); fclose(fd); zip_fclose(zfile); diff --git a/src/recovery.c b/src/recovery.c index e67b10d..52f4802 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -31,6 +31,13 @@ #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); + } + return 0; +} + int recovery_check_mode() { irecv_client_t recovery = NULL; irecv_error_t recovery_error = IRECV_E_SUCCESS; @@ -92,8 +99,9 @@ int recovery_enter_restore(const char* uuid, const char* ipsw, plist_t tss) { error("ERROR: Unable to connect to device in restore mode\n"); return -1; } - restore_close(device, restore); + restore_close(device, restore); + idevicerestore_mode = MODE_RESTORE; return 0; } @@ -149,6 +157,7 @@ int recovery_open_with_timeout(irecv_client_t* client) { debug("Retrying connection...\n"); } + irecv_event_subscribe(recovery, IRECV_PROGRESS, &recovery_progress_callback, NULL); *client = recovery; return 0; } diff --git a/src/restore.c b/src/restore.c index 46a509a..b5eea66 100644 --- a/src/restore.c +++ b/src/restore.c @@ -208,7 +208,7 @@ void restore_close(idevice_t device, restored_client_t restore) { restored_client_free(restore); if (device) idevice_free(device); - idevice_event_unsubscribe(); + //idevice_event_unsubscribe(); } const char* restore_progress_string(unsigned int operation) { |