From 09caab6993bfe2e696ab47776189a4216547c6a9 Mon Sep 17 00:00:00 2001 From: Joshua Hill Date: Sun, 6 Jun 2010 18:52:47 -0400 Subject: Moved progress bar into irecovery and finished implementing progress notications --- src/libirecovery.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to 'src/libirecovery.c') diff --git a/src/libirecovery.c b/src/libirecovery.c index acf1d6b..4900fbf 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c @@ -324,8 +324,8 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un } int i = 0; - double count = 0; double progress = 0; + unsigned int count = 0; unsigned int status = 0; for (i = 0; i < packets; i++) { int size = i + 1 < packets ? 0x800 : last; @@ -349,15 +349,12 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un count += size; if(client->progress_callback != NULL) { irecv_event_t event; + event.progress = ((double) count/ (double) length) * 100.0; event.type = IRECV_PROGRESS; - event.data = NULL; - event.size = count/length; + event.data = "Uploading"; + event.size = count; client->progress_callback(client, &event); } - else if((count / (double) length) * 100.0 > progress) { - progress = (count / (double) length) * 100.0; - irecv_print_progress("Uploading", progress); - } } libusb_control_transfer(client->handle, 0x21, 1, 0, 0, buffer, 0, 1000); @@ -525,30 +522,3 @@ const char* irecv_strerror(irecv_error_t error) { return NULL; } - -void irecv_print_progress(const char* operation, float progress) { - int i = 0; - if(progress < 0) { - return; - } - - if(progress > 100) { - progress = 100; - } - - printf("\r%s [", operation); - for(i = 0; i < 50; i++) { - if(i < progress / 2) { - printf("="); - } else { - printf(" "); - } - } - - printf("] %3.1f%%", progress); - fflush(stdout); - if(progress == 100) { - printf("\n"); - } - -} -- cgit v1.1-32-gdbae