From fcc1bb855efb6860417ed827d3b50feba24a9a8b Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 26 Feb 2013 03:20:56 +0100 Subject: Refactor port number use into service descriptor to enable SSL for services This is a major change which breaks API but is required in order to support SSL communication for services as used by network connections. --- src/webinspector.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/webinspector.c') diff --git a/src/webinspector.c b/src/webinspector.c index c3d57cc..eb12d4d 100644 --- a/src/webinspector.c +++ b/src/webinspector.c @@ -62,7 +62,7 @@ static webinspector_error_t webinspector_error(property_list_service_error_t err * Connects to the webinspector service on the specified device. * * @param device The device to connect to. - * @param port Destination port (usually given by lockdownd_start_service). + * @param service The service descriptor returned by lockdownd_start_service. * @param client Pointer that will point to a newly allocated * webinspector_client_t upon successful return. Must be freed using * webinspector_client_free() after use. @@ -70,19 +70,19 @@ static webinspector_error_t webinspector_error(property_list_service_error_t err * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when * client is NULL, or an WEBINSPECTOR_E_* error code otherwise. */ -webinspector_error_t webinspector_client_new(idevice_t device, uint16_t port, webinspector_client_t * client) +webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client) { *client = NULL; - debug_info("Creating webinspector_client, port = %d.", port); + debug_info("Creating webinspector_client, port = %d.", service->port); - if (!device || port == 0 || !client || *client) { + if (!device || service->port == 0 || !client || *client) { debug_info("Incorrect parameter passed to webinspector_client_new."); return WEBINSPECTOR_E_INVALID_ARG; } property_list_service_client_t plclient = NULL; - webinspector_error_t ret = webinspector_error(property_list_service_client_new(device, port, &plclient)); + webinspector_error_t ret = webinspector_error(property_list_service_client_new(device, service, &plclient)); if (ret != WEBINSPECTOR_E_SUCCESS) { debug_info("Creating a property list client failed. Error: %i", ret); return ret; @@ -118,22 +118,27 @@ webinspector_error_t webinspector_start_service(idevice_t device, webinspector_c debug_info("Could not create a lockdown client."); return WEBINSPECTOR_E_UNKNOWN_ERROR; } - - uint16_t port = 0; - lockdownd_start_service(lckd, WEBINSPECTOR_SERVICE_NAME, &port); + + lockdownd_service_descriptor_t service = NULL; + lockdownd_start_service(lckd, WEBINSPECTOR_SERVICE_NAME, &service); lockdownd_client_free(lckd); - if (port <= 0) { + if (service->port <= 0) { debug_info("Could not start webinspector service!"); return WEBINSPECTOR_E_UNKNOWN_ERROR; } - webinspector_error_t res = webinspector_client_new(device, port, client); + webinspector_error_t res = webinspector_client_new(device, service, client); if (res != WEBINSPECTOR_E_SUCCESS) { - debug_info("Could not connect to webinspector! Port: %i, error: %i", port, res); + debug_info("Could not connect to webinspector! Port: %i, error: %i", service->port, res); return res; } + if (service) { + lockdownd_service_descriptor_free(service); + service = NULL; + } + return WEBINSPECTOR_E_SUCCESS; } -- cgit v1.1-32-gdbae