diff options
| author | 2022-05-09 19:02:35 +0200 | |
|---|---|---|
| committer | 2022-05-09 19:02:35 +0200 | |
| commit | 3909271599917bc4a3a996f99bdd3f88c49577fa (patch) | |
| tree | eea92211456cff432b9512b73e350a6db2705a95 | |
| parent | 534ddefac4b7118bd4781cd91f8781d8727ff49a (diff) | |
| download | ideviceinstaller-3909271599917bc4a3a996f99bdd3f88c49577fa.tar.gz ideviceinstaller-3909271599917bc4a3a996f99bdd3f88c49577fa.tar.bz2 | |
Ignore remove events when unsubscribing the event callback
Otherwise we see 'Device removed' messages which might be misleading.
| -rw-r--r-- | src/ideviceinstaller.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c index e45bb12..2334199 100644 --- a/src/ideviceinstaller.c +++ b/src/ideviceinstaller.c | |||
| @@ -117,6 +117,7 @@ int use_notifier = 0; | |||
| 117 | int notification_expected = 0; | 117 | int notification_expected = 0; |
| 118 | int is_device_connected = 0; | 118 | int is_device_connected = 0; |
| 119 | int command_completed = 0; | 119 | int command_completed = 0; |
| 120 | int ignore_events = 0; | ||
| 120 | int err_occurred = 0; | 121 | int err_occurred = 0; |
| 121 | int notified = 0; | 122 | int notified = 0; |
| 122 | 123 | ||
| @@ -351,6 +352,9 @@ static int zip_get_app_directory(struct zip* zf, char** path) | |||
| 351 | 352 | ||
| 352 | static void idevice_event_callback(const idevice_event_t* event, void* userdata) | 353 | static void idevice_event_callback(const idevice_event_t* event, void* userdata) |
| 353 | { | 354 | { |
| 355 | if (ignore_events) { | ||
| 356 | return; | ||
| 357 | } | ||
| 354 | if (event->event == IDEVICE_DEVICE_REMOVE) { | 358 | if (event->event == IDEVICE_DEVICE_REMOVE) { |
| 355 | if (!strcmp(udid, event->udid)) { | 359 | if (!strcmp(udid, event->udid)) { |
| 356 | fprintf(stderr, "ideviceinstaller: Device removed\n"); | 360 | fprintf(stderr, "ideviceinstaller: Device removed\n"); |
| @@ -362,6 +366,7 @@ static void idevice_event_callback(const idevice_event_t* event, void* userdata) | |||
| 362 | static void idevice_wait_for_command_to_complete() | 366 | static void idevice_wait_for_command_to_complete() |
| 363 | { | 367 | { |
| 364 | is_device_connected = 1; | 368 | is_device_connected = 1; |
| 369 | ignore_events = 0; | ||
| 365 | 370 | ||
| 366 | /* subscribe to make sure to exit on device removal */ | 371 | /* subscribe to make sure to exit on device removal */ |
| 367 | idevice_event_subscribe(idevice_event_callback, NULL); | 372 | idevice_event_subscribe(idevice_event_callback, NULL); |
| @@ -377,6 +382,7 @@ static void idevice_wait_for_command_to_complete() | |||
| 377 | wait_ms(50); | 382 | wait_ms(50); |
| 378 | } | 383 | } |
| 379 | 384 | ||
| 385 | ignore_events = 1; | ||
| 380 | idevice_event_unsubscribe(); | 386 | idevice_event_unsubscribe(); |
| 381 | } | 387 | } |
| 382 | 388 | ||
