summaryrefslogtreecommitdiffstats
path: root/src/ideviceinstaller.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ideviceinstaller.c')
-rw-r--r--src/ideviceinstaller.c83
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 @@
/*
* ideviceinstaller - Manage apps on iOS devices.
*
+ * Copyright (C) 2010-2019 Nikias Bassen <nikias@gmx.li>
* Copyright (C) 2010-2015 Martin Szulecki <m.szulecki@libimobiledevice.org>
- * Copyright (C) 2010-2014 Nikias Bassen <nikias@gmx.li>
*
* Licensed under the GNU General Public License Version 2
*
@@ -109,6 +109,7 @@ int cmd = CMD_NONE;
char *last_status = NULL;
int wait_for_command_complete = 0;
+int use_notifier = 0;
int notification_expected = 0;
int is_device_connected = 0;
int command_completed = 0;
@@ -368,7 +369,7 @@ static void idevice_wait_for_command_to_complete()
}
/* wait some time if a notification is expected */
- while (notification_expected && !notified && !err_occurred && is_device_connected) {
+ while (use_notifier && notification_expected && !notified && !err_occurred && is_device_connected) {
wait_ms(50);
}
@@ -404,6 +405,8 @@ static void print_usage(int argc, char **argv)
" -r, --restore APPID\tRestore archived app specified by APPID\n"
" -R, --remove-archive APPID Remove app archive specified by APPID\n"
" -o, --options\t\tPass additional options to the specified command.\n"
+ " -n, --notify-wait\t\tWait for app installed/uninstalled notification\n"
+ " \t\tto before reporting success of operation\n"
" -h, --help\t\tprints usage information\n"
" -d, --debug\t\tenable communication debugging\n" "\n");
printf("Homepage: <http://libimobiledevice.org>\n");
@@ -412,24 +415,25 @@ static void print_usage(int argc, char **argv)
static void parse_opts(int argc, char **argv)
{
static struct option longopts[] = {
- {"help", 0, NULL, 'h'},
- {"udid", 1, NULL, 'u'},
- {"list-apps", 0, NULL, 'l'},
- {"install", 1, NULL, 'i'},
- {"uninstall", 1, NULL, 'U'},
- {"upgrade", 1, NULL, 'g'},
- {"list-archives", 0, NULL, 'L'},
- {"archive", 1, NULL, 'a'},
- {"restore", 1, NULL, 'r'},
- {"remove-archive", 1, NULL, 'R'},
- {"options", 1, NULL, 'o'},
- {"debug", 0, NULL, 'd'},
- {NULL, 0, NULL, 0}
+ { "help", no_argument, NULL, 'h' },
+ { "udid", required_argument, NULL, 'u' },
+ { "list-apps", no_argument, NULL, 'l' },
+ { "install", required_argument, NULL, 'i' },
+ { "uninstall", required_argument, NULL, 'U' },
+ { "upgrade", required_argument, NULL, 'g' },
+ { "list-archives", no_argument, NULL, 'L' },
+ { "archive", required_argument, NULL, 'a' },
+ { "restore", required_argument, NULL, 'r' },
+ { "remove-archive", required_argument, NULL, 'R' },
+ { "options", required_argument, NULL, 'o' },
+ { "notify-wait", no_argument, NULL, 'n' },
+ { "debug", no_argument, NULL, 'd' },
+ { NULL, 0, NULL, 0 }
};
int c;
while (1) {
- c = getopt_long(argc, argv, "hU:li:u:g:La:r:R:o:d", longopts,
+ c = getopt_long(argc, argv, "hU:li:u:g:La:r:R:o:nd", longopts,
(int *) 0);
if (c == -1) {
break;
@@ -508,6 +512,9 @@ static void parse_opts(int argc, char **argv)
options = newopts;
}
break;
+ case 'n':
+ use_notifier = 1;
+ break;
case 'd':
idevice_set_debug_level(1);
break;
@@ -654,33 +661,35 @@ int main(int argc, char **argv)
goto leave_cleanup;
}
- if ((lockdownd_start_service
- (client, "com.apple.mobile.notification_proxy",
- &service) != LOCKDOWN_E_SUCCESS) || !service) {
- fprintf(stderr,
- "Could not start com.apple.mobile.notification_proxy!\n");
- res = -1;
- goto leave_cleanup;
- }
+ if (use_notifier) {
+ if ((lockdownd_start_service
+ (client, "com.apple.mobile.notification_proxy",
+ &service) != LOCKDOWN_E_SUCCESS) || !service) {
+ fprintf(stderr,
+ "Could not start com.apple.mobile.notification_proxy!\n");
+ res = -1;
+ goto leave_cleanup;
+ }
- np_error_t nperr = np_client_new(device, service, &np);
+ np_error_t nperr = np_client_new(device, service, &np);
- if (service) {
- lockdownd_service_descriptor_free(service);
- }
- service = NULL;
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ }
+ service = NULL;
- if (nperr != NP_E_SUCCESS) {
- fprintf(stderr, "Could not connect to notification_proxy!\n");
- res = -1;
- goto leave_cleanup;
- }
+ if (nperr != NP_E_SUCCESS) {
+ fprintf(stderr, "Could not connect to notification_proxy!\n");
+ res = -1;
+ goto leave_cleanup;
+ }
- np_set_notify_callback(np, notifier, NULL);
+ np_set_notify_callback(np, notifier, NULL);
- const char *noties[3] = { NP_APP_INSTALLED, NP_APP_UNINSTALLED, NULL };
+ const char *noties[3] = { NP_APP_INSTALLED, NP_APP_UNINSTALLED, NULL };
- np_observe_notifications(np, noties);
+ np_observe_notifications(np, noties);
+ }
run_again:
if (service) {