summaryrefslogtreecommitdiffstats
path: root/src/asr.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2012-11-07 22:08:53 +0100
committerGravatar Martin Szulecki2012-11-07 22:08:53 +0100
commitb65a7ce7ebca6730fce5dcbfd820d8ef4124e18f (patch)
tree3aaa3a68931bbaf3ec31bef6fad18c951cf7d32f /src/asr.c
parentb44ad07bec397f6cd1c597946efe86e5ed2a490b (diff)
downloadidevicerestore-b65a7ce7ebca6730fce5dcbfd820d8ef4124e18f.tar.gz
idevicerestore-b65a7ce7ebca6730fce5dcbfd820d8ef4124e18f.tar.bz2
libidevicerecovery: implemented progress callback logic
Diffstat (limited to 'src/asr.c')
-rw-r--r--src/asr.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/asr.c b/src/asr.c
index 401bc51..96d7396 100644
--- a/src/asr.c
+++ b/src/asr.c
@@ -27,6 +27,7 @@
#include "asr.h"
#include "idevicerestore.h"
+#include "common.h"
#define ASR_VERSION 1
#define ASR_STREAM_ID 1
@@ -103,6 +104,15 @@ int asr_open_with_timeout(idevice_t device, asr_client_t* asr) {
return 0;
}
+void asr_set_progress_callback(asr_client_t asr, asr_progress_cb_t cbfunc, void* userdata)
+{
+ if (!asr) {
+ return;
+ }
+ asr->progress_cb = cbfunc;
+ asr->progress_cb_data = userdata;
+}
+
int asr_receive(asr_client_t asr, plist_t* data) {
uint32_t size = 0;
char* buffer = NULL;
@@ -387,8 +397,11 @@ int asr_send_payload(asr_client_t asr, const char* filesystem) {
}
bytes += size;
- progress = ((double) bytes/ (double) length) * 100.0;
- print_progress_bar(progress);
+ progress = ((double) bytes/ (double) length);
+ if (asr->progress_cb && ((int)(progress*100) > asr->lastprogress)) {
+ asr->progress_cb(progress, asr->progress_cb_data);
+ asr->lastprogress = (int)(progress*100);
+ }
}
// if last chunk wasn't terminated with a checksum we do it here