diff options
| author | 2019-06-13 03:25:27 +0200 | |
|---|---|---|
| committer | 2019-06-13 03:25:27 +0200 | |
| commit | ab9352110092cf651b5602301371cd00691c7e13 (patch) | |
| tree | de5193070199670f2ea57675fe53b8a7b2af2147 | |
| parent | 8c1945ccd27c5069c22acd1018435dfff0d0b609 (diff) | |
| download | ideviceinstaller-ab9352110092cf651b5602301371cd00691c7e13.tar.gz ideviceinstaller-ab9352110092cf651b5602301371cd00691c7e13.tar.bz2 | |
Make wait for install/uninstall notification optional with -n command line switch
| -rw-r--r-- | src/ideviceinstaller.c | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c index 17f6966..27b4669 100644 --- a/src/ideviceinstaller.c +++ b/src/ideviceinstaller.c | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * ideviceinstaller - Manage apps on iOS devices. | 2 | * ideviceinstaller - Manage apps on iOS devices. |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2010-2019 Nikias Bassen <nikias@gmx.li> | ||
| 4 | * Copyright (C) 2010-2015 Martin Szulecki <m.szulecki@libimobiledevice.org> | 5 | * Copyright (C) 2010-2015 Martin Szulecki <m.szulecki@libimobiledevice.org> |
| 5 | * Copyright (C) 2010-2014 Nikias Bassen <nikias@gmx.li> | ||
| 6 | * | 6 | * |
| 7 | * Licensed under the GNU General Public License Version 2 | 7 | * Licensed under the GNU General Public License Version 2 |
| 8 | * | 8 | * |
| @@ -109,6 +109,7 @@ int cmd = CMD_NONE; | |||
| 109 | 109 | ||
| 110 | char *last_status = NULL; | 110 | char *last_status = NULL; |
| 111 | int wait_for_command_complete = 0; | 111 | int wait_for_command_complete = 0; |
| 112 | int use_notifier = 0; | ||
| 112 | int notification_expected = 0; | 113 | int notification_expected = 0; |
| 113 | int is_device_connected = 0; | 114 | int is_device_connected = 0; |
| 114 | int command_completed = 0; | 115 | int command_completed = 0; |
| @@ -368,7 +369,7 @@ static void idevice_wait_for_command_to_complete() | |||
| 368 | } | 369 | } |
| 369 | 370 | ||
| 370 | /* wait some time if a notification is expected */ | 371 | /* wait some time if a notification is expected */ |
| 371 | while (notification_expected && !notified && !err_occurred && is_device_connected) { | 372 | while (use_notifier && notification_expected && !notified && !err_occurred && is_device_connected) { |
| 372 | wait_ms(50); | 373 | wait_ms(50); |
| 373 | } | 374 | } |
| 374 | 375 | ||
| @@ -404,6 +405,8 @@ static void print_usage(int argc, char **argv) | |||
| 404 | " -r, --restore APPID\tRestore archived app specified by APPID\n" | 405 | " -r, --restore APPID\tRestore archived app specified by APPID\n" |
| 405 | " -R, --remove-archive APPID Remove app archive specified by APPID\n" | 406 | " -R, --remove-archive APPID Remove app archive specified by APPID\n" |
| 406 | " -o, --options\t\tPass additional options to the specified command.\n" | 407 | " -o, --options\t\tPass additional options to the specified command.\n" |
| 408 | " -n, --notify-wait\t\tWait for app installed/uninstalled notification\n" | ||
| 409 | " \t\tto before reporting success of operation\n" | ||
| 407 | " -h, --help\t\tprints usage information\n" | 410 | " -h, --help\t\tprints usage information\n" |
| 408 | " -d, --debug\t\tenable communication debugging\n" "\n"); | 411 | " -d, --debug\t\tenable communication debugging\n" "\n"); |
| 409 | printf("Homepage: <http://libimobiledevice.org>\n"); | 412 | printf("Homepage: <http://libimobiledevice.org>\n"); |
| @@ -412,24 +415,25 @@ static void print_usage(int argc, char **argv) | |||
| 412 | static void parse_opts(int argc, char **argv) | 415 | static void parse_opts(int argc, char **argv) |
| 413 | { | 416 | { |
| 414 | static struct option longopts[] = { | 417 | static struct option longopts[] = { |
| 415 | {"help", 0, NULL, 'h'}, | 418 | { "help", no_argument, NULL, 'h' }, |
| 416 | {"udid", 1, NULL, 'u'}, | 419 | { "udid", required_argument, NULL, 'u' }, |
| 417 | {"list-apps", 0, NULL, 'l'}, | 420 | { "list-apps", no_argument, NULL, 'l' }, |
| 418 | {"install", 1, NULL, 'i'}, | 421 | { "install", required_argument, NULL, 'i' }, |
| 419 | {"uninstall", 1, NULL, 'U'}, | 422 | { "uninstall", required_argument, NULL, 'U' }, |
| 420 | {"upgrade", 1, NULL, 'g'}, | 423 | { "upgrade", required_argument, NULL, 'g' }, |
| 421 | {"list-archives", 0, NULL, 'L'}, | 424 | { "list-archives", no_argument, NULL, 'L' }, |
| 422 | {"archive", 1, NULL, 'a'}, | 425 | { "archive", required_argument, NULL, 'a' }, |
| 423 | {"restore", 1, NULL, 'r'}, | 426 | { "restore", required_argument, NULL, 'r' }, |
| 424 | {"remove-archive", 1, NULL, 'R'}, | 427 | { "remove-archive", required_argument, NULL, 'R' }, |
| 425 | {"options", 1, NULL, 'o'}, | 428 | { "options", required_argument, NULL, 'o' }, |
| 426 | {"debug", 0, NULL, 'd'}, | 429 | { "notify-wait", no_argument, NULL, 'n' }, |
| 427 | {NULL, 0, NULL, 0} | 430 | { "debug", no_argument, NULL, 'd' }, |
| 431 | { NULL, 0, NULL, 0 } | ||
| 428 | }; | 432 | }; |
| 429 | int c; | 433 | int c; |
| 430 | 434 | ||
| 431 | while (1) { | 435 | while (1) { |
| 432 | c = getopt_long(argc, argv, "hU:li:u:g:La:r:R:o:d", longopts, | 436 | c = getopt_long(argc, argv, "hU:li:u:g:La:r:R:o:nd", longopts, |
| 433 | (int *) 0); | 437 | (int *) 0); |
| 434 | if (c == -1) { | 438 | if (c == -1) { |
| 435 | break; | 439 | break; |
| @@ -508,6 +512,9 @@ static void parse_opts(int argc, char **argv) | |||
| 508 | options = newopts; | 512 | options = newopts; |
| 509 | } | 513 | } |
| 510 | break; | 514 | break; |
| 515 | case 'n': | ||
| 516 | use_notifier = 1; | ||
| 517 | break; | ||
| 511 | case 'd': | 518 | case 'd': |
| 512 | idevice_set_debug_level(1); | 519 | idevice_set_debug_level(1); |
| 513 | break; | 520 | break; |
| @@ -654,33 +661,35 @@ int main(int argc, char **argv) | |||
| 654 | goto leave_cleanup; | 661 | goto leave_cleanup; |
| 655 | } | 662 | } |
| 656 | 663 | ||
| 657 | if ((lockdownd_start_service | 664 | if (use_notifier) { |
| 658 | (client, "com.apple.mobile.notification_proxy", | 665 | if ((lockdownd_start_service |
| 659 | &service) != LOCKDOWN_E_SUCCESS) || !service) { | 666 | (client, "com.apple.mobile.notification_proxy", |
| 660 | fprintf(stderr, | 667 | &service) != LOCKDOWN_E_SUCCESS) || !service) { |
| 661 | "Could not start com.apple.mobile.notification_proxy!\n"); | 668 | fprintf(stderr, |
| 662 | res = -1; | 669 | "Could not start com.apple.mobile.notification_proxy!\n"); |
| 663 | goto leave_cleanup; | 670 | res = -1; |
| 664 | } | 671 | goto leave_cleanup; |
| 672 | } | ||
| 665 | 673 | ||
| 666 | np_error_t nperr = np_client_new(device, service, &np); | 674 | np_error_t nperr = np_client_new(device, service, &np); |
| 667 | 675 | ||
| 668 | if (service) { | 676 | if (service) { |
| 669 | lockdownd_service_descriptor_free(service); | 677 | lockdownd_service_descriptor_free(service); |
| 670 | } | 678 | } |
| 671 | service = NULL; | 679 | service = NULL; |
| 672 | 680 | ||
| 673 | if (nperr != NP_E_SUCCESS) { | 681 | if (nperr != NP_E_SUCCESS) { |
| 674 | fprintf(stderr, "Could not connect to notification_proxy!\n"); | 682 | fprintf(stderr, "Could not connect to notification_proxy!\n"); |
| 675 | res = -1; | 683 | res = -1; |
| 676 | goto leave_cleanup; | 684 | goto leave_cleanup; |
| 677 | } | 685 | } |
| 678 | 686 | ||
| 679 | np_set_notify_callback(np, notifier, NULL); | 687 | np_set_notify_callback(np, notifier, NULL); |
| 680 | 688 | ||
| 681 | const char *noties[3] = { NP_APP_INSTALLED, NP_APP_UNINSTALLED, NULL }; | 689 | const char *noties[3] = { NP_APP_INSTALLED, NP_APP_UNINSTALLED, NULL }; |
| 682 | 690 | ||
| 683 | np_observe_notifications(np, noties); | 691 | np_observe_notifications(np, noties); |
| 692 | } | ||
| 684 | 693 | ||
| 685 | run_again: | 694 | run_again: |
| 686 | if (service) { | 695 | if (service) { |
