diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ideviceinstaller.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c index b626caa..5758b46 100644 --- a/src/ideviceinstaller.c +++ b/src/ideviceinstaller.c | |||
| @@ -56,14 +56,19 @@ char *udid = NULL; | |||
| 56 | char *options = NULL; | 56 | char *options = NULL; |
| 57 | char *appid = NULL; | 57 | char *appid = NULL; |
| 58 | 58 | ||
| 59 | int list_apps_mode = 0; | 59 | enum cmd_mode { |
| 60 | int install_mode = 0; | 60 | CMD_NONE = 0, |
| 61 | int uninstall_mode = 0; | 61 | CMD_LIST_APPS, |
| 62 | int upgrade_mode = 0; | 62 | CMD_INSTALL, |
| 63 | int list_archives_mode = 0; | 63 | CMD_UNINSTALL, |
| 64 | int archive_mode = 0; | 64 | CMD_UPGRADE, |
| 65 | int restore_mode = 0; | 65 | CMD_LIST_ARCHIVES, |
| 66 | int remove_archive_mode = 0; | 66 | CMD_ARCHIVE, |
| 67 | CMD_RESTORE, | ||
| 68 | CMD_REMOVE_ARCHIVE | ||
| 69 | }; | ||
| 70 | |||
| 71 | int cmd = CMD_NONE; | ||
| 67 | 72 | ||
| 68 | char *last_status = NULL; | 73 | char *last_status = NULL; |
| 69 | int wait_for_op_complete = 0; | 74 | int wait_for_op_complete = 0; |
| @@ -339,33 +344,32 @@ static void parse_opts(int argc, char **argv) | |||
| 339 | udid = strdup(optarg); | 344 | udid = strdup(optarg); |
| 340 | break; | 345 | break; |
| 341 | case 'l': | 346 | case 'l': |
| 342 | list_apps_mode = 1; | 347 | cmd = CMD_LIST_APPS; |
| 343 | break; | 348 | break; |
| 344 | case 'i': | 349 | case 'i': |
| 345 | install_mode = 1; | 350 | cmd = CMD_INSTALL; |
| 346 | appid = strdup(optarg); | 351 | appid = strdup(optarg); |
| 347 | break; | 352 | break; |
| 348 | case 'u': | 353 | cmd = CMD_UNINSTALL; |
| 349 | uninstall_mode = 1; | ||
| 350 | appid = strdup(optarg); | 354 | appid = strdup(optarg); |
| 351 | break; | 355 | break; |
| 352 | case 'g': | 356 | case 'g': |
| 353 | upgrade_mode = 1; | 357 | cmd = CMD_UPGRADE; |
| 354 | appid = strdup(optarg); | 358 | appid = strdup(optarg); |
| 355 | break; | 359 | break; |
| 356 | case 'L': | 360 | case 'L': |
| 357 | list_archives_mode = 1; | 361 | cmd = CMD_LIST_ARCHIVES; |
| 358 | break; | 362 | break; |
| 359 | case 'a': | 363 | case 'a': |
| 360 | archive_mode = 1; | 364 | cmd = CMD_ARCHIVE; |
| 361 | appid = strdup(optarg); | 365 | appid = strdup(optarg); |
| 362 | break; | 366 | break; |
| 363 | case 'r': | 367 | case 'r': |
| 364 | restore_mode = 1; | 368 | cmd = CMD_RESTORE; |
| 365 | appid = strdup(optarg); | 369 | appid = strdup(optarg); |
| 366 | break; | 370 | break; |
| 367 | case 'R': | 371 | case 'R': |
| 368 | remove_archive_mode = 1; | 372 | cmd = CMD_REMOVE_ARCHIVE; |
| 369 | appid = strdup(optarg); | 373 | appid = strdup(optarg); |
| 370 | break; | 374 | break; |
| 371 | case 'o': | 375 | case 'o': |
| @@ -559,7 +563,7 @@ run_again: | |||
| 559 | } | 563 | } |
| 560 | notification_expected = 0; | 564 | notification_expected = 0; |
| 561 | 565 | ||
| 562 | if (list_apps_mode) { | 566 | if (cmd == CMD_LIST_APPS) { |
| 563 | int xml_mode = 0; | 567 | int xml_mode = 0; |
| 564 | plist_t client_opts = instproxy_client_options_new(); | 568 | plist_t client_opts = instproxy_client_options_new(); |
| 565 | instproxy_client_options_add(client_opts, "ApplicationType", "User", NULL); | 569 | instproxy_client_options_add(client_opts, "ApplicationType", "User", NULL); |
| @@ -652,7 +656,7 @@ run_again: | |||
| 652 | free(s_appid); | 656 | free(s_appid); |
| 653 | } | 657 | } |
| 654 | plist_free(apps); | 658 | plist_free(apps); |
| 655 | } else if (install_mode || upgrade_mode) { | 659 | } else if (cmd == CMD_INSTALL || cmd == CMD_UPGRADE) { |
| 656 | plist_t sinf = NULL; | 660 | plist_t sinf = NULL; |
| 657 | plist_t meta = NULL; | 661 | plist_t meta = NULL; |
| 658 | char *pkgname = NULL; | 662 | char *pkgname = NULL; |
| @@ -950,7 +954,7 @@ run_again: | |||
| 950 | } | 954 | } |
| 951 | 955 | ||
| 952 | /* perform installation or upgrade */ | 956 | /* perform installation or upgrade */ |
| 953 | if (install_mode) { | 957 | if (cmd == CMD_INSTALL) { |
| 954 | printf("Installing '%s'\n", bundleidentifier); | 958 | printf("Installing '%s'\n", bundleidentifier); |
| 955 | #ifdef HAVE_LIBIMOBILEDEVICE_1_1 | 959 | #ifdef HAVE_LIBIMOBILEDEVICE_1_1 |
| 956 | instproxy_install(ipc, pkgname, client_opts, status_cb, NULL); | 960 | instproxy_install(ipc, pkgname, client_opts, status_cb, NULL); |
| @@ -969,7 +973,7 @@ run_again: | |||
| 969 | free(pkgname); | 973 | free(pkgname); |
| 970 | wait_for_op_complete = 1; | 974 | wait_for_op_complete = 1; |
| 971 | notification_expected = 1; | 975 | notification_expected = 1; |
| 972 | } else if (uninstall_mode) { | 976 | } else if (cmd == CMD_UNINSTALL) { |
| 973 | printf("Uninstalling '%s'\n", appid); | 977 | printf("Uninstalling '%s'\n", appid); |
| 974 | #ifdef HAVE_LIBIMOBILEDEVICE_1_1 | 978 | #ifdef HAVE_LIBIMOBILEDEVICE_1_1 |
| 975 | instproxy_uninstall(ipc, appid, NULL, status_cb, NULL); | 979 | instproxy_uninstall(ipc, appid, NULL, status_cb, NULL); |
| @@ -978,7 +982,7 @@ run_again: | |||
| 978 | #endif | 982 | #endif |
| 979 | wait_for_op_complete = 1; | 983 | wait_for_op_complete = 1; |
| 980 | notification_expected = 0; | 984 | notification_expected = 0; |
| 981 | } else if (list_archives_mode) { | 985 | } else if (cmd == CMD_LIST_ARCHIVES) { |
| 982 | int xml_mode = 0; | 986 | int xml_mode = 0; |
| 983 | plist_t dict = NULL; | 987 | plist_t dict = NULL; |
| 984 | plist_t lres = NULL; | 988 | plist_t lres = NULL; |
| @@ -1069,7 +1073,7 @@ run_again: | |||
| 1069 | } | 1073 | } |
| 1070 | while (node); | 1074 | while (node); |
| 1071 | plist_free(dict); | 1075 | plist_free(dict); |
| 1072 | } else if (archive_mode) { | 1076 | } else if (cmd == CMD_ARCHIVE) { |
| 1073 | char *copy_path = NULL; | 1077 | char *copy_path = NULL; |
| 1074 | int remove_after_copy = 0; | 1078 | int remove_after_copy = 0; |
| 1075 | int skip_uninstall = 1; | 1079 | int skip_uninstall = 1; |
| @@ -1274,8 +1278,7 @@ run_again: | |||
| 1274 | if (remove_after_copy) { | 1278 | if (remove_after_copy) { |
| 1275 | /* remove archive if requested */ | 1279 | /* remove archive if requested */ |
| 1276 | printf("Removing '%s'\n", appid); | 1280 | printf("Removing '%s'\n", appid); |
| 1277 | archive_mode = 0; | 1281 | cmd = CMD_REMOVE_ARCHIVE; |
| 1278 | remove_archive_mode = 1; | ||
| 1279 | free(options); | 1282 | free(options); |
| 1280 | options = NULL; | 1283 | options = NULL; |
| 1281 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "ideviceinstaller")) { | 1284 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "ideviceinstaller")) { |
| @@ -1286,7 +1289,7 @@ run_again: | |||
| 1286 | } | 1289 | } |
| 1287 | } | 1290 | } |
| 1288 | goto leave_cleanup; | 1291 | goto leave_cleanup; |
| 1289 | } else if (restore_mode) { | 1292 | } else if (cmd == CMD_RESTORE) { |
| 1290 | #ifdef HAVE_LIBIMOBILEDEVICE_1_1 | 1293 | #ifdef HAVE_LIBIMOBILEDEVICE_1_1 |
| 1291 | instproxy_restore(ipc, appid, NULL, status_cb, NULL); | 1294 | instproxy_restore(ipc, appid, NULL, status_cb, NULL); |
| 1292 | #else | 1295 | #else |
| @@ -1294,7 +1297,7 @@ run_again: | |||
| 1294 | #endif | 1297 | #endif |
| 1295 | wait_for_op_complete = 1; | 1298 | wait_for_op_complete = 1; |
| 1296 | notification_expected = 1; | 1299 | notification_expected = 1; |
| 1297 | } else if (remove_archive_mode) { | 1300 | } else if (cmd == CMD_REMOVE_ARCHIVE) { |
| 1298 | #ifdef HAVE_LIBIMOBILEDEVICE_1_1 | 1301 | #ifdef HAVE_LIBIMOBILEDEVICE_1_1 |
| 1299 | instproxy_remove_archive(ipc, appid, NULL, status_cb, NULL); | 1302 | instproxy_remove_archive(ipc, appid, NULL, status_cb, NULL); |
| 1300 | #else | 1303 | #else |
