diff options
Diffstat (limited to 'include/libimobiledevice/house_arrest.h')
| -rw-r--r-- | include/libimobiledevice/house_arrest.h | 160 |
1 files changed, 138 insertions, 22 deletions
diff --git a/include/libimobiledevice/house_arrest.h b/include/libimobiledevice/house_arrest.h index 04290f1..f9ba68a 100644 --- a/include/libimobiledevice/house_arrest.h +++ b/include/libimobiledevice/house_arrest.h | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * @file libimobiledevice/house_arrest.h | 2 | * @file libimobiledevice/house_arrest.h |
| 3 | * @brief Access AppStore application folders and their contents. | 3 | * @brief Access app folders and their contents. |
| 4 | * \internal | 4 | * \internal |
| 5 | * | 5 | * |
| 6 | * Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved. | ||
| 6 | * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. | 7 | * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. |
| 7 | * | 8 | * |
| 8 | * This library is free software; you can redistribute it and/or | 9 | * This library is free software; you can redistribute it and/or |
| @@ -20,42 +21,157 @@ | |||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ | 22 | */ |
| 22 | 23 | ||
| 23 | #ifndef HOUSE_ARREST_H | 24 | #ifndef IHOUSE_ARREST_H |
| 24 | #define HOUSE_ARREST_H | 25 | #define IHOUSE_ARREST_H |
| 25 | 26 | ||
| 26 | #ifdef __cplusplus | 27 | #ifdef __cplusplus |
| 27 | extern "C" { | 28 | extern "C" { |
| 28 | #endif | 29 | #endif |
| 29 | 30 | ||
| 30 | #include <libimobiledevice/libimobiledevice.h> | 31 | #include <libimobiledevice/libimobiledevice.h> |
| 32 | #include <libimobiledevice/lockdown.h> | ||
| 31 | #include <libimobiledevice/afc.h> | 33 | #include <libimobiledevice/afc.h> |
| 32 | 34 | ||
| 33 | /** @name Error Codes */ | 35 | /** Service identifier passed to lockdownd_start_service() to start the house arrest service */ |
| 34 | /*@{*/ | 36 | #define HOUSE_ARREST_SERVICE_NAME "com.apple.mobile.house_arrest" |
| 35 | #define HOUSE_ARREST_E_SUCCESS 0 | ||
| 36 | #define HOUSE_ARREST_E_INVALID_ARG -1 | ||
| 37 | #define HOUSE_ARREST_E_PLIST_ERROR -2 | ||
| 38 | #define HOUSE_ARREST_E_CONN_FAILED -3 | ||
| 39 | #define HOUSE_ARREST_E_INVALID_MODE -4 | ||
| 40 | 37 | ||
| 41 | #define HOUSE_ARREST_E_UNKNOWN_ERROR -256 | 38 | /** Error Codes */ |
| 42 | /*@}*/ | 39 | typedef enum { |
| 40 | HOUSE_ARREST_E_SUCCESS = 0, | ||
| 41 | HOUSE_ARREST_E_INVALID_ARG = -1, | ||
| 42 | HOUSE_ARREST_E_PLIST_ERROR = -2, | ||
| 43 | HOUSE_ARREST_E_CONN_FAILED = -3, | ||
| 44 | HOUSE_ARREST_E_INVALID_MODE = -4, | ||
| 45 | HOUSE_ARREST_E_UNKNOWN_ERROR = -256 | ||
| 46 | } house_arrest_error_t; | ||
| 43 | 47 | ||
| 44 | /** Represents an error code. */ | 48 | typedef struct house_arrest_client_private house_arrest_client_private; /**< \private */ |
| 45 | typedef int16_t house_arrest_error_t; | ||
| 46 | |||
| 47 | typedef struct house_arrest_client_private house_arrest_client_private; | ||
| 48 | typedef house_arrest_client_private *house_arrest_client_t; /**< The client handle. */ | 49 | typedef house_arrest_client_private *house_arrest_client_t; /**< The client handle. */ |
| 49 | 50 | ||
| 50 | /* Interface */ | 51 | /* Interface */ |
| 51 | house_arrest_error_t house_arrest_client_new(idevice_t device, uint16_t port, house_arrest_client_t *client); | ||
| 52 | house_arrest_error_t house_arrest_client_free(house_arrest_client_t client); | ||
| 53 | 52 | ||
| 54 | house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict); | 53 | /** |
| 55 | house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid); | 54 | * Connects to the house_arrest service on the specified device. |
| 56 | house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict); | 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 point to a newly allocated | ||
| 59 | * housearrest_client_t upon successful return. | ||
| 60 | * | ||
| 61 | * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when | ||
| 62 | * client is NULL, or an HOUSE_ARREST_E_* error code otherwise. | ||
| 63 | */ | ||
| 64 | LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client); | ||
| 65 | |||
| 66 | /** | ||
| 67 | * Starts a new house_arrest 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 | * house_arrest_client_t upon successful return. Must be freed using | ||
| 72 | * house_arrest_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 HOUSE_ARREST_E_SUCCESS on success, or an HOUSE_ARREST_E_* error | ||
| 77 | * code otherwise. | ||
| 78 | */ | ||
| 79 | LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t* client, const char* label); | ||
| 80 | |||
| 81 | /** | ||
| 82 | * Disconnects an house_arrest client from the device and frees up the | ||
| 83 | * house_arrest client data. | ||
| 84 | * | ||
| 85 | * @note After using afc_client_new_from_house_arrest_client(), make sure | ||
| 86 | * you call afc_client_free() before calling this function to ensure | ||
| 87 | * a proper cleanup. Do not call this function if you still need to | ||
| 88 | * perform AFC operations since it will close the connection. | ||
| 89 | * | ||
| 90 | * @param client The house_arrest client to disconnect and free. | ||
| 91 | * | ||
| 92 | * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when | ||
| 93 | * client is NULL, or an HOUSE_ARREST_E_* error code otherwise. | ||
| 94 | */ | ||
| 95 | LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_free(house_arrest_client_t client); | ||
| 96 | |||
| 97 | |||
| 98 | /** | ||
| 99 | * Sends a generic request to the connected house_arrest service. | ||
| 100 | * | ||
| 101 | * @param client The house_arrest client to use. | ||
| 102 | * @param dict The request to send as a plist of type PLIST_DICT. | ||
| 103 | * | ||
| 104 | * @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean | ||
| 105 | * that the request was successful. To check for success or failure you | ||
| 106 | * need to call house_arrest_get_result(). | ||
| 107 | * @see house_arrest_get_result | ||
| 108 | * | ||
| 109 | * @return HOUSE_ARREST_E_SUCCESS if the request was successfully sent, | ||
| 110 | * HOUSE_ARREST_E_INVALID_ARG if client or dict is invalid, | ||
| 111 | * HOUSE_ARREST_E_PLIST_ERROR if dict is not a plist of type PLIST_DICT, | ||
| 112 | * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode, | ||
| 113 | * or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred. | ||
| 114 | */ | ||
| 115 | LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict); | ||
| 116 | |||
| 117 | /** | ||
| 118 | * Send a command to the connected house_arrest service. | ||
| 119 | * Calls house_arrest_send_request() internally. | ||
| 120 | * | ||
| 121 | * @param client The house_arrest client to use. | ||
| 122 | * @param command The command to send. Currently, only VendContainer and | ||
| 123 | * VendDocuments are known. | ||
| 124 | * @param appid The application identifier to pass along with the . | ||
| 125 | * | ||
| 126 | * @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean | ||
| 127 | * that the command was successful. To check for success or failure you | ||
| 128 | * need to call house_arrest_get_result(). | ||
| 129 | * @see house_arrest_get_result | ||
| 130 | * | ||
| 131 | * @return HOUSE_ARREST_E_SUCCESS if the command was successfully sent, | ||
| 132 | * HOUSE_ARREST_E_INVALID_ARG if client, command, or appid is invalid, | ||
| 133 | * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode, | ||
| 134 | * or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred. | ||
| 135 | */ | ||
| 136 | LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid); | ||
| 137 | |||
| 138 | /** | ||
| 139 | * Retrieves the result of a previously sent house_arrest_request_* request. | ||
| 140 | * | ||
| 141 | * @param client The house_arrest client to use | ||
| 142 | * @param dict Pointer that will be set to a plist containing the result to | ||
| 143 | * the last performed operation. It holds a key 'Status' with the value | ||
| 144 | * 'Complete' on success or a key 'Error' with an error description as | ||
| 145 | * value. The caller is responsible for freeing the returned plist. | ||
| 146 | * | ||
| 147 | * @return HOUSE_ARREST_E_SUCCESS if a result plist was retrieved, | ||
| 148 | * HOUSE_ARREST_E_INVALID_ARG if client is invalid, | ||
| 149 | * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode, | ||
| 150 | * or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred. | ||
| 151 | */ | ||
| 152 | LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict); | ||
| 153 | |||
| 57 | 154 | ||
| 58 | afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client); | 155 | /** |
| 156 | * Creates an AFC client using the given house_arrest client's connection | ||
| 157 | * allowing file access to a specific application directory requested by | ||
| 158 | * functions like house_arrest_request_vendor_documents(). | ||
| 159 | * | ||
| 160 | * @param client The house_arrest client to use. | ||
| 161 | * @param afc_client Pointer that will be set to a newly allocated afc_client_t | ||
| 162 | * upon successful return. | ||
| 163 | * | ||
| 164 | * @note After calling this function the house_arrest client will go in an | ||
| 165 | * AFC mode that will only allow calling house_arrest_client_free(). | ||
| 166 | * Only call house_arrest_client_free() if all AFC operations have | ||
| 167 | * completed since it will close the connection. | ||
| 168 | * | ||
| 169 | * @return AFC_E_SUCCESS if the afc client was successfully created, | ||
| 170 | * AFC_E_INVALID_ARG if client is invalid or was already used to create | ||
| 171 | * an afc client, or an AFC_E_* error code returned by | ||
| 172 | * afc_client_new_with_service_client(). | ||
| 173 | */ | ||
| 174 | LIBIMOBILEDEVICE_API afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client); | ||
| 59 | 175 | ||
| 60 | #ifdef __cplusplus | 176 | #ifdef __cplusplus |
| 61 | } | 177 | } |
