diff options
Diffstat (limited to 'include/libimobiledevice/restore.h')
-rw-r--r-- | include/libimobiledevice/restore.h | 165 |
1 files changed, 136 insertions, 29 deletions
diff --git a/include/libimobiledevice/restore.h b/include/libimobiledevice/restore.h index 9c30b03..859dc98 100644 --- a/include/libimobiledevice/restore.h +++ b/include/libimobiledevice/restore.h | |||
@@ -1,8 +1,10 @@ | |||
1 | /** | 1 | /** |
2 | * @file libimobiledevice/restore.h | 2 | * @file libimobiledevice/restore.h |
3 | * @brief Initiate restore process or reboot device. | 3 | * @brief Initiate restore process or reboot device. |
4 | * @note This service is only available if the device is in restore mode. | ||
4 | * \internal | 5 | * \internal |
5 | * | 6 | * |
7 | * Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved. | ||
6 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. | 8 | * Copyright (c) 2010 Joshua Hill. All Rights Reserved. |
7 | * | 9 | * |
8 | * This library is free software; you can redistribute it and/or | 10 | * This library is free software; you can redistribute it and/or |
@@ -20,8 +22,8 @@ | |||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | */ | 23 | */ |
22 | 24 | ||
23 | #ifndef RESTORE_H | 25 | #ifndef IRESTORE_H |
24 | #define RESTORE_H | 26 | #define IRESTORE_H |
25 | 27 | ||
26 | #ifdef __cplusplus | 28 | #ifdef __cplusplus |
27 | extern "C" { | 29 | extern "C" { |
@@ -29,41 +31,146 @@ extern "C" { | |||
29 | 31 | ||
30 | #include <libimobiledevice/libimobiledevice.h> | 32 | #include <libimobiledevice/libimobiledevice.h> |
31 | 33 | ||
32 | /** @name Error Codes */ | 34 | /** Error Codes */ |
33 | /*@{*/ | 35 | typedef enum { |
34 | #define RESTORE_E_SUCCESS 0 | 36 | RESTORE_E_SUCCESS = 0, |
35 | #define RESTORE_E_INVALID_ARG -1 | 37 | RESTORE_E_INVALID_ARG = -1, |
36 | #define RESTORE_E_INVALID_CONF -2 | 38 | RESTORE_E_PLIST_ERROR = -2, |
37 | #define RESTORE_E_PLIST_ERROR -3 | 39 | RESTORE_E_MUX_ERROR = -3, |
38 | #define RESTORE_E_DICT_ERROR -4 | 40 | RESTORE_E_NOT_ENOUGH_DATA = -4, |
39 | #define RESTORE_E_NOT_ENOUGH_DATA -5 | 41 | RESTORE_E_RECEIVE_TIMEOUT = -5, |
40 | #define RESTORE_E_MUX_ERROR -6 | 42 | RESTORE_E_UNKNOWN_ERROR = -256 |
41 | #define RESTORE_E_START_RESTORE_FAILED -7 | 43 | } restored_error_t; |
42 | 44 | ||
43 | #define RESTORE_E_UNKNOWN_ERROR -256 | 45 | typedef struct restored_client_private restored_client_private; /**< \private */ |
44 | /*@}*/ | ||
45 | |||
46 | /** Represents an error code. */ | ||
47 | typedef int16_t restored_error_t; | ||
48 | |||
49 | typedef struct restored_client_private restored_client_private; | ||
50 | typedef restored_client_private *restored_client_t; /**< The client handle. */ | 46 | typedef restored_client_private *restored_client_t; /**< The client handle. */ |
51 | 47 | ||
52 | /* Interface */ | 48 | /* Interface */ |
53 | restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label); | ||
54 | restored_error_t restored_client_free(restored_client_t client); | ||
55 | 49 | ||
56 | restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version); | 50 | /** |
57 | restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ; | 51 | * Creates a new restored client for the device. |
58 | restored_error_t restored_send(restored_client_t client, plist_t plist); | 52 | * |
59 | restored_error_t restored_receive(restored_client_t client, plist_t *plist); | 53 | * @param device The device to create a restored client for |
60 | restored_error_t restored_goodbye(restored_client_t client); | 54 | * @param client The pointer to the location of the new restored_client |
55 | * @param label The label to use for communication. Usually the program name. | ||
56 | * | ||
57 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL | ||
58 | */ | ||
59 | LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label); | ||
60 | |||
61 | /** | ||
62 | * Closes the restored client session if one is running and frees up the | ||
63 | * restored_client struct. | ||
64 | * | ||
65 | * @param client The restore client | ||
66 | * | ||
67 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL | ||
68 | */ | ||
69 | LIBIMOBILEDEVICE_API restored_error_t restored_client_free(restored_client_t client); | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Query the type of the service daemon. Depending on whether the device is | ||
74 | * queried in normal mode or restore mode, different types will be returned. | ||
75 | * | ||
76 | * @param client The restored client | ||
77 | * @param type The type returned by the service daemon. Pass NULL to ignore. | ||
78 | * @param version The restore protocol version. Pass NULL to ignore. | ||
79 | * | ||
80 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL | ||
81 | */ | ||
82 | LIBIMOBILEDEVICE_API restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version); | ||
83 | |||
84 | /** | ||
85 | * Queries a value from the device specified by a key. | ||
86 | * | ||
87 | * @param client An initialized restored client. | ||
88 | * @param key The key name to request | ||
89 | * @param value A plist node representing the result value node | ||
90 | * | ||
91 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found | ||
92 | */ | ||
93 | LIBIMOBILEDEVICE_API restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value); | ||
94 | |||
95 | /** | ||
96 | * Retrieves a value from information plist specified by a key. | ||
97 | * | ||
98 | * @param client An initialized restored client. | ||
99 | * @param key The key name to request or NULL to query for all keys | ||
100 | * @param value A plist node representing the result value node | ||
101 | * | ||
102 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found | ||
103 | */ | ||
104 | LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ; | ||
105 | |||
106 | /** | ||
107 | * Sends a plist to restored. | ||
108 | * | ||
109 | * @note This function is low-level and should only be used if you need to send | ||
110 | * a new type of message. | ||
111 | * | ||
112 | * @param client The restored client | ||
113 | * @param plist The plist to send | ||
114 | * | ||
115 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client or | ||
116 | * plist is NULL | ||
117 | */ | ||
118 | LIBIMOBILEDEVICE_API restored_error_t restored_send(restored_client_t client, plist_t plist); | ||
119 | |||
120 | /** | ||
121 | * Receives a plist from restored. | ||
122 | * | ||
123 | * @param client The restored client | ||
124 | * @param plist The plist to store the received data | ||
125 | * | ||
126 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client or | ||
127 | * plist is NULL | ||
128 | */ | ||
129 | LIBIMOBILEDEVICE_API restored_error_t restored_receive(restored_client_t client, plist_t *plist); | ||
130 | |||
131 | /** | ||
132 | * Sends the Goodbye request to restored signaling the end of communication. | ||
133 | * | ||
134 | * @param client The restore client | ||
135 | * | ||
136 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, | ||
137 | * RESTORE_E_PLIST_ERROR if the device did not acknowledge the request | ||
138 | */ | ||
139 | LIBIMOBILEDEVICE_API restored_error_t restored_goodbye(restored_client_t client); | ||
61 | 140 | ||
62 | restored_error_t restored_start_restore(restored_client_t client); | 141 | |
63 | restored_error_t restored_reboot(restored_client_t client); | 142 | /** |
143 | * Requests to start a restore and retrieve it's port on success. | ||
144 | * | ||
145 | * @param client The restored client | ||
146 | * @param options PLIST_DICT with options for the restore process or NULL | ||
147 | * @param version the restore protocol version, see restored_query_type() | ||
148 | * | ||
149 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG if a parameter | ||
150 | * is NULL, RESTORE_E_START_RESTORE_FAILED if the request fails | ||
151 | */ | ||
152 | LIBIMOBILEDEVICE_API restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version); | ||
153 | |||
154 | /** | ||
155 | * Requests device to reboot. | ||
156 | * | ||
157 | * @param client The restored client | ||
158 | * | ||
159 | * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG if a parameter | ||
160 | * is NULL | ||
161 | */ | ||
162 | LIBIMOBILEDEVICE_API restored_error_t restored_reboot(restored_client_t client); | ||
64 | 163 | ||
65 | /* Helper */ | 164 | /* Helper */ |
66 | void restored_client_set_label(restored_client_t client, const char *label); | 165 | |
166 | /** | ||
167 | * Sets the label to send for requests to restored. | ||
168 | * | ||
169 | * @param client The restore client | ||
170 | * @param label The label to set or NULL to disable sending a label | ||
171 | * | ||
172 | */ | ||
173 | LIBIMOBILEDEVICE_API void restored_client_set_label(restored_client_t client, const char *label); | ||
67 | 174 | ||
68 | #ifdef __cplusplus | 175 | #ifdef __cplusplus |
69 | } | 176 | } |