Apply various patches
[apps/livebox/livebox-edje.git] / src / script_port.c
index e8a11c8..da52f0f 100644 (file)
@@ -1,11 +1,11 @@
 /*
- * Copyright 2012  Samsung Electronics Co., Ltd
+ * Copyright 2013  Samsung Electronics Co., Ltd
  *
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * Licensed under the Flora License, Version 1.1 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.tizenopensource.org/license
+ * http://floralicense.org/license/
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,7 +18,9 @@
 #include <libgen.h>
 #include <errno.h>
 #include <unistd.h>
+#include <ctype.h>
 
+#include <Elementary.h>
 #include <Evas.h>
 #include <Edje.h>
 #include <Eina.h>
 #include <Eet.h>
 #include <Ecore_X.h>
 
+#include <system_settings.h>
+
 #include <dlog.h>
 #include <debug.h>
 #include <vconf.h>
+#include <livebox-errno.h>
+#include <livebox-service.h>
 
 #include "script_port.h"
 
 #define TEXT_CLASS     "tizen"
-
-extern void evas_common_font_flush(void);
-extern int evas_common_font_cache_get(void);
-extern void evas_common_font_cache_set(int size);
+#define DEFAULT_FONT_SIZE      -100
+#define BASE_WIDTH     720.0f
+
+#define PUBLIC __attribute__((visibility("default")))
+
+struct image_option {
+       int orient;
+       int aspect;
+       enum {
+               FILL_DISABLE,
+               FILL_IN_SIZE,
+               FILL_OVER_SIZE,
+       } fill;
+
+       int width;
+       int height;
+};
 
 struct info {
        char *file;
@@ -59,53 +78,25 @@ struct child {
 struct obj_info {
        char *id;
        Eina_List *children;
+       Evas_Object *win;
+       Eina_List *access_chain;
 };
 
-struct {
-       Ecore_Event_Handler *property_handler;
-       char *font;
-       int size;
+static struct {
+       char *font_name;
+       int font_size;
 } s_info = {
-       .property_handler = NULL,
-       .font = NULL,
-       .size = -100,
+       .font_name = NULL,
+       .font_size = -100,
 };
 
-/*!
- * \NOTE
- * Reservce this for future use
-static inline void common_cache_flush(void *evas)
+static inline double scale_get(void)
 {
-       int file_cache;
-       int collection_cache;
-       int image_cache;
-       int font_cache;
-
-       file_cache = edje_file_cache_get();
-       collection_cache = edje_collection_cache_get();
-       image_cache = evas_image_cache_get(evas);
-       font_cache = evas_font_cache_get(evas);
-
-       edje_file_cache_set(file_cache);
-       edje_collection_cache_set(collection_cache);
-       evas_image_cache_set(evas, 0);
-       evas_font_cache_set(evas, 0);
-
-       evas_image_cache_flush(evas);
-       evas_render_idle_flush(evas);
-       evas_font_cache_flush(evas);
-
-       edje_file_cache_flush();
-       edje_collection_cache_flush();
-
-       edje_file_cache_set(file_cache);
-       edje_collection_cache_set(collection_cache);
-       evas_image_cache_set(evas, image_cache);
-       evas_font_cache_set(evas, font_cache);
-
-       eet_clearcache();
+       int width;
+       int height;
+       ecore_x_window_size_get(0, &width, &height);
+       return (double)width / BASE_WIDTH;
 }
- */
 
 static inline Evas_Object *find_edje(struct info *handle, const char *id)
 {
@@ -137,12 +128,34 @@ static inline Evas_Object *find_edje(struct info *handle, const char *id)
        return NULL;
 }
 
-const char *script_magic_id(void)
+static inline void rebuild_focus_chain(Evas_Object *obj)
+{
+       struct obj_info *obj_info;
+       Evas_Object *ao;
+       Eina_List *l;
+
+       obj_info = evas_object_data_get(obj, "obj_info");
+       if (!obj_info) {
+               ErrPrint("Object info is not available\n");
+               return;
+       }
+
+       elm_object_focus_custom_chain_unset(obj);
+
+       DbgPrint("Rebuild focus chain begin\n");
+       EINA_LIST_FOREACH(obj_info->access_chain, l, ao) {
+               DbgPrint("Append %p\n", ao);
+               elm_object_focus_custom_chain_append(obj, ao, NULL);
+       }
+       DbgPrint("Rebuild focus chain done\n");
+}
+
+PUBLIC const char *script_magic_id(void)
 {
        return "edje";
 }
 
-int script_update_color(void *h, Evas *e, const char *id, const char *part, const char *rgba)
+PUBLIC int script_update_color(void *h, Evas *e, const char *id, const char *part, const char *rgba)
 {
        struct info *handle = h;
        Evas_Object *edje;
@@ -151,7 +164,7 @@ int script_update_color(void *h, Evas *e, const char *id, const char *part, cons
 
        edje = find_edje(handle, id);
        if (!edje)
-               return -ENOENT;
+               return LB_STATUS_ERROR_NOT_EXIST;
 
        ret = sscanf(rgba, "%d %d %d %d %d %d %d %d %d %d %d %d",
                                        r, g, b, a,                     /* OBJECT */
@@ -159,32 +172,388 @@ int script_update_color(void *h, Evas *e, const char *id, const char *part, cons
                                        r + 2, g + 2, b + 2, a + 2);    /* SHADOW */
        if (ret != 12) {
                DbgPrint("id[%s] part[%s] rgba[%s]\n", id, part, rgba);
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
-       ret = edje_object_color_class_set(edje, part,
+       ret = edje_object_color_class_set(elm_layout_edje_get(edje), part,
                                r[0], g[0], b[0], a[0], /* OBJECT */
                                r[1], g[1], b[1], a[1], /* OUTLINE */
                                r[2], g[2], b[2], a[2]); /* SHADOW */
 
        DbgPrint("EDJE[%s] color class is %s changed", id, ret == EINA_TRUE ? "successfully" : "not");
-       return 0;
+       return LB_STATUS_SUCCESS;
+}
+
+static void activate_cb(void *data, Evas_Object *part_obj, Elm_Object_Item *item)
+{
+       Evas_Object *ao;
+       Evas_Object *edje;
+       Evas *e;
+       int x;
+       int y;
+       int w;
+       int h;
+       struct timeval tv;
+       double timestamp;
+
+       ao = evas_object_data_get(part_obj, "ao");
+       if (!ao)
+               return;
+
+       edje = evas_object_data_get(ao, "edje");
+       if (!edje)
+               return;
+
+       e = evas_object_evas_get(part_obj);
+       evas_object_geometry_get(part_obj, &x, &y, &w, &h);
+       x += w / 2;
+       y += h / 2;
+
+       if (gettimeofday(&tv, NULL) < 0) {
+               ErrPrint("Failed to get time\n");
+               timestamp = 0.0f;
+       } else {
+               timestamp = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0f);
+       }
+
+       DbgPrint("Cursor is on %dx%d\n", x, y);
+       evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
+       evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
+       evas_event_feed_mouse_move(e, x, y, timestamp + 0.02f, NULL);
+       evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.03f, NULL);
 }
 
-int script_update_text(void *h, Evas *e, const char *id, const char *part, const char *text)
+PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part, const char *text)
 {
+       struct obj_info *obj_info;
        struct info *handle = h;
        Evas_Object *edje;
+       Evas_Object *to;
 
        edje = find_edje(handle, id);
-       if (!edje)
-               return -ENOENT;
+       if (!edje) {
+               ErrPrint("Failed to find EDJE\n");
+               return LB_STATUS_ERROR_NOT_EXIST;
+       }
+
+       obj_info = evas_object_data_get(edje, "obj_info");
+       if (!obj_info) {
+               ErrPrint("Object info is not available\n");
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       elm_object_part_text_set(edje, part, text ? text : "");
+
+       to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+       if (to) {
+               Evas_Object *ao;
+               char *utf8;
+
+               ao = evas_object_data_get(to, "ao");
+               if (!ao) {
+                       ao = elm_access_object_register(to, edje);
+                       if (!ao) {
+                               ErrPrint("Unable to add ao: %s\n", part);
+                               goto out;
+                       }
+                       obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
+                       evas_object_data_set(to, "ao", ao);
+                       evas_object_data_set(ao, "edje", edje);
+                       elm_access_activate_cb_set(ao, activate_cb, NULL);
+                       elm_object_focus_custom_chain_append(edje, ao, NULL);
+               }
+
+               if (!text || !strlen(text)) {
+                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+                       evas_object_data_del(to, "ao");
+                       evas_object_data_del(ao, "edje");
+                       elm_access_object_unregister(ao);
+                       DbgPrint("[%s] Remove access object\n", part);
+
+                       rebuild_focus_chain(edje);
+                       goto out;
+               }
+
+               utf8 = elm_entry_markup_to_utf8(text);
+               if ((!utf8 || !strlen(utf8))) {
+                       free(utf8);
+
+                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+                       evas_object_data_del(to, "ao");
+                       evas_object_data_del(ao, "edje");
+                       elm_access_object_unregister(ao);
+                       DbgPrint("[%s] Remove access object\n", part);
+
+                       rebuild_focus_chain(edje);
+                       goto out;
+               }
 
-       edje_object_part_text_set(edje, part, text);
-       return 0;
+               elm_access_info_set(ao, ELM_ACCESS_INFO, utf8);
+               DbgPrint("[%s] Update access object (%s)\n", part, utf8);
+               free(utf8);
+       } else {
+               ErrPrint("Unable to get text part[%s]\n", part);
+       }
+
+out:
+       return LB_STATUS_SUCCESS;
+}
+
+static void parse_aspect(struct image_option *img_opt, const char *value, int len)
+{
+       while (len > 0 && *value == ' ') {
+               value++;
+               len--;
+       }
+
+       if (len < 4)
+               return;
+
+       img_opt->aspect = !strncasecmp(value, "true", 4);
+       DbgPrint("Parsed ASPECT: %d (%s)\n", img_opt->aspect, value);
+}
+
+static void parse_orient(struct image_option *img_opt, const char *value, int len)
+{
+       while (len > 0 && *value == ' ') {
+               value++;
+               len--;
+       }
+
+       if (len < 4)
+               return;
+
+       img_opt->orient = !strncasecmp(value, "true", 4);
+       DbgPrint("Parsed ORIENT: %d (%s)\n", img_opt->orient, value);
 }
 
-int script_update_image(void *_h, Evas *e, const char *id, const char *part, const char *path)
+static void parse_size(struct image_option *img_opt, const char *value, int len)
+{
+       int width;
+       int height;
+       char *buf;
+
+       while (len > 0 && *value == ' ') {
+               value++;
+               len--;
+       }
+
+       buf = strndup(value, len);
+       if (!buf) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return;
+       }
+
+       if (sscanf(buf, "%dx%d", &width, &height) == 2) {
+               img_opt->width = width;
+               img_opt->height = height;
+               DbgPrint("Parsed size : %dx%d (%s)\n", width, height, buf);
+       } else {
+               DbgPrint("Invalid size tag[%s]\n", buf);
+       }
+
+       free(buf);
+}
+
+static void parse_fill(struct image_option *img_opt, const char *value, int len)
+{
+       while (len > 0 && *value == ' ') {
+               value++;
+               len--;
+       }
+
+       if (!strncasecmp(value, "in-size", len))
+               img_opt->fill = FILL_IN_SIZE;
+       else if (!strncasecmp(value, "over-size", len))
+               img_opt->fill = FILL_OVER_SIZE;
+       else
+               img_opt->fill = FILL_DISABLE;
+
+       DbgPrint("Parsed FILL: %d (%s)\n", img_opt->fill, value);
+}
+
+static inline void parse_image_option(const char *option, struct image_option *img_opt)
+{
+       const char *ptr;
+       const char *cmd;
+       const char *value;
+       struct {
+               const char *cmd;
+               void (*handler)(struct image_option *img_opt, const char *value, int len);
+       } cmd_list[] = {
+               {
+                       .cmd = "aspect", /* Keep the aspect ratio */
+                       .handler = parse_aspect,
+               },
+               {
+                       .cmd = "orient", /* Keep the orientation value: for the rotated images */
+                       .handler = parse_orient,
+               },
+               {
+                       .cmd = "fill", /* Fill the image to its container */
+                       .handler = parse_fill, /* Value: in-size, over-size, disable(default) */
+               },
+               {
+                       .cmd = "size",
+                       .handler = parse_size,
+               },
+       };
+       enum {
+               STATE_START,
+               STATE_TOKEN,
+               STATE_DATA,
+               STATE_IGNORE,
+               STATE_ERROR,
+               STATE_END,
+       } state;
+       int idx;
+       int tag;
+
+       if (!option || !*option)
+               return;
+
+       state = STATE_START;
+       /*!
+        * \note
+        * GCC 4.7 warnings uninitialized idx and tag value.
+        * But it will be initialized by the state machine. :(
+        * Anyway, I just reset idx and tag for reducing the GCC4.7 complains.
+        */
+       idx = 0;
+       tag = 0;
+       cmd = NULL;
+       value = NULL;
+
+       for (ptr = option; state != STATE_END; ptr++) {
+               switch (state) {
+               case STATE_START:
+                       if (*ptr == '\0') {
+                               state = STATE_END;
+                               continue;
+                       }
+
+                       if (isalpha(*ptr)) {
+                               state = STATE_TOKEN;
+                               ptr--;
+                       }
+                       tag = 0;
+                       idx = 0;
+
+                       cmd = cmd_list[tag].cmd;
+                       break;
+               case STATE_IGNORE:
+                       if (*ptr == '=') {
+                               state = STATE_DATA;
+                               value = ptr;
+                       } else if (*ptr == '\0') {
+                               state = STATE_END;
+                       }
+                       break;
+               case STATE_TOKEN:
+                       if (cmd[idx] == '\0' && (*ptr == ' ' || *ptr == '\t' || *ptr == '=')) {
+                               if (*ptr == '=') {
+                                       value = ptr;
+                                       state = STATE_DATA;
+                               } else {
+                                       state = STATE_IGNORE;
+                               }
+                               idx = 0;
+                       } else if (*ptr == '\0') {
+                               state = STATE_END;
+                       } else if (cmd[idx] == *ptr) {
+                               idx++;
+                       } else {
+                               ptr -= (idx + 1);
+
+                               tag++;
+                               if (tag == sizeof(cmd_list) / sizeof(cmd_list[0])) {
+                                       tag = 0;
+                                       state = STATE_ERROR;
+                               } else {
+                                       cmd = cmd_list[tag].cmd;
+                               }
+                               idx = 0;
+                       }
+                       break;
+               case STATE_DATA:
+                       if (*ptr == ';' || *ptr == '\0') {
+                               cmd_list[tag].handler(img_opt, value + 1, idx);
+                               state = *ptr ? STATE_START : STATE_END;
+                       } else {
+                               idx++;
+                       }
+                       break;
+               case STATE_ERROR:
+                       if (*ptr == ';')
+                               state = STATE_START;
+                       else if (*ptr == '\0')
+                               state = STATE_END;
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *part, const char *text, const char *option)
+{
+       struct info *handle = _h;
+       Evas_Object *edje;
+       struct obj_info *obj_info;
+       Evas_Object *to;
+
+       edje = find_edje(handle, id);
+       if (!edje) {
+               ErrPrint("No such object: %s\n", id);
+               return LB_STATUS_ERROR_NOT_EXIST;
+       }
+
+       obj_info = evas_object_data_get(edje, "obj_info");
+       if (!obj_info) {
+               ErrPrint("Object info is not available\n");
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+       if (to) {
+               Evas_Object *ao;
+
+               ao = evas_object_data_get(to, "ao");
+               if (ao) {
+                       DbgPrint("[%s] Update access object (%s)\n", part, text);
+                       if (text && strlen(text)) {
+                               elm_access_info_set(ao, ELM_ACCESS_INFO, text);
+                       } else {
+                               obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+                               evas_object_data_del(to, "ao");
+                               evas_object_data_del(ao, "edje");
+                               elm_access_object_unregister(ao);
+                               DbgPrint("Successfully unregistered\n");
+
+                               rebuild_focus_chain(edje);
+                       }
+               } else if (text && strlen(text)) {
+                       ao = elm_access_object_register(to, edje);
+                       if (!ao) {
+                               ErrPrint("Unable to register access object\n");
+                       } else {
+                               elm_access_info_set(ao, ELM_ACCESS_INFO, text);
+                               obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
+                               evas_object_data_set(to, "ao", ao);
+                               elm_object_focus_custom_chain_append(edje, ao, NULL);
+                               DbgPrint("[%s] Register access info: (%s)\n", part, text);
+                               evas_object_data_set(ao, "edje", edje);
+                               elm_access_activate_cb_set(ao, activate_cb, NULL);
+                       }
+               }
+       } else {
+               ErrPrint("[%s] is not exists\n", part);
+       }
+
+       return LB_STATUS_SUCCESS;
+}
+
+PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *part, const char *path, const char *option)
 {
        struct info *handle = _h;
        Evas_Load_Error err;
@@ -193,25 +562,31 @@ int script_update_image(void *_h, Evas *e, const char *id, const char *part, con
        Evas_Coord w, h;
        struct obj_info *obj_info;
        struct child *child;
+       struct image_option img_opt = {
+               .aspect = 0,
+               .orient = 0,
+               .fill = FILL_DISABLE,
+               .width = -1,
+               .height = -1,
+       };
 
        edje = find_edje(handle, id);
        if (!edje) {
                ErrPrint("No such object: %s\n", id);
-               return -ENOENT;
+               return LB_STATUS_ERROR_NOT_EXIST;
        }
 
        obj_info = evas_object_data_get(edje, "obj_info");
        if (!obj_info) {
                ErrPrint("Object info is not available\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       img = edje_object_part_swallow_get(edje, part);
+       img = elm_object_part_content_unset(edje, part);
        if (img) {
                Eina_List *l;
                Eina_List *n;
-
-               edje_object_part_unswallow(edje, img);
+               Evas_Object *ao;
 
                EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) {
                        if (child->obj != img)
@@ -224,36 +599,47 @@ int script_update_image(void *_h, Evas *e, const char *id, const char *part, con
                }
 
                DbgPrint("delete object %s %p\n", part, img);
+               ao = evas_object_data_del(img, "ao");
+               if (ao) {
+                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+                       evas_object_data_del(ao, "edje");
+                       elm_access_object_unregister(ao);
+                       DbgPrint("Successfully unregistered\n");
+               }
                evas_object_del(img);
+
+               rebuild_focus_chain(edje);
        }
 
        if (!path || !strlen(path) || access(path, R_OK) != 0) {
                DbgPrint("SKIP - Path: [%s]\n", path);
-               return 0;
+               return LB_STATUS_SUCCESS;
        }
 
        child = malloc(sizeof(*child));
        if (!child) {
                ErrPrint("Heap: %s\n", strerror(errno));
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
        child->part = strdup(part);
        if (!child->part) {
                ErrPrint("Heap: %s\n", strerror(errno));
                free(child);
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
-       img = evas_object_image_filled_add(e);
+       img = evas_object_image_add(e);
        if (!img) {
                ErrPrint("Failed to add an image object\n");
                free(child->part);
                free(child);
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       child->obj = img;
+       evas_object_image_preload(img, EINA_FALSE);
+       parse_image_option(option, &img_opt);
+       evas_object_image_load_orientation_set(img, img_opt.orient);
 
        evas_object_image_file_set(img, path, NULL);
        err = evas_object_image_load_error_get(img);
@@ -262,24 +648,111 @@ int script_update_image(void *_h, Evas *e, const char *id, const char *part, con
                evas_object_del(img);
                free(child->part);
                free(child);
-               return -EIO;
+               return LB_STATUS_ERROR_IO;
        }
 
        evas_object_image_size_get(img, &w, &h);
-       evas_object_image_fill_set(img, 0, 0, w, h);
-       evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       evas_object_resize(img, w, h);
+       if (img_opt.aspect) {
+               if (img_opt.fill == FILL_OVER_SIZE) {
+                       Evas_Coord part_w;
+                       Evas_Coord part_h;
+
+                       if (img_opt.width >= 0 && img_opt.height >= 0) {
+                               part_w = img_opt.width * scale_get();
+                               part_h = img_opt.height * scale_get();
+                       } else {
+                               part_w = 0;
+                               part_h = 0;
+                               edje_object_part_geometry_get(elm_layout_edje_get(edje), part, NULL, NULL, &part_w, &part_h);
+                       }
+                       DbgPrint("Original %dx%d (part: %dx%d)\n", w, h, part_w, part_h);
+
+                       if (part_w > w || part_h > h) {
+                               double fw;
+                               double fh;
+
+                               fw = (double)part_w / (double)w;
+                               fh = (double)part_h / (double)h;
+
+                               if (fw > fh) {
+                                       w = part_w;
+                                       h = (double)h * fw;
+                               } else {
+                                       h = part_h;
+                                       w = (double)w * fh;
+                               }
+                       }
+                       DbgPrint("Size: %dx%d\n", w, h);
+
+                       evas_object_image_load_size_set(img, w, h);
+                       evas_object_image_load_region_set(img, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h);
+                       evas_object_image_fill_set(img, 0, 0, part_w, part_h);
+                       evas_object_image_reload(img);
+               } else if (img_opt.fill == FILL_IN_SIZE) {
+                       Evas_Coord part_w;
+                       Evas_Coord part_h;
+
+                       if (img_opt.width >= 0 && img_opt.height >= 0) {
+                               part_w = img_opt.width * scale_get();
+                               part_h = img_opt.height * scale_get();
+                       } else {
+                               part_w = 0;
+                               part_h = 0;
+                               edje_object_part_geometry_get(elm_layout_edje_get(edje), part, NULL, NULL, &part_w, &part_h);
+                       }
+                       DbgPrint("Original %dx%d (part: %dx%d)\n", w, h, part_w, part_h);
+
+                       if (part_w > w || part_h > h) {
+                               double fw;
+                               double fh;
+
+                               fw = (double)part_w / (double)w;
+                               fh = (double)part_h / (double)h;
+
+                               if (fw > fh) {
+                                       w = part_w;
+                                       h = (double)h * fw;
+                               } else {
+                                       h = part_h;
+                                       w = (double)w * fh;
+                               }
+                       }
+                       DbgPrint("Size: %dx%d\n", w, h);
+                       evas_object_image_fill_set(img, 0, 0, part_w, part_h);
+                       evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
+                       evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               } else {
+                       evas_object_image_fill_set(img, 0, 0, w, h);
+                       evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
+                       evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_BOTH, w, h);
+               }
+       } else {
+               if (img_opt.width >= 0 && img_opt.height >= 0) {
+                       w = img_opt.width;
+                       h = img_opt.height;
+                       DbgPrint("Using given image size: %dx%d\n", w, h);
+               }
+
+               evas_object_image_fill_set(img, 0, 0, w, h);
+               evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       }
 
        /*!
         * \note
         * object will be shown by below statement automatically
         */
-       DbgPrint("%s part swallow image %p\n", part, img);
-       edje_object_part_swallow(edje, part, img);
+       DbgPrint("%s part swallow image %p (%dx%d)\n", part, img, w, h);
+       child->obj = img;
+       elm_object_part_content_set(edje, part, img);
        obj_info->children = eina_list_append(obj_info->children, child);
 
-       return 0;
+       /*!
+        * \note
+        * This object is not registered as an access object.
+        * So the developer should add it to access list manually, using DESC_ACCESS block.
+        */
+       return LB_STATUS_SUCCESS;
 }
 
 static void script_signal_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
@@ -297,7 +770,7 @@ static void script_signal_cb(void *data, Evas_Object *obj, const char *emission,
        double ey;
 
        evas_object_geometry_get(obj, NULL, NULL, &w, &h);
-       edje_object_part_geometry_get(obj, source, &px, &py, &pw, &ph);
+       edje_object_part_geometry_get(elm_layout_edje_get(obj), source, &px, &py, &pw, &ph);
 
        sx = ex = 0.0f;
        if (w) {
@@ -320,6 +793,7 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info
        struct info *handle = _info;
        struct obj_info *obj_info;
        struct child *child;
+       Evas_Object *ao;
 
        handle->obj_list = eina_list_remove(handle->obj_list, obj);
 
@@ -331,21 +805,186 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info
 
        DbgPrint("delete object %s %p\n", obj_info->id, obj);
 
-       edje_object_signal_callback_del_full(obj, "*", "*", script_signal_cb, handle);
+       elm_object_signal_callback_del(obj, "*", "*", script_signal_cb);
+
+       elm_object_focus_custom_chain_unset(obj);
 
        EINA_LIST_FREE(obj_info->children, child) {
                DbgPrint("delete object %s %p\n", child->part, child->obj);
-               if (child->obj)
+               if (child->obj) {
+                       Evas_Object *ao;
+                       ao = evas_object_data_del(child->obj, "ao");
+                       if (ao) {
+                               obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+                               evas_object_data_del(ao, "edje");
+                               elm_access_object_unregister(ao);
+                       }
                        evas_object_del(child->obj);
+               }
                free(child->part);
                free(child);
        }
 
+       EINA_LIST_FREE(obj_info->access_chain, ao) {
+               evas_object_data_del(ao, "edje");
+               elm_access_object_unregister(ao);
+       }
+
        free(obj_info->id);
        free(obj_info);
 }
 
-int script_update_script(void *h, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *group)
+/*!
+       LB_ACCESS_HIGHLIGHT             0
+       LB_ACCESS_HIGHLIGHT_NEXT        1
+       LB_ACCESS_HIGHLIGHT_PREV        2
+       LB_ACCESS_ACTIVATE              3
+       LB_ACCESS_ACTION                4
+       LB_ACCESS_SCROLL                5
+*/
+PUBLIC int script_feed_event(void *h, Evas *e, int event_type, int x, int y, int down, double timestamp)
+{
+       struct info *handle = h;
+       Evas_Object *edje;
+       struct obj_info *obj_info;
+       int ret = LB_STATUS_SUCCESS;
+
+       DbgPrint("event: %d, x: %d, y: %d\n", event_type, x, y);
+
+       edje = find_edje(handle, NULL); /*!< Get the base layout */
+       if (!edje) {
+               ErrPrint("Base layout is not exist\n");
+               return LB_STATUS_ERROR_NOT_EXIST;
+       }
+
+       obj_info = evas_object_data_get(edje, "obj_info");
+       if (!obj_info) {
+               ErrPrint("Object info is not valid\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (event_type & LB_SCRIPT_ACCESS_EVENT) {
+               Elm_Access_Action_Info *info;
+               Elm_Access_Action_Type action;
+               const Eina_List *chain;
+
+               info = calloc(1, sizeof(*info));
+               if (!info) {
+                       ErrPrint("Error: %s\n", strerror(errno));
+                       return LB_STATUS_ERROR_MEMORY;
+               }
+
+               chain = elm_object_focus_custom_chain_get(edje);
+               DbgPrint("Focus chain : %d\n", eina_list_count(chain));
+
+               if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT) == LB_SCRIPT_ACCESS_HIGHLIGHT) {
+                       action = ELM_ACCESS_ACTION_HIGHLIGHT;
+                       info->x = x;
+                       info->y = y;
+                       ret = elm_access_action(edje, action, info);
+                       DbgPrint("ACCESS_HIGHLIGHT: %dx%d returns %d\n", x, y, ret);
+                       ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+               } else if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT) == LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT) {
+                       action = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
+                       info->highlight_cycle = EINA_FALSE;
+                       ret = elm_access_action(edje, action, info);
+                       DbgPrint("ACCESS_HIGHLIGHT_NEXT, returns %d\n", ret);
+                       ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_LAST : LB_ACCESS_STATUS_DONE;
+               } else if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT_PREV) == LB_SCRIPT_ACCESS_HIGHLIGHT_PREV) {
+                       action = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
+                       info->highlight_cycle = EINA_FALSE;
+                       ret = elm_access_action(edje, action, info);
+                       DbgPrint("ACCESS_HIGHLIGHT_PREV, returns %d\n", ret);
+                       ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_FIRST : LB_ACCESS_STATUS_DONE;
+               } else if ((event_type & LB_SCRIPT_ACCESS_ACTIVATE) == LB_SCRIPT_ACCESS_ACTIVATE) {
+                       action = ELM_ACCESS_ACTION_ACTIVATE;
+                       ret = elm_access_action(edje, action, info);
+                       DbgPrint("ACCESS_ACTIVATE, returns %d\n", ret);
+                       ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+               } else if ((event_type & LB_SCRIPT_ACCESS_ACTION) == LB_SCRIPT_ACCESS_ACTION) {
+                       if (down == 0) {
+                               action = ELM_ACCESS_ACTION_UP;
+                               ret = elm_access_action(edje, action, info);
+                               DbgPrint("ACCESS_ACTION(%d), returns %d\n", down, ret);
+                               ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+                       } else if (down == 1) {
+                               action = ELM_ACCESS_ACTION_DOWN;
+                               ret = elm_access_action(edje, action, info);
+                               DbgPrint("ACCESS_ACTION(%d), returns %d\n", down, ret);
+                               ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+                       } else {
+                               ErrPrint("Invalid access event\n");
+                               ret = LB_ACCESS_STATUS_ERROR;
+                       }
+               } else if ((event_type & LB_SCRIPT_ACCESS_SCROLL) == LB_SCRIPT_ACCESS_SCROLL) {
+                       action = ELM_ACCESS_ACTION_SCROLL;
+                       info->x = x;
+                       info->y = y;
+                       switch (down) {
+                       case 0:
+                               info->mouse_type = 0;
+                               ret = elm_access_action(edje, action, info);
+                               DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret);
+                               ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+                               break;
+                       case -1:
+                               info->mouse_type = 1;
+                               ret = elm_access_action(edje, action, info);
+                               DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret);
+                               ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+                               break;
+                       case 1:
+                               info->mouse_type = 2;
+                               ret = elm_access_action(edje, action, info);
+                               DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret);
+                               ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+                               break;
+                       default:
+                               ret = LB_ACCESS_STATUS_ERROR;
+                               break;
+                       }
+               } else if ((event_type & LB_SCRIPT_ACCESS_UNHIGHLIGHT) == LB_SCRIPT_ACCESS_UNHIGHLIGHT) {
+                       action = ELM_ACCESS_ACTION_UNHIGHLIGHT;
+                       ret = elm_access_action(edje, action, info);
+                       DbgPrint("ACCESS_UNHIGHLIGHT, returns %d\n", ret);
+                       ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+               } else {
+                       DbgPrint("Invalid event\n");
+                       ret = LB_ACCESS_STATUS_ERROR;
+               }
+
+               free(info);
+       } else if (event_type & LB_SCRIPT_MOUSE_EVENT) {
+               switch (event_type) {
+               case LB_SCRIPT_MOUSE_DOWN:
+                       evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
+                       evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
+                       break;
+               case LB_SCRIPT_MOUSE_MOVE:
+                       evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
+                       break;
+               case LB_SCRIPT_MOUSE_UP:
+                       evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
+                       evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
+                       break;
+               case LB_SCRIPT_MOUSE_IN:
+                       evas_event_feed_mouse_in(e, timestamp, NULL);
+                       break;
+               case LB_SCRIPT_MOUSE_OUT:
+                       evas_event_feed_mouse_out(e, timestamp, NULL);
+                       break;
+               default:
+                       return LB_STATUS_ERROR_INVALID;
+               }
+       } else if (event_type & LB_SCRIPT_KEY_EVENT) {
+               DbgPrint("Key event is not implemented\n");
+               return LB_STATUS_ERROR_NOT_IMPLEMENTED;
+       }
+
+       return ret;
+}
+
+PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *group)
 {
        struct info *handle = h;
        Evas_Object *edje;
@@ -358,57 +997,60 @@ int script_update_script(void *h, Evas *e, const char *src_id, const char *targe
        edje = find_edje(handle, src_id);
        if (!edje) {
                ErrPrint("Edje is not exists\n");
-               return -ENOENT;
+               return LB_STATUS_ERROR_NOT_EXIST;
        }
 
        obj_info = evas_object_data_get(edje, "obj_info");
        if (!obj_info) {
                ErrPrint("Object info is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
-       obj = edje_object_part_swallow_get(edje, part);
+       obj = elm_object_part_content_unset(edje, part);
        if (obj) {
                Eina_List *l;
                Eina_List *n;
 
-               edje_object_part_unswallow(edje, obj);
-
                EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) {
                        if (child->obj != obj)
                                continue;
 
                        obj_info->children = eina_list_remove(obj_info->children, child);
+
                        free(child->part);
                        free(child);
                        break;
                }
 
                DbgPrint("delete object %s %p\n", part, obj);
+               /*!
+                * \note
+                * This will call the edje_del_cb.
+                * It will delete all access objects
+                */
                evas_object_del(obj);
        }
 
        if (!path || !strlen(path) || access(path, R_OK) != 0) {
                DbgPrint("SKIP - Path: [%s]\n", path);
-               return 0;
+               return LB_STATUS_SUCCESS;
        }
 
-       obj = edje_object_add(e);
+       obj = elm_layout_add(edje);
        if (!obj) {
                ErrPrint("Failed to add a new edje object\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       //edje_object_text_class_set(obj, TEXT_CLASS, s_info.font, s_info.size);
-       if (!edje_object_file_set(obj, path, group)) {
+       if (!elm_layout_file_set(obj, path, group)) {
                int err;
                const char *errmsg;
 
-               err = edje_object_load_error_get(obj);
+               err = edje_object_load_error_get(elm_layout_edje_get(obj));
                errmsg = edje_load_error_str(err);
                ErrPrint("Could not load %s from %s: %s\n", group, path, errmsg);
                evas_object_del(obj);
-               return -EIO;
+               return LB_STATUS_ERROR_IO;
        }
 
        evas_object_show(obj);
@@ -417,7 +1059,7 @@ int script_update_script(void *h, Evas *e, const char *src_id, const char *targe
        if (!obj_info) {
                ErrPrint("Failed to add a obj_info\n");
                evas_object_del(obj);
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
        obj_info->id = strdup(target_id);
@@ -425,7 +1067,7 @@ int script_update_script(void *h, Evas *e, const char *src_id, const char *targe
                ErrPrint("Failed to add a obj_info\n");
                free(obj_info);
                evas_object_del(obj);
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
        child = malloc(sizeof(*child));
@@ -434,7 +1076,7 @@ int script_update_script(void *h, Evas *e, const char *src_id, const char *targe
                free(obj_info->id);
                free(obj_info);
                evas_object_del(obj);
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
        child->part = strdup(part);
@@ -444,24 +1086,24 @@ int script_update_script(void *h, Evas *e, const char *src_id, const char *targe
                free(obj_info->id);
                free(obj_info);
                evas_object_del(obj);
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
        child->obj = obj;
 
        evas_object_data_set(obj, "obj_info", obj_info);
        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, edje_del_cb, handle);
-       edje_object_signal_callback_add(obj, "*", "*", script_signal_cb, handle);
+       elm_object_signal_callback_add(obj, "*", "*", script_signal_cb, handle);
        handle->obj_list = eina_list_append(handle->obj_list, obj);
 
        DbgPrint("%s part swallow edje %p\n", part, obj);
-       edje_object_part_swallow(edje, part, obj);
+       elm_object_part_content_set(edje, part, obj);
        obj_info = evas_object_data_get(edje, "obj_info");
        obj_info->children = eina_list_append(obj_info->children, child);
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
-int script_update_signal(void *h, Evas *e, const char *id, const char *part, const char *signal)
+PUBLIC int script_update_signal(void *h, Evas *e, const char *id, const char *part, const char *signal)
 {
        struct info *handle = h;
        Evas_Object *edje;
@@ -470,13 +1112,13 @@ int script_update_signal(void *h, Evas *e, const char *id, const char *part, con
 
        edje = find_edje(handle, id);
        if (!edje)
-               return -ENOENT;
+               return LB_STATUS_ERROR_NOT_EXIST;
 
-       edje_object_signal_emit(edje, signal, part);
-       return 0;
+       elm_object_signal_emit(edje, signal, part);
+       return LB_STATUS_SUCCESS;
 }
 
-int script_update_drag(void *h, Evas *e, const char *id, const char *part, double x, double y)
+PUBLIC int script_update_drag(void *h, Evas *e, const char *id, const char *part, double x, double y)
 {
        struct info *handle = h;
        Evas_Object *edje;
@@ -485,20 +1127,20 @@ int script_update_drag(void *h, Evas *e, const char *id, const char *part, doubl
 
        edje = find_edje(handle, id);
        if (!edje)
-               return -ENOENT;
+               return LB_STATUS_ERROR_NOT_EXIST;
 
-       edje_object_part_drag_value_set(edje, part, x, y);
-       return 0;
+       edje_object_part_drag_value_set(elm_layout_edje_get(edje), part, x, y);
+       return LB_STATUS_SUCCESS;
 }
 
-int script_update_size(void *han, Evas *e, const char *id, int w, int h)
+PUBLIC int script_update_size(void *han, Evas *e, const char *id, int w, int h)
 {
        struct info *handle = han;
        Evas_Object *edje;
 
        edje = find_edje(handle, id);
        if (!edje)
-               return -ENOENT;
+               return LB_STATUS_ERROR_NOT_EXIST;
 
        if (!id) {
                handle->w = w;
@@ -507,10 +1149,10 @@ int script_update_size(void *han, Evas *e, const char *id, int w, int h)
 
        DbgPrint("Resize object to %dx%d\n", w, h);
        evas_object_resize(edje, w, h);
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
-int script_update_category(void *h, Evas *e, const char *id, const char *category)
+PUBLIC int script_update_category(void *h, Evas *e, const char *id, const char *category)
 {
        struct info *handle = h;
 
@@ -522,18 +1164,18 @@ int script_update_category(void *h, Evas *e, const char *id, const char *categor
        }
 
        if (!category)
-               return 0;
+               return LB_STATUS_SUCCESS;
 
        handle->category = strdup(category);
        if (!handle->category) {
                ErrPrint("Error: %s\n", strerror(errno));
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
-void *script_create(const char *file, const char *group)
+PUBLIC void *script_create(const char *file, const char *group)
 {
        struct info *handle;
 
@@ -563,7 +1205,7 @@ void *script_create(const char *file, const char *group)
        return handle;
 }
 
-int script_destroy(void *_handle)
+PUBLIC int script_destroy(void *_handle)
 {
        struct info *handle;
        Evas_Object *edje;
@@ -578,10 +1220,10 @@ int script_destroy(void *_handle)
        free(handle->file);
        free(handle->group);
        free(handle);
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
-int script_load(void *_handle, Evas *e, int w, int h)
+PUBLIC int script_load(void *_handle, Evas *e, int w, int h)
 {
        struct info *handle;
        Evas_Object *edje;
@@ -592,35 +1234,42 @@ int script_load(void *_handle, Evas *e, int w, int h)
        obj_info = calloc(1, sizeof(*obj_info));
        if (!obj_info) {
                ErrPrint("Heap: %s\n", strerror(errno));
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
-       edje = edje_object_add(e);
+       obj_info->win = evas_object_rectangle_add(e);
+       if (!obj_info->win) {
+               free(obj_info);
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       edje = elm_layout_add(obj_info->win);
        if (!edje) {
                ErrPrint("Failed to create an edje object\n");
+               evas_object_del(obj_info->win);
                free(obj_info);
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       //edje_object_text_class_set(edje, TEXT_CLASS, s_info.font, s_info.size);
        DbgPrint("Load edje: %s - %s\n", handle->file, handle->group);
-       if (!edje_object_file_set(edje, handle->file, handle->group)) {
+       if (!elm_layout_file_set(edje, handle->file, handle->group)) {
                int err;
                const char *errmsg;
 
-               err = edje_object_load_error_get(edje);
+               err = edje_object_load_error_get(elm_layout_edje_get(edje));
                errmsg = edje_load_error_str(err);
                ErrPrint("Could not load %s from %s: %s\n", handle->group, handle->file, errmsg);
                evas_object_del(edje);
+               evas_object_del(obj_info->win);
                free(obj_info);
-               return -EIO;
+               return LB_STATUS_ERROR_IO;
        }
 
        handle->e = e;
        handle->w = w;
        handle->h = h;
 
-       edje_object_signal_callback_add(edje, "*", "*", script_signal_cb, handle);
+       elm_object_signal_callback_add(edje, "*", "*", script_signal_cb, handle);
        evas_object_event_callback_add(edje, EVAS_CALLBACK_DEL, edje_del_cb, handle);
        evas_object_size_hint_weight_set(edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_fill_set(edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -629,10 +1278,10 @@ int script_load(void *_handle, Evas *e, int w, int h)
        evas_object_data_set(edje, "obj_info", obj_info);
 
        handle->obj_list = eina_list_append(handle->obj_list, edje);
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
-int script_unload(void *_handle, Evas *e)
+PUBLIC int script_unload(void *_handle, Evas *e)
 {
        struct info *handle;
        Evas_Object *edje;
@@ -644,104 +1293,153 @@ int script_unload(void *_handle, Evas *e)
        if (edje)
                evas_object_del(edje);
        handle->e = NULL;
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
-static Eina_Bool property_cb(void *data, int type, void *event)
+static void access_cb(keynode_t *node, void *user_data)
 {
-       Ecore_X_Event_Window_Property *info = (Ecore_X_Event_Window_Property *)event;
+       int state;
 
-       if (info->atom == ecore_x_atom_get("FONT_TYPE_change") || info->atom == ecore_x_atom_get("BADA_FONT_change")) {
-               Eina_List *list;
-               char *text;
-               char *font;
-               int cache;
+       if (!node) {
+               if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &state) != 0) {
+                       ErrPrint("Idle lock state is not valid\n");
+                       state = 0; /* DISABLED */
+               }
+       } else {
+               state = vconf_keynode_get_bool(node);
+       }
 
-               font = vconf_get_str("db/setting/accessibility/font_name");
-               if (!font)
-                       return ECORE_CALLBACK_PASS_ON;
+       DbgPrint("ELM CONFIG ACCESS: %d\n", state);
+       elm_config_access_set(state);
+}
 
-               if (s_info.font)
-                       free(s_info.font);
+static void update_font_cb(void *data)
+{
+       elm_config_font_overlay_set(TEXT_CLASS, s_info.font_name, DEFAULT_FONT_SIZE);
+       DbgPrint("Update text class %s (%s, %d)\n", TEXT_CLASS, s_info.font_name, DEFAULT_FONT_SIZE);
+}
 
-               s_info.font = font;
+static void font_changed_cb(keynode_t *node, void *user_data)
+{
+       char *font_name;
 
-               cache = evas_common_font_cache_get();
-               evas_common_font_cache_set(0);
-               evas_common_font_flush();
+       font_name = vconf_get_str("db/setting/accessibility/font_name");
+       if (!font_name) {
+               ErrPrint("Invalid font name (NULL)\n");
+               return;
+       }
 
-               list = edje_text_class_list();
-               EINA_LIST_FREE(list, text) {
-                       if (!strncasecmp(text, TEXT_CLASS, strlen(TEXT_CLASS))) {
-                               edje_text_class_del(text);
-                               edje_text_class_set(text, s_info.font, s_info.size);
-                               DbgPrint("Update text class %s (%s, %d)\n", text, s_info.font, s_info.size);
-                       } else {
-                               DbgPrint("Skip text class %s\n", text);
-                       }
-               }
+       if (s_info.font_name && !strcmp(s_info.font_name, font_name)) {
+               DbgPrint("Font is not changed (Old: %s(%p) <> New: %s(%p))\n", s_info.font_name, s_info.font_name, font_name, font_name);
+               free(font_name);
+               return;
+       }
 
-               evas_common_font_cache_set(cache);
+       if (s_info.font_name) {
+               DbgPrint("Release old font name: %s(%p)\n", s_info.font_name, s_info.font_name);
+               free(s_info.font_name);
+               s_info.font_name = NULL;
        }
 
-       return ECORE_CALLBACK_PASS_ON;
+       s_info.font_name = font_name;
+       DbgPrint("Font name is changed to %s(%p)\n", s_info.font_name, s_info.font_name);
+
+       /*!
+        * \NOTE
+        * Try to update all liveboxes
+        */
+       update_font_cb(NULL);
 }
 
-static void font_name_cb(keynode_t *node, void *user_data)
+static inline int convert_font_size(int size)
 {
-       const char *font;
+       switch (size) {
+       case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
+               size = -80;
+               break;
+       case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
+               size = -100;
+               break;
+       case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
+               size = -150;
+               break;
+       case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
+               size = -190;
+               break;
+       case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
+               size = -250;
+               break;
+       default:
+               size = -100;
+               break;
+       }
 
-       if (!node)
-               return;
+       DbgPrint("Return size: %d\n", size);
+       return size;
+}
+
+static void font_size_cb(system_settings_key_e key, void *user_data)
+{
+       int size;
 
-       font = vconf_keynode_get_str(node);
-       if (!font)
+       if (system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size) != SYSTEM_SETTINGS_ERROR_NONE)
                return;
 
-       DbgPrint("Font changed to %s\n", font);
-}
+       size = convert_font_size(size);
 
-static void font_size_cb(keynode_t *node, void *user_data)
-{
-       if (!node)
+       if (size == s_info.font_size) {
+               DbgPrint("Font size is not changed\n");
                return;
-       /*!
-        * \TODO
-        * Implementing me.
-        */
-       DbgPrint("Size type: %d\n", vconf_keynode_get_int(node));
+       }
+
+       s_info.font_size = size;
+       DbgPrint("Font size is changed to %d\n", size);
+
+       update_font_cb(NULL);
 }
 
-int script_init(void)
+PUBLIC int script_init(void)
 {
        int ret;
+       int size = DEFAULT_FONT_SIZE;
+       char *argv[] = {
+               "livebox.edje",
+               NULL,
+       };
        /* ecore is already initialized */
-       edje_init();
+       elm_init(1, argv);
+       elm_config_scale_set(scale_get());
 
-       s_info.property_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, property_cb, NULL);
-       if (!s_info.property_handler)
-               ErrPrint("Failed to add a property change event handler\n");
-
-       ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, font_size_cb, NULL);
+       ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, access_cb, NULL);
        if (ret < 0)
-               ErrPrint("Failed to add vconf for font size change\n");
+               ErrPrint("Failed to access cb\n");
 
-       ret = vconf_notify_key_changed("db/setting/accessibility/font_name", font_name_cb, NULL);
-       if (ret < 0)
-               ErrPrint("Failed to add vconf for font name change\n");
+       access_cb(NULL, NULL);
+
+       ret = vconf_notify_key_changed("db/setting/accessibility/font_name", font_changed_cb, NULL);
+       DbgPrint("System font is changed: %d\n", ret);
+       
+       ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, font_size_cb, NULL);
+       DbgPrint("System font size is changed: %d\n", ret);
+
+       s_info.font_name = vconf_get_str("db/setting/accessibility/font_name");
+       DbgPrint("Current font: %s\n", s_info.font_name);
 
-       return 0;
+       ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size);
+       s_info.font_size = convert_font_size(size);
+       DbgPrint("Current size: %d\n", s_info.font_size);
+
+       return LB_STATUS_SUCCESS;
 }
 
-int script_fini(void)
+PUBLIC int script_fini(void)
 {
-
-       vconf_ignore_key_changed("db/setting/accessibility/font_name", font_name_cb);
-       vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, font_size_cb);
-       ecore_event_handler_del(s_info.property_handler);
-       s_info.property_handler = NULL;
-       edje_shutdown();
-       return 0;
+       int ret;
+       ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE);
+       ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE);
+       ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, access_cb);
+       elm_shutdown();
+       return LB_STATUS_SUCCESS;
 }
 
 /* End of a file */