diff options
| author | 2014-03-27 10:07:09 -0400 | |
|---|---|---|
| committer | 2014-03-27 21:40:43 -0400 | |
| commit | 2342dc5b4ef148b993fbe3816f3facdef8365546 (patch) | |
| tree | 69f812d91b2fc07db0fad5dcba6c80d2f8b6849e /include/libimobiledevice/lockdown.h | |
| parent | ee82e861a8c942b5013accd7589cf898d1f97167 (diff) | |
| download | libimobiledevice-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/lockdown.h')
| -rw-r--r-- | include/libimobiledevice/lockdown.h | 302 |
1 files changed, 302 insertions, 0 deletions
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 { | |||
| 81 | typedef struct lockdownd_service_descriptor *lockdownd_service_descriptor_t; | 81 | typedef 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 | */ | ||
| 84 | lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label); | 100 | lockdownd_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 | */ | ||
| 85 | lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label); | 119 | lockdownd_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 | */ | ||
| 86 | lockdownd_error_t lockdownd_client_free(lockdownd_client_t client); | 129 | lockdownd_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 | */ | ||
| 88 | lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type); | 141 | lockdownd_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 | */ | ||
| 89 | lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value); | 153 | lockdownd_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 | */ | ||
| 90 | lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value); | 166 | lockdownd_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 | */ | ||
| 91 | lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key); | 179 | lockdownd_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 | */ | ||
| 92 | lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service); | 193 | lockdownd_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 | */ | ||
| 93 | lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled); | 208 | lockdownd_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 | */ | ||
| 94 | lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id); | 220 | lockdownd_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 | */ | ||
| 95 | lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist); | 234 | lockdownd_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 | */ | ||
| 96 | lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist); | 245 | lockdownd_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 | */ | ||
| 97 | lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); | 261 | lockdownd_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 | */ | ||
| 98 | lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); | 280 | lockdownd_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 | */ | ||
| 99 | lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); | 296 | lockdownd_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 | */ | ||
| 100 | lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record); | 315 | lockdownd_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 | */ | ||
| 101 | lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client); | 327 | lockdownd_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 | */ | ||
| 102 | lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client); | 336 | lockdownd_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 | */ | ||
| 103 | lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client); | 347 | lockdownd_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 | */ | ||
| 106 | void lockdownd_client_set_label(lockdownd_client_t client, const char *label); | 358 | void 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 | */ | ||
| 107 | lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t control, char **udid); | 369 | lockdownd_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 | */ | ||
| 108 | lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name); | 380 | lockdownd_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 | */ | ||
| 109 | lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count); | 395 | lockdownd_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 | */ | ||
| 110 | lockdownd_error_t lockdownd_data_classes_free(char **classes); | 404 | lockdownd_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 | */ | ||
| 111 | lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service); | 413 | lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service); |
| 112 | 414 | ||
| 113 | #ifdef __cplusplus | 415 | #ifdef __cplusplus |
