Release tizen_2.0_beta
[apps/home/ug-wifi-efl.git] / sources / wifi-syspopup / viewer-popups / view-main.c
index 56b07d3..58a17d3 100644 (file)
@@ -1,32 +1,38 @@
 /*
-  * Copyright 2012  Samsung Electronics Co., Ltd
-  *
-  * Licensed under the Flora License, Version 1.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-  *
-  *    http://www.tizenopensource.org/license
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
+*  Wi-Fi syspopup
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+
+* Licensed under the Flora License, Version 1.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+
+* http://www.tizenopensource.org/license
+
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
 
 
 
 #include "common.h"
 #include "view-main.h"
-#include "wifi-syspopup.h"
-#include "view-password.h"
+#include "common_pswd_popup.h"
+#include "common_utils.h"
+#include "view-alerts.h"
+#include "i18nmanager.h"
+#include "common_eap_connect.h"
 
-extern wifi_object* app_state;
+extern wifi_object* syspopup_app_state;
 
 static Evas_Object* list = NULL;
 static Elm_Genlist_Item_Class itc;
 
-int view_main_item_connection_mode_set(genlist_data *data, ITEM_CONNECTION_MODES mode)
+int view_main_item_connection_mode_set(syspopup_genlist_data_t *data, ITEM_CONNECTION_MODES mode)
 {
        __COMMON_FUNC_ENTER__;
 
@@ -63,7 +69,7 @@ static ITEM_CONNECTION_MODES view_main_state_get(Evas_Object *glist)
        Elm_Object_Item* it = NULL;
        it = elm_genlist_first_item_get(glist);
        while (it) {
-               genlist_data *gdata = (genlist_data *)elm_object_item_data_get(it);
+               syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t *)elm_object_item_data_get(it);
                if (gdata->connection_mode == ITEM_CONNECTION_MODE_CONNECTING) {
                        return ITEM_CONNECTION_MODE_CONNECTING;
                }
@@ -75,20 +81,147 @@ static ITEM_CONNECTION_MODES view_main_state_get(Evas_Object *glist)
        return ITEM_CONNECTION_MODE_OFF;
 }
 
+static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       __COMMON_FUNC_ENTER__;
+       if (!syspopup_app_state->passpopup) {
+               return;
+       }
+       assertm_if(NULL == data, "data is NULL!!");
+       assertm_if(NULL == obj, "obj is NULL!!");
+       assertm_if(NULL == event_info, "event_info is NULL!!");
+
+       syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t *)data;
+       char *profile_name = gdata->dev_info->profile_name;
+       wlan_security_mode_type_t sec_mode = gdata->dev_info->security_mode;
+
+       char* password = NULL;
+       int len_password = 0;
+       int ret = WLAN_MANAGER_ERR_UNKNOWN;
+       password = common_pswd_popup_get_txt(syspopup_app_state->passpopup);
+       len_password = strlen(password);
+       INFO_LOG(SP_NAME_NORMAL, "* password len [%d]", len_password);
+
+       switch (sec_mode) {
+       case WLAN_SEC_MODE_WEP:
+               if (len_password == 5 || len_password == 13 || len_password == 26 || len_password == 10) {
+                       wlan_manager_password_data* param = (wlan_manager_password_data *)g_malloc0(sizeof(wlan_manager_password_data));
+                       assertm_if(NULL == param, "param is NULL!!");
+
+                       param->wlan_eap_type = WLAN_MANAGER_EAP_TYPE_NONE;
+                       param->password = password;
+
+                       ret = wlan_manager_connect_with_password(profile_name, sec_mode, param);
+                       g_free(param);
+
+               } else {
+                       view_alerts_popup_show(WEP_WRONG_PASSWORD_LEN_ERR_MSG_STR);
+                       goto popup_ok_exit;
+               }
+               break;
+
+       case WLAN_SEC_MODE_WPA_PSK:
+       case WLAN_SEC_MODE_WPA2_PSK:
+               if (len_password < 8 || len_password > 63) {
+                       view_alerts_popup_show(WPA_WRONG_PASSWORD_LEN_ERR_MSG_STR);
+                       goto popup_ok_exit;
+               } else {
+                       wlan_manager_password_data* param = (wlan_manager_password_data *)g_malloc0(sizeof(wlan_manager_password_data));
+                       assertm_if(NULL == param, "param is NULL!!");
+
+                       param->wlan_eap_type = WLAN_MANAGER_EAP_TYPE_NONE;
+                       param->password = password;
+
+                       ret = wlan_manager_connect_with_password(profile_name, sec_mode, param);
+                       g_free(param);
+               }
+               break;
+
+       default:
+               ret = WLAN_MANAGER_ERR_UNKNOWN;
+               ERROR_LOG(SP_NAME_ERR, "Fatal: Wrong security mode : %d", sec_mode);
+               break;
+       }
+
+       if (WLAN_MANAGER_ERR_NONE == ret)
+               view_main_item_connection_mode_set(gdata, ITEM_CONNECTION_MODE_CONNECTING);
+       else
+               view_main_item_connection_mode_set(gdata, ITEM_CONNECTION_MODE_OFF);
+
+       common_pswd_popup_destroy(syspopup_app_state->passpopup);
+       syspopup_app_state->passpopup = NULL;
+
+popup_ok_exit:
+       g_free(password);
+
+       __COMMON_FUNC_EXIT__;
+}
+
+static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       __COMMON_FUNC_ENTER__;
+
+       INFO_LOG(SP_NAME_NORMAL, "button cancel");
+
+       common_pswd_popup_destroy(syspopup_app_state->passpopup);
+       syspopup_app_state->passpopup = NULL;
+
+       __COMMON_FUNC_EXIT__;
+}
+
+static void _wps_pbc_popup_cancel_connecting(void* data, Evas_Object* obj, void* event_info)
+{
+       if (!syspopup_app_state->passpopup || !data) {
+               return;
+       }
+
+       syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t *)data;
+       char *profile_name = gdata->dev_info->profile_name;
+       int ret = wlan_manager_request_cancel_wps_connection(profile_name);
+       if (ret == WLAN_MANAGER_ERR_NONE) {
+               INFO_LOG(SP_NAME_NORMAL, "WPS conection cancelled successfully for AP[%s]", profile_name);
+       } else {
+               ERROR_LOG(SP_NAME_ERR, "Error!!! wlan_manager_request_cancel_wps_connection failed for AP[%s]", profile_name);
+       }
+       common_pswd_popup_destroy(syspopup_app_state->passpopup);
+       syspopup_app_state->passpopup = NULL;
+       return;
+}
+
+static void _wps_btn_cb(void* data, Evas_Object* obj, void* event_info)
+{
+       __COMMON_FUNC_ENTER__;
+       if (!syspopup_app_state->passpopup || !data) {
+               return;
+       }
+
+       syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t *)data;
+       int ret = wlan_manager_request_wps_connection(gdata->dev_info->profile_name);
+       if (ret == WLAN_MANAGER_ERR_NONE) {
+               common_pswd_popup_pbc_popup_create(syspopup_app_state->passpopup, _wps_pbc_popup_cancel_connecting, gdata);
+       } else {
+               ERROR_LOG(SP_NAME_ERR, "Error!!! wlan_manager_request_wps_connection failed");
+       }
+       __COMMON_FUNC_EXIT__;
+}
+
+
 static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
 {
        __COMMON_FUNC_ENTER__;
+       assertm_if(NULL == data, "data is NULL!!");
+       assertm_if(NULL == obj, "obj is NULL!!");
+       assertm_if(NULL == event_info, "event_info is NULL!!");
+       Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+
        if (view_main_state_get(obj) != ITEM_CONNECTION_MODE_OFF) {
                INFO_LOG(SP_NAME_NORMAL, "In connecting state, nothing can do" );
+               elm_genlist_item_selected_set(item, 0);
                __COMMON_FUNC_EXIT__;
                return;
        }
 
-       Elm_Object_Item *item = (Elm_Object_Item *)event_info;
-
-       assertm_if(NULL == data, "data is NULL!!");
-       assertm_if(NULL == obj, "obj is NULL!!");
-       genlist_data *gdata = (genlist_data*) data;
+       syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t*) data;
 
        int ret = WLAN_MANAGER_ERR_UNKNOWN;
 
@@ -96,7 +229,6 @@ static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
        case ITEM_CONNECTION_MODE_OFF:
                INFO_LOG( SP_NAME_NORMAL, "item state: off");
                ret = wlan_manager_request_connection(gdata->dev_info);
-
                break;
        case ITEM_CONNECTION_MODE_CONNECTING:
                INFO_LOG( SP_NAME_NORMAL, "item state: connecting");
@@ -113,7 +245,17 @@ static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
                break;
        case WLAN_MANAGER_ERR_CONNECT_PASSWORD_NEEDED:
                INFO_LOG( SP_NAME_NORMAL, "Password view will show up");
-               view_password_show(gdata);
+               pswd_popup_create_req_data_t    popup_info;
+               popup_info.title = gdata->dev_info->ssid;
+               popup_info.ok_cb = _popup_ok_cb;
+               popup_info.cancel_cb = _popup_cancel_cb;
+               popup_info.show_wps_btn = gdata->dev_info->wps_mode;
+               popup_info.wps_btn_cb = _wps_btn_cb;
+               popup_info.cb_data = gdata;
+               syspopup_app_state->passpopup = common_pswd_popup_create(syspopup_app_state->win_main, PACKAGE, &popup_info);
+               break;
+       case WLAN_MANAGER_ERR_CONNECT_EAP_SEC_TYPE:
+               create_eap_connect(syspopup_app_state->win_main, NULL, PACKAGE, gdata->dev_info, NULL);
                break;
        default:
                view_main_item_connection_mode_set(gdata, ITEM_CONNECTION_MODE_OFF);
@@ -131,59 +273,31 @@ static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part)
 {
        __COMMON_FUNC_ENTER__;
+       char *ret = NULL;
        assertm_if(NULL == data, "data param is NULL!!");
        assertm_if(NULL == obj, "obj param is NULL!!");
        assertm_if(NULL == part, "part param is NULL!!");
 
-       genlist_data *gdata = (genlist_data *) data;
-       const char* ssid_name = gdata->dev_info->ssid;
-
-       if (ssid_name == NULL) {
-               __COMMON_FUNC_EXIT__;
-               ERROR_LOG(SP_NAME_NORMAL, "ssid name is NULL!!");
-               return NULL;
-       }
-       __COMMON_FUNC_EXIT__;
-
-       return strdup(ssid_name);
-}
-
-static char *wifi_get_device_icon(wifi_device_info_t *device_info)
-{
-       __COMMON_FUNC_ENTER__;
-       assertm_if(NULL == device_info, "device param is NULL!!");
-
-       char tmp_str[128] = {0,};
-       char* ret;
-
-       sprintf(tmp_str, "%s/37_wifi_icon", WIFI_SP_ICON_PATH);
-
-       if (device_info->security_mode != WLAN_SEC_MODE_NONE) {
-               sprintf(tmp_str,"%s_lock", tmp_str);
-       }
-
-       switch (wlan_manager_get_signal_strength(device_info->rssi)) {
-       case SIGNAL_STRENGTH_TYPE_EXCELLENT:
-               sprintf(tmp_str,"%s_03", tmp_str);
-               break;
-       case SIGNAL_STRENGTH_TYPE_GOOD:
-               sprintf(tmp_str,"%s_02", tmp_str);
-               break;
-       case SIGNAL_STRENGTH_TYPE_WEAK:
-               sprintf(tmp_str,"%s_01", tmp_str);
-               break;
-       case SIGNAL_STRENGTH_TYPE_VERY_WEAK:
-       case SIGNAL_STRENGTH_TYPE_NULL:
-               sprintf(tmp_str,"%s_00", tmp_str);
-               break;
+       syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t *) data;
+       if (!strncmp(part, "elm.text.1", strlen(part))) {
+               ret = gdata->dev_info->ssid;
+               if (ret == NULL) {
+                       ERROR_LOG(SP_NAME_NORMAL, "ssid name is NULL!!");
+               }
+       } else if (!strncmp(part, "elm.text.2", strlen(part))) {
+               if (ITEM_CONNECTION_MODE_CONNECTING == gdata->connection_mode) {
+                       ret = sc(PACKAGE, I18N_TYPE_Connecting);
+               } else {
+                       ret = gdata->dev_info->ap_status_txt;
+               }
+               if (ret == NULL) {
+                       ERROR_LOG(SP_NAME_NORMAL, "ap_status_txt is NULL!!");
+               }
        }
 
-       sprintf(tmp_str, "%s.png", tmp_str);
-
-       ret = strdup(tmp_str);
        __COMMON_FUNC_EXIT__;
 
-       return ret;
+       return g_strdup(ret);
 }
 
 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part)
@@ -192,48 +306,55 @@ static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *pa
        if (data == NULL)
                return NULL;
 
-       genlist_data *gdata = (genlist_data *) data;
+       syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t *) data;
 
        const char* ssid_name = gdata->dev_info->ssid;
        INFO_LOG(SP_NAME_NORMAL, "ssid name [%s]", ssid_name);
 
-       char*dev_icon_file = NULL;
        Evas_Object* icon = NULL;
 
        if (!strncmp(part, "elm.icon.1", strlen(part))) {
+               icon = elm_icon_add(obj);
+               elm_icon_file_set(icon, gdata->dev_info->ap_image_path, NULL);
+               evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 5, 5);
+       } else if (!strncmp(part, "elm.icon.2", strlen(part))) {
                switch (gdata->connection_mode) {
                case ITEM_CONNECTION_MODE_OFF:
-                       if (gdata->progressbar != NULL) {
-                               elm_progressbar_pulse(gdata->progressbar, EINA_FALSE);
-                               evas_object_del(gdata->progressbar);
-                               gdata->progressbar = NULL;
-                       }
-
-                       icon = elm_icon_add(obj);
-                       dev_icon_file = wifi_get_device_icon(gdata->dev_info);
-                       INFO_LOG(SP_NAME_NORMAL, "icon name [%s]", dev_icon_file);
-                       elm_icon_file_set(icon, dev_icon_file, NULL);
-                       g_free(dev_icon_file);
-                       evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 5, 5);
-                       return icon;
-
-               case ITEM_CONNECTION_MODE_CONNECTING:
-                       gdata->progressbar = elm_progressbar_add(obj);
-                       if (gdata->progressbar == NULL)
-                               return NULL;
-
-                       elm_object_style_set(gdata->progressbar, "list_process");
-                       evas_object_size_hint_align_set(gdata->progressbar, EVAS_HINT_FILL, 0.5);
-                       evas_object_size_hint_weight_set(gdata->progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-                       elm_progressbar_pulse(gdata->progressbar, TRUE);
-                       return gdata->progressbar;
                default:
                        break;
+               case ITEM_CONNECTION_MODE_CONNECTING:
+                       icon = elm_progressbar_add(obj);
+                       elm_object_style_set(icon, "list_process");
+                       evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, 0.5);
+                       evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+                       elm_progressbar_pulse(icon, TRUE);
+                       break;
                }
+
        }
 
        __COMMON_FUNC_EXIT__;
-       return NULL;
+       return icon;
+}
+
+static void _gl_list_del(void* data, Evas_Object* obj)
+{
+       if (data == NULL)
+               return;
+
+       syspopup_genlist_data_t* gdata = (syspopup_genlist_data_t *) data;
+
+       if (gdata->dev_info) {
+               DEBUG_LOG(UG_NAME_NORMAL, "del target ssid:[%s]", gdata->dev_info->ssid);
+               g_free(gdata->dev_info->ap_image_path);
+               g_free(gdata->dev_info->ap_status_txt);
+               g_free(gdata->dev_info->ssid);
+               g_free(gdata->dev_info);
+       }
+       elm_object_item_data_set(gdata->it, NULL);
+       g_free(gdata);
+
+       return;
 }
 
 Evas_Object *view_main_create(Evas_Object* parent)
@@ -241,10 +362,9 @@ Evas_Object *view_main_create(Evas_Object* parent)
        __COMMON_FUNC_ENTER__;
        assertm_if(NULL == parent, "parent is NULL!!");
 
-       list = elm_genlist_add(parent); //app_state->win_main);
+       list = elm_genlist_add(parent); //syspopup_app_state->win_main);
        assertm_if(NULL == list, "list allocation fail!!");
 
-       elm_genlist_mode_set(list, ELM_LIST_LIMIT);
        evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
@@ -271,17 +391,6 @@ static void view_main_scan_ui_clear(void)
 
        if (list == NULL)
                return;
-
-       Elm_Object_Item* it = NULL;
-       it = elm_genlist_first_item_get(list);
-       while (it) {
-               genlist_data *gdata = (genlist_data *)elm_object_item_data_get(it);
-               if (gdata)
-                       g_free(gdata);
-
-               it = elm_genlist_item_next_get(it);
-       }
-
        elm_genlist_clear(list);
 
        __COMMON_FUNC_EXIT__;
@@ -291,14 +400,15 @@ void *view_main_item_set(net_profile_info_t *profile_info)
 {
        __COMMON_FUNC_ENTER__;
 
-       wifi_device_info_t *wifi_device = (wifi_device_info_t*)malloc(sizeof(wifi_device_info_t));
-       memset(wifi_device, 0, sizeof(wifi_device_info_t));
+       wifi_device_info_t *wifi_device = (wifi_device_info_t*)g_malloc0(sizeof(wifi_device_info_t));
 
-       wifi_device->profile_name = strdup(profile_info->ProfileName);
-       wifi_device->ssid = strdup(profile_info->ProfileInfo.Wlan.essid);
+       wifi_device->profile_name = g_strdup(profile_info->ProfileName);
+       wifi_device->ssid = g_strdup(profile_info->ProfileInfo.Wlan.essid);
        wifi_device->rssi = (int)profile_info->ProfileInfo.Wlan.Strength;
        wifi_device->security_mode = (int)profile_info->ProfileInfo.Wlan.security_info.sec_mode;
        wifi_device->wps_mode = (int)profile_info->ProfileInfo.Wlan.security_info.wps_support;
+       wifi_device->ap_status_txt = common_utils_get_ap_security_type_info_txt(PACKAGE, wifi_device);
+       wifi_device->ap_image_path = common_utils_get_device_icon(WIFI_SP_ICON_PATH, wifi_device);
 
        __COMMON_FUNC_EXIT__;
        return wifi_device;
@@ -306,88 +416,76 @@ void *view_main_item_set(net_profile_info_t *profile_info)
 
 int view_main_refresh()
 {
-       view_main_scan_ui_clear();
-       view_main_show();
+       view_main_show(NULL);
+
        return TRUE;
 }
 
-int view_main_show(void)
+Eina_Bool view_main_show(void *data)
 {
        __COMMON_FUNC_ENTER__;
 
        if (list == NULL) {
                ERROR_LOG( SP_NAME_NORMAL, "list is NULL!!" );
-               return FALSE;
+               return ECORE_CALLBACK_CANCEL;
        }
 
+       view_main_scan_ui_clear();
+
        char profile_name[NET_PROFILE_NAME_LEN_MAX+1] = "";
        int state = wlan_manager_state_get(profile_name);
-       switch (state) {
-       case WLAN_MANAGER_ERROR:
-       case WLAN_MANAGER_OFF:
-               return FALSE;
-       case WLAN_MANAGER_UNCONNECTED:
-       case WLAN_MANAGER_CONNECTED:
-       case WLAN_MANAGER_DISCONNECTING:
-               profile_name[0] = '\0';
-               break;
-       case WLAN_MANAGER_CONNECTING:
-               break;
-       }
 
-       view_main_scan_ui_clear();
+       if (WLAN_MANAGER_ERROR == state || WLAN_MANAGER_OFF == state) {
+               return ECORE_CALLBACK_CANCEL;
+       }
 
        net_profile_info_t *profiles_list = wlan_manager_profile_table_get();
        if (profiles_list == NULL)
-               return FALSE;
+               return ECORE_CALLBACK_CANCEL;
 
        int profiles_list_size = wlan_manager_profile_scanned_length_get();
        INFO_LOG(SP_NAME_NORMAL, "profiles list count [%d]\n", profiles_list_size);
+       if (profiles_list_size <= 0) {
+               WARN_LOG(SP_NAME_NORMAL, "scan size is ZERO");
+               return ECORE_CALLBACK_CANCEL;
+       }
 
-       itc.item_style = "1text.1icon.4";
+       itc.item_style = "2text.2icon.4";
        itc.func.text_get = _gl_text_get;
        itc.func.content_get = _gl_content_get;
        itc.func.state_get = NULL;
-       itc.func.del = NULL;
+       itc.func.del = _gl_list_del;
 
        int i = 0;
-       wifi_device_info_t *device_info = NULL;
-       if (profiles_list_size > 0) {
-        if (profile_name[0] == '\0') {
-                   for (i = 0; i < profiles_list_size; i++) {
-                               device_info = (wifi_device_info_t *)view_main_item_set(profiles_list+i);
-
-                               genlist_data *gdata = (genlist_data *) malloc(sizeof(genlist_data));
-                               gdata->dev_info = device_info;
-                               gdata->connection_mode = ITEM_CONNECTION_MODE_OFF;
-                               gdata->progressbar = NULL;
-
+       if (WLAN_MANAGER_CONNECTING == state) {
+               for (; i < profiles_list_size; i++) {
+                       syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t *)g_malloc0(sizeof(syspopup_genlist_data_t));
+                       gdata->dev_info = (wifi_device_info_t *)view_main_item_set(profiles_list+i);
+                       if (!g_strcmp0((profiles_list+i)->ProfileName, profile_name)) {
+                               gdata->connection_mode = ITEM_CONNECTION_MODE_CONNECTING;
                                gdata->it = elm_genlist_item_append(list, &itc, gdata, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, gdata);
-                               elm_object_item_data_set(gdata->it, gdata);
-               }
-        } else {
-                       for (i = 0; i < profiles_list_size; i++) {
-                               device_info = (wifi_device_info_t *)view_main_item_set(profiles_list+i);
-
-                               genlist_data *gdata = (genlist_data *) malloc(sizeof(genlist_data));
-                               gdata->dev_info = device_info;
-                               gdata->progressbar = NULL;
-                               if (!strcmp((profiles_list+i)->ProfileName, profile_name)) {
-                                       gdata->connection_mode = ITEM_CONNECTION_MODE_CONNECTING;
-                               } else {
-                                       gdata->connection_mode = ITEM_CONNECTION_MODE_OFF;
-                               }
-
-                               gdata->it = elm_genlist_item_append(list, &itc, gdata, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, gdata);
-                               elm_object_item_data_set(gdata->it, gdata);
+                               /* We have found the connecting AP, so lets break here and continue list
+                                * the remaining in the below for loop. The below for loop doesnt have comparison.
+                                * So it makes things little fast.
+                                */
+                               break;
                        }
-        }
-       } else if (profiles_list_size == 0) {
-               WARN_LOG(SP_NAME_NORMAL, "scan size is ZERO");
+                       gdata->connection_mode = ITEM_CONNECTION_MODE_OFF;
+                       gdata->it = elm_genlist_item_append(list, &itc, gdata, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, gdata);
+               }
+       }
+
+       for (; i < profiles_list_size; i++) {
+               syspopup_genlist_data_t *gdata = (syspopup_genlist_data_t *)g_malloc0(sizeof(syspopup_genlist_data_t));
+               gdata->dev_info = (wifi_device_info_t *)view_main_item_set(profiles_list+i);
+               gdata->connection_mode = ITEM_CONNECTION_MODE_OFF;
+
+               gdata->it = elm_genlist_item_append(list, &itc, gdata, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, gdata);
+               elm_object_item_data_set(gdata->it, gdata);
        }
 
        evas_object_show(list);
        __COMMON_FUNC_EXIT__;
 
-       return TRUE;
+       return ECORE_CALLBACK_CANCEL;
 }