From 2623f6512622c037b1ae6e9db064100069c2d7c8 Mon Sep 17 00:00:00 2001 From: DaiYoung Kim Date: Wed, 22 May 2013 19:37:08 +0900 Subject: [PATCH] ecp : host keyboard on/off support, starting info add Signed-off-by: DaiYoung, Kim --- tizen/src/Makefile.tizen | 2 +- tizen/src/ecs.c | 83 +++++++++++++++-------------------- tizen/src/ecs.h | 56 ++++++++++++++++++++++++ tizen/src/ecs_msg.c | 97 +++++++++++++++++++++++++++++++++++++++++ tizen/src/hw/maru_virtio_evdi.c | 2 +- 5 files changed, 189 insertions(+), 51 deletions(-) mode change 100755 => 100644 tizen/src/ecs.c mode change 100755 => 100644 tizen/src/ecs.h create mode 100644 tizen/src/ecs_msg.c diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index a7378fa..46bcf40 100755 --- a/tizen/src/Makefile.tizen +++ b/tizen/src/Makefile.tizen @@ -105,7 +105,7 @@ endif obj-y += debug_ch.o # ecs -obj-y += ecs.o ecs-json-streamer.o qmp_handler.o +obj-y += ecs_msg.o ecs.o ecs-json-streamer.o qmp_handler.o # maru hardware include $(SRC_PATH)/tizen/src/Makefile.tizen.$(TARGET_BASE_ARCH) diff --git a/tizen/src/ecs.c b/tizen/src/ecs.c old mode 100755 new mode 100644 index 7d8530f..25f5115 --- a/tizen/src/ecs.c +++ b/tizen/src/ecs.c @@ -4,10 +4,6 @@ #include "console.h" #include "migration.h" -#ifndef _WIN32 -#include -#endif - #include "qemu-common.h" #include "qemu_socket.h" #include "qemu-queue.h" @@ -19,7 +15,7 @@ #include "qemu-char.h" #include "sdb.h" #include "qjson.h" -#include "ecs-json-streamer.h" + #include "json-parser.h" #include "qmp-commands.h" #include "qint.h" @@ -28,8 +24,7 @@ #include #include -#define OUT_BUF_SIZE 4096 -#define READ_BUF_LEN 4096 + #define DEBUG @@ -40,38 +35,6 @@ struct mon_fd_t { QLIST_ENTRY(mon_fd_t) next; }; -struct Monitor { - int suspend_cnt; - uint8_t outbuf[OUT_BUF_SIZE]; - int outbuf_index; - CPUArchState *mon_cpu; - void *password_opaque; - QError *error; - QLIST_HEAD(,mon_fd_t) fds; - QLIST_ENTRY(Monitor) entry; -}; - -#define MAX_EVENTS 1000 -typedef struct ECS_State { - int listen_fd; - int epoll_fd; - struct epoll_event events[MAX_EVENTS]; - int is_unix; - int ecs_running; - QEMUTimer *alive_timer; - Monitor *mon; -} ECS_State; - -typedef struct ECS_Client { - int client_fd; - int client_id; - int keep_alive; - const char* type; - ECS_State *cs; - JSONMessageParser parser; - QTAILQ_ENTRY(ECS_Client) next; -} ECS_Client; - typedef struct mon_cmd_t { const char *name; const char *args_type; @@ -808,8 +771,9 @@ static bool injector_command_proc(ECS_Client *clii, QObject *obj) memset(cmd, 0, 10); strcpy(cmd, qdict_get_str(header, "cat")); type_length length = (type_length) qdict_get_int(header, "length"); - type_group action = (type_group) (qdict_get_int(header, "action") & 0xff); - type_action group = (type_action) (qdict_get_int(header, "group") & 0xff); + type_group group = (type_action) (qdict_get_int(header, "group") & 0xff); + type_action action = (type_group) (qdict_get_int(header, "action") & 0xff); + // get data const char* data = qdict_get_str(qobject_to_qdict(obj), COMMANDS_DATA); @@ -843,6 +807,20 @@ static bool injector_command_proc(ECS_Client *clii, QObject *obj) static bool control_command_proc(ECS_Client *clii, QObject *obj) { + int64_t control_type = qdict_get_int(qobject_to_qdict(obj), "control_type"); + + QDict* data = qdict_get_qdict(qobject_to_qdict(obj), "data"); + + if (control_type == CONTROL_COMMAND_HOST_KEYBOARD_ONOFF_REQ) + { + control_host_keyboard_onoff_req(clii, data); + } + else if (control_type == CONTROL_COMMAND_SCREENSHOT_REQ) + { + + } + //LOG(">> control : feature = %s, action=%d, data=%s", feature, action, data); + return true; } @@ -887,12 +865,7 @@ static void handle_ecs_command(JSONMessageParser *parser, QList *tokens, void *o type_name = qdict_get_str(qobject_to_qdict(obj), COMMANDS_TYPE); - if (!strcmp(type_name, TYPE_DATA_SELF)) { - LOG("set client fd %d keep alive 0", clii->client_fd); - clii->keep_alive = 0; - return; - } - + /* def_data = check_key(obj, COMMANDS_DATA); if (0 > def_data) { LOG("json format error: data."); @@ -901,9 +874,14 @@ static void handle_ecs_command(JSONMessageParser *parser, QList *tokens, void *o LOG("data key is not found."); return; } + */ - - if (!strcmp(type_name, COMMAND_TYPE_INJECTOR)) { + if (!strcmp(type_name, TYPE_DATA_SELF)) { + LOG("set client fd %d keep alive 0", clii->client_fd); + clii->keep_alive = 0; + return; + } + else if (!strcmp(type_name, COMMAND_TYPE_INJECTOR)) { injector_command_proc(clii, obj); } else if (!strcmp(type_name, COMMAND_TYPE_CONTROL)) { @@ -912,6 +890,13 @@ static void handle_ecs_command(JSONMessageParser *parser, QList *tokens, void *o else if (!strcmp(type_name, COMMAND_TYPE_MONITOR)) { handle_qmp_command(clii, type_name, get_data_object(obj)); } + else if (!strcmp(type_name, ECS_MSG_STARTINFO_REQ)){ + ecs_startinfo_req(clii); + } + else + { + LOG("handler not found"); + } } static Monitor *monitor_create(void) diff --git a/tizen/src/ecs.h b/tizen/src/ecs.h old mode 100755 new mode 100644 index 870f5f0..b31e94e --- a/tizen/src/ecs.h +++ b/tizen/src/ecs.h @@ -1,7 +1,12 @@ #ifndef __ECS_H__ #define __ECS_H__ +#ifndef _WIN32 +#include +#endif + #include "qemu-common.h" +#include "ecs-json-streamer.h" #define ECS_DEBUG 1 @@ -32,6 +37,10 @@ #define COMMAND_TYPE_CONTROL "control" #define COMMAND_TYPE_MONITOR "monitor" +#define ECS_MSG_STARTINFO_REQ "startinfo_req" +#define ECS_MSG_STARTINFO_ANS "startinfo_ans" + + #define TIMER_ALIVE_S 60 #define TYPE_DATA_SELF "self" @@ -40,6 +49,42 @@ 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 + + +struct Monitor { + int suspend_cnt; + uint8_t outbuf[OUT_BUF_SIZE]; + int outbuf_index; + CPUArchState *mon_cpu; + void *password_opaque; + QError *error; + QLIST_HEAD(,mon_fd_t) fds; + QLIST_ENTRY(Monitor) entry; +}; + +#define MAX_EVENTS 1000 +typedef struct ECS_State { + int listen_fd; + int epoll_fd; + struct epoll_event events[MAX_EVENTS]; + int is_unix; + int ecs_running; + QEMUTimer *alive_timer; + Monitor *mon; +} ECS_State; + +typedef struct ECS_Client { + int client_fd; + int client_id; + int keep_alive; + const char* type; + ECS_State *cs; + JSONMessageParser parser; + QTAILQ_ENTRY(ECS_Client) next; +} ECS_Client; + int start_ecs(void); int stop_ecs(void); @@ -61,4 +106,15 @@ 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); + + +enum{ + CONTROL_COMMAND_HOST_KEYBOARD_ONOFF_REQ = 1, + CONTROL_COMMAND_SCREENSHOT_REQ = 2 +}; + +// messages +void ecs_startinfo_req(ECS_Client *clii); +void control_host_keyboard_onoff_req(ECS_Client *clii, QDict* data); + #endif /* __ECS_H__ */ diff --git a/tizen/src/ecs_msg.c b/tizen/src/ecs_msg.c new file mode 100644 index 0000000..f851f09 --- /dev/null +++ b/tizen/src/ecs_msg.c @@ -0,0 +1,97 @@ + +#include "hw/qdev.h" +#include "net.h" +#include "console.h" +#include "migration.h" + +#ifndef _WIN32 +#include +#endif + +#include "qemu-common.h" +#include "qemu_socket.h" +#include "qemu-queue.h" +#include "qemu-option.h" +#include "main-loop.h" +#include "ui/qemu-spice.h" +#include "qemu-char.h" +#include "sdb.h" +#include "qjson.h" +#include "ecs-json-streamer.h" +#include "json-parser.h" +#include "qmp-commands.h" +#include "qint.h" +#include "qbool.h" +#include "ecs.h" +#include "hw/maru_virtio_evdi.h" +#include "skin/maruskin_operation.h" +#include +#include + + +void ecs_startinfo_req(ECS_Client *clii) +{ + LOG("ecs_startinfo_req"); + + int usbkbd_status = mloop_evcmd_get_hostkbd_status(); + + LOG("usbkbd_status = %d", usbkbd_status); + + + + QDict* objData = qdict_new(); + qdict_put(objData, "host_keyboard_onoff", qint_from_int((int64_t )usbkbd_status)); + + QDict* objMsg = qdict_new(); + qobject_incref(QOBJECT(objData)); + + qdict_put(objMsg, "type", qstring_from_str(ECS_MSG_STARTINFO_ANS)); + qdict_put(objMsg, "result", qstring_from_str("success")); + qdict_put(objMsg, "data", objData); + + QString *json; + json = qobject_to_json(QOBJECT(objMsg)); + + assert(json != NULL); + + qstring_append_chr(json, '\n'); + const char* snddata = qstring_get_str(json); + + LOG("<< startinfo json str = %s", snddata); + + send_to_client(clii->client_fd, snddata); + + QDECREF(json); + QDECREF(objData); + QDECREF(objMsg); +} + +void control_host_keyboard_onoff_req(ECS_Client *clii, QDict* data) +{ + int64_t is_on = qdict_get_int(data, "is_on"); + onoff_host_kbd(is_on); +} + +void host_keyboard_onoff_ntf(int is_on) +{ + QDict* objMsg = qdict_new(); + + qdict_put(objMsg, "type", qstring_from_str("host_keyboard_onoff_ntf")); + qdict_put(objMsg, "ison", qbool_from_int((int64_t)is_on)); + + QString *json; + json = qobject_to_json(QOBJECT(objMsg)); + + assert(json != NULL); + + qstring_append_chr(json, '\n'); + const char* snddata = qstring_get_str(json); + + LOG("<< json str = %s", snddata); + + send_to_all_client(snddata, strlen(snddata)); + + QDECREF(json); + + QDECREF(objMsg); +} diff --git a/tizen/src/hw/maru_virtio_evdi.c b/tizen/src/hw/maru_virtio_evdi.c index 8653b9b..b315a27 100755 --- a/tizen/src/hw/maru_virtio_evdi.c +++ b/tizen/src/hw/maru_virtio_evdi.c @@ -168,7 +168,7 @@ static void flush_evdi_recv_queue(void) memcpy(elem.in_sg[0].iov_base, &msginfo->info, sizeof(struct msg_info)); //INFO(">> send to guest count = %d, use = %d, msg = %s, iov_len = %d \n", - ++g_cnt, msginfo->info.use, msginfo->info.buf, elem.in_sg[0].iov_len); + // ++g_cnt, msginfo->info.use, msginfo->info.buf, elem.in_sg[0].iov_len); virtqueue_push(vio_evdi->rvq, &elem, sizeof(msg_info)); virtio_notify(&vio_evdi->vdev, vio_evdi->rvq); -- 2.7.4