summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2010-01-22 02:58:51 +0100
committerGravatar Martin Szulecki2010-01-22 16:39:58 +0100
commit1f9bf779543bf7fde74905c1f52119d234e629fe (patch)
treef88beea9d702fda53defcd6388cb6194a8e5590a
parent19fcf57f2a4f46b69fb9c8cdb0d8dde16889ff67 (diff)
downloadideviceinstaller-1f9bf779543bf7fde74905c1f52119d234e629fe.tar.gz
ideviceinstaller-1f9bf779543bf7fde74905c1f52119d234e629fe.tar.bz2
Updated code to latest libiphone API change
-rw-r--r--src/iphoneinstaller.c60
1 files changed, 44 insertions, 16 deletions
diff --git a/src/iphoneinstaller.c b/src/iphoneinstaller.c
index 8787a24..04ac341 100644
--- a/src/iphoneinstaller.c
+++ b/src/iphoneinstaller.c
@@ -379,7 +379,8 @@ run_again:
379 379
380 if (list_apps_mode) { 380 if (list_apps_mode) {
381 int xml_mode = 0; 381 int xml_mode = 0;
382 instproxy_apptype_t apptype = INSTPROXY_APPTYPE_USER; 382 plist_t client_opts = instproxy_client_options_new();
383 instproxy_client_options_add(client_opts, "ApplicationType", "User", NULL);
383 instproxy_error_t err; 384 instproxy_error_t err;
384 plist_t apps = NULL; 385 plist_t apps = NULL;
385 386
@@ -389,11 +390,15 @@ run_again:
389 char *elem = strtok(opts, ","); 390 char *elem = strtok(opts, ",");
390 while (elem) { 391 while (elem) {
391 if (!strcmp(elem, "list_system")) { 392 if (!strcmp(elem, "list_system")) {
392 apptype = INSTPROXY_APPTYPE_SYSTEM; 393 if (!client_opts) {
394 client_opts = instproxy_client_options_new();
395 }
396 instproxy_client_options_add(client_opts, "ApplicationType", "System", NULL);
393 } else if (!strcmp(elem, "list_all")) { 397 } else if (!strcmp(elem, "list_all")) {
394 apptype = INSTPROXY_APPTYPE_ALL; 398 instproxy_client_options_free(client_opts);
399 client_opts = NULL;
395 } else if (!strcmp(elem, "list_user")) { 400 } else if (!strcmp(elem, "list_user")) {
396 apptype = INSTPROXY_APPTYPE_USER; 401 /* do nothing, we're already set */
397 } else if (!strcmp(elem, "xml")) { 402 } else if (!strcmp(elem, "xml")) {
398 xml_mode = 1; 403 xml_mode = 1;
399 } 404 }
@@ -401,7 +406,8 @@ run_again:
401 } 406 }
402 } 407 }
403 408
404 err = instproxy_browse(ipc, apptype, &apps); 409 err = instproxy_browse(ipc, client_opts, &apps);
410 instproxy_client_options_free(client_opts);
405 if (err != INSTPROXY_E_SUCCESS) { 411 if (err != INSTPROXY_E_SUCCESS) {
406 fprintf(stderr, "ERROR: instproxy_browse returned %d\n", err); 412 fprintf(stderr, "ERROR: instproxy_browse returned %d\n", err);
407 goto leave_cleanup; 413 goto leave_cleanup;
@@ -641,18 +647,26 @@ run_again:
641 printf("done.\n"); 647 printf("done.\n");
642 648
643 /* perform installation or upgrade */ 649 /* perform installation or upgrade */
650 plist_t client_opts = instproxy_client_options_new();
651 if (sinf) {
652 instproxy_client_options_add(client_opts, "ApplicationSINF", sinf, NULL);
653 }
654 if (meta) {
655 instproxy_client_options_add(client_opts, "iTunesMetadata", meta, NULL);
656 }
644 if (install_mode) { 657 if (install_mode) {
645 printf("Installing '%s'\n", pkgname); 658 printf("Installing '%s'\n", pkgname);
646 instproxy_install(ipc, pkgname, sinf, meta, status_cb); 659 instproxy_install(ipc, pkgname, client_opts, status_cb);
647 } else { 660 } else {
648 printf("Upgrading '%s'\n", pkgname); 661 printf("Upgrading '%s'\n", pkgname);
649 instproxy_upgrade(ipc, pkgname, sinf, meta, status_cb); 662 instproxy_upgrade(ipc, pkgname, client_opts, status_cb);
650 } 663 }
664 instproxy_client_options_free(client_opts);
651 free(pkgname); 665 free(pkgname);
652 wait_for_op_complete = 1; 666 wait_for_op_complete = 1;
653 notification_expected = 1; 667 notification_expected = 1;
654 } else if (uninstall_mode) { 668 } else if (uninstall_mode) {
655 instproxy_uninstall(ipc, appid, status_cb); 669 instproxy_uninstall(ipc, appid, NULL, status_cb);
656 wait_for_op_complete = 1; 670 wait_for_op_complete = 1;
657 notification_expected = 1; 671 notification_expected = 1;
658 } else if (list_archives_mode) { 672 } else if (list_archives_mode) {
@@ -673,7 +687,7 @@ run_again:
673 } 687 }
674 } 688 }
675 689
676 err = instproxy_lookup_archives(ipc, &dict); 690 err = instproxy_lookup_archives(ipc, NULL, &dict);
677 if (err != INSTPROXY_E_SUCCESS) { 691 if (err != INSTPROXY_E_SUCCESS) {
678 fprintf(stderr, "ERROR: lookup_archives returned %d\n", err); 692 fprintf(stderr, "ERROR: lookup_archives returned %d\n", err);
679 goto leave_cleanup; 693 goto leave_cleanup;
@@ -747,18 +761,21 @@ run_again:
747 while (node); 761 while (node);
748 plist_free(dict); 762 plist_free(dict);
749 } else if (archive_mode) { 763 } else if (archive_mode) {
750 uint32_t opt = INSTPROXY_ARCHIVE_SKIP_UNINSTALL;
751 char *copy_path = NULL; 764 char *copy_path = NULL;
752 int remove_after_copy = 0; 765 int remove_after_copy = 0;
766 int skip_uninstall = 1;
767 int app_only = 0;
768 plist_t client_opts = NULL;
769
753 /* look for options */ 770 /* look for options */
754 if (options) { 771 if (options) {
755 char *opts = strdup(options); 772 char *opts = strdup(options);
756 char *elem = strtok(opts, ","); 773 char *elem = strtok(opts, ",");
757 while (elem) { 774 while (elem) {
758 if (!strcmp(elem, "uninstall")) { 775 if (!strcmp(elem, "uninstall")) {
759 opt &= ~INSTPROXY_ARCHIVE_SKIP_UNINSTALL; 776 skip_uninstall = 0;
760 } else if (!strcmp(elem, "app_only")) { 777 } else if (!strcmp(elem, "app_only")) {
761 opt |= INSTPROXY_ARCHIVE_APP_ONLY; 778 app_only = 1;
762 } else if ((strlen(elem) > 5) && !strncmp(elem, "copy=", 5)) { 779 } else if ((strlen(elem) > 5) && !strncmp(elem, "copy=", 5)) {
763 copy_path = strdup(elem+5); 780 copy_path = strdup(elem+5);
764 } else if (!strcmp(elem, "remove")) { 781 } else if (!strcmp(elem, "remove")) {
@@ -768,6 +785,16 @@ run_again:
768 } 785 }
769 } 786 }
770 787
788 if (skip_uninstall || app_only) {
789 client_opts = instproxy_client_options_new();
790 if (skip_uninstall) {
791 instproxy_client_options_add(client_opts, "SkipUninstall", 1, NULL);
792 }
793 if (app_only) {
794 instproxy_client_options_add(client_opts, "ArchiveType", "ApplicationOnly", NULL);
795 }
796 }
797
771 if (copy_path) { 798 if (copy_path) {
772 struct stat fst; 799 struct stat fst;
773 if (stat(copy_path, &fst) != 0) { 800 if (stat(copy_path, &fst) != 0) {
@@ -798,9 +825,10 @@ run_again:
798 } 825 }
799 } 826 }
800 827
801 instproxy_archive(ipc, appid, opt, status_cb); 828 instproxy_archive(ipc, appid, client_opts, status_cb);
829 instproxy_client_options_free(client_opts);
802 wait_for_op_complete = 1; 830 wait_for_op_complete = 1;
803 if (opt & INSTPROXY_ARCHIVE_SKIP_UNINSTALL) { 831 if (skip_uninstall) {
804 notification_expected = 0; 832 notification_expected = 0;
805 } else { 833 } else {
806 notification_expected = 1; 834 notification_expected = 1;
@@ -931,11 +959,11 @@ run_again:
931 } 959 }
932 goto leave_cleanup; 960 goto leave_cleanup;
933 } else if (restore_mode) { 961 } else if (restore_mode) {
934 instproxy_restore(ipc, appid, status_cb); 962 instproxy_restore(ipc, appid, NULL, status_cb);
935 wait_for_op_complete = 1; 963 wait_for_op_complete = 1;
936 notification_expected = 1; 964 notification_expected = 1;
937 } else if (remove_archive_mode) { 965 } else if (remove_archive_mode) {
938 instproxy_remove_archive(ipc, appid, status_cb); 966 instproxy_remove_archive(ipc, appid, NULL, status_cb);
939 wait_for_op_complete = 1; 967 wait_for_op_complete = 1;
940 } else { 968 } else {
941 printf 969 printf