diff options
| -rw-r--r-- | src/InstallationProxy.c | 66 | ||||
| -rw-r--r-- | src/InstallationProxy.h | 3 |
2 files changed, 35 insertions, 34 deletions
diff --git a/src/InstallationProxy.c b/src/InstallationProxy.c index 387f9ca..34777d1 100644 --- a/src/InstallationProxy.c +++ b/src/InstallationProxy.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | #include <plist/plist.h> | 26 | #include <plist/plist.h> |
| 27 | 27 | ||
| 28 | #include "InstallationProxy.h" | 28 | #include "InstallationProxy.h" |
| 29 | #include "iphone.h" | 29 | #include "property_list_service.h" |
| 30 | #include "utils.h" | 30 | #include "utils.h" |
| 31 | 31 | ||
| 32 | struct instproxy_status_data { | 32 | struct instproxy_status_data { |
| @@ -56,24 +56,25 @@ static void instproxy_unlock(instproxy_client_t client) | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | * Convert an iphone_error_t value to an instproxy_error_t value. | 59 | * Convert a property_list_service_error_t value to an instproxy_error_t value. |
| 60 | * Used internally to get correct error codes when using plist helper | 60 | * Used internally to get correct error codes. |
| 61 | * functions. | ||
| 62 | * | 61 | * |
| 63 | * @param err An iphone_error_t error code | 62 | * @param err A property_list_service_error_t error code |
| 64 | * | 63 | * |
| 65 | * @return A matching instproxy_error_t error code, | 64 | * @return A matching instproxy_error_t error code, |
| 66 | * INSTPROXY_E_UNKNOWN_ERROR otherwise. | 65 | * INSTPROXY_E_UNKNOWN_ERROR otherwise. |
| 67 | */ | 66 | */ |
| 68 | static instproxy_error_t iphone_to_instproxy_error(iphone_error_t err) | 67 | static instproxy_error_t instproxy_error(property_list_service_error_t err) |
| 69 | { | 68 | { |
| 70 | switch (err) { | 69 | switch (err) { |
| 71 | case IPHONE_E_SUCCESS: | 70 | case PROPERTY_LIST_SERVICE_E_SUCCESS: |
| 72 | return INSTPROXY_E_SUCCESS; | 71 | return INSTPROXY_E_SUCCESS; |
| 73 | case IPHONE_E_INVALID_ARG: | 72 | case PROPERTY_LIST_SERVICE_E_INVALID_ARG: |
| 74 | return INSTPROXY_E_INVALID_ARG; | 73 | return INSTPROXY_E_INVALID_ARG; |
| 75 | case IPHONE_E_PLIST_ERROR: | 74 | case PROPERTY_LIST_SERVICE_E_PLIST_ERROR: |
| 76 | return INSTPROXY_E_PLIST_ERROR; | 75 | return INSTPROXY_E_PLIST_ERROR; |
| 76 | case PROPERTY_LIST_SERVICE_E_MUX_ERROR: | ||
| 77 | return INSTPROXY_E_CONN_FAILED; | ||
| 77 | default: | 78 | default: |
| 78 | break; | 79 | break; |
| 79 | } | 80 | } |
| @@ -100,14 +101,13 @@ instproxy_error_t instproxy_client_new(iphone_device_t device, int dst_port, ins | |||
| 100 | if (!device) | 101 | if (!device) |
| 101 | return INSTPROXY_E_INVALID_ARG; | 102 | return INSTPROXY_E_INVALID_ARG; |
| 102 | 103 | ||
| 103 | /* Attempt connection */ | 104 | property_list_service_client_t plistclient = NULL; |
| 104 | iphone_connection_t connection = NULL; | 105 | if (property_list_service_client_new(device, dst_port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { |
| 105 | if (iphone_device_connect(device, dst_port, &connection) != IPHONE_E_SUCCESS) { | ||
| 106 | return INSTPROXY_E_CONN_FAILED; | 106 | return INSTPROXY_E_CONN_FAILED; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | instproxy_client_t client_loc = (instproxy_client_t) malloc(sizeof(struct instproxy_client_int)); | 109 | instproxy_client_t client_loc = (instproxy_client_t) malloc(sizeof(struct instproxy_client_int)); |
| 110 | client_loc->connection = connection; | 110 | client_loc->parent = plistclient; |
| 111 | client_loc->mutex = g_mutex_new(); | 111 | client_loc->mutex = g_mutex_new(); |
| 112 | client_loc->status_updater = NULL; | 112 | client_loc->status_updater = NULL; |
| 113 | 113 | ||
| @@ -128,8 +128,8 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client) | |||
| 128 | if (!client) | 128 | if (!client) |
| 129 | return INSTPROXY_E_INVALID_ARG; | 129 | return INSTPROXY_E_INVALID_ARG; |
| 130 | 130 | ||
| 131 | iphone_device_disconnect(client->connection); | 131 | property_list_service_client_free(client->parent); |
| 132 | client->connection = NULL; | 132 | client->parent = NULL; |
| 133 | if (client->status_updater) { | 133 | if (client->status_updater) { |
| 134 | log_dbg_msg(DBGMASK_INSTPROXY, "joining status_updater"); | 134 | log_dbg_msg(DBGMASK_INSTPROXY, "joining status_updater"); |
| 135 | g_thread_join(client->status_updater); | 135 | g_thread_join(client->status_updater); |
| @@ -155,7 +155,7 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client) | |||
| 155 | */ | 155 | */ |
| 156 | instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_t apptype, plist_t *result) | 156 | instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_t apptype, plist_t *result) |
| 157 | { | 157 | { |
| 158 | if (!client || !client->connection || !result) | 158 | if (!client || !client->parent || !result) |
| 159 | return INSTPROXY_E_INVALID_ARG; | 159 | return INSTPROXY_E_INVALID_ARG; |
| 160 | 160 | ||
| 161 | instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR; | 161 | instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR; |
| @@ -184,7 +184,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_ | |||
| 184 | plist_dict_insert_item(dict, "Command", plist_new_string("Browse")); | 184 | plist_dict_insert_item(dict, "Command", plist_new_string("Browse")); |
| 185 | 185 | ||
| 186 | instproxy_lock(client); | 186 | instproxy_lock(client); |
| 187 | res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict)); | 187 | res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict)); |
| 188 | plist_free(dict); | 188 | plist_free(dict); |
| 189 | if (res != INSTPROXY_E_SUCCESS) { | 189 | if (res != INSTPROXY_E_SUCCESS) { |
| 190 | log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist\n", __func__); | 190 | log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist\n", __func__); |
| @@ -196,7 +196,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_ | |||
| 196 | do { | 196 | do { |
| 197 | browsing = 0; | 197 | browsing = 0; |
| 198 | dict = NULL; | 198 | dict = NULL; |
| 199 | res = iphone_to_instproxy_error(iphone_device_receive_plist(client->connection, &dict)); | 199 | res = instproxy_error(property_list_service_receive_plist(client->parent, &dict)); |
| 200 | if (res != INSTPROXY_E_SUCCESS) { | 200 | if (res != INSTPROXY_E_SUCCESS) { |
| 201 | break; | 201 | break; |
| 202 | } | 202 | } |
| @@ -261,7 +261,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client, | |||
| 261 | 261 | ||
| 262 | do { | 262 | do { |
| 263 | instproxy_lock(client); | 263 | instproxy_lock(client); |
| 264 | res = iphone_to_instproxy_error(iphone_device_receive_plist_with_timeout(client->connection, &dict, 30000)); | 264 | res = instproxy_error(property_list_service_receive_plist_with_timeout(client->parent, &dict, 30000)); |
| 265 | instproxy_unlock(client); | 265 | instproxy_unlock(client); |
| 266 | if (res != INSTPROXY_E_SUCCESS) { | 266 | if (res != INSTPROXY_E_SUCCESS) { |
| 267 | log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not receive plist, error %d\n", __func__, res); | 267 | log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not receive plist, error %d\n", __func__, res); |
| @@ -314,7 +314,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client, | |||
| 314 | plist_free(dict); | 314 | plist_free(dict); |
| 315 | dict = NULL; | 315 | dict = NULL; |
| 316 | } | 316 | } |
| 317 | } while (ok && client->connection); | 317 | } while (ok && client->parent); |
| 318 | 318 | ||
| 319 | return res; | 319 | return res; |
| 320 | } | 320 | } |
| @@ -404,7 +404,7 @@ static instproxy_error_t instproxy_create_status_updater(instproxy_client_t clie | |||
| 404 | */ | 404 | */ |
| 405 | static instproxy_error_t instproxy_install_or_upgrade(instproxy_client_t client, const char *pkg_path, plist_t sinf, plist_t metadata, instproxy_status_cb_t status_cb, const char *command) | 405 | static instproxy_error_t instproxy_install_or_upgrade(instproxy_client_t client, const char *pkg_path, plist_t sinf, plist_t metadata, instproxy_status_cb_t status_cb, const char *command) |
| 406 | { | 406 | { |
| 407 | if (!client || !client->connection || !pkg_path) { | 407 | if (!client || !client->parent || !pkg_path) { |
| 408 | return INSTPROXY_E_INVALID_ARG; | 408 | return INSTPROXY_E_INVALID_ARG; |
| 409 | } | 409 | } |
| 410 | if (sinf && (plist_get_node_type(sinf) != PLIST_DATA)) { | 410 | if (sinf && (plist_get_node_type(sinf) != PLIST_DATA)) { |
| @@ -433,7 +433,7 @@ static instproxy_error_t instproxy_install_or_upgrade(instproxy_client_t client, | |||
| 433 | plist_dict_insert_item(dict, "PackagePath", plist_new_string(pkg_path)); | 433 | plist_dict_insert_item(dict, "PackagePath", plist_new_string(pkg_path)); |
| 434 | 434 | ||
| 435 | instproxy_lock(client); | 435 | instproxy_lock(client); |
| 436 | res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict)); | 436 | res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict)); |
| 437 | instproxy_unlock(client); | 437 | instproxy_unlock(client); |
| 438 | 438 | ||
| 439 | plist_free(dict); | 439 | plist_free(dict); |
| @@ -512,7 +512,7 @@ instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_p | |||
| 512 | */ | 512 | */ |
| 513 | instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb) | 513 | instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb) |
| 514 | { | 514 | { |
| 515 | if (!client || !client->connection || !appid) { | 515 | if (!client || !client->parent || !appid) { |
| 516 | return INSTPROXY_E_INVALID_ARG; | 516 | return INSTPROXY_E_INVALID_ARG; |
| 517 | } | 517 | } |
| 518 | 518 | ||
| @@ -526,7 +526,7 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app | |||
| 526 | plist_dict_insert_item(dict, "Command", plist_new_string("Uninstall")); | 526 | plist_dict_insert_item(dict, "Command", plist_new_string("Uninstall")); |
| 527 | 527 | ||
| 528 | instproxy_lock(client); | 528 | instproxy_lock(client); |
| 529 | res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict)); | 529 | res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict)); |
| 530 | instproxy_unlock(client); | 530 | instproxy_unlock(client); |
| 531 | 531 | ||
| 532 | plist_free(dict); | 532 | plist_free(dict); |
| @@ -553,7 +553,7 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app | |||
| 553 | */ | 553 | */ |
| 554 | instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t *result) | 554 | instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t *result) |
| 555 | { | 555 | { |
| 556 | if (!client || !client->connection || !result) | 556 | if (!client || !client->parent || !result) |
| 557 | return INSTPROXY_E_INVALID_ARG; | 557 | return INSTPROXY_E_INVALID_ARG; |
| 558 | 558 | ||
| 559 | instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR; | 559 | instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR; |
| @@ -563,7 +563,7 @@ instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t * | |||
| 563 | 563 | ||
| 564 | instproxy_lock(client); | 564 | instproxy_lock(client); |
| 565 | 565 | ||
| 566 | res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict)); | 566 | res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict)); |
| 567 | plist_free(dict); | 567 | plist_free(dict); |
| 568 | 568 | ||
| 569 | if (res != INSTPROXY_E_SUCCESS) { | 569 | if (res != INSTPROXY_E_SUCCESS) { |
| @@ -571,7 +571,7 @@ instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t * | |||
| 571 | goto leave_unlock; | 571 | goto leave_unlock; |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | res = iphone_to_instproxy_error(iphone_device_receive_plist(client->connection, result)); | 574 | res = instproxy_error(property_list_service_receive_plist(client->parent, result)); |
| 575 | if (res != INSTPROXY_E_SUCCESS) { | 575 | if (res != INSTPROXY_E_SUCCESS) { |
| 576 | log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not receive plist, error %d\n", __func__, res); | 576 | log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not receive plist, error %d\n", __func__, res); |
| 577 | goto leave_unlock; | 577 | goto leave_unlock; |
| @@ -610,7 +610,7 @@ leave_unlock: | |||
| 610 | */ | 610 | */ |
| 611 | instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, uint32_t options, instproxy_status_cb_t status_cb) | 611 | instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, uint32_t options, instproxy_status_cb_t status_cb) |
| 612 | { | 612 | { |
| 613 | if (!client || !client->connection || !appid) | 613 | if (!client || !client->parent || !appid) |
| 614 | return INSTPROXY_E_INVALID_ARG; | 614 | return INSTPROXY_E_INVALID_ARG; |
| 615 | 615 | ||
| 616 | if (client->status_updater) { | 616 | if (client->status_updater) { |
| @@ -634,7 +634,7 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid | |||
| 634 | plist_dict_insert_item(dict, "Command", plist_new_string("Archive")); | 634 | plist_dict_insert_item(dict, "Command", plist_new_string("Archive")); |
| 635 | 635 | ||
| 636 | instproxy_lock(client); | 636 | instproxy_lock(client); |
| 637 | res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict)); | 637 | res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict)); |
| 638 | instproxy_unlock(client); | 638 | instproxy_unlock(client); |
| 639 | 639 | ||
| 640 | plist_free(dict); | 640 | plist_free(dict); |
| @@ -666,7 +666,7 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid | |||
| 666 | */ | 666 | */ |
| 667 | instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb) | 667 | instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb) |
| 668 | { | 668 | { |
| 669 | if (!client || !client->connection || !appid) | 669 | if (!client || !client->parent || !appid) |
| 670 | return INSTPROXY_E_INVALID_ARG; | 670 | return INSTPROXY_E_INVALID_ARG; |
| 671 | 671 | ||
| 672 | if (client->status_updater) { | 672 | if (client->status_updater) { |
| @@ -680,7 +680,7 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid | |||
| 680 | plist_dict_insert_item(dict, "Command", plist_new_string("Restore")); | 680 | plist_dict_insert_item(dict, "Command", plist_new_string("Restore")); |
| 681 | 681 | ||
| 682 | instproxy_lock(client); | 682 | instproxy_lock(client); |
| 683 | res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict)); | 683 | res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict)); |
| 684 | instproxy_unlock(client); | 684 | instproxy_unlock(client); |
| 685 | 685 | ||
| 686 | plist_free(dict); | 686 | plist_free(dict); |
| @@ -712,7 +712,7 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid | |||
| 712 | */ | 712 | */ |
| 713 | instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb) | 713 | instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb) |
| 714 | { | 714 | { |
| 715 | if (!client || !client->connection || !appid) | 715 | if (!client || !client->parent || !appid) |
| 716 | return INSTPROXY_E_INVALID_ARG; | 716 | return INSTPROXY_E_INVALID_ARG; |
| 717 | 717 | ||
| 718 | if (client->status_updater) { | 718 | if (client->status_updater) { |
| @@ -726,7 +726,7 @@ instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char | |||
| 726 | plist_dict_insert_item(dict, "Command", plist_new_string("RemoveArchive")); | 726 | plist_dict_insert_item(dict, "Command", plist_new_string("RemoveArchive")); |
| 727 | 727 | ||
| 728 | instproxy_lock(client); | 728 | instproxy_lock(client); |
| 729 | res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict)); | 729 | res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict)); |
| 730 | instproxy_unlock(client); | 730 | instproxy_unlock(client); |
| 731 | 731 | ||
| 732 | plist_free(dict); | 732 | plist_free(dict); |
diff --git a/src/InstallationProxy.h b/src/InstallationProxy.h index c8c5ef1..f0b5691 100644 --- a/src/InstallationProxy.h +++ b/src/InstallationProxy.h | |||
| @@ -24,9 +24,10 @@ | |||
| 24 | #include <glib.h> | 24 | #include <glib.h> |
| 25 | 25 | ||
| 26 | #include "libiphone/installation_proxy.h" | 26 | #include "libiphone/installation_proxy.h" |
| 27 | #include "property_list_service.h" | ||
| 27 | 28 | ||
| 28 | struct instproxy_client_int { | 29 | struct instproxy_client_int { |
| 29 | iphone_connection_t connection; | 30 | property_list_service_client_t parent; |
| 30 | GMutex *mutex; | 31 | GMutex *mutex; |
| 31 | GThread *status_updater; | 32 | GThread *status_updater; |
| 32 | }; | 33 | }; |
