Add input device path parser for conf.
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 19 Mar 2013 02:36:55 +0000 (02:36 +0000)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 19 Mar 2013 02:36:55 +0000 (02:36 +0000)
Change-Id: I052bf13d13d3b10ab1f85b75dc802481071c8573

data/baltic.conf.ini
data/private.conf.ini
include/conf.h
src/conf.c
src/event.c

index d823052..8854848 100644 (file)
@@ -28,3 +28,4 @@ debug_mode=false
 overwrite_content=false
 com_core_thread=true
 use_xmonitor=false
+input=/dev/input/event1
index c5285fe..243a291 100644 (file)
@@ -28,3 +28,4 @@ debug_mode=false
 overwrite_content=false
 com_core_thread=true
 use_xmonitor=false
+input=/dev/input/event1
index 98a479a..5920fbd 100644 (file)
@@ -65,6 +65,7 @@ struct conf {
                char *reader;
                char *always;
                char *db;
+               char *input;
        } path;
 
        int max_size_type;
@@ -132,6 +133,7 @@ extern int conf_loader(void);
 #define SLAVE_LOG_PATH         g_conf.path.slave_log
 #define READER_PATH            g_conf.path.reader
 #define ALWAYS_PATH            g_conf.path.always
+#define INPUT_PATH             g_conf.path.input
 
 #define REPLACE_TAG_APPID      g_conf.replace_tag
 #define SLAVE_TTL              g_conf.slave_ttl
index aab6a7a..f0ab7ea 100644 (file)
@@ -71,6 +71,7 @@ HAPI struct conf g_conf = {
                .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,
@@ -307,6 +308,14 @@ static void share_path_handler(char *buffer)
        DbgPrint("Shared folder: %s\n", g_conf.path.image);
 }
 
+static void input_path_handler(char *buffer)
+{
+       g_conf.path.input = strdup(buffer);
+       if (!g_conf.path.input)
+               ErrPrint("Heap: %s\n", strerror(errno));
+       DbgPrint("Input device: %s\n", g_conf.path.input);
+}
+
 static void ping_time_handler(char *buffer)
 {
        if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1)
@@ -469,6 +478,10 @@ HAPI int conf_loader(void)
                        .handler = com_core_thread_handler,
                },
                {
+                       .name = "input",
+                       .handler = input_path_handler,
+               },
+               {
                        .name = NULL,
                        .handler = NULL,
                },
index a749575..0062abb 100644 (file)
@@ -311,34 +311,16 @@ static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
        return ECORE_CALLBACK_RENEW;
 }
 
-static inline char *detect_input_device(void)
-{
-       /*!
-        * \NOTE
-        * Implements this first.
-        * We should detect the input device.
-        */
-       return strdup("/dev/input/event1");
-}
-
 HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data)
 {
        int status;
-       char *device_node;
 
        if (s_info.handle >= 0) {
                DbgPrint("Already activated\n");
                return 0;
        }
 
-       device_node = detect_input_device();
-       if (!device_node) {
-               ErrPrint("Input device is not recognized\n");
-               return -ENOTSUP;
-       }
-
-       s_info.handle = open(device_node, O_RDONLY);
-       free(device_node);
+       s_info.handle = open(INPUT_PATH, O_RDONLY);
        if (s_info.handle < 0) {
                ErrPrint("Unable to access the device: %s\n", strerror(errno));
                return -EIO;