diff options
Diffstat (limited to 'include/libimobiledevice/sbservices.h')
-rw-r--r-- | include/libimobiledevice/sbservices.h | 155 |
1 files changed, 135 insertions, 20 deletions
diff --git a/include/libimobiledevice/sbservices.h b/include/libimobiledevice/sbservices.h index 616168e..7435947 100644 --- a/include/libimobiledevice/sbservices.h +++ b/include/libimobiledevice/sbservices.h | |||
@@ -3,7 +3,8 @@ | |||
3 | * @brief Manage SpringBoard icons and retrieve icon images. | 3 | * @brief Manage SpringBoard icons and retrieve icon images. |
4 | * \internal | 4 | * \internal |
5 | * | 5 | * |
6 | * Copyright (c) 2009 Nikias Bassen All Rights Reserved. | 6 | * Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved. |
7 | * Copyright (c) 2009-2010 Nikias Bassen All Rights Reserved. | ||
7 | * | 8 | * |
8 | * This library is free software; you can redistribute it and/or | 9 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public | 10 | * modify it under the terms of the GNU Lesser General Public |
@@ -20,38 +21,152 @@ | |||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | */ | 22 | */ |
22 | 23 | ||
23 | #ifndef SB_SERVICES_H | 24 | #ifndef ISB_SERVICES_H |
24 | #define SB_SERVICES_H | 25 | #define ISB_SERVICES_H |
25 | 26 | ||
26 | #ifdef __cplusplus | 27 | #ifdef __cplusplus |
27 | extern "C" { | 28 | extern "C" { |
28 | #endif | 29 | #endif |
29 | 30 | ||
30 | #include <libimobiledevice/libimobiledevice.h> | 31 | #include <libimobiledevice/libimobiledevice.h> |
32 | #include <libimobiledevice/lockdown.h> | ||
31 | 33 | ||
32 | /** @name Error Codes */ | 34 | /** Service identifier passed to lockdownd_start_service() to start the springboardservices service */ |
33 | /*@{*/ | 35 | #define SBSERVICES_SERVICE_NAME "com.apple.springboardservices" |
34 | #define SBSERVICES_E_SUCCESS 0 | ||
35 | #define SBSERVICES_E_INVALID_ARG -1 | ||
36 | #define SBSERVICES_E_PLIST_ERROR -2 | ||
37 | #define SBSERVICES_E_CONN_FAILED -3 | ||
38 | 36 | ||
39 | #define SBSERVICES_E_UNKNOWN_ERROR -256 | 37 | /** Error Codes */ |
40 | /*@}*/ | 38 | typedef enum { |
39 | SBSERVICES_E_SUCCESS = 0, | ||
40 | SBSERVICES_E_INVALID_ARG = -1, | ||
41 | SBSERVICES_E_PLIST_ERROR = -2, | ||
42 | SBSERVICES_E_CONN_FAILED = -3, | ||
43 | SBSERVICES_E_UNKNOWN_ERROR = -256 | ||
44 | } sbservices_error_t; | ||
41 | 45 | ||
42 | /** Represents an error code. */ | 46 | /** Orientation of the user interface on the device */ |
43 | typedef int16_t sbservices_error_t; | 47 | typedef enum { |
48 | SBSERVICES_INTERFACE_ORIENTATION_UNKNOWN = 0, | ||
49 | SBSERVICES_INTERFACE_ORIENTATION_PORTRAIT = 1, | ||
50 | SBSERVICES_INTERFACE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2, | ||
51 | SBSERVICES_INTERFACE_ORIENTATION_LANDSCAPE_RIGHT = 3, | ||
52 | SBSERVICES_INTERFACE_ORIENTATION_LANDSCAPE_LEFT = 4 | ||
53 | } sbservices_interface_orientation_t; | ||
44 | 54 | ||
45 | typedef struct sbservices_client_private sbservices_client_private; | 55 | typedef struct sbservices_client_private sbservices_client_private; /**< \private */ |
46 | typedef sbservices_client_private *sbservices_client_t; /**< The client handle. */ | 56 | typedef sbservices_client_private *sbservices_client_t; /**< The client handle. */ |
47 | 57 | ||
48 | /* Interface */ | 58 | /* Interface */ |
49 | sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbservices_client_t *client); | 59 | |
50 | sbservices_error_t sbservices_client_free(sbservices_client_t client); | 60 | /** |
51 | sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version); | 61 | * Connects to the springboardservices service on the specified device. |
52 | sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); | 62 | * |
53 | sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); | 63 | * @param device The device to connect to. |
54 | sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize); | 64 | * @param service The service descriptor returned by lockdownd_start_service. |
65 | * @param client Pointer that will point to a newly allocated | ||
66 | * sbservices_client_t upon successful return. | ||
67 | * | ||
68 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
69 | * client is NULL, or an SBSERVICES_E_* error code otherwise. | ||
70 | */ | ||
71 | LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client); | ||
72 | |||
73 | /** | ||
74 | * Starts a new sbservices service on the specified device and connects to it. | ||
75 | * | ||
76 | * @param device The device to connect to. | ||
77 | * @param client Pointer that will point to a newly allocated | ||
78 | * sbservices_client_t upon successful return. Must be freed using | ||
79 | * sbservices_client_free() after use. | ||
80 | * @param label The label to use for communication. Usually the program name. | ||
81 | * Pass NULL to disable sending the label in requests to lockdownd. | ||
82 | * | ||
83 | * @return SBSERVICES_E_SUCCESS on success, or an SBSERVICES_E_* error | ||
84 | * code otherwise. | ||
85 | */ | ||
86 | LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t* client, const char* label); | ||
87 | |||
88 | /** | ||
89 | * Disconnects an sbservices client from the device and frees up the | ||
90 | * sbservices client data. | ||
91 | * | ||
92 | * @param client The sbservices client to disconnect and free. | ||
93 | * | ||
94 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
95 | * client is NULL, or an SBSERVICES_E_* error code otherwise. | ||
96 | */ | ||
97 | LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_free(sbservices_client_t client); | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Gets the icon state of the connected device. | ||
102 | * | ||
103 | * @param client The connected sbservices client to use. | ||
104 | * @param state Pointer that will point to a newly allocated plist containing | ||
105 | * the current icon state. It is up to the caller to free the memory. | ||
106 | * @param format_version A string to be passed as formatVersion along with | ||
107 | * the request, or NULL if no formatVersion should be passed. This is only | ||
108 | * supported since iOS 4.0 so for older firmware versions this must be set | ||
109 | * to NULL. | ||
110 | * | ||
111 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
112 | * client or state is invalid, or an SBSERVICES_E_* error code otherwise. | ||
113 | */ | ||
114 | LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version); | ||
115 | |||
116 | /** | ||
117 | * Sets the icon state of the connected device. | ||
118 | * | ||
119 | * @param client The connected sbservices client to use. | ||
120 | * @param newstate A plist containing the new iconstate. | ||
121 | * | ||
122 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
123 | * client or newstate is NULL, or an SBSERVICES_E_* error code otherwise. | ||
124 | */ | ||
125 | LIBIMOBILEDEVICE_API sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); | ||
126 | |||
127 | /** | ||
128 | * Get the icon of the specified app as PNG data. | ||
129 | * | ||
130 | * @param client The connected sbservices client to use. | ||
131 | * @param bundleId The bundle identifier of the app to retrieve the icon for. | ||
132 | * @param pngdata Pointer that will point to a newly allocated buffer | ||
133 | * containing the PNG data upon successful return. It is up to the caller | ||
134 | * to free the memory. | ||
135 | * @param pngsize Pointer to a uint64_t that will be set to the size of the | ||
136 | * buffer pngdata points to upon successful return. | ||
137 | * | ||
138 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
139 | * client, bundleId, or pngdata are invalid, or an SBSERVICES_E_* error | ||
140 | * code otherwise. | ||
141 | */ | ||
142 | LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); | ||
143 | |||
144 | /** | ||
145 | * Gets the interface orientation of the device. | ||
146 | * | ||
147 | * @param client The connected sbservices client to use. | ||
148 | * @param interface_orientation The interface orientation upon successful return. | ||
149 | * | ||
150 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
151 | * client or state is invalid, or an SBSERVICES_E_* error code otherwise. | ||
152 | */ | ||
153 | LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation); | ||
154 | |||
155 | /** | ||
156 | * Get the home screen wallpaper as PNG data. | ||
157 | * | ||
158 | * @param client The connected sbservices client to use. | ||
159 | * @param pngdata Pointer that will point to a newly allocated buffer | ||
160 | * containing the PNG data upon successful return. It is up to the caller | ||
161 | * to free the memory. | ||
162 | * @param pngsize Pointer to a uint64_t that will be set to the size of the | ||
163 | * buffer pngdata points to upon successful return. | ||
164 | * | ||
165 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
166 | * client or pngdata are invalid, or an SBSERVICES_E_* error | ||
167 | * code otherwise. | ||
168 | */ | ||
169 | LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize); | ||
55 | 170 | ||
56 | #ifdef __cplusplus | 171 | #ifdef __cplusplus |
57 | } | 172 | } |