From: GiWoong Kim Date: Mon, 14 Oct 2013 04:32:41 +0000 (+0900) Subject: skin: prepare for booting progressbar X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~693^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=568b4c5e2118e6ab65d908a7e07cd7e055e0281a;p=sdk%2Femulator%2Fqemu.git skin: prepare for booting progressbar Change-Id: Ia6d673a3ad3a4d2da9278aa3d58fce00987df421 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 2519524832..458b01d46b 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -1185,12 +1185,35 @@ public class EmulatorSkin { /* abstract */ } - public void dispalyBrightness(boolean on) { - if (on == true) { - displayOn(); - } else { - displayOff(); - } + public void updateProgressBar(final int progress) { + getShell().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + if (bootingProgress != null) { + bootingProgress.setSelection(progress); + + if (progress == 100 | progress == 0) { + /* this means progressbar will be disposed */ + if (bootingProgress != null) { + bootingProgress = null; + } + } + } + } + }); + } + + public void updateBrightness(final boolean on) { + getShell().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + if (on == true) { + displayOn(); + } else { + displayOff(); + } + } + }); } protected void displayOn() { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java index c8b3a2f7e1..ddb86ac470 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java @@ -344,17 +344,7 @@ public class SocketCommunicator implements ICommunicator { } /* draw progress bar */ - if (skin.bootingProgress != null) { - skin.bootingProgress.setSelection(value); - - if (value == 100 | value == 0) { - /* this means progressbar will be - disposed soon */ - if (skin.bootingProgress != null) { - skin.bootingProgress = null; - } - } - } + skin.updateProgressBar(value); } break; @@ -377,9 +367,9 @@ public class SocketCommunicator implements ICommunicator { } if (value == 0) { - skin.dispalyBrightness(false); + skin.updateBrightness(false); } else { - skin.dispalyBrightness(true); + skin.updateBrightness(true); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java index 6a994efe1e..c3b79ffbfb 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java @@ -1,7 +1,7 @@ /** + * Custom Progress Bar * - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim @@ -30,6 +30,8 @@ package org.tizen.emulator.skin.custom; import java.util.logging.Logger; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; @@ -47,18 +49,34 @@ public class CustomProgressBar extends Canvas { private Composite parent; private int selection; + private Color colorProgress; + /** + * Constructor + */ public CustomProgressBar(final Composite parent, int style) { super(parent, style); this.parent = parent; this.selection = 0; + this.colorProgress = new Color(parent.getDisplay(), PROGRESS_COLOR); + + addProgressBarListener(); - this.addPaintListener(new PaintListener() { + /* default is hidden */ + parent.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + setVisible(false); + } + }); + } + + protected void addProgressBarListener() { + addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { - e.gc.setBackground( - new Color(parent.getDisplay(), PROGRESS_COLOR)); + e.gc.setBackground(colorProgress); Rectangle bounds = getBounds(); int width = (bounds.width * selection) / 100; @@ -77,22 +95,29 @@ public class CustomProgressBar extends Canvas { } }); - /* default is hidden */ - parent.getDisplay().asyncExec(new Runnable() { + addDisposeListener(new DisposeListener() { @Override - public void run() { - setVisible(false); + public void widgetDisposed(DisposeEvent e) { + logger.info("progress bar is disposed"); + + colorProgress.dispose(); } }); } public void setSelection(int value) { - parent.getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - setVisible(true); - } - }); + if (isDisposed() == true) { + return; + } + + if (isVisible() == false) { + parent.getDisplay().syncExec(new Runnable() { + @Override + public void run() { + setVisible(true); + } + }); + } if (value < 0) { value = 0; diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 3f212ed389..dabad9a257 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -100,7 +100,7 @@ extern char tizen_target_path[]; enum { /* This values must match the Java definitions - in Skin process */ + in Skin process */ RECV_START = 1, RECV_MOUSE_EVENT = 10, @@ -191,6 +191,7 @@ static void* do_heart_beat(void* args); static int start_heart_beat(void); static void stop_heart_beat(void); + int start_skin_server(int argc, char** argv, int qemu_argc, char** qemu_argv) { @@ -213,7 +214,6 @@ int start_skin_server(int argc, char** argv, NULL, QEMU_THREAD_JOINABLE); return 1; - } void shutdown_skin_server(void) @@ -235,7 +235,6 @@ void shutdown_skin_server(void) } if (success_send) { - int count = 0; int max_sleep_count = 10; @@ -382,37 +381,26 @@ void notify_ramdump_completed(void) ERR("fail to send SEND_RAMDUMP_COMPLETE to skin.\n"); } + } else { + INFO("skin client socket is not connected yet\n"); } } void notify_booting_progress(int progress_value) { #define PROGRESS_DATA_LENGTH 4 - char progress_data[PROGRESS_DATA_LENGTH] = { 0, }; - int len = 1; TRACE("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 { - progress_value = 100; - len = 3; - } - - snprintf(progress_data, len + 1, "%d", progress_value); + snprintf(progress_data, + PROGRESS_DATA_LENGTH, "%03d", progress_value); TRACE("booting...%s\%\n", progress_data); if (client_sock) { if (0 > send_skin_data(client_sock, - SEND_BOOTING_PROGRESS, (unsigned char *)progress_data, len + 1, 0)) { + SEND_BOOTING_PROGRESS, + (unsigned char *)progress_data, PROGRESS_DATA_LENGTH, 0)) { ERR("fail to send SEND_BOOTING_PROGRESS to skin.\n"); } @@ -422,27 +410,34 @@ void notify_booting_progress(int progress_value) #else usleep(1000); #endif + } else { + INFO("skin client socket is not connected yet\n"); } } void notify_brightness(bool on) { - char brightness_data[2] = { 0, }; +#define BRIGHTNESS_DATA_LENGTH 2 + char brightness_data[BRIGHTNESS_DATA_LENGTH] = { 0, }; int brightness_value = 1; if (on == FALSE) { brightness_value = 0; } - snprintf(brightness_data, 2, "%d", brightness_value); + snprintf(brightness_data, + BRIGHTNESS_DATA_LENGTH, "%d", brightness_value); TRACE("brightness value = %s\n", brightness_data); if (client_sock) { if (0 > send_skin_data(client_sock, - SEND_BRIGHTNESS_VALUE, (unsigned char *)brightness_data, 2, 0)) { + SEND_BRIGHTNESS_VALUE, + (unsigned char *)brightness_data, BRIGHTNESS_DATA_LENGTH, 0)) { ERR("fail to send SEND_BRIGHTNESS_VALUE to skin.\n"); } + } else { + INFO("skin client socket is not connected yet\n"); } }