diff options
author | Nikias Bassen | 2010-07-09 02:50:48 +0200 |
---|---|---|
committer | Nikias Bassen | 2010-07-09 02:50:48 +0200 |
commit | 31ec3f32bb828a5851f920c51c8e8e6b8f1f682b (patch) | |
tree | 7bfd2ebdbe069878d224aca612d2b0d7b4ef7676 | |
parent | ccb63b0cc6335d2e186a9223b14f50542feeb982 (diff) | |
download | libimobiledevice-31ec3f32bb828a5851f920c51c8e8e6b8f1f682b.tar.gz libimobiledevice-31ec3f32bb828a5851f920c51c8e8e6b8f1f682b.tar.bz2 |
sbservices: add support for fetching the home screen wallpaper
-rw-r--r-- | include/libimobiledevice/sbservices.h | 1 | ||||
-rw-r--r-- | src/sbservices.c | 49 |
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); sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state); sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); +sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize); #ifdef __cplusplus } 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: } +/** + * Get the home screen wallpaper as PNG data. + * + * @param client The connected sbservices client to use. + * @param pngdata Pointer that will point to a newly allocated buffer + * containing the PNG data upon successful return. It is up to the caller + * to free the memory. + * @param pngsize Pointer to a uint64_t that will be set to the size of the + * buffer pngdata points to upon successful return. + * + * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when + * client or pngdata are invalid, or an SBSERVICES_E_* error + * code otherwise. + */ +sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize) +{ + if (!client || !client->parent || !pngdata) + return SBSERVICES_E_INVALID_ARG; + + sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; + + plist_t dict = plist_new_dict(); + plist_dict_insert_item(dict, "command", plist_new_string("getHomeScreenWallpaperPNGData")); + + sbs_lock(client); + + res = sbservices_error(property_list_service_send_binary_plist(client->parent, dict)); + if (res != SBSERVICES_E_SUCCESS) { + debug_info("could not send plist, error %d", res); + goto leave_unlock; + } + plist_free(dict); + + dict = NULL; + res = sbservices_error(property_list_service_receive_plist(client->parent, &dict)); + if (res == SBSERVICES_E_SUCCESS) { + plist_t node = plist_dict_get_item(dict, "pngData"); + if (node) { + plist_get_data_val(node, pngdata, pngsize); + } + } + +leave_unlock: + if (dict) { + plist_free(dict); + } + sbs_unlock(client); + return res; +} |