From f65a52c4ddbfb1f531bb1f290430cddc505b3b9c Mon Sep 17 00:00:00 2001 From: Abhishek Sansanwal Date: Wed, 5 Apr 2017 10:23:40 +0530 Subject: [PATCH] Removed emulator build dependency Signed-off-by: Abhishek Sansanwal Change-Id: Ie07e500e4e1cc82d62a6815102724ec16914526c --- CMakeLists.txt | 3 - packaging/wifi-efl-ug.spec | 4 +- sources/libraries/Common/common_ip_info.c | 60 +++++---- sources/libraries/Common/common_utils.c | 109 ++++++++++++++++ sources/libraries/Common/include/common_utils.h | 2 +- .../WlanManager/WlanManager/include/wlan_manager.h | 4 - .../WlanManager/WlanManager/wlan_manager.c | 142 ++++++++++----------- sources/ui-gadget/include/ug_wifi.h | 2 - sources/ui-gadget/viewers-layout/viewer_manager.c | 39 +++--- .../ui-gadget/viewers-layout/wifi_viewer_list.c | 74 ++++++----- sources/ui-gadget/wifi-wlan-callbacks.c | 12 +- 11 files changed, 265 insertions(+), 186 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e87e81a..ce50643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,9 +22,6 @@ ENDIF(TIZEN_TETHERING_ENABLE) IF(MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE) ADD_DEFINITIONS(-DMODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE) ENDIF(MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE) -IF(TIZEN_EMULATOR) - ADD_DEFINITIONS(-DTIZEN_EMULATOR) -ENDIF(TIZEN_EMULATOR) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED diff --git a/packaging/wifi-efl-ug.spec b/packaging/wifi-efl-ug.spec index 637bc06..e1fd916 100644 --- a/packaging/wifi-efl-ug.spec +++ b/packaging/wifi-efl-ug.spec @@ -29,6 +29,7 @@ BuildRequires: pkgconfig(aul) BuildRequires: cmake BuildRequires: gettext-tools BuildRequires: edje-tools +BuildRequires: pkgconfig(libxml-2.0) Requires(post): /sbin/ldconfig requires(postun): /sbin/ldconfig @@ -53,9 +54,6 @@ cmake -DCMAKE_INSTALL_PREFIX=%{PREFIX} \ -DTIZEN_TETHERING_ENABLE=1 \ -DMODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE=1 \ -DTIZEN_MOBILE=1 \ -%if "%{?_with_emulator}" == "1" - -DTIZEN_EMULATOR=1 \ -%endif . make %{?_smp_mflags} diff --git a/sources/libraries/Common/common_ip_info.c b/sources/libraries/Common/common_ip_info.c index 8290237..8244484 100755 --- a/sources/libraries/Common/common_ip_info.c +++ b/sources/libraries/Common/common_ip_info.c @@ -997,7 +997,6 @@ static void ip_info_print_values(wifi_manager_ap_h ap) } #endif -#ifdef TIZEN_EMULATOR #define EMULATOR_MAC_ADDR_SIZE 6 #define EMULATOR_MAC_ADDR_MAX 20 static int ip_info_emulator_get_random_mac(unsigned char *buf) @@ -1019,7 +1018,6 @@ static int ip_info_emulator_get_random_mac(unsigned char *buf) return rc != EMULATOR_MAC_ADDR_SIZE ? -1 : 0; } -#endif void ip_info_delete_prev(prev_ip_info_t *prev_ip_info) { @@ -1141,38 +1139,38 @@ full_ip_info_t *ip_info_append_items(wifi_manager_ap_h ap, const char *pkg_name, ip_addr = NULL; } -#ifdef TIZEN_EMULATOR - char rand_addr[EMULATOR_MAC_ADDR_MAX]; - unsigned char rand_mac_add[EMULATOR_MAC_ADDR_SIZE + 1]; - if (ip_info_emulator_get_random_mac(rand_mac_add) == -1) { - ERROR_LOG(UG_NAME_ERR, "Failed to get random mac address"); - return NULL; - } + if (_is_emulator()) { + char rand_addr[EMULATOR_MAC_ADDR_MAX]; + unsigned char rand_mac_add[EMULATOR_MAC_ADDR_SIZE + 1]; + if (ip_info_emulator_get_random_mac(rand_mac_add) == -1) { + ERROR_LOG(UG_NAME_ERR, "Failed to get random mac address"); + return NULL; + } - rand_mac_add[0] &= 0xFE; - rand_mac_add[0] |= 0x02; - - snprintf(rand_addr, EMULATOR_MAC_ADDR_MAX, "%x:%x:%x:%x:%x:%x", - rand_mac_add[0], rand_mac_add[1], - rand_mac_add[2], rand_mac_add[3], - rand_mac_add[4], rand_mac_add[5]); - item = _add_description(genlist, - "IDS_WIFI_BODY_MAC_ADDRESS", rand_addr, NULL); - ip_info_list_data->mac_addr_item = item; -#else - char *mac_addr = NULL; - /* Mac address */ - ret = wifi_manager_ap_get_bssid(ap, &mac_addr); - if (ret != WIFI_MANAGER_ERROR_NONE) - INFO_LOG(UG_NAME_ERR, "Failed to get bssid! [%d]", ret); + rand_mac_add[0] &= 0xFE; + rand_mac_add[0] |= 0x02; - item = _add_description(genlist, - "IDS_WIFI_BODY_MAC_ADDRESS", mac_addr, NULL); - ip_info_list_data->mac_addr_item = item; + snprintf(rand_addr, EMULATOR_MAC_ADDR_MAX, "%x:%x:%x:%x:%x:%x", + rand_mac_add[0], rand_mac_add[1], + rand_mac_add[2], rand_mac_add[3], + rand_mac_add[4], rand_mac_add[5]); + item = _add_description(genlist, + "IDS_WIFI_BODY_MAC_ADDRESS", rand_addr, NULL); + ip_info_list_data->mac_addr_item = item; + } else { + char *mac_addr = NULL; + /* Mac address */ + ret = wifi_manager_ap_get_bssid(ap, &mac_addr); + if (ret != WIFI_MANAGER_ERROR_NONE) + INFO_LOG(UG_NAME_ERR, "Failed to get bssid! [%d]", ret); - g_free(mac_addr); - mac_addr = NULL; -#endif + item = _add_description(genlist, + "IDS_WIFI_BODY_MAC_ADDRESS", mac_addr, NULL); + ip_info_list_data->mac_addr_item = item; + + g_free(mac_addr); + mac_addr = NULL; + } ret = wifi_manager_ap_get_proxy_type(ap, &proxy_type); assertm_if(WIFI_MANAGER_ERROR_NONE != ret, "NULL!!"); diff --git a/sources/libraries/Common/common_utils.c b/sources/libraries/Common/common_utils.c index 3d40770..9343d99 100755 --- a/sources/libraries/Common/common_utils.c +++ b/sources/libraries/Common/common_utils.c @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #include "common.h" #include "ug_wifi.h" @@ -33,6 +36,19 @@ #define COLOR_TABLE "/usr/apps/wifi-efl-ug/shared/res/tables/ug-wifi-efl_ChangeableColorTable.xml" #define FONT_TABLE "/usr/apps/wifi-efl-ug/shared/res/tables/ug-wifi-efl_FontInfoTable.xml" +#define MODEL_CONFIG_FILE "/etc/config/model-config.xml" +#define TYPE_FIELD "string" +#define FEATURE_TAG "platform" +#define MODEL_CONFIG_TAG "model-config" + +typedef enum { + TIZEN_MODEL_UNKNOWN = 0, + TIZEN_MODEL_EMULATOR = 0x1, + TIZEN_MODEL_NOT_EMULATOR = 0x2, +} tizen_model_t; + +static tizen_model_t emulator = TIZEN_MODEL_UNKNOWN; + typedef struct { char *title_str; char *info_str; @@ -792,3 +808,96 @@ int common_utils_get_sim_state(void) return value; } + +static inline int __get_model_from_model_config_xml(const char *field, char **value) +{ + char *node_name = NULL; + char *node_value = NULL; + xmlNode *cur_node = NULL; + xmlNodePtr cur_ptr = NULL; + xmlNodePtr model_ptr = NULL; + xmlDocPtr xml_doc = NULL; + + xml_doc = xmlParseFile(MODEL_CONFIG_FILE); + if (xml_doc == NULL) + return -1; + + cur_ptr = xmlDocGetRootElement(xml_doc); + if (cur_ptr == NULL) { + xmlFreeDoc(xml_doc); + return -1; + } + + for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) { + if (!xmlStrcmp(cur_ptr->name, (const xmlChar*)MODEL_CONFIG_TAG)) + break; + } + + if (cur_ptr == NULL) { + xmlFreeDoc(xml_doc); + return -1; + } + + cur_ptr = cur_ptr->xmlChildrenNode; + for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) { + if (!xmlStrcmp(cur_node->name, (const xmlChar*)FEATURE_TAG)) { + model_ptr = cur_node; + break; + } + } + + if (model_ptr == NULL) { + xmlFreeDoc(xml_doc); + return -1; + } + + if (model_ptr) { + cur_ptr = model_ptr->xmlChildrenNode; + + for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) { + if (cur_node->type == XML_ELEMENT_NODE) { + node_name = (char *)xmlGetProp(cur_node, (const xmlChar*)"name"); + + if (!strncmp(node_name, field, strlen(node_name))) { + node_value = (char *)xmlNodeListGetString(xml_doc, cur_node->xmlChildrenNode, 1); + if (node_value) { + *value = strdup(node_value); + free(node_name); + free(node_value); + break; + } + } + free(node_name); + } + } + } + + xmlFreeDoc(xml_doc); + return 0; +} + +Eina_Bool _is_emulator(void) +{ + char *model_name = NULL; + + if (emulator == TIZEN_MODEL_EMULATOR) + return EINA_TRUE; + else if (emulator == TIZEN_MODEL_NOT_EMULATOR) + return EINA_FALSE; + + if (__get_model_from_model_config_xml("tizen.org/system/model_name", &model_name) < 0) + return EINA_FALSE; + + if (model_name == NULL) + return EINA_FALSE; + + if (strncmp(model_name, "Emulator", strlen("Emulator")) == 0) { + free(model_name); + emulator = TIZEN_MODEL_EMULATOR; + return EINA_TRUE; + } else { + free(model_name); + emulator = TIZEN_MODEL_NOT_EMULATOR; + return EINA_FALSE; + } +} diff --git a/sources/libraries/Common/include/common_utils.h b/sources/libraries/Common/include/common_utils.h index 95ef1ac..5d05df7 100755 --- a/sources/libraries/Common/include/common_utils.h +++ b/sources/libraries/Common/include/common_utils.h @@ -131,7 +131,7 @@ void common_util_manager_ecore_scan_update_timer_reset(void); gboolean common_util_subscribe_scanning_signal(GDBusSignalCallback callback); gboolean common_util_unsubscribe_scanning_signal(void); int common_utils_get_sim_state(void); - +Eina_Bool _is_emulator(void); #ifdef __cplusplus } #endif diff --git a/sources/libraries/WlanManager/WlanManager/include/wlan_manager.h b/sources/libraries/WlanManager/WlanManager/include/wlan_manager.h index a2a4772..cef6295 100755 --- a/sources/libraries/WlanManager/WlanManager/include/wlan_manager.h +++ b/sources/libraries/WlanManager/WlanManager/include/wlan_manager.h @@ -238,10 +238,8 @@ int wlan_manager_wps_pin_connect(wifi_manager_ap_h ap, const char *pin); int wlan_manager_power_on(void); int wlan_manager_power_off(void); void wlan_validate_alt_connection(void); -#ifdef TIZEN_EMULATOR int wlan_manager_emulator_power_on(void); int wlan_manager_emulator_power_off(void); -#endif int wlan_manager_disconnect(wifi_manager_ap_h); int wlan_manager_scan(void); int wlan_manager_forget(wifi_manager_ap_h ap); @@ -256,7 +254,6 @@ STRENGTH_TYPES wlan_manager_get_signal_strength(int rssi); //// profile refresh ///////////////////////////////////////////// void wlan_manager_scanned_profile_refresh(void); -#ifdef TIZEN_EMULATOR typedef struct { int event_id; guint timer_id; @@ -272,7 +269,6 @@ typedef enum { void wifi_emulator_create_event_timer(int evt_id, int itv, void *evt_cb, void *usr_data); void wifi_emulator_remove_event_timer(int evt_id); void wifi_emulator_remove_all_event_timer(void); -#endif #ifdef __cplusplus } diff --git a/sources/libraries/WlanManager/WlanManager/wlan_manager.c b/sources/libraries/WlanManager/WlanManager/wlan_manager.c index baec23f..d24fee0 100755 --- a/sources/libraries/WlanManager/WlanManager/wlan_manager.c +++ b/sources/libraries/WlanManager/WlanManager/wlan_manager.c @@ -55,9 +55,7 @@ static void wlan_manager_deregister_cbs(void); static wlan_manager_object *manager_object = NULL; -#ifdef TIZEN_EMULATOR static wifi_manager_device_state_e wifi_emulator_state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED; -#endif wlan_manager_object *wlan_manager_get_singleton(void) { @@ -256,7 +254,6 @@ exit: __COMMON_FUNC_EXIT__; } -#ifdef TIZEN_EMULATOR static GSList *emul_timer_list = NULL; void wifi_emulator_create_event_timer(int evt_id, int itv, void *evt_cb, void *usr_data) { @@ -327,7 +324,6 @@ void wifi_emulator_remove_all_event_timer(void) __COMMON_FUNC_EXIT__; } -#endif static void wlan_manager_disconnect_cb(wifi_manager_error_e error, void *user_data) { @@ -349,17 +345,15 @@ static void wlan_manager_device_state_changed_cb( wlan_manager_enable_scan_result_update(); wlan_manager_register_cbs(); event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_POWER_ON_OK; -#ifdef TIZEN_EMULATOR - wifi_emulator_state = WIFI_MANAGER_DEVICE_STATE_ACTIVATED; -#endif + if (_is_emulator()) + wifi_emulator_state = WIFI_MANAGER_DEVICE_STATE_ACTIVATED; break; case WIFI_MANAGER_DEVICE_STATE_DEACTIVATED: wlan_manager_deregister_cbs(); event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_POWER_OFF_OK; -#ifdef TIZEN_EMULATOR - wifi_emulator_state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED; -#endif + if (_is_emulator()) + wifi_emulator_state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED; break; default: @@ -555,53 +549,53 @@ int wlan_manager_state_get(void) { int ret_val = 0; -#ifdef TIZEN_EMULATOR - if (wifi_emulator_state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) - ret_val = WLAN_MANAGER_UNCONNECTED; - else - ret_val = WLAN_MANAGER_OFF; -#else - wifi_manager_connection_state_e connection_state; - bool activated; + if (_is_emulator()) { + if (wifi_emulator_state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) + ret_val = WLAN_MANAGER_UNCONNECTED; + else + ret_val = WLAN_MANAGER_OFF; + } else { + wifi_manager_connection_state_e connection_state; + bool activated; - if (WIFI_MANAGER_ERROR_NONE != wifi_manager_is_activated(manager_object->wifi, &activated)) { - return WLAN_MANAGER_ERROR; - } else if (false == activated) { - INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_OFF"); + if (WIFI_MANAGER_ERROR_NONE != wifi_manager_is_activated(manager_object->wifi, &activated)) { + return WLAN_MANAGER_ERROR; + } else if (false == activated) { + INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_OFF"); - return WLAN_MANAGER_OFF; - } + return WLAN_MANAGER_OFF; + } - ret_val = wifi_manager_get_connection_state(manager_object->wifi, &connection_state); - if (WIFI_MANAGER_ERROR_NONE != ret_val) - return WLAN_MANAGER_ERROR; + ret_val = wifi_manager_get_connection_state(manager_object->wifi, &connection_state); + if (WIFI_MANAGER_ERROR_NONE != ret_val) + return WLAN_MANAGER_ERROR; - switch (connection_state) { - case WIFI_MANAGER_CONNECTION_STATE_FAILURE: - case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED: - INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_DISCONNECTED"); + switch (connection_state) { + case WIFI_MANAGER_CONNECTION_STATE_FAILURE: + case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED: + INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_DISCONNECTED"); - ret_val = WLAN_MANAGER_UNCONNECTED; - break; - case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION: - case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION: - INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_CONNECTING"); + ret_val = WLAN_MANAGER_UNCONNECTED; + break; + case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION: + case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION: + INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_CONNECTING"); - ret_val = WLAN_MANAGER_CONNECTING; - break; - case WIFI_MANAGER_CONNECTION_STATE_CONNECTED: - INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_CONNECTED"); + ret_val = WLAN_MANAGER_CONNECTING; + break; + case WIFI_MANAGER_CONNECTION_STATE_CONNECTED: + INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_CONNECTED"); - ret_val = WLAN_MANAGER_CONNECTED; - break; - default: - ERROR_LOG(COMMON_NAME_ERR, "Unknown state: %d", connection_state); + ret_val = WLAN_MANAGER_CONNECTED; + break; + default: + ERROR_LOG(COMMON_NAME_ERR, "Unknown state: %d", connection_state); - ret_val = WLAN_MANAGER_ERROR; - break; + ret_val = WLAN_MANAGER_ERROR; + break; + } } -#endif return ret_val; } @@ -630,23 +624,23 @@ int wlan_manager_power_on(void) } #endif -#ifndef TIZEN_EMULATOR - int ret = 0; - wlan_mgr_req_data_t *req_data = g_new0(wlan_mgr_req_data_t, 1); - req_data->req_type = WLAN_MANAGER_REQ_TYPE_ACTIVATE; - ret = wifi_manager_activate(manager_object->wifi, wlan_manager_network_event_cb, req_data); - if (WIFI_MANAGER_ERROR_NONE != ret && WIFI_MANAGER_ERROR_ALREADY_EXISTS != ret) { - ERROR_LOG(UG_NAME_REQ, "Power on request. Error Reason [%d]", ret); - g_free(req_data); - - if (WIFI_MANAGER_ERROR_SECURITY_RESTRICTED == ret) - ret = common_utils_send_restriction_to_net_popup("Wi-Fi unavailable", - "toast_popup", "wifi"); - - __COMMON_FUNC_EXIT__; - return WLAN_MANAGER_ERR_UNKNOWN; + if (!_is_emulator()) { + int ret = 0; + wlan_mgr_req_data_t *req_data = g_new0(wlan_mgr_req_data_t, 1); + req_data->req_type = WLAN_MANAGER_REQ_TYPE_ACTIVATE; + ret = wifi_manager_activate(manager_object->wifi, wlan_manager_network_event_cb, req_data); + if (WIFI_MANAGER_ERROR_NONE != ret && WIFI_MANAGER_ERROR_ALREADY_EXISTS != ret) { + ERROR_LOG(UG_NAME_REQ, "Power on request. Error Reason [%d]", ret); + g_free(req_data); + + if (WIFI_MANAGER_ERROR_SECURITY_RESTRICTED == ret) + ret = common_utils_send_restriction_to_net_popup("Wi-Fi unavailable", + "toast_popup", "wifi"); + + __COMMON_FUNC_EXIT__; + return WLAN_MANAGER_ERR_UNKNOWN; + } } -#endif __COMMON_FUNC_EXIT__; return WLAN_MANAGER_ERR_NONE; @@ -656,26 +650,25 @@ int wlan_manager_power_off(void) { __COMMON_FUNC_ENTER__; -#ifndef TIZEN_EMULATOR - wlan_mgr_req_data_t *req_data = g_new0(wlan_mgr_req_data_t, 1); - req_data->req_type = WLAN_MANAGER_REQ_TYPE_DEACTIVATE; + if (!_is_emulator()) { + wlan_mgr_req_data_t *req_data = g_new0(wlan_mgr_req_data_t, 1); + req_data->req_type = WLAN_MANAGER_REQ_TYPE_DEACTIVATE; - int ret = wifi_manager_deactivate(manager_object->wifi, wlan_manager_network_event_cb, req_data); - if (WIFI_MANAGER_ERROR_NONE != ret && WIFI_MANAGER_ERROR_ALREADY_EXISTS != ret) { - ERROR_LOG(UG_NAME_REQ, "Power off request. Error Reason [%d]", ret); + int ret = wifi_manager_deactivate(manager_object->wifi, wlan_manager_network_event_cb, req_data); + if (WIFI_MANAGER_ERROR_NONE != ret && WIFI_MANAGER_ERROR_ALREADY_EXISTS != ret) { + ERROR_LOG(UG_NAME_REQ, "Power off request. Error Reason [%d]", ret); - g_free(req_data); + g_free(req_data); - __COMMON_FUNC_EXIT__; - return WLAN_MANAGER_ERR_UNKNOWN; + __COMMON_FUNC_EXIT__; + return WLAN_MANAGER_ERR_UNKNOWN; + } } -#endif __COMMON_FUNC_EXIT__; return WLAN_MANAGER_ERR_NONE; } -#ifdef TIZEN_EMULATOR int wlan_manager_emulator_power_on(void) { wlan_manager_device_state_changed_cb(WIFI_MANAGER_DEVICE_STATE_ACTIVATED, NULL); @@ -697,7 +690,6 @@ int wlan_manager_emulator_power_off(void) return WLAN_MANAGER_ERR_NONE; } -#endif int wlan_manager_wps_connect(wifi_manager_ap_h ap) { diff --git a/sources/ui-gadget/include/ug_wifi.h b/sources/ui-gadget/include/ug_wifi.h index 7a299be..fa9c4ae 100755 --- a/sources/ui-gadget/include/ug_wifi.h +++ b/sources/ui-gadget/include/ug_wifi.h @@ -81,13 +81,11 @@ struct ug_data { Evas_Object *elm_conform; }; -#ifdef TIZEN_EMULATOR typedef struct { char *ssid; int security; int wps; } wifi_emulator_sample_s; -#endif int wifi_exit(void); bool wifi_is_scan_required(void); diff --git a/sources/ui-gadget/viewers-layout/viewer_manager.c b/sources/ui-gadget/viewers-layout/viewer_manager.c index 3c58d91..ec135af 100755 --- a/sources/ui-gadget/viewers-layout/viewer_manager.c +++ b/sources/ui-gadget/viewers-layout/viewer_manager.c @@ -84,7 +84,6 @@ static Eina_Bool rotate_flag = EINA_FALSE; static bool show_more = TRUE; -#ifdef TIZEN_EMULATOR wifi_emulator_sample_s wifi_samples[] = { {"datanetwork", WLAN_SEC_MODE_WPA_PSK, 1}, {"ureadyinternet", WLAN_SEC_MODE_IEEE8021X, 0}, @@ -93,7 +92,6 @@ wifi_emulator_sample_s wifi_samples[] = { {"Tizen", WLAN_SEC_MODE_WPA2_PSK, 1}, }; int wifi_sample_count = sizeof(wifi_samples) / sizeof(wifi_samples[0]); -#endif static void _hidden_button_callback(void* data, Evas_Object* obj, void* event_info); static void viewer_manager_hidden_confirm_cleanup(void); @@ -185,10 +183,11 @@ void power_control(void) viewer_manager_show(VIEWER_WINSET_SEARCHING); viewer_manager_header_mode_set(HEADER_MODE_ACTIVATING); viewer_manager_create_scan_btn(); -#ifdef TIZEN_EMULATOR - wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_ACTIVATE, - 1000, wlan_manager_emulator_power_on, NULL); -#endif + + if (_is_emulator()) { + wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_ACTIVATE, + 1000, wlan_manager_emulator_power_on, NULL); + } break; #if defined TIZEN_TETHERING_ENABLE @@ -226,10 +225,10 @@ void power_control(void) // Lets ignore all the scan updates because we are powering off now. wlan_manager_disable_scan_result_update(); -#ifdef TIZEN_EMULATOR - wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_DEACTIVATE, - 500, wlan_manager_emulator_power_off, NULL); -#endif + if (_is_emulator()) { + wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_DEACTIVATE, + 500, wlan_manager_emulator_power_off, NULL); + } break; case WLAN_MANAGER_ERR_IN_PROGRESS: @@ -1693,7 +1692,6 @@ static gint compare(gconstpointer a, gconstpointer b) } } -#ifndef TIZEN_EMULATOR static bool wifi_update_list_for_each_ap(wifi_manager_ap_h ap, void *user_data) { int *profile_size = (int *)user_data; @@ -1708,9 +1706,7 @@ static bool wifi_update_list_for_each_ap(wifi_manager_ap_h ap, void *user_data) return true; } -#endif -#ifdef TIZEN_EMULATOR static wifi_device_info_t *view_list_item_emulator_device_info_create(int index) { wifi_device_info_t* wifi_device = NULL; @@ -1742,7 +1738,6 @@ static void wifi_update_list_for_emulator_ap(void) INFO_LOG(UG_NAME_NORMAL, "wifi_device_list added device(%s)", wifi_device->ssid); } } -#endif static int viewer_manager_update_list_all(char *ssid) { @@ -1760,12 +1755,11 @@ static int viewer_manager_update_list_all(char *ssid) manager_object->sort_type = _convert_vconf_to_sort_by_value( common_util_get_system_registry(VCONF_SORT_BY)); -#ifdef TIZEN_EMULATOR - profiles_list_size = wifi_sample_count; - wifi_update_list_for_emulator_ap(); -#else - wlan_manager_foreach_found_ap(wifi_update_list_for_each_ap, &profiles_list_size); -#endif + if (_is_emulator()) { + profiles_list_size = wifi_sample_count; + wifi_update_list_for_emulator_ap(); + } else + wlan_manager_foreach_found_ap(wifi_update_list_for_each_ap, &profiles_list_size); list_of_device = wifi_device_list; for (i = 0; i < profiles_list_size && list_of_device != NULL; i++) { @@ -1819,9 +1813,8 @@ static int viewer_manager_update_list_all(char *ssid) } } -#ifdef TIZEN_EMULATOR - wifi_emulator_remove_event_timer(WIFI_EMUL_EVENT_TIMER_SCAN); -#endif + if (_is_emulator()) + wifi_emulator_remove_event_timer(WIFI_EMUL_EVENT_TIMER_SCAN); __COMMON_FUNC_EXIT__; return ssid_count; diff --git a/sources/ui-gadget/viewers-layout/wifi_viewer_list.c b/sources/ui-gadget/viewers-layout/wifi_viewer_list.c index e9e4f03..0777901 100755 --- a/sources/ui-gadget/viewers-layout/wifi_viewer_list.c +++ b/sources/ui-gadget/viewers-layout/wifi_viewer_list.c @@ -1020,7 +1020,6 @@ int viewer_list_item_radio_mode_set(Elm_Object_Item* item, return TRUE; } -#ifndef TIZEN_EMULATOR static wifi_manager_connection_state_e _convert_wifi_state_to_viewer_radio_mode( wifi_manager_connection_state_e state) { @@ -1035,7 +1034,6 @@ static wifi_manager_connection_state_e _convert_wifi_state_to_viewer_radio_mode( return VIEWER_ITEM_RADIO_MODE_OFF; } } -#endif Elm_Object_Item *viewer_list_item_insert_after(wifi_device_info_t *wifi_device, Elm_Object_Item *after) @@ -1045,48 +1043,48 @@ Elm_Object_Item *viewer_list_item_insert_after(wifi_device_info_t *wifi_device, wifi_device_info_t *no_wifi_device = NULL; retvm_if(NULL == viewer_list, NULL); -#ifdef TIZEN_EMULATOR - if (wifi_device != NULL) { - wifi_device->ap_status_txt = viewer_list_get_device_status_txt( - wifi_device, - VIEWER_ITEM_RADIO_MODE_OFF); - } else { - no_wifi_device = g_try_new0(wifi_device_info_t, 1); - if (no_wifi_device == NULL) - return NULL; + if (_is_emulator()) { + if (wifi_device != NULL) { + wifi_device->ap_status_txt = viewer_list_get_device_status_txt( + wifi_device, + VIEWER_ITEM_RADIO_MODE_OFF); + } else { + no_wifi_device = g_try_new0(wifi_device_info_t, 1); + if (no_wifi_device == NULL) + return NULL; - no_wifi_device->ssid = g_strdup(sc(PACKAGE, I18N_TYPE_No_Wi_Fi_AP_Found)); - wifi_device = no_wifi_device; - } -#else - wifi_manager_connection_state_e state = WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED; - VIEWER_ITEM_RADIO_MODES rad_mode = VIEWER_ITEM_RADIO_MODE_OFF; - if (wifi_device != NULL && wifi_device->ap != NULL) { - if (wifi_manager_ap_get_connection_state(wifi_device->ap, &state) == - WIFI_MANAGER_ERROR_NONE) { - rad_mode = _convert_wifi_state_to_viewer_radio_mode(state); + no_wifi_device->ssid = g_strdup(sc(PACKAGE, I18N_TYPE_No_Wi_Fi_AP_Found)); + wifi_device = no_wifi_device; } - wifi_device->ap_status_txt = viewer_list_get_device_status_txt( - wifi_device, - rad_mode); } else { - if (ug_app_state->is_first_scan == true) { - int scan_result = wlan_manager_scan(); - if (scan_result != WLAN_MANAGER_ERR_NONE) { - viewer_manager_hide(VIEWER_WINSET_SEARCHING); - viewer_manager_header_mode_set(viewer_manager_header_mode_get()); + wifi_manager_connection_state_e state = WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED; + VIEWER_ITEM_RADIO_MODES rad_mode = VIEWER_ITEM_RADIO_MODE_OFF; + if (wifi_device != NULL && wifi_device->ap != NULL) { + if (wifi_manager_ap_get_connection_state(wifi_device->ap, &state) == + WIFI_MANAGER_ERROR_NONE) { + rad_mode = _convert_wifi_state_to_viewer_radio_mode(state); } - ug_app_state->is_first_scan = false; - return NULL; - } - no_wifi_device = g_try_new0(wifi_device_info_t, 1); - if (no_wifi_device == NULL) - return NULL; + wifi_device->ap_status_txt = viewer_list_get_device_status_txt( + wifi_device, + rad_mode); + } else { + if (ug_app_state->is_first_scan == true) { + int scan_result = wlan_manager_scan(); + if (scan_result != WLAN_MANAGER_ERR_NONE) { + viewer_manager_hide(VIEWER_WINSET_SEARCHING); + viewer_manager_header_mode_set(viewer_manager_header_mode_get()); + } + ug_app_state->is_first_scan = false; + return NULL; + } + no_wifi_device = g_try_new0(wifi_device_info_t, 1); + if (no_wifi_device == NULL) + return NULL; - no_wifi_device->ssid = g_strdup(sc(PACKAGE, I18N_TYPE_No_Wi_Fi_AP_Found)); - wifi_device = no_wifi_device; + no_wifi_device->ssid = g_strdup(sc(PACKAGE, I18N_TYPE_No_Wi_Fi_AP_Found)); + wifi_device = no_wifi_device; + } } -#endif gdata = g_try_new0(ug_genlist_data_t, 1); if (gdata == NULL) { diff --git a/sources/ui-gadget/wifi-wlan-callbacks.c b/sources/ui-gadget/wifi-wlan-callbacks.c index 736f8a8..f59629a 100755 --- a/sources/ui-gadget/wifi-wlan-callbacks.c +++ b/sources/ui-gadget/wifi-wlan-callbacks.c @@ -27,6 +27,7 @@ #include "viewer_manager.h" #include "wlan_connection.h" #include "wifi-engine-callback.h" +#include "common_utils.h" extern wifi_appdata *ug_app_state; @@ -297,12 +298,11 @@ void wlan_engine_refresh_callback(void) { __COMMON_FUNC_ENTER__; -#ifdef TIZEN_EMULATOR - wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_SCAN, - 1000, viewer_manager_refresh, NULL); -#else - viewer_manager_refresh(); -#endif + if (_is_emulator()) { + wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_SCAN, + 1000, viewer_manager_refresh, NULL); + } else + viewer_manager_refresh(); __COMMON_FUNC_EXIT__; } -- 2.7.4