communication: added ECS_SERVER_STARTED protocol
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 10 Sep 2013 10:38:14 +0000 (19:38 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 10 Sep 2013 10:38:14 +0000 (19:38 +0900)
Change-Id: I5c1ad9b39d4b3fc104bf7fac8f087e7cc6ab4953
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java
tizen/src/skin/maruskin_server.c
tizen/src/skin/maruskin_server.h

index 61cc8c4..e051dd9 100644 (file)
@@ -194,16 +194,16 @@ public interface ICommunicator extends Runnable {
                        return this.id;
                }
                
-               public static RotationInfo getValue( short id ) {
+               public static RotationInfo getValue(short id) {
                        RotationInfo[] values = RotationInfo.values();
                        for (int i = 0; i < values.length; i++) {
-                               if( values[i].id == id ) {
+                               if (values[i].id == id) {
                                        return values[i];
                                }
                        }
-                       throw new IllegalArgumentException( Integer.toString(id) );
-               }
 
+                       throw new IllegalArgumentException(Integer.toString(id));
+               }
        }
 
        public enum SendCommand {
@@ -270,6 +270,7 @@ public interface ICommunicator extends Runnable {
                ECP_PORT((short) 7),
                SENSOR_DAEMON_START((short) 800),
                SDB_DAEMON_START((short) 801),
+               ECS_SERVER_START((short) 802),
                DRAW_FRAME((short) 900),
                DRAW_BLANK_GUIDE((short) 901),
                SHUTDOWN((short) 999);
index 6234d5d..5fc9230 100755 (executable)
@@ -65,7 +65,6 @@ import org.tizen.emulator.skin.util.SkinUtil;
  */
 public class SocketCommunicator implements ICommunicator {
        public class DataTranfer {
-
                private boolean isTransferState;
                private byte[] receivedData;
 
@@ -112,6 +111,7 @@ public class SocketCommunicator implements ICommunicator {
        private boolean isTerminated;
        private boolean isSensorDaemonStarted;
        private boolean isSdbDaemonStarted;
+       private boolean isEcsServerStarted;
        private boolean isRamdump;
        private TimerTask heartbeatExecutor;
        private Timer heartbeatTimer;
@@ -180,38 +180,32 @@ public class SocketCommunicator implements ICommunicator {
 
        @Override
        public void run() {
-
                sendQueue = new LinkedList<SkinSendData>();
 
                sendThread = new Thread("sendThread") {
-
                        List<SkinSendData> list = new ArrayList<SkinSendData>();
 
                        @Override
                        public void run() {
-
-                               while ( true ) {
-
-                                       synchronized ( sendQueue ) {
-
-                                               if ( sendQueue.isEmpty() ) {
+                               while (true) {
+                                       synchronized (sendQueue) {
+                                               if (sendQueue.isEmpty()) {
                                                        try {
                                                                sendQueue.wait();
-                                                       } catch ( InterruptedException e ) {
-                                                               logger.log( Level.SEVERE, e.getMessage(), e );
+                                                       } catch (InterruptedException e) {
+                                                               logger.log(Level.SEVERE, e.getMessage(), e);
                                                        }
                                                }
 
                                                SkinSendData sendData = null;
-                                               while ( true ) {
+                                               while (true) {
                                                        sendData = sendQueue.poll();
-                                                       if ( null != sendData ) {
-                                                               list.add( sendData );
+                                                       if (null != sendData) {
+                                                               list.add(sendData);
                                                        } else {
                                                                break;
                                                        }
                                                }
-
                                        }
 
                                        if (isTerminated) {
@@ -219,13 +213,12 @@ public class SocketCommunicator implements ICommunicator {
                                                break;
                                        }
 
-                                       for ( SkinSendData data : list ) {
-                                               sendToQEMUInternal( data );
+                                       for (SkinSendData data : list) {
+                                               sendToQEMUInternal(data);
                                        }
 
                                        list.clear();
                                }
-
                        }
                };
 
@@ -412,6 +405,14 @@ public class SocketCommunicator implements ICommunicator {
                                        }
                                        break;
                                }
+                               case ECS_SERVER_START: {
+                                       logger.info("received ECS_SERVER_START from QEMU.");
+
+                                       synchronized (this) {
+                                               isEcsServerStarted = true;
+                                       }
+                                       break;
+                               }
                                case DRAW_FRAME: {
                                        //logger.info("received DRAW_FRAME from QEMU.");
 
index 74d4a49..15f435b 100644 (file)
@@ -133,6 +133,7 @@ enum {
     SEND_ECP_PORT = 7,
     SEND_SENSOR_DAEMON_START = 800,
     SEND_SDB_DAEMON_START = 801,
+    SEND_ECS_SERVER_START = 802,
     SEND_DRAW_FRAME = 900,
     SEND_DRAW_BLANK_GUIDE = 901,
     SEND_SHUTDOWN = 999,
@@ -147,6 +148,7 @@ static int client_sock = 0;
 static int stop_server = 0;
 static int is_sensord_initialized = 0;
 static int is_sdbd_initialized = 0;
+static int is_ecs_initialized = 0;
 static int ready_server = 0;
 static int ignore_heartbeat = 0;
 static int is_force_close_client = 0;
@@ -322,6 +324,22 @@ void notify_draw_blank_guide(void)
     }
 }
 
+void notify_ecs_server_start(void)
+{
+    INFO("notify_ecs_server_start\n");
+
+    is_ecs_initialized = 1;
+    if (client_sock) {
+        if (0 > send_skin_header_only(
+            client_sock, SEND_ECS_SERVER_START, 1)) {
+
+            ERR("fail to send SEND_ECS_SERVER_START to skin.\n");
+        }
+    } else {
+        INFO("skin client socket is not connected yet\n");
+    }
+}
+
 void notify_sdb_daemon_start(void)
 {
     INFO("notify_sdb_daemon_start\n");
@@ -333,6 +351,8 @@ void notify_sdb_daemon_start(void)
 
             ERR("fail to send SEND_SDB_DAEMON_START to skin.\n");
         }
+    } else {
+        INFO("skin client socket is not connected yet\n");
     }
 }
 
@@ -347,6 +367,8 @@ void notify_sensor_daemon_start(void)
 
             ERR("fail to send SEND_SENSOR_DAEMON_START to skin.\n");
         }
+    } else {
+        INFO("skin client socket is not connected yet\n");
     }
 }
 
index 428ff74..76e3d60 100644 (file)
@@ -39,6 +39,7 @@ void notify_draw_frame(void);
 void notify_draw_blank_guide(void);
 void notify_sensor_daemon_start(void);
 void notify_sdb_daemon_start(void);
+void notify_ecs_server_start(void);
 void notify_ramdump_completed(void);
 void notify_booting_progress(int progress_value);
 void notify_brightness(bool on);