diff options
Diffstat (limited to 'include/libimobiledevice/misagent.h')
-rw-r--r-- | include/libimobiledevice/misagent.h | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/include/libimobiledevice/misagent.h b/include/libimobiledevice/misagent.h new file mode 100644 index 0000000..7981a8b --- /dev/null +++ b/include/libimobiledevice/misagent.h | |||
@@ -0,0 +1,168 @@ | |||
1 | /** | ||
2 | * @file libimobiledevice/misagent.h | ||
3 | * @brief Manage provisioning profiles. | ||
4 | * \internal | ||
5 | * | ||
6 | * Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved. | ||
7 | * Copyright (c) 2012 Nikias Bassen All Rights Reserved. | ||
8 | * | ||
9 | * This library is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Lesser General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2.1 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * This library is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with this library; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | */ | ||
23 | |||
24 | #ifndef IMISAGENT_H | ||
25 | #define IMISAGENT_H | ||
26 | |||
27 | #ifdef __cplusplus | ||
28 | extern "C" { | ||
29 | #endif | ||
30 | |||
31 | #include <libimobiledevice/libimobiledevice.h> | ||
32 | #include <libimobiledevice/lockdown.h> | ||
33 | |||
34 | /** Service identifier passed to lockdownd_start_service() to start the misagent service */ | ||
35 | #define MISAGENT_SERVICE_NAME "com.apple.misagent" | ||
36 | |||
37 | /** Error Codes */ | ||
38 | typedef enum { | ||
39 | MISAGENT_E_SUCCESS = 0, | ||
40 | MISAGENT_E_INVALID_ARG = -1, | ||
41 | MISAGENT_E_PLIST_ERROR = -2, | ||
42 | MISAGENT_E_CONN_FAILED = -3, | ||
43 | MISAGENT_E_REQUEST_FAILED = -4, | ||
44 | MISAGENT_E_UNKNOWN_ERROR = -256 | ||
45 | } misagent_error_t; | ||
46 | |||
47 | typedef struct misagent_client_private misagent_client_private; /**< \private */ | ||
48 | typedef misagent_client_private *misagent_client_t; /**< The client handle. */ | ||
49 | |||
50 | /* Interface */ | ||
51 | |||
52 | /** | ||
53 | * Connects to the misagent service on the specified device. | ||
54 | * | ||
55 | * @param device The device to connect to. | ||
56 | * @param service The service descriptor returned by lockdownd_start_service. | ||
57 | * @param client Pointer that will point to a newly allocated | ||
58 | * misagent_client_t upon successful return. | ||
59 | * | ||
60 | * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when | ||
61 | * client is NULL, or an MISAGENT_E_* error code otherwise. | ||
62 | */ | ||
63 | LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client); | ||
64 | |||
65 | /** | ||
66 | * Starts a new misagent service on the specified device and connects to it. | ||
67 | * | ||
68 | * @param device The device to connect to. | ||
69 | * @param client Pointer that will point to a newly allocated | ||
70 | * misagent_client_t upon successful return. Must be freed using | ||
71 | * misagent_client_free() after use. | ||
72 | * @param label The label to use for communication. Usually the program name. | ||
73 | * Pass NULL to disable sending the label in requests to lockdownd. | ||
74 | * | ||
75 | * @return MISAGENT_E_SUCCESS on success, or an MISAGENT_E_* error | ||
76 | * code otherwise. | ||
77 | */ | ||
78 | LIBIMOBILEDEVICE_API misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t* client, const char* label); | ||
79 | |||
80 | /** | ||
81 | * Disconnects an misagent client from the device and frees up the | ||
82 | * misagent client data. | ||
83 | * | ||
84 | * @param client The misagent client to disconnect and free. | ||
85 | * | ||
86 | * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when | ||
87 | * client is NULL, or an MISAGENT_E_* error code otherwise. | ||
88 | */ | ||
89 | LIBIMOBILEDEVICE_API misagent_error_t misagent_client_free(misagent_client_t client); | ||
90 | |||
91 | |||
92 | /** | ||
93 | * Installs the given provisioning profile. Only works with valid profiles. | ||
94 | * | ||
95 | * @param client The connected misagent to use for installation | ||
96 | * @param profile The valid provisioning profile to install. This has to be | ||
97 | * passed as a PLIST_DATA, otherwise the function will fail. | ||
98 | * | ||
99 | * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when | ||
100 | * client is invalid, or an MISAGENT_E_* error code otherwise. | ||
101 | */ | ||
102 | LIBIMOBILEDEVICE_API misagent_error_t misagent_install(misagent_client_t client, plist_t profile); | ||
103 | |||
104 | /** | ||
105 | * Retrieves all installed provisioning profiles (iOS 9.2.1 or below). | ||
106 | * | ||
107 | * @param client The connected misagent to use. | ||
108 | * @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY | ||
109 | * if the function is successful. | ||
110 | * | ||
111 | * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when | ||
112 | * client is invalid, or an MISAGENT_E_* error code otherwise. | ||
113 | * | ||
114 | * @note This API call only works with iOS 9.2.1 or below. | ||
115 | * For newer iOS versions use misagent_copy_all() instead. | ||
116 | * | ||
117 | * @note If no provisioning profiles are installed on the device, this function | ||
118 | * still returns MISAGENT_E_SUCCESS and profiles will just point to an | ||
119 | * empty array. | ||
120 | */ | ||
121 | LIBIMOBILEDEVICE_API misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles); | ||
122 | |||
123 | /** | ||
124 | * Retrieves all installed provisioning profiles (iOS 9.3 or higher). | ||
125 | * | ||
126 | * @param client The connected misagent to use. | ||
127 | * @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY | ||
128 | * if the function is successful. | ||
129 | * | ||
130 | * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when | ||
131 | * client is invalid, or an MISAGENT_E_* error code otherwise. | ||
132 | * | ||
133 | * @note This API call only works with iOS 9.3 or higher. | ||
134 | * For older iOS versions use misagent_copy() instead. | ||
135 | * | ||
136 | * @note If no provisioning profiles are installed on the device, this function | ||
137 | * still returns MISAGENT_E_SUCCESS and profiles will just point to an | ||
138 | * empty array. | ||
139 | */ | ||
140 | LIBIMOBILEDEVICE_API misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles); | ||
141 | |||
142 | /** | ||
143 | * Removes a given provisioning profile. | ||
144 | * | ||
145 | * @param client The connected misagent to use. | ||
146 | * @param profileID Identifier of the provisioning profile to remove. | ||
147 | * This is a UUID that can be obtained from the provisioning profile data. | ||
148 | * @see misagent_copy | ||
149 | * | ||
150 | * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when | ||
151 | * client is invalid, or an MISAGENT_E_* error code otherwise. | ||
152 | */ | ||
153 | LIBIMOBILEDEVICE_API misagent_error_t misagent_remove(misagent_client_t client, const char* profileID); | ||
154 | |||
155 | /** | ||
156 | * Retrieves the status code from the last operation. | ||
157 | * | ||
158 | * @param client The misagent to use. | ||
159 | * | ||
160 | * @return -1 if client is invalid, or the status code from the last operation | ||
161 | */ | ||
162 | LIBIMOBILEDEVICE_API int misagent_get_status_code(misagent_client_t client); | ||
163 | |||
164 | #ifdef __cplusplus | ||
165 | } | ||
166 | #endif | ||
167 | |||
168 | #endif | ||