From 76fd1b07710574599be11c227fe64b9758f325aa Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Mon, 19 Nov 2012 14:06:09 +0900 Subject: [PATCH] Update for handling the multi-depth edje loading Add a new API instead of changing the old API. For keeping the compatibility. Change-Id: I50deda7b26e7bb1c99f5bc34e84a40d6330b9560 --- include/livebox.h | 19 ++++++++++++++++++- packaging/liblivebox.spec | 2 +- src/livebox.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/include/livebox.h b/include/livebox.h index cf0224a..41447e2 100644 --- a/include/livebox.h +++ b/include/livebox.h @@ -22,6 +22,13 @@ extern const int LB_SYS_EVENT_LANG_CHANGED; /*!< System language is changed */ extern const int LB_SYS_EVENT_PAUSED; extern const int LB_SYS_EVENT_RESUMED; +#define LB_DESC_TYPE_TEXT "text" +#define LB_DESC_TYPE_IMAGE "image" +#define LB_DESC_TYPE_SIGNAL "signal" +#define LB_DESC_TYPE_INFO "info" +#define LB_DESC_TYPE_DRAG "drag" +#define LB_DESC_TYPE_SCRIPT "script" + /*! * \brief * Extra event informatino for livebox_content_event interface function @@ -80,9 +87,19 @@ extern int livebox_desc_set_category(struct livebox_desc *handle, const char *id extern int livebox_desc_set_size(struct livebox_desc *handle, const char *id, int w, int h); /*! - * \brief Add a new block + * \breif Set the target id of given block + * Only available for the script block * \param[in] handle + * \param[in] idx * \param[in] id + * \return ret + */ +extern int livebox_desc_set_id(struct livebox_desc *handle, int idx, const char *id); + +/*! + * \brief Add a new block + * \param[in] handle + * \param[in] id ID of source script object * \param[in] type image|text|script|signal|... * \param[in] part target part to update with given content(data) * \param[in] data content for specified part diff --git a/packaging/liblivebox.spec b/packaging/liblivebox.spec index 31eb06f..0da34d5 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.3 +Version: 0.1.4 Release: 1 Group: main/app License: Samsung Proprietary License diff --git a/src/livebox.c b/src/livebox.c index 1bf5204..244919b 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -6,6 +6,7 @@ #include #include +#include #include #include "debug.h" @@ -29,6 +30,7 @@ struct block { char *group; char *id; char *file; + char *target_id; }; struct livebox_desc { @@ -132,6 +134,11 @@ EAPI int livebox_desc_close(struct livebox_desc *handle) DbgPrint("id=%s\n", block->id); } + if (block->target_id) { + fprintf(handle->fp, "target=%s\n", block->target_id); + DbgPrint("target=%s\n", block->target_id); + } + fprintf(handle->fp, "}\n"); DbgPrint("}\n"); @@ -140,6 +147,7 @@ EAPI int livebox_desc_close(struct livebox_desc *handle) free(block->data); free(block->group); free(block->id); + free(block->target_id); free(block); } @@ -159,7 +167,7 @@ EAPI int livebox_desc_set_category(struct livebox_desc *handle, const char *id, if (!block) return -ENOMEM; - block->type = strdup("info"); + block->type = strdup(LB_DESC_TYPE_INFO); if (!block->type) { free(block); return -ENOMEM; @@ -208,7 +216,7 @@ EAPI int livebox_desc_set_size(struct livebox_desc *handle, const char *id, int if (!block) return -ENOMEM; - block->type = strdup("info"); + block->type = strdup(LB_DESC_TYPE_INFO); if (!block->type) { free(block); return -ENOMEM; @@ -299,6 +307,37 @@ EAPI char *livebox_util_nl2br(const char *str) return ret; } +EAPI int livebox_desc_set_id(struct livebox_desc *handle, int idx, const char *id) +{ + struct dlist *l; + struct block *block; + + dlist_foreach(handle->block_list, l, block) { + if (block->idx == idx) { + if (strcasecmp(block->type, LB_DESC_TYPE_SCRIPT)) { + ErrPrint("Invalid block is used\n"); + return -EINVAL; + } + + free(block->target_id); + block->target_id = NULL; + + if (!id || !strlen(id)) + return 0; + + block->target_id = strdup(id); + if (!block->target_id) { + ErrPrint("Heap: %s\n", strerror(errno)); + return -ENOMEM; + } + + return 0; + } + } + + return -ENOENT; +} + /*! * \return idx */ @@ -375,6 +414,7 @@ EAPI int livebox_desc_del_block(struct livebox_desc *handle, int idx) free(block->data); free(block->group); free(block->id); + free(block->target_id); free(block); return 0; } -- 2.7.4