diff options
Diffstat (limited to 'include/libimobiledevice/libimobiledevice.h')
| -rw-r--r-- | include/libimobiledevice/libimobiledevice.h | 423 |
1 files changed, 380 insertions, 43 deletions
diff --git a/include/libimobiledevice/libimobiledevice.h b/include/libimobiledevice/libimobiledevice.h index d0923d6..bc57778 100644 --- a/include/libimobiledevice/libimobiledevice.h +++ b/include/libimobiledevice/libimobiledevice.h | |||
| @@ -3,101 +3,438 @@ | |||
| 3 | * @brief Device/Connection handling and communication | 3 | * @brief Device/Connection handling and communication |
| 4 | * \internal | 4 | * \internal |
| 5 | * | 5 | * |
| 6 | * Copyright (c) 2010-2019 Nikias Bassen All Rights Reserved. | ||
| 7 | * Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved. | ||
| 8 | * Copyright (c) 2014 Christophe Fergeau All Rights Reserved. | ||
| 6 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. | 9 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. |
| 7 | * | 10 | * |
| 8 | * This library is free software; you can redistribute it and/or | 11 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public | 12 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation; either | 13 | * License as published by the Free Software Foundation; either |
| 11 | * version 2.1 of the License, or (at your option) any later version. | 14 | * version 2.1 of the License, or (at your option) any later version. |
| 12 | * | 15 | * |
| 13 | * This library is distributed in the hope that it will be useful, | 16 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. | 19 | * Lesser General Public License for more details. |
| 17 | * | 20 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public | 21 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software | 22 | * License along with this library; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ | 24 | */ |
| 22 | 25 | ||
| 23 | #ifndef LIBIMOBILEDEVICE_H | 26 | #ifndef IMOBILEDEVICE_H |
| 24 | #define LIBIMOBILEDEVICE_H | 27 | #define IMOBILEDEVICE_H |
| 25 | 28 | ||
| 26 | #ifdef __cplusplus | 29 | #ifdef __cplusplus |
| 27 | extern "C" { | 30 | extern "C" { |
| 28 | #endif | 31 | #endif |
| 29 | 32 | ||
| 30 | #include <stdint.h> | 33 | #include <stdint.h> |
| 31 | #include <sys/types.h> | ||
| 32 | #include <sys/stat.h> | ||
| 33 | #include <plist/plist.h> | 34 | #include <plist/plist.h> |
| 34 | 35 | ||
| 35 | /** @name Error Codes */ | 36 | #if defined(_MSC_VER) |
| 36 | /*@{*/ | 37 | #include <basetsd.h> |
| 37 | #define IDEVICE_E_SUCCESS 0 | 38 | typedef SSIZE_T ssize_t; |
| 38 | #define IDEVICE_E_INVALID_ARG -1 | 39 | #endif |
| 39 | #define IDEVICE_E_UNKNOWN_ERROR -2 | 40 | |
| 40 | #define IDEVICE_E_NO_DEVICE -3 | 41 | #ifndef LIBIMOBILEDEVICE_API |
| 41 | #define IDEVICE_E_NOT_ENOUGH_DATA -4 | 42 | #ifdef LIBIMOBILEDEVICE_STATIC |
| 42 | #define IDEVICE_E_BAD_HEADER -5 | 43 | #define LIBIMOBILEDEVICE_API |
| 43 | #define IDEVICE_E_SSL_ERROR -6 | 44 | #elif defined(_WIN32) |
| 44 | /*@}*/ | 45 | #define LIBIMOBILEDEVICE_API __declspec(dllimport) |
| 45 | 46 | #else | |
| 46 | /** Represents an error code. */ | 47 | #define LIBIMOBILEDEVICE_API |
| 47 | typedef int16_t idevice_error_t; | 48 | #endif |
| 48 | 49 | #endif | |
| 49 | typedef struct idevice_private idevice_private; | 50 | |
| 51 | /** Error Codes */ | ||
| 52 | typedef enum { | ||
| 53 | IDEVICE_E_SUCCESS = 0, | ||
| 54 | IDEVICE_E_INVALID_ARG = -1, | ||
| 55 | IDEVICE_E_UNKNOWN_ERROR = -2, | ||
| 56 | IDEVICE_E_NO_DEVICE = -3, | ||
| 57 | IDEVICE_E_NOT_ENOUGH_DATA = -4, | ||
| 58 | IDEVICE_E_CONNREFUSED = -5, | ||
| 59 | IDEVICE_E_SSL_ERROR = -6, | ||
| 60 | IDEVICE_E_TIMEOUT = -7 | ||
| 61 | } idevice_error_t; | ||
| 62 | |||
| 63 | typedef struct idevice_private idevice_private; /**< \private */ | ||
| 50 | typedef idevice_private *idevice_t; /**< The device handle. */ | 64 | typedef idevice_private *idevice_t; /**< The device handle. */ |
| 51 | 65 | ||
| 52 | typedef struct idevice_connection_private idevice_connection_private; | 66 | typedef struct idevice_connection_private idevice_connection_private; /**< \private */ |
| 53 | typedef idevice_connection_private *idevice_connection_t; /**< The connection handle. */ | 67 | typedef idevice_connection_private *idevice_connection_t; /**< The connection handle. */ |
| 54 | 68 | ||
| 55 | /* generic */ | 69 | /** Options for idevice_new_with_options() */ |
| 56 | void idevice_set_debug_level(int level); | 70 | enum idevice_options { |
| 71 | IDEVICE_LOOKUP_USBMUX = 1 << 1, /**< include USBMUX devices during lookup */ | ||
| 72 | IDEVICE_LOOKUP_NETWORK = 1 << 2, /**< include network devices during lookup */ | ||
| 73 | IDEVICE_LOOKUP_PREFER_NETWORK = 1 << 3 /**< prefer network connection if device is available via USBMUX *and* network */ | ||
| 74 | }; | ||
| 75 | |||
| 76 | /** Type of connection a device is available on */ | ||
| 77 | enum idevice_connection_type { | ||
| 78 | CONNECTION_USBMUXD = 1, /**< device is available via USBMUX */ | ||
| 79 | CONNECTION_NETWORK /**< device is available via network */ | ||
| 80 | }; | ||
| 81 | |||
| 82 | /** Device information returned by #idevice_get_device_list_extended API */ | ||
| 83 | struct idevice_info { | ||
| 84 | char *udid; /**< UDID of the device */ | ||
| 85 | enum idevice_connection_type conn_type; /**< Type of connection the device is available on */ | ||
| 86 | void* conn_data; /**< Connection data, depending on the connection type */ | ||
| 87 | }; | ||
| 88 | typedef struct idevice_info* idevice_info_t; | ||
| 57 | 89 | ||
| 58 | /* discovery (events/asynchronous) */ | 90 | /* discovery (events/asynchronous) */ |
| 59 | /** The event type for device add or removal */ | 91 | /** The event type for device add or removal */ |
| 60 | enum idevice_event_type { | 92 | enum idevice_event_type { |
| 61 | IDEVICE_DEVICE_ADD = 1, | 93 | IDEVICE_DEVICE_ADD = 1, /**< device was added */ |
| 62 | IDEVICE_DEVICE_REMOVE | 94 | IDEVICE_DEVICE_REMOVE, /**< device was removed */ |
| 95 | IDEVICE_DEVICE_PAIRED /**< device completed pairing process */ | ||
| 63 | }; | 96 | }; |
| 64 | 97 | ||
| 65 | /* event data structure */ | 98 | /* event data structure */ |
| 66 | /** Provides information about the occured event. */ | 99 | /** Provides information about the occurred event. */ |
| 67 | typedef struct { | 100 | typedef struct { |
| 68 | enum idevice_event_type event; /**< The event type. */ | 101 | enum idevice_event_type event; /**< The event type. */ |
| 69 | const char *uuid; /**< The device unique id. */ | 102 | const char *udid; /**< The device unique id. */ |
| 70 | int conn_type; /**< The connection type. Currently only 1 for usbmuxd. */ | 103 | enum idevice_connection_type conn_type; /**< The connection type. */ |
| 71 | } idevice_event_t; | 104 | } idevice_event_t; |
| 72 | 105 | ||
| 73 | /* event callback function prototype */ | 106 | /* event callback function prototype */ |
| 74 | /** Callback to notifiy if a device was added or removed. */ | 107 | /** Callback to notifiy if a device was added or removed. */ |
| 75 | typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_data); | 108 | typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_data); |
| 76 | 109 | ||
| 110 | /** Event subscription context type */ | ||
| 111 | typedef struct idevice_subscription_context* idevice_subscription_context_t; | ||
| 112 | |||
| 77 | /* functions */ | 113 | /* functions */ |
| 78 | idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data); | 114 | |
| 79 | idevice_error_t idevice_event_unsubscribe(); | 115 | /** |
| 116 | * Set the level of debugging. | ||
| 117 | * | ||
| 118 | * @param level Set to 0 for no debug output or 1 to enable debug output. | ||
| 119 | */ | ||
| 120 | LIBIMOBILEDEVICE_API void idevice_set_debug_level(int level); | ||
| 121 | |||
| 122 | /** | ||
| 123 | * Subscribe a callback function that will be called when device add/remove | ||
| 124 | * events occur. | ||
| 125 | * | ||
| 126 | * @param context A pointer to a idevice_subscription_context_t that will be | ||
| 127 | * set upon creation of the subscription. The returned context must be | ||
| 128 | * passed to idevice_events_unsubscribe() to unsubscribe the callback. | ||
| 129 | * @param callback Callback function to call. | ||
| 130 | * @param user_data Application-specific data passed as parameter | ||
| 131 | * to the registered callback function. | ||
| 132 | * | ||
| 133 | * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. | ||
| 134 | */ | ||
| 135 | LIBIMOBILEDEVICE_API idevice_error_t idevice_events_subscribe(idevice_subscription_context_t *context, idevice_event_cb_t callback, void *user_data); | ||
| 136 | |||
| 137 | /** | ||
| 138 | * Unsubscribe the event callback function that has been registered with | ||
| 139 | * idevice_events_subscribe(). | ||
| 140 | * | ||
| 141 | * @param context A valid context as returned from idevice_events_subscribe(). | ||
| 142 | * | ||
| 143 | * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. | ||
| 144 | */ | ||
| 145 | LIBIMOBILEDEVICE_API idevice_error_t idevice_events_unsubscribe(idevice_subscription_context_t context); | ||
| 146 | |||
| 147 | /** | ||
| 148 | * (DEPRECATED) Register a callback function that will be called when device add/remove | ||
| 149 | * events occur. | ||
| 150 | * | ||
| 151 | * @deprecated Use idevice_events_subscribe() instead. | ||
| 152 | * | ||
| 153 | * @param callback Callback function to call. | ||
| 154 | * @param user_data Application-specific data passed as parameter | ||
| 155 | * to the registered callback function. | ||
| 156 | * | ||
| 157 | * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. | ||
| 158 | */ | ||
| 159 | LIBIMOBILEDEVICE_API idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data); | ||
| 160 | |||
| 161 | /** | ||
| 162 | * (DEPRECATED) Release the event callback function that has been registered with | ||
| 163 | * idevice_event_subscribe(). | ||
| 164 | * | ||
| 165 | * @deprecated Use idevice_events_unsubscribe() instead. | ||
| 166 | * | ||
| 167 | * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. | ||
| 168 | */ | ||
| 169 | LIBIMOBILEDEVICE_API idevice_error_t idevice_event_unsubscribe(void); | ||
| 80 | 170 | ||
| 81 | /* discovery (synchronous) */ | 171 | /* discovery (synchronous) */ |
| 82 | idevice_error_t idevice_get_device_list(char ***devices, int *count); | 172 | |
| 83 | idevice_error_t idevice_device_list_free(char **devices); | 173 | /** |
| 174 | * Get a list of UDIDs of currently available devices (USBMUX devices only). | ||
| 175 | * | ||
| 176 | * @param devices List of UDIDs of devices that are currently available. | ||
| 177 | * This list is terminated by a NULL pointer. | ||
| 178 | * @param count Number of devices found. | ||
| 179 | * | ||
| 180 | * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. | ||
| 181 | * | ||
| 182 | * @note This function only returns the UDIDs of USBMUX devices. To also include | ||
| 183 | * network devices in the list, use idevice_get_device_list_extended(). | ||
| 184 | * @see idevice_get_device_list_extended | ||
| 185 | */ | ||
| 186 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list(char ***devices, int *count); | ||
| 187 | |||
| 188 | /** | ||
| 189 | * Free a list of device UDIDs. | ||
| 190 | * | ||
| 191 | * @param devices List of UDIDs to free. | ||
| 192 | * | ||
| 193 | * @return Always returnes IDEVICE_E_SUCCESS. | ||
| 194 | */ | ||
| 195 | LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_free(char **devices); | ||
| 196 | |||
| 197 | /** | ||
| 198 | * Get a list of currently available devices | ||
| 199 | * | ||
| 200 | * @param devices List of idevice_info_t records with device information. | ||
| 201 | * This list is terminated by a NULL pointer. | ||
| 202 | * @param count Number of devices included in the list. | ||
| 203 | * | ||
| 204 | * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. | ||
| 205 | */ | ||
| 206 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *count); | ||
| 207 | |||
| 208 | /** | ||
| 209 | * Free an extended device list retrieved through idevice_get_device_list_extended(). | ||
| 210 | * | ||
| 211 | * @param devices Device list to free. | ||
| 212 | * | ||
| 213 | * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. | ||
| 214 | */ | ||
| 215 | LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_extended_free(idevice_info_t *devices); | ||
| 84 | 216 | ||
| 85 | /* device structure creation and destruction */ | 217 | /* device structure creation and destruction */ |
| 86 | idevice_error_t idevice_new(idevice_t *device, const char *uuid); | 218 | |
| 87 | idevice_error_t idevice_free(idevice_t device); | 219 | /** |
| 220 | * Creates an idevice_t structure for the device specified by UDID, | ||
| 221 | * if the device is available (USBMUX devices only). | ||
| 222 | * | ||
| 223 | * @note The resulting idevice_t structure has to be freed with | ||
| 224 | * idevice_free() if it is no longer used. | ||
| 225 | * If you need to connect to a device available via network, use | ||
| 226 | * idevice_new_with_options() and include IDEVICE_LOOKUP_NETWORK in options. | ||
| 227 | * | ||
| 228 | * @see idevice_new_with_options | ||
| 229 | * | ||
| 230 | * @param device Upon calling this function, a pointer to a location of type | ||
| 231 | * idevice_t. On successful return, this location will be populated. | ||
| 232 | * @param udid The UDID to match. | ||
| 233 | * | ||
| 234 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 235 | */ | ||
| 236 | LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t *device, const char *udid); | ||
| 237 | |||
| 238 | /** | ||
| 239 | * Creates an idevice_t structure for the device specified by UDID, | ||
| 240 | * if the device is available, with the given lookup options. | ||
| 241 | * | ||
| 242 | * @note The resulting idevice_t structure has to be freed with | ||
| 243 | * idevice_free() if it is no longer used. | ||
| 244 | * | ||
| 245 | * @param device Upon calling this function, a pointer to a location of type | ||
| 246 | * idevice_t. On successful return, this location will be populated. | ||
| 247 | * @param udid The UDID to match. | ||
| 248 | * @param options Specifies what connection types should be considered | ||
| 249 | * when looking up devices. Accepts bitwise or'ed values of idevice_options. | ||
| 250 | * If 0 (no option) is specified it will default to IDEVICE_LOOKUP_USBMUX. | ||
| 251 | * To lookup both USB and network-connected devices, pass | ||
| 252 | * IDEVICE_LOOKUP_USBMUX | IDEVICE_LOOKUP_NETWORK. If a device is available | ||
| 253 | * both via USBMUX *and* network, it will select the USB connection. | ||
| 254 | * This behavior can be changed by adding IDEVICE_LOOKUP_PREFER_NETWORK | ||
| 255 | * to the options in which case it will select the network connection. | ||
| 256 | * | ||
| 257 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 258 | */ | ||
| 259 | LIBIMOBILEDEVICE_API idevice_error_t idevice_new_with_options(idevice_t *device, const char *udid, enum idevice_options options); | ||
| 260 | |||
| 261 | /** | ||
| 262 | * Cleans up an idevice structure, then frees the structure itself. | ||
| 263 | * | ||
| 264 | * @param device idevice_t to free. | ||
| 265 | */ | ||
| 266 | LIBIMOBILEDEVICE_API idevice_error_t idevice_free(idevice_t device); | ||
| 88 | 267 | ||
| 89 | /* connection/disconnection */ | 268 | /* connection/disconnection */ |
| 90 | idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection); | 269 | |
| 91 | idevice_error_t idevice_disconnect(idevice_connection_t connection); | 270 | /** |
| 271 | * Set up a connection to the given device. | ||
| 272 | * | ||
| 273 | * @param device The device to connect to. | ||
| 274 | * @param port The destination port to connect to. | ||
| 275 | * @param connection Pointer to an idevice_connection_t that will be filled | ||
| 276 | * with the necessary data of the connection. | ||
| 277 | * | ||
| 278 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 279 | */ | ||
| 280 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection); | ||
| 281 | |||
| 282 | /** | ||
| 283 | * Disconnect from the device and clean up the connection structure. | ||
| 284 | * | ||
| 285 | * @param connection The connection to close. | ||
| 286 | * | ||
| 287 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 288 | */ | ||
| 289 | LIBIMOBILEDEVICE_API idevice_error_t idevice_disconnect(idevice_connection_t connection); | ||
| 92 | 290 | ||
| 93 | /* communication */ | 291 | /* communication */ |
| 94 | idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes); | 292 | |
| 95 | idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout); | 293 | /** |
| 96 | idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes); | 294 | * Send data to a device via the given connection. |
| 295 | * | ||
| 296 | * @param connection The connection to send data over. | ||
| 297 | * @param data Buffer with data to send. | ||
| 298 | * @param len Size of the buffer to send. | ||
| 299 | * @param sent_bytes Pointer to an uint32_t that will be filled | ||
| 300 | * with the number of bytes actually sent. | ||
| 301 | * | ||
| 302 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 303 | */ | ||
| 304 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes); | ||
| 305 | |||
| 306 | /** | ||
| 307 | * Receive data from a device via the given connection. | ||
| 308 | * This function will return after the given timeout even if no data has been | ||
| 309 | * received. | ||
| 310 | * | ||
| 311 | * @param connection The connection to receive data from. | ||
| 312 | * @param data Buffer that will be filled with the received data. | ||
| 313 | * This buffer has to be large enough to hold len bytes. | ||
| 314 | * @param len Buffer size or number of bytes to receive. | ||
| 315 | * @param recv_bytes Number of bytes actually received. | ||
| 316 | * @param timeout Timeout in milliseconds after which this function should | ||
| 317 | * return even if no data has been received. | ||
| 318 | * | ||
| 319 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 320 | */ | ||
| 321 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout); | ||
| 322 | |||
| 323 | /** | ||
| 324 | * Receive data from a device via the given connection. | ||
| 325 | * This function is like idevice_connection_receive_timeout, but with a | ||
| 326 | * predefined reasonable timeout. | ||
| 327 | * | ||
| 328 | * @param connection The connection to receive data from. | ||
| 329 | * @param data Buffer that will be filled with the received data. | ||
| 330 | * This buffer has to be large enough to hold len bytes. | ||
| 331 | * @param len Buffer size or number of bytes to receive. | ||
| 332 | * @param recv_bytes Number of bytes actually received. | ||
| 333 | * | ||
| 334 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 335 | */ | ||
| 336 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes); | ||
| 337 | |||
| 338 | /** | ||
| 339 | * Enables SSL for the given connection. | ||
| 340 | * | ||
| 341 | * @param connection The connection to enable SSL for. | ||
| 342 | * | ||
| 343 | * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection | ||
| 344 | * is NULL or connection->ssl_data is non-NULL, or IDEVICE_E_SSL_ERROR when | ||
| 345 | * SSL initialization, setup, or handshake fails. | ||
| 346 | */ | ||
| 347 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection); | ||
| 348 | |||
| 349 | /** | ||
| 350 | * Disable SSL for the given connection. | ||
| 351 | * | ||
| 352 | * @param connection The connection to disable SSL for. | ||
| 353 | * | ||
| 354 | * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection | ||
| 355 | * is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not | ||
| 356 | * enabled and does no further error checking on cleanup. | ||
| 357 | */ | ||
| 358 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection); | ||
| 359 | |||
| 360 | /** | ||
| 361 | * Disable bypass SSL for the given connection without sending out terminate messages. | ||
| 362 | * | ||
| 363 | * @param connection The connection to disable SSL for. | ||
| 364 | * @param sslBypass if true ssl connection will not be terminated but just cleaned up, allowing | ||
| 365 | * plain text data going on underlying connection | ||
| 366 | * | ||
| 367 | * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection | ||
| 368 | * is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not | ||
| 369 | * enabled and does no further error checking on cleanup. | ||
| 370 | */ | ||
| 371 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_bypass_ssl(idevice_connection_t connection, uint8_t sslBypass); | ||
| 372 | |||
| 373 | |||
| 374 | /** | ||
| 375 | * Get the underlying file descriptor for a connection | ||
| 376 | * | ||
| 377 | * @param connection The connection to get fd of | ||
| 378 | * @param fd Pointer to an int where the fd is stored | ||
| 379 | * | ||
| 380 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 381 | */ | ||
| 382 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd); | ||
| 97 | 383 | ||
| 98 | /* misc */ | 384 | /* misc */ |
| 99 | idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle); | 385 | |
| 100 | idevice_error_t idevice_get_uuid(idevice_t device, char **uuid); | 386 | /** |
| 387 | * Gets the handle or (USBMUX device id) of the device. | ||
| 388 | * | ||
| 389 | * @param device The device to get the USBMUX device id for. | ||
| 390 | * @param handle Pointer to a uint32_t that will be set to the USBMUX handle value. | ||
| 391 | * | ||
| 392 | * @return IDEVICE_E_SUCCESS on success, otherwise an error code. | ||
| 393 | */ | ||
| 394 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle); | ||
| 395 | |||
| 396 | /** | ||
| 397 | * Gets the Unique Device ID for the device. | ||
| 398 | * | ||
| 399 | * @param device The device to get the Unique Device ID for. | ||
| 400 | * @param udid Pointer that will be set to an allocated buffer with the device UDID. The consumer is responsible for releasing the allocated memory. | ||
| 401 | * | ||
| 402 | * @return IDEVICE_E_SUCCESS on success, otherwise an error code. | ||
| 403 | */ | ||
| 404 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_udid(idevice_t device, char **udid); | ||
| 405 | |||
| 406 | /** | ||
| 407 | * Returns the device ProductVersion in numerical form, where "X.Y.Z" | ||
| 408 | * will be returned as (X << 16) | (Y << 8) | Z . | ||
| 409 | * Use IDEVICE_DEVICE_VERSION macro for easy version comparison. | ||
| 410 | * @see IDEVICE_DEVICE_VERSION | ||
| 411 | * | ||
| 412 | * @param client Initialized device client | ||
| 413 | * | ||
| 414 | * @return A numerical representation of the X.Y.Z ProductVersion string | ||
| 415 | * or 0 if the version cannot be retrieved. | ||
| 416 | */ | ||
| 417 | LIBIMOBILEDEVICE_API unsigned int idevice_get_device_version(idevice_t device); | ||
| 418 | |||
| 419 | /** | ||
| 420 | * Gets a readable error string for a given idevice error code. | ||
| 421 | * | ||
| 422 | * @param err An idevice error code | ||
| 423 | * | ||
| 424 | * @return A readable error string | ||
| 425 | */ | ||
| 426 | LIBIMOBILEDEVICE_API const char* idevice_strerror(idevice_error_t err); | ||
| 427 | |||
| 428 | /** | ||
| 429 | * Returns a static string of the libimobiledevice version. | ||
| 430 | * | ||
| 431 | * @return The libimobiledevice version as static ascii string | ||
| 432 | */ | ||
| 433 | LIBIMOBILEDEVICE_API const char* libimobiledevice_version(); | ||
| 434 | |||
| 435 | /* macros */ | ||
| 436 | /** Helper macro to get a numerical representation of a product version tuple */ | ||
| 437 | #define IDEVICE_DEVICE_VERSION(maj, min, patch) ((((maj) & 0xFF) << 16) | (((min) & 0xFF) << 8) | ((patch) & 0xFF)) | ||
| 101 | 438 | ||
| 102 | #ifdef __cplusplus | 439 | #ifdef __cplusplus |
| 103 | } | 440 | } |
