From d44af054c88ffc2aa1baeee609fa6e704afb2b77 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Mon, 26 Jan 2015 23:38:47 +0100 Subject: installation_proxy: Use new lookup command for app path retrieval helper --- include/libimobiledevice/installation_proxy.h | 3 --- src/installation_proxy.c | 34 +++++++-------------------- 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); * @return INSTPROXY_E_SUCCESS on success, INSTPROXY_E_OP_FAILED if * the path could not be determined or an INSTPROXY_E_* error * value if an error occured. - * - * @note This implementation browses all applications and matches the - * right entry by the application identifier. */ instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path); 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 instproxy_client_options_add(client_opts, "ApplicationType", "Any", NULL); // only return attributes we need - plist_t return_attributes = plist_new_array(); - plist_array_append_item(return_attributes, plist_new_string("CFBundleIdentifier")); - plist_array_append_item(return_attributes, plist_new_string("CFBundleExecutable")); - plist_array_append_item(return_attributes, plist_new_string("Path")); - instproxy_client_options_add(client_opts, "ReturnAttributes", return_attributes, NULL); - plist_free(return_attributes); - return_attributes = NULL; + instproxy_client_options_set_return_attributes(client_opts, "CFBundleIdentifier", "CFBundleExecutable", "Path", NULL); + + // only query for specific appid + plist_t appid_node = plist_new_string(appid); // query device for list of apps - instproxy_error_t ierr = instproxy_browse(client, client_opts, &apps); + instproxy_error_t ierr = instproxy_lookup(client, appid_node, client_opts, &apps); + + plist_free(appid_node); instproxy_client_options_free(client_opts); if (ierr != INSTPROXY_E_SUCCESS) { return ierr; } - plist_t app_found = NULL; - uint32_t i; - for (i = 0; i < plist_array_get_size(apps); i++) { - char *appid_str = NULL; - plist_t app_info = plist_array_get_item(apps, i); - plist_t idp = plist_dict_get_item(app_info, "CFBundleIdentifier"); - if (idp) { - plist_get_string_val(idp, &appid_str); - } - if (appid_str && strcmp(appid, appid_str) == 0) { - app_found = app_info; - } - free(appid_str); - if (app_found) { - break; - } - } - + plist_t app_found = plist_access_path(apps, 1, appid); if (!app_found) { if (apps) plist_free(apps); -- cgit v1.1-32-gdbae