summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-05-31 18:36:41 -0400
committerGravatar Joshua Hill2010-05-31 18:36:41 -0400
commit75a3f5f5c6ec5b89659f4e4aacd5d629a3912f22 (patch)
treea991838d2f8c03cd92d47133b2bc318f831f3e78 /src
parentda25954379029b2f244ef305cd05b2c9129aac8f (diff)
downloadidevicerestore-75a3f5f5c6ec5b89659f4e4aacd5d629a3912f22.tar.gz
idevicerestore-75a3f5f5c6ec5b89659f4e4aacd5d629a3912f22.tar.bz2
Added code to automatically detect when connection is lost
Diffstat (limited to 'src')
-rw-r--r--src/idevicerestore.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index be8c9c7..fa685bd 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -43,6 +43,7 @@
int idevicerestore_debug = 0;
static int idevicerestore_mode = 0;
+static int idevicerestore_quit = 0;
static int idevicerestore_custom = 0;
void usage(int argc, char* argv[]);
@@ -344,12 +345,11 @@ int main(int argc, char* argv[]) {
info("Device has successfully entered restore mode\n");
/* start restore process */
- int quit_flag = 0;
char* kernelcache = NULL;
info("Restore protocol version is %llu.\n", version);
restore_error = restored_start_restore(restore);
if (restore_error == RESTORE_E_SUCCESS) {
- while (!quit_flag) {
+ while (!idevicerestore_quit) {
plist_t message = NULL;
restore_error = restored_receive(restore, &message);
plist_t msgtype_node = plist_dict_get_item(message, "MsgType");
@@ -398,7 +398,7 @@ int main(int argc, char* argv[]) {
if (RESTORE_E_SUCCESS != restore_error) {
error("Invalid return status %d\n", restore_error);
- //quit_flag = 1;
+ //idevicerestore_quit = 1;
}
plist_free(message);
@@ -417,6 +417,8 @@ int main(int argc, char* argv[]) {
void device_callback(const idevice_event_t* event, void *user_data) {
if (event->event == IDEVICE_DEVICE_ADD) {
idevicerestore_mode = RESTORE_MODE;
+ } else if(event->event == IDEVICE_DEVICE_REMOVE) {
+ idevicerestore_quit = 1;
}
}