Sync with the latest one
[platform/framework/web/livebox-viewer.git] / src / desc_parser.c
index 74fb887..d0fa14c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <dlog.h>
 #include <livebox-errno.h>
+#include <livebox-service.h>
 
 #include "debug.h"
 #include "livebox.h"
@@ -29,7 +30,6 @@
 #include "desc_parser.h"
 #include "dlist.h"
 #include "util.h"
-#include "critical_log.h"
 
 #define TYPE_TEXT "text"
 #define TYPE_IMAGE "image"
@@ -37,6 +37,8 @@
 #define TYPE_SIGNAL "signal"
 #define TYPE_INFO "info"
 #define TYPE_DRAG "drag"
+#define TYPE_ACCESS "access"
+#define TYPE_OPERATE_ACCESS "access,operation"
 
 #define INFO_SIZE "size"
 #define INFO_CATEGORY "category"
@@ -182,6 +184,40 @@ static int update_info(struct livebox *handle, struct block *block, int is_pd)
        return 0;
 }
 
+static int update_access(struct livebox *handle, struct block *block, int is_pd)
+{
+       struct livebox_script_operators *ops;
+
+       if (!block) {
+               ErrPrint("Invalid argument\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       ops = is_pd ? &handle->pd.data.ops : &handle->lb.data.ops;
+       if (ops->update_access) {
+               ops->update_access(handle, block->id, block->part, block->data, block->option);
+       }
+
+       return 0;
+}
+
+static int operate_access(struct livebox *handle, struct block *block, int is_pd)
+{
+       struct livebox_script_operators *ops;
+
+       if (!block) {
+               ErrPrint("Invalid argument\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       ops = is_pd ? &handle->pd.data.ops : &handle->lb.data.ops;
+       if (ops->operate_access) {
+               ops->operate_access(handle, block->id, block->part, block->data, block->option);
+       }
+
+       return 0;
+}
+
 static inline int update_begin(struct livebox *handle, int is_pd)
 {
        struct livebox_script_operators *ops;
@@ -269,6 +305,14 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd)
                        .handler = update_info,
                },
                {
+                       .type = TYPE_ACCESS,
+                       .handler = update_access,
+               },
+               {
+                       .type = TYPE_OPERATE_ACCESS,
+                       .handler = operate_access,
+               },
+               {
                        .type = NULL,
                        .handler = NULL,
                },
@@ -316,7 +360,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd)
 
                        block = calloc(1, sizeof(*block));
                        if (!block) {
-                               CRITICAL_LOG("Heap: %s\n", strerror(errno));
+                               ErrPrint("Heap: %s\n", strerror(errno));
                                update_end(handle, is_pd);
                                if (fclose(fp) != 0) {
                                        ErrPrint("fclose: %s\n", strerror(errno));
@@ -438,7 +482,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd)
                                block->type_len += 256;
                                block->type = realloc(block->type, block->type_len);
                                if (!block->type) {
-                                       CRITICAL_LOG("Heap: %s\n", strerror(errno));
+                                       ErrPrint("Heap: %s\n", strerror(errno));
                                        goto errout;
                                }
                        }
@@ -460,7 +504,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd)
                                block->part_len += 256;
                                block->part = realloc(block->part, block->part_len);
                                if (!block->part) {
-                                       CRITICAL_LOG("Heap: %s\n", strerror(errno));
+                                       ErrPrint("Heap: %s\n", strerror(errno));
                                        goto errout;
                                }
                        }
@@ -482,7 +526,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd)
                                block->data_len += 256;
                                block->data = realloc(block->data, block->data_len);
                                if (!block->data) {
-                                       CRITICAL_LOG("Heap: %s\n", strerror(errno));
+                                       ErrPrint("Heap: %s\n", strerror(errno));
                                        goto errout;
                                }
                        }
@@ -504,7 +548,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd)
                                block->file_len += 256;
                                block->file = realloc(block->file, block->file_len);
                                if (!block->file) {
-                                       CRITICAL_LOG("Heap: %s\n", strerror(errno));
+                                       ErrPrint("Heap: %s\n", strerror(errno));
                                        goto errout;
                                }
                        }
@@ -526,7 +570,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd)
                                block->option_len += 256;
                                block->option = realloc(block->option, block->option_len);
                                if (!block->option) {
-                                       CRITICAL_LOG("Heap: %s\n", strerror(errno));
+                                       ErrPrint("Heap: %s\n", strerror(errno));
                                        goto errout;
                                }
                        }
@@ -547,7 +591,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd)
                                block->id_len += 256;
                                block->id = realloc(block->id, block->id_len);
                                if (!block->id) {
-                                       CRITICAL_LOG("Heap: %s\n", strerror(errno));
+                                       ErrPrint("Heap: %s\n", strerror(errno));
                                        goto errout;
                                }
                        }