From dabf6e321b91bdc5c3ef26650533e0604729b0aa Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 10 Jan 2013 17:13:21 +0900 Subject: [PATCH] Add new API for request to update boxes. Change-Id: I6ba3b5a445a65664a4a1a9a122418e6fab7b5f32 --- include/livebox.h | 7 +++++++ packaging/liblivebox.spec | 2 +- src/livebox.c | 34 +++++++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/include/livebox.h b/include/livebox.h index 667a6e1..c17c222 100644 --- a/include/livebox.h +++ b/include/livebox.h @@ -204,6 +204,13 @@ extern int livebox_unref_buffer(void *buffer); */ extern int livebox_sync_buffer(struct livebox_buffer *handle); +/*! + * \brief + * \param[in] filename + * \return int + */ +extern int livebox_request_update(const char *filename); + #ifdef __cplusplus } #endif diff --git a/packaging/liblivebox.spec b/packaging/liblivebox.spec index 3556271..ec0db1c 100644 --- a/packaging/liblivebox.spec +++ b/packaging/liblivebox.spec @@ -1,6 +1,6 @@ Name: liblivebox Summary: Library for the development of a livebox -Version: 0.1.8 +Version: 0.1.9 Release: 1 Group: main/app License: Flora License diff --git a/src/livebox.c b/src/livebox.c index d36e777..9fcf597 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -32,10 +32,13 @@ #define EAPI __attribute__((visibility("default"))) +#define FILE_SCHEMA "file://" + /*! * \brief This function is defined by the data-provider-slave */ extern const char *livebox_find_pkgname(const char *filename); +extern int livebox_request_update_by_id(const char *uri); struct block { unsigned int idx; @@ -457,30 +460,51 @@ EAPI struct livebox_buffer *livebox_acquire_buffer(const char *filename, int is_ return NULL; } - uri_len = strlen(filename) + strlen("file://") + 1; + uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1; uri = malloc(uri_len); if (!uri) { ErrPrint("Heap: %s\n", strerror(errno)); return NULL; } - snprintf(uri, uri_len, "file://%s", filename); - DbgPrint("Before call the livebox_find_pkgname\n"); + snprintf(uri, uri_len, FILE_SCHEMA "%s", filename); pkgname = livebox_find_pkgname(uri); - DbgPrint("After call the livebox_find_pkgname\n"); if (!pkgname) { ErrPrint("Invalid Request\n"); free(uri); return NULL; } - DbgPrint("URI: %s\n", uri); handle = provider_buffer_acquire((!!is_pd) ? TYPE_PD : TYPE_LB, pkgname, uri, width, height, sizeof(int), handler, data); DbgPrint("Acquire buffer for PD(%s), %s, %p\n", pkgname, uri, handle); free(uri); return handle; } +EAPI int livebox_request_update(const char *filename) +{ + int uri_len; + char *uri; + int ret; + + if (!filename) { + ErrPrint("Invalid argument\n"); + return -EINVAL; + } + + uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1; + uri = malloc(uri_len); + if (!uri) { + ErrPrint("Heap: %s\n", strerror(errno)); + return -ENOMEM; + } + + snprintf(uri, uri_len, FILE_SCHEMA "%s", filename); + ret = livebox_request_update_by_id(uri); + free(uri); + return ret; +} + EAPI unsigned long livebox_pixmap_id(struct livebox_buffer *handle) { return provider_buffer_pixmap_id(handle); -- 2.7.4