Update for handling the multi-depth edje loading
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 19 Nov 2012 05:06:09 +0000 (14:06 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 20 Nov 2012 03:16:39 +0000 (12:16 +0900)
Add a new API instead of changing the old API.
For keeping the compatibility.

Change-Id: I50deda7b26e7bb1c99f5bc34e84a40d6330b9560

include/livebox.h
packaging/liblivebox.spec
src/livebox.c

index cf0224a..41447e2 100644 (file)
@@ -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
index 31eb06f..0da34d5 100644 (file)
@@ -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
index 1bf5204..244919b 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <dlog.h>
 #include <livebox-service.h>
+#include <provider.h>
 #include <provider_buffer.h>
 
 #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;
                }