diff options
author | 2022-04-12 02:56:18 +0200 | |
---|---|---|
committer | 2022-04-12 02:56:18 +0200 | |
commit | 854ab9a5d9d04fb884459c5092f6620faa99673b (patch) | |
tree | c13e8ac64084e15cfabb09682dd19528dfa90b47 | |
parent | dca3cf8c5bd804bf563fd43a6cdfdb1a5b85d490 (diff) | |
download | libimobiledevice-854ab9a5d9d04fb884459c5092f6620faa99673b.tar.gz libimobiledevice-854ab9a5d9d04fb884459c5092f6620faa99673b.tar.bz2 |
Add property_list_client_get_service_client() and service_get_connection() functions
This allows for custom service implementations to easier switch to non-plist
communication after the service has been started.
-rw-r--r-- | include/libimobiledevice/property_list_service.h | 20 | ||||
-rw-r--r-- | include/libimobiledevice/service.h | 10 | ||||
-rw-r--r-- | src/property_list_service.c | 7 | ||||
-rw-r--r-- | src/service.c | 7 |
4 files changed, 40 insertions, 4 deletions
diff --git a/include/libimobiledevice/property_list_service.h b/include/libimobiledevice/property_list_service.h index 5205551..3f6ebad 100644 --- a/include/libimobiledevice/property_list_service.h +++ b/include/libimobiledevice/property_list_service.h | |||
@@ -29,6 +29,7 @@ extern "C" { | |||
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #include <libimobiledevice/lockdown.h> | 31 | #include <libimobiledevice/lockdown.h> |
32 | #include <libimobiledevice/service.h> | ||
32 | 33 | ||
33 | /** Error Codes */ | 34 | /** Error Codes */ |
34 | typedef enum { | 35 | typedef enum { |
@@ -147,8 +148,8 @@ property_list_service_error_t property_list_service_receive_plist(property_list_ | |||
147 | * should be enabled. | 148 | * should be enabled. |
148 | * | 149 | * |
149 | * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, | 150 | * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, |
150 | * PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is | 151 | * PROPERTY_LIST_SERVICE_E_INVALID_ARG if one or more of the arguments are invalid, |
151 | * NULL, PROPERTY_LIST_SERVICE_E_SSL_ERROR when SSL could not be enabled, | 152 | * PROPERTY_LIST_SERVICE_E_SSL_ERROR when SSL could not be enabled, |
152 | * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise. | 153 | * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise. |
153 | */ | 154 | */ |
154 | property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client); | 155 | property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client); |
@@ -160,11 +161,22 @@ property_list_service_error_t property_list_service_enable_ssl(property_list_ser | |||
160 | * should be disabled. | 161 | * should be disabled. |
161 | * | 162 | * |
162 | * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, | 163 | * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, |
163 | * PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is | 164 | * PROPERTY_LIST_SERVICE_E_INVALID_ARG if one or more of the arguments are invalid, |
164 | * NULL, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise. | 165 | * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise. |
165 | */ | 166 | */ |
166 | property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client); | 167 | property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client); |
167 | 168 | ||
169 | /** | ||
170 | * Return a handle to the parent #service_client_t of the given property list service client. | ||
171 | * | ||
172 | * @param client The property list service client | ||
173 | * @param service_client Pointer to be assigned to the parent #service_client_t | ||
174 | * | ||
175 | * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, | ||
176 | * PROPERTY_LIST_SERVICE_E_INVALID_ARG if one or more of the arguments are invalid. | ||
177 | */ | ||
178 | property_list_service_error_t property_list_service_get_service_client(property_list_service_client_t client, service_client_t *service_client); | ||
179 | |||
168 | #ifdef __cplusplus | 180 | #ifdef __cplusplus |
169 | } | 181 | } |
170 | #endif | 182 | #endif |
diff --git a/include/libimobiledevice/service.h b/include/libimobiledevice/service.h index 6842054..28b6db6 100644 --- a/include/libimobiledevice/service.h +++ b/include/libimobiledevice/service.h | |||
@@ -184,6 +184,16 @@ service_error_t service_disable_ssl(service_client_t client); | |||
184 | */ | 184 | */ |
185 | service_error_t service_disable_bypass_ssl(service_client_t client, uint8_t sslBypass); | 185 | service_error_t service_disable_bypass_ssl(service_client_t client, uint8_t sslBypass); |
186 | 186 | ||
187 | /** | ||
188 | * Return a handle to the parent #idevice_connection_t of the given service client. | ||
189 | * | ||
190 | * @param client The service client | ||
191 | * @param connection Pointer to be assigned to the #idevice_connection_t. | ||
192 | * | ||
193 | * @return SERVICE_E_SUCCESS on success, | ||
194 | * SERVICE_E_INVALID_ARG if one or more of the arguments are invalid. | ||
195 | */ | ||
196 | service_error_t service_get_connection(service_client_t client, idevice_connection_t *connection); | ||
187 | #ifdef __cplusplus | 197 | #ifdef __cplusplus |
188 | } | 198 | } |
189 | #endif | 199 | #endif |
diff --git a/src/property_list_service.c b/src/property_list_service.c index 7b5c738..4654b6e 100644 --- a/src/property_list_service.c +++ b/src/property_list_service.c | |||
@@ -286,3 +286,10 @@ LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_disable | |||
286 | return service_to_property_list_service_error(service_disable_ssl(client->parent)); | 286 | return service_to_property_list_service_error(service_disable_ssl(client->parent)); |
287 | } | 287 | } |
288 | 288 | ||
289 | LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_get_service_client(property_list_service_client_t client, service_client_t *service_client) | ||
290 | { | ||
291 | if (!client || !client->parent || !service_client) | ||
292 | return PROPERTY_LIST_SERVICE_E_INVALID_ARG; | ||
293 | *service_client = client->parent; | ||
294 | return PROPERTY_LIST_SERVICE_E_SUCCESS; | ||
295 | } | ||
diff --git a/src/service.c b/src/service.c index 0928bcd..6c9d109 100644 --- a/src/service.c +++ b/src/service.c | |||
@@ -198,3 +198,10 @@ LIBIMOBILEDEVICE_API service_error_t service_disable_bypass_ssl(service_client_t | |||
198 | return idevice_to_service_error(idevice_connection_disable_bypass_ssl(client->connection, sslBypass)); | 198 | return idevice_to_service_error(idevice_connection_disable_bypass_ssl(client->connection, sslBypass)); |
199 | } | 199 | } |
200 | 200 | ||
201 | LIBIMOBILEDEVICE_API service_error_t service_get_connection(service_client_t client, idevice_connection_t *connection) | ||
202 | { | ||
203 | if (!client || !client->connection || !connection) | ||
204 | return SERVICE_E_INVALID_ARG; | ||
205 | *connection = client->connection; | ||
206 | return SERVICE_E_SUCCESS; | ||
207 | } | ||