summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2010-07-09 02:50:48 +0200
committerGravatar Nikias Bassen2010-07-09 02:50:48 +0200
commit31ec3f32bb828a5851f920c51c8e8e6b8f1f682b (patch)
tree7bfd2ebdbe069878d224aca612d2b0d7b4ef7676
parentccb63b0cc6335d2e186a9223b14f50542feeb982 (diff)
downloadlibimobiledevice-31ec3f32bb828a5851f920c51c8e8e6b8f1f682b.tar.gz
libimobiledevice-31ec3f32bb828a5851f920c51c8e8e6b8f1f682b.tar.bz2
sbservices: add support for fetching the home screen wallpaper
-rw-r--r--include/libimobiledevice/sbservices.h1
-rw-r--r--src/sbservices.c49
2 files changed, 50 insertions, 0 deletions
diff --git a/include/libimobiledevice/sbservices.h b/include/libimobiledevice/sbservices.h
index fcedf1a..4274278 100644
--- a/include/libimobiledevice/sbservices.h
+++ b/include/libimobiledevice/sbservices.h
@@ -51,6 +51,7 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client);
51sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state); 51sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state);
52sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); 52sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate);
53sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); 53sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize);
54sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize);
54 55
55#ifdef __cplusplus 56#ifdef __cplusplus
56} 57}
diff --git a/src/sbservices.c b/src/sbservices.c
index 2678e24..e6342d1 100644
--- a/src/sbservices.c
+++ b/src/sbservices.c
@@ -269,3 +269,52 @@ leave_unlock:
269 269
270} 270}
271 271
272/**
273 * Get the home screen wallpaper as PNG data.
274 *
275 * @param client The connected sbservices client to use.
276 * @param pngdata Pointer that will point to a newly allocated buffer
277 * containing the PNG data upon successful return. It is up to the caller
278 * to free the memory.
279 * @param pngsize Pointer to a uint64_t that will be set to the size of the
280 * buffer pngdata points to upon successful return.
281 *
282 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
283 * client or pngdata are invalid, or an SBSERVICES_E_* error
284 * code otherwise.
285 */
286sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize)
287{
288 if (!client || !client->parent || !pngdata)
289 return SBSERVICES_E_INVALID_ARG;
290
291 sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR;
292
293 plist_t dict = plist_new_dict();
294 plist_dict_insert_item(dict, "command", plist_new_string("getHomeScreenWallpaperPNGData"));
295
296 sbs_lock(client);
297
298 res = sbservices_error(property_list_service_send_binary_plist(client->parent, dict));
299 if (res != SBSERVICES_E_SUCCESS) {
300 debug_info("could not send plist, error %d", res);
301 goto leave_unlock;
302 }
303 plist_free(dict);
304
305 dict = NULL;
306 res = sbservices_error(property_list_service_receive_plist(client->parent, &dict));
307 if (res == SBSERVICES_E_SUCCESS) {
308 plist_t node = plist_dict_get_item(dict, "pngData");
309 if (node) {
310 plist_get_data_val(node, pngdata, pngsize);
311 }
312 }
313
314leave_unlock:
315 if (dict) {
316 plist_free(dict);
317 }
318 sbs_unlock(client);
319 return res;
320}