From: SeokYeon Hwang Date: Mon, 14 Jul 2014 09:18:58 +0000 (+0900) Subject: emulator: move get_log_path(), get_bin_path() to emul_state X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~228^2^2~70 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=758cb9b7b9f0d3fbf59db4e875b914ddd05bcee8;p=sdk%2Femulator%2Fqemu.git emulator: move get_log_path(), get_bin_path() to emul_state Change-Id: Ie41921003dc6c191a44c83600bb26901c1c2d5b7 Signed-off-by: SeokYeon Hwang --- diff --git a/tizen/src/ecs/ecs_msg.c b/tizen/src/ecs/ecs_msg.c index 866b9eff9c..48f2f7f94f 100644 --- a/tizen/src/ecs/ecs_msg.c +++ b/tizen/src/ecs/ecs_msg.c @@ -67,7 +67,6 @@ #include "skin/maruskin_operation.h" #include "skin/maruskin_server.h" #include "util/maru_device_hotplug.h" -#include "emulator.h" #include "emul_state.h" #include "debug_ch.h" @@ -994,7 +993,7 @@ static char* get_emulator_sdcard_path(void) */ char *get_tizen_sdk_data_path(void) { - char *emul_bin_path = NULL; + char const *emul_bin_path = NULL; char *sdk_info_file_path = NULL; char *tizen_sdk_data_path = NULL; #ifndef CONFIG_WIN32 diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 67286fbfc1..7e10d185d9 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -30,8 +30,9 @@ */ #include "emul_state.h" +#include "emulator_options.h" #include "skin/maruskin_server.h" -#include "debug_ch.h" +#include "util/new_debug_ch.h" #if defined(CONFIG_LINUX) #include @@ -39,12 +40,51 @@ #include #endif -MULTI_DEBUG_CHANNEL(qemu, emul_state); - +DECLARE_DEBUG_CHANNEL(emul_state); static EmulatorConfigInfo _emul_info = {0,}; static EmulatorConfigState _emul_state; +/* misc */ +char bin_path[PATH_MAX] = { 0, }; +#ifdef SUPPORT_LEGACY_ARGS +// for compatibility +char log_path[PATH_MAX] = { 0, }; +#endif + + +const char *get_bin_path(void) +{ + return bin_path; +} + +const char *get_log_path(void) +{ +#ifdef SUPPORT_LEGACY_ARGS + if (log_path[0]) { + return log_path; + } +#endif + char *log_path = get_variable("log_path"); + + // if "log_path" is not exist, make it first + if (!log_path) { + char *vms_path = get_variable("vms_path"); + char *vm_name = get_variable("vm_name"); + if (!vms_path || !vm_name) { + log_path = NULL; + } + else { + log_path = g_strdup_printf("%s/%s/logs", vms_path, vm_name); + } + + set_variable("log_path", log_path, false); + } + + return log_path; +} + + /* start_skin_client or not ? */ void set_emul_skin_enable(bool enable) { @@ -62,7 +102,7 @@ void set_emul_resolution(int width, int height) _emul_info.resolution_w = width; _emul_info.resolution_h = height; - INFO("emulator graphic resolution : %dx%d\n", + LOG_INFO("emulator graphic resolution : %dx%d\n", _emul_info.resolution_w, _emul_info.resolution_h); } @@ -82,7 +122,7 @@ void set_emul_sdl_bpp(int bpp) _emul_info.sdl_bpp = bpp; if (_emul_info.sdl_bpp != 32) { - INFO("sdl bpp : %d\n", _emul_info.sdl_bpp); + LOG_INFO("sdl bpp : %d\n", _emul_info.sdl_bpp); } } @@ -97,7 +137,7 @@ void set_emul_input_mouse_enable(bool on) _emul_info.input_mouse_enable = on; if (_emul_info.input_mouse_enable == true) { - INFO("set_emul_input_mouse_enable\n"); + LOG_INFO("set_emul_input_mouse_enable\n"); } } @@ -112,7 +152,7 @@ void set_emul_input_touch_enable(bool on) _emul_info.input_touch_enable = on; if (_emul_info.input_touch_enable == true) { - INFO("set_emul_input_touch_enable\n"); + LOG_INFO("set_emul_input_touch_enable\n"); } } @@ -129,7 +169,7 @@ void set_emul_max_touch_point(int cnt) } _emul_info.max_touch_point = cnt; - INFO("set max touch point : %d\n", cnt); + LOG_INFO("set max touch point : %d\n", cnt); } int get_emul_max_touch_point(void) @@ -177,10 +217,10 @@ int get_emulator_condition(void) void set_emulator_condition(int state) { if (state == BOOT_COMPLETED) { - INFO("boot completed!\n"); + LOG_INFO("boot completed!\n"); // TODO: } else if (state == RESET) { - INFO("reset emulator!\n"); + LOG_INFO("reset emulator!\n"); notify_emul_reset(); } @@ -192,12 +232,12 @@ void set_emulator_condition(int state) void set_emul_win_scale(double scale_factor) { if (scale_factor < 0.0 || scale_factor > 2.0) { - INFO("scale_factor is out of range : %f\n", scale_factor); + LOG_INFO("scale_factor is out of range : %f\n", scale_factor); scale_factor = 1.0; } _emul_state.scale_factor = scale_factor; - INFO("emulator window scale_factor : %f\n", _emul_state.scale_factor); + LOG_INFO("emulator window scale_factor : %f\n", _emul_state.scale_factor); } double get_emul_win_scale(void) @@ -210,12 +250,12 @@ void set_emul_rotation(short rotation_type) { if (rotation_type < ROTATION_PORTRAIT || rotation_type > ROTATION_REVERSE_LANDSCAPE) { - INFO("rotation type is out of range : %d\n", rotation_type); + LOG_INFO("rotation type is out of range : %d\n", rotation_type); rotation_type = ROTATION_PORTRAIT; } _emul_state.rotation_type = rotation_type; - INFO("emulator rotation type : %d\n", _emul_state.rotation_type); + LOG_INFO("emulator rotation type : %d\n", _emul_state.rotation_type); } short get_emul_rotation(void) diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index f63fb8af2a..0cadfcd9ad 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -36,6 +36,8 @@ #include "display/maru_finger.h" +#define SUPPORT_LEGACY_ARGS + enum { RESET = 0, BOOT_COMPLETED = 1, @@ -104,6 +106,14 @@ typedef struct EmulatorConfigState { /* add here */ } EmulatorConfigState; +/* misc */ +extern gchar bin_path[]; +#ifdef SUPPORT_LEGACY_ARGS +extern gchar log_path[]; +#endif + +char const *get_bin_path(void); +char const *get_log_path(void); /* setter */ void set_emul_skin_enable(bool enable); diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index c115991df4..60b1a5b5e1 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -30,6 +30,7 @@ #include #include +#include #include "qemu/config-file.h" #include "qemu/sockets.h" @@ -51,26 +52,17 @@ #include #endif -#ifdef CONFIG_WIN32 -#include -#endif - #ifdef CONFIG_DARWIN -#include #include "ns_event.h" int thread_running = 1; /* Check if we need exit main */ #endif DECLARE_DEBUG_CHANNEL(main); -#define SUPPORT_LEGACY_ARGS - #define ARGS_LIMIT 128 #define LEN_MARU_KERNEL_CMDLINE 512 char maru_kernel_cmdline[LEN_MARU_KERNEL_CMDLINE]; -char bin_path[PATH_MAX] = { 0, }; - char tizen_target_path[PATH_MAX]; char tizen_target_img_path[PATH_MAX]; @@ -82,32 +74,6 @@ char **_skin_argv; int _qemu_argc; char **_qemu_argv; -const char *get_log_path(void) -{ -#ifdef SUPPORT_LEGACY_ARGS - if (log_path[0]) { - return log_path; - } -#endif - char *log_path = get_variable("log_path"); - - // if "log_path" is not exist, make it first - if (!log_path) { - char *vms_path = get_variable("vms_path"); - char *vm_name = get_variable("vm_name"); - if (!vms_path || !vm_name) { - log_path = NULL; - } - else { - log_path = g_strdup_printf("%s/%s/logs", vms_path, vm_name); - } - - set_variable("log_path", log_path, false); - } - - return log_path; -} - void emulator_add_exit_notifier(Notifier *notify) { qemu_add_exit_notifier(notify); @@ -137,16 +103,11 @@ static void get_host_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, get_host_proxy_os(http_proxy, https_proxy, ftp_proxy, socks_proxy); } -static void set_bin_path(gchar * exec_argv) +static void set_bin_path(char const *const exec_argv) { set_bin_path_os(exec_argv); } -gchar * get_bin_path(void) -{ - return bin_path; -} - static void check_vm_lock(void) { check_vm_lock_os(); @@ -292,7 +253,7 @@ static void prepare_opengl_acceleration(gchar * const kernel_cmdline) } #endif -const gchar *prepare_maru(const gchar * const kernel_cmdline) +const char *prepare_maru(const gchar * const kernel_cmdline) { LOG_INFO("Prepare maru specified feature\n"); diff --git a/tizen/src/emulator.h b/tizen/src/emulator.h index 7198e4cf7d..cd918b483d 100644 --- a/tizen/src/emulator.h +++ b/tizen/src/emulator.h @@ -42,15 +42,9 @@ #include "qemu/option.h" #include "sysemu/sysemu.h" -extern gchar bin_path[]; -extern gchar log_path[]; - -char *get_bin_path(void); -const gchar * prepare_maru(const gchar * const kernel_cmdline); +const char *prepare_maru(const gchar * const kernel_cmdline); void start_skin(void); -const gchar * get_log_path(void); - void emulator_add_exit_notifier(Notifier *notify); #endif /* __EMULATOR_H__ */ diff --git a/tizen/src/emulator_legacy.c b/tizen/src/emulator_legacy.c index 3d75746b89..3b8194c95f 100644 --- a/tizen/src/emulator_legacy.c +++ b/tizen/src/emulator_legacy.c @@ -69,9 +69,6 @@ MULTI_DEBUG_CHANNEL(qemu, main); #define MIDBUF 128 #define LEN_MARU_KERNEL_CMDLINE 512 -// for compatibility -gchar log_path[PATH_MAX] = { 0, }; - extern gchar maru_kernel_cmdline[LEN_MARU_KERNEL_CMDLINE]; extern char tizen_target_path[PATH_MAX]; diff --git a/tizen/src/emulator_options.c b/tizen/src/emulator_options.c index 2c43aa691f..d683dbde5c 100644 --- a/tizen/src/emulator_options.c +++ b/tizen/src/emulator_options.c @@ -30,7 +30,7 @@ #include "qemu/queue.h" #include "emulator_options.h" -#include "emulator.h" +#include "emul_state.h" #define LINE_LIMIT 1024 #define TOKEN_LIMIT 128 diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index 5a327f02a8..5001a1cb52 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -138,13 +138,13 @@ static void *run_skin_client(void *arg) strcpy(JAVA_EXEFILE_PATH, "java"); } - char* bin_dir = get_bin_path(); + char const* bin_dir = get_bin_path(); int bin_len = strlen(bin_dir); char bin_dir_win[bin_len]; strcpy(bin_dir_win, bin_dir); bin_dir_win[strlen(bin_dir_win) -1] = '\0'; #else - char* bin_dir = get_bin_path(); + char const* bin_dir = get_bin_path(); #endif INFO("bin directory : %s\n", bin_dir); @@ -367,13 +367,13 @@ int start_simple_client(char* msg) strcpy(JAVA_EXEFILE_PATH, "java"); } - char* bin_dir = get_bin_path(); + char const* bin_dir = get_bin_path(); int bin_dir_len = strlen(bin_dir); char bin_dir_win[bin_dir_len]; strcpy(bin_dir_win, bin_dir); bin_dir_win[strlen(bin_dir_win) -1] = '\0'; #else - char* bin_dir = get_bin_path(); + char const* bin_dir = get_bin_path(); #endif INFO("bin directory : %s\n", bin_dir); diff --git a/tizen/src/util/new_debug_ch.c b/tizen/src/util/new_debug_ch.c index e27abdef08..4effe690a2 100644 --- a/tizen/src/util/new_debug_ch.c +++ b/tizen/src/util/new_debug_ch.c @@ -32,7 +32,7 @@ #include "qemu-common.h" -#include "emulator.h" +#include "emul_state.h" #include "util/new_debug_ch.h" #include "util/osutil.h" diff --git a/tizen/src/util/osutil-darwin.c b/tizen/src/util/osutil-darwin.c index a4f483cda3..feedd7fbe4 100644 --- a/tizen/src/util/osutil-darwin.c +++ b/tizen/src/util/osutil-darwin.c @@ -126,7 +126,7 @@ void remove_vm_lock_os(void) } } -void set_bin_path_os(gchar * exec_argv) +void set_bin_path_os(char const *const exec_argv) { gchar *file_name = NULL; diff --git a/tizen/src/util/osutil-linux.c b/tizen/src/util/osutil-linux.c index 866355ba23..4e898941cd 100644 --- a/tizen/src/util/osutil-linux.c +++ b/tizen/src/util/osutil-linux.c @@ -160,7 +160,7 @@ void remove_vm_lock_os(void) } -void set_bin_path_os(gchar * exec_argv) +void set_bin_path_os(char const *const exec_argv) { gchar link_path[PATH_MAX] = { 0, }; char *file_name = NULL; diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index fc2349a913..05771cbf49 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -144,7 +144,7 @@ void remove_vm_lock_os(void) } -void set_bin_path_os(gchar * exec_argv) +void set_bin_path_os(char const *const exec_argv) { gchar link_path[PATH_MAX] = { 0, }; gchar *file_name = NULL; diff --git a/tizen/src/util/osutil.h b/tizen/src/util/osutil.h index 566f4a3034..926f3a0a37 100644 --- a/tizen/src/util/osutil.h +++ b/tizen/src/util/osutil.h @@ -64,7 +64,7 @@ void check_vm_lock_os(void); void make_vm_lock_os(void); void remove_vm_lock_os(void); -void set_bin_path_os(gchar *); +void set_bin_path_os(char const *const); void print_system_info_os(void);