summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2015-01-27 21:37:38 +0100
committerGravatar Martin Szulecki2015-01-27 22:01:23 +0100
commit73b36cce1475c7465a1407ccc29f0526699035b9 (patch)
treed397608846266d8d16f2ca64efc53fa33e2a4afe
parentd44af054c88ffc2aa1baeee609fa6e704afb2b77 (diff)
downloadlibimobiledevice-73b36cce1475c7465a1407ccc29f0526699035b9.tar.gz
libimobiledevice-73b36cce1475c7465a1407ccc29f0526699035b9.tar.bz2
installation_proxy: Use char* array to pass appids for lookup command
-rw-r--r--include/libimobiledevice/installation_proxy.h6
-rw-r--r--src/installation_proxy.c43
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
193 * Lookup information about specific applications from the device. 193 * Lookup information about specific applications from the device.
194 * 194 *
195 * @param client The connected installation_proxy client 195 * @param client The connected installation_proxy client
196 * @param appids A PLIST_ARRAY with PLIST_STRINGs of bundle identifiers, a 196 * @param appids An array of bundle identifiers that MUST have a terminating
197 * single PLIST_STRING for one bundle identifier or NULL to lookup all. 197 * NULL entry or NULL to lookup all.
198 * @param client_options The client options to use, as PLIST_DICT, or NULL. 198 * @param client_options The client options to use, as PLIST_DICT, or NULL.
199 * Currently there are no known client options, so pass NULL here. 199 * Currently there are no known client options, so pass NULL here.
200 * @param result Pointer that will be set to a plist containing a PLIST_DICT 200 * @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
203 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if 203 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
204 * an error occured. 204 * an error occured.
205 */ 205 */
206instproxy_error_t instproxy_lookup(instproxy_client_t client, plist_t appids, plist_t client_options, plist_t *result); 206instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result);
207 207
208/** 208/**
209 * Install an application on the device. 209 * 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
605 } 605 }
606} 606}
607 607
608LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup(instproxy_client_t client, plist_t appids, plist_t client_options, plist_t *result) 608LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result)
609{ 609{
610 if (!client || !client->parent || !result)
611 return INSTPROXY_E_INVALID_ARG;
612
613 if (appids && (plist_get_node_type(appids) != PLIST_ARRAY && plist_get_node_type(appids) != PLIST_STRING))
614 return INSTPROXY_E_INVALID_ARG;
615
616 instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR; 610 instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
617 611 int i = 0;
618 plist_t lookup_result = NULL; 612 plist_t lookup_result = NULL;
613 plist_t command = NULL;
614 plist_t appid_array = NULL;
615 plist_t node = NULL;
619 616
620 plist_t command = plist_new_dict(); 617 if (!client || !client->parent || !result)
618 return INSTPROXY_E_INVALID_ARG;
619
620 command = plist_new_dict();
621 plist_dict_set_item(command, "Command", plist_new_string("Lookup")); 621 plist_dict_set_item(command, "Command", plist_new_string("Lookup"));
622 if (client_options) {
623 node = plist_copy(client_options);
624 } else if (appids) {
625 node = plist_new_dict();
626 }
627
628 /* add bundle identifiers to client options */
622 if (appids) { 629 if (appids) {
623 plist_dict_set_item(client_options, "BundleIDs", plist_copy(appids)); 630 appid_array = plist_new_array();
631 while (appids[i]) {
632 plist_array_append_item(appid_array, plist_new_string(appids[i]));
633 i++;
634 }
635 plist_dict_set_item(node, "BundleIDs", appid_array);
636 }
637
638 if (node) {
639 plist_dict_set_item(command, "ClientOptions", node);
624 } 640 }
625 if (client_options)
626 plist_dict_set_item(command, "ClientOptions", plist_copy(client_options));
627 641
628 res = instproxy_perform_command(client, command, INSTPROXY_COMMAND_TYPE_SYNC, instproxy_copy_lookup_result_cb, (void*)&lookup_result); 642 res = instproxy_perform_command(client, command, INSTPROXY_COMMAND_TYPE_SYNC, instproxy_copy_lookup_result_cb, (void*)&lookup_result);
629 643
@@ -973,12 +987,11 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_get_path_for_bundle_iden
973 instproxy_client_options_set_return_attributes(client_opts, "CFBundleIdentifier", "CFBundleExecutable", "Path", NULL); 987 instproxy_client_options_set_return_attributes(client_opts, "CFBundleIdentifier", "CFBundleExecutable", "Path", NULL);
974 988
975 // only query for specific appid 989 // only query for specific appid
976 plist_t appid_node = plist_new_string(appid); 990 const char* appids[] = {appid, NULL};
977 991
978 // query device for list of apps 992 // query device for list of apps
979 instproxy_error_t ierr = instproxy_lookup(client, appid_node, client_opts, &apps); 993 instproxy_error_t ierr = instproxy_lookup(client, appids, client_opts, &apps);
980 994
981 plist_free(appid_node);
982 instproxy_client_options_free(client_opts); 995 instproxy_client_options_free(client_opts);
983 996
984 if (ierr != INSTPROXY_E_SUCCESS) { 997 if (ierr != INSTPROXY_E_SUCCESS) {