emuld: update the latest code from public
authormunkyu.im <munkyu.im@samsung.com>
Mon, 25 Nov 2013 10:33:56 +0000 (19:33 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Tue, 26 Nov 2013 02:02:48 +0000 (11:02 +0900)
integrated public source codes
added sap supporting codes on it.
modified boilerplate.

Change-Id: If991eca08c0f534d17229a7fac22432a76863930
Signed-off-by: munkyu.im <munkyu.im@samsung.com>
18 files changed:
AUTHORS
CMakeLists.txt
NOTICE
emuld [deleted file]
include/emuld.h [changed mode: 0755->0644]
include/emuld_common.h [changed mode: 0755->0644]
include/emuld_proc.h
include/evdi.h
include/evdi_protocol.h [changed mode: 0755->0644]
include/log.h
include/synbuf.h [changed mode: 0755->0644]
packaging/emuld.spec
src/client.cpp
src/emuld.cpp
src/emuld_proc.cpp
src/evdi.cpp
src/get_status.cpp
src/log.cpp

diff --git a/AUTHORS b/AUTHORS
index 3ba9fb3ba258c720da70e1648af7cd37c6c880cc..73e5de9be213e887c210c49f5b831a9fe82eb2c0 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,7 +1,7 @@
 YeongKyoon Lee <yeongkyoon.lee@samsung.com>
 DaiYoung Kim <daiyoung777.kim@samsung.com>
-SeokYeon Hwang <syeon.hwang@samsung.com>
 Jinhyung Choi <jinhyung2.choi@samsung.com>
+SeokYeon Hwang <syeon.hwang@samsung.com>
 SangJin Kim <sangjin3.kim@samsung.com>
 KiTae Kim <kt920.kim@samsung.com>
 JinHyung Jo <jinhyung.jo@samsung.com>
index 5e658f8d08584fec30f15d2d1edee22041d71d4b..4730ffd3db72820862f8ad9f892b6af3fc640b48 100644 (file)
@@ -20,23 +20,23 @@ set(CMAKE_VERBOSE_MAKEFILE OFF)
 #FIND_PROGRAM(UNAME NAMES uname)
 #EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
 #IF("${ARCH}" STREQUAL "arm")
-#        ADD_DEFINITIONS("-DTARGET -DHWREV_CHECK")
-#        MESSAGE("add -DTARGET")
+#   ADD_DEFINITIONS("-DTARGET -DHWREV_CHECK")
+#   MESSAGE("add -DTARGET")
 #ELSE("${ARCH}" STREQUAL "arm")
-#      ADD_DEFINITIONS("-DSIMULATOR")
-#      MESSAGE("add -DSIMULATOR")
+#   ADD_DEFINITIONS("-DSIMULATOR")
+#   MESSAGE("add -DSIMULATOR")
 #ENDIF("${ARCH}" STREQUAL "arm")
 
 ADD_DEFINITIONS("-DTARGET -DHWREV_CHECK")
 
 #add_definitions(-D_ESTIMATE_PERFORMANCE)
 #add_definitions(-D_DEFAULT_FONT_NAME="Vera")
-add_definitions(-Wall -O3 -omit-frame-pointer)
+add_definitions(-Werror -Wall -O3 -omit-frame-pointer)
 #add_definitions(-Wall -g -D_DEBUG)
 add_definitions(-Iinclude)
 ADD_EXECUTABLE(${PROJECT_NAME} src/emuld.cpp src/evdi.cpp src/emuld_proc.cpp src/client.cpp src/get_status.cpp src/log.cpp)
 
 target_link_libraries(${PROJECT_NAME} ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} "-lpthread -lvconf" )
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} "-lpthread -lvconf -lpmapi" )
 
 install(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin)
diff --git a/NOTICE b/NOTICE
index f085dc6e7586f220da6d2f320c01d01502666aba..272ca70b4f1ff32fae534b79b8e532649a854318 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -1 +1 @@
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
diff --git a/emuld b/emuld
deleted file mode 100644 (file)
index 7f13703..0000000
--- a/emuld
+++ /dev/null
@@ -1,3 +0,0 @@
-/usr/bin/emuld &
-/usr/sbin/sensord &
-/etc/emulator/sensor_setting.sh &
old mode 100755 (executable)
new mode 100644 (file)
index a063e45..c70fd1d
@@ -1,11 +1,13 @@
 /*
  * emulator-daemon
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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");
 #include "emuld_proc.h"
 
 /* definition */
-#define MAX_CLIENT             10000
-#define MAX_EVENTS             10000
-#define MAX_GETCNT             10
-#define SDBD_PORT              26101
-#define DEFAULT_PORT           3577
-#define VMODEM_PORT            3578
-#define SAP_PORT               9999
-#define GPSD_PORT              3579
-#define SENSORD_PORT           3580
-#define SRV_IP                         "10.0.2.2"
-#define ID_SIZE                        10
-#define HEADER_SIZE            4
+#define MAX_CLIENT          10000
+#define MAX_EVENTS          10000
+#define MAX_GETCNT          10
+#define SDBD_PORT           26101
+#define DEFAULT_PORT        3577
+#define VMODEM_PORT         3578
+#define SAP_PORT                   9999
+#define GPSD_PORT           3579
+#define SENSORD_PORT        3580
+#define SRV_IP              "10.0.2.2"
+#define ID_SIZE             10
+#define HEADER_SIZE         4
 #define EMD_DEBUG
-#define POWEROFF_DURATION      2
+#define POWEROFF_DURATION   2
 
-
-#define SDB_PORT_FILE          "/opt/home/sdb_port.txt"
+#define SDB_PORT_FILE       "/opt/home/sdb_port.txt"
 
 enum
 {
@@ -93,20 +94,18 @@ extern struct sockaddr_in si_sensord_other;
 extern int g_fd[fdtype_max];
 
 
-#define IJTYPE_TELEPHONY               "telephony"
-#define IJTYPE_SAP                     "sap"
-#define IJTYPE_SDCARD                  "sdcard"
+#define IJTYPE_TELEPHONY    "telephony"
+#define IJTYPE_SAP                 "sap"
+#define IJTYPE_SDCARD       "sdcard"
 
 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);
 
-
 bool epoll_init(void);            /* epoll fd create */
 bool epoll_ctl_add(const int fd);
 
-
 void init_data0(void);            /* initialize data. */
 bool init_server0(int svr_port, int* ret_fd);
 void end_server(int sig);
@@ -128,48 +127,36 @@ bool is_sap_connected(void);
 
 void* init_vm_connect(void* data);
 void* init_sap_connect(void* data);
-
-
-
-
 void systemcall(const char* param);
 
 void recv_from_evdi(evdi_fd fd);
 
-static int log_print = 1;
-
-
 int powerdown_by_force(void);
 // location
 void setting_location(char* databuf);
 
-
 #define LOG(fmt, arg...) \
-       do { \
-               log_print_out("[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); \
-       } while (0)
-
-
-
+    do { \
+        log_print_out("[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); \
+    } while (0)
 
 #include <map>
 
-typedef unsigned short CliSN;
+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) {}
+    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 */
+    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);
@@ -180,34 +167,33 @@ bool send_to_all_ij(char* data, const int len);
 bool is_ij_exist();
 void stop_listen(void);
 
-
 struct fd_info
 {
-       fd_info() : fd(-1){}
-       int fd;
-       int fdtype;
+    fd_info() : fd(-1){}
+    int fd;
+    int fdtype;
 };
 
 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;
-
-       LXT_MESSAGE msg;
+    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;
+
+    LXT_MESSAGE msg;
 };
 
 void process_evdi_command(ijcommand* ijcmd);
@@ -224,5 +210,4 @@ bool msgproc_nfc(const int sockfd, ijcommand* ijcmd, const bool is_evdi);
 bool msgproc_system(const int sockfd, ijcommand* ijcmd, const bool is_evdi);
 bool msgproc_sdcard(const int sockfd, ijcommand* ijcmd, const bool is_evdi);
 
-
 #endif //__emuld_h__
old mode 100755 (executable)
new mode 100644 (file)
index 579e841..638651a
@@ -1,11 +1,13 @@
 /*
  * emulator-daemon
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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");
 
 // define group id
 // return value to the injector
-#define STATUS 15
+#define STATUS              15
 
 // define action id
-#define BATTERY_LEVEL 100
-#define BATTERY_CHARGER 101
-#define USB_STATUS 102
-#define EARJACK_STATUS 103
-#define RSSI_LEVEL 104
-
-#define ACCEL_VALUE 110
-#define GYRO_VALUE 111
-#define MAG_VALUE 112
-#define LIGHT_VALUE 113
-#define PROXI_VALUE 114
-#define MOTION_VALUE 115
-
-#define LOCATION_STATUS 120
-
-#define NFC_STATUS 121
-
-#define PATH_SENSOR_ACCEL_XYZ  "/sys/devices/virtual/sensor/accel/xyz"
-#define PATH_SENSOR_PROXI_VO   "/sys/devices/virtual/sensor/proxi/vo"
-#define PATH_SENSOR_LIGHT_ADC  "/sys/devices/virtual/sensor/light/adc"
-#define PATH_SENSOR_GYRO_X_RAW "/sys/devices/virtual/sensor/gyro/gyro_x_raw"
-#define PATH_SENSOR_GYRO_Y_RAW "/sys/devices/virtual/sensor/gyro/gyro_y_raw"
-#define PATH_SENSOR_GYRO_Z_RAW "/sys/devices/virtual/sensor/gyro/gyro_z_raw"
-#define PATH_SENSOR_GEO_TESLA  "/sys/devices/virtual/sensor/geo/tesla"
-#define PATH_NFC_DATA  "/sys/devices/virtual/network/nfc/data"
+#define BATTERY_LEVEL       100
+#define BATTERY_CHARGER     101
+#define USB_STATUS          102
+#define EARJACK_STATUS      103
+#define RSSI_LEVEL          104
+
+#define ACCEL_VALUE         110
+#define GYRO_VALUE          111
+#define MAG_VALUE           112
+#define LIGHT_VALUE         113
+#define PROXI_VALUE         114
+#define MOTION_VALUE        115
+
+#define LOCATION_STATUS     120
+
+#define NFC_STATUS          121
+
+#define PATH_SENSOR_ACCEL_XYZ   "/sys/devices/virtual/sensor/accel/xyz"
+#define PATH_SENSOR_PROXI_VO    "/sys/devices/virtual/sensor/proxi/vo"
+#define PATH_SENSOR_LIGHT_ADC   "/sys/devices/virtual/sensor/light/adc"
+#define PATH_SENSOR_GYRO_X_RAW  "/sys/devices/virtual/sensor/gyro/gyro_x_raw"
+#define PATH_SENSOR_GYRO_Y_RAW  "/sys/devices/virtual/sensor/gyro/gyro_y_raw"
+#define PATH_SENSOR_GYRO_Z_RAW  "/sys/devices/virtual/sensor/gyro/gyro_z_raw"
+#define PATH_SENSOR_GEO_TESLA   "/sys/devices/virtual/sensor/geo/tesla"
+#define PATH_NFC_DATA           "/sys/devices/virtual/network/nfc/data"
 
 struct LXT_MESSAGE// lxt_message
 {
-       unsigned short length;
-       unsigned char group;
-       unsigned char action;
-       void *data; 
+    unsigned short length;
+    unsigned char group;
+    unsigned char action;
+    void *data;
 };
 
 typedef struct LXT_MESSAGE LXT_MESSAGE;
@@ -102,18 +104,18 @@ char* get_nfc_status(void* , bool);
 
 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;
+    _auto_mutex(pthread_mutex_t* t)
+    {
+        _mutex = t;
+        pthread_mutex_lock(_mutex);
+
+    }
+    ~_auto_mutex()
+    {
+        pthread_mutex_unlock(_mutex);
+    }
+
+    pthread_mutex_t* _mutex;
 };
 
 #endif //
index 3d423b983e2ee541ed19138a8d13649818af0961..d825a8570cbc6c908ea3a8f9e9a748c231ed7b0a 100644 (file)
@@ -1,3 +1,31 @@
+/*
+ * 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
+ *
+ */
 
 #ifndef __emuld_proc_h__
 #define __emuld_proc_h__
index 29e0f24958b0c05876a842e02304749f1923d615..28996a0dabe2ddd1189ef2512bfa8837e870432f 100644 (file)
@@ -1,9 +1,37 @@
+/*
+ * 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
+ *
+ */
 
 
 #ifndef __evdi_h__
 #define __evdi_h__
 
-typedef int            evdi_fd;
+typedef int     evdi_fd;
 
 bool init_device(evdi_fd* ret_fd);
 
old mode 100755 (executable)
new mode 100644 (file)
index 36f3d98..e389f4b
@@ -1,38 +1,61 @@
-/*\r
- * evdi_protocol.h\r
- *\r
- *  Created on: 2013. 4. 15.\r
- *      Author: dykim\r
- */\r
-\r
-#ifndef EVDI_PROTOCOL_H_\r
-#define EVDI_PROTOCOL_H_\r
-\r
-/* device protocol */\r
-\r
-#define __MAX_BUF_SIZE 1024\r
-\r
-enum\r
-{\r
-       route_qemu = 0,\r
-       route_control_server = 1,\r
-       route_monitor = 2\r
-};\r
-\r
-typedef unsigned int CSCliSN;\r
-\r
-struct msg_info {\r
-       char buf[__MAX_BUF_SIZE];\r
-\r
-       uint32_t route;\r
-       uint32_t use;\r
-       uint16_t count;\r
-       uint16_t index;\r
-\r
-       CSCliSN cclisn;\r
-};\r
-\r
-/* device protocol */\r
-\r
-\r
-#endif /* EVDI_PROTOCOL_H_ */\r
+/*
+ * 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
+ *
+ */
+
+
+#ifndef EVDI_PROTOCOL_H_
+#define EVDI_PROTOCOL_H_
+
+/* device protocol */
+
+#define __MAX_BUF_SIZE  1024
+
+enum
+{
+    route_qemu = 0,
+    route_control_server = 1,
+    route_monitor = 2
+};
+
+typedef unsigned int CSCliSN;
+
+struct msg_info {
+    char buf[__MAX_BUF_SIZE];
+
+    uint32_t route;
+    uint32_t use;
+    uint16_t count;
+    uint16_t index;
+
+    CSCliSN cclisn;
+};
+
+/* device protocol */
+
+
+#endif /* EVDI_PROTOCOL_H_ */
index 1135171534245a29e60e3d77cf7d2dad98e4e73c..8c4cec2b1ff993bee185881a112d917c8323f520 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * 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
+ *
+ */
+
 
 #ifndef __log_h__
 #define __log_h__
old mode 100755 (executable)
new mode 100644 (file)
index bb79751..26bacfe
-/*\r
- * synbuf.h\r
- *\r
- *  Created on: 2013. 4. 12.\r
- *      Author: dykim\r
- */\r
-\r
-#ifndef SYNBUF_H_\r
-#define SYNBUF_H_\r
-\r
-#include <stdbool.h>\r
-\r
-\r
-class synbuf\r
-{\r
-public:\r
-\r
-       enum\r
-       {\r
-               default_buf_size = 2048\r
-       };\r
-       synbuf()\r
-               : m_buf(NULL), m_size(default_buf_size), m_use(0)\r
-       {\r
-               m_buf = (char*) malloc(default_buf_size);\r
-               memset(m_buf, 0, default_buf_size);\r
-               m_readptr = m_buf;\r
-       }\r
-\r
-       void reset_buf()\r
-       {\r
-               freebuf();\r
-\r
-               m_buf = (char*) malloc(default_buf_size);\r
-               memset(m_buf, 0, default_buf_size);\r
-               m_readptr = m_buf;\r
-\r
-               m_size = default_buf_size;\r
-               m_use = 0;\r
-       }\r
-\r
-       int available()\r
-       {\r
-               return m_size - m_use;\r
-       }\r
-\r
-       char* get_readptr()\r
-       {\r
-               return m_readptr;\r
-       }\r
-\r
-       void set_written(const int written)\r
-       {\r
-               m_use += written;\r
-       }\r
-\r
-       void freebuf()\r
-       {\r
-               if (m_buf)\r
-               {\r
-                       free(m_buf);\r
-                       m_buf = NULL;\r
-               }\r
-       }\r
-\r
-       bool realloc_and_move(const int newsize, const int readed)\r
-       {\r
-               char* tmp = (char*) malloc(newsize);\r
-               if (!tmp)\r
-                       return false;\r
-\r
-               int left = m_use - readed;\r
-               memset(tmp, 0, newsize);\r
-               memcpy(tmp, m_buf + readed, left);\r
-\r
-               freebuf();\r
-\r
-               m_buf = tmp;\r
-               m_use = left;\r
-               m_size = newsize;\r
-               m_readptr = m_buf;\r
-\r
-               return true;\r
-       }\r
-\r
-       bool write(const char* buf, const int len)\r
-       {\r
-               if (len >= available())\r
-               {\r
-                       if (!realloc_and_move((m_size * 2), 0))\r
-                               return false;\r
-               }\r
-\r
-               memcpy(m_buf + m_use, buf, len);\r
-               m_use += len;\r
-\r
-               return true;\r
-       }\r
-\r
-       int read(char* buf, const int len)\r
-       {\r
-               if (m_use < len)\r
-                       return 0;\r
-\r
-               memcpy(buf, m_buf, len);\r
-\r
-               int left = m_use - len;\r
-               if (left > 0)\r
-               {\r
-                       realloc_and_move(m_size, len);\r
-               }\r
-               else\r
-               {\r
-                       // there is no more readable buffer, reset all variables\r
-                       memset(m_buf, 0, m_size);\r
-                       m_readptr = m_buf;\r
-                       m_use = 0;\r
-               }\r
-\r
-               return len;\r
-       }\r
-\r
-\r
-private:\r
-\r
-\r
-       char* m_buf;\r
-       char* m_readptr;\r
-       int m_size;\r
-       int m_use;\r
-};\r
-\r
-\r
-\r
-#endif /* SYNBUF_H_ */\r
+/*
+ * 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
+ *
+ */
+
+
+#ifndef SYNBUF_H_
+#define SYNBUF_H_
+
+#include <stdbool.h>
+
+
+class synbuf
+{
+public:
+
+    enum
+    {
+        default_buf_size = 2048
+    };
+    synbuf()
+        : m_buf(NULL), m_size(default_buf_size), m_use(0)
+    {
+        m_buf = (char*) malloc(default_buf_size);
+        memset(m_buf, 0, default_buf_size);
+        m_readptr = m_buf;
+    }
+
+    void reset_buf()
+    {
+        freebuf();
+
+        m_buf = (char*) malloc(default_buf_size);
+        memset(m_buf, 0, default_buf_size);
+        m_readptr = m_buf;
+
+        m_size = default_buf_size;
+        m_use = 0;
+    }
+
+    int available()
+    {
+        return m_size - m_use;
+    }
+
+    char* get_readptr()
+    {
+        return m_readptr;
+    }
+
+    void set_written(const int written)
+    {
+        m_use += written;
+    }
+
+    void freebuf()
+    {
+        if (m_buf)
+        {
+            free(m_buf);
+            m_buf = NULL;
+        }
+    }
+
+    bool realloc_and_move(const int newsize, const int readed)
+    {
+        char* tmp = (char*) malloc(newsize);
+        if (!tmp)
+            return false;
+
+        int left = m_use - readed;
+        memset(tmp, 0, newsize);
+        memcpy(tmp, m_buf + readed, left);
+
+        freebuf();
+
+        m_buf = tmp;
+        m_use = left;
+        m_size = newsize;
+        m_readptr = m_buf;
+
+        return true;
+    }
+
+    bool write(const char* buf, const int len)
+    {
+        if (len >= available())
+        {
+            if (!realloc_and_move((m_size * 2), 0))
+                return false;
+        }
+
+        memcpy(m_buf + m_use, buf, len);
+        m_use += len;
+
+        return true;
+    }
+
+    int read(char* buf, const int len)
+    {
+        if (m_use < len)
+            return 0;
+
+        memcpy(buf, m_buf, len);
+
+        int left = m_use - len;
+        if (left > 0)
+        {
+            realloc_and_move(m_size, len);
+        }
+        else
+        {
+            // there is no more readable buffer, reset all variables
+            memset(m_buf, 0, m_size);
+            m_readptr = m_buf;
+            m_use = 0;
+        }
+
+        return len;
+    }
+
+
+private:
+
+
+    char* m_buf;
+    char* m_readptr;
+    int m_size;
+    int m_use;
+};
+
+
+
+#endif /* SYNBUF_H_ */
index 6ae8d39aeac261b7f23e83b9ab35e7723d56f6e6..9ab81721b1b4fe06bfc5d7e200e4fa79cd3b3d7a 100644 (file)
@@ -1,32 +1,31 @@
-#git:/slp/pkgs/e/emulator-daemon
 Name: emuld
-Version: 0.2.30
-Release: 1
-Summary: emuld is used for communication emulator between and ide.
-License: Apache
+Version: 0.4.0
+Release: 0
+Summary: Emulator daemon
+License: Apache-2.0
 Source0: %{name}-%{version}.tar.gz
+Group: SDK/Other
 Source1001: packaging/emuld.manifest
-BuildArch: i386
-ExclusiveArch: %{ix86}
 BuildRequires: cmake
-BuildRequires:  pkgconfig(vconf)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(pmapi)
 
 %description
+A emulator daemon is used for communication emulator between and ide.
 
 %prep
 %setup -q
 
 %build
-export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"    
-    
+export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
+
 LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
 
 make
 
 %install
-rm -rf %{buildroot}
-
 #for systemd
+rm -rf %{buildroot}
 if [ ! -d %{buildroot}/usr/lib/systemd/system/emulator.target.wants ]; then
     mkdir -p %{buildroot}/usr/lib/systemd/system/emulator.target.wants
 fi
@@ -34,14 +33,17 @@ cp emuld.service %{buildroot}/usr/lib/systemd/system/.
 ln -s ../emuld.service %{buildroot}/usr/lib/systemd/system/emulator.target.wants/emuld.service
 
 #for legacy init
-if [ ! -d %{buildroot}/etc/init.d ]; then
-    mkdir -p %{buildroot}/etc/init.d
-fi
-cp emuld %{buildroot}/etc/init.d/.
-if [ ! -d %{buildroot}/etc/rc.d/rc3.d ]; then
-    mkdir -p %{buildroot}/etc/rc.d/rc3.d
-fi
-ln -s /etc/init.d/emuld %{buildroot}/etc/rc.d/rc3.d/S04emuld
+#if [ ! -d %{buildroot}/etc/init.d ]; then
+#    mkdir -p %{buildroot}/etc/init.d
+#fi
+#cp emuld %{buildroot}/etc/init.d/.
+#if [ ! -d %{buildroot}/etc/rc.d/rc3.d ]; then
+#    mkdir -p %{buildroot}/etc/rc.d/rc3.d
+#fi
+#ln -s /etc/init.d/emuld %{buildroot}/etc/rc.d/rc3.d/S04emuld
+
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
 
 %make_install
 
@@ -51,20 +53,20 @@ rm -rf CMakeCache.txt
 rm -rf CMakeFiles
 rm -rf cmake_install.cmake
 rm -rf Makefile
-rm -rf install_manifes.txt
+rm -rf install_manifest.txt
 
 %post
-chmod 777 /usr/bin/emuld
+chmod 770 %{_prefix}/bin/emuld
 mkdir -p /opt/nfc
-
-%postun
+touch /opt/nfc/sdkMsg
 
 %files
 %defattr(-,root,root,-)
 %{_prefix}/bin/emuld
+/usr/share/license/%{name}
 /usr/lib/systemd/system/emuld.service
 /usr/lib/systemd/system/emulator.target.wants/emuld.service
-/etc/init.d/emuld
-/etc/rc.d/rc3.d/S04emuld
+#/etc/init.d/emuld
+#/etc/rc.d/rc3.d/S04emuld
 
 %changelog
index 876771cb58851cba4b505c3e3f8dada946ee54a6..2fd0e9b1bed53c4371a3ca71000f7e643c1bc699 100644 (file)
-\r
-\r
-#include "emuld.h"\r
-#include "emuld_common.h"\r
-\r
-static pthread_mutex_t mutex_climap = PTHREAD_MUTEX_INITIALIZER;\r
-\r
-\r
-CliMap g_climap;\r
-\r
-void clipool_add(int fd, unsigned short port, const int fdtype)\r
-{\r
-       _auto_mutex _(&mutex_climap);\r
-\r
-       static CliSN s_id = 0;\r
-\r
-       CliSN id = s_id;\r
-       s_id++;\r
-       Cli* cli = new Cli(id, fdtype, fd, port);\r
-       if (!cli)\r
-               return;\r
-\r
-       if (!g_climap.insert(CliMap::value_type(fd, cli)).second)\r
-               return;\r
-\r
-       LOG("clipool_add fd = %d, port = %d, type = %d \n", fd, port, fdtype);\r
-}\r
-\r
-\r
-void close_cli(int cli_fd)\r
-{\r
-       clipool_delete(cli_fd);\r
-       close(cli_fd);\r
-}\r
-\r
-void clipool_delete(int fd)\r
-{\r
-       _auto_mutex _(&mutex_climap);\r
-\r
-       CliMap::iterator it = g_climap.find(fd);\r
-\r
-       if (it != g_climap.end())\r
-       {\r
-               Cli* cli = it->second;\r
-               g_climap.erase(it);\r
-\r
-               if (cli)\r
-               {\r
-                       delete cli;\r
-                       cli = NULL;\r
-               }\r
-       }\r
-\r
-       LOG("clipool_delete fd = %d\n", fd);\r
-}\r
-\r
-\r
-Cli* find_cli(const int fd)\r
-{\r
-       _auto_mutex _(&mutex_climap);\r
-\r
-       CliMap::iterator it = g_climap.find(fd);\r
-       if (it != g_climap.end())\r
-               return NULL;\r
-\r
-       Cli* cli = it->second;\r
-       return cli;\r
-}\r
-\r
-// for thread safe\r
-bool send_to_cli(const int fd, char* data, const int len)\r
-{\r
-       _auto_mutex _(&mutex_climap);\r
-\r
-       CliMap::iterator it = g_climap.find(fd);\r
-       if (it == g_climap.end())\r
-               return false;\r
-\r
-       Cli* cli = it->second;\r
-\r
-       if (send(cli->sockfd, data, len, 0) == -1)\r
-               return false;\r
-\r
-       return true;\r
-}\r
-\r
-bool send_to_all_ij(char* data, const int len)\r
-{\r
-       _auto_mutex _(&mutex_climap);\r
-\r
-       bool result = false;\r
-       CliMap::iterator it, itend = g_climap.end();\r
-\r
-       for (it = g_climap.begin(); it != itend; it++)\r
-       {\r
-               Cli* cli = it->second;\r
-\r
-               if (!cli)\r
-                       continue;\r
-\r
-               int sent = send(cli->sockfd, data, len, 0);\r
-               result = (sent == -1) ? false : true;\r
-               if (sent == -1)\r
-               {\r
-                       perror("failed to send to ij\n");\r
-               }\r
-\r
-               LOG("send_len: %d, err= %d\n", sent, errno);\r
-       }\r
-       return result;\r
-}\r
-\r
-bool is_ij_exist()\r
-{\r
-       _auto_mutex _(&mutex_climap);\r
-\r
-       bool result = (g_climap.size() > 0) ? true : false;\r
-       return result;\r
-}\r
-\r
-void stop_listen(void)\r
-{\r
-       pthread_mutex_destroy(&mutex_climap);;\r
-}\r
-\r
-\r
-\r
-\r
-\r
+/*
+ * 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 "emuld.h"
+#include "emuld_common.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;
+
+    LOG("clipool_add fd = %d, port = %d, type = %d \n", 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;
+        }
+    }
+
+    LOG("clipool_delete fd = %d\n", fd);
+}
+
+
+Cli* find_cli(const int fd)
+{
+    _auto_mutex _(&mutex_climap);
+
+    CliMap::iterator it = g_climap.find(fd);
+    if (it != g_climap.end())
+        return NULL;
+
+    Cli* cli = it->second;
+    return cli;
+}
+
+// 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)
+        {
+            perror("failed to send to ij\n");
+        }
+
+        LOG("send_len: %d, err= %d\n", 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);;
+}
+
+
+
+
+
index 1296c6ea8dee474f93ee5f04fa09e474d0962eba..b626a876fa3e078105fc0d8440024afbdac1db30 100644 (file)
@@ -1,14 +1,15 @@
-/* -*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-
+/*
  * emulator-daemon
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
+ * Jinhyung Choi <jinhyung2.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
  * 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
  *
  */
 
-/*-----------------------------------------------------------------
-
-epoll server program by Sungmin Ha.
-Platform : Linux 2.6.x (kernel)
-compiler Gcc: 3.4.3. 
-License: GNU General Public License   
-
-------------------------------------------------------------------*/
 #include "emuld_common.h"
 #include "emuld.h"
 #include "synbuf.h"
+#include "pmapi.h"
 
-
+#define PMAPI_RETRY_COUNT       3
 #define MAX_CONNECT_TRY_COUNT   (60 * 3)
 #define SRV_IP "10.0.2.2"
 
@@ -47,41 +41,35 @@ unsigned short vmodem_port = VMODEM_PORT;
 unsigned short sap_port = SAP_PORT;
 unsigned short sensord_port = SENSORD_PORT;
 
-int g_svr_port;                 /* global server port number */
+/* global server port number */
+int g_svr_port;
 
 static int g_vm_connect_status; /* connection status between emuld and vmodem  */
 static int g_sap_connect_status;/* connection status between emuld and sap daemon  */
 
-
 pthread_t tid[MAX_CLIENT + 1];
 
-
 /* udp socket */
 struct sockaddr_in si_sensord_other;
 
-
-
 int g_fd[fdtype_max];
 
-
 typedef std::queue<msg_info*> __msg_queue;
 
 __msg_queue g_msgqueue;
 
-
 int g_epoll_fd;
 
 static pthread_mutex_t mutex_vmconnect = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t mutex_sapconnect = PTHREAD_MUTEX_INITIALIZER;
 
-struct epoll_event g_events[MAX_EVENTS]; 
+struct epoll_event g_events[MAX_EVENTS];
 
 bool exit_flag = false;
-/*--------------------------------------------------------------*/
-/* FUNCTION PART 
- *---------------------------------------------------------------*/
-
 
+/*----------------------------------------------------------------*/
+/* FUNCTION PART                                                  */
+/* ---------------------------------------------------------------*/
 
 void systemcall(const char* param)
 {
@@ -142,10 +130,8 @@ void set_sap_connect_status(const int v)
     g_sap_connect_status = v;
 }
 
-
-
-/*------------------------------------------------------------- 
-function: init_server0 
+/*-------------------------------------------------------------
+function: init_server0
 io: input : integer - server port (must be positive)
 output: none
 desc : tcp/ip listening socket setting with input variable
@@ -195,7 +181,7 @@ bool init_server0(int svr_port, int* ret_fd)
     }
     LOG("[START] Now Server listening on port %d, EMdsockfd: %d"
             ,svr_port, fd);
-    
     /* notify to qemu that emuld is ready */
     emuld_ready();
 
@@ -211,7 +197,7 @@ bool init_server0(int svr_port, int* ret_fd)
 fail:
     close(fd);
     return false;
-} 
+}
 /*------------------------------- end of function init_server0 */
 
 void emuld_ready()
@@ -253,11 +239,12 @@ void emuld_ready()
     fprintf(stderr, "send message to guest server\n");
 
     while(sendto(s, buf, sizeof(buf), 0, (struct sockaddr*)&si_other, slen) == -1)
-    {     
+    {
         fprintf(stderr, "sendto error! retry sendto\n");
         usleep(1000);
     }
     fprintf(stderr, "emuld is ready.\n");
+
     close(s);
 
 }
@@ -265,8 +252,7 @@ void emuld_ready()
 void* init_vm_connect(void* data)
 {
     struct sockaddr_in vm_addr;
-    int ret = -1;   
-    bool is_connected = false;
+    int ret = -1;
 
     set_vm_connect_status(0);
 
@@ -281,7 +267,7 @@ void* init_vm_connect(void* data)
     }
 
     /* Address Setting */
-    memset( &vm_addr , 0 , sizeof(vm_addr)) ;
+    memset( &vm_addr , 0 , sizeof(vm_addr));
 
     vm_addr.sin_family = AF_INET;
     vm_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
@@ -297,10 +283,6 @@ void* init_vm_connect(void* data)
             LOG("connection failed to vmodem! try \n");
             sleep(1);
         }
-        else
-        {
-            is_connected = true;
-        }
     }
 
     epoll_ctl_add(g_fd[fdtype_vmodem]);
@@ -314,7 +296,6 @@ void* init_sap_connect(void* data)
 {
     struct sockaddr_in sap_addr;
     int ret = -1;
-    bool is_connected = false;
 
     set_sap_connect_status(0);
 
@@ -345,10 +326,6 @@ void* init_sap_connect(void* data)
             LOG("connection failed to sap! try \n");
             sleep(1);
         }
-        else
-        {
-            is_connected = true;
-        }
     }
 
     epoll_ctl_add(g_fd[fdtype_sap]);
@@ -358,7 +335,6 @@ void* init_sap_connect(void* data)
     pthread_exit((void *) 0);
 }
 
-
 bool epoll_ctl_add(const int fd)
 {
     struct epoll_event events;
@@ -618,7 +594,7 @@ void recv_from_vmodem(int fd)
     }
 
     LOG("vmodem data length: %d", ijcmd.msg.length);
-    const int tmplen = HEADER_SIZE + ijcmd.msg.length; 
+    const int tmplen = HEADER_SIZE + ijcmd.msg.length;
     char* tmp = (char*) malloc(tmplen);
 
     if (tmp)
@@ -684,7 +660,6 @@ void recv_from_sap(int fd)
     }
 }
 
-
 void recv_from_ij(int fd)
 {
     printf("recv_from_ij\n");
@@ -934,12 +909,24 @@ void end_server(int sig)
     exit(0);
 }
 
+void set_lock_state() {
+    int i = 0;
+    // Now we blocking to enter "SLEEP".
+    while (i < PMAPI_RETRY_COUNT && pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0) == -1) {
+        ++i;
+        sleep(10);
+    }
+    if (i == PMAPI_RETRY_COUNT) {
+        fprintf(stderr, "Emulator Daemon: Failed to call pm_lock_state().\n");
+    }
+}
 
 int main( int argc , char *argv[])
 {
-    int state;
+    int vm_state;
+    int sap_state;
 
-    if(log_print == 1)
+    //if(log_print == 1)
     {
         // for emuld log file
         systemcall("rm /var/log/emuld.log");
@@ -949,13 +936,9 @@ int main( int argc , char *argv[])
     LOG("start");
     /* entry , argument check and process */
     if(argc < 3){
-
         g_svr_port = DEFAULT_PORT;
-
     }else {
-
-        if(strcmp("-port",argv[1]) ==  0 ) {
-
+        if(strcmp("-port", argv[1]) ==  0 ) {
             g_svr_port = atoi(argv[2]);
             if(g_svr_port < 1024) {
                 fprintf(stderr, "[STOP] port number invalid : %d\n",g_svr_port);
@@ -1000,10 +983,10 @@ int main( int argc , char *argv[])
         close(g_epoll_fd);
         exit(0);
     }
-
-
     udp_init();
 
+    set_lock_state();
+
     bool is_exit = false;
 
     while(!is_exit)
@@ -1020,7 +1003,11 @@ int main( int argc , char *argv[])
         LOG("vmodem thread end %d\n", status);
     }
 
-    state = pthread_mutex_destroy(&mutex_vmconnect);
+    vm_state = pthread_mutex_destroy(&mutex_vmconnect);
+    if (vm_state != 0)
+    {
+        LOG("mutex_vmconnect is failed to destroy.");
+    }
 
     if (!is_sap_connected())
     {
@@ -1029,7 +1016,11 @@ int main( int argc , char *argv[])
         LOG("sap thread end %d\n", status);
     }
 
-    state = pthread_mutex_destroy(&mutex_sapconnect);
+    sap_state = pthread_mutex_destroy(&mutex_sapconnect);
+    if (sap_state != 0)
+    {
+        LOG("mutex_vmconnect is failed to destroy.");
+    }
 
     stop_listen();
 
index aff8eb35bdd65a4dd2405f8244e23a60dc8aa000..5db50c814b71be895c31dc855c587151801ef128 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * 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
+ *
+ */
+
 /*
  * emuld_proc.cpp
  *
 #include <stdlib.h>
 #include <mntent.h>
 
-
 char SDpath[256];
 static struct timeval tv_start_poweroff;
 
-
 struct setting_device_param
 {
     setting_device_param() : get_status_sockfd(-1), ActionID(0), is_evdi(false)
@@ -39,8 +66,6 @@ struct mount_param
     bool is_evdi;
 };
 
-
-
 char* get_mount_info() {
     struct mntent *ent;
     FILE *aFile;
@@ -168,7 +193,7 @@ void* mount_sdcard(void* data)
             //
 
             if (ret == 0) {
-                //ret = system("/usr/bin/sys_event mmcblk_add");    // sdcard is not supported
+                ret = system("/usr/bin/sys_event mmcblk_add");
             }
 
             break;
@@ -250,7 +275,7 @@ int umount_sdcard(const int fd, bool is_evdi)
 
             memset(SDpath, '\0', sizeof(SDpath));
             sprintf(SDpath, "umounted");
-            //ret = system("/usr/bin/sys_event mmcblk_remove"); // sdcard is not supported
+            ret = system("/usr/bin/sys_event mmcblk_remove");
 
             break;
         }
@@ -588,7 +613,7 @@ bool msgproc_sensor(const int sockfd, ijcommand* ijcmd, const bool is_evdi)
         if (!param)
             return false;
 
-        memset(param, 0, sizeof(param));
+        memset(param, 0, sizeof(*param));
 
         param->get_status_sockfd = sockfd;
         param->ActionID = ijcmd->msg.action;
@@ -692,8 +717,6 @@ bool msgproc_system(const int sockfd, ijcommand* ijcmd, const bool is_evdi)
     return true;
 }
 
-
-
 bool msgproc_sdcard(const int sockfd, ijcommand* ijcmd, const bool is_evdi)
 {
     LOG("msgproc_sdcard\n");
@@ -846,7 +869,6 @@ bool msgproc_sdcard(const int sockfd, ijcommand* ijcmd, const bool is_evdi)
     return true;
 }
 
-
 //sdcard event
 void send_guest_server(char* databuf)
 {
index c92134add319856c59ca680ebe0ad4d630a89e7d..f520b77fdb58dabc2c18618bdd3902a59c110346 100644 (file)
-/*\r
- * evdi.cpp\r
- *\r
- *  Created on: 2013. 4. 15.\r
- *      Author: dykim\r
- */\r
-\r
-#include "evdi.h"\r
-#include "emuld.h"\r
-\r
-#define DEVICE_NODE_PATH       "/dev/evdi0"\r
-\r
-\r
-static pthread_mutex_t mutex_evdi = PTHREAD_MUTEX_INITIALIZER;\r
-\r
-\r
-evdi_fd open_device(void)\r
-{\r
-       evdi_fd fd;\r
-\r
-       fd = open(DEVICE_NODE_PATH, O_RDWR); //O_CREAT|O_WRONLY|O_TRUNC.\r
-       printf("evdi open fd is %d", fd);\r
-\r
-       if (fd <= 0) {\r
-               printf("open %s fail", DEVICE_NODE_PATH);\r
-               return fd;\r
-       }\r
-\r
-       return fd;\r
-}\r
-\r
-\r
-bool set_nonblocking(evdi_fd fd)\r
-{\r
-    int opts;\r
-    opts= fcntl(fd, F_GETFL);\r
-    if (opts < 0)\r
-    {\r
-        perror("fcntl failed\n");\r
-        return false;\r
-    }\r
-    opts = opts | O_NONBLOCK;\r
-    if (fcntl(fd, F_SETFL, opts) < 0)\r
-    {\r
-        perror("fcntl failed\n");\r
-        return false;\r
-    }\r
-    return true;\r
-}\r
-\r
-\r
-bool init_device(evdi_fd* ret_fd)\r
-{\r
-       evdi_fd fd;\r
-\r
-       *ret_fd = -1;\r
-\r
-       fd = open_device();\r
-       if (fd <= 0)\r
-               return false;\r
-\r
-       if (!set_nonblocking(fd))\r
-       {\r
-               close(fd);\r
-               return false;\r
-       }\r
-\r
-       if (!epoll_ctl_add(fd))\r
-       {\r
-               fprintf(stderr, "Epoll control fails.\n");\r
-               close(fd);\r
-               return false;\r
-       }\r
-\r
-       *ret_fd = fd;\r
-\r
-       return true;\r
-}\r
-\r
-\r
-bool send_to_evdi(evdi_fd fd, const char* data, const int len)\r
-{\r
-       printf("send to evdi client, len = %d\n", len);\r
-       int ret;\r
-\r
-       ret = write(fd, data, len);\r
-\r
-       printf("written bytes = %d\n", ret);\r
-\r
-       if (ret == -1)\r
-               return false;\r
-       return true;\r
-}\r
-\r
-bool ijmsg_send_to_evdi(evdi_fd fd, const char* cat, const char* data, const int len)\r
-{\r
-       _auto_mutex _(&mutex_evdi);\r
-\r
-       LOG("ijmsg_send_to_evdi\n");\r
-\r
-       if (fd == -1)\r
-               return false;\r
-\r
-       char tmp[ID_SIZE];\r
-       memset(tmp, 0, ID_SIZE);\r
-       strncpy(tmp, cat, 10);\r
-\r
-       // TODO: need to make fragmented transmission\r
-       if (len + ID_SIZE > __MAX_BUF_SIZE) {\r
-               LOG("evdi message len is too large\n");\r
-               return false;\r
-       }\r
-\r
-       msg_info _msg;\r
-       memset(_msg.buf, 0, __MAX_BUF_SIZE);\r
-       memcpy(_msg.buf, tmp, ID_SIZE);\r
-       memcpy(_msg.buf + ID_SIZE, data, len);\r
-\r
-       _msg.route = route_control_server;\r
-       _msg.use = len + ID_SIZE;\r
-       _msg.count = 1;\r
-       _msg.index = 0;\r
-       _msg.cclisn = 0;\r
-\r
-       LOG("ijmsg_send_to_evdi - %s", _msg.buf);\r
-\r
-       if (!send_to_evdi(fd, (char*) &_msg, sizeof(_msg)))\r
-               return false;\r
-\r
-       return true;\r
-}\r
-\r
-bool msg_send_to_evdi(evdi_fd fd, const char* data, const int len)\r
-{\r
-       _auto_mutex _(&mutex_evdi);\r
-\r
-       // TODO: need to make fragmented transmission\r
-       if (len > __MAX_BUF_SIZE)\r
-       {\r
-               LOG("evdi message len is too large\n");\r
-               return false;\r
-       }\r
-\r
-       msg_info _msg;\r
-       memset(_msg.buf, 0, __MAX_BUF_SIZE);\r
-       memcpy(_msg.buf, data, len);\r
-\r
-       _msg.route = route_control_server;\r
-       _msg.use = len;\r
-       _msg.count = 1;\r
-       _msg.index = 0;\r
-       _msg.cclisn = 0;\r
-\r
-       LOG("msg_send_to_evdi - %s", _msg.buf);\r
-\r
-       if (!send_to_evdi(fd, (char*)&_msg, sizeof(_msg)))\r
-               return false;\r
-\r
-       return true;\r
-}\r
-\r
-\r
-\r
-\r
+/*
+ * 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 "evdi.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.
+    printf("evdi open fd is %d", fd);
+
+    if (fd <= 0) {
+        printf("open %s fail", DEVICE_NODE_PATH);
+        return fd;
+    }
+
+    return fd;
+}
+
+bool set_nonblocking(evdi_fd fd)
+{
+    int opts;
+    opts= fcntl(fd, F_GETFL);
+    if (opts < 0)
+    {
+        perror("fcntl failed\n");
+        return false;
+    }
+    opts = opts | O_NONBLOCK;
+    if (fcntl(fd, F_SETFL, opts) < 0)
+    {
+        perror("fcntl failed\n");
+        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))
+    {
+        fprintf(stderr, "Epoll control fails.\n");
+        close(fd);
+        return false;
+    }
+
+    *ret_fd = fd;
+
+    return true;
+}
+
+bool send_to_evdi(evdi_fd fd, const char* data, const int len)
+{
+    printf("send to evdi client, len = %d\n", len);
+    int ret;
+
+    ret = write(fd, data, len);
+
+    printf("written bytes = %d\n", 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);
+
+    LOG("ijmsg_send_to_evdi\n");
+
+    if (fd == -1)
+        return false;
+
+    char tmp[ID_SIZE];
+    memset(tmp, 0, ID_SIZE);
+    strncpy(tmp, cat, 10);
+
+    // TODO: need to make fragmented transmission
+    if (len + ID_SIZE > __MAX_BUF_SIZE) {
+        LOG("evdi message len is too large\n");
+        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;
+
+    LOG("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)
+    {
+        LOG("evdi message len is too large\n");
+        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;
+
+    LOG("msg_send_to_evdi - %s", _msg.buf);
+
+    if (!send_to_evdi(fd, (char*)&_msg, sizeof(_msg)))
+        return false;
+
+    return true;
+}
+
index 6c75ed1d24a70a47314167ecd8de9a634f345f9e..934192724a9eb12684ad5c47f5411b0ebe47e27d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * emulator-daemon
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
  * SooYoung Ha <yoosah.ha@samsnung.com>
 
 static int inline get_message(char* message, int status, int buf_len, bool is_evdi)
 {
-       if (is_evdi) {
-               sprintf(message, "%d", status);
-               return strlen(message);
-       } else {
-               // int to byte
-               message[3] = (char) (status & 0xff);
-               message[2] = (char) (status >> 8 & 0xff);
-               message[1] = (char) (status >> 16 & 0xff);
-               message[0] = (char) (status >> 24 & 0xff);
-               message[4] = '\0';
-       }
-
-       return 4;       
+    if (is_evdi) {
+        sprintf(message, "%d", status);
+        return strlen(message);
+    } else {
+        // int to byte
+        message[3] = (char) (status & 0xff);
+        message[2] = (char) (status >> 8 & 0xff);
+        message[1] = (char) (status >> 16 & 0xff);
+        message[0] = (char) (status >> 24 & 0xff);
+        message[4] = '\0';
+    }
+
+    return 4;
 }
 
 static int inline get_status(const char* filename)
 {
-       int ret;
-       int status = 0;
-       FILE* fd = fopen(filename, "r");
-       if(!fd)
-               return -1;
-
-       ret = fscanf(fd, "%d", &status);
-       fclose(fd);
-       
-       if (ret < 0) {
-               return ret;
-       }
-
-       return status;
+    int ret;
+    int status = 0;
+    FILE* fd = fopen(filename, "r");
+    if(!fd)
+        return -1;
+
+    ret = fscanf(fd, "%d", &status);
+    fclose(fd);
+
+    if (ret < 0) {
+        return ret;
+    }
+
+    return status;
 }
 
 static int inline get_file_status(char* msg, const char* filename, int buf_len, bool is_evdi)
 {
-       int status = get_status(filename);
-       if (status < 0)
-               return status;
-       return get_message(msg, status, buf_len, is_evdi);
+    int status = get_status(filename);
+    if (status < 0)
+        return status;
+    return get_message(msg, status, buf_len, is_evdi);
 }
 
 static int inline get_vconf_status(char* msg, const char* key, int buf_len, bool is_evdi)
 {
-       int status;
-       int ret = vconf_get_int(key, &status);
-       if (ret != 0) {
-               //LOG("cannot get vconf key - %s", key);
-               return -1;
-       }
-
-       return get_message(msg, status, buf_len, is_evdi);
+    int status;
+    int ret = vconf_get_int(key, &status);
+    if (ret != 0) {
+        //LOG("cannot get vconf key - %s", key);
+        return -1;
+    }
+
+    return get_message(msg, status, buf_len, is_evdi);
 }
 
 char* __tmpalloc(const int size)
 {
-       char* message = (char*)malloc(sizeof(char) * size);
-       memset(message, 0, sizeof(char) * size);
-       return message;
+    char* message = (char*)malloc(sizeof(char) * size);
+    memset(message, 0, sizeof(char) * size);
+    return message;
 }
 
 char* get_usb_status(void* p, bool is_evdi)
 {
-       char* message = __tmpalloc(5);
-       int length = get_file_status(message, "/sys/devices/platform/jack/usb_online", 5, is_evdi);
-       if (length < 0){
-               //LOG("get usb status error - %d", length);
-               length = 0;
-       }
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = length;
-       packet->group  = STATUS;
-       packet->action = USB_STATUS;
-
-       return message;
+    char* message = __tmpalloc(5);
+    int length = get_file_status(message, "/sys/devices/platform/jack/usb_online", 5, is_evdi);
+    if (length < 0){
+        //LOG("get usb status error - %d", length);
+        length = 0;
+    }
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = length;
+    packet->group  = STATUS;
+    packet->action = USB_STATUS;
+
+    return message;
 }
 
 char* get_earjack_status(void* p, bool is_evdi)
 {
-       char* message = __tmpalloc(5);
-       int length = get_file_status(message, "/sys/devices/platform/jack/earjack_online", 5, is_evdi);
-       if (length < 0){
-               return 0;
-       }
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = length;
-       packet->group  = STATUS;
-       packet->action = EARJACK_STATUS;
-
-       return message;
+    char* message = __tmpalloc(5);
+    int length = get_file_status(message, "/sys/devices/platform/jack/earjack_online", 5, is_evdi);
+    if (length < 0){
+        return 0;
+    }
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = length;
+    packet->group  = STATUS;
+    packet->action = EARJACK_STATUS;
+
+    return message;
 }
 
 char* get_rssi_level(void* p, bool is_evdi)
 {
-       char* message = __tmpalloc(5);
-       int length = get_vconf_status(message, "memory/telephony/rssi", 5, is_evdi);
-       if (length < 0){
-               return 0;
-       }
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = length;
-       packet->group  = STATUS;
-       packet->action = RSSI_LEVEL;
-
-       return message;
+    char* message = __tmpalloc(5);
+    int length = get_vconf_status(message, "memory/telephony/rssi", 5, is_evdi);
+    if (length < 0){
+        return 0;
+    }
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = length;
+    packet->group  = STATUS;
+    packet->action = RSSI_LEVEL;
+
+    return message;
 }
 
 char* get_battery_level(void* p, bool is_evdi)
 {
-       char* message = __tmpalloc(5);
-       int length = get_file_status(message, "/sys/class/power_supply/battery/capacity", 5, is_evdi);
-       if (length < 0){
-               return 0;
-       }
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = length;
-       packet->group  = STATUS;
-       packet->action = BATTERY_LEVEL;
-
-       return message;
+    char* message = __tmpalloc(5);
+    int length = get_file_status(message, "/sys/class/power_supply/battery/capacity", 5, is_evdi);
+    if (length < 0){
+        return 0;
+    }
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = length;
+    packet->group  = STATUS;
+    packet->action = BATTERY_LEVEL;
+
+    return message;
 }
 
 char* get_battery_charger(void* p, bool is_evdi)
 {
-       char* message = __tmpalloc(5);
-       int length = get_file_status(message, "/sys/class/power_supply/battery/charge_now", 5, is_evdi);
-       if (length < 0){
-               return 0;
-       }
-       
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = length;
-       packet->group  = STATUS;
-       packet->action = BATTERY_CHARGER;
-
-       return message;
+    char* message = __tmpalloc(5);
+    int length = get_file_status(message, "/sys/class/power_supply/battery/charge_now", 5, is_evdi);
+    if (length < 0){
+        return 0;
+    }
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = length;
+    packet->group  = STATUS;
+    packet->action = BATTERY_CHARGER;
+
+    return message;
 }
 
 char* get_proximity_status(void* p, bool is_evdi)
 {
-       char* message = __tmpalloc(5);
-       int length = get_file_status(message, PATH_SENSOR_PROXI_VO, 5, is_evdi);
-       if (length < 0){
-               return 0;
-       }
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = length;
-       packet->group  = STATUS;
-       packet->action = PROXI_VALUE;
-
-       return message;
+    char* message = __tmpalloc(5);
+    int length = get_file_status(message, PATH_SENSOR_PROXI_VO, 5, is_evdi);
+    if (length < 0){
+        return 0;
+    }
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = length;
+    packet->group  = STATUS;
+    packet->action = PROXI_VALUE;
+
+    return message;
 }
 
 char* get_light_level(void* p, bool is_evdi)
 {
-       char* message = __tmpalloc(6);
-       int length = get_file_status(message, PATH_SENSOR_LIGHT_ADC, 6, is_evdi);
-       if (length < 0){
-               return 0;
-       }
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = length;
-       packet->group  = STATUS;
-       packet->action = LIGHT_VALUE;
-
-       return message;
+    char* message = __tmpalloc(6);
+    int length = get_file_status(message, PATH_SENSOR_LIGHT_ADC, 6, is_evdi);
+    if (length < 0){
+        return 0;
+    }
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = length;
+    packet->group  = STATUS;
+    packet->action = LIGHT_VALUE;
+
+    return message;
 }
 
 char* get_acceleration_value(void* p, bool is_evdi)
 {
-       FILE* fd = fopen(PATH_SENSOR_ACCEL_XYZ, "r");
-       if(!fd)
-       {
-               return 0;
-       }
+    FILE* fd = fopen(PATH_SENSOR_ACCEL_XYZ, "r");
+    if(!fd)
+    {
+        return 0;
+    }
 
-       char* message = __tmpalloc(128);
+    char* message = __tmpalloc(128);
 
-       //fscanf(fd, "%d, %d, %d", message);
-       if (!fgets(message, 128, fd))
-               fprintf(stderr, "fgets failure");
+    //fscanf(fd, "%d, %d, %d", message);
+    if (!fgets(message, 128, fd))
+        fprintf(stderr, "fgets failure");
 
-       fclose(fd);
+    fclose(fd);
 
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = strlen(message);
-       packet->group  = STATUS;
-       packet->action = ACCEL_VALUE;
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = strlen(message);
+    packet->group  = STATUS;
+    packet->action = ACCEL_VALUE;
 
-       return message;
+    return message;
 }
 
 char* get_gyroscope_value(void* p, bool is_evdi)
 {
-       int x, y, z;
-       int ret;
-
-       FILE* fd = fopen(PATH_SENSOR_GYRO_X_RAW, "r");
-       if(!fd)
-       {
-               return 0;
-       }
-       ret = fscanf(fd, "%d", &x);
-       fclose(fd);
-
-       fd = fopen(PATH_SENSOR_GYRO_Y_RAW, "r");
-       if(!fd)
-       {
-               return 0;
-       }
-       ret = fscanf(fd, "%d", &y);
-       fclose(fd);
-
-       fd = fopen(PATH_SENSOR_GYRO_Z_RAW, "r");
-       if(!fd)
-       {
-               return 0;
-       }
-       ret = fscanf(fd, "%d", &z);
-       fclose(fd);
-
-       char* message = __tmpalloc(128);
-
-       ret = sprintf(message, "%d, %d, %d", x, y, z);
-       if (ret < 0) {
-               free(message);
-               message = 0;
-               return 0;
-       }
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = strlen(message);
-       packet->group  = STATUS;
-       packet->action = GYRO_VALUE;
-
-       return message;
+    int x, y, z;
+    int ret;
+
+    FILE* fd = fopen(PATH_SENSOR_GYRO_X_RAW, "r");
+    if(!fd)
+    {
+        return 0;
+    }
+    ret = fscanf(fd, "%d", &x);
+    fclose(fd);
+
+    fd = fopen(PATH_SENSOR_GYRO_Y_RAW, "r");
+    if(!fd)
+    {
+        return 0;
+    }
+    ret = fscanf(fd, "%d", &y);
+    fclose(fd);
+
+    fd = fopen(PATH_SENSOR_GYRO_Z_RAW, "r");
+    if(!fd)
+    {
+        return 0;
+    }
+    ret = fscanf(fd, "%d", &z);
+    fclose(fd);
+
+    char* message = __tmpalloc(128);
+
+    ret = sprintf(message, "%d, %d, %d", x, y, z);
+    if (ret < 0) {
+        free(message);
+        message = 0;
+        return 0;
+    }
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = strlen(message);
+    packet->group  = STATUS;
+    packet->action = GYRO_VALUE;
+
+    return message;
 }
 
 char* get_magnetic_value(void* p, bool is_evdi)
 {
-       FILE* fd = fopen(PATH_SENSOR_GEO_TESLA, "r");
-       if(!fd)
-       {
-               return 0;
-       }
-
-       char* message = __tmpalloc(128);
-       if (!fgets(message, 128, fd))
-       {
-               fprintf(stderr, "fgets failure");
-       }
-       fclose(fd);
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = strlen(message);
-       packet->group  = STATUS;
-       packet->action = MAG_VALUE;
-       return message;
+    FILE* fd = fopen(PATH_SENSOR_GEO_TESLA, "r");
+    if(!fd)
+    {
+        return 0;
+    }
+
+    char* message = __tmpalloc(128);
+    if (!fgets(message, 128, fd))
+    {
+        fprintf(stderr, "fgets failure");
+    }
+    fclose(fd);
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = strlen(message);
+    packet->group  = STATUS;
+    packet->action = MAG_VALUE;
+    return message;
 }
 
 char* get_location_status(void* p, bool is_evdi)
 {
-       int mode;
-       int ret = vconf_get_int("db/location/replay/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("db/location/replay/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;
-               ret = vconf_get_dbl("db/location/replay/ManualLatitude", &latitude);
-               if (ret != 0) {
-                       return 0;
-               }
-               ret = vconf_get_dbl("db/location/replay/ManualLongitude", &logitude);
-               if (ret != 0) {
-                       return 0;
-               }
-               message = (char*)malloc(128);
-               memset(message, 0, 128);
-               ret = sprintf(message, "%d,%f,%f", mode, latitude, logitude);
-               if (ret < 0) {
-                       free(message);
-                       message = 0;
-                       return 0;
-               }
-       }
-
-       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;
+    int mode;
+    int ret = vconf_get_int("db/location/replay/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("db/location/replay/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;
+        ret = vconf_get_dbl("db/location/replay/ManualLatitude", &latitude);
+        if (ret != 0) {
+            return 0;
+        }
+        ret = vconf_get_dbl("db/location/replay/ManualLongitude", &logitude);
+        if (ret != 0) {
+            return 0;
+        }
+        message = (char*)malloc(128);
+        memset(message, 0, 128);
+        ret = sprintf(message, "%d,%f,%f", mode, latitude, logitude);
+        if (ret < 0) {
+            free(message);
+            message = 0;
+            return 0;
+        }
+    }
+
+    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;
 }
 
 char* get_nfc_status(void* p, bool is_evdi)
 {
-       int ret;
-       FILE* fd = fopen(PATH_NFC_DATA, "r");
-       if(!fd)
-       {
-               return 0;
-       }
-
-       char* message = __tmpalloc(5000);
-       ret = fscanf(fd, "%s\n", message);
-       fclose(fd);
-
-       LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-       memset(packet, 0, sizeof(LXT_MESSAGE));
-       packet->length = strlen(message);
-       packet->group  = STATUS;
-       packet->action = NFC_STATUS;
-
-       return message;
+    int ret;
+    FILE* fd = fopen(PATH_NFC_DATA, "r");
+    if(!fd)
+    {
+        return 0;
+    }
+
+    char* message = __tmpalloc(5000);
+    ret = fscanf(fd, "%s\n", message);
+    if (ret < 0)
+    {
+        return 0;
+    }
+    fclose(fd);
+
+    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+    memset(packet, 0, sizeof(LXT_MESSAGE));
+    packet->length = strlen(message);
+    packet->group  = STATUS;
+    packet->action = NFC_STATUS;
+
+    return message;
 }
 
 
index 5391d883c5d826420c08e289ebb5801bf5efdd37..029b9b00b1f6200101852c37f4f77ff4f5f13a51 100644 (file)
@@ -1,3 +1,31 @@
+/*
+ * 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 <stdio.h>
 #include <stdlib.h>
 
 struct emuld_log
 {
-       emuld_log()
-       {
-               m_isLogout = false;
-
-               char* buf = getenv("EMULD_LOG");
-               if (buf != NULL) {
-                       fprintf(stdout, "env EMULD_LOG is set => print logs \n");
-                       m_isLogout = true;
-               }
-       }
-
-       void out_v(const char *fmt, ...)
-       {
-               if (m_isLogout)
-               {
-                       char buf[4096];
-                       va_list ap;
-
-                       va_start(ap, fmt);
-                       vsnprintf(buf, sizeof(buf), fmt, ap);
-                       va_end(ap);
-
-                       fprintf(stdout, "%s", buf);
-                       FILE* log_fd = fopen("/var/log/emuld.log", "a");
-                       fprintf(log_fd, "%s", buf);
-                       fclose(log_fd);
-               }
-       }
-
-       void out(const char* outbuf)
-               {
-                       if (!m_isLogout)
-                               return;
-
-                       char timestr[512];
-                       make_timestamp(timestr);
-                       fprintf(stdout, "%s - %s", timestr, outbuf);
-                       FILE* log_fd = fopen("/var/log/emuld.log", "a");
-                       fprintf(log_fd, "%s - %s", timestr, outbuf);
-                       fclose(log_fd);
-               }
-
-       bool m_isLogout;
+    emuld_log()
+    {
+        m_isLogout = false;
+
+        char* buf = getenv("EMULD_LOG");
+        if (buf != NULL) {
+            fprintf(stdout, "env EMULD_LOG is set => print logs \n");
+            m_isLogout = true;
+        }
+    }
+
+    void out_v(const char *fmt, ...)
+    {
+        if (m_isLogout)
+        {
+            char buf[4096];
+            va_list ap;
+
+            va_start(ap, fmt);
+            vsnprintf(buf, sizeof(buf), fmt, ap);
+            va_end(ap);
+
+            fprintf(stdout, "%s", buf);
+            FILE* log_fd = fopen("/var/log/emuld.log", "a");
+            fprintf(log_fd, "%s", buf);
+            fclose(log_fd);
+        }
+    }
+
+    void out(const char* outbuf)
+        {
+            if (!m_isLogout)
+                return;
+
+            char timestr[512];
+            make_timestamp(timestr);
+            fprintf(stdout, "%s - %s", timestr, outbuf);
+            FILE* log_fd = fopen("/var/log/emuld.log", "a");
+            fprintf(log_fd, "%s - %s", timestr, outbuf);
+            fclose(log_fd);
+        }
+
+    bool m_isLogout;
 };
 
 
@@ -62,17 +90,17 @@ void log_print_out(const char *fmt, ...)
 
 #ifdef EMD_DEBUG
 
-       char buf[4096];
-       va_list ap;
+    char buf[4096];
+    va_list ap;
 
-       va_start(ap, fmt);
-       vsnprintf(buf, sizeof(buf), fmt, ap);
-       va_end(ap);
+    va_start(ap, fmt);
+    vsnprintf(buf, sizeof(buf), fmt, ap);
+    va_end(ap);
 
-       g_log.out(buf);
+    g_log.out(buf);
 #endif
 
-       return;
+    return;
 }
 
 void make_timestamp(char* ret)