cmake_minimum_required(VERSION 2.6)
project(emuld CXX)
-# to install pkgconfig setup file.
-SET(EXEC_PREFIX "\${prefix}")
-#SET(LIBDIR "\${prefix}/lib")
-SET(INCLUDEDIR "\${prefix}/include")
-SET(VERSION 1.1)
-
-set(PROJECT_MAJOR_VERSION "1")
-set(PROJECT_MINOR_VERSION "1")
-set(PROJECT_RELEASE_VERSION "0")
+SET(VERSION 0.9.15)
+
set(CMAKE_VERBOSE_MAKEFILE OFF)
IF("$ENV{CFLAGS}" MATCHES "-DMOBILE")
OPTION(USE_D_TV "Use TV Def" ON)
ENDIF()
+IF("$ENV{CFLAGS}" MATCHES "-DUNKNOWN_PROFILE")
+ ADD_DEFINITIONS("-DUNKNOWN_PROFILE")
+ENDIF()
+
SET(SRCS
src/emuld.cpp
src/net.cpp
- src/evdi.cpp
- src/client.cpp
src/common.cpp
)
+IF(MSGPROC_HDS STREQUAL on)
+ ADD_DEFINITIONS("-DENABLE_HDS")
+ SET(SRCS ${SRCS} src/msgproc_hds.cpp)
+ENDIF()
+
+IF(MSGPROC_CMD STREQUAL on)
+ ADD_DEFINITIONS("-DENABLE_CMD")
+ SET(SRCS ${SRCS} src/msgproc_cmd.cpp)
+ENDIF()
+
+IF(MSGPROC_PACKAGE STREQUAL on)
+ ADD_DEFINITIONS("-DENABLE_PACKAGE")
+ SET(SRCS ${SRCS} src/msgproc_package.cpp)
+ENDIF()
+
+IF(MSGPROC_SYSTEM STREQUAL on)
+ ADD_DEFINITIONS("-DENABLE_SYSTEM")
+ SET(SRCS ${SRCS} src/msgproc_system.cpp)
+ENDIF()
+
+IF(MSGPROC_VCONF STREQUAL on)
+ ADD_DEFINITIONS("-DENABLE_VCONF")
+ SET(SRCS ${SRCS} src/msgproc_vconf.cpp)
+ENDIF()
+
+IF(MSGPROC_SUSPEND STREQUAL on)
+ ADD_DEFINITIONS("-DENABLE_SUSPEND")
+ SET(SRCS ${SRCS} src/msgproc_suspend.cpp)
+ENDIF()
+
+IF(MSGPROC_LOCATION STREQUAL on)
+ ADD_DEFINITIONS("-DENABLE_LOCATION")
+ SET(SRCS ${SRCS} src/msgproc_location.cpp)
+ENDIF()
+
IF(USE_D_MOBILE)
SET(SRCS ${SRCS}
src/mobile.cpp
SET(LIBS
${LIBS}
+ libemuld
pthread
+ dl
)
#IF(USE_D_TV)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS} ${LIBS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin)
+
+ADD_SUBDIRECTORY(src/libemuld)
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
\r
Apache License\r
Version 2.0, January 2004\r
-Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
* Daiyoung Kim <daiyoung777.kim@samsung.com>
#ifndef __EMULD_H__
#define __EMULD_H__
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <pthread.h>
#include <sys/epoll.h>
-#include <glib.h>
-#include <vconf.h>
-#include <iostream>
+#include <errno.h>
#include <cassert>
-
#include <map>
-#include "evdi.h"
-
-#define FDTYPE_MAX 6
-
-enum
-{
- fdtype_device = 1,
- fdtype_ij = 4,
- fdtype_max = FDTYPE_MAX
-};
-
-/* definition */
-#define MAX_CLIENT 10000
-#define MAX_EVENTS 10000
-#define MAX_GETCNT 10
-#define ID_SIZE 10
-#define HEADER_SIZE 4
-#define STATUS 15
-
-#define TID_NETWORK 1
-#define TID_LOCATION 3
-#define TID_HDS_ATTACH 4
-#define TID_HDS_DETACH 5
-#define TID_SENSOR 6
-#define TID_VCONF 7
-
-extern pthread_t tid[MAX_CLIENT + 1];
-extern int g_fd[fdtype_max];
-extern bool exit_flag;
-extern int g_epoll_fd;
-extern struct epoll_event g_events[MAX_EVENTS];
-
-void writelog(const char* fmt, ...);
-
-#if defined(ENABLE_DLOG_OUT)
-# define LOG_TAG "EMULD"
-# include <dlog/dlog.h>
-# define LOGINFO LOGI
-# define LOGERR LOGE
-# define LOGDEBUG LOGD
-# define LOGFAIL(expr, fmt, ...) \
- do { \
- if (expr) \
- LOGE(fmt, ##__VA_ARGS__); \
- } while (0)
-#else
-# define LOG_TAG "EMULD"
-# include <dlog/dlog.h>
-# define LOGINFO(fmt, ...) \
- do { \
- writelog(fmt, ##__VA_ARGS__); \
- LOGI(fmt, ##__VA_ARGS__); \
- } while (0)
-# define LOGERR(fmt, ...) \
- do { \
- writelog(fmt, ##__VA_ARGS__); \
- LOGE(fmt, ##__VA_ARGS__); \
- } while (0)
-# define LOGDEBUG(fmt, ...) \
- do { \
- writelog(fmt, ##__VA_ARGS__); \
- LOGD(fmt, ##__VA_ARGS__); \
- } while (0)
-# define LOGFAIL(expr, fmt, ...) \
- do { \
- if (expr) { \
- writelog(fmt, ##__VA_ARGS__); \
- LOGE(fmt, ##__VA_ARGS__); \
- } \
- } while (0)
-#endif
-
-typedef unsigned short CliSN;
-
-struct Cli
-{
- Cli(CliSN clisn, int fdtype, int fd, unsigned short port) :
- clisn(clisn), fdtype(fdtype), sockfd(fd), cli_port(port) {}
-
- CliSN clisn;
- int fdtype;
- int sockfd; /* client socket fds */
- unsigned short cli_port; /* client connection port */
-};
-
-typedef std::map<CliSN, Cli*> CliMap;
-
-void clipool_add(int fd, unsigned short port, const int fdtype);
-void clipool_delete(int fd);
-void close_cli(int cli_fd);
-
-bool send_to_cli(const int fd, char* data, const int len);
-bool send_to_all_ij(char* data, const int len);
-bool is_ij_exist();
-void stop_listen(void);
-
-bool epoll_ctl_add(const int fd);
-void userpool_add(int cli_fd, unsigned short cli_port, const int fdtype);
-void userpool_delete(int cli_fd);
-
-struct fd_info
-{
- fd_info() : fd(-1){}
- int fd;
- int fdtype;
-};
-
-struct LXT_MESSAGE
-{
- unsigned short length;
- unsigned char group;
- unsigned char action;
- void *data;
-};
+#include "synbuf.h"
+#include "libemuld.h"
-typedef struct LXT_MESSAGE LXT_MESSAGE;
+// plugin
+#define EMULD_PLUGIN_DIR "/usr/lib/emuld"
+#define EMULD_PLUGIN_INIT_FN "emuld_plugin_init"
+#define MAX_PLUGINS 16
-struct ijcommand
-{
- enum { CMD_SIZE = 48 };
- ijcommand() : data(NULL)
- {
- memset(cmd, 0, CMD_SIZE);
- }
- ~ijcommand()
- {
- if (data)
- {
- free(data);
- data = NULL;
- }
- }
- char cmd[CMD_SIZE];
- char* data;
- fd_info fdinfo;
+// epoll & evdi
+#define MAX_EVENTS 10000
+#define DEVICE_NODE_PATH "/dev/evdi0"
- LXT_MESSAGE msg;
-};
-
-struct _auto_mutex
-{
- _auto_mutex(pthread_mutex_t* t)
- {
- _mutex = t;
- pthread_mutex_lock(_mutex);
+// DBUS & Boot done signal
+#define BOOT_DONE_SIGNAL "BootingDone"
+#define DBUS_PATH_BOOT_DONE "/Org/Tizen/System/DeviceD/Core"
+#define DBUS_IFACE_BOOT_DONE "org.tizen.system.deviced.core"
- }
- ~_auto_mutex()
- {
- pthread_mutex_unlock(_mutex);
- }
-
- pthread_mutex_t* _mutex;
-};
-
-struct setting_device_param
-{
- setting_device_param() : ActionID(0)
- {
- memset(type_cmd, 0, ID_SIZE);
- }
- unsigned char ActionID;
- char type_cmd[ID_SIZE];
-};
-
-bool read_ijcmd(const int fd, ijcommand* ijcmd);
-int recv_data(int event_fd, char** r_databuf, int size);
-void recv_from_evdi(evdi_fd fd);
-bool accept_proc(const int server_fd);
-void get_guest_addr(void);
-void *register_connection(void* data);
+// Network
+#define MAX_CLIENT 10000
+#define TID_NETWORK 1
+void* register_connection(void *data);
void destroy_connection(void);
+extern pthread_t tid[MAX_CLIENT+1];
-void set_vconf_cb(void);
-void send_to_ecs(const char* cat, int group, int action, char* data);
-void send_emuld_connection(void);
-void send_default_suspend_req(void);
-void send_default_mount_req(void);
-void systemcall(const char* param);
-int parse_val(char *buff, unsigned char data, char *parsbuf);
-
-#define DBUS_MSG_BUF_SIZE 512
-#define DBUS_SEND_SYSNOTI "SysNoti"
-#define DBUS_SEND_EXTCON "ExtCon"
-#define DEVICE_CHANGED "device_changed"
-void dbus_send(const char* device, const char* target, const char* option);
-
+// Common
+#define DEFAULT_MSGPROC "default"
#define HDS_DEFAULT_ID "fsdef0"
#define HDS_DEFAULT_TAG "fileshare"
#define HDS_DEFAULT_PATH "/mnt/host"
#define COMPAT_DEFAULT_DATA "fileshare\n/mnt/host\n"
-#define HDS_ACTION_DEFAULT 99
+#define DBUS_SEND_EXTCON "ExtCon"
+#define DBUS_SEND_SYSNOTI "SysNoti"
+#define DEVICE_CHANGED "device_changed"
+#define DBUS_MSG_BUF_SIZE 512
#define MSG_GROUP_HDS 100
-bool valid_hds_path(char* path);
-int try_mount(char* tag, char* path);
-void hds_unmount_all(void);
-
-#define IJTYPE_SUSPEND "suspend"
-#define IJTYPE_HDS "hds"
-#define IJTYPE_SYSTEM "system"
-#define IJTYPE_GUEST "guest"
-#define IJTYPE_CMD "cmd"
-#define IJTYPE_PACKAGE "package"
-#define IJTYPE_BOOT "boot"
-#define IJTYPE_VCONF "vconf"
-#define IJTYPE_LOCATION "location"
-
-void *g_main_thread_cb(void *arg);
-void msgproc_suspend(ijcommand* ijcmd);
-void msgproc_system(ijcommand* ijcmd);
-void msgproc_package(ijcommand* ijcmd);
-void msgproc_hds(ijcommand* ijcmd);
-void msgproc_location(ijcommand* ijcmd);
-void* exec_cmd_thread(void *args);
-void msgproc_cmd(ijcommand* ijcmd);
-void msgproc_vconf(ijcommand* ijcmd);
-
+#define HDS_ACTION_DEFAULT 99
#define GROUP_MEMORY 30
+#define STATUS 15
+
+#define TID_NETWORK 1
+#define TID_LOCATION 3
+#define TID_HDS_ATTACH 4
+#define TID_HDS_DETACH 5
+#define TID_SENSOR 6
+#define TID_VCONF 7
/* common vconf keys */
#define VCONF_LOW_MEMORY "memory/sysman/low_memory"
#define VCONF_SET 1
#define VCONF_GET 0
-enum VCONF_TYPE {
- SENSOR = 0,
- TELEPHONY = 1,
- LOCATION = 2,
- TV = 3,
- MEMORY = 4
-};
-
struct vconf_res_type {
char *vconf_key;
char *vconf_val;
vconf_t vconf_type;
};
-void add_vconf_map(VCONF_TYPE key, std::string value);
-void add_vconf_map_common(void);
-bool check_possible_vconf_key(std::string key);
+struct setting_device_param
+{
+ setting_device_param() : ActionID(0)
+ {
+ memset(type_cmd, 0, ID_SIZE);
+ }
+ unsigned char ActionID;
+ char type_cmd[ID_SIZE];
+};
-/*
- * For the multi-profile
- */
-bool extra_evdi_command(ijcommand* ijcmd);
+void add_vconf_map_common(void);
void add_vconf_map_profile(void);
-int get_vconf_status(char** value, vconf_t type, const char* key);
+void send_default_suspend_req(void);
+void send_default_mount_req(void);
+bool valid_hds_path(char* path);
+int try_mount(char* tag, char* path);
+void hds_unmount_all(void);
+void set_vconf_cb(void);
+void send_emuld_connection(void);
+void add_msg_proc_common(void);
+void add_msg_proc_ext(void);
+void dbus_send(const char* device, const char* target, const char* option);
+int parse_val(char *buff, unsigned char data, char *parsbuf);
+bool msgproc_hds(ijcommand* ijcmd);
+bool msgproc_cmd(ijcommand* ijcmd);
+bool msgproc_suspend(ijcommand* ijcmd);
+bool msgproc_system(ijcommand* ijcmd);
+bool msgproc_package(ijcommand* ijcmd);
+bool msgproc_vconf(ijcommand* ijcmd);
+bool msgproc_location(ijcommand* ijcmd);
-static inline char* __tmpalloc(const int size)
-{
- char* message = (char*)malloc(sizeof(char) * size);
- if (!message) {
- return NULL;
- }
- memset(message, 0, sizeof(char) * size);
- return message;
-}
-#endif
+#endif // __EMULD_H__
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef __EMULD_LOG_H__
+#define __EMULD_LOG_H__
+
+void writelog(const char* fmt, ...);
+
+#if defined(ENABLE_DLOG_OUT)
+# define LOG_TAG "EMULD"
+# include <dlog/dlog.h>
+# define LOGINFO LOGI
+# define LOGERR LOGE
+# define LOGDEBUG LOGD
+# define LOGWARN LOGW
+# define LOGFAIL(expr, fmt, ...) \
+ do { \
+ if (expr) \
+ LOGW(fmt, ##__VA_ARGS__); \
+ } while (0)
+#else
+# define LOG_TAG "EMULD"
+# include <dlog/dlog.h>
+# define LOGINFO(fmt, ...) \
+ do { \
+ writelog(fmt, ##__VA_ARGS__); \
+ LOGI(fmt, ##__VA_ARGS__); \
+ } while (0)
+# define LOGERR(fmt, ...) \
+ do { \
+ writelog(fmt, ##__VA_ARGS__); \
+ LOGE(fmt, ##__VA_ARGS__); \
+ } while (0)
+# define LOGDEBUG(fmt, ...) \
+ do { \
+ writelog(fmt, ##__VA_ARGS__); \
+ LOGD(fmt, ##__VA_ARGS__); \
+ } while (0)
+# define LOGWARN(fmt, ...) \
+ do { \
+ writelog(fmt, ##__VA_ARGS__); \
+ LOGW(fmt, ##__VA_ARGS__); \
+ } while (0)
+# define LOGFAIL(expr, fmt, ...) \
+ do { \
+ if (expr) { \
+ writelog(fmt, ##__VA_ARGS__); \
+ LOGW(fmt, ##__VA_ARGS__); \
+ } \
+ } while (0)
+#endif
+
+#endif // __EMULD_LOG_H__
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
* Daiyoung Kim <daiyoung777.kim@samsung.com>
#define __MAX_BUF_SIZE 1024
#include <stdarg.h>
+#include <stdint.h>
enum
{
typedef int evdi_fd;
-bool init_device(evdi_fd* ret_fd);
-
-evdi_fd open_device(void);
-
bool ijmsg_send_to_evdi(evdi_fd fd, const char* cat, const char* data, const int len);
bool send_to_evdi(evdi_fd fd, const char* msg, const int len);
bool msg_send_to_evdi(evdi_fd fd, const char* data, const int len);
--- /dev/null
+/*
+ * emulator-daemon library
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Hakhyun Kim <haken.kim@samsung.com>
+ * Jinhyung choi <jinh0.choi@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef __IJCMD_H__
+#define __IJCMD_H__
+
+#include <stdlib.h>
+#include <string.h>
+
+#define CMD_SIZE 48
+
+// command
+#define IJTYPE_SUSPEND "suspend"
+#define IJTYPE_HDS "hds"
+#define IJTYPE_SYSTEM "system"
+#define IJTYPE_GUEST "guest"
+#define IJTYPE_CMD "cmd"
+#define IJTYPE_PACKAGE "package"
+#define IJTYPE_BOOT "boot"
+#define IJTYPE_VCONF "vconf"
+#define IJTYPE_LOCATION "location"
+
+// struct
+struct fd_info
+{
+ fd_info() : fd(-1){}
+ int fd;
+ int fdtype;
+};
+
+struct LXT_MESSAGE
+{
+ unsigned short length;
+ unsigned char group;
+ unsigned char action;
+ void *data;
+};
+
+typedef struct LXT_MESSAGE LXT_MESSAGE;
+
+struct ijcommand
+{
+ ijcommand() : data(NULL)
+ {
+ memset(cmd, 0, CMD_SIZE);
+ }
+ ~ijcommand()
+ {
+ if (data)
+ {
+ free(data);
+ data = NULL;
+ }
+ }
+ char cmd[CMD_SIZE];
+ char* data;
+ fd_info fdinfo;
+
+ LXT_MESSAGE msg;
+};
+#endif // __IJCMD_H__
--- /dev/null
+/*
+ * emulator-daemon library
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Hakhyun Kim <haken.kim@samsung.com>
+ * Jinhyung choi <jinh0.choi@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef __LIBEMULD_H__
+#define __LIBEMULD_H__
+
+// include
+#include <vconf.h>
+#include <pthread.h>
+#include <iostream>
+
+#include "ijcmd.h"
+#include "evdi.h"
+#include "msgproc.h"
+#include "emuld_log.h"
+
+#define FDTYPE_MAX 6
+
+#define HEADER_SIZE 4
+#define ID_SIZE 10
+
+enum VCONF_TYPE {
+ SENSOR = 0,
+ TELEPHONY = 1,
+ LOCATION = 2,
+ TV = 3,
+ MEMORY = 4
+};
+
+enum
+{
+ fdtype_device = 1,
+ fdtype_ij = 4,
+ fdtype_max = FDTYPE_MAX
+};
+
+struct _auto_mutex
+{
+ _auto_mutex(pthread_mutex_t* t)
+ {
+ _mutex = t;
+ pthread_mutex_lock(_mutex);
+
+ }
+ ~_auto_mutex()
+ {
+ pthread_mutex_unlock(_mutex);
+ }
+
+ pthread_mutex_t* _mutex;
+};
+
+// function
+extern "C" {
+bool emuld_plugin_init(void);
+}
+
+void add_vconf_map(VCONF_TYPE key, std::string value);
+bool check_possible_vconf_key(std::string key);
+
+int get_vconf_status(char** value, vconf_t type, const char* key);
+void send_to_ecs(const char* cat, int group, int action, char* data);
+void systemcall(const char* param);
+
+extern int g_fd[fdtype_max];
+#endif // __LIBEMULD_H__
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
* Daiyoung Kim <daiyoung777.kim@samsung.com>
#define VCONF_RSSI "memory/telephony/rssi"
-void msgproc_sensor(ijcommand* ijcmd);
+bool msgproc_sensor(ijcommand* ijcmd);
#endif
--- /dev/null
+/*
+ * emulator-daemon library
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Hakhyun Kim <haken.kim@samsung.com>
+ * Jinhyung choi <jinh0.choi@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef __MSGPROC_H__
+#define __MSGPROC_H__
+
+#include "ijcmd.h"
+
+#define MAX_PATH 4096
+#define NAME_LEN 256
+
+typedef bool (*msgproc)(ijcommand*);
+
+enum msgproc_prio {
+ MSGPROC_PRIO_HIGH,
+ MSGPROC_PRIO_MIDDLE,
+ MSGPROC_PRIO_LOW,
+ MSGPROC_PRIO_END
+};
+
+struct emuld_msgproc {
+ char name[NAME_LEN];
+ char cmd[CMD_SIZE];
+ msgproc func;
+ emuld_msgproc *next;
+};
+typedef emuld_msgproc emuld_msgproc;
+
+extern emuld_msgproc msgproc_head[MSGPROC_PRIO_END];
+
+bool msgproc_add(const char* name, const char* cmd, msgproc func, msgproc_prio priority);
+bool msgproc_del(const char* name, const char* cmd, msgproc_prio priority);
+
+#endif // __MSGPROC_H__
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
* Daiyoung Kim <daiyoung777.kim@samsung.com>
#include <stdbool.h>
#include <stdlib.h>
+#include <string.h>
class synbuf
{
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* Jinhyung Choi <jinhyung2.choi@samsnung.com>
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
* Daiyoung Kim <daiyoung777.kim@samsung.com>
#define IJTYPE_SENSOR "sensor"
-void msgproc_sensor(ijcommand* ijcmd);
+bool msgproc_sensor(ijcommand* ijcmd);
#endif
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
%description
A emulator daemon is used for communication between guest and host
+%package emuld
+Summary: Emulator daemon
+Requires: libemuld = %{version}-%{release}
+
+%description emuld
+Emulator daemon
+
+%package -n libemuld
+Summary: Emulator daemon library
+Requires: vconf
+
+%description -n libemuld
+Emulator daemon library for emuld and plugins
+
+%package -n libemuld-devel
+Summary: Emulator daemon library for (devel)
+Requires: libemuld = %{version}-%{release}
+
+%description -n libemuld-devel
+Emulator daemon library for emuld plugins
+
%prep
+chmod 644 %{SOURCE0}
%setup -q
-%if "%{?profile}" == "mobile"
+# Default msgproc configuration
+%define msgproc_hds on
+%define msgproc_cmd on
+%define msgproc_package on
+%define msgproc_system on
+%define msgproc_vconf on
+%define msgproc_suspend on
+
+%if "%{?tizen_profile_name}" == "mobile"
+%define msgproc_location on
+%endif
+%if "%{?tizen_profile_name}" == "wearable"
+%define msgproc_location on
+%endif
+
+%if "%{?tizen_profile_name}" == "mobile"
export CFLAGS+=" -DMOBILE"
%else
%if "%{?profile}" == "wearable"
%else
%if "%{?profile}" == "tv"
export CFLAGS+=" -DTV"
+%else
+export CFLAGS+=" -DUNKNOWN_PROFILE"
%endif
%endif
%endif
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+cmake . \
+ -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DMSGPROC_HDS=%{msgproc_hds} \
+ -DMSGPROC_CMD=%{msgproc_cmd} \
+ -DMSGPROC_PACKAGE=%{msgproc_package} \
+ -DMSGPROC_SYSTEM=%{msgproc_system} \
+ -DMSGPROC_VCONF=%{msgproc_vconf} \
+ -DMSGPROC_SUSPEND=%{msgproc_suspend} \
+ -DMSGPROC_LOCATION=%{msgproc_location}
%build
# for license
mkdir -p %{buildroot}/usr/share/license
cp LICENSE %{buildroot}/usr/share/license/%{name}
+cp LICENSE %{buildroot}/usr/share/license/libemuld
%make_install
%post
chmod 770 %{_prefix}/bin/emuld
-%files
+%post -n libemuld -p /sbin/ldconfig
+
+%postun -n libemuld -p /sbin/ldconfig
+
+%files -n emuld
%defattr(-,root,root,-)
%manifest emuld.manifest
%{_prefix}/bin/emuld
/usr/lib/systemd/system/emuld.service
/usr/lib/systemd/system/emulator.target.wants/emuld.service
+%files -n libemuld
+%defattr(-,root,root,-)
+%manifest libemuld.manifest
+/usr/share/license/libemuld
+%{_libdir}/libemuld.so.*
+
+%files -n libemuld-devel
+%defattr(-,root,root,-)
+%{_includedir}/libemuld/*.h
+%{_libdir}/libemuld.so
+%{_libdir}/pkgconfig/libemuld.pc
+
%changelog
+++ /dev/null
-/*
- * emulator-daemon
- *
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
- * SooYoung Ha <yoosah.ha@samsnung.com>
- * Sungmin Ha <sungmin82.ha@samsung.com>
- * Daiyoung Kim <daiyoung777.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "emuld.h"
-
-static pthread_mutex_t mutex_climap = PTHREAD_MUTEX_INITIALIZER;
-
-CliMap g_climap;
-
-void clipool_add(int fd, unsigned short port, const int fdtype)
-{
- _auto_mutex _(&mutex_climap);
-
- static CliSN s_id = 0;
-
- CliSN id = s_id;
- s_id++;
- Cli* cli = new Cli(id, fdtype, fd, port);
- if (!cli)
- return;
-
- if (!g_climap.insert(CliMap::value_type(fd, cli)).second)
- return;
-
- LOGINFO("clipool_add fd = %d, port = %d, type = %d", fd, port, fdtype);
-}
-
-
-void close_cli(int cli_fd)
-{
- clipool_delete(cli_fd);
- close(cli_fd);
-}
-
-void clipool_delete(int fd)
-{
- _auto_mutex _(&mutex_climap);
-
- CliMap::iterator it = g_climap.find(fd);
-
- if (it != g_climap.end())
- {
- Cli* cli = it->second;
- g_climap.erase(it);
-
- if (cli)
- {
- delete cli;
- cli = NULL;
- }
- }
-
- LOGINFO("clipool_delete fd = %d", fd);
-}
-
-// for thread safe
-bool send_to_cli(const int fd, char* data, const int len)
-{
- _auto_mutex _(&mutex_climap);
-
- CliMap::iterator it = g_climap.find(fd);
- if (it == g_climap.end())
- return false;
-
- Cli* cli = it->second;
-
- if (send(cli->sockfd, data, len, 0) == -1)
- return false;
-
- return true;
-}
-
-bool send_to_all_ij(char* data, const int len)
-{
- _auto_mutex _(&mutex_climap);
-
- bool result = false;
- CliMap::iterator it, itend = g_climap.end();
-
- for (it = g_climap.begin(); it != itend; it++)
- {
- Cli* cli = it->second;
-
- if (!cli)
- continue;
-
- int sent = send(cli->sockfd, data, len, 0);
- result = (sent == -1) ? false : true;
- if (sent == -1)
- {
- LOGERR("failed to send to ij");
- }
-
- LOGDEBUG("send_len: %d, err= %d", sent, errno);
- }
- return result;
-}
-
-bool is_ij_exist()
-{
- _auto_mutex _(&mutex_climap);
-
- bool result = (g_climap.size() > 0) ? true : false;
- return result;
-}
-
-void stop_listen(void)
-{
- pthread_mutex_destroy(&mutex_climap);;
-}
-
-
-
-
-
* Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
* Daiyoung Kim <daiyoung777.kim@samsung.com>
*
*/
-#include <sys/time.h>
-#include <sys/reboot.h>
#include <sys/mount.h>
-#include <stdio.h>
#include <unistd.h>
-#include <errno.h>
+#include <stdio.h>
#include <utility>
#include <dirent.h>
#include <stdlib.h>
#include <mntent.h>
-#include <vconf-keys.h>
-
#include "emuld.h"
-#include "dd-display.h"
-
-#define PMAPI_RETRY_COUNT 3
-#define POWEROFF_DURATION 2
-
-#define SUSPEND_UNLOCK 0
-#define SUSPEND_LOCK 1
-
-#define MAX_PKGS_BUF 1024
-#define MAX_DATA_BUF 1024
-
-#define PATH_PACKAGE_INSTALL "/opt/usr/apps/tmp/sdk_tools/"
-#define RPM_CMD_QUERY "-q"
-#define RPM_CMD_INSTALL "-U"
-static pthread_mutex_t mutex_pkg = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t mutex_cmd = PTHREAD_MUTEX_INITIALIZER;
-static const char* hds_available_path [] = {
- "/mnt/",
- NULL,
-};
-
-static struct timeval tv_start_poweroff;
-
-static std::multimap<int, std::string> vconf_multimap;
-
-void add_vconf_map(VCONF_TYPE key, std::string value)
-{
- vconf_multimap.insert(std::pair<int, std::string>(key, value));
-}
+#define CMD_BUF 1024
void add_vconf_map_common(void)
{
+
+#ifdef ENABLE_LOCATION
/* location */
add_vconf_map(LOCATION, VCONF_REPLAYMODE);
add_vconf_map(LOCATION, VCONF_FILENAME);
add_vconf_map(LOCATION, VCONF_MLONGITUDE);
add_vconf_map(LOCATION, VCONF_MALTITUDE);
add_vconf_map(LOCATION, VCONF_MHACCURACY);
-
+#endif
/* memory */
add_vconf_map(MEMORY, VCONF_LOW_MEMORY);
}
-bool check_possible_vconf_key(std::string key)
-{
- std::multimap<int, std::string>::iterator it;
- for(it = vconf_multimap.begin(); it != vconf_multimap.end(); it++) {
- if (it->second.compare(key) == 0) {
- return true;
- }
- }
-
- return false;
-}
-
-void systemcall(const char* param)
-{
- if (!param)
- return;
-
- if (system(param) == -1)
- LOGERR("system call failure(command = %s)", param);
-}
-
int parse_val(char *buff, unsigned char data, char *parsbuf)
{
int count=0;
return 0;
}
-enum emuld_system_action {
- EMULD_SYSTEM_ACTION_FORCE_CLOSE,
- EMULD_SYSTEM_ACTION_REBOOT
-};
-
-void powerdown_by_force(void)
-{
- struct timeval now;
- int poweroff_duration = POWEROFF_DURATION;
-
- gettimeofday(&now, NULL);
- /* Waiting until power off duration and displaying animation */
- while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
- LOGINFO("power down wait");
- usleep(100000);
- gettimeofday(&now, NULL);
- }
-
- LOGINFO("Power off by force");
- LOGINFO("sync");
-
- sync();
-
- LOGINFO("poweroff");
-
- reboot(RB_POWER_OFF);
-}
-
-void msgproc_system(ijcommand* ijcmd)
-{
- int action = ijcmd->msg.action;
- LOGDEBUG("msgproc_system with %d action", action);
-
- if (action == EMULD_SYSTEM_ACTION_FORCE_CLOSE) {
- LOGINFO("/etc/rc.d/rc.shutdown, sync, reboot(RB_POWER_OFF)");
-
- sync();
-
- systemcall("/etc/rc.d/rc.shutdown &");
-
- gettimeofday(&tv_start_poweroff, NULL);
-
- powerdown_by_force();
- } else if (action == EMULD_SYSTEM_ACTION_REBOOT) {
- LOGINFO("sync, unmount all hds");
-
- sync();
-
- hds_unmount_all();
- } else {
- LOGERR("unknown system action %d", action);
- }
-}
-
-static int lock_state = SUSPEND_UNLOCK;
-
-static void set_lock_state(int state) {
- int i = 0;
- int ret = 0;
-
- // FIXME: int lock_state = get_lock_state();
- LOGINFO("current lock state : %d (1: lock, other: unlock)", lock_state);
-
- while(i < PMAPI_RETRY_COUNT ) {
- if (state == SUSPEND_LOCK) {
- // Now we blocking to enter "SLEEP".
- ret = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
- } else if (lock_state == SUSPEND_LOCK) {
- ret = display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
- } else {
- LOGINFO("meaningless unlock -> unlock state request. RETURN!");
- return;
- }
-
- LOGINFO("display_(lock/unlock)_state return: %d", ret);
-
- if(ret == 0)
- {
- break;
- }
- ++i;
- sleep(10);
- }
- if (i == PMAPI_RETRY_COUNT) {
- LOGERR("Emulator Daemon: Failed to set lock state.\n");
- return;
- }
- lock_state = state;
-}
-
-void msgproc_suspend(ijcommand* ijcmd)
-{
- LOGINFO("[Suspend] Set lock state as %d (1: lock, other: unlock)", ijcmd->msg.action);
-
- if (ijcmd->msg.action == SUSPEND_LOCK) {
- set_lock_state(SUSPEND_LOCK);
- } else {
- set_lock_state(SUSPEND_UNLOCK);
- }
-}
-
-void send_to_ecs(const char* cat, int group, int action, char* data)
-{
- int datalen = 0;
- int tmplen = HEADER_SIZE;
- if (data != NULL) {
- datalen = strlen(data);
- tmplen += datalen;
- }
-
- char* tmp = (char*) malloc(tmplen);
- if (!tmp)
- return;
-
- memcpy(tmp, &datalen, 2);
- memcpy(tmp + 2, &group, 1);
- memcpy(tmp + 3, &action, 1);
- if (data != NULL) {
- memcpy(tmp + 4, data, datalen);
- }
-
- ijmsg_send_to_evdi(g_fd[fdtype_device], cat, (const char*) tmp, tmplen);
-
- if (tmp)
- free(tmp);
-}
-
void send_emuld_connection(void)
{
send_to_ecs(IJTYPE_GUEST, 0, 1, NULL);
send_to_ecs(IJTYPE_SUSPEND, 5, 15, NULL);
}
-static bool do_rpm_execute(char* pkgs)
-{
- char buf[MAX_PKGS_BUF];
- int ret = 0;
-
- FILE* fp = popen(pkgs, "r");
- if (fp == NULL) {
- LOGERR("[rpm] Failed to popen %s", pkgs);
- return false;
- }
-
- memset(buf, 0, sizeof(buf));
- while(fgets(buf, sizeof(buf), fp)) {
- LOGINFO("[rpm]%s", buf);
- memset(buf, 0, sizeof(buf));
- }
-
- ret = pclose(fp);
- if (ret == -1) {
- LOGINFO("[rpm] pclose error: %d", errno);
- return false;
- }
-
- if (ret >= 0 && WIFEXITED(ret) && WEXITSTATUS(ret) == 0) {
- LOGINFO("[rpm] RPM execution success: %s", pkgs);
- return true;
- }
-
- LOGINFO("[rpm] RPM execution fail: [%x,%x,%x] %s", ret, WIFEXITED(ret), WEXITSTATUS(ret), pkgs);
-
- return false;
-}
-
-static void remove_package(char* data)
-{
- char token[] = ", ";
- char pkg_list[MAX_PKGS_BUF];
- char *addon = NULL;
- char *copy = strdup(data);
- size_t remain;
- if (copy == NULL) {
- LOGERR("Failed to copy data.");
- return;
- }
-
- memset(pkg_list, 0, sizeof(pkg_list));
-
- strcpy(pkg_list, "rm -rf ");
-
- strcat(pkg_list, PATH_PACKAGE_INSTALL);
- addon = strtok(copy, token);
-
- if (addon == NULL) {
- LOGERR("Addon is null");
- free(copy);
- return;
- }
-
- remain = MAX_PKGS_BUF - strnlen(pkg_list, MAX_PKGS_BUF);
-
- if (remain < strnlen(addon, MAX_PKGS_BUF)) {
- LOGERR("Cannot copy add-on name. Insufficient buf size");
- free(copy);
- return;
- }
-
- strncat(pkg_list, addon, remain - 1); // terminating null byte
-
- LOGINFO("remove packages: %s", pkg_list);
-
- systemcall(pkg_list);
-
- free(copy);
-}
-
-static bool do_package(int action, char* data)
-{
- char token[] = ", ";
- char *pkg = NULL;
- char *addon = NULL;
- char pkg_list[MAX_PKGS_BUF];
- size_t remain;
-
- if (data == NULL) {
- LOGERR("Add on package list is empty");
- return false;
- }
-
- memset(pkg_list, 0, sizeof(pkg_list));
-
- strcpy(pkg_list, "rpm");
-
- if (action == 1) {
- strcat(pkg_list, " ");
- strcat(pkg_list, RPM_CMD_QUERY);
- } else if (action == 2) {
- strcat(pkg_list, " ");
- strcat(pkg_list, RPM_CMD_INSTALL);
- } else {
- LOGERR("Unknown action.");
- return false;
- }
- addon = strtok(data, token); // for addon path
-
- if (addon == NULL) {
- LOGERR("Addon is null");
- return false;
- }
-
- pkg = strtok(NULL, token);
- while (pkg != NULL) {
- if (action == 1) {
- pkg[strlen(pkg) - 4] = 0; //remove .rpm
- }
- strcat(pkg_list, " ");
- if (action == 2) {
- strcat(pkg_list, PATH_PACKAGE_INSTALL);
- remain = MAX_PKGS_BUF - strnlen(pkg_list, MAX_PKGS_BUF) - strlen("/");
- strncat(pkg_list, addon, remain - 1); // terminating null byte
- strcat(pkg_list, "/");
- }
-
- remain = MAX_PKGS_BUF - strnlen(pkg_list, MAX_PKGS_BUF) - strlen(" 2>&1");
-
- if (remain < strnlen(addon, MAX_PKGS_BUF)) {
- LOGERR("Cannot copy package name. Insufficient buf size");
- return false;
- }
-
- strncat(pkg_list, pkg, remain - 1); // terminating null byte
-
- pkg = strtok(NULL, token);
- }
-
- strcat(pkg_list, " ");
- strcat(pkg_list, "2>&1");
-
- LOGINFO("[cmd] %s", pkg_list);
- if ((action == 1 || action == 2) && do_rpm_execute(pkg_list)) {
- return true;
- }
-
- return false;
-}
-
-static void* package_thread(void* args)
-{
- LOGINFO("install package_thread starts.");
- int action = 0;
- ijcommand* ijcmd = (ijcommand*)args;
- char* data = strdup(ijcmd->data);
- if (data == NULL) {
- LOGERR("install data is failed to copied.");
- return NULL;
- }
-
- if (ijcmd->msg.action == 1) { // validate packages
- if (do_package(1, data)) {
- action = 1; // already installed
- } else {
- action = 2; // need to install
- }
- } else if (ijcmd->msg.action == 2) { // install packages
- if (do_package(2, data)) {
- action = 3; // install success
- } else {
- action = 4; // failed to install
- }
- remove_package(ijcmd->data);
- } else {
- LOGERR("invalid command (action:%d)", ijcmd->msg.action);
- }
-
- LOGINFO("send %d, with %s", action, ijcmd->data);
- send_to_ecs(IJTYPE_PACKAGE, 0, action, ijcmd->data);
-
- free(data);
-
- return NULL;
-}
-
-void msgproc_package(ijcommand* ijcmd)
-{
- _auto_mutex _(&mutex_pkg);
- int ret = 0;
- void* retval = NULL;
- pthread_t pkg_thread_id;
-
- if (!ijcmd->data) {
- LOGERR("package data is empty.");
- return;
- }
-
- LOGINFO("received %d, with %s", ijcmd->msg.action, ijcmd->data);
-
- if (pthread_create(&pkg_thread_id, NULL, package_thread, (void*)ijcmd) != 0)
- {
- LOGERR("validate package pthread creation is failed!");
- }
- ret = pthread_join(pkg_thread_id, &retval);
- if (ret < 0) {
- LOGERR("validate package pthread join is failed.");
- }
-}
-
-// Location
-#define LOCATION_STATUS 120
-char command[512];
-
-void* exec_cmd_thread(void *args)
-{
- char *command = (char*)args;
-
- systemcall(command);
- LOGDEBUG("executed cmd: %s", command);
- free(command);
-
- pthread_exit(NULL);
-}
-
-void msgproc_cmd(ijcommand* ijcmd)
-{
- _auto_mutex _(&mutex_cmd);
- pthread_t cmd_thread_id;
- char *cmd = (char*) malloc(ijcmd->msg.length + 1);
-
- if (!cmd) {
- LOGERR("malloc failed.");
- return;
- }
-
- memset(cmd, 0x00, ijcmd->msg.length + 1);
- strncpy(cmd, ijcmd->data, ijcmd->msg.length);
- LOGDEBUG("cmd: %s, length: %d", cmd, ijcmd->msg.length);
-
- if (pthread_create(&cmd_thread_id, NULL, exec_cmd_thread, (void*)cmd) != 0) {
- LOGERR("cmd pthread create fail!");
- }
-}
-
int get_vconf_status(char** value, vconf_t type, const char* key)
{
if (type == VCONF_TYPE_INT) {
return strlen(*value);
}
-static void* get_vconf_value(void* data)
-{
- pthread_detach(pthread_self());
-
- char *value = NULL;
- vconf_res_type *vrt = (vconf_res_type*)data;
-
- if (!check_possible_vconf_key(vrt->vconf_key)) {
- LOGERR("%s is not available key.");
- } else {
- int length = get_vconf_status(&value, vrt->vconf_type, vrt->vconf_key);
- if (length == 0 || !value) {
- LOGERR("send error message to injector");
- send_to_ecs(IJTYPE_VCONF, vrt->group, STATUS, NULL);
- } else {
- LOGDEBUG("send data to injector");
- send_to_ecs(IJTYPE_VCONF, vrt->group, STATUS, value);
- free(value);
- }
- }
-
- free(vrt->vconf_key);
- free(vrt);
-
- pthread_exit((void *) 0);
-}
-
-static void* set_vconf_value(void* data)
-{
- pthread_detach(pthread_self());
-
- vconf_res_type *vrt = (vconf_res_type*)data;
-
- if (!check_possible_vconf_key(vrt->vconf_key)) {
- LOGERR("%s is not available key.");
- } else {
- keylist_t *get_keylist;
- keynode_t *pkey_node = NULL;
- get_keylist = vconf_keylist_new();
- if (!get_keylist) {
- LOGERR("vconf_keylist_new() failed");
- } else {
- vconf_get(get_keylist, vrt->vconf_key, VCONF_GET_ALL);
- int ret = vconf_keylist_lookup(get_keylist, vrt->vconf_key, &pkey_node);
- if (ret == 0) {
- LOGERR("%s key not found", vrt->vconf_key);
- } else {
- if (vconf_keynode_get_type(pkey_node) != vrt->vconf_type) {
- LOGERR("inconsistent type (prev: %d, new: %d)",
- vconf_keynode_get_type(pkey_node), vrt->vconf_type);
- }
- }
- vconf_keylist_free(get_keylist);
- }
-
- /* TODO: to be implemented another type */
- if (vrt->vconf_type == VCONF_TYPE_INT) {
- int val = atoi(vrt->vconf_val);
- vconf_set_int(vrt->vconf_key, val);
- LOGDEBUG("key: %s, val: %d", vrt->vconf_key, val);
- } else if (vrt->vconf_type == VCONF_TYPE_DOUBLE) {
- LOGERR("not implemented");
- } else if (vrt->vconf_type == VCONF_TYPE_STRING) {
- LOGERR("not implemented");
- } else if (vrt->vconf_type == VCONF_TYPE_BOOL) {
- LOGERR("not implemented");
- } else if (vrt->vconf_type == VCONF_TYPE_DIR) {
- LOGERR("not implemented");
- } else {
- LOGERR("undefined vconf type");
- }
- }
-
- free(vrt->vconf_key);
- free(vrt->vconf_val);
- free(vrt);
-
- pthread_exit((void *) 0);
-}
-
-void msgproc_vconf(ijcommand* ijcmd)
-{
- LOGDEBUG("msgproc_vconf");
-
- const int tmpsize = ijcmd->msg.length;
- char token[] = "\n";
- char tmpdata[tmpsize];
- memcpy(tmpdata, ijcmd->data, tmpsize);
-
- char* ret = NULL;
- ret = strtok(tmpdata, token);
- if (!ret) {
- LOGERR("vconf type is empty");
- return;
- }
-
- vconf_res_type *vrt = (vconf_res_type*)malloc(sizeof(vconf_res_type));
- if (!vrt) {
- LOGERR("insufficient memory available");
- return;
- }
-
- if (strcmp(ret, "int") == 0) {
- vrt->vconf_type = VCONF_TYPE_INT;
- } else if (strcmp(ret, "double") == 0) {
- vrt->vconf_type = VCONF_TYPE_DOUBLE;
- } else if (strcmp(ret, "string") == 0) {
- vrt->vconf_type = VCONF_TYPE_STRING;
- } else if (strcmp(ret, "bool") == 0) {
- vrt->vconf_type = VCONF_TYPE_BOOL;
- } else if (strcmp(ret, "dir") ==0) {
- vrt->vconf_type = VCONF_TYPE_DIR;
- } else {
- LOGERR("undefined vconf type");
- free(vrt);
- return;
- }
-
- ret = strtok(NULL, token);
- if (!ret) {
- LOGERR("vconf key is empty");
- free(vrt);
- return;
- }
-
- vrt->vconf_key = (char*)malloc(strlen(ret) + 1);
- if (!vrt->vconf_key) {
- LOGERR("insufficient memory available");
- free(vrt);
- return;
- }
- sprintf(vrt->vconf_key, "%s", ret);
-
- if (ijcmd->msg.action == VCONF_SET) {
- ret = strtok(NULL, token);
- if (!ret) {
- LOGERR("vconf value is empty");
- free(vrt->vconf_key);
- free(vrt);
- return;
- }
-
- vrt->vconf_val = (char*)malloc(strlen(ret) + 1);
- if (!vrt->vconf_val) {
- LOGERR("insufficient memory available");
- free(vrt->vconf_key);
- free(vrt);
- return;
- }
- sprintf(vrt->vconf_val, "%s", ret);
-
- if (pthread_create(&tid[TID_VCONF], NULL, set_vconf_value, (void*)vrt) != 0) {
- LOGERR("set vconf pthread create fail!");
- return;
- }
- } else if (ijcmd->msg.action == VCONF_GET) {
- vrt->group = ijcmd->msg.group;
- if (pthread_create(&tid[TID_VCONF], NULL, get_vconf_value, (void*)vrt) != 0) {
- LOGERR("get vconf pthread create fail!");
- return;
- }
- } else {
- LOGERR("undefined action %d", ijcmd->msg.action);
- }
-}
-
-/*
- * Location function
- */
-static char* get_location_status(void* p)
-{
- int mode;
- int ret = vconf_get_int(VCONF_REPLAYMODE, &mode);
- if (ret != 0) {
- return 0;
- }
-
- char* message = 0;
-
- if (mode == 0)
- { // STOP
- message = (char*)malloc(5);
- memset(message, 0, 5);
-
- ret = sprintf(message, "%d", mode);
- if (ret < 0) {
- free(message);
- message = 0;
- return 0;
- }
- }
- else if (mode == 1)
- { // NMEA MODE(LOG MODE)
- char* temp = 0;
- temp = (char*) vconf_get_str(VCONF_FILENAME);
- if (temp == 0) {
- //free(temp);
- return 0;
- }
-
- message = (char*)malloc(256);
- memset(message, 0, 256);
- ret = sprintf(message, "%d,%s", mode, temp);
- if (ret < 0) {
- free(message);
- message = 0;
- return 0;
- }
- } else if (mode == 2) { // MANUAL MODE
- double latitude;
- double logitude;
- double altitude;
- double accuracy;
- ret = vconf_get_dbl(VCONF_MLATITUDE, &latitude);
- if (ret != 0) {
- return 0;
- }
- ret = vconf_get_dbl(VCONF_MLONGITUDE, &logitude);
- if (ret != 0) {
- return 0;
- }
- ret = vconf_get_dbl(VCONF_MALTITUDE, &altitude);
- if (ret != 0) {
- return 0;
- }
- ret = vconf_get_dbl(VCONF_MHACCURACY, &accuracy);
- if (ret != 0) {
- return 0;
- }
-
- message = (char*)malloc(128);
- memset(message, 0, 128);
- ret = sprintf(message, "%d,%f,%f,%f,%f", mode, latitude, logitude, altitude, accuracy);
- if (ret < 0) {
- free(message);
- message = 0;
- return 0;
- }
- }
-
- if (message) {
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = strlen(message);
- packet->group = STATUS;
- packet->action = LOCATION_STATUS;
- return message;
- } else {
- return NULL;
- }
-}
-
-static void* getting_location(void* data)
-{
- pthread_detach(pthread_self());
-
- setting_device_param* param = (setting_device_param*) data;
-
- if (!param)
- return 0;
-
- char* msg = 0;
- LXT_MESSAGE* packet = (LXT_MESSAGE*)malloc(sizeof(LXT_MESSAGE));
- if (!packet)
- {
- LOGERR("Failed to allocate packet");
- return NULL;
- }
-
- switch(param->ActionID)
- {
- case LOCATION_STATUS:
- msg = get_location_status((void*)packet);
- if (msg == 0) {
- LOGERR("failed getting location status");
- }
- break;
- default:
- LOGERR("Wrong action ID. %d", param->ActionID);
- break;
- }
-
- if (msg == 0)
- {
- LOGDEBUG("send error message to injector");
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = 0;
- packet->group = STATUS;
- packet->action = param->ActionID;
- }
- else
- {
- LOGDEBUG("send data to injector");
- }
-
- const int tmplen = HEADER_SIZE + packet->length;
- char* tmp = (char*) malloc(tmplen);
- if (tmp)
- {
- memcpy(tmp, packet, HEADER_SIZE);
- if (packet->length > 0)
- memcpy(tmp + HEADER_SIZE, msg, packet->length);
-
- ijmsg_send_to_evdi(g_fd[fdtype_device], param->type_cmd, (const char*) tmp, tmplen);
-
- free(tmp);
- }
-
- if(msg != 0)
- {
- free(msg);
- msg = 0;
- }
-
- free(packet);
-
- if (param)
- delete param;
-
- pthread_exit((void *) 0);
-}
-
-void setting_location(char* databuf)
-{
- char* s = strchr(databuf, ',');
- int err = 0;
- if (s == NULL) { // SET MODE
- int mode = atoi(databuf);
-
- // 0: STOP MODE, 1: NMEA_MODE (LOG MODE), 2: MANUAL MODE
- if (mode < 0 || mode > 2) {
- LOGERR("error(%s) : stop replay mode", databuf);
- mode = 0;
- }
-
- err = vconf_set_int(VCONF_REPLAYMODE, mode);
- LOGFAIL(err, "Set ReplayMode failed. mode = %d", mode);
- } else {
- *s = '\0';
- int mode = atoi(databuf);
- if(mode == 1) { // NMEA MODE (LOG MODE)
- err = vconf_set_str(VCONF_FILENAME, s+1);
- LOGFAIL(err, "Set FileName failed. name = %s", s+1);
- err = vconf_set_int(VCONF_REPLAYMODE, mode);
- LOGFAIL(err, "Set ReplayMode failed. mode = %d", mode);
- } else if(mode == 2) {
- char* ptr = strtok(s+1, ",");
- double value = 0.0;
-
- // Latitude
- value = atof(ptr);
- err = vconf_set_dbl(VCONF_MLATITUDE, value);
- LOGFAIL(err, "Set ManualLatitude failed. value = %f", value);
-
- // Longitude
- ptr = strtok(NULL, ",");
- value = atof(ptr);
- err = vconf_set_dbl(VCONF_MLONGITUDE, value);
- LOGFAIL(err, "Set ManualLongitude failed. value = %f", value);
-
- // Altitude
- ptr = strtok(NULL, ",");
- value = atof(ptr);
- err = vconf_set_dbl(VCONF_MALTITUDE, value);
- LOGFAIL(err, "Set ManualAltitude failed. value = %f", value);
-
- // Accuracy
- ptr = strtok(NULL, ",");
- value = atof(ptr);
- err = vconf_set_dbl(VCONF_MHACCURACY, value);
- LOGFAIL(err, "Set ManualHAccuracy failed. value = %f", value);
- }
- }
-}
-
-void msgproc_location(ijcommand* ijcmd)
-{
- LOGDEBUG("msgproc_location");
- if (ijcmd->msg.group == STATUS)
- {
- setting_device_param* param = new setting_device_param();
- if (!param)
- return;
-
- param->ActionID = ijcmd->msg.action;
- memcpy(param->type_cmd, ijcmd->cmd, ID_SIZE);
-
- if (pthread_create(&tid[TID_LOCATION], NULL, getting_location, (void*) param) != 0)
- {
- LOGERR("location pthread create fail!");
- return;
- }
- }
- else
- {
- setting_location(ijcmd->data);
- }
-}
-
int try_mount(char* tag, char* path)
{
int ret = 0;
void hds_unmount_all(void)
{
- char tmp[MAX_DATA_BUF];
+ char tmp[CMD_BUF];
snprintf(tmp, sizeof(tmp), "%s", "umount -a -t 9p");
systemcall(tmp);
}
-static bool get_tag_path(char* data, char** tag, char** path)
-{
- char token[] = "\n";
-
- LOGINFO("get_tag_path data : %s", data);
- *tag = strtok(data, token);
- if (*tag == NULL) {
- LOGERR("data does not have a correct tag: %s", data);
- return false;
- }
-
- *path = strtok(NULL, token);
- if (*path == NULL) {
- LOGERR("data does not have a correct path: %s", data);
- return false;
- }
-
- return true;
-}
-
-static bool secure_hds_path(char* path) {
- int index = 0;
- int len = sizeof(hds_available_path) / sizeof(char*);
- for (index = 0; index < len; index++) {
- if (hds_available_path[index] &&
- !strncmp(path, hds_available_path[index], strlen(hds_available_path[index]))) {
- return true;
- }
- }
- return false;
-}
-
bool valid_hds_path(char* path) {
struct stat buf;
int ret = -1;
return true;
}
-static void* mount_hds(void* args)
-{
- int i, ret = 0;
- int action = 2;
- char* tag;
- char* path;
- char* data = (char*)args;
-
- LOGINFO("start hds mount thread");
-
- pthread_detach(pthread_self());
-
- if (!get_tag_path(data, &tag, &path)) {
- free(data);
- return NULL;
- }
-
- if (!strncmp(tag, HDS_DEFAULT_ID, 6)) {
- free(data);
- return NULL;
- }
-
- if (!secure_hds_path(path)) {
- send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, 11, tag);
- free(data);
- return NULL;
- }
-
- if (!valid_hds_path(path)) {
- send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, 12, tag);
- free(data);
- return NULL;
- }
-
- LOGINFO("tag : %s, path: %s", tag, path);
-
- for (i = 0; i < 10; i++)
- {
- ret = try_mount(tag, path);
- if(ret == 0) {
- action = 1;
- break;
- } else {
- LOGERR("%d trial: mount is failed with errno: %d", i, errno);
- }
- usleep(500000);
- }
-
- send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, action, tag);
-
- free(data);
-
- return NULL;
-}
-
-static void* umount_hds(void* args)
-{
- int ret = 0;
- int action = 3;
- char* tag;
- char* path;
- char* data = (char*)args;
-
- LOGINFO("unmount hds.");
- pthread_detach(pthread_self());
-
- if (!get_tag_path(data, &tag, &path)) {
- LOGERR("wrong tag or path.");
- free(data);
- return NULL;
- }
-
- ret = umount(path);
- if (ret != 0) {
- LOGERR("unmount failed with error num: %d", errno);
- action = 4;
- }
-
- ret = rmdir(path);
- LOGINFO("remove path result '%d:%d' with %s", ret, errno, path);
-
- send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, action, tag);
-
- LOGINFO("send result with action %d to evdi", action);
-
- free(data);
-
- return NULL;
-}
-
-void msgproc_hds(ijcommand* ijcmd)
-{
- char* data;
- char* tag;
- char* path;
- LOGDEBUG("msgproc_hds");
-
- if (!strncmp(ijcmd->data, HDS_DEFAULT_PATH, 9)) {
- LOGINFO("hds compatibility mode with %s", ijcmd->data);
- data = strdup(COMPAT_DEFAULT_DATA);
- } else {
- data = strdup(ijcmd->data);
- }
-
- if (data == NULL) {
- LOGERR("data dup is failed. out of memory.");
- return;
- }
-
- LOGINFO("action: %d, data: %s", ijcmd->msg.action, data);
- if (ijcmd->msg.action == 1) {
- if (pthread_create(&tid[TID_HDS_ATTACH], NULL, mount_hds, (void*)data) != 0) {
- if (!get_tag_path(data, &tag, &path)) {
- LOGERR("mount pthread_create fail - wrong tag or path.");
- free(data);
- return;
- }
- LOGERR("mount hds pthread create fail!");
- send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, 2, tag);
- }
- } else if (ijcmd->msg.action == 2) {
- if (pthread_create(&tid[TID_HDS_DETACH], NULL, umount_hds, (void*)data) != 0) {
- if (!get_tag_path(data, &tag, &path)) {
- LOGERR("umount pthread_create fail - wrong tag or path.");
- free(data);
- return;
- }
- LOGERR("umount hds pthread create fail!");
- send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, 4, tag);
- }
- } else {
- LOGERR("unknown action cmd.");
- }
- free(data);
-}
-
void send_default_mount_req()
{
send_to_ecs(IJTYPE_HDS, 0, 0, NULL);
LOGINFO("dbus_send: %s", cmd);
}
+void add_msg_proc_common(void)
+{
+ bool ret;
+#ifdef ENABLE_SUSPEND
+ ret = msgproc_add(DEFAULT_MSGPROC, IJTYPE_SUSPEND, &msgproc_suspend, MSGPROC_PRIO_MIDDLE);
+ LOGFAIL(!ret, "Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_SUSPEND);
+#endif
+#ifdef ENABLE_HDS
+ ret = msgproc_add(DEFAULT_MSGPROC, IJTYPE_HDS, &msgproc_hds, MSGPROC_PRIO_MIDDLE);
+ LOGFAIL(!ret, "Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_HDS);
+#endif
+#ifdef ENABLE_SYSTEM
+ ret = msgproc_add(DEFAULT_MSGPROC, IJTYPE_SYSTEM, &msgproc_system, MSGPROC_PRIO_MIDDLE);
+ LOGFAIL(!ret, "Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_SYSTEM);
+#endif
+#ifdef ENABLE_PACKAGE
+ ret = msgproc_add(DEFAULT_MSGPROC, IJTYPE_PACKAGE, &msgproc_package, MSGPROC_PRIO_MIDDLE);
+ LOGFAIL(!ret, "Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_PACKAGE);
+#endif
+#ifdef ENABLE_CMD
+ ret = msgproc_add(DEFAULT_MSGPROC, IJTYPE_CMD, &msgproc_cmd, MSGPROC_PRIO_MIDDLE);
+ LOGFAIL(!ret, "Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_CMD);
+#endif
+#ifdef ENABLE_VCONF
+ ret = msgproc_add(DEFAULT_MSGPROC, IJTYPE_VCONF, &msgproc_vconf, MSGPROC_PRIO_MIDDLE);
+ LOGFAIL(!ret, "Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_VCONF);
+#endif
+#ifdef ENABLE_LOCATION
+ ret = msgproc_add(DEFAULT_MSGPROC, IJTYPE_LOCATION, &msgproc_location, MSGPROC_PRIO_MIDDLE);
+ LOGFAIL(!ret, "Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_LOCATION);
+#endif
+}
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* DaiYoung Kim <daiyoung777.kim@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
*
*/
-#include <errno.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <unistd.h>
-
-#include "emuld.h"
-#include "synbuf.h"
-
+#include <fcntl.h>
+#include <dirent.h>
+#include <dlfcn.h>
#include <E_DBus.h>
#include <Ecore.h>
-#include <queue>
-
-/* global definition */
-typedef std::queue<msg_info*> __msg_queue;
-__msg_queue g_msgqueue;
+#include "emuld.h"
-int g_epoll_fd;
-int g_fd[fdtype_max];
pthread_t tid[MAX_CLIENT + 1];
+int g_epoll_fd;
struct epoll_event g_events[MAX_EVENTS];
-bool exit_flag = false;
+void* dl_handles[MAX_PLUGINS];
+int dl_count;
-static void init_fd(void)
+enum ioctl_cmd {
+ IOCTL_CMD_BOOT_DONE,
+};
+
+static void emuld_exit(void)
{
- register int i;
+ while (dl_count > 0)
+ dlclose(dl_handles[--dl_count]);
- for(i = 0 ; i < fdtype_max ; i++)
- {
- g_fd[i] = -1;
- }
+ msgproc_del(NULL, NULL, MSGPROC_PRIO_HIGH);
+ msgproc_del(NULL, NULL, MSGPROC_PRIO_MIDDLE);
+ msgproc_del(NULL, NULL, MSGPROC_PRIO_LOW);
}
-bool epoll_ctl_add(const int fd)
+static void init_plugins(void)
{
- struct epoll_event events;
+ DIR *dirp = NULL;
+ struct dirent *dir_ent = NULL;
+ char plugin_path[MAX_PATH] = {0, };
+ void* handle = NULL;
+ bool (*plugin_init)() = NULL;
+ char* error = NULL;
- events.events = EPOLLIN; // check In event
- events.data.fd = fd;
+ dirp = opendir(EMULD_PLUGIN_DIR);
- if (epoll_ctl(g_epoll_fd, EPOLL_CTL_ADD, fd, &events) < 0 )
+ if (!dirp)
{
- LOGERR("Epoll control fails.");
- return false;
+ LOGWARN("Dir(%s) open failed. errno = %d\n", EMULD_PLUGIN_DIR, errno);
+ return;
}
- LOGINFO("[START] epoll events add fd success for server");
- return true;
-}
-
-static bool epoll_init(void)
-{
- g_epoll_fd = epoll_create(MAX_EVENTS); // create event pool
- if(g_epoll_fd < 0)
+ while ((dir_ent = readdir(dirp)))
{
- LOGERR("Epoll create Fails.");
- return false;
- }
+ sprintf(plugin_path, "%s/%s", EMULD_PLUGIN_DIR, dir_ent->d_name);
- LOGINFO("[START] epoll creation success");
- return true;
-}
+ LOGDEBUG("Try to load plugin (%s)", plugin_path);
-int recv_data(int event_fd, char** r_databuf, int size)
-{
- int recvd_size = 0;
- int len = 0;
- int getcnt = 0;
- char* r_tmpbuf = NULL;
- const int alloc_size = sizeof(char) * size + 1;
-
- r_tmpbuf = (char*)malloc(alloc_size);
- if(r_tmpbuf == NULL)
- {
- return -1;
- }
-
- char* databuf = (char*)malloc(alloc_size);
- if(databuf == NULL)
- {
- free(r_tmpbuf);
- *r_databuf = NULL;
- return -1;
- }
+ if (dl_count >= MAX_PLUGINS)
+ {
+ LOGWARN("Cannot load more plugins. (%s)", plugin_path);
+ continue;
+ }
- memset(databuf, '\0', alloc_size);
+ handle = dlopen(plugin_path, RTLD_NOW);
+ if (!handle)
+ {
+ LOGWARN("File open failed : %s\n", dlerror());
+ continue;
+ }
- while(recvd_size < size)
- {
- memset(r_tmpbuf, '\0', alloc_size);
- len = recv(event_fd, r_tmpbuf, size - recvd_size, 0);
- if (len < 0) {
- break;
+ plugin_init = (bool(*)())dlsym(handle, EMULD_PLUGIN_INIT_FN);
+ if ((error = dlerror()) != NULL)
+ {
+ LOGWARN("Could not found symbol : %s\n", error);
+ dlclose(handle);
+ continue;
}
- memcpy(databuf + recvd_size, r_tmpbuf, len);
- recvd_size += len;
- getcnt++;
- if(getcnt > MAX_GETCNT) {
- break;
+ if (!plugin_init()) {
+ LOGWARN("emuld_plugin_init failed (%s)", plugin_path);
+ dlclose(handle);
+ continue;
}
+
+ dl_handles[dl_count++] = handle;
}
- free(r_tmpbuf);
- r_tmpbuf = NULL;
- *r_databuf = databuf;
+ closedir(dirp);
+}
- return recvd_size;
+static void sig_handler(int signo)
+{
+ LOGINFO("received signal: %d. EXIT!", signo);
+
+ hds_unmount_all();
+
+ _exit(0);
}
-static int read_header(int fd, LXT_MESSAGE* packet)
+static void add_sig_handler(int signo)
{
- char* readbuf = NULL;
- int readed = recv_data(fd, &readbuf, HEADER_SIZE);
- if (readed <= 0){
- if (readbuf)
- free(readbuf);
- return 0;
- }
- memcpy((void*) packet, (void*) readbuf, HEADER_SIZE);
+ sighandler_t sig;
- if (readbuf)
- {
- free(readbuf);
- readbuf = NULL;
+ sig = signal(signo, sig_handler);
+ if (sig == SIG_ERR) {
+ LOGERR("adding %d signal failed : %d", signo, errno);
}
- return readed;
}
-static void process_evdi_command(ijcommand* ijcmd)
+static void send_to_kernel(void)
{
- if (strcmp(ijcmd->cmd, IJTYPE_SUSPEND) == 0)
- {
- msgproc_suspend(ijcmd);
- }
- else if (strcmp(ijcmd->cmd, IJTYPE_HDS) == 0)
- {
- msgproc_hds(ijcmd);
- }
- else if (strcmp(ijcmd->cmd, IJTYPE_SYSTEM) == 0)
- {
- msgproc_system(ijcmd);
- }
- else if (strcmp(ijcmd->cmd, IJTYPE_PACKAGE) == 0)
- {
- msgproc_package(ijcmd);
- }
- else if (strcmp(ijcmd->cmd, IJTYPE_CMD) == 0)
- {
- msgproc_cmd(ijcmd);
- }
- else if (strcmp(ijcmd->cmd, IJTYPE_VCONF) == 0)
- {
- msgproc_vconf(ijcmd);
+ if(ioctl(g_fd[fdtype_device], IOCTL_CMD_BOOT_DONE, NULL) == -1) {
+ LOGWARN("Failed to send ioctl to kernel");
+ return;
}
- else
- {
- if (!extra_evdi_command(ijcmd)) {
- LOGERR("Unknown packet: %s", ijcmd->cmd);
- }
+ LOGINFO("[DBUS] sent booting done to kernel");
+}
+
+static void boot_done(void *data, DBusMessage *msg)
+{
+ if (dbus_message_is_signal(msg,
+ DBUS_IFACE_BOOT_DONE,
+ BOOT_DONE_SIGNAL) != 0) {
+ LOGINFO("[DBUS] sending booting done to ecs.");
+ send_to_ecs(IJTYPE_BOOT, 0, 0, NULL);
+ LOGINFO("[DBUS] sending booting done to kernel for log.");
+ send_to_kernel();
}
}
-bool read_ijcmd(const int fd, ijcommand* ijcmd)
+static bool epoll_init(void)
{
- int readed;
- readed = read_header(fd, &ijcmd->msg);
+ g_epoll_fd = epoll_create(MAX_EVENTS); // create event pool
+ if(g_epoll_fd < 0)
+ {
+ LOGERR("Epoll create Fails.");
+ return false;
+ }
- LOGDEBUG("action: %d", ijcmd->msg.action);
- LOGDEBUG("length: %d", ijcmd->msg.length);
+ LOGINFO("[START] epoll creation success");
+ return true;
+}
- if (readed <= 0)
- return false;
+static void init_fd(void)
+{
+ register int i;
- // TODO : this code should removed, for telephony
- if (ijcmd->msg.length == 0)
+ for(i = 0 ; i < fdtype_max ; i++)
{
- if (ijcmd->msg.action == 71) // that's strange packet from telephony initialize
- {
- ijcmd->msg.length = 4;
- }
+ g_fd[i] = -1;
}
+}
- if (ijcmd->msg.length <= 0)
- return true;
+static void process_evdi_command(ijcommand* ijcmd)
+{
+ int prio = 0;
+ LOGDEBUG("process_evdi_command : cmd = %s\n", ijcmd->cmd);
- if (ijcmd->msg.length > 0)
+ for (prio = MSGPROC_PRIO_HIGH; prio != MSGPROC_PRIO_END; prio++)
{
- readed = recv_data(fd, &ijcmd->data, ijcmd->msg.length);
- if (readed <= 0)
+ LOGDEBUG("process_evdi_command : msgproc_head[%d].next = %p", prio, msgproc_head[prio].next);
+ emuld_msgproc *pMsgProc = msgproc_head[prio].next;
+ while (pMsgProc)
{
- free(ijcmd->data);
- ijcmd->data = NULL;
- return false;
+ LOGDEBUG("pMsgProc->name = %s, pMsgProc->cmd = %s, func = %p", pMsgProc->name, pMsgProc->cmd, pMsgProc->func);
+ if (strcmp(pMsgProc->cmd, ijcmd->cmd))
+ {
+ pMsgProc = pMsgProc->next;
+ continue;
+ }
+ if (!pMsgProc->func(ijcmd))
+ {
+ LOGINFO("Stopped more message handling by ( Plugin : %s, Command : %s )", pMsgProc->name, pMsgProc->cmd);
+ return;
+ }
+ pMsgProc = pMsgProc->next;
}
-
}
- return true;
}
-void recv_from_evdi(evdi_fd fd)
+static void recv_from_evdi(evdi_fd fd)
{
LOGDEBUG("recv_from_evdi");
int readed;
if (readed < ijcmd.msg.length)
{
- LOGERR("received data is insufficient");
+ LOGWARN("received data is insufficient");
}
}
process_evdi_command(&ijcmd);
}
-void writelog(const char* fmt, ...)
-{
- FILE* logfile = fopen("/tmp/emuld.log", "a+");
- va_list args;
- va_start(args, fmt);
- vfprintf(logfile, fmt, args);
- fprintf(logfile, "\n");
- va_end(args);
- fclose(logfile);
-}
-
static bool server_process(void)
{
int i,nfds;
}
else
{
- LOGERR("unknown request event fd : (%d)", fd_tmp);
+ LOGWARN("unknown request event fd : (%d)", fd_tmp);
}
}
return false;
}
-enum ioctl_cmd {
- IOCTL_CMD_BOOT_DONE,
-};
-
-void send_to_kernel(void)
+static bool epoll_ctl_add(const int fd)
{
- if(ioctl(g_fd[fdtype_device], IOCTL_CMD_BOOT_DONE, NULL) == -1) {
- LOGERR("Failed to send ioctl to kernel");
- return;
+ struct epoll_event events;
+
+ events.events = EPOLLIN; // check In event
+ events.data.fd = fd;
+
+ if (epoll_ctl(g_epoll_fd, EPOLL_CTL_ADD, fd, &events) < 0 )
+ {
+ LOGERR("Epoll control fails.");
+ return false;
}
- LOGINFO("[DBUS] sent booting done to kernel");
+
+ LOGINFO("[START] epoll events add fd success for server");
+ return true;
}
-#define DBUS_PATH_BOOT_DONE "/Org/Tizen/System/DeviceD/Core"
-#define DBUS_IFACE_BOOT_DONE "org.tizen.system.deviced.core"
-#define BOOT_DONE_SIGNAL "BootingDone"
+static evdi_fd open_device(void)
+{
+ evdi_fd fd;
-static void boot_done(void *data, DBusMessage *msg)
+ fd = open(DEVICE_NODE_PATH, O_RDWR); //O_CREAT|O_WRONLY|O_TRUNC.
+ LOGDEBUG("evdi open fd is %d", fd);
+
+ if (fd < 0) {
+ LOGERR("open %s fail", DEVICE_NODE_PATH);
+ }
+
+ return fd;
+}
+
+static bool set_nonblocking(evdi_fd fd)
{
- if (dbus_message_is_signal(msg,
- DBUS_IFACE_BOOT_DONE,
- BOOT_DONE_SIGNAL) != 0) {
- LOGINFO("[DBUS] sending booting done to ecs.");
- send_to_ecs(IJTYPE_BOOT, 0, 0, NULL);
- LOGINFO("[DBUS] sending booting done to kernel for log.");
- send_to_kernel();
+ int opts;
+ opts= fcntl(fd, F_GETFL);
+ if (opts < 0)
+ {
+ LOGERR("F_GETFL fcntl failed");
+ return false;
+ }
+ opts = opts | O_NONBLOCK;
+ if (fcntl(fd, F_SETFL, opts) < 0)
+ {
+ LOGERR("NONBLOCK fcntl failed");
+ return false;
}
+ return true;
}
-static void sig_handler(int signo)
+static bool init_device(evdi_fd* ret_fd)
{
- LOGINFO("received signal: %d. EXIT!", signo);
+ evdi_fd fd;
- hds_unmount_all();
+ *ret_fd = -1;
- _exit(0);
-}
+ fd = open_device();
+ if (fd < 0)
+ return false;
-static void add_sig_handler(int signo)
-{
- sighandler_t sig;
+ if (!set_nonblocking(fd))
+ {
+ close(fd);
+ return false;
+ }
- sig = signal(signo, sig_handler);
- if (sig == SIG_ERR) {
- LOGERR("adding %d signal failed : %d", signo, errno);
+ if (!epoll_ctl_add(fd))
+ {
+ LOGERR("Epoll control fails.");
+ close(fd);
+ return false;
}
+
+ *ret_fd = fd;
+
+ return true;
}
-void* handling_network(void* data)
+static void* handling_network(void* data)
{
int ret = -1;
+ bool exit_flag = false;
init_fd();
}
add_vconf_map_common();
+#ifndef UNKNOWN_PROFILE
add_vconf_map_profile();
+#endif
+
set_vconf_cb();
send_emuld_connection();
exit_flag = server_process();
}
- stop_listen();
-
hds_unmount_all();
exit(0);
add_sig_handler(SIGINT);
add_sig_handler(SIGTERM);
+ add_msg_proc_common();
+#ifndef UNKNOWN_PROFILE
+ add_msg_proc_ext();
+#endif
+
+ init_plugins();
+
if (pthread_create(&conn_thread_t, NULL, register_connection, NULL) < 0) {
LOGERR("network connection pthread create fail!");
return -1;
LOGERR("network connection pthread join is failed.");
}
+ emuld_exit();
+
return 0;
}
-
+++ /dev/null
-/*
- * emulator-daemon
- *
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
- * SooYoung Ha <yoosah.ha@samsnung.com>
- * Sungmin Ha <sungmin82.ha@samsung.com>
- * Daiyoung Kim <daiyoung777.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "emuld.h"
-
-#define DEVICE_NODE_PATH "/dev/evdi0"
-
-static pthread_mutex_t mutex_evdi = PTHREAD_MUTEX_INITIALIZER;
-
-evdi_fd open_device(void)
-{
- evdi_fd fd;
-
- fd = open(DEVICE_NODE_PATH, O_RDWR); //O_CREAT|O_WRONLY|O_TRUNC.
- LOGDEBUG("evdi open fd is %d", fd);
-
- if (fd < 0) {
- LOGERR("open %s fail", DEVICE_NODE_PATH);
- }
-
- return fd;
-}
-
-bool set_nonblocking(evdi_fd fd)
-{
- int opts;
- opts= fcntl(fd, F_GETFL);
- if (opts < 0)
- {
- LOGERR("F_GETFL fcntl failed");
- return false;
- }
- opts = opts | O_NONBLOCK;
- if (fcntl(fd, F_SETFL, opts) < 0)
- {
- LOGERR("NONBLOCK fcntl failed");
- return false;
- }
- return true;
-}
-
-bool init_device(evdi_fd* ret_fd)
-{
- evdi_fd fd;
-
- *ret_fd = -1;
-
- fd = open_device();
- if (fd < 0)
- return false;
-
- if (!set_nonblocking(fd))
- {
- close(fd);
- return false;
- }
-
- if (!epoll_ctl_add(fd))
- {
- LOGERR("Epoll control fails.");
- close(fd);
- return false;
- }
-
- *ret_fd = fd;
-
- return true;
-}
-
-bool send_to_evdi(evdi_fd fd, const char* data, const int len)
-{
- LOGDEBUG("send to evdi client, len = %d", len);
- int ret;
-
- ret = write(fd, data, len);
-
- LOGDEBUG("written bytes = %d", ret);
-
- if (ret == -1)
- return false;
- return true;
-}
-
-bool ijmsg_send_to_evdi(evdi_fd fd, const char* cat, const char* data, const int len)
-{
- _auto_mutex _(&mutex_evdi);
-
- LOGDEBUG("ijmsg_send_to_evdi");
-
- if (fd == -1)
- return false;
-
- char tmp[ID_SIZE];
- memset(tmp, 0, ID_SIZE);
- strncpy(tmp, cat, ID_SIZE - 1);
-
- // TODO: need to make fragmented transmission
- if (len + ID_SIZE > __MAX_BUF_SIZE) {
- LOGERR("evdi message len is too large");
- return false;
- }
-
- msg_info _msg;
- memset(_msg.buf, 0, __MAX_BUF_SIZE);
- memcpy(_msg.buf, tmp, ID_SIZE);
- memcpy(_msg.buf + ID_SIZE, data, len);
-
- _msg.route = route_control_server;
- _msg.use = len + ID_SIZE;
- _msg.count = 1;
- _msg.index = 0;
- _msg.cclisn = 0;
-
- LOGDEBUG("ijmsg_send_to_evdi - %s", _msg.buf);
-
- if (!send_to_evdi(fd, (char*) &_msg, sizeof(_msg)))
- return false;
-
- return true;
-}
-
-bool msg_send_to_evdi(evdi_fd fd, const char* data, const int len)
-{
- _auto_mutex _(&mutex_evdi);
-
- // TODO: need to make fragmented transmission
- if (len > __MAX_BUF_SIZE)
- {
- LOGERR("evdi message len is too large");
- return false;
- }
-
- msg_info _msg;
- memset(_msg.buf, 0, __MAX_BUF_SIZE);
- memcpy(_msg.buf, data, len);
-
- _msg.route = route_control_server;
- _msg.use = len;
- _msg.count = 1;
- _msg.index = 0;
- _msg.cclisn = 0;
-
- LOGDEBUG("msg_send_to_evdi - %s", _msg.buf);
-
- if (!send_to_evdi(fd, (char*)&_msg, sizeof(_msg)))
- return false;
-
- return true;
-}
-
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(libemuld CXX)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "${PREFIX}/bin")
+SET(INCLUDEDIR "${PREFIX}/include/${PROJECT_NAME}")
+SET(LIBDIR "${PREFIX}/lib")
+
+SET(LIBEMULD_SRCS
+ msgproc.cpp
+ libemuld.cpp
+ evdi.cpp
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(libpkgs REQUIRED
+ vconf
+ dlog)
+
+FOREACH(flag ${libpkgs_CFLAGS})
+ SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${LIBEMULD_SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME emuld)
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/libemuld.h
+ ${CMAKE_SOURCE_DIR}/include/emuld_log.h
+ ${CMAKE_SOURCE_DIR}/include/evdi.h
+ ${CMAKE_SOURCE_DIR}/include/ijcmd.h
+ ${CMAKE_SOURCE_DIR}/include/msgproc.h
+ DESTINATION include/${PROJECT_NAME})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include "libemuld.h"
+
+static pthread_mutex_t mutex_evdi = PTHREAD_MUTEX_INITIALIZER;
+
+bool send_to_evdi(evdi_fd fd, const char* data, const int len)
+{
+ LOGDEBUG("send to evdi client, len = %d", len);
+ int ret;
+
+ ret = write(fd, data, len);
+
+ LOGDEBUG("written bytes = %d", ret);
+
+ if (ret == -1)
+ return false;
+ return true;
+}
+
+bool ijmsg_send_to_evdi(evdi_fd fd, const char* cat, const char* data, const int len)
+{
+ _auto_mutex _(&mutex_evdi);
+
+ LOGDEBUG("ijmsg_send_to_evdi");
+
+ if (fd == -1)
+ return false;
+
+ char tmp[ID_SIZE];
+ memset(tmp, 0, ID_SIZE);
+ strncpy(tmp, cat, ID_SIZE - 1);
+
+ // TODO: need to make fragmented transmission
+ if (len + ID_SIZE > __MAX_BUF_SIZE) {
+ LOGERR("evdi message len is too large");
+ return false;
+ }
+
+ msg_info _msg;
+ memset(_msg.buf, 0, __MAX_BUF_SIZE);
+ memcpy(_msg.buf, tmp, ID_SIZE);
+ memcpy(_msg.buf + ID_SIZE, data, len);
+
+ _msg.route = route_control_server;
+ _msg.use = len + ID_SIZE;
+ _msg.count = 1;
+ _msg.index = 0;
+ _msg.cclisn = 0;
+
+ LOGDEBUG("ijmsg_send_to_evdi - %s", _msg.buf);
+
+ if (!send_to_evdi(fd, (char*) &_msg, sizeof(_msg)))
+ return false;
+
+ return true;
+}
+
+bool msg_send_to_evdi(evdi_fd fd, const char* data, const int len)
+{
+ _auto_mutex _(&mutex_evdi);
+
+ // TODO: need to make fragmented transmission
+ if (len > __MAX_BUF_SIZE)
+ {
+ LOGERR("evdi message len is too large");
+ return false;
+ }
+
+ msg_info _msg;
+ memset(_msg.buf, 0, __MAX_BUF_SIZE);
+ memcpy(_msg.buf, data, len);
+
+ _msg.route = route_control_server;
+ _msg.use = len;
+ _msg.count = 1;
+ _msg.index = 0;
+ _msg.cclisn = 0;
+
+ LOGDEBUG("msg_send_to_evdi - %s", _msg.buf);
+
+ if (!send_to_evdi(fd, (char*)&_msg, sizeof(_msg)))
+ return false;
+
+ return true;
+}
+
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * DaiYoung Kim <daiyoung777.kim@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+
+#include "emuld.h"
+
+#include <E_DBus.h>
+#include <Ecore.h>
+#include <map>
+#include <queue>
+#include "libemuld.h"
+
+#define MAX_GETCNT 10
+
+int g_fd[fdtype_max];
+
+// Vconf
+static std::multimap<int, std::string> vconf_multimap;
+
+void add_vconf_map(VCONF_TYPE key, std::string value)
+{
+ vconf_multimap.insert(std::pair<int, std::string>(key, value));
+}
+
+bool check_possible_vconf_key(std::string key)
+{
+ std::multimap<int, std::string>::iterator it;
+ for(it = vconf_multimap.begin(); it != vconf_multimap.end(); it++) {
+ if (it->second.compare(key) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void writelog(const char* fmt, ...)
+{
+ FILE* logfile = fopen("/tmp/emuld.log", "a+");
+ va_list args;
+ va_start(args, fmt);
+ vfprintf(logfile, fmt, args);
+ fprintf(logfile, "\n");
+ va_end(args);
+ fclose(logfile);
+}
+
+void send_to_ecs(const char* cat, int group, int action, char* data)
+{
+ int datalen = 0;
+ int tmplen = HEADER_SIZE;
+ if (data != NULL) {
+ datalen = strlen(data);
+ tmplen += datalen;
+ }
+
+ char* tmp = (char*) malloc(tmplen);
+ if (!tmp)
+ return;
+
+ memcpy(tmp, &datalen, 2);
+ memcpy(tmp + 2, &group, 1);
+ memcpy(tmp + 3, &action, 1);
+ if (data != NULL) {
+ memcpy(tmp + 4, data, datalen);
+ }
+
+ ijmsg_send_to_evdi(g_fd[fdtype_device], cat, (const char*) tmp, tmplen);
+
+ if (tmp)
+ free(tmp);
+}
+
+void systemcall(const char* param)
+{
+ if (!param)
+ return;
+
+ if (system(param) == -1)
+ LOGERR("system call failure(command = %s)", param);
+}
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: libemuld
+Description: Emulator daemon plugin library
+Version: @VERSION@
+Requires: vconf
+Libs: -L${libdir} -lemuld
+Cflags: -I${includedir}
--- /dev/null
+/*
+ * emulator-daemon library
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Hakhyun Kim <haken.kim@samsung.com>
+ * Jinhyung choi <jinh0.choi@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "libemuld.h"
+
+emuld_msgproc msgproc_head[MSGPROC_PRIO_END];
+
+bool msgproc_add(const char* name, const char* cmd, msgproc func, msgproc_prio priority)
+{
+ if (!name || !cmd || !func || priority == MSGPROC_PRIO_END)
+ {
+ LOGWARN("Invalid param : name = %s, cmd = %s, msgproc = %p, priority = %d",
+ name, cmd, func, priority);
+ return false;
+ }
+
+ if ((strnlen(name, NAME_LEN) == NAME_LEN) || (strnlen(cmd, CMD_SIZE) == CMD_SIZE))
+ {
+ LOGWARN("Invalid param : max name length = %d , max cmd length = %d",
+ NAME_LEN-1, CMD_SIZE-1);
+ return false;
+ }
+
+ emuld_msgproc *pPrev = &msgproc_head[priority];
+ emuld_msgproc *pMsgProc = msgproc_head[priority].next;
+ while (pMsgProc != NULL)
+ {
+ pPrev = pMsgProc;
+ pMsgProc = pMsgProc->next;
+ }
+ pMsgProc = (emuld_msgproc*)malloc(sizeof(emuld_msgproc));
+ if (!pMsgProc)
+ {
+ LOGWARN("Failed to allocate memory");
+ return false;
+ }
+ strcpy(pMsgProc->name, name);
+ strcpy(pMsgProc->cmd, cmd);
+ pMsgProc->func = func;
+ pMsgProc->next = NULL;
+ pPrev->next = pMsgProc;
+
+ return true;
+}
+
+static void msgproc_del_by_priority(msgproc_prio priority)
+{
+ emuld_msgproc *pPrev = &msgproc_head[priority];
+ emuld_msgproc *pMsgProc = msgproc_head[priority].next;
+
+ while (pMsgProc)
+ {
+ pPrev->next = pMsgProc->next;
+ free(pMsgProc);
+ pMsgProc = pPrev->next;
+ }
+}
+
+static void msgproc_del_by_cmd(const char* cmd, msgproc_prio priority)
+{
+ emuld_msgproc *pPrev = &msgproc_head[priority];
+ emuld_msgproc *pMsgProc = msgproc_head[priority].next;
+
+ while (pMsgProc)
+ {
+ if (!strcmp(pMsgProc->cmd, cmd)) {
+ pPrev->next = pMsgProc->next;
+ free(pMsgProc);
+ pMsgProc = pPrev->next;
+ } else {
+ pPrev = pMsgProc;
+ pMsgProc = pMsgProc->next;
+ }
+ }
+}
+
+static void msgproc_del_by_name(const char* name, msgproc_prio priority)
+{
+ emuld_msgproc *pPrev = &msgproc_head[priority];
+ emuld_msgproc *pMsgProc = msgproc_head[priority].next;
+
+ while (pMsgProc)
+ {
+ if (!strcmp(pMsgProc->name, name)) {
+ pPrev->next = pMsgProc->next;
+ free(pMsgProc);
+ pMsgProc = pPrev->next;
+ } else {
+ pPrev = pMsgProc;
+ pMsgProc = pMsgProc->next;
+ }
+ }
+}
+
+static void msgproc_del_by_name_and_cmd(const char* name, const char* cmd, msgproc_prio priority)
+{
+ emuld_msgproc *pPrev = &msgproc_head[priority];
+ emuld_msgproc *pMsgProc = msgproc_head[priority].next;
+
+ while (pMsgProc)
+ {
+ if (!strcmp(pMsgProc->name, name) && !strcmp(pMsgProc->cmd, cmd)) {
+ pPrev->next = pMsgProc->next;
+ free(pMsgProc);
+ pMsgProc = pPrev->next;
+ } else {
+ pPrev = pMsgProc;
+ pMsgProc = pMsgProc->next;
+ }
+ }
+}
+
+bool msgproc_del(const char* name, const char* cmd, msgproc_prio priority)
+{
+ if (priority == MSGPROC_PRIO_END)
+ {
+ LOGWARN("Invalid param : priority = %d", priority);
+ return false;
+ }
+
+ if ((name && (strnlen(name, NAME_LEN) == NAME_LEN)) || (cmd && (strnlen(cmd, CMD_SIZE) == CMD_SIZE)))
+ {
+ LOGWARN("Invalid param : max name length = %d , max cmd length = %d",
+ NAME_LEN-1, CMD_SIZE-1);
+ return false;
+ }
+
+ if (!name && !cmd) {
+ msgproc_del_by_priority(priority);
+ } else if (!name) {
+ msgproc_del_by_cmd(cmd, priority);
+ } else if (!cmd) {
+ msgproc_del_by_name(name, priority);
+ } else {
+ msgproc_del_by_name_and_cmd(name, cmd, priority);
+ }
+
+ return true;
+}
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* DaiYoung Kim <daiyoung777.kim@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
*
*/
+#include <stdio.h>
#include <vconf/vconf-keys.h>
#include "emuld.h"
pthread_exit((void *) 0);
}
-void msgproc_sensor(ijcommand* ijcmd)
+bool msgproc_sensor(ijcommand* ijcmd)
{
LOGDEBUG("msgproc_sensor");
{
setting_device_param* param = new setting_device_param();
if (!param)
- return;
+ return true;
memset(param, 0, sizeof(*param));
if (pthread_create(&tid[TID_SENSOR], NULL, getting_sensor, (void*)param) != 0)
{
LOGERR("sensor pthread create fail!");
- return;
+ return true;
}
}
else
setting_sensor(ijcmd->data);
}
}
-}
-
-bool extra_evdi_command(ijcommand* ijcmd) {
-
- if (strncmp(ijcmd->cmd, IJTYPE_SENSOR, 6) == 0)
- {
- msgproc_sensor(ijcmd);
- return true;
- }
- else if (strcmp(ijcmd->cmd, IJTYPE_LOCATION) == 0)
- {
- msgproc_location(ijcmd);
- return true;
- }
- return false;
+ return true;
}
void add_vconf_map_profile(void)
/* telephony */
add_vconf_map(TELEPHONY, VCONF_RSSI);
}
+
+void add_msg_proc_ext(void)
+{
+ if (!msgproc_add(DEFAULT_MSGPROC, IJTYPE_SENSOR, &msgproc_sensor, MSGPROC_PRIO_MIDDLE))
+ {
+ LOGWARN("Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_SENSOR);
+ }
+}
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "emuld.h"
+
+static pthread_mutex_t mutex_cmd = PTHREAD_MUTEX_INITIALIZER;
+
+void* exec_cmd_thread(void *args)
+{
+ char *command = (char*)args;
+
+ systemcall(command);
+ LOGDEBUG("executed cmd: %s", command);
+ free(command);
+
+ pthread_exit(NULL);
+}
+
+bool msgproc_cmd(ijcommand* ijcmd)
+{
+ _auto_mutex _(&mutex_cmd);
+ pthread_t cmd_thread_id;
+ char *cmd = (char*) malloc(ijcmd->msg.length + 1);
+
+ if (!cmd) {
+ LOGERR("malloc failed.");
+ return true;
+ }
+
+ memset(cmd, 0x00, ijcmd->msg.length + 1);
+ strncpy(cmd, ijcmd->data, ijcmd->msg.length);
+ LOGDEBUG("cmd: %s, length: %d", cmd, ijcmd->msg.length);
+
+ if (pthread_create(&cmd_thread_id, NULL, exec_cmd_thread, (void*)cmd) != 0) {
+ LOGERR("cmd pthread create fail!");
+ }
+ return true;
+}
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <sys/mount.h>
+#include <unistd.h>
+#include "emuld.h"
+
+static const char* hds_available_path [] = {
+ "/mnt/",
+ NULL,
+};
+
+static bool get_tag_path(char* data, char** tag, char** path)
+{
+ char token[] = "\n";
+
+ LOGINFO("get_tag_path data : %s", data);
+ *tag = strtok(data, token);
+ if (*tag == NULL) {
+ LOGERR("data does not have a correct tag: %s", data);
+ return false;
+ }
+
+ *path = strtok(NULL, token);
+ if (*path == NULL) {
+ LOGERR("data does not have a correct path: %s", data);
+ return false;
+ }
+
+ return true;
+}
+
+static bool secure_hds_path(char* path) {
+ int index = 0;
+ int len = sizeof(hds_available_path) / sizeof(char*);
+ for (index = 0; index < len; index++) {
+ if (hds_available_path[index] &&
+ !strncmp(path, hds_available_path[index], strlen(hds_available_path[index]))) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static void* mount_hds(void* args)
+{
+ int i, ret = 0;
+ int action = 2;
+ char* tag;
+ char* path;
+ char* data = (char*)args;
+
+ LOGINFO("start hds mount thread");
+
+ pthread_detach(pthread_self());
+
+ if (!get_tag_path(data, &tag, &path)) {
+ free(data);
+ return NULL;
+ }
+
+ if (!strncmp(tag, HDS_DEFAULT_ID, 6)) {
+ free(data);
+ return NULL;
+ }
+
+ if (!secure_hds_path(path)) {
+ send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, 11, tag);
+ free(data);
+ return NULL;
+ }
+
+ if (!valid_hds_path(path)) {
+ send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, 12, tag);
+ free(data);
+ return NULL;
+ }
+
+ LOGINFO("tag : %s, path: %s", tag, path);
+
+ for (i = 0; i < 10; i++)
+ {
+ ret = try_mount(tag, path);
+ if(ret == 0) {
+ action = 1;
+ break;
+ } else {
+ LOGERR("%d trial: mount is failed with errno: %d", i, errno);
+ }
+ usleep(500000);
+ }
+
+ send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, action, tag);
+
+ free(data);
+
+ return NULL;
+}
+
+
+static void* umount_hds(void* args)
+{
+ int ret = 0;
+ int action = 3;
+ char* tag;
+ char* path;
+ char* data = (char*)args;
+
+ LOGINFO("unmount hds.");
+ pthread_detach(pthread_self());
+
+ if (!get_tag_path(data, &tag, &path)) {
+ LOGERR("wrong tag or path.");
+ free(data);
+ return NULL;
+ }
+
+ ret = umount(path);
+ if (ret != 0) {
+ LOGERR("unmount failed with error num: %d", errno);
+ action = 4;
+ }
+
+ ret = rmdir(path);
+ LOGINFO("remove path result '%d:%d' with %s", ret, errno, path);
+
+ send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, action, tag);
+
+ LOGINFO("send result with action %d to evdi", action);
+
+ free(data);
+
+ return NULL;
+}
+
+bool msgproc_hds(ijcommand* ijcmd)
+{
+ char* data;
+ char* tag;
+ char* path;
+ LOGDEBUG("msgproc_hds");
+
+ if (!strncmp(ijcmd->data, HDS_DEFAULT_PATH, 9)) {
+ LOGINFO("hds compatibility mode with %s", ijcmd->data);
+ data = strdup(COMPAT_DEFAULT_DATA);
+ } else {
+ data = strdup(ijcmd->data);
+ }
+
+ if (data == NULL) {
+ LOGERR("data dup is failed. out of memory.");
+ return true;
+ }
+
+ LOGINFO("action: %d, data: %s", ijcmd->msg.action, data);
+ if (ijcmd->msg.action == 1) {
+ if (pthread_create(&tid[TID_HDS_ATTACH], NULL, mount_hds, (void*)data) != 0) {
+ if (!get_tag_path(data, &tag, &path)) {
+ LOGERR("mount pthread_create fail - wrong tag or path.");
+ return true;
+ }
+ LOGERR("mount hds pthread create fail!");
+ send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, 2, tag);
+ }
+ } else if (ijcmd->msg.action == 2) {
+ if (pthread_create(&tid[TID_HDS_DETACH], NULL, umount_hds, (void*)data) != 0) {
+ if (!get_tag_path(data, &tag, &path)) {
+ LOGERR("umount pthread_create fail - wrong tag or path.");
+ free(data);
+ return true;
+ }
+ LOGERR("umount hds pthread create fail!");
+ send_to_ecs(IJTYPE_HDS, MSG_GROUP_HDS, 4, tag);
+ }
+ } else {
+ LOGERR("unknown action cmd.");
+ }
+ free(data);
+ return true;
+}
+
+
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <stdio.h>
+#include "emuld.h"
+
+#define LOCATION_STATUS 120
+
+/*
+ * Location function
+ */
+static char* get_location_status(void* p)
+{
+ int mode;
+ int ret = vconf_get_int(VCONF_REPLAYMODE, &mode);
+ if (ret != 0) {
+ return 0;
+ }
+
+ char* message = 0;
+
+ if (mode == 0)
+ { // STOP
+ message = (char*)malloc(5);
+ memset(message, 0, 5);
+
+ ret = sprintf(message, "%d", mode);
+ if (ret < 0) {
+ free(message);
+ message = 0;
+ return 0;
+ }
+ }
+ else if (mode == 1)
+ { // NMEA MODE(LOG MODE)
+ char* temp = 0;
+ temp = (char*) vconf_get_str(VCONF_FILENAME);
+ if (temp == 0) {
+ //free(temp);
+ return 0;
+ }
+
+ message = (char*)malloc(256);
+ memset(message, 0, 256);
+ ret = sprintf(message, "%d,%s", mode, temp);
+ if (ret < 0) {
+ free(message);
+ message = 0;
+ return 0;
+ }
+ } else if (mode == 2) { // MANUAL MODE
+ double latitude;
+ double logitude;
+ double altitude;
+ double accuracy;
+ ret = vconf_get_dbl(VCONF_MLATITUDE, &latitude);
+ if (ret != 0) {
+ return 0;
+ }
+ ret = vconf_get_dbl(VCONF_MLONGITUDE, &logitude);
+ if (ret != 0) {
+ return 0;
+ }
+ ret = vconf_get_dbl(VCONF_MALTITUDE, &altitude);
+ if (ret != 0) {
+ return 0;
+ }
+ ret = vconf_get_dbl(VCONF_MHACCURACY, &accuracy);
+ if (ret != 0) {
+ return 0;
+ }
+
+ message = (char*)malloc(128);
+ memset(message, 0, 128);
+ ret = sprintf(message, "%d,%f,%f,%f,%f", mode, latitude, logitude, altitude, accuracy);
+ if (ret < 0) {
+ free(message);
+ message = 0;
+ return 0;
+ }
+ }
+
+ if (message) {
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = LOCATION_STATUS;
+ return message;
+ } else {
+ return NULL;
+ }
+}
+
+static void* getting_location(void* data)
+{
+ pthread_detach(pthread_self());
+
+ setting_device_param* param = (setting_device_param*) data;
+
+ if (!param)
+ return 0;
+
+ char* msg = 0;
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)malloc(sizeof(LXT_MESSAGE));
+
+ if (!package)
+ {
+ LOGERR("Failed to allocate packet");
+ return NULL;
+ }
+
+ switch(param->ActionID)
+ {
+ case LOCATION_STATUS:
+ msg = get_location_status((void*)packet);
+ if (msg == 0) {
+ LOGERR("failed getting location status");
+ }
+ break;
+ default:
+ LOGERR("Wrong action ID. %d", param->ActionID);
+ break;
+ }
+
+ if (msg == 0)
+ {
+ LOGDEBUG("send error message to injector");
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 0;
+ packet->group = STATUS;
+ packet->action = param->ActionID;
+ }
+ else
+ {
+ LOGDEBUG("send data to injector");
+ }
+
+ const int tmplen = HEADER_SIZE + packet->length;
+ char* tmp = (char*) malloc(tmplen);
+ if (tmp)
+ {
+ memcpy(tmp, packet, HEADER_SIZE);
+ if (packet->length > 0)
+ memcpy(tmp + HEADER_SIZE, msg, packet->length);
+
+ ijmsg_send_to_evdi(g_fd[fdtype_device], param->type_cmd, (const char*) tmp, tmplen);
+
+ free(tmp);
+ }
+
+ if(msg != 0)
+ {
+ free(msg);
+ msg = 0;
+ }
+
+ free(packet);
+
+ if (param)
+ delete param;
+
+ pthread_exit((void *) 0);
+}
+
+void setting_location(char* databuf)
+{
+ char* s = strchr(databuf, ',');
+ int err = 0;
+ if (s == NULL) { // SET MODE
+ int mode = atoi(databuf);
+
+ // 0: STOP MODE, 1: NMEA_MODE (LOG MODE), 2: MANUAL MODE
+ if (mode < 0 || mode > 2) {
+ LOGERR("error(%s) : stop replay mode", databuf);
+ mode = 0;
+ }
+
+ err = vconf_set_int(VCONF_REPLAYMODE, mode);
+ LOGFAIL(err, "Set ReplayMode failed. mode = %d", mode);
+ } else {
+ *s = '\0';
+ int mode = atoi(databuf);
+ if(mode == 1) { // NMEA MODE (LOG MODE)
+ err = vconf_set_str(VCONF_FILENAME, s+1);
+ LOGFAIL(err, "Set FileName failed. name = %s", s+1);
+ err = vconf_set_int(VCONF_REPLAYMODE, mode);
+ LOGFAIL(err, "Set ReplayMode failed. mode = %d", mode);
+ } else if (mode == 2) {
+ char* ptr = strtok(s+1, ",");
+ double value = 0.0;
+
+ // Latitude
+ value = atof(ptr);
+ err = vconf_set_dbl(VCONF_MLATITUDE, value);
+ LOGFAIL(err, "Set ManualLatitude failed. value = %f", value);
+
+ // Longitude
+ ptr = strtok(NULL, ",");
+ value = atof(ptr);
+ err = vconf_set_dbl(VCONF_MLONGITUDE, value);
+ LOGFAIL(err, "Set ManualLongitude failed. value = %f", value);
+
+ // Altitude
+ ptr = strtok(NULL, ",");
+ value = atof(ptr);
+ err = vconf_set_dbl(VCONF_MALTITUDE, value);
+ LOGFAIL(err, "Set ManualAltitude failed. value = %f", value);
+
+ // Accuracy
+ ptr = strtok(NULL, ",");
+ value = atof(ptr);
+ err = vconf_set_dbl(VCONF_MHACCURACY, value);
+ LOGFAIL(err, "Set ManualHAccuracy failed. value = %f", value);
+ }
+ }
+}
+
+bool msgproc_location(ijcommand* ijcmd)
+{
+ LOGDEBUG("msgproc_location");
+ if (ijcmd->msg.group == STATUS)
+ {
+ setting_device_param* param = new setting_device_param();
+ if (!param)
+ return true;
+
+ param->ActionID = ijcmd->msg.action;
+ memcpy(param->type_cmd, ijcmd->cmd, ID_SIZE);
+
+ if (pthread_create(&tid[TID_LOCATION], NULL, getting_location, (void*) param) != 0)
+ {
+ LOGERR("location pthread create fail!");
+ return true;
+ }
+ }
+ else
+ {
+ setting_location(ijcmd->data);
+ }
+ return true;
+}
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <stdio.h>
+#include "emuld.h"
+
+#define MAX_PKGS_BUF 1024
+#define MAX_DATA_BUF 1024
+#define PATH_PACKAGE_INSTALL "/opt/usr/apps/tmp/sdk_tools/"
+#define RPM_CMD_QUERY "-q"
+#define RPM_CMD_INSTALL "-U"
+
+static pthread_mutex_t mutex_pkg = PTHREAD_MUTEX_INITIALIZER;
+
+static bool do_rpm_execute(char* pkgs)
+{
+ char buf[MAX_PKGS_BUF];
+ int ret = 0;
+
+ FILE* fp = popen(pkgs, "r");
+ if (fp == NULL) {
+ LOGERR("[rpm] Failed to popen %s", pkgs);
+ return false;
+ }
+
+ memset(buf, 0, sizeof(buf));
+ while(fgets(buf, sizeof(buf), fp)) {
+ LOGINFO("[rpm]%s", buf);
+ memset(buf, 0, sizeof(buf));
+ }
+
+ ret = pclose(fp);
+ if (ret == -1) {
+ LOGINFO("[rpm] pclose error: %d", errno);
+ return false;
+ }
+
+ if (ret >= 0 && WIFEXITED(ret) && WEXITSTATUS(ret) == 0) {
+ LOGINFO("[rpm] RPM execution success: %s", pkgs);
+ return true;
+ }
+
+ LOGINFO("[rpm] RPM execution fail: [%x,%x,%x] %s", ret, WIFEXITED(ret), WEXITSTATUS(ret), pkgs);
+
+ return false;
+}
+
+static void remove_package(char* data)
+{
+ char token[] = ", ";
+ char pkg_list[MAX_PKGS_BUF];
+ char *addon = NULL;
+ char *copy = strdup(data);
+ size_t remain;
+ if (copy == NULL) {
+ LOGERR("Failed to copy data.");
+ return;
+ }
+
+ memset(pkg_list, 0, sizeof(pkg_list));
+
+ strcpy(pkg_list, "rm -rf ");
+
+ strcat(pkg_list, PATH_PACKAGE_INSTALL);
+ addon = strtok(copy, token);
+
+ if (addon == NULL) {
+ LOGERR("Addon is null");
+ free(copy);
+ return;
+ }
+
+ remain = MAX_PKGS_BUF - strnlen(pkg_list, MAX_PKGS_BUF);
+
+ if (remain < strnlen(addon, MAX_PKGS_BUF)) {
+ LOGERR("Cannot copy add-on name. Insufficient buf size");
+ free(copy);
+ return;
+ }
+
+ strncat(pkg_list, addon, remain - 1); // terminating null byte
+
+ LOGINFO("remove packages: %s", pkg_list);
+
+ systemcall(pkg_list);
+
+ free(copy);
+}
+
+static bool do_package(int action, char* data)
+{
+ char token[] = ", ";
+ char *pkg = NULL;
+ char *addon = NULL;
+ char pkg_list[MAX_PKGS_BUF];
+ size_t remain;
+
+ if (data == NULL) {
+ LOGERR("Add on package list is empty");
+ return false;
+ }
+
+ memset(pkg_list, 0, sizeof(pkg_list));
+
+ strcpy(pkg_list, "rpm");
+
+ if (action == 1) {
+ strcat(pkg_list, " ");
+ strcat(pkg_list, RPM_CMD_QUERY);
+ } else if (action == 2) {
+ strcat(pkg_list, " ");
+ strcat(pkg_list, RPM_CMD_INSTALL);
+ } else {
+ LOGERR("Unknown action.");
+ return false;
+ }
+ addon = strtok(data, token); // for addon path
+
+ if (addon == NULL) {
+ LOGERR("Addon is null");
+ return false;
+ }
+
+ pkg = strtok(NULL, token);
+ while (pkg != NULL) {
+ if (action == 1) {
+ pkg[strlen(pkg) - 4] = 0; //remove .rpm
+ }
+ strcat(pkg_list, " ");
+ if (action == 2) {
+ strcat(pkg_list, PATH_PACKAGE_INSTALL);
+ remain = MAX_PKGS_BUF - strnlen(pkg_list, MAX_PKGS_BUF) - strlen("/");
+ strncat(pkg_list, addon, remain - 1); // terminating null byte
+ strcat(pkg_list, "/");
+ }
+
+ remain = MAX_PKGS_BUF - strnlen(pkg_list, MAX_PKGS_BUF) - strlen(" 2>&1");
+
+ if (remain < strnlen(addon, MAX_PKGS_BUF)) {
+ LOGERR("Cannot copy package name. Insufficient buf size");
+ return false;
+ }
+
+ strncat(pkg_list, pkg, remain - 1); // terminating null byte
+
+ pkg = strtok(NULL, token);
+ }
+
+ strcat(pkg_list, " ");
+ strcat(pkg_list, "2>&1");
+
+ LOGINFO("[cmd] %s", pkg_list);
+ if ((action == 1 || action == 2) && do_rpm_execute(pkg_list)) {
+ return true;
+ }
+
+ return false;
+}
+
+static void* package_thread(void* args)
+{
+ LOGINFO("install package_thread starts.");
+ int action = 0;
+ ijcommand* ijcmd = (ijcommand*)args;
+ char* data = strdup(ijcmd->data);
+ if (data == NULL) {
+ LOGERR("install data is failed to copied.");
+ return NULL;
+ }
+
+ if (ijcmd->msg.action == 1) { // validate packages
+ if (do_package(1, data)) {
+ action = 1; // already installed
+ } else {
+ action = 2; // need to install
+ }
+ } else if (ijcmd->msg.action == 2) { // install packages
+ if (do_package(2, data)) {
+ action = 3; // install success
+ } else {
+ action = 4; // failed to install
+ }
+ remove_package(ijcmd->data);
+ } else {
+ LOGERR("invalid command (action:%d)", ijcmd->msg.action);
+ }
+
+ LOGINFO("send %d, with %s", action, ijcmd->data);
+ send_to_ecs(IJTYPE_PACKAGE, 0, action, ijcmd->data);
+
+ free(data);
+
+ return NULL;
+}
+
+
+bool msgproc_package(ijcommand* ijcmd)
+{
+ _auto_mutex _(&mutex_pkg);
+ int ret = 0;
+ void* retval = NULL;
+ pthread_t pkg_thread_id;
+
+ if (!ijcmd->data) {
+ LOGERR("package data is empty.");
+ return true;
+ }
+
+ LOGINFO("received %d, with %s", ijcmd->msg.action, ijcmd->data);
+
+ if (pthread_create(&pkg_thread_id, NULL, package_thread, (void*)ijcmd) != 0)
+ {
+ LOGERR("validate package pthread creation is failed!");
+ }
+ ret = pthread_join(pkg_thread_id, &retval);
+ if (ret < 0) {
+ LOGERR("validate package pthread join is failed.");
+ }
+ return true;
+}
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <unistd.h>
+#include "emuld.h"
+#include "dd-display.h"
+
+#define PMAPI_RETRY_COUNT 3
+#define SUSPEND_UNLOCK 0
+#define SUSPEND_LOCK 1
+
+static int lock_state = SUSPEND_UNLOCK;
+
+static void set_lock_state(int state) {
+ int i = 0;
+ int ret = 0;
+
+ // FIXME: int lock_state = get_lock_state();
+ LOGINFO("current lock state : %d (1: lock, other: unlock)", lock_state);
+
+ while (i < PMAPI_RETRY_COUNT) {
+ if (state == SUSPEND_LOCK) {
+ // Now we blocking to enter "SLEEP".
+ ret = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ } else if (lock_state == SUSPEND_LOCK) {
+ ret = display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ } else {
+ LOGINFO("meaningless unlock -> unlock state request. RETURN!");
+ return;
+ }
+
+ LOGINFO("display_(lock/unlock)_state return: %d", ret);
+
+ if(ret == 0)
+ {
+ break;
+ }
+ ++i;
+ sleep(10);
+ }
+ if (i == PMAPI_RETRY_COUNT) {
+ LOGERR("Emulator Daemon: Failed to set lock state.\n");
+ return;
+ }
+ lock_state = state;
+}
+
+bool msgproc_suspend(ijcommand* ijcmd)
+{
+ LOGINFO("[Suspend] Set lock state as %d (1: lock, other: unlock)", ijcmd->msg.action);
+
+ if (ijcmd->msg.action == SUSPEND_LOCK) {
+ set_lock_state(SUSPEND_LOCK);
+ } else {
+ set_lock_state(SUSPEND_UNLOCK);
+ }
+ return true;
+}
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <sys/time.h>
+#include <sys/reboot.h>
+#include <unistd.h>
+#include "emuld.h"
+
+#define POWEROFF_DURATION 2
+
+static struct timeval tv_start_poweroff;
+
+enum emuld_system_action {
+ EMULD_SYSTEM_ACTION_FORCE_CLOSE,
+ EMULD_SYSTEM_ACTION_REBOOT
+};
+
+void powerdown_by_force(void)
+{
+ struct timeval now;
+ int poweroff_duration = POWEROFF_DURATION;
+
+ gettimeofday(&now, NULL);
+ /* Waiting until power off duration and displaying animation */
+ while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
+ LOGINFO("power down wait");
+ usleep(100000);
+ gettimeofday(&now, NULL);
+ }
+
+ LOGINFO("Power off by force");
+ LOGINFO("sync");
+
+ sync();
+
+ LOGINFO("poweroff");
+
+ reboot(RB_POWER_OFF);
+}
+
+bool msgproc_system(ijcommand* ijcmd)
+{
+ int action = ijcmd->msg.action;
+ LOGDEBUG("msgproc_system with %d action", action);
+
+ if (action == EMULD_SYSTEM_ACTION_FORCE_CLOSE) {
+ LOGINFO("/etc/rc.d/rc.shutdown, sync, reboot(RB_POWER_OFF)");
+
+ sync();
+
+ systemcall("/etc/rc.d/rc.shutdown &");
+
+ gettimeofday(&tv_start_poweroff, NULL);
+
+ powerdown_by_force();
+ } else if (action == EMULD_SYSTEM_ACTION_REBOOT) {
+ LOGINFO("sync, unmount all hds");
+
+ sync();
+
+ hds_unmount_all();
+ } else {
+ LOGERR("unknown system action %d", action);
+ }
+
+ return true;
+}
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <stdio.h>
+#include "emuld.h"
+
+static void* get_vconf_value(void* data)
+{
+ pthread_detach(pthread_self());
+
+ char *value = NULL;
+ vconf_res_type *vrt = (vconf_res_type*)data;
+
+ if (!check_possible_vconf_key(vrt->vconf_key)) {
+ LOGERR("%s is not available key.");
+ } else {
+ int length = get_vconf_status(&value, vrt->vconf_type, vrt->vconf_key);
+ if (length == 0 || !value) {
+ LOGERR("send error message to injector");
+ send_to_ecs(IJTYPE_VCONF, vrt->group, STATUS, NULL);
+ } else {
+ LOGDEBUG("send data to injector");
+ send_to_ecs(IJTYPE_VCONF, vrt->group, STATUS, value);
+ free(value);
+ }
+ }
+
+ free(vrt->vconf_key);
+ free(vrt);
+
+ pthread_exit((void *) 0);
+}
+
+static void* set_vconf_value(void* data)
+{
+ pthread_detach(pthread_self());
+
+ vconf_res_type *vrt = (vconf_res_type*)data;
+
+ if (!check_possible_vconf_key(vrt->vconf_key)) {
+ LOGERR("%s is not available key.");
+ } else {
+ keylist_t *get_keylist;
+ keynode_t *pkey_node = NULL;
+ get_keylist = vconf_keylist_new();
+ if (!get_keylist) {
+ LOGERR("vconf_keylist_new() failed");
+ } else {
+ vconf_get(get_keylist, vrt->vconf_key, VCONF_GET_ALL);
+ int ret = vconf_keylist_lookup(get_keylist, vrt->vconf_key, &pkey_node);
+ if (ret == 0) {
+ LOGERR("%s key not found", vrt->vconf_key);
+ } else {
+ if (vconf_keynode_get_type(pkey_node) != vrt->vconf_type) {
+ LOGERR("inconsistent type (prev: %d, new: %d)",
+ vconf_keynode_get_type(pkey_node), vrt->vconf_type);
+ }
+ }
+ vconf_keylist_free(get_keylist);
+ }
+
+ /* TODO: to be implemented another type */
+ if (vrt->vconf_type == VCONF_TYPE_INT) {
+ int val = atoi(vrt->vconf_val);
+ vconf_set_int(vrt->vconf_key, val);
+ LOGDEBUG("key: %s, val: %d", vrt->vconf_key, val);
+ } else if (vrt->vconf_type == VCONF_TYPE_DOUBLE) {
+ LOGERR("not implemented");
+ } else if (vrt->vconf_type == VCONF_TYPE_STRING) {
+ LOGERR("not implemented");
+ } else if (vrt->vconf_type == VCONF_TYPE_BOOL) {
+ LOGERR("not implemented");
+ } else if (vrt->vconf_type == VCONF_TYPE_DIR) {
+ LOGERR("not implemented");
+ } else {
+ LOGERR("undefined vconf type");
+ }
+ }
+
+ free(vrt->vconf_key);
+ free(vrt->vconf_val);
+ free(vrt);
+
+ pthread_exit((void *) 0);
+}
+
+bool msgproc_vconf(ijcommand* ijcmd)
+{
+ LOGDEBUG("msgproc_vconf");
+
+ const int tmpsize = ijcmd->msg.length;
+ char token[] = "\n";
+ char tmpdata[tmpsize];
+ memcpy(tmpdata, ijcmd->data, tmpsize);
+
+ char* ret = NULL;
+ ret = strtok(tmpdata, token);
+ if (!ret) {
+ LOGERR("vconf type is empty");
+ return true;
+ }
+
+ vconf_res_type *vrt = (vconf_res_type*)malloc(sizeof(vconf_res_type));
+ if (!vrt) {
+ LOGERR("insufficient memory available");
+ return true;
+ }
+
+ if (strcmp(ret, "int") == 0) {
+ vrt->vconf_type = VCONF_TYPE_INT;
+ } else if (strcmp(ret, "double") == 0) {
+ vrt->vconf_type = VCONF_TYPE_DOUBLE;
+ } else if (strcmp(ret, "string") == 0) {
+ vrt->vconf_type = VCONF_TYPE_STRING;
+ } else if (strcmp(ret, "bool") == 0) {
+ vrt->vconf_type = VCONF_TYPE_BOOL;
+ } else if (strcmp(ret, "dir") ==0) {
+ vrt->vconf_type = VCONF_TYPE_DIR;
+ } else {
+ LOGERR("undefined vconf type");
+ goto error;
+ }
+
+ ret = strtok(NULL, token);
+ if (!ret) {
+ LOGERR("vconf key is empty");
+ goto error;
+ }
+
+ vrt->vconf_key = (char*)malloc(strlen(ret) + 1);
+ if (!vrt->vconf_key) {
+ LOGERR("insufficient memory available");
+ goto error;
+ }
+ sprintf(vrt->vconf_key, "%s", ret);
+
+ if (ijcmd->msg.action == VCONF_SET) {
+ ret = strtok(NULL, token);
+ if (!ret) {
+ LOGERR("vconf value is empty");
+ goto error2;
+ }
+
+ vrt->vconf_val = (char*)malloc(strlen(ret) + 1);
+ if (!vrt->vconf_val) {
+ LOGERR("insufficient memory available");
+ goto error2;
+ }
+ sprintf(vrt->vconf_val, "%s", ret);
+
+ if (pthread_create(&tid[TID_VCONF], NULL, set_vconf_value, (void*)vrt) == 0) {
+ return true;
+ }
+ LOGERR("set vconf pthread create fail!");
+ free(vrt->vconf_val);
+ } else if (ijcmd->msg.action == VCONF_GET) {
+ vrt->group = ijcmd->msg.group;
+ if (pthread_create(&tid[TID_VCONF], NULL, get_vconf_value, (void*)vrt) == 0) {
+ return true;
+ }
+ LOGERR("get vconf pthread create fail!");
+ } else {
+ LOGERR("undefined action %d", ijcmd->msg.action);
+ }
+
+error2:
+ free(vrt->vconf_key);
+error:
+ free(vrt);
+
+ return true;
+}
/*
* emulator-daemon
*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* Munkyu Im <munkyu.im@samsnung.com>
/*
* emulator-daemon
*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* DaiYoung Kim <daiyoung777.kim@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
return true;
}
-bool extra_evdi_command(ijcommand* ijcmd) {
-
- if (strncmp(ijcmd->cmd, IJTYPE_GESTURE, 7) == 0)
- {
- msgproc_gesture(ijcmd);
- return true;
- }
- else if (strncmp(ijcmd->cmd, IJTYPE_VOICE, 5) == 0)
- {
- msgproc_voice(ijcmd);
- return true;
- }
- else if (strncmp(ijcmd->cmd, IJTYPE_EI, 2) == 0)
- {
- msgproc_extinput(ijcmd);
- return true;
- }
-
- return false;
-}
-
void add_vconf_map_profile(void)
{
/* tv */
add_vconf_map(TV, VCONF_COMP1);
add_vconf_map(TV, VCONF_COMP2);
}
+
+void add_msg_proc_ext(void)
+{
+ if (!msgproc_add(DEFAULT_MSGPROC, IJTYPE_GESTURE, &msgproc_gesture, MSGPROC_PRIO_MIDDLE))
+ {
+ LOGWARN("Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_GESTURE);
+ }
+ if (!msgproc_add(DEFAULT_MSGPROC, IJTYPE_VOICE, &msgproc_voice, MSGPROC_PRIO_MIDDLE))
+ {
+ LOGWARN("Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_VOICE);
+ }
+ if (!msgproc_add(DEFAULT_MSGPROC, IJTYPE_EI, &msgproc_extinput, MSGPROC_PRIO_MIDDLE))
+ {
+ LOGWARN("Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_EI);
+ }
+}
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * Chulho Song <ch81.song@samsung.com>
+ * Jinhyung Choi <jinh0.choi@samsnung.com>
* DaiYoung Kim <daiyoung777.kim@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
}
}
-void msgproc_sensor(ijcommand* ijcmd)
+bool msgproc_sensor(ijcommand* ijcmd)
{
LOGDEBUG("msgproc_sensor");
setting_sensor(ijcmd->data);
}
}
+ return true;
}
-bool extra_evdi_command(ijcommand* ijcmd) {
-
- if (strncmp(ijcmd->cmd, IJTYPE_SENSOR, 6) == 0)
- {
- msgproc_sensor(ijcmd);
- return true;
- }
- else if (strcmp(ijcmd->cmd, IJTYPE_LOCATION) == 0)
- {
- msgproc_location(ijcmd);
- return true;
- }
- return false;
+void add_vconf_map_profile(void)
+{
}
-void add_vconf_map_profile(void)
+void add_msg_proc_ext(void)
{
+ if (!msgproc_add(DEFAULT_MSGPROC, IJTYPE_SENSOR, &msgproc_sensor, MSGPROC_PRIO_MIDDLE))
+ {
+ LOGWARN("Msgproc add failed. plugin = %s, cmd = %s", DEFAULT_MSGPROC, IJTYPE_SENSOR);
+ }
}