summaryrefslogtreecommitdiffstats
path: root/src/webinspector.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-02-26 03:20:56 +0100
committerGravatar Martin Szulecki2013-02-26 03:20:56 +0100
commitfcc1bb855efb6860417ed827d3b50feba24a9a8b (patch)
tree47d3c7d6a985dc647f7962329014c8116d657cc9 /src/webinspector.c
parent3b54aac30447bc02fafd721a63a752968628e7e0 (diff)
downloadlibimobiledevice-fcc1bb855efb6860417ed827d3b50feba24a9a8b.tar.gz
libimobiledevice-fcc1bb855efb6860417ed827d3b50feba24a9a8b.tar.bz2
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.
Diffstat (limited to 'src/webinspector.c')
-rw-r--r--src/webinspector.c27
1 files changed, 16 insertions, 11 deletions
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;
}