summaryrefslogtreecommitdiffstats
path: root/src/libirecovery.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-06 18:52:47 -0400
committerGravatar Joshua Hill2010-06-06 18:52:47 -0400
commit09caab6993bfe2e696ab47776189a4216547c6a9 (patch)
tree3a409e309d5c20327b3e93dddc71d6bc43124f82 /src/libirecovery.c
parentff1d99f386c9a0667d5f4056ab8ffaba70e91324 (diff)
downloadlibirecovery-09caab6993bfe2e696ab47776189a4216547c6a9.tar.gz
libirecovery-09caab6993bfe2e696ab47776189a4216547c6a9.tar.bz2
Moved progress bar into irecovery and finished implementing progress notications
Diffstat (limited to 'src/libirecovery.c')
-rw-r--r--src/libirecovery.c38
1 files changed, 4 insertions, 34 deletions
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");
- }
-
-}