summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2015-01-26 23:38:47 +0100
committerGravatar Martin Szulecki2015-01-27 22:01:23 +0100
commitd44af054c88ffc2aa1baeee609fa6e704afb2b77 (patch)
tree229d888d2cee32fd8b359fcb19b94589d283e9e2
parent9d7667a1ace1da60f508fa075793bba87e98af4a (diff)
downloadlibimobiledevice-d44af054c88ffc2aa1baeee609fa6e704afb2b77.tar.gz
libimobiledevice-d44af054c88ffc2aa1baeee609fa6e704afb2b77.tar.bz2
installation_proxy: Use new lookup command for app path retrieval helper
-rw-r--r--include/libimobiledevice/installation_proxy.h3
-rw-r--r--src/installation_proxy.c34
2 files changed, 8 insertions, 29 deletions
diff --git a/include/libimobiledevice/installation_proxy.h b/include/libimobiledevice/installation_proxy.h
index 6810978..0f924d7 100644
--- a/include/libimobiledevice/installation_proxy.h
+++ b/include/libimobiledevice/installation_proxy.h
@@ -492,9 +492,6 @@ void instproxy_client_options_free(plist_t client_options);
492 * @return INSTPROXY_E_SUCCESS on success, INSTPROXY_E_OP_FAILED if 492 * @return INSTPROXY_E_SUCCESS on success, INSTPROXY_E_OP_FAILED if
493 * the path could not be determined or an INSTPROXY_E_* error 493 * the path could not be determined or an INSTPROXY_E_* error
494 * value if an error occured. 494 * value if an error occured.
495 *
496 * @note This implementation browses all applications and matches the
497 * right entry by the application identifier.
498 */ 495 */
499instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path); 496instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path);
500 497
diff --git a/src/installation_proxy.c b/src/installation_proxy.c
index b7326dc..e4484ad 100644
--- a/src/installation_proxy.c
+++ b/src/installation_proxy.c
@@ -970,40 +970,22 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_get_path_for_bundle_iden
970 instproxy_client_options_add(client_opts, "ApplicationType", "Any", NULL); 970 instproxy_client_options_add(client_opts, "ApplicationType", "Any", NULL);
971 971
972 // only return attributes we need 972 // only return attributes we need
973 plist_t return_attributes = plist_new_array(); 973 instproxy_client_options_set_return_attributes(client_opts, "CFBundleIdentifier", "CFBundleExecutable", "Path", NULL);
974 plist_array_append_item(return_attributes, plist_new_string("CFBundleIdentifier")); 974
975 plist_array_append_item(return_attributes, plist_new_string("CFBundleExecutable")); 975 // only query for specific appid
976 plist_array_append_item(return_attributes, plist_new_string("Path")); 976 plist_t appid_node = plist_new_string(appid);
977 instproxy_client_options_add(client_opts, "ReturnAttributes", return_attributes, NULL);
978 plist_free(return_attributes);
979 return_attributes = NULL;
980 977
981 // query device for list of apps 978 // query device for list of apps
982 instproxy_error_t ierr = instproxy_browse(client, client_opts, &apps); 979 instproxy_error_t ierr = instproxy_lookup(client, appid_node, client_opts, &apps);
980
981 plist_free(appid_node);
983 instproxy_client_options_free(client_opts); 982 instproxy_client_options_free(client_opts);
984 983
985 if (ierr != INSTPROXY_E_SUCCESS) { 984 if (ierr != INSTPROXY_E_SUCCESS) {
986 return ierr; 985 return ierr;
987 } 986 }
988 987
989 plist_t app_found = NULL; 988 plist_t app_found = plist_access_path(apps, 1, appid);
990 uint32_t i;
991 for (i = 0; i < plist_array_get_size(apps); i++) {
992 char *appid_str = NULL;
993 plist_t app_info = plist_array_get_item(apps, i);
994 plist_t idp = plist_dict_get_item(app_info, "CFBundleIdentifier");
995 if (idp) {
996 plist_get_string_val(idp, &appid_str);
997 }
998 if (appid_str && strcmp(appid, appid_str) == 0) {
999 app_found = app_info;
1000 }
1001 free(appid_str);
1002 if (app_found) {
1003 break;
1004 }
1005 }
1006
1007 if (!app_found) { 989 if (!app_found) {
1008 if (apps) 990 if (apps)
1009 plist_free(apps); 991 plist_free(apps);