summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2016-07-02 01:37:50 +0200
committerGravatar Nikias Bassen2017-06-29 02:43:29 +0200
commit5250024b53b799a427a486ae133ecb927f5c555e (patch)
treef10b0640db53763df00eee23ee50f52d8d23fddd /include
parent835d84b678d23f92622445f5bf142c2bf52a7e9b (diff)
downloadlibimobiledevice-5250024b53b799a427a486ae133ecb927f5c555e.tar.gz
libimobiledevice-5250024b53b799a427a486ae133ecb927f5c555e.tar.bz2
Add basic mobileactivation service implementation
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am1
-rw-r--r--include/libimobiledevice/mobileactivation.h144
2 files changed, 145 insertions, 0 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 9f61e6b..f2b93ed 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -20,5 +20,6 @@ nobase_include_HEADERS = libimobiledevice/libimobiledevice.h \
20 libimobiledevice/diagnostics_relay.h\ 20 libimobiledevice/diagnostics_relay.h\
21 libimobiledevice/debugserver.h\ 21 libimobiledevice/debugserver.h\
22 libimobiledevice/syslog_relay.h\ 22 libimobiledevice/syslog_relay.h\
23 libimobiledevice/mobileactivation.h\
23 libimobiledevice/property_list_service.h\ 24 libimobiledevice/property_list_service.h\
24 libimobiledevice/service.h 25 libimobiledevice/service.h
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
27extern "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 */
36typedef 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
46typedef struct mobileactivation_client_private mobileactivation_client_private;
47typedef 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 */
61mobileactivation_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 */
76mobileactivation_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 */
89mobileactivation_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 */
104mobileactivation_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 */
118mobileactivation_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 */
131mobileactivation_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 */
138mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client);
139
140#ifdef __cplusplus
141}
142#endif
143
144#endif