summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-09-14 11:44:25 (GMT)
committerSung-jae Park <nicesj.park@samsung.com>2013-09-14 11:44:25 (GMT)
commit941b30125c131c0fdd83f64c3db397552fb9ebaa (patch)
treef20af0dfe0b849747564133e1e28568ddb8e1920
parentee7d6d4823bd538712bbc269b2598fd40103173a (diff)
downloaddata-provider-master-941b30125c131c0fdd83f64c3db397552fb9ebaa.zip
data-provider-master-941b30125c131c0fdd83f64c3db397552fb9ebaa.tar.gz
data-provider-master-941b30125c131c0fdd83f64c3db397552fb9ebaa.tar.bz2
Update sequence of conf loading.
Load the script engine plugin when it is required. Change-Id: I537b1dd927c07a95eeea28ff35231f7a46fb37f2
-rw-r--r--CMakeLists.txt2
-rw-r--r--include/conf.h7
-rw-r--r--packaging/data-provider-master.spec3
-rw-r--r--src/conf.c314
-rw-r--r--src/main.c16
-rw-r--r--src/script_handler.c336
6 files changed, 443 insertions, 235 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d552d4a..60e28df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,6 +62,8 @@ 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("-DDEFAULT_MASTER_CONF=\"/usr/share/data-provider-master/conf.ini\"")
+
ADD_DEFINITIONS("-DNDEBUG")
#ADD_DEFINITIONS("-DFLOG")
ADD_DEFINITIONS(${pkg_CFLAGS})
diff --git a/include/conf.h b/include/conf.h
index 2cc2f2b..d29dd2b 100644
--- a/include/conf.h
+++ b/include/conf.h
@@ -95,6 +95,9 @@ struct conf {
extern struct conf g_conf;
extern int conf_loader(void);
+extern void conf_update_size(void);
+extern void conf_reset(void);
+extern void conf_init(void);
#define BASE_W g_conf.base_width
#define BASE_H g_conf.base_height
@@ -167,6 +170,10 @@ extern int conf_loader(void);
#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
#endif
+#if !defined(VCONFKEY_MASTER_RESTART_COUNT)
+#define VCONFKEY_MASTER_RESTART_COUNT "memory/private/data-provider-master/restart_count"
+#endif
+
#define USE_XMONITOR g_conf.use_xmonitor
#define HAPI __attribute__((visibility("hidden")))
diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec
index 763504f..10781ba 100644
--- a/packaging/data-provider-master.spec
+++ b/packaging/data-provider-master.spec
@@ -1,6 +1,6 @@
Name: data-provider-master
Summary: Master service provider for liveboxes.
-Version: 0.25.11
+Version: 0.25.12
Release: 1
Group: HomeTF/Livebox
License: Flora License
@@ -116,6 +116,7 @@ chmod 640 /opt/dbspace/.livebox.db
chown 0:5000 /opt/dbspace/.livebox.db-journal
chmod 640 /opt/dbspace/.livebox.db-journal
vconftool set -t bool "memory/data-provider-master/started" 0 -i -u 5000 -f -s system::vconf_system
+vconftool set -t int "memory/private/data-provider-master/restart_count" 0 -i -u 5000 -f -s data-provider-master
vconftool set -t string "db/data-provider-master/serveraddr" "/opt/usr/share/live_magazine/.client.socket" -i -u 5000 -f -s system::vconf_system
echo "Successfully installed. Please start a daemon again manually"
echo "%{_sysconfdir}/init.d/data-provider-master start"
diff --git a/src/conf.c b/src/conf.c
index d01eda6..e572d85 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -24,75 +24,57 @@
#include "util.h"
#include "debug.h"
-HAPI struct conf g_conf = {
- .width = 0,
- .height = 0,
-
- .base_width = 720,
- .base_height = 1280,
-
- .minimum_period = 1.0f,
-
- .default_conf.script = "edje",
- .default_conf.abi = "c",
- .default_conf.pd_group = "disclosure",
- .default_conf.period = -1.0f,
-
- .launch_key.name = "name",
- .launch_key.secured = "secured",
- .launch_key.abi = "abi",
-
- .default_packet_time = 0.0001f,
-
- .empty_content = "",
- .empty_title = "",
-
- .default_content = "default",
- .default_title = "",
-
- .minimum_space = 5242880,
-
- .replace_tag = "/APPID/",
-
- .slave_ttl = 30.0f,
- .slave_activate_time = 30.0f,
- .slave_relaunch_time = 3.0f,
- .slave_relaunch_count = 3,
-
- .max_log_line = 1000,
- .max_log_file = 3,
-
- .sqlite_flush_max = 1048576,
-
- .path = {
- .conf = "/opt/usr/live/%s/etc/%s.conf",
- .image = "/opt/usr/share/live_magazine/",
- .slave_log = "/opt/usr/share/live_magazine/log",
- .reader = "/opt/usr/share/live_magazine/reader",
- .always = "/opt/usr/share/live_magazine/always",
- .script = "/opt/usr/live/%s/res/script/%s.edj",
- .root = "/opt/usr/live/",
- .script_port = "/usr/share/data-provider-master/plugin-script/",
- .db = "/opt/dbspace/.livebox.db",
- .input = "/dev/input/event1",
- },
-
- .ping_time = 240.0f,
- .slave_max_load = 30,
-
- .use_sw_backend = 0,
- .provider_method = "pixmap",
- .debug_mode = 0,
- .overwrite_content = 0,
- .com_core_thread = 1,
- .use_xmonitor = 0,
-
- .scale_width_factor = 1.0f,
- .scale_height_factor = 1.0f,
- .pd_request_timeout = 5.0f,
-};
-
-static void conf_update_size(void)
+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_READER = "/opt/usr/share/live_magazine/reader";
+static const char *CONF_DEFAULT_PATH_ALWAYS = "/opt/usr/share/live_magazine/always";
+static const char *CONF_DEFAULT_PATH_SCRIPT = "/opt/usr/live/%s/res/script/%s.edj";
+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_SCRIPT_TYPE = "edje";
+static const char *CONF_DEFAULT_ABI = "c";
+static const char *CONF_DEFAULT_PD_GROUP = "disclosure";
+static const char *CONF_DEFAULT_LAUNCH_BUNDLE_NAME = "name";
+static const char *CONF_DEFAULT_LAUNCH_BUNDLE_SECURED = "secured";
+static const char *CONF_DEFAULT_LAUNCH_BUNDLE_ABI = "abi";
+static const char *CONF_DEFAULT_CONTENT = "default";
+static const char *CONF_DEFAULT_TITLE = "";
+static const char *CONF_DEFAULT_EMPTY_CONTENT = "";
+static const char *CONF_DEFAULT_EMPTY_TITLE = "";
+static const char *CONF_DEFAULT_REPLACE_TAG = "/APPID/";
+static const char *CONF_DEFAULT_PROVIDER_METHOD = "pixmap";
+static const int CONF_DEFAULT_WIDTH = 0;
+static const int CONF_DEFAULT_HEIGHT = 0;
+static const int CONF_DEFAULT_BASE_WIDTH = 720;
+static const int CONF_DEFAULT_BASE_HEIGHT = 1280;
+static const double CONF_DEFAULT_MINIMUM_PERIOD = 1.0f;
+static const double CONF_DEFAULT_PERIOD = -1.0f;
+static const double CONF_DEFAULT_PACKET_TIME = 0.0001f;
+static const unsigned long CONF_DEFAULT_MINIMUM_SPACE = 5242880;
+static const double CONF_DEFAULT_SLAVE_TTL = 30.0f;
+static const double CONF_DEFAULT_SLAVE_ACTIVATE_TIME = 30.0f;
+static const double CONF_DEFAULT_SLAVE_RELAUNCH_TIME = 3.0f;
+static const int CONF_DEFAULT_SLAVE_RELAUNCH_COUNT = 3;
+static const int CONF_DEFAULT_MAX_LOG_LINE = 1000;
+static const int CONF_DEFAULT_MAX_LOG_FILE = 3;
+static const int CONF_DEFAULT_SQLITE_FLUSH_MAX = 1048576;
+static const double CONF_DEFAULT_PING_TIME = 240.0f;
+static const int CONF_DEFAULT_SLAVE_MAX_LOAD = 30;
+static const int CONF_DEFAULT_USE_SW_BACKEND = 0;
+static const int CONF_DEFAULT_DEBUG_MODE = 0;
+static const int CONF_DEFAULT_OVERWRITE_CONTENT = 0;
+static const int CONF_DEFAULT_COM_CORE_THREAD = 1;
+static const int CONF_DEFAULT_USE_XMONITOR = 0;
+static const 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;
+
+HAPI struct conf g_conf;
+
+HAPI void conf_update_size(void)
{
ecore_x_window_size_get(0, &g_conf.width, &g_conf.height);
g_conf.scale_width_factor = (double)g_conf.width / (double)BASE_W;
@@ -356,6 +338,57 @@ static void pd_request_timeout_handler(char *buffer)
DbgPrint("Default PD request timeout: %lf\n", g_conf.pd_request_timeout);
}
+HAPI void conf_init(void)
+{
+ g_conf.width = CONF_DEFAULT_WIDTH;
+ g_conf.height = CONF_DEFAULT_HEIGHT;
+ g_conf.base_width = CONF_DEFAULT_BASE_WIDTH;
+ g_conf.base_height = CONF_DEFAULT_BASE_HEIGHT;
+ g_conf.minimum_period = CONF_DEFAULT_MINIMUM_PERIOD;
+ g_conf.default_conf.period = CONF_DEFAULT_PERIOD;
+ g_conf.minimum_space = CONF_DEFAULT_MINIMUM_SPACE;
+ g_conf.default_packet_time = CONF_DEFAULT_PACKET_TIME;
+ g_conf.slave_ttl = CONF_DEFAULT_SLAVE_TTL;
+ g_conf.slave_activate_time = CONF_DEFAULT_SLAVE_ACTIVATE_TIME;
+ g_conf.slave_relaunch_time = CONF_DEFAULT_SLAVE_RELAUNCH_TIME;
+ g_conf.slave_relaunch_count = CONF_DEFAULT_SLAVE_RELAUNCH_COUNT;
+ g_conf.max_log_line = CONF_DEFAULT_MAX_LOG_LINE;
+ g_conf.max_log_file = CONF_DEFAULT_MAX_LOG_FILE;
+ g_conf.sqlite_flush_max = CONF_DEFAULT_SQLITE_FLUSH_MAX;
+ g_conf.ping_time = CONF_DEFAULT_PING_TIME;
+ g_conf.slave_max_load = CONF_DEFAULT_SLAVE_MAX_LOAD;
+ g_conf.use_sw_backend = CONF_DEFAULT_USE_SW_BACKEND;
+ g_conf.debug_mode = CONF_DEFAULT_DEBUG_MODE;
+ g_conf.overwrite_content = CONF_DEFAULT_OVERWRITE_CONTENT;
+ g_conf.com_core_thread = CONF_DEFAULT_COM_CORE_THREAD;
+ g_conf.use_xmonitor = CONF_DEFAULT_USE_XMONITOR;
+ 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.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.launch_key.name = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_NAME;
+ g_conf.launch_key.secured = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_SECURED;
+ g_conf.launch_key.abi = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_ABI;
+ g_conf.empty_content = (char *)CONF_DEFAULT_EMPTY_CONTENT;
+ g_conf.empty_title = (char *)CONF_DEFAULT_EMPTY_TITLE;
+ g_conf.default_content = (char *)CONF_DEFAULT_CONTENT;
+ g_conf.default_title = (char *)CONF_DEFAULT_TITLE;
+ g_conf.replace_tag = (char *)CONF_DEFAULT_REPLACE_TAG;
+ g_conf.path.conf = (char *)CONF_DEFAULT_PATH_CONF;
+ g_conf.path.image = (char *)CONF_DEFAULT_PATH_IMAGE;
+ g_conf.path.slave_log = (char *)CONF_DEFAULT_PATH_LOG;
+ g_conf.path.reader = (char *)CONF_DEFAULT_PATH_READER;
+ g_conf.path.always = (char *)CONF_DEFAULT_PATH_ALWAYS;
+ g_conf.path.script = (char *)CONF_DEFAULT_PATH_SCRIPT;
+ g_conf.path.root = (char *)CONF_DEFAULT_PATH_ROOT;
+ g_conf.path.script_port = (char *)CONF_DEFAULT_PATH_SCRIPT_PORT;
+ 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;
+}
+
HAPI int conf_loader(void)
{
FILE *fp;
@@ -525,9 +558,7 @@ HAPI int conf_loader(void)
},
};
- conf_update_size();
-
- fp = fopen("/usr/share/data-provider-master/conf.ini", "rt");
+ fp = fopen(DEFAULT_MASTER_CONF, "rt");
if (!fp) {
ErrPrint("Error: %s\n", strerror(errno));
return LB_STATUS_ERROR_IO;
@@ -700,4 +731,143 @@ HAPI int conf_loader(void)
return LB_STATUS_SUCCESS;
}
+HAPI void conf_reset(void)
+{
+ g_conf.width = CONF_DEFAULT_WIDTH;
+ g_conf.height = CONF_DEFAULT_HEIGHT;
+ g_conf.base_width = CONF_DEFAULT_BASE_WIDTH;
+ g_conf.base_height = CONF_DEFAULT_BASE_HEIGHT;
+ g_conf.minimum_period = CONF_DEFAULT_MINIMUM_PERIOD;
+ g_conf.default_conf.period = CONF_DEFAULT_PERIOD;
+ g_conf.minimum_space = CONF_DEFAULT_MINIMUM_SPACE;
+ g_conf.default_packet_time = CONF_DEFAULT_PACKET_TIME;
+ g_conf.slave_ttl = CONF_DEFAULT_SLAVE_TTL;
+ g_conf.slave_activate_time = CONF_DEFAULT_SLAVE_ACTIVATE_TIME;
+ g_conf.slave_relaunch_time = CONF_DEFAULT_SLAVE_RELAUNCH_TIME;
+ g_conf.slave_relaunch_count = CONF_DEFAULT_SLAVE_RELAUNCH_COUNT;
+ g_conf.max_log_line = CONF_DEFAULT_MAX_LOG_LINE;
+ g_conf.max_log_file = CONF_DEFAULT_MAX_LOG_FILE;
+ g_conf.sqlite_flush_max = CONF_DEFAULT_SQLITE_FLUSH_MAX;
+ g_conf.ping_time = CONF_DEFAULT_PING_TIME;
+ g_conf.slave_max_load = CONF_DEFAULT_SLAVE_MAX_LOAD;
+ g_conf.use_sw_backend = CONF_DEFAULT_USE_SW_BACKEND;
+ g_conf.debug_mode = CONF_DEFAULT_DEBUG_MODE;
+ g_conf.overwrite_content = CONF_DEFAULT_OVERWRITE_CONTENT;
+ g_conf.com_core_thread = CONF_DEFAULT_COM_CORE_THREAD;
+ g_conf.use_xmonitor = CONF_DEFAULT_USE_XMONITOR;
+ 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;
+
+ if (g_conf.default_conf.script != CONF_DEFAULT_SCRIPT_TYPE) {
+ DbgFree(g_conf.default_conf.script);
+ g_conf.default_conf.script = (char *)CONF_DEFAULT_SCRIPT_TYPE;
+ }
+
+ if (g_conf.default_conf.abi != CONF_DEFAULT_ABI) {
+ DbgFree(g_conf.default_conf.abi);
+ g_conf.default_conf.abi = (char *)CONF_DEFAULT_ABI;
+ }
+
+ if (g_conf.default_conf.pd_group != CONF_DEFAULT_PD_GROUP) {
+ DbgFree(g_conf.default_conf.pd_group);
+ g_conf.default_conf.pd_group = (char *)CONF_DEFAULT_PD_GROUP;
+ }
+
+ if (g_conf.launch_key.name != CONF_DEFAULT_LAUNCH_BUNDLE_NAME) {
+ DbgFree(g_conf.launch_key.name);
+ g_conf.launch_key.name = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_NAME;
+ }
+
+ if (g_conf.launch_key.secured != CONF_DEFAULT_LAUNCH_BUNDLE_SECURED) {
+ DbgFree(g_conf.launch_key.secured);
+ g_conf.launch_key.secured = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_SECURED;
+ }
+
+ if (g_conf.launch_key.abi != CONF_DEFAULT_LAUNCH_BUNDLE_ABI) {
+ DbgFree(g_conf.launch_key.abi);
+ g_conf.launch_key.abi = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_ABI;
+ }
+
+ if (g_conf.empty_content != CONF_DEFAULT_EMPTY_CONTENT) {
+ DbgFree(g_conf.empty_content);
+ g_conf.empty_content = (char *)CONF_DEFAULT_EMPTY_CONTENT;
+ }
+
+ if (g_conf.empty_title != CONF_DEFAULT_EMPTY_TITLE) {
+ DbgFree(g_conf.empty_title);
+ g_conf.empty_title = (char *)CONF_DEFAULT_EMPTY_TITLE;
+ }
+
+ if (g_conf.default_content != CONF_DEFAULT_CONTENT) {
+ DbgFree(g_conf.default_content);
+ g_conf.default_content = (char *)CONF_DEFAULT_CONTENT;
+ }
+
+ if (g_conf.default_title != CONF_DEFAULT_TITLE) {
+ DbgFree(g_conf.default_title);
+ g_conf.default_title = (char *)CONF_DEFAULT_TITLE;
+ }
+
+ if (g_conf.replace_tag != CONF_DEFAULT_REPLACE_TAG) {
+ DbgFree(g_conf.replace_tag);
+ g_conf.replace_tag = (char *)CONF_DEFAULT_REPLACE_TAG;
+ }
+
+ if (g_conf.path.conf != CONF_DEFAULT_PATH_CONF) {
+ DbgFree(g_conf.path.conf);
+ g_conf.path.conf = (char *)CONF_DEFAULT_PATH_CONF;
+ }
+
+ if (g_conf.path.image != CONF_DEFAULT_PATH_IMAGE) {
+ DbgFree(g_conf.path.image);
+ g_conf.path.image = (char *)CONF_DEFAULT_PATH_IMAGE;
+ }
+
+ if (g_conf.path.slave_log != CONF_DEFAULT_PATH_LOG) {
+ DbgFree(g_conf.path.slave_log);
+ g_conf.path.slave_log = (char *)CONF_DEFAULT_PATH_LOG;
+ }
+
+ if (g_conf.path.reader != CONF_DEFAULT_PATH_READER) {
+ DbgFree(g_conf.path.reader);
+ g_conf.path.reader = (char *)CONF_DEFAULT_PATH_READER;
+ }
+
+ if (g_conf.path.always != CONF_DEFAULT_PATH_ALWAYS) {
+ DbgFree(g_conf.path.always);
+ g_conf.path.always = (char *)CONF_DEFAULT_PATH_ALWAYS;
+ }
+
+ if (g_conf.path.script != CONF_DEFAULT_PATH_SCRIPT) {
+ DbgFree(g_conf.path.script);
+ g_conf.path.script = (char *)CONF_DEFAULT_PATH_SCRIPT;
+ }
+
+ if (g_conf.path.root != CONF_DEFAULT_PATH_ROOT) {
+ DbgFree(g_conf.path.root);
+ g_conf.path.root = (char *)CONF_DEFAULT_PATH_ROOT;
+ }
+
+ if (g_conf.path.script_port != CONF_DEFAULT_PATH_SCRIPT_PORT) {
+ DbgFree(g_conf.path.script_port);
+ g_conf.path.script_port = (char *)CONF_DEFAULT_PATH_SCRIPT_PORT;
+ }
+
+ if (g_conf.path.db != CONF_DEFAULT_PATH_DB) {
+ DbgFree(g_conf.path.db);
+ g_conf.path.db = (char *)CONF_DEFAULT_PATH_DB;
+ }
+
+ if (g_conf.path.input != CONF_DEFAULT_PATH_INPUT) {
+ DbgFree(g_conf.path.input);
+ g_conf.path.input = (char *)CONF_DEFAULT_PATH_INPUT;
+ }
+
+ if (g_conf.provider_method != CONF_DEFAULT_PROVIDER_METHOD) {
+ DbgFree(g_conf.provider_method);
+ g_conf.provider_method = (char *)CONF_DEFAULT_PROVIDER_METHOD;
+ }
+}
+
/* End of a file */
diff --git a/src/main.c b/src/main.c
index 4aae8be..6e3e298 100644
--- a/src/main.c
+++ b/src/main.c
@@ -244,9 +244,13 @@ static Eina_Bool signal_cb(void *data, Ecore_Fd_Handler *handler)
int main(int argc, char *argv[])
{
int ret;
+ int restart_count = 0;
sigset_t mask;
Ecore_Fd_Handler *signal_handler = NULL;
+ conf_init();
+ conf_loader();
+
/*!
* \note
* Clear old contents files before start the master provider.
@@ -336,10 +340,18 @@ int main(int argc, char *argv[])
g_type_init();
- conf_loader();
+ /*!
+ * \note
+ * conf_update_size requires ecore_x_init.
+ */
+ conf_update_size();
app_create();
+ vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
+ restart_count++;
+ vconf_set_int(VCONFKEY_MASTER_RESTART_COUNT, restart_count);
+
vconf_set_bool(VCONFKEY_MASTER_STARTED, 1);
ecore_main_loop_begin();
vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
@@ -363,6 +375,8 @@ int main(int argc, char *argv[])
fclose(__file_log_fp);
}
#endif
+
+ conf_reset();
return 0;
}
diff --git a/src/script_handler.c b/src/script_handler.c
index 0e04bda..badcdbb 100644
--- a/src/script_handler.c
+++ b/src/script_handler.c
@@ -135,11 +135,186 @@ struct script_info {
static inline void consuming_parsed_block(int lineno, struct inst_info *inst, int is_pd, struct block *block);
+static int load_all_ports(void)
+{
+ struct script_port *item;
+ struct dirent *ent;
+ DIR *dir;
+ char *path;
+ int pathlen;
+
+ dir = opendir(SCRIPT_PORT_PATH);
+ if (!dir) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ return LB_STATUS_ERROR_IO;
+ }
+
+ while ((ent = readdir(dir))) {
+ if (ent->d_name[0] == '.') {
+ continue;
+ }
+
+ pathlen = strlen(ent->d_name) + strlen(SCRIPT_PORT_PATH) + 1;
+ path = malloc(pathlen);
+ if (!path) {
+ ErrPrint("Heap: %s %d\n", strerror(errno), pathlen);
+ if (closedir(dir) < 0) {
+ ErrPrint("closedir: %s\n", strerror(errno));
+ }
+ return LB_STATUS_ERROR_MEMORY;
+ }
+
+ snprintf(path, pathlen, "%s%s", SCRIPT_PORT_PATH, ent->d_name);
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ DbgFree(path);
+ if (closedir(dir) < 0) {
+ ErrPrint("closedir: %s\n", strerror(errno));
+ }
+ return LB_STATUS_ERROR_MEMORY;
+ }
+
+ DbgPrint("Open SCRIPT PORT: %s\n", path);
+ item->handle = dlopen(path, RTLD_GLOBAL | RTLD_NOW | RTLD_DEEPBIND);
+ DbgFree(path);
+ if (!item->handle) {
+ ErrPrint("Error: %s\n", dlerror());
+ DbgFree(item);
+ if (closedir(dir) < 0) {
+ ErrPrint("closedir: %s\n", strerror(errno));
+ }
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ item->magic_id = dlsym(item->handle, "script_magic_id");
+ if (!item->magic_id) {
+ goto errout;
+ }
+
+ DbgPrint("SCRIPT PORT magic id: %s\n", item->magic_id());
+
+ item->update_color = dlsym(item->handle, "script_update_color");
+ if (!item->update_color) {
+ goto errout;
+ }
+
+ item->update_text = dlsym(item->handle, "script_update_text");
+ if (!item->update_text) {
+ goto errout;
+ }
+
+ item->update_image = dlsym(item->handle, "script_update_image");
+ if (!item->update_image) {
+ goto errout;
+ }
+
+ item->update_access = dlsym(item->handle, "script_update_access");
+ if (!item->update_access) {
+ goto errout;
+ }
+
+ item->update_script = dlsym(item->handle, "script_update_script");
+ if (!item->update_script) {
+ goto errout;
+ }
+
+ item->update_signal = dlsym(item->handle, "script_update_signal");
+ if (!item->update_signal) {
+ goto errout;
+ }
+
+ item->update_drag = dlsym(item->handle, "script_update_drag");
+ if (!item->update_drag) {
+ goto errout;
+ }
+
+ item->update_size = dlsym(item->handle, "script_update_size");
+ if (!item->update_size) {
+ goto errout;
+ }
+
+ item->update_category = dlsym(item->handle, "script_update_category");
+ if (!item->update_category) {
+ goto errout;
+ }
+
+ item->create = dlsym(item->handle, "script_create");
+ if (!item->create) {
+ goto errout;
+ }
+
+ item->destroy = dlsym(item->handle, "script_destroy");
+ if (!item->destroy) {
+ goto errout;
+ }
+
+ item->load = dlsym(item->handle, "script_load");
+ if (!item->load) {
+ goto errout;
+ }
+
+ item->unload = dlsym(item->handle, "script_unload");
+ if (!item->unload) {
+ goto errout;
+ }
+
+ item->init = dlsym(item->handle, "script_init");
+ if (!item->init) {
+ goto errout;
+ }
+
+ item->fini = dlsym(item->handle, "script_fini");
+ if (!item->fini) {
+ goto errout;
+ }
+
+ item->feed_event = dlsym(item->handle, "script_feed_event");
+ if (!item->feed_event) {
+ goto errout;
+ }
+
+ if (item->init() < 0) {
+ ErrPrint("Failed to initialize script engine\n");
+ goto errout;
+ }
+
+ s_info.script_port_list = eina_list_append(s_info.script_port_list, item);
+ }
+
+ if (closedir(dir) < 0) {
+ ErrPrint("closedir: %s\n", strerror(errno));
+ }
+
+ return LB_STATUS_SUCCESS;
+
+errout:
+ ErrPrint("Error: %s\n", dlerror());
+ if (dlclose(item->handle) != 0) {
+ ErrPrint("dlclose: %s\n", strerror(errno));
+ }
+ DbgFree(item);
+ if (closedir(dir) < 0) {
+ ErrPrint("closedir: %s\n", strerror(errno));
+ }
+ return LB_STATUS_ERROR_FAULT;
+}
+
static inline struct script_port *find_port(const char *magic_id)
{
Eina_List *l;
struct script_port *item;
+ if (!s_info.script_port_list) {
+ int ret;
+
+ ret = load_all_ports();
+ if (ret < 0) {
+ ErrPrint("load_all_ports: %d\n", ret);
+ }
+ }
+
EINA_LIST_FOREACH(s_info.script_port_list, l, item) {
if (!strcmp(item->magic_id(), magic_id)) {
return item;
@@ -1255,174 +1430,13 @@ errout:
HAPI int script_init(void)
{
- struct script_port *item;
- struct dirent *ent;
- DIR *dir;
- char *path;
- int pathlen;
-
if (!strcasecmp(PROVIDER_METHOD, "shm")) {
s_info.env_buf_type = BUFFER_TYPE_SHM;
} else if (!strcasecmp(PROVIDER_METHOD, "pixmap")) {
s_info.env_buf_type = BUFFER_TYPE_PIXMAP;
}
- dir = opendir(SCRIPT_PORT_PATH);
- if (!dir) {
- ErrPrint("Error: %s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
- }
-
- while ((ent = readdir(dir))) {
- if (ent->d_name[0] == '.') {
- continue;
- }
-
- pathlen = strlen(ent->d_name) + strlen(SCRIPT_PORT_PATH) + 1;
- path = malloc(pathlen);
- if (!path) {
- ErrPrint("Heap: %s %d\n", strerror(errno), pathlen);
- if (closedir(dir) < 0) {
- ErrPrint("closedir: %s\n", strerror(errno));
- }
- return LB_STATUS_ERROR_MEMORY;
- }
-
- snprintf(path, pathlen, "%s%s", SCRIPT_PORT_PATH, ent->d_name);
-
- item = malloc(sizeof(*item));
- if (!item) {
- ErrPrint("Heap: %s\n", strerror(errno));
- DbgFree(path);
- if (closedir(dir) < 0) {
- ErrPrint("closedir: %s\n", strerror(errno));
- }
- return LB_STATUS_ERROR_MEMORY;
- }
-
- DbgPrint("Open SCRIPT PORT: %s\n", path);
- item->handle = dlopen(path, RTLD_GLOBAL | RTLD_NOW | RTLD_DEEPBIND);
- DbgFree(path);
- if (!item->handle) {
- ErrPrint("Error: %s\n", dlerror());
- DbgFree(item);
- if (closedir(dir) < 0) {
- ErrPrint("closedir: %s\n", strerror(errno));
- }
- return LB_STATUS_ERROR_FAULT;
- }
-
- item->magic_id = dlsym(item->handle, "script_magic_id");
- if (!item->magic_id) {
- goto errout;
- }
-
- DbgPrint("SCRIPT PORT magic id: %s\n", item->magic_id());
-
- item->update_color = dlsym(item->handle, "script_update_color");
- if (!item->update_color) {
- goto errout;
- }
-
- item->update_text = dlsym(item->handle, "script_update_text");
- if (!item->update_text) {
- goto errout;
- }
-
- item->update_image = dlsym(item->handle, "script_update_image");
- if (!item->update_image) {
- goto errout;
- }
-
- item->update_access = dlsym(item->handle, "script_update_access");
- if (!item->update_access) {
- goto errout;
- }
-
- item->update_script = dlsym(item->handle, "script_update_script");
- if (!item->update_script) {
- goto errout;
- }
-
- item->update_signal = dlsym(item->handle, "script_update_signal");
- if (!item->update_signal) {
- goto errout;
- }
-
- item->update_drag = dlsym(item->handle, "script_update_drag");
- if (!item->update_drag) {
- goto errout;
- }
-
- item->update_size = dlsym(item->handle, "script_update_size");
- if (!item->update_size) {
- goto errout;
- }
-
- item->update_category = dlsym(item->handle, "script_update_category");
- if (!item->update_category) {
- goto errout;
- }
-
- item->create = dlsym(item->handle, "script_create");
- if (!item->create) {
- goto errout;
- }
-
- item->destroy = dlsym(item->handle, "script_destroy");
- if (!item->destroy) {
- goto errout;
- }
-
- item->load = dlsym(item->handle, "script_load");
- if (!item->load) {
- goto errout;
- }
-
- item->unload = dlsym(item->handle, "script_unload");
- if (!item->unload) {
- goto errout;
- }
-
- item->init = dlsym(item->handle, "script_init");
- if (!item->init) {
- goto errout;
- }
-
- item->fini = dlsym(item->handle, "script_fini");
- if (!item->fini) {
- goto errout;
- }
-
- item->feed_event = dlsym(item->handle, "script_feed_event");
- if (!item->feed_event) {
- goto errout;
- }
-
- if (item->init() < 0) {
- ErrPrint("Failed to initialize script engine\n");
- goto errout;
- }
-
- s_info.script_port_list = eina_list_append(s_info.script_port_list, item);
- }
-
- if (closedir(dir) < 0) {
- ErrPrint("closedir: %s\n", strerror(errno));
- }
-
return LB_STATUS_SUCCESS;
-
-errout:
- ErrPrint("Error: %s\n", dlerror());
- if (dlclose(item->handle) != 0) {
- ErrPrint("dlclose: %s\n", strerror(errno));
- }
- DbgFree(item);
- if (closedir(dir) < 0) {
- ErrPrint("closedir: %s\n", strerror(errno));
- }
- return LB_STATUS_ERROR_FAULT;
}
HAPI int script_fini(void)