summaryrefslogtreecommitdiffstats
path: root/src/property_list_service.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/property_list_service.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/property_list_service.c')
-rw-r--r--src/property_list_service.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/property_list_service.c b/src/property_list_service.c
index c9a8edf..15adbc8 100644
--- a/src/property_list_service.c
+++ b/src/property_list_service.c
@@ -57,8 +57,7 @@ static property_list_service_error_t idevice_to_property_list_service_error(idev
57 * Creates a new property list service for the specified port. 57 * Creates a new property list service for the specified port.
58 * 58 *
59 * @param device The device to connect to. 59 * @param device The device to connect to.
60 * @param port The port on the device to connect to, usually opened by a call to 60 * @param service The service descriptor returned by lockdownd_start_service.
61 * lockdownd_start_service.
62 * @param client Pointer that will be set to a newly allocated 61 * @param client Pointer that will be set to a newly allocated
63 * property_list_service_client_t upon successful return. 62 * property_list_service_client_t upon successful return.
64 * 63 *
@@ -66,14 +65,14 @@ static property_list_service_error_t idevice_to_property_list_service_error(idev
66 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid, 65 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid,
67 * or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed. 66 * or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed.
68 */ 67 */
69property_list_service_error_t property_list_service_client_new(idevice_t device, uint16_t port, property_list_service_client_t *client) 68property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client)
70{ 69{
71 if (!device || port == 0 || !client || *client) 70 if (!device || (service->port == 0) || !client || *client)
72 return PROPERTY_LIST_SERVICE_E_INVALID_ARG; 71 return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
73 72
74 /* Attempt connection */ 73 /* Attempt connection */
75 idevice_connection_t connection = NULL; 74 idevice_connection_t connection = NULL;
76 if (idevice_connect(device, port, &connection) != IDEVICE_E_SUCCESS) { 75 if (idevice_connect(device, service->port, &connection) != IDEVICE_E_SUCCESS) {
77 return PROPERTY_LIST_SERVICE_E_MUX_ERROR; 76 return PROPERTY_LIST_SERVICE_E_MUX_ERROR;
78 } 77 }
79 78
@@ -81,8 +80,12 @@ property_list_service_error_t property_list_service_client_new(idevice_t device,
81 property_list_service_client_t client_loc = (property_list_service_client_t)malloc(sizeof(struct property_list_service_client_private)); 80 property_list_service_client_t client_loc = (property_list_service_client_t)malloc(sizeof(struct property_list_service_client_private));
82 client_loc->connection = connection; 81 client_loc->connection = connection;
83 82
84 *client = client_loc; 83 /* enable SSL if requested */
84 if (service->ssl_enabled == 1)
85 property_list_service_enable_ssl(client_loc);
85 86
87 /* all done, return success */
88 *client = client_loc;
86 return PROPERTY_LIST_SERVICE_E_SUCCESS; 89 return PROPERTY_LIST_SERVICE_E_SUCCESS;
87} 90}
88 91