Added the emulator feature to operate wifi on emulator 91/87891/2
authorhyunuktak <hyunuk.tak@samsung.com>
Mon, 12 Sep 2016 05:04:39 +0000 (14:04 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Tue, 20 Sep 2016 08:36:49 +0000 (17:36 +0900)
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
Change-Id: I813a504a039cf00dd64b2136923cd0984caf3769

CMakeLists.txt
packaging/wifi-efl-ug.spec
sources/libraries/Common/common_ip_info.c
sources/libraries/WlanManager/WlanManager/include/wlan_manager.h [changed mode: 0644->0755]
sources/libraries/WlanManager/WlanManager/wlan_manager.c
sources/ui-gadget/include/ug_wifi.h [changed mode: 0644->0755]
sources/ui-gadget/include/viewer_manager.h
sources/ui-gadget/viewers-layout/viewer_manager.c
sources/ui-gadget/viewers-layout/wifi_viewer_list.c
sources/ui-gadget/wifi-wlan-callbacks.c

index 824f982..2e892d1 100644 (file)
@@ -22,6 +22,9 @@ 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
index 97448f6..d7f0e09 100644 (file)
@@ -1,7 +1,7 @@
 %define _unpackaged_files_terminate_build 0
 Name:          wifi-efl-ug
 Summary:       Wi-Fi UI Gadget for TIZEN
-Version:       1.0.201
+Version:       1.0.202
 Release:       1
 Group:         App/Network
 License:       Flora-1.1
@@ -77,6 +77,9 @@ cmake -DCMAKE_INSTALL_PREFIX=%{PREFIX} \
 %if "%{profile}" == "wearable"
        -DTIZEN_WEARABLE=1 \
 %endif
+%if "%{?_with_emulator}" == "1"
+       -DTIZEN_EMULATOR=1 \
+%endif
        .
 
 make %{?_smp_mflags}
index d75b926..eb10f7e 100755 (executable)
@@ -1051,6 +1051,7 @@ static Evas_Object *_ip_info_iptoggle_content_get(void *data,
        return toggle_btn;
 }
 
+#if 0
 static void ip_info_print_values(wifi_ap_h ap)
 {
        char *txt;
@@ -1119,6 +1120,31 @@ static void ip_info_print_values(wifi_ap_h ap)
        SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* PROXY PORT [%s]", proxy_port);
        g_free(txt);
 }
+#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)
+{
+       __COMMON_FUNC_ENTER__;
+
+       FILE *fp;
+       int rc;
+
+       fp = fopen("/dev/urandom", "rb");
+       if (fp == NULL) {
+               ERROR_LOG(UG_NAME_ERR, "Could not open /dev/urandom");
+               return -1;
+       }
+
+       rc = fread(buf, 1, EMULATOR_MAC_ADDR_SIZE, fp);
+       if (fp)
+               fclose(fp);
+
+       return rc != EMULATOR_MAC_ADDR_SIZE ? -1 : 0;
+}
+#endif
 
 void ip_info_delete_prev(prev_ip_info_t *prev_ip_info)
 {
@@ -1150,7 +1176,6 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name,
        common_utils_entry_info_t *edit_box_details;
        wifi_proxy_type_e proxy_type;
        char *ip_addr = NULL;
-       char *mac_addr = NULL;
        char *temp = NULL;
        char *str2 = NULL;
        full_ip_info_t *ip_data = NULL;
@@ -1246,6 +1271,26 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name,
        g_free(channel_num_str);
 #endif
 
+#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;
+       }
+
+       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_ap_get_bssid(ap, &mac_addr);
        if (ret != WIFI_ERROR_NONE)
@@ -1256,6 +1301,7 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name,
        ip_info_list_data->mac_addr_item = item;
 
        g_free(mac_addr);
+#endif
 
        ret = wifi_ap_get_proxy_type(ap, &proxy_type);
        assertm_if(WIFI_ERROR_NONE != ret, "NULL!!");
@@ -1449,7 +1495,7 @@ void ip_info_save_data(full_ip_info_t *ip_data)
                g_free((gpointer)txt);
        }
 
-       ip_info_print_values(ap);
+       /* ip_info_print_values(ap); */
 
        __COMMON_FUNC_EXIT__;
 }
old mode 100644 (file)
new mode 100755 (executable)
index f78b1da..5f387e3
@@ -230,6 +230,10 @@ int wlan_manager_wps_connect(wifi_ap_h ap);
 int wlan_manager_wps_pin_connect(wifi_ap_h ap, const char *pin);
 int wlan_manager_power_on(void);
 int wlan_manager_power_off(void);
+#ifdef TIZEN_EMULATOR
+int wlan_manager_emulator_power_on(void);
+int wlan_manager_emulator_power_off(void);
+#endif
 int wlan_manager_scan(void);
 int wlan_manager_forget(wifi_ap_h ap);
 int wlan_manager_scan_with_ssid(const char *ssid, void *data);
@@ -243,6 +247,24 @@ 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;
+} wifi_emul_timer_s;
+
+typedef enum {
+       WIFI_EMUL_EVENT_TIMER_ACTIVATE = 0x00,
+       WIFI_EMUL_EVENT_TIMER_DEACTIVATE,
+       WIFI_EMUL_EVENT_TIMER_SCAN,
+       WIFI_EMUL_EVENT_TIMER_MAX,
+} wifi_emul_event_timer_e;
+
+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
 }
 #endif
index f486104..0fe7208 100755 (executable)
@@ -55,6 +55,10 @@ static void wlan_manager_deregister_cbs(void);
 
 static wlan_manager_object *manager_object = NULL;
 
+#ifdef TIZEN_EMULATOR
+static int wifi_emulator_state = WIFI_DEVICE_STATE_DEACTIVATED;
+#endif
+
 wlan_manager_object *wlan_manager_get_singleton(void)
 {
        if (NULL == manager_object) {
@@ -143,6 +147,176 @@ int wlan_manager_forget(wifi_ap_h ap)
        return WLAN_MANAGER_ERR_NONE;
 }
 
+static void wlan_manager_network_event_cb(
+               wifi_error_e error_code, void *user_data)
+{
+       __COMMON_FUNC_ENTER__;
+
+       wlan_mgr_req_data_t *req_data = (wlan_mgr_req_data_t *)user_data;
+       if (req_data == NULL) {
+               ERROR_LOG(UG_NAME_ERR, "Request data is NULL !!!");
+
+               __COMMON_FUNC_EXIT__;
+               return;
+       }
+
+       wlan_mgr_event_info_t event_info;
+       memset(&event_info, 0, sizeof(event_info));
+
+       switch (req_data->req_type) {
+       case WLAN_MANAGER_REQ_TYPE_ACTIVATE:
+               /* fall through */
+       case WLAN_MANAGER_REQ_TYPE_DEACTIVATE:
+               /* We will send POWER_ON_OK / POWER_OFF_OK response when we receive
+                * device state change. Lets just clean up the request data now.
+                */
+               goto exit;
+               /* fall through */
+       case WLAN_MANAGER_REQ_TYPE_SCAN:
+               if (WIFI_ERROR_NONE == error_code) {
+                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_SCAN_OK;
+               } else {
+                       goto exit;
+               }
+
+               break;
+
+       case WLAN_MANAGER_REQ_TYPE_SPECIFIC_SCAN:
+               if (WIFI_ERROR_NONE == error_code) {
+                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_SPECIFIC_SCAN_OK;
+               } else {
+                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_SPECIFIC_SCAN_FAIL;
+               }
+
+               break;
+
+       case WLAN_MANAGER_REQ_TYPE_SCAN_RESULT:
+               if (WIFI_ERROR_NONE == error_code) {
+                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_SCAN_RESULT_IND;
+                       manager_object->message_func(&event_info, req_data->user_data);
+               }
+
+               return; // The request data is static. So returning here.
+
+       case WLAN_MANAGER_REQ_TYPE_CONNECT:
+               event_info.ap = req_data->ap;
+
+               if (WIFI_ERROR_NONE != error_code) {
+                       if (error_code == WIFI_ERROR_INVALID_KEY) {
+                               event_info.event_type =
+                                               WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_INVALID_KEY;
+                       } else if (error_code == WIFI_ERROR_DHCP_FAILED) {
+                               event_info.event_type =
+                                               WLAN_MANAGER_RESPONSE_TYPE_DHCP_FAILED;
+                       } else {
+                               event_info.event_type =
+                                               WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_CONNECT_FAILED;
+                       }
+               } else {
+                       goto exit;
+               }
+
+               break;
+
+       case WLAN_MANAGER_REQ_TYPE_WPS_CONNECT:
+               event_info.ap = req_data->ap;
+
+               if (WIFI_ERROR_NONE != error_code) {
+                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_WPS_ENROLL_FAIL;
+               } else {
+                       goto exit;
+               }
+
+               break;
+
+       default:
+               goto exit;
+       }
+
+       manager_object->message_func(&event_info, req_data->user_data);
+
+exit:
+       if (req_data != NULL) {
+               wifi_ap_destroy(req_data->ap);
+               g_free(req_data);
+       }
+
+       __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)
+{
+       __COMMON_FUNC_ENTER__;
+
+       wifi_emul_timer_s *evt_info = NULL;
+       evt_info = g_try_malloc0(sizeof(wifi_emul_timer_s));
+       if (evt_info == NULL) {
+               ERROR_LOG(UG_NAME_ERR, "malloc fail");
+               return;
+       }
+
+       wifi_emulator_remove_event_timer(evt_id);
+
+       evt_info->event_id = evt_id;
+       evt_info->timer_id = g_timeout_add(itv, (GSourceFunc)evt_cb, (gpointer)usr_data);
+
+       INFO_LOG(UG_NAME_NORMAL, "Create emulator event timer. event id: %d, timer id: %d\n",
+                               evt_id, evt_info->timer_id);
+
+       emul_timer_list = g_slist_append(emul_timer_list, evt_info);
+
+       __COMMON_FUNC_EXIT__;
+}
+
+void wifi_emulator_remove_event_timer(int evt_id)
+{
+       __COMMON_FUNC_ENTER__;
+
+       GSList *list;
+
+       INFO_LOG(UG_NAME_NORMAL, "Remove emulator event timer. event id: %d\n", evt_id);
+
+       for (list = emul_timer_list; list; list = g_slist_next(list)) {
+               wifi_emul_timer_s *evt_info = list->data;
+               if (evt_info == NULL)
+                       continue;
+
+               if (evt_info->event_id == evt_id) {
+                       g_source_remove(evt_info->timer_id);
+                       emul_timer_list = g_slist_remove(emul_timer_list, evt_info);
+                       g_free(evt_info);
+                       break;
+               }
+       }
+
+       __COMMON_FUNC_EXIT__;
+}
+
+void wifi_emulator_remove_all_event_timer(void)
+{
+       __COMMON_FUNC_ENTER__;
+
+       GSList *list;
+
+       for (list = emul_timer_list; list; list = g_slist_next(list)) {
+               wifi_emul_timer_s *evt_info = list->data;
+               if (evt_info == NULL)
+                       continue;
+
+               g_source_remove(evt_info->timer_id);
+               emul_timer_list = g_slist_remove(emul_timer_list, evt_info);
+               g_free(evt_info);
+       }
+
+       g_slist_free(emul_timer_list);
+       emul_timer_list = NULL;
+
+       __COMMON_FUNC_EXIT__;
+}
+#endif
+
 static void wlan_manager_device_state_changed_cb(
                wifi_device_state_e state, void *user_data)
 {
@@ -158,11 +332,17 @@ 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_DEVICE_STATE_ACTIVATED;
+#endif
                break;
 
        case WIFI_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_DEVICE_STATE_DEACTIVATED;
+#endif
                break;
 
        default:
@@ -245,103 +425,6 @@ static void wlan_manager_specific_scan_finished_cb(
        __COMMON_FUNC_EXIT__;
 }
 
-static void wlan_manager_network_event_cb(
-               wifi_error_e error_code, void *user_data)
-{
-       __COMMON_FUNC_ENTER__;
-
-       wlan_mgr_req_data_t *req_data = (wlan_mgr_req_data_t *)user_data;
-       if (req_data == NULL) {
-               ERROR_LOG(UG_NAME_ERR, "Request data is NULL !!!");
-
-               __COMMON_FUNC_EXIT__;
-               return;
-       }
-
-       wlan_mgr_event_info_t event_info;
-       memset(&event_info, 0, sizeof(event_info));
-
-       switch (req_data->req_type) {
-       case WLAN_MANAGER_REQ_TYPE_ACTIVATE:
-               /* fall through */
-       case WLAN_MANAGER_REQ_TYPE_DEACTIVATE:
-               /* We will send POWER_ON_OK / POWER_OFF_OK response when we receive
-                * device state change. Lets just clean up the request data now.
-                */
-               goto exit;
-               /* fall through */
-       case WLAN_MANAGER_REQ_TYPE_SCAN:
-               if (WIFI_ERROR_NONE == error_code) {
-                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_SCAN_OK;
-               } else {
-                       goto exit;
-               }
-
-               break;
-
-       case WLAN_MANAGER_REQ_TYPE_SPECIFIC_SCAN:
-               if (WIFI_ERROR_NONE == error_code) {
-                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_SPECIFIC_SCAN_OK;
-               } else {
-                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_SPECIFIC_SCAN_FAIL;
-               }
-
-               break;
-
-       case WLAN_MANAGER_REQ_TYPE_SCAN_RESULT:
-               if (WIFI_ERROR_NONE == error_code) {
-                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_SCAN_RESULT_IND;
-                       manager_object->message_func(&event_info, req_data->user_data);
-               }
-
-               return; // The request data is static. So returning here.
-
-       case WLAN_MANAGER_REQ_TYPE_CONNECT:
-               event_info.ap = req_data->ap;
-
-               if (WIFI_ERROR_NONE != error_code) {
-                       if (error_code == WIFI_ERROR_INVALID_KEY) {
-                               event_info.event_type =
-                                               WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_INVALID_KEY;
-                       } else if (error_code == WIFI_ERROR_DHCP_FAILED) {
-                               event_info.event_type =
-                                               WLAN_MANAGER_RESPONSE_TYPE_DHCP_FAILED;
-                       } else {
-                               event_info.event_type =
-                                               WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_CONNECT_FAILED;
-                       }
-               } else {
-                       goto exit;
-               }
-
-               break;
-
-       case WLAN_MANAGER_REQ_TYPE_WPS_CONNECT:
-               event_info.ap = req_data->ap;
-
-               if (WIFI_ERROR_NONE != error_code) {
-                       event_info.event_type = WLAN_MANAGER_RESPONSE_TYPE_WPS_ENROLL_FAIL;
-               } else {
-                       goto exit;
-               }
-
-               break;
-
-       default:
-               goto exit;
-       }
-
-       manager_object->message_func(&event_info, req_data->user_data);
-
-exit:
-       if (req_data != NULL) {
-               wifi_ap_destroy(req_data->ap);
-               g_free(req_data);
-       }
-
-       __COMMON_FUNC_EXIT__;
-}
-
 static void wlan_manager_register_cbs(void)
 {
        __COMMON_FUNC_ENTER__;
@@ -449,6 +532,13 @@ wifi_ap_h wlan_manager_get_ap_with_state(int ap_state)
 int wlan_manager_state_get(void)
 {
        int ret_val = 0;
+
+#ifdef TIZEN_EMULATOR
+       if (wifi_emulator_state == WIFI_DEVICE_STATE_ACTIVATED)
+               ret_val = WLAN_MANAGER_UNCONNECTED;
+       else
+               ret_val = WLAN_MANAGER_OFF;
+#else
        wifi_connection_state_e connection_state;
        bool activated;
 
@@ -489,6 +579,7 @@ int wlan_manager_state_get(void)
                ret_val = WLAN_MANAGER_ERROR;
                break;
        }
+#endif
 
        return ret_val;
 }
@@ -499,7 +590,6 @@ int wlan_manager_power_on(void)
 
        INFO_LOG(UG_NAME_REQ, "power on");
 
-       int ret = 0;
 #if defined TIZEN_TETHERING_ENABLE
        int tethering =
                        common_util_get_system_registry("memory/mobile_hotspot/mode");
@@ -518,6 +608,8 @@ 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_activate(wlan_manager_network_event_cb, req_data);
@@ -532,6 +624,7 @@ int wlan_manager_power_on(void)
                __COMMON_FUNC_EXIT__;
                return WLAN_MANAGER_ERR_UNKNOWN;
        }
+#endif
 
        __COMMON_FUNC_EXIT__;
        return WLAN_MANAGER_ERR_NONE;
@@ -541,6 +634,7 @@ 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;
 
@@ -553,11 +647,36 @@ int wlan_manager_power_off(void)
                __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_DEVICE_STATE_ACTIVATED, NULL);
+
+       memset(&scan_req_data, 0, sizeof(scan_req_data));
+       scan_req_data.req_type = WLAN_MANAGER_REQ_TYPE_SCAN_RESULT;
+       wlan_manager_network_event_cb(WIFI_ERROR_NONE, &scan_req_data);
+
+       wifi_emulator_remove_event_timer(WIFI_EMUL_EVENT_TIMER_ACTIVATE);
+
+       return WLAN_MANAGER_ERR_NONE;
+}
+
+int wlan_manager_emulator_power_off(void)
+{
+       wlan_manager_device_state_changed_cb(WIFI_DEVICE_STATE_DEACTIVATED, NULL);
+
+       wifi_emulator_remove_all_event_timer();
+
+       return WLAN_MANAGER_ERR_NONE;
+}
+#endif
+
 int wlan_manager_wps_connect(wifi_ap_h ap)
 {
        __COMMON_FUNC_ENTER__;
old mode 100644 (file)
new mode 100755 (executable)
index a011729..6ae0dea
@@ -80,6 +80,14 @@ 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);
 
index 50155c2..4b81945 100755 (executable)
@@ -55,7 +55,6 @@ typedef enum {
        VIEWER_WINSET_SEARCHING_GRP_TITLE
 } VIEWER_WINSETS;
 
-
 Evas_Object *viewer_manager_create(Evas_Object *parent, Evas_Object *_win_main);
 void viewer_manager_destroy(void);
 Eina_Bool viewer_manager_show(VIEWER_WINSETS winset);
index af0e780..e1045f8 100755 (executable)
@@ -80,6 +80,17 @@ 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},
+               {"uready", WLAN_SEC_MODE_IEEE8021X, 1},
+               {"setup", WLAN_SEC_MODE_NONE, 0},
+               {"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);
 
@@ -171,6 +182,10 @@ 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
                        break;
 
 #if defined TIZEN_TETHERING_ENABLE
@@ -208,6 +223,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
                        break;
 
                case WLAN_MANAGER_ERR_IN_PROGRESS:
@@ -1625,6 +1644,7 @@ static gint compare(gconstpointer a, gconstpointer b)
        }
 }
 
+#ifndef TIZEN_EMULATOR
 static bool wifi_update_list_for_each_ap(wifi_ap_h ap, void *user_data)
 {
        int *profile_size = (int *)user_data;
@@ -1639,6 +1659,41 @@ static bool wifi_update_list_for_each_ap(wifi_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;
+
+       wifi_device = g_try_new0(wifi_device_info_t, 1);
+       retvm_if(NULL == wifi_device, NULL);
+
+       wifi_device->ap = NULL;
+       wifi_device->ssid = g_strdup(wifi_samples[index].ssid);
+       wifi_device->rssi = 100;
+       wifi_device->security_mode = wifi_samples[index].security;
+       wifi_device->wps_mode = wifi_samples[index].wps;
+       common_utils_get_device_icon(wifi_device, &wifi_device->ap_image_path);
+
+       return wifi_device;
+}
+
+static void wifi_update_list_for_emulator_ap(void)
+{
+       int index;
+       wifi_device_info_t *wifi_device = NULL;
+
+       for (index = 0; index < wifi_sample_count; ++index) {
+               wifi_device = view_list_item_emulator_device_info_create(index);
+               if (wifi_device == NULL)
+                       return;
+
+               wifi_device_list = g_list_insert_sorted(wifi_device_list, wifi_device, compare);
+               INFO_LOG(UG_NAME_NORMAL, "wifi_device_list added device(%s)", wifi_device->ssid);
+       }
+}
+#endif
 
 static int viewer_manager_update_list_all(char *ssid)
 {
@@ -1656,7 +1711,12 @@ 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
        wifi_foreach_found_aps(wifi_update_list_for_each_ap, &profiles_list_size);
+#endif
 
        list_of_device = wifi_device_list;
        for (i = 0; i < profiles_list_size && list_of_device != NULL; i++) {
@@ -1710,6 +1770,10 @@ static int viewer_manager_update_list_all(char *ssid)
                }
        }
 
+#ifdef TIZEN_EMULATOR
+       wifi_emulator_remove_event_timer(WIFI_EMUL_EVENT_TIMER_SCAN);
+#endif
+
        __COMMON_FUNC_EXIT__;
        return ssid_count;
 }
index 22b246b..f7b257c 100755 (executable)
@@ -35,10 +35,10 @@ static Evas_Object* viewer_list = NULL;
 static Elm_Object_Item* first_item = NULL;
 static Elm_Object_Item* last_item = NULL;
 
-static Elm_Genlist_Item_Class itc;
-static Elm_Genlist_Item_Class no_wifi_device_itc;
-static Elm_Genlist_Item_Class grouptitle_itc;
-static Elm_Object_Itemgrouptitle = NULL;
+static Elm_Genlist_Item_Class *itc;
+static Elm_Genlist_Item_Class *no_wifi_device_itc;
+static Elm_Genlist_Item_Class *grouptitle_itc;
+static Elm_Object_Item *grouptitle = NULL;
 
 extern wifi_appdata *ug_app_state;
 
@@ -927,17 +927,19 @@ Evas_Object* viewer_list_create(Evas_Object *win)
        evas_object_size_hint_weight_set(viewer_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(viewer_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
-       itc.item_style = WIFI_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
-       itc.func.text_get = _gl_listview_text_get;
-       itc.func.content_get = _gl_listview_content_get;
-       itc.func.state_get = NULL;
-       itc.func.del = _gl_listview_del;
+       itc = elm_genlist_item_class_new();
+       itc->item_style = WIFI_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
+       itc->func.text_get = _gl_listview_text_get;
+       itc->func.content_get = _gl_listview_content_get;
+       itc->func.state_get = NULL;
+       itc->func.del = _gl_listview_del;
 
-       no_wifi_device_itc.item_style = WIFI_GENLIST_1LINE_TEXT_STYLE;
-       no_wifi_device_itc.func.text_get = _gl_listview_text_get;
-       no_wifi_device_itc.func.content_get = NULL;
-       no_wifi_device_itc.func.state_get = NULL;
-       no_wifi_device_itc.func.del = _gl_listview_del;
+       no_wifi_device_itc = elm_genlist_item_class_new();
+       no_wifi_device_itc->item_style = WIFI_GENLIST_1LINE_TEXT_STYLE;
+       no_wifi_device_itc->func.text_get = _gl_listview_text_get;
+       no_wifi_device_itc->func.content_get = NULL;
+       no_wifi_device_itc->func.state_get = NULL;
+       no_wifi_device_itc->func.del = _gl_listview_del;
 
        first_item = last_item = NULL;
 
@@ -974,13 +976,14 @@ void viewer_list_title_item_set(Elm_Object_Item *item_header)
                return;
        }
 
-       memset(&grouptitle_itc, 0, sizeof(grouptitle_itc));
-       grouptitle_itc.item_style = WIFI_GENLIST_GROUP_INDEX_STYLE;
-       grouptitle_itc.func.text_get = _gl_text_available_networks_get;
-       grouptitle_itc.func.content_get = _gl_content_scanning_icon_get;
+       //memset(&grouptitle_itc, 0, sizeof(grouptitle_itc));
+       grouptitle_itc = elm_genlist_item_class_new();
+       grouptitle_itc->item_style = WIFI_GENLIST_GROUP_INDEX_STYLE;
+       grouptitle_itc->func.text_get = _gl_text_available_networks_get;
+       grouptitle_itc->func.content_get = _gl_content_scanning_icon_get;
 
        grouptitle = elm_genlist_item_insert_after(viewer_list,
-                       &grouptitle_itc, NULL, NULL, item_header,
+                       grouptitle_itc, NULL, NULL, item_header,
                        ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
        assertm_if(NULL == grouptitle, "NULL!!");
@@ -1024,6 +1027,7 @@ int viewer_list_item_radio_mode_set(Elm_Object_Item* item,
        return TRUE;
 }
 
+#ifndef TIZEN_EMULATOR
 static wifi_connection_state_e _convert_wifi_state_to_viewer_radio_mode(
                wifi_connection_state_e state)
 {
@@ -1038,6 +1042,7 @@ static wifi_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,10 +1050,24 @@ Elm_Object_Item *viewer_list_item_insert_after(wifi_device_info_t *wifi_device,
        Elm_Object_Item* ret = NULL;
        ug_genlist_data_t* gdata = NULL;
        wifi_device_info_t *no_wifi_device = NULL;
-       wifi_connection_state_e state = WIFI_CONNECTION_STATE_DISCONNECTED;
-       VIEWER_ITEM_RADIO_MODES rad_mode = VIEWER_ITEM_RADIO_MODE_OFF;
        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;
+
+               no_wifi_device->ssid = g_strdup(sc(PACKAGE, I18N_TYPE_No_Wi_Fi_AP_Found));
+               wifi_device = no_wifi_device;
+       }
+#else
+       wifi_connection_state_e state = WIFI_CONNECTION_STATE_DISCONNECTED;
+       VIEWER_ITEM_RADIO_MODES rad_mode = VIEWER_ITEM_RADIO_MODE_OFF;
        if (wifi_device != NULL && wifi_device->ap != NULL) {
                if (wifi_ap_get_connection_state(wifi_device->ap, &state) ==
                                WIFI_ERROR_NONE) {
@@ -1072,9 +1091,9 @@ Elm_Object_Item *viewer_list_item_insert_after(wifi_device_info_t *wifi_device,
                        return NULL;
 
                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);
        retvm_if(NULL == gdata, NULL);
@@ -1089,7 +1108,7 @@ Elm_Object_Item *viewer_list_item_insert_after(wifi_device_info_t *wifi_device,
        if (no_wifi_device == NULL) {
                ret = elm_genlist_item_insert_after(
                                viewer_list, /*obj*/
-                               &itc,/*itc*/
+                               itc,/*itc*/
                                gdata,/*data*/
                                NULL,/*parent*/
                                after, /*after than*/
@@ -1099,7 +1118,7 @@ Elm_Object_Item *viewer_list_item_insert_after(wifi_device_info_t *wifi_device,
        } else {
                ret = elm_genlist_item_insert_after(
                                viewer_list, /*obj*/
-                               &no_wifi_device_itc,/*itc*/
+                               no_wifi_device_itc,/*itc*/
                                gdata,/*data*/
                                NULL,/*parent*/
                                after, /*after than*/
index 9920379..defc6b0 100755 (executable)
@@ -292,7 +292,12 @@ 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
 
        __COMMON_FUNC_EXIT__;
 }