summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/Makefile.am3
-rw-r--r--include/libimobiledevice/property_list_service.h170
-rw-r--r--src/property_list_service.c100
-rw-r--r--src/property_list_service.h33
4 files changed, 173 insertions, 133 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 4ee11b4..1a49703 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -19,4 +19,5 @@ nobase_include_HEADERS = libimobiledevice/libimobiledevice.h \
19 libimobiledevice/heartbeat.h\ 19 libimobiledevice/heartbeat.h\
20 libimobiledevice/diagnostics_relay.h\ 20 libimobiledevice/diagnostics_relay.h\
21 libimobiledevice/syslog_relay.h\ 21 libimobiledevice/syslog_relay.h\
22 libimobiledevice/service.h \ No newline at end of file 22 libimobiledevice/property_list_service.h\
23 libimobiledevice/service.h
diff --git a/include/libimobiledevice/property_list_service.h b/include/libimobiledevice/property_list_service.h
new file mode 100644
index 0000000..4a004ba
--- /dev/null
+++ b/include/libimobiledevice/property_list_service.h
@@ -0,0 +1,170 @@
1/*
2 * @file libimobiledevice/property_list_service.h
3 * @brief Definitions for the PropertyList service
4 *
5 * Copyright (c) 2010 Nikias Bassen, All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef IPROPERTY_LIST_SERVICE_H
23#define IPROPERTY_LIST_SERVICE_H
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#include <libimobiledevice/lockdown.h>
30
31/* Error Codes */
32/*@{*/
33#define PROPERTY_LIST_SERVICE_E_SUCCESS 0
34#define PROPERTY_LIST_SERVICE_E_INVALID_ARG -1
35#define PROPERTY_LIST_SERVICE_E_PLIST_ERROR -2
36#define PROPERTY_LIST_SERVICE_E_MUX_ERROR -3
37#define PROPERTY_LIST_SERVICE_E_SSL_ERROR -4
38#define PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT -5
39#define PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR -256
40/*@}*/
41
42/** Represents an error code */
43typedef int16_t property_list_service_error_t;
44
45typedef struct property_list_service_client_private property_list_service_private;
46typedef property_list_service_private* property_list_service_client_t; /**< The client handle. */
47
48/* Interface */
49
50/**
51 * Creates a new property list service for the specified port.
52 *
53 * @param device The device to connect to.
54 * @param service The service descriptor returned by lockdownd_start_service.
55 * @param client Pointer that will be set to a newly allocated
56 * property_list_service_client_t upon successful return.
57 *
58 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
59 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid,
60 * or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed.
61 */
62property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client);
63
64/**
65 * Frees a PropertyList service.
66 *
67 * @param client The property list service to free.
68 *
69 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
70 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client is invalid, or a
71 * PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when another error occured.
72 */
73property_list_service_error_t property_list_service_client_free(property_list_service_client_t client);
74
75/**
76 * Sends an XML plist.
77 *
78 * @param client The property list service client to use for sending.
79 * @param plist plist to send
80 *
81 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
82 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or plist is NULL,
83 * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist,
84 * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs.
85 */
86property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist);
87
88/**
89 * Sends a binary plist.
90 *
91 * @param client The property list service client to use for sending.
92 * @param plist plist to send
93 *
94 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
95 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or plist is NULL,
96 * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist,
97 * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs.
98 */
99property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist);
100
101/**
102 * Receives a plist using the given property list service client with specified
103 * timeout.
104 * Binary or XML plists are automatically handled.
105 *
106 * @param client The property list service client to use for receiving
107 * @param plist pointer to a plist_t that will point to the received plist
108 * upon successful return
109 * @param timeout Maximum time in milliseconds to wait for data.
110 *
111 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
112 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when connection or *plist is NULL,
113 * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when the received data cannot be
114 * converted to a plist, PROPERTY_LIST_SERVICE_E_MUX_ERROR when a
115 * communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when
116 * an unspecified error occurs.
117 */
118property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout);
119
120/**
121 * Receives a plist using the given property list service client.
122 * Binary or XML plists are automatically handled.
123 *
124 * This function is like property_list_service_receive_plist_with_timeout
125 * using a timeout of 10 seconds.
126 * @see property_list_service_receive_plist_with_timeout
127 *
128 * @param client The property list service client to use for receiving
129 * @param plist pointer to a plist_t that will point to the received plist
130 * upon successful return
131 *
132 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
133 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or *plist is NULL,
134 * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when the received data cannot be
135 * converted to a plist, PROPERTY_LIST_SERVICE_E_MUX_ERROR when a
136 * communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when
137 * an unspecified error occurs.
138 */
139property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist);
140
141/**
142 * Enable SSL for the given property list service client.
143 *
144 * @param client The connected property list service client for which SSL
145 * should be enabled.
146 *
147 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
148 * PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is
149 * NULL, PROPERTY_LIST_SERVICE_E_SSL_ERROR when SSL could not be enabled,
150 * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise.
151 */
152property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client);
153
154/**
155 * Disable SSL for the given property list service client.
156 *
157 * @param client The connected property list service client for which SSL
158 * should be disabled.
159 *
160 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
161 * PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is
162 * NULL, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise.
163 */
164property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client);
165
166#ifdef __cplusplus
167}
168#endif
169
170#endif
diff --git a/src/property_list_service.c b/src/property_list_service.c
index 3f2e6c3..c260d3e 100644
--- a/src/property_list_service.c
+++ b/src/property_list_service.c
@@ -54,18 +54,6 @@ static property_list_service_error_t service_to_property_list_service_error(serv
54 return PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR; 54 return PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR;
55} 55}
56 56
57/**
58 * Creates a new property list service for the specified port.
59 *
60 * @param device The device to connect to.
61 * @param service The service descriptor returned by lockdownd_start_service.
62 * @param client Pointer that will be set to a newly allocated
63 * property_list_service_client_t upon successful return.
64 *
65 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
66 * 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.
68 */
69property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client) 57property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client)
70{ 58{
71 if (!device || !service || service->port == 0 || !client || *client) 59 if (!device || !service || service->port == 0 || !client || *client)
@@ -86,15 +74,6 @@ property_list_service_error_t property_list_service_client_new(idevice_t device,
86 return PROPERTY_LIST_SERVICE_E_SUCCESS; 74 return PROPERTY_LIST_SERVICE_E_SUCCESS;
87} 75}
88 76
89/**
90 * Frees a PropertyList service.
91 *
92 * @param client The property list service to free.
93 *
94 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
95 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client is invalid, or a
96 * PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when another error occured.
97 */
98property_list_service_error_t property_list_service_client_free(property_list_service_client_t client) 77property_list_service_error_t property_list_service_client_free(property_list_service_client_t client)
99{ 78{
100 if (!client) 79 if (!client)
@@ -168,33 +147,11 @@ static property_list_service_error_t internal_plist_send(property_list_service_c
168 return res; 147 return res;
169} 148}
170 149
171/**
172 * Sends an XML plist.
173 *
174 * @param client The property list service client to use for sending.
175 * @param plist plist to send
176 *
177 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
178 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or plist is NULL,
179 * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist,
180 * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs.
181 */
182property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist) 150property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist)
183{ 151{
184 return internal_plist_send(client, plist, 0); 152 return internal_plist_send(client, plist, 0);
185} 153}
186 154
187/**
188 * Sends a binary plist.
189 *
190 * @param client The property list service client to use for sending.
191 * @param plist plist to send
192 *
193 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
194 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or plist is NULL,
195 * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist,
196 * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs.
197 */
198property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist) 155property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist)
199{ 156{
200 return internal_plist_send(client, plist, 1); 157 return internal_plist_send(client, plist, 1);
@@ -293,63 +250,16 @@ static property_list_service_error_t internal_plist_receive_timeout(property_lis
293 return res; 250 return res;
294} 251}
295 252
296/**
297 * Receives a plist using the given property list service client with specified
298 * timeout.
299 * Binary or XML plists are automatically handled.
300 *
301 * @param client The property list service client to use for receiving
302 * @param plist pointer to a plist_t that will point to the received plist
303 * upon successful return
304 * @param timeout Maximum time in milliseconds to wait for data.
305 *
306 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
307 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when connection or *plist is NULL,
308 * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when the received data cannot be
309 * converted to a plist, PROPERTY_LIST_SERVICE_E_MUX_ERROR when a
310 * communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when
311 * an unspecified error occurs.
312 */
313property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout) 253property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout)
314{ 254{
315 return internal_plist_receive_timeout(client, plist, timeout); 255 return internal_plist_receive_timeout(client, plist, timeout);
316} 256}
317 257
318/**
319 * Receives a plist using the given property list service client.
320 * Binary or XML plists are automatically handled.
321 *
322 * This function is like property_list_service_receive_plist_with_timeout
323 * using a timeout of 10 seconds.
324 * @see property_list_service_receive_plist_with_timeout
325 *
326 * @param client The property list service client to use for receiving
327 * @param plist pointer to a plist_t that will point to the received plist
328 * upon successful return
329 *
330 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
331 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or *plist is NULL,
332 * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when the received data cannot be
333 * converted to a plist, PROPERTY_LIST_SERVICE_E_MUX_ERROR when a
334 * communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when
335 * an unspecified error occurs.
336 */
337property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist) 258property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist)
338{ 259{
339 return internal_plist_receive_timeout(client, plist, 10000); 260 return internal_plist_receive_timeout(client, plist, 10000);
340} 261}
341 262
342/**
343 * Enable SSL for the given property list service client.
344 *
345 * @param client The connected property list service client for which SSL
346 * should be enabled.
347 *
348 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
349 * PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is
350 * NULL, PROPERTY_LIST_SERVICE_E_SSL_ERROR when SSL could not be enabled,
351 * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise.
352 */
353property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client) 263property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client)
354{ 264{
355 if (!client || !client->parent) 265 if (!client || !client->parent)
@@ -357,16 +267,6 @@ property_list_service_error_t property_list_service_enable_ssl(property_list_ser
357 return service_to_property_list_service_error(service_enable_ssl(client->parent)); 267 return service_to_property_list_service_error(service_enable_ssl(client->parent));
358} 268}
359 269
360/**
361 * Disable SSL for the given property list service client.
362 *
363 * @param client The connected property list service client for which SSL
364 * should be disabled.
365 *
366 * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
367 * PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is
368 * NULL, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise.
369 */
370property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client) 270property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client)
371{ 271{
372 if (!client || !client->parent) 272 if (!client || !client->parent)
diff --git a/src/property_list_service.h b/src/property_list_service.h
index 5c5f38f..6775c7c 100644
--- a/src/property_list_service.h
+++ b/src/property_list_service.h
@@ -22,42 +22,11 @@
22#ifndef __PROPERTY_LIST_SERVICE_H 22#ifndef __PROPERTY_LIST_SERVICE_H
23#define __PROPERTY_LIST_SERVICE_H 23#define __PROPERTY_LIST_SERVICE_H
24 24
25#include <libimobiledevice/lockdown.h> 25#include "libimobiledevice/property_list_service.h"
26#include "service.h" 26#include "service.h"
27#include "idevice.h"
28
29/* Error Codes */
30#define PROPERTY_LIST_SERVICE_E_SUCCESS 0
31#define PROPERTY_LIST_SERVICE_E_INVALID_ARG -1
32#define PROPERTY_LIST_SERVICE_E_PLIST_ERROR -2
33#define PROPERTY_LIST_SERVICE_E_MUX_ERROR -3
34#define PROPERTY_LIST_SERVICE_E_SSL_ERROR -4
35#define PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT -5
36
37#define PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR -256
38 27
39struct property_list_service_client_private { 28struct property_list_service_client_private {
40 service_client_t parent; 29 service_client_t parent;
41}; 30};
42 31
43typedef struct property_list_service_client_private *property_list_service_client_t;
44
45typedef int16_t property_list_service_error_t;
46
47/* creation and destruction */
48property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client);
49property_list_service_error_t property_list_service_client_free(property_list_service_client_t client);
50
51/* sending */
52property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist);
53property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist);
54
55/* receiving */
56property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout);
57property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist);
58
59/* misc */
60property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client);
61property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client);
62
63#endif 32#endif