skin: added protocol of booting progress
authorgiwoong.kim <giwoong.kim@samsung.com>
Wed, 12 Dec 2012 05:58:21 +0000 (14:58 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Wed, 12 Dec 2012 05:58:21 +0000 (14:58 +0900)
Emulator can notify the booting progress to skin.

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/client/src/org/tizen/emulator/skin/window/CustomProgressBar.java
tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_server.c [changed mode: 0755->0644]
tizen/src/skin/maruskin_server.h

index f57edc790b630dfd7a1a2bb339f59d5a92a81442..22cc55d49ba8239b677dad4c44646ed931819beb 100644 (file)
@@ -64,9 +64,11 @@ public interface ICommunicator extends Runnable {
                MouseButtonType( short value ) {
                        this.value = value;
                }
+
                public short value() {
                        return this.value;
                }
+
                public static MouseButtonType getValue( String val ) {
                        MouseButtonType[] values = MouseButtonType.values();
                        for (int i = 0; i < values.length; i++) {
@@ -76,6 +78,7 @@ public interface ICommunicator extends Runnable {
                        }
                        throw new IllegalArgumentException( val );
                }
+
                public static MouseButtonType getValue( short val ) {
                        MouseButtonType[] values = MouseButtonType.values();
                        for (int i = 0; i < values.length; i++) {
@@ -99,9 +102,11 @@ public interface ICommunicator extends Runnable {
                MouseEventType( short value ) {
                        this.value = value;
                }
+
                public short value() {
                        return this.value;
                }
+
                public static MouseEventType getValue( String val ) {
                        MouseEventType[] values = MouseEventType.values();
                        for (int i = 0; i < values.length; i++) {
@@ -111,6 +116,7 @@ public interface ICommunicator extends Runnable {
                        }
                        throw new IllegalArgumentException( val );
                }
+
                public static MouseEventType getValue( short val ) {
                        MouseEventType[] values = MouseEventType.values();
                        for (int i = 0; i < values.length; i++) {
@@ -131,9 +137,11 @@ public interface ICommunicator extends Runnable {
                KeyEventType( short value ) {
                        this.value = value;
                }
+
                public short value() {
                        return this.value;
                }
+
                public static KeyEventType getValue( String val ) {
                        KeyEventType[] values = KeyEventType.values();
                        for (int i = 0; i < values.length; i++) {
@@ -143,6 +151,7 @@ public interface ICommunicator extends Runnable {
                        }
                        throw new IllegalArgumentException( val );
                }
+
                public static KeyEventType getValue( short val ) {
                        KeyEventType[] values = KeyEventType.values();
                        for (int i = 0; i < values.length; i++) {
@@ -171,12 +180,15 @@ public interface ICommunicator extends Runnable {
                        this.id = id;
                        this.angle = ratio;
                }
+
                public String value() {
                        return this.value;
                }
+
                public int angle() {
                        return this.angle;
                }
+
                public short id() {
                        return this.id;
                }
@@ -194,7 +206,8 @@ public interface ICommunicator extends Runnable {
        }
 
        public enum SendCommand {
-               
+               /* This values must match the QEMU definitions */
+
                SEND_START( (short)1 ),
                
                SEND_MOUSE_EVENT( (short)10 ),
@@ -216,9 +229,11 @@ public interface ICommunicator extends Runnable {
                SendCommand( short value ) {
                        this.value = value;
                }
+
                public short value() {
                        return this.value;
                }
+
                public static SendCommand getValue( String val ) {
                        SendCommand[] values = SendCommand.values();
                        for (int i = 0; i < values.length; i++) {
@@ -228,6 +243,7 @@ public interface ICommunicator extends Runnable {
                        }
                        throw new IllegalArgumentException( val );
                }
+
                public static SendCommand getValue( short val ) {
                        SendCommand[] values = SendCommand.values();
                        for (int i = 0; i < values.length; i++) {
@@ -240,21 +256,25 @@ public interface ICommunicator extends Runnable {
        }
 
        public enum ReceiveCommand {
-               
-               HEART_BEAT( (short)1 ),
-               SCREEN_SHOT_DATA( (short)2 ),
-               DETAIL_INFO_DATA( (short)3 ),
-               RAMDUMP_COMPLETE( (short)4 ),
-               SENSOR_DAEMON_START( (short)800 ),
-               SHUTDOWN( (short)999 );
-               
+               /* This values must match the QEMU definitions */
+
+               HEART_BEAT((short) 1),
+               SCREEN_SHOT_DATA((short) 2),
+               DETAIL_INFO_DATA((short) 3),
+               RAMDUMP_COMPLETE((short) 4),
+               BOOTING_PROGRESS((short) 5),
+               SENSOR_DAEMON_START((short) 800),
+               SHUTDOWN((short) 999);
+
                private short value;
                ReceiveCommand( short value ) {
                        this.value = value;
                }
+
                public short value() {
                        return this.value;
                }
+
                public static ReceiveCommand getValue( String val ) {
                        ReceiveCommand[] values = ReceiveCommand.values();
                        for (int i = 0; i < values.length; i++) {
@@ -264,6 +284,7 @@ public interface ICommunicator extends Runnable {
                        }
                        throw new IllegalArgumentException( val );
                }
+
                public static ReceiveCommand getValue( short val ) {
                        ReceiveCommand[] values = ReceiveCommand.values();
                        for (int i = 0; i < values.length; i++) {
index 24d3d40a35b172682d1eae9cdcf4475a8120111a..2e93863ece524d27a363603888b6d846d1036f8a 100644 (file)
@@ -116,6 +116,7 @@ public class SocketCommunicator implements ICommunicator {
 
        private DataTranfer screenShotDataTransfer;
        private DataTranfer detailInfoTransfer;
+       private DataTranfer progressDataTransfer;
        
        private Thread sendThread;
        private LinkedList<SkinSendData> sendQueue;
@@ -134,7 +135,11 @@ public class SocketCommunicator implements ICommunicator {
                this.detailInfoTransfer.sleep = DETAIL_INFO_WAIT_INTERVAL;
                this.detailInfoTransfer.maxWaitTime = DETAIL_INFO_WAIT_LIMIT;
 
-               this.heartbeatCount = new AtomicInteger( 0 );
+               this.progressDataTransfer = new DataTranfer();
+               this.progressDataTransfer.sleep = DETAIL_INFO_WAIT_INTERVAL;
+               this.progressDataTransfer.maxWaitTime = DETAIL_INFO_WAIT_LIMIT;
+
+               this.heartbeatCount = new AtomicInteger(0);
                this.heartbeatExecutor = Executors.newSingleThreadScheduledExecutor();
 
                try {
@@ -305,6 +310,30 @@ public class SocketCommunicator implements ICommunicator {
                                        setRamdumpFlag(false);
                                        break;
                                }
+                               case BOOTING_PROGRESS: {
+                                       logger.info("received BOOTING_PROGRESS from QEMU.");
+                                       receiveData(progressDataTransfer, length);
+
+                                       byte[] receivedData = getReceivedData(progressDataTransfer);
+                                       if (null != receivedData) {
+                                               String strValue = new String(receivedData, 0, length - 1);
+
+                                               int value = 0;
+                                               try {
+                                                       value = Integer.parseInt(strValue);
+                                               } catch (NumberFormatException e) {
+                                                       e.printStackTrace();
+                                               }
+
+                                               /* draw progress bar */
+                                               if (skin.bootingProgress != null) {
+                                                       skin.bootingProgress.setSelection(value);
+                                               }
+                                       }
+                                       //TODO: resetDataTransfer(progressDataTransfer)
+
+                                       break;
+                               }
                                case SENSOR_DAEMON_START: {
                                        logger.info( "received SENSOR_DAEMON_START from QEMU." );
                                        synchronized ( this ) {
index abc523b8be819d93d3d777a613ea3e1573383b16..e9f04ff336587f63dc9eeacdbeb024b1c7e38e1c 100644 (file)
@@ -28,6 +28,8 @@
 
 package org.tizen.emulator.skin.window;
 
+import java.util.logging.Logger;
+
 import org.eclipse.swt.events.PaintEvent;
 import org.eclipse.swt.events.PaintListener;
 import org.eclipse.swt.graphics.Color;
@@ -35,13 +37,21 @@ import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.skin.dialog.DetailInfoDialog;
+import org.tizen.emulator.skin.log.SkinLogger;
 
 public class CustomProgressBar extends Canvas {
+       private Logger logger =
+                       SkinLogger.getSkinLogger(CustomProgressBar.class).getLogger();
+
+       private Composite parent;
        private int selection = 0;
 
        public CustomProgressBar(final Composite parent, int style) {
                super(parent, style);
 
+               this.parent = parent;
+
                this.addPaintListener(new PaintListener() {
                        @Override
                        public void paintControl(PaintEvent e) {
@@ -63,7 +73,14 @@ public class CustomProgressBar extends Canvas {
                }
 
                selection = value;
-               redraw();
+               logger.info("progress : " + selection);
+
+               parent.getDisplay().asyncExec(new Runnable() {
+                       @Override
+                       public void run() {
+                               redraw();
+                       }
+               });
        }
 
        public int getSelection() {
index 04c50d7ec021f3b7c24829e6d3fe7f42478b4f89..a142823f3770a8d82fdfa2e4ea82831e7c592a34 100644 (file)
@@ -485,7 +485,7 @@ void do_guestmemory_dump(void)
 {
     INFO("dump guest memory!\n");
 
-    //TODO:
+    /* TODO: */
 }
 
 void request_close(void)
old mode 100755 (executable)
new mode 100644 (file)
index f5f1f42..052f085
 #include <windows.h>
 #include <winsock2.h>
 #include <ws2tcpip.h>
+
+#define socket_error() WSAGetLastError()
+
 #else
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
+
+#define socket_error() errno
+
 #endif
 
 #include "debug_ch.h"
@@ -93,6 +99,9 @@ MULTI_DEBUG_CHANNEL(qemu, skin_server);
 #define SKIN_CONFIG_PROP ".skinconfig.properties"
 
 enum {
+    /* This values must match the Java definitions
+        in Skin process */
+
     RECV_START = 1,
     RECV_MOUSE_EVENT = 10,
     RECV_KEY_EVENT = 11,
@@ -110,10 +119,14 @@ enum {
 };
 
 enum {
+    /* This values must match the Java definitions
+    in Skin process */
+
     SEND_HEART_BEAT = 1,
     SEND_SCREEN_SHOT = 2,
     SEND_DETAIL_INFO = 3,
     SEND_RAMDUMP_COMPLETE = 4,
+    SEND_BOOTING_PROGRESS = 5,
     SEND_SENSOR_DAEMON_START = 800,
     SEND_SHUTDOWN = 999,
 };
@@ -249,12 +262,16 @@ void shutdown_skin_server( void ) {
 
 }
 
-void notify_sensor_daemon_start( void ) {
-    INFO( "notify_sensor_daemon_start\n" );
+void notify_sensor_daemon_start(void)
+{
+    INFO("notify_sensor_daemon_start\n");
+
     is_sensord_initialized = 1;
-    if ( client_sock ) {
-        if ( 0 > send_skin_header_only( client_sock, SEND_SENSOR_DAEMON_START, 1 ) ) {
-            ERR( "fail to send SEND_SENSOR_DAEMON_START to skin.\n" );
+    if (client_sock) {
+        if (0 > send_skin_header_only(
+            client_sock, SEND_SENSOR_DAEMON_START, 1)) {
+
+            ERR("fail to send SEND_SENSOR_DAEMON_START to skin.\n");
         }
     }
 }
@@ -264,12 +281,49 @@ void notify_ramdump_completed(void)
     INFO("ramdump completed!\n");
 
     if (client_sock) {
-        if (0 > send_skin_header_only( client_sock, SEND_RAMDUMP_COMPLETE, 1)) {
+        if (0 > send_skin_header_only(
+            client_sock, SEND_RAMDUMP_COMPLETE, 1)) {
+
             ERR("fail to send SEND_RAMDUMP_COMPLETE to skin.\n");
         }
     }
 }
 
+void notify_booting_progress(int progress_value)
+{
+#define PROGRESS_DATA_LENGTH 4
+
+    char progress_data[PROGRESS_DATA_LENGTH] = { 0, };
+    int len = 1;
+
+    INFO("notify_booting_progress\n");
+
+    /* percentage */
+    if (progress_value < 0) {
+        progress_value = 0;
+        len = 1;
+    } else if (progress_value < 10) {
+        len = 1;
+    } else if (progress_value < 100) {
+        len = 2;
+    } else if (progress_value = 100) {
+        len = 3;
+    } else if (progress_value > 100) {
+        progress_value = 100;
+        len = 3;
+    }
+
+    snprintf(progress_data, len + 1, "%d", progress_value);
+    INFO("booting...%s\%\n", progress_data);
+
+    if (client_sock) {
+        if (0 > send_skin_data(client_sock,
+            SEND_BOOTING_PROGRESS, progress_data, len + 1, 1)) {
+
+            ERR("fail to send SEND_BOOTING_PROGRESS to skin.\n");
+        }
+    }
+}
 
 int is_ready_skin_server(void)
 {
@@ -507,8 +561,9 @@ static void* run_skin_server(void* args)
         INFO( "start accepting socket...\n" );
 
         if ( 0 > ( client_sock = accept( server_sock, (struct sockaddr *) &client_addr, &client_len ) ) ) {
-            ERR( "skin_servier accept error\n" );
-            perror( "skin_servier accept error : " );
+            ERR("skin_server accept error\n");
+            perror("skin_server accept error : ");
+
             continue;
         }
 
@@ -526,15 +581,16 @@ static void* run_skin_server(void* args)
 
             int read_cnt = recv_n( client_sock, recvbuf, RECV_HEADER_SIZE );
 
-            if ( 0 > read_cnt ) {
-
-                if( is_force_close_client ) {
+            if (0 > read_cnt) {
+                if (is_force_close_client) {
                     INFO( "force close client socket.\n" );
                     is_force_close_client = 0;
-                }else {
-                    ERR( "skin_server read error:%d\n", read_cnt );
-                    perror( "skin_server read error : " );
+                } else {
+                    ERR("skin_server read error (%d): %d\n",
+                        socket_error(), read_cnt);
+                    perror("skin_server read error : ");
                 }
+
                 break;
 
             } else {
index 3ef909fb8a0adba28967d22a5cf6614bd8a2dc57..adac22541fe43ab071eadfd13a9d4b44e09bc913 100644 (file)
 
 int start_skin_server(int argc, char** argv, int qemu_argc, char** qemu_argv);
 void shutdown_skin_server(void);
+
 void notify_sensor_daemon_start(void);
 void notify_ramdump_complete(void);
+void notify_booting_progress(int progress_value);
 int is_ready_skin_server(void);
 int get_skin_server_port(void);