From: GiWoong Kim Date: Thu, 11 Sep 2014 05:18:54 +0000 (+0900) Subject: menu: added proxy arguments for ECP X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~228^2^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=094fafca73e8b9ea8f29d5789a472846485bba49;p=sdk%2Femulator%2Fqemu.git menu: added proxy arguments for ECP Location page needs host proxy information for browsing map. Change-Id: I6342b5660f4ff49ce3ed7087385cb31aa869b4eb Signed-off-by: GiWoong Kim Signed-off-by: Munkyu Im --- diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 0f47b12fd6..1959d671e6 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -356,3 +356,23 @@ char* get_emul_vm_name(void) return _emul_info.vm_name; } +/* emualtor http proxy */ +void set_emul_http_proxy_addr(char *addr) +{ + strncpy(_emul_info.http_proxy_addr, addr, strlen(addr)); +} + +char* get_emul_http_proxy_addr(void) +{ + return _emul_info.http_proxy_addr; +} + +void set_emul_http_proxy_port(char *port) +{ + strncpy(_emul_info.http_proxy_port, port, strlen(port)); +} + +char* get_emul_http_proxy_port(void) +{ + return _emul_info.http_proxy_port; +} diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index 5c9d599651..2663d776a6 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -37,6 +37,8 @@ #include "display/maru_finger.h" #define SUPPORT_LEGACY_ARGS +#define MAX_ADDR_LEN 256 +#define MAX_PORT_LEN 256 enum { RESET = 0, @@ -95,6 +97,8 @@ typedef struct EmulatorConfigInfo { int vm_base_port; int device_serial_number; int ecs_port; + char http_proxy_addr[MAX_ADDR_LEN]; + char http_proxy_port[MAX_PORT_LEN]; int spice_port; int websocket_port; char *vm_name; @@ -139,6 +143,8 @@ void set_emul_rotation(short rotation_type); void set_emul_caps_lock_state(int state); void set_emul_num_lock_state(int state); void set_emul_vm_name(char *vm_name); +void set_emul_http_proxy_addr(char *addr); +void set_emul_http_proxy_port(char *port); /* getter */ bool get_emul_skin_enable(void); @@ -164,5 +170,7 @@ int get_host_lock_key_state_darwin(int key); int get_emul_caps_lock_state(void); int get_emul_num_lock_state(void); char* get_emul_vm_name(void); +char* get_emul_http_proxy_addr(void); +char* get_emul_http_proxy_port(void); #endif /* __EMUL_STATE_H__ */ diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index a66de955bf..18b6705461 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -232,6 +232,22 @@ static void prepare_basic_features(gchar * const kernel_cmdline) http_proxy, https_proxy, ftp_proxy, socks_proxy, dns, get_emul_resolution_width(), get_emul_resolution_height()); + if(strlen(http_proxy) > 0) { + gchar** proxy; + if(g_str_has_prefix(http_proxy, HTTP_PREFIX)) { + char buf_proxy[MAXLEN] = {0,}; + remove_string(http_proxy, buf_proxy, HTTP_PREFIX); + proxy = g_strsplit(buf_proxy, ":", -1); + } else { + proxy = g_strsplit(http_proxy, ":", -1); + } + LOG_INFO("http_proxy address: %s, port: %s\n", proxy[0], proxy[1]); + set_emul_http_proxy_addr(proxy[0]); + set_emul_http_proxy_port(proxy[1]); + if(proxy != NULL) { + g_strfreev(proxy); + } + } g_strlcat(kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE); g_free(tmp_str); diff --git a/tizen/src/emulator.h b/tizen/src/emulator.h index cd918b483d..a264473dc4 100644 --- a/tizen/src/emulator.h +++ b/tizen/src/emulator.h @@ -42,6 +42,8 @@ #include "qemu/option.h" #include "sysemu/sysemu.h" +#define MAXLEN 512 + const char *prepare_maru(const gchar * const kernel_cmdline); void start_skin(void); 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 a5fecc4ee0..51c12abf63 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 @@ -1856,31 +1856,56 @@ public class EmulatorSkin { try { SkinUtil.openMessage(shell, null, "Control Panel file does not exist in the following path.\n" - + ecpFile.getCanonicalPath(), + + ecpFile.getCanonicalPath(), SWT.ICON_ERROR, config); } catch (IOException ee) { logger.log(Level.SEVERE, ee.getMessage(), ee); } return; - } + } - String emulName = SkinUtil.getVmName(config); - int portSdb = config.getArgInt(ArgsConstants.VM_BASE_PORT); + String emulName = SkinUtil.getVmName(config); + int basePort = config.getArgInt(ArgsConstants.VM_BASE_PORT); + String proxyAddr = config.getArg(ArgsConstants.PROXY_ADDR); + String proxyPort = config.getArg(ArgsConstants.PROXY_PORT); ProcessBuilder procEcp = new ProcessBuilder(); // FIXME: appropriate running binary setting is necessary. if (SwtUtil.isWindowsPlatform()) { - procEcp.command("java.exe", "-jar", ecpPath, "vmname=" - + emulName, "base.port=" + portSdb); + if (proxyAddr != null && proxyPort != null) { + procEcp.command("java.exe", "-Dhttp.proxyHost=" + + proxyAddr, "-Dhttp.proxyPort=" + proxyPort, + "-jar", ecpPath, "vmname=" + emulName, + "base.port=" + basePort); + } else { + procEcp.command("java.exe", "-jar", ecpPath, "vmname=" + + emulName, "base.port=" + basePort); + } } else if (SwtUtil.isMacPlatform()) { - procEcp.command("java", "-jar", "-XstartOnFirstThread", - ecpPath, "vmname=" + emulName, "base.port=" - + portSdb); + if (proxyAddr != null && proxyPort != null) { + procEcp.command("java", + "-Dhttp.proxyHost=" + proxyAddr, + "-Dhttp.proxyPort=" + proxyPort, "-jar", + "-XstartOnFirstThread", ecpPath, "vmname=" + + emulName, "base.port=" + basePort); + } else { + procEcp.command("java", "-jar", "-XstartOnFirstThread", + ecpPath, "vmname=" + emulName, "base.port=" + + basePort); + } } else { /* Linux */ - procEcp.command("java", "-jar", ecpPath, "vmname=" - + emulName, "base.port=" + portSdb); + if (proxyAddr != null && proxyPort != null) { + procEcp.command("java", + "-Dhttp.proxyHost=" + proxyAddr, + "-Dhttp.proxyPort=" + proxyPort, "-jar", + ecpPath, "vmname=" + emulName, "base.port=" + + basePort); + } else { + procEcp.command("java", "-jar", ecpPath, "vmname=" + + emulName, "base.port=" + basePort); + } } logger.info(procEcp.command().toString()); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java index 7e30c44391..ddd2848fc5 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java @@ -82,6 +82,8 @@ public class EmulatorConfig { public static final String INPUT_MOUSE = "input.mouse"; public static final String INPUT_TOUCHSCREEN = "input.touch"; public static final String INPUT_TOUCH_MAXPOINT = "input.touch.maxpoint"; + public static final String PROXY_ADDR = "proxy.addr"; + public static final String PROXY_PORT = "proxy.port"; } public interface SkinPropertiesConstants { diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index 5001a1cb52..a533050cc3 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -66,6 +66,8 @@ MULTI_DEBUG_CHANNEL(qemu, skin_client); #define OPT_INPUT_MOUSE "input.mouse" #define OPT_INPUT_TOUCH "input.touch" #define OPT_MAX_TOUCHPOINT "input.touch.maxpoint" +#define OPT_PROXY_ADDR "proxy.addr" +#define OPT_PROXY_PORT "proxy.port" #define OPT_BOOLEAN_TRUE "true" #define OPT_BOOLEAN_FALSE "false" @@ -103,9 +105,9 @@ static void *run_skin_client(void *arg) int skin_server_port = get_skin_server_port(); int vm_base_port = get_emul_vm_base_port(); - char buf_skin_server_port[16]; - char buf_uid[16]; - char buf_vm_base_port[16]; + char buf_skin_server_port[16] = { 0, }; + char buf_uid[16] = { 0, }; + char buf_vm_base_port[16] = { 0, }; sprintf(buf_skin_server_port, "%d", skin_server_port); sprintf(buf_uid, "%d", uid); sprintf(buf_vm_base_port, "%d", vm_base_port); @@ -120,10 +122,17 @@ static void *run_skin_client(void *arg) /* input */ char buf_input[12] = { 0, }; - if (is_emul_input_mouse_enable() == true) + if (is_emul_input_mouse_enable() == true) { strcpy(buf_input, OPT_INPUT_MOUSE); - else + } else { strcpy(buf_input, OPT_INPUT_TOUCH); + } + + /* network */ + char buf_proxy_addr[MAX_ADDR_LEN] = { 0, }; + char buf_proxy_port[MAX_PORT_LEN] = { 0, }; + sprintf(buf_proxy_addr, "%s", get_emul_http_proxy_addr()); + sprintf(buf_proxy_port, "%s", get_emul_http_proxy_port()); #ifdef CONFIG_WIN32 /* find java path in 64bit windows */ @@ -181,7 +190,11 @@ static void *run_skin_client(void *arg) strlen(buf_input) + EQUAL_LEN + strlen(OPT_BOOLEAN_TRUE) + SPACE_LEN + strlen(OPT_MAX_TOUCHPOINT) + EQUAL_LEN + - len_maxtouchpoint + SPACE_LEN + 1 + + len_maxtouchpoint + SPACE_LEN + + strlen(OPT_PROXY_ADDR) + EQUAL_LEN + + strlen(buf_proxy_addr) + SPACE_LEN + + strlen(OPT_PROXY_PORT) + EQUAL_LEN + + strlen(buf_proxy_port) + SPACE_LEN + 1 + strlen(argv); INFO("skin command length : %d\n", cmd_len); @@ -201,6 +214,8 @@ static void *run_skin_client(void *arg) %s=%s \ %s=%s \ %s=%d \ +%s=%s \ +%s=%s \ %s", JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, #ifdef CONFIG_WIN32 @@ -215,6 +230,8 @@ static void *run_skin_client(void *arg) OPT_DISPLAY_SHM, buf_display_shm, buf_input, OPT_BOOLEAN_TRUE, OPT_MAX_TOUCHPOINT, maxtouchpoint, + OPT_PROXY_ADDR, buf_proxy_addr, + OPT_PROXY_PORT, buf_proxy_port, argv); INFO("command for swt : %s\n", cmd); diff --git a/tizen/src/util/osutil-darwin.c b/tizen/src/util/osutil-darwin.c index 1ce5b24390..fcb7286f9e 100644 --- a/tizen/src/util/osutil-darwin.c +++ b/tizen/src/util/osutil-darwin.c @@ -445,8 +445,16 @@ int remove_sdcard_lock_os(char *sdcard) perror("file unlock error "); return ERR_UNLCK; } - unlink(lock_file); + + if (unlink(lock_file) < 0) { + perror("unlink error "); + return ERR_UNLCK; + } + + if (remove(lock_file) < 0) { + perror("remove error "); + return ERR_UNLCK; + } INFO("unlock success: %s\n", lock_file); return ERR_SUCCESS; } - diff --git a/tizen/src/util/osutil-linux.c b/tizen/src/util/osutil-linux.c index 48a4bf6605..c75e4ca531 100644 --- a/tizen/src/util/osutil-linux.c +++ b/tizen/src/util/osutil-linux.c @@ -219,7 +219,16 @@ int remove_sdcard_lock_os(char *sdcard) perror("file unlock error "); return ERR_UNLCK; } - unlink(lock_file); + + if (unlink(lock_file) < 0) { + perror("unlink error "); + return ERR_UNLCK; + } + + if (remove(lock_file) < 0) { + perror("remove error "); + return ERR_UNLCK; + } INFO("unlock success: %s\n", lock_file); return ERR_SUCCESS; }