summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sbservices.c49
1 files changed, 49 insertions, 0 deletions
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}