From 3f905a68b10d4dec0f6e94b11e670a42c6486a7c Mon Sep 17 00:00:00 2001 From: SeokYeon Hwang Date: Wed, 23 Jan 2013 15:41:08 +0900 Subject: [PATCH] emulator: Remove option.c, option.h from emulator Remove option.c, option.h because they are no more needed Signed-off-by: SeokYeon Hwang --- tizen/src/Makefile.tizen | 2 +- tizen/src/option.c | 556 ----------------------------------------------- tizen/src/option.h | 46 ---- vl.c | 8 +- 4 files changed, 4 insertions(+), 608 deletions(-) delete mode 100644 tizen/src/option.c delete mode 100644 tizen/src/option.h diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index 3303e89..86d1dec 100755 --- a/tizen/src/Makefile.tizen +++ b/tizen/src/Makefile.tizen @@ -70,7 +70,7 @@ endif #CONFIG_GL #endif #!CONFIG_DARWIN # maru loader -obj-y += emulator.o emul_state.o option.o maru_err_table.o +obj-y += emulator.o emul_state.o maru_err_table.o # osutil obj-y += osutil.o diff --git a/tizen/src/option.c b/tizen/src/option.c deleted file mode 100644 index c215b0b..0000000 --- a/tizen/src/option.c +++ /dev/null @@ -1,556 +0,0 @@ -/* - * Emulator - * - * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * MunKyu Im - * GiWoong Kim - * YeongKyoon Lee - * HyunJun Son - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -/** - @file option.c - @brief collection of dialog function - */ - -#include "option.h" -#include "emulator.h" -#include "maru_common.h" -#if defined (CONFIG_LINUX) -#include -#include -#include -#include -#include -#include -#include -#elif defined (CONFIG_WIN32) -#include -#include -#include -#include -#elif defined (CONFIG_DARWIN) -#include -CFDictionaryRef proxySettings; -#endif -#include - -#include "debug_ch.h" - -#define HTTP_PROTOCOL "http=" -#define HTTP_PREFIX "http://" -#define HTTPS_PROTOCOL "https=" -#define FTP_PROTOCOL "ftp=" -#define SOCKS_PROTOCOL "socks=" -#define DIRECT "DIRECT" -#define PROXY "PROXY" -#define MAXPORTLEN 6 -MULTI_DEBUG_CHANNEL(tizen, option); -#if defined(CONFIG_WIN32) -BYTE *url; -#endif -const char *pactempfile = ".autoproxy"; - -#if defined (CONFIG_DARWIN) -static char *cfstring_to_cstring(CFStringRef str) { - if (str == NULL) { - return NULL; - } - - CFIndex length = CFStringGetLength(str); - CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); - char *buffer = (char *)malloc(maxSize); - if (CFStringGetCString(str, buffer, maxSize, kCFStringEncodingUTF8)) - return buffer; - return NULL; -} - -static int cfnumber_to_int(CFNumberRef num) { - if (!num) - return 0; - - int value; - CFNumberGetValue(num, kCFNumberIntType, &value); - return value; -} -#endif - -static size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - size_t written; - written = fwrite(ptr, size, nmemb, stream); - return written; -} - -static void download_url(char *url) -{ - CURL *curl; - FILE *fp; - CURLcode res; - - curl = curl_easy_init(); - if (curl) { - fp = fopen(pactempfile,"wb"); - curl_easy_setopt(curl, CURLOPT_URL, url); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); - //just in case network does not work. - curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 3000); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); - res = curl_easy_perform(curl); - if(res != 0) { - ERR("Fail to download pac file: %s\n", url); - } - curl_easy_cleanup(curl); - fclose(fp); - } - - return; -} - -#if defined (CONFIG_DARWIN) -static void getmacproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) -{ - char *hostname; - int port; - CFNumberRef isEnable; - CFStringRef proxyHostname; - CFNumberRef proxyPort; - CFDictionaryRef proxySettings; - proxySettings = SCDynamicStoreCopyProxies(NULL); - - isEnable = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPEnable); - if (cfnumber_to_int(isEnable)) { - // Get proxy hostname - proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPProxy); - hostname = cfstring_to_cstring(proxyHostname); - // Get proxy port - proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPPort); - port = cfnumber_to_int(proxyPort); - // Save hostname & port - snprintf(http_proxy, MAXLEN, "%s:%d", hostname, port); - - free(hostname); - } else { - INFO("http proxy is null\n"); - } - - isEnable = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSEnable); - if (cfnumber_to_int(isEnable)) { - // Get proxy hostname - proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSProxy); - hostname = cfstring_to_cstring(proxyHostname); - // Get proxy port - proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSPort); - port = cfnumber_to_int(proxyPort); - // Save hostname & port - snprintf(https_proxy, MAXLEN, "%s:%d", hostname, port); - - free(hostname); - } else { - INFO("https proxy is null\n"); - } - - isEnable = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPEnable); - if (cfnumber_to_int(isEnable)) { - // Get proxy hostname - proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPProxy); - hostname = cfstring_to_cstring(proxyHostname); - // Get proxy port - proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPPort); - port = cfnumber_to_int(proxyPort); - // Save hostname & port - snprintf(ftp_proxy, MAXLEN, "%s:%d", hostname, port); - - free(hostname); - } else { - INFO("ftp proxy is null\n"); - } - - isEnable = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSEnable); - if (cfnumber_to_int(isEnable)) { - // Get proxy hostname - proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSProxy); - hostname = cfstring_to_cstring(proxyHostname); - // Get proxy port - proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSPort); - port = cfnumber_to_int(proxyPort); - // Save hostname & port - snprintf(socks_proxy, MAXLEN, "%s:%d", hostname, port); - - free(hostname); - } else { - INFO("socks proxy is null\n"); - } - CFRelease(proxySettings); -} -#endif - -static void remove_string(char *src, char *dst, const char *toremove) -{ - int len = strlen(toremove); - int i, j; - int max_len = strlen(src); - - for(i = len, j = 0; i < max_len; i++) - { - dst[j++] = src[i]; - } - - dst[j] = '\0'; -} - -#if defined (CONFIG_LINUX) -static void getlinuxproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) -{ - char buf[MAXLEN] = {0,}; - char buf_port[MAXPORTLEN] = {0,}; - char buf_proxy[MAXLEN] = {0,}; - char *buf_proxy_bak; - char *proxy; - FILE *output; - int MAXPROXYLEN = MAXLEN + MAXPORTLEN; - - output = popen("gconftool-2 --get /system/http_proxy/host", "r"); - if(fscanf(output, "%s", buf) > 0) { - snprintf(buf_proxy, MAXLEN, "%s", buf); - } - pclose(output); - - output = popen("gconftool-2 --get /system/http_proxy/port", "r"); - if(fscanf(output, "%s", buf_port) <= 0) { - //for abnormal case: if can't find the key of http port, get from environment value. - buf_proxy_bak = getenv("http_proxy"); - INFO("http_proxy from env: %s\n", buf_proxy_bak); - if(buf_proxy_bak != NULL) { - proxy = malloc(MAXLEN); - remove_string(buf_proxy_bak, proxy, HTTP_PREFIX); - strncpy(http_proxy, proxy, strlen(proxy)-1); - INFO("final http_proxy value: %s\n", http_proxy); - free(proxy); - } - else { - INFO("http_proxy is not set on env.\n"); - pclose(output); - return; - } - - } - else { - snprintf(http_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf_port); - memset(buf_proxy, 0, MAXLEN); - INFO("http_proxy: %s\n", http_proxy); - } - pclose(output); - - memset(buf, 0, MAXLEN); - - output = popen("gconftool-2 --get /system/proxy/secure_host", "r"); - if(fscanf(output, "%s", buf) > 0) { - snprintf(buf_proxy, MAXLEN, "%s", buf); - } - pclose(output); - - output = popen("gconftool-2 --get /system/proxy/secure_port", "r"); - if(fscanf(output, "%s", buf) > 0) { - snprintf(https_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf); - } - pclose(output); - memset(buf, 0, MAXLEN); - memset(buf_proxy, 0, MAXLEN); - INFO("https_proxy : %s\n", https_proxy); - - output = popen("gconftool-2 --get /system/proxy/ftp_host", "r"); - if(fscanf(output, "%s", buf) > 0) { - snprintf(buf_proxy, MAXLEN, "%s", buf); - } - pclose(output); - - output = popen("gconftool-2 --get /system/proxy/ftp_port", "r"); - if(fscanf(output, "%s", buf) > 0) { - snprintf(ftp_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf); - } - pclose(output); - memset(buf, 0, MAXLEN); - memset(buf_proxy, 0, MAXLEN); - INFO("ftp_proxy : %s\n", ftp_proxy); - - output = popen("gconftool-2 --get /system/proxy/socks_host", "r"); - if(fscanf(output, "%s", buf) > 0) { - snprintf(buf_proxy, MAXLEN, "%s", buf); - } - pclose(output); - - output = popen("gconftool-2 --get /system/proxy/socks_port", "r"); - if(fscanf(output, "%s", buf) > 0) { - snprintf(socks_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf); - } - pclose(output); - INFO("socks_proxy : %s\n", socks_proxy); -} -#endif - -static int getautoproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) -{ - char type[MAXLEN]; - char proxy[MAXLEN]; - char line[MAXLEN]; - FILE *fp_pacfile; - char *p = NULL; -#if defined(CONFIG_LINUX) - FILE *output; - char buf[MAXLEN]; - - output = popen("gconftool-2 --get /system/proxy/autoconfig_url", "r"); - if(fscanf(output, "%s", buf) > 0) { - INFO("pac address: %s\n", buf); - download_url(buf); - } - pclose(output); -#elif defined(CONFIG_WIN32) - INFO("pac address: %s\n", (char*)url); - download_url((char*)url); -#elif defined(CONFIG_DARWIN) - CFStringRef pacURL = (CFStringRef)CFDictionaryGetValue(proxySettings, - kSCPropNetProxiesProxyAutoConfigURLString); - if (pacURL) { - char url[MAXLEN] = {}; - CFStringGetCString(pacURL, url, sizeof url, kCFStringEncodingASCII); - INFO("pac address: %s\n", (char*)url); - download_url(url); - } -#endif - fp_pacfile = fopen(pactempfile, "r"); - if(fp_pacfile != NULL) { - while(fgets(line, MAXLEN, fp_pacfile) != NULL) { - if( (strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) { - INFO("line found %s", line); - sscanf(line, "%*[^\"]\"%s %s", type, proxy); - } - } - - if(g_str_has_prefix(type, DIRECT)) { - INFO("auto proxy is set to direct mode\n"); - fclose(fp_pacfile); - } - else if(g_str_has_prefix(type, PROXY)) { - INFO("auto proxy is set to proxy mode\n"); - INFO("type: %s, proxy: %s\n", type, proxy); - p = strtok(proxy, "\";"); - if(p != NULL) { - INFO("auto proxy to set: %s\n",p); - strcpy(http_proxy, p); - strcpy(https_proxy, p); - strcpy(ftp_proxy, p); - strcpy(socks_proxy, p); - } - fclose(fp_pacfile); - } - else - { - ERR("pac file is not wrong! It could be the wrong pac address or pac file format\n"); - fclose(fp_pacfile); - } - } - else { - ERR("fail to get pacfile fp\n"); - return -1; - } - - remove(pactempfile); - return 0; -} - - -/** - @brief get host proxy server address - @param proxy: return value (proxy server address) - @return always 0 - */ -int gethostproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) -{ -#if defined(CONFIG_LINUX) - char buf[MAXLEN]; - FILE *output; - - output = popen("gconftool-2 --get /system/proxy/mode", "r"); - if(fscanf(output, "%s", buf) > 0) { - //priority : auto > manual > none - if (strcmp(buf, "auto") == 0) { - INFO("AUTO PROXY MODE\n"); - getautoproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); - } - else if (strcmp(buf, "manual") == 0) { - INFO("MANUAL PROXY MODE\n"); - getlinuxproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); - } - else if (strcmp(buf, "none") == 0) { - INFO("DIRECT PROXY MODE\n"); - } - } - pclose(output); - -#elif defined(CONFIG_WIN32) - HKEY hKey; - int nRet; - LONG lRet; - BYTE *proxyenable, *proxyserver; - char *p; - char *real_proxy; - - DWORD dwLength = 0; - nRet = RegOpenKeyEx(HKEY_CURRENT_USER, - "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", - 0, KEY_QUERY_VALUE, &hKey); - if (nRet != ERROR_SUCCESS) { - ERR("Failed to open registry from %s\n", - "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"); - return 0; - } - //check auto proxy key exists - lRet = RegQueryValueEx(hKey, "AutoConfigURL", 0, NULL, NULL, &dwLength); - if (lRet != ERROR_SUCCESS && dwLength == 0) { - ERR("Failed to query value from %s\n", - "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\AutoConfigURL"); - } - else { - //if exists - url = (char*)malloc(dwLength); - if (url == NULL) { - ERR( "Failed to allocate a buffer\n"); - } - else { - memset(url, 0x00, dwLength); - lRet = RegQueryValueEx(hKey, "AutoConfigURL", 0, NULL, url, &dwLength); - if (lRet == ERROR_SUCCESS && dwLength != 0) { - getautoproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); - RegCloseKey(hKey); - return 0; - } - } - } - //check manual proxy key exists - lRet = RegQueryValueEx(hKey, "ProxyEnable", 0, NULL, NULL, &dwLength); - if (lRet != ERROR_SUCCESS && dwLength == 0) { - ERR(stderr, "Failed to query value from %s\n", - "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyEnable"); - RegCloseKey(hKey); - return 0; - } - proxyenable = (BYTE*)malloc(dwLength); - if (proxyenable == NULL) { - ERR( "Failed to allocate a buffer\n"); - RegCloseKey(hKey); - return 0; - } - - lRet = RegQueryValueEx(hKey, "ProxyEnable", 0, NULL, proxyenable, &dwLength); - if (lRet != ERROR_SUCCESS) { - free(proxyenable); - ERR("Failed to query value from %s\n", - "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyEnable"); - RegCloseKey(hKey); - return 0; - } - if (*(char*)proxyenable == 0) { - free(proxyenable); - RegCloseKey(hKey); - return 0; - } - - dwLength = 0; - lRet = RegQueryValueEx(hKey, "ProxyServer", 0, NULL, NULL, &dwLength); - if (lRet != ERROR_SUCCESS && dwLength == 0) { - ERR("Failed to query value from from %s\n", - "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"); - RegCloseKey(hKey); - return 0; - } - - proxyserver = (BYTE*)malloc(dwLength); - if (proxyserver == NULL) { - ERR( "Failed to allocate a buffer\n"); - RegCloseKey(hKey); - return 0; - } - - memset(proxyserver, 0x00, dwLength); - lRet = RegQueryValueEx(hKey, "ProxyServer", 0, NULL, proxyserver, &dwLength); - if (lRet != ERROR_SUCCESS) { - free(proxyserver); - ERR( "Failed to query value from from %s\n", - "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"); - RegCloseKey(hKey); - return 0; - } - - if((char*)proxyserver != NULL) { - INFO("proxy value: %s\n", (char*)proxyserver); - real_proxy = malloc(MAXLEN); - - for(p = strtok((char*)proxyserver, ";"); p; p = strtok(NULL, ";")){ - if(strstr(p, HTTP_PROTOCOL)) { - remove_string(p, real_proxy, HTTP_PROTOCOL); - strcpy(http_proxy, real_proxy); - } - else if(strstr(p, HTTPS_PROTOCOL)) { - remove_string(p, real_proxy, HTTPS_PROTOCOL); - strcpy(https_proxy, real_proxy); - } - else if(strstr(p, FTP_PROTOCOL)) { - remove_string(p, real_proxy, FTP_PROTOCOL); - strcpy(ftp_proxy, real_proxy); - } - else if(strstr(p, SOCKS_PROTOCOL)) { - remove_string(p, real_proxy, SOCKS_PROTOCOL); - strcpy(socks_proxy, real_proxy); - } - else { - INFO("all protocol uses the same proxy server: %s\n", p); - strcpy(http_proxy, p); - strcpy(https_proxy, p); - strcpy(ftp_proxy, p); - strcpy(socks_proxy, p); - } - } - free(real_proxy); - } - else { - INFO("proxy is null\n"); - return 0; - } - RegCloseKey(hKey); -#elif defined (CONFIG_DARWIN) - int ret; - proxySettings = SCDynamicStoreCopyProxies(NULL); - if(proxySettings) { - INFO("AUTO PROXY MODE\n"); - ret = getautoproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); - if(strlen(http_proxy) == 0 && ret < 0) { - INFO("MANUAL PROXY MODE\n"); - getmacproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); - } - } -#endif - return 0; -} diff --git a/tizen/src/option.h b/tizen/src/option.h deleted file mode 100644 index 09442a1..0000000 --- a/tizen/src/option.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Emulator - * - * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * MunKyu Im - * GiWoong Kim - * YeongKyoon Lee - * HyunJun Son - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef __OPTION_H__ -#define __OPTION_H__ - -#include - -#include -#include -#include -#include -#include -#include - -int gethostproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy); -#endif - diff --git a/vl.c b/vl.c index 937bae8..db1be54 100644 --- a/vl.c +++ b/vl.c @@ -181,14 +181,12 @@ int qemu_main(int argc, char **argv, char **envp); #include "ui/qemu-spice.h" #ifdef CONFIG_MARU -#include "tizen/src/emulator.h" #include "tizen/src/maru_common.h" -#include "tizen/src/maru_display.h" -#include "tizen/src/option.h" -#include "tizen/src/sdb.h" +#include "tizen/src/emulator.h" +#include "tizen/src/maru_err_table.h" #include "tizen/src/emul_state.h" +#include "tizen/src/maru_display.h" #include "tizen/src/skin/maruskin_operation.h" -#include "tizen/src/maru_err_table.h" #endif //#define DEBUG_NET -- 2.7.4