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
bundle
ecore-x
ecore
- evas
- ecore-evas
com-core
x11
libdri2
pkgmgr
livebox-service
notification
+ notification-service
badge
+ badge-service
libsmack
shortcut
)
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\"")
src/conf.c
src/dead_monitor.c
src/group.c
- src/fb.c
src/script_handler.c
src/buffer_handler.c
src/io.c
)
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)
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)
-
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
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/
--- /dev/null
+#!/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
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
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
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]
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,
/*!
* \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 */
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;
#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
#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
#define USE_XMONITOR g_conf.use_xmonitor
#define HAPI __attribute__((visibility("hidden")))
+/*!
+ * EAPI is defined from eina.h
+ */
/* End of a file */
struct event_data {
int x;
int y;
+ unsigned int keycode;
int device;
int slot;
struct {
--- /dev/null
+/*
+ * 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 */
+
+++ /dev/null
-/*
- * 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 */
* 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.
*
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 {
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);
* 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);
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);
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);
/*!
*/
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);
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 */
* \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
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://"
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
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)
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
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"
%{_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
#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 */
* | - |
* +---------+
* CREATE TABLE version ( version INTEGER )
- *
+ *
*
* pkgmap
* +-------+-------+-------+-------+
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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:
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;
}
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;
{
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);
{
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;
}
}
int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid)
{
+ ErrPrintWithConsole("[%s]\n", appid);
db_fini();
return 0;
}
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;
}
{
int cnt;
+ ErrPrintWithConsole("[%s]\n", appid);
+
if (!s_info.handle) {
if (db_init() < 0) {
ErrPrint("Failed to init DB\n");
int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid)
{
+ ErrPrintWithConsole("[%s]\n", appid);
db_fini();
return 0;
}
xmlNodePtr node;
int ret;
+ ErrPrintWithConsole("[%s]\n", appid);
+
if (!s_info.handle) {
ErrPrint("Failed to init DB\n");
return -EIO;
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");
{
int cnt;
+ ErrPrintWithConsole("[%s]\n", appid);
+
if (!s_info.handle) {
return -EIO;
}
int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
{
+ ErrPrintWithConsole("[%s]\n", appid);
if (!s_info.handle) {
return -EIO;
}
#include <badge.h>
#include <badge_db.h>
+#include <badge_setting_service.h>
#include <security-server.h>
#include "service_common.h"
};
/*!
+ * 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)
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;
}
}
}
+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;
}
}
-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
*/
.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,
{
void *buffer;
char *id;
+ char *lock;
+ int lock_fd;
enum buffer_type type;
int is_loaded;
struct inst_info *inst;
+ void *data;
};
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)
return LB_STATUS_SUCCESS;
}
-HAPI int buffer_handler_load(struct buffer_info *info)
+EAPI int buffer_handler_load(struct buffer_info *info)
{
int ret;
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);
return LB_STATUS_SUCCESS;
}
-HAPI int buffer_handler_unload(struct buffer_info *info)
+EAPI int buffer_handler_unload(struct buffer_info *info)
{
int ret;
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:
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;
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;
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;
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;
/*!
* \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;
/*!
* \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;
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;
* \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;
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;
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;
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;
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;
}
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;
}
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));
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;
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;
return handle;
}
-HAPI int buffer_handler_raw_close(struct buffer *buffer)
+EAPI int buffer_handler_raw_close(struct buffer *buffer)
{
int ret;
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 */
#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";
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";
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;
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");
}
}
+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) {
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;
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)
.handler = use_sw_backend_handler,
},
{
+ .name = "emergency_disk",
+ .handler = emergency_disk_handler,
+ },
+ {
+ .name = "services",
+ .handler = services_handler,
+ },
+ {
.name = "use_xmonitor",
.handler = use_xmonitor,
},
.handler = pd_request_timeout_handler,
},
{
+ .name = "premultiplied",
+ .handler = premultiplied_handler,
+ },
+ {
.name = NULL,
.handler = NULL,
},
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);
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 */
.y = -1,
.device = -1,
.slot = -1,
+ .keycode = 0,
},
.event_listener_list = NULL,
}
break;
case EV_KEY:
+ DbgPrint("EV_KEY: 0x%X\n", event->value);
+ s_info.event_data.keycode = event->value;
break;
case EV_REL:
break;
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) {
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) {
--- /dev/null
+#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 */
+++ /dev/null
-/*
- * 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 */
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;
}
#include <errno.h>
#include <dlog.h>
-#include <Ecore_Evas.h>
#include <Eina.h>
#include <gio/gio.h>
#include <Ecore.h>
#include "package.h"
#include "script_handler.h"
#include "buffer_handler.h"
-#include "fb.h"
#include "setting.h"
int errno;
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 {
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 {
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);
}
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 {
}
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 {
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 {
}
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 {
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;
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 {
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);
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);
instance_ref(inst);
if (package_add_instance(inst->info, inst) < 0) {
- instance_state_reset(inst);
instance_destroy(inst, INSTANCE_DESTROY_FAULT);
return NULL;
}
goto out;
}
+ DbgPrint("[%s] %d (0x%X)\n", inst->id, ret, inst->state);
+
if (inst->state == INST_DESTROYED) {
/*!
* \note
* 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);
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;
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
}
break;
default:
- info = inst->info;
instance_broadcast_deleted_event(inst, ret);
instance_state_reset(inst);
instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
goto out;
}
+ DbgPrint("[%s] returns %d (state: 0x%X)\n", inst->id, ret, inst->state);
+
if (inst->state == INST_DESTROYED) {
/*!
* \note
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;
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);
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);
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) {
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 {
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;
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);
}
}
+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) {
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:
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;
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;
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);
FILE *fp;
int ch;
int idx = 0;
- int tag_id = -1;
+ int tag_id = 0;
enum {
INIT = 0x0,
GROUP = 0x1,
#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>
{
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));
}
}
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;
}
{
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);
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);
(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?
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
app_terminate();
- evas_shutdown();
- ecore_evas_shutdown();
-
ecore_x_shutdown();
if (signal_handler) {
#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"
);
}
+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, ¬i_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, ¬i_pkgname);
+ notification_get_property(noti, &property);
+ notification_get_type(noti, ¬i_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
*/
}
}
+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;
}
}
+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;
.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,
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");
#include <dlog.h>
#include <Eina.h>
-#include <Ecore_Evas.h>
#include <packet.h>
#include <livebox-errno.h>
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);
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
*
* 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);
}
}
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;
static Eina_List *s_list;
int errno;
-#if __x86_64__
+#if __x86__64__
#define RETURN_TYPE long long
#else
#define RETURN_TYPE int
#include <sys/stat.h>
#include <fcntl.h>
-#include <Ecore_Evas.h>
#include <Ecore.h>
-#include <Evas.h>
#include <Eina.h>
#include <dlog.h>
#include "instance.h"
#include "buffer_handler.h"
#include "script_handler.h"
-#include "fb.h"
#include "debug.h"
#include "conf.h"
#include "util.h"
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);
};
};
struct script_info {
- Ecore_Evas *ee;
- struct fb_info *fb;
- struct inst_info *inst;
+ struct buffer_info *buffer_handle;
int loaded;
int w;
int y;
int down;
+ unsigned int keycode;
+
struct script_port *port;
void *port_data;
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;
}
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 = "";
}
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");
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;
}
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;
}
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);
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;
}
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)
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");
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)
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");
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)
PERF_INIT();
PERF_BEGIN();
struct script_info *info;
- Evas *e;
+ int ret;
if (!block || !block->part) {
ErrPrint("Block or part is not valid\n");
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)
PERF_INIT();
PERF_BEGIN();
struct script_info *info;
- Evas *e;
+ int ret;
if (!block || !block->part) {
ErrPrint("Block or block->part is NIL\n");
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)
PERF_INIT();
PERF_BEGIN();
struct script_info *info;
- Evas *e;
+ int ret;
if (!block || !block->part) {
ErrPrint("Block or block->part is NIL\n");
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)
PERF_INIT();
PERF_BEGIN();
struct script_info *info;
- Evas *e;
+ int ret;
if (!block || !block->part) {
ErrPrint("Block or part is NIL\n");
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)
PERF_INIT();
PERF_BEGIN();
struct script_info *info;
- Evas *e;
+ int ret;
if (!block) {
ErrPrint("block is NIL\n");
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)
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");
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();
}
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);
}
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");
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)
}
}
#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.
#include <errno.h>
#include <dlog.h>
-#include <Evas.h>
-#include <Ecore_Evas.h> /* fb.h */
#include <aul.h>
#include <Ecore.h>
#include <ail.h>
#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"
TYPE_ERROR
};
-struct access_cbdata {
+struct event_cbdata {
int status;
struct inst_info *inst;
};
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;
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);
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;
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) {
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;
}
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;
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;
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) {
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;
}
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;
{
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);
}
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) {
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;
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:
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 {
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) {
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;
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) {
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;
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) {
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;
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) {
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;
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) {
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;
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) {
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;
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) {
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
+ if (ret != 4) {
ErrPrint("Parameter is not matched\n");
ret = LB_STATUS_ERROR_INVALID;
goto out;
}
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, ×tamp, &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, ×tamp, &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, ×tamp, &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, ×tamp, &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)
}
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");
}
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");
}
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");
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) {
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;
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) {
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;
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) {
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;
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) {
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;
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
+ if (ret != 4) {
ErrPrint("Invalid parameter\n");
ret = LB_STATUS_ERROR_INVALID;
goto out;
}
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) {
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, ×tamp, &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, ×tamp, &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)
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) {
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
+ if (ret != 4) {
ErrPrint("Invalid parameter\n");
ret = LB_STATUS_ERROR_INVALID;
goto out;
}
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) {
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)
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) {
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) {
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) {
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) {
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) {
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) {
*/
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
struct script_info *script;
- Evas *e;
script = instance_lb_script(inst);
if (!script) {
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) {
*/
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
struct script_info *script;
- Evas *e;
script = instance_lb_script(inst);
if (!script) {
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) {
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) {
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, ×tamp, &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, ×tamp, &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) {
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;
*/
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
struct script_info *script;
- Evas *e;
script = instance_lb_script(inst);
if (!script) {
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) {
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;
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;
}
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) {
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) {
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, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
+ if (ret != 4) {
ErrPrint("Parameter is not matched\n");
ret = LB_STATUS_ERROR_INVALID;
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.
- */
+ 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) {
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;
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) {
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
+ if (ret != 4) {
ErrPrint("Parameter is not matched\n");
ret = LB_STATUS_ERROR_INVALID;
goto out;
}
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) {
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;
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) {
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
+ if (ret != 4) {
ErrPrint("Parameter is not matched\n");
ret = LB_STATUS_ERROR_INVALID;
goto out;
}
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) {
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)
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) {
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
+ if (ret != 4) {
ErrPrint("Parameter is not matched\n");
ret = LB_STATUS_ERROR_INVALID;
goto out;
}
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) {
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)
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) {
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;
const char *pkgname;
const char *id;
struct client_node *client;
- struct inst_info *inst = NULL;
int pixmap;
void *buf_ptr;
int ret;
goto out;
}
- ret = validate_request(pkgname, id, &inst, NULL);
+ ret = validate_request(pkgname, id, NULL, NULL);
if (ret != LB_STATUS_SUCCESS) {
goto out;
}
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) {
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;
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) {
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);
if (!inst) {
ErrPrint("Failed to create a new instance\n");
}
- } else {
- ErrPrint("Not enough space\n");
}
+
return EXIT_SUCCESS;
}
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;
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;
const char *id;
const char *content_info;
const char *title;
+ const char *icon = NULL;
+ const char *name = NULL;
int w;
int h;
double priority;
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;
}
}
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:
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);
}
.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",
.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",
.cmd = "access_status",
.handler = slave_access_status,
},
+ {
+ .cmd = "key_status",
+ .handler = slave_key_status,
+ },
+ {
+ .cmd = "close_pd",
+ .handler = slave_close_pd,
+ },
{
.cmd = "hello",
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;
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);
}
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);
}
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)
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");
}
* 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;
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;
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);
+ }
}
}
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);
slave_set_reactivation(slave, 0);
slave_set_reactivate_instances(slave, 0);
- slave = slave_deactivate(slave);
+ slave = slave_deactivate(slave, 0);
}
return slave;
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);
}
* 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)
}
/*!
- * 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;
}
* \note
* Must have to check the overflow
*/
+
return space;
}
return tmp;
}
-
HAPI char *util_replace_string(const char *src, const char *pattern, const char *replace)
{
const char *ptr;
return ret;
}
-
HAPI const char *util_uri_to_path(const char *uri)
{
int len;
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 */
#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
#include <sys/stat.h>
#include <sys/types.h>
-#include <Evas.h>
#include <Ecore_X.h>
#include <Ecore.h>
s_info.age++;
}
-static inline void help(void)
+static void help(void)
{
printf("liveinfo - Livebox utility\n");
printf("------------------------------ [Option] ------------------------------\n");
static inline int next_state(int from, char ch)
{
- switch (ch) {
+ switch (ch)
+ {
case '\0':
case '/':
return 1;
if (from == 1) {
return 2;
}
-
if (from == 2) {
return 3;
}
int src_idx = 0;
int src_len = strlen(pBuffer);
pRet[idx] = '/';
- idx++;
+ idx ++;
while (src_idx <= src_len) {
from = state;
}
} else {
pRet[idx] = pBuffer[src_idx];
- idx ++;
+ idx++;
}
break;
case 3: