qemu: moved ecs_start and port decision, and removed some warnings
authorJinhyung Choi <jinhyung2.choi@samsung.com>
Tue, 30 Jul 2013 07:07:06 +0000 (16:07 +0900)
committerJinhyung Choi <jinhyung2.choi@samsung.com>
Tue, 30 Jul 2013 07:07:06 +0000 (16:07 +0900)
Signed-off-by: Jinhyung Choi <jinhyung2.choi@samsung.com>
tizen/src/base64.c
tizen/src/base64.h
tizen/src/ecs.c
tizen/src/ecs.h
tizen/src/ecs_msg.c
tizen/src/emulator.c

index 63d255abe7a864344c47cddcde6676660f030226..3b723051a156682a75d4f6dd668c586da28b4c16 100644 (file)
@@ -32,7 +32,7 @@ static int DecodeMimeBase64[256] = {
     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1   /* F0-FF */
     };
 
-int base64_decode(char *text, unsigned char *dst, int numBytes )
+int base64_decode(const char *text, unsigned char *dst, int numBytes )
 {
   const char* cp;
   int space_idx = 0, phase;
@@ -76,7 +76,7 @@ int base64_decode(char *text, unsigned char *dst, int numBytes )
 
 }
 
-int base64_encode(char *text, int numBytes, char **encodedText)
+int base64_encode(const char *text, int numBytes, char **encodedText)
 {
   unsigned char input[3]  = {0,0,0};
   unsigned char output[4] = {0,0,0,0};
index 242adadec7aa3c3133f1bd92cd617f10f7ed6fe7..fa5ded1d79f757c39c22342af14f01747b555663 100644 (file)
@@ -1,4 +1,4 @@
 #include "maru_common.h"
 
-int base64_decode(char *text, unsigned char *dst, int numBytes);
-int base64_encode(char *text, int numBytes, char **encodedText);
+int base64_decode(const char *text, unsigned char *dst, int numBytes);
+int base64_encode(const char *text, int numBytes, char **encodedText);
index da291e9bbc089c0a1e8d7bcfd9f205affedbabe9..5c7292d3af061ef57ea1cc2e2420651c56584c06 100644 (file)
@@ -64,7 +64,6 @@ static QTAILQ_HEAD(ECS_ClientHead, ECS_Client)
 clients = QTAILQ_HEAD_INITIALIZER(clients);
 
 static ECS_State *current_ecs;
-static int port;
 
 static pthread_mutex_t mutex_clilist = PTHREAD_MUTEX_INITIALIZER;
 
@@ -315,11 +314,12 @@ static inline bool handler_is_async(const mon_cmd_t *cmd) {
        return cmd->flags & MONITOR_CMD_ASYNC;
 }
 
+/*
 static void monitor_user_noop(Monitor *mon, const QObject *data) {
 }
 
 static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data) {
-       vga_hw_screen_dump(qdict_get_str(qdict, "filename"));
+       //vga_hw_screen_dump(qdict_get_str(qdict, "filename"));
        return 0;
 }
 
@@ -337,6 +337,7 @@ static int do_qmp_capabilities(Monitor *mon, const QDict *params,
                QObject **ret_data) {
        return 0;
 }
+*/
 
 static const mon_cmd_t qmp_cmds[] = {
 //#include "qmp-commands-old.h"
@@ -1103,7 +1104,6 @@ static ECS_Client *ecs_find_client(int fd) {
 }
 
 static int ecs_add_client(ECS_State *cs, int fd) {
-       const char* welcome;
 
        ECS_Client *clii = g_malloc0(sizeof(ECS_Client));
        if (NULL == clii) {
@@ -1131,10 +1131,6 @@ static int ecs_add_client(ECS_State *cs, int fd) {
 
        LOG("Add an ecs client. fd: %d", fd);
 
-       welcome = WELCOME_MESSAGE;
-
-       //send_to_client(fd, welcome);
-
        pthread_mutex_unlock(&mutex_clilist);
 
        return 0;
@@ -1192,6 +1188,7 @@ static void epoll_init(ECS_State *cs) {
 #endif
 
 static void alive_checker(void *opaque) {
+       /*
        ECS_State *cs = opaque;
        ECS_Client *clii;
        QObject *obj;
@@ -1202,7 +1199,6 @@ static void alive_checker(void *opaque) {
                return;
        }
 
-       /*
        QTAILQ_FOREACH(clii, &clients, next)
        {
                if (1 == clii->keep_alive) {
@@ -1304,7 +1300,7 @@ static int ecs_loop(ECS_State *cs)
 }
 #endif
 
-static int check_port(void) {
+int get_ecs_port(void) {
        int port = HOST_LISTEN_PORT;
        int try = EMULATOR_SERVER_NUM;
 
@@ -1318,10 +1314,6 @@ static int check_port(void) {
        return -1;
 }
 
-int get_ecs_port(void) {
-       return port;
-}
-
 static void* ecs_initialize(void* args) {
        int ret = 1;
        ECS_State *cs = NULL;
@@ -1329,6 +1321,7 @@ static void* ecs_initialize(void* args) {
        Error *local_err = NULL;
        Monitor* mon = NULL;
        char host_port[16];
+       int port = -1;
 
        start_logging();
        LOG("ecs starts initializing.");
@@ -1340,7 +1333,7 @@ static void* ecs_initialize(void* args) {
                return NULL;
        }
 
-       port = check_port();
+       port = (int) args;
        if (port < 0) {
                LOG("None of port is available.");
                return NULL;
@@ -1403,10 +1396,10 @@ int stop_ecs(void) {
        return 0;
 }
 
-int start_ecs(void) {
+int start_ecs(int port) {
        pthread_t thread_id;
 
-       if (0 != pthread_create(&thread_id, NULL, ecs_initialize, NULL)) {
+       if (0 != pthread_create(&thread_id, NULL, ecs_initialize, (void*) port)) {
                LOG("pthread creation failed.");
                return -1;
        }
index 72ad384b13f59e5d6402e2b6f53692803fd4f20f..84ff260032fc4fbb896d41baafb919899000dce7 100644 (file)
@@ -33,7 +33,6 @@
 #define HOST_LISTEN_ADDR               "127.0.0.1"
 #define HOST_LISTEN_PORT               27000
 #define EMULATOR_SERVER_NUM            3
-#define WELCOME_MESSAGE                        "### Welcome to ECS service. ###\n"
 
 #define COMMANDS_TYPE                  "type"
 #define COMMANDS_DATA                  "data"
@@ -128,14 +127,13 @@ typedef struct ECS_Client {
 } ECS_Client;
 
 
-int start_ecs(void);
+int start_ecs(int port);
 int stop_ecs(void);
+int get_ecs_port(void);
 
 void ecs_vprintf(const char *type, const char *fmt, va_list ap);
 void ecs_printf(const char *type, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
 
-int get_ecs_port(void);
-
 bool handle_protobuf_msg(ECS_Client* cli, char* data, const int len);
 
 bool ntf_to_injector(const char* data, const int len);
index 1bcfed3cef646965e14010b8b1896aae1c699b9e..7cf47f080c5e2b09242302fec9ddbc707aa36653 100644 (file)
 #include "qmp-commands.h"
 
 #include "ecs.h"
+#include "base64.h"
+#include "mloop_event.h"
 #include "hw/maru_virtio_evdi.h"
 #include "hw/maru_virtio_sensor.h"
+#include "hw/maru_virtio_nfc.h"
 #include "skin/maruskin_operation.h"
 
 // utility functions
 
-void* build_master(ECS__Master* master, int* payloadsize)
+static void* build_master(ECS__Master* master, int* payloadsize)
 {
        int len_pack = ecs__master__get_packed_size(master);
        *payloadsize = len_pack + 4;
@@ -77,7 +80,6 @@ bool msgproc_start_req(ECS_Client* ccli, ECS__StartReq* msg)
 {
        LOG("ecs_startinfo_req");
 
-
        int hostkbd_status = mloop_evcmd_get_hostkbd_status();
 
        LOG("hostkbd_status = %d", hostkbd_status);
@@ -133,7 +135,6 @@ bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg)
                }
        }
 
-
        send_to_evdi(route_ij, sndbuf, sndlen);
 
        g_free(sndbuf);
@@ -163,7 +164,7 @@ bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg)
 bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg)
 {
        char cmd[10];
-       char* data;
+       char* data = NULL;
        memset(cmd, 0, 10);
        strcpy(cmd, msg->category);
        type_length length = (type_length) msg->length;
index 5ca93e61581469ca6d36bfaaa982afdd9a54baa8..1db3f9e20bf467f28f7a77c1ab06a1d6adef3235 100644 (file)
@@ -90,6 +90,7 @@ gchar bin_path[PATH_MAX] = { 0, };
 gchar log_path[PATH_MAX] = { 0, };
 
 int tizen_base_port;
+int tizen_ecs_port;
 char tizen_target_path[PATH_MAX];
 char tizen_target_img_path[PATH_MAX];
 
@@ -360,6 +361,12 @@ static void prepare_basic_features(void)
 
     tizen_base_port = get_sdb_base_port();
 
+       tizen_ecs_port = get_ecs_port();
+
+    qemu_add_opts(&qemu_ecs_opts);
+
+       start_ecs(tizen_ecs_port);
+
     get_host_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
     /* using "DNS" provided by default QEMU */
     g_strlcpy(dns, DEFAULT_QEMU_DNS_IP, strlen(DEFAULT_QEMU_DNS_IP) + 1);
@@ -503,10 +510,6 @@ void prepare_maru(void)
     int guest_server_port = tizen_base_port + SDB_UDP_SENSOR_INDEX;
     start_guest_server(guest_server_port);
 
-    qemu_add_opts(&qemu_ecs_opts);
-
-       start_ecs();
-
     mloop_ev_init();
 }