summaryrefslogtreecommitdiffstats
path: root/include/libimobiledevice/mobileactivation.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libimobiledevice/mobileactivation.h')
-rw-r--r--include/libimobiledevice/mobileactivation.h192
1 files changed, 192 insertions, 0 deletions
diff --git a/include/libimobiledevice/mobileactivation.h b/include/libimobiledevice/mobileactivation.h
new file mode 100644
index 0000000..8e036a8
--- /dev/null
+++ b/include/libimobiledevice/mobileactivation.h
@@ -0,0 +1,192 @@
1/**
2 * @file libimobiledevice/mobileactivation.h
3 * @brief Handle device activation and deactivation.
4 * \internal
5 *
6 * Copyright (c) 2016-2017 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
27extern "C" {
28#endif
29
30#include <libimobiledevice/libimobiledevice.h>
31#include <libimobiledevice/lockdown.h>
32
33/** Service identifier passed to lockdownd_start_service() to start the mobile activation service */
34#define MOBILEACTIVATION_SERVICE_NAME "com.apple.mobileactivationd"
35
36/** Error Codes */
37typedef enum {
38 MOBILEACTIVATION_E_SUCCESS = 0,
39 MOBILEACTIVATION_E_INVALID_ARG = -1,
40 MOBILEACTIVATION_E_PLIST_ERROR = -2,
41 MOBILEACTIVATION_E_MUX_ERROR = -3,
42 MOBILEACTIVATION_E_UNKNOWN_REQUEST = -4,
43 MOBILEACTIVATION_E_REQUEST_FAILED = -5,
44 MOBILEACTIVATION_E_UNKNOWN_ERROR = -256
45} mobileactivation_error_t;
46
47typedef struct mobileactivation_client_private mobileactivation_client_private; /**< \private */
48typedef mobileactivation_client_private *mobileactivation_client_t; /**< The client handle. */
49
50/**
51 * Connects to the mobileactivation service on the specified device.
52 *
53 * @param device The device to connect to.
54 * @param service The service descriptor returned by lockdownd_start_service.
55 * @param client Reference that will point to a newly allocated
56 * mobileactivation_client_t upon successful return.
57 *
58 * @return MOBILEACTIVATION_E_SUCCESS on success,
59 * MOBILEACTIVATION_E_INVALID_ARG when one of the parameters is invalid,
60 * or MOBILEACTIVATION_E_MUX_ERROR when the connection failed.
61 */
62LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobileactivation_client_t *client);
63
64/**
65 * Starts a new mobileactivation service on the specified device and connects to it.
66 *
67 * @param device The device to connect to.
68 * @param client Pointer that will point to a newly allocated
69 * mobileactivation_client_t upon successful return. Must be freed using
70 * mobileactivation_client_free() after use.
71 * @param label The label to use for communication. Usually the program name.
72 * Pass NULL to disable sending the label in requests to lockdownd.
73 *
74 * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
75 * error code otherwise.
76 */
77LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, mobileactivation_client_t* client, const char* label);
78
79/**
80 * Disconnects a mobileactivation client from the device and frees up the
81 * mobileactivation client data.
82 *
83 * @param client The mobileactivation client to disconnect and free.
84 *
85 * @return MOBILEACTIVATION_E_SUCCESS on success,
86 * MOBILEACTIVATION_E_INVALID_ARG when one of client or client->parent
87 * is invalid, or MOBILEACTIVATION_E_UNKNOWN_ERROR when the was an
88 * error freeing the parent property_list_service client.
89 */
90LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t client);
91
92
93/**
94 * Retrieves the device's activation state.
95 *
96 * @param client The mobileactivation client.
97 * @param state Pointer to a plist_t variable that will be set to the
98 * activation state reported by the mobileactivation service. The
99 * consumer is responsible for freeing the returned object using
100 * plist_free().
101 *
102 * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
103 * error code otherwise.
104 */
105LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_client_t client, plist_t *state);
106
107/**
108 * Retrieves a session blob required for 'drmHandshake' via albert.apple.com.
109 *
110 * @param client The mobileactivation client
111 * @param blob Pointer to a plist_t variable that will be set to the
112 * session blob created by the mobielactivation service. The
113 * consumer is responsible for freeing the returned object using
114 * plist_free().
115 *
116 * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
117 * error code otherwise.
118 */
119LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_session_info(mobileactivation_client_t client, plist_t *blob);
120
121/**
122 * Retrieves the activation info required for device activation.
123 *
124 * @param client The mobileactivation client
125 * @param info Pointer to a plist_t variable that will be set to the
126 * activation info created by the mobileactivation service. The
127 * consumer is responsible for freeing the returned object using
128 * plist_free().
129 *
130 * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
131 * error code otherwise.
132 */
133LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_info(mobileactivation_client_t client, plist_t *info);
134
135/**
136 * Retrieves the activation info required for device activation in 'session'
137 * mode. This function expects a handshake result retrieved from
138 * https://albert.apple.com/deviceservies/drmHandshake with a blob
139 * provided by mobileactivation_create_activation_session_info().
140 *
141 * @param client The mobileactivation client
142 * @param handshake_response The handshake response returned from drmHandshake
143 * @param info Pointer to a plist_t variable that will be set to the
144 * activation info created by the mobileactivation service. The
145 * consumer is responsible for freeing the returned object using
146 * plist_free().
147 *
148 * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
149 * error code otherwise.
150 */
151LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_info_with_session(mobileactivation_client_t client, plist_t handshake_response, plist_t *info);
152
153/**
154 * Activates the device with the given activation record.
155 * The activation record plist dictionary must be obtained using the
156 * activation protocol requesting from Apple's https webservice.
157 *
158 * @param client The mobileactivation client
159 * @param activation_record The activation record plist dictionary
160 *
161 * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
162 * error code otherwise.
163 */
164LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t client, plist_t activation_record);
165
166/**
167 * Activates the device with the given activation record in 'session' mode.
168 * The activation record plist must be obtained using the
169 * activation protocol requesting from Apple's https webservice.
170 *
171 * @param client The mobileactivation client
172 * @param activation_record The activation record in plist format
173 * @param headers A plist dictionary with the activation response headers
174 * as returned from Apple's https webservice with the activation record
175 *
176 * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
177 * error code otherwise.
178 */
179LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate_with_session(mobileactivation_client_t client, plist_t activation_record, plist_t headers);
180
181/**
182 * Deactivates the device.
183 *
184 * @param client The mobileactivation client
185 */
186LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client);
187
188#ifdef __cplusplus
189}
190#endif
191
192#endif