Various patches are applied
[apps/livebox/livebox-viewer.git] / src / livebox.c
index 6ca3adc..0ceae6f 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,
@@ -26,6 +26,7 @@
 #include <com-core_packet.h>
 #include <packet.h>
 #include <livebox-service.h>
+#include <livebox-errno.h>
 
 #include "debug.h"
 #include "fb.h"
@@ -115,6 +116,16 @@ static inline void default_lb_size_changed_cb(struct livebox *handler, int ret,
        DbgPrint("Default LB size changed event handler: %d\n", ret);
 }
 
+static inline void default_update_mode_cb(struct livebox *handler, int ret, void *data)
+{
+       DbgPrint("Default update mode set event handler: %d\n", ret);
+}
+
+static inline void default_access_event_cb(struct livebox *handler, int ret, void *data)
+{
+       DbgPrint("Default access event handler: %d\n", ret);
+}
+
 static inline __attribute__((always_inline)) struct cb_info *create_cb_info(ret_cb_t cb, void *data)
 {
        struct cb_info *info;
@@ -135,6 +146,33 @@ static inline void destroy_cb_info(struct cb_info *info)
        free(info);
 }
 
+static void update_mode_cb(struct livebox *handler, const struct packet *result, void *data)
+{
+       int ret;
+
+       if (!result) {
+               ret = LB_STATUS_ERROR_FAULT;
+               goto errout;
+       } else if (packet_get(result, "i", &ret) != 1) {
+               ErrPrint("Invalid argument\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto errout;
+       }
+
+       if (ret < 0) {
+               DbgPrint("Resize request is failed: %d\n", ret);
+               goto errout;
+       }
+
+       return;
+
+errout:
+       handler->update_mode_cb(handler, ret, handler->update_mode_cbdata);
+       handler->update_mode_cb = NULL;
+       handler->update_mode_cbdata = NULL;
+       return;
+}
+
 static void resize_cb(struct livebox *handler, const struct packet *result, void *data)
 {
        int ret;
@@ -147,10 +185,12 @@ static void resize_cb(struct livebox *handler, const struct packet *result, void
        destroy_cb_info(info);
 
        if (!result) {
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
+               goto errout;
        } else if (packet_get(result, "i", &ret) != 1) {
                ErrPrint("Invalid argument\n");
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
+               goto errout;
        }
 
        /*!
@@ -162,14 +202,18 @@ static void resize_cb(struct livebox *handler, const struct packet *result, void
         * So the user can only get the resized value(result) from the first update event
         * after this request.
         */
-       if (ret == 0) {
-               DbgPrint("Resize request is done, prepare the size changed event\n");
-               handler->size_changed_cb = cb;
-               handler->size_cbdata = cbdata;
-       } else {
+       if (ret < 0) {
                DbgPrint("Resize request is failed: %d\n", ret);
-               cb(handler, ret, cbdata);
+               goto errout;
        }
+
+       DbgPrint("Resize request is successfully sent\n");
+       return;
+
+errout:
+       handler->size_changed_cb(handler, ret, handler->size_cbdata);
+       handler->size_changed_cb = NULL;
+       handler->size_cbdata = NULL;
 }
 
 static void text_signal_cb(struct livebox *handler, const struct packet *result, void *data)
@@ -184,10 +228,10 @@ static void text_signal_cb(struct livebox *handler, const struct packet *result,
        destroy_cb_info(info);
 
        if (!result) {
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
        } else if (packet_get(result, "i", &ret) != 1) {
                ErrPrint("Invalid argument\n");
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
        }
 
        if (cb)
@@ -198,55 +242,50 @@ static void text_signal_cb(struct livebox *handler, const struct packet *result,
 static void set_group_ret_cb(struct livebox *handler, const struct packet *result, void *data)
 {
        int ret;
-       void *cbdata;
-       ret_cb_t cb;
-       struct cb_info *info = data;
-
-       cbdata = info->data;
-       cb = info->cb;
-       destroy_cb_info(info);
 
        if (!result) {
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
+               goto errout;
        } else if (packet_get(result, "i", &ret) != 1) {
                ErrPrint("Invalid argument\n");
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
+               goto errout;
        }
 
-       if (ret == 0) { /*!< Group information is successfully changed */
-               handler->group_changed_cb = cb;
-               handler->group_cbdata = cbdata;
-       } else if (cb) {
-               cb(handler, ret, cbdata);
-       }
+       if (ret < 0)
+               goto errout;
 
        return;
+
+errout:
+       handler->group_changed_cb(handler, ret, handler->group_cbdata);
+       handler->group_changed_cb = NULL;
+       handler->group_cbdata = NULL;
 }
 
 static void period_ret_cb(struct livebox *handler, const struct packet *result, void *data)
 {
-       struct cb_info *info = data;
        int ret;
-       ret_cb_t cb;
-       void *cbdata;
-
-       cb = info->cb;
-       cbdata = info->data;
-       destroy_cb_info(info);
 
        if (!result) {
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
+               goto errout;
        } else if (packet_get(result, "i", &ret) != 1) {
                ErrPrint("Invalid argument\n");
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
+               goto errout;
        }
 
-       if (ret == 0) {
-               handler->period_changed_cb = cb;
-               handler->period_cbdata = cbdata;
-       } else if (cb) {
-               cb(handler, ret, cbdata);
-       }
+       if (ret < 0)
+               goto errout;
+
+       DbgPrint("Succeed to send period change request, waiting result\n");
+       return;
+
+errout:
+       handler->period_changed_cb(handler, ret, handler->period_cbdata);
+       handler->period_changed_cb = NULL;
+       handler->period_cbdata = NULL;
 }
 
 static void del_ret_cb(struct livebox *handler, const struct packet *result, void *data)
@@ -262,10 +301,10 @@ static void del_ret_cb(struct livebox *handler, const struct packet *result, voi
 
        if (!result) {
                ErrPrint("Connection lost?\n");
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
        } else if (packet_get(result, "i", &ret) != 1) {
                ErrPrint("Invalid argument\n");
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
        }
 
        if (ret == 0) {
@@ -299,9 +338,9 @@ static void new_ret_cb(struct livebox *handler, const struct packet *result, voi
        destroy_cb_info(info);
 
        if (!result) {
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
        } else if (packet_get(result, "i", &ret) != 1) {
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
        }
 
        if (ret >= 0) {
@@ -329,29 +368,27 @@ static void new_ret_cb(struct livebox *handler, const struct packet *result, voi
 
 static void pd_create_cb(struct livebox *handler, const struct packet *result, void *data)
 {
-       struct cb_info *info = data;
-       void *cbdata;
-       ret_cb_t cb;
        int ret;
 
-       cb = info->cb;
-       cbdata = info->data;
-       destroy_cb_info(data);
-
        if (!result) {
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
+               goto errout;
        } else if (packet_get(result, "i", &ret) != 1) {
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
+               goto errout;
        }
 
-       if (ret == 0) {
-               DbgPrint("PD Created event handler prepared\n");
-               handler->pd_created_cb = cb;
-               handler->pd_created_cbdata = cbdata;
-       } else if (cb) {
+       if (ret < 0) {
                DbgPrint("Failed to create a PD\n");
-               cb(handler, ret, cbdata);
+               goto errout;
        }
+
+       return;
+
+errout:
+       handler->pd_created_cb(handler, ret, handler->pd_created_cbdata);
+       handler->pd_created_cb = NULL;
+       handler->pd_created_cbdata = NULL;
 }
 
 static void activated_cb(struct livebox *handler, const struct packet *result, void *data)
@@ -367,9 +404,9 @@ static void activated_cb(struct livebox *handler, const struct packet *result, v
        destroy_cb_info(info);
 
        if (!result) {
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
        } else if (packet_get(result, "is", &ret, &pkgname) != 2) {
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
        }
 
        if (cb)
@@ -389,10 +426,10 @@ static void pd_destroy_cb(struct livebox *handler, const struct packet *result,
 
        if (!result) {
                DbgPrint("Result is NIL (may connection lost)\n");
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
        } else if (packet_get(result, "i", &ret) != 1) {
                DbgPrint("Invalid parameter\n");
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
        }
 
        if (ret == 0) {
@@ -418,9 +455,9 @@ static void delete_cluster_cb(struct livebox *handler, const struct packet *resu
        destroy_cb_info(info);
 
        if (!result) {
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
        } else if (packet_get(result, "i", &ret) != 1) {
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
        }
 
        DbgPrint("Delete category returns: %d\n", ret);
@@ -441,9 +478,9 @@ static void delete_category_cb(struct livebox *handler, const struct packet *res
        destroy_cb_info(info);
 
        if (!result)
-               ret = -EFAULT;
+               ret = LB_STATUS_ERROR_FAULT;
        else if (packet_get(result, "i", &ret) != 1)
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
 
        DbgPrint("Delete category returns: %d\n", ret);
 
@@ -474,40 +511,85 @@ static void pixmap_acquired_cb(struct livebox *handler, const struct packet *res
 static void pinup_done_cb(struct livebox *handler, const struct packet *result, void *data)
 {
        int ret;
-       ret_cb_t cb;
-       void *cbdata;
-       struct cb_info *info = data;
 
-       cb = info->cb;
-       cbdata = info->data;
-       destroy_cb_info(info);
+       if (!result) {
+               ret = LB_STATUS_ERROR_FAULT;
+               goto errout;
+       } else if (packet_get(result, "i", &ret) != 1) {
+               goto errout;
+       }
 
-       if (!result)
-               ret = -EFAULT;
-       else if (packet_get(result, "i", &ret) != 1)
-               ret = -EINVAL;
+       if (ret < 0)
+               goto errout;
 
-       if (ret == 0) {
-               handler->pinup_cb = cb;
-               handler->pinup_cbdata = cbdata;
-       } else if (cb) {
-               cb(handler, ret, cbdata);
+       return;
+
+errout:
+       handler->pinup_cb(handler, ret, handler->pinup_cbdata);
+       handler->pinup_cb = NULL;
+       handler->pinup_cbdata = NULL;
+}
+
+static void access_ret_cb(struct livebox *handler, const struct packet *result, void *data)
+{
+       int ret;
+
+       if (!result) {
+               ret = LB_STATUS_ERROR_FAULT;
+               return;
+       }
+
+       if (packet_get(result, "i", &ret) != 1) {
+               ret = LB_STATUS_ERROR_INVALID;
+               return;
+       }
+
+       if (ret != LB_STATUS_SUCCESS) {
+               goto errout;
+       }
+
+       DbgPrint("Access event is successfully sent. waiting result\n");
+       return;
+
+errout:
+       handler->access_event_cb(handler, ret, handler->access_event_cbdata);
+       handler->access_event_cb = NULL;
+       handler->access_event_cbdata = NULL;
+       return;
+}
+
+static int send_access_event(struct livebox *handler, const char *event, int x, int y)
+{
+       struct packet *packet;
+       double timestamp;
+
+       timestamp = util_timestamp();
+
+       packet = packet_create(event, "ssdii", handler->pkgname, handler->id, timestamp, x, y);
+       if (!packet) {
+               ErrPrint("Failed to build packet\n");
+               return LB_STATUS_ERROR_FAULT;
        }
+
+       DbgPrint("Send: %dx%d\n", x, y);
+
+       return master_rpc_async_request(handler, packet, 0, access_ret_cb, NULL);
 }
 
-static int send_mouse_event(struct livebox *handler, const char *event, double x, double y, int w, int h)
+static int send_mouse_event(struct livebox *handler, const char *event, int x, int y)
 {
        struct packet *packet;
        double timestamp;
 
        timestamp = util_timestamp();
-       packet = packet_create_noack(event, "ssiiddd", handler->pkgname, handler->id, w, h,
-                                               timestamp, x, y);
+       packet = packet_create_noack(event, "ssdii", handler->pkgname, handler->id, timestamp, x, y);
        if (!packet) {
                ErrPrint("Failed to build param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
+       DbgPrint("Send: %dx%d\n", x, y);
+
        return master_rpc_request_only(handler, packet);
 }
 
@@ -517,7 +599,7 @@ EAPI int livebox_init(void *disp)
 
        if (s_info.init_count > 0) {
                s_info.init_count++;
-               return 0;
+               return LB_STATUS_SUCCESS;
        }
        env = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
        if (env && !strcasecmp(env, "true"))
@@ -541,27 +623,27 @@ EAPI int livebox_init(void *disp)
        client_init();
 
        s_info.init_count++;
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI int livebox_fini(void)
 {
        if (s_info.init_count <= 0) {
                DbgPrint("Didn't initialized\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        s_info.init_count--;
        if (s_info.init_count > 0) {
                DbgPrint("init count : %d\n", s_info.init_count);
-               return 0;
+               return LB_STATUS_SUCCESS;
        }
 
        client_fini();
        fb_fini();
        livebox_service_fini();
        critical_log_fini();
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 static inline char *lb_pkgname(const char *pkgname)
@@ -592,8 +674,9 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont
        int ret;
        int width = 0;
        int height = 0;
+       struct cb_info *cbinfo;
 
-       if (!pkgname || !cluster || !category || width < 0 || height < 0) {
+       if (!pkgname || !cluster || !category) {
                ErrPrint("Invalid arguments: pkgname[%p], cluster[%p], category[%p]\n",
                                                                pkgname, cluster, category);
                return NULL;
@@ -610,7 +693,6 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont
 
        handler->pkgname = lb_pkgname(pkgname);
        if (!handler->pkgname) {
-               ErrPrint("Error: %s\n", strerror(errno));
                free(handler);
                return NULL;
        }
@@ -684,9 +766,22 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont
                return NULL;
        }
 
-       ret = master_rpc_async_request(handler, packet, 0, new_ret_cb, create_cb_info(cb, data));
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               ErrPrint("Failed to create a cbinfo\n");
+               packet_destroy(packet);
+               free(handler->category);
+               free(handler->cluster);
+               free(handler->content);
+               free(handler->pkgname);
+               free(handler);
+               return NULL;
+       }
+
+       ret = master_rpc_async_request(handler, packet, 0, new_ret_cb, cbinfo);
        if (ret < 0) {
                ErrPrint("Failed to send a new packet\n");
+               destroy_cb_info(cbinfo);
                free(handler->category);
                free(handler->cluster);
                free(handler->content);
@@ -713,47 +808,59 @@ EAPI double livebox_period(struct livebox *handler)
 EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       int ret;
 
        if (!handler || handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (handler->period_changed_cb) {
+               ErrPrint("Previous request for changing period is not finished\n");
+               return LB_STATUS_ERROR_BUSY;
        }
 
        if (!handler->is_user) {
                ErrPrint("CA Livebox is not able to change the period\n");
-               return -EPERM;
+               return LB_STATUS_ERROR_PERMISSION;
        }
 
        if (handler->lb.period == period) {
                DbgPrint("No changes\n");
-               return -EALREADY;
+               return LB_STATUS_ERROR_ALREADY;
        }
 
-       if (handler->period_changed_cb)
-               DbgPrint("Already requested\n");
-
        packet = packet_create("set_period", "ssd", handler->pkgname, handler->id, period);
        if (!packet) {
                ErrPrint("Failed to build a packet %s\n", handler->pkgname);
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (!cb)
                cb = default_period_changed_cb;
 
-       return master_rpc_async_request(handler, packet, 0, period_ret_cb, create_cb_info(cb, data));
+       handler->period_changed_cb = cb;
+       handler->period_cbdata = data;
+
+       ret = master_rpc_async_request(handler, packet, 0, period_ret_cb, NULL);
+       if (ret < 0) {
+               handler->period_changed_cb = NULL;
+               handler->period_cbdata = NULL;
+       }
+
+       return ret;
 }
 
 EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE) {
                ErrPrint("Handler is already deleted\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        handler->state = DELETE;
@@ -770,7 +877,7 @@ EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data)
                 */
                if (cb)
                        cb(handler, 0, data);
-               return 0;
+               return LB_STATUS_SUCCESS;
        }
 
        if (!cb)
@@ -784,19 +891,19 @@ EAPI int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char
        struct fault_info *info;
 
        if (!cb)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        info = malloc(sizeof(*info));
        if (!info) {
                CRITICAL_LOG("Heap: %s\n", strerror(errno));
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
        info->handler = cb;
        info->user_data = data;
 
        s_info.fault_list = dlist_append(s_info.fault_list, info);
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI void *livebox_unset_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *))
@@ -824,20 +931,20 @@ EAPI int livebox_set_event_handler(int (*cb)(struct livebox *, enum livebox_even
 
        if (!cb) {
                ErrPrint("Invalid argument cb is nil\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        info = malloc(sizeof(*info));
        if (!info) {
                CRITICAL_LOG("Heap: %s\n", strerror(errno));
-               return -ENOMEM;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
        info->handler = cb;
        info->user_data = data;
 
        s_info.event_list = dlist_append(s_info.event_list, info);
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI void *livebox_unset_event_handler(int (*cb)(struct livebox *, enum livebox_event_type, void *))
@@ -860,50 +967,118 @@ EAPI void *livebox_unset_event_handler(int (*cb)(struct livebox *, enum livebox_
        return NULL;
 }
 
+EAPI int livebox_set_update_mode(struct livebox *handler, int active_update, ret_cb_t cb, void *data)
+{
+       struct packet *packet;
+       int ret;
+
+       if (!handler) {
+               ErrPrint("Handler is NIL\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (handler->state != CREATE || !handler->id)
+               return LB_STATUS_ERROR_INVALID;
+
+       if (handler->update_mode_cb) {
+               ErrPrint("Previous update_mode cb is not finished yet\n");
+               return LB_STATUS_ERROR_BUSY;
+       }
+
+       if (handler->is_active_update == active_update)
+               return LB_STATUS_ERROR_ALREADY;
+
+       if (!handler->is_user)
+               return LB_STATUS_ERROR_PERMISSION;
+
+       packet = packet_create("update_mode", "ssi", handler->pkgname, handler->id, active_update);
+       if (!packet)
+               return LB_STATUS_ERROR_FAULT;
+
+       if (!cb)
+               cb = default_update_mode_cb;
+
+       handler->update_mode_cb = cb;
+       handler->update_mode_cbdata = data;
+
+       ret = master_rpc_async_request(handler, packet, 0, update_mode_cb, NULL);
+       if (ret < 0) {
+               handler->update_mode_cb = NULL;
+               handler->update_mode_cbdata = NULL;
+       }
+
+       return ret;
+}
+
+EAPI int livebox_is_active_update(struct livebox *handler)
+{
+       if (!handler) {
+               ErrPrint("Handler is NIL\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (handler->state != CREATE || !handler->id)
+               return LB_STATUS_ERROR_INVALID;
+
+       return handler->is_active_update;
+}
+
 EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *data)
 {
        struct packet *packet;
        int w;
        int h;
+       int ret;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (handler->size_changed_cb) {
+               ErrPrint("Previous resize request is not finished yet\n");
+               return LB_STATUS_ERROR_BUSY;
        }
 
        if (!handler->is_user) {
                ErrPrint("CA Livebox is not able to be resized\n");
-               return -EPERM;
+               return LB_STATUS_ERROR_PERMISSION;
        }
 
        if (livebox_service_get_size(type, &w, &h) != 0) {
                ErrPrint("Invalid size type\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->lb.width == w && handler->lb.height == h) {
                DbgPrint("No changes\n");
-               return -EALREADY;
+               return LB_STATUS_ERROR_ALREADY;;
        }
 
-       if (handler->size_changed_cb)
-               DbgPrint("Already pended\n");
-
        packet = packet_create("resize", "ssii", handler->pkgname, handler->id, w, h);
        if (!packet) {
                ErrPrint("Failed to build param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (!cb)
                cb = default_lb_size_changed_cb;
 
-       return master_rpc_async_request(handler, packet, 0, resize_cb, create_cb_info(cb, data));
+       handler->size_changed_cb = cb;
+       handler->size_cbdata = data;
+
+       ret = master_rpc_async_request(handler, packet, 0, resize_cb, NULL);
+       if (ret < 0) {
+               handler->size_changed_cb = NULL;
+               handler->size_cbdata = NULL;
+       }
+
+       return ret;
 }
 
 EAPI int livebox_click(struct livebox *handler, double x, double y)
@@ -914,38 +1089,41 @@ EAPI int livebox_click(struct livebox *handler, double x, double y)
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
-       if (handler->lb.auto_launch)
+       if (handler->lb.auto_launch) {
+               DbgPrint("Auto-launch enabled: %s\n", handler->lb.auto_launch);
                if (aul_launch_app(handler->lb.auto_launch, NULL) < 0)
                        ErrPrint("Failed to launch app %s\n", handler->lb.auto_launch);
+       }
 
        timestamp = util_timestamp();
        packet = packet_create_noack("clicked", "sssddd", handler->pkgname, handler->id, "clicked", timestamp, x, y);
        if (!packet) {
                ErrPrint("Failed to build param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        ret = master_rpc_request_only(handler, packet);
+       DbgPrint("Click request: %d\n", ret);
 
        if (!handler->lb.mouse_event && (handler->lb.type == _LB_TYPE_BUFFER || handler->lb.type == _LB_TYPE_SCRIPT)) {
                int ret; /* Shadow variable */
-               ret = send_mouse_event(handler, "lb_mouse_down", x, y, handler->lb.width, handler->lb.height);
+               ret = send_mouse_event(handler, "lb_mouse_down", x * handler->lb.width, y * handler->lb.height);
                if (ret < 0)
                        DbgPrint("Failed to send Down: %d\n", ret);
 
-               ret = send_mouse_event(handler, "lb_mouse_move", x, y, handler->lb.width, handler->lb.height);
+               ret = send_mouse_event(handler, "lb_mouse_move", x * handler->lb.width, y * handler->lb.height);
                if (ret < 0)
                        DbgPrint("Failed to send Move: %d\n", ret);
 
-               ret = send_mouse_event(handler, "lb_mouse_up", x, y, handler->lb.width, handler->lb.height);
+               ret = send_mouse_event(handler, "lb_mouse_up", x * handler->lb.width, y * handler->lb.height);
                if (ret < 0)
                        DbgPrint("Failed to send Up: %d\n", ret);
        }
@@ -957,12 +1135,12 @@ EAPI int livebox_has_pd(struct livebox *handler)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        return !!handler->pd.data.fb;
@@ -972,12 +1150,12 @@ EAPI int livebox_pd_is_created(struct livebox *handler)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        return handler->is_pd_created;
@@ -991,167 +1169,327 @@ EAPI int livebox_create_pd(struct livebox *handler, ret_cb_t cb, void *data)
 EAPI int livebox_create_pd_with_position(struct livebox *handler, double x, double y, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       int ret;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->is_pd_created == 1) {
                DbgPrint("PD already created\n");
-               return 0;
+               return LB_STATUS_SUCCESS;
+       }
+
+       if (handler->pd_created_cb) {
+               ErrPrint("Previous request is not completed yet\n");
+               return LB_STATUS_ERROR_BUSY;
        }
 
        packet = packet_create("create_pd", "ssdd", handler->pkgname, handler->id, x, y);
        if (!packet) {
                ErrPrint("Failed to build param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (!cb)
-               handler->pd_created_cb = default_pd_created_cb;
+               cb = default_pd_created_cb;
+
+       handler->pd_created_cb = cb;
+       handler->pd_created_cbdata = data;
+
+       ret = master_rpc_async_request(handler, packet, 0, pd_create_cb, NULL);
+       if (ret < 0) {
+               handler->pd_created_cb = NULL;
+               handler->pd_created_cbdata = NULL;
+       }
+
+       return ret;
+}
+
+EAPI int livebox_move_pd(struct livebox *handler, double x, double y)
+{
+       struct packet *packet;
+
+       if (!handler) {
+               ErrPrint("Handler is NIL\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
+               ErrPrint("Handler is not valid\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (!handler->is_pd_created) {
+               DbgPrint("PD is not created\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
 
-       return master_rpc_async_request(handler, packet, 0, pd_create_cb, create_cb_info(cb, data));
+       packet = packet_create_noack("pd_move", "ssdd", handler->pkgname, handler->id, x, y);
+       if (!packet) {
+               ErrPrint("Failed to build param\n");
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       return master_rpc_request_only(handler, packet);
 }
 
 EAPI int livebox_activate(const char *pkgname, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       struct cb_info *cbinfo;
+       int ret;
 
        if (!pkgname)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        packet = packet_create("activate_package", "s", pkgname);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       return master_rpc_async_request(NULL, packet, 0, activated_cb, create_cb_info(cb, data));
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               ErrPrint("Unable to create cbinfo\n");
+               packet_destroy(packet);
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       ret = master_rpc_async_request(NULL, packet, 0, activated_cb, cbinfo);
+       if (ret < 0)
+               destroy_cb_info(cbinfo);
+
+       return ret;
 }
 
 EAPI int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       struct cb_info *cbinfo;
+       int ret;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!handler->is_pd_created) {
                ErrPrint("PD is not created\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        packet = packet_create("destroy_pd", "ss", handler->pkgname, handler->id);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (!cb)
                cb = default_pd_destroyed_cb;
 
-       return master_rpc_async_request(handler, packet, 0, pd_destroy_cb, create_cb_info(cb, data));
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               packet_destroy(packet);
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       ret = master_rpc_async_request(handler, packet, 0, pd_destroy_cb, cbinfo);
+       if (ret < 0)
+               destroy_cb_info(cbinfo);
+
+       return ret;
+}
+
+EAPI int livebox_access_event(struct livebox *handler, enum access_event_type type, double x, double y, ret_cb_t cb, void *data)
+{
+       int w = 1;
+       int h = 1;
+       char cmd[32] = { '\0', };
+       char *ptr = cmd;
+       int ret;
+
+       if (!handler) {
+               ErrPrint("Handler is NIL\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (handler->state != CREATE || !handler->id) {
+               ErrPrint("Handler is not valid\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (handler->access_event_cb) {
+               ErrPrint("Previous access event is not yet done\n");
+               return LB_STATUS_ERROR_BUSY;
+       }
+
+       if (type & ACCESS_EVENT_PD_MASK) {
+               if (!handler->is_pd_created) {
+                       ErrPrint("PD is not created\n");
+                       return LB_STATUS_ERROR_INVALID;
+               }
+               *ptr++ = 'p';
+               *ptr++ = 'd';
+               w = handler->pd.width;
+               h = handler->pd.height;
+       } else if (type & ACCESS_EVENT_LB_MASK) {
+               *ptr++ = 'l';
+               *ptr++ = 'b';
+               w = handler->lb.width;
+               h = handler->lb.height;
+       } else {
+               ErrPrint("Invalid event type\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       switch (type & ~ACCESS_EVENT_PD_MASK) {
+       case ACCESS_EVENT_HIGHLIGHT:
+               strcpy(ptr, "_access_hl");
+               break;
+       case ACCESS_EVENT_HIGHLIGHT_NEXT:
+               strcpy(ptr, "_access_hl_next");
+               break;
+       case ACCESS_EVENT_HIGHLIGHT_PREV:
+               strcpy(ptr, "_access_hl_prev");
+               break;
+       case ACCESS_EVENT_ACTIVATE:
+               strcpy(ptr, "_access_activate");
+               break;
+       case ACCESS_EVENT_ACTION_DOWN:
+               strcpy(ptr, "_access_action_down");
+               break;
+       case ACCESS_EVENT_ACTION_UP:
+               strcpy(ptr, "_access_action_up");
+               break;
+       case ACCESS_EVENT_UNHIGHLIGHT:
+               strcpy(ptr, "_access_unhighlight");
+               break;
+       case ACCESS_EVENT_SCROLL_DOWN:
+               strcpy(ptr, "_access_scroll_down");
+               break;
+       case ACCESS_EVENT_SCROLL_MOVE:
+               strcpy(ptr, "_access_scroll_move");
+               break;
+       case ACCESS_EVENT_SCROLL_UP:
+               strcpy(ptr, "_access_scroll_up");
+               break;
+       default:
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (!cb)
+               cb = default_access_event_cb;
+
+       handler->access_event_cb = cb;
+       handler->access_event_cbdata = data;
+
+       ret = send_access_event(handler, cmd, x * w, y * h);
+       if (ret < 0) {
+               handler->access_event_cb = NULL;
+               handler->access_event_cbdata = NULL;
+       }
+
+       return ret;
 }
 
 EAPI int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y)
 {
-       int w;
-       int h;
-       char cmd[20] = { '\0', };
+       int w = 1;
+       int h = 1;
+       char cmd[32] = { '\0', };
        char *ptr = cmd;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (type & CONTENT_EVENT_PD_MASK) {
+               int flag = 1;
+
                if (!handler->is_pd_created) {
                        ErrPrint("PD is not created\n");
-                       return -EINVAL;
+                       return LB_STATUS_ERROR_INVALID;
                }
 
                if (type & CONTENT_EVENT_MOUSE_MASK) {
                        if (!handler->pd.data.fb) {
                                ErrPrint("Handler is not valid\n");
-                               return -EINVAL;
+                               return LB_STATUS_ERROR_INVALID;
                        }
 
                        if (type & CONTENT_EVENT_MOUSE_MOVE) {
                                if (fabs(x - handler->pd.x) < MINIMUM_EVENT && fabs(y - handler->pd.y) < MINIMUM_EVENT)
-                                       return -EBUSY;
+                                       return LB_STATUS_ERROR_BUSY;
+                       } else if (type & CONTENT_EVENT_MOUSE_SET) {
+                               flag = 0;
                        }
                }
 
-               w = handler->pd.width;
-               h = handler->pd.height;
-               handler->pd.x = x;
-               handler->pd.y = y;
+               if (flag) {
+                       w = handler->pd.width;
+                       h = handler->pd.height;
+                       handler->pd.x = x;
+                       handler->pd.y = y;
+               }
                *ptr++ = 'p';
                *ptr++ = 'd';
-       } else {
+       } else if (type & CONTENT_EVENT_LB_MASK) {
+               int flag = 1;
+
                if (type & CONTENT_EVENT_MOUSE_MASK) {
                        if (!handler->lb.mouse_event) {
                                ErrPrint("Box is not support the mouse event\n");
-                               return -EINVAL;
+                               return LB_STATUS_ERROR_INVALID;
                        }
 
                        if (!handler->lb.data.fb) {
                                ErrPrint("Handler is not valid\n");
-                               return -EINVAL;
+                               return LB_STATUS_ERROR_INVALID;
                        }
 
                        if (type & CONTENT_EVENT_MOUSE_MOVE) {
                                if (fabs(x - handler->lb.x) < MINIMUM_EVENT && fabs(y - handler->lb.y) < MINIMUM_EVENT)
-                                       return -EBUSY;
+                                       return LB_STATUS_ERROR_BUSY;
+                       } else if (type & CONTENT_EVENT_MOUSE_SET) {
+                               flag = 0;
                        }
                }
 
-               w = handler->lb.width;
-               h = handler->lb.height;
-               handler->lb.x = x;
-               handler->lb.y = y;
+               if (flag) {
+                       w = handler->lb.width;
+                       h = handler->lb.height;
+                       handler->lb.x = x;
+                       handler->lb.y = y;
+               }
                *ptr++ = 'l';
                *ptr++ = 'b';
+       } else {
+               ErrPrint("Invalid event type\n");
+               return LB_STATUS_ERROR_INVALID;
        }
 
-       switch ((type & ~CONTENT_EVENT_PD_MASK)) {
-       case CONTENT_EVENT_ACCESS_READ | CONTENT_EVENT_ACCESS_MASK:
-               strcpy(ptr, "_access_read");
-               break;
-       case CONTENT_EVENT_ACCESS_READ_PREV | CONTENT_EVENT_ACCESS_MASK:
-               strcpy(ptr, "_access_read_prev");
-               break;
-       case CONTENT_EVENT_ACCESS_READ_NEXT | CONTENT_EVENT_ACCESS_MASK:
-               strcpy(ptr, "_access_read_next");
-               break;
-       case CONTENT_EVENT_ACCESS_ACTIVATE | CONTENT_EVENT_ACCESS_MASK:
-               strcpy(ptr, "_access_activate");
-               break;
-       case CONTENT_EVENT_ACCESS_UP | CONTENT_EVENT_ACCESS_MASK:
-               strcpy(ptr, "_access_up");
-               break;
-       case CONTENT_EVENT_ACCESS_DOWN | CONTENT_EVENT_ACCESS_MASK:
-               strcpy(ptr, "_access_down");
-               break;
+       /*!
+        * Must be short than 29 bytes.
+        */
+       switch ((type & ~(CONTENT_EVENT_PD_MASK | CONTENT_EVENT_LB_MASK))) {
        case CONTENT_EVENT_MOUSE_ENTER | CONTENT_EVENT_MOUSE_MASK:
                strcpy(ptr, "_mouse_enter");
                break;
@@ -1167,6 +1505,12 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type
        case CONTENT_EVENT_MOUSE_MOVE | CONTENT_EVENT_MOUSE_MASK:
                strcpy(ptr, "_mouse_move");
                break;
+       case CONTENT_EVENT_MOUSE_SET | CONTENT_EVENT_MOUSE_MASK:
+               strcpy(ptr, "_mouse_set");
+               break;
+       case CONTENT_EVENT_MOUSE_UNSET | CONTENT_EVENT_MOUSE_MASK:
+               strcpy(ptr, "_mouse_unset");
+               break;
        case CONTENT_EVENT_KEY_DOWN | CONTENT_EVENT_KEY_MASK:
                strcpy(ptr, "_key_down");
                break;
@@ -1175,10 +1519,10 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type
                break;
        default:
                ErrPrint("Invalid event type\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
-       return send_mouse_event(handler, cmd, x, y, w, h);
+       return send_mouse_event(handler, cmd, x * w, y * h);
 }
 
 EAPI const char *livebox_filename(struct livebox *handler)
@@ -1207,12 +1551,12 @@ EAPI int livebox_get_pdsize(struct livebox *handler, int *w, int *h)
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!w)
@@ -1220,23 +1564,16 @@ EAPI int livebox_get_pdsize(struct livebox *handler, int *w, int *h)
        if (!h)
                h = &_h;
 
-       *w = handler->pd.width;
-       *h = handler->pd.height;
-
-       switch (handler->pd.type) {
-       case _PD_TYPE_BUFFER:
-       case _PD_TYPE_SCRIPT:
-               if (!handler->is_pd_created) {
-                       DbgPrint("Buffer is not created yet - reset size\n");
-                       *w = 0;
-                       *h = 0;
-               }
-               break;
-       default:
-               break;
+       if (!handler->is_pd_created) {
+               DbgPrint("Buffer is not created yet [%dx%d]\n", *w, *h);
+               *w = handler->pd.default_width;
+               *h = handler->pd.default_height;
+       } else {
+               *w = handler->pd.width;
+               *h = handler->pd.height;
        }
 
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI int livebox_size(struct livebox *handler)
@@ -1246,12 +1583,12 @@ EAPI int livebox_size(struct livebox *handler)
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        w = handler->lb.width;
@@ -1276,57 +1613,69 @@ EAPI int livebox_size(struct livebox *handler)
 EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const char *category, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       int ret;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!cluster || !category || handler->state != CREATE || !handler->id) {
                ErrPrint("Invalid argument\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (handler->group_changed_cb) {
+               ErrPrint("Previous group changing request is not finished yet\n");
+               return LB_STATUS_ERROR_BUSY;
        }
 
        if (!handler->is_user) {
                ErrPrint("CA Livebox is not able to change the group\n");
-               return -EPERM;
+               return LB_STATUS_ERROR_PERMISSION;
        }
 
        if (!strcmp(handler->cluster, cluster) && !strcmp(handler->category, category)) {
                DbgPrint("No changes\n");
-               return -EALREADY;
+               return LB_STATUS_ERROR_ALREADY;
        }
 
-       if (handler->group_changed_cb)
-               DbgPrint("Already sent\n");
-
        packet = packet_create("change_group", "ssss", handler->pkgname, handler->id, cluster, category);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (!cb)
                cb = default_group_changed_cb;
 
-       return master_rpc_async_request(handler, packet, 0, set_group_ret_cb, create_cb_info(cb, data));
+       handler->group_changed_cb = cb;
+       handler->group_cbdata = data; 
+
+       ret = master_rpc_async_request(handler, packet, 0, set_group_ret_cb, NULL);
+       if (ret < 0) {
+               handler->group_changed_cb = NULL;
+               handler->group_cbdata = NULL;
+       }
+
+       return ret;
 }
 
 EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!cluster || !category || handler->state != CREATE || !handler->id) {
                ErrPrint("Invalid argument\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        *cluster = handler->cluster;
        *category = handler->category;
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *size_list)
@@ -1336,12 +1685,12 @@ EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *siz
 
        if (!handler || !size_list) {
                ErrPrint("Invalid argument, handler(%p), size_list(%p)\n", handler, size_list);
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!cnt || handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        for (j = i = 0; i < NR_OF_SIZE_LIST; i++) {
@@ -1354,7 +1703,7 @@ EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *siz
        }
 
        *cnt = j;
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI const char *livebox_pkgname(struct livebox *handler)
@@ -1390,27 +1739,51 @@ EAPI double livebox_priority(struct livebox *handler)
 EAPI int livebox_delete_cluster(const char *cluster, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       struct cb_info *cbinfo;
+       int ret;
 
        packet = packet_create("delete_cluster", "s", cluster);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       return master_rpc_async_request(NULL, packet, 0, delete_cluster_cb, create_cb_info(cb, data));
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               packet_destroy(packet);
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       ret = master_rpc_async_request(NULL, packet, 0, delete_cluster_cb, cbinfo);
+       if (ret < 0)
+               destroy_cb_info(cbinfo);
+
+       return ret;
 }
 
 EAPI int livebox_delete_category(const char *cluster, const char *category, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       struct cb_info *cbinfo;
+       int ret;
 
        packet = packet_create("delete_category", "ss", cluster, category);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               packet_destroy(packet);
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       return master_rpc_async_request(NULL, packet, 0, delete_category_cb, create_cb_info(cb, data));
+       ret = master_rpc_async_request(NULL, packet, 0, delete_category_cb, cbinfo);
+       if (ret < 0)
+               destroy_cb_info(cbinfo);
+
+       return ret;
 }
 
 EAPI enum livebox_lb_type livebox_lb_type(struct livebox *handler)
@@ -1481,65 +1854,77 @@ EAPI int livebox_set_pd_text_handler(struct livebox *handler, struct livebox_scr
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        memcpy(&handler->pd.data.ops, ops, sizeof(*ops));
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI int livebox_set_text_handler(struct livebox *handler, struct livebox_script_operators *ops)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        memcpy(&handler->lb.data.ops, ops, sizeof(*ops));
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       struct cb_info *cbinfo;
        const char *id;
+       int ret;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Invalid handle\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
                ErrPrint("Handler is not valid type\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        id = fb_id(handler->lb.data.fb);
        if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        packet = packet_create("lb_acquire_pixmap", "ss", handler->pkgname, handler->id);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               packet_destroy(packet);
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       return master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, create_cb_info(cb, data));
+       ret = master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, cbinfo);
+       if (ret < 0)
+               destroy_cb_info(cbinfo);
+
+       return ret;
 }
 
 EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap)
@@ -1548,23 +1933,23 @@ EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap)
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Invalid handle\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
                ErrPrint("Handler is not valid type\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        packet = packet_create_noack("lb_release_pixmap", "ssi", handler->pkgname, handler->id, pixmap);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        return master_rpc_request_only(handler, packet);
@@ -1573,34 +1958,46 @@ EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap)
 EAPI int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       struct cb_info *cbinfo;
        const char *id;
+       int ret;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Invalid handle\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
                ErrPrint("Handler is not valid type\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        id = fb_id(handler->pd.data.fb);
        if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        packet = packet_create("pd_acquire_pixmap", "ss", handler->pkgname, handler->id);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       return master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, create_cb_info(cb, data));
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               packet_destroy(packet);
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       ret = master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, cbinfo);
+       if (ret < 0)
+               destroy_cb_info(cbinfo);
+
+       return ret;
 }
 
 EAPI int livebox_pd_pixmap(const struct livebox *handler)
@@ -1667,23 +2064,23 @@ EAPI int livebox_release_pd_pixmap(struct livebox *handler, int pixmap)
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Invalid handle\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
                ErrPrint("Handler is not valid type\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        packet = packet_create_noack("pd_release_pixmap", "ssi", handler->pkgname, handler->id, pixmap);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        return master_rpc_request_only(handler, packet);
@@ -1753,12 +2150,12 @@ EAPI int livebox_pdfb_bufsz(struct livebox *handler)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        return fb_size(handler->pd.data.fb);
@@ -1768,12 +2165,12 @@ EAPI int livebox_lbfb_bufsz(struct livebox *handler)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        return fb_size(handler->lb.data.fb);
@@ -1783,12 +2180,12 @@ EAPI int livebox_is_user(struct livebox *handler)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE) {
                ErrPrint("Handler is invalid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        return handler->is_user;
@@ -1797,46 +2194,58 @@ EAPI int livebox_is_user(struct livebox *handler)
 EAPI int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       int ret;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (handler->pinup_cb) {
+               ErrPrint("Previous pinup request is not finished\n");
+               return LB_STATUS_ERROR_BUSY;
        }
 
        if (handler->is_pinned_up == flag) {
                DbgPrint("No changes\n");
-               return -EALREADY;
+               return LB_STATUS_ERROR_ALREADY;
        }
 
-       if (handler->pinup_cb)
-               DbgPrint("Already sent\n");
-
        packet = packet_create("pinup_changed", "ssi", handler->pkgname, handler->id, flag);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (!cb)
                cb = default_pinup_cb;
 
-       return master_rpc_async_request(handler, packet, 0, pinup_done_cb, create_cb_info(cb, data));
+       handler->pinup_cb = cb;
+       handler->pinup_cbdata = data;
+
+       ret = master_rpc_async_request(handler, packet, 0, pinup_done_cb, NULL);
+       if (ret < 0) {
+               handler->pinup_cb = NULL;
+               handler->pinup_cbdata = NULL;
+       }
+
+       return ret;
 }
 
 EAPI int livebox_is_pinned_up(struct livebox *handler)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        return handler->is_pinned_up;
 }
@@ -1845,11 +2254,11 @@ EAPI int livebox_has_pinup(struct livebox *handler)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        return handler->lb.pinup_supported;
 }
@@ -1858,14 +2267,14 @@ EAPI int livebox_set_data(struct livebox *handler, void *data)
 {
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        handler->data = data;
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 EAPI void *livebox_get_data(struct livebox *handler)
@@ -1923,15 +2332,17 @@ EAPI const char *livebox_category_title(struct livebox *handler)
 EAPI int livebox_emit_text_signal(struct livebox *handler, const char *emission, const char *source, double sx, double sy, double ex, double ey, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       struct cb_info *cbinfo;
+       int ret;
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if ((handler->lb.type != _LB_TYPE_TEXT && handler->pd.type != _PD_TYPE_TEXT) || handler->state != CREATE || !handler->id) {
                ErrPrint("Handler is not valid\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (!emission)
@@ -1944,10 +2355,20 @@ EAPI int livebox_emit_text_signal(struct livebox *handler, const char *emission,
                                handler->pkgname, handler->id, emission, source, sx, sy, ex, ey);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
-       return master_rpc_async_request(handler, packet, 0, text_signal_cb, create_cb_info(cb, data));
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               packet_destroy(packet);
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       ret = master_rpc_async_request(handler, packet, 0, text_signal_cb, cbinfo);
+       if (ret < 0)
+               destroy_cb_info(cbinfo);
+
+       return LB_STATUS_ERROR_FAULT;
 }
 
 EAPI int livebox_subscribe_group(const char *cluster, const char *category)
@@ -1963,7 +2384,7 @@ EAPI int livebox_subscribe_group(const char *cluster, const char *category)
        packet = packet_create_noack("subscribe", "ss", cluster ? cluster : "", category ? category : "");
        if (!packet) {
                ErrPrint("Failed to create a packet\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        return master_rpc_request_only(NULL, packet);
@@ -1983,7 +2404,7 @@ EAPI int livebox_unsubscribe_group(const char *cluster, const char *category)
        packet = packet_create_noack("unsubscribe", "ss", cluster ? cluster : "", category ? category : "");
        if (!packet) {
                ErrPrint("Failed to create a packet\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        return master_rpc_request_only(NULL, packet);
@@ -1995,16 +2416,16 @@ EAPI int livebox_refresh(struct livebox *handler)
 
        if (!handler) {
                ErrPrint("Hnalder is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        packet = packet_create_noack("update", "ss", handler->pkgname, handler->id);
        if (!packet) {
                ErrPrint("Failed to create a packet\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        return master_rpc_request_only(handler, packet);
@@ -2016,13 +2437,13 @@ EAPI int livebox_refresh_group(const char *cluster, const char *category)
 
        if (!cluster || !category) {
                ErrPrint("Invalid argument\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        packet = packet_create_noack("refresh_group", "ss", cluster, category);
        if (!packet) {
                ErrPrint("Failed to create a packet\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        return master_rpc_request_only(NULL, packet);
@@ -2035,27 +2456,29 @@ EAPI int livebox_set_visibility(struct livebox *handler, enum livebox_visible_st
 
        if (!handler) {
                ErrPrint("Handler is NIL\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->state != CREATE || !handler->id)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        if (!handler->is_user) {
                /* System cluster livebox cannot be changed its visible states */
                if (state == LB_HIDE_WITH_PAUSE) {
                        ErrPrint("CA Livebox is not able to change the visibility\n");
-                       return -EPERM;
+                       return LB_STATUS_ERROR_PERMISSION;
                }
        }
 
+       DbgPrint("Change the visibility %d <> %d, %s\n", handler->visible, state, handler->id);
+
        if (handler->visible == state)
-               return 0;
+               return LB_STATUS_ERROR_ALREADY;
 
        packet = packet_create_noack("change,visibility", "ssi", handler->pkgname, handler->id, (int)state);
        if (!packet) {
                ErrPrint("Failed to create a packet\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        ret = master_rpc_request_only(handler, packet);
@@ -2072,7 +2495,7 @@ EAPI enum livebox_visible_state livebox_visibility(struct livebox *handler)
                return LB_VISIBLE_ERROR;
        }
 
-       if (handler->state != CREATE)
+       if (handler->state != CREATE || !handler->id)
                return LB_VISIBLE_ERROR;
 
        return handler->visible;
@@ -2087,7 +2510,7 @@ int lb_set_group(struct livebox *handler, const char *cluster, const char *categ
                pc = strdup(cluster);
                if (!pc) {
                        CRITICAL_LOG("Heap: %s (cluster: %s)\n", strerror(errno), cluster);
-                       return -ENOMEM;
+                       return LB_STATUS_ERROR_MEMORY;
                }
        }
 
@@ -2096,7 +2519,7 @@ int lb_set_group(struct livebox *handler, const char *cluster, const char *categ
                if (!ps) {
                        CRITICAL_LOG("Heap: %s (category: %s)\n", strerror(errno), category);
                        free(pc);
-                       return -ENOMEM;
+                       return LB_STATUS_ERROR_MEMORY;
                }
        }
 
@@ -2109,7 +2532,7 @@ int lb_set_group(struct livebox *handler, const char *cluster, const char *categ
        handler->cluster = pc;
        handler->category = ps;
 
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 void lb_set_size(struct livebox *handler, int w, int h)
@@ -2118,12 +2541,23 @@ void lb_set_size(struct livebox *handler, int w, int h)
        handler->lb.height = h;
 }
 
+void lb_set_update_mode(struct livebox *handle, int active_mode)
+{
+       handle->is_active_update = active_mode;
+}
+
 void lb_set_pdsize(struct livebox *handler, int w, int h)
 {
        handler->pd.width = w;
        handler->pd.height = h;
 }
 
+void lb_set_default_pdsize(struct livebox *handler, int w, int h)
+{
+       handler->pd.default_width = w;
+       handler->pd.default_height = h;
+}
+
 void lb_invoke_fault_handler(enum livebox_fault_type event, const char *pkgname, const char *file, const char *func)
 {
        struct dlist *l;
@@ -2273,25 +2707,27 @@ int lb_delete_all(void)
                lb_unref(handler);
        }
 
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 int lb_set_content(struct livebox *handler, const char *content)
 {
        if (handler->content) {
+               DbgPrint("Release content: %s\n", content);
                free(handler->content);
                handler->content = NULL;
        }
 
        if (content) {
+               DbgPrint("Update Content: [%s]\n", content);
                handler->content = strdup(content);
                if (!handler->content) {
                        CRITICAL_LOG("Heap: %s (content: %s)\n", strerror(errno), content);
-                       return -ENOMEM;
+                       return LB_STATUS_ERROR_MEMORY;
                }
        }
 
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 int lb_set_title(struct livebox *handler, const char *title)
@@ -2305,11 +2741,11 @@ int lb_set_title(struct livebox *handler, const char *title)
                handler->title = strdup(title);
                if (!handler->title) {
                        CRITICAL_LOG("Heap: %s (title: %s)\n", strerror(errno), title);
-                       return -ENOMEM;
+                       return LB_STATUS_ERROR_MEMORY;
                }
        }
 
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 void lb_set_size_list(struct livebox *handler, int size_list)
@@ -2357,18 +2793,18 @@ int lb_set_lb_fb(struct livebox *handler, const char *filename)
        struct fb_info *fb;
 
        if (!handler)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        fb = handler->lb.data.fb;
        if (fb && !strcmp(fb_id(fb), filename)) /*!< BUFFER is not changed, */
-               return 0;
+               return LB_STATUS_SUCCESS;
 
        handler->lb.data.fb = NULL;
 
        if (!filename || filename[0] == '\0') {
                if (fb)
                        fb_destroy(fb);
-               return 0;
+               return LB_STATUS_SUCCESS;
        }
 
        handler->lb.data.fb = fb_create(filename, handler->lb.width, handler->lb.height);
@@ -2376,13 +2812,13 @@ int lb_set_lb_fb(struct livebox *handler, const char *filename)
                ErrPrint("Faield to create a FB\n");
                if (fb)
                        fb_destroy(fb);
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (fb)
                fb_destroy(fb);
 
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 int lb_set_pd_fb(struct livebox *handler, const char *filename)
@@ -2390,19 +2826,19 @@ int lb_set_pd_fb(struct livebox *handler, const char *filename)
        struct fb_info *fb;
 
        if (!handler)
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
 
        fb = handler->pd.data.fb;
        if (fb && !strcmp(fb_id(fb), filename)) {
                /* BUFFER is not changed, just update the content */
-               return -EEXIST;
+               return LB_STATUS_ERROR_EXIST;
        }
        handler->pd.data.fb = NULL;
 
        if (!filename || filename[0] == '\0') {
                if (fb)
                        fb_destroy(fb);
-               return 0;
+               return LB_STATUS_SUCCESS;
        }
 
        handler->pd.data.fb = fb_create(filename, handler->pd.width, handler->pd.height);
@@ -2410,12 +2846,12 @@ int lb_set_pd_fb(struct livebox *handler, const char *filename)
                ErrPrint("Failed to create a FB\n");
                if (fb)
                        fb_destroy(fb);
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (fb)
                fb_destroy(fb);
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 struct fb_info *lb_get_lb_fb(struct livebox *handler)
@@ -2481,6 +2917,79 @@ struct livebox *lb_unref(struct livebox *handler)
        if (handler->refcnt > 0)
                return handler;
 
+       if (handler->created_cb) {
+               DbgPrint("Clear created event callback\n");
+               handler->created_cb(handler, LB_STATUS_ERROR_FAULT, handler->created_cbdata);
+               handler->created_cb = NULL;
+               handler->created_cbdata = NULL;
+       }
+
+       if (handler->deleted_cb) {
+               DbgPrint("Clear deleted event callback\n");
+               handler->deleted_cb(handler, LB_STATUS_ERROR_FAULT, handler->deleted_cbdata);
+               handler->deleted_cb = NULL;
+               handler->deleted_cbdata = NULL;
+       }
+
+       if (handler->pinup_cb) {
+               DbgPrint("Clear pinup event callback\n");
+               handler->pinup_cb(handler, LB_STATUS_ERROR_FAULT, handler->pinup_cbdata);
+               handler->pinup_cb = NULL;
+               handler->pinup_cbdata = NULL;
+       }
+
+       if (handler->group_changed_cb) {
+               DbgPrint("Clear group changed event callback\n");
+               handler->group_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->group_cbdata);
+               handler->group_changed_cb = NULL;
+               handler->group_cbdata = NULL;
+       }
+
+       if (handler->period_changed_cb) {
+               DbgPrint("Clear period changed event callback\n");
+               handler->period_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->period_cbdata);
+               handler->period_changed_cb = NULL;
+               handler->period_cbdata = NULL;
+       }
+
+       if (handler->size_changed_cb) {
+               DbgPrint("Clear size changed event callback\n");
+               handler->size_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->size_cbdata);
+               handler->size_changed_cb = NULL;
+               handler->size_cbdata = NULL;
+       }
+
+       if (handler->pd_created_cb) {
+               DbgPrint("Clear pd created event callback\n");
+               handler->pd_created_cb(handler, LB_STATUS_ERROR_FAULT, handler->pd_created_cbdata);
+               handler->pd_created_cb = NULL;
+               handler->pd_created_cbdata = NULL;
+       }
+
+       if (handler->pd_destroyed_cb) {
+               DbgPrint("Clear pd destroyed event callback\n");
+               handler->pd_destroyed_cb(handler, LB_STATUS_ERROR_FAULT, handler->pd_destroyed_cbdata);
+               handler->pd_destroyed_cb = NULL;
+               handler->pd_destroyed_cbdata = NULL;
+       }
+
+       if (handler->update_mode_cb) {
+               DbgPrint("Clear update mode callback\n");
+               handler->update_mode_cb(handler, LB_STATUS_ERROR_FAULT, handler->update_mode_cbdata);
+               handler->update_mode_cb = NULL;
+               handler->update_mode_cbdata = NULL;
+       }
+
+       if (handler->access_event_cb) {
+               DbgPrint("Clear access status callback\n");
+               handler->access_event_cb(handler, LB_STATUS_ERROR_FAULT, handler->access_event_cbdata);
+               handler->access_event_cb = NULL;
+               handler->access_event_cbdata = NULL;
+       }
+
+       if (handler->filename)
+               util_unlink(handler->filename);
+
        dlist_remove_data(s_info.livebox_list, handler);
 
        handler->state = DESTROYED;
@@ -2508,30 +3017,42 @@ struct livebox *lb_unref(struct livebox *handler)
 int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data)
 {
        struct packet *packet;
+       struct cb_info *cbinfo;
+       int ret;
 
        if (!cb && !!data) {
                ErrPrint("Invalid argument\n");
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        if (handler->deleted_cb) {
                ErrPrint("Already in-progress\n");
-               return -EINPROGRESS;
+               return LB_STATUS_ERROR_BUSY;
        }
 
        packet = packet_create("delete", "ss", handler->pkgname, handler->id);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
                if (cb)
-                       cb(handler, -EFAULT, data);
+                       cb(handler, LB_STATUS_ERROR_FAULT, data);
 
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        if (!cb)
                cb = default_delete_cb;
 
-       return master_rpc_async_request(handler, packet, 0, del_ret_cb, create_cb_info(cb, data));
+       cbinfo = create_cb_info(cb, data);
+       if (!cbinfo) {
+               packet_destroy(packet);
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       ret = master_rpc_async_request(handler, packet, 0, del_ret_cb, cbinfo);
+       if (ret < 0)
+               destroy_cb_info(cbinfo);
+
+       return ret;
 }
 
 EAPI int livebox_client_paused(void)
@@ -2541,7 +3062,7 @@ EAPI int livebox_client_paused(void)
        packet = packet_create_noack("client_paused", "d", util_timestamp());
        if (!packet) {
                ErrPrint("Failed to create a pause packet\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        return master_rpc_request_only(NULL, packet);
@@ -2554,7 +3075,7 @@ EAPI int livebox_client_resumed(void)
        packet = packet_create_noack("client_resumed", "d", util_timestamp());
        if (!packet) {
                ErrPrint("Failed to create a resume packet\n");
-               return -EFAULT;
+               return LB_STATUS_ERROR_FAULT;
        }
 
        return master_rpc_request_only(NULL, packet);