Sync with the latest code of phone profile 71/14471/5
authorSung-jae Park <nicesj.park@samsung.com>
Sun, 5 Jan 2014 08:27:43 +0000 (17:27 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Sun, 5 Jan 2014 08:42:53 +0000 (17:42 +0900)
Let's see the long stroy of this patch set.
(Code diff - history of code changes - is skipped)

* Sung-jae Park [Sun, 5 Jan 2014 04:02:37 +0000]
- Review the code

* Sung-jae Park [Sat, 4 Jan 2014 08:33:58 +0000]
- Remove unnecessary header inclusion

* Sung-jae Park [Sat, 4 Jan 2014 08:17:27 +0000]
- Separate the EFL plugin from the master process.
- Only the EFL should be loaded by liblivebox-edje when it is required.

* Sung-jae Park [Thu, 2 Jan 2014 03:06:48 +0000]
- Selectable service enabling code is added

* Sung-jae Park [Fri, 27 Dec 2013 10:07:35 +0000]
- Remove NONBLOCK flag from the pipe2

* youngsub ko [Fri, 27 Dec 2013 02:23:45 +0000]
- releasing data-provider-master_0.31.2-1

* youngsub ko [Thu, 26 Dec 2013 12:54:06 +0000]
- include badge-service package

* Sung-jae Park [Mon, 23 Dec 2013 15:30:00 +0000]
- Add premultipled color control conf.

* Sung-jae Park [Mon, 23 Dec 2013 05:37:20 +0000]
- Add locking mechanism.
- for SHM & FILE method for content sharing.

* Sung-jae Park [Sat, 21 Dec 2013 13:23:46 +0000]
- Remove inline keyword
- To prevent from GCC build warnings.

* Sung-jae Park [Sat, 21 Dec 2013 12:49:47 +0000]
- Replace EINA_LIST_FREE with eina_list_free

* Sung-jae Park [Sat, 21 Dec 2013 12:37:58 +0000]
- Initialize the var. for may-uninitialized (gcc)

* Sung-jae Park [Sat, 21 Dec 2013 11:38:04 +0000]
- Fix build error (inline fail)

* Sung-jae Park [Fri, 20 Dec 2013 08:06:21 +0000]
- Add log dump data

* Sung-jae Park [Wed, 18 Dec 2013 06:25:57 +0000]
- Create folder first before dump the logs.

* Sung-jae Park [Wed, 18 Dec 2013 04:09:17 +0000]
- Add alternative icon & name for the instance

* Sung-jae Park [Tue, 17 Dec 2013 09:02:00 +0000]
- Fix the invalid client pid of content filename

* Sung-jae Park [Sat, 14 Dec 2013 03:40:32 +0000]
- Add log for pkgmgr plugin

* Sung-jae Park [Fri, 13 Dec 2013 12:52:14 +0000]
- Update log path

* Sung-jae Park [Fri, 13 Dec 2013 11:56:42 +0000]
- Print error log for plugin of pkgmgr

* Sung-jae Park [Fri, 13 Dec 2013 09:45:02 +0000]
- Update log_dump script

* Sung-jae Park [Fri, 13 Dec 2013 08:48:02 +0000]
- Add new event path for propagating the delete type.

* Sung-jae Park [Thu, 12 Dec 2013 13:31:07 +0000]
- Update the fault tolerant code

* Sung-jae Park [Wed, 11 Dec 2013 00:53:53 +0000]
- update state when clear the terminating timer

* Sung-jae Park [Wed, 11 Dec 2013 00:28:29 +0000]
- Adopt the terminate timer.
- Terminate timer will be fired instead of direct terminating services.
- After the terminate timer callback is called, the service provider will be terminated.

* Sung-jae Park [Tue, 10 Dec 2013 11:44:03 +0000]
- Do not terminate process even though it gets off.vconf

* Sung-jae Park [Tue, 10 Dec 2013 10:25:15 +0000]
- Update debug log

* Sung-jae Park [Tue, 10 Dec 2013 09:17:31 +0000]
- Even if there is not enough space to manage the dboxes, try to use the tmpfs

* Sung-jae Park [Mon, 9 Dec 2013 12:36:18 +0000]
- If the system has not enough space, use tmpfs(6 MB)

* Sung-jae Park [Sat, 7 Dec 2013 06:33:22 +0000]
- Add new event path. (close_pd)
- App wants to close their PD in some cases.
- The app requests to close the PD, but the viewer can accepts it. (or rejects it)

* Sung-jae Park [Fri, 6 Dec 2013 12:45:26 +0000]
- Update key event forwarding code

* Sung-jae Park [Fri, 6 Dec 2013 04:56:50 +0000]
- Add key event path

Change-Id: Ida194388b66df8f13e264820e4b0f38cbfbaf459

39 files changed:
CMakeLists.txt
data/CMakeLists.txt
data/baltic.conf.ini
data/dump_livebox.sh [new file with mode: 0644]
data/private.conf.ini
include/buffer_handler.h
include/conf.h
include/event.h
include/event_queue.h [new file with mode: 0644]
include/fb.h [deleted file]
include/instance.h
include/script_handler.h
include/slave_life.h
include/util.h
packaging/data-provider-master.spec
pkgmgr_livebox/src/service_register.c
src/badge_service.c
src/buffer_handler.c
src/conf.c
src/event.c
src/event_queue.c [new file with mode: 0644]
src/fb.c [deleted file]
src/file_service.c
src/instance.c
src/io.c
src/main.c
src/notification_service.c
src/package.c
src/parser.c
src/script_handler.c
src/server.c
src/service_common.c
src/setting.c
src/slave_life.c
src/util.c
src/utility_service.c
src/xmonitor.c
util_liveinfo/src/liveinfo.c
util_liveinfo/src/node.c

index c6c6639..b065c5c 100644 (file)
@@ -14,8 +14,6 @@ pkg_check_modules(pkg REQUIRED
        bundle
        ecore-x
        ecore
-       evas
-       ecore-evas
        com-core
        x11
        libdri2
@@ -28,7 +26,9 @@ pkg_check_modules(pkg REQUIRED
        pkgmgr
        livebox-service
        notification
+       notification-service
        badge
+       badge-service
        libsmack
        shortcut
 )
@@ -60,6 +60,7 @@ ADD_DEFINITIONS("-DUTILITY_SMACK_LABEL=\"data-provider-master::utility\"")
 ADD_DEFINITIONS("-DSHORTCUT_SMACK_LABEL=\"data-provider-master::shortcut\"")
 ADD_DEFINITIONS("-DNOTIFICATION_SMACK_LABEL=\"data-provider-master::notification\"")
 ADD_DEFINITIONS("-DBADGE_SMACK_LABEL=\"data-provider-master::badge\"")
+ADD_DEFINITIONS("-DDATA_SHARE_LABEL=\"data-provider-master::share\"")
 
 ADD_DEFINITIONS("-DDEFAULT_MASTER_CONF=\"/usr/share/data-provider-master/conf.ini\"")
 
@@ -79,7 +80,6 @@ ADD_EXECUTABLE(${PROJECT_NAME}
        src/conf.c
        src/dead_monitor.c
        src/group.c
-       src/fb.c
        src/script_handler.c
        src/buffer_handler.c
        src/io.c
@@ -106,14 +106,13 @@ ADD_EXECUTABLE(${PROJECT_NAME}
 )
 
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl -lrt")
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data-provider-master.rule DESTINATION /opt/etc/smack/accesses.d PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/abi.ini DESTINATION /usr/share/data-provider-master PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PRODUCT}.conf.ini DESTINATION /usr/share/data-provider-master RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/resolution.ini DESTINATION /usr/share/data-provider-master PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "${PROJECT_NAME}")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
 
 # INCLUDE FOR BUILD & INSTALL .PO FILES
 ADD_SUBDIRECTORY(res)
index 133698e..772eac6 100644 (file)
@@ -1,4 +1,2 @@
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/data-provider-master DESTINATION /etc/rc.d/init.d/ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/data-provider-master.service DESTINATION /usr/lib/systemd/user/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/data-provider-master.socket DESTINATION /usr/lib/systemd/user/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-
index 9a9c2f4..644b940 100644 (file)
@@ -7,7 +7,7 @@ default_group=disclosure
 default_period=-1.0
 default_packet_time=0.0001
 default_content=default
-minimum_space=5242880
+minimum_space=104857600
 replace_tag=/APPID/
 slave_ttl=30.0
 slave_activate_time=30.0
@@ -18,7 +18,7 @@ max_log_file=3
 sqilte_flush_max=1048576
 db_path=/opt/dbspace/.livebox.db
 share_path=/opt/usr/share/live_magazine/
-log_path=/opt/usr/share/live_magazine/log
+log_path=/tmp/.dbox.service
 always_path=/opt/usr/share/live_magazine/always
 reader_path=/opt/usr/share/live_magazine/reader
 script_port_path=/usr/share/data-provider-master/plugin-script/
diff --git a/data/dump_livebox.sh b/data/dump_livebox.sh
new file mode 100644 (file)
index 0000000..2fb6c32
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+LIVEBOX_DEBUG=$1/livebox
+mkdir -p ${LIVEBOX_DEBUG}
+/bin/cp -r /opt/usr/share/live_magazine ${LIVEBOX_DEBUG}
+/bin/cp -r /tmp/.dbox.service ${LIVEBOX_DEBUG}/log
+ls -la /tmp/ | /bin/grep srw > ${LIVEBOX_DEBUG}/log/tmp.hidden_files
index 383e3d6..597f22c 100644 (file)
@@ -1,14 +1,14 @@
 base_width=720
 base_height=1280
 minimum_period=1.0
-script=edje
-default_abi=c
-default_group=disclosure
+#script=edje
+#default_abi=c
+#default_group=disclosure
 default_period=-1.0
 default_packet_time=0.0001
-default_content=default
-minimum_space=5242880
-replace_tag=/APPID/
+#default_content=default
+minimum_space=104857600
+#replace_tag=/APPID/
 slave_ttl=30.0
 slave_activate_time=30.0
 slave_relaunch_time=3.0
@@ -16,12 +16,12 @@ slave_relaunch_count=3
 max_log_line=1000
 max_log_file=3
 sqilte_flush_max=1048576
-db_path=/opt/dbspace/.livebox.db
-share_path=/opt/usr/share/live_magazine/
-log_path=/opt/usr/share/live_magazine/log
-always_path=/opt/usr/share/live_magazine/always
-reader_path=/opt/usr/share/live_magazine/reader
-script_port_path=/usr/share/data-provider-master/plugin-script/
+#db_path=/opt/dbspace/.livebox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.service
+#always_path=/opt/usr/share/live_magazine/always
+#reader_path=/opt/usr/share/live_magazine/reader
+#script_port_path=/usr/share/data-provider-master/plugin-script/
 ping_interval=240.0
 slave_max_load=30
 use_sw_backend=false
@@ -30,5 +30,8 @@ debug_mode=false
 overwrite_content=false
 com_core_thread=true
 use_xmonitor=false
-input=/dev/input/event2
+#input=/dev/input/event2
 pd_request_timeout=5.0
+premultiplied=1
+#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
+#services=[livebox],[shortcut],[notification],[utility],[badge],[file]
index a60c59a..e3aa982 100644 (file)
@@ -18,7 +18,7 @@ struct buffer_info;
 struct inst_info;
 struct buffer;
 
-enum buffer_type { /*!< Must have to be sync with libprovider, liblivebox-viewer */
+enum buffer_type { /*!< Must have to be sync with libprovider, liblivebox-viewer, liblivebox-edje */
        BUFFER_TYPE_FILE,
        BUFFER_TYPE_SHM,
        BUFFER_TYPE_PIXMAP,
@@ -146,26 +146,187 @@ extern int buffer_handler_init(void);
 
 /*!
  * \brief
+ * \details
+ * \remarks
  * \return int
+ * \retval
+ * \pre
+ * \post
+ * \sa
  */
 extern int buffer_handler_fini(void);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] info
+ * \return void *
+ * \retval NULL
+ * \retval address
+ * \pre
+ * \post
+ * \sa
+ */
 extern void *buffer_handler_pixmap_ref(struct buffer_info *info);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] buffer_ptr
+ * \return int
+ * \retval 
+ * \pre
+ * \post
+ * \sa
+ */
 extern int buffer_handler_pixmap_unref(void *buffer_ptr);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] pixmap
+ * \return void *
+ * \retval
+ * \pre
+ * \post
+ * \sa
+ */
 extern void *buffer_handler_pixmap_find(int pixmap);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] info
+ * \return void *
+ * \retval
+ * \pre
+ * \post
+ * \sa
+ */
 extern void *buffer_handler_pixmap_buffer(struct buffer_info *info);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] info
+ * \return struct inst_info *
+ * \retval
+ * \pre
+ * \post
+ * \sa
+ */
 extern struct inst_info *buffer_handler_instance(struct buffer_info *info);
 
-extern struct buffer *buffer_handler_raw_open(enum buffer_type, void *resource);
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] type
+ * \param[in] resource
+ * \return struct buffer *
+ * \retval NULL
+ * \retval address
+ * \pre
+ * \post
+ * \sa
+ */
+extern struct buffer *buffer_handler_raw_open(enum buffer_type type, void *resource);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] buffer
+ * \return int
+ * \retval
+ * \pre
+ * \post
+ * \sa
+ */
 extern int buffer_handler_raw_close(struct buffer *buffer);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] buffer
+ * \return void *
+ * \retval NULL
+ * \pre
+ * \post
+ * \sa
+ */
 extern void *buffer_handler_raw_data(struct buffer *buffer);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] buffer
+ * \return int
+ * \retval
+ * \pre
+ * \post
+ * \sa
+ */
 extern int buffer_handler_raw_size(struct buffer *buffer);
 
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] buffer
+ * \return int
+ * \retval
+ * \pre
+ * \post
+ * \sa
+ */
+extern int buffer_handler_lock(struct buffer_info *buffer);
+
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] buffer
+ * \return int
+ * \retval
+ * \pre
+ * \post
+ * \sa
+ */
+extern int buffer_handler_unlock(struct buffer_info *buffer);
+
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] buffer
+ * \param[in] data
+ * \return int
+ * \retval
+ * \pre
+ * \post
+ * \sa
+ */
+extern int buffer_handler_set_data(struct buffer_info *buffer, void *data);
+
+/*!
+ * \brief
+ * \details
+ * \remarks
+ * \param[in] buffer
+ * \return void *
+ * \retval NULL
+ * \retval address
+ * \pre
+ * \post
+ * \sa
+ */
+extern void *buffer_handler_data(struct buffer_info *buffer);
 /* End of a file */
index d29dd2b..db1bdeb 100644 (file)
@@ -85,11 +85,15 @@ struct conf {
        int overwrite_content;
        int com_core_thread;
        int use_xmonitor;
+       int premultiplied;
 
        double scale_width_factor;
        double scale_height_factor;
 
        double pd_request_timeout;
+
+       char *emergency_disk;
+       char *services;
 };
 
 extern struct conf g_conf;
@@ -105,6 +109,7 @@ extern void conf_init(void);
 #define CR 13
 #define LF 10
 
+#define EMERGENCY_DISK         g_conf.emergency_disk
 #define SCALE_WIDTH_FACTOR     g_conf.scale_width_factor
 #define SCALE_HEIGHT_FACTOR    g_conf.scale_height_factor
 
@@ -158,6 +163,16 @@ extern void conf_init(void);
 
 #define SLAVE_MAX_LOAD         g_conf.slave_max_load
 #define DEFAULT_PING_TIME      g_conf.ping_time
+#define PREMULTIPLIED_COLOR    g_conf.premultiplied
+#define SERVICES               g_conf.services
+
+#define SERVICE_LIVEBOX                "[livebox]"
+#define SERVICE_NOTIFICATION   "[notification]"
+#define SERVICE_BADGE          "[badge]"
+#define SERVICE_SHORTCUT       "[shortcut]"
+#define SERVICE_UTILITY                "[utility]"
+#define SERVICE_FILE           "[file]"
+
 #define PAUSED_FILE            "/tmp/.live.paused"
 
 #define MAX_ABI                256
@@ -177,5 +192,8 @@ extern void conf_init(void);
 #define USE_XMONITOR           g_conf.use_xmonitor
 
 #define HAPI __attribute__((visibility("hidden")))
+/*!
+ * EAPI is defined from eina.h
+ */
 
 /* End of a file */
index acc5bdc..800b071 100644 (file)
@@ -17,6 +17,7 @@
 struct event_data {
        int x;
        int y;
+       unsigned int keycode;
        int device;
        int slot;
        struct {
diff --git a/include/event_queue.h b/include/event_queue.h
new file mode 100644 (file)
index 0000000..6bab451
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2013  Samsung Electronics Co., Ltd
+ *
+ * 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://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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+struct event_handle;
+
+extern struct event_handle *event_queue_create(void);
+extern int event_queue_destroy(struct event_handle *handle);
+extern int event_queue_put(struct event_handle *handle, void *data);
+extern void *event_queue_get(struct event_handle *handle);
+extern int event_queue_fd(struct event_handle *handle);
+
+/* End of a file */
+
diff --git a/include/fb.h b/include/fb.h
deleted file mode 100644 (file)
index 0061bc6..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2013  Samsung Electronics Co., Ltd
- *
- * 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://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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-struct fb_info;
-struct inst_info;
-struct buffer_info;
-
-extern int fb_init(void);
-extern int fb_fini(void);
-extern struct fb_info *fb_create(struct inst_info *inst, int w, int h, enum buffer_type type);
-extern int fb_destroy(struct fb_info *info);
-extern Ecore_Evas * const fb_canvas(struct fb_info *info);
-extern const char *fb_id(struct fb_info *info);
-extern int fb_get_size(struct fb_info *info, int *w, int *h);
-extern void fb_sync(struct fb_info *info);
-extern int fb_create_buffer(struct fb_info *info);
-extern int fb_destroy_buffer(struct fb_info *info);
-extern int fb_resize(struct fb_info *info, int w, int h);
-
-/*!
- * \note Only for the pixmap
- */
-extern void *fb_pixmap_render_pre(struct fb_info *info);
-extern int fb_pixmap_render_post(struct fb_info *info);
-extern struct buffer_info *fb_buffer_info(struct fb_info *info);
-/* End of a file */
index 2e3ce7a..a523c7f 100644 (file)
@@ -19,7 +19,7 @@
  * An instance has three states.
  * ACTIVATED, DEACTIVATED, DESTROYED
  *
- * When the master is launched and someone requiers to create this instance,
+ * When the master is launched and someone requires to create this instance,
  * The master just allocate a heap for new instance.
  * We defined this as "DEACTIVATED" state.
  *
@@ -100,7 +100,8 @@ enum instance_destroy_type {
        INSTANCE_DESTROY_UNINSTALL = 0x02,
        INSTANCE_DESTROY_TERMINATE = 0x03,
        INSTANCE_DESTROY_FAULT = 0x04,
-       INSTANCE_DESTROY_UNKNOWN = 0x05,
+       INSTANCE_DESTROY_TEMPORARY = 0x05,
+       INSTANCE_DESTROY_UNKNOWN = 0x06
 };
 
 enum instance_state {
@@ -154,6 +155,7 @@ extern int instance_need_slave(struct inst_info *inst);
 extern void instance_set_lb_info(struct inst_info *inst, double priority, const char *content, const char *title);
 extern void instance_set_lb_size(struct inst_info *inst, int w, int h);
 extern void instance_set_pd_size(struct inst_info *inst, int w, int h);
+extern void instance_set_alt_info(struct inst_info *inst, const char *icon, const char *name);
 
 extern int instance_set_pinup(struct inst_info *inst, int pinup);
 extern int instance_resize(struct inst_info *inst, int w, int h);
@@ -198,7 +200,7 @@ extern const enum instance_state const instance_state(const struct inst_info *in
  * event
  */
 extern int instance_unicast_created_event(struct inst_info *inst, struct client_node *client);
-extern int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client);
+extern int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client, int reason);
 
 extern int instance_create_lb_buffer(struct inst_info *inst);
 extern int instance_create_pd_buffer(struct inst_info *inst);
@@ -228,6 +230,7 @@ extern int instance_client_pd_destroyed(struct inst_info *inst, int status);
 extern int instance_client_pd_created(struct inst_info *inst, int status);
 
 extern int instance_send_access_status(struct inst_info *inst, int status);
+extern int instance_send_key_status(struct inst_info *inst, int status);
 extern int instance_forward_packet(struct inst_info *inst, struct packet *packet);
 
 extern struct client_node *instance_pd_owner(struct inst_info *inst);
@@ -244,7 +247,7 @@ extern int instance_init(void);
 extern int instance_fini(void);
 
 extern int instance_event_callback_add(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
-extern int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data));
+extern int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
 
 /*!
  */
index 6a2195f..5e84f2b 100644 (file)
@@ -19,8 +19,6 @@ struct fb_info;
 
 extern struct script_info *script_handler_create(struct inst_info *inst, const char *file, const char *group, int w, int h);
 extern int script_handler_destroy(struct script_info *info);
-extern struct fb_info *script_handler_fb(struct script_info *info);
-extern void *script_handler_evas(struct script_info *info);
 extern int script_handler_parse_desc(struct inst_info *inst, const char *descfile, int is_pd);
 extern int script_handler_unload(struct script_info *info, int is_pd);
 extern int script_handler_load(struct script_info *info, int is_pd);
@@ -30,8 +28,12 @@ extern int script_handler_feed_event(struct script_info *info, int event, double
 extern int script_init(void);
 extern int script_fini(void);
 
-extern int script_signal_emit(Evas *e, const char *part, const char *signal, double sx, double sy, double ex, double ey);
+extern int script_signal_emit(void *buffer_handle, const char *part, const char *signal, double sx, double sy, double ex, double ey);
+
 extern int script_handler_update_pointer(struct script_info *inst, int x, int y, int down);
+extern int script_handler_update_keycode(struct script_info *info, unsigned int keycode);
 extern int script_handler_resize(struct script_info *info, int w, int h);
+extern const char *script_handler_buffer_id(struct script_info *info);
+extern struct buffer_info *script_handler_buffer_info(struct script_info *info);
 
 /* End of a file */
index 5f7fd35..3f110f1 100644 (file)
@@ -103,7 +103,7 @@ extern int slave_activate(struct slave_node *slave);
  * \brief After this function call, the slave object can be deleted
  * \param[in] slave
  */
-extern struct slave_node *slave_deactivate(struct slave_node *slave) __attribute__((warn_unused_result));
+extern struct slave_node *slave_deactivate(struct slave_node *slave, int direct) __attribute__((warn_unused_result));
 
 /*!
  * To check the slave's activation state
index a43a462..f5e4dd0 100644 (file)
@@ -28,6 +28,11 @@ extern const char *util_uri_to_path(const char *uri);
 extern void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *data);
 extern void util_timer_interval_set(void *timer, double interval);
 extern double util_time_delay_for_compensation(double period);
+extern void util_setup_log_disk(void);
+extern void util_remove_emergency_disk(void);
+extern void util_prepare_emergency_disk(void);
+extern int util_emergency_disk_is_mounted(void);
+extern int util_service_is_enabled(const char *tag);
 
 #define SCHEMA_FILE    "file://"
 #define SCHEMA_PIXMAP  "pixmap://"
index b2c26c5..8d3debd 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes
-Version: 0.25.34
+Version: 0.33.1
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
@@ -19,8 +19,6 @@ BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(ecore-x)
 BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(evas)
-BuildRequires: pkgconfig(ecore-evas)
 BuildRequires: pkgconfig(com-core)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(x11)
@@ -34,7 +32,9 @@ BuildRequires: pkgconfig(xdamage)
 BuildRequires: pkgconfig(pkgmgr)
 BuildRequires: pkgconfig(livebox-service)
 BuildRequires: pkgconfig(notification)
+BuildRequires: pkgconfig(notification-service)
 BuildRequires: pkgconfig(badge)
+BuildRequires: pkgconfig(badge-service)
 BuildRequires: pkgconfig(shortcut)
 BuildRequires: pkgconfig(security-server)
 Requires(post): sys-assert
@@ -49,6 +49,12 @@ Keep trace on the life-cycle of the livebox and status of the service providers,
 cp %{SOURCE1001} .
 
 %build
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+
 export ENGINEER=false
 %if 0%{?tizen_build_binary_release_type_eng}
 export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE"
@@ -140,6 +146,7 @@ echo "%{_sysconfdir}/init.d/data-provider-master start"
 
 %{_datarootdir}/license/*
 /opt/usr/share/live_magazine/*
+/opt/etc/dump.d/module.d/dump_livebox.sh
 %if 0%{?tizen_build_binary_release_type_eng}
 /opt/usr/devel/usr/bin/*
 %endif
index 2eb8bfd..e92ec85 100644 (file)
@@ -47,6 +47,7 @@
 #if !defined(FLOG)
 #define DbgPrint(format, arg...)       SECURE_LOGD("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
 #define ErrPrint(format, arg...)       SECURE_LOGE("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+#define ErrPrintWithConsole(format, arg...)    do { fprintf(stderr, "[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); SECURE_LOGE("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); } while (0)
 #endif
 /* End of a file */
 
@@ -61,7 +62,7 @@
  * |   -     |
  * +---------+
  * CREATE TABLE version ( version INTEGER )
- *
+ * 
  *
  * pkgmap
  * +-------+-------+-------+-------+
@@ -651,13 +652,13 @@ static int db_insert_provider(struct livebox *livebox)
        dml = "INSERT INTO provider ( pkgid, network, abi, secured, box_type, box_src, box_group, pd_type, pd_src, pd_group, libexec, timeout, period, script, pinup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
        }
 
        ret = sqlite3_bind_text(stmt, 1, (char *)livebox->pkgid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
@@ -665,104 +666,104 @@ static int db_insert_provider(struct livebox *livebox)
 
        ret = sqlite3_bind_int(stmt, 2, livebox->network);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 3, abi, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
        ret = sqlite3_bind_int(stmt, 4, livebox->secured);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 5, livebox->lb_type);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 6, box_src, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 7, box_group, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 8, livebox->pd_type);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 9, pd_src, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 10, pd_group, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 11, libexec, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 12, atoi(timeout));
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 13, period, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 14, script, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 15, livebox->pinup);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = 0;
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
        }
 
@@ -802,76 +803,76 @@ static inline int db_insert_client(struct livebox *livebox)
        dml = "INSERT INTO client ( pkgid, icon, name, auto_launch, pd_size, content, nodisplay, setup, mouse_event ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
        }
 
        ret = sqlite3_bind_text(stmt, 1, (char *)livebox->pkgid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 2, (char *)livebox->icon, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 3, (char *)livebox->name, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 4, (char *)livebox->auto_launch, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 5, (char *)livebox->pd_size, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 6, livebox->content ? (char *)livebox->content : "", -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 7, livebox->nodisplay);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 8, livebox->setup ? (char *)livebox->setup : "", -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 9, livebox->mouse_event);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = 0;
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
        }
 
@@ -944,41 +945,41 @@ static inline int db_insert_i18n(const char *pkgid, const char *lang, const char
        dml = "INSERT INTO i18n ( pkgid, lang, name, icon ) VALUES (?, ?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
        }
 
        ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 2, lang, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 3, name, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 4, icon, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = 0;
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
        }
 
@@ -1053,34 +1054,34 @@ static inline int db_insert_group(const char *pkgid, const char *cluster, const
        dml = "INSERT INTO groupinfo ( cluster, category, pkgid ) VALUES (?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
        }
 
        ret = sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 3, pkgid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = 0;
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
        }
 
@@ -1249,34 +1250,34 @@ static inline int db_insert_groupmap(int id, const char *pkgid, const char *ctx_
        dml = "INSERT INTO groupmap ( id, pkgid, ctx_item ) VALUES (?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
        }
 
        ret = sqlite3_bind_int(stmt, 1, id);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = 0;
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
        }
 
@@ -1353,41 +1354,41 @@ static inline int db_insert_option(const char *pkgid, int option_id, const char
        dml = "INSERT INTO option (pkgid, option_id, key, value) VALUES (?, ?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
        }
 
        ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 2, option_id);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 3, key, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 4, value, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = 0;
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
        }
 out:
@@ -1463,48 +1464,48 @@ static int db_insert_box_size(const char *pkgid, int size_type, const char *prev
        dml = "INSERT INTO box_size ( pkgid, size_type, preview, touch_effect, need_frame ) VALUES (?, ?, ?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
        }
 
        ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 2, size_type);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_text(stmt, 3, preview ? preview : "", -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = sqlite3_bind_int(stmt, 4, touch_effect);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret =  sqlite3_bind_int(stmt, 5, need_frame);
        if (ret != SQLITE_OK) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
        }
 
        ret = 0;
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
        }
 
@@ -2755,7 +2756,7 @@ errout:
        return ret;
 }
 
-static inline int pkglist_get_via_callback(const char *appid, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data)
+static int pkglist_get_via_callback(const char *appid, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data)
 {
        const char *dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ?";
        int ret;
@@ -2809,6 +2810,8 @@ static void clear_all_pkg(const char *appid, const char *pkgid, int prime, void
 {
        int ret;
 
+       ErrPrintWithConsole("Remove old package info: appid(%s), pkgid(%s)\n", appid, pkgid);
+
        ret = db_remove_box_size((char *)pkgid);
        if (ret < 0) {
                ErrPrint("Remove box size: %d\n", ret);
@@ -2854,9 +2857,11 @@ int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid)
 {
        int cnt;
 
+       ErrPrintWithConsole("%s\n", appid);
+
        if (!s_info.handle) {
                if (db_init() < 0) {
-                       ErrPrint("Failed to init DB\n");
+                       ErrPrintWithConsole("Failed to init DB\n");
                        return -EIO;
                }
        }
@@ -2873,6 +2878,7 @@ int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid)
 
 int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid)
 {
+       ErrPrintWithConsole("[%s]\n", appid);
        db_fini();
        return 0;
 }
@@ -2882,14 +2888,16 @@ int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
        xmlNodePtr node;
        int ret;
 
+       ErrPrintWithConsole("[%s]\n", appid);
+
        if (!s_info.handle) {
-               ErrPrint("Failed to init DB\n");
+               ErrPrintWithConsole("Failed to init DB\n");
                return -EIO;
        }
 
        node = xmlDocGetRootElement(docPtr);
        if (!node) {
-               ErrPrint("Invalid document\n");
+               ErrPrintWithConsole("Invalid document\n");
                return -EINVAL;
        }
 
@@ -2908,6 +2916,8 @@ int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid)
 {
        int cnt;
 
+       ErrPrintWithConsole("[%s]\n", appid);
+
        if (!s_info.handle) {
                if (db_init() < 0) {
                        ErrPrint("Failed to init DB\n");
@@ -2927,6 +2937,7 @@ int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid)
 
 int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid)
 {
+       ErrPrintWithConsole("[%s]\n", appid);
        db_fini();
        return 0;
 }
@@ -2936,6 +2947,8 @@ int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
        xmlNodePtr node;
        int ret;
 
+       ErrPrintWithConsole("[%s]\n", appid);
+
        if (!s_info.handle) {
                ErrPrint("Failed to init DB\n");
                return -EIO;
@@ -2959,6 +2972,8 @@ int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
 
 int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid)
 {
+       ErrPrintWithConsole("[%s]\n", appid);
+
        if (!s_info.handle) {
                if (db_init() < 0) {
                        ErrPrint("Failed to init DB\n");
@@ -2974,6 +2989,8 @@ int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid)
 {
        int cnt;
 
+       ErrPrintWithConsole("[%s]\n", appid);
+
        if (!s_info.handle) {
                return -EIO;
        }
@@ -2989,6 +3006,7 @@ int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid)
 
 int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
 {
+       ErrPrintWithConsole("[%s]\n", appid);
        if (!s_info.handle) {
                return -EIO;
        }
index ac3f302..cdc0e82 100755 (executable)
@@ -26,6 +26,7 @@
 
 #include <badge.h>
 #include <badge_db.h>
+#include <badge_setting_service.h>
 #include <security-server.h>
 
 #include "service_common.h"
@@ -56,6 +57,38 @@ struct badge_service {
 };
 
 /*!
+ * FUNCTIONS to check smack permission
+ */
+static int _is_valid_permission(int fd, struct badge_service *service)
+{
+       int ret;
+
+       if (service->rule != NULL && service->access != NULL) {
+               ret = security_server_check_privilege_by_sockfd(fd, service->rule, service->access);
+               if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
+                       ErrPrint("SMACK:Access denied\n");
+                       return 0;
+               }
+       }
+
+       return 1;
+}
+
+static int _is_manager_permission(int fd)
+{
+       int ret;
+
+       ret = security_server_check_privilege_by_sockfd(fd,
+                       "data-provider-master::badge.manager", "w");
+       if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
+               ErrPrint("SMACK:not a manager\n");
+               return 0;
+       }
+
+       return 1;
+}
+
+/*!
  * FUNCTIONS to handle badge
  */
 static inline char *get_string(char *string)
@@ -134,7 +167,11 @@ static void _handler_delete_badge(struct tcb *tcb, struct packet *packet, void *
                caller = get_string(caller);
 
                if (pkgname != NULL && caller != NULL) {
-                       ret = badge_db_delete(pkgname, caller);
+                       if (_is_manager_permission(tcb_fd(tcb)) == 1) {
+                               ret = badge_db_delete(pkgname, pkgname);
+                       } else {
+                               ret = badge_db_delete(pkgname, caller);
+                       }
                } else {
                        ret = BADGE_ERROR_INVALID_DATA;
                }
@@ -261,6 +298,97 @@ static void _handler_set_display_option(struct tcb *tcb, struct packet *packet,
        }
 }
 
+static void _handler_set_setting_property(struct tcb *tcb, struct packet *packet, void *data)
+{
+       int ret = 0, ret_p = 0;
+       int is_display = 0;
+       struct packet *packet_reply = NULL;
+       struct packet *packet_service = NULL;
+       char *pkgname = NULL;
+       char *property = NULL;
+       char *value = NULL;
+
+       if (packet_get(packet, "sss", &pkgname, &property, &value) == 3) {
+               pkgname = get_string(pkgname);
+               property = get_string(property);
+               value = get_string(value);
+
+               if (pkgname != NULL && property != NULL && value != NULL) {
+                       ret = badge_setting_db_set(pkgname, property, value);
+               } else {
+                       ret = BADGE_ERROR_INVALID_DATA;
+               }
+
+               packet_reply = packet_create_reply(packet, "ii", ret, ret);
+               if (packet_reply) {
+                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+                               ErrPrint("failed to send reply packet:%d\n", ret_p);
+                       }
+                       packet_destroy(packet_reply);
+               } else {
+                       ErrPrint("failed to create a reply packet\n");
+               }
+
+               if (ret == BADGE_ERROR_NONE) {
+                       if (strcmp(property, "OPT_BADGE") == 0) {
+                               if (strcmp(value, "ON") == 0) {
+                                       is_display = 1;
+                               } else {
+                                       is_display = 0;
+                               }
+
+                               packet_service = packet_create("set_disp_option", "isi", ret, pkgname, is_display);
+                               if (packet_service != NULL) {
+                                       if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+                                               ErrPrint("Failed to send a muticast packet:%d", ret_p);
+                                       }
+                                       packet_destroy(packet_service);
+                               } else {
+                                       ErrPrint("Failed to create a multicast packet");
+                               }
+                       }
+               } else {
+                       ErrPrint("failed to set noti property:%d\n", ret);
+               }
+       } else {
+               ErrPrint("Failed to get data from the packet");
+       }
+}
+
+static void _handler_get_setting_property(struct tcb *tcb, struct packet *packet, void *data)
+{
+       int ret = 0, ret_p = 0;
+       struct packet *packet_reply = NULL;
+       char *pkgname = NULL;
+       char *property = NULL;
+       char *value = NULL;
+
+       if (packet_get(packet, "sss", &pkgname, &property) == 2) {
+               pkgname = get_string(pkgname);
+               property = get_string(property);
+
+               if (pkgname != NULL && property != NULL) {
+                       ret = badge_setting_db_get(pkgname, property, &value);
+               } else {
+                       ret = BADGE_ERROR_INVALID_DATA;
+               }
+
+               packet_reply = packet_create_reply(packet, "is", ret, value);
+               if (packet_reply) {
+                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+                               ErrPrint("failed to send reply packet:%d\n", ret_p);
+                       }
+                       packet_destroy(packet_reply);
+               } else {
+                       ErrPrint("failed to create a reply packet\n");
+               }
+
+               if (value != NULL) {
+                       DbgFree(value);
+               }
+       }
+}
+
 static void _handler_service_register(struct tcb *tcb, struct packet *packet, void *data)
 {
        int ret = 0;
@@ -298,21 +426,6 @@ static void _handler_access_control_error(struct tcb *tcb, struct packet *packet
        }
 }
 
-static int _is_valid_permission(int fd, struct badge_service *service)
-{
-       int ret;
-
-       if (service->rule != NULL && service->access != NULL) {
-               ret = security_server_check_privilege_by_sockfd(fd, service->rule, service->access);
-               if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
-                       ErrPrint("SMACK:Access denied\n");
-                       return 0;
-               }
-       }
-
-       return 1;
-}
-
 /*!
  * SERVICE THREAD
  */
@@ -346,6 +459,18 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                        .access = "w",
                },
                {
+                       .cmd = "set_noti_property",
+                       .handler = _handler_set_setting_property,
+                       .rule = "data-provider-master::badge.client",
+                       .access = "w",
+               },
+               {
+                       .cmd = "get_noti_property",
+                       .handler = _handler_get_setting_property,
+                       .rule = "data-provider-master::badge.client",
+                       .access = "r",
+               },
+               {
                        .cmd = "service_register",
                        .handler = _handler_service_register,
                        .rule = NULL,
index 076ed75..b00a784 100644 (file)
@@ -87,6 +87,8 @@ struct buffer_info
 {
        void *buffer;
        char *id;
+       char *lock;
+       int lock_fd;
 
        enum buffer_type type;
 
@@ -96,6 +98,7 @@ struct buffer_info
        int is_loaded;
 
        struct inst_info *inst;
+       void *data;
 };
 
 static struct {
@@ -112,56 +115,114 @@ static struct {
        .pixmap_list = NULL,
 };
 
-HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buffer_type type, int w, int h, int pixel_size)
+static int destroy_lock_file(struct buffer_info *info)
 {
-       struct buffer_info *info;
+       if (!info->inst) {
+               return LB_STATUS_ERROR_INVALID;
+       }
 
-       info = malloc(sizeof(*info));
-       if (!info) {
+       if (!info->lock) {
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (close(info->lock_fd) < 0) {
+               ErrPrint("close: %s\n", strerror(errno));
+       }
+       info->lock_fd = -1;
+
+       if (unlink(info->lock) < 0) {
+               ErrPrint("unlink: %s\n", strerror(errno));
+       }
+
+       DbgFree(info->lock);
+       info->lock = NULL;
+       return LB_STATUS_SUCCESS;
+}
+
+static int create_lock_file(struct buffer_info *info)
+{
+       const char *id;
+       int len;
+       char *file;
+
+       if (!info->inst) {
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       id = instance_id(info->inst);
+       if (!id) {
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       len = strlen(id);
+       file = malloc(len + 20);
+       if (!file) {
                ErrPrint("Heap: %s\n", strerror(errno));
-               return NULL;
+               return LB_STATUS_ERROR_MEMORY;
        }
 
-       switch (type) {
-       case BUFFER_TYPE_SHM:
-               info->id = strdup(SCHEMA_SHM "-1");
-               if (!info->id) {
-                       ErrPrint("Heap: %s\n", strerror(errno));
-                       DbgFree(info);
-                       return NULL;
-               }
-               break;
-       case BUFFER_TYPE_FILE:
-               info->id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
-               if (!info->id) {
-                       ErrPrint("Heap: %s\n", strerror(errno));
-                       DbgFree(info);
-                       return NULL;
-               }
-               break;
-       case BUFFER_TYPE_PIXMAP:
-               info->id = strdup(SCHEMA_PIXMAP "0");
-               if (!info->id) {
-                       ErrPrint("Heap: %s\n", strerror(errno));
-                       DbgFree(info);
-                       return NULL;
+       snprintf(file, len + 20, "%s.%s.lck", util_uri_to_path(id), instance_pd_buffer(info->inst) == info ? "pd" : "lb");
+       info->lock_fd = open(file, O_WRONLY|O_CREAT, 0644);
+       if (info->lock_fd < 0) {
+               ErrPrint("open: %s\n", strerror(errno));
+               DbgFree(file);
+               return LB_STATUS_ERROR_IO;
+       }
+
+       info->lock = file;
+       return LB_STATUS_SUCCESS;
+}
+
+static int do_buffer_lock(struct buffer_info *buffer)
+{
+       struct flock flock;
+       int ret;
+
+       if (buffer->lock_fd < 0) {
+               return LB_STATUS_SUCCESS;
+       }
+
+       flock.l_type = F_WRLCK;
+       flock.l_whence = SEEK_SET;
+       flock.l_start = 0;
+       flock.l_len = 0;
+       flock.l_pid = getpid();
+
+       do {
+               ret = fcntl(buffer->lock_fd, F_SETLKW, &flock);
+               if (ret < 0) {
+                       ret = errno;
+                       ErrPrint("fcntl: %s\n", strerror(errno));
                }
-               break;
-       default:
-               ErrPrint("Invalid type\n");
-               DbgFree(info);
-               return NULL;
+       } while (ret == EINTR);
+
+       return LB_STATUS_SUCCESS;
+}
+
+static int do_buffer_unlock(struct buffer_info *buffer)
+{
+       struct flock flock;
+       int ret;
+
+       if (buffer->lock_fd < 0) {
+               return LB_STATUS_SUCCESS;
        }
 
-       info->w = w;
-       info->h = h;
-       info->pixel_size = pixel_size;
-       info->type = type;
-       info->is_loaded = 0;
-       info->inst = inst;
-       info->buffer = NULL;
+       flock.l_type = F_UNLCK;
+       flock.l_whence = SEEK_SET;
+       flock.l_start = 0;
+       flock.l_len = 0;
+       flock.l_pid = getpid();
 
-       return info;
+       do {
+               ret = fcntl(buffer->lock_fd, F_SETLKW, &flock);
+               if (ret < 0) {
+                       ret = errno;
+                       ErrPrint("fcntl: %s\n", strerror(errno));
+               }
+       } while (ret == EINTR);
+
+       return LB_STATUS_SUCCESS;
 }
 
 static inline struct buffer *create_pixmap(struct buffer_info *info)
@@ -598,7 +659,7 @@ static inline int load_pixmap_buffer(struct buffer_info *info)
        return LB_STATUS_SUCCESS;
 }
 
-HAPI int buffer_handler_load(struct buffer_info *info)
+EAPI int buffer_handler_load(struct buffer_info *info)
 {
        int ret;
 
@@ -615,9 +676,11 @@ HAPI int buffer_handler_load(struct buffer_info *info)
        switch (info->type) {
        case BUFFER_TYPE_FILE:
                ret = load_file_buffer(info);
+               (void)create_lock_file(info);
                break;
        case BUFFER_TYPE_SHM:
                ret = load_shm_buffer(info);
+               (void)create_lock_file(info);
                break;
        case BUFFER_TYPE_PIXMAP:
                ret = load_pixmap_buffer(info);
@@ -733,7 +796,7 @@ static inline int unload_pixmap_buffer(struct buffer_info *info)
        return LB_STATUS_SUCCESS;
 }
 
-HAPI int buffer_handler_unload(struct buffer_info *info)
+EAPI int buffer_handler_unload(struct buffer_info *info)
 {
        int ret;
 
@@ -749,9 +812,11 @@ HAPI int buffer_handler_unload(struct buffer_info *info)
 
        switch (info->type) {
        case BUFFER_TYPE_FILE:
+               (void)destroy_lock_file(info);
                ret = unload_file_buffer(info);
                break;
        case BUFFER_TYPE_SHM:
+               (void)destroy_lock_file(info);
                ret = unload_shm_buffer(info);
                break;
        case BUFFER_TYPE_PIXMAP:
@@ -770,39 +835,17 @@ HAPI int buffer_handler_unload(struct buffer_info *info)
        return ret;
 }
 
-HAPI int buffer_handler_destroy(struct buffer_info *info)
-{
-       Eina_List *l;
-       struct buffer *buffer;
-
-       if (!info) {
-               DbgPrint("Buffer is not created yet. info is NIL\n");
-               return LB_STATUS_SUCCESS;
-       }
-
-       EINA_LIST_FOREACH(s_info.pixmap_list, l, buffer) {
-               if (buffer->info == info) {
-                       buffer->info = NULL;
-               }
-       }
-
-       buffer_handler_unload(info);
-       DbgFree(info->id);
-       DbgFree(info);
-       return LB_STATUS_SUCCESS;
-}
-
-HAPI const char *buffer_handler_id(const struct buffer_info *info)
+EAPI const char *buffer_handler_id(const struct buffer_info *info)
 {
        return info ? info->id : "";
 }
 
-HAPI enum buffer_type buffer_handler_type(const struct buffer_info *info)
+EAPI enum buffer_type buffer_handler_type(const struct buffer_info *info)
 {
        return info ? info->type : BUFFER_TYPE_ERROR;
 }
 
-HAPI void *buffer_handler_fb(struct buffer_info *info)
+EAPI void *buffer_handler_fb(struct buffer_info *info)
 {
        struct buffer *buffer;
 
@@ -831,7 +874,7 @@ HAPI void *buffer_handler_fb(struct buffer_info *info)
        return buffer->data;
 }
 
-HAPI int buffer_handler_pixmap(const struct buffer_info *info)
+EAPI int buffer_handler_pixmap(const struct buffer_info *info)
 {
        struct buffer *buf;
        struct gem_data *gem;
@@ -856,7 +899,7 @@ HAPI int buffer_handler_pixmap(const struct buffer_info *info)
        return gem->pixmap;
 }
 
-HAPI void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info)
+EAPI void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info)
 {
        struct buffer *buffer;
 
@@ -873,7 +916,7 @@ HAPI void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info)
        return acquire_gem(buffer);
 }
 
-HAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
+EAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
 {
        struct buffer *buffer;
        struct gem_data *gem;
@@ -899,7 +942,7 @@ HAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
 /*!
  * \return "buffer" object (Not the buffer_info)
  */
-HAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
+EAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
 {
        struct buffer *buffer;
 
@@ -960,7 +1003,7 @@ HAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
 /*!
  * \return "buffer"
  */
-HAPI void *buffer_handler_pixmap_find(int pixmap)
+EAPI void *buffer_handler_pixmap_find(int pixmap)
 {
        struct buffer *buffer;
        struct gem_data *gem;
@@ -987,7 +1030,7 @@ HAPI void *buffer_handler_pixmap_find(int pixmap)
        return NULL;
 }
 
-HAPI int buffer_handler_pixmap_release_buffer(void *canvas)
+EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
 {
        struct buffer *buffer;
        struct gem_data *gem;
@@ -1028,7 +1071,7 @@ HAPI int buffer_handler_pixmap_release_buffer(void *canvas)
  * \return Return NULL if the buffer is in still uses.
  *        Return buffer_ptr if it needs to destroy
  */
-HAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
+EAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
 {
        struct buffer *buffer = buffer_ptr;
        struct buffer_info *info;
@@ -1057,12 +1100,12 @@ HAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
        return LB_STATUS_SUCCESS;
 }
 
-HAPI int buffer_handler_is_loaded(const struct buffer_info *info)
+EAPI int buffer_handler_is_loaded(const struct buffer_info *info)
 {
        return info ? info->is_loaded : 0;
 }
 
-HAPI void buffer_handler_update_size(struct buffer_info *info, int w, int h)
+EAPI void buffer_handler_update_size(struct buffer_info *info, int w, int h)
 {
        if (!info) {
                return;
@@ -1072,7 +1115,7 @@ HAPI void buffer_handler_update_size(struct buffer_info *info, int w, int h)
        info->h = h;
 }
 
-HAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
+EAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
 {
        int ret;
 
@@ -1106,7 +1149,7 @@ HAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
        return LB_STATUS_SUCCESS;
 }
 
-HAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
+EAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
 {
        if (!info) {
                return LB_STATUS_ERROR_INVALID;
@@ -1122,7 +1165,7 @@ HAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
        return LB_STATUS_SUCCESS;
 }
 
-HAPI struct inst_info *buffer_handler_instance(struct buffer_info *info)
+EAPI struct inst_info *buffer_handler_instance(struct buffer_info *info)
 {
        return info->inst;
 }
@@ -1240,7 +1283,7 @@ static inline int sync_for_pixmap(struct buffer *buffer)
        return LB_STATUS_SUCCESS;
 }
 
-HAPI void buffer_handler_flush(struct buffer_info *info)
+EAPI void buffer_handler_flush(struct buffer_info *info)
 {
        int fd;
        int size;
@@ -1283,9 +1326,11 @@ HAPI void buffer_handler_flush(struct buffer_info *info)
                }
 
                size = info->w * info->h * info->pixel_size;
+               do_buffer_lock(info);
                if (write(fd, info->buffer, size) != size) {
                        ErrPrint("Write is not completed: %s\n", strerror(errno));
                }
+               do_buffer_unlock(info);
 
                if (close(fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
@@ -1506,7 +1551,7 @@ static inline int raw_close_pixmap(struct buffer *buffer)
        return 0;
 }
 
-HAPI void *buffer_handler_raw_data(struct buffer *buffer)
+EAPI void *buffer_handler_raw_data(struct buffer *buffer)
 {
        if (!buffer || buffer->state != CREATED) {
                return NULL;
@@ -1515,16 +1560,16 @@ HAPI void *buffer_handler_raw_data(struct buffer *buffer)
        return buffer->data;
 }
 
-HAPI int buffer_handler_raw_size(struct buffer *buffer)
+EAPI int buffer_handler_raw_size(struct buffer *buffer)
 {
        if (!buffer || buffer->state != CREATED) {
-               return -EINVAL;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        return (int)buffer->info;
 }
 
-HAPI struct buffer *buffer_handler_raw_open(enum buffer_type buffer_type, void *resource)
+EAPI struct buffer *buffer_handler_raw_open(enum buffer_type buffer_type, void *resource)
 {
        struct buffer *handle;
 
@@ -1546,7 +1591,7 @@ HAPI struct buffer *buffer_handler_raw_open(enum buffer_type buffer_type, void *
        return handle;
 }
 
-HAPI int buffer_handler_raw_close(struct buffer *buffer)
+EAPI int buffer_handler_raw_close(struct buffer *buffer)
 {
        int ret;
 
@@ -1561,11 +1606,147 @@ HAPI int buffer_handler_raw_close(struct buffer *buffer)
                ret = raw_close_pixmap(buffer);
                break;
        default:
-               ret = -EINVAL;
+               ret = LB_STATUS_ERROR_INVALID;
                break;
        }
 
        return ret;
 }
 
+EAPI int buffer_handler_lock(struct buffer_info *buffer)
+{
+       if (buffer->type == BUFFER_TYPE_PIXMAP) {
+               return LB_STATUS_SUCCESS;
+       }
+
+       if (buffer->type == BUFFER_TYPE_FILE) {
+               return LB_STATUS_SUCCESS;
+       }
+
+       return do_buffer_lock(buffer);
+}
+
+EAPI int buffer_handler_unlock(struct buffer_info *buffer)
+{
+       if (buffer->type == BUFFER_TYPE_PIXMAP) {
+               return LB_STATUS_SUCCESS;
+       }
+
+       if (buffer->type == BUFFER_TYPE_FILE) {
+               return LB_STATUS_SUCCESS;
+       }
+
+       return do_buffer_unlock(buffer);
+}
+
+/*!
+ * \note
+ * Only can be used by master.
+ * Plugin cannot access the user data
+ */
+
+HAPI int buffer_handler_set_data(struct buffer_info *buffer, void *data)
+{
+       if (!buffer) {
+               ErrPrint("Invalid handle\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       buffer->data = data;
+       return LB_STATUS_SUCCESS;
+}
+
+HAPI void *buffer_handler_data(struct buffer_info *buffer)
+{
+       if (!buffer) {
+               ErrPrint("Invalid handle\n");
+               return NULL;
+       }
+
+       return buffer->data;
+}
+
+HAPI int buffer_handler_destroy(struct buffer_info *info)
+{
+       Eina_List *l;
+       struct buffer *buffer;
+
+       if (!info) {
+               DbgPrint("Buffer is not created yet. info is NIL\n");
+               return LB_STATUS_SUCCESS;
+       }
+
+       EINA_LIST_FOREACH(s_info.pixmap_list, l, buffer) {
+               if (buffer->info == info) {
+                       buffer->info = NULL;
+               }
+       }
+
+       buffer_handler_unload(info);
+       if (info->lock) {
+               if (unlink(info->lock) < 0) {
+                       ErrPrint("Remove lock: %s (%s)\n", info->lock, strerror(errno));
+               }
+       }
+
+       DbgFree(info->id);
+       DbgFree(info);
+       return LB_STATUS_SUCCESS;
+}
+
+HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buffer_type type, int w, int h, int pixel_size)
+{
+       struct buffer_info *info;
+
+       info = malloc(sizeof(*info));
+       if (!info) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return NULL;
+       }
+
+       switch (type) {
+       case BUFFER_TYPE_SHM:
+               info->id = strdup(SCHEMA_SHM "-1");
+               if (!info->id) {
+                       ErrPrint("Heap: %s\n", strerror(errno));
+                       DbgFree(info);
+                       return NULL;
+               }
+               break;
+       case BUFFER_TYPE_FILE:
+               info->id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
+               if (!info->id) {
+                       ErrPrint("Heap: %s\n", strerror(errno));
+                       DbgFree(info);
+                       return NULL;
+               }
+               break;
+       case BUFFER_TYPE_PIXMAP:
+               info->id = strdup(SCHEMA_PIXMAP "0");
+               if (!info->id) {
+                       ErrPrint("Heap: %s\n", strerror(errno));
+                       DbgFree(info);
+                       return NULL;
+               }
+               break;
+       default:
+               ErrPrint("Invalid type\n");
+               DbgFree(info);
+               return NULL;
+       }
+
+       info->lock = NULL;
+       info->lock_fd = -1;
+       info->w = w;
+       info->h = h;
+       info->pixel_size = pixel_size;
+       info->type = type;
+       info->is_loaded = 0;
+       info->inst = inst;
+       info->buffer = NULL;
+       info->data = NULL;
+
+       return info;
+}
+
 /* End of a file */
index ba04f34..c9e78dc 100644 (file)
@@ -24,6 +24,8 @@
 #include "util.h"
 #include "debug.h"
 
+static const char *CONF_DEFAULT_SERVICES = "[livebox],[shortcut],[notification],[badge],[utility],[file]";
+static const char *CONF_DEFAULT_EMERGENCY_DISK = "source=tmpfs;type=tmpfs;option=size=6M";
 static const char *CONF_DEFAULT_PATH_CONF = "/opt/usr/live/%s/etc/%s.conf";
 static const char *CONF_DEFAULT_PATH_IMAGE = "/opt/usr/share/live_magazine/";
 static const char *CONF_DEFAULT_PATH_LOG = "/opt/usr/share/live_magazine/log";
@@ -33,7 +35,7 @@ static const char *CONF_DEFAULT_PATH_SCRIPT = "/opt/usr/live/%s/res/script/%s.ed
 static const char *CONF_DEFAULT_PATH_ROOT = "/opt/usr/live/";
 static const char *CONF_DEFAULT_PATH_SCRIPT_PORT = "/usr/share/data-provider-master/plugin-script/";
 static const char *CONF_DEFAULT_PATH_DB = "/opt/dbspace/.livebox.db";
-static const char *CONF_DEFAULT_PATH_INPUT = "/dev/input/event1";
+static const char *CONF_DEFAULT_PATH_INPUT = "/dev/input/event2";
 static const char *CONF_DEFAULT_SCRIPT_TYPE = "edje";
 static const char *CONF_DEFAULT_ABI = "c";
 static const char *CONF_DEFAULT_PD_GROUP = "disclosure";
@@ -68,6 +70,7 @@ static const int CONF_DEFAULT_DEBUG_MODE = 0;
 static const int CONF_DEFAULT_OVERWRITE_CONTENT = 0;
 static const int CONF_DEFAULT_COM_CORE_THREAD = 1;
 static const int CONF_DEFAULT_USE_XMONITOR = 0;
+static const int CONF_DEFAULT_PREMULTIPLIED = 1;
 static const double CONF_DEFAULT_SCALE_WIDTH_FACTOR = 1.0f;
 static const double CONF_DEFAULT_SCALE_HEIGHT_FACTOR = 1.0f;
 static const double CONF_DEFAULT_PD_REQUEST_TIMEOUT = 5.0f;
@@ -87,6 +90,22 @@ static void use_xmonitor(char *buffer)
        g_conf.use_xmonitor = !strcasecmp(buffer, "true");
 }
 
+static void emergency_disk_handler(char *buffer)
+{
+       g_conf.emergency_disk = strdup(buffer);
+       if (!g_conf.emergency_disk) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+       }
+}
+
+static void services_handler(char *buffer)
+{
+       g_conf.services = strdup(buffer);
+       if (!g_conf.services) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+       }
+}
+
 static void use_sw_backend_handler(char *buffer)
 {
        g_conf.use_sw_backend = !strcasecmp(buffer, "true");
@@ -331,6 +350,15 @@ static void slave_max_loader(char *buffer)
        }
 }
 
+static void premultiplied_handler(char *buffer)
+{
+       if (sscanf(buffer, "%d", &g_conf.premultiplied) != 1) {
+               ErrPrint("Failed to parse the premultiplied color\n");
+       }
+
+       DbgPrint("Premultiplied: %d\n", g_conf.premultiplied);
+}
+
 static void pd_request_timeout_handler(char *buffer)
 {
        if (sscanf(buffer, "%lf", &g_conf.pd_request_timeout) != 1) {
@@ -366,6 +394,7 @@ HAPI void conf_init(void)
        g_conf.scale_width_factor = CONF_DEFAULT_SCALE_WIDTH_FACTOR;
        g_conf.scale_height_factor = CONF_DEFAULT_SCALE_HEIGHT_FACTOR;
        g_conf.pd_request_timeout = CONF_DEFAULT_PD_REQUEST_TIMEOUT;
+       g_conf.premultiplied = CONF_DEFAULT_PREMULTIPLIED;
        g_conf.default_conf.script = (char *)CONF_DEFAULT_SCRIPT_TYPE;
        g_conf.default_conf.abi = (char *)CONF_DEFAULT_ABI;
        g_conf.default_conf.pd_group = (char *)CONF_DEFAULT_PD_GROUP;
@@ -388,6 +417,8 @@ HAPI void conf_init(void)
        g_conf.path.db = (char *)CONF_DEFAULT_PATH_DB;
        g_conf.path.input = (char *)CONF_DEFAULT_PATH_INPUT;
        g_conf.provider_method = (char *)CONF_DEFAULT_PROVIDER_METHOD;
+       g_conf.emergency_disk = (char *)CONF_DEFAULT_EMERGENCY_DISK;
+       g_conf.services = (char *)CONF_DEFAULT_SERVICES;
 }
 
 HAPI int conf_loader(void)
@@ -526,6 +557,14 @@ HAPI int conf_loader(void)
                        .handler = use_sw_backend_handler,
                },
                {
+                       .name = "emergency_disk",
+                       .handler = emergency_disk_handler,
+               },
+               {
+                       .name = "services",
+                       .handler = services_handler,
+               },
+               {
                        .name = "use_xmonitor",
                        .handler = use_xmonitor,
                },
@@ -554,6 +593,10 @@ HAPI int conf_loader(void)
                        .handler = pd_request_timeout_handler,
                },
                {
+                       .name = "premultiplied",
+                       .handler = premultiplied_handler,
+               },
+               {
                        .name = NULL,
                        .handler = NULL,
                },
@@ -759,6 +802,7 @@ HAPI void conf_reset(void)
        g_conf.scale_width_factor = CONF_DEFAULT_SCALE_WIDTH_FACTOR;
        g_conf.scale_height_factor = CONF_DEFAULT_SCALE_HEIGHT_FACTOR;
        g_conf.pd_request_timeout = CONF_DEFAULT_PD_REQUEST_TIMEOUT;
+       g_conf.premultiplied = CONF_DEFAULT_PREMULTIPLIED;
 
        if (g_conf.default_conf.script != CONF_DEFAULT_SCRIPT_TYPE) {
                DbgFree(g_conf.default_conf.script);
@@ -869,6 +913,16 @@ HAPI void conf_reset(void)
                DbgFree(g_conf.provider_method);
                g_conf.provider_method = (char *)CONF_DEFAULT_PROVIDER_METHOD;
        }
+
+       if (g_conf.emergency_disk != CONF_DEFAULT_EMERGENCY_DISK) {
+               DbgFree(g_conf.emergency_disk);
+               g_conf.emergency_disk = (char *)CONF_DEFAULT_EMERGENCY_DISK;
+       }
+
+       if (g_conf.services != CONF_DEFAULT_SERVICES) {
+               DbgFree(g_conf.services);
+               g_conf.services = (char *)CONF_DEFAULT_SERVICES;
+       }
 }
 
 /* End of a file */
index af19f99..0604c11 100644 (file)
@@ -71,6 +71,7 @@ static struct info {
                .y = -1,
                .device = -1,
                .slot = -1,
+               .keycode = 0,
        },
 
        .event_listener_list = NULL,
@@ -178,6 +179,8 @@ static inline int processing_input_event(struct input_event *event)
                }
                break;
        case EV_KEY:
+               DbgPrint("EV_KEY: 0x%X\n", event->value);
+               s_info.event_data.keycode = event->value;
                break;
        case EV_REL:
                break;
@@ -492,7 +495,7 @@ static int activate_thread(void)
                ErrPrint("Error: %s\n", strerror(errno));
        }
 
-       status = pipe2(s_info.evt_pipe, O_NONBLOCK | O_CLOEXEC);
+       status = pipe2(s_info.evt_pipe, O_CLOEXEC);
        if (status < 0) {
                ErrPrint("Unable to prepare evt pipe: %s\n", strerror(errno));
                if (close(s_info.handle) < 0) {
@@ -502,7 +505,7 @@ static int activate_thread(void)
                return LB_STATUS_ERROR_FAULT;
        }
 
-       status = pipe2(s_info.tcb_pipe, O_NONBLOCK | O_CLOEXEC);
+       status = pipe2(s_info.tcb_pipe, O_CLOEXEC);
        if (status < 0) {
                ErrPrint("Unable to prepare tcb pipe: %s\n", strerror(errno));
                if (close(s_info.handle) < 0) {
diff --git a/src/event_queue.c b/src/event_queue.c
new file mode 100644 (file)
index 0000000..3f07629
--- /dev/null
@@ -0,0 +1,120 @@
+#include <stdio.h>
+#include <sys/eventfd.h>
+#include <pthread.h>
+#include <unistd.h>
+
+#include <Eina.h>
+#include <dlog.h>
+
+#include "debug.h"
+#include "event_queue.h"
+
+struct event_handle {
+       int handle;
+
+       Eina_List *list;
+       pthread_mutex_t list_lock;
+};
+
+struct event_handle *event_queue_create(void)
+{
+       struct event_handle *handle;
+       int status;
+
+       handle = malloc(sizeof(*handle));
+       if (!handle) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return NULL;
+       }
+
+       handle->handle = eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK | EFD_CLOEXEC);
+       if (!handle->handle) {
+               ErrPrint("eventfd: %s\n", strerror(errno));
+               DbgFree(handle);
+               return NULL;
+       }
+
+       status = pthread_mutex_init(&handle->list_lock, NULL);
+       if (status != 0) {
+               ErrPrint("mutex: %s\n", strerror(status));
+               close(handle->handle);
+               DbgFree(handle);
+               return NULL;
+       }
+
+       handle->list = NULL;
+       return handle;
+}
+
+int event_queue_destroy(struct event_handle *handle)
+{
+       void *item;
+       int status;
+
+       if (close(handle->handle) < 0) {
+               ErrPrint("close: %s\n", strerror(errno));
+       }
+
+       CRITICAL_SECTION_BEGIN(&handle->list_lock);
+
+       EINA_LIST_FREE(handle->list, item);
+
+       CRITICAL_SECTION_END(&handle->list_lock);
+
+       status = pthread_mutex_destroy(&handle->list_lock);
+       if (status != 0) {
+               ErrPrint("destroy: %s\n", strerror(status));
+       }
+
+       DbgFree(handle);
+       return 0;
+}
+
+int event_queue_put(struct event_handle *handle, void *data)
+{
+       int status;
+       uint64_t efd_data = 0x0000000000000001llu;
+
+       CRITICAL_SECTION_BEGIN(&handle->list_lock);
+
+       handle->list = eina_list_append(handle->list, data);
+
+       CRITICAL_SECTION_END(&handle->list_lock);
+
+       status = write(handle->handle, &efd_data, sizeof(efd_data));
+       if (status != sizeof(efd_data)) {
+               ErrPrint("read: %s\n", strerror(errno));
+               return -EIO;
+       }
+
+       return 0;
+}
+
+void *event_queue_get(struct event_handle *handle)
+{
+       int status;
+       void *data;
+       uint64_t efd_data;
+
+       status = read(handle->handle, &efd_data, sizeof(efd_data));
+       if (status != sizeof(efd_data)) {
+               ErrPrint("read: %s\n", strerror(errno));
+               return NULL;
+       }
+
+       CRITICAL_SECTION_BEGIN(&handle->list_lock);
+
+       data = eina_list_nth(handle->list, 0);
+       handle->list = eina_list_remove(handle->list, data);
+
+       CRITICAL_SECTION_END(&handle->list_lock);
+
+       return data;
+}
+
+int event_queue_fd(struct event_handle *handle)
+{
+       return handle->handle;
+}
+
+/* End of a file */
diff --git a/src/fb.c b/src/fb.c
deleted file mode 100644 (file)
index 65a4048..0000000
--- a/src/fb.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright 2013  Samsung Electronics Co., Ltd
- *
- * 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://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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <unistd.h> /* access */
-#include <errno.h>
-
-#include <dlog.h>
-#include <Ecore_Evas.h>
-#include <Evas.h>
-#include <livebox-errno.h>
-
-#include "util.h"
-#include "conf.h"
-#include "debug.h"
-#include "buffer_handler.h"
-#include "fb.h"
-
-int errno;
-
-struct fb_info {
-       Ecore_Evas *ee;
-
-       struct buffer_info *buffer;
-};
-
-HAPI int fb_init(void)
-{
-       return LB_STATUS_SUCCESS;
-}
-
-HAPI int fb_fini(void)
-{
-       return LB_STATUS_SUCCESS;
-}
-
-static void *alloc_fb(void *data, int size)
-{
-       struct fb_info *info = data;
-
-       if (buffer_handler_load(info->buffer) < 0) {
-               ErrPrint("Failed to load buffer handler\n");
-               return NULL;
-       }
-
-       return buffer_handler_fb(info->buffer);
-}
-
-static void free_fb(void *data, void *ptr)
-{
-       struct fb_info *info = data;
-
-       if (!info->buffer) {
-               ErrPrint("Buffer is not valid (maybe already released)\n");
-               return;
-       }
-
-       if (buffer_handler_fb(info->buffer) != ptr) {
-               ErrPrint("Buffer pointer is not matched\n");
-       }
-
-       (void)buffer_handler_unload(info->buffer);
-}
-
-HAPI struct fb_info *fb_create(struct inst_info *inst, int w, int h, enum buffer_type type)
-{
-       struct fb_info *info;
-
-       info = calloc(1, sizeof(*info));
-       if (!info) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return NULL;
-       }
-
-       info->buffer = buffer_handler_create(inst, type, w, h, sizeof(int));
-       if (!info->buffer) {
-               ErrPrint("Failed to create a buffer\n");
-               DbgFree(info);
-               return NULL;
-       }
-
-       info->ee = NULL;
-       return info;
-}
-
-static void sw_render_pre_cb(void *data, Evas *e, void *event_info)
-{
-       struct fb_info *info = data;
-       int w;
-       int h;
-
-       buffer_handler_get_size(info->buffer, &w, &h);
-       evas_damage_rectangle_add(e, 0, 0, w, h);
-}
-
-static void sw_render_post_cb(void *data, Evas *e, void *event_info)
-{
-        void *canvas;
-        Ecore_Evas *internal_ee;
-       int x, y, w, h;
-
-        internal_ee = ecore_evas_ecore_evas_get(e);
-        if (!internal_ee) {
-               ErrPrint("Failed to get ecore evas\n");
-                return;
-        }
-
-        // Get a pointer of a buffer of the virtual canvas
-        canvas = (void*)ecore_evas_buffer_pixels_get(internal_ee);
-        if (!canvas) {
-               ErrPrint("Failed to get pixel canvas\n");
-                return;
-        }
-
-       ecore_evas_geometry_get(internal_ee, &x, &y, &w, &h);
-       evas_data_argb_unpremul(canvas, w * h);
-}
-
-static void render_pre_cb(void *data, Evas *e, void *event_info)
-{
-       fb_pixmap_render_pre(data);
-       sw_render_pre_cb(data, e, event_info);
-}
-
-static void render_post_cb(void *data, Evas *e, void *event_info)
-{
-       sw_render_post_cb(data, e, event_info);
-       fb_pixmap_render_post(data);
-}
-
-HAPI int fb_create_buffer(struct fb_info *info)
-{
-       int ow;
-       int oh;
-       Evas *e;
-
-       buffer_handler_get_size(info->buffer, &ow, &oh);
-       if (ow == 0 && oh == 0) {
-               DbgPrint("ZERO Size FB accessed\n");
-               return LB_STATUS_SUCCESS;
-       }
-
-       if (info->ee) {
-               int w = 0;
-               int h = 0;
-
-               ecore_evas_geometry_get(info->ee, NULL, NULL, &w, &h);
-               if (w != ow || h != oh) {
-                       ErrPrint("EE exists, size mismatched requested (%dx%d) but (%dx%d)\n", ow, oh, w, h);
-                       ecore_evas_resize(info->ee, ow, oh);
-               }
-
-               return LB_STATUS_SUCCESS;
-       }
-
-       info->ee = ecore_evas_buffer_allocfunc_new(ow, oh, alloc_fb, free_fb, info);
-       if (!info->ee) {
-               ErrPrint("Failed to create a buffer\n");
-               return LB_STATUS_ERROR_FAULT;
-       }
-
-       e = ecore_evas_get(info->ee);
-       if (buffer_handler_type(info->buffer) == BUFFER_TYPE_PIXMAP) {
-               evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb, info);
-               evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, render_post_cb, info);
-
-               /*!
-                * \note
-                * ecore_evas_alpha_set tries to access the canvas buffer.
-                * Without any render_pre/render_post callback.
-                */
-               fb_pixmap_render_pre(info);
-               ecore_evas_alpha_set(info->ee, EINA_TRUE);
-               fb_pixmap_render_post(info);
-       } else {
-               evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, sw_render_pre_cb, info);
-               evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, sw_render_post_cb, info);
-               ecore_evas_alpha_set(info->ee, EINA_TRUE);
-       }
-
-       return LB_STATUS_SUCCESS;
-}
-
-HAPI int fb_destroy_buffer(struct fb_info *info)
-{
-       if (!info->ee) {
-               ErrPrint("EE is not exists (Maybe ZERO byte ee?)\n");
-               return LB_STATUS_ERROR_INVALID;
-       }
-
-       if (buffer_handler_type(info->buffer) == BUFFER_TYPE_PIXMAP) {
-               Evas *e;
-               e = ecore_evas_get(info->ee);
-               if (e) {
-                       evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, render_post_cb);
-                       evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb);
-               }
-       }
-
-       ecore_evas_free(info->ee);
-       info->ee = NULL;
-       return LB_STATUS_SUCCESS;
-}
-
-HAPI int fb_destroy(struct fb_info *info)
-{
-       fb_destroy_buffer(info);
-       DbgFree(info);
-       return LB_STATUS_SUCCESS;
-}
-
-HAPI Ecore_Evas * const fb_canvas(struct fb_info *info)
-{
-       return info->ee;
-}
-
-HAPI const char *fb_id(struct fb_info *fb)
-{
-       return fb ? buffer_handler_id(fb->buffer) : "";
-}
-
-HAPI int fb_resize(struct fb_info *info, int w, int h)
-{
-       buffer_handler_update_size(info->buffer, w, h);
-
-       if (info->ee) {
-               ecore_evas_resize(info->ee, w, h);
-       } else if (!info->ee && !info->buffer) {
-               /*!
-                * This object has no size at the initial time.
-                * Create a new buffer and use it
-                */
-       }
-
-       return LB_STATUS_SUCCESS;
-}
-
-HAPI int fb_get_size(struct fb_info *info, int *w, int *h)
-{
-       return buffer_handler_get_size(info->buffer, w, h);
-}
-
-HAPI void fb_sync(struct fb_info *info)
-{
-       buffer_handler_flush(info->buffer);
-}
-
-HAPI void *fb_pixmap_render_pre(struct fb_info *info)
-{
-       void *canvas;
-       canvas = buffer_handler_pixmap_acquire_buffer(info->buffer);
-       return canvas;
-}
-
-HAPI int fb_pixmap_render_post(struct fb_info *info)
-{
-       void *canvas;
-
-       /*!
-        * \note
-        * info->buffer == struct buffer_info
-        */
-       canvas = buffer_handler_pixmap_buffer(info->buffer);
-       return buffer_handler_pixmap_release_buffer(canvas);
-}
-
-HAPI struct buffer_info *fb_buffer_info(struct fb_info *info)
-{
-       return info->buffer;
-}
-
-/* End of a file */
index c524dbd..f473ade 100644 (file)
@@ -618,7 +618,7 @@ int file_service_init(void)
                return LB_STATUS_ERROR_ALREADY;
        }
 
-       if (pipe2(s_info.request_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
+       if (pipe2(s_info.request_pipe, O_CLOEXEC) < 0) {
                ErrPrint("pipe: %s\n", strerror(errno));
                return LB_STATUS_ERROR_FAULT;
        }
index 52c392d..3a2f4ba 100644 (file)
@@ -19,7 +19,6 @@
 #include <errno.h>
 
 #include <dlog.h>
-#include <Ecore_Evas.h>
 #include <Eina.h>
 #include <gio/gio.h>
 #include <Ecore.h>
@@ -40,7 +39,6 @@
 #include "package.h"
 #include "script_handler.h"
 #include "buffer_handler.h"
-#include "fb.h"
 #include "setting.h"
 
 int errno;
@@ -109,6 +107,9 @@ struct inst_info {
        int scroll_locked; /*!< Scroller which is in viewer is locked. */
        int active_update; /*!< Viewer will reload the buffer by itself, so the provider doesn't need to send the updated event */
 
+       char *icon;
+       char *name;
+
        enum livebox_visible_state visible;
 
        struct {
@@ -316,7 +317,7 @@ static inline void instance_send_resized_event(struct inst_info *inst, int is_pd
 
        lb_type = package_lb_type(inst->info);
        if (lb_type == LB_TYPE_SCRIPT) {
-               id = fb_id(script_handler_fb(inst->lb.canvas.script));
+               id = script_handler_buffer_id(inst->lb.canvas.script);
        } else if (lb_type == LB_TYPE_BUFFER) {
                id = buffer_handler_id(inst->lb.canvas.buffer);
        } else {
@@ -338,26 +339,22 @@ static void update_mode_cb(struct slave_node *slave, const struct packet *packet
 
        if (!packet) {
                ErrPrint("Invalid packet\n");
-               instance_send_update_mode_event(cbdata->inst, cbdata->active_update, LB_STATUS_ERROR_FAULT);
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata);
-               return;
+               ret = LB_STATUS_ERROR_FAULT;
+               goto out;
        }
 
        if (packet_get(packet, "i", &ret) != 1) {
                ErrPrint("Invalid parameters\n");
-               instance_send_update_mode_event(cbdata->inst, cbdata->active_update, LB_STATUS_ERROR_INVALID);
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata);
-               return;
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
        }
 
        if (ret == LB_STATUS_SUCCESS) {
                cbdata->inst->active_update = cbdata->active_update;
        }
 
+out:
        instance_send_update_mode_event(cbdata->inst, cbdata->active_update, ret);
-
        instance_unref(cbdata->inst);
        DbgFree(cbdata);
 }
@@ -381,7 +378,7 @@ HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_no
        pd_type = package_pd_type(inst->info);
 
        if (lb_type == LB_TYPE_SCRIPT) {
-               lb_file = fb_id(script_handler_fb(inst->lb.canvas.script));
+               lb_file = script_handler_buffer_id(inst->lb.canvas.script);
        } else if (lb_type == LB_TYPE_BUFFER) {
                lb_file = buffer_handler_id(inst->lb.canvas.buffer);
        } else {
@@ -389,7 +386,7 @@ HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_no
        }
 
        if (pd_type == PD_TYPE_SCRIPT) {
-               pd_file = fb_id(script_handler_fb(inst->pd.canvas.script));
+               pd_file = script_handler_buffer_id(inst->pd.canvas.script);
        } else if (pd_type == PD_TYPE_BUFFER) {
                pd_file = buffer_handler_id(inst->pd.canvas.buffer);
        } else {
@@ -442,7 +439,7 @@ static int instance_broadcast_created_event(struct inst_info *inst)
        pd_type = package_pd_type(inst->info);
 
        if (lb_type == LB_TYPE_SCRIPT) {
-               lb_file = fb_id(script_handler_fb(inst->lb.canvas.script));
+               lb_file = script_handler_buffer_id(inst->lb.canvas.script);
        } else if (lb_type == LB_TYPE_BUFFER) {
                lb_file = buffer_handler_id(inst->lb.canvas.buffer);
        } else {
@@ -450,7 +447,7 @@ static int instance_broadcast_created_event(struct inst_info *inst)
        }
 
        if (pd_type == PD_TYPE_SCRIPT) {
-               pd_file = fb_id(script_handler_fb(inst->pd.canvas.script));
+               pd_file = script_handler_buffer_id(inst->pd.canvas.script);
        } else if (pd_type == PD_TYPE_BUFFER) {
                pd_file = buffer_handler_id(inst->pd.canvas.buffer);
        } else {
@@ -599,7 +596,7 @@ HAPI int instance_event_callback_add(struct inst_info *inst, enum instance_event
        return LB_STATUS_SUCCESS;
 }
 
-HAPI int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data))
+HAPI int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data)
 {
        Eina_List *l;
        Eina_List *n;
@@ -608,7 +605,7 @@ HAPI int instance_event_callback_del(struct inst_info *inst, enum instance_event
        switch (type) {
        case INSTANCE_EVENT_DESTROY:
                EINA_LIST_FOREACH_SAFE(inst->delete_event_list, l, n, item) {
-                       if (item->event_cb == event_cb) {
+                       if (item->event_cb == event_cb && item->data == data) {
                                if (inst->in_event_process & INST_EVENT_PROCESS_DELETE) {
                                        item->deleted = 1;
                                } else {
@@ -689,6 +686,8 @@ static inline void destroy_instance(struct inst_info *inst)
        EINA_LIST_FREE(inst->delete_event_list, item) {
                DbgFree(item);
        }
+       DbgFree(inst->icon);
+       DbgFree(inst->name);
        DbgFree(inst->category);
        DbgFree(inst->cluster);
        DbgFree(inst->content);
@@ -801,12 +800,13 @@ HAPI struct inst_info *instance_create(struct client_node *client, double timest
 
        if (client) {
                inst->client = client_ref(client);
-               client_event_callback_add(inst->client, CLIENT_EVENT_DEACTIVATE, client_deactivated_cb, inst);
+               if (client_event_callback_add(inst->client, CLIENT_EVENT_DEACTIVATE, client_deactivated_cb, inst) < 0) {
+                       ErrPrint("Failed to add client event callback: %s\n", inst->id);
+               }
        }
 
        if (fork_package(inst, pkgname) < 0) {
-               client_event_callback_del(inst->client, CLIENT_EVENT_DEACTIVATE, client_deactivated_cb, inst);
-               client_unref(inst->client);
+               (void)client_unref(inst->client);
                DbgFree(inst->title);
                DbgFree(inst->category);
                DbgFree(inst->cluster);
@@ -820,7 +820,6 @@ HAPI struct inst_info *instance_create(struct client_node *client, double timest
        instance_ref(inst);
 
        if (package_add_instance(inst->info, inst) < 0) {
-               instance_state_reset(inst);
                instance_destroy(inst, INSTANCE_DESTROY_FAULT);
                return NULL;
        }
@@ -891,6 +890,8 @@ static void deactivate_cb(struct slave_node *slave, const struct packet *packet,
                goto out;
        }
 
+       DbgPrint("[%s] %d (0x%X)\n", inst->id, ret, inst->state);
+
        if (inst->state == INST_DESTROYED) {
                /*!
                 * \note
@@ -946,7 +947,6 @@ static void deactivate_cb(struct slave_node *slave, const struct packet *packet,
                 * This is not possible, slave will always return LB_STATUS_ERROR_NOT_EXIST, LB_STATUS_ERROR_INVALID, or 0.
                 * but care this exceptional case.
                 */
-               info = inst->info;
                instance_broadcast_deleted_event(inst, ret);
                instance_state_reset(inst);
                instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
@@ -961,7 +961,6 @@ out:
 static void reactivate_cb(struct slave_node *slave, const struct packet *packet, void *data)
 {
        struct inst_info *inst = data;
-       struct pkg_info *info;
        enum lb_type lb_type;
        enum pd_type pd_type;
        int ret;
@@ -1027,9 +1026,8 @@ static void reactivate_cb(struct slave_node *slave, const struct packet *packet,
                        break;
                case INST_ACTIVATED:
                        inst->is_pinned_up = is_pinned_up;
-                       info = inst->info;
-                       lb_type = package_lb_type(info);
-                       pd_type = package_pd_type(info);
+                       lb_type = package_lb_type(inst->info);
+                       pd_type = package_pd_type(inst->info);
 
                        /*!
                         * \note
@@ -1109,7 +1107,6 @@ static void reactivate_cb(struct slave_node *slave, const struct packet *packet,
                }
                break;
        default:
-               info = inst->info;
                instance_broadcast_deleted_event(inst, ret);
                instance_state_reset(inst);
                instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
@@ -1146,6 +1143,8 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v
                goto out;
        }
 
+       DbgPrint("[%s] returns %d (state: 0x%X)\n", inst->id, ret, inst->state);
+
        if (inst->state == INST_DESTROYED) {
                /*!
                 * \note
@@ -1302,7 +1301,7 @@ HAPI int instance_destroy(struct inst_info *inst, enum instance_destroy_type typ
        case INST_INIT:
                inst->state = INST_DESTROYED;
                inst->requested_state = INST_DESTROYED;
-               instance_unref(inst);
+               (void)instance_unref(inst);
                return LB_STATUS_SUCCESS;
        case INST_DESTROYED:
                inst->requested_state = INST_DESTROYED;
@@ -1631,7 +1630,7 @@ HAPI int instance_lb_update_begin(struct inst_info *inst, double priority, const
                        ErrPrint("Script is null [%s]\n", inst->id);
                        return LB_STATUS_ERROR_INVALID;
                }
-               fbfile = fb_id(script_handler_fb(inst->lb.canvas.script));
+               fbfile = script_handler_buffer_id(inst->lb.canvas.script);
                break;
        default:
                ErrPrint("Invalid request[%s]\n", inst->id);
@@ -1706,7 +1705,7 @@ HAPI int instance_pd_update_begin(struct inst_info *inst)
                        ErrPrint("Script is null [%s]\n", inst->id);
                        return LB_STATUS_ERROR_INVALID;
                }
-               fbfile = fb_id(script_handler_fb(inst->pd.canvas.script));
+               fbfile = script_handler_buffer_id(inst->pd.canvas.script);
                break;
        default:
                ErrPrint("Invalid request[%s]\n", inst->id);
@@ -1765,6 +1764,8 @@ HAPI void instance_lb_updated_by_instance(struct inst_info *inst, const char *sa
        enum lb_type lb_type;
        const char *title;
        const char *content;
+       const char *icon;
+       const char *name;
 
        if (inst->client && inst->visible != LB_SHOW) {
                if (inst->visible == LB_HIDE) {
@@ -1776,7 +1777,7 @@ HAPI void instance_lb_updated_by_instance(struct inst_info *inst, const char *sa
 
        lb_type = package_lb_type(inst->info);
        if (lb_type == LB_TYPE_SCRIPT) {
-               id = fb_id(script_handler_fb(inst->lb.canvas.script));
+               id = script_handler_buffer_id(inst->lb.canvas.script);
        } else if (lb_type == LB_TYPE_BUFFER) {
                id = buffer_handler_id(inst->lb.canvas.buffer);
        } else {
@@ -1795,9 +1796,21 @@ HAPI void instance_lb_updated_by_instance(struct inst_info *inst, const char *sa
                title = "";
        }
 
-       packet = packet_create_noack("lb_updated", "sssiidsss",
+       if (inst->icon) {
+               icon = inst->icon;
+       } else {
+               icon = "";
+       }
+
+       if (inst->name) {
+               name = inst->name;
+       } else {
+               name = "";
+       }
+
+       packet = packet_create_noack("lb_updated", "sssiidsssss",
                        package_name(inst->info), inst->id, id,
-                       inst->lb.width, inst->lb.height, inst->lb.priority, content, title, safe_file);
+                       inst->lb.width, inst->lb.height, inst->lb.priority, content, title, safe_file, icon, name);
        if (!packet) {
                ErrPrint("Failed to create param (%s - %s)\n", package_name(inst->info), inst->id);
                return;
@@ -1860,7 +1873,7 @@ HAPI void instance_pd_updated_by_instance(struct inst_info *inst, const char *de
 
        switch (package_pd_type(inst->info)) {
        case PD_TYPE_SCRIPT:
-               id = fb_id(script_handler_fb(inst->pd.canvas.script));
+               id = script_handler_buffer_id(inst->pd.canvas.script);
                break;
        case PD_TYPE_BUFFER:
                id = buffer_handler_id(inst->pd.canvas.buffer);
@@ -1969,6 +1982,36 @@ HAPI void instance_set_lb_info(struct inst_info *inst, double priority, const ch
        }
 }
 
+HAPI void instance_set_alt_info(struct inst_info *inst, const char *icon, const char *name)
+{
+       char *_icon = NULL;
+       char *_name = NULL;
+
+       if (icon && strlen(icon)) {
+               _icon = strdup(icon);
+               if (!_icon) {
+                       ErrPrint("Heap: %s\n", strerror(errno));
+               }
+       }
+
+       if (name && strlen(name)) {
+               _name = strdup(name);
+               if (!_name) {
+                       ErrPrint("Heap: %s\n", strerror(errno));
+               }
+       }
+
+       if (_icon) {
+               DbgFree(inst->icon);
+               inst->icon = _icon;
+       }
+
+       if (_name) {
+               DbgFree(inst->name);
+               inst->name = _name;
+       }
+}
+
 HAPI void instance_set_lb_size(struct inst_info *inst, int w, int h)
 {
        if (inst->lb.width != w || inst->lb.height != h) {
@@ -2724,6 +2767,11 @@ HAPI int instance_recover_state(struct inst_info *inst)
                return LB_STATUS_SUCCESS;
        }
 
+       if (package_is_fault(inst->info)) {
+               ErrPrint("Package is faulted(%s), Delete it\n", inst->id);
+               inst->requested_state = INST_DESTROYED;
+       }
+
        switch (inst->state) {
        case INST_ACTIVATED:
        case INST_REQUEST_TO_REACTIVATE:
@@ -2764,7 +2812,6 @@ HAPI int instance_recover_state(struct inst_info *inst)
                        DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
                        instance_state_reset(inst);
                        instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
-                       ret = 1;
                        break;
                default:
                        break;
@@ -2860,6 +2907,19 @@ HAPI int instance_forward_packet(struct inst_info *inst, struct packet *packet)
        return CLIENT_SEND_EVENT(inst, packet);
 }
 
+HAPI int instance_send_key_status(struct inst_info *inst, int status)
+{
+       struct packet *packet;
+
+       packet = packet_create_noack("key_status", "ssi", package_name(inst->info), inst->id, status);
+       if (!packet) {
+               ErrPrint("Failed to build a packet\n");
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       return CLIENT_SEND_EVENT(inst, packet);
+}
+
 HAPI int instance_send_access_status(struct inst_info *inst, int status)
 {
        struct packet *packet;
@@ -3042,7 +3102,7 @@ HAPI int instance_client_pd_created(struct inst_info *inst, int status)
 
        switch (package_pd_type(inst->info)) {
        case PD_TYPE_SCRIPT:
-               buf_id = fb_id(script_handler_fb(inst->pd.canvas.script));
+               buf_id = script_handler_buffer_id(inst->pd.canvas.script);
                break;
        case PD_TYPE_BUFFER:
                buf_id = buffer_handler_id(inst->pd.canvas.buffer);
index e290da1..fb6e732 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -53,7 +53,7 @@ static int load_abi_table(void)
        FILE *fp;
        int ch;
        int idx = 0;
-       int tag_id = -1;
+       int tag_id = 0;
        enum {
                INIT = 0x0,
                GROUP = 0x1,
index 18fa179..631f45c 100644 (file)
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/signalfd.h>
+#include <ctype.h>
 
 #include <Ecore.h>
 #include <Ecore_X.h>
-#include <Evas.h>
-#include <Ecore_Evas.h>
 #include <glib.h>
 #include <glib-object.h>
 #include <aul.h>
@@ -66,8 +65,8 @@ static inline int app_create(void)
 {
        int ret;
 
-       if (access(SLAVE_LOG_PATH, R_OK|W_OK) != 0) {
-               if (mkdir(SLAVE_LOG_PATH, 755) < 0) {
+       if (access(SLAVE_LOG_PATH, R_OK | W_OK) != 0) {
+               if (mkdir(SLAVE_LOG_PATH, 0755) < 0) {
                        ErrPrint("Failed to create %s (%s)\n", SLAVE_LOG_PATH, strerror(errno));
                }
        }
@@ -121,13 +120,27 @@ static inline int app_create(void)
 
        event_init();
 
-       shortcut_service_init();
-       notification_service_init();
-       badge_service_init();
-       utility_service_init();
+       if (util_service_is_enabled(SERVICE_SHORTCUT)) {
+               shortcut_service_init();
+       }
+
+       if (util_service_is_enabled(SERVICE_NOTIFICATION)) {
+               notification_service_init();
+       }
+
+       if (util_service_is_enabled(SERVICE_BADGE)) {
+               badge_service_init();
+       }
+
+       if (util_service_is_enabled(SERVICE_UTILITY)) {
+               utility_service_init();
+       }
+
        script_init();
 
-       file_service_init();
+       if (util_service_is_enabled(SERVICE_FILE)) {
+               file_service_init();
+       }
 
        return 0;
 }
@@ -136,8 +149,10 @@ static inline int app_terminate(void)
 {
        int ret;
 
-       ret = file_service_fini();
-       DbgPrint("Finalize the file service: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_FILE)) {
+               ret = file_service_fini();
+               DbgPrint("Finalize the file service: %d\n", ret);
+       }
 
        ret = server_fini();
        DbgPrint("Finalize server: %d\n", ret);
@@ -145,17 +160,25 @@ static inline int app_terminate(void)
        ret = dead_fini();
        DbgPrint("dead signal handler finalized: %d\n", ret);
 
-       ret = utility_service_fini();
-       DbgPrint("utility: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_UTILITY)) {
+               ret = utility_service_fini();
+               DbgPrint("utility: %d\n", ret);
+       }
 
-       ret = badge_service_fini();
-       DbgPrint("badge: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_BADGE)) {
+               ret = badge_service_fini();
+               DbgPrint("badge: %d\n", ret);
+       }
 
-       ret = notification_service_fini();
-       DbgPrint("noti: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_NOTIFICATION)) {
+               ret = notification_service_fini();
+               DbgPrint("noti: %d\n", ret);
+       }
 
-       ret = shortcut_service_fini();
-       DbgPrint("shortcut: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_SHORTCUT)) {
+               ret = shortcut_service_fini();
+               DbgPrint("shortcut: %d\n", ret);
+       }
 
        ret = event_fini();
        DbgPrint("event: %d\n", ret);
@@ -260,6 +283,13 @@ int main(int argc, char *argv[])
        (void)util_unlink_files(IMAGE_PATH);
        (void)util_unlink_files(SLAVE_LOG_PATH);
 
+       if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
+               util_remove_emergency_disk();
+               util_prepare_emergency_disk();
+       }
+
+       util_setup_log_disk();
+
        /*!
         * How could we care this return values?
         * Is there any way to print something on the screen?
@@ -321,23 +351,6 @@ int main(int argc, char *argv[])
 
        ecore_app_args_set(argc, (const char **)argv);
 
-       if (evas_init() <= 0) {
-               CRITICAL_LOG("Failed to init evas return count is below than 0\n");
-               ecore_x_shutdown();
-               ecore_shutdown();
-               critical_log_fini();
-               return -EFAULT;
-       }
-
-       if (ecore_evas_init() <= 0) {
-               CRITICAL_LOG("Failed to init ecore_evas\n");
-               evas_shutdown();
-               ecore_x_shutdown();
-               ecore_shutdown();
-               critical_log_fini();
-               return -EFAULT;
-       }
-
 #if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36)
        g_type_init();
 #endif
@@ -360,9 +373,6 @@ int main(int argc, char *argv[])
 
        app_terminate();
 
-       evas_shutdown();
-       ecore_evas_shutdown();
-
        ecore_x_shutdown();
 
        if (signal_handler) {
index 0149b7f..3e64ef9 100755 (executable)
 #include <sys/smack.h>
 #include <security-server.h>
 
+#include <vconf.h>
 #include <notification_ipc.h>
 #include <notification_noti.h>
 #include <notification_error.h>
+#include <notification_setting_service.h>
 
 #include "service_common.h"
 #include "debug.h"
@@ -100,6 +102,40 @@ static inline struct packet *create_packet_from_deleted_list(int op_num, int *li
                );
 }
 
+static void _notification_data_init(void)
+{
+       int property = 0;
+       int priv_id = 0;
+       char *noti_pkgname = NULL;
+       notification_h noti = NULL;
+       notification_list_h noti_list = NULL;
+       notification_list_h noti_list_head = NULL;
+       notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
+
+       notification_get_list(NOTIFICATION_TYPE_NONE, -1, &noti_list);
+       noti_list_head = noti_list;
+
+       while (noti_list != NULL) {
+               noti = notification_list_get_data(noti_list);
+               if (noti) {
+                       notification_get_id(noti, NULL, &priv_id);
+                       notification_get_pkgname(noti, &noti_pkgname);
+                       notification_get_property(noti, &property);
+                       notification_get_type(noti, &noti_type);
+
+                       if (noti_type == NOTIFICATION_TYPE_ONGOING
+                                       || property & NOTIFICATION_PROP_VOLATILE_DISPLAY) {
+                               notification_noti_delete_by_priv_id(noti_pkgname, priv_id);
+                       }
+               }
+               noti_list = notification_list_get_next(noti_list);
+       }
+
+       if (noti_list_head != NULL) {
+               notification_free_list(noti_list_head);
+       }
+}
+
 /*!
  * SERVICE HANDLER
  */
@@ -332,6 +368,79 @@ static void _handler_delete_multiple(struct tcb *tcb, struct packet *packet, voi
        }
 }
 
+static void _handler_set_noti_property(struct tcb *tcb, struct packet *packet, void *data)
+{
+       int ret = 0, ret_p = 0;
+       struct packet *packet_reply = NULL;
+       char *pkgname = NULL;
+       char *property = NULL;
+       char *value = NULL;
+
+       if (packet_get(packet, "sss", &pkgname, &property, &value) == 3) {
+               pkgname = get_string(pkgname);
+               property = get_string(property);
+               value = get_string(value);
+
+               ret = notification_setting_db_set(pkgname, property, value);
+
+               packet_reply = packet_create_reply(packet, "ii", ret, ret);
+               if (packet_reply) {
+                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+                               ErrPrint("failed to send reply packet:%d\n", ret_p);
+                       }
+                       packet_destroy(packet_reply);
+               } else {
+                       ErrPrint("failed to create a reply packet\n");
+               }
+
+               if (ret != NOTIFICATION_ERROR_NONE) {
+                       ErrPrint("failed to set noti property:%d\n", ret);
+               }
+       } else {
+               ErrPrint("Failed to get data from the packet");
+       }
+}
+
+static void _handler_get_noti_property(struct tcb *tcb, struct packet *packet, void *data)
+{
+       int ret = 0, ret_p = 0;
+       struct packet *packet_reply = NULL;
+       char *pkgname = NULL;
+       char *property = NULL;
+       char *value = NULL;
+
+       if (packet_get(packet, "sss", &pkgname, &property) == 2) {
+               pkgname = get_string(pkgname);
+               property = get_string(property);
+
+               ret = notification_setting_db_get(pkgname, property, &value);
+
+               packet_reply = packet_create_reply(packet, "is", ret, value);
+               if (packet_reply) {
+                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+                               ErrPrint("failed to send reply packet:%d\n", ret_p);
+                       }
+                       packet_destroy(packet_reply);
+               } else {
+                       ErrPrint("failed to create a reply packet\n");
+               }
+
+               if (value != NULL) {
+                       DbgFree(value);
+               }
+       }
+}
+
+static void _notification_init(void) {
+       int ret = -1;
+       int restart_count = 0;
+
+       ret = vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
+       if (ret == 0 && restart_count <= 1) {
+               _notification_data_init();
+       }
+}
+
 static void _handler_service_register(struct tcb *tcb, struct packet *packet, void *data)
 {
        int ret = 0;
@@ -382,6 +491,22 @@ static void _handler_access_control_error_refresh(struct tcb *tcb, struct packet
        }
 }
 
+static void _handler_access_control_error_get_property(struct tcb *tcb, struct packet *packet)
+{
+       int ret_p = 0;
+       struct packet *packet_reply = NULL;
+
+       packet_reply = packet_create_reply(packet, "is", NOTIFICATION_ERROR_PERMISSION_DENIED, NULL);
+       if (packet_reply) {
+               if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+                       ErrPrint("Failed to send a reply packet:%d", ret_p);
+               }
+               packet_destroy(packet_reply);
+       } else {
+               ErrPrint("Failed to create a reply packet");
+       }
+}
+
 static int _is_valid_permission(int fd, struct noti_service *service)
 {
        int ret;
@@ -441,6 +566,20 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                        .handler_access_error = _handler_access_control_error_common,
                },
                {
+                       .cmd = "set_noti_property",
+                       .handler = _handler_set_noti_property,
+                       .rule = "data-provider-master::notification.client",
+                       .access = "w",
+                       .handler_access_error = _handler_access_control_error_common,
+               },
+               {
+                       .cmd = "get_noti_property",
+                       .handler = _handler_get_noti_property,
+                       .rule = "data-provider-master::notification.client",
+                       .access = "r",
+                       .handler_access_error = _handler_access_control_error_get_property,
+               },
+               {
                        .cmd = "service_register",
                        .handler = _handler_service_register,
                        .rule = NULL,
@@ -521,6 +660,8 @@ HAPI int notification_service_init(void)
                return LB_STATUS_ERROR_ALREADY;
        }
 
+       _notification_init();
+
        s_info.svc_ctx = service_common_create(NOTIFICATION_SOCKET, service_thread_main, NULL);
        if (!s_info.svc_ctx) {
                ErrPrint("Unable to activate service thread\n");
index 2aa6e20..24b0017 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <dlog.h>
 #include <Eina.h>
-#include <Ecore_Evas.h>
 
 #include <packet.h>
 #include <livebox-errno.h>
@@ -282,11 +281,9 @@ static int slave_resumed_cb(struct slave_node *slave, void *data)
 
 static inline void destroy_package(struct pkg_info *info)
 {
-       struct context_info *ctx_info __attribute__((unused));
-
-       EINA_LIST_FREE(info->ctx_list, ctx_info) {
-               /* This items will be deleted from group_del_livebox */
-       }
+       eina_list_free(info->ctx_list);
+       /* This items will be deleted from group_del_livebox */
+       info->ctx_list = NULL;
 
        group_del_livebox(info->lbid);
        package_clear_fault(info);
@@ -1141,15 +1138,15 @@ HAPI int package_add_instance(struct pkg_info *info, struct inst_info *inst)
                        DbgPrint("Slave %s is used for %s\n", slave_name(info->slave), info->lbid);
                }
 
-               slave_ref(info->slave);
+               (void)slave_ref(info->slave);
                slave_load_package(info->slave);
-               slave_event_callback_add(info->slave, SLAVE_EVENT_DEACTIVATE, slave_deactivated_cb, info);
-               slave_event_callback_add(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
-               slave_event_callback_add(info->slave, SLAVE_EVENT_FAULT, slave_fault_cb, info);
+               (void)slave_event_callback_add(info->slave, SLAVE_EVENT_DEACTIVATE, slave_deactivated_cb, info);
+               (void)slave_event_callback_add(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
+               (void)slave_event_callback_add(info->slave, SLAVE_EVENT_FAULT, slave_fault_cb, info);
 
                if (info->secured) {
-                       slave_event_callback_add(info->slave, SLAVE_EVENT_PAUSE, slave_paused_cb, info);
-                       slave_event_callback_add(info->slave, SLAVE_EVENT_RESUME, slave_resumed_cb, info);
+                       (void)slave_event_callback_add(info->slave, SLAVE_EVENT_PAUSE, slave_paused_cb, info);
+                       (void)slave_event_callback_add(info->slave, SLAVE_EVENT_RESUME, slave_resumed_cb, info);
 
                        /*!
                         * \note
@@ -1159,8 +1156,8 @@ HAPI int package_add_instance(struct pkg_info *info, struct inst_info *inst)
                         *
                         * This callback will freeze the timer only if a slave doesn't running.
                         */
-                       xmonitor_add_event_callback(XMONITOR_PAUSED, xmonitor_paused_cb, info);
-                       xmonitor_add_event_callback(XMONITOR_RESUMED, xmonitor_resumed_cb, info);
+                       (void)xmonitor_add_event_callback(XMONITOR_PAUSED, xmonitor_paused_cb, info);
+                       (void)xmonitor_add_event_callback(XMONITOR_RESUMED, xmonitor_resumed_cb, info);
                }
        }
 
@@ -1524,7 +1521,7 @@ HAPI int package_alter_instances_to_client(struct client_node *client, enum alte
                                        break;
                                case ALTER_DESTROY:
                                        if (instance_has_client(inst, client)) {
-                                               instance_unicast_deleted_event(inst, client);
+                                               instance_unicast_deleted_event(inst, client, LB_STATUS_SUCCESS);
                                                instance_del_client(inst, client);
                                        }
                                        break;
index e68fb64..a7633bd 100644 (file)
@@ -33,7 +33,7 @@
 static Eina_List *s_list;
 int errno;
 
-#if __x86_64__
+#if __x86__64__
 #define RETURN_TYPE long long
 #else
 #define RETURN_TYPE int
index 2e6d5ac..1c6ab94 100644 (file)
@@ -27,9 +27,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include <Ecore_Evas.h>
 #include <Ecore.h>
-#include <Evas.h>
 #include <Eina.h>
 
 #include <dlog.h>
@@ -43,7 +41,6 @@
 #include "instance.h"
 #include "buffer_handler.h"
 #include "script_handler.h"
-#include "fb.h"
 #include "debug.h"
 #include "conf.h"
 #include "util.h"
@@ -90,25 +87,25 @@ struct script_port {
        void *handle;
 
        const char *(*magic_id)(void);
-       int (*update_color)(void *handle, Evas *e, const char *id, const char *part, const char *rgba);
-       int (*update_text)(void *handle, Evas *e, const char *id, const char *part, const char *text);
-       int (*update_image)(void *handle, Evas *e, const char *id, const char *part, const char *path, const char *option);
-       int (*update_access)(void *handle, Evas *e, const char *id, const char *part, const char *text, const char *option);
-       int (*operate_access)(void *handle, Evas *e, const char *id, const char *part, const char *operation, const char *option);
-       int (*update_script)(void *handle, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *option);
-       int (*update_signal)(void *handle, Evas *e, const char *id, const char *part, const char *signal);
-       int (*update_drag)(void *handle, Evas *e, const char *id, const char *part, double x, double y);
-       int (*update_size)(void *handle, Evas *e, const char *id, int w, int h);
-       int (*update_category)(void *handle, Evas *e, const char *id, const char *category);
-       int (*feed_event)(void *handle, Evas *e, int event_type, int x, int y, int down, double timestamp);
-
-       void *(*create)(const char *file, const char *option);
+       int (*update_color)(void *handle, const char *id, const char *part, const char *rgba);
+       int (*update_text)(void *handle, const char *id, const char *part, const char *text);
+       int (*update_image)(void *handle, const char *id, const char *part, const char *path, const char *option);
+       int (*update_access)(void *handle, const char *id, const char *part, const char *text, const char *option);
+       int (*operate_access)(void *handle, const char *id, const char *part, const char *operation, const char *option);
+       int (*update_script)(void *handle, const char *src_id, const char *target_id, const char *part, const char *path, const char *option);
+       int (*update_signal)(void *handle, const char *id, const char *part, const char *signal);
+       int (*update_drag)(void *handle, const char *id, const char *part, double x, double y);
+       int (*update_size)(void *handle, const char *id, int w, int h);
+       int (*update_category)(void *handle, const char *id, const char *category);
+       int (*feed_event)(void *handle, int event_type, int x, int y, int down, unsigned int keycode, double timestamp);
+
+       void *(*create)(void *buffer_info, const char *file, const char *option);
        int (*destroy)(void *handle);
 
-       int (*load)(void *handle, Evas *e, int w, int h);
-       int (*unload)(void *handle, Evas *e);
+       int (*load)(void *handle, int (*render_pre)(void *buffer_info, void *data), int (*render_post)(void *buffer_info, void *data), void *data);
+       int (*unload)(void *handle);
 
-       int (*init)(double scale);
+       int (*init)(double scale, int premultiplied);
        int (*fini)(void);
 };
 
@@ -150,9 +147,7 @@ struct block {
 };
 
 struct script_info {
-       Ecore_Evas *ee;
-       struct fb_info *fb;
-       struct inst_info *inst;
+       struct buffer_info *buffer_handle; 
        int loaded;
 
        int w;
@@ -162,6 +157,8 @@ struct script_info {
        int y;
        int down;
 
+       unsigned int keycode;
+
        struct script_port *port;
        void *port_data;
 
@@ -315,7 +312,7 @@ static int load_all_ports(void)
                        goto errout;
                }
 
-               if (item->init(SCALE_WIDTH_FACTOR) < 0) {
+               if (item->init(SCALE_WIDTH_FACTOR, PREMULTIPLIED_COLOR) < 0) {
                        ErrPrint("Failed to initialize script engine\n");
                        goto errout;
                }
@@ -370,91 +367,76 @@ static inline void delete_block(struct block *block)
        DbgFree(block);
 }
 
-static void render_pre_cb(void *data, Evas *e, void *event_info)
+static int render_post_cb(void *_buffer_handle, void *data)
 {
        PERF_INIT();
        PERF_BEGIN();
-       struct inst_info *inst = data;
+       struct inst_info *inst;
+       struct buffer_info *buffer_handle = _buffer_handle;
        struct script_info *info;
 
-       if (instance_state(inst) != INST_ACTIVATED) {
-               ErrPrint("Render pre invoked but instance is not activated\n");
-               goto out;
-       }
-
-       info = instance_lb_script(inst);
-       if (info && script_handler_evas(info) == e) {
+       inst = buffer_handler_instance(buffer_handle);
+       if (!inst) {
                goto out;
        }
 
-       info = instance_pd_script(inst);
-       if (info && script_handler_evas(info) == e) {
-               goto out;
-       }
-
-       ErrPrint("Failed to do sync\n");
-out:
-       PERF_MARK("render,pre");
-       return;
-}
-
-static void render_post_cb(void *data, Evas *e, void *event_info)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct inst_info *inst;
-       struct script_info *info;
-
-       inst = data;
-
        if (instance_state(inst) != INST_ACTIVATED) {
                ErrPrint("Render post invoked but instance is not activated\n");
                PERF_MARK(__func__);
-               return;
+               return LB_STATUS_ERROR_INVALID;
        }
 
        info = instance_lb_script(inst);
-       if (info && script_handler_evas(info) == e) {
-               fb_sync(script_handler_fb(info));
+       if (info && info == data) {
+               buffer_handler_flush(buffer_handle);
                instance_lb_updated_by_instance(inst, NULL);
                PERF_MARK("lb,update");
-               return;
+               return LB_STATUS_SUCCESS;
        }
 
        info = instance_pd_script(inst);
-       if (info && script_handler_evas(info) == e) {
-               fb_sync(script_handler_fb(info));
+       if (info && info == data) {
+               buffer_handler_flush(buffer_handle);
                instance_pd_updated_by_instance(inst, NULL);
                PERF_MARK("pd,update");
-               return;
+               return LB_STATUS_SUCCESS;
        }
 
+out:
        ErrPrint("Failed to sync\n");
        PERF_MARK(__func__);
-       return;
+       return LB_STATUS_ERROR_FAULT;
 }
 
 /*!
  * \NOTE
  * Exported API
  */
-int script_signal_emit(Evas *e, const char *part, const char *signal, double sx, double sy, double ex, double ey)
+EAPI int script_signal_emit(void *buffer_handle, const char *part, const char *signal, double sx, double sy, double ex, double ey)
 {
-       Ecore_Evas *ee;
        struct script_info *info;
+       struct inst_info *inst;
+       int w;
+       int h;
+       double fx;
+       double fy;
 
-       ee = ecore_evas_ecore_evas_get(e);
-       if (!ee) {
-               ErrPrint("Evas has no Ecore_Evas\n");
+       if (!buffer_handle) {
+               ErrPrint("Invalid handle\n");
                return LB_STATUS_ERROR_INVALID;
        }
 
-       info = ecore_evas_data_get(ee, "script,info");
+       info = buffer_handler_data(buffer_handle);
        if (!info) {
-               ErrPrint("ecore_evas doesn't carry info data\n");
+               ErrPrint("Invalid handle\n");
                return LB_STATUS_ERROR_INVALID;
        }
 
+       inst = buffer_handler_instance(buffer_handle);
+       if (!inst) {
+               return LB_STATUS_ERROR_FAULT;
+       }
+
        if (!signal || strlen(signal) == 0) {
                signal = "";
        }
@@ -463,22 +445,35 @@ int script_signal_emit(Evas *e, const char *part, const char *signal, double sx,
                part = "";
        }
 
-       return instance_signal_emit(info->inst, signal, part, sx, sy, ex, ey, (double)info->x / (double)info->w, (double)info->y / (double)info->h, info->down);
+       buffer_handler_get_size(buffer_handle, &w, &h);
+
+       fx = (double)info->x / (double)w;
+       fy = (double)info->y / (double)h;
+
+       return instance_signal_emit(inst, signal, part, sx, sy, ex, ey, fx, fy, info->down);
 }
 
 static inline void flushing_cached_block(struct script_info *info)
 {
        struct block *block;
+       struct inst_info *inst;
+       int is_pd;
+
+       inst = buffer_handler_instance(info->buffer_handle);
+       if (!inst) {
+               ErrPrint("Instance is not valid\n");
+       }
+
+       is_pd = instance_pd_script(inst) == info;
 
        EINA_LIST_FREE(info->cached_blocks, block) {
-               consuming_parsed_block(info->inst, (instance_pd_script(info->inst) == info), block);
+               consuming_parsed_block(inst, is_pd, block);
        }
 }
 
 HAPI int script_handler_load(struct script_info *info, int is_pd)
 {
-       int ret;
-       Evas *e;
+       struct inst_info *inst;
 
        if (!info || !info->port) {
                ErrPrint("Script handler is not created\n");
@@ -490,86 +485,43 @@ HAPI int script_handler_load(struct script_info *info, int is_pd)
                return LB_STATUS_SUCCESS;
        }
 
-       ret = fb_create_buffer(info->fb);
-       if (ret < 0) {
-               return ret;
-       }
-
-       info->ee = fb_canvas(info->fb);
-       if (!info->ee) {
-               ErrPrint("Failed to get canvas\n");
-               fb_destroy_buffer(info->fb);
+       if (info->port->load(info->port_data, NULL, render_post_cb, info) < 0) {
+               ErrPrint("Unable to load the script\n");
                return LB_STATUS_ERROR_FAULT;
        }
 
-       ecore_evas_data_set(info->ee, "script,info", info);
+       info->loaded = 1;
+       flushing_cached_block(info);
 
-       e = script_handler_evas(info);
-       if (e) {
-               evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb, info->inst);
-               evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, render_post_cb, info->inst);
-               if (info->port->load(info->port_data, e, info->w, info->h) < 0) {
-                       ErrPrint("Failed to add new script object\n");
-                       evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, render_post_cb);
-                       evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb);
-                       fb_destroy_buffer(info->fb);
-                       return LB_STATUS_ERROR_FAULT;
-               }
-               info->loaded = 1;
-               flushing_cached_block(info);
-               script_signal_emit(e, instance_id(info->inst),
+       inst = buffer_handler_instance(info->buffer_handle);
+       if (inst) {
+               script_signal_emit(info->buffer_handle, instance_id(inst),
                                is_pd ? "pd,show" : "lb,show", 0.0f, 0.0f, 0.0f, 0.0f);
-       } else {
-               ErrPrint("Evas: (nil) %dx%d\n", info->w, info->h);
        }
-
-       ecore_evas_manual_render_set(info->ee, EINA_FALSE);
-       ecore_evas_resize(info->ee, info->w, info->h);
-       ecore_evas_show(info->ee);
-       ecore_evas_activate(info->ee);
-       fb_sync(info->fb);
-
+       buffer_handler_flush(info->buffer_handle);
        return LB_STATUS_SUCCESS;
 }
 
 HAPI int script_handler_unload(struct script_info *info, int is_pd)
 {
-       Ecore_Evas *ee;
-       Evas *e;
-
        if (!info || !info->port) {
                return LB_STATUS_ERROR_INVALID;
        }
 
        info->loaded--;
        if (info->loaded > 0) {
-               return LB_STATUS_SUCCESS;
+               return LB_STATUS_ERROR_BUSY;
        }
 
        if (info->loaded < 0) {
                info->loaded = 0;
-               return LB_STATUS_SUCCESS;
-       }
-
-       e = script_handler_evas(info);
-       if (e) {
-               script_signal_emit(e, instance_id(info->inst),
-                               is_pd ? "pd,hide" : "lb,hide", 0.0f, 0.0f, 0.0f, 0.0f);
-               if (info->port->unload(info->port_data, e) < 0) {
-                       ErrPrint("Failed to unload script object. but go ahead\n");
-               }
-               evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, render_post_cb);
-               evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb);
-       } else {
-               ErrPrint("Evas(nil): Unload script\n");
+               return LB_STATUS_ERROR_ALREADY;
        }
 
-       ee = fb_canvas(info->fb);
-       if (ee) {
-               ecore_evas_data_set(ee, "script,info", NULL);
+       if (info->port->unload(info->port_data) < 0) {
+               ErrPrint("Failed to unload script object. but go ahead\n");
        }
 
-       fb_destroy_buffer(info->fb);
        return LB_STATUS_SUCCESS;
 }
 
@@ -589,30 +541,28 @@ HAPI struct script_info *script_handler_create(struct inst_info *inst, const cha
                return NULL;
        }
 
-       info->fb = fb_create(inst, w, h, s_info.env_buf_type);
-       if (!info->fb) {
-               ErrPrint("Failed to create a FB (%dx%d)\n", w, h);
+       info->buffer_handle = buffer_handler_create(inst, s_info.env_buf_type, w, h, sizeof(int));
+       if (!info->buffer_handle) {
+               /* buffer_handler_create will prints some log */
                DbgFree(info);
                return NULL;
        }
 
-       info->inst = inst;
+       (void)buffer_handler_set_data(info->buffer_handle, info);
+
        info->port = find_port(package_script(instance_package(inst)));
        if (!info->port) {
                ErrPrint("Failed to find a proper port for [%s]%s\n",
                                        instance_package(inst), package_script(instance_package(inst)));
-               fb_destroy(info->fb);
+               buffer_handler_destroy(info->buffer_handle);
                DbgFree(info);
                return NULL;
        }
 
-       info->w = w;
-       info->h = h;
-
-       info->port_data = info->port->create(file, option);
+       info->port_data = info->port->create(info->buffer_handle, file, option);
        if (!info->port_data) {
                ErrPrint("Failed to create a port (%s - %s)\n", file, option);
-               fb_destroy(info->fb);
+               buffer_handler_destroy(info->buffer_handle);
                DbgFree(info);
                return NULL;
        }
@@ -632,7 +582,7 @@ HAPI int script_handler_destroy(struct script_info *info)
 
        if (info->loaded != 0) {
                ErrPrint("Script handler is not unloaded\n");
-               return LB_STATUS_ERROR_INVALID;
+               return LB_STATUS_ERROR_BUSY;
        }
 
        ret = info->port->destroy(info->port_data);
@@ -640,11 +590,12 @@ HAPI int script_handler_destroy(struct script_info *info)
                ErrPrint("Failed to destroy port, but go ahead: %d\n", ret);
        }
 
-       fb_destroy(info->fb);
+       (void)buffer_handler_destroy(info->buffer_handle);
 
        EINA_LIST_FREE(info->cached_blocks, block) {
                delete_block(block);
        }
+
        DbgFree(info);
        return LB_STATUS_SUCCESS;
 }
@@ -654,22 +605,13 @@ HAPI int script_handler_is_loaded(struct script_info *info)
        return info ? info->loaded > 0 : 0;
 }
 
-HAPI struct fb_info *script_handler_fb(struct script_info *info)
-{
-       return info ? info->fb : NULL;
-}
-
-HAPI void *script_handler_evas(struct script_info *info)
+HAPI struct buffer_info *script_handler_buffer_info(struct script_info *info)
 {
        if (!info) {
                return NULL;
        }
 
-       if (!info->ee) {
-               return NULL;
-       }
-
-       return ecore_evas_get(info->ee);
+       return info->buffer_handle;
 }
 
 static int update_script_color(struct inst_info *inst, struct block *block, int is_pd)
@@ -677,7 +619,7 @@ static int update_script_color(struct inst_info *inst, struct block *block, int
        PERF_INIT();
        PERF_BEGIN();
        struct script_info *info;
-       Evas *e;
+       int ret;
 
        if (!block || !block->part || !block->data) {
                ErrPrint("Block or part or data is not valid\n");
@@ -698,15 +640,9 @@ static int update_script_color(struct inst_info *inst, struct block *block, int
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (e) {
-               info->port->update_color(info->port_data, e, block->id, block->part, block->data);
-       } else {
-               ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
-       }
+       ret = info->port->update_color(info->port_data, block->id, block->part, block->data);
        PERF_MARK("color");
-
-       return LB_STATUS_SUCCESS;
+       return ret;
 }
 
 static int update_script_text(struct inst_info *inst, struct block *block, int is_pd)
@@ -714,7 +650,7 @@ static int update_script_text(struct inst_info *inst, struct block *block, int i
        PERF_INIT();
        PERF_BEGIN();
        struct script_info *info;
-       Evas *e;
+       int ret;
 
        if (!block || !block->part || !block->data) {
                ErrPrint("Block or part or data is not valid\n");
@@ -735,15 +671,11 @@ static int update_script_text(struct inst_info *inst, struct block *block, int i
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (e) {
-               info->port->update_text(info->port_data, e, block->id, block->part, block->data);
-       } else {
-               ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
-       }
-
+       DbgPrint("[%s] %s (%s)\n", block->id, block->part, block->data);
+       ret = info->port->update_text(info->port_data, block->id, block->part, block->data);
+       
        PERF_MARK("text");
-       return LB_STATUS_SUCCESS;
+       return ret;
 }
 
 static int update_script_image(struct inst_info *inst, struct block *block, int is_pd)
@@ -751,7 +683,7 @@ static int update_script_image(struct inst_info *inst, struct block *block, int
        PERF_INIT();
        PERF_BEGIN();
        struct script_info *info;
-       Evas *e;
+       int ret;
 
        if (!block || !block->part) {
                ErrPrint("Block or part is not valid\n");
@@ -772,14 +704,10 @@ static int update_script_image(struct inst_info *inst, struct block *block, int
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (e) {
-               info->port->update_image(info->port_data, e, block->id, block->part, block->data, block->option);
-       } else {
-               ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
-       }
+       DbgPrint("[%s] %s (%s)\n", block->id, block->part, block->data);
+       ret = info->port->update_image(info->port_data, block->id, block->part, block->data, block->option);
        PERF_MARK("image");
-       return LB_STATUS_SUCCESS;
+       return ret;
 }
 
 static int update_access(struct inst_info *inst, struct block *block, int is_pd)
@@ -787,7 +715,7 @@ static int update_access(struct inst_info *inst, struct block *block, int is_pd)
        PERF_INIT();
        PERF_BEGIN();
        struct script_info *info;
-       Evas *e;
+       int ret;
 
        if (!block || !block->part) {
                ErrPrint("Block or block->part is NIL\n");
@@ -808,14 +736,9 @@ static int update_access(struct inst_info *inst, struct block *block, int is_pd)
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (e) {
-               info->port->update_access(info->port_data, e, block->id, block->part, block->data, block->option);
-       } else {
-               ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
-       }
+       ret = info->port->update_access(info->port_data, block->id, block->part, block->data, block->option);
        PERF_MARK("access");
-       return LB_STATUS_SUCCESS;
+       return ret;
 }
 
 static int operate_access(struct inst_info *inst, struct block *block, int is_pd)
@@ -823,7 +746,7 @@ static int operate_access(struct inst_info *inst, struct block *block, int is_pd
        PERF_INIT();
        PERF_BEGIN();
        struct script_info *info;
-       Evas *e;
+       int ret;
 
        if (!block || !block->part) {
                ErrPrint("Block or block->part is NIL\n");
@@ -844,14 +767,9 @@ static int operate_access(struct inst_info *inst, struct block *block, int is_pd
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (e) {
-               info->port->operate_access(info->port_data, e, block->id, block->part, block->data, block->option);
-       } else {
-               ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
-       }
+       ret = info->port->operate_access(info->port_data, block->id, block->part, block->data, block->option);
        PERF_MARK("operate_access");
-       return LB_STATUS_SUCCESS;
+       return ret;
 }
 
 static int update_script_script(struct inst_info *inst, struct block *block, int is_pd)
@@ -859,7 +777,7 @@ static int update_script_script(struct inst_info *inst, struct block *block, int
        PERF_INIT();
        PERF_BEGIN();
        struct script_info *info;
-       Evas *e;
+       int ret;
 
        if (!block || !block->part) {
                ErrPrint("Block or part is NIL\n");
@@ -880,15 +798,9 @@ static int update_script_script(struct inst_info *inst, struct block *block, int
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (e) {
-               info->port->update_script(info->port_data, e, block->id, block->target, block->part, block->data, block->option);
-       } else {
-               ErrPrint("Evas: (nil) id[%s] part[%s] data[%s] option[%s]\n",
-                                               block->id, block->part, block->data, block->option);
-       }
+       ret = info->port->update_script(info->port_data, block->id, block->target, block->part, block->data, block->option);
        PERF_MARK("script");
-       return LB_STATUS_SUCCESS;
+       return ret;
 }
 
 static int update_script_signal(struct inst_info *inst, struct block *block, int is_pd)
@@ -896,7 +808,7 @@ static int update_script_signal(struct inst_info *inst, struct block *block, int
        PERF_INIT();
        PERF_BEGIN();
        struct script_info *info;
-       Evas *e;
+       int ret;
 
        if (!block) {
                ErrPrint("block is NIL\n");
@@ -917,14 +829,9 @@ static int update_script_signal(struct inst_info *inst, struct block *block, int
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (e) {
-               info->port->update_signal(info->port_data, e, block->id, block->part, block->data);
-       } else {
-               ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
-       }
+       ret = info->port->update_signal(info->port_data, block->id, block->part, block->data);
        PERF_MARK("signal");
-       return LB_STATUS_SUCCESS;
+       return ret;
 }
 
 static int update_script_drag(struct inst_info *inst, struct block *block, int is_pd)
@@ -933,7 +840,7 @@ static int update_script_drag(struct inst_info *inst, struct block *block, int i
        PERF_BEGIN();
        struct script_info *info;
        double dx, dy;
-       Evas *e;
+       int ret;
 
        if (!block || !block->data || !block->part) {
                ErrPrint("block or block->data or block->part is NIL\n");
@@ -960,54 +867,69 @@ static int update_script_drag(struct inst_info *inst, struct block *block, int i
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (e) {
-               info->port->update_drag(info->port_data, e, block->id, block->part, dx, dy);
+       ret = info->port->update_drag(info->port_data, block->id, block->part, dx, dy);
+       PERF_MARK("drag");
+       return ret;
+}
+
+static void update_size_for_script(struct script_info *info, struct inst_info *inst, int w, int h)
+{
+       /*!
+        * \note
+        * After update the buffer size,
+        * If it required to be unload and load.
+        * New size of buffer will be allocated
+        */
+       buffer_handler_update_size(info->buffer_handle, w, h);
+
+       if (info->port->update_size) {
+               (void)info->port->update_size(info->port_data, NULL, w, h);
+       }
+
+       if (instance_lb_script(inst) == info) {
+               instance_set_lb_size(inst, w, h);
+       } else if (instance_pd_script(inst) == info) {
+               instance_set_pd_size(inst, w, h);
        } else {
-               ErrPrint("Evas(nil) id[%s] part[%s] %lfx%lf\n", block->id, block->part, dx, dy);
+               ErrPrint("Unknown script\n");
        }
-       PERF_MARK("drag");
-       return LB_STATUS_SUCCESS;
 }
 
 HAPI int script_handler_resize(struct script_info *info, int w, int h)
 {
        PERF_INIT();
        PERF_BEGIN();
+       struct inst_info *inst;
+
        if (!info) {
-       //|| (info->w == w && info->h == h)) {
                ErrPrint("info[%p] resize is ignored\n", info);
                PERF_MARK("resize");
                return LB_STATUS_SUCCESS;
        }
 
-       fb_resize(script_handler_fb(info), w, h);
-
-       if (info->port->update_size) {
-               Evas *e;
-               e = script_handler_evas(info);
-               if (e) {
-                       info->port->update_size(info->port_data, e, NULL , w, h);
-               } else {
-                       ErrPrint("Evas(nil) resize to %dx%d\n", w, h);
-               }
+       inst = buffer_handler_instance(info->buffer_handle);
+       if (!inst) {
+               ErrPrint("Instance is not valid\n");
+               PERF_MARK("resize");
+               return LB_STATUS_ERROR_INVALID;
        }
 
-       if (instance_lb_script(info->inst) == info) {
-               instance_set_lb_size(info->inst, w, h);
-       } else if (instance_pd_script(info->inst) == info) {
-               instance_set_pd_size(info->inst, w, h);
-       } else {
-               ErrPrint("Script is not known\n");
-       }
+       update_size_for_script(info, inst, w, h);
 
-       info->w = w;
-       info->h = h;
        PERF_MARK("resize");
-
        return LB_STATUS_SUCCESS;
 }
 
+HAPI const char *script_handler_buffer_id(struct script_info *info)
+{
+       if (!info || !info->buffer_handle) {
+               ErrPrint("Invalid info\n");
+               return "";
+       }
+
+       return buffer_handler_id(info->buffer_handle);
+}
+
 static int update_info(struct inst_info *inst, struct block *block, int is_pd)
 {
        PERF_INIT();
@@ -1034,7 +956,7 @@ static int update_info(struct inst_info *inst, struct block *block, int is_pd)
        }
 
        if (!strcasecmp(block->part, INFO_SIZE)) {
-               Evas_Coord w, h;
+               int w, h;
 
                if (sscanf(block->data, "%dx%d", &w, &h) != 2) {
                        ErrPrint("Invalid format for SIZE(%s)\n", block->data);
@@ -1043,24 +965,12 @@ static int update_info(struct inst_info *inst, struct block *block, int is_pd)
                }
 
                if (!block->id) {
-                       script_handler_resize(info, w, h);
+                       update_size_for_script(info, inst, w, h);
                } else {
-                       Evas *e;
-                       e = script_handler_evas(info);
-                       if (e) {
-                               info->port->update_size(info->port_data, e, block->id, w, h);
-                       } else {
-                               ErrPrint("Evas(nil): id[%s] %dx%d\n", block->id, w, h);
-                       }
+                       (void)info->port->update_size(info->port_data, block->id, w, h);
                }
        } else if (!strcasecmp(block->part, INFO_CATEGORY)) {
-               Evas *e;
-               e = script_handler_evas(info);
-               if (e) {
-                       info->port->update_category(info->port_data, e, block->id, block->data);
-               } else {
-                       ErrPrint("Evas(nil): id[%s] data[%s]\n", block->id, block->data);
-               }
+               (void)info->port->update_category(info->port_data, block->id, block->data);
        }
        PERF_MARK("info");
 
@@ -1152,22 +1062,28 @@ HAPI int script_handler_update_pointer(struct script_info *info, int x, int y, i
        return LB_STATUS_SUCCESS;
 }
 
+HAPI int script_handler_update_keycode(struct script_info *info, unsigned int keycode)
+{
+       if (!info) {
+               return LB_STATUS_SUCCESS;
+       }
+
+       info->keycode = keycode;
+
+       return LB_STATUS_SUCCESS;
+}
+
 HAPI int script_handler_feed_event(struct script_info *info, int event, double timestamp)
 {
-       Evas *e;
+       int ret;
 
        if (!info->port) {
                ErrPrint("info->port is NIL\n");
                return LB_STATUS_ERROR_INVALID;
        }
 
-       e = script_handler_evas(info);
-       if (!e) {
-               ErrPrint("Evas is not exists\n");
-               return LB_STATUS_ERROR_FAULT;
-       }
-
-       return info->port->feed_event(info->port_data, e, event, info->x, info->y, info->down, timestamp);
+       ret = info->port->feed_event(info->port_data, event, info->x, info->y, info->down, info->keycode, timestamp);
+       return ret;
 }
 
 static inline char *load_file(const char *filename)
@@ -1562,9 +1478,11 @@ HAPI int script_handler_parse_desc(struct inst_info *inst, const char *filename,
                }
        }
 #else
+       ErrPrint("Begin: Set content for EDJE object\n");
        EINA_LIST_FREE(block_list, block) {
                consuming_parsed_block(inst, is_pd, block);
        }
+       ErrPrint("End: Set content for EDJE object\n");
 
        /*!
         * Doesn't need to force to render the contents.
index 5809130..fe2c9f2 100644 (file)
@@ -19,8 +19,6 @@
 #include <errno.h>
 
 #include <dlog.h>
-#include <Evas.h>
-#include <Ecore_Evas.h> /* fb.h */
 #include <aul.h>
 #include <Ecore.h>
 #include <ail.h>
@@ -44,7 +42,6 @@
 #include "buffer_handler.h"
 #include "util.h"
 #include "fault_manager.h"
-#include "fb.h" /* fb_type */
 #include "group.h"
 #include "xmonitor.h"
 #include "abi.h"
@@ -73,7 +70,7 @@ enum target_type {
        TYPE_ERROR
 };
 
-struct access_cbdata {
+struct event_cbdata {
        int status;
        struct inst_info *inst;
 };
@@ -137,7 +134,7 @@ out:
        return ret;
 }
 
-static inline int forward_pd_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, int x, int y)
+static int forward_pd_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, int x, int y)
 {
        int ret;
        struct buffer_info *buffer;
@@ -193,9 +190,82 @@ out:
        return ret;
 }
 
+static int forward_pd_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
+{
+       int ret;
+       struct buffer_info *buffer;
+       struct slave_node *slave;
+       struct packet *p;
+
+       buffer = instance_lb_buffer(inst);
+       if (!buffer) {
+               ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
+               ret = LB_STATUS_ERROR_FAULT;
+               goto out;
+       }
+
+       slave = package_slave(pkg);
+       if (!slave) {
+               ErrPrint("Package[%s] has no slave\n", package_name(pkg));
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       p = packet_create_noack(command, "ssdi", package_name(pkg), instance_id(inst), timestamp, keycode);
+       ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
+
+out:
+       return ret;
+}
+
+static int forward_lb_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
+{
+       int ret;
+       struct buffer_info *buffer;
+       struct slave_node *slave;
+       struct packet *p;
+
+       buffer = instance_lb_buffer(inst);
+       if (!buffer) {
+               ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
+               ret = LB_STATUS_ERROR_FAULT;
+               goto out;
+       }
+
+       slave = package_slave(pkg);
+       if (!slave) {
+               ErrPrint("Package[%s] has no slave\n", package_name(pkg));
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       p = packet_create_noack(command, "ssdi", package_name(pkg), instance_id(inst), timestamp, keycode);
+       ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
+
+out:
+       return ret;
+}
+
+static Eina_Bool lazy_key_status_cb(void *data)
+{
+       struct event_cbdata *cbdata = data;
+
+       if (instance_unref(cbdata->inst)) {
+               instance_send_key_status(cbdata->inst, cbdata->status);
+       } else {
+               DbgPrint("Skip sending key status (%d)\n", cbdata->status);
+       }
+       /*!
+        * If instance_unref returns NULL,
+        * The instance is destroyed. it means, we don't need to send event to the viewer
+        */
+       DbgFree(cbdata);
+       return ECORE_CALLBACK_CANCEL;
+}
+
 static Eina_Bool lazy_access_status_cb(void *data)
 {
-       struct access_cbdata *cbdata = data;
+       struct event_cbdata *cbdata = data;
 
        if (instance_unref(cbdata->inst)) {
                instance_send_access_status(cbdata->inst, cbdata->status);
@@ -298,7 +368,47 @@ static int slave_fault_resize_buffer_cb(struct slave_node *slave, void *data)
        return -1; /* remove this handler */
 }
 
-static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
+static int key_event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+       struct inst_info *inst = data;
+       const struct pkg_info *pkg;
+       struct slave_node *slave;
+       struct packet *packet;
+       const char *cmdstr;
+
+       pkg = instance_package(inst);
+       if (!pkg) {
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       slave = package_slave(pkg);
+       if (!slave) {
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       switch (state) {
+       case EVENT_STATE_ACTIVATE:
+               cmdstr = "lb_key_down";
+               break;
+       case EVENT_STATE_ACTIVATED:
+               cmdstr = "lb_key_down";
+               break;
+       case EVENT_STATE_DEACTIVATE:
+               cmdstr = "lb_key_up";
+               break;
+       default:
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       packet = packet_create_noack(cmdstr, "ssdi", package_name(pkg), instance_id(inst), util_timestamp(), event_info->keycode);
+       if (!packet) {
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
+}
+
+static int mouse_event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
 {
        struct inst_info *inst = data;
        const struct pkg_info *pkg;
@@ -338,13 +448,12 @@ static int event_lb_route_cb(enum event_state state, struct event_data *event_in
        return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
 }
 
-static int event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+static int key_event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
 {
        struct script_info *script;
        struct inst_info *inst = data;
        const struct pkg_info *pkg;
        double timestamp;
-       Evas *e;
 
        pkg = instance_package(inst);
        if (!pkg) {
@@ -356,8 +465,43 @@ static int event_lb_consume_cb(enum event_state state, struct event_data *event_
                return LB_STATUS_ERROR_FAULT;
        }
 
-       e = script_handler_evas(script);
-       if (!e) {
+       timestamp = util_timestamp();
+
+       switch (state) {
+       case EVENT_STATE_ACTIVATE:
+               script_handler_update_keycode(script, event_info->keycode);
+               (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+               break;
+       case EVENT_STATE_ACTIVATED:
+               script_handler_update_keycode(script, event_info->keycode);
+               (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+               break;
+       case EVENT_STATE_DEACTIVATE:
+               script_handler_update_keycode(script, event_info->keycode);
+               (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
+               break;
+       default:
+               ErrPrint("Unknown event\n");
+               break;
+       }
+
+       return 0;
+}
+
+static int mouse_event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+       struct script_info *script;
+       struct inst_info *inst = data;
+       const struct pkg_info *pkg;
+       double timestamp;
+
+       pkg = instance_package(inst);
+       if (!pkg) {
+               return 0;
+       }
+
+       script = instance_lb_script(inst);
+       if (!script) {
                return LB_STATUS_ERROR_FAULT;
        }
 
@@ -366,15 +510,15 @@ static int event_lb_consume_cb(enum event_state state, struct event_data *event_
        switch (state) {
        case EVENT_STATE_ACTIVATE:
                script_handler_update_pointer(script, event_info->x, event_info->y, 1);
-               script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
+               (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
                break;
        case EVENT_STATE_ACTIVATED:
                script_handler_update_pointer(script, event_info->x, event_info->y, -1);
-               script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
+               (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
                break;
        case EVENT_STATE_DEACTIVATE:
                script_handler_update_pointer(script, event_info->x, event_info->y, 0);
-               script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
+               (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
                break;
        default:
                break;
@@ -383,7 +527,47 @@ static int event_lb_consume_cb(enum event_state state, struct event_data *event_
        return 0;
 }
 
-static int event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
+static int key_event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+       struct inst_info *inst = data;
+       const struct pkg_info *pkg;
+       struct slave_node *slave;
+       struct packet *packet;
+       const char *cmdstr;
+
+       pkg = instance_package(inst);
+       if (!pkg) {
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       slave = package_slave(pkg);
+       if (!slave) {
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       switch (state) {
+       case EVENT_STATE_ACTIVATE:
+               cmdstr = "pd_key_down";
+               break;
+       case EVENT_STATE_ACTIVATED:
+               cmdstr = "pd_key_down";
+               break;
+       case EVENT_STATE_DEACTIVATE:
+               cmdstr = "pd_key_up";
+               break;
+       default:
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       packet = packet_create_noack(cmdstr, "ssdi", package_name(pkg), instance_id(inst), util_timestamp(), event_info->keycode);
+       if (!packet) {
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
+}
+
+static int mouse_event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
 {
        struct inst_info *inst = data;
        const struct pkg_info *pkg;
@@ -423,13 +607,12 @@ static int event_pd_route_cb(enum event_state state, struct event_data *event_in
        return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
 }
 
-static int event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+static int key_event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
 {
        struct script_info *script;
        struct inst_info *inst = data;
        const struct pkg_info *pkg;
        double timestamp;
-       Evas *e;
 
        pkg = instance_package(inst);
        if (!pkg) {
@@ -441,8 +624,43 @@ static int event_pd_consume_cb(enum event_state state, struct event_data *event_
                return LB_STATUS_ERROR_FAULT;
        }
 
-       e = script_handler_evas(script);
-       if (!e) {
+       timestamp = util_timestamp();
+
+       switch (state) {
+       case EVENT_STATE_ACTIVATE:
+               script_handler_update_keycode(script, event_info->keycode);
+               (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+               break;
+       case EVENT_STATE_ACTIVATED:
+               script_handler_update_keycode(script, event_info->keycode);
+               (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+               break;
+       case EVENT_STATE_DEACTIVATE:
+               script_handler_update_keycode(script, event_info->keycode);
+               (void)script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
+               break;
+       default:
+               ErrPrint("Unknown event\n");
+               break;
+       }
+
+       return 0;
+}
+
+static int mouse_event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+       struct script_info *script;
+       struct inst_info *inst = data;
+       const struct pkg_info *pkg;
+       double timestamp;
+
+       pkg = instance_package(inst);
+       if (!pkg) {
+               return 0;
+       }
+
+       script = instance_pd_script(inst);
+       if (!script) {
                return LB_STATUS_ERROR_FAULT;
        }
 
@@ -451,15 +669,15 @@ static int event_pd_consume_cb(enum event_state state, struct event_data *event_
        switch (state) {
        case EVENT_STATE_ACTIVATE:
                script_handler_update_pointer(script, event_info->x, event_info->y, 1);
-               script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
+               (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
                break;
        case EVENT_STATE_ACTIVATED:
                script_handler_update_pointer(script, event_info->x, event_info->y, -1);
-               script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
+               (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
                break;
        case EVENT_STATE_DEACTIVATE:
                script_handler_update_pointer(script, event_info->x, event_info->y, 0);
-               script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
+               (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
                break;
        default:
                break;
@@ -700,12 +918,13 @@ static Eina_Bool lazy_delete_cb(void *data)
 {
        struct deleted_item *item = data;
 
+       DbgPrint("Lazy delete callback called\n");
        /*!
         * Before invoke this callback, the instance is able to already remove this client
         * So check it again
         */
        if (instance_has_client(item->inst, item->client)) {
-               (void)instance_unicast_deleted_event(item->inst, item->client);
+               (void)instance_unicast_deleted_event(item->inst, item->client, LB_STATUS_SUCCESS);
                (void)instance_del_client(item->inst, item->client);
        }
 
@@ -722,7 +941,9 @@ static struct packet *client_delete(pid_t pid, int handle, const struct packet *
        const char *pkgname;
        const char *id;
        struct inst_info *inst = NULL;
+       const struct pkg_info *pkg;
        int ret;
+       int type;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
@@ -731,23 +952,37 @@ static struct packet *client_delete(pid_t pid, int handle, const struct packet *
                goto out;
        }
 
-       ret = packet_get(packet, "ss", &pkgname, &id);
-       if (ret != 2) {
+       ret = packet_get(packet, "ssi", &pkgname, &id, &type);
+       if (ret != 3) {
                ErrPrint("Parameter is not matched\n");
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
        }
+       /*!
+        * \note
+        * Below two types must has to be sync'd with livebox-viewer
+        *
+        * LB_DELETE_PERMANENTLY = 0x01,
+        * LB_DELETE_TEMPORARY = 0x02,
+        *
+        */
 
        /*!
         * \NOTE:
         * Trust the package name which are sent by the client.
         * The package has to be a livebox package name.
         */
-       ret = validate_request(pkgname, id, &inst, NULL);
+       ret = validate_request(pkgname, id, &inst, &pkg);
        if (ret != LB_STATUS_SUCCESS) {
                goto out;
        }
 
+       if (package_is_fault(pkg)) {
+               DbgPrint("Faulted package. will be deleted soon: %s\n", id);
+               ret = LB_STATUS_ERROR_FAULT;
+               goto out;
+       }
+
        if (instance_client(inst) != client) {
                if (instance_has_client(inst, client)) {
                        struct deleted_item *item;
@@ -784,7 +1019,16 @@ static struct packet *client_delete(pid_t pid, int handle, const struct packet *
                        ret = LB_STATUS_ERROR_PERMISSION;
                }
        } else {
-               ret = instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+               switch (type) {
+               case LB_DELETE_PERMANENTLY:
+                       ret = instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+                       break;
+               case LB_DELETE_TEMPORARY:
+                       ret = instance_destroy(inst, INSTANCE_DESTROY_TEMPORARY);
+                       break;
+               default:
+                       break;
+               }
        }
 
 out:
@@ -917,7 +1161,7 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac
                ret = LB_STATUS_ERROR_FAULT;
        } else if (package_is_fault(info)) {
                ret = LB_STATUS_ERROR_FAULT;
-       } else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
+       } else if (util_free_space(IMAGE_PATH) <= MINIMUM_SPACE) {
                ErrPrint("Not enough space\n");
                ret = LB_STATUS_ERROR_NO_SPACE;
        } else {
@@ -1128,7 +1372,6 @@ static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct
                ret = forward_pd_event_packet(pkg, inst, packet);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -1136,12 +1379,6 @@ static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
                ret = 0;
@@ -1190,7 +1427,6 @@ static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct
                ret = forward_pd_event_packet(pkg, inst, packet);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -1198,12 +1434,6 @@ static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
                ret = 0;
@@ -1252,7 +1482,6 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p
                ret = forward_pd_event_packet(pkg, inst, packet);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -1260,12 +1489,6 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 1);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
                ret = 0;
@@ -1314,7 +1537,6 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac
                ret = forward_pd_event_packet(pkg, inst, packet);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -1322,12 +1544,6 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 0);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
                ret = 0;
@@ -1376,7 +1592,6 @@ static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct p
                ret = forward_pd_event_packet(pkg, inst, packet);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -1384,12 +1599,6 @@ static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct p
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
                ret = 0;
@@ -1438,7 +1647,6 @@ static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct p
                ret = forward_lb_event_packet(pkg, inst, packet);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -1446,12 +1654,6 @@ static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct p
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
                ret = 0;
@@ -1471,17 +1673,18 @@ static int inst_del_cb(struct inst_info *inst, void *data)
        return -1; /* Delete this callback */
 }
 
-static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
+
+static struct packet *client_pd_key_set(pid_t pid, int handle, const struct packet *packet)
 {
        struct client_node *client;
        const char *pkgname;
        const char *id;
        int ret;
        double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
+       unsigned int keycode;
+       struct inst_info *inst;
+       const struct pkg_info *pkg;
+       struct packet *result;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
@@ -1490,8 +1693,8 @@ static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct pa
                goto out;
        }
 
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
-       if (ret != 5) {
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
                ErrPrint("Parameter is not matched\n");
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
@@ -1503,21 +1706,241 @@ static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct pa
        }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
-               ret = event_activate(x, y, event_lb_route_cb, inst);
+               ret = event_activate(0, 0, key_event_pd_route_cb, inst);
                if (ret == 0) {
-                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, event_lb_route_cb);
+                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_route_cb);
                }
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
-               ret = event_activate(x, y, event_lb_consume_cb, inst);
+               ret = event_activate(0, 0, key_event_pd_consume_cb, inst);
                if (ret == 0) {
-                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, event_lb_consume_cb);
+                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_consume_cb);
                }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
        }
+
 out:
-       return NULL;
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *client_pd_key_unset(pid_t pid, int handle, const struct packet *packet)
+{
+       struct client_node *client;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       double timestamp;
+       unsigned int keycode;
+       struct inst_info *inst;
+       const struct pkg_info *pkg;
+       struct packet *result;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               ret = LB_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
+               ErrPrint("Parameter is not matched\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != LB_STATUS_SUCCESS) {
+               goto out;
+       }
+
+       if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+               ret = event_deactivate(key_event_pd_route_cb, inst);
+               if (ret == 0) {
+                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_route_cb);
+               }
+       } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+               ret = event_deactivate(key_event_pd_consume_cb, inst);
+               if (ret == 0) {
+                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_consume_cb);
+               }
+       } else {
+               ErrPrint("Unsupported package\n");
+               ret = LB_STATUS_ERROR_INVALID;
+       }
+
+out:
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *client_lb_key_set(pid_t pid, int handle, const struct packet *packet)
+{
+       struct client_node *client;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       double timestamp;
+       unsigned int keycode;
+       struct inst_info *inst;
+       const struct pkg_info *pkg;
+       struct packet *result;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               ret = LB_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
+               ErrPrint("Parameter is not matched\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != LB_STATUS_SUCCESS) {
+               goto out;
+       }
+
+       if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+               ret = event_activate(0, 0, key_event_lb_route_cb, inst);
+               if (ret == 0) {
+                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_route_cb);
+               }
+       } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+               ret = event_activate(0, 0, key_event_lb_consume_cb, inst);
+               if (ret == 0) {
+                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_consume_cb);
+               }
+       } else {
+               ErrPrint("Unsupported package\n");
+               ret = LB_STATUS_ERROR_INVALID;
+       }
+
+out:
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *client_lb_key_unset(pid_t pid, int handle, const struct packet *packet)
+{
+       struct client_node *client;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       double timestamp;
+       unsigned int keycode;
+       struct inst_info *inst;
+       const struct pkg_info *pkg;
+       struct packet *result;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               ret = LB_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
+               ErrPrint("Parameter is not matched\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != LB_STATUS_SUCCESS) {
+               goto out;
+       }
+
+       if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+               ret = event_deactivate(key_event_lb_route_cb, inst);
+               if (ret == 0) {
+                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_route_cb);
+               }
+       } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+               ret = event_deactivate(key_event_lb_consume_cb, inst);
+               if (ret == 0) {
+                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_consume_cb);
+               }
+       } else {
+               ErrPrint("Unsupported package\n");
+               ret = LB_STATUS_ERROR_INVALID;
+       }
+
+out:
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
+{
+       struct client_node *client;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       double timestamp;
+       int x;
+       int y;
+       struct inst_info *inst = NULL;
+       const struct pkg_info *pkg = NULL;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               ret = LB_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+       if (ret != 5) {
+               ErrPrint("Parameter is not matched\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != LB_STATUS_SUCCESS) {
+               goto out;
+       }
+
+       if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+               ret = event_activate(x, y, mouse_event_lb_route_cb, inst);
+               if (ret == 0) {
+                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_route_cb);
+               }
+       } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+               ret = event_activate(x, y, mouse_event_lb_consume_cb, inst);
+               if (ret == 0) {
+                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_consume_cb);
+               }
+       } else {
+               ErrPrint("Unsupported package\n");
+               ret = LB_STATUS_ERROR_INVALID;
+       }
+out:
+       return NULL;
 }
 
 static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
@@ -1552,14 +1975,14 @@ static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct
        }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
-               ret = event_deactivate(event_lb_route_cb, inst);
+               ret = event_deactivate(mouse_event_lb_route_cb, inst);
                if (ret == 0) {
-                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_route_cb);
                }
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
-               ret = event_deactivate(event_lb_consume_cb, inst);
+               ret = event_deactivate(mouse_event_lb_consume_cb, inst);
                if (ret == 0) {
-                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_consume_cb);
                }
        } else {
                ErrPrint("Unsupported package\n");
@@ -1601,14 +2024,14 @@ static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct pa
        }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
-               ret = event_activate(x, y, event_pd_route_cb, inst);
+               ret = event_activate(x, y, mouse_event_pd_route_cb, inst);
                if (ret == 0) {
-                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, event_pd_route_cb);
+                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_route_cb);
                }
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
-               ret = event_activate(x, y, event_pd_consume_cb, inst);
+               ret = event_activate(x, y, mouse_event_pd_consume_cb, inst);
                if (ret == 0) {
-                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, event_pd_consume_cb);
+                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_consume_cb);
                }
        } else {
                ErrPrint("Unsupported package\n");
@@ -1651,14 +2074,14 @@ static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct
        }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
-               ret = event_deactivate(event_pd_route_cb, inst);
+               ret = event_deactivate(mouse_event_pd_route_cb, inst);
                if (ret == 0) {
-                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_route_cb);
                }
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
-               ret = event_deactivate(event_pd_consume_cb, inst);
+               ret = event_deactivate(mouse_event_pd_consume_cb, inst);
                if (ret == 0) {
-                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_consume_cb);
                }
        } else {
                ErrPrint("Unsupported package\n");
@@ -1703,7 +2126,6 @@ static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct
                ret = forward_lb_event_packet(pkg, inst, packet);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -1711,12 +2133,6 @@ static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
                ret = 0;
@@ -1765,7 +2181,6 @@ static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct
                ret = forward_lb_event_packet(pkg, inst, packet);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -1773,12 +2188,6 @@ static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
                ret = 0;
@@ -1827,7 +2236,6 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p
                ret = forward_lb_event_packet(pkg, inst, packet);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -1835,12 +2243,6 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 1);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
                ret = 0;
@@ -1889,7 +2291,6 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac
                ret = forward_lb_event_packet(pkg, inst, packet);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -1897,12 +2298,6 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 0);
                script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
                ret = 0;
@@ -1952,7 +2347,6 @@ static struct packet *client_pd_access_action_up(pid_t pid, int handle, const st
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -1960,16 +2354,10 @@ static struct packet *client_pd_access_action_up(pid_t pid, int handle, const st
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 0);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2037,7 +2425,6 @@ static struct packet *client_pd_access_action_down(pid_t pid, int handle, const
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2045,16 +2432,10 @@ static struct packet *client_pd_access_action_down(pid_t pid, int handle, const
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2122,7 +2503,6 @@ static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2130,16 +2510,10 @@ static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2207,7 +2581,6 @@ static struct packet *client_pd_access_scroll_move(pid_t pid, int handle, const
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2215,16 +2588,10 @@ static struct packet *client_pd_access_scroll_move(pid_t pid, int handle, const
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2292,7 +2659,6 @@ static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const st
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2300,16 +2666,10 @@ static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const st
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 0);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2377,7 +2737,6 @@ static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2385,16 +2744,10 @@ static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2461,7 +2814,6 @@ static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct pa
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2469,16 +2821,10 @@ static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct pa
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2546,7 +2892,6 @@ static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const stru
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2554,16 +2899,10 @@ static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const stru
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2631,7 +2970,6 @@ static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const stru
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2640,17 +2978,10 @@ static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const stru
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ErrPrint("Evas is not exists\n");
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2722,7 +3053,6 @@ static struct packet *client_pd_access_activate(pid_t pid, int handle, const str
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2730,16 +3060,10 @@ static struct packet *client_pd_access_activate(pid_t pid, int handle, const str
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -2771,17 +3095,17 @@ out:
        return result;
 }
 
-static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_pd_key_focus_in(pid_t pid, int handle, const struct packet *packet)
 {
        struct client_node *client;
        const char *pkgname;
        const char *id;
        int ret;
        double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
+       unsigned int keycode;
+       struct inst_info *inst;
+       const struct pkg_info *pkg;
+       struct packet *result;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
@@ -2790,8 +3114,8 @@ static struct packet *client_pd_key_down(pid_t pid, int handle, const struct pac
                goto out;
        }
 
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
-       if (ret != 5) {
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
                ErrPrint("Invalid parameter\n");
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
@@ -2803,10 +3127,9 @@ static struct packet *client_pd_key_down(pid_t pid, int handle, const struct pac
        }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
-               ret = forward_pd_event_packet(pkg, inst, packet);
+               ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2814,25 +3137,193 @@ static struct packet *client_pd_key_down(pid_t pid, int handle, const struct pac
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
+               script_handler_update_keycode(script, keycode);
+               ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_IN, timestamp);
+               if (ret >= 0) {
+                       struct event_cbdata *cbdata;
+
+                       cbdata = malloc(sizeof(*cbdata));
+                       if (!cbdata) {
+                               ret = LB_STATUS_ERROR_MEMORY;
+                       } else {
+                               cbdata->inst = instance_ref(inst);
+                               cbdata->status = ret;
+
+                               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
+                                       (void)instance_unref(cbdata->inst);
+                                       DbgFree(cbdata);
+                                       ret = LB_STATUS_ERROR_FAULT;
+                               } else {
+                                       ret = LB_STATUS_SUCCESS;
+                               }
+                       }
+               }
+       } else {
+               ErrPrint("Unsupported package\n");
+               ret = LB_STATUS_ERROR_INVALID;
+       }
+
+out:
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *client_pd_key_focus_out(pid_t pid, int handle, const struct packet *packet)
+{
+       struct client_node *client;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       double timestamp;
+       unsigned int keycode;
+       struct inst_info *inst = NULL;
+       const struct pkg_info *pkg = NULL;
+       struct packet *result;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               ret = LB_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
+               ErrPrint("Invalid parameter\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != LB_STATUS_SUCCESS) {
+               goto out;
+       }
+
+       if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+               ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+       } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+               struct script_info *script;
+
+               script = instance_pd_script(inst);
+               if (!script) {
                        ret = LB_STATUS_ERROR_FAULT;
                        goto out;
                }
 
-               script_handler_update_pointer(script, x, y, -1);
-               /*!
-                * \TODO: Push up the KEY_DOWN event
-                */
-               ret = 0;
+               script_handler_update_keycode(script, keycode);
+               ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_OUT, timestamp);
+               if (ret >= 0) {
+                       struct event_cbdata *cbdata;
+
+                       cbdata = malloc(sizeof(*cbdata));
+                       if (!cbdata) {
+                               ret = LB_STATUS_ERROR_MEMORY;
+                       } else {
+                               cbdata->inst = instance_ref(inst);
+                               cbdata->status = ret;
+
+                               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
+                                       (void)instance_unref(cbdata->inst);
+                                       DbgFree(cbdata);
+                                       ret = LB_STATUS_ERROR_FAULT;
+                               } else {
+                                       ret = LB_STATUS_SUCCESS;
+                               }
+                       }
+               }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
        }
 
 out:
-       /*! \note No reply packet */
-       return NULL;
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
+{
+       struct client_node *client;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       double timestamp;
+       unsigned int keycode;
+       struct inst_info *inst;
+       const struct pkg_info *pkg;
+       struct packet *result;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               ret = LB_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
+               ErrPrint("Invalid parameter\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != LB_STATUS_SUCCESS) {
+               goto out;
+       }
+
+       if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+               ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+       } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+               struct script_info *script;
+
+               script = instance_pd_script(inst);
+               if (!script) {
+                       ret = LB_STATUS_ERROR_FAULT;
+                       goto out;
+               }
+
+               script_handler_update_keycode(script, keycode);
+               ret = script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+               if (ret >= 0) {
+                       struct event_cbdata *cbdata;
+
+                       cbdata = malloc(sizeof(*cbdata));
+                       if (!cbdata) {
+                               ret = LB_STATUS_ERROR_MEMORY;
+                       } else {
+                               cbdata->inst = instance_ref(inst);
+                               cbdata->status = ret;
+
+                               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
+                                       (void)instance_unref(cbdata->inst);
+                                       DbgFree(cbdata);
+                                       ret = LB_STATUS_ERROR_FAULT;
+                               } else {
+                                       ret = LB_STATUS_SUCCESS;
+                               }
+                       }
+               }
+       } else {
+               ErrPrint("Unsupported package\n");
+               ret = LB_STATUS_ERROR_INVALID;
+       }
+
+out:
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
 }
 
 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
@@ -2900,10 +3391,10 @@ static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packe
        const char *id;
        int ret;
        double timestamp;
-       int x;
-       int y;
+       unsigned int keycode;
        struct inst_info *inst = NULL;
        const struct pkg_info *pkg = NULL;
+       struct packet *result;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
@@ -2912,8 +3403,8 @@ static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packe
                goto out;
        }
 
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
-       if (ret != 7) {
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
                ErrPrint("Invalid parameter\n");
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
@@ -2925,10 +3416,9 @@ static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packe
        }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
-               ret = forward_pd_event_packet(pkg, inst, packet);
+               ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_pd_script(inst);
                if (!script) {
@@ -2936,25 +3426,39 @@ static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packe
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
+               script_handler_update_keycode(script, keycode);
+               ret = script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
+               if (ret >= 0) {
+                       struct event_cbdata *cbdata;
 
-               script_handler_update_pointer(script, x, y, -1);
-               /*!
-                * \TODO: Push up the KEY_UP event
-                */
-               ret = 0;
+                       cbdata = malloc(sizeof(*cbdata));
+                       if (!cbdata) {
+                               ret = LB_STATUS_ERROR_MEMORY;
+                       } else {
+                               cbdata->inst = instance_ref(inst);
+                               cbdata->status = ret;
+
+                               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
+                                       (void)instance_unref(cbdata->inst);
+                                       DbgFree(cbdata);
+                                       ret = LB_STATUS_ERROR_FAULT;
+                               } else {
+                                       ret = LB_STATUS_SUCCESS;
+                               }
+                       }
+               }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
        }
 
 out:
-       /*! \note No reply packet */
-       return NULL;
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
 }
 
 static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct packet *packet)
@@ -2993,7 +3497,6 @@ static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct pa
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3001,16 +3504,10 @@ static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct pa
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3078,7 +3575,6 @@ static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const stru
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3086,16 +3582,10 @@ static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const stru
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3163,7 +3653,6 @@ static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const stru
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3171,16 +3660,10 @@ static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const stru
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3253,7 +3736,6 @@ static struct packet *client_lb_access_action_up(pid_t pid, int handle, const st
                 */
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3262,17 +3744,10 @@ static struct packet *client_lb_access_action_up(pid_t pid, int handle, const st
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ErrPrint("Script has no evas\n");
-                       ret = LB_STATUS_ERROR_INVALID;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 0);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3345,7 +3820,6 @@ static struct packet *client_lb_access_action_down(pid_t pid, int handle, const
                 */
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3354,17 +3828,10 @@ static struct packet *client_lb_access_action_down(pid_t pid, int handle, const
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ErrPrint("Script has no evas\n");
-                       ret = LB_STATUS_ERROR_INVALID;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, 1);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3432,7 +3899,6 @@ static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3440,16 +3906,178 @@ static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
+               script_handler_update_pointer(script, x, y, -1);
+               ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
+               if (ret >= 0) {
+                       struct event_cbdata *cbdata;
+
+                       cbdata = malloc(sizeof(*cbdata));
+                       if (!cbdata) {
+                               ret = LB_STATUS_ERROR_MEMORY;
+                       } else {
+                               cbdata->inst = instance_ref(inst);
+                               cbdata->status = ret;
+
+                               if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
+                                       (void)instance_unref(cbdata->inst);
+                                       DbgFree(cbdata);
+                                       ret = LB_STATUS_ERROR_FAULT;
+                               } else {
+                                       ret = LB_STATUS_SUCCESS;
+                               }
+                       }
+               }
+       } else {
+               ErrPrint("Unsupported package\n");
+               ret = LB_STATUS_ERROR_INVALID;
+       }
+
+out:
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
+{
+       struct packet *result;
+       struct client_node *client;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       double timestamp;
+       struct inst_info *inst = NULL;
+       const struct pkg_info *pkg = NULL;
+       int x;
+       int y;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exist\n", pid);
+               ret = LB_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+       if (ret != 5) {
+               ErrPrint("Parameter is not matched\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != LB_STATUS_SUCCESS) {
+               goto out;
+       }
+
+       if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+               ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
+               /*!
+                * Enen if it fails to send packet,
+                * The packet will be unref'd
+                * So we don't need to check the ret value.
+                */
+       } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+               struct script_info *script;
+
+               script = instance_lb_script(inst);
+               if (!script) {
+                       ErrPrint("Instance has no script\n");
+                       ret = LB_STATUS_ERROR_FAULT;
+                       goto out;
+               }
+
+               script_handler_update_pointer(script, x, y, 1);
+               ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
+               if (ret >= 0) {
+                       struct event_cbdata *cbdata;
+
+                       cbdata = malloc(sizeof(*cbdata));
+                       if (!cbdata) {
+                               ret = LB_STATUS_ERROR_MEMORY;
+                       } else {
+                               cbdata->inst = instance_ref(inst);
+                               cbdata->status = ret;
+
+                               if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
+                                       (void)instance_unref(cbdata->inst);
+                                       DbgFree(cbdata);
+                                       ret = LB_STATUS_ERROR_FAULT;
+                               } else {
+                                       ret = LB_STATUS_SUCCESS;
+                               }
+                       }
+               }
+       } else {
+               ErrPrint("Unsupported package\n");
+               ret = LB_STATUS_ERROR_INVALID;
+       }
+
+out:
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
+}
+
+static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
+{
+       struct packet *result;
+       struct client_node *client;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       double timestamp;
+       struct inst_info *inst = NULL;
+       const struct pkg_info *pkg = NULL;
+       int x;
+       int y;
+
+       client = client_find_by_rpc_handle(handle);
+       if (!client) {
+               ErrPrint("Client %d is not exist\n", pid);
+               ret = LB_STATUS_ERROR_NOT_EXIST;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+       if (ret != 5) {
+               ErrPrint("Parameter is not matched\n");
+               ret = LB_STATUS_ERROR_INVALID;
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, &pkg);
+       if (ret != LB_STATUS_SUCCESS) {
+               goto out;
+       }
+
+       if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+               ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
+               /*!
+                * Enen if it fails to send packet,
+                * The packet will be unref'd
+                * So we don't need to check the ret value.
+                */
+       } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+               struct script_info *script;
+
+               script = instance_lb_script(inst);
+               if (!script) {
+                       ErrPrint("Instance has no script\n");
                        ret = LB_STATUS_ERROR_FAULT;
                        goto out;
                }
 
                script_handler_update_pointer(script, x, y, -1);
-               ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
+               ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3481,7 +4109,7 @@ out:
        return result;
 }
 
-static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
 {
        struct packet *result;
        struct client_node *client;
@@ -3522,7 +4150,6 @@ static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const
                 */
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3531,17 +4158,10 @@ static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ErrPrint("Instance has no evas\n");
-                       ret = LB_STATUS_ERROR_INVALID;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, x, y, 1);
+               script_handler_update_pointer(script, x, y, 0);
                ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3573,7 +4193,7 @@ out:
        return result;
 }
 
-static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
 {
        struct packet *result;
        struct client_node *client;
@@ -3581,14 +4201,14 @@ static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const
        const char *id;
        int ret;
        double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
        int x;
        int y;
+       struct inst_info *inst = NULL;
+       const struct pkg_info *pkg = NULL;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
+               ErrPrint("Client %d is not exists\n", pid);
                ret = LB_STATUS_ERROR_NOT_EXIST;
                goto out;
        }
@@ -3607,14 +4227,8 @@ static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3623,17 +4237,10 @@ static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ErrPrint("Instance has no evas\n");
-                       ret = LB_STATUS_ERROR_INVALID;
-                       goto out;
-               }
-
                script_handler_update_pointer(script, x, y, -1);
-               ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
+               ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3665,28 +4272,27 @@ out:
        return result;
 }
 
-static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
 {
-       struct packet *result;
        struct client_node *client;
        const char *pkgname;
        const char *id;
        int ret;
        double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       int x;
-       int y;
+       unsigned int keycode;
+       struct inst_info *inst;
+       const struct pkg_info *pkg;
+       struct packet *result;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
+               ErrPrint("Client %d is not exists\n", pid);
                ret = LB_STATUS_ERROR_NOT_EXIST;
                goto out;
        }
 
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
-       if (ret != 5) {
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
                ErrPrint("Parameter is not matched\n");
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
@@ -3698,34 +4304,20 @@ static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const st
        }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
-               ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
+               ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
-                       ErrPrint("Instance has no script\n");
                        ret = LB_STATUS_ERROR_FAULT;
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ErrPrint("Instance has no evas\n");
-                       ret = LB_STATUS_ERROR_INVALID;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, x, y, 0);
-               ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
+               script_handler_update_keycode(script, keycode);
+               ret = script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3734,7 +4326,7 @@ static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const st
                                cbdata->inst = instance_ref(inst);
                                cbdata->status = ret;
 
-                               if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
+                               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
                                        (void)instance_unref(cbdata->inst);
                                        DbgFree(cbdata);
                                        ret = LB_STATUS_ERROR_FAULT;
@@ -3757,18 +4349,17 @@ out:
        return result;
 }
 
-static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_lb_key_focus_in(pid_t pid, int handle, const struct packet *packet)
 {
-       struct packet *result;
        struct client_node *client;
        const char *pkgname;
        const char *id;
        int ret;
        double timestamp;
-       int x;
-       int y;
+       unsigned int keycode;
        struct inst_info *inst = NULL;
        const struct pkg_info *pkg = NULL;
+       struct packet *result;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
@@ -3777,8 +4368,8 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str
                goto out;
        }
 
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
-       if (ret != 5) {
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
                ErrPrint("Parameter is not matched\n");
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
@@ -3790,29 +4381,20 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str
        }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
-               ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
+               ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
-                       ErrPrint("Instance has no script\n");
                        ret = LB_STATUS_ERROR_FAULT;
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ErrPrint("Script has no Evas\n");
-                       ret = LB_STATUS_ERROR_INVALID;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, x, y, -1);
-               ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
+               script_handler_update_keycode(script, keycode);
+               ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_IN, timestamp);
                if (ret >= 0) {
-                       struct access_cbdata *cbdata;
+                       struct event_cbdata *cbdata;
 
                        cbdata = malloc(sizeof(*cbdata));
                        if (!cbdata) {
@@ -3821,7 +4403,7 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str
                                cbdata->inst = instance_ref(inst);
                                cbdata->status = ret;
 
-                               if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
+                               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
                                        (void)instance_unref(cbdata->inst);
                                        DbgFree(cbdata);
                                        ret = LB_STATUS_ERROR_FAULT;
@@ -3844,17 +4426,17 @@ out:
        return result;
 }
 
-static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_lb_key_focus_out(pid_t pid, int handle, const struct packet *packet)
 {
        struct client_node *client;
        const char *pkgname;
        const char *id;
        int ret;
        double timestamp;
-       int x;
-       int y;
+       unsigned int keycode;
        struct inst_info *inst = NULL;
        const struct pkg_info *pkg = NULL;
+       struct packet *result;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
@@ -3863,8 +4445,8 @@ static struct packet *client_lb_key_down(pid_t pid, int handle, const struct pac
                goto out;
        }
 
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
-       if (ret != 7) {
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
                ErrPrint("Parameter is not matched\n");
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
@@ -3876,10 +4458,9 @@ static struct packet *client_lb_key_down(pid_t pid, int handle, const struct pac
        }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
-               ret = forward_lb_event_packet(pkg, inst, packet);
+               ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3887,26 +4468,39 @@ static struct packet *client_lb_key_down(pid_t pid, int handle, const struct pac
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
+               script_handler_update_keycode(script, keycode);
+               ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_OUT, timestamp);
+               if (ret >= 0) {
+                       struct event_cbdata *cbdata;
 
-               script_handler_update_pointer(script, x, y, -1);
+                       cbdata = malloc(sizeof(*cbdata));
+                       if (!cbdata) {
+                               ret = LB_STATUS_ERROR_MEMORY;
+                       } else {
+                               cbdata->inst = instance_ref(inst);
+                               cbdata->status = ret;
 
-               /*!
-                * \TODO: Feed up this KEY_DOWN event
-                */
-               ret = 0;
+                               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
+                                       (void)instance_unref(cbdata->inst);
+                                       DbgFree(cbdata);
+                                       ret = LB_STATUS_ERROR_FAULT;
+                               } else {
+                                       ret = LB_STATUS_SUCCESS;
+                               }
+                       }
+               }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
        }
 
 out:
-       /*! \note No reply packet */
-       return NULL;
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
 }
 
 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
@@ -3916,10 +4510,10 @@ static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packe
        const char *id;
        int ret;
        double timestamp;
-       int x;
-       int y;
+       unsigned int keycode;
        struct inst_info *inst = NULL;
        const struct pkg_info *pkg = NULL;
+       struct packet *result;
 
        client = client_find_by_rpc_handle(handle);
        if (!client) {
@@ -3928,8 +4522,8 @@ static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packe
                goto out;
        }
 
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
-       if (ret != 7) {
+       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
+       if (ret != 4) {
                ErrPrint("Parameter is not matched\n");
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
@@ -3941,10 +4535,9 @@ static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packe
        }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
-               ret = forward_lb_event_packet(pkg, inst, packet);
+               ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                struct script_info *script;
-               Evas *e;
 
                script = instance_lb_script(inst);
                if (!script) {
@@ -3952,26 +4545,39 @@ static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packe
                        goto out;
                }
 
-               e = script_handler_evas(script);
-               if (!e) {
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
+               script_handler_update_keycode(script, keycode);
+               ret = script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
+               if (ret >= 0) {
+                       struct event_cbdata *cbdata;
 
-               script_handler_update_pointer(script, x, y, -1);
+                       cbdata = malloc(sizeof(*cbdata));
+                       if (!cbdata) {
+                               ret = LB_STATUS_ERROR_MEMORY;
+                       } else {
+                               cbdata->inst = instance_ref(inst);
+                               cbdata->status = ret;
 
-               /*!
-                * \TODO: Feed up this KEY_UP event
-                */
-               ret = 0;
+                               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
+                                       (void)instance_unref(cbdata->inst);
+                                       DbgFree(cbdata);
+                                       ret = LB_STATUS_ERROR_FAULT;
+                               } else {
+                                       ret = LB_STATUS_SUCCESS;
+                               }
+                       }
+               }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
        }
 
 out:
-       /*! \note No reply packet */
-       return NULL;
+       result = packet_create_reply(packet, "i", ret);
+       if (!result) {
+               ErrPrint("Failed to create a reply packet\n");
+       }
+
+       return result;
 }
 
 static int release_pixmap_cb(struct client_node *client, void *canvas)
@@ -4015,7 +4621,6 @@ static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const stru
        buffer = instance_lb_buffer(inst);
        if (!buffer) {
                struct script_info *script_info;
-               struct fb_info *fb_info;
 
                script_info = instance_lb_script(inst);
                if (!script_info) {
@@ -4024,14 +4629,7 @@ static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const stru
                        goto out;
                }
 
-               fb_info = script_handler_fb(script_info);
-               if (!fb_info) {
-                       ErrPrint("Unable to get fb_info: %s\n", id);
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
-               buffer = fb_buffer_info(fb_info);
+               buffer = script_handler_buffer_info(script_info);
                if (!buffer) {
                        ErrPrint("Unable to get buffer_info: %s\n", id);
                        ret = LB_STATUS_ERROR_FAULT;
@@ -4069,7 +4667,6 @@ static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const stru
        const char *pkgname;
        const char *id;
        struct client_node *client;
-       struct inst_info *inst = NULL;
        int pixmap;
        void *buf_ptr;
        int ret;
@@ -4086,7 +4683,7 @@ static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const stru
                goto out;
        }
 
-       ret = validate_request(pkgname, id, &inst, NULL);
+       ret = validate_request(pkgname, id, NULL, NULL);
        if (ret != LB_STATUS_SUCCESS) {
                goto out;
        }
@@ -4145,7 +4742,6 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru
        buffer = instance_pd_buffer(inst);
        if (!buffer) {
                struct script_info *script_info;
-               struct fb_info *fb_info;
 
                script_info = instance_pd_script(inst);
                if (!script_info) {
@@ -4154,14 +4750,7 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru
                        goto out;
                }
 
-               fb_info = script_handler_fb(script_info);
-               if (!fb_info) {
-                       ErrPrint("Unable to get fb_info: %s\n", id);
-                       ret = LB_STATUS_ERROR_FAULT;
-                       goto out;
-               }
-
-               buffer = fb_buffer_info(fb_info);
+               buffer = script_handler_buffer_info(script_info);
                if (!buffer) {
                        ErrPrint("Unable to get buffer_info: %s\n", id);
                        ret = LB_STATUS_ERROR_FAULT;
@@ -4178,10 +4767,13 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru
 
        ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
        if (ret < 0) {
+               ErrPrint("Failed to add a new client deactivate callback\n");
                buffer_handler_pixmap_unref(buf_ptr);
+       } else {
+               pixmap = buffer_handler_pixmap(buffer);
+               ret = LB_STATUS_SUCCESS;
        }
 
-       pixmap = buffer_handler_pixmap(buffer);
 out:
        result = packet_create_reply(packet, "ii", pixmap, ret);
        if (!result) {
@@ -4730,7 +5322,6 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
 
                pd_monitor = instance_del_data(inst, "pd,open,monitor");
                if (pd_monitor) {
-                       
                        ErrPrint("PD Open request is found. cancel it [%s]\n", pkgname);
 
                        slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst);
@@ -5049,9 +5640,8 @@ static inline int update_pkg_cb(struct category *category, const char *pkgname,
                if (!inst) {
                        ErrPrint("Failed to create a new instance\n");
                }
-       } else {
-               ErrPrint("Not enough space\n");
        }
+
        return EXIT_SUCCESS;
 }
 
@@ -5512,6 +6102,40 @@ out:
        return NULL;
 }
 
+static struct packet *slave_key_status(pid_t pid, int handle, const struct packet *packet)
+{
+       struct slave_node *slave;
+       struct inst_info *inst;
+       const char *pkgname;
+       const char *id;
+       int status;
+       int ret;
+
+       slave = slave_find_by_pid(pid);
+       if (!slave) {
+               ErrPrint("Slave %d is not exists\n", pid);
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssi", &pkgname, &id, &status);
+       if (ret != 3) {
+               ErrPrint("Invalid parameters\n");
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, NULL);
+       if (ret == LB_STATUS_SUCCESS) {
+               if (instance_state(inst) == INST_DESTROYED) {
+                       ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+               } else {
+                       (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
+               }
+       }
+
+out:
+       return NULL;
+}
+
 static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet)
 {
        struct slave_node *slave;
@@ -5546,11 +6170,45 @@ out:
        return NULL;
 }
 
+static struct packet *slave_close_pd(pid_t pid, int handle, const struct packet *packet)
+{
+       struct slave_node *slave;
+       struct inst_info *inst;
+       const char *pkgname;
+       const char *id;
+       int status;
+       int ret;
+
+       slave = slave_find_by_pid(pid);
+       if (!slave) {
+               ErrPrint("Slave %d is not exists\n", pid);
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssi", &pkgname, &id, &status);
+       if (ret != 3) {
+               ErrPrint("Invalid parameters\n");
+               goto out;
+       }
+
+       ret = validate_request(pkgname, id, &inst, NULL);
+       if (ret == LB_STATUS_SUCCESS) {
+               if (instance_state(inst) == INST_DESTROYED) {
+                       ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+               } else {
+                       (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
+               }
+       }
+
+out:
+       return NULL;
+}
+
 static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet)
 {
        struct slave_node *slave;
-       const struct pkg_info *pkg = NULL;
-       struct inst_info *inst = NULL;
+       const struct pkg_info *pkg;
+       struct inst_info *inst;
        const char *pkgname;
        const char *id;
        int ret;
@@ -5649,6 +6307,8 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
        const char *id;
        const char *content_info;
        const char *title;
+       const char *icon = NULL;
+       const char *name = NULL;
        int w;
        int h;
        double priority;
@@ -5661,11 +6321,11 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
                goto out;
        }
 
-       ret = packet_get(packet, "ssiidsss", &pkgname, &id,
+       ret = packet_get(packet, "ssiidsssss", &pkgname, &id,
                                                &w, &h, &priority,
                                                &content_info, &title,
-                                               &safe_filename);
-       if (ret != 8) {
+                                               &safe_filename, &icon, &name);
+       if (ret != 10) {
                ErrPrint("Parameter is not matched\n");
                goto out;
        }
@@ -5678,6 +6338,7 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
                }
 
                instance_set_lb_info(inst, priority, content_info, title);
+               instance_set_alt_info(inst, icon, name);
 
                switch (package_lb_type(instance_package(inst))) {
                case LB_TYPE_SCRIPT:
@@ -5778,6 +6439,7 @@ static struct packet *slave_desc_updated(pid_t pid, int handle, const struct pac
 
        switch (package_pd_type(instance_package(inst))) {
        case PD_TYPE_SCRIPT:
+               DbgPrint("%s updated (%s)\n", instance_id(inst), descfile);
                if (script_handler_is_loaded(instance_pd_script(inst))) {
                        (void)script_handler_parse_desc(inst, descfile, 1);
                }
@@ -6949,6 +7611,22 @@ static struct method s_client_table[] = {
                .cmd = "lb_key_up",
                .handler = client_lb_key_up,
        },
+       {
+               .cmd = "lb_key_focus_in",
+               .handler = client_lb_key_focus_in,
+       },
+       {
+               .cmd = "lb_key_focus_out",
+               .handler = client_lb_key_focus_out,
+       },
+       {
+               .cmd = "lb_key_set",
+               .handler = client_lb_key_set,
+       },
+       {
+               .cmd = "lb_key_unset",
+               .handler = client_lb_key_unset,
+       },
 
        {
                .cmd = "pd_key_down",
@@ -6958,6 +7636,22 @@ static struct method s_client_table[] = {
                .cmd = "pd_key_up",
                .handler = client_pd_key_up,
        },
+       {
+               .cmd = "pd_key_focus_in",
+               .handler = client_pd_key_focus_in,
+       },
+       {
+               .cmd = "pd_key_focus_out",
+               .handler = client_pd_key_focus_out,
+       },
+       {
+               .cmd = "pd_key_set",
+               .handler = client_pd_key_set,
+       },
+       {
+               .cmd = "pd_key_unset",
+               .handler = client_pd_key_unset,
+       },
 
        {
                .cmd = "client_paused",
@@ -7057,6 +7751,14 @@ static struct method s_slave_table[] = {
                .cmd = "access_status",
                .handler = slave_access_status,
        },
+       {
+               .cmd = "key_status",
+               .handler = slave_key_status,
+       },
+       {
+               .cmd = "close_pd",
+               .handler = slave_close_pd,
+       },
 
        {
                .cmd = "hello",
index d045dee..4de77e1 100644 (file)
@@ -427,7 +427,7 @@ static inline struct tcb *tcb_create(struct service_context *svc_ctx, int fd)
                return NULL;
        }
 
-       if (pipe2(tcb->ctrl_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
+       if (pipe2(tcb->ctrl_pipe, O_CLOEXEC) < 0) {
                ErrPrint("pipe2: %s\n", strerror(errno));
                DbgFree(tcb);
                return NULL;
@@ -866,14 +866,14 @@ HAPI struct service_context *service_common_create(const char *addr, int (*servi
                ErrPrint("fcntl: %s\n", strerror(errno));
        }
 
-       if (pipe2(svc_ctx->evt_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
+       if (pipe2(svc_ctx->evt_pipe, O_CLOEXEC) < 0) {
                ErrPrint("pipe: %d\n", strerror(errno));
                secure_socket_destroy_handle(svc_ctx->fd);
                DbgFree(svc_ctx);
                return NULL;
        }
 
-       if (pipe2(svc_ctx->tcb_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
+       if (pipe2(svc_ctx->tcb_pipe, O_CLOEXEC) < 0) {
                ErrPrint("pipe: %s\n", strerror(errno));
                CLOSE_PIPE(svc_ctx->evt_pipe);
                secure_socket_destroy_handle(svc_ctx->fd);
index f6d204b..4e75ab4 100644 (file)
@@ -85,16 +85,7 @@ static void power_off_cb(keynode_t *node, void *user_data)
        }
 
        if (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART) {
-               int fd;
-
-               fd = creat("/tmp/.stop.provider", 0644);
-               if (fd < 0 || close(fd) < 0) {
-                       ErrPrint("stop.provider [%s]\n", strerror(errno));
-               }
-
-               vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
-               //exit(0);
-               ecore_main_loop_quit();
+               DbgPrint("Power off requested: Ignored\n");
        } else {
                ErrPrint("Unknown power state: %d\n", val);
        }
index 3eb4ae5..4e1f97b 100644 (file)
@@ -84,9 +84,10 @@ struct slave_node {
 
        Eina_List *data_list;
 
-       Ecore_Timer *ttl_timer; /* Time to live */
-       Ecore_Timer *activate_timer; /* Waiting hello packet for this time */
-       Ecore_Timer *relaunch_timer; /* Try to relaunch service app */
+       Ecore_Timer *ttl_timer; /*!< Time to live */
+       Ecore_Timer *activate_timer; /*!< Waiting hello packet for this time */
+       Ecore_Timer *relaunch_timer; /*!< Try to relaunch service app */
+       Ecore_Timer *terminate_timer; /*!< Waiting this timer before terminate the service provider */
        int relaunch_count;
 
 #if defined(_USE_ECORE_TIME_GET)
@@ -131,7 +132,7 @@ static Eina_Bool slave_ttl_cb(void *data)
        slave_set_reactivation(slave, 0);
        slave_set_reactivate_instances(slave, 1);
 
-       slave = slave_deactivate(slave);
+       slave = slave_deactivate(slave, 1);
        if (!slave) {
                DbgPrint("Slave is deleted\n");
        }
@@ -542,7 +543,11 @@ HAPI int slave_activate(struct slave_node *slave)
         * about it is alive? or not.
         */
        if (slave_pid(slave) != (pid_t)-1) {
-               if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE) {
+               if (slave->terminate_timer) {
+                       DbgPrint("Clear terminate timer. to reuse (%d)\n", slave->pid);
+                       ecore_timer_del(slave->terminate_timer);
+                       slave->terminate_timer = NULL;
+               } else if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE) {
                        slave_set_reactivation(slave, 1);
                }
                return LB_STATUS_ERROR_ALREADY;
@@ -735,7 +740,29 @@ static inline int invoke_deactivate_cb(struct slave_node *slave)
        return reactivate;
 }
 
-HAPI struct slave_node *slave_deactivate(struct slave_node *slave)
+static Eina_Bool terminate_timer_cb(void *data)
+{
+       struct slave_node *slave = data;
+       int ret;
+
+       /*!
+        * \todo
+        * check the return value of the aul_terminate_pid
+        */
+       slave->state = SLAVE_REQUEST_TO_TERMINATE;
+       slave->terminate_timer = NULL;
+
+       DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
+       ret = aul_terminate_pid(slave->pid);
+       if (ret < 0) {
+               ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
+               slave = slave_deactivated(slave);
+       }
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
+HAPI struct slave_node *slave_deactivate(struct slave_node *slave, int direct)
 {
        int ret;
 
@@ -752,18 +779,46 @@ HAPI struct slave_node *slave_deactivate(struct slave_node *slave)
                return slave;
        }
 
-       /*!
-        * \todo
-        * check the return value of the aul_terminate_pid
-        */
-       slave->state = SLAVE_REQUEST_TO_TERMINATE;
-
        if (slave_pid(slave) > 0) {
-               DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
-               ret = aul_terminate_pid(slave->pid);
-               if (ret < 0) {
-                       ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
-                       slave = slave_deactivated(slave);
+               if (slave->terminate_timer) {
+                       ErrPrint("Terminate timer is already fired (%d)\n", slave->pid);
+               } else if (!direct) {
+                       DbgPrint("Fire the terminate timer: %d\n", slave->pid);
+                       slave->terminate_timer = ecore_timer_add(SLAVE_ACTIVATE_TIME, terminate_timer_cb, slave);
+                       if (!slave->terminate_timer) {
+                               /*!
+                                * \note
+                                * Normally, Call the terminate_timer_cb directly from here
+                                * But in this case. if the aul_terminate_pid failed, Call the slave_deactivated function directly.
+                                * Then the "slave" pointer can be changed. To trace it, Copy the body of terminate_timer_cb to here.
+                                */
+                               ErrPrint("Failed to add a new timer for terminating\n");
+                               DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
+                               /*!
+                                * \todo
+                                * check the return value of the aul_terminate_pid
+                                */
+                               slave->state = SLAVE_REQUEST_TO_TERMINATE;
+
+                               ret = aul_terminate_pid(slave->pid);
+                               if (ret < 0) {
+                                       ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
+                                       slave = slave_deactivated(slave);
+                               }
+                       }
+               } else {
+                       /*!
+                        * \todo
+                        * check the return value of the aul_terminate_pid
+                        */
+                       slave->state = SLAVE_REQUEST_TO_TERMINATE;
+
+                       DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
+                       ret = aul_terminate_pid(slave->pid);
+                       if (ret < 0) {
+                               ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
+                               slave = slave_deactivated(slave);
+                       }
                }
        }
 
@@ -792,6 +847,11 @@ HAPI struct slave_node *slave_deactivated(struct slave_node *slave)
                slave->relaunch_timer = NULL;
        }
 
+       if (slave->terminate_timer) {
+               ecore_timer_del(slave->terminate_timer);
+               slave->terminate_timer = NULL;
+       }
+
        reactivate = invoke_deactivate_cb(slave);
 
        slave = slave_unref(slave);
@@ -1286,7 +1346,7 @@ HAPI struct slave_node *slave_unload_instance(struct slave_node *slave)
                slave_set_reactivation(slave, 0);
                slave_set_reactivate_instances(slave, 0);
 
-               slave = slave_deactivate(slave);
+               slave = slave_deactivate(slave, 0);
        }
 
        return slave;
@@ -1570,7 +1630,7 @@ HAPI int slave_deactivate_all(int reactivate, int reactivate_instances)
                slave_set_reactivate_instances(slave, reactivate_instances);
                slave_set_reactivation(slave, reactivate);
 
-               if (!slave_deactivate(slave)) {
+               if (!slave_deactivate(slave, 0)) {
                        s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
                }
 
index 58ff2eb..fc07d5b 100644 (file)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#define _GNU_SOURCE
+
 #include <stdio.h>
 #include <sys/time.h>
 #include <string.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <ctype.h>
+#include <sys/statvfs.h>
+#include <sys/mount.h>
 
+#include <sys/smack.h>
 #include <dlog.h>
 #include <Eina.h>
 #include <Ecore.h>
 #include "debug.h"
 #include "conf.h"
 
+static struct info {
+       int emergency_mounted;
+} s_info = {
+       .emergency_mounted = 0,
+};
+
 int errno;
 
 HAPI unsigned long util_string_hash(const char *str)
@@ -200,14 +211,14 @@ HAPI const char *util_basename(const char *name)
 }
 
 /*!
- * Return size of stroage in MegaBytes unit.
+ * Return size of stroage in Bytes unit.
  */
 HAPI unsigned long long util_free_space(const char *path)
 {
-       struct statfs st;
+       struct statvfs st;
        unsigned long long space;
 
-       if (statfs(path, &st) < 0) {
+       if (statvfs(path, &st) < 0) {
                ErrPrint("statvfs: %s\n", strerror(errno));
                return 0lu;
        }
@@ -218,6 +229,7 @@ HAPI unsigned long long util_free_space(const char *path)
         * \note
         * Must have to check the overflow
         */
+
        return space;
 }
 
@@ -235,7 +247,6 @@ static inline char *extend_heap(char *buffer, int *sz, int incsz)
        return tmp;
 }
 
-
 HAPI char *util_replace_string(const char *src, const char *pattern, const char *replace)
 {
        const char *ptr;
@@ -342,7 +353,6 @@ HAPI char *util_replace_string(const char *src, const char *pattern, const char
        return ret;
 }
 
-
 HAPI const char *util_uri_to_path(const char *uri)
 {
        int len;
@@ -467,4 +477,252 @@ HAPI int util_unlink_files(const char *folder)
        return LB_STATUS_SUCCESS;
 }
 
+HAPI void util_remove_emergency_disk(void)
+{
+       int ret;
+       ret = umount(IMAGE_PATH);
+       if (ret < 0) {
+               ErrPrint("umount: %s\n", strerror(errno));
+       }
+
+       DbgPrint("Try to unmount[%s] %d\n", IMAGE_PATH, ret);
+       s_info.emergency_mounted = 0;
+}
+
+HAPI void util_prepare_emergency_disk(void)
+{
+       char *buf;
+       char *source = NULL;
+       char *type = NULL;
+       char *option = NULL;
+       char *ptr;
+       char *rollback_ptr;
+       int tag_idx;
+       int idx;
+       int len;
+       int ret;
+       static const char *tag[] = {
+               "source",
+               "type",
+               "option",
+               NULL,
+       };
+       enum tag_type {
+               TAG_SOURCE,
+               TAG_TYPE,
+               TAG_OPTION,
+               TAG_ERROR
+       };
+
+       buf = strdup(EMERGENCY_DISK);
+       if (!buf) {
+               ErrPrint("Failed to prepare emergency disk info\n");
+               return;
+       }
+
+       rollback_ptr = ptr = buf;
+       idx = 0;
+       tag_idx = 0;
+       len = strlen(ptr);
+
+       while (tag[tag_idx] != NULL && ptr != (buf + len)) {
+               if (tag[tag_idx][idx] == '\0') {
+                       if (*ptr == '=' || isblank(*ptr)) {
+                               switch (tag_idx) {
+                               case TAG_SOURCE:
+                                       if (source) {
+                                               ErrPrint("source[%s] is overrided\n", source);
+                                       }
+
+                                       while ((*ptr != '\0' && *ptr != ';') && (*ptr == '=' || isblank(*ptr))) {
+                                               ptr++;
+                                       }
+
+                                       source = ptr;
+                                       while (*ptr != '\0' && *ptr != ';') {
+                                               ptr++;
+                                       }
+
+                                       if (*source == '\0') {
+                                               type = NULL;
+                                       }
+
+                                       *ptr = '\0';
+                                       rollback_ptr = ptr + 1;
+                                       idx = 0;
+                                       break;
+                               case TAG_TYPE:
+                                       if (type) {
+                                               ErrPrint("type[%s] is overrided\n", type);
+                                       }
+
+                                       while ((*ptr != '\0' && *ptr != ';') && (*ptr == '=' || isblank(*ptr))) {
+                                               ptr++;
+                                       }
+
+                                       type = ptr;
+                                       while (*ptr != '\0' && *ptr != ';') {
+                                               ptr++;
+                                       }
+
+                                       if (*type == '\0') {
+                                               type = NULL;
+                                       }
+
+                                       *ptr = '\0';
+                                       rollback_ptr = ptr + 1;
+                                       idx = 0;
+                                       break;
+                               case TAG_OPTION:
+                                       if (option) {
+                                               ErrPrint("option[%s] is overrided\n", option);
+                                       }
+
+                                       while ((*ptr != '\0' && *ptr != ';') && (*ptr == '=' || isblank(*ptr))) {
+                                               ptr++;
+                                       }
+
+                                       option = ptr;
+                                       while (*ptr != '\0' && *ptr != ';') {
+                                               ptr++;
+                                       }
+
+                                       if (*option == '\0') {
+                                               option = NULL;
+                                       }
+
+                                       *ptr = '\0';
+                                       rollback_ptr = ptr + 1;
+                                       idx = 0;
+                                       break;
+                               default:
+                                       break;
+                               }
+                       } else {
+                               ptr = rollback_ptr;
+                               tag_idx++;
+                               idx = 0;
+                       }
+               } else if (tag[tag_idx][idx] != *ptr) {
+                       ptr = rollback_ptr;
+                       tag_idx++;
+                       idx = 0;
+               } else {
+                       ptr++;
+                       idx++;
+               } // tag
+       }
+
+       DbgPrint("source[%s] type[%s] option[%s]\n", source, type, option);
+
+       ret = mount(source, IMAGE_PATH, type, MS_NOSUID | MS_NOEXEC, option);
+       DbgFree(buf);
+       if (ret < 0) {
+               ErrPrint("Failed to mount: %s\n", strerror(errno));
+               return;
+       }
+
+       MINIMUM_SPACE = 0;
+
+       ErrPrint("Disk space is not enough, use the tmpfs. Currently required minimum space is %lu bytes\n", MINIMUM_SPACE);
+       if (chmod(IMAGE_PATH, 0750) < 0) {
+               ErrPrint("chmod: %s\n", strerror(errno));
+       }
+
+       if (chown(IMAGE_PATH, 5000, 5000) < 0) {
+               ErrPrint("chown: %s\n", strerror(errno));
+       }
+
+       ret = smack_setlabel(IMAGE_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+       if (ret != 0) {
+               ErrPrint("Failed to set SMACK for %s (%d)\n", IMAGE_PATH, ret);
+       } else {
+               ret = smack_setlabel(IMAGE_PATH, "1", SMACK_LABEL_TRANSMUTE);
+               DbgPrint("[%s] is successfully created (t: %d)\n", IMAGE_PATH, ret);
+       }
+
+       if (mkdir(ALWAYS_PATH, 0755) < 0) {
+               ErrPrint("mkdir: (%s) %s\n", ALWAYS_PATH, strerror(errno));
+       } else {
+               if (chmod(ALWAYS_PATH, 0750) < 0) {
+                       ErrPrint("chmod: %s\n", strerror(errno));
+               }
+
+               if (chown(ALWAYS_PATH, 5000, 5000) < 0) {
+                       ErrPrint("chown: %s\n", strerror(errno));
+               }
+
+               ret = smack_setlabel(ALWAYS_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+               if (ret != 0) {
+                       ErrPrint("Failed to set SMACK for %s (%d)\n", ALWAYS_PATH, ret);
+               } else {
+                       ret = smack_setlabel(ALWAYS_PATH, "1", SMACK_LABEL_TRANSMUTE);
+                       DbgPrint("[%s] is successfully created (t: %d)\n", ALWAYS_PATH, ret);
+               }
+       }
+
+       if (mkdir(READER_PATH, 0755) < 0) {
+               ErrPrint("mkdir: (%s) %s\n", READER_PATH, strerror(errno));
+       } else {
+               if (chmod(READER_PATH, 0750) < 0) {
+                       ErrPrint("chmod: %s\n", strerror(errno));
+               }
+
+               if (chown(READER_PATH, 5000, 5000) < 0) {
+                       ErrPrint("chown: %s\n", strerror(errno));
+               }
+
+               ret = smack_setlabel(READER_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+               if (ret != 0) {
+                       ErrPrint("Failed to set SMACK for %s (%d)\n", READER_PATH, ret);
+               } else {
+                       ret = smack_setlabel(READER_PATH, "1", SMACK_LABEL_TRANSMUTE);
+                       DbgPrint("[%s] is successfully created (t: %d)\n", READER_PATH, ret);
+               }
+       }
+
+       s_info.emergency_mounted = 1;
+}
+
+HAPI int util_emergency_disk_is_mounted(void)
+{
+       return s_info.emergency_mounted;
+}
+
+HAPI void util_setup_log_disk(void)
+{
+       int ret;
+
+       if (access(SLAVE_LOG_PATH, R_OK | W_OK | X_OK) == 0) {
+               DbgPrint("[%s] is already accessible\n", SLAVE_LOG_PATH);
+               return;
+       }
+
+       DbgPrint("Initiate the critical log folder [%s]\n", SLAVE_LOG_PATH);
+       if (mkdir(SLAVE_LOG_PATH, 0755) < 0) {
+               ErrPrint("mkdir: %s\n", strerror(errno));
+       } else {
+               if (chmod(SLAVE_LOG_PATH, 0750) < 0) {
+                       ErrPrint("chmod: %s\n", strerror(errno));
+               }
+
+               if (chown(SLAVE_LOG_PATH, 5000, 5000) < 0) {
+                       ErrPrint("chown: %s\n", strerror(errno));
+               }
+
+               ret = smack_setlabel(SLAVE_LOG_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+               if (ret != 0) {
+                       ErrPrint("Failed to set SMACK for %s (%d)\n", SLAVE_LOG_PATH, ret);
+               } else {
+                       ret = smack_setlabel(SLAVE_LOG_PATH, "1", SMACK_LABEL_TRANSMUTE);
+                       DbgPrint("[%s] is successfully created (t: %d)\n", SLAVE_LOG_PATH, ret);
+               }
+       }
+}
+
+HAPI int util_service_is_enabled(const char *tag)
+{
+       return !!strcasestr(SERVICES, tag);
+}
+
 /* End of a file */
index 21ce342..e3d9837 100644 (file)
@@ -33,7 +33,7 @@
 #include "conf.h"
 
 #ifndef SVC_PKG
-#define SVC_PKG                "org.tizen.data-provider-slave.icon"
+#define SVC_PKG                "com.samsung.data-provider-slave.icon"
 #endif
 
 #ifndef LAUNCH_TIMEOUT
index 36da47f..6f519c1 100644 (file)
@@ -24,7 +24,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include <Evas.h>
 #include <Ecore_X.h>
 #include <Ecore.h>
 
index d01f00f..fc79bf6 100644 (file)
@@ -560,7 +560,7 @@ static void send_inst_list(const char *pkgname)
        s_info.age++;
 }
 
-static inline void help(void)
+static void help(void)
 {
        printf("liveinfo - Livebox utility\n");
        printf("------------------------------ [Option] ------------------------------\n");
index bbe9929..ae7da68 100644 (file)
@@ -65,7 +65,8 @@ char *node_to_abspath(const struct node *node)
 
 static inline int next_state(int from, char ch)
 {
-       switch (ch) {
+       switch (ch)
+       {
        case '\0':
        case '/':
                return 1;
@@ -73,7 +74,6 @@ static inline int next_state(int from, char ch)
                if (from == 1) {
                        return 2;
                }
-
                if (from == 2) {
                        return 3;
                }
@@ -90,7 +90,7 @@ static inline void abspath(const char* pBuffer, char* pRet)
        int src_idx = 0;
        int src_len = strlen(pBuffer);
        pRet[idx] = '/';
-       idx++;
+       idx ++;
 
        while (src_idx <= src_len) {
                from = state;
@@ -110,7 +110,7 @@ static inline void abspath(const char* pBuffer, char* pRet)
                                }
                        } else {
                                pRet[idx] = pBuffer[src_idx];
-                               idx ++;
+                               idx++;
                        }
                        break;
                case 3: