summaryrefslogtreecommitdiffstats
path: root/src/InstallationProxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/InstallationProxy.c')
-rw-r--r--src/InstallationProxy.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/InstallationProxy.c b/src/InstallationProxy.c
index 387f9ca..9ada994 100644
--- a/src/InstallationProxy.c
+++ b/src/InstallationProxy.c
@@ -26,8 +26,8 @@
#include <plist/plist.h>
#include "InstallationProxy.h"
-#include "iphone.h"
-#include "utils.h"
+#include "property_list_service.h"
+#include "debug.h"
struct instproxy_status_data {
instproxy_client_t client;
@@ -41,7 +41,7 @@ struct instproxy_status_data {
*/
static void instproxy_lock(instproxy_client_t client)
{
- log_debug_msg("InstallationProxy: Locked\n");
+ debug_info("InstallationProxy: Locked");
g_mutex_lock(client->mutex);
}
@@ -51,29 +51,30 @@ static void instproxy_lock(instproxy_client_t client)
*/
static void instproxy_unlock(instproxy_client_t client)
{
- log_debug_msg("InstallationProxy: Unlocked\n");
+ debug_info("InstallationProxy: Unlocked");
g_mutex_unlock(client->mutex);
}
/**
- * Convert an iphone_error_t value to an instproxy_error_t value.
- * Used internally to get correct error codes when using plist helper
- * functions.
+ * Convert a property_list_service_error_t value to an instproxy_error_t value.
+ * Used internally to get correct error codes.
*
- * @param err An iphone_error_t error code
+ * @param err A property_list_service_error_t error code
*
* @return A matching instproxy_error_t error code,
* INSTPROXY_E_UNKNOWN_ERROR otherwise.
*/
-static instproxy_error_t iphone_to_instproxy_error(iphone_error_t err)
+static instproxy_error_t instproxy_error(property_list_service_error_t err)
{
switch (err) {
- case IPHONE_E_SUCCESS:
+ case PROPERTY_LIST_SERVICE_E_SUCCESS:
return INSTPROXY_E_SUCCESS;
- case IPHONE_E_INVALID_ARG:
+ case PROPERTY_LIST_SERVICE_E_INVALID_ARG:
return INSTPROXY_E_INVALID_ARG;
- case IPHONE_E_PLIST_ERROR:
+ case PROPERTY_LIST_SERVICE_E_PLIST_ERROR:
return INSTPROXY_E_PLIST_ERROR;
+ case PROPERTY_LIST_SERVICE_E_MUX_ERROR:
+ return INSTPROXY_E_CONN_FAILED;
default:
break;
}
@@ -84,14 +85,14 @@ static instproxy_error_t iphone_to_instproxy_error(iphone_error_t err)
* Creates a new installation_proxy client
*
* @param device The device to connect to
- * @param dst_port Destination port (usually given by lockdownd_start_service).
+ * @param port Destination port (usually given by lockdownd_start_service).
* @param client Pointer that will be set to a newly allocated
* instproxy_client_t upon successful return.
*
* @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value
* when an error occured.
*/
-instproxy_error_t instproxy_client_new(iphone_device_t device, int dst_port, instproxy_client_t *client)
+instproxy_error_t instproxy_client_new(iphone_device_t device, uint16_t port, instproxy_client_t *client)
{
/* makes sure thread environment is available */
if (!g_thread_supported())
@@ -100,14 +101,13 @@ instproxy_error_t instproxy_client_new(iphone_device_t device, int dst_port, ins
if (!device)
return INSTPROXY_E_INVALID_ARG;
- /* Attempt connection */
- iphone_connection_t connection = NULL;
- if (iphone_device_connect(device, dst_port, &connection) != IPHONE_E_SUCCESS) {
+ property_list_service_client_t plistclient = NULL;
+ if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
return INSTPROXY_E_CONN_FAILED;
}
instproxy_client_t client_loc = (instproxy_client_t) malloc(sizeof(struct instproxy_client_int));
- client_loc->connection = connection;
+ client_loc->parent = plistclient;
client_loc->mutex = g_mutex_new();
client_loc->status_updater = NULL;
@@ -128,10 +128,10 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client)
if (!client)
return INSTPROXY_E_INVALID_ARG;
- iphone_device_disconnect(client->connection);
- client->connection = NULL;
+ property_list_service_client_free(client->parent);
+ client->parent = NULL;
if (client->status_updater) {
- log_dbg_msg(DBGMASK_INSTPROXY, "joining status_updater");
+ debug_info("joining status_updater");
g_thread_join(client->status_updater);
}
if (client->mutex) {
@@ -155,7 +155,7 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client)
*/
instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_t apptype, plist_t *result)
{
- if (!client || !client->connection || !result)
+ if (!client || !client->parent || !result)
return INSTPROXY_E_INVALID_ARG;
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -174,7 +174,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_
p_apptype = plist_new_string("User");
break;
default:
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: unknown apptype %d given, using INSTPROXY_APPTYPE_USER instead\n", __func__, apptype);
+ debug_info("unknown apptype %d given, using INSTPROXY_APPTYPE_USER instead", apptype);
p_apptype = plist_new_string("User");
break;
}
@@ -184,10 +184,10 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_
plist_dict_insert_item(dict, "Command", plist_new_string("Browse"));
instproxy_lock(client);
- res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict));
+ res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict));
plist_free(dict);
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist\n", __func__);
+ debug_info("could not send plist");
goto leave_unlock;
}
@@ -196,7 +196,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_
do {
browsing = 0;
dict = NULL;
- res = iphone_to_instproxy_error(iphone_device_receive_plist(client->connection, &dict));
+ res = instproxy_error(property_list_service_receive_plist(client->parent, &dict));
if (res != INSTPROXY_E_SUCCESS) {
break;
}
@@ -223,7 +223,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_
if (!strcmp(status, "BrowsingApplications")) {
browsing = 1;
} else if (!strcmp(status, "Complete")) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: Browsing applications completed\n");
+ debug_info("Browsing applications completed");
res = INSTPROXY_E_SUCCESS;
}
free(status);
@@ -261,10 +261,10 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
do {
instproxy_lock(client);
- res = iphone_to_instproxy_error(iphone_device_receive_plist_with_timeout(client->connection, &dict, 30000));
+ res = instproxy_error(property_list_service_receive_plist_with_timeout(client->parent, &dict, 30000));
instproxy_unlock(client);
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not receive plist, error %d\n", __func__, res);
+ debug_info("could not receive plist, error %d", res);
break;
}
if (dict) {
@@ -279,7 +279,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
char *err_msg = NULL;
plist_get_string_val(err, &err_msg);
if (err_msg) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s(%s): ERROR: %s\n", __func__, operation, err_msg);
+ debug_info("(%s): ERROR: %s", operation, err_msg);
free(err_msg);
}
#endif
@@ -303,9 +303,9 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
int percent;
plist_get_uint_val(npercent, &val);
percent = val;
- log_dbg_msg(DBGMASK_INSTPROXY, "%s(%s): %s (%d%%)\n", __func__, operation, status_msg, percent);
+ debug_info("(%s): %s (%d%%)", operation, status_msg, percent);
} else {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s(%s): %s\n", __func__, operation, status_msg);
+ debug_info("(%s): %s", operation, status_msg);
}
#endif
free(status_msg);
@@ -314,7 +314,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
plist_free(dict);
dict = NULL;
}
- } while (ok && client->connection);
+ } while (ok && client->parent);
return res;
}
@@ -338,7 +338,7 @@ static gpointer instproxy_status_updater(gpointer arg)
/* cleanup */
instproxy_lock(data->client);
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: done, cleaning up.\n", __func__);
+ debug_info("done, cleaning up.");
if (data->operation) {
free(data->operation);
}
@@ -404,15 +404,15 @@ static instproxy_error_t instproxy_create_status_updater(instproxy_client_t clie
*/
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)
{
- if (!client || !client->connection || !pkg_path) {
+ if (!client || !client->parent || !pkg_path) {
return INSTPROXY_E_INVALID_ARG;
}
if (sinf && (plist_get_node_type(sinf) != PLIST_DATA)) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s(%s): ERROR: sinf data is not a PLIST_DATA node!\n", __func__, command);
+ debug_info("(%s): ERROR: sinf data is not a PLIST_DATA node!", command);
return INSTPROXY_E_INVALID_ARG;
}
if (metadata && (plist_get_node_type(metadata) != PLIST_DATA)) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s(%s): ERROR: metadata is not a PLIST_DATA node!\n", __func__, command);
+ debug_info("(%s): ERROR: metadata is not a PLIST_DATA node!", command);
return INSTPROXY_E_INVALID_ARG;
}
@@ -433,13 +433,13 @@ static instproxy_error_t instproxy_install_or_upgrade(instproxy_client_t client,
plist_dict_insert_item(dict, "PackagePath", plist_new_string(pkg_path));
instproxy_lock(client);
- res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict));
+ res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict));
instproxy_unlock(client);
plist_free(dict);
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist, error %d\n", __func__, res);
+ debug_info("could not send plist, error %d", res);
return res;
}
@@ -512,7 +512,7 @@ instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_p
*/
instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb)
{
- if (!client || !client->connection || !appid) {
+ if (!client || !client->parent || !appid) {
return INSTPROXY_E_INVALID_ARG;
}
@@ -526,13 +526,13 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app
plist_dict_insert_item(dict, "Command", plist_new_string("Uninstall"));
instproxy_lock(client);
- res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict));
+ res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict));
instproxy_unlock(client);
plist_free(dict);
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist, error %d\n", __func__, res);
+ debug_info("could not send plist, error %d", res);
return res;
}
@@ -553,7 +553,7 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app
*/
instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t *result)
{
- if (!client || !client->connection || !result)
+ if (!client || !client->parent || !result)
return INSTPROXY_E_INVALID_ARG;
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -563,17 +563,17 @@ instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t *
instproxy_lock(client);
- res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict));
+ res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict));
plist_free(dict);
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist, error %d\n", __func__, res);
+ debug_info("could not send plist, error %d", res);
goto leave_unlock;
}
- res = iphone_to_instproxy_error(iphone_device_receive_plist(client->connection, result));
+ res = instproxy_error(property_list_service_receive_plist(client->parent, result));
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not receive plist, error %d\n", __func__, res);
+ debug_info("could not receive plist, error %d", res);
goto leave_unlock;
}
@@ -610,7 +610,7 @@ leave_unlock:
*/
instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, uint32_t options, instproxy_status_cb_t status_cb)
{
- if (!client || !client->connection || !appid)
+ if (!client || !client->parent || !appid)
return INSTPROXY_E_INVALID_ARG;
if (client->status_updater) {
@@ -634,13 +634,13 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid
plist_dict_insert_item(dict, "Command", plist_new_string("Archive"));
instproxy_lock(client);
- res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict));
+ res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict));
instproxy_unlock(client);
plist_free(dict);
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist, error %d\n", __func__, res);
+ debug_info("could not send plist, error %d", res);
return res;
}
return instproxy_create_status_updater(client, status_cb, "Archive");
@@ -666,7 +666,7 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid
*/
instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb)
{
- if (!client || !client->connection || !appid)
+ if (!client || !client->parent || !appid)
return INSTPROXY_E_INVALID_ARG;
if (client->status_updater) {
@@ -680,13 +680,13 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid
plist_dict_insert_item(dict, "Command", plist_new_string("Restore"));
instproxy_lock(client);
- res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict));
+ res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict));
instproxy_unlock(client);
plist_free(dict);
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist, error %d\n", __func__, res);
+ debug_info("could not send plist, error %d", res);
return res;
}
return instproxy_create_status_updater(client, status_cb, "Restore");
@@ -712,7 +712,7 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid
*/
instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, instproxy_status_cb_t status_cb)
{
- if (!client || !client->connection || !appid)
+ if (!client || !client->parent || !appid)
return INSTPROXY_E_INVALID_ARG;
if (client->status_updater) {
@@ -726,13 +726,13 @@ instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char
plist_dict_insert_item(dict, "Command", plist_new_string("RemoveArchive"));
instproxy_lock(client);
- res = iphone_to_instproxy_error(iphone_device_send_xml_plist(client->connection, dict));
+ res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict));
instproxy_unlock(client);
plist_free(dict);
if (res != INSTPROXY_E_SUCCESS) {
- log_dbg_msg(DBGMASK_INSTPROXY, "%s: could not send plist, error %d\n", __func__, res);
+ debug_info("could not send plist, error %d", res);
return res;
}
return instproxy_create_status_updater(client, status_cb, "RemoveArchive");