summaryrefslogtreecommitdiffstats
path: root/include/libimobiledevice
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 /include/libimobiledevice
parentee82e861a8c942b5013accd7589cf898d1f97167 (diff)
downloadlibimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.gz
libimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.bz2
Moved Doxygen comments from source files to public headers.
Conflicts: include/libimobiledevice/afc.h
Diffstat (limited to 'include/libimobiledevice')
-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
20 files changed, 2701 insertions, 0 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