diff options
Diffstat (limited to 'include/libimobiledevice/mobileactivation.h')
| -rw-r--r-- | include/libimobiledevice/mobileactivation.h | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/include/libimobiledevice/mobileactivation.h b/include/libimobiledevice/mobileactivation.h new file mode 100644 index 0000000..bb977fe --- /dev/null +++ b/include/libimobiledevice/mobileactivation.h | |||
| @@ -0,0 +1,144 @@ | |||
| 1 | /** | ||
| 2 | * @file libimobiledevice/mobileactivation.h | ||
| 3 | * @brief Handle device activation and deactivation. | ||
| 4 | * \internal | ||
| 5 | * | ||
| 6 | * Copyright (c) 2016 Nikias Bassen, All Rights Reserved. | ||
| 7 | * | ||
| 8 | * This library is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This library is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * 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 | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef IMOBILEACTIVATION_H | ||
| 24 | #define IMOBILEACTIVATION_H | ||
| 25 | |||
| 26 | #ifdef __cplusplus | ||
| 27 | extern "C" { | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #include <libimobiledevice/libimobiledevice.h> | ||
| 31 | #include <libimobiledevice/lockdown.h> | ||
| 32 | |||
| 33 | #define MOBILEACTIVATION_SERVICE_NAME "com.apple.mobileactivationd" | ||
| 34 | |||
| 35 | /** Error Codes */ | ||
| 36 | typedef enum { | ||
| 37 | MOBILEACTIVATION_E_SUCCESS = 0, | ||
| 38 | MOBILEACTIVATION_E_INVALID_ARG = -1, | ||
| 39 | MOBILEACTIVATION_E_PLIST_ERROR = -2, | ||
| 40 | MOBILEACTIVATION_E_MUX_ERROR = -3, | ||
| 41 | MOBILEACTIVATION_E_UNKNOWN_REQUEST = -4, | ||
| 42 | MOBILEACTIVATION_E_REQUEST_FAILED = -5, | ||
| 43 | MOBILEACTIVATION_E_UNKNOWN_ERROR = -256 | ||
| 44 | } mobileactivation_error_t; | ||
| 45 | |||
| 46 | typedef struct mobileactivation_client_private mobileactivation_client_private; | ||
| 47 | typedef mobileactivation_client_private *mobileactivation_client_t; /**< The client handle. */ | ||
| 48 | |||
| 49 | /** | ||
| 50 | * Connects to the mobileactivation service on the specified device. | ||
| 51 | * | ||
| 52 | * @param device The device to connect to. | ||
| 53 | * @param service The service descriptor returned by lockdownd_start_service. | ||
| 54 | * @param client Reference that will point to a newly allocated | ||
| 55 | * mobileactivation_client_t upon successful return. | ||
| 56 | * | ||
| 57 | * @return MOBILEACTIVATION_E_SUCCESS on success, | ||
| 58 | * MOBILEACTIVATION_E_INVALID_ARG when one of the parameters is invalid, | ||
| 59 | * or MOBILEACTIVATION_E_MUX_ERROR when the connection failed. | ||
| 60 | */ | ||
| 61 | mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobileactivation_client_t *client); | ||
| 62 | |||
| 63 | /** | ||
| 64 | * Starts a new mobileactivation service on the specified device and connects to it. | ||
| 65 | * | ||
| 66 | * @param device The device to connect to. | ||
| 67 | * @param client Pointer that will point to a newly allocated | ||
| 68 | * mobileactivation_client_t upon successful return. Must be freed using | ||
| 69 | * mobileactivation_client_free() after use. | ||
| 70 | * @param label The label to use for communication. Usually the program name. | ||
| 71 | * Pass NULL to disable sending the label in requests to lockdownd. | ||
| 72 | * | ||
| 73 | * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* | ||
| 74 | * error code otherwise. | ||
| 75 | */ | ||
| 76 | mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, mobileactivation_client_t* client, const char* label); | ||
| 77 | |||
| 78 | /** | ||
| 79 | * Disconnects a mobileactivation client from the device and frees up the | ||
| 80 | * mobileactivation client data. | ||
| 81 | * | ||
| 82 | * @param client The mobileactivation client to disconnect and free. | ||
| 83 | * | ||
| 84 | * @return MOBILEACTIVATION_E_SUCCESS on success, | ||
| 85 | * MOBILEACTIVATION_E_INVALID_ARG when one of client or client->parent | ||
| 86 | * is invalid, or MOBILEACTIVATION_E_UNKNOWN_ERROR when the was an | ||
| 87 | * error freeing the parent property_list_service client. | ||
| 88 | */ | ||
| 89 | mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t client); | ||
| 90 | |||
| 91 | |||
| 92 | /** | ||
| 93 | * Retrieves the device's activation state. | ||
| 94 | * | ||
| 95 | * @param client The mobileactivation client. | ||
| 96 | * @param state Pointer to a plist_t variable that will be set to the | ||
| 97 | * activation state reported by the mobileactivation service. The | ||
| 98 | * consumer is responsible for freeing the returned object using | ||
| 99 | * plist_free(). | ||
| 100 | * | ||
| 101 | * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* | ||
| 102 | * error code otherwise. | ||
| 103 | */ | ||
| 104 | mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_client_t client, plist_t *state); | ||
| 105 | |||
| 106 | /** | ||
| 107 | * Retrieves the activation info required for device activation. | ||
| 108 | * | ||
| 109 | * @param client The mobileactivation client | ||
| 110 | * @param info Pointer to a plist_t variable that will be set to the | ||
| 111 | * activation info created by the mobileactivation service. The | ||
| 112 | * consumer is responsible for freeing the returned object using | ||
| 113 | * plist_free(). | ||
| 114 | * | ||
| 115 | * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* | ||
| 116 | * error code otherwise. | ||
| 117 | */ | ||
| 118 | mobileactivation_error_t mobileactivation_create_activation_info(mobileactivation_client_t client, plist_t *info); | ||
| 119 | |||
| 120 | /** | ||
| 121 | * Activates the device with the given activation record. | ||
| 122 | * The activation record plist dictionary must be obtained using the | ||
| 123 | * activation protocol requesting from Apple's https webservice. | ||
| 124 | * | ||
| 125 | * @param client The mobileactivation client | ||
| 126 | * @param activation_record The activation record plist dictionary | ||
| 127 | * | ||
| 128 | * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* | ||
| 129 | * error code otherwise. | ||
| 130 | */ | ||
| 131 | mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t client, plist_t activation_record); | ||
| 132 | |||
| 133 | /** | ||
| 134 | * Deactivates the device. | ||
| 135 | * | ||
| 136 | * @param client The mobileactivation client | ||
| 137 | */ | ||
| 138 | mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client); | ||
| 139 | |||
| 140 | #ifdef __cplusplus | ||
| 141 | } | ||
| 142 | #endif | ||
| 143 | |||
| 144 | #endif | ||
