ecs: reduce header definition for ecs.h
authorJinhyung Choi <jinh0.choi@samsung.com>
Wed, 6 Jan 2016 04:55:10 +0000 (13:55 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 7 Jan 2016 11:07:59 +0000 (20:07 +0900)
- clean-up and re-arrange the definitions and inclusion
- remove unused function definition

Change-Id: Ic54e9d81da2e91f6e534c45f9c7064a53d7e54cc
Signed-off-by: Jinhyung Choi <jinh0.choi@samsung.com>
tizen/src/ecs/ecs.c
tizen/src/ecs/ecs.h
tizen/src/ecs/ecs_eventcast.c
tizen/src/ecs/ecs_internal.h [new file with mode: 0644]
tizen/src/ecs/ecs_msg_device.c
tizen/src/ecs/ecs_msg_injector.c
tizen/src/ecs/ecs_sensor.c
tizen/src/ecs/ecs_sensor.h [new file with mode: 0644]

index 663d7f8..32ddd68 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Contact:
- *  Jinhyung choi   <jinhyung2.choi@samsung.com>
+ *  Jinhyung Choi   <jinh0.choi@samsung.com>
  *  MunKyu Im       <munkyu.im@samsung.com>
  *  Daiyoung Kim    <daiyoung777.kim@samsung.com>
  *  YeongKyoon Lee  <yeongkyoon.lee@samsung.com>
@@ -50,8 +50,6 @@
 #include "ecs.h"
 #include "emul_state.h"
 
-#include "genmsg/ecs.pb-c.h"
-
 #include "debug_ch.h"
 MULTI_DEBUG_CHANNEL(qemu, ecs);
 
@@ -278,6 +276,83 @@ static void reset_sbuf(sbuf* sbuf)
     sbuf->_netlen = 0;
 }
 
+static bool handle_protobuf_msg(ECS_Client* cli, char* data, int len)
+{
+    ECS__Master* master = ecs__master__unpack(NULL, (size_t)len, (const uint8_t*)data);
+    if (!master)
+        return false;
+
+    if (master->type == ECS__MASTER__TYPE__INJECTOR_REQ) {
+        ECS__InjectorReq* msg = master->injector_req;
+        if (!msg)
+            goto fail;
+        msgproc_injector_req(cli, msg);
+    } else if (master->type == ECS__MASTER__TYPE__MONITOR_REQ) {
+        ECS__MonitorReq* msg = master->monitor_req;
+        if (!msg)
+            goto fail;
+        msgproc_monitor_req(cli, msg);
+    } else if (master->type == ECS__MASTER__TYPE__DEVICE_REQ) {
+        cli->client_type = TYPE_ECP;
+        ECS__DeviceReq* msg = master->device_req;
+        if (!msg)
+            goto fail;
+        msgproc_device_req(cli, msg);
+    } else if (master->type == ECS__MASTER__TYPE__NFC_REQ) {
+        ECS__NfcReq* msg = master->nfc_req;
+        if (!msg)
+            goto fail;
+
+        qemu_mutex_lock(&mutex_clilist);
+        if(cli->client_type == TYPE_NONE) {
+            if (!strncmp(msg->category, MSG_TYPE_NFC, 3)) {
+                QTAILQ_REMOVE(&clients, cli, next);
+                cli->client_type = TYPE_ECP;
+                if(g_client_id > 255) {
+                    g_client_id = 1;
+                }
+                cli->client_id = g_client_id++;
+
+                QTAILQ_INSERT_TAIL(&clients, cli, next);
+            } else if (!strncmp(msg->category, MSG_TYPE_SIMUL_NFC, 9)) {
+                QTAILQ_REMOVE(&clients, cli, next);
+                cli->client_type = TYPE_SIMUL_NFC;
+                if(g_client_id > 255) {
+                    g_client_id = 1;
+                }
+                cli->client_id = g_client_id++;
+                QTAILQ_INSERT_TAIL(&clients, cli, next);
+            } else {
+                LOG_SEVERE("unsupported category is found: %s\n", msg->category);
+                qemu_mutex_unlock(&mutex_clilist);
+                goto fail;
+            }
+        }
+        qemu_mutex_unlock(&mutex_clilist);
+
+        msgproc_nfc_req(cli, msg);
+    } else if (master->type == ECS__MASTER__TYPE__KEEPALIVE_ANS) {
+        ECS__KeepAliveAns* msg = master->keepalive_ans;
+        if (!msg)
+            goto fail;
+        msgproc_keepalive_ans(cli, msg);
+    } else if (master->type == ECS__MASTER__TYPE__EVENTCAST_REQ) {
+        ECS__EventCastReq* msg = master->eventcast_req;
+        if (!msg)
+            goto fail;
+        msgproc_eventcast_req(cli, msg);
+    } else {
+        goto fail;
+    }
+
+    ecs__master__free_unpacked(master, NULL);
+    return true;
+fail:
+    LOG_SEVERE("invalid message type : %d\n", master->type);
+    ecs__master__free_unpacked(master, NULL);
+    return false;
+}
+
 static void ecs_read(ECS_Client *cli) {
 
     int read = 0;
@@ -743,99 +818,3 @@ int start_ecs(void) {
     return 0;
 }
 
-bool handle_protobuf_msg(ECS_Client* cli, char* data, int len)
-{
-    ECS__Master* master = ecs__master__unpack(NULL, (size_t)len, (const uint8_t*)data);
-    if (!master)
-        return false;
-
-    if (master->type == ECS__MASTER__TYPE__INJECTOR_REQ)
-    {
-        ECS__InjectorReq* msg = master->injector_req;
-        if (!msg)
-            goto fail;
-        msgproc_injector_req(cli, msg);
-    }
-    else if (master->type == ECS__MASTER__TYPE__MONITOR_REQ)
-    {
-        ECS__MonitorReq* msg = master->monitor_req;
-        if (!msg)
-            goto fail;
-        msgproc_monitor_req(cli, msg);
-    }
-    else if (master->type == ECS__MASTER__TYPE__DEVICE_REQ)
-    {
-        cli->client_type = TYPE_ECP;
-        ECS__DeviceReq* msg = master->device_req;
-        if (!msg)
-            goto fail;
-        msgproc_device_req(cli, msg);
-    }
-    else if (master->type == ECS__MASTER__TYPE__NFC_REQ)
-    {
-        ECS__NfcReq* msg = master->nfc_req;
-        if (!msg)
-            goto fail;
-
-        qemu_mutex_lock(&mutex_clilist);
-        if(cli->client_type == TYPE_NONE) {
-            if (!strncmp(msg->category, MSG_TYPE_NFC, 3)) {
-                QTAILQ_REMOVE(&clients, cli, next);
-                cli->client_type = TYPE_ECP;
-                if(g_client_id > 255) {
-                    g_client_id = 1;
-                }
-                cli->client_id = g_client_id++;
-
-                QTAILQ_INSERT_TAIL(&clients, cli, next);
-            }
-            else if (!strncmp(msg->category, MSG_TYPE_SIMUL_NFC, 9)) {
-                QTAILQ_REMOVE(&clients, cli, next);
-                cli->client_type = TYPE_SIMUL_NFC;
-                if(g_client_id > 255) {
-                    g_client_id = 1;
-                }
-                cli->client_id = g_client_id++;
-                QTAILQ_INSERT_TAIL(&clients, cli, next);
-            }
-            else {
-                LOG_SEVERE("unsupported category is found: %s\n", msg->category);
-                qemu_mutex_unlock(&mutex_clilist);
-                goto fail;
-            }
-        }
-        qemu_mutex_unlock(&mutex_clilist);
-
-        msgproc_nfc_req(cli, msg);
-    }
-#if 0
-    else if (master->type == ECS__MASTER__TYPE__CHECKVERSION_REQ)
-    {
-        ECS__CheckVersionReq* msg = master->checkversion_req;
-        if (!msg)
-            goto fail;
-        msgproc_checkversion_req(cli, msg);
-    }
-#endif
-    else if (master->type == ECS__MASTER__TYPE__KEEPALIVE_ANS)
-    {
-        ECS__KeepAliveAns* msg = master->keepalive_ans;
-        if (!msg)
-            goto fail;
-        msgproc_keepalive_ans(cli, msg);
-    }
-    else if (master->type == ECS__MASTER__TYPE__EVENTCAST_REQ)
-    {
-        ECS__EventCastReq* msg = master->eventcast_req;
-        if (!msg)
-            goto fail;
-        msgproc_eventcast_req(cli, msg);
-    }
-
-    ecs__master__free_unpacked(master, NULL);
-    return true;
-fail:
-    LOG_SEVERE("invalid message type : %d\n", master->type);
-    ecs__master__free_unpacked(master, NULL);
-    return false;
-}
index fbfdae4..19e43d4 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Contact:
- *  Jinhyung choi   <jinhyung2.choi@samsung.com>
+ *  Jinhyung Choi   <jinh0.choi@samsung.com>
  *  MunKyu Im       <munkyu.im@samsung.com>
  *  Daiyoung Kim    <daiyoung777.kim@samsung.com>
  *  YeongKyoon Lee  <yeongkyoon.lee@samsung.com>
 #ifndef __ECS_H__
 #define __ECS_H__
 
-#ifdef CONFIG_LINUX
-#include <sys/epoll.h>
-#endif
-
-#include "qapi/qmp/qerror.h"
-#include "qemu-common.h"
-#include "ecs-json-streamer.h"
-#include "genmsg/ecs.pb-c.h"
-#include "genmsg/ecs_ids.pb-c.h"
+#include "ecs_internal.h"
 
 #define HOST_LISTEN_ADDR        "127.0.0.1"
 
@@ -50,7 +42,6 @@
 #define COMMAND_TYPE_CONTROL    "control"
 #define COMMAND_TYPE_MONITOR    "monitor"
 #define COMMAND_TYPE_DEVICE     "device"
-
 #define COMMAND_TYPE_TETHERING  "eventcast"
 
 #define MSG_TYPE_SENSOR         "sensor"
 
 #define MSG_GROUP_STATUS        15
 
-enum message_action {
-    MSG_ACT_BATTERY_LEVEL = 100,
-    MSG_ACT_BATTERY_CHARGER = 101,
-    MSG_ACT_USB = 102,
-    MSG_ACT_EARJACK = 103,
-    MSG_ACT_RSSI = 104,
-    MSG_ACT_ACCEL = 110,
-    MSG_ACT_GYRO = 111,
-    MSG_ACT_MAG = 112,
-    MSG_ACT_LIGHT = 113,
-    MSG_ACT_PROXI = 114,
-    MSG_ACT_MOTION = 115,
-    MSG_ACT_PRESSURE = 116,
-    MSG_ACT_UV = 117,
-    MSG_ACT_HRM = 118,
-    MSG_ACT_LOCATION = 120,
-    MSG_ACT_NETBRIDGE = 123
-};
-
-#define TIMER_ALIVE_S           60
-#define TYPE_DATA_SELF          "self"
-
-enum injector_level {
-    level_accel = 1,
-    level_proxi = 2,
-    level_light = 3,
-    level_gyro = 4,
-    level_geo = 5,
-    level_battery = 8,
-    level_tilt = 12,
-    level_magnetic = 13,
-    level_pressure = 20,
-    level_uv = 21,
-    level_hrm = 22,
-};
-
-#define MAX_CATEGORY_LEN        10
-typedef unsigned short  type_length;
-typedef unsigned char   type_group;
-typedef unsigned char   type_action;
-
-#define OUT_BUF_SIZE    4096
-#define READ_BUF_LEN    4096
-#define MAX_ID_SIZE     255
-#define MAX_INJECTOR_REQ_DATA 128
-typedef struct sbuf
-{
-    int _netlen;
-    int _use;
-    char _buf[OUT_BUF_SIZE];
-}sbuf;
-
-struct Monitor {
-    int suspend_cnt;
-    uint8_t outbuf[OUT_BUF_SIZE];
-    int outbuf_index;
-    void *password_opaque;
-    Error *error;
-    QLIST_HEAD(,mon_fd_t) fds;
-    QLIST_ENTRY(Monitor) entry;
-};
-
-#define MAX_EVENTS  1000
-#define MAX_FD_NUM  300
-typedef struct ECS_State {
-    int listen_fd;
-#ifdef CONFIG_LINUX
-    int epoll_fd;
-    struct epoll_event events[MAX_EVENTS];
-#else
-    fd_set reads;
-#endif
-    int is_unix;
-    int ecs_running;
-    QEMUTimer *alive_timer;
-    Monitor *mon;
-} ECS_State;
-
-#define TYPE_NONE       0x00
-#define TYPE_ECP        0x01
-#define TYPE_SIMUL_NFC  0x02
-
-typedef struct ECS_Client {
-    int client_fd;
-    unsigned char client_id;
-    unsigned char client_type;
-    int keep_alive;
-    const char* type;
-
-    sbuf sbuf;
-
-    ECS_State *cs;
-    JSONMessageParser parser;
-    QTAILQ_ENTRY(ECS_Client) next;
-} ECS_Client;
-
 #define NFC_MAX_BUF_SIZE  4096
 
 typedef struct nfc_msg_info {
@@ -175,16 +70,10 @@ typedef struct nfc_msg_info {
 int start_ecs(void);
 bool is_ecs_running(void);
 
-ECS_Client *find_client(unsigned char id, unsigned char type);
-bool handle_protobuf_msg(ECS_Client* cli, char* data, const int len);
-
-bool ntf_to_injector(const char* data, const int len);
-bool ntf_to_control(const char* data, const int len);
-bool ntf_to_monitor(const char* data, const int len);
-
 bool send_msg_to_guest(const char* cmd, int group, int action,
                        char* data, int data_len);
 
+/* System request */
 enum ecs_system_action {
     ECS_SYSTEM_ACTION_FORCE_CLOSE,
     ECS_SYSTEM_ACTION_REBOOT
@@ -194,59 +83,16 @@ void send_shutdown_request(int action);
 
 void make_send_device_ntf (char* cmd, int group, int action, char* data);
 
-bool pb_to_all_clients(ECS__Master* master);
-bool pb_to_single_client(ECS__Master* master, ECS_Client *clii);
-
 bool send_injector_ntf(const char* data, const int len);
 bool send_monitor_ntf(const char* data, const int len);
 bool send_device_ntf(const char* data, const int len);
 bool send_nfc_ntf(struct nfc_msg_info *msg);
 
-void send_to_single_client(ECS_Client *clii, const char* data, const int len);
-bool send_to_all_client(const char* data, const int len);
-void send_to_client(int fd, const char* data, const int len);
-
-void ecs_client_close(ECS_Client* clii);
-int ecs_write(int fd, const uint8_t *buf, int len);
-void ecs_make_header(QDict* obj, type_length length, type_group group, type_action action);
-
-void read_val_short(const char* data, unsigned short* ret_val);
-void read_val_char(const char* data, unsigned char* ret_val);
-void read_val_str(const char* data, char* ret_val, int len);
-void print_binary(const char* data, const int len);
-
-bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg);
-bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg);
-bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg);
-bool msgproc_device_req_ext(ECS_Client* ccli, ECS__DeviceReq* msg);
-bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg);
-void msgproc_checkversion_req(ECS_Client* ccli, ECS__CheckVersionReq* msg);
-void msgproc_keepalive_ans(ECS_Client* ccli, ECS__KeepAliveAns* msg);
-bool msgproc_eventcast_req(ECS_Client* ccli, ECS__EventCastReq* msg);
-
-char *get_tizen_sdk_data_path(void);
-
-/* version check  */
-//void send_ecs_version_check(ECS_Client* ccli);
-
-/* Suspend/resume */
+/* Suspend-resume */
 #define SUSPEND_LOCK   1
 #define SUSPEND_UNLOCK 0
 int ecs_get_suspend_state(void);
 void ecs_set_suspend_state(int state);
 void ecs_suspend_lock_state(int state);
 
-void send_host_keyboard_ntf(int on);
-
-void send_target_image_information(ECS_Client* ccli);
-
-/* request */
-int accel_min_max(double value);
-void req_set_sensor_accel(int x, int y, int z);
-void req_set_sensor_accel_angle(int angle);
-void set_injector_data(const char* data);
-
-/* Monitor */
-void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens, void *opaque);
-
 #endif /* __ECS_H__ */
index 45261b9..a922399 100644 (file)
@@ -30,6 +30,7 @@
 #include "ui/console.h"
 
 #include "ecs.h"
+#include "ecs_sensor.h"
 #include "ecs_eventcast.h"
 #include "eventcast/common.h"
 #include "eventcast/sensor.h"
@@ -259,7 +260,7 @@ static bool send_eventcast_ntf(const char *data)
 
 void send_eventcast_sensor_data(const char *data, int len)
 {
-    set_injector_data(data);
+    ecs_sensor_set_injector_data(data);
 }
 
 void send_eventcast_touch_data(int x, int y, int index, int status)
diff --git a/tizen/src/ecs/ecs_internal.h b/tizen/src/ecs/ecs_internal.h
new file mode 100644 (file)
index 0000000..02da13b
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * Emulator Control Server - internal
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ *  Jinhyung Choi   <jinh0.choi@samsung.com>
+ *  SeokYeon Hwang  <syeon.hwang@samsung.com>
+ *  Sangho Park     <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef __ECS_INTERNAL_H__
+#define __ECS_INTERNAL_H__
+
+#ifdef CONFIG_LINUX
+#include <sys/epoll.h>
+#endif
+
+#include "qemu-common.h"
+#include "qapi/qmp/qerror.h"
+#include "ecs-json-streamer.h"
+#include "genmsg/ecs.pb-c.h"
+#include "genmsg/ecs_ids.pb-c.h"
+#include "ecs_sensor.h"
+
+#define TIMER_ALIVE_S           60
+#define TYPE_DATA_SELF          "self"
+
+#define OUT_BUF_SIZE    4096
+#define READ_BUF_LEN    4096
+#define MAX_ID_SIZE     255
+#define MAX_INJECTOR_REQ_DATA 128
+
+enum message_action {
+    MSG_ACT_BATTERY_LEVEL = 100,
+    MSG_ACT_BATTERY_CHARGER = 101,
+    MSG_ACT_USB = 102,
+    MSG_ACT_EARJACK = 103,
+    MSG_ACT_RSSI = 104,
+    MSG_ACT_ACCEL = 110,
+    MSG_ACT_GYRO = 111,
+    MSG_ACT_MAG = 112,
+    MSG_ACT_LIGHT = 113,
+    MSG_ACT_PROXI = 114,
+    MSG_ACT_MOTION = 115,
+    MSG_ACT_PRESSURE = 116,
+    MSG_ACT_UV = 117,
+    MSG_ACT_HRM = 118,
+    MSG_ACT_LOCATION = 120,
+    MSG_ACT_NETBRIDGE = 123
+};
+
+typedef struct sbuf
+{
+    int _netlen;
+    int _use;
+    char _buf[OUT_BUF_SIZE];
+} sbuf;
+
+struct Monitor {
+    int suspend_cnt;
+    uint8_t outbuf[OUT_BUF_SIZE];
+    int outbuf_index;
+    void *password_opaque;
+    Error *error;
+    QLIST_HEAD(,mon_fd_t) fds;
+    QLIST_ENTRY(Monitor) entry;
+};
+
+#define MAX_EVENTS  1000
+#define MAX_FD_NUM  300
+typedef struct ECS_State {
+    int listen_fd;
+#ifdef CONFIG_LINUX
+    int epoll_fd;
+    struct epoll_event events[MAX_EVENTS];
+#else
+    fd_set reads;
+#endif
+    int is_unix;
+    int ecs_running;
+    QEMUTimer *alive_timer;
+    Monitor *mon;
+} ECS_State;
+
+#define TYPE_NONE       0x00
+#define TYPE_ECP        0x01
+#define TYPE_SIMUL_NFC  0x02
+
+typedef struct ECS_Client {
+    int client_fd;
+    unsigned char client_id;
+    unsigned char client_type;
+    int keep_alive;
+    const char* type;
+
+    sbuf sbuf;
+
+    ECS_State *cs;
+    JSONMessageParser parser;
+    QTAILQ_ENTRY(ECS_Client) next;
+} ECS_Client;
+
+#define MAX_CATEGORY_LEN        10
+typedef unsigned short  type_length;
+typedef unsigned char   type_group;
+typedef unsigned char   type_action;
+
+
+void read_val_short(const char* data, unsigned short* ret_val);
+void read_val_char(const char* data, unsigned char* ret_val);
+void read_val_str(const char* data, char* ret_val, int len);
+void print_binary(const char* data, const int len);
+
+bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg);
+bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg);
+bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg);
+bool msgproc_device_req_ext(ECS_Client* ccli, ECS__DeviceReq* msg);
+bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg);
+void msgproc_keepalive_ans(ECS_Client* ccli, ECS__KeepAliveAns* msg);
+bool msgproc_eventcast_req(ECS_Client* ccli, ECS__EventCastReq* msg);
+
+ECS_Client *find_client(unsigned char id, unsigned char type);
+
+bool ntf_to_injector(const char* data, const int len);
+bool ntf_to_control(const char* data, const int len);
+bool ntf_to_monitor(const char* data, const int len);
+
+bool pb_to_all_clients(ECS__Master* master);
+bool pb_to_single_client(ECS__Master* master, ECS_Client *clii);
+
+void send_to_single_client(ECS_Client *clii, const char* data, const int len);
+bool send_to_all_client(const char* data, const int len);
+void send_to_client(int fd, const char* data, const int len);
+
+void ecs_client_close(ECS_Client* clii);
+int ecs_write(int fd, const uint8_t *buf, int len);
+void ecs_make_header(QDict* obj, type_length length, type_group group, type_action action);
+
+
+/* Monitor */
+void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens, void *opaque);
+
+#endif /* __ECS_INTERNAL_H__ */
index 53707ed..dfc2a79 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Contact:
- *  Jinhyung choi   <jinhyung2.choi@samsung.com>
+ *  Jinhyung Choi   <jinh0.choi@samsung.com>
  *  MunKyu Im       <munkyu.im@samsung.com>
  *  Daiyoung Kim    <daiyoung777.kim@samsung.com>
  *  YeongKyoon Lee  <yeongkyoon.lee@samsung.com>
@@ -39,6 +39,7 @@
 #include "hw/virtio/maru_virtio_nfc.h"
 
 #include "util/ui_operations.h"
+#include "ecs_sensor.h"
 #include "ecs_hds.h"
 #include "emul_state.h"
 #include "ecs.h"
@@ -85,7 +86,7 @@ static void msgproc_device_ans(ECS_Client* ccli, const char* category, bool succ
         g_free(ans.category);
 }
 
-void send_target_image_information(ECS_Client* ccli) {
+static void send_target_image_information(ECS_Client* ccli) {
     ECS__Master master = ECS__MASTER__INIT;
     ECS__DeviceAns ans = ECS__DEVICE_ANS__INIT;
     const char *drive_image_file = get_drive_image_file();
@@ -155,7 +156,7 @@ static void msgproc_device_req_sensor(ECS_Client* ccli, ECS__DeviceReq* msg, cha
         }
     } else {
         if (data != NULL) {
-            set_injector_data(data);
+            ecs_sensor_set_injector_data(data);
             msgproc_device_ans(ccli, cmd, true, NULL);
         } else {
             LOG_SEVERE("sensor set data is null\n");
index c98fbd2..6f1a3bf 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Contact:
- *  Jinhyung choi   <jinhyung2.choi@samsung.com>
+ *  Jinhyung Choi   <jinh0.choi@samsung.com>
  *  MunKyu Im       <munkyu.im@samsung.com>
  *  Daiyoung Kim    <daiyoung777.kim@samsung.com>
  *  YeongKyoon Lee  <yeongkyoon.lee@samsung.com>
@@ -40,6 +40,7 @@
 
 #include "emul_state.h"
 #include "ecs_hds.h"
+#include "ecs_sensor.h"
 #include "debug_ch.h"
 #include "util/osutil.h"
 #include "util/exported_strings.h"
@@ -207,7 +208,7 @@ static bool injector_req_sensor(ECS_Client* ccli, ECS__InjectorReq* msg, char *c
         send_status_injector_ntf(MSG_TYPE_SENSOR, 6, action, data);
         return true;
     } else if (msg->data.data && msg->data.len > 0) {
-        set_injector_data((char*) msg->data.data);
+        ecs_sensor_set_injector_data((char*) msg->data.data);
         return injector_send(ccli, msg, cmd);
     }
 
index 707f445..35ad486 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Contact:
- *  Jinhyung choi   <jinhyung2.choi@samsung.com>
+ *  Jinhyung Choi   <jinh0.choi@samsung.com>
  *  MunKyu Im       <munkyu.im@samsung.com>
  *  Daiyoung Kim    <daiyoung777.kim@samsung.com>
  *  YeongKyoon Lee  <yeongkyoon.lee@samsung.com>
  */
 
 #include "qemu-common.h"
-//#include "qemu_socket.h"
-//#include "qemu-queue.h"
-//#include "qemu-option.h"
-//#include "qemu-config.h"
-//#include "qemu-timer.h"
 
 #include <math.h>
 
@@ -104,6 +99,7 @@ static int _accel_min_max(char* tmp)
     return accel_min_max(atof(tmp));
 }
 
+#if defined(CONFIG_JAVA_UI)
 void req_set_sensor_accel(int x, int y, int z)
 {
     char tmp[TEMP_BUF_SIZE] = { 0, };
@@ -112,7 +108,9 @@ void req_set_sensor_accel(int x, int y, int z)
 
     set_sensor_accel(tmp, strlen(tmp));
 }
+#endif
 
+#if defined(CONFIG_QT)
 static int convert_abs_angle(int angle) {
     if (angle < SENSOR_ANGLE_MIN) {
         return convert_abs_angle(angle + SENSOR_ANGLE_MAX);
@@ -174,6 +172,7 @@ void req_set_sensor_accel_angle(int angle)
 
     set_sensor_accel(accel, strlen(accel));
 }
+#endif
 
 static void _req_set_sensor_accel(int len, const char* data)
 {
@@ -473,7 +472,7 @@ static void set_battery_data(int len, const char* data) {
     }
 }
 
-void set_injector_data(const char* data)
+void ecs_sensor_set_injector_data(const char* data)
 {
     char tmpbuf[TEMP_BUF_SIZE];
     int len = get_parse_val(data, tmpbuf);
diff --git a/tizen/src/ecs/ecs_sensor.h b/tizen/src/ecs/ecs_sensor.h
new file mode 100644 (file)
index 0000000..f8df3d8
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Emulator Control Server - Sensor Device Handler
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ *  Jinhyung Choi   <jinh0.choi@samsung.com>
+ *  SeokYeon Hwang  <syeon.hwang@samsung.com>
+ *  Sangho Park     <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef __ECS_SENSOR_H__
+#define __ECS_SENSOR_H__
+
+enum injector_level {
+    level_accel = 1,
+    level_proxi = 2,
+    level_light = 3,
+    level_gyro = 4,
+    level_geo = 5,
+    level_battery = 8,
+    level_tilt = 12,
+    level_magnetic = 13,
+    level_pressure = 20,
+    level_uv = 21,
+    level_hrm = 22,
+};
+
+/* skin rotation request */
+int accel_min_max(double value);
+#if defined(CONFIG_QT)
+void req_set_sensor_accel_angle(int angle);
+#elif defined(CONFIG_JAVA_UI)
+void req_set_sensor_accel(int x, int y, int z);
+#endif
+
+void ecs_sensor_set_injector_data(const char* data);
+
+#endif // __ECS_SENSOR_H__