From: giwoong.kim Date: Mon, 7 Jan 2013 11:30:24 +0000 (+0900) Subject: skin: indent the code X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1213 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95a6479286014987cc0f2bbfa76928e873baaedd;p=sdk%2Femulator%2Fqemu.git skin: indent the code indent the code & give a name to thread in skin Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/maru_err_table.c b/tizen/src/maru_err_table.c index 5a40889c36..83712876c4 100644 --- a/tizen/src/maru_err_table.c +++ b/tizen/src/maru_err_table.c @@ -49,7 +49,7 @@ Check if the file is corrupted or missing.\n\n", /* 3 */ "Failed to load a bios file the following path.\ Check if the file is corrupted or missing.\n\n", /* 4 */ "Skin process cannot be initialized. Skin server is not ready.", - /* 5 */ "Skin client cannot connected to Skin server. The time of internal heartbeat has expired.", + /* 5 */ "Skin client could not connect to Skin server. The time of internal heartbeat has expired.", /* add here.. */ "" }; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShutdownhook.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShutdownhook.java index 8d288ca9fe..787e7e4b83 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShutdownhook.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShutdownhook.java @@ -39,17 +39,18 @@ import org.tizen.emulator.skin.log.SkinLogger; * */ public class EmulatorShutdownhook extends Thread { + private Logger logger = + SkinLogger.getSkinLogger(EmulatorShutdownhook.class).getLogger(); - private Logger logger = SkinLogger.getSkinLogger( EmulatorShutdownhook.class ).getLogger(); private ICommunicator communicator; - - public EmulatorShutdownhook( ICommunicator communicator ) { + + public EmulatorShutdownhook(ICommunicator communicator) { this.communicator = communicator; } @Override public void run() { - logger.info( " EmulatorShutdownhook run by a signal." ); + logger.info("EmulatorShutdownhook run by a signal."); communicator.terminate(); } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java index c162bdd938..315c514c7a 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java @@ -227,11 +227,13 @@ public class EmulatorSkinMain { } else { // linux & windows skin = new EmulatorSdlSkin(currentState, finger, config, skinInfo, isOnTop); } + /* create a qemu communicator */ int uid = config.getArgInt(ArgsConstants.UID); communicator = new SocketCommunicator(config, uid, skin); skin.setCommunicator(communicator); finger.setEmulatorSkin(skin); + /* initialize a skin layout */ long windowHandleId = skin.initLayout(); communicator.setInitialData(windowHandleId); @@ -243,9 +245,10 @@ public class EmulatorSkinMain { Runtime.getRuntime().addShutdownHook( new EmulatorShutdownhook(communicator)); - Thread communicatorThread = new Thread(communicator); + Thread communicatorThread = + new Thread(communicator, "communicator"); communicatorThread.start(); - + // SkinReopenPolicy reopenPolicy = skin.open(); // // while( true ) { @@ -284,7 +287,7 @@ public class EmulatorSkinMain { System.out.println("Shutdown skin process !!!"); } - if(null != communicator) { + if (null != communicator) { communicator.terminate(); } @@ -296,43 +299,44 @@ public class EmulatorSkinMain { } - private static void initLog( Map argsMap, Properties properties ) { + private static void initLog(Map argsMap, Properties properties) { - String argLogLevel = argsMap.get( ArgsConstants.LOG_LEVEL ); + String argLogLevel = argsMap.get(ArgsConstants.LOG_LEVEL); String configPropertyLogLevel = null; - if( null != properties ) { - configPropertyLogLevel = (String) properties.get( ConfigPropertiesConstants.LOG_LEVEL ); + if (null != properties) { + configPropertyLogLevel = + (String) properties.get(ConfigPropertiesConstants.LOG_LEVEL); } - // default log level is debug. + /* default log level is debug. */ String logLevel = ""; - - if( !StringUtil.isEmpty( argLogLevel ) ) { + + if (!StringUtil.isEmpty(argLogLevel)) { logLevel = argLogLevel; - }else if( !StringUtil.isEmpty( configPropertyLogLevel ) ) { + } else if (!StringUtil.isEmpty(configPropertyLogLevel)) { logLevel = configPropertyLogLevel; - }else { + } else { logLevel = EmulatorConfig.DEFAULT_LOG_LEVEL.value(); } - + SkinLogLevel skinLogLevel = EmulatorConfig.DEFAULT_LOG_LEVEL; - + SkinLogLevel[] values = SkinLogLevel.values(); - - for ( SkinLogLevel level : values ) { - if ( level.value().equalsIgnoreCase( logLevel ) ) { + + for (SkinLogLevel level : values) { + if (level.value().equalsIgnoreCase(logLevel)) { skinLogLevel = level; break; } } - SkinLogger.setLevel( skinLogLevel.level() ); + SkinLogger.setLevel(skinLogLevel.level()); } - private static String getSimpleMsg( String[] args ) { + private static String getSimpleMsg(String[] args) { for ( int i = 0; i < args.length; i++ ) { final String simple = "simple.msg"; diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index 33a5d09a26..e598ee3ab8 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -65,12 +65,12 @@ static void* run_skin_client(void* arg) char cmd[JAVA_MAX_COMMAND_LENGTH] = { 0, }; char argv[JAVA_MAX_COMMAND_LENGTH] = { 0, }; - INFO("run skin client\n"); + INFO("run skin client\n"); int i; for (i = 0; i < skin_argc; ++i) { strncat(argv, skin_argv[i], strlen(skin_argv[i])); strncat(argv, " ", 1); - INFO( "[skin args %d] %s\n", i, skin_argv[i] ); + INFO("[skin args %d] %s\n", i, skin_argv[i]); } int skin_server_port = get_skin_server_port(); @@ -91,12 +91,12 @@ static void* run_skin_client(void* arg) #ifdef CONFIG_WIN32 // find java path in 64bit windows JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH); - memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH); + memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH); if (is_wow64()) { INFO("This process is running under WOW64.\n"); if (!get_java_path(&JAVA_EXEFILE_PATH)) { strcpy(JAVA_EXEFILE_PATH, "java"); - } + } } else { strcpy(JAVA_EXEFILE_PATH, "java"); } @@ -159,7 +159,7 @@ static void* run_skin_client(void* arg) argv ); #endif - INFO( "command for swt : %s\n", cmd ); + INFO("command for swt : %s\n", cmd); #ifdef CONFIG_WIN32 // for 64bit windows @@ -197,7 +197,8 @@ static void* run_skin_client(void* arg) INFO("the child thread state was signaled!\n"); break; case WAIT_TIMEOUT: - INFO("time-out interval elapsed, and the child thread's state is nonsignaled.\n"); + INFO("time-out interval elapsed,\ + and the child thread's state is nonsignaled.\n"); break; case WAIT_FAILED: ERR("WaitForSingleObject() failed, error %u\n", GetLastError()); @@ -253,29 +254,29 @@ int start_skin_client(int argc, char* argv[]) int count = 0; int skin_server_ready = 0; - while( 1 ) { + while(1) { - if( 100 * SKIN_SERVER_READY_TIME < count ) { + if (100 * SKIN_SERVER_READY_TIME < count) { break; } - if ( is_ready_skin_server() ) { + if (is_ready_skin_server()) { skin_server_ready = 1; break; } else { count++; - INFO( "sleep for ready. count:%d\n", count ); + INFO("sleep for ready. count:%d\n", count); #ifdef CONFIG_WIN32 - Sleep( SKIN_SERVER_SLEEP_TIME ); + Sleep(SKIN_SERVER_SLEEP_TIME); #else - usleep( 1000 * SKIN_SERVER_SLEEP_TIME ); + usleep(1000 * SKIN_SERVER_SLEEP_TIME); #endif } } - if ( !skin_server_ready ) { - ERR( "skin_server is not ready.\n" ); + if (!skin_server_ready) { + ERR("skin_server is not ready.\n"); return -1; } @@ -292,8 +293,8 @@ int start_skin_client(int argc, char* argv[]) return 1; } - -int start_simple_client(char* msg) { +int start_simple_client(char* msg) +{ int ret = 0; char cmd[JAVA_MAX_COMMAND_LENGTH] = { 0, }; @@ -302,12 +303,12 @@ int start_simple_client(char* msg) { #ifdef CONFIG_WIN32 // find java path in 64bit windows JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH); - memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH); + memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH); if (is_wow64()) { INFO("This process is running under WOW64.\n"); if (!get_java_path(&JAVA_EXEFILE_PATH)) { strcpy(JAVA_EXEFILE_PATH, "java"); - } + } } else { strcpy(JAVA_EXEFILE_PATH, "java"); } @@ -363,7 +364,7 @@ int is_wow64(void) if (!fnIsWow64Process(GetCurrentProcess(),&result)) { //handle error - INFO("Can not find 'IsWow64Process'\n"); + INFO("Can not find 'IsWow64Process'\n"); } } return result; @@ -371,40 +372,40 @@ int is_wow64(void) int get_java_path(char** java_path) { - HKEY hKeyNew; - HKEY hKey; - //char strJavaRuntimePath[JAVA_MAX_COMMAND_LENGTH] = {0}; - char strChoosenName[JAVA_MAX_COMMAND_LENGTH] = {0}; - char strSubKeyName[JAVA_MAX_COMMAND_LENGTH] = {0}; - char strJavaHome[JAVA_MAX_COMMAND_LENGTH] = {0}; - int index; - DWORD dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH; - DWORD dwBufLen = JAVA_MAX_COMMAND_LENGTH; + HKEY hKeyNew; + HKEY hKey; + //char strJavaRuntimePath[JAVA_MAX_COMMAND_LENGTH] = {0}; + char strChoosenName[JAVA_MAX_COMMAND_LENGTH] = {0}; + char strSubKeyName[JAVA_MAX_COMMAND_LENGTH] = {0}; + char strJavaHome[JAVA_MAX_COMMAND_LENGTH] = {0}; + int index; + DWORD dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH; + DWORD dwBufLen = JAVA_MAX_COMMAND_LENGTH; RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Runtime Environment", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | MY_KEY_WOW64_64KEY, &hKey); RegEnumKeyEx(hKey, 0, (LPSTR)strSubKeyName, &dwSubKeyNameMax, NULL, NULL, NULL, NULL); strcpy(strChoosenName, strSubKeyName); - index = 1; - while (ERROR_SUCCESS == RegEnumKeyEx(hKey, index, (LPSTR)strSubKeyName, &dwSubKeyNameMax, - NULL, NULL, NULL, NULL)) { + index = 1; + while (ERROR_SUCCESS == RegEnumKeyEx(hKey, index, (LPSTR)strSubKeyName, &dwSubKeyNameMax, + NULL, NULL, NULL, NULL)) { if (strcmp(strChoosenName, strSubKeyName) < 0) { strcpy(strChoosenName, strSubKeyName); } index++; - } + } - RegOpenKeyEx(hKey, strChoosenName, 0, KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hKeyNew); - RegQueryValueEx(hKeyNew, "JavaHome", NULL, NULL, (LPBYTE)strJavaHome, &dwBufLen); - RegCloseKey(hKey); - if (strJavaHome[0] != '\0') { + RegOpenKeyEx(hKey, strChoosenName, 0, KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hKeyNew); + RegQueryValueEx(hKeyNew, "JavaHome", NULL, NULL, (LPBYTE)strJavaHome, &dwBufLen); + RegCloseKey(hKey); + if (strJavaHome[0] != '\0') { sprintf(*java_path, "\"%s\\bin\\java\"", strJavaHome); //strcpy(*java_path, strJavaHome); //strcat(*java_path, "\\bin\\java"); } else { - return 0; - } + return 0; + } return 1; } #endif diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 9274b76900..1f015142ea 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -155,21 +155,28 @@ static char** skin_argv = NULL; static int qmu_argc = 0; static char** qmu_argv = NULL; -static void parse_skin_args( void ); -static void parse_skinconfig_prop( void ); -static void* run_skin_server( void* args ); -static int recv_n( int client_sock, char* read_buf, int recv_len ); -static void make_header( int client_sock, short send_cmd, int data_length, char* sendbuf, int print_log ); -static int send_skin_header_only( int client_sock, short send_cmd, int print_log ); -static int send_skin_data( int client_sock, short send_cmd, unsigned char* data, int length, int big_data ); -static int send_n( int client_sock, unsigned char* data, int length, int big_data ); +static void parse_skin_args(void); +static void parse_skinconfig_prop(void); +static void* run_skin_server(void* args); -static void* do_heart_beat( void* args ); -static int start_heart_beat( void ); -static void stop_heart_beat( void ); +static int recv_n(int client_sock, char* read_buf, int recv_len); +static int send_n(int client_sock, unsigned char* data, int length, int big_data); -int start_skin_server( int argc, char** argv, int qemu_argc, char** qemu_argv ) { +static void make_header(int client_sock, + short send_cmd, int data_length, char* sendbuf, int print_log); +static int send_skin_header_only(int client_sock, + short send_cmd, int print_log); +static int send_skin_data(int client_sock, + short send_cmd, unsigned char* data, int length, int big_data); + +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) +{ skin_argc = argc; skin_argv = argv; @@ -178,7 +185,7 @@ int start_skin_server( int argc, char** argv, int qemu_argc, char** qemu_argv ) // arguments have higher priority than '.skinconfig.properties' parse_skin_args(); - INFO( "ignore_heartbeat:%d\n", ignore_heartbeat ); + INFO("ignore_heartbeat:%d\n", ignore_heartbeat); qmu_argc = qemu_argc; qmu_argv = qemu_argv; @@ -192,44 +199,44 @@ int start_skin_server( int argc, char** argv, int qemu_argc, char** qemu_argv ) } -void shutdown_skin_server( void ) { - - INFO( "shutdown_skin_server\n" ); +void shutdown_skin_server(void) +{ + INFO("shutdown_skin_server\n"); int close_server_socket = 0; int success_send = 0; - if ( client_sock ) { - INFO( "send shutdown to skin.\n" ); - if ( 0 > send_skin_header_only( client_sock, SEND_SHUTDOWN, 1 ) ) { - ERR( "fail to send SEND_SHUTDOWN to skin.\n" ); + if (client_sock) { + INFO("send shutdown to skin.\n"); + if (0 > send_skin_header_only(client_sock, SEND_SHUTDOWN, 1)) { + ERR("fail to send SEND_SHUTDOWN to skin.\n"); close_server_socket = 1; } else { success_send = 1; - // skin sent RECV_RESPONSE_SHUTDOWN. + /* skin sent RECV_RESPONSE_SHUTDOWN */ } } - if ( success_send ) { + if (success_send) { int count = 0; int max_sleep_count = 10; - while ( 1 ) { + while (1) { - if ( max_sleep_count < count ) { + if (max_sleep_count < count) { close_server_socket = 1; break; } - if ( stop_server ) { - INFO( "skin client sent normal shutdown response.\n" ); + if (stop_server) { + INFO("skin client sent normal shutdown response.\n"); break; } else { #ifdef CONFIG_WIN32 - Sleep( 1 ); // 1ms + Sleep(1); // 1ms #else - usleep( 1000 ); // 1ms + usleep(1000); // 1ms #endif count++; } @@ -239,22 +246,22 @@ void shutdown_skin_server( void ) { stop_server = 1; is_force_close_client = 1; - if ( client_sock ) { + if (client_sock) { #ifdef CONFIG_WIN32 - closesocket( client_sock ); + closesocket(client_sock); #else - close( client_sock ); + close(client_sock); #endif client_sock = 0; } - if ( close_server_socket ) { - INFO( "skin client did not send normal shutdown response.\n" ); - if ( server_sock ) { + if (close_server_socket) { + INFO("skin client did not send normal shutdown response.\n"); + if (server_sock) { #ifdef CONFIG_WIN32 - closesocket( server_sock ); + closesocket(server_sock); #else - close( server_sock ); + close(server_sock); #endif server_sock = 0; }