summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Aaron Burghardt2014-03-27 10:07:09 -0400
committerGravatar Aaron Burghardt2014-03-27 21:40:43 -0400
commit2342dc5b4ef148b993fbe3816f3facdef8365546 (patch)
tree69f812d91b2fc07db0fad5dcba6c80d2f8b6849e
parentee82e861a8c942b5013accd7589cf898d1f97167 (diff)
downloadlibimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.gz
libimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.bz2
Moved Doxygen comments from source files to public headers.
Conflicts: include/libimobiledevice/afc.h
-rw-r--r--include/libimobiledevice/afc.h233
-rw-r--r--include/libimobiledevice/diagnostics_relay.h111
-rw-r--r--include/libimobiledevice/file_relay.h102
-rw-r--r--include/libimobiledevice/heartbeat.h72
-rw-r--r--include/libimobiledevice/house_arrest.h114
-rw-r--r--include/libimobiledevice/installation_proxy.h247
-rw-r--r--include/libimobiledevice/libimobiledevice.h147
-rw-r--r--include/libimobiledevice/lockdown.h302
-rw-r--r--include/libimobiledevice/misagent.h82
-rw-r--r--include/libimobiledevice/mobile_image_mounter.h100
-rw-r--r--include/libimobiledevice/mobilebackup.h169
-rw-r--r--include/libimobiledevice/mobilebackup2.h144
-rw-r--r--include/libimobiledevice/mobilesync.h249
-rw-r--r--include/libimobiledevice/notification_proxy.h90
-rw-r--r--include/libimobiledevice/restore.h110
-rw-r--r--include/libimobiledevice/sbservices.h102
-rw-r--r--include/libimobiledevice/screenshotr.h55
-rw-r--r--include/libimobiledevice/service.h105
-rw-r--r--include/libimobiledevice/syslog_relay.h94
-rw-r--r--include/libimobiledevice/webinspector.h73
-rw-r--r--src/afc.c212
-rw-r--r--src/diagnostics_relay.c86
-rw-r--r--src/file_relay.c98
-rw-r--r--src/heartbeat.c67
-rw-r--r--src/house_arrest.c107
-rw-r--r--src/idevice.c132
-rw-r--r--src/installation_proxy.c232
-rw-r--r--src/lockdown.c279
-rw-r--r--src/misagent.c75
-rw-r--r--src/mobile_image_mounter.c93
-rw-r--r--src/mobilebackup.c157
-rw-r--r--src/mobilebackup2.c134
-rw-r--r--src/mobilesync.c228
-rw-r--r--src/notification_proxy.c83
-rw-r--r--src/restore.c101
-rw-r--r--src/sbservices.c94
-rw-r--r--src/screenshotr.c51
-rw-r--r--src/service.c97
-rw-r--r--src/syslog_relay.c87
-rw-r--r--src/webinspector.c67
40 files changed, 2703 insertions, 2478 deletions
diff --git a/include/libimobiledevice/afc.h b/include/libimobiledevice/afc.h
index 289c749..2f272e0 100644
--- a/include/libimobiledevice/afc.h
+++ b/include/libimobiledevice/afc.h
@@ -95,30 +95,263 @@ typedef struct afc_client_private afc_client_private;
95typedef afc_client_private *afc_client_t; /**< The client handle. */ 95typedef afc_client_private *afc_client_t; /**< The client handle. */
96 96
97/* Interface */ 97/* Interface */
98
99/**
100 * Makes a connection to the AFC service on the device.
101 *
102 * @param device The device to connect to.
103 * @param service The service descriptor returned by lockdownd_start_service.
104 * @param client Pointer that will be set to a newly allocated afc_client_t
105 * upon successful return.
106 *
107 * @return AFC_E_SUCCESS on success, AFC_E_INVALID_ARG if device or service is
108 * invalid, AFC_E_MUX_ERROR if the connection cannot be established,
109 * or AFC_E_NO_MEM if there is a memory allocation problem.
110 */
98afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t *client); 111afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t *client);
112
113/**
114 * Starts a new AFC service on the specified device and connects to it.
115 *
116 * @param device The device to connect to.
117 * @param client Pointer that will point to a newly allocated
118 * afc_client_t upon successful return. Must be freed using
119 * afc_client_free() after use.
120 * @param label The label to use for communication. Usually the program name.
121 * Pass NULL to disable sending the label in requests to lockdownd.
122 *
123 * @return AFC_E_SUCCESS on success, or an AFC_E_* error
124 * code otherwise.
125 */
99afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, const char* label); 126afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, const char* label);
127
128/**
129 * Frees up an AFC client. If the connection was created by the
130 * client itself, the connection will be closed.
131 *
132 * @param client The client to free.
133 */
100afc_error_t afc_client_free(afc_client_t client); 134afc_error_t afc_client_free(afc_client_t client);
101 135
136/**
137 * Get device information for a connected client. The device information
138 * returned is the device model as well as the free space, the total capacity
139 * and blocksize on the accessed disk partition.
140 *
141 * @param client The client to get device info for.
142 * @param infos A char ** list of parameters as given by AFC or NULL if there
143 * was an error.
144 *
145 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
146 */
102afc_error_t afc_get_device_info(afc_client_t client, char ***infos); 147afc_error_t afc_get_device_info(afc_client_t client, char ***infos);
148
149/**
150 * Gets a directory listing of the directory requested.
151 *
152 * @param client The client to get a directory listing from.
153 * @param dir The directory to list. (must be a fully-qualified path)
154 * @param list A char list of files in that directory, terminated by an empty
155 * string or NULL if there was an error.
156 *
157 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
158 */
103afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list); 159afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list);
160
161/**
162 * Gets information about a specific file.
163 *
164 * @param client The client to use to get the information of the file.
165 * @param path The fully-qualified path to the file.
166 * @param infolist Pointer to a buffer that will be filled with a NULL-terminated
167 * list of strings with the file information.
168 * Set to NULL before calling this function.
169 *
170 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
171 */
104afc_error_t afc_get_file_info(afc_client_t client, const char *filename, char ***infolist); 172afc_error_t afc_get_file_info(afc_client_t client, const char *filename, char ***infolist);
173
174/**
175 * Opens a file on the device.
176 *
177 * @param client The client to use to open the file.
178 * @param filename The file to open. (must be a fully-qualified path)
179 * @param file_mode The mode to use to open the file. Can be AFC_FILE_READ or
180 * AFC_FILE_WRITE; the former lets you read and write,
181 * however, and the second one will *create* the file,
182 * destroying anything previously there.
183 * @param handle Pointer to a uint64_t that will hold the handle of the file
184 *
185 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
186 */
105afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle); 187afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle);
188
189/**
190 * Closes a file on the device.
191 *
192 * @param client The client to close the file with.
193 * @param handle File handle of a previously opened file.
194 */
106afc_error_t afc_file_close(afc_client_t client, uint64_t handle); 195afc_error_t afc_file_close(afc_client_t client, uint64_t handle);
196
197/**
198 * Locks or unlocks a file on the device.
199 *
200 * makes use of flock on the device, see
201 * http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/flock.2.html
202 *
203 * @param client The client to lock the file with.
204 * @param handle File handle of a previously opened file.
205 * @param operation the lock or unlock operation to perform, this is one of
206 * AFC_LOCK_SH (shared lock), AFC_LOCK_EX (exclusive lock),
207 * or AFC_LOCK_UN (unlock).
208 */
107afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation); 209afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation);
210
211/**
212 * Attempts to the read the given number of bytes from the given file.
213 *
214 * @param client The relevant AFC client
215 * @param handle File handle of a previously opened file
216 * @param data The pointer to the memory region to store the read data
217 * @param length The number of bytes to read
218 * @param bytes_read The number of bytes actually read.
219 *
220 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
221 */
108afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read); 222afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read);
223
224/**
225 * Writes a given number of bytes to a file.
226 *
227 * @param client The client to use to write to the file.
228 * @param handle File handle of previously opened file.
229 * @param data The data to write to the file.
230 * @param length How much data to write.
231 * @param bytes_written The number of bytes actually written to the file.
232 *
233 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
234 */
109afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written); 235afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written);
236
237/**
238 * Seeks to a given position of a pre-opened file on the device.
239 *
240 * @param client The client to use to seek to the position.
241 * @param handle File handle of a previously opened.
242 * @param offset Seek offset.
243 * @param whence Seeking direction, one of SEEK_SET, SEEK_CUR, or SEEK_END.
244 *
245 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
246 */
110afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence); 247afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence);
248
249/**
250 * Returns current position in a pre-opened file on the device.
251 *
252 * @param client The client to use.
253 * @param handle File handle of a previously opened file.
254 * @param position Position in bytes of indicator
255 *
256 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
257 */
111afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position); 258afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position);
259
260/**
261 * Sets the size of a file on the device.
262 *
263 * @param client The client to use to set the file size.
264 * @param handle File handle of a previously opened file.
265 * @param newsize The size to set the file to.
266 *
267 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
268 *
269 * @note This function is more akin to ftruncate than truncate, and truncate
270 * calls would have to open the file before calling this, sadly.
271 */
112afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize); 272afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize);
273
274/**
275 * Deletes a file or directory.
276 *
277 * @param client The client to use.
278 * @param path The path to delete. (must be a fully-qualified path)
279 *
280 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
281 */
113afc_error_t afc_remove_path(afc_client_t client, const char *path); 282afc_error_t afc_remove_path(afc_client_t client, const char *path);
283
284/**
285 * Renames a file or directory on the device.
286 *
287 * @param client The client to have rename.
288 * @param from The name to rename from. (must be a fully-qualified path)
289 * @param to The new name. (must also be a fully-qualified path)
290 *
291 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
292 */
114afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to); 293afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to);
294
295/**
296 * Creates a directory on the device.
297 *
298 * @param client The client to use to make a directory.
299 * @param dir The directory's path. (must be a fully-qualified path, I assume
300 * all other mkdir restrictions apply as well)
301 *
302 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
303 */
115afc_error_t afc_make_directory(afc_client_t client, const char *dir); 304afc_error_t afc_make_directory(afc_client_t client, const char *dir);
305
306/**
307 * Sets the size of a file on the device without prior opening it.
308 *
309 * @param client The client to use to set the file size.
310 * @param path The path of the file to be truncated.
311 * @param newsize The size to set the file to.
312 *
313 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
314 */
116afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize); 315afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize);
316
317/**
318 * Creates a hard link or symbolic link on the device.
319 *
320 * @param client The client to use for making a link
321 * @param linktype 1 = hard link, 2 = symlink
322 * @param target The file to be linked.
323 * @param linkname The name of link.
324 *
325 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
326 */
117afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); 327afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname);
328
329/**
330 * Sets the modification time of a file on the device.
331 *
332 * @param client The client to use to set the file size.
333 * @param path Path of the file for which the modification time should be set.
334 * @param mtime The modification time to set in nanoseconds since epoch.
335 *
336 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
337 */
118afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime); 338afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime);
119 339
120/* Helper functions */ 340/* Helper functions */
341
342/**
343 * Get a specific key of the device info list for a client connection.
344 * Known key values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize.
345 * This is a helper function for afc_get_device_info().
346 *
347 * @param client The client to get device info for.
348 * @param key The key to get the value of.
349 * @param value The value for the key if successful or NULL otherwise.
350 *
351 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
352 */
121afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value); 353afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value);
354
122afc_error_t afc_dictionary_free(char **dictionary); 355afc_error_t afc_dictionary_free(char **dictionary);
123 356
124#ifdef __cplusplus 357#ifdef __cplusplus
diff --git a/include/libimobiledevice/diagnostics_relay.h b/include/libimobiledevice/diagnostics_relay.h
index 17e73dd..b25750b 100644
--- a/include/libimobiledevice/diagnostics_relay.h
+++ b/include/libimobiledevice/diagnostics_relay.h
@@ -58,17 +58,128 @@ typedef int16_t diagnostics_relay_error_t;
58typedef struct diagnostics_relay_client_private diagnostics_relay_client_private; 58typedef struct diagnostics_relay_client_private diagnostics_relay_client_private;
59typedef diagnostics_relay_client_private *diagnostics_relay_client_t; /**< The client handle. */ 59typedef diagnostics_relay_client_private *diagnostics_relay_client_t; /**< The client handle. */
60 60
61/**
62 * Connects to the diagnostics_relay service on the specified device.
63 *
64 * @param device The device to connect to.
65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Reference that will point to a newly allocated
67 * diagnostics_relay_client_t upon successful return.
68 *
69 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
70 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid,
71 * or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed.
72 */
61diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client); 73diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client);
74
75/**
76 * Starts a new diagnostics_relay service on the specified device and connects to it.
77 *
78 * @param device The device to connect to.
79 * @param client Pointer that will point to a newly allocated
80 * diagnostics_relay_client_t upon successful return. Must be freed using
81 * diagnostics_relay_client_free() after use.
82 * @param label The label to use for communication. Usually the program name.
83 * Pass NULL to disable sending the label in requests to lockdownd.
84 *
85 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, or an DIAGNOSTICS_RELAY_E_* error
86 * code otherwise.
87 */
62diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t* client, const char* label); 88diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t* client, const char* label);
89
90/**
91 * Disconnects a diagnostics_relay client from the device and frees up the
92 * diagnostics_relay client data.
93 *
94 * @param client The diagnostics_relay client to disconnect and free.
95 *
96 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
97 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of client or client->parent
98 * is invalid, or DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR when the was an
99 * error freeing the parent property_list_service client.
100 */
63diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client); 101diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client);
64 102
103
104/**
105 * Sends the Goodbye request signaling the end of communication.
106 *
107 * @param client The diagnostics_relay client
108 *
109 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
110 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
111 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
112 * request
113 */
65diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client); 114diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client);
115
116/**
117 * Puts the device into deep sleep mode and disconnects from host.
118 *
119 * @param client The diagnostics_relay client
120 *
121 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
122 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
123 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
124 * request
125 */
66diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client); 126diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client);
127
128/**
129 * Restart the device and optionally show a user notification.
130 *
131 * @param client The diagnostics_relay client
132 * @param flags A binary flag combination of
133 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
134 * diagnostics_relay_client_free() disconnects before execution and
135 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
136 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
137 *
138 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
139 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
140 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
141 * request
142 */
67diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags); 143diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags);
144
145/**
146 * Shutdown of the device and optionally show a user notification.
147 *
148 * @param client The diagnostics_relay client
149 * @param flags A binary flag combination of
150 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
151 * diagnostics_relay_client_free() disconnects before execution and
152 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
153 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
154 *
155 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
156 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
157 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
158 * request
159 */
68diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags); 160diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags);
161
162/**
163 * Shutdown of the device and optionally show a user notification.
164 *
165 * @param client The diagnostics_relay client
166 * @param flags A binary flag combination of
167 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
168 * diagnostics_relay_client_free() disconnects before execution and
169 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
170 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
171 *
172 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
173 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
174 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
175 * request
176 */
69diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics); 177diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics);
178
70diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result); 179diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result);
180
71diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* name, const char* class, plist_t* result); 181diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* name, const char* class, plist_t* result);
182
72diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result); 183diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result);
73 184
74#ifdef __cplusplus 185#ifdef __cplusplus
diff --git a/include/libimobiledevice/file_relay.h b/include/libimobiledevice/file_relay.h
index d197f2e..f9318bd 100644
--- a/include/libimobiledevice/file_relay.h
+++ b/include/libimobiledevice/file_relay.h
@@ -50,11 +50,113 @@ typedef int16_t file_relay_error_t;
50typedef struct file_relay_client_private file_relay_client_private; 50typedef struct file_relay_client_private file_relay_client_private;
51typedef file_relay_client_private *file_relay_client_t; /**< The client handle. */ 51typedef file_relay_client_private *file_relay_client_t; /**< The client handle. */
52 52
53/**
54 * Connects to the file_relay service on the specified device.
55 *
56 * @param device The device to connect to.
57 * @param service The service descriptor returned by lockdownd_start_service.
58 * @param client Reference that will point to a newly allocated
59 * file_relay_client_t upon successful return.
60 *
61 * @return FILE_RELAY_E_SUCCESS on success,
62 * FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid,
63 * or FILE_RELAY_E_MUX_ERROR when the connection failed.
64 */
53file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client); 65file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client);
66
67/**
68 * Starts a new file_relay service on the specified device and connects to it.
69 *
70 * @param device The device to connect to.
71 * @param client Pointer that will point to a newly allocated
72 * file_relay_client_t upon successful return. Must be freed using
73 * file_relay_client_free() after use.
74 * @param label The label to use for communication. Usually the program name.
75 * Pass NULL to disable sending the label in requests to lockdownd.
76 *
77 * @return FILE_RELAY_E_SUCCESS on success, or an FILE_RELAY_E_* error
78 * code otherwise.
79 */
54file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t* client, const char* label); 80file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t* client, const char* label);
81
82/**
83 * Disconnects a file_relay client from the device and frees up the file_relay
84 * client data.
85 *
86 * @param client The file_relay client to disconnect and free.
87 *
88 * @return FILE_RELAY_E_SUCCESS on success,
89 * FILE_RELAY_E_INVALID_ARG when one of client or client->parent
90 * is invalid, or FILE_RELAY_E_UNKNOWN_ERROR when the was an error
91 * freeing the parent property_list_service client.
92 */
55file_relay_error_t file_relay_client_free(file_relay_client_t client); 93file_relay_error_t file_relay_client_free(file_relay_client_t client);
56 94
95
96/**
97 * Request data for the given sources.
98 *
99 * @param client The connected file_relay client.
100 * @param sources A NULL-terminated list of sources to retrieve.
101 * Valid sources are:
102 * - AppleSupport
103 * - Network
104 * - VPN
105 * - WiFi
106 * - UserDatabases
107 * - CrashReporter
108 * - tmp
109 * - SystemConfiguration
110 * @param connection The connection that has to be used for receiving the
111 * data using idevice_connection_receive(). The connection will be closed
112 * automatically by the device, but use file_relay_client_free() to clean
113 * up properly.
114 * @param timeout Maximum time in milliseconds to wait for data.
115 *
116 * @note WARNING: Don't call this function without reading the data afterwards.
117 * A directory mobile_file_relay.XXXX used for creating the archive will
118 * remain in the /tmp directory otherwise.
119 *
120 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
121 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
122 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
123 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
124 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
125 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
126 */
57file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection); 127file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection);
128
129/**
130 * Request data for the given sources. Calls file_relay_request_sources_timeout() with
131 * a timeout of 60000 milliseconds (60 seconds).
132 *
133 * @param client The connected file_relay client.
134 * @param sources A NULL-terminated list of sources to retrieve.
135 * Valid sources are:
136 * - AppleSupport
137 * - Network
138 * - VPN
139 * - WiFi
140 * - UserDatabases
141 * - CrashReporter
142 * - tmp
143 * - SystemConfiguration
144 * @param connection The connection that has to be used for receiving the
145 * data using idevice_connection_receive(). The connection will be closed
146 * automatically by the device, but use file_relay_client_free() to clean
147 * up properly.
148 *
149 * @note WARNING: Don't call this function without reading the data afterwards.
150 * A directory mobile_file_relay.XXXX used for creating the archive will
151 * remain in the /tmp directory otherwise.
152 *
153 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
154 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
155 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
156 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
157 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
158 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
159 */
58file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout); 160file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout);
59 161
60#ifdef __cplusplus 162#ifdef __cplusplus
diff --git a/include/libimobiledevice/heartbeat.h b/include/libimobiledevice/heartbeat.h
index 8db2941..c943e51 100644
--- a/include/libimobiledevice/heartbeat.h
+++ b/include/libimobiledevice/heartbeat.h
@@ -48,12 +48,84 @@ typedef int16_t heartbeat_error_t;
48typedef struct heartbeat_client_private heartbeat_client_private; 48typedef struct heartbeat_client_private heartbeat_client_private;
49typedef heartbeat_client_private *heartbeat_client_t; /**< The client handle. */ 49typedef heartbeat_client_private *heartbeat_client_t; /**< The client handle. */
50 50
51/**
52 * Connects to the heartbeat service on the specified device.
53 *
54 * @param device The device to connect to.
55 * @param service The service descriptor returned by lockdownd_start_service.
56 * @param client Pointer that will point to a newly allocated
57 * heartbeat_client_t upon successful return. Must be freed using
58 * heartbeat_client_free() after use.
59 *
60 * @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
61 * client is NULL, or an HEARTBEAT_E_* error code otherwise.
62 */
51heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client); 63heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client);
64
65/**
66 * Starts a new heartbeat service on the specified device and connects to it.
67 *
68 * @param device The device to connect to.
69 * @param client Pointer that will point to a newly allocated
70 * heartbeat_client_t upon successful return. Must be freed using
71 * heartbeat_client_free() after use.
72 * @param label The label to use for communication. Usually the program name.
73 * Pass NULL to disable sending the label in requests to lockdownd.
74 *
75 * @return HEARTBEAT_E_SUCCESS on success, or an HEARTBEAT_E_* error
76 * code otherwise.
77 */
52heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label); 78heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label);
79
80/**
81 * Disconnects a heartbeat client from the device and frees up the
82 * heartbeat client data.
83 *
84 * @param client The heartbeat client to disconnect and free.
85 *
86 * @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
87 * client is NULL, or an HEARTBEAT_E_* error code otherwise.
88 */
53heartbeat_error_t heartbeat_client_free(heartbeat_client_t client); 89heartbeat_error_t heartbeat_client_free(heartbeat_client_t client);
54 90
91
92/**
93 * Sends a plist to the service.
94 *
95 * @param client The heartbeat client
96 * @param plist The plist to send
97 *
98 * @return HEARTBEAT_E_SUCCESS on success,
99 * HEARTBEAT_E_INVALID_ARG when client or plist is NULL
100 */
55heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist); 101heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist);
102
103/**
104 * Receives a plist from the service.
105 *
106 * @param client The heartbeat client
107 * @param plist The plist to store the received data
108 *
109 * @return HEARTBEAT_E_SUCCESS on success,
110 * HEARTBEAT_E_INVALID_ARG when client or plist is NULL
111 */
56heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist); 112heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist);
113
114/**
115 * Receives a plist using the given heartbeat client.
116 *
117 * @param client The heartbeat client to use for receiving
118 * @param plist pointer to a plist_t that will point to the received plist
119 * upon successful return
120 * @param timeout Maximum time in milliseconds to wait for data.
121 *
122 * @return HEARTBEAT_E_SUCCESS on success,
123 * HEARTBEAT_E_INVALID_ARG when client or *plist is NULL,
124 * HEARTBEAT_E_PLIST_ERROR when the received data cannot be
125 * converted to a plist, HEARTBEAT_E_MUX_ERROR when a
126 * communication error occurs, or HEARTBEAT_E_UNKNOWN_ERROR
127 * when an unspecified error occurs.
128 */
57heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms); 129heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms);
58 130
59#ifdef __cplusplus 131#ifdef __cplusplus
diff --git a/include/libimobiledevice/house_arrest.h b/include/libimobiledevice/house_arrest.h
index ccd6ac7..170cad2 100644
--- a/include/libimobiledevice/house_arrest.h
+++ b/include/libimobiledevice/house_arrest.h
@@ -51,14 +51,128 @@ typedef struct house_arrest_client_private house_arrest_client_private;
51typedef house_arrest_client_private *house_arrest_client_t; /**< The client handle. */ 51typedef house_arrest_client_private *house_arrest_client_t; /**< The client handle. */
52 52
53/* Interface */ 53/* Interface */
54
55/**
56 * Connects to the house_arrest service on the specified device.
57 *
58 * @param device The device to connect to.
59 * @param service The service descriptor returned by lockdownd_start_service.
60 * @param client Pointer that will point to a newly allocated
61 * housearrest_client_t upon successful return.
62 *
63 * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
64 * client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
65 */
54house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client); 66house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client);
67
68/**
69 * Starts a new house_arrest service on the specified device and connects to it.
70 *
71 * @param device The device to connect to.
72 * @param client Pointer that will point to a newly allocated
73 * house_arrest_client_t upon successful return. Must be freed using
74 * house_arrest_client_free() after use.
75 * @param label The label to use for communication. Usually the program name.
76 * Pass NULL to disable sending the label in requests to lockdownd.
77 *
78 * @return HOUSE_ARREST_E_SUCCESS on success, or an HOUSE_ARREST_E_* error
79 * code otherwise.
80 */
55house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t* client, const char* label); 81house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t* client, const char* label);
82
83/**
84 * Disconnects an house_arrest client from the device and frees up the
85 * house_arrest client data.
86 *
87 * @note After using afc_client_new_from_house_arrest_client(), make sure
88 * you call afc_client_free() before calling this function to ensure
89 * a proper cleanup. Do not call this function if you still need to
90 * perform AFC operations since it will close the connection.
91 *
92 * @param client The house_arrest client to disconnect and free.
93 *
94 * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
95 * client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
96 */
56house_arrest_error_t house_arrest_client_free(house_arrest_client_t client); 97house_arrest_error_t house_arrest_client_free(house_arrest_client_t client);
57 98
99
100/**
101 * Sends a generic request to the connected house_arrest service.
102 *
103 * @param client The house_arrest client to use.
104 * @param dict The request to send as a plist of type PLIST_DICT.
105 *
106 * @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean
107 * that the request was successful. To check for success or failure you
108 * need to call house_arrest_get_result().
109 * @see house_arrest_get_result
110 *
111 * @return HOUSE_ARREST_E_SUCCESS if the request was successfully sent,
112 * HOUSE_ARREST_E_INVALID_ARG if client or dict is invalid,
113 * HOUSE_ARREST_E_PLIST_ERROR if dict is not a plist of type PLIST_DICT,
114 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
115 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
116 */
58house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict); 117house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict);
118
119/**
120 * Send a command to the connected house_arrest service.
121 * Calls house_arrest_send_request() internally.
122 *
123 * @param client The house_arrest client to use.
124 * @param command The command to send. Currently, only VendContainer and
125 * VendDocuments are known.
126 * @param appid The application identifier to pass along with the .
127 *
128 * @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean
129 * that the command was successful. To check for success or failure you
130 * need to call house_arrest_get_result().
131 * @see house_arrest_get_result
132 *
133 * @return HOUSE_ARREST_E_SUCCESS if the command was successfully sent,
134 * HOUSE_ARREST_E_INVALID_ARG if client, command, or appid is invalid,
135 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
136 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
137 */
59house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid); 138house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid);
139
140/**
141 * Retrieves the result of a previously sent house_arrest_request_* request.
142 *
143 * @param client The house_arrest client to use
144 * @param dict Pointer that will be set to a plist containing the result to
145 * the last performed operation. It holds a key 'Status' with the value
146 * 'Complete' on success or a key 'Error' with an error description as
147 * value. The caller is responsible for freeing the returned plist.
148 *
149 * @return HOUSE_ARREST_E_SUCCESS if a result plist was retrieved,
150 * HOUSE_ARREST_E_INVALID_ARG if client is invalid,
151 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
152 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
153 */
60house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict); 154house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict);
61 155
156
157/**
158 * Creates an AFC client using the given house_arrest client's connection
159 * allowing file access to a specific application directory requested by
160 * functions like house_arrest_request_vendor_documents().
161 *
162 * @param client The house_arrest client to use.
163 * @param afc_client Pointer that will be set to a newly allocated afc_client_t
164 * upon successful return.
165 *
166 * @note After calling this function the house_arrest client will go in an
167 * AFC mode that will only allow calling house_arrest_client_free().
168 * Only call house_arrest_client_free() if all AFC operations have
169 * completed since it will close the connection.
170 *
171 * @return AFC_E_SUCCESS if the afc client was successfully created,
172 * AFC_E_INVALID_ARG if client is invalid or was already used to create
173 * an afc client, or an AFC_E_* error code returned by
174 * afc_client_new_with_service_client().
175 */
62afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client); 176afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client);
63 177
64#ifdef __cplusplus 178#ifdef __cplusplus
diff --git a/include/libimobiledevice/installation_proxy.h b/include/libimobiledevice/installation_proxy.h
index 18b7804..4740b20 100644
--- a/include/libimobiledevice/installation_proxy.h
+++ b/include/libimobiledevice/installation_proxy.h
@@ -55,24 +55,271 @@ typedef instproxy_client_private *instproxy_client_t; /**< The client handle. */
55typedef void (*instproxy_status_cb_t) (const char *operation, plist_t status, void *user_data); 55typedef void (*instproxy_status_cb_t) (const char *operation, plist_t status, void *user_data);
56 56
57/* Interface */ 57/* Interface */
58
59/**
60 * Connects to the installation_proxy service on the specified device.
61 *
62 * @param device The device to connect to
63 * @param service The service descriptor returned by lockdownd_start_service.
64 * @param client Pointer that will be set to a newly allocated
65 * instproxy_client_t upon successful return.
66 *
67 * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value
68 * when an error occured.
69 */
58instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client); 70instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client);
71
72/**
73 * Starts a new installation_proxy service on the specified device and connects to it.
74 *
75 * @param device The device to connect to.
76 * @param client Pointer that will point to a newly allocated
77 * instproxy_client_t upon successful return. Must be freed using
78 * instproxy_client_free() after use.
79 * @param label The label to use for communication. Usually the program name.
80 * Pass NULL to disable sending the label in requests to lockdownd.
81 *
82 * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error
83 * code otherwise.
84 */
59instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label); 85instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label);
86
87/**
88 * Disconnects an installation_proxy client from the device and frees up the
89 * installation_proxy client data.
90 *
91 * @param client The installation_proxy client to disconnect and free.
92 *
93 * @return INSTPROXY_E_SUCCESS on success
94 * or INSTPROXY_E_INVALID_ARG if client is NULL.
95 */
60instproxy_error_t instproxy_client_free(instproxy_client_t client); 96instproxy_error_t instproxy_client_free(instproxy_client_t client);
61 97
98
99/**
100 * List installed applications. This function runs synchronously.
101 *
102 * @param client The connected installation_proxy client
103 * @param client_options The client options to use, as PLIST_DICT, or NULL.
104 * Valid client options include:
105 * "ApplicationType" -> "User"
106 * "ApplicationType" -> "System"
107 * @param result Pointer that will be set to a plist that will hold an array
108 * of PLIST_DICT holding information about the applications found.
109 *
110 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
111 * an error occured.
112 */
62instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result); 113instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result);
114
115/**
116 * Install an application on the device.
117 *
118 * @param client The connected installation_proxy client
119 * @param pkg_path Path of the installation package (inside the AFC jail)
120 * @param client_options The client options to use, as PLIST_DICT, or NULL.
121 * Valid options include:
122 * "iTunesMetadata" -> PLIST_DATA
123 * "ApplicationSINF" -> PLIST_DATA
124 * "PackageType" -> "Developer"
125 * If PackageType -> Developer is specified, then pkg_path points to
126 * an .app directory instead of an install package.
127 * @param status_cb Callback function for progress and status information. If
128 * NULL is passed, this function will run synchronously.
129 * @param user_data Callback data passed to status_cb.
130 *
131 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
132 * an error occured.
133 *
134 * @note If a callback function is given (async mode), this function returns
135 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
136 * created successfully; any error occuring during the operation has to be
137 * handled inside the specified callback function.
138 */
63instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); 139instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
140
141/**
142 * Upgrade an application on the device. This function is nearly the same as
143 * instproxy_install; the difference is that the installation progress on the
144 * device is faster if the application is already installed.
145 *
146 * @param client The connected installation_proxy client
147 * @param pkg_path Path of the installation package (inside the AFC jail)
148 * @param client_options The client options to use, as PLIST_DICT, or NULL.
149 * Valid options include:
150 * "iTunesMetadata" -> PLIST_DATA
151 * "ApplicationSINF" -> PLIST_DATA
152 * "PackageType" -> "Developer"
153 * If PackageType -> Developer is specified, then pkg_path points to
154 * an .app directory instead of an install package.
155 * @param status_cb Callback function for progress and status information. If
156 * NULL is passed, this function will run synchronously.
157 * @param user_data Callback data passed to status_cb.
158 *
159 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
160 * an error occured.
161 *
162 * @note If a callback function is given (async mode), this function returns
163 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
164 * created successfully; any error occuring during the operation has to be
165 * handled inside the specified callback function.
166 */
64instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); 167instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
168
169/**
170 * Uninstall an application from the device.
171 *
172 * @param client The connected installation proxy client
173 * @param appid ApplicationIdentifier of the app to uninstall
174 * @param client_options The client options to use, as PLIST_DICT, or NULL.
175 * Currently there are no known client options, so pass NULL here.
176 * @param status_cb Callback function for progress and status information. If
177 * NULL is passed, this function will run synchronously.
178 * @param user_data Callback data passed to status_cb.
179 *
180 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
181 * an error occured.
182 *
183 * @note If a callback function is given (async mode), this function returns
184 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
185 * created successfully; any error occuring during the operation has to be
186 * handled inside the specified callback function.
187 */
65instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); 188instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
66 189
190
191/**
192 * List archived applications. This function runs synchronously.
193 *
194 * @see instproxy_archive
195 *
196 * @param client The connected installation_proxy client
197 * @param client_options The client options to use, as PLIST_DICT, or NULL.
198 * Currently there are no known client options, so pass NULL here.
199 * @param result Pointer that will be set to a plist containing a PLIST_DICT
200 * holding information about the archived applications found.
201 *
202 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
203 * an error occured.
204 */
67instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result); 205instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result);
206
207/**
208 * Archive an application on the device.
209 * This function tells the device to make an archive of the specified
210 * application. This results in the device creating a ZIP archive in the
211 * 'ApplicationArchives' directory and uninstalling the application.
212 *
213 * @param client The connected installation proxy client
214 * @param appid ApplicationIdentifier of the app to archive.
215 * @param client_options The client options to use, as PLIST_DICT, or NULL.
216 * Valid options include:
217 * "SkipUninstall" -> Boolean
218 * "ArchiveType" -> "ApplicationOnly"
219 * @param status_cb Callback function for progress and status information. If
220 * NULL is passed, this function will run synchronously.
221 * @param user_data Callback data passed to status_cb.
222 *
223 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
224 * an error occured.
225 *
226 * @note If a callback function is given (async mode), this function returns
227 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
228 * created successfully; any error occuring during the operation has to be
229 * handled inside the specified callback function.
230 */
68instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); 231instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
232
233/**
234 * Restore a previously archived application on the device.
235 * This function is the counterpart to instproxy_archive.
236 * @see instproxy_archive
237 *
238 * @param client The connected installation proxy client
239 * @param appid ApplicationIdentifier of the app to restore.
240 * @param client_options The client options to use, as PLIST_DICT, or NULL.
241 * Currently there are no known client options, so pass NULL here.
242 * @param status_cb Callback function for progress and status information. If
243 * NULL is passed, this function will run synchronously.
244 * @param user_data Callback data passed to status_cb.
245 *
246 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
247 * an error occured.
248 *
249 * @note If a callback function is given (async mode), this function returns
250 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
251 * created successfully; any error occuring during the operation has to be
252 * handled inside the specified callback function.
253 */
69instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); 254instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
255
256/**
257 * Removes a previously archived application from the device.
258 * This function removes the ZIP archive from the 'ApplicationArchives'
259 * directory.
260 *
261 * @param client The connected installation proxy client
262 * @param appid ApplicationIdentifier of the archived app to remove.
263 * @param client_options The client options to use, as PLIST_DICT, or NULL.
264 * Currently there are no known client options, so passing NULL is fine.
265 * @param status_cb Callback function for progress and status information. If
266 * NULL is passed, this function will run synchronously.
267 * @param user_data Callback data passed to status_cb.
268 *
269 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
270 * an error occured.
271 *
272 * @note If a callback function is given (async mode), this function returns
273 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
274 * created successfully; any error occuring during the operation has to be
275 * handled inside the specified callback function.
276 */
70instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); 277instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
71 278
72/* Helper */ 279/* Helper */
280
281/**
282 * Create a new client_options plist.
283 *
284 * @return A new plist_t of type PLIST_DICT.
285 */
73plist_t instproxy_client_options_new(); 286plist_t instproxy_client_options_new();
287
288/**
289 * Add one or more new key:value pairs to the given client_options.
290 *
291 * @param client_options The client options to modify.
292 * @param ... KEY, VALUE, [KEY, VALUE], NULL
293 *
294 * @note The keys and values passed are expected to be strings, except for the
295 * keys "ApplicationSINF", "iTunesMetadata", "ReturnAttributes" which are
296 * expecting a plist_t node as value and "SkipUninstall" expects int.
297 */
74void instproxy_client_options_add(plist_t client_options, ...); 298void instproxy_client_options_add(plist_t client_options, ...);
299
300/**
301 * Free client_options plist.
302 *
303 * @param client_options The client options plist to free. Does nothing if NULL
304 * is passed.
305 */
75void instproxy_client_options_free(plist_t client_options); 306void instproxy_client_options_free(plist_t client_options);
307
308/**
309 * Query the device for the path of an application.
310 *
311 * @param client The connected installation proxy client.
312 * @param appid ApplicationIdentifier of app to retrieve the path for.
313 * @param path Pointer to store the device path for the application
314 * which is set to NULL if it could not be determined.
315 *
316 * @return INSTPROXY_E_SUCCESS on success, INSTPROXY_E_OP_FAILED if
317 * the path could not be determined or an INSTPROXY_E_* error
318 * value if an error occured.
319 *
320 * @note This implementation browses all applications and matches the
321 * right entry by the application identifier.
322 */
76instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path); 323instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path);
77 324
78#ifdef __cplusplus 325#ifdef __cplusplus
diff --git a/include/libimobiledevice/libimobiledevice.h b/include/libimobiledevice/libimobiledevice.h
index e33715f..3cbb96b 100644
--- a/include/libimobiledevice/libimobiledevice.h
+++ b/include/libimobiledevice/libimobiledevice.h
@@ -75,30 +75,177 @@ typedef struct {
75typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_data); 75typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_data);
76 76
77/* functions */ 77/* functions */
78
79/**
80 * Register a callback function that will be called when device add/remove
81 * events occur.
82 *
83 * @param callback Callback function to call.
84 * @param user_data Application-specific data passed as parameter
85 * to the registered callback function.
86 *
87 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
88 */
78idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data); 89idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data);
90
91/**
92 * Release the event callback function that has been registered with
93 * idevice_event_subscribe().
94 *
95 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
96 */
79idevice_error_t idevice_event_unsubscribe(); 97idevice_error_t idevice_event_unsubscribe();
80 98
81/* discovery (synchronous) */ 99/* discovery (synchronous) */
100
101/**
102 * Get a list of currently available devices.
103 *
104 * @param devices List of udids of devices that are currently available.
105 * This list is terminated by a NULL pointer.
106 * @param count Number of devices found.
107 *
108 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
109 */
82idevice_error_t idevice_get_device_list(char ***devices, int *count); 110idevice_error_t idevice_get_device_list(char ***devices, int *count);
111
112/**
113 * Free a list of device udids.
114 *
115 * @param devices List of udids to free.
116 *
117 * @return Always returnes IDEVICE_E_SUCCESS.
118 */
83idevice_error_t idevice_device_list_free(char **devices); 119idevice_error_t idevice_device_list_free(char **devices);
84 120
85/* device structure creation and destruction */ 121/* device structure creation and destruction */
122
123/**
124 * Creates an idevice_t structure for the device specified by udid,
125 * if the device is available.
126 *
127 * @note The resulting idevice_t structure has to be freed with
128 * idevice_free() if it is no longer used.
129 *
130 * @param device Upon calling this function, a pointer to a location of type
131 * idevice_t. On successful return, this location will be populated.
132 * @param udid The UDID to match.
133 *
134 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
135 */
86idevice_error_t idevice_new(idevice_t *device, const char *udid); 136idevice_error_t idevice_new(idevice_t *device, const char *udid);
137
138/**
139 * Cleans up an idevice structure, then frees the structure itself.
140 * This is a library-level function; deals directly with the device to tear
141 * down relations, but otherwise is mostly internal.
142 *
143 * @param device idevice_t to free.
144 */
87idevice_error_t idevice_free(idevice_t device); 145idevice_error_t idevice_free(idevice_t device);
88 146
89/* connection/disconnection */ 147/* connection/disconnection */
148
149/**
150 * Set up a connection to the given device.
151 *
152 * @param device The device to connect to.
153 * @param port The destination port to connect to.
154 * @param connection Pointer to an idevice_connection_t that will be filled
155 * with the necessary data of the connection.
156 *
157 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
158 */
90idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection); 159idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection);
160
161/**
162 * Disconnect from the device and clean up the connection structure.
163 *
164 * @param connection The connection to close.
165 *
166 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
167 */
91idevice_error_t idevice_disconnect(idevice_connection_t connection); 168idevice_error_t idevice_disconnect(idevice_connection_t connection);
92 169
93/* communication */ 170/* communication */
171
172/**
173 * Send data to a device via the given connection.
174 *
175 * @param connection The connection to send data over.
176 * @param data Buffer with data to send.
177 * @param len Size of the buffer to send.
178 * @param sent_bytes Pointer to an uint32_t that will be filled
179 * with the number of bytes actually sent.
180 *
181 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
182 */
94idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes); 183idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes);
184
185/**
186 * Receive data from a device via the given connection.
187 * This function will return after the given timeout even if no data has been
188 * received.
189 *
190 * @param connection The connection to receive data from.
191 * @param data Buffer that will be filled with the received data.
192 * This buffer has to be large enough to hold len bytes.
193 * @param len Buffer size or number of bytes to receive.
194 * @param recv_bytes Number of bytes actually received.
195 * @param timeout Timeout in milliseconds after which this function should
196 * return even if no data has been received.
197 *
198 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
199 */
95idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout); 200idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout);
201
202/**
203 * Receive data from a device via the given connection.
204 * This function is like idevice_connection_receive_timeout, but with a
205 * predefined reasonable timeout.
206 *
207 * @param connection The connection to receive data from.
208 * @param data Buffer that will be filled with the received data.
209 * This buffer has to be large enough to hold len bytes.
210 * @param len Buffer size or number of bytes to receive.
211 * @param recv_bytes Number of bytes actually received.
212 *
213 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
214 */
96idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes); 215idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes);
216
217/**
218 * Enables SSL for the given connection.
219 *
220 * @param connection The connection to enable SSL for.
221 *
222 * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection
223 * is NULL or connection->ssl_data is non-NULL, or IDEVICE_E_SSL_ERROR when
224 * SSL initialization, setup, or handshake fails.
225 */
97idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection); 226idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection);
227
228/**
229 * Disable SSL for the given connection.
230 *
231 * @param connection The connection to disable SSL for.
232 *
233 * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection
234 * is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not
235 * enabled and does no further error checking on cleanup.
236 */
98idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection); 237idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection);
99 238
100/* misc */ 239/* misc */
240
241/**
242 * Gets the handle of the device. Depends on the connection type.
243 */
101idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle); 244idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle);
245
246/**
247 * Gets the unique id for the device.
248 */
102idevice_error_t idevice_get_udid(idevice_t device, char **udid); 249idevice_error_t idevice_get_udid(idevice_t device, char **udid);
103 250
104#ifdef __cplusplus 251#ifdef __cplusplus
diff --git a/include/libimobiledevice/lockdown.h b/include/libimobiledevice/lockdown.h
index 233c796..d59c489 100644
--- a/include/libimobiledevice/lockdown.h
+++ b/include/libimobiledevice/lockdown.h
@@ -81,33 +81,335 @@ struct lockdownd_service_descriptor {
81typedef struct lockdownd_service_descriptor *lockdownd_service_descriptor_t; 81typedef struct lockdownd_service_descriptor *lockdownd_service_descriptor_t;
82 82
83/* Interface */ 83/* Interface */
84
85/**
86 * Creates a new lockdownd client for the device.
87 *
88 * @note This function does not pair with the device or start a session. This
89 * has to be done manually by the caller after the client is created.
90 * The device disconnects automatically if the lockdown connection idles
91 * for more than 10 seconds. Make sure to call lockdownd_client_free() as soon
92 * as the connection is no longer needed.
93 *
94 * @param device The device to create a lockdownd client for
95 * @param client The pointer to the location of the new lockdownd_client
96 * @param label The label to use for communication. Usually the program name.
97 *
98 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
99 */
84lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label); 100lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label);
101
102/**
103 * Creates a new lockdownd client for the device and starts initial handshake.
104 * The handshake consists out of query_type, validate_pair, pair and
105 * start_session calls. It uses the internal pairing record management.
106 *
107 * @note The device disconnects automatically if the lockdown connection idles
108 * for more than 10 seconds. Make sure to call lockdownd_client_free() as soon
109 * as the connection is no longer needed.
110 *
111 * @param device The device to create a lockdownd client for
112 * @param client The pointer to the location of the new lockdownd_client
113 * @param label The label to use for communication. Usually the program name.
114 * Pass NULL to disable sending the label in requests to lockdownd.
115 *
116 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
117 * LOCKDOWN_E_INVALID_CONF if configuration data is wrong
118 */
85lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label); 119lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label);
120
121/**
122 * Closes the lockdownd client session if one is running and frees up the
123 * lockdownd_client struct.
124 *
125 * @param client The lockdown client
126 *
127 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
128 */
86lockdownd_error_t lockdownd_client_free(lockdownd_client_t client); 129lockdownd_error_t lockdownd_client_free(lockdownd_client_t client);
87 130
131
132/**
133 * Query the type of the service daemon. Depending on whether the device is
134 * queried in normal mode or restore mode, different types will be returned.
135 *
136 * @param client The lockdownd client
137 * @param type The type returned by the service daemon. Pass NULL to ignore.
138 *
139 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
140 */
88lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type); 141lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type);
142
143/**
144 * Retrieves a preferences plist using an optional domain and/or key name.
145 *
146 * @param client An initialized lockdownd client.
147 * @param domain The domain to query on or NULL for global domain
148 * @param key The key name to request or NULL to query for all keys
149 * @param value A plist node representing the result value node
150 *
151 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
152 */
89lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value); 153lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value);
154
155/**
156 * Sets a preferences value using a plist and optional by domain and/or key name.
157 *
158 * @param client an initialized lockdownd client.
159 * @param domain the domain to query on or NULL for global domain
160 * @param key the key name to set the value or NULL to set a value dict plist
161 * @param value a plist node of any node type representing the value to set
162 *
163 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
164 * value is NULL
165 */
90lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value); 166lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value);
167
168/**
169 * Removes a preference node by domain and/or key name.
170 *
171 * @note: Use with caution as this could remove vital information on the device
172 *
173 * @param client An initialized lockdownd client.
174 * @param domain The domain to query on or NULL for global domain
175 * @param key The key name to remove or NULL remove all keys for the current domain
176 *
177 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
178 */
91lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key); 179lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key);
180
181/**
182 * Requests to start a service and retrieve it's port on success.
183 *
184 * @param client The lockdownd client
185 * @param identifier The identifier of the service to start
186 * @param descriptor The service descriptor on success or NULL on failure
187
188 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
189 * is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known
190 * by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not because
191 * started by the device
192 */
92lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service); 193lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service);
194
195/**
196 * Opens a session with lockdownd and switches to SSL mode if device wants it.
197 *
198 * @param client The lockdownd client
199 * @param host_id The HostID of the computer
200 * @param session_id The new session_id of the created session
201 * @param ssl_enabled Whether SSL communication is used in the session
202 *
203 * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when a client
204 * or host_id is NULL, LOCKDOWN_E_PLIST_ERROR if the response plist had errors,
205 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the supplied HostID,
206 * LOCKDOWN_E_SSL_ERROR if enabling SSL communication failed
207 */
93lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled); 208lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled);
209
210/**
211 * Closes the lockdownd session by sending the StopSession request.
212 *
213 * @see lockdownd_start_session
214 *
215 * @param client The lockdown client
216 * @param session_id The id of a running session
217 *
218 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
219 */
94lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id); 220lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id);
221
222/**
223 * Sends a plist to lockdownd.
224 *
225 * @note This function is low-level and should only be used if you need to send
226 * a new type of message.
227 *
228 * @param client The lockdownd client
229 * @param plist The plist to send
230 *
231 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
232 * plist is NULL
233 */
95lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist); 234lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist);
235
236/**
237 * Receives a plist from lockdownd.
238 *
239 * @param client The lockdownd client
240 * @param plist The plist to store the received data
241 *
242 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
243 * plist is NULL
244 */
96lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist); 245lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist);
246
247/**
248 * Pairs the device using the supplied pair record.
249 *
250 * @param client The lockdown client to pair with.
251 * @param pair_record The pair record to use for pairing. If NULL is passed, then
252 * the pair records from the current machine are used. New records will be
253 * generated automatically when pairing is done for the first time.
254 *
255 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
256 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
257 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
258 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
259 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
260 */
97lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); 261lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
262
263/**
264 * Validates if the device is paired with the given HostID. If succeeded them
265 * specified host will become trusted host of the device indicated by the
266 * lockdownd preference named TrustedHostAttached. Otherwise the host must because
267 * paired using lockdownd_pair() first.
268 *
269 * @param client The lockdown client to pair with.
270 * @param pair_record The pair record to validate pairing with. If NULL is
271 * passed, then the pair record is read from the internal pairing record
272 * management.
273 *
274 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
275 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
276 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
277 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
278 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
279 */
98lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); 280lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
281
282/**
283 * Unpairs the device with the given HostID and removes the pairing records
284 * from the device and host if the internal pairing record management is used.
285 *
286 * @param client The lockdown client to pair with.
287 * @param pair_record The pair record to use for unpair. If NULL is passed, then
288 * the pair records from the current machine are used.
289 *
290 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
291 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
292 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
293 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
294 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
295 */
99lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); 296lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
297
298/**
299 * Activates the device. Only works within an open session.
300 * The ActivationRecord plist dictionary must be obtained using the
301 * activation protocol requesting from Apple's https webservice.
302 *
303 * @see http://iphone-docs.org/doku.php?id=docs:protocols:activation
304 *
305 * @param client The lockdown client
306 * @param activation_record The activation record plist dictionary
307 *
308 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
309 * activation_record is NULL, LOCKDOWN_E_NO_RUNNING_SESSION if no session is
310 * open, LOCKDOWN_E_PLIST_ERROR if the received plist is broken,
311 * LOCKDOWN_E_ACTIVATION_FAILED if the activation failed,
312 * LOCKDOWN_E_INVALID_ACTIVATION_RECORD if the device reports that the
313 * activation_record is invalid
314 */
100lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record); 315lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record);
316
317/**
318 * Deactivates the device, returning it to the locked “Activate with iTunes”
319 * screen.
320 *
321 * @param client The lockdown client
322 *
323 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
324 * LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
325 * LOCKDOWN_E_PLIST_ERROR if the received plist is broken
326 */
101lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client); 327lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client);
328
329/**
330 * Tells the device to immediately enter recovery mode.
331 *
332 * @param client The lockdown client
333 *
334 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
335 */
102lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client); 336lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client);
337
338/**
339 * Sends the Goodbye request to lockdownd signaling the end of communication.
340 *
341 * @param client The lockdown client
342 *
343 * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client
344 * is NULL, LOCKDOWN_E_PLIST_ERROR if the device did not acknowledge the
345 * request
346 */
103lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client); 347lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client);
104 348
105/* Helper */ 349/* Helper */
350
351/**
352 * Sets the label to send for requests to lockdownd.
353 *
354 * @param client The lockdown client
355 * @param label The label to set or NULL to disable sending a label
356 *
357 */
106void lockdownd_client_set_label(lockdownd_client_t client, const char *label); 358void lockdownd_client_set_label(lockdownd_client_t client, const char *label);
359
360/**
361 * Returns the unique id of the device from lockdownd.
362 *
363 * @param client An initialized lockdownd client.
364 * @param udid Holds the unique id of the device. The caller is responsible
365 * for freeing the memory.
366 *
367 * @return LOCKDOWN_E_SUCCESS on success
368 */
107lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t control, char **udid); 369lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t control, char **udid);
370
371/**
372 * Retrieves the name of the device from lockdownd set by the user.
373 *
374 * @param client An initialized lockdownd client.
375 * @param device_name Holds the name of the device. The caller is
376 * responsible for freeing the memory.
377 *
378 * @return LOCKDOWN_E_SUCCESS on success
379 */
108lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name); 380lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name);
381
382/**
383 * Calculates and returns the data classes the device supports from lockdownd.
384 *
385 * @param client An initialized lockdownd client.
386 * @param classes A pointer to store an array of class names. The caller is responsible
387 * for freeing the memory which can be done using mobilesync_data_classes_free().
388 * @param count The number of items in the classes array.
389 *
390 * @return LOCKDOWN_E_SUCCESS on success,
391 * LOCKDOWN_E_INVALID_ARG when client is NULL,
392 * LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
393 * LOCKDOWN_E_PLIST_ERROR if the received plist is broken
394 */
109lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count); 395lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count);
396
397/**
398 * Frees memory of an allocated array of data classes as returned by lockdownd_get_sync_data_classes()
399 *
400 * @param classes An array of class names to free.
401 *
402 * @return LOCKDOWN_E_SUCCESS on success
403 */
110lockdownd_error_t lockdownd_data_classes_free(char **classes); 404lockdownd_error_t lockdownd_data_classes_free(char **classes);
405
406/**
407 * Frees memory of a service descriptor as returned by lockdownd_start_service()
408 *
409 * @param sevice A service descriptor instance to free.
410 *
411 * @return LOCKDOWN_E_SUCCESS on success
412 */
111lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service); 413lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service);
112 414
113#ifdef __cplusplus 415#ifdef __cplusplus
diff --git a/include/libimobiledevice/misagent.h b/include/libimobiledevice/misagent.h
index fe0acb2..7bb7333 100644
--- a/include/libimobiledevice/misagent.h
+++ b/include/libimobiledevice/misagent.h
@@ -50,13 +50,95 @@ typedef struct misagent_client_private misagent_client_private;
50typedef misagent_client_private *misagent_client_t; /**< The client handle. */ 50typedef misagent_client_private *misagent_client_t; /**< The client handle. */
51 51
52/* Interface */ 52/* Interface */
53
54/**
55 * Connects to the misagent service on the specified device.
56 *
57 * @param device The device to connect to.
58 * @param service The service descriptor returned by lockdownd_start_service.
59 * @param client Pointer that will point to a newly allocated
60 * misagent_client_t upon successful return.
61 *
62 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
63 * client is NULL, or an MISAGENT_E_* error code otherwise.
64 */
53misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client); 65misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client);
66
67/**
68 * Starts a new misagent service on the specified device and connects to it.
69 *
70 * @param device The device to connect to.
71 * @param client Pointer that will point to a newly allocated
72 * misagent_client_t upon successful return. Must be freed using
73 * misagent_client_free() after use.
74 * @param label The label to use for communication. Usually the program name.
75 * Pass NULL to disable sending the label in requests to lockdownd.
76 *
77 * @return MISAGENT_E_SUCCESS on success, or an MISAGENT_E_* error
78 * code otherwise.
79 */
54misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t* client, const char* label); 80misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t* client, const char* label);
81
82/**
83 * Disconnects an misagent client from the device and frees up the
84 * misagent client data.
85 *
86 * @param client The misagent client to disconnect and free.
87 *
88 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
89 * client is NULL, or an MISAGENT_E_* error code otherwise.
90 */
55misagent_error_t misagent_client_free(misagent_client_t client); 91misagent_error_t misagent_client_free(misagent_client_t client);
56 92
93
94/**
95 * Installs the given provisioning profile. Only works with valid profiles.
96 *
97 * @param client The connected misagent to use for installation
98 * @param profile The valid provisioning profile to install. This has to be
99 * passed as a PLIST_DATA, otherwise the function will fail.
100 *
101 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
102 * client is invalid, or an MISAGENT_E_* error code otherwise.
103 */
57misagent_error_t misagent_install(misagent_client_t client, plist_t profile); 104misagent_error_t misagent_install(misagent_client_t client, plist_t profile);
105
106/**
107 * Retrieves an array of all installed provisioning profiles.
108 *
109 * @param client The connected misagent to use.
110 * @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY
111 * if the function is successful.
112 *
113 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
114 * client is invalid, or an MISAGENT_E_* error code otherwise.
115 *
116 * @note If no provisioning profiles are installed on the device, this function
117 * still returns MISAGENT_E_SUCCESS and profiles will just point to an
118 * empty array.
119 */
58misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles); 120misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles);
121
122/**
123 * Removes a given provisioning profile.
124 *
125 * @param client The connected misagent to use.
126 * @param profileID Identifier of the provisioning profile to remove.
127 * This is a UUID that can be obtained from the provisioning profile data.
128 * @see misagent_copy
129 *
130 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
131 * client is invalid, or an MISAGENT_E_* error code otherwise.
132 */
59misagent_error_t misagent_remove(misagent_client_t client, const char* profileID); 133misagent_error_t misagent_remove(misagent_client_t client, const char* profileID);
134
135/**
136 * Retrieves the status code from the last operation.
137 *
138 * @param client The misagent to use.
139 *
140 * @return -1 if client is invalid, or the status code from the last operation
141 */
60int misagent_get_status_code(misagent_client_t client); 142int misagent_get_status_code(misagent_client_t client);
61 143
62#ifdef __cplusplus 144#ifdef __cplusplus
diff --git a/include/libimobiledevice/mobile_image_mounter.h b/include/libimobiledevice/mobile_image_mounter.h
index 560fec6..569b288 100644
--- a/include/libimobiledevice/mobile_image_mounter.h
+++ b/include/libimobiledevice/mobile_image_mounter.h
@@ -53,13 +53,113 @@ typedef mobile_image_mounter_client_private *mobile_image_mounter_client_t; /**<
53typedef ssize_t (*mobile_image_mounter_upload_cb_t) (void* buffer, size_t length, void *user_data); 53typedef ssize_t (*mobile_image_mounter_upload_cb_t) (void* buffer, size_t length, void *user_data);
54 54
55/* Interface */ 55/* Interface */
56
57/**
58 * Connects to the mobile_image_mounter service on the specified device.
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 * mobile_image_mounter_client_t upon successful return.
64 *
65 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
66 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if device is NULL,
67 * or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the
68 * device could not be established.
69 */
56mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client); 70mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client);
71
72/**
73 * Starts a new mobile_image_mounter service on the specified device and connects to it.
74 *
75 * @param device The device to connect to.
76 * @param client Pointer that will point to a newly allocated
77 * mobile_image_mounter_t upon successful return. Must be freed using
78 * mobile_image_mounter_free() after use.
79 * @param label The label to use for communication. Usually the program name.
80 * Pass NULL to disable sending the label in requests to lockdownd.
81 *
82 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an MOBILE_IMAGE_MOUNTER_E_* error
83 * code otherwise.
84 */
57mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t* client, const char* label); 85mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t* client, const char* label);
86
87/**
88 * Disconnects a mobile_image_mounter client from the device and frees up the
89 * mobile_image_mounter client data.
90 *
91 * @param client The mobile_image_mounter client to disconnect and free.
92 *
93 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
94 * or MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is NULL.
95 */
58mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client); 96mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client);
59 97
98
99/**
100 * Tells if the image of ImageType is already mounted.
101 *
102 * @param client The client use
103 * @param image_type The type of the image to look up
104 * @param result Pointer to a plist that will receive the result of the
105 * operation.
106 *
107 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
108 * operation has failed. Check the resulting plist for further information.
109 *
110 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an error code on error
111 */
60mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result); 112mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result);
113
114/**
115 * Uploads an image to the device.
116 *
117 * @param client The connected mobile_image_mounter client.
118 * @param image_type Type of image that is being uploaded.
119 * @param image_size Total size of the image.
120 * @param upload_cb Callback function that gets the data chunks for uploading
121 * the image.
122 * @param userdata User defined data for the upload callback function.
123 *
124 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a
125 * MOBILE_IMAGE_MOUNTER_E_* error code otherwise.
126 */
61mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata); 127mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata);
128
129/**
130 * Mounts an image on the device.
131 *
132 * @param client The connected mobile_image_mounter client.
133 * @param image_path The absolute path of the image to mount. The image must
134 * be present before calling this function.
135 * @param image_signature Pointer to a buffer holding the images' signature
136 * @param signature_length Length of the signature image_signature points to
137 * @param image_type Type of image to mount
138 * @param result Pointer to a plist that will receive the result of the
139 * operation.
140 *
141 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
142 * operation has failed. Check the resulting plist for further information.
143 * Note that there is no unmounting function. The mount persists until the
144 * device is rebooted.
145 *
146 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
147 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are
148 * invalid, or another error code otherwise.
149 */
62mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result); 150mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result);
151
152/**
153 * Hangs up the connection to the mobile_image_mounter service.
154 * This functions has to be called before freeing up a mobile_image_mounter
155 * instance. If not, errors appear in the device's syslog.
156 *
157 * @param client The client to hang up
158 *
159 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
160 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is invalid,
161 * or another error code otherwise.
162 */
63mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client); 163mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client);
64 164
65#ifdef __cplusplus 165#ifdef __cplusplus
diff --git a/include/libimobiledevice/mobilebackup.h b/include/libimobiledevice/mobilebackup.h
index c62e99e..c07ba68 100644
--- a/include/libimobiledevice/mobilebackup.h
+++ b/include/libimobiledevice/mobilebackup.h
@@ -56,18 +56,187 @@ typedef enum {
56 MB_RESTORE_PRESERVE_CAMERA_ROLL = 1 << 2 56 MB_RESTORE_PRESERVE_CAMERA_ROLL = 1 << 2
57} mobilebackup_flags_t; 57} mobilebackup_flags_t;
58 58
59
60/**
61 * Connects to the mobilebackup service on the specified device.
62 *
63 * @param device The device to connect to.
64 * @param service The service descriptor returned by lockdownd_start_service.
65 * @param client Pointer that will be set to a newly allocated
66 * mobilebackup_client_t upon successful return.
67 *
68 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID ARG if one
69 * or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if
70 * the mobilebackup version on the device is newer.
71 */
59mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client); 72mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client);
73
74/**
75 * Starts a new mobilebackup service on the specified device and connects to it.
76 *
77 * @param device The device to connect to.
78 * @param client Pointer that will point to a newly allocated
79 * mobilebackup_client_t upon successful return. Must be freed using
80 * mobilebackup_client_free() after use.
81 * @param label The label to use for communication. Usually the program name.
82 * Pass NULL to disable sending the label in requests to lockdownd.
83 *
84 * @return MOBILEBACKUP_E_SUCCESS on success, or an MOBILEBACKUP_E_* error
85 * code otherwise.
86 */
60mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t* client, const char* label); 87mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t* client, const char* label);
88
89/**
90 * Disconnects a mobilebackup client from the device and frees up the
91 * mobilebackup client data.
92 *
93 * @param client The mobilebackup client to disconnect and free.
94 *
95 * @return MOBILEBACKUP_E_SUCCESS on success, or MOBILEBACKUP_E_INVALID_ARG
96 * if client is NULL.
97 */
61mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client); 98mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client);
62 99
100
101/**
102 * Polls the device for mobilebackup data.
103 *
104 * @param client The mobilebackup client
105 * @param plist A pointer to the location where the plist should be stored
106 *
107 * @return an error code
108 */
63mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t *plist); 109mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t *plist);
110
111/**
112 * Sends mobilebackup data to the device
113 *
114 * @note This function is low-level and should only be used if you need to send
115 * a new type of message.
116 *
117 * @param client The mobilebackup client
118 * @param plist The location of the plist to send
119 *
120 * @return an error code
121 */
64mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist); 122mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist);
123
124/**
125 * Request a backup from the connected device.
126 *
127 * @param client The connected MobileBackup client to use.
128 * @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
129 * containing the backup state of the last backup. For a first-time backup
130 * set this parameter to NULL.
131 * @param base_path The base path on the device to use for the backup
132 * operation, usually "/".
133 * @param proto_version A string denoting the version of the backup protocol
134 * to use. Latest known version is "1.6"
135 *
136 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
137 * one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
138 * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
139 * if a communication error occurs, MOBILEBACKUP_E_REPLY_NOT_OK
140 */
65mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version); 141mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version);
142
143/**
144 * Sends a confirmation to the device that a backup file has been received.
145 *
146 * @param client The connected MobileBackup client to use.
147 *
148 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
149 * client is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication error
150 * occurs.
151 */
66mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client); 152mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client);
153
154/**
155 * Request that a backup should be restored to the connected device.
156 *
157 * @param client The connected MobileBackup client to use.
158 * @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
159 * containing the backup state to be restored.
160 * @param flags Flags to send with the request. Currently this is a combination
161 * of the following mobilebackup_flags_t:
162 * MB_RESTORE_NOTIFY_SPRINGBOARD - let SpringBoard show a 'Restore' screen
163 * MB_RESTORE_PRESERVE_SETTINGS - do not overwrite any settings
164 * MB_RESTORE_PRESERVE_CAMERA_ROLL - preserve the photos of the camera roll
165 * @param proto_version A string denoting the version of the backup protocol
166 * to use. Latest known version is "1.6". Ideally this value should be
167 * extracted from the given manifest plist.
168 *
169 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
170 * one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
171 * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
172 * if a communication error occurs, or MOBILEBACKUP_E_REPLY_NOT_OK
173 * if the device did not accept the request.
174 */
67mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version); 175mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version);
176
177/**
178 * Receive a confirmation from the device that it successfully received
179 * a restore file.
180 *
181 * @param client The connected MobileBackup client to use.
182 * @param result Pointer to a plist_t that will be set to the received plist
183 * for further processing. The caller has to free it using plist_free().
184 * Note that it will be set to NULL if the operation itself fails due to
185 * a communication or plist error.
186 * If this parameter is NULL, it will be ignored.
187 *
188 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
189 * client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
190 * 'BackupMessageRestoreFileReceived' message could not be received,
191 * MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
192 * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
193 * occurs.
194 */
68mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result); 195mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result);
196
197/**
198 * Receive a confirmation from the device that it successfully received
199 * application data file.
200 *
201 * @param client The connected MobileBackup client to use.
202 * @param result Pointer to a plist_t that will be set to the received plist
203 * for further processing. The caller has to free it using plist_free().
204 * Note that it will be set to NULL if the operation itself fails due to
205 * a communication or plist error.
206 * If this parameter is NULL, it will be ignored.
207 *
208 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
209 * client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
210 * 'BackupMessageRestoreApplicationReceived' message could not be received,
211 * MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
212 * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
213 * occurs.
214 */
69mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result); 215mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result);
216
217/**
218 * Tells the device that the restore process is complete and waits for the
219 * device to close the connection. After that, the device should reboot.
220 *
221 * @param client The connected MobileBackup client to use.
222 *
223 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
224 * client is invalid, MOBILEBACKUP_E_PLIST_ERROR if the received disconnect
225 * message plist is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication
226 * error occurs.
227 */
70mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client); 228mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client);
229
230/**
231 * Sends a backup error message to the device.
232 *
233 * @param client The connected MobileBackup client to use.
234 * @param reason A string describing the reason for the error message.
235 *
236 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
237 * one of the parameters is invalid, or MOBILEBACKUP_E_MUX_ERROR if a
238 * communication error occurs.
239 */
71mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason); 240mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason);
72 241
73#ifdef __cplusplus 242#ifdef __cplusplus
diff --git a/include/libimobiledevice/mobilebackup2.h b/include/libimobiledevice/mobilebackup2.h
index 65bbfc7..ad1dcea 100644
--- a/include/libimobiledevice/mobilebackup2.h
+++ b/include/libimobiledevice/mobilebackup2.h
@@ -51,16 +51,160 @@ typedef int16_t mobilebackup2_error_t;
51typedef struct mobilebackup2_client_private mobilebackup2_client_private; 51typedef struct mobilebackup2_client_private mobilebackup2_client_private;
52typedef mobilebackup2_client_private *mobilebackup2_client_t; /**< The client handle. */ 52typedef mobilebackup2_client_private *mobilebackup2_client_t; /**< The client handle. */
53 53
54
55/**
56 * Connects to the mobilebackup2 service on the specified device.
57 *
58 * @param device The device to connect to.
59 * @param service The service descriptor returned by lockdownd_start_service.
60 * @param client Pointer that will be set to a newly allocated
61 * mobilebackup2_client_t upon successful return.
62 *
63 * @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID ARG
64 * if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION
65 * if the mobilebackup2 version on the device is newer.
66 */
54mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup2_client_t * client); 67mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup2_client_t * client);
68
69/**
70 * Starts a new mobilebackup2 service on the specified device and connects to it.
71 *
72 * @param device The device to connect to.
73 * @param client Pointer that will point to a newly allocated
74 * mobilebackup2_client_t upon successful return. Must be freed using
75 * mobilebackup2_client_free() after use.
76 * @param label The label to use for communication. Usually the program name.
77 * Pass NULL to disable sending the label in requests to lockdownd.
78 *
79 * @return MOBILEBACKUP2_E_SUCCESS on success, or an MOBILEBACKUP2_E_* error
80 * code otherwise.
81 */
55mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t* client, const char* label); 82mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t* client, const char* label);
83
84/**
85 * Disconnects a mobilebackup2 client from the device and frees up the
86 * mobilebackup2 client data.
87 *
88 * @param client The mobilebackup2 client to disconnect and free.
89 *
90 * @return MOBILEBACKUP2_E_SUCCESS on success, or MOBILEBACKUP2_E_INVALID_ARG
91 * if client is NULL.
92 */
56mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client); 93mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client);
57 94
95
96/**
97 * Sends a backup message plist.
98 *
99 * @param client The connected MobileBackup client to use.
100 * @param message The message to send. This will be inserted into the request
101 * plist as value for MessageName. If this parameter is NULL,
102 * the plist passed in the options parameter will be sent directly.
103 * @param options Additional options as PLIST_DICT to add to the request.
104 * The MessageName key with the value passed in the message parameter
105 * will be inserted into this plist before sending it. This parameter
106 * can be NULL if message is not NULL.
107 */
58mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options); 108mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options);
109
110/**
111 * Receives a DL* message plist from the device.
112 * This function is a wrapper around device_link_service_receive_message.
113 *
114 * @param client The connected MobileBackup client to use.
115 * @param msg_plist Pointer to a plist that will be set to the contents of the
116 * message plist upon successful return.
117 * @param dlmessage A pointer that will be set to a newly allocated char*
118 * containing the DL* string from the given plist. It is up to the caller
119 * to free the allocated memory. If this parameter is NULL
120 * it will be ignored.
121 *
122 * @return MOBILEBACKUP2_E_SUCCESS if a DL* message was received,
123 * MOBILEBACKUP2_E_INVALID_ARG if client or message is invalid,
124 * MOBILEBACKUP2_E_PLIST_ERROR if the received plist is invalid
125 * or is not a DL* message plist, or MOBILEBACKUP2_E_MUX_ERROR if
126 * receiving from the device failed.
127 */
59mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage); 128mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage);
129
130/**
131 * Send binary data to the device.
132 *
133 * @note This function returns MOBILEBACKUP2_E_SUCCESS even if less than the
134 * requested length has been sent. The fourth parameter is required and
135 * must be checked to ensure if the whole data has been sent.
136 *
137 * @param client The MobileBackup client to send to.
138 * @param data Pointer to the data to send
139 * @param length Number of bytes to send
140 * @param bytes Number of bytes actually sent
141 *
142 * @return MOBILEBACKUP2_E_SUCCESS if any data was successfully sent,
143 * MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
144 * or MOBILEBACKUP2_E_MUX_ERROR if sending of the data failed.
145 */
60mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes); 146mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes);
147
148/**
149 * Receive binary from the device.
150 *
151 * @note This function returns MOBILEBACKUP2_E_SUCCESS even if no data
152 * has been received (unless a communication error occured).
153 * The fourth parameter is required and must be checked to know how
154 * many bytes were actually received.
155 *
156 * @param client The MobileBackup client to receive from.
157 * @param data Pointer to a buffer that will be filled with the received data.
158 * @param length Number of bytes to receive. The data buffer needs to be large
159 * enough to store this amount of data.
160 * @paran bytes Number of bytes actually received.
161 *
162 * @return MOBILEBACKUP2_E_SUCCESS if any or no data was received,
163 * MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
164 * or MOBILEBACKUP2_E_MUX_ERROR if receiving the data failed.
165 */
61mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes); 166mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes);
167
168/**
169 * Performs the mobilebackup2 protocol version exchange.
170 *
171 * @param client The MobileBackup client to use.
172 * @param local_versions An array of supported versions to send to the remote.
173 * @param count The number of items in local_versions.
174 * @param remote_version Holds the protocol version of the remote on success.
175 *
176 * @return MOBILEBACKUP2_E_SUCCESS on success, or a MOBILEBACKUP2_E_* error
177 * code otherwise.
178 */
62mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version); 179mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version);
180
181/**
182 * Send a request to the connected mobilebackup2 service.
183 *
184 * @param client
185 * @param request The request to send to the backup service.
186 * Currently, this is one of "Backup", "Restore", "Info", or "List".
187 * @param target_identifier UDID of the target device.
188 * @param source_identifier UDID of backup data?
189 * @param options Additional options in a plist of type PLIST_DICT.
190 *
191 * @return MOBILEBACKUP2_E_SUCCESS if the request was successfully sent,
192 * or a MOBILEBACKUP2_E_* error value otherwise.
193 */
63mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options); 194mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options);
195
196/**
197 * Sends a DLMessageStatusResponse to the device.
198 *
199 * @param client The MobileBackup client to use.
200 * @param status_code The status code to send.
201 * @param status1 A status message to send. Can be NULL if not required.
202 * @param status2 An additional status plist to attach to the response.
203 * Can be NULL if not required.
204 *
205 * @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID_ARG
206 * if client is invalid, or another MOBILEBACKUP2_E_* otherwise.
207 */
64mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2); 208mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2);
65 209
66#ifdef __cplusplus 210#ifdef __cplusplus
diff --git a/include/libimobiledevice/mobilesync.h b/include/libimobiledevice/mobilesync.h
index 8e263ce..6ba197b 100644
--- a/include/libimobiledevice/mobilesync.h
+++ b/include/libimobiledevice/mobilesync.h
@@ -68,35 +68,284 @@ typedef struct {
68typedef mobilesync_anchors *mobilesync_anchors_t; /**< Anchors used by the device and computer. */ 68typedef mobilesync_anchors *mobilesync_anchors_t; /**< Anchors used by the device and computer. */
69 69
70/* Interface */ 70/* Interface */
71
72/**
73 * Connects to the mobilesync service on the specified device.
74 *
75 * @param device The device to connect to.
76 * @param service The service descriptor returned by lockdownd_start_service.
77 * @param client Pointer that will be set to a newly allocated
78 * #mobilesync_client_t upon successful return.
79 *
80 * @retval MOBILESYNC_E_SUCCESS on success
81 * @retval MOBILESYNC_E_INVALID_ARG if one or more parameters are invalid
82 * @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on
83 * the device is newer.
84 */
71mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client); 85mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client);
86
87/**
88 * Starts a new mobilesync service on the specified device and connects to it.
89 *
90 * @param device The device to connect to.
91 * @param client Pointer that will point to a newly allocated
92 * mobilesync_client_t upon successful return. Must be freed using
93 * mobilesync_client_free() after use.
94 * @param label The label to use for communication. Usually the program name.
95 * Pass NULL to disable sending the label in requests to lockdownd.
96 *
97 * @return MOBILESYNC_E_SUCCESS on success, or an MOBILESYNC_E_* error
98 * code otherwise.
99 */
72mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label); 100mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label);
101
102/**
103 * Disconnects a mobilesync client from the device and frees up the
104 * mobilesync client data.
105 *
106 * @param client The mobilesync client to disconnect and free.
107 *
108 * @retval MOBILESYNC_E_SUCCESS on success
109 * @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL.
110 */
73mobilesync_error_t mobilesync_client_free(mobilesync_client_t client); 111mobilesync_error_t mobilesync_client_free(mobilesync_client_t client);
74 112
113
114/**
115 * Polls the device for mobilesync data.
116 *
117 * @param client The mobilesync client
118 * @param plist A pointer to the location where the plist should be stored
119 *
120 * @return an error code
121 */
75mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist); 122mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist);
123
124/**
125 * Sends mobilesync data to the device
126 *
127 * @note This function is low-level and should only be used if you need to send
128 * a new type of message.
129 *
130 * @param client The mobilesync client
131 * @param plist The location of the plist to send
132 *
133 * @return an error code
134 */
76mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist); 135mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist);
77 136
137
138/**
139 * Requests starting synchronization of a data class with the device
140 *
141 * @param client The mobilesync client
142 * @param data_class The data class identifier to sync
143 * @param anchors The anchors required to exchange with the device. The anchors
144 * allow the device to tell if the synchronization information on the computer
145 * and device are consistent to determine what sync type is required.
146 * @param computer_data_class_version The version of the data class storage on the computer
147 * @param sync_type A pointer to store the sync type reported by the device_anchor
148 * @param device_data_class_version The version of the data class storage on the device
149 * @param error_description A pointer to store an error message if reported by the device
150 *
151 * @retval MOBILESYNC_E_SUCCESS on success
152 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
153 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
154 * @retval MOBILESYNC_E_SYNC_REFUSED if the device refused to sync
155 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
156 * sync request
157 */
78mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description); 158mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description);
159
160/**
161 * Cancels a running synchronization session with a device at any time.
162 *
163 * @param client The mobilesync client
164 * @param reason The reason to supply to the device for cancelling
165 *
166 * @retval MOBILESYNC_E_SUCCESS on success
167 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
168 */
79mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason); 169mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason);
170
171/**
172 * Finish a synchronization session of a data class on the device.
173 * A session must have previously been started using mobilesync_start().
174 *
175 * @param client The mobilesync client
176 *
177 * @retval MOBILESYNC_E_SUCCESS on success
178 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
179 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
180 * form
181 */
80mobilesync_error_t mobilesync_finish(mobilesync_client_t client); 182mobilesync_error_t mobilesync_finish(mobilesync_client_t client);
81 183
184
185/**
186 * Requests to receive all records of the currently set data class from the device.
187 * The actually changes are retrieved using mobilesync_receive_changes() after this
188 * request has been successful.
189 *
190 * @param client The mobilesync client
191 *
192 * @retval MOBILESYNC_E_SUCCESS on success
193 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
194 */
82mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client); 195mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client);
196
197/**
198 * Requests to receive only changed records of the currently set data class from the device.
199 * The actually changes are retrieved using mobilesync_receive_changes() after this
200 * request has been successful.
201 *
202 * @param client The mobilesync client
203 *
204 * @retval MOBILESYNC_E_SUCCESS on success
205 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
206 */
83mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client); 207mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client);
208
209/**
210 * Requests the device to delete all records of the current data class
211 *
212 * @note The operation must be called after starting synchronization.
213 *
214 * @param client The mobilesync client
215 *
216 * @retval MOBILESYNC_E_SUCCESS on success
217 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
218 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
219 */
84mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client); 220mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client);
85 221
222
223/**
224 * Receives changed entitites of the currently set data class from the device
225 *
226 * @param client The mobilesync client
227 * @param entities A pointer to store the changed entity records as a PLIST_DICT
228 * @param is_last_record A pointer to store a flag indicating if this submission is the last one
229 * @param actions A pointer to additional flags the device is sending or NULL to ignore
230 *
231 * @retval MOBILESYNC_E_SUCCESS on success
232 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
233 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
234 * session
235 */
86mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions); 236mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions);
237
238/**
239 * Acknowledges to the device that the changes have been merged on the computer
240 *
241 * @param client The mobilesync client
242 *
243 * @retval MOBILESYNC_E_SUCCESS on success
244 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
245 */
87mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client); 246mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client);
88 247
248
249/**
250 * Verifies if the device is ready to receive changes from the computer.
251 * This call changes the synchronization direction so that mobilesync_send_changes()
252 * can be used to send changes to the device.
253 *
254 * @param client The mobilesync client
255 *
256 * @retval MOBILESYNC_E_SUCCESS on success
257 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
258 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
259 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
260 * not permit this call
261 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
262 * session
263 * @retval MOBILESYNC_E_NOT_READY if the device is not ready to start
264 * receiving any changes
265 */
89mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client); 266mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client);
90 267
268
269/**
270 * Sends changed entities of the currently set data class to the device
271 *
272 * @param client The mobilesync client
273 * @param entities The changed entity records as a PLIST_DICT
274 * @param is_last_record A flag indicating if this submission is the last one
275 * @param actions Additional actions for the device created with mobilesync_actions_new()
276 * or NULL if no actions should be passed
277 *
278 * @retval MOBILESYNC_E_SUCCESS on success
279 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid,
280 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
281 * not permit this call
282 */
91mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions); 283mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions);
284
285/**
286 * Receives any remapped identifiers reported after the device merged submitted changes.
287 *
288 * @param client The mobilesync client
289 * @param mapping A pointer to an array plist containing a dict of identifier remappings
290 *
291 * @retval MOBILESYNC_E_SUCCESS on success
292 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
293 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
294 * form
295 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
296 * not permit this call
297 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
298 * session
299 */
92mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping); 300mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping);
93 301
94/* Helper */ 302/* Helper */
303
304/**
305 * Allocates memory for a new anchors struct initialized with the passed anchors.
306 *
307 * @param device_anchor An anchor the device reported the last time or NULL
308 * if none is known yet which for instance is true on first synchronization.
309 * @param computer_anchor An arbitrary string to use as anchor for the computer.
310 *
311 * @return A new #mobilesync_anchors_t struct. Must be freed using mobilesync_anchors_free().
312 */
95mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor); 313mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor);
314
315/**
316 * Free memory used by anchors.
317 *
318 * @param anchors The anchors to free.
319 */
96void mobilesync_anchors_free(mobilesync_anchors_t anchors); 320void mobilesync_anchors_free(mobilesync_anchors_t anchors);
97 321
322
323/**
324 * Create a new actions plist to use in mobilesync_send_changes().
325 *
326 * @return A new plist_t of type PLIST_DICT.
327 */
98plist_t mobilesync_actions_new(); 328plist_t mobilesync_actions_new();
329
330/**
331 * Add one or more new key:value pairs to the given actions plist.
332 *
333 * @param actions The actions to modify.
334 * @param ... KEY, VALUE, [KEY, VALUE], NULL
335 *
336 * @note The known keys so far are "SyncDeviceLinkEntityNamesKey" which expects
337 * an array of entity names, followed by a count paramter as well as
338 * "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey" which expects an
339 * integer to use as a boolean value indicating that the device should
340 * link submitted changes and report remapped identifiers.
341 */
99void mobilesync_actions_add(plist_t actions, ...); 342void mobilesync_actions_add(plist_t actions, ...);
343
344/**
345 * Free actions plist.
346 *
347 * @param actions The actions plist to free. Does nothing if NULL is passed.
348 */
100void mobilesync_actions_free(plist_t actions); 349void mobilesync_actions_free(plist_t actions);
101 350
102#ifdef __cplusplus 351#ifdef __cplusplus
diff --git a/include/libimobiledevice/notification_proxy.h b/include/libimobiledevice/notification_proxy.h
index 4f025ee..a66057b 100644
--- a/include/libimobiledevice/notification_proxy.h
+++ b/include/libimobiledevice/notification_proxy.h
@@ -93,13 +93,103 @@ typedef np_client_private *np_client_t; /**< The client handle. */
93typedef void (*np_notify_cb_t) (const char *notification, void *user_data); 93typedef void (*np_notify_cb_t) (const char *notification, void *user_data);
94 94
95/* Interface */ 95/* Interface */
96
97/**
98 * Connects to the notification_proxy on the specified device.
99 *
100 * @param device The device to connect to.
101 * @param service The service descriptor returned by lockdownd_start_service.
102 * @param client Pointer that will be set to a newly allocated np_client_t
103 * upon successful return.
104 *
105 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when device is NULL,
106 * or NP_E_CONN_FAILED when the connection to the device could not be
107 * established.
108 */
96np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client); 109np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client);
110
111/**
112 * Starts a new notification proxy service on the specified device and connects to it.
113 *
114 * @param device The device to connect to.
115 * @param client Pointer that will point to a newly allocated
116 * np_client_t upon successful return. Must be freed using
117 * np_client_free() after use.
118 * @param label The label to use for communication. Usually the program name.
119 * Pass NULL to disable sending the label in requests to lockdownd.
120 *
121 * @return NP_E_SUCCESS on success, or an NP_E_* error
122 * code otherwise.
123 */
97np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label); 124np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label);
125
126/**
127 * Disconnects a notification_proxy client from the device and frees up the
128 * notification_proxy client data.
129 *
130 * @param client The notification_proxy client to disconnect and free.
131 *
132 * @return NP_E_SUCCESS on success, or NP_E_INVALID_ARG when client is NULL.
133 */
98np_error_t np_client_free(np_client_t client); 134np_error_t np_client_free(np_client_t client);
99 135
136
137/**
138 * Sends a notification to the device's notification_proxy.
139 *
140 * @param client The client to send to
141 * @param notification The notification message to send
142 *
143 * @return NP_E_SUCCESS on success, or an error returned by np_plist_send
144 */
100np_error_t np_post_notification(np_client_t client, const char *notification); 145np_error_t np_post_notification(np_client_t client, const char *notification);
146
147/**
148 * Tells the device to send a notification on the specified event.
149 *
150 * @param client The client to send to
151 * @param notification The notifications that should be observed.
152 *
153 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or
154 * notification are NULL, or an error returned by np_plist_send.
155 */
101np_error_t np_observe_notification(np_client_t client, const char *notification); 156np_error_t np_observe_notification(np_client_t client, const char *notification);
157
158/**
159 * Tells the device to send a notification on specified events.
160 *
161 * @param client The client to send to
162 * @param notification_spec Specification of the notifications that should be
163 * observed. This is expected to be an array of const char* that MUST have a
164 * terminating NULL entry.
165 *
166 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client is null,
167 * or an error returned by np_observe_notification.
168 */
102np_error_t np_observe_notifications(np_client_t client, const char **notification_spec); 169np_error_t np_observe_notifications(np_client_t client, const char **notification_spec);
170
171/**
172 * This function allows an application to define a callback function that will
173 * be called when a notification has been received.
174 * It will start a thread that polls for notifications and calls the callback
175 * function if a notification has been received.
176 * In case of an error condition when polling for notifications - e.g. device
177 * disconnect - the thread will call the callback function with an empty
178 * notification "" and terminate itself.
179 *
180 * @param client the NP client
181 * @param notify_cb pointer to a callback function or NULL to de-register a
182 * previously set callback function.
183 * @param user_data Pointer that will be passed to the callback function as
184 * user data. If notify_cb is NULL, this parameter is ignored.
185 *
186 * @note Only one callback function can be registered at the same time;
187 * any previously set callback function will be removed automatically.
188 *
189 * @return NP_E_SUCCESS when the callback was successfully registered,
190 * NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when
191 * the callback thread could no be created.
192 */
103np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *userdata); 193np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *userdata);
104 194
105#ifdef __cplusplus 195#ifdef __cplusplus
diff --git a/include/libimobiledevice/restore.h b/include/libimobiledevice/restore.h
index 584adb4..f4e8822 100644
--- a/include/libimobiledevice/restore.h
+++ b/include/libimobiledevice/restore.h
@@ -51,20 +51,130 @@ typedef struct restored_client_private restored_client_private;
51typedef restored_client_private *restored_client_t; /**< The client handle. */ 51typedef restored_client_private *restored_client_t; /**< The client handle. */
52 52
53/* Interface */ 53/* Interface */
54
55/**
56 * Creates a new restored client for the device.
57 *
58 * @param device The device to create a restored client for
59 * @param client The pointer to the location of the new restored_client
60 * @param label The label to use for communication. Usually the program name.
61 *
62 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
63 */
54restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label); 64restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label);
65
66/**
67 * Closes the restored client session if one is running and frees up the
68 * restored_client struct.
69 *
70 * @param client The restore client
71 *
72 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
73 */
55restored_error_t restored_client_free(restored_client_t client); 74restored_error_t restored_client_free(restored_client_t client);
56 75
76
77/**
78 * Query the type of the service daemon. Depending on whether the device is
79 * queried in normal mode or restore mode, different types will be returned.
80 *
81 * @param client The restored client
82 * @param type The type returned by the service daemon. Pass NULL to ignore.
83 * @param version The restore protocol version. Pass NULL to ignore.
84 *
85 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
86 */
57restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version); 87restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version);
88
89/**
90 * Queries a value from the device specified by a key.
91 *
92 * @param client An initialized restored client.
93 * @param key The key name to request
94 * @param value A plist node representing the result value node
95 *
96 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
97 */
58restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value); 98restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value);
99
100/**
101 * Retrieves a value from information plist specified by a key.
102 *
103 * @param client An initialized restored client.
104 * @param key The key name to request or NULL to query for all keys
105 * @param value A plist node representing the result value node
106 *
107 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
108 */
59restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ; 109restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ;
110
111/**
112 * Sends a plist to restored.
113 *
114 * @note This function is low-level and should only be used if you need to send
115 * a new type of message.
116 *
117 * @param client The restored client
118 * @param plist The plist to send
119 *
120 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client or
121 * plist is NULL
122 */
60restored_error_t restored_send(restored_client_t client, plist_t plist); 123restored_error_t restored_send(restored_client_t client, plist_t plist);
124
125/**
126 * Receives a plist from restored.
127 *
128 * @param client The restored client
129 * @param plist The plist to store the received data
130 *
131 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client or
132 * plist is NULL
133 */
61restored_error_t restored_receive(restored_client_t client, plist_t *plist); 134restored_error_t restored_receive(restored_client_t client, plist_t *plist);
135
136/**
137 * Sends the Goodbye request to restored signaling the end of communication.
138 *
139 * @param client The restore client
140 *
141 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
142 * RESTORE_E_PLIST_ERROR if the device did not acknowledge the request
143 */
62restored_error_t restored_goodbye(restored_client_t client); 144restored_error_t restored_goodbye(restored_client_t client);
63 145
146
147/**
148 * Requests to start a restore and retrieve it's port on success.
149 *
150 * @param client The restored client
151 * @param options PLIST_DICT with options for the restore process or NULL
152 * @param version the restore protocol version, see restored_query_type()
153 *
154 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
155 * is NULL, RESTORE_E_START_RESTORE_FAILED if the request fails
156 */
64restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version); 157restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version);
158
159/**
160 * Requests device to reboot.
161 *
162 * @param client The restored client
163 *
164 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
165 * is NULL
166 */
65restored_error_t restored_reboot(restored_client_t client); 167restored_error_t restored_reboot(restored_client_t client);
66 168
67/* Helper */ 169/* Helper */
170
171/**
172 * Sets the label to send for requests to restored.
173 *
174 * @param client The restore client
175 * @param label The label to set or NULL to disable sending a label
176 *
177 */
68void restored_client_set_label(restored_client_t client, const char *label); 178void restored_client_set_label(restored_client_t client, const char *label);
69 179
70#ifdef __cplusplus 180#ifdef __cplusplus
diff --git a/include/libimobiledevice/sbservices.h b/include/libimobiledevice/sbservices.h
index f9d131b..f0bf2c4 100644
--- a/include/libimobiledevice/sbservices.h
+++ b/include/libimobiledevice/sbservices.h
@@ -60,14 +60,116 @@ typedef struct sbservices_client_private sbservices_client_private;
60typedef sbservices_client_private *sbservices_client_t; /**< The client handle. */ 60typedef sbservices_client_private *sbservices_client_t; /**< The client handle. */
61 61
62/* Interface */ 62/* Interface */
63
64/**
65 * Connects to the springboardservices service on the specified device.
66 *
67 * @param device The device to connect to.
68 * @param service The service descriptor returned by lockdownd_start_service.
69 * @param client Pointer that will point to a newly allocated
70 * sbservices_client_t upon successful return.
71 *
72 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
73 * client is NULL, or an SBSERVICES_E_* error code otherwise.
74 */
63sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client); 75sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client);
76
77/**
78 * Starts a new sbservices service on the specified device and connects to it.
79 *
80 * @param device The device to connect to.
81 * @param client Pointer that will point to a newly allocated
82 * sbservices_client_t upon successful return. Must be freed using
83 * sbservices_client_free() after use.
84 * @param label The label to use for communication. Usually the program name.
85 * Pass NULL to disable sending the label in requests to lockdownd.
86 *
87 * @return SBSERVICES_E_SUCCESS on success, or an SBSERVICES_E_* error
88 * code otherwise.
89 */
64sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t* client, const char* label); 90sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t* client, const char* label);
91
92/**
93 * Disconnects an sbservices client from the device and frees up the
94 * sbservices client data.
95 *
96 * @param client The sbservices client to disconnect and free.
97 *
98 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
99 * client is NULL, or an SBSERVICES_E_* error code otherwise.
100 */
65sbservices_error_t sbservices_client_free(sbservices_client_t client); 101sbservices_error_t sbservices_client_free(sbservices_client_t client);
66 102
103
104/**
105 * Gets the icon state of the connected device.
106 *
107 * @param client The connected sbservices client to use.
108 * @param state Pointer that will point to a newly allocated plist containing
109 * the current icon state. It is up to the caller to free the memory.
110 * @param format_version A string to be passed as formatVersion along with
111 * the request, or NULL if no formatVersion should be passed. This is only
112 * supported since iOS 4.0 so for older firmware versions this must be set
113 * to NULL.
114 *
115 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
116 * client or state is invalid, or an SBSERVICES_E_* error code otherwise.
117 */
67sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version); 118sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version);
119
120/**
121 * Sets the icon state of the connected device.
122 *
123 * @param client The connected sbservices client to use.
124 * @param newstate A plist containing the new iconstate.
125 *
126 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
127 * client or newstate is NULL, or an SBSERVICES_E_* error code otherwise.
128 */
68sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); 129sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate);
130
131/**
132 * Get the icon of the specified app as PNG data.
133 *
134 * @param client The connected sbservices client to use.
135 * @param bundleId The bundle identifier of the app to retrieve the icon for.
136 * @param pngdata Pointer that will point to a newly allocated buffer
137 * containing the PNG data upon successful return. It is up to the caller
138 * to free the memory.
139 * @param pngsize Pointer to a uint64_t that will be set to the size of the
140 * buffer pngdata points to upon successful return.
141 *
142 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
143 * client, bundleId, or pngdata are invalid, or an SBSERVICES_E_* error
144 * code otherwise.
145 */
69sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); 146sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize);
147
148/**
149 * Gets the interface orientation of the device.
150 *
151 * @param client The connected sbservices client to use.
152 * @param interface_orientation The interface orientation upon successful return.
153 *
154 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
155 * client or state is invalid, or an SBSERVICES_E_* error code otherwise.
156 */
70sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation); 157sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation);
158
159/**
160 * Get the home screen wallpaper as PNG data.
161 *
162 * @param client The connected sbservices client to use.
163 * @param pngdata Pointer that will point to a newly allocated buffer
164 * containing the PNG data upon successful return. It is up to the caller
165 * to free the memory.
166 * @param pngsize Pointer to a uint64_t that will be set to the size of the
167 * buffer pngdata points to upon successful return.
168 *
169 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
170 * client or pngdata are invalid, or an SBSERVICES_E_* error
171 * code otherwise.
172 */
71sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize); 173sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize);
72 174
73#ifdef __cplusplus 175#ifdef __cplusplus
diff --git a/include/libimobiledevice/screenshotr.h b/include/libimobiledevice/screenshotr.h
index c8679a9..3601172 100644
--- a/include/libimobiledevice/screenshotr.h
+++ b/include/libimobiledevice/screenshotr.h
@@ -50,10 +50,65 @@ typedef int16_t screenshotr_error_t;
50typedef struct screenshotr_client_private screenshotr_client_private; 50typedef struct screenshotr_client_private screenshotr_client_private;
51typedef screenshotr_client_private *screenshotr_client_t; /**< The client handle. */ 51typedef screenshotr_client_private *screenshotr_client_t; /**< The client handle. */
52 52
53
54/**
55 * Connects to the screenshotr service on the specified device.
56 *
57 * @param device The device to connect to.
58 * @param service The service descriptor returned by lockdownd_start_service.
59 * @param client Pointer that will be set to a newly allocated
60 * screenshotr_client_t upon successful return.
61 *
62 * @note This service is only available if a developer disk image has been
63 * mounted.
64 *
65 * @return SCREENSHOTR_E_SUCCESS on success, SCREENSHOTR_E_INVALID ARG if one
66 * or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the
67 * connection to the device could not be established.
68 */
53screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, screenshotr_client_t * client); 69screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, screenshotr_client_t * client);
70
71/**
72 * Starts a new screenshotr service on the specified device and connects to it.
73 *
74 * @param device The device to connect to.
75 * @param client Pointer that will point to a newly allocated
76 * screenshotr_client_t upon successful return. Must be freed using
77 * screenshotr_client_free() after use.
78 * @param label The label to use for communication. Usually the program name.
79 * Pass NULL to disable sending the label in requests to lockdownd.
80 *
81 * @return SCREENSHOTR_E_SUCCESS on success, or an SCREENSHOTR_E_* error
82 * code otherwise.
83 */
54screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t* client, const char* label); 84screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t* client, const char* label);
85
86/**
87 * Disconnects a screenshotr client from the device and frees up the
88 * screenshotr client data.
89 *
90 * @param client The screenshotr client to disconnect and free.
91 *
92 * @return SCREENSHOTR_E_SUCCESS on success, or SCREENSHOTR_E_INVALID_ARG
93 * if client is NULL.
94 */
55screenshotr_error_t screenshotr_client_free(screenshotr_client_t client); 95screenshotr_error_t screenshotr_client_free(screenshotr_client_t client);
56 96
97
98/**
99 * Get a screen shot from the connected device.
100 *
101 * @param client The connection screenshotr service client.
102 * @param imgdata Pointer that will point to a newly allocated buffer
103 * containing TIFF image data upon successful return. It is up to the
104 * caller to free the memory.
105 * @param imgsize Pointer to a uint64_t that will be set to the size of the
106 * buffer imgdata points to upon successful return.
107 *
108 * @return SCREENSHOTR_E_SUCCESS on success, SCREENSHOTR_E_INVALID_ARG if
109 * one or more parameters are invalid, or another error code if an
110 * error occured.
111 */
57screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize); 112screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize);
58 113
59#ifdef __cplusplus 114#ifdef __cplusplus
diff --git a/include/libimobiledevice/service.h b/include/libimobiledevice/service.h
index 6585fe7..acf846b 100644
--- a/include/libimobiledevice/service.h
+++ b/include/libimobiledevice/service.h
@@ -49,15 +49,120 @@ typedef service_client_private* service_client_t; /**< The client handle. */
49#define SERVICE_CONSTRUCTOR(x) (int16_t (*)(idevice_t, lockdownd_service_descriptor_t, void**))(x) 49#define SERVICE_CONSTRUCTOR(x) (int16_t (*)(idevice_t, lockdownd_service_descriptor_t, void**))(x)
50 50
51/* Interface */ 51/* Interface */
52
53/**
54 * Creates a new service for the specified service descriptor.
55 *
56 * @param device The device to connect to.
57 * @param service The service descriptor returned by lockdownd_start_service.
58 * @param client Pointer that will be set to a newly allocated
59 * service_client_t upon successful return.
60 *
61 * @return SERVICE_E_SUCCESS on success,
62 * SERVICE_E_INVALID_ARG when one of the arguments is invalid,
63 * or SERVICE_E_MUX_ERROR when connecting to the device failed.
64 */
52service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client); 65service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client);
66
67/**
68 * Starts a new service on the specified device with given name and
69 * connects to it.
70 *
71 * @param device The device to connect to.
72 * @param service_name The name of the service to start.
73 * @param client Pointer that will point to a newly allocated service_client_t
74 * upon successful return. Must be freed using service_client_free() after
75 * use.
76 * @param label The label to use for communication. Usually the program name.
77 * Pass NULL to disable sending the label in requests to lockdownd.
78 *
79 * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code
80 * otherwise.
81 */
53service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code); 82service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code);
83
84/**
85 * Frees a service instance.
86 *
87 * @param client The service instance to free.
88 *
89 * @return SERVICE_E_SUCCESS on success,
90 * SERVICE_E_INVALID_ARG when client is invalid, or a
91 * SERVICE_E_UNKNOWN_ERROR when another error occured.
92 */
54service_error_t service_client_free(service_client_t client); 93service_error_t service_client_free(service_client_t client);
55 94
95
96/**
97 * Sends data using the given service client.
98 *
99 * @param client The service client to use for sending.
100 * @param data Data to send
101 * @param size Size of the data to send
102 * @param sent Number of bytes sent (can be NULL to ignore)
103 *
104 * @return SERVICE_E_SUCCESS on success,
105 * SERVICE_E_INVALID_ARG when one or more parameters are
106 * invalid, or SERVICE_E_UNKNOWN_ERROR when an unspecified
107 * error occurs.
108 */
56service_error_t service_send(service_client_t client, const char *data, uint32_t size, uint32_t *sent); 109service_error_t service_send(service_client_t client, const char *data, uint32_t size, uint32_t *sent);
110
111/**
112 * Receives data using the given service client with specified timeout.
113 *
114 * @param client The service client to use for receiving
115 * @param data Buffer that will be filled with the data received
116 * @param size Number of bytes to receive
117 * @param received Number of bytes received (can be NULL to ignore)
118 * @param timeout Maximum time in milliseconds to wait for data.
119 *
120 * @return SERVICE_E_SUCCESS on success,
121 * SERVICE_E_INVALID_ARG when one or more parameters are
122 * invalid, SERVICE_E_MUX_ERROR when a communication error
123 * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
124 * error occurs.
125 */
57service_error_t service_receive_with_timeout(service_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); 126service_error_t service_receive_with_timeout(service_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
127
128/**
129 * Receives data using the given service client.
130 *
131 * @param client The service client to use for receiving
132 * @param data Buffer that will be filled with the data received
133 * @param size Number of bytes to receive
134 * @param received Number of bytes received (can be NULL to ignore)
135 *
136 * @return SERVICE_E_SUCCESS on success,
137 * SERVICE_E_INVALID_ARG when one or more parameters are
138 * invalid, SERVICE_E_MUX_ERROR when a communication error
139 * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
140 * error occurs.
141 */
58service_error_t service_receive(service_client_t client, char *data, uint32_t size, uint32_t *received); 142service_error_t service_receive(service_client_t client, char *data, uint32_t size, uint32_t *received);
59 143
144
145/**
146 * Enable SSL for the given service client.
147 *
148 * @param client The connected service client for that SSL should be enabled.
149 *
150 * @return SERVICE_E_SUCCESS on success,
151 * SERVICE_E_INVALID_ARG if client or client->connection is
152 * NULL, SERVICE_E_SSL_ERROR when SSL could not be enabled,
153 * or SERVICE_E_UNKNOWN_ERROR otherwise.
154 */
60service_error_t service_enable_ssl(service_client_t client); 155service_error_t service_enable_ssl(service_client_t client);
156
157/**
158 * Disable SSL for the given service client.
159 *
160 * @param client The connected service client for that SSL should be disabled.
161 *
162 * @return SERVICE_E_SUCCESS on success,
163 * SERVICE_E_INVALID_ARG if client or client->connection is
164 * NULL, or SERVICE_E_UNKNOWN_ERROR otherwise.
165 */
61service_error_t service_disable_ssl(service_client_t client); 166service_error_t service_disable_ssl(service_client_t client);
62 167
63#ifdef __cplusplus 168#ifdef __cplusplus
diff --git a/include/libimobiledevice/syslog_relay.h b/include/libimobiledevice/syslog_relay.h
index 7ccfd74..952840e 100644
--- a/include/libimobiledevice/syslog_relay.h
+++ b/include/libimobiledevice/syslog_relay.h
@@ -51,15 +51,109 @@ typedef syslog_relay_client_private *syslog_relay_client_t; /**< The client hand
51typedef void (*syslog_relay_receive_cb_t)(char c, void *user_data); 51typedef void (*syslog_relay_receive_cb_t)(char c, void *user_data);
52 52
53/* Interface */ 53/* Interface */
54
55/**
56 * Connects to the syslog_relay service on the specified device.
57 *
58 * @param device The device to connect to.
59 * @param service The service descriptor returned by lockdownd_start_service.
60 * @param client Pointer that will point to a newly allocated
61 * syslog_relay_client_t upon successful return. Must be freed using
62 * syslog_relay_client_free() after use.
63 *
64 * @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
65 * client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
66 */
54syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client); 67syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client);
68
69/**
70 * Starts a new syslog_relay service on the specified device and connects to it.
71 *
72 * @param device The device to connect to.
73 * @param client Pointer that will point to a newly allocated
74 * syslog_relay_client_t upon successful return. Must be freed using
75 * syslog_relay_client_free() after use.
76 * @param label The label to use for communication. Usually the program name.
77 * Pass NULL to disable sending the label in requests to lockdownd.
78 *
79 * @return SYSLOG_RELAY_E_SUCCESS on success, or an SYSLOG_RELAY_E_* error
80 * code otherwise.
81 */
55syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label); 82syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label);
83
84/**
85 * Disconnects a syslog_relay client from the device and frees up the
86 * syslog_relay client data.
87 *
88 * @param client The syslog_relay client to disconnect and free.
89 *
90 * @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
91 * client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
92 */
56syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client); 93syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client);
57 94
95
96/**
97 * Starts capturing the syslog of the device using a callback.
98 *
99 * Use syslog_relay_stop_capture() to stop receiving the syslog.
100 *
101 * @param client The syslog_relay client to use
102 * @param callback Callback to receive each character from the syslog.
103 * @param user_data Custom pointer passed to the callback function.
104 *
105 * @return SYSLOG_RELAY_E_SUCCESS on success,
106 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
107 * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
108 * error occurs or a syslog capture has already been started.
109 */
58syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data); 110syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data);
111
112/**
113 * Stops capturing the syslog of the device.
114 *
115 * Use syslog_relay_start_capture() to start receiving the syslog.
116 *
117 * @param client The syslog_relay client to use
118 *
119 * @return SYSLOG_RELAY_E_SUCCESS on success,
120 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
121 * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
122 * error occurs or a syslog capture has already been started.
123 */
59syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client); 124syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client);
60 125
61/* Receiving */ 126/* Receiving */
127
128/**
129 * Receives data using the given syslog_relay client with specified timeout.
130 *
131 * @param client The syslog_relay client to use for receiving
132 * @param data Buffer that will be filled with the data received
133 * @param size Number of bytes to receive
134 * @param received Number of bytes received (can be NULL to ignore)
135 * @param timeout Maximum time in milliseconds to wait for data.
136 *
137 * @return SYSLOG_RELAY_E_SUCCESS on success,
138 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
139 * invalid, SYSLOG_RELAY_E_MUX_ERROR when a communication error
140 * occurs, or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
141 * error occurs.
142 */
62syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); 143syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
144
145/**
146 * Receives data from the service.
147 *
148 * @param client The syslog_relay client
149 * @param data Buffer that will be filled with the data received
150 * @param size Number of bytes to receive
151 * @param received Number of bytes received (can be NULL to ignore)
152 * @param timeout Maximum time in milliseconds to wait for data.
153 *
154 * @return SYSLOG_RELAY_E_SUCCESS on success,
155 * SYSLOG_RELAY_E_INVALID_ARG when client or plist is NULL
156 */
63syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received); 157syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received);
64 158
65#ifdef __cplusplus 159#ifdef __cplusplus
diff --git a/include/libimobiledevice/webinspector.h b/include/libimobiledevice/webinspector.h
index dfd4dd2..499e7f0 100644
--- a/include/libimobiledevice/webinspector.h
+++ b/include/libimobiledevice/webinspector.h
@@ -48,12 +48,85 @@ typedef int16_t webinspector_error_t;
48typedef struct webinspector_client_private webinspector_client_private; 48typedef struct webinspector_client_private webinspector_client_private;
49typedef webinspector_client_private *webinspector_client_t; /**< The client handle. */ 49typedef webinspector_client_private *webinspector_client_t; /**< The client handle. */
50 50
51
52/**
53 * Connects to the webinspector service on the specified device.
54 *
55 * @param device The device to connect to.
56 * @param service The service descriptor returned by lockdownd_start_service.
57 * @param client Pointer that will point to a newly allocated
58 * webinspector_client_t upon successful return. Must be freed using
59 * webinspector_client_free() after use.
60 *
61 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
62 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
63 */
51webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client); 64webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client);
65
66/**
67 * Starts a new webinspector service on the specified device and connects to it.
68 *
69 * @param device The device to connect to.
70 * @param client Pointer that will point to a newly allocated
71 * webinspector_client_t upon successful return. Must be freed using
72 * webinspector_client_free() after use.
73 * @param label The label to use for communication. Usually the program name.
74 * Pass NULL to disable sending the label in requests to lockdownd.
75 *
76 * @return WEBINSPECTOR_E_SUCCESS on success, or an WEBINSPECTOR_E_* error
77 * code otherwise.
78 */
52webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label); 79webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label);
80
81/**
82 * Disconnects a webinspector client from the device and frees up the
83 * webinspector client data.
84 *
85 * @param client The webinspector client to disconnect and free.
86 *
87 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
88 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
89 */
53webinspector_error_t webinspector_client_free(webinspector_client_t client); 90webinspector_error_t webinspector_client_free(webinspector_client_t client);
54 91
92
93/**
94 * Sends a plist to the service.
95 *
96 * @param client The webinspector client
97 * @param plist The plist to send
98 *
99 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
100 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
101 */
55webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist); 102webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist);
103
104/**
105 * Receives a plist from the service.
106 *
107 * @param client The webinspector client
108 * @param plist The plist to store the received data
109 *
110 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
111 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
112 */
56webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist); 113webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist);
114
115/**
116 * Receives a plist using the given webinspector client.
117 *
118 * @param client The webinspector client to use for receiving
119 * @param plist pointer to a plist_t that will point to the received plist
120 * upon successful return
121 * @param timeout Maximum time in milliseconds to wait for data.
122 *
123 * @return WEBINSPECTOR_E_SUCCESS on success,
124 * WEBINSPECTOR_E_INVALID_ARG when client or *plist is NULL,
125 * WEBINSPECTOR_E_PLIST_ERROR when the received data cannot be
126 * converted to a plist, WEBINSPECTOR_E_MUX_ERROR when a
127 * communication error occurs, or WEBINSPECTOR_E_UNKNOWN_ERROR
128 * when an unspecified error occurs.
129 */
57webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms); 130webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms);
58 131
59#ifdef __cplusplus 132#ifdef __cplusplus
diff --git a/src/afc.c b/src/afc.c
index dd75558..b5203f1 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -95,18 +95,6 @@ afc_error_t afc_client_new_with_service_client(service_client_t service_client,
95 return AFC_E_SUCCESS; 95 return AFC_E_SUCCESS;
96} 96}
97 97
98/**
99 * Makes a connection to the AFC service on the device.
100 *
101 * @param device The device to connect to.
102 * @param service The service descriptor returned by lockdownd_start_service.
103 * @param client Pointer that will be set to a newly allocated afc_client_t
104 * upon successful return.
105 *
106 * @return AFC_E_SUCCESS on success, AFC_E_INVALID_ARG if device or service is
107 * invalid, AFC_E_MUX_ERROR if the connection cannot be established,
108 * or AFC_E_NO_MEM if there is a memory allocation problem.
109 */
110afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client) 98afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client)
111{ 99{
112 if (!device || !service || service->port == 0) 100 if (!device || !service || service->port == 0)
@@ -126,19 +114,6 @@ afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t serv
126 return err; 114 return err;
127} 115}
128 116
129/**
130 * Starts a new AFC service on the specified device and connects to it.
131 *
132 * @param device The device to connect to.
133 * @param client Pointer that will point to a newly allocated
134 * afc_client_t upon successful return. Must be freed using
135 * afc_client_free() after use.
136 * @param label The label to use for communication. Usually the program name.
137 * Pass NULL to disable sending the label in requests to lockdownd.
138 *
139 * @return AFC_E_SUCCESS on success, or an AFC_E_* error
140 * code otherwise.
141 */
142afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, const char* label) 117afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, const char* label)
143{ 118{
144 afc_error_t err = AFC_E_UNKNOWN_ERROR; 119 afc_error_t err = AFC_E_UNKNOWN_ERROR;
@@ -146,12 +121,6 @@ afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, co
146 return err; 121 return err;
147} 122}
148 123
149/**
150 * Frees up an AFC client. If the connection was created by the
151 * client itself, the connection will be closed.
152 *
153 * @param client The client to free.
154 */
155afc_error_t afc_client_free(afc_client_t client) 124afc_error_t afc_client_free(afc_client_t client)
156{ 125{
157 if (!client || !client->afc_packet) 126 if (!client || !client->afc_packet)
@@ -432,16 +401,6 @@ static char **make_strings_list(char *tokens, uint32_t length)
432 return list; 401 return list;
433} 402}
434 403
435/**
436 * Gets a directory listing of the directory requested.
437 *
438 * @param client The client to get a directory listing from.
439 * @param dir The directory to list. (must be a fully-qualified path)
440 * @param list A char list of files in that directory, terminated by an empty
441 * string or NULL if there was an error.
442 *
443 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
444 */
445afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list) 404afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list)
446{ 405{
447 uint32_t bytes = 0; 406 uint32_t bytes = 0;
@@ -478,17 +437,6 @@ afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***lis
478 return ret; 437 return ret;
479} 438}
480 439
481/**
482 * Get device information for a connected client. The device information
483 * returned is the device model as well as the free space, the total capacity
484 * and blocksize on the accessed disk partition.
485 *
486 * @param client The client to get device info for.
487 * @param infos A char ** list of parameters as given by AFC or NULL if there
488 * was an error.
489 *
490 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
491 */
492afc_error_t afc_get_device_info(afc_client_t client, char ***infos) 440afc_error_t afc_get_device_info(afc_client_t client, char ***infos)
493{ 441{
494 uint32_t bytes = 0; 442 uint32_t bytes = 0;
@@ -526,17 +474,6 @@ afc_error_t afc_get_device_info(afc_client_t client, char ***infos)
526 return ret; 474 return ret;
527} 475}
528 476
529/**
530 * Get a specific key of the device info list for a client connection.
531 * Known key values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize.
532 * This is a helper function for afc_get_device_info().
533 *
534 * @param client The client to get device info for.
535 * @param key The key to get the value of.
536 * @param value The value for the key if successful or NULL otherwise.
537 *
538 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
539 */
540afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value) 477afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value)
541{ 478{
542 afc_error_t ret = AFC_E_INTERNAL_ERROR; 479 afc_error_t ret = AFC_E_INTERNAL_ERROR;
@@ -564,14 +501,6 @@ afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char *
564 return ret; 501 return ret;
565} 502}
566 503
567/**
568 * Deletes a file or directory.
569 *
570 * @param client The client to use.
571 * @param path The path to delete. (must be a fully-qualified path)
572 *
573 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
574 */
575afc_error_t afc_remove_path(afc_client_t client, const char *path) 504afc_error_t afc_remove_path(afc_client_t client, const char *path)
576{ 505{
577 uint32_t bytes = 0; 506 uint32_t bytes = 0;
@@ -600,15 +529,6 @@ afc_error_t afc_remove_path(afc_client_t client, const char *path)
600 return ret; 529 return ret;
601} 530}
602 531
603/**
604 * Renames a file or directory on the device.
605 *
606 * @param client The client to have rename.
607 * @param from The name to rename from. (must be a fully-qualified path)
608 * @param to The new name. (must also be a fully-qualified path)
609 *
610 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
611 */
612afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to) 532afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to)
613{ 533{
614 char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); 534 char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t)));
@@ -638,15 +558,6 @@ afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *t
638 return ret; 558 return ret;
639} 559}
640 560
641/**
642 * Creates a directory on the device.
643 *
644 * @param client The client to use to make a directory.
645 * @param dir The directory's path. (must be a fully-qualified path, I assume
646 * all other mkdir restrictions apply as well)
647 *
648 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
649 */
650afc_error_t afc_make_directory(afc_client_t client, const char *dir) 561afc_error_t afc_make_directory(afc_client_t client, const char *dir)
651{ 562{
652 uint32_t bytes = 0; 563 uint32_t bytes = 0;
@@ -671,17 +582,6 @@ afc_error_t afc_make_directory(afc_client_t client, const char *dir)
671 return ret; 582 return ret;
672} 583}
673 584
674/**
675 * Gets information about a specific file.
676 *
677 * @param client The client to use to get the information of the file.
678 * @param path The fully-qualified path to the file.
679 * @param infolist Pointer to a buffer that will be filled with a NULL-terminated
680 * list of strings with the file information.
681 * Set to NULL before calling this function.
682 *
683 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
684 */
685afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***infolist) 585afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***infolist)
686{ 586{
687 char *received = NULL; 587 char *received = NULL;
@@ -712,19 +612,6 @@ afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***inf
712 return ret; 612 return ret;
713} 613}
714 614
715/**
716 * Opens a file on the device.
717 *
718 * @param client The client to use to open the file.
719 * @param filename The file to open. (must be a fully-qualified path)
720 * @param file_mode The mode to use to open the file. Can be AFC_FILE_READ or
721 * AFC_FILE_WRITE; the former lets you read and write,
722 * however, and the second one will *create* the file,
723 * destroying anything previously there.
724 * @param handle Pointer to a uint64_t that will hold the handle of the file
725 *
726 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
727 */
728idevice_error_t 615idevice_error_t
729afc_file_open(afc_client_t client, const char *filename, 616afc_file_open(afc_client_t client, const char *filename,
730 afc_file_mode_t file_mode, uint64_t *handle) 617 afc_file_mode_t file_mode, uint64_t *handle)
@@ -772,17 +659,6 @@ afc_file_open(afc_client_t client, const char *filename,
772 return ret; 659 return ret;
773} 660}
774 661
775/**
776 * Attempts to the read the given number of bytes from the given file.
777 *
778 * @param client The relevant AFC client
779 * @param handle File handle of a previously opened file
780 * @param data The pointer to the memory region to store the read data
781 * @param length The number of bytes to read
782 * @param bytes_read The number of bytes actually read.
783 *
784 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
785 */
786idevice_error_t 662idevice_error_t
787afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read) 663afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read)
788{ 664{
@@ -837,17 +713,6 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length,
837 return ret; 713 return ret;
838} 714}
839 715
840/**
841 * Writes a given number of bytes to a file.
842 *
843 * @param client The client to use to write to the file.
844 * @param handle File handle of previously opened file.
845 * @param data The data to write to the file.
846 * @param length How much data to write.
847 * @param bytes_written The number of bytes actually written to the file.
848 *
849 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
850 */
851idevice_error_t 716idevice_error_t
852afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written) 717afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written)
853{ 718{
@@ -881,12 +746,6 @@ afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t
881 return ret; 746 return ret;
882} 747}
883 748
884/**
885 * Closes a file on the device.
886 *
887 * @param client The client to close the file with.
888 * @param handle File handle of a previously opened file.
889 */
890afc_error_t afc_file_close(afc_client_t client, uint64_t handle) 749afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
891{ 750{
892 uint32_t bytes = 0; 751 uint32_t bytes = 0;
@@ -915,18 +774,6 @@ afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
915 return ret; 774 return ret;
916} 775}
917 776
918/**
919 * Locks or unlocks a file on the device.
920 *
921 * makes use of flock on the device, see
922 * http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/flock.2.html
923 *
924 * @param client The client to lock the file with.
925 * @param handle File handle of a previously opened file.
926 * @param operation the lock or unlock operation to perform, this is one of
927 * AFC_LOCK_SH (shared lock), AFC_LOCK_EX (exclusive lock),
928 * or AFC_LOCK_UN (unlock).
929 */
930afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation) 777afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation)
931{ 778{
932 uint32_t bytes = 0; 779 uint32_t bytes = 0;
@@ -961,16 +808,6 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op
961 return ret; 808 return ret;
962} 809}
963 810
964/**
965 * Seeks to a given position of a pre-opened file on the device.
966 *
967 * @param client The client to use to seek to the position.
968 * @param handle File handle of a previously opened.
969 * @param offset Seek offset.
970 * @param whence Seeking direction, one of SEEK_SET, SEEK_CUR, or SEEK_END.
971 *
972 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
973 */
974afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence) 811afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence)
975{ 812{
976 uint32_t bytes = 0; 813 uint32_t bytes = 0;
@@ -1004,15 +841,6 @@ afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset,
1004 return ret; 841 return ret;
1005} 842}
1006 843
1007/**
1008 * Returns current position in a pre-opened file on the device.
1009 *
1010 * @param client The client to use.
1011 * @param handle File handle of a previously opened file.
1012 * @param position Position in bytes of indicator
1013 *
1014 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1015 */
1016afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position) 844afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position)
1017{ 845{
1018 char *buffer = (char *) malloc(sizeof(char) * 8); 846 char *buffer = (char *) malloc(sizeof(char) * 8);
@@ -1047,18 +875,6 @@ afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *positi
1047 return ret; 875 return ret;
1048} 876}
1049 877
1050/**
1051 * Sets the size of a file on the device.
1052 *
1053 * @param client The client to use to set the file size.
1054 * @param handle File handle of a previously opened file.
1055 * @param newsize The size to set the file to.
1056 *
1057 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1058 *
1059 * @note This function is more akin to ftruncate than truncate, and truncate
1060 * calls would have to open the file before calling this, sadly.
1061 */
1062afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize) 878afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize)
1063{ 879{
1064 uint32_t bytes = 0; 880 uint32_t bytes = 0;
@@ -1090,15 +906,6 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new
1090 return ret; 906 return ret;
1091} 907}
1092 908
1093/**
1094 * Sets the size of a file on the device without prior opening it.
1095 *
1096 * @param client The client to use to set the file size.
1097 * @param path The path of the file to be truncated.
1098 * @param newsize The size to set the file to.
1099 *
1100 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1101 */
1102afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize) 909afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize)
1103{ 910{
1104 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); 911 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
@@ -1129,16 +936,6 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize
1129 return ret; 936 return ret;
1130} 937}
1131 938
1132/**
1133 * Creates a hard link or symbolic link on the device.
1134 *
1135 * @param client The client to use for making a link
1136 * @param linktype 1 = hard link, 2 = symlink
1137 * @param target The file to be linked.
1138 * @param linkname The name of link.
1139 *
1140 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1141 */
1142afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname) 939afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname)
1143{ 940{
1144 char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); 941 char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8));
@@ -1173,15 +970,6 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c
1173 return ret; 970 return ret;
1174} 971}
1175 972
1176/**
1177 * Sets the modification time of a file on the device.
1178 *
1179 * @param client The client to use to set the file size.
1180 * @param path Path of the file for which the modification time should be set.
1181 * @param mtime The modification time to set in nanoseconds since epoch.
1182 *
1183 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1184 */
1185afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime) 973afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime)
1186{ 974{
1187 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); 975 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
diff --git a/src/diagnostics_relay.c b/src/diagnostics_relay.c
index de3781c..cc9c645 100644
--- a/src/diagnostics_relay.c
+++ b/src/diagnostics_relay.c
@@ -69,18 +69,6 @@ static int diagnostics_relay_check_result(plist_t dict)
69 return ret; 69 return ret;
70} 70}
71 71
72/**
73 * Connects to the diagnostics_relay service on the specified device.
74 *
75 * @param device The device to connect to.
76 * @param service The service descriptor returned by lockdownd_start_service.
77 * @param client Reference that will point to a newly allocated
78 * diagnostics_relay_client_t upon successful return.
79 *
80 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
81 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid,
82 * or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed.
83 */
84diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client) 72diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client)
85{ 73{
86 if (!device || !service || service->port == 0 || !client || *client) { 74 if (!device || !service || service->port == 0 || !client || *client) {
@@ -101,19 +89,6 @@ diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdow
101 return DIAGNOSTICS_RELAY_E_SUCCESS; 89 return DIAGNOSTICS_RELAY_E_SUCCESS;
102} 90}
103 91
104/**
105 * Starts a new diagnostics_relay service on the specified device and connects to it.
106 *
107 * @param device The device to connect to.
108 * @param client Pointer that will point to a newly allocated
109 * diagnostics_relay_client_t upon successful return. Must be freed using
110 * diagnostics_relay_client_free() after use.
111 * @param label The label to use for communication. Usually the program name.
112 * Pass NULL to disable sending the label in requests to lockdownd.
113 *
114 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, or an DIAGNOSTICS_RELAY_E_* error
115 * code otherwise.
116 */
117diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t * client, const char* label) 92diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t * client, const char* label)
118{ 93{
119 diagnostics_relay_error_t err = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR; 94 diagnostics_relay_error_t err = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
@@ -121,17 +96,6 @@ diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t devic
121 return err; 96 return err;
122} 97}
123 98
124/**
125 * Disconnects a diagnostics_relay client from the device and frees up the
126 * diagnostics_relay client data.
127 *
128 * @param client The diagnostics_relay client to disconnect and free.
129 *
130 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
131 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of client or client->parent
132 * is invalid, or DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR when the was an
133 * error freeing the parent property_list_service client.
134 */
135diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client) 99diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client)
136{ 100{
137 if (!client) 101 if (!client)
@@ -198,16 +162,6 @@ static diagnostics_relay_error_t diagnostics_relay_send(diagnostics_relay_client
198 return ret; 162 return ret;
199} 163}
200 164
201/**
202 * Sends the Goodbye request signaling the end of communication.
203 *
204 * @param client The diagnostics_relay client
205 *
206 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
207 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
208 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
209 * request
210 */
211diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client) 165diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client)
212{ 166{
213 if (!client) 167 if (!client)
@@ -242,16 +196,6 @@ diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t c
242 return ret; 196 return ret;
243} 197}
244 198
245/**
246 * Puts the device into deep sleep mode and disconnects from host.
247 *
248 * @param client The diagnostics_relay client
249 *
250 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
251 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
252 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
253 * request
254 */
255diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client) 199diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client)
256{ 200{
257 if (!client) 201 if (!client)
@@ -328,41 +272,11 @@ static diagnostics_relay_error_t internal_diagnostics_relay_action(diagnostics_r
328 return ret; 272 return ret;
329} 273}
330 274
331/**
332 * Restart the device and optionally show a user notification.
333 *
334 * @param client The diagnostics_relay client
335 * @param flags A binary flag combination of
336 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
337 * diagnostics_relay_client_free() disconnects before execution and
338 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
339 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
340 *
341 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
342 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
343 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
344 * request
345 */
346diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags) 275diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags)
347{ 276{
348 return internal_diagnostics_relay_action(client, "Restart", flags); 277 return internal_diagnostics_relay_action(client, "Restart", flags);
349} 278}
350 279
351/**
352 * Shutdown of the device and optionally show a user notification.
353 *
354 * @param client The diagnostics_relay client
355 * @param flags A binary flag combination of
356 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
357 * diagnostics_relay_client_free() disconnects before execution and
358 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
359 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
360 *
361 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
362 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
363 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
364 * request
365 */
366diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags) 280diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags)
367{ 281{
368 return internal_diagnostics_relay_action(client, "Shutdown", flags); 282 return internal_diagnostics_relay_action(client, "Shutdown", flags);
diff --git a/src/file_relay.c b/src/file_relay.c
index fb802a8..3d1eb12 100644
--- a/src/file_relay.c
+++ b/src/file_relay.c
@@ -24,18 +24,6 @@
24#include "property_list_service.h" 24#include "property_list_service.h"
25#include "common/debug.h" 25#include "common/debug.h"
26 26
27/**
28 * Connects to the file_relay service on the specified device.
29 *
30 * @param device The device to connect to.
31 * @param service The service descriptor returned by lockdownd_start_service.
32 * @param client Reference that will point to a newly allocated
33 * file_relay_client_t upon successful return.
34 *
35 * @return FILE_RELAY_E_SUCCESS on success,
36 * FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid,
37 * or FILE_RELAY_E_MUX_ERROR when the connection failed.
38 */
39file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client) 27file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client)
40{ 28{
41 if (!device || !service || service->port == 0 || !client || *client) { 29 if (!device || !service || service->port == 0 || !client || *client) {
@@ -56,19 +44,6 @@ file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_des
56 return FILE_RELAY_E_SUCCESS; 44 return FILE_RELAY_E_SUCCESS;
57} 45}
58 46
59/**
60 * Starts a new file_relay service on the specified device and connects to it.
61 *
62 * @param device The device to connect to.
63 * @param client Pointer that will point to a newly allocated
64 * file_relay_client_t upon successful return. Must be freed using
65 * file_relay_client_free() after use.
66 * @param label The label to use for communication. Usually the program name.
67 * Pass NULL to disable sending the label in requests to lockdownd.
68 *
69 * @return FILE_RELAY_E_SUCCESS on success, or an FILE_RELAY_E_* error
70 * code otherwise.
71 */
72file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t * client, const char* label) 47file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t * client, const char* label)
73{ 48{
74 file_relay_error_t err = FILE_RELAY_E_UNKNOWN_ERROR; 49 file_relay_error_t err = FILE_RELAY_E_UNKNOWN_ERROR;
@@ -76,17 +51,6 @@ file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_
76 return err; 51 return err;
77} 52}
78 53
79/**
80 * Disconnects a file_relay client from the device and frees up the file_relay
81 * client data.
82 *
83 * @param client The file_relay client to disconnect and free.
84 *
85 * @return FILE_RELAY_E_SUCCESS on success,
86 * FILE_RELAY_E_INVALID_ARG when one of client or client->parent
87 * is invalid, or FILE_RELAY_E_UNKNOWN_ERROR when the was an error
88 * freeing the parent property_list_service client.
89 */
90file_relay_error_t file_relay_client_free(file_relay_client_t client) 54file_relay_error_t file_relay_client_free(file_relay_client_t client)
91{ 55{
92 if (!client) 56 if (!client)
@@ -98,37 +62,6 @@ file_relay_error_t file_relay_client_free(file_relay_client_t client)
98 return FILE_RELAY_E_SUCCESS; 62 return FILE_RELAY_E_SUCCESS;
99} 63}
100 64
101/**
102 * Request data for the given sources.
103 *
104 * @param client The connected file_relay client.
105 * @param sources A NULL-terminated list of sources to retrieve.
106 * Valid sources are:
107 * - AppleSupport
108 * - Network
109 * - VPN
110 * - WiFi
111 * - UserDatabases
112 * - CrashReporter
113 * - tmp
114 * - SystemConfiguration
115 * @param connection The connection that has to be used for receiving the
116 * data using idevice_connection_receive(). The connection will be closed
117 * automatically by the device, but use file_relay_client_free() to clean
118 * up properly.
119 * @param timeout Maximum time in milliseconds to wait for data.
120 *
121 * @note WARNING: Don't call this function without reading the data afterwards.
122 * A directory mobile_file_relay.XXXX used for creating the archive will
123 * remain in the /tmp directory otherwise.
124 *
125 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
126 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
127 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
128 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
129 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
130 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
131 */
132file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout) 65file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout)
133{ 66{
134 if (!client || !client->parent || !sources || !sources[0]) { 67 if (!client || !client->parent || !sources || !sources[0]) {
@@ -218,37 +151,6 @@ leave:
218 return err; 151 return err;
219} 152}
220 153
221/**
222 * Request data for the given sources. Calls file_relay_request_sources_timeout() with
223 * a timeout of 60000 milliseconds (60 seconds).
224 *
225 * @param client The connected file_relay client.
226 * @param sources A NULL-terminated list of sources to retrieve.
227 * Valid sources are:
228 * - AppleSupport
229 * - Network
230 * - VPN
231 * - WiFi
232 * - UserDatabases
233 * - CrashReporter
234 * - tmp
235 * - SystemConfiguration
236 * @param connection The connection that has to be used for receiving the
237 * data using idevice_connection_receive(). The connection will be closed
238 * automatically by the device, but use file_relay_client_free() to clean
239 * up properly.
240 *
241 * @note WARNING: Don't call this function without reading the data afterwards.
242 * A directory mobile_file_relay.XXXX used for creating the archive will
243 * remain in the /tmp directory otherwise.
244 *
245 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
246 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
247 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
248 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
249 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
250 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
251 */
252file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection) 154file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection)
253{ 155{
254 return file_relay_request_sources_timeout(client, sources, connection, 60000); 156 return file_relay_request_sources_timeout(client, sources, connection, 60000);
diff --git a/src/heartbeat.c b/src/heartbeat.c
index e03b44e..7654dd0 100644
--- a/src/heartbeat.c
+++ b/src/heartbeat.c
@@ -58,18 +58,6 @@ static heartbeat_error_t heartbeat_error(property_list_service_error_t err)
58 return HEARTBEAT_E_UNKNOWN_ERROR; 58 return HEARTBEAT_E_UNKNOWN_ERROR;
59} 59}
60 60
61/**
62 * Connects to the heartbeat service on the specified device.
63 *
64 * @param device The device to connect to.
65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Pointer that will point to a newly allocated
67 * heartbeat_client_t upon successful return. Must be freed using
68 * heartbeat_client_free() after use.
69 *
70 * @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
71 * client is NULL, or an HEARTBEAT_E_* error code otherwise.
72 */
73heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client) 61heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client)
74{ 62{
75 *client = NULL; 63 *client = NULL;
@@ -97,19 +85,6 @@ heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descr
97 return 0; 85 return 0;
98} 86}
99 87
100/**
101 * Starts a new heartbeat service on the specified device and connects to it.
102 *
103 * @param device The device to connect to.
104 * @param client Pointer that will point to a newly allocated
105 * heartbeat_client_t upon successful return. Must be freed using
106 * heartbeat_client_free() after use.
107 * @param label The label to use for communication. Usually the program name.
108 * Pass NULL to disable sending the label in requests to lockdownd.
109 *
110 * @return HEARTBEAT_E_SUCCESS on success, or an HEARTBEAT_E_* error
111 * code otherwise.
112 */
113heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label) 88heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label)
114{ 89{
115 heartbeat_error_t err = HEARTBEAT_E_UNKNOWN_ERROR; 90 heartbeat_error_t err = HEARTBEAT_E_UNKNOWN_ERROR;
@@ -117,15 +92,6 @@ heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_cli
117 return err; 92 return err;
118} 93}
119 94
120/**
121 * Disconnects a heartbeat client from the device and frees up the
122 * heartbeat client data.
123 *
124 * @param client The heartbeat client to disconnect and free.
125 *
126 * @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
127 * client is NULL, or an HEARTBEAT_E_* error code otherwise.
128 */
129heartbeat_error_t heartbeat_client_free(heartbeat_client_t client) 95heartbeat_error_t heartbeat_client_free(heartbeat_client_t client)
130{ 96{
131 if (!client) 97 if (!client)
@@ -137,15 +103,6 @@ heartbeat_error_t heartbeat_client_free(heartbeat_client_t client)
137 return err; 103 return err;
138} 104}
139 105
140/**
141 * Sends a plist to the service.
142 *
143 * @param client The heartbeat client
144 * @param plist The plist to send
145 *
146 * @return HEARTBEAT_E_SUCCESS on success,
147 * HEARTBEAT_E_INVALID_ARG when client or plist is NULL
148 */
149heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist) 106heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist)
150{ 107{
151 heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR; 108 heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR;
@@ -161,35 +118,11 @@ heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist)
161 return res; 118 return res;
162} 119}
163 120
164/**
165 * Receives a plist from the service.
166 *
167 * @param client The heartbeat client
168 * @param plist The plist to store the received data
169 *
170 * @return HEARTBEAT_E_SUCCESS on success,
171 * HEARTBEAT_E_INVALID_ARG when client or plist is NULL
172 */
173heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist) 121heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist)
174{ 122{
175 return heartbeat_receive_with_timeout(client, plist, 1000); 123 return heartbeat_receive_with_timeout(client, plist, 1000);
176} 124}
177 125
178/**
179 * Receives a plist using the given heartbeat client.
180 *
181 * @param client The heartbeat client to use for receiving
182 * @param plist pointer to a plist_t that will point to the received plist
183 * upon successful return
184 * @param timeout Maximum time in milliseconds to wait for data.
185 *
186 * @return HEARTBEAT_E_SUCCESS on success,
187 * HEARTBEAT_E_INVALID_ARG when client or *plist is NULL,
188 * HEARTBEAT_E_PLIST_ERROR when the received data cannot be
189 * converted to a plist, HEARTBEAT_E_MUX_ERROR when a
190 * communication error occurs, or HEARTBEAT_E_UNKNOWN_ERROR
191 * when an unspecified error occurs.
192 */
193heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms) 126heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms)
194{ 127{
195 heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR; 128 heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR;
diff --git a/src/house_arrest.c b/src/house_arrest.c
index 9aaad34..4158368 100644
--- a/src/house_arrest.c
+++ b/src/house_arrest.c
@@ -55,17 +55,6 @@ static house_arrest_error_t house_arrest_error(property_list_service_error_t err
55 return HOUSE_ARREST_E_UNKNOWN_ERROR; 55 return HOUSE_ARREST_E_UNKNOWN_ERROR;
56} 56}
57 57
58/**
59 * Connects to the house_arrest service on the specified device.
60 *
61 * @param device The device to connect to.
62 * @param service The service descriptor returned by lockdownd_start_service.
63 * @param client Pointer that will point to a newly allocated
64 * housearrest_client_t upon successful return.
65 *
66 * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
67 * client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
68 */
69house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client) 58house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client)
70{ 59{
71 property_list_service_client_t plistclient = NULL; 60 property_list_service_client_t plistclient = NULL;
@@ -82,19 +71,6 @@ house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service
82 return HOUSE_ARREST_E_SUCCESS; 71 return HOUSE_ARREST_E_SUCCESS;
83} 72}
84 73
85/**
86 * Starts a new house_arrest service on the specified device and connects to it.
87 *
88 * @param device The device to connect to.
89 * @param client Pointer that will point to a newly allocated
90 * house_arrest_client_t upon successful return. Must be freed using
91 * house_arrest_client_free() after use.
92 * @param label The label to use for communication. Usually the program name.
93 * Pass NULL to disable sending the label in requests to lockdownd.
94 *
95 * @return HOUSE_ARREST_E_SUCCESS on success, or an HOUSE_ARREST_E_* error
96 * code otherwise.
97 */
98house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t * client, const char* label) 74house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t * client, const char* label)
99{ 75{
100 house_arrest_error_t err = HOUSE_ARREST_E_UNKNOWN_ERROR; 76 house_arrest_error_t err = HOUSE_ARREST_E_UNKNOWN_ERROR;
@@ -102,20 +78,6 @@ house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_a
102 return err; 78 return err;
103} 79}
104 80
105/**
106 * Disconnects an house_arrest client from the device and frees up the
107 * house_arrest client data.
108 *
109 * @note After using afc_client_new_from_house_arrest_client(), make sure
110 * you call afc_client_free() before calling this function to ensure
111 * a proper cleanup. Do not call this function if you still need to
112 * perform AFC operations since it will close the connection.
113 *
114 * @param client The house_arrest client to disconnect and free.
115 *
116 * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
117 * client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
118 */
119house_arrest_error_t house_arrest_client_free(house_arrest_client_t client) 81house_arrest_error_t house_arrest_client_free(house_arrest_client_t client)
120{ 82{
121 if (!client) 83 if (!client)
@@ -131,23 +93,6 @@ house_arrest_error_t house_arrest_client_free(house_arrest_client_t client)
131 return err; 93 return err;
132} 94}
133 95
134/**
135 * Sends a generic request to the connected house_arrest service.
136 *
137 * @param client The house_arrest client to use.
138 * @param dict The request to send as a plist of type PLIST_DICT.
139 *
140 * @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean
141 * that the request was successful. To check for success or failure you
142 * need to call house_arrest_get_result().
143 * @see house_arrest_get_result
144 *
145 * @return HOUSE_ARREST_E_SUCCESS if the request was successfully sent,
146 * HOUSE_ARREST_E_INVALID_ARG if client or dict is invalid,
147 * HOUSE_ARREST_E_PLIST_ERROR if dict is not a plist of type PLIST_DICT,
148 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
149 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
150 */
151house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict) 96house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict)
152{ 97{
153 if (!client || !client->parent || !dict) 98 if (!client || !client->parent || !dict)
@@ -164,25 +109,6 @@ house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, pli
164 return res; 109 return res;
165} 110}
166 111
167/**
168 * Send a command to the connected house_arrest service.
169 * Calls house_arrest_send_request() internally.
170 *
171 * @param client The house_arrest client to use.
172 * @param command The command to send. Currently, only VendContainer and
173 * VendDocuments are known.
174 * @param appid The application identifier to pass along with the .
175 *
176 * @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean
177 * that the command was successful. To check for success or failure you
178 * need to call house_arrest_get_result().
179 * @see house_arrest_get_result
180 *
181 * @return HOUSE_ARREST_E_SUCCESS if the command was successfully sent,
182 * HOUSE_ARREST_E_INVALID_ARG if client, command, or appid is invalid,
183 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
184 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
185 */
186house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid) 112house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid)
187{ 113{
188 if (!client || !client->parent || !command || !appid) 114 if (!client || !client->parent || !command || !appid)
@@ -203,20 +129,6 @@ house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, con
203 return res; 129 return res;
204} 130}
205 131
206/**
207 * Retrieves the result of a previously sent house_arrest_request_* request.
208 *
209 * @param client The house_arrest client to use
210 * @param dict Pointer that will be set to a plist containing the result to
211 * the last performed operation. It holds a key 'Status' with the value
212 * 'Complete' on success or a key 'Error' with an error description as
213 * value. The caller is responsible for freeing the returned plist.
214 *
215 * @return HOUSE_ARREST_E_SUCCESS if a result plist was retrieved,
216 * HOUSE_ARREST_E_INVALID_ARG if client is invalid,
217 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
218 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
219 */
220house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict) 132house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict)
221{ 133{
222 if (!client || !client->parent) 134 if (!client || !client->parent)
@@ -235,25 +147,6 @@ house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist
235 return res; 147 return res;
236} 148}
237 149
238/**
239 * Creates an AFC client using the given house_arrest client's connection
240 * allowing file access to a specific application directory requested by
241 * functions like house_arrest_request_vendor_documents().
242 *
243 * @param client The house_arrest client to use.
244 * @param afc_client Pointer that will be set to a newly allocated afc_client_t
245 * upon successful return.
246 *
247 * @note After calling this function the house_arrest client will go in an
248 * AFC mode that will only allow calling house_arrest_client_free().
249 * Only call house_arrest_client_free() if all AFC operations have
250 * completed since it will close the connection.
251 *
252 * @return AFC_E_SUCCESS if the afc client was successfully created,
253 * AFC_E_INVALID_ARG if client is invalid or was already used to create
254 * an afc client, or an AFC_E_* error code returned by
255 * afc_client_new_with_service_client().
256 */
257afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client) 150afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client)
258{ 151{
259 if (!client || !client->parent || (client->mode == HOUSE_ARREST_CLIENT_MODE_AFC)) { 152 if (!client || !client->parent || (client->mode == HOUSE_ARREST_CLIENT_MODE_AFC)) {
diff --git a/src/idevice.c b/src/idevice.c
index 0577815..eed02fc 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -142,16 +142,6 @@ static void usbmux_event_cb(const usbmuxd_event_t *event, void *user_data)
142 } 142 }
143} 143}
144 144
145/**
146 * Register a callback function that will be called when device add/remove
147 * events occur.
148 *
149 * @param callback Callback function to call.
150 * @param user_data Application-specific data passed as parameter
151 * to the registered callback function.
152 *
153 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
154 */
155idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data) 145idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data)
156{ 146{
157 event_cb = callback; 147 event_cb = callback;
@@ -164,12 +154,6 @@ idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_
164 return IDEVICE_E_SUCCESS; 154 return IDEVICE_E_SUCCESS;
165} 155}
166 156
167/**
168 * Release the event callback function that has been registered with
169 * idevice_event_subscribe().
170 *
171 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
172 */
173idevice_error_t idevice_event_unsubscribe() 157idevice_error_t idevice_event_unsubscribe()
174{ 158{
175 event_cb = NULL; 159 event_cb = NULL;
@@ -181,15 +165,6 @@ idevice_error_t idevice_event_unsubscribe()
181 return IDEVICE_E_SUCCESS; 165 return IDEVICE_E_SUCCESS;
182} 166}
183 167
184/**
185 * Get a list of currently available devices.
186 *
187 * @param devices List of udids of devices that are currently available.
188 * This list is terminated by a NULL pointer.
189 * @param count Number of devices found.
190 *
191 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
192 */
193idevice_error_t idevice_get_device_list(char ***devices, int *count) 168idevice_error_t idevice_get_device_list(char ***devices, int *count)
194{ 169{
195 usbmuxd_device_info_t *dev_list; 170 usbmuxd_device_info_t *dev_list;
@@ -220,13 +195,6 @@ idevice_error_t idevice_get_device_list(char ***devices, int *count)
220 return IDEVICE_E_SUCCESS; 195 return IDEVICE_E_SUCCESS;
221} 196}
222 197
223/**
224 * Free a list of device udids.
225 *
226 * @param devices List of udids to free.
227 *
228 * @return Always returnes IDEVICE_E_SUCCESS.
229 */
230idevice_error_t idevice_device_list_free(char **devices) 198idevice_error_t idevice_device_list_free(char **devices)
231{ 199{
232 if (devices) { 200 if (devices) {
@@ -240,19 +208,6 @@ idevice_error_t idevice_device_list_free(char **devices)
240 return IDEVICE_E_SUCCESS; 208 return IDEVICE_E_SUCCESS;
241} 209}
242 210
243/**
244 * Creates an idevice_t structure for the device specified by udid,
245 * if the device is available.
246 *
247 * @note The resulting idevice_t structure has to be freed with
248 * idevice_free() if it is no longer used.
249 *
250 * @param device Upon calling this function, a pointer to a location of type
251 * idevice_t. On successful return, this location will be populated.
252 * @param udid The UDID to match.
253 *
254 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
255 */
256idevice_error_t idevice_new(idevice_t * device, const char *udid) 211idevice_error_t idevice_new(idevice_t * device, const char *udid)
257{ 212{
258 usbmuxd_device_info_t muxdev; 213 usbmuxd_device_info_t muxdev;
@@ -270,13 +225,6 @@ idevice_error_t idevice_new(idevice_t * device, const char *udid)
270 return IDEVICE_E_NO_DEVICE; 225 return IDEVICE_E_NO_DEVICE;
271} 226}
272 227
273/**
274 * Cleans up an idevice structure, then frees the structure itself.
275 * This is a library-level function; deals directly with the device to tear
276 * down relations, but otherwise is mostly internal.
277 *
278 * @param device idevice_t to free.
279 */
280idevice_error_t idevice_free(idevice_t device) 228idevice_error_t idevice_free(idevice_t device)
281{ 229{
282 if (!device) 230 if (!device)
@@ -297,16 +245,6 @@ idevice_error_t idevice_free(idevice_t device)
297 return ret; 245 return ret;
298} 246}
299 247
300/**
301 * Set up a connection to the given device.
302 *
303 * @param device The device to connect to.
304 * @param port The destination port to connect to.
305 * @param connection Pointer to an idevice_connection_t that will be filled
306 * with the necessary data of the connection.
307 *
308 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
309 */
310idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection) 248idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection)
311{ 249{
312 if (!device) { 250 if (!device) {
@@ -333,13 +271,6 @@ idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connect
333 return IDEVICE_E_UNKNOWN_ERROR; 271 return IDEVICE_E_UNKNOWN_ERROR;
334} 272}
335 273
336/**
337 * Disconnect from the device and clean up the connection structure.
338 *
339 * @param connection The connection to close.
340 *
341 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
342 */
343idevice_error_t idevice_disconnect(idevice_connection_t connection) 274idevice_error_t idevice_disconnect(idevice_connection_t connection)
344{ 275{
345 if (!connection) { 276 if (!connection) {
@@ -390,17 +321,6 @@ static idevice_error_t internal_connection_send(idevice_connection_t connection,
390 321
391} 322}
392 323
393/**
394 * Send data to a device via the given connection.
395 *
396 * @param connection The connection to send data over.
397 * @param data Buffer with data to send.
398 * @param len Size of the buffer to send.
399 * @param sent_bytes Pointer to an uint32_t that will be filled
400 * with the number of bytes actually sent.
401 *
402 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
403 */
404idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes) 324idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes)
405{ 325{
406 if (!connection || !data || (connection->ssl_data && !connection->ssl_data->session)) { 326 if (!connection || !data || (connection->ssl_data && !connection->ssl_data->session)) {
@@ -447,21 +367,6 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t
447 return IDEVICE_E_UNKNOWN_ERROR; 367 return IDEVICE_E_UNKNOWN_ERROR;
448} 368}
449 369
450/**
451 * Receive data from a device via the given connection.
452 * This function will return after the given timeout even if no data has been
453 * received.
454 *
455 * @param connection The connection to receive data from.
456 * @param data Buffer that will be filled with the received data.
457 * This buffer has to be large enough to hold len bytes.
458 * @param len Buffer size or number of bytes to receive.
459 * @param recv_bytes Number of bytes actually received.
460 * @param timeout Timeout in milliseconds after which this function should
461 * return even if no data has been received.
462 *
463 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
464 */
465idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout) 370idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout)
466{ 371{
467 if (!connection || (connection->ssl_data && !connection->ssl_data->session)) { 372 if (!connection || (connection->ssl_data && !connection->ssl_data->session)) {
@@ -516,19 +421,6 @@ static idevice_error_t internal_connection_receive(idevice_connection_t connecti
516 return IDEVICE_E_UNKNOWN_ERROR; 421 return IDEVICE_E_UNKNOWN_ERROR;
517} 422}
518 423
519/**
520 * Receive data from a device via the given connection.
521 * This function is like idevice_connection_receive_timeout, but with a
522 * predefined reasonable timeout.
523 *
524 * @param connection The connection to receive data from.
525 * @param data Buffer that will be filled with the received data.
526 * This buffer has to be large enough to hold len bytes.
527 * @param len Buffer size or number of bytes to receive.
528 * @param recv_bytes Number of bytes actually received.
529 *
530 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
531 */
532idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes) 424idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes)
533{ 425{
534 if (!connection || (connection->ssl_data && !connection->ssl_data->session)) { 426 if (!connection || (connection->ssl_data && !connection->ssl_data->session)) {
@@ -552,9 +444,6 @@ idevice_error_t idevice_connection_receive(idevice_connection_t connection, char
552 return internal_connection_receive(connection, data, len, recv_bytes); 444 return internal_connection_receive(connection, data, len, recv_bytes);
553} 445}
554 446
555/**
556 * Gets the handle of the device. Depends on the connection type.
557 */
558idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) 447idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
559{ 448{
560 if (!device) 449 if (!device)
@@ -569,9 +458,6 @@ idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
569 return IDEVICE_E_UNKNOWN_ERROR; 458 return IDEVICE_E_UNKNOWN_ERROR;
570} 459}
571 460
572/**
573 * Gets the unique id for the device.
574 */
575idevice_error_t idevice_get_udid(idevice_t device, char **udid) 461idevice_error_t idevice_get_udid(idevice_t device, char **udid)
576{ 462{
577 if (!device || !udid) 463 if (!device || !udid)
@@ -741,15 +627,6 @@ static int internal_cert_callback(gnutls_session_t session, const gnutls_datum_t
741} 627}
742#endif 628#endif
743 629
744/**
745 * Enables SSL for the given connection.
746 *
747 * @param connection The connection to enable SSL for.
748 *
749 * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection
750 * is NULL or connection->ssl_data is non-NULL, or IDEVICE_E_SSL_ERROR when
751 * SSL initialization, setup, or handshake fails.
752 */
753idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection) 630idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection)
754{ 631{
755 if (!connection || connection->ssl_data) 632 if (!connection || connection->ssl_data)
@@ -888,15 +765,6 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection)
888 return ret; 765 return ret;
889} 766}
890 767
891/**
892 * Disable SSL for the given connection.
893 *
894 * @param connection The connection to disable SSL for.
895 *
896 * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection
897 * is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not
898 * enabled and does no further error checking on cleanup.
899 */
900idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection) 768idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection)
901{ 769{
902 if (!connection) 770 if (!connection)
diff --git a/src/installation_proxy.c b/src/installation_proxy.c
index 109df10..e3a8103 100644
--- a/src/installation_proxy.c
+++ b/src/installation_proxy.c
@@ -86,17 +86,6 @@ static instproxy_error_t instproxy_error(property_list_service_error_t err)
86 return INSTPROXY_E_UNKNOWN_ERROR; 86 return INSTPROXY_E_UNKNOWN_ERROR;
87} 87}
88 88
89/**
90 * Connects to the installation_proxy service on the specified device.
91 *
92 * @param device The device to connect to
93 * @param service The service descriptor returned by lockdownd_start_service.
94 * @param client Pointer that will be set to a newly allocated
95 * instproxy_client_t upon successful return.
96 *
97 * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value
98 * when an error occured.
99 */
100instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client) 89instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client)
101{ 90{
102 property_list_service_client_t plistclient = NULL; 91 property_list_service_client_t plistclient = NULL;
@@ -114,19 +103,6 @@ instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descr
114 return INSTPROXY_E_SUCCESS; 103 return INSTPROXY_E_SUCCESS;
115} 104}
116 105
117/**
118 * Starts a new installation_proxy service on the specified device and connects to it.
119 *
120 * @param device The device to connect to.
121 * @param client Pointer that will point to a newly allocated
122 * instproxy_client_t upon successful return. Must be freed using
123 * instproxy_client_free() after use.
124 * @param label The label to use for communication. Usually the program name.
125 * Pass NULL to disable sending the label in requests to lockdownd.
126 *
127 * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error
128 * code otherwise.
129 */
130instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label) 106instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label)
131{ 107{
132 instproxy_error_t err = INSTPROXY_E_UNKNOWN_ERROR; 108 instproxy_error_t err = INSTPROXY_E_UNKNOWN_ERROR;
@@ -134,15 +110,6 @@ instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_cli
134 return err; 110 return err;
135} 111}
136 112
137/**
138 * Disconnects an installation_proxy client from the device and frees up the
139 * installation_proxy client data.
140 *
141 * @param client The installation_proxy client to disconnect and free.
142 *
143 * @return INSTPROXY_E_SUCCESS on success
144 * or INSTPROXY_E_INVALID_ARG if client is NULL.
145 */
146instproxy_error_t instproxy_client_free(instproxy_client_t client) 113instproxy_error_t instproxy_client_free(instproxy_client_t client)
147{ 114{
148 if (!client) 115 if (!client)
@@ -195,20 +162,6 @@ static instproxy_error_t instproxy_send_command(instproxy_client_t client, const
195 return err; 162 return err;
196} 163}
197 164
198/**
199 * List installed applications. This function runs synchronously.
200 *
201 * @param client The connected installation_proxy client
202 * @param client_options The client options to use, as PLIST_DICT, or NULL.
203 * Valid client options include:
204 * "ApplicationType" -> "User"
205 * "ApplicationType" -> "System"
206 * @param result Pointer that will be set to a plist that will hold an array
207 * of PLIST_DICT holding information about the applications found.
208 *
209 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
210 * an error occured.
211 */
212instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result) 165instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result)
213{ 166{
214 if (!client || !client->parent || !result) 167 if (!client || !client->parent || !result)
@@ -461,85 +414,16 @@ static instproxy_error_t instproxy_install_or_upgrade(instproxy_client_t client,
461 return instproxy_create_status_updater(client, status_cb, command, user_data); 414 return instproxy_create_status_updater(client, status_cb, command, user_data);
462} 415}
463 416
464/**
465 * Install an application on the device.
466 *
467 * @param client The connected installation_proxy client
468 * @param pkg_path Path of the installation package (inside the AFC jail)
469 * @param client_options The client options to use, as PLIST_DICT, or NULL.
470 * Valid options include:
471 * "iTunesMetadata" -> PLIST_DATA
472 * "ApplicationSINF" -> PLIST_DATA
473 * "PackageType" -> "Developer"
474 * If PackageType -> Developer is specified, then pkg_path points to
475 * an .app directory instead of an install package.
476 * @param status_cb Callback function for progress and status information. If
477 * NULL is passed, this function will run synchronously.
478 * @param user_data Callback data passed to status_cb.
479 *
480 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
481 * an error occured.
482 *
483 * @note If a callback function is given (async mode), this function returns
484 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
485 * created successfully; any error occuring during the operation has to be
486 * handled inside the specified callback function.
487 */
488instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 417instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
489{ 418{
490 return instproxy_install_or_upgrade(client, pkg_path, client_options, status_cb, "Install", user_data); 419 return instproxy_install_or_upgrade(client, pkg_path, client_options, status_cb, "Install", user_data);
491} 420}
492 421
493/**
494 * Upgrade an application on the device. This function is nearly the same as
495 * instproxy_install; the difference is that the installation progress on the
496 * device is faster if the application is already installed.
497 *
498 * @param client The connected installation_proxy client
499 * @param pkg_path Path of the installation package (inside the AFC jail)
500 * @param client_options The client options to use, as PLIST_DICT, or NULL.
501 * Valid options include:
502 * "iTunesMetadata" -> PLIST_DATA
503 * "ApplicationSINF" -> PLIST_DATA
504 * "PackageType" -> "Developer"
505 * If PackageType -> Developer is specified, then pkg_path points to
506 * an .app directory instead of an install package.
507 * @param status_cb Callback function for progress and status information. If
508 * NULL is passed, this function will run synchronously.
509 * @param user_data Callback data passed to status_cb.
510 *
511 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
512 * an error occured.
513 *
514 * @note If a callback function is given (async mode), this function returns
515 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
516 * created successfully; any error occuring during the operation has to be
517 * handled inside the specified callback function.
518 */
519instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 422instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
520{ 423{
521 return instproxy_install_or_upgrade(client, pkg_path, client_options, status_cb, "Upgrade", user_data); 424 return instproxy_install_or_upgrade(client, pkg_path, client_options, status_cb, "Upgrade", user_data);
522} 425}
523 426
524/**
525 * Uninstall an application from the device.
526 *
527 * @param client The connected installation proxy client
528 * @param appid ApplicationIdentifier of the app to uninstall
529 * @param client_options The client options to use, as PLIST_DICT, or NULL.
530 * Currently there are no known client options, so pass NULL here.
531 * @param status_cb Callback function for progress and status information. If
532 * NULL is passed, this function will run synchronously.
533 * @param user_data Callback data passed to status_cb.
534 *
535 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
536 * an error occured.
537 *
538 * @note If a callback function is given (async mode), this function returns
539 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
540 * created successfully; any error occuring during the operation has to be
541 * handled inside the specified callback function.
542 */
543instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 427instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
544{ 428{
545 if (!client || !client->parent || !appid) { 429 if (!client || !client->parent || !appid) {
@@ -564,20 +448,6 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app
564 return instproxy_create_status_updater(client, status_cb, "Uninstall", user_data); 448 return instproxy_create_status_updater(client, status_cb, "Uninstall", user_data);
565} 449}
566 450
567/**
568 * List archived applications. This function runs synchronously.
569 *
570 * @see instproxy_archive
571 *
572 * @param client The connected installation_proxy client
573 * @param client_options The client options to use, as PLIST_DICT, or NULL.
574 * Currently there are no known client options, so pass NULL here.
575 * @param result Pointer that will be set to a plist containing a PLIST_DICT
576 * holding information about the archived applications found.
577 *
578 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
579 * an error occured.
580 */
581instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result) 451instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result)
582{ 452{
583 if (!client || !client->parent || !result) 453 if (!client || !client->parent || !result)
@@ -604,30 +474,6 @@ leave_unlock:
604 return res; 474 return res;
605} 475}
606 476
607/**
608 * Archive an application on the device.
609 * This function tells the device to make an archive of the specified
610 * application. This results in the device creating a ZIP archive in the
611 * 'ApplicationArchives' directory and uninstalling the application.
612 *
613 * @param client The connected installation proxy client
614 * @param appid ApplicationIdentifier of the app to archive.
615 * @param client_options The client options to use, as PLIST_DICT, or NULL.
616 * Valid options include:
617 * "SkipUninstall" -> Boolean
618 * "ArchiveType" -> "ApplicationOnly"
619 * @param status_cb Callback function for progress and status information. If
620 * NULL is passed, this function will run synchronously.
621 * @param user_data Callback data passed to status_cb.
622 *
623 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
624 * an error occured.
625 *
626 * @note If a callback function is given (async mode), this function returns
627 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
628 * created successfully; any error occuring during the operation has to be
629 * handled inside the specified callback function.
630 */
631instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 477instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
632{ 478{
633 if (!client || !client->parent || !appid) 479 if (!client || !client->parent || !appid)
@@ -648,27 +494,6 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid
648 return instproxy_create_status_updater(client, status_cb, "Archive", user_data); 494 return instproxy_create_status_updater(client, status_cb, "Archive", user_data);
649} 495}
650 496
651/**
652 * Restore a previously archived application on the device.
653 * This function is the counterpart to instproxy_archive.
654 * @see instproxy_archive
655 *
656 * @param client The connected installation proxy client
657 * @param appid ApplicationIdentifier of the app to restore.
658 * @param client_options The client options to use, as PLIST_DICT, or NULL.
659 * Currently there are no known client options, so pass NULL here.
660 * @param status_cb Callback function for progress and status information. If
661 * NULL is passed, this function will run synchronously.
662 * @param user_data Callback data passed to status_cb.
663 *
664 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
665 * an error occured.
666 *
667 * @note If a callback function is given (async mode), this function returns
668 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
669 * created successfully; any error occuring during the operation has to be
670 * handled inside the specified callback function.
671 */
672instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 497instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
673{ 498{
674 if (!client || !client->parent || !appid) 499 if (!client || !client->parent || !appid)
@@ -689,27 +514,6 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid
689 return instproxy_create_status_updater(client, status_cb, "Restore", user_data); 514 return instproxy_create_status_updater(client, status_cb, "Restore", user_data);
690} 515}
691 516
692/**
693 * Removes a previously archived application from the device.
694 * This function removes the ZIP archive from the 'ApplicationArchives'
695 * directory.
696 *
697 * @param client The connected installation proxy client
698 * @param appid ApplicationIdentifier of the archived app to remove.
699 * @param client_options The client options to use, as PLIST_DICT, or NULL.
700 * Currently there are no known client options, so passing NULL is fine.
701 * @param status_cb Callback function for progress and status information. If
702 * NULL is passed, this function will run synchronously.
703 * @param user_data Callback data passed to status_cb.
704 *
705 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
706 * an error occured.
707 *
708 * @note If a callback function is given (async mode), this function returns
709 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
710 * created successfully; any error occuring during the operation has to be
711 * handled inside the specified callback function.
712 */
713instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 517instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
714{ 518{
715 if (!client || !client->parent || !appid) 519 if (!client || !client->parent || !appid)
@@ -730,26 +534,11 @@ instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char
730 return instproxy_create_status_updater(client, status_cb, "RemoveArchive", user_data); 534 return instproxy_create_status_updater(client, status_cb, "RemoveArchive", user_data);
731} 535}
732 536
733/**
734 * Create a new client_options plist.
735 *
736 * @return A new plist_t of type PLIST_DICT.
737 */
738plist_t instproxy_client_options_new() 537plist_t instproxy_client_options_new()
739{ 538{
740 return plist_new_dict(); 539 return plist_new_dict();
741} 540}
742 541
743/**
744 * Add one or more new key:value pairs to the given client_options.
745 *
746 * @param client_options The client options to modify.
747 * @param ... KEY, VALUE, [KEY, VALUE], NULL
748 *
749 * @note The keys and values passed are expected to be strings, except for the
750 * keys "ApplicationSINF", "iTunesMetadata", "ReturnAttributes" which are
751 * expecting a plist_t node as value and "SkipUninstall" expects int.
752 */
753void instproxy_client_options_add(plist_t client_options, ...) 542void instproxy_client_options_add(plist_t client_options, ...)
754{ 543{
755 if (!client_options) 544 if (!client_options)
@@ -783,12 +572,6 @@ void instproxy_client_options_add(plist_t client_options, ...)
783 va_end(args); 572 va_end(args);
784} 573}
785 574
786/**
787 * Free client_options plist.
788 *
789 * @param client_options The client options plist to free. Does nothing if NULL
790 * is passed.
791 */
792void instproxy_client_options_free(plist_t client_options) 575void instproxy_client_options_free(plist_t client_options)
793{ 576{
794 if (client_options) { 577 if (client_options) {
@@ -796,21 +579,6 @@ void instproxy_client_options_free(plist_t client_options)
796 } 579 }
797} 580}
798 581
799/**
800 * Query the device for the path of an application.
801 *
802 * @param client The connected installation proxy client.
803 * @param appid ApplicationIdentifier of app to retrieve the path for.
804 * @param path Pointer to store the device path for the application
805 * which is set to NULL if it could not be determined.
806 *
807 * @return INSTPROXY_E_SUCCESS on success, INSTPROXY_E_OP_FAILED if
808 * the path could not be determined or an INSTPROXY_E_* error
809 * value if an error occured.
810 *
811 * @note This implementation browses all applications and matches the
812 * right entry by the application identifier.
813 */
814instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* appid, char** path) 582instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* appid, char** path)
815{ 583{
816 if (!client || !client->parent || !appid) 584 if (!client || !client->parent || !appid)
diff --git a/src/lockdown.c b/src/lockdown.c
index 9b579e8..cf03e0f 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -154,16 +154,6 @@ static void plist_dict_add_label(plist_t plist, const char *label)
154 } 154 }
155} 155}
156 156
157/**
158 * Closes the lockdownd session by sending the StopSession request.
159 *
160 * @see lockdownd_start_session
161 *
162 * @param client The lockdown client
163 * @param session_id The id of a running session
164 *
165 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
166 */
167lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id) 157lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id)
168{ 158{
169 if (!client) 159 if (!client)
@@ -247,14 +237,6 @@ static lockdownd_error_t lockdownd_client_free_simple(lockdownd_client_t client)
247 return ret; 237 return ret;
248} 238}
249 239
250/**
251 * Closes the lockdownd client session if one is running and frees up the
252 * lockdownd_client struct.
253 *
254 * @param client The lockdown client
255 *
256 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
257 */
258lockdownd_error_t lockdownd_client_free(lockdownd_client_t client) 240lockdownd_error_t lockdownd_client_free(lockdownd_client_t client)
259{ 241{
260 if (!client) 242 if (!client)
@@ -271,13 +253,6 @@ lockdownd_error_t lockdownd_client_free(lockdownd_client_t client)
271 return ret; 253 return ret;
272} 254}
273 255
274/**
275 * Sets the label to send for requests to lockdownd.
276 *
277 * @param client The lockdown client
278 * @param label The label to set or NULL to disable sending a label
279 *
280 */
281void lockdownd_client_set_label(lockdownd_client_t client, const char *label) 256void lockdownd_client_set_label(lockdownd_client_t client, const char *label)
282{ 257{
283 if (client) { 258 if (client) {
@@ -288,15 +263,6 @@ void lockdownd_client_set_label(lockdownd_client_t client, const char *label)
288 } 263 }
289} 264}
290 265
291/**
292 * Receives a plist from lockdownd.
293 *
294 * @param client The lockdownd client
295 * @param plist The plist to store the received data
296 *
297 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
298 * plist is NULL
299 */
300lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist) 266lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist)
301{ 267{
302 if (!client || !plist || (plist && *plist)) 268 if (!client || !plist || (plist && *plist))
@@ -315,18 +281,6 @@ lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist)
315 return ret; 281 return ret;
316} 282}
317 283
318/**
319 * Sends a plist to lockdownd.
320 *
321 * @note This function is low-level and should only be used if you need to send
322 * a new type of message.
323 *
324 * @param client The lockdownd client
325 * @param plist The plist to send
326 *
327 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
328 * plist is NULL
329 */
330lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist) 284lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
331{ 285{
332 if (!client || !plist) 286 if (!client || !plist)
@@ -342,15 +296,6 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
342 return ret; 296 return ret;
343} 297}
344 298
345/**
346 * Query the type of the service daemon. Depending on whether the device is
347 * queried in normal mode or restore mode, different types will be returned.
348 *
349 * @param client The lockdownd client
350 * @param type The type returned by the service daemon. Pass NULL to ignore.
351 *
352 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
353 */
354lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type) 299lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
355{ 300{
356 if (!client) 301 if (!client)
@@ -396,16 +341,6 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
396 return ret; 341 return ret;
397} 342}
398 343
399/**
400 * Retrieves a preferences plist using an optional domain and/or key name.
401 *
402 * @param client An initialized lockdownd client.
403 * @param domain The domain to query on or NULL for global domain
404 * @param key The key name to request or NULL to query for all keys
405 * @param value A plist node representing the result value node
406 *
407 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
408 */
409lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value) 344lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value)
410{ 345{
411 if (!client) 346 if (!client)
@@ -461,17 +396,6 @@ lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *dom
461 return ret; 396 return ret;
462} 397}
463 398
464/**
465 * Sets a preferences value using a plist and optional by domain and/or key name.
466 *
467 * @param client an initialized lockdownd client.
468 * @param domain the domain to query on or NULL for global domain
469 * @param key the key name to set the value or NULL to set a value dict plist
470 * @param value a plist node of any node type representing the value to set
471 *
472 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
473 * value is NULL
474 */
475lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value) 399lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value)
476{ 400{
477 if (!client || !value) 401 if (!client || !value)
@@ -520,17 +444,6 @@ lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *dom
520 return ret; 444 return ret;
521} 445}
522 446
523/**
524 * Removes a preference node by domain and/or key name.
525 *
526 * @note: Use with caution as this could remove vital information on the device
527 *
528 * @param client An initialized lockdownd client.
529 * @param domain The domain to query on or NULL for global domain
530 * @param key The key name to remove or NULL remove all keys for the current domain
531 *
532 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
533 */
534lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key) 447lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key)
535{ 448{
536 if (!client) 449 if (!client)
@@ -578,15 +491,6 @@ lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *
578 return ret; 491 return ret;
579} 492}
580 493
581/**
582 * Returns the unique id of the device from lockdownd.
583 *
584 * @param client An initialized lockdownd client.
585 * @param udid Holds the unique id of the device. The caller is responsible
586 * for freeing the memory.
587 *
588 * @return LOCKDOWN_E_SUCCESS on success
589 */
590lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid) 494lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid)
591{ 495{
592 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; 496 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
@@ -633,15 +537,6 @@ static lockdownd_error_t lockdownd_get_device_public_key_as_key_data(lockdownd_c
633 return ret; 537 return ret;
634} 538}
635 539
636/**
637 * Retrieves the name of the device from lockdownd set by the user.
638 *
639 * @param client An initialized lockdownd client.
640 * @param device_name Holds the name of the device. The caller is
641 * responsible for freeing the memory.
642 *
643 * @return LOCKDOWN_E_SUCCESS on success
644 */
645lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name) 540lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name)
646{ 541{
647 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; 542 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
@@ -659,21 +554,6 @@ lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **de
659 return ret; 554 return ret;
660} 555}
661 556
662/**
663 * Creates a new lockdownd client for the device.
664 *
665 * @note This function does not pair with the device or start a session. This
666 * has to be done manually by the caller after the client is created.
667 * The device disconnects automatically if the lockdown connection idles
668 * for more than 10 seconds. Make sure to call lockdownd_client_free() as soon
669 * as the connection is no longer needed.
670 *
671 * @param device The device to create a lockdownd client for
672 * @param client The pointer to the location of the new lockdownd_client
673 * @param label The label to use for communication. Usually the program name.
674 *
675 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
676 */
677lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label) 557lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label)
678{ 558{
679 if (!client) 559 if (!client)
@@ -707,23 +587,6 @@ lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *cli
707 return LOCKDOWN_E_SUCCESS; 587 return LOCKDOWN_E_SUCCESS;
708} 588}
709 589
710/**
711 * Creates a new lockdownd client for the device and starts initial handshake.
712 * The handshake consists out of query_type, validate_pair, pair and
713 * start_session calls. It uses the internal pairing record management.
714 *
715 * @note The device disconnects automatically if the lockdown connection idles
716 * for more than 10 seconds. Make sure to call lockdownd_client_free() as soon
717 * as the connection is no longer needed.
718 *
719 * @param device The device to create a lockdownd client for
720 * @param client The pointer to the location of the new lockdownd_client
721 * @param label The label to use for communication. Usually the program name.
722 * Pass NULL to disable sending the label in requests to lockdownd.
723 *
724 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
725 * LOCKDOWN_E_INVALID_CONF if configuration data is wrong
726 */
727lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label) 590lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label)
728{ 591{
729 if (!client) 592 if (!client)
@@ -1091,73 +954,21 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_
1091 return ret; 954 return ret;
1092} 955}
1093 956
1094/**
1095 * Pairs the device using the supplied pair record.
1096 *
1097 * @param client The lockdown client to pair with.
1098 * @param pair_record The pair record to use for pairing. If NULL is passed, then
1099 * the pair records from the current machine are used. New records will be
1100 * generated automatically when pairing is done for the first time.
1101 *
1102 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
1103 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
1104 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
1105 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
1106 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
1107 */
1108lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 957lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1109{ 958{
1110 return lockdownd_do_pair(client, pair_record, "Pair"); 959 return lockdownd_do_pair(client, pair_record, "Pair");
1111} 960}
1112 961
1113/**
1114 * Validates if the device is paired with the given HostID. If succeeded them
1115 * specified host will become trusted host of the device indicated by the
1116 * lockdownd preference named TrustedHostAttached. Otherwise the host must because
1117 * paired using lockdownd_pair() first.
1118 *
1119 * @param client The lockdown client to pair with.
1120 * @param pair_record The pair record to validate pairing with. If NULL is
1121 * passed, then the pair record is read from the internal pairing record
1122 * management.
1123 *
1124 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
1125 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
1126 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
1127 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
1128 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
1129 */
1130lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 962lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1131{ 963{
1132 return lockdownd_do_pair(client, pair_record, "ValidatePair"); 964 return lockdownd_do_pair(client, pair_record, "ValidatePair");
1133} 965}
1134 966
1135/**
1136 * Unpairs the device with the given HostID and removes the pairing records
1137 * from the device and host if the internal pairing record management is used.
1138 *
1139 * @param client The lockdown client to pair with.
1140 * @param pair_record The pair record to use for unpair. If NULL is passed, then
1141 * the pair records from the current machine are used.
1142 *
1143 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
1144 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
1145 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
1146 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
1147 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
1148 */
1149lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 967lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1150{ 968{
1151 return lockdownd_do_pair(client, pair_record, "Unpair"); 969 return lockdownd_do_pair(client, pair_record, "Unpair");
1152} 970}
1153 971
1154/**
1155 * Tells the device to immediately enter recovery mode.
1156 *
1157 * @param client The lockdown client
1158 *
1159 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
1160 */
1161lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client) 972lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
1162{ 973{
1163 if (!client) 974 if (!client)
@@ -1186,15 +997,6 @@ lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
1186 return ret; 997 return ret;
1187} 998}
1188 999
1189/**
1190 * Sends the Goodbye request to lockdownd signaling the end of communication.
1191 *
1192 * @param client The lockdown client
1193 *
1194 * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client
1195 * is NULL, LOCKDOWN_E_PLIST_ERROR if the device did not acknowledge the
1196 * request
1197 */
1198lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client) 1000lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
1199{ 1001{
1200 if (!client) 1002 if (!client)
@@ -1228,19 +1030,6 @@ lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
1228 return ret; 1030 return ret;
1229} 1031}
1230 1032
1231/**
1232 * Opens a session with lockdownd and switches to SSL mode if device wants it.
1233 *
1234 * @param client The lockdownd client
1235 * @param host_id The HostID of the computer
1236 * @param session_id The new session_id of the created session
1237 * @param ssl_enabled Whether SSL communication is used in the session
1238 *
1239 * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when a client
1240 * or host_id is NULL, LOCKDOWN_E_PLIST_ERROR if the response plist had errors,
1241 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the supplied HostID,
1242 * LOCKDOWN_E_SSL_ERROR if enabling SSL communication failed
1243 */
1244lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled) 1033lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled)
1245{ 1034{
1246 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; 1035 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
@@ -1345,18 +1134,6 @@ lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char
1345 return ret; 1134 return ret;
1346} 1135}
1347 1136
1348/**
1349 * Requests to start a service and retrieve it's port on success.
1350 *
1351 * @param client The lockdownd client
1352 * @param identifier The identifier of the service to start
1353 * @param descriptor The service descriptor on success or NULL on failure
1354
1355 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
1356 * is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known
1357 * by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not because
1358 * started by the device
1359 */
1360lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service) 1137lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service)
1361{ 1138{
1362 if (!client || !identifier || !service) 1139 if (!client || !identifier || !service)
@@ -1442,24 +1219,7 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
1442 return ret; 1219 return ret;
1443} 1220}
1444 1221
1445/** 1222lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record)
1446 * Activates the device. Only works within an open session.
1447 * The ActivationRecord plist dictionary must be obtained using the
1448 * activation protocol requesting from Apple's https webservice.
1449 *
1450 * @see http://iphone-docs.org/doku.php?id=docs:protocols:activation
1451 *
1452 * @param client The lockdown client
1453 * @param activation_record The activation record plist dictionary
1454 *
1455 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
1456 * activation_record is NULL, LOCKDOWN_E_NO_RUNNING_SESSION if no session is
1457 * open, LOCKDOWN_E_PLIST_ERROR if the received plist is broken,
1458 * LOCKDOWN_E_ACTIVATION_FAILED if the activation failed,
1459 * LOCKDOWN_E_INVALID_ACTIVATION_RECORD if the device reports that the
1460 * activation_record is invalid
1461 */
1462lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record)
1463{ 1223{
1464 if (!client) 1224 if (!client)
1465 return LOCKDOWN_E_INVALID_ARG; 1225 return LOCKDOWN_E_INVALID_ARG;
@@ -1510,16 +1270,6 @@ lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activati
1510 return ret; 1270 return ret;
1511} 1271}
1512 1272
1513/**
1514 * Deactivates the device, returning it to the locked “Activate with iTunes”
1515 * screen.
1516 *
1517 * @param client The lockdown client
1518 *
1519 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
1520 * LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
1521 * LOCKDOWN_E_PLIST_ERROR if the received plist is broken
1522 */
1523lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client) 1273lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client)
1524{ 1274{
1525 if (!client) 1275 if (!client)
@@ -1567,19 +1317,6 @@ static void str_remove_spaces(char *source)
1567 *dest = 0; 1317 *dest = 0;
1568} 1318}
1569 1319
1570/**
1571 * Calculates and returns the data classes the device supports from lockdownd.
1572 *
1573 * @param client An initialized lockdownd client.
1574 * @param classes A pointer to store an array of class names. The caller is responsible
1575 * for freeing the memory which can be done using mobilesync_data_classes_free().
1576 * @param count The number of items in the classes array.
1577 *
1578 * @return LOCKDOWN_E_SUCCESS on success,
1579 * LOCKDOWN_E_INVALID_ARG when client is NULL,
1580 * LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
1581 * LOCKDOWN_E_PLIST_ERROR if the received plist is broken
1582 */
1583lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count) 1320lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count)
1584{ 1321{
1585 if (!client) 1322 if (!client)
@@ -1634,13 +1371,6 @@ lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, cha
1634} 1371}
1635 1372
1636 1373
1637/**
1638 * Frees memory of an allocated array of data classes as returned by lockdownd_get_sync_data_classes()
1639 *
1640 * @param classes An array of class names to free.
1641 *
1642 * @return LOCKDOWN_E_SUCCESS on success
1643 */
1644lockdownd_error_t lockdownd_data_classes_free(char **classes) 1374lockdownd_error_t lockdownd_data_classes_free(char **classes)
1645{ 1375{
1646 if (classes) { 1376 if (classes) {
@@ -1653,13 +1383,6 @@ lockdownd_error_t lockdownd_data_classes_free(char **classes)
1653 return LOCKDOWN_E_SUCCESS; 1383 return LOCKDOWN_E_SUCCESS;
1654} 1384}
1655 1385
1656/**
1657 * Frees memory of a service descriptor as returned by lockdownd_start_service()
1658 *
1659 * @param sevice A service descriptor instance to free.
1660 *
1661 * @return LOCKDOWN_E_SUCCESS on success
1662 */
1663lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service) 1386lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service)
1664{ 1387{
1665 if (service) 1388 if (service)
diff --git a/src/misagent.c b/src/misagent.c
index 6edbadd..96dddba 100644
--- a/src/misagent.c
+++ b/src/misagent.c
@@ -87,17 +87,6 @@ static misagent_error_t misagent_check_result(plist_t response, int* status_code
87 } 87 }
88} 88}
89 89
90/**
91 * Connects to the misagent service on the specified device.
92 *
93 * @param device The device to connect to.
94 * @param service The service descriptor returned by lockdownd_start_service.
95 * @param client Pointer that will point to a newly allocated
96 * misagent_client_t upon successful return.
97 *
98 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
99 * client is NULL, or an MISAGENT_E_* error code otherwise.
100 */
101misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client) 90misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client)
102{ 91{
103 property_list_service_client_t plistclient = NULL; 92 property_list_service_client_t plistclient = NULL;
@@ -114,19 +103,6 @@ misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descrip
114 return MISAGENT_E_SUCCESS; 103 return MISAGENT_E_SUCCESS;
115} 104}
116 105
117/**
118 * Starts a new misagent service on the specified device and connects to it.
119 *
120 * @param device The device to connect to.
121 * @param client Pointer that will point to a newly allocated
122 * misagent_client_t upon successful return. Must be freed using
123 * misagent_client_free() after use.
124 * @param label The label to use for communication. Usually the program name.
125 * Pass NULL to disable sending the label in requests to lockdownd.
126 *
127 * @return MISAGENT_E_SUCCESS on success, or an MISAGENT_E_* error
128 * code otherwise.
129 */
130misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t * client, const char* label) 106misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t * client, const char* label)
131{ 107{
132 misagent_error_t err = MISAGENT_E_UNKNOWN_ERROR; 108 misagent_error_t err = MISAGENT_E_UNKNOWN_ERROR;
@@ -134,15 +110,6 @@ misagent_error_t misagent_client_start_service(idevice_t device, misagent_client
134 return err; 110 return err;
135} 111}
136 112
137/**
138 * Disconnects an misagent client from the device and frees up the
139 * misagent client data.
140 *
141 * @param client The misagent client to disconnect and free.
142 *
143 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
144 * client is NULL, or an MISAGENT_E_* error code otherwise.
145 */
146misagent_error_t misagent_client_free(misagent_client_t client) 113misagent_error_t misagent_client_free(misagent_client_t client)
147{ 114{
148 if (!client) 115 if (!client)
@@ -158,16 +125,6 @@ misagent_error_t misagent_client_free(misagent_client_t client)
158 return err; 125 return err;
159} 126}
160 127
161/**
162 * Installs the given provisioning profile. Only works with valid profiles.
163 *
164 * @param client The connected misagent to use for installation
165 * @param profile The valid provisioning profile to install. This has to be
166 * passed as a PLIST_DATA, otherwise the function will fail.
167 *
168 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
169 * client is invalid, or an MISAGENT_E_* error code otherwise.
170 */
171misagent_error_t misagent_install(misagent_client_t client, plist_t profile) 128misagent_error_t misagent_install(misagent_client_t client, plist_t profile)
172{ 129{
173 if (!client || !client->parent || !profile || (plist_get_node_type(profile) != PLIST_DATA)) 130 if (!client || !client->parent || !profile || (plist_get_node_type(profile) != PLIST_DATA))
@@ -205,20 +162,6 @@ misagent_error_t misagent_install(misagent_client_t client, plist_t profile)
205 return res; 162 return res;
206} 163}
207 164
208/**
209 * Retrieves an array of all installed provisioning profiles.
210 *
211 * @param client The connected misagent to use.
212 * @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY
213 * if the function is successful.
214 *
215 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
216 * client is invalid, or an MISAGENT_E_* error code otherwise.
217 *
218 * @note If no provisioning profiles are installed on the device, this function
219 * still returns MISAGENT_E_SUCCESS and profiles will just point to an
220 * empty array.
221 */
222misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles) 165misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles)
223{ 166{
224 if (!client || !client->parent || !profiles) 167 if (!client || !client->parent || !profiles)
@@ -259,17 +202,6 @@ misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles)
259 202
260} 203}
261 204
262/**
263 * Removes a given provisioning profile.
264 *
265 * @param client The connected misagent to use.
266 * @param profileID Identifier of the provisioning profile to remove.
267 * This is a UUID that can be obtained from the provisioning profile data.
268 * @see misagent_copy
269 *
270 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
271 * client is invalid, or an MISAGENT_E_* error code otherwise.
272 */
273misagent_error_t misagent_remove(misagent_client_t client, const char* profileID) 205misagent_error_t misagent_remove(misagent_client_t client, const char* profileID)
274{ 206{
275 if (!client || !client->parent || !profileID) 207 if (!client || !client->parent || !profileID)
@@ -307,13 +239,6 @@ misagent_error_t misagent_remove(misagent_client_t client, const char* profileID
307 return res; 239 return res;
308} 240}
309 241
310/**
311 * Retrieves the status code from the last operation.
312 *
313 * @param client The misagent to use.
314 *
315 * @return -1 if client is invalid, or the status code from the last operation
316 */
317int misagent_get_status_code(misagent_client_t client) 242int misagent_get_status_code(misagent_client_t client)
318{ 243{
319 if (!client) { 244 if (!client) {
diff --git a/src/mobile_image_mounter.c b/src/mobile_image_mounter.c
index 4b2818d..7133b8b 100644
--- a/src/mobile_image_mounter.c
+++ b/src/mobile_image_mounter.c
@@ -75,19 +75,6 @@ static mobile_image_mounter_error_t mobile_image_mounter_error(property_list_ser
75 return MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR; 75 return MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR;
76} 76}
77 77
78/**
79 * Connects to the mobile_image_mounter service on the specified device.
80 *
81 * @param device The device to connect to.
82 * @param service The service descriptor returned by lockdownd_start_service.
83 * @param client Pointer that will be set to a newly allocated
84 * mobile_image_mounter_client_t upon successful return.
85 *
86 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
87 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if device is NULL,
88 * or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the
89 * device could not be established.
90 */
91mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client) 78mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client)
92{ 79{
93 property_list_service_client_t plistclient = NULL; 80 property_list_service_client_t plistclient = NULL;
@@ -105,19 +92,6 @@ mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdown
105 return MOBILE_IMAGE_MOUNTER_E_SUCCESS; 92 return MOBILE_IMAGE_MOUNTER_E_SUCCESS;
106} 93}
107 94
108/**
109 * Starts a new mobile_image_mounter service on the specified device and connects to it.
110 *
111 * @param device The device to connect to.
112 * @param client Pointer that will point to a newly allocated
113 * mobile_image_mounter_t upon successful return. Must be freed using
114 * mobile_image_mounter_free() after use.
115 * @param label The label to use for communication. Usually the program name.
116 * Pass NULL to disable sending the label in requests to lockdownd.
117 *
118 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an MOBILE_IMAGE_MOUNTER_E_* error
119 * code otherwise.
120 */
121mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t * client, const char* label) 95mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t * client, const char* label)
122{ 96{
123 mobile_image_mounter_error_t err = MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR; 97 mobile_image_mounter_error_t err = MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR;
@@ -125,15 +99,6 @@ mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device
125 return err; 99 return err;
126} 100}
127 101
128/**
129 * Disconnects a mobile_image_mounter client from the device and frees up the
130 * mobile_image_mounter client data.
131 *
132 * @param client The mobile_image_mounter client to disconnect and free.
133 *
134 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
135 * or MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is NULL.
136 */
137mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client) 102mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client)
138{ 103{
139 if (!client) 104 if (!client)
@@ -147,19 +112,6 @@ mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_clie
147 return MOBILE_IMAGE_MOUNTER_E_SUCCESS; 112 return MOBILE_IMAGE_MOUNTER_E_SUCCESS;
148} 113}
149 114
150/**
151 * Tells if the image of ImageType is already mounted.
152 *
153 * @param client The client use
154 * @param image_type The type of the image to look up
155 * @param result Pointer to a plist that will receive the result of the
156 * operation.
157 *
158 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
159 * operation has failed. Check the resulting plist for further information.
160 *
161 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an error code on error
162 */
163mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result) 115mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result)
164{ 116{
165 if (!client || !image_type || !result) { 117 if (!client || !image_type || !result) {
@@ -189,19 +141,6 @@ leave_unlock:
189 return res; 141 return res;
190} 142}
191 143
192/**
193 * Uploads an image to the device.
194 *
195 * @param client The connected mobile_image_mounter client.
196 * @param image_type Type of image that is being uploaded.
197 * @param image_size Total size of the image.
198 * @param upload_cb Callback function that gets the data chunks for uploading
199 * the image.
200 * @param userdata User defined data for the upload callback function.
201 *
202 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a
203 * MOBILE_IMAGE_MOUNTER_E_* error code otherwise.
204 */
205mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata) 144mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata)
206{ 145{
207 if (!client || !image_type || (image_size == 0) || !upload_cb) { 146 if (!client || !image_type || (image_size == 0) || !upload_cb) {
@@ -311,27 +250,6 @@ leave_unlock:
311 250
312} 251}
313 252
314/**
315 * Mounts an image on the device.
316 *
317 * @param client The connected mobile_image_mounter client.
318 * @param image_path The absolute path of the image to mount. The image must
319 * be present before calling this function.
320 * @param image_signature Pointer to a buffer holding the images' signature
321 * @param signature_length Length of the signature image_signature points to
322 * @param image_type Type of image to mount
323 * @param result Pointer to a plist that will receive the result of the
324 * operation.
325 *
326 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
327 * operation has failed. Check the resulting plist for further information.
328 * Note that there is no unmounting function. The mount persists until the
329 * device is rebooted.
330 *
331 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
332 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are
333 * invalid, or another error code otherwise.
334 */
335mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result) 253mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result)
336{ 254{
337 if (!client || !image_path || !image_signature || (signature_length == 0) || !image_type || !result) { 255 if (!client || !image_path || !image_signature || (signature_length == 0) || !image_type || !result) {
@@ -363,17 +281,6 @@ leave_unlock:
363 return res; 281 return res;
364} 282}
365 283
366/**
367 * Hangs up the connection to the mobile_image_mounter service.
368 * This functions has to be called before freeing up a mobile_image_mounter
369 * instance. If not, errors appear in the device's syslog.
370 *
371 * @param client The client to hang up
372 *
373 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
374 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is invalid,
375 * or another error code otherwise.
376 */
377mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client) 284mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client)
378{ 285{
379 if (!client) { 286 if (!client) {
diff --git a/src/mobilebackup.c b/src/mobilebackup.c
index 66e590a..7107d12 100644
--- a/src/mobilebackup.c
+++ b/src/mobilebackup.c
@@ -60,18 +60,6 @@ static mobilebackup_error_t mobilebackup_error(device_link_service_error_t err)
60 return MOBILEBACKUP_E_UNKNOWN_ERROR; 60 return MOBILEBACKUP_E_UNKNOWN_ERROR;
61} 61}
62 62
63/**
64 * Connects to the mobilebackup service on the specified device.
65 *
66 * @param device The device to connect to.
67 * @param service The service descriptor returned by lockdownd_start_service.
68 * @param client Pointer that will be set to a newly allocated
69 * mobilebackup_client_t upon successful return.
70 *
71 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID ARG if one
72 * or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if
73 * the mobilebackup version on the device is newer.
74 */
75mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client) 63mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client)
76{ 64{
77 if (!device || !service || service->port == 0 || !client || *client) 65 if (!device || !service || service->port == 0 || !client || *client)
@@ -99,19 +87,6 @@ mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service
99 return ret; 87 return ret;
100} 88}
101 89
102/**
103 * Starts a new mobilebackup service on the specified device and connects to it.
104 *
105 * @param device The device to connect to.
106 * @param client Pointer that will point to a newly allocated
107 * mobilebackup_client_t upon successful return. Must be freed using
108 * mobilebackup_client_free() after use.
109 * @param label The label to use for communication. Usually the program name.
110 * Pass NULL to disable sending the label in requests to lockdownd.
111 *
112 * @return MOBILEBACKUP_E_SUCCESS on success, or an MOBILEBACKUP_E_* error
113 * code otherwise.
114 */
115mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t * client, const char* label) 90mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t * client, const char* label)
116{ 91{
117 mobilebackup_error_t err = MOBILEBACKUP_E_UNKNOWN_ERROR; 92 mobilebackup_error_t err = MOBILEBACKUP_E_UNKNOWN_ERROR;
@@ -119,15 +94,6 @@ mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobileb
119 return err; 94 return err;
120} 95}
121 96
122/**
123 * Disconnects a mobilebackup client from the device and frees up the
124 * mobilebackup client data.
125 *
126 * @param client The mobilebackup client to disconnect and free.
127 *
128 * @return MOBILEBACKUP_E_SUCCESS on success, or MOBILEBACKUP_E_INVALID_ARG
129 * if client is NULL.
130 */
131mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client) 97mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client)
132{ 98{
133 if (!client) 99 if (!client)
@@ -141,14 +107,6 @@ mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client)
141 return err; 107 return err;
142} 108}
143 109
144/**
145 * Polls the device for mobilebackup data.
146 *
147 * @param client The mobilebackup client
148 * @param plist A pointer to the location where the plist should be stored
149 *
150 * @return an error code
151 */
152mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * plist) 110mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * plist)
153{ 111{
154 if (!client) 112 if (!client)
@@ -157,17 +115,6 @@ mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t
157 return ret; 115 return ret;
158} 116}
159 117
160/**
161 * Sends mobilebackup data to the device
162 *
163 * @note This function is low-level and should only be used if you need to send
164 * a new type of message.
165 *
166 * @param client The mobilebackup client
167 * @param plist The location of the plist to send
168 *
169 * @return an error code
170 */
171mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist) 118mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist)
172{ 119{
173 if (!client || !plist) 120 if (!client || !plist)
@@ -285,23 +232,6 @@ leave:
285 return err; 232 return err;
286} 233}
287 234
288/**
289 * Request a backup from the connected device.
290 *
291 * @param client The connected MobileBackup client to use.
292 * @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
293 * containing the backup state of the last backup. For a first-time backup
294 * set this parameter to NULL.
295 * @param base_path The base path on the device to use for the backup
296 * operation, usually "/".
297 * @param proto_version A string denoting the version of the backup protocol
298 * to use. Latest known version is "1.6"
299 *
300 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
301 * one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
302 * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
303 * if a communication error occurs, MOBILEBACKUP_E_REPLY_NOT_OK
304 */
305mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version) 235mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version)
306{ 236{
307 if (!client || !client->parent || !base_path || !proto_version) 237 if (!client || !client->parent || !base_path || !proto_version)
@@ -362,41 +292,11 @@ leave:
362 return err; 292 return err;
363} 293}
364 294
365/**
366 * Sends a confirmation to the device that a backup file has been received.
367 *
368 * @param client The connected MobileBackup client to use.
369 *
370 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
371 * client is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication error
372 * occurs.
373 */
374mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client) 295mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client)
375{ 296{
376 return mobilebackup_send_message(client, "kBackupMessageBackupFileReceived", NULL); 297 return mobilebackup_send_message(client, "kBackupMessageBackupFileReceived", NULL);
377} 298}
378 299
379/**
380 * Request that a backup should be restored to the connected device.
381 *
382 * @param client The connected MobileBackup client to use.
383 * @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
384 * containing the backup state to be restored.
385 * @param flags Flags to send with the request. Currently this is a combination
386 * of the following mobilebackup_flags_t:
387 * MB_RESTORE_NOTIFY_SPRINGBOARD - let SpringBoard show a 'Restore' screen
388 * MB_RESTORE_PRESERVE_SETTINGS - do not overwrite any settings
389 * MB_RESTORE_PRESERVE_CAMERA_ROLL - preserve the photos of the camera roll
390 * @param proto_version A string denoting the version of the backup protocol
391 * to use. Latest known version is "1.6". Ideally this value should be
392 * extracted from the given manifest plist.
393 *
394 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
395 * one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
396 * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
397 * if a communication error occurs, or MOBILEBACKUP_E_REPLY_NOT_OK
398 * if the device did not accept the request.
399 */
400mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version) 300mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version)
401{ 301{
402 if (!client || !client->parent || !backup_manifest || !proto_version) 302 if (!client || !client->parent || !backup_manifest || !proto_version)
@@ -451,63 +351,16 @@ leave:
451 return err; 351 return err;
452} 352}
453 353
454/**
455 * Receive a confirmation from the device that it successfully received
456 * a restore file.
457 *
458 * @param client The connected MobileBackup client to use.
459 * @param result Pointer to a plist_t that will be set to the received plist
460 * for further processing. The caller has to free it using plist_free().
461 * Note that it will be set to NULL if the operation itself fails due to
462 * a communication or plist error.
463 * If this parameter is NULL, it will be ignored.
464 *
465 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
466 * client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
467 * 'BackupMessageRestoreFileReceived' message could not be received,
468 * MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
469 * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
470 * occurs.
471 */
472mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result) 354mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result)
473{ 355{
474 return mobilebackup_receive_message(client, "BackupMessageRestoreFileReceived", result); 356 return mobilebackup_receive_message(client, "BackupMessageRestoreFileReceived", result);
475} 357}
476 358
477/**
478 * Receive a confirmation from the device that it successfully received
479 * application data file.
480 *
481 * @param client The connected MobileBackup client to use.
482 * @param result Pointer to a plist_t that will be set to the received plist
483 * for further processing. The caller has to free it using plist_free().
484 * Note that it will be set to NULL if the operation itself fails due to
485 * a communication or plist error.
486 * If this parameter is NULL, it will be ignored.
487 *
488 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
489 * client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
490 * 'BackupMessageRestoreApplicationReceived' message could not be received,
491 * MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
492 * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
493 * occurs.
494 */
495mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result) 359mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result)
496{ 360{
497 return mobilebackup_receive_message(client, "BackupMessageRestoreApplicationReceived", result); 361 return mobilebackup_receive_message(client, "BackupMessageRestoreApplicationReceived", result);
498} 362}
499 363
500/**
501 * Tells the device that the restore process is complete and waits for the
502 * device to close the connection. After that, the device should reboot.
503 *
504 * @param client The connected MobileBackup client to use.
505 *
506 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
507 * client is invalid, MOBILEBACKUP_E_PLIST_ERROR if the received disconnect
508 * message plist is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication
509 * error occurs.
510 */
511mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client) 364mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client)
512{ 365{
513 mobilebackup_error_t err = mobilebackup_send_message(client, "BackupMessageRestoreComplete", NULL); 366 mobilebackup_error_t err = mobilebackup_send_message(client, "BackupMessageRestoreComplete", NULL);
@@ -553,16 +406,6 @@ mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t cl
553 return err; 406 return err;
554} 407}
555 408
556/**
557 * Sends a backup error message to the device.
558 *
559 * @param client The connected MobileBackup client to use.
560 * @param reason A string describing the reason for the error message.
561 *
562 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
563 * one of the parameters is invalid, or MOBILEBACKUP_E_MUX_ERROR if a
564 * communication error occurs.
565 */
566mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason) 409mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason)
567{ 410{
568 if (!client || !client->parent || !reason) 411 if (!client || !client->parent || !reason)
diff --git a/src/mobilebackup2.c b/src/mobilebackup2.c
index 09b156d..41fe5d3 100644
--- a/src/mobilebackup2.c
+++ b/src/mobilebackup2.c
@@ -61,18 +61,6 @@ static mobilebackup2_error_t mobilebackup2_error(device_link_service_error_t err
61 return MOBILEBACKUP2_E_UNKNOWN_ERROR; 61 return MOBILEBACKUP2_E_UNKNOWN_ERROR;
62} 62}
63 63
64/**
65 * Connects to the mobilebackup2 service on the specified device.
66 *
67 * @param device The device to connect to.
68 * @param service The service descriptor returned by lockdownd_start_service.
69 * @param client Pointer that will be set to a newly allocated
70 * mobilebackup2_client_t upon successful return.
71 *
72 * @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID ARG
73 * if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION
74 * if the mobilebackup2 version on the device is newer.
75 */
76mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, 64mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service,
77 mobilebackup2_client_t * client) 65 mobilebackup2_client_t * client)
78{ 66{
@@ -101,19 +89,6 @@ mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_servi
101 return ret; 89 return ret;
102} 90}
103 91
104/**
105 * Starts a new mobilebackup2 service on the specified device and connects to it.
106 *
107 * @param device The device to connect to.
108 * @param client Pointer that will point to a newly allocated
109 * mobilebackup2_client_t upon successful return. Must be freed using
110 * mobilebackup2_client_free() after use.
111 * @param label The label to use for communication. Usually the program name.
112 * Pass NULL to disable sending the label in requests to lockdownd.
113 *
114 * @return MOBILEBACKUP2_E_SUCCESS on success, or an MOBILEBACKUP2_E_* error
115 * code otherwise.
116 */
117mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t * client, const char* label) 92mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t * client, const char* label)
118{ 93{
119 mobilebackup2_error_t err = MOBILEBACKUP2_E_UNKNOWN_ERROR; 94 mobilebackup2_error_t err = MOBILEBACKUP2_E_UNKNOWN_ERROR;
@@ -121,15 +96,6 @@ mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobil
121 return err; 96 return err;
122} 97}
123 98
124/**
125 * Disconnects a mobilebackup2 client from the device and frees up the
126 * mobilebackup2 client data.
127 *
128 * @param client The mobilebackup2 client to disconnect and free.
129 *
130 * @return MOBILEBACKUP2_E_SUCCESS on success, or MOBILEBACKUP2_E_INVALID_ARG
131 * if client is NULL.
132 */
133mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client) 99mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client)
134{ 100{
135 if (!client) 101 if (!client)
@@ -143,18 +109,6 @@ mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client)
143 return err; 109 return err;
144} 110}
145 111
146/**
147 * Sends a backup message plist.
148 *
149 * @param client The connected MobileBackup client to use.
150 * @param message The message to send. This will be inserted into the request
151 * plist as value for MessageName. If this parameter is NULL,
152 * the plist passed in the options parameter will be sent directly.
153 * @param options Additional options as PLIST_DICT to add to the request.
154 * The MessageName key with the value passed in the message parameter
155 * will be inserted into this plist before sending it. This parameter
156 * can be NULL if message is not NULL.
157 */
158mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options) 112mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options)
159{ 113{
160 if (!client || !client->parent || (!message && !options)) 114 if (!client || !client->parent || (!message && !options))
@@ -253,45 +207,11 @@ leave:
253 return err; 207 return err;
254} 208}
255 209
256/**
257 * Receives a DL* message plist from the device.
258 * This function is a wrapper around device_link_service_receive_message.
259 *
260 * @param client The connected MobileBackup client to use.
261 * @param msg_plist Pointer to a plist that will be set to the contents of the
262 * message plist upon successful return.
263 * @param dlmessage A pointer that will be set to a newly allocated char*
264 * containing the DL* string from the given plist. It is up to the caller
265 * to free the allocated memory. If this parameter is NULL
266 * it will be ignored.
267 *
268 * @return MOBILEBACKUP2_E_SUCCESS if a DL* message was received,
269 * MOBILEBACKUP2_E_INVALID_ARG if client or message is invalid,
270 * MOBILEBACKUP2_E_PLIST_ERROR if the received plist is invalid
271 * or is not a DL* message plist, or MOBILEBACKUP2_E_MUX_ERROR if
272 * receiving from the device failed.
273 */
274mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage) 210mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage)
275{ 211{
276 return mobilebackup2_error(device_link_service_receive_message(client->parent, msg_plist, dlmessage)); 212 return mobilebackup2_error(device_link_service_receive_message(client->parent, msg_plist, dlmessage));
277} 213}
278 214
279/**
280 * Send binary data to the device.
281 *
282 * @note This function returns MOBILEBACKUP2_E_SUCCESS even if less than the
283 * requested length has been sent. The fourth parameter is required and
284 * must be checked to ensure if the whole data has been sent.
285 *
286 * @param client The MobileBackup client to send to.
287 * @param data Pointer to the data to send
288 * @param length Number of bytes to send
289 * @param bytes Number of bytes actually sent
290 *
291 * @return MOBILEBACKUP2_E_SUCCESS if any data was successfully sent,
292 * MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
293 * or MOBILEBACKUP2_E_MUX_ERROR if sending of the data failed.
294 */
295mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes) 215mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes)
296{ 216{
297 if (!client || !client->parent || !data || (length == 0) || !bytes) 217 if (!client || !client->parent || !data || (length == 0) || !bytes)
@@ -318,24 +238,6 @@ mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, cons
318 } 238 }
319} 239}
320 240
321/**
322 * Receive binary from the device.
323 *
324 * @note This function returns MOBILEBACKUP2_E_SUCCESS even if no data
325 * has been received (unless a communication error occured).
326 * The fourth parameter is required and must be checked to know how
327 * many bytes were actually received.
328 *
329 * @param client The MobileBackup client to receive from.
330 * @param data Pointer to a buffer that will be filled with the received data.
331 * @param length Number of bytes to receive. The data buffer needs to be large
332 * enough to store this amount of data.
333 * @paran bytes Number of bytes actually received.
334 *
335 * @return MOBILEBACKUP2_E_SUCCESS if any or no data was received,
336 * MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
337 * or MOBILEBACKUP2_E_MUX_ERROR if receiving the data failed.
338 */
339mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes) 241mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes)
340{ 242{
341 if (!client || !client->parent || !data || (length == 0) || !bytes) 243 if (!client || !client->parent || !data || (length == 0) || !bytes)
@@ -363,17 +265,6 @@ mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, c
363 } 265 }
364} 266}
365 267
366/**
367 * Performs the mobilebackup2 protocol version exchange.
368 *
369 * @param client The MobileBackup client to use.
370 * @param local_versions An array of supported versions to send to the remote.
371 * @param count The number of items in local_versions.
372 * @param remote_version Holds the protocol version of the remote on success.
373 *
374 * @return MOBILEBACKUP2_E_SUCCESS on success, or a MOBILEBACKUP2_E_* error
375 * code otherwise.
376 */
377mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version) 268mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version)
378{ 269{
379 int i; 270 int i;
@@ -432,19 +323,6 @@ leave:
432 return err; 323 return err;
433} 324}
434 325
435/**
436 * Send a request to the connected mobilebackup2 service.
437 *
438 * @param client
439 * @param request The request to send to the backup service.
440 * Currently, this is one of "Backup", "Restore", "Info", or "List".
441 * @param target_identifier UDID of the target device.
442 * @param source_identifier UDID of backup data?
443 * @param options Additional options in a plist of type PLIST_DICT.
444 *
445 * @return MOBILEBACKUP2_E_SUCCESS if the request was successfully sent,
446 * or a MOBILEBACKUP2_E_* error value otherwise.
447 */
448mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options) 326mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options)
449{ 327{
450 if (!client || !client->parent || !request || !target_identifier) 328 if (!client || !client->parent || !request || !target_identifier)
@@ -476,18 +354,6 @@ mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client,
476 return err; 354 return err;
477} 355}
478 356
479/**
480 * Sends a DLMessageStatusResponse to the device.
481 *
482 * @param client The MobileBackup client to use.
483 * @param status_code The status code to send.
484 * @param status1 A status message to send. Can be NULL if not required.
485 * @param status2 An additional status plist to attach to the response.
486 * Can be NULL if not required.
487 *
488 * @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID_ARG
489 * if client is invalid, or another MOBILEBACKUP2_E_* otherwise.
490 */
491mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2) 357mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2)
492{ 358{
493 if (!client || !client->parent) 359 if (!client || !client->parent)
diff --git a/src/mobilesync.c b/src/mobilesync.c
index fd64e63..f0fc4b2 100644
--- a/src/mobilesync.c
+++ b/src/mobilesync.c
@@ -65,19 +65,6 @@ static mobilesync_error_t mobilesync_error(device_link_service_error_t err)
65 return MOBILESYNC_E_UNKNOWN_ERROR; 65 return MOBILESYNC_E_UNKNOWN_ERROR;
66} 66}
67 67
68/**
69 * Connects to the mobilesync service on the specified device.
70 *
71 * @param device The device to connect to.
72 * @param service The service descriptor returned by lockdownd_start_service.
73 * @param client Pointer that will be set to a newly allocated
74 * #mobilesync_client_t upon successful return.
75 *
76 * @retval MOBILESYNC_E_SUCCESS on success
77 * @retval MOBILESYNC_E_INVALID_ARG if one or more parameters are invalid
78 * @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on
79 * the device is newer.
80 */
81mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, 68mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service,
82 mobilesync_client_t * client) 69 mobilesync_client_t * client)
83{ 70{
@@ -108,19 +95,6 @@ mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_des
108 return ret; 95 return ret;
109} 96}
110 97
111/**
112 * Starts a new mobilesync service on the specified device and connects to it.
113 *
114 * @param device The device to connect to.
115 * @param client Pointer that will point to a newly allocated
116 * mobilesync_client_t upon successful return. Must be freed using
117 * mobilesync_client_free() after use.
118 * @param label The label to use for communication. Usually the program name.
119 * Pass NULL to disable sending the label in requests to lockdownd.
120 *
121 * @return MOBILESYNC_E_SUCCESS on success, or an MOBILESYNC_E_* error
122 * code otherwise.
123 */
124mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t * client, const char* label) 98mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t * client, const char* label)
125{ 99{
126 mobilesync_error_t err = MOBILESYNC_E_UNKNOWN_ERROR; 100 mobilesync_error_t err = MOBILESYNC_E_UNKNOWN_ERROR;
@@ -128,15 +102,6 @@ mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_
128 return err; 102 return err;
129} 103}
130 104
131/**
132 * Disconnects a mobilesync client from the device and frees up the
133 * mobilesync client data.
134 *
135 * @param client The mobilesync client to disconnect and free.
136 *
137 * @retval MOBILESYNC_E_SUCCESS on success
138 * @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL.
139 */
140mobilesync_error_t mobilesync_client_free(mobilesync_client_t client) 105mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
141{ 106{
142 if (!client) 107 if (!client)
@@ -147,14 +112,6 @@ mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
147 return err; 112 return err;
148} 113}
149 114
150/**
151 * Polls the device for mobilesync data.
152 *
153 * @param client The mobilesync client
154 * @param plist A pointer to the location where the plist should be stored
155 *
156 * @return an error code
157 */
158mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plist) 115mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plist)
159{ 116{
160 if (!client) 117 if (!client)
@@ -163,17 +120,6 @@ mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plis
163 return ret; 120 return ret;
164} 121}
165 122
166/**
167 * Sends mobilesync data to the device
168 *
169 * @note This function is low-level and should only be used if you need to send
170 * a new type of message.
171 *
172 * @param client The mobilesync client
173 * @param plist The location of the plist to send
174 *
175 * @return an error code
176 */
177mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist) 123mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
178{ 124{
179 if (!client || !plist) 125 if (!client || !plist)
@@ -181,26 +127,6 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
181 return mobilesync_error(device_link_service_send(client->parent, plist)); 127 return mobilesync_error(device_link_service_send(client->parent, plist));
182} 128}
183 129
184/**
185 * Requests starting synchronization of a data class with the device
186 *
187 * @param client The mobilesync client
188 * @param data_class The data class identifier to sync
189 * @param anchors The anchors required to exchange with the device. The anchors
190 * allow the device to tell if the synchronization information on the computer
191 * and device are consistent to determine what sync type is required.
192 * @param computer_data_class_version The version of the data class storage on the computer
193 * @param sync_type A pointer to store the sync type reported by the device_anchor
194 * @param device_data_class_version The version of the data class storage on the device
195 * @param error_description A pointer to store an error message if reported by the device
196 *
197 * @retval MOBILESYNC_E_SUCCESS on success
198 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
199 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
200 * @retval MOBILESYNC_E_SYNC_REFUSED if the device refused to sync
201 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
202 * sync request
203 */
204mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description) 130mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description)
205{ 131{
206 if (!client || client->data_class || !data_class || 132 if (!client || client->data_class || !data_class ||
@@ -327,17 +253,6 @@ mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data
327 return err; 253 return err;
328} 254}
329 255
330/**
331 * Finish a synchronization session of a data class on the device.
332 * A session must have previously been started using mobilesync_start().
333 *
334 * @param client The mobilesync client
335 *
336 * @retval MOBILESYNC_E_SUCCESS on success
337 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
338 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
339 * form
340 */
341mobilesync_error_t mobilesync_finish(mobilesync_client_t client) 256mobilesync_error_t mobilesync_finish(mobilesync_client_t client)
342{ 257{
343 if (!client || !client->data_class) { 258 if (!client || !client->data_class) {
@@ -423,49 +338,16 @@ static mobilesync_error_t mobilesync_get_records(mobilesync_client_t client, con
423 return err; 338 return err;
424} 339}
425 340
426/**
427 * Requests to receive all records of the currently set data class from the device.
428 * The actually changes are retrieved using mobilesync_receive_changes() after this
429 * request has been successful.
430 *
431 * @param client The mobilesync client
432 *
433 * @retval MOBILESYNC_E_SUCCESS on success
434 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
435 */
436mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client) 341mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client)
437{ 342{
438 return mobilesync_get_records(client, "SDMessageGetAllRecordsFromDevice"); 343 return mobilesync_get_records(client, "SDMessageGetAllRecordsFromDevice");
439} 344}
440 345
441/**
442 * Requests to receive only changed records of the currently set data class from the device.
443 * The actually changes are retrieved using mobilesync_receive_changes() after this
444 * request has been successful.
445 *
446 * @param client The mobilesync client
447 *
448 * @retval MOBILESYNC_E_SUCCESS on success
449 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
450 */
451mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client) 346mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client)
452{ 347{
453 return mobilesync_get_records(client, "SDMessageGetChangesFromDevice"); 348 return mobilesync_get_records(client, "SDMessageGetChangesFromDevice");
454} 349}
455 350
456/**
457 * Receives changed entitites of the currently set data class from the device
458 *
459 * @param client The mobilesync client
460 * @param entities A pointer to store the changed entity records as a PLIST_DICT
461 * @param is_last_record A pointer to store a flag indicating if this submission is the last one
462 * @param actions A pointer to additional flags the device is sending or NULL to ignore
463 *
464 * @retval MOBILESYNC_E_SUCCESS on success
465 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
466 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
467 * session
468 */
469mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions) 351mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions)
470{ 352{
471 if (!client || !client->data_class) { 353 if (!client || !client->data_class) {
@@ -533,17 +415,6 @@ mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_
533 return err; 415 return err;
534} 416}
535 417
536/**
537 * Requests the device to delete all records of the current data class
538 *
539 * @note The operation must be called after starting synchronization.
540 *
541 * @param client The mobilesync client
542 *
543 * @retval MOBILESYNC_E_SUCCESS on success
544 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
545 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
546 */
547mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client) 418mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client)
548{ 419{
549 if (!client || !client->data_class) { 420 if (!client || !client->data_class) {
@@ -613,14 +484,6 @@ mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t cl
613 return err; 484 return err;
614} 485}
615 486
616/**
617 * Acknowledges to the device that the changes have been merged on the computer
618 *
619 * @param client The mobilesync client
620 *
621 * @retval MOBILESYNC_E_SUCCESS on success
622 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
623 */
624mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client) 487mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client)
625{ 488{
626 if (!client || !client->data_class) { 489 if (!client || !client->data_class) {
@@ -655,23 +518,6 @@ static plist_t create_process_changes_message(const char *data_class, plist_t en
655 return msg; 518 return msg;
656} 519}
657 520
658/**
659 * Verifies if the device is ready to receive changes from the computer.
660 * This call changes the synchronization direction so that mobilesync_send_changes()
661 * can be used to send changes to the device.
662 *
663 * @param client The mobilesync client
664 *
665 * @retval MOBILESYNC_E_SUCCESS on success
666 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
667 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
668 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
669 * not permit this call
670 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
671 * session
672 * @retval MOBILESYNC_E_NOT_READY if the device is not ready to start
673 * receiving any changes
674 */
675mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client) 521mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client)
676{ 522{
677 if (!client || !client->data_class) { 523 if (!client || !client->data_class) {
@@ -739,20 +585,6 @@ mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_cli
739 return err; 585 return err;
740} 586}
741 587
742/**
743 * Sends changed entities of the currently set data class to the device
744 *
745 * @param client The mobilesync client
746 * @param entities The changed entity records as a PLIST_DICT
747 * @param is_last_record A flag indicating if this submission is the last one
748 * @param actions Additional actions for the device created with mobilesync_actions_new()
749 * or NULL if no actions should be passed
750 *
751 * @retval MOBILESYNC_E_SUCCESS on success
752 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid,
753 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
754 * not permit this call
755 */
756mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions) 588mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions)
757{ 589{
758 if (!client || !client->data_class || !entities) { 590 if (!client || !client->data_class || !entities) {
@@ -781,21 +613,6 @@ mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t e
781 return err; 613 return err;
782} 614}
783 615
784/**
785 * Receives any remapped identifiers reported after the device merged submitted changes.
786 *
787 * @param client The mobilesync client
788 * @param mapping A pointer to an array plist containing a dict of identifier remappings
789 *
790 * @retval MOBILESYNC_E_SUCCESS on success
791 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
792 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
793 * form
794 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
795 * not permit this call
796 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
797 * session
798 */
799mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping) 616mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping)
800{ 617{
801 if (!client || !client->data_class) { 618 if (!client || !client->data_class) {
@@ -865,15 +682,6 @@ mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plis
865 return err; 682 return err;
866} 683}
867 684
868/**
869 * Cancels a running synchronization session with a device at any time.
870 *
871 * @param client The mobilesync client
872 * @param reason The reason to supply to the device for cancelling
873 *
874 * @retval MOBILESYNC_E_SUCCESS on success
875 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
876 */
877mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason) 685mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason)
878{ 686{
879 if (!client || !client->data_class || !reason) { 687 if (!client || !client->data_class || !reason) {
@@ -900,15 +708,6 @@ mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* rea
900 return err; 708 return err;
901} 709}
902 710
903/**
904 * Allocates memory for a new anchors struct initialized with the passed anchors.
905 *
906 * @param device_anchor An anchor the device reported the last time or NULL
907 * if none is known yet which for instance is true on first synchronization.
908 * @param computer_anchor An arbitrary string to use as anchor for the computer.
909 *
910 * @return A new #mobilesync_anchors_t struct. Must be freed using mobilesync_anchors_free().
911 */
912mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor) 711mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor)
913{ 712{
914 mobilesync_anchors_t anchors = (mobilesync_anchors_t) malloc(sizeof(mobilesync_anchors)); 713 mobilesync_anchors_t anchors = (mobilesync_anchors_t) malloc(sizeof(mobilesync_anchors));
@@ -926,11 +725,6 @@ mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const cha
926 return anchors; 725 return anchors;
927} 726}
928 727
929/**
930 * Free memory used by anchors.
931 *
932 * @param anchors The anchors to free.
933 */
934void mobilesync_anchors_free(mobilesync_anchors_t anchors) 728void mobilesync_anchors_free(mobilesync_anchors_t anchors)
935{ 729{
936 if (anchors->device_anchor != NULL) { 730 if (anchors->device_anchor != NULL) {
@@ -945,28 +739,11 @@ void mobilesync_anchors_free(mobilesync_anchors_t anchors)
945 anchors = NULL; 739 anchors = NULL;
946} 740}
947 741
948/**
949 * Create a new actions plist to use in mobilesync_send_changes().
950 *
951 * @return A new plist_t of type PLIST_DICT.
952 */
953plist_t mobilesync_actions_new() 742plist_t mobilesync_actions_new()
954{ 743{
955 return plist_new_dict(); 744 return plist_new_dict();
956} 745}
957 746
958/**
959 * Add one or more new key:value pairs to the given actions plist.
960 *
961 * @param actions The actions to modify.
962 * @param ... KEY, VALUE, [KEY, VALUE], NULL
963 *
964 * @note The known keys so far are "SyncDeviceLinkEntityNamesKey" which expects
965 * an array of entity names, followed by a count paramter as well as
966 * "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey" which expects an
967 * integer to use as a boolean value indicating that the device should
968 * link submitted changes and report remapped identifiers.
969 */
970void mobilesync_actions_add(plist_t actions, ...) 747void mobilesync_actions_add(plist_t actions, ...)
971{ 748{
972 if (!actions) 749 if (!actions)
@@ -999,11 +776,6 @@ void mobilesync_actions_add(plist_t actions, ...)
999 va_end(args); 776 va_end(args);
1000} 777}
1001 778
1002/**
1003 * Free actions plist.
1004 *
1005 * @param actions The actions plist to free. Does nothing if NULL is passed.
1006 */
1007void mobilesync_actions_free(plist_t actions) 779void mobilesync_actions_free(plist_t actions)
1008{ 780{
1009 if (actions) { 781 if (actions) {
diff --git a/src/notification_proxy.c b/src/notification_proxy.c
index 1ccda6b..909ede4 100644
--- a/src/notification_proxy.c
+++ b/src/notification_proxy.c
@@ -86,18 +86,6 @@ static np_error_t np_error(property_list_service_error_t err)
86 return NP_E_UNKNOWN_ERROR; 86 return NP_E_UNKNOWN_ERROR;
87} 87}
88 88
89/**
90 * Connects to the notification_proxy on the specified device.
91 *
92 * @param device The device to connect to.
93 * @param service The service descriptor returned by lockdownd_start_service.
94 * @param client Pointer that will be set to a newly allocated np_client_t
95 * upon successful return.
96 *
97 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when device is NULL,
98 * or NP_E_CONN_FAILED when the connection to the device could not be
99 * established.
100 */
101np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client) 89np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client)
102{ 90{
103 property_list_service_client_t plistclient = NULL; 91 property_list_service_client_t plistclient = NULL;
@@ -116,19 +104,6 @@ np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t servic
116 return NP_E_SUCCESS; 104 return NP_E_SUCCESS;
117} 105}
118 106
119/**
120 * Starts a new notification proxy service on the specified device and connects to it.
121 *
122 * @param device The device to connect to.
123 * @param client Pointer that will point to a newly allocated
124 * np_client_t upon successful return. Must be freed using
125 * np_client_free() after use.
126 * @param label The label to use for communication. Usually the program name.
127 * Pass NULL to disable sending the label in requests to lockdownd.
128 *
129 * @return NP_E_SUCCESS on success, or an NP_E_* error
130 * code otherwise.
131 */
132np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label) 107np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label)
133{ 108{
134 np_error_t err = NP_E_UNKNOWN_ERROR; 109 np_error_t err = NP_E_UNKNOWN_ERROR;
@@ -136,14 +111,6 @@ np_error_t np_client_start_service(idevice_t device, np_client_t* client, const
136 return err; 111 return err;
137} 112}
138 113
139/**
140 * Disconnects a notification_proxy client from the device and frees up the
141 * notification_proxy client data.
142 *
143 * @param client The notification_proxy client to disconnect and free.
144 *
145 * @return NP_E_SUCCESS on success, or NP_E_INVALID_ARG when client is NULL.
146 */
147np_error_t np_client_free(np_client_t client) 114np_error_t np_client_free(np_client_t client)
148{ 115{
149 if (!client) 116 if (!client)
@@ -161,14 +128,6 @@ np_error_t np_client_free(np_client_t client)
161 return NP_E_SUCCESS; 128 return NP_E_SUCCESS;
162} 129}
163 130
164/**
165 * Sends a notification to the device's notification_proxy.
166 *
167 * @param client The client to send to
168 * @param notification The notification message to send
169 *
170 * @return NP_E_SUCCESS on success, or an error returned by np_plist_send
171 */
172np_error_t np_post_notification(np_client_t client, const char *notification) 131np_error_t np_post_notification(np_client_t client, const char *notification)
173{ 132{
174 if (!client || !notification) { 133 if (!client || !notification) {
@@ -220,15 +179,6 @@ np_error_t np_post_notification(np_client_t client, const char *notification)
220 return res; 179 return res;
221} 180}
222 181
223/**
224 * Tells the device to send a notification on the specified event.
225 *
226 * @param client The client to send to
227 * @param notification The notifications that should be observed.
228 *
229 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or
230 * notification are NULL, or an error returned by np_plist_send.
231 */
232np_error_t np_observe_notification( np_client_t client, const char *notification ) 182np_error_t np_observe_notification( np_client_t client, const char *notification )
233{ 183{
234 if (!client || !notification) { 184 if (!client || !notification) {
@@ -250,17 +200,6 @@ np_error_t np_observe_notification( np_client_t client, const char *notification
250 return res; 200 return res;
251} 201}
252 202
253/**
254 * Tells the device to send a notification on specified events.
255 *
256 * @param client The client to send to
257 * @param notification_spec Specification of the notifications that should be
258 * observed. This is expected to be an array of const char* that MUST have a
259 * terminating NULL entry.
260 *
261 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client is null,
262 * or an error returned by np_observe_notification.
263 */
264np_error_t np_observe_notifications(np_client_t client, const char **notification_spec) 203np_error_t np_observe_notifications(np_client_t client, const char **notification_spec)
265{ 204{
266 int i = 0; 205 int i = 0;
@@ -390,28 +329,6 @@ void* np_notifier( void* arg )
390 return NULL; 329 return NULL;
391} 330}
392 331
393/**
394 * This function allows an application to define a callback function that will
395 * be called when a notification has been received.
396 * It will start a thread that polls for notifications and calls the callback
397 * function if a notification has been received.
398 * In case of an error condition when polling for notifications - e.g. device
399 * disconnect - the thread will call the callback function with an empty
400 * notification "" and terminate itself.
401 *
402 * @param client the NP client
403 * @param notify_cb pointer to a callback function or NULL to de-register a
404 * previously set callback function.
405 * @param user_data Pointer that will be passed to the callback function as
406 * user data. If notify_cb is NULL, this parameter is ignored.
407 *
408 * @note Only one callback function can be registered at the same time;
409 * any previously set callback function will be removed automatically.
410 *
411 * @return NP_E_SUCCESS when the callback was successfully registered,
412 * NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when
413 * the callback thread could no be created.
414 */
415np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb, void *user_data ) 332np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb, void *user_data )
416{ 333{
417 if (!client) 334 if (!client)
diff --git a/src/restore.c b/src/restore.c
index 6339270..2a025e8 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -89,14 +89,6 @@ static void plist_dict_add_label(plist_t plist, const char *label)
89 } 89 }
90} 90}
91 91
92/**
93 * Closes the restored client session if one is running and frees up the
94 * restored_client struct.
95 *
96 * @param client The restore client
97 *
98 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
99 */
100restored_error_t restored_client_free(restored_client_t client) 92restored_error_t restored_client_free(restored_client_t client)
101{ 93{
102 if (!client) 94 if (!client)
@@ -127,13 +119,6 @@ restored_error_t restored_client_free(restored_client_t client)
127 return ret; 119 return ret;
128} 120}
129 121
130/**
131 * Sets the label to send for requests to restored.
132 *
133 * @param client The restore client
134 * @param label The label to set or NULL to disable sending a label
135 *
136 */
137void restored_client_set_label(restored_client_t client, const char *label) 122void restored_client_set_label(restored_client_t client, const char *label)
138{ 123{
139 if (client) { 124 if (client) {
@@ -144,15 +129,6 @@ void restored_client_set_label(restored_client_t client, const char *label)
144 } 129 }
145} 130}
146 131
147/**
148 * Receives a plist from restored.
149 *
150 * @param client The restored client
151 * @param plist The plist to store the received data
152 *
153 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client or
154 * plist is NULL
155 */
156restored_error_t restored_receive(restored_client_t client, plist_t *plist) 132restored_error_t restored_receive(restored_client_t client, plist_t *plist)
157{ 133{
158 if (!client || !plist || (plist && *plist)) 134 if (!client || !plist || (plist && *plist))
@@ -172,18 +148,6 @@ restored_error_t restored_receive(restored_client_t client, plist_t *plist)
172 return ret; 148 return ret;
173} 149}
174 150
175/**
176 * Sends a plist to restored.
177 *
178 * @note This function is low-level and should only be used if you need to send
179 * a new type of message.
180 *
181 * @param client The restored client
182 * @param plist The plist to send
183 *
184 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client or
185 * plist is NULL
186 */
187restored_error_t restored_send(restored_client_t client, plist_t plist) 151restored_error_t restored_send(restored_client_t client, plist_t plist)
188{ 152{
189 if (!client || !plist) 153 if (!client || !plist)
@@ -199,16 +163,6 @@ restored_error_t restored_send(restored_client_t client, plist_t plist)
199 return ret; 163 return ret;
200} 164}
201 165
202/**
203 * Query the type of the service daemon. Depending on whether the device is
204 * queried in normal mode or restore mode, different types will be returned.
205 *
206 * @param client The restored client
207 * @param type The type returned by the service daemon. Pass NULL to ignore.
208 * @param version The restore protocol version. Pass NULL to ignore.
209 *
210 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
211 */
212restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version) 166restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version)
213{ 167{
214 if (!client) 168 if (!client)
@@ -268,15 +222,6 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint
268 return ret; 222 return ret;
269} 223}
270 224
271/**
272 * Queries a value from the device specified by a key.
273 *
274 * @param client An initialized restored client.
275 * @param key The key name to request
276 * @param value A plist node representing the result value node
277 *
278 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
279 */
280restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value) 225restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value)
281{ 226{
282 if (!client || !key) 227 if (!client || !key)
@@ -319,16 +264,7 @@ restored_error_t restored_query_value(restored_client_t client, const char *key,
319 return ret; 264 return ret;
320} 265}
321 266
322/** 267restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value)
323 * Retrieves a value from information plist specified by a key.
324 *
325 * @param client An initialized restored client.
326 * @param key The key name to request or NULL to query for all keys
327 * @param value A plist node representing the result value node
328 *
329 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
330 */
331restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value)
332{ 268{
333 if (!client || !value || (value && *value)) 269 if (!client || !value || (value && *value))
334 return RESTORE_E_INVALID_ARG; 270 return RESTORE_E_INVALID_ARG;
@@ -355,15 +291,6 @@ restored_error_t restored_get_value(restored_client_t client, const char *key, p
355 return ret; 291 return ret;
356} 292}
357 293
358/**
359 * Creates a new restored client for the device.
360 *
361 * @param device The device to create a restored client for
362 * @param client The pointer to the location of the new restored_client
363 * @param label The label to use for communication. Usually the program name.
364 *
365 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
366 */
367restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label) 294restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label)
368{ 295{
369 if (!client) 296 if (!client)
@@ -405,14 +332,6 @@ restored_error_t restored_client_new(idevice_t device, restored_client_t *client
405 return ret; 332 return ret;
406} 333}
407 334
408/**
409 * Sends the Goodbye request to restored signaling the end of communication.
410 *
411 * @param client The restore client
412 *
413 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
414 * RESTORE_E_PLIST_ERROR if the device did not acknowledge the request
415 */
416restored_error_t restored_goodbye(restored_client_t client) 335restored_error_t restored_goodbye(restored_client_t client)
417{ 336{
418 if (!client) 337 if (!client)
@@ -445,16 +364,6 @@ restored_error_t restored_goodbye(restored_client_t client)
445 return ret; 364 return ret;
446} 365}
447 366
448/**
449 * Requests to start a restore and retrieve it's port on success.
450 *
451 * @param client The restored client
452 * @param options PLIST_DICT with options for the restore process or NULL
453 * @param version the restore protocol version, see restored_query_type()
454 *
455 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
456 * is NULL, RESTORE_E_START_RESTORE_FAILED if the request fails
457 */
458restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version) 367restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version)
459{ 368{
460 if (!client) 369 if (!client)
@@ -479,14 +388,6 @@ restored_error_t restored_start_restore(restored_client_t client, plist_t option
479 return ret; 388 return ret;
480} 389}
481 390
482/**
483 * Requests device to reboot.
484 *
485 * @param client The restored client
486 *
487 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
488 * is NULL
489 */
490restored_error_t restored_reboot(restored_client_t client) 391restored_error_t restored_reboot(restored_client_t client)
491{ 392{
492 if (!client) 393 if (!client)
diff --git a/src/sbservices.c b/src/sbservices.c
index 1d043f1..ea12e35 100644
--- a/src/sbservices.c
+++ b/src/sbservices.c
@@ -76,17 +76,6 @@ static sbservices_error_t sbservices_error(property_list_service_error_t err)
76 return SBSERVICES_E_UNKNOWN_ERROR; 76 return SBSERVICES_E_UNKNOWN_ERROR;
77} 77}
78 78
79/**
80 * Connects to the springboardservices service on the specified device.
81 *
82 * @param device The device to connect to.
83 * @param service The service descriptor returned by lockdownd_start_service.
84 * @param client Pointer that will point to a newly allocated
85 * sbservices_client_t upon successful return.
86 *
87 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
88 * client is NULL, or an SBSERVICES_E_* error code otherwise.
89 */
90sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client) 79sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client)
91{ 80{
92 property_list_service_client_t plistclient = NULL; 81 property_list_service_client_t plistclient = NULL;
@@ -103,19 +92,6 @@ sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_des
103 return SBSERVICES_E_SUCCESS; 92 return SBSERVICES_E_SUCCESS;
104} 93}
105 94
106/**
107 * Starts a new sbservices service on the specified device and connects to it.
108 *
109 * @param device The device to connect to.
110 * @param client Pointer that will point to a newly allocated
111 * sbservices_client_t upon successful return. Must be freed using
112 * sbservices_client_free() after use.
113 * @param label The label to use for communication. Usually the program name.
114 * Pass NULL to disable sending the label in requests to lockdownd.
115 *
116 * @return SBSERVICES_E_SUCCESS on success, or an SBSERVICES_E_* error
117 * code otherwise.
118 */
119sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t * client, const char* label) 95sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t * client, const char* label)
120{ 96{
121 sbservices_error_t err = SBSERVICES_E_UNKNOWN_ERROR; 97 sbservices_error_t err = SBSERVICES_E_UNKNOWN_ERROR;
@@ -123,15 +99,6 @@ sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_
123 return err; 99 return err;
124} 100}
125 101
126/**
127 * Disconnects an sbservices client from the device and frees up the
128 * sbservices client data.
129 *
130 * @param client The sbservices client to disconnect and free.
131 *
132 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
133 * client is NULL, or an SBSERVICES_E_* error code otherwise.
134 */
135sbservices_error_t sbservices_client_free(sbservices_client_t client) 102sbservices_error_t sbservices_client_free(sbservices_client_t client)
136{ 103{
137 if (!client) 104 if (!client)
@@ -145,20 +112,6 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client)
145 return err; 112 return err;
146} 113}
147 114
148/**
149 * Gets the icon state of the connected device.
150 *
151 * @param client The connected sbservices client to use.
152 * @param state Pointer that will point to a newly allocated plist containing
153 * the current icon state. It is up to the caller to free the memory.
154 * @param format_version A string to be passed as formatVersion along with
155 * the request, or NULL if no formatVersion should be passed. This is only
156 * supported since iOS 4.0 so for older firmware versions this must be set
157 * to NULL.
158 *
159 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
160 * client or state is invalid, or an SBSERVICES_E_* error code otherwise.
161 */
162sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version) 115sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version)
163{ 116{
164 if (!client || !client->parent || !state) 117 if (!client || !client->parent || !state)
@@ -199,15 +152,6 @@ leave_unlock:
199 return res; 152 return res;
200} 153}
201 154
202/**
203 * Sets the icon state of the connected device.
204 *
205 * @param client The connected sbservices client to use.
206 * @param newstate A plist containing the new iconstate.
207 *
208 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
209 * client or newstate is NULL, or an SBSERVICES_E_* error code otherwise.
210 */
211sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate) 155sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate)
212{ 156{
213 if (!client || !client->parent || !newstate) 157 if (!client || !client->parent || !newstate)
@@ -234,21 +178,6 @@ sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t
234 return res; 178 return res;
235} 179}
236 180
237/**
238 * Get the icon of the specified app as PNG data.
239 *
240 * @param client The connected sbservices client to use.
241 * @param bundleId The bundle identifier of the app to retrieve the icon for.
242 * @param pngdata Pointer that will point to a newly allocated buffer
243 * containing the PNG data upon successful return. It is up to the caller
244 * to free the memory.
245 * @param pngsize Pointer to a uint64_t that will be set to the size of the
246 * buffer pngdata points to upon successful return.
247 *
248 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
249 * client, bundleId, or pngdata are invalid, or an SBSERVICES_E_* error
250 * code otherwise.
251 */
252sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize) 181sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize)
253{ 182{
254 if (!client || !client->parent || !bundleId || !pngdata) 183 if (!client || !client->parent || !bundleId || !pngdata)
@@ -286,15 +215,6 @@ leave_unlock:
286 return res; 215 return res;
287} 216}
288 217
289/**
290 * Gets the interface orientation of the device.
291 *
292 * @param client The connected sbservices client to use.
293 * @param interface_orientation The interface orientation upon successful return.
294 *
295 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
296 * client or state is invalid, or an SBSERVICES_E_* error code otherwise.
297 */
298sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation) 218sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation)
299{ 219{
300 if (!client || !client->parent || !interface_orientation) 220 if (!client || !client->parent || !interface_orientation)
@@ -333,20 +253,6 @@ leave_unlock:
333 return res; 253 return res;
334} 254}
335 255
336/**
337 * Get the home screen wallpaper as PNG data.
338 *
339 * @param client The connected sbservices client to use.
340 * @param pngdata Pointer that will point to a newly allocated buffer
341 * containing the PNG data upon successful return. It is up to the caller
342 * to free the memory.
343 * @param pngsize Pointer to a uint64_t that will be set to the size of the
344 * buffer pngdata points to upon successful return.
345 *
346 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
347 * client or pngdata are invalid, or an SBSERVICES_E_* error
348 * code otherwise.
349 */
350sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize) 256sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize)
351{ 257{
352 if (!client || !client->parent || !pngdata) 258 if (!client || !client->parent || !pngdata)
diff --git a/src/screenshotr.c b/src/screenshotr.c
index a1b5759..e92fe9f 100644
--- a/src/screenshotr.c
+++ b/src/screenshotr.c
@@ -58,21 +58,6 @@ static screenshotr_error_t screenshotr_error(device_link_service_error_t err)
58 return SCREENSHOTR_E_UNKNOWN_ERROR; 58 return SCREENSHOTR_E_UNKNOWN_ERROR;
59} 59}
60 60
61/**
62 * Connects to the screenshotr service on the specified device.
63 *
64 * @param device The device to connect to.
65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Pointer that will be set to a newly allocated
67 * screenshotr_client_t upon successful return.
68 *
69 * @note This service is only available if a developer disk image has been
70 * mounted.
71 *
72 * @return SCREENSHOTR_E_SUCCESS on success, SCREENSHOTR_E_INVALID ARG if one
73 * or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the
74 * connection to the device could not be established.
75 */
76screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, 61screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service,
77 screenshotr_client_t * client) 62 screenshotr_client_t * client)
78{ 63{
@@ -101,19 +86,6 @@ screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_d
101 return ret; 86 return ret;
102} 87}
103 88
104/**
105 * Starts a new screenshotr service on the specified device and connects to it.
106 *
107 * @param device The device to connect to.
108 * @param client Pointer that will point to a newly allocated
109 * screenshotr_client_t upon successful return. Must be freed using
110 * screenshotr_client_free() after use.
111 * @param label The label to use for communication. Usually the program name.
112 * Pass NULL to disable sending the label in requests to lockdownd.
113 *
114 * @return SCREENSHOTR_E_SUCCESS on success, or an SCREENSHOTR_E_* error
115 * code otherwise.
116 */
117screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t * client, const char* label) 89screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t * client, const char* label)
118{ 90{
119 screenshotr_error_t err = SCREENSHOTR_E_UNKNOWN_ERROR; 91 screenshotr_error_t err = SCREENSHOTR_E_UNKNOWN_ERROR;
@@ -121,15 +93,6 @@ screenshotr_error_t screenshotr_client_start_service(idevice_t device, screensho
121 return err; 93 return err;
122} 94}
123 95
124/**
125 * Disconnects a screenshotr client from the device and frees up the
126 * screenshotr client data.
127 *
128 * @param client The screenshotr client to disconnect and free.
129 *
130 * @return SCREENSHOTR_E_SUCCESS on success, or SCREENSHOTR_E_INVALID_ARG
131 * if client is NULL.
132 */
133screenshotr_error_t screenshotr_client_free(screenshotr_client_t client) 96screenshotr_error_t screenshotr_client_free(screenshotr_client_t client)
134{ 97{
135 if (!client) 98 if (!client)
@@ -140,20 +103,6 @@ screenshotr_error_t screenshotr_client_free(screenshotr_client_t client)
140 return err; 103 return err;
141} 104}
142 105
143/**
144 * Get a screen shot from the connected device.
145 *
146 * @param client The connection screenshotr service client.
147 * @param imgdata Pointer that will point to a newly allocated buffer
148 * containing TIFF image data upon successful return. It is up to the
149 * caller to free the memory.
150 * @param imgsize Pointer to a uint64_t that will be set to the size of the
151 * buffer imgdata points to upon successful return.
152 *
153 * @return SCREENSHOTR_E_SUCCESS on success, SCREENSHOTR_E_INVALID_ARG if
154 * one or more parameters are invalid, or another error code if an
155 * error occured.
156 */
157screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize) 106screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize)
158{ 107{
159 if (!client || !client->parent || !imgdata) 108 if (!client || !client->parent || !imgdata)
diff --git a/src/service.c b/src/service.c
index e8444b8..701c8b4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -52,18 +52,6 @@ static service_error_t idevice_to_service_error(idevice_error_t err)
52 return SERVICE_E_UNKNOWN_ERROR; 52 return SERVICE_E_UNKNOWN_ERROR;
53} 53}
54 54
55/**
56 * Creates a new service for the specified service descriptor.
57 *
58 * @param device The device to connect to.
59 * @param service The service descriptor returned by lockdownd_start_service.
60 * @param client Pointer that will be set to a newly allocated
61 * service_client_t upon successful return.
62 *
63 * @return SERVICE_E_SUCCESS on success,
64 * SERVICE_E_INVALID_ARG when one of the arguments is invalid,
65 * or SERVICE_E_MUX_ERROR when connecting to the device failed.
66 */
67service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client) 55service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client)
68{ 56{
69 if (!device || !service || service->port == 0 || !client || *client) 57 if (!device || !service || service->port == 0 || !client || *client)
@@ -88,21 +76,6 @@ service_error_t service_client_new(idevice_t device, lockdownd_service_descripto
88 return SERVICE_E_SUCCESS; 76 return SERVICE_E_SUCCESS;
89} 77}
90 78
91/**
92 * Starts a new service on the specified device with given name and
93 * connects to it.
94 *
95 * @param device The device to connect to.
96 * @param service_name The name of the service to start.
97 * @param client Pointer that will point to a newly allocated service_client_t
98 * upon successful return. Must be freed using service_client_free() after
99 * use.
100 * @param label The label to use for communication. Usually the program name.
101 * Pass NULL to disable sending the label in requests to lockdownd.
102 *
103 * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code
104 * otherwise.
105 */
106service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code) 79service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code)
107{ 80{
108 *client = NULL; 81 *client = NULL;
@@ -142,15 +115,6 @@ service_error_t service_client_factory_start_service(idevice_t device, const cha
142 return (ec == SERVICE_E_SUCCESS) ? SERVICE_E_SUCCESS : SERVICE_E_START_SERVICE_ERROR; 115 return (ec == SERVICE_E_SUCCESS) ? SERVICE_E_SUCCESS : SERVICE_E_START_SERVICE_ERROR;
143} 116}
144 117
145/**
146 * Frees a service instance.
147 *
148 * @param client The service instance to free.
149 *
150 * @return SERVICE_E_SUCCESS on success,
151 * SERVICE_E_INVALID_ARG when client is invalid, or a
152 * SERVICE_E_UNKNOWN_ERROR when another error occured.
153 */
154service_error_t service_client_free(service_client_t client) 118service_error_t service_client_free(service_client_t client)
155{ 119{
156 if (!client) 120 if (!client)
@@ -164,19 +128,6 @@ service_error_t service_client_free(service_client_t client)
164 return err; 128 return err;
165} 129}
166 130
167/**
168 * Sends data using the given service client.
169 *
170 * @param client The service client to use for sending.
171 * @param data Data to send
172 * @param size Size of the data to send
173 * @param sent Number of bytes sent (can be NULL to ignore)
174 *
175 * @return SERVICE_E_SUCCESS on success,
176 * SERVICE_E_INVALID_ARG when one or more parameters are
177 * invalid, or SERVICE_E_UNKNOWN_ERROR when an unspecified
178 * error occurs.
179 */
180service_error_t service_send(service_client_t client, const char* data, uint32_t size, uint32_t *sent) 131service_error_t service_send(service_client_t client, const char* data, uint32_t size, uint32_t *sent)
181{ 132{
182 service_error_t res = SERVICE_E_UNKNOWN_ERROR; 133 service_error_t res = SERVICE_E_UNKNOWN_ERROR;
@@ -198,21 +149,6 @@ service_error_t service_send(service_client_t client, const char* data, uint32_t
198 return res; 149 return res;
199} 150}
200 151
201/**
202 * Receives data using the given service client with specified timeout.
203 *
204 * @param client The service client to use for receiving
205 * @param data Buffer that will be filled with the data received
206 * @param size Number of bytes to receive
207 * @param received Number of bytes received (can be NULL to ignore)
208 * @param timeout Maximum time in milliseconds to wait for data.
209 *
210 * @return SERVICE_E_SUCCESS on success,
211 * SERVICE_E_INVALID_ARG when one or more parameters are
212 * invalid, SERVICE_E_MUX_ERROR when a communication error
213 * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
214 * error occurs.
215 */
216service_error_t service_receive_with_timeout(service_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout) 152service_error_t service_receive_with_timeout(service_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
217{ 153{
218 service_error_t res = SERVICE_E_UNKNOWN_ERROR; 154 service_error_t res = SERVICE_E_UNKNOWN_ERROR;
@@ -233,35 +169,11 @@ service_error_t service_receive_with_timeout(service_client_t client, char* data
233 return res; 169 return res;
234} 170}
235 171
236/**
237 * Receives data using the given service client.
238 *
239 * @param client The service client to use for receiving
240 * @param data Buffer that will be filled with the data received
241 * @param size Number of bytes to receive
242 * @param received Number of bytes received (can be NULL to ignore)
243 *
244 * @return SERVICE_E_SUCCESS on success,
245 * SERVICE_E_INVALID_ARG when one or more parameters are
246 * invalid, SERVICE_E_MUX_ERROR when a communication error
247 * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
248 * error occurs.
249 */
250service_error_t service_receive(service_client_t client, char* data, uint32_t size, uint32_t *received) 172service_error_t service_receive(service_client_t client, char* data, uint32_t size, uint32_t *received)
251{ 173{
252 return service_receive_with_timeout(client, data, size, received, 10000); 174 return service_receive_with_timeout(client, data, size, received, 10000);
253} 175}
254 176
255/**
256 * Enable SSL for the given service client.
257 *
258 * @param client The connected service client for that SSL should be enabled.
259 *
260 * @return SERVICE_E_SUCCESS on success,
261 * SERVICE_E_INVALID_ARG if client or client->connection is
262 * NULL, SERVICE_E_SSL_ERROR when SSL could not be enabled,
263 * or SERVICE_E_UNKNOWN_ERROR otherwise.
264 */
265service_error_t service_enable_ssl(service_client_t client) 177service_error_t service_enable_ssl(service_client_t client)
266{ 178{
267 if (!client || !client->connection) 179 if (!client || !client->connection)
@@ -269,15 +181,6 @@ service_error_t service_enable_ssl(service_client_t client)
269 return idevice_to_service_error(idevice_connection_enable_ssl(client->connection)); 181 return idevice_to_service_error(idevice_connection_enable_ssl(client->connection));
270} 182}
271 183
272/**
273 * Disable SSL for the given service client.
274 *
275 * @param client The connected service client for that SSL should be disabled.
276 *
277 * @return SERVICE_E_SUCCESS on success,
278 * SERVICE_E_INVALID_ARG if client or client->connection is
279 * NULL, or SERVICE_E_UNKNOWN_ERROR otherwise.
280 */
281service_error_t service_disable_ssl(service_client_t client) 184service_error_t service_disable_ssl(service_client_t client)
282{ 185{
283 if (!client || !client->connection) 186 if (!client || !client->connection)
diff --git a/src/syslog_relay.c b/src/syslog_relay.c
index b908153..a636e6e 100644
--- a/src/syslog_relay.c
+++ b/src/syslog_relay.c
@@ -61,18 +61,6 @@ static syslog_relay_error_t syslog_relay_error(service_error_t err)
61 return SYSLOG_RELAY_E_UNKNOWN_ERROR; 61 return SYSLOG_RELAY_E_UNKNOWN_ERROR;
62} 62}
63 63
64/**
65 * Connects to the syslog_relay service on the specified device.
66 *
67 * @param device The device to connect to.
68 * @param service The service descriptor returned by lockdownd_start_service.
69 * @param client Pointer that will point to a newly allocated
70 * syslog_relay_client_t upon successful return. Must be freed using
71 * syslog_relay_client_free() after use.
72 *
73 * @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
74 * client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
75 */
76syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client) 64syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client)
77{ 65{
78 *client = NULL; 66 *client = NULL;
@@ -101,19 +89,6 @@ syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service
101 return 0; 89 return 0;
102} 90}
103 91
104/**
105 * Starts a new syslog_relay service on the specified device and connects to it.
106 *
107 * @param device The device to connect to.
108 * @param client Pointer that will point to a newly allocated
109 * syslog_relay_client_t upon successful return. Must be freed using
110 * syslog_relay_client_free() after use.
111 * @param label The label to use for communication. Usually the program name.
112 * Pass NULL to disable sending the label in requests to lockdownd.
113 *
114 * @return SYSLOG_RELAY_E_SUCCESS on success, or an SYSLOG_RELAY_E_* error
115 * code otherwise.
116 */
117syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label) 92syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label)
118{ 93{
119 syslog_relay_error_t err = SYSLOG_RELAY_E_UNKNOWN_ERROR; 94 syslog_relay_error_t err = SYSLOG_RELAY_E_UNKNOWN_ERROR;
@@ -121,15 +96,6 @@ syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_
121 return err; 96 return err;
122} 97}
123 98
124/**
125 * Disconnects a syslog_relay client from the device and frees up the
126 * syslog_relay client data.
127 *
128 * @param client The syslog_relay client to disconnect and free.
129 *
130 * @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
131 * client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
132 */
133syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client) 99syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client)
134{ 100{
135 if (!client) 101 if (!client)
@@ -146,38 +112,11 @@ syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client)
146 return err; 112 return err;
147} 113}
148 114
149/**
150 * Receives data from the service.
151 *
152 * @param client The syslog_relay client
153 * @param data Buffer that will be filled with the data received
154 * @param size Number of bytes to receive
155 * @param received Number of bytes received (can be NULL to ignore)
156 * @param timeout Maximum time in milliseconds to wait for data.
157 *
158 * @return SYSLOG_RELAY_E_SUCCESS on success,
159 * SYSLOG_RELAY_E_INVALID_ARG when client or plist is NULL
160 */
161syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received) 115syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received)
162{ 116{
163 return syslog_relay_receive_with_timeout(client, data, size, received, 1000); 117 return syslog_relay_receive_with_timeout(client, data, size, received, 1000);
164} 118}
165 119
166/**
167 * Receives data using the given syslog_relay client with specified timeout.
168 *
169 * @param client The syslog_relay client to use for receiving
170 * @param data Buffer that will be filled with the data received
171 * @param size Number of bytes to receive
172 * @param received Number of bytes received (can be NULL to ignore)
173 * @param timeout Maximum time in milliseconds to wait for data.
174 *
175 * @return SYSLOG_RELAY_E_SUCCESS on success,
176 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
177 * invalid, SYSLOG_RELAY_E_MUX_ERROR when a communication error
178 * occurs, or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
179 * error occurs.
180 */
181syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout) 120syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
182{ 121{
183 syslog_relay_error_t res = SYSLOG_RELAY_E_UNKNOWN_ERROR; 122 syslog_relay_error_t res = SYSLOG_RELAY_E_UNKNOWN_ERROR;
@@ -232,20 +171,6 @@ void *syslog_relay_worker(void *arg)
232 return NULL; 171 return NULL;
233} 172}
234 173
235/**
236 * Starts capturing the syslog of the device using a callback.
237 *
238 * Use syslog_relay_stop_capture() to stop receiving the syslog.
239 *
240 * @param client The syslog_relay client to use
241 * @param callback Callback to receive each character from the syslog.
242 * @param user_data Custom pointer passed to the callback function.
243 *
244 * @return SYSLOG_RELAY_E_SUCCESS on success,
245 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
246 * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
247 * error occurs or a syslog capture has already been started.
248 */
249syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data) 174syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data)
250{ 175{
251 if (!client || !callback) 176 if (!client || !callback)
@@ -273,18 +198,6 @@ syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, sy
273 return res; 198 return res;
274} 199}
275 200
276/**
277 * Stops capturing the syslog of the device.
278 *
279 * Use syslog_relay_start_capture() to start receiving the syslog.
280 *
281 * @param client The syslog_relay client to use
282 *
283 * @return SYSLOG_RELAY_E_SUCCESS on success,
284 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
285 * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
286 * error occurs or a syslog capture has already been started.
287 */
288syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client) 201syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client)
289{ 202{
290 if (client->worker) { 203 if (client->worker) {
diff --git a/src/webinspector.c b/src/webinspector.c
index 14a8bd8..31c5b2c 100644
--- a/src/webinspector.c
+++ b/src/webinspector.c
@@ -58,18 +58,6 @@ static webinspector_error_t webinspector_error(property_list_service_error_t err
58 return WEBINSPECTOR_E_UNKNOWN_ERROR; 58 return WEBINSPECTOR_E_UNKNOWN_ERROR;
59} 59}
60 60
61/**
62 * Connects to the webinspector service on the specified device.
63 *
64 * @param device The device to connect to.
65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Pointer that will point to a newly allocated
67 * webinspector_client_t upon successful return. Must be freed using
68 * webinspector_client_free() after use.
69 *
70 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
71 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
72 */
73webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client) 61webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client)
74{ 62{
75 *client = NULL; 63 *client = NULL;
@@ -97,19 +85,6 @@ webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service
97 return 0; 85 return 0;
98} 86}
99 87
100/**
101 * Starts a new webinspector service on the specified device and connects to it.
102 *
103 * @param device The device to connect to.
104 * @param client Pointer that will point to a newly allocated
105 * webinspector_client_t upon successful return. Must be freed using
106 * webinspector_client_free() after use.
107 * @param label The label to use for communication. Usually the program name.
108 * Pass NULL to disable sending the label in requests to lockdownd.
109 *
110 * @return WEBINSPECTOR_E_SUCCESS on success, or an WEBINSPECTOR_E_* error
111 * code otherwise.
112 */
113webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label) 88webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label)
114{ 89{
115 webinspector_error_t err = WEBINSPECTOR_E_UNKNOWN_ERROR; 90 webinspector_error_t err = WEBINSPECTOR_E_UNKNOWN_ERROR;
@@ -117,15 +92,6 @@ webinspector_error_t webinspector_client_start_service(idevice_t device, webinsp
117 return err; 92 return err;
118} 93}
119 94
120/**
121 * Disconnects a webinspector client from the device and frees up the
122 * webinspector client data.
123 *
124 * @param client The webinspector client to disconnect and free.
125 *
126 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
127 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
128 */
129webinspector_error_t webinspector_client_free(webinspector_client_t client) 95webinspector_error_t webinspector_client_free(webinspector_client_t client)
130{ 96{
131 if (!client) 97 if (!client)
@@ -137,15 +103,6 @@ webinspector_error_t webinspector_client_free(webinspector_client_t client)
137 return err; 103 return err;
138} 104}
139 105
140/**
141 * Sends a plist to the service.
142 *
143 * @param client The webinspector client
144 * @param plist The plist to send
145 *
146 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
147 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
148 */
149webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist) 106webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist)
150{ 107{
151 webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR; 108 webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR;
@@ -203,35 +160,11 @@ webinspector_error_t webinspector_send(webinspector_client_t client, plist_t pli
203 return res; 160 return res;
204} 161}
205 162
206/**
207 * Receives a plist from the service.
208 *
209 * @param client The webinspector client
210 * @param plist The plist to store the received data
211 *
212 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
213 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
214 */
215webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist) 163webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist)
216{ 164{
217 return webinspector_receive_with_timeout(client, plist, 5000); 165 return webinspector_receive_with_timeout(client, plist, 5000);
218} 166}
219 167
220/**
221 * Receives a plist using the given webinspector client.
222 *
223 * @param client The webinspector client to use for receiving
224 * @param plist pointer to a plist_t that will point to the received plist
225 * upon successful return
226 * @param timeout Maximum time in milliseconds to wait for data.
227 *
228 * @return WEBINSPECTOR_E_SUCCESS on success,
229 * WEBINSPECTOR_E_INVALID_ARG when client or *plist is NULL,
230 * WEBINSPECTOR_E_PLIST_ERROR when the received data cannot be
231 * converted to a plist, WEBINSPECTOR_E_MUX_ERROR when a
232 * communication error occurs, or WEBINSPECTOR_E_UNKNOWN_ERROR
233 * when an unspecified error occurs.
234 */
235webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms) 168webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms)
236{ 169{
237 webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR; 170 webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR;