From 73b36cce1475c7465a1407ccc29f0526699035b9 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 27 Jan 2015 21:37:38 +0100 Subject: installation_proxy: Use char* array to pass appids for lookup command --- include/libimobiledevice/installation_proxy.h | 6 ++-- src/installation_proxy.c | 43 +++++++++++++++++---------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/libimobiledevice/installation_proxy.h b/include/libimobiledevice/installation_proxy.h index 0f924d7..9ce0490 100644 --- a/include/libimobiledevice/installation_proxy.h +++ b/include/libimobiledevice/installation_proxy.h @@ -193,8 +193,8 @@ instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plis * Lookup information about specific applications from the device. * * @param client The connected installation_proxy client - * @param appids A PLIST_ARRAY with PLIST_STRINGs of bundle identifiers, a - * single PLIST_STRING for one bundle identifier or NULL to lookup all. + * @param appids An array of bundle identifiers that MUST have a terminating + * NULL entry or NULL to lookup all. * @param client_options The client options to use, as PLIST_DICT, or NULL. * Currently there are no known client options, so pass NULL here. * @param result Pointer that will be set to a plist containing a PLIST_DICT @@ -203,7 +203,7 @@ instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plis * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if * an error occured. */ -instproxy_error_t instproxy_lookup(instproxy_client_t client, plist_t appids, plist_t client_options, plist_t *result); +instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result); /** * Install an application on the device. diff --git a/src/installation_proxy.c b/src/installation_proxy.c index e4484ad..76eb0ba 100644 --- a/src/installation_proxy.c +++ b/src/installation_proxy.c @@ -605,25 +605,39 @@ static void instproxy_copy_lookup_result_cb(plist_t command, plist_t status, voi } } -LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup(instproxy_client_t client, plist_t appids, plist_t client_options, plist_t *result) +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result) { - if (!client || !client->parent || !result) - return INSTPROXY_E_INVALID_ARG; - - if (appids && (plist_get_node_type(appids) != PLIST_ARRAY && plist_get_node_type(appids) != PLIST_STRING)) - return INSTPROXY_E_INVALID_ARG; - instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR; - + int i = 0; plist_t lookup_result = NULL; + plist_t command = NULL; + plist_t appid_array = NULL; + plist_t node = NULL; - plist_t command = plist_new_dict(); + if (!client || !client->parent || !result) + return INSTPROXY_E_INVALID_ARG; + + command = plist_new_dict(); plist_dict_set_item(command, "Command", plist_new_string("Lookup")); + if (client_options) { + node = plist_copy(client_options); + } else if (appids) { + node = plist_new_dict(); + } + + /* add bundle identifiers to client options */ if (appids) { - plist_dict_set_item(client_options, "BundleIDs", plist_copy(appids)); + appid_array = plist_new_array(); + while (appids[i]) { + plist_array_append_item(appid_array, plist_new_string(appids[i])); + i++; + } + plist_dict_set_item(node, "BundleIDs", appid_array); + } + + if (node) { + plist_dict_set_item(command, "ClientOptions", node); } - if (client_options) - plist_dict_set_item(command, "ClientOptions", plist_copy(client_options)); res = instproxy_perform_command(client, command, INSTPROXY_COMMAND_TYPE_SYNC, instproxy_copy_lookup_result_cb, (void*)&lookup_result); @@ -973,12 +987,11 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_get_path_for_bundle_iden 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); + const char* appids[] = {appid, NULL}; // query device for list of apps - instproxy_error_t ierr = instproxy_lookup(client, appid_node, client_opts, &apps); + instproxy_error_t ierr = instproxy_lookup(client, appids, client_opts, &apps); - plist_free(appid_node); instproxy_client_options_free(client_opts); if (ierr != INSTPROXY_E_SUCCESS) { -- cgit v1.1-32-gdbae