04e41705b3814a2bf07f6b74dfada8f48294aa33
[apps/native/ug-wifi-efl.git] / sources / ui-gadget / viewers-layout / wifi_viewer_list.c
1 /*
2  * Wi-Fi
3  *
4  * Copyright 2012 Samsung Electronics Co., Ltd
5  *
6  * Licensed under the Flora License, Version 1.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.tizenopensource.org/license
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include "common.h"
21 #include "ug_wifi.h"
22 #include "common_utils.h"
23 #include "common_generate_pin.h"
24 #include "connection_manager.h"
25 #include "wlan_manager.h"
26 #include "view_detail.h"
27 #include "viewer_list.h"
28 #include "viewer_manager.h"
29 #include "appcoreWrapper.h"
30 #include "i18nmanager.h"
31
32 #define LIST_ITEM_CONNECTED_AP_FONT_SIZE                28
33
34 static Evas_Object* viewer_list = NULL;
35 static Elm_Object_Item* first_item = NULL;
36 static Elm_Object_Item* last_item = NULL;
37
38 static Elm_Genlist_Item_Class itc;
39 static Elm_Genlist_Item_Class no_wifi_device_itc;
40 static Elm_Genlist_Item_Class grouptitle_itc;
41 static Elm_Object_Item* grouptitle = NULL;
42
43 extern wifi_appdata *ug_app_state;
44
45 struct connecting_cancel_popup_data {
46         Evas_Object *popup;
47         wifi_ap_h ap;
48 };
49
50 static struct connecting_cancel_popup_data *g_disconnect_popup = NULL;
51
52 static void _gl_listview_more_btn_cb(void *data, Evas_Object *obj, void *event_info)
53 {
54         __COMMON_FUNC_ENTER__;
55
56         elm_object_disabled_set(obj, EINA_TRUE);
57
58         wifi_device_info_t *device_info = (wifi_device_info_t *)data;
59
60         if (data == NULL) {
61                 __COMMON_FUNC_EXIT__;
62                 return;
63         }
64
65         SECURE_DEBUG_LOG(UG_NAME_NORMAL, "ssid [%s]", device_info->ssid);
66
67         view_detail(device_info, ug_app_state->layout_main, obj);
68
69         __COMMON_FUNC_EXIT__;
70 }
71
72 char* ConvertRGBAtoHex(int r, int g, int b, int a)
73 {
74         int hexcolor = 0;
75         char* string = NULL;
76
77         string = g_try_malloc0(sizeof(char )* 255);
78         if (string != NULL) {
79                 hexcolor = (r << 24) + (g << 16) + (b << 8) + a;
80                 g_snprintf(string, sizeof(string), "%08x", hexcolor);
81         }
82
83         return string;
84 }
85
86 static char* _gl_listview_text_get(void *data, Evas_Object *obj, const char *part)
87 {
88         char* det = NULL;
89         char* buf = NULL;
90         char* convertedColor = NULL;
91
92         ug_genlist_data_t* gdata = (ug_genlist_data_t*) data;
93         retvm_if(NULL == gdata || NULL == gdata->device_info, NULL);
94
95         assertm_if(NULL == gdata->device_info->ssid, "NULL!!");
96
97         if (!strcmp("elm.text", part)) {
98                 det = evas_textblock_text_utf8_to_markup(NULL,
99                                 gdata->device_info->ssid);
100                 assertm_if(NULL == det, "NULL!!");
101
102                 convertedColor = ConvertRGBAtoHex(2, 61, 132, 255);
103                 assertm_if(NULL == convertedColor, "NULL!!");
104                 if (VIEWER_ITEM_RADIO_MODE_CONNECTED == gdata->radio_mode) {
105                         buf = g_strdup_printf("<color=#%s>%s</color>",
106                                 convertedColor, det);
107
108                         g_free(det);
109                         g_free(convertedColor);
110                         return buf;
111                 }
112         } else if (!strcmp("elm.text.sub", part)
113                         && gdata->device_info->ap_status_txt != NULL) {
114                 det = g_strdup(gdata->device_info->ap_status_txt);
115
116                 assertm_if(NULL == det, "NULL!!");
117         }
118         return det;
119 }
120
121 static Evas_Object *_gl_listview_content_get(void *data, Evas_Object *obj, const char *part)
122 {
123         ug_genlist_data_t *gdata = (ug_genlist_data_t *)data;
124         retvm_if(NULL == gdata, NULL);
125
126         Evas_Object *icon = NULL;
127         Evas_Object *btn = NULL;
128
129         if (gdata->device_info->ap_image_path == NULL) {
130                 /* if there is no ap_image_path (NO AP Found situation) */
131                 DEBUG_LOG(UG_NAME_ERR, "Fatal: Image path is NULL");
132
133         } else if (!strcmp("elm.swallow.icon", part)) {
134                 icon = elm_image_add(obj);
135                 retvm_if(NULL == icon, NULL);
136
137                 /* for strength */
138                 char *temp_str = NULL;
139                 temp_str = g_strdup_printf("%s.png", gdata->device_info->ap_image_path);
140                 elm_image_file_set(icon, CUSTOM_EDITFIELD_PATH, temp_str);
141                 g_free(temp_str);
142
143                 evas_object_color_set(icon, 2, 61, 132, 204);
144                 evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(DEFAULT_BUTTON_CIRCLE_SIZE), ELM_SCALE_SIZE(DEFAULT_BUTTON_CIRCLE_SIZE));
145
146         } else if (!strcmp("elm.swallow.end", part)) {
147                 if (VIEWER_ITEM_RADIO_MODE_CONNECTING == gdata->radio_mode ||
148                                 VIEWER_ITEM_RADIO_MODE_CONFIGURATION == gdata->radio_mode) {
149
150                         icon = elm_progressbar_add(obj);
151
152                         elm_object_style_set(icon, "process_medium");
153                         evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, 0.5);
154                         evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
155                         elm_progressbar_pulse(icon, TRUE);
156                         evas_object_propagate_events_set(icon, EINA_FALSE);
157
158                 } else {
159                         btn = elm_button_add(obj);
160                         elm_object_style_set(btn, "circle_custom");
161                         icon = elm_image_add(btn);
162                         elm_image_file_set(icon, CUSTOM_EDITFIELD_PATH, "wifi_icon_badge_info.png");
163                         elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE);
164                         elm_object_part_content_set(btn, "elm.swallow.content", icon);
165                         evas_object_propagate_events_set(btn, EINA_FALSE);
166                         evas_object_smart_callback_add(btn, "clicked", _gl_listview_more_btn_cb,gdata->device_info);
167                         evas_object_show(btn);
168
169                         return btn;
170                 }
171         }
172         return icon;
173 }
174
175 static void _gl_listview_del(void *data, Evas_Object *obj)
176 {
177         if (data == NULL)
178                 return;
179
180         ug_genlist_data_t *gdata = (ug_genlist_data_t *)data;
181         retm_if(NULL == gdata || NULL == gdata->device_info);
182
183         g_free(gdata->device_info->ap_image_path);
184         g_free(gdata->device_info->ap_status_txt);
185         g_free(gdata->device_info->ssid);
186         wifi_ap_destroy(gdata->device_info->ap);
187         g_free(gdata->device_info);
188         g_free(gdata);
189 }
190
191 static char *_gl_text_available_networks_get(void *data, Evas_Object *obj,
192                 const char *part)
193 {
194         if (!strcmp("elm.text", part))
195                 return g_strdup(sc(PACKAGE, I18N_TYPE_Available_networks));
196
197         return NULL;
198 }
199
200 static Evas_Object *_gl_content_scanning_icon_get(void *data, Evas_Object *obj,
201                 const char *part)
202 {
203         Evas_Object *title_progressbar = NULL;
204
205         if (HEADER_MODE_SEARCHING == viewer_manager_header_mode_get()) {
206                 title_progressbar  = elm_progressbar_add(obj);
207                 elm_object_style_set(title_progressbar, "process_small");
208                 elm_progressbar_horizontal_set(title_progressbar, EINA_TRUE);
209                 elm_progressbar_pulse(title_progressbar, EINA_TRUE);
210         }
211
212         return title_progressbar;
213 }
214
215 Elm_Object_Item* viewer_list_get_first_item(void)
216 {
217         return first_item;
218 }
219
220 Elm_Object_Item* viewer_list_get_last_item(void)
221 {
222         return last_item;
223 }
224
225 #ifdef ACCESSIBLITY_FEATURE
226 static char *_access_info_cb(void *data, Evas_Object *obj)
227 {
228         char *strength = NULL;
229         char *buf = NULL;
230
231         ug_genlist_data_t *gdata = (ug_genlist_data_t *)data;
232         if (!gdata) {
233                 return NULL;
234         }
235
236         strength = common_utils_get_rssi_text(PACKAGE, gdata->device_info->rssi);
237         buf = g_strdup_printf("%s. %s. %s.", strength, gdata->device_info->ssid, gdata->device_info->ap_status_txt);
238
239         g_free(strength);
240         return buf;
241 }
242 #endif
243
244 static void gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
245 {
246         elm_genlist_realized_items_update(obj);
247 }
248
249 static void _gl_realized(void *data, Evas_Object *obj, void *event_info)
250 {
251 #ifdef ACCESSIBLITY_FEATURE
252         HEADER_MODES header_mode = viewer_manager_header_mode_get();
253         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
254
255         if (header_mode == HEADER_MODE_ACTIVATING ||
256                 header_mode == HEADER_MODE_DEACTIVATING ||
257                 header_mode == HEADER_MODE_OFF) {
258                 return ;
259         }
260
261         Elm_Object_Item *first_item = viewer_list_get_first_item();
262         Elm_Object_Item *last_item = viewer_list_get_last_item();
263
264         if (first_item == NULL || last_item == NULL) {
265                 return;
266         }
267
268         int index = (int)elm_genlist_item_index_get(item);
269         int first_item_index = (int)elm_genlist_item_index_get(first_item);
270         int last_item_index = (int)elm_genlist_item_index_get(last_item);
271         char buf[100] = "";
272
273         if (first_item_index == -1) {
274                 int group_index = (int)elm_genlist_item_index_get(grouptitle);
275                 first_item_index = group_index + 1;
276         }
277
278         if (index >= first_item_index && index <= last_item_index &&
279                         first_item_index < last_item_index) {
280
281                 Evas_Object *ao = elm_object_item_access_object_get(item);
282                 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, elm_object_item_data_get(item));
283                 g_snprintf(buf, sizeof(buf), "%s%s",
284                                                 sc(PACKAGE, I18N_TYPE_Double_tap),
285                                                 sc(PACKAGE, I18N_TYPE_Connect_to_device));
286                 elm_access_info_set(ao, ELM_ACCESS_TYPE, buf);
287                 elm_access_info_set(ao, ELM_ACCESS_STATE, sc(PACKAGE, I18N_TYPE_Wi_Fi_network_info));
288         }
289 #else
290         Elm_Object_Item *first_item = viewer_list_get_first_item();
291
292         if (first_item == NULL) {
293                 return;
294         }
295
296         int first_item_index = (int)elm_genlist_item_index_get(first_item);
297
298         if (first_item_index == -1) {
299                 int group_index = (int)elm_genlist_item_index_get(grouptitle);
300                 first_item_index = group_index + 1;
301         }
302 #endif
303 }
304
305 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
306 {
307         pswd_popup_t *passpopup = (pswd_popup_t *)data;
308
309         if (passpopup != NULL && passpopup->info_popup != NULL) {
310                 evas_object_del(passpopup->info_popup);
311                 passpopup->info_popup = NULL;
312         }
313 }
314
315 static void __passwd_popup_cancel_cb(void *data,  Evas_Object *obj,
316                 void *event_info)
317 {
318         __COMMON_FUNC_ENTER__;
319
320         if (ug_app_state->passpopup == NULL) {
321                 return;
322         }
323
324         passwd_popup_free(ug_app_state->passpopup);
325         ug_app_state->passpopup = NULL;
326
327         if (data) {
328                 g_free(data);
329         }
330
331         __COMMON_FUNC_EXIT__;
332 }
333
334 static void __passwd_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
335 {
336         __COMMON_FUNC_ENTER__;
337
338         wifi_ap_h ap = NULL;
339         int password_len = 0;
340         const char *password = NULL;
341         wifi_security_type_e sec_type = WIFI_SECURITY_TYPE_NONE;
342
343         if (ug_app_state->passpopup == NULL) {
344                 return;
345         }
346
347         ap = passwd_popup_get_ap(ug_app_state->passpopup);
348         password = passwd_popup_get_txt(ug_app_state->passpopup);
349         if (password != NULL)
350                 password_len = strlen(password);
351
352         wifi_ap_get_security_type(ap, &sec_type);
353
354         switch (sec_type) {
355         case WIFI_SECURITY_TYPE_WEP:
356                 if (password_len != 5 && password_len != 13 &&
357                                 password_len != 26 && password_len != 10) {
358                         common_utils_send_message_to_net_popup(
359                                         "Network connection popup",
360                                         "wrong password", "toast_popup", NULL);
361
362                         if (ug_app_state->passpopup->entry) {
363                                 elm_object_focus_set(
364                                                 ug_app_state->passpopup->entry,
365                                                 EINA_TRUE);
366                         }
367                         goto failure;
368                 }
369                 break;
370
371         case WIFI_SECURITY_TYPE_WPA_PSK:
372         case WIFI_SECURITY_TYPE_WPA2_PSK:
373                 if (password_len < 8 || password_len > 64) {
374                         common_utils_send_message_to_net_popup(
375                                         "Network connection popup",
376                                         "wrong password", "toast_popup", NULL);
377
378                         if (ug_app_state->passpopup->entry) {
379                                 elm_object_focus_set(
380                                                 ug_app_state->passpopup->entry,
381                                                 EINA_TRUE);
382                         }
383                         goto failure;
384                 }
385                 break;
386
387         default:
388                 ERROR_LOG(UG_NAME_NORMAL, "Wrong security mode: %d", sec_type);
389                 passwd_popup_free(ug_app_state->passpopup);
390                 ug_app_state->passpopup = NULL;
391
392                 goto popup_ok_cb_exit;
393         }
394
395         bool favorite = FALSE;
396         if(wifi_ap_is_favorite(ap, &favorite) == WIFI_ERROR_NONE
397                 && favorite == TRUE) {
398                 wlan_manager_forget(ap);
399                 wifi_ap_refresh(ap);
400         }
401
402         if (ug_app_state->is_hidden) {
403                 wifi_ap_h hidden_ap;
404                 char *ssid;
405                 wifi_ap_get_essid(ap, &ssid);
406                 wifi_ap_hidden_create(ssid, &hidden_ap);
407                 g_free(ssid);
408                 wifi_ap_set_security_type(hidden_ap, sec_type);
409                 wlan_manager_connect_with_password(hidden_ap, password);
410         } else
411                 wlan_manager_connect_with_password(ap, password);
412
413         passwd_popup_free(ug_app_state->passpopup);
414         ug_app_state->passpopup = NULL;
415
416 popup_ok_cb_exit:
417         if (data) {
418                 g_free(data);
419         }
420
421 failure:
422         g_free((gpointer)password);
423
424         __COMMON_FUNC_EXIT__;
425 }
426
427 static void __wps_pbc_popup_cancel_connecting(void *data, Evas_Object *obj,
428                 void *event_info)
429 {
430         __COMMON_FUNC_ENTER__;
431
432         if (ug_app_state->passpopup == NULL) {
433                 return;
434         }
435
436         wifi_ap_h ap = passwd_popup_get_ap(ug_app_state->passpopup);
437
438         int ret = wlan_manager_disconnect(ap);
439         if (ret != WLAN_MANAGER_ERR_NONE) {
440                 ERROR_LOG(UG_NAME_NORMAL, "Failed WPS PBC cancellation [0x%x]", ap);
441         }
442
443         passwd_popup_free(ug_app_state->passpopup);
444         ug_app_state->passpopup = NULL;
445
446         viewer_manager_header_mode_set(HEADER_MODE_ON);
447
448         __COMMON_FUNC_EXIT__;
449 }
450
451 static void _wps_btn_cb(void* data, Evas_Object* obj, void* event_info)
452 {
453         __COMMON_FUNC_ENTER__;
454
455         if (!ug_app_state->passpopup) {
456                 return;
457         }
458
459         wifi_ap_h ap = passwd_popup_get_ap(ug_app_state->passpopup);
460         int ret = wlan_manager_wps_connect(ap);
461         if (ret == WLAN_MANAGER_ERR_NONE) {
462                 create_pbc_popup(ug_app_state->passpopup,
463                                 __wps_pbc_popup_cancel_connecting, NULL,
464                                 POPUP_WPS_BTN, NULL);
465         } else {
466                 ERROR_LOG(UG_NAME_NORMAL, "wlan_manager_wps_connect failed");
467                 passwd_popup_free(ug_app_state->passpopup);
468                 ug_app_state->passpopup = NULL;
469         }
470
471         __COMMON_FUNC_EXIT__;
472 }
473
474 static void _wps_cancel_cb(void* data, Evas_Object* obj, void* event_info)
475 {
476         __COMMON_FUNC_ENTER__;
477
478         if (ug_app_state->passpopup == NULL) {
479                 return;
480         }
481
482         current_popup_free(ug_app_state->passpopup, POPUP_WPS_OPTIONS);
483
484         __COMMON_FUNC_EXIT__;
485 }
486
487 static void _wps_pin_cb(void* data, Evas_Object* obj, void* event_info)
488 {
489         __COMMON_FUNC_ENTER__;
490         unsigned int rpin = 0;
491         char npin[9] = { '\0' };
492         int pin_len = 0;
493         int ret = WLAN_MANAGER_ERR_NONE;
494         wifi_ap_h ap = NULL;
495         Evas_Object *info_popup = NULL;
496
497         if (!ug_app_state->passpopup) {
498                 return;
499         }
500
501         /* Generate WPS pin */
502         rpin = wps_generate_pin();
503         if (rpin > 0)
504                 g_snprintf(npin, sizeof(npin), "%08d", rpin);
505
506         pin_len = strlen(npin);
507         if (pin_len != 8) {
508                 info_popup = common_utils_show_info_ok_popup(
509                                 ug_app_state->layout_main, PACKAGE,
510                                 sc(PACKAGE, I18N_TYPE_Invalid_pin),
511                                 _info_popup_ok_cb,
512                                 ug_app_state->passpopup);
513                 ug_app_state->passpopup->info_popup = info_popup;
514
515                 __COMMON_FUNC_EXIT__;
516                 return;
517         }
518
519         ap = passwd_popup_get_ap(ug_app_state->passpopup);
520
521         ret = wlan_manager_wps_pin_connect(ap, npin);
522         if (ret == WLAN_MANAGER_ERR_NONE) {
523                 INFO_LOG(UG_NAME_NORMAL, "wlan_manager_wps_pin_connect successful");
524
525                 create_pbc_popup(ug_app_state->passpopup,
526                                 __wps_pbc_popup_cancel_connecting, NULL,
527                                 POPUP_WPS_PIN, npin);
528         } else {
529                 ERROR_LOG(UG_NAME_NORMAL, "wlan_manager_wps_pin_connect failed");
530                 passwd_popup_free(ug_app_state->passpopup);
531                 ug_app_state->passpopup = NULL;
532         }
533
534         __COMMON_FUNC_EXIT__;
535 }
536
537 static void __wps_options_popup_cb(void* data, Evas_Object* obj, void* event_info)
538 {
539         __COMMON_FUNC_ENTER__;
540         pswd_popup_create_req_data_t popup_info;
541
542         if (!ug_app_state->passpopup) {
543                 return;
544         }
545
546         memset(&popup_info, 0, sizeof(pswd_popup_create_req_data_t));
547
548         popup_info.title = "IDS_WIFI_HEADER_SELECT_WPS_METHOD_ABB";
549         popup_info.ok_cb = NULL;
550         popup_info.cancel_cb = _wps_cancel_cb;
551         popup_info.show_wps_btn = EINA_FALSE;
552         popup_info.wps_btn_cb = _wps_btn_cb;
553         popup_info.wps_pin_cb = _wps_pin_cb;
554         popup_info.ap = passwd_popup_get_ap(ug_app_state->passpopup);
555         popup_info.cb_data = NULL;
556         create_wps_options_popup(ug_app_state->layout_main, ug_app_state->passpopup,
557                         &popup_info);
558
559         __COMMON_FUNC_EXIT__;
560 }
561
562 void viewer_list_wifi_reconnect(wifi_device_info_t *device_info)
563 {
564         pswd_popup_create_req_data_t popup_info;
565         wifi_security_type_e sec_type = WIFI_SECURITY_TYPE_NONE;
566         wifi_device_info_t *device_info_temp = NULL;
567         struct ug_data *ugd = (struct ug_data *)ug_app_state->gadget;
568
569         if (device_info == NULL)
570                 return;
571
572         if (ug_app_state->passpopup != NULL || ug_app_state->eap_view != NULL) {
573                 INFO_LOG(UG_NAME_ERR, "already launched popup");
574                 return;
575         }
576
577         wifi_ap_get_security_type(device_info->ap, &sec_type);
578
579         switch (sec_type) {
580         case WIFI_SECURITY_TYPE_WEP:
581         case WIFI_SECURITY_TYPE_WPA_PSK:
582         case WIFI_SECURITY_TYPE_WPA2_PSK:
583                 memset(&popup_info, 0, sizeof(pswd_popup_create_req_data_t));
584
585                 device_info_temp = view_list_item_device_info_create(device_info->ap);
586
587                 popup_info.title = device_info->ssid;
588                 popup_info.ok_cb = __passwd_popup_ok_cb;
589                 popup_info.cancel_cb = __passwd_popup_cancel_cb;
590                 popup_info.show_wps_btn = device_info->wps_mode;
591                 popup_info.wps_btn_cb = __wps_options_popup_cb;
592                 popup_info.ap = device_info->ap;
593                 popup_info.cb_data = device_info_temp;
594                 popup_info.sec_type = sec_type;
595
596                 /* TODO: parameter with device_info */
597                 /* TODO: finally parameter with wifi_ap_h, WPA, EAP */
598                 ug_app_state->passpopup = create_passwd_popup(
599                                 ug_app_state->conformant,
600                                 ug_app_state->layout_main, PACKAGE, &popup_info);
601
602                 if (ug_app_state->passpopup == NULL) {
603                         INFO_LOG(UG_NAME_ERR, "Fail to create password popup");
604                 }
605
606                 break;
607         case WIFI_SECURITY_TYPE_EAP:
608                 ug_app_state->eap_view = create_eap_view(
609                                 ug_app_state->layout_main, ugd->win_main,
610                                 ug_app_state->conformant,
611                                 PACKAGE, device_info,
612                                 viewer_manager_eap_view_deref);
613                 break;
614         default:
615                 ERROR_LOG(UG_NAME_NORMAL, "Unknown security type [%d]", sec_type);
616                 return;
617         }
618
619 }
620
621 void viewer_list_wifi_connect(wifi_device_info_t *device_info)
622 {
623         bool favorite = false;
624         pswd_popup_create_req_data_t popup_info;
625         wifi_security_type_e sec_type = WIFI_SECURITY_TYPE_NONE;
626         wifi_device_info_t *dev_info_temp = NULL;
627         struct ug_data *ugd = (struct ug_data *)ug_app_state->gadget;
628
629         if (device_info == NULL)
630                 return;
631
632         wifi_ap_is_favorite(device_info->ap, &favorite);
633         if (favorite == true) {
634                 wlan_manager_connect(device_info->ap);
635                 return;
636         }
637
638         if (ug_app_state->passpopup != NULL || ug_app_state->eap_view != NULL) {
639                 INFO_LOG(UG_NAME_ERR, "already launched popup");
640                 return;
641         }
642
643         wifi_ap_get_security_type(device_info->ap, &sec_type);
644
645         switch (sec_type) {
646         case WIFI_SECURITY_TYPE_NONE:
647                 if(ug_app_state->is_hidden) {
648                         wifi_ap_h ap;
649                         char *ssid;
650                         wifi_ap_get_essid(device_info->ap, &ssid);
651                         wifi_ap_hidden_create(ssid, &ap);
652                         g_free(ssid);
653                         wifi_ap_set_security_type(ap, WIFI_SECURITY_TYPE_NONE);
654                         wlan_manager_connect(ap);
655                 } else
656                         wlan_manager_connect(device_info->ap);
657                 break;
658
659         case WIFI_SECURITY_TYPE_WEP:
660         case WIFI_SECURITY_TYPE_WPA_PSK:
661         case WIFI_SECURITY_TYPE_WPA2_PSK:
662                 memset(&popup_info, 0, sizeof(pswd_popup_create_req_data_t));
663
664                 dev_info_temp = view_list_item_device_info_create(device_info->ap);
665
666                 popup_info.title = device_info->ssid;
667                 popup_info.ok_cb = __passwd_popup_ok_cb;
668                 popup_info.cancel_cb = __passwd_popup_cancel_cb;
669                 popup_info.show_wps_btn = device_info->wps_mode;
670                 popup_info.wps_btn_cb = __wps_options_popup_cb;
671                 popup_info.ap = device_info->ap;
672                 popup_info.cb_data = dev_info_temp;
673                 popup_info.sec_type = sec_type;
674
675                 /* TODO: parameter with device_info */
676                 /* TODO: finally parameter with wifi_ap_h, WPA, EAP */
677                 ug_app_state->passpopup = create_passwd_popup(
678                                 ug_app_state->conformant,
679                                 ug_app_state->layout_main, PACKAGE, &popup_info);
680
681                 if (ug_app_state->passpopup == NULL) {
682                         INFO_LOG(UG_NAME_ERR, "Fail to create password popup");
683                 }
684
685                 break;
686
687         case WIFI_SECURITY_TYPE_EAP:
688                 ug_app_state->eap_view = create_eap_view(
689                                 ug_app_state->layout_main, ugd->win_main,
690                                 ug_app_state->conformant,
691                                 PACKAGE, device_info,
692                                 viewer_manager_eap_view_deref);
693                 break;
694
695         default:
696                 ERROR_LOG(UG_NAME_NORMAL, "Unknown security type[%d]", sec_type);
697                 break;
698         }
699 }
700
701 void viewer_list_clear_disconnect_popup(wifi_ap_h ap)
702 {
703         if (!g_disconnect_popup)
704                 return;
705
706         if (ap && g_disconnect_popup->ap &&
707                         wlan_manager_is_same_network(g_disconnect_popup->ap, ap) != TRUE)
708                 return;
709
710         if (g_disconnect_popup->popup)
711                 evas_object_del(g_disconnect_popup->popup);
712
713         if (g_disconnect_popup->ap)
714                 wifi_ap_destroy(g_disconnect_popup->ap);
715
716         g_free(g_disconnect_popup);
717         g_disconnect_popup = NULL;
718 }
719
720 static void __viewer_list_disconnect_cancel_cb(void *data,
721                 Evas_Object *obj, void *event_info)
722 {
723         struct connecting_cancel_popup_data *popup =
724                         (struct connecting_cancel_popup_data *)data;
725         if (!popup)
726                 return;
727
728         if (popup->popup)
729                 evas_object_del(popup->popup);
730
731         if (popup->ap)
732                 wifi_ap_destroy(popup->ap);
733
734         g_free(popup);
735         g_disconnect_popup = NULL;
736 }
737
738 static gboolean __viewer_list_update_ap(gpointer data)
739 {
740         wifi_ap_h ap = (wifi_ap_h)data;
741
742         viewer_manager_update_item_favorite_status(ap);
743         wifi_ap_destroy(ap);
744
745         return FALSE;
746 }
747
748 static void __viewer_list_disconnect_ok_cb(void *data,
749                 Evas_Object *obj, void *event_info)
750 {
751         guint id;
752         struct connecting_cancel_popup_data *popup =
753                         (struct connecting_cancel_popup_data *)data;
754         if (!popup)
755                 return;
756
757         wlan_manager_disconnect(popup->ap);
758         wlan_manager_forget(popup->ap);
759
760         if (popup->popup)
761                 evas_object_del(popup->popup);
762
763         id = common_util_managed_idle_add(__viewer_list_update_ap, (gpointer)popup->ap);
764         if (!id) {
765                 viewer_manager_update_item_favorite_status(popup->ap);
766                 wifi_ap_destroy(popup->ap);
767         }
768
769         g_free(popup);
770         g_disconnect_popup = NULL;
771 }
772
773 static void __viewer_list_disconnect_popup(wifi_device_info_t *device_info,
774                 Evas_Object *win_main)
775 {
776         popup_btn_info_t popup_data;
777         struct connecting_cancel_popup_data *popup = NULL;
778
779         memset(&popup_data, 0, sizeof(popup_data));
780
781         popup = g_try_new0(struct connecting_cancel_popup_data, 1);
782         if (!popup)
783                 return;
784
785         g_disconnect_popup = popup;
786         wifi_ap_clone(&popup->ap, device_info->ap);
787
788         popup_data.title_txt = "IDS_WIFI_OPT_FORGET_NETWORK";
789         popup_data.info_txt = "IDS_WIFI_POP_CURRENT_NETWORK_WILL_BE_DISCONNECTED";
790         popup_data.btn1_cb = __viewer_list_disconnect_cancel_cb;
791         popup_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
792         popup_data.btn1_data = popup;
793         popup_data.btn2_cb = __viewer_list_disconnect_ok_cb;
794         popup_data.btn2_txt = "IDS_WIFI_SK_FORGET";
795         popup_data.btn2_data = popup;
796
797         popup->popup = common_utils_show_info_popup(win_main, &popup_data);
798 }
799
800 static void __viewer_list_item_clicked_cb(void *data, Evas_Object *obj,
801                 void *event_info)
802 {
803         __COMMON_FUNC_ENTER__;
804
805         assertm_if(NULL == event_info, "event_info is NULL!!");
806         assertm_if(NULL == obj, "obj is NULL!!");
807
808         Elm_Object_Item *it = (Elm_Object_Item *)event_info;
809         ug_genlist_data_t *gdata = NULL;
810         wifi_device_info_t *device_info = NULL;
811
812         gdata = (ug_genlist_data_t *)elm_object_item_data_get(it);
813         retm_if(NULL == gdata);
814
815         device_info = gdata->device_info;
816         retm_if(NULL == device_info || NULL == device_info->ssid);
817
818         int item_state = gdata->radio_mode;
819         int current_state = 0;
820
821         SECURE_INFO_LOG(UG_NAME_NORMAL, "ssid --- %s", device_info->ssid);
822         INFO_LOG(UG_NAME_NORMAL, "ap --- 0x%x", device_info->ap);
823         INFO_LOG(UG_NAME_NORMAL, "current item_state state is --- %d", item_state);
824
825         if (ug_app_state->is_lbhome == EINA_TRUE &&
826                         ug_app_state->app_control != NULL) {
827                 INFO_LOG(UG_NAME_NORMAL, "exit with reply");
828                 char *bssid = NULL;
829                 app_control_h reply;
830
831                 app_control_create(&reply);
832                 wifi_ap_get_bssid(device_info->ap, &bssid);
833                 SECURE_INFO_LOG(UG_NAME_NORMAL, "bssid %s, ssid %s", bssid, device_info->ssid);
834
835                 app_control_add_extra_data(reply, "bssid", bssid);
836                 app_control_add_extra_data(reply, "ssid", device_info->ssid);
837                 app_control_reply_to_launch_request(reply, ug_app_state->app_control,
838                                 APP_CONTROL_RESULT_SUCCEEDED);
839                 app_control_destroy(reply);
840                 g_free(bssid);
841                 wifi_exit();
842                 return;
843         }
844
845         switch (item_state) {
846         case VIEWER_ITEM_RADIO_MODE_OFF:
847                 current_state = viewer_manager_header_mode_get();
848
849                 INFO_LOG(UG_NAME_NORMAL, "Clicked AP information\n");
850                 INFO_LOG(UG_NAME_NORMAL, "header mode [%d]", current_state);
851
852                 switch (current_state) {
853                 case HEADER_MODE_ON:
854                 case HEADER_MODE_CONNECTED:
855                 case HEADER_MODE_CONNECTING:
856                 case HEADER_MODE_SEARCHING:
857                         viewer_list_wifi_connect(device_info);
858                         break;
859
860                 case HEADER_MODE_OFF:
861                 case HEADER_MODE_ACTIVATING:
862                 case HEADER_MODE_DEACTIVATING:
863                 default:
864                         INFO_LOG(UG_NAME_NORMAL, "Ignore click");
865                         break;
866                 }
867                 break;
868
869         case VIEWER_ITEM_RADIO_MODE_CONNECTING:
870         case VIEWER_ITEM_RADIO_MODE_CONFIGURATION:
871                 __viewer_list_disconnect_popup(device_info, ug_app_state->layout_main);
872                 break;
873         case VIEWER_ITEM_RADIO_MODE_CONNECTED:
874         default:
875                 INFO_LOG(UG_NAME_NORMAL, "Ignore click");
876                 break;
877         }
878
879         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
880
881         __COMMON_FUNC_EXIT__;
882 }
883
884 static char *viewer_list_get_device_status_txt(wifi_device_info_t *wifi_device,
885                 VIEWER_ITEM_RADIO_MODES mode)
886 {
887         char *status_txt = NULL;
888         int current_state = 0;
889
890         current_state = viewer_manager_header_mode_get();
891         /* The strings are currently hard coded. It will be replaced with string ids later */
892         if (VIEWER_ITEM_RADIO_MODE_CONNECTING == mode) {
893                 status_txt = g_strdup(sc(PACKAGE, I18N_TYPE_Connecting));
894         } else if (VIEWER_ITEM_RADIO_MODE_CONFIGURATION == mode) {
895                 status_txt = g_strdup(sc(PACKAGE, I18N_TYPE_Obtaining_IP_addr));
896         } else if (VIEWER_ITEM_RADIO_MODE_CONNECTED == mode) {
897                 if (connection_manager_is_wifi_connection_used() ||
898                                 current_state == HEADER_MODE_CONNECTED ) {
899                         status_txt = g_strdup(sc(PACKAGE, I18N_TYPE_Connected));
900                 }
901         } else if (VIEWER_ITEM_RADIO_MODE_OFF == mode) {
902                 status_txt = common_utils_get_ap_security_type_info_txt(PACKAGE,
903                         wifi_device, true);
904         } else {
905                 status_txt = g_strdup(sc(PACKAGE, I18N_TYPE_Unknown));
906                 INFO_LOG(UG_NAME_NORMAL, "Invalid mode: %d", mode);
907         }
908
909         return status_txt;
910 }
911
912 Evas_Object* viewer_list_create(Evas_Object *win)
913 {
914         __COMMON_FUNC_ENTER__;
915
916         assertm_if(NULL == win, "NULL!!");
917         assertm_if(NULL != viewer_list, "Err!!");
918
919         viewer_list = elm_genlist_add(win);
920         assertm_if(NULL == viewer_list, "NULL!!");
921
922         // To use multiline textblock/entry/editfield in genlist, set height_for_width mode
923         // then the item's height is calculated while the item's width fits to genlist width.
924         elm_genlist_mode_set(viewer_list, ELM_LIST_COMPRESS);
925         //elm_genlist_realization_mode_set(viewer_list, EINA_TRUE);
926
927         evas_object_size_hint_weight_set(viewer_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
928         evas_object_size_hint_align_set(viewer_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
929
930         itc.item_style = WIFI_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
931         itc.func.text_get = _gl_listview_text_get;
932         itc.func.content_get = _gl_listview_content_get;
933         itc.func.state_get = NULL;
934         itc.func.del = _gl_listview_del;
935
936         no_wifi_device_itc.item_style = WIFI_GENLIST_1LINE_TEXT_STYLE;
937         no_wifi_device_itc.func.text_get = _gl_listview_text_get;
938         no_wifi_device_itc.func.content_get = NULL;
939         no_wifi_device_itc.func.state_get = NULL;
940         no_wifi_device_itc.func.del = _gl_listview_del;
941
942         first_item = last_item = NULL;
943
944         evas_object_smart_callback_add(viewer_list, "realized",
945                         _gl_realized, NULL);
946         evas_object_smart_callback_add(viewer_list, "language,changed",
947                         gl_lang_changed, NULL);
948
949         __COMMON_FUNC_EXIT__;
950         return viewer_list;
951 }
952
953 void viewer_list_title_item_del(void)
954 {
955         if (grouptitle != NULL) {
956                 elm_object_item_del(grouptitle);
957                 grouptitle = NULL;
958         }
959 }
960
961 void viewer_list_title_item_update(void)
962 {
963         if (grouptitle != NULL)
964                 elm_genlist_item_update(grouptitle);
965 }
966
967 void viewer_list_title_item_set(Elm_Object_Item *item_header)
968 {
969         if (item_header == NULL)
970                 return;
971
972         if (grouptitle != NULL) {
973                 elm_genlist_item_update(grouptitle);
974                 return;
975         }
976
977         memset(&grouptitle_itc, 0, sizeof(grouptitle_itc));
978         grouptitle_itc.item_style = WIFI_GENLIST_GROUP_INDEX_STYLE;
979         grouptitle_itc.func.text_get = _gl_text_available_networks_get;
980         grouptitle_itc.func.content_get = _gl_content_scanning_icon_get;
981
982         grouptitle = elm_genlist_item_insert_after(viewer_list,
983                         &grouptitle_itc, NULL, NULL, item_header,
984                         ELM_GENLIST_ITEM_NONE, NULL, NULL);
985
986         assertm_if(NULL == grouptitle, "NULL!!");
987
988         elm_genlist_item_select_mode_set(grouptitle,
989                         ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
990 }
991
992 int viewer_list_item_radio_mode_set(Elm_Object_Item* item,
993                 VIEWER_ITEM_RADIO_MODES mode)
994 {
995         __COMMON_FUNC_ENTER__;
996
997         if (NULL == item) {
998                 INFO_LOG(COMMON_NAME_ERR, "item is NULL");
999                 return FALSE;
1000         }
1001
1002         ug_genlist_data_t* gdata = (ug_genlist_data_t *) elm_object_item_data_get(item);
1003         if (NULL == gdata || NULL == gdata->device_info) {
1004                 INFO_LOG(COMMON_NAME_ERR, "gdata or device_info is NULL");
1005                 return FALSE;
1006         }
1007
1008         if (gdata->radio_mode == mode) {
1009                 SECURE_INFO_LOG(UG_NAME_NORMAL, "[%s] is already in requested state", gdata->device_info->ssid);
1010                 return FALSE;
1011         }
1012
1013         SECURE_INFO_LOG(UG_NAME_NORMAL, "[%s] AP Item State Transition from [%d] --> [%d]", gdata->device_info->ssid, gdata->radio_mode, mode);
1014         gdata->radio_mode = mode;
1015         if (gdata->device_info->ap_status_txt) {
1016                 g_free(gdata->device_info->ap_status_txt);
1017                 gdata->device_info->ap_status_txt = viewer_list_get_device_status_txt(gdata->device_info, mode);
1018         }
1019
1020         if(item != NULL)
1021                 elm_genlist_item_update(item);
1022
1023         __COMMON_FUNC_EXIT__;
1024         return TRUE;
1025 }
1026
1027 static wifi_connection_state_e _convert_wifi_state_to_viewer_radio_mode(
1028                 wifi_connection_state_e state)
1029 {
1030         switch (state) {
1031                 case WIFI_CONNECTION_STATE_ASSOCIATION:
1032                         return VIEWER_ITEM_RADIO_MODE_CONNECTING;
1033                 case WIFI_CONNECTION_STATE_CONFIGURATION:
1034                         return VIEWER_ITEM_RADIO_MODE_CONFIGURATION;
1035                 case WIFI_CONNECTION_STATE_CONNECTED:
1036                         return VIEWER_ITEM_RADIO_MODE_CONNECTED;
1037                 default:
1038                         return VIEWER_ITEM_RADIO_MODE_OFF;
1039         }
1040 }
1041
1042 Elm_Object_Item *viewer_list_item_insert_after(wifi_device_info_t *wifi_device,
1043                 Elm_Object_Item *after)
1044 {
1045         Elm_Object_Item* ret = NULL;
1046         ug_genlist_data_t* gdata = NULL;
1047         wifi_device_info_t *no_wifi_device = NULL;
1048         wifi_connection_state_e state = WIFI_CONNECTION_STATE_DISCONNECTED;
1049         VIEWER_ITEM_RADIO_MODES rad_mode = VIEWER_ITEM_RADIO_MODE_OFF;
1050         retvm_if(NULL == viewer_list, NULL);
1051
1052         if (wifi_device != NULL) {
1053                 if (wifi_ap_get_connection_state(wifi_device->ap, &state) ==
1054                                 WIFI_ERROR_NONE) {
1055                         rad_mode = _convert_wifi_state_to_viewer_radio_mode(state);
1056                 }
1057                 wifi_device->ap_status_txt = viewer_list_get_device_status_txt(
1058                                                 wifi_device,
1059                                                 rad_mode);
1060         } else {
1061                 if (ug_app_state->is_first_scan == true) {
1062                         int scan_result = wlan_manager_scan();
1063                         if (scan_result != WLAN_MANAGER_ERR_NONE) {
1064                                 viewer_manager_hide(VIEWER_WINSET_SEARCHING);
1065                                 viewer_manager_header_mode_set(viewer_manager_header_mode_get());
1066                         }
1067                         ug_app_state->is_first_scan = false;
1068                         return NULL;
1069                 }
1070                 no_wifi_device = g_try_new0(wifi_device_info_t, 1);
1071                 if (no_wifi_device == NULL)
1072                         return NULL;
1073
1074                 no_wifi_device->ssid = g_strdup(sc(PACKAGE, I18N_TYPE_No_Wi_Fi_AP_Found));
1075
1076                 wifi_device = no_wifi_device;
1077         }
1078
1079         gdata = g_try_new0(ug_genlist_data_t, 1);
1080         retvm_if(NULL == gdata, NULL);
1081         gdata->device_info = wifi_device;
1082         gdata->radio_mode = VIEWER_ITEM_RADIO_MODE_OFF;
1083
1084         if (!after) {
1085                 /* If the after item is NULL then insert it as first item */
1086                 after = grouptitle;
1087         }
1088
1089         if (no_wifi_device == NULL) {
1090                 ret = elm_genlist_item_insert_after(
1091                                 viewer_list, /*obj*/
1092                                 &itc,/*itc*/
1093                                 gdata,/*data*/
1094                                 NULL,/*parent*/
1095                                 after, /*after than*/
1096                                 ELM_GENLIST_ITEM_NONE, /*flags*/
1097                                 __viewer_list_item_clicked_cb,/*func*/
1098                                 NULL);/*func_data*/
1099         } else {
1100                 ret = elm_genlist_item_insert_after(
1101                                 viewer_list, /*obj*/
1102                                 &no_wifi_device_itc,/*itc*/
1103                                 gdata,/*data*/
1104                                 NULL,/*parent*/
1105                                 after, /*after than*/
1106                                 ELM_GENLIST_ITEM_NONE, /*flags*/
1107                                 __viewer_list_item_clicked_cb,/*func*/
1108                                 NULL);/*func_data*/
1109         }
1110
1111         if (!ret) {
1112                 assertm_if(NULL == ret, "NULL!!");
1113                 g_free(gdata);
1114         } else {
1115                 /* SECURE_DEBUG_LOG(UG_NAME_NORMAL,
1116                                 "* item add complete item [0x%x] ssid:[%s] security[%d] size:[%d]",
1117                                 ret,
1118                                 wifi_device->ssid,
1119                                 wifi_device->security_mode,
1120                                 viewer_list_item_size_get()); */
1121
1122                 if (after == grouptitle) {
1123                         first_item = ret;
1124                         if (!last_item) {
1125                                 last_item = ret;
1126                         }
1127                 } else {
1128                         last_item = ret;
1129                         if (!first_item) {
1130                                 first_item = ret;
1131                         }
1132                 }
1133
1134                 if(ret != NULL)
1135                         elm_genlist_item_update(ret);
1136         }
1137
1138         return ret;
1139 }
1140
1141 void viewer_list_item_del(Elm_Object_Item *it)
1142 {
1143         if (it == NULL) {
1144                 return;
1145         }
1146
1147         if (it == first_item) {
1148                 first_item = elm_genlist_item_next_get(first_item);
1149         } else if (it == last_item) {
1150                 last_item = elm_genlist_item_prev_get(last_item);
1151         }
1152         elm_object_item_del(it);
1153 }
1154
1155 int viewer_list_item_size_get()
1156 {
1157         int ret = 0;
1158         Elm_Object_Item *it = first_item;
1159
1160         while(it) {
1161                 ret++;
1162                 if (it == last_item) {
1163                         break;
1164                 }
1165                 it = elm_genlist_item_next_get(it);
1166         }
1167
1168         return ret;
1169 }
1170
1171 void viewer_list_item_clear(void)
1172 {
1173         __COMMON_FUNC_ENTER__;
1174
1175         Elm_Object_Item *it = first_item;
1176         Elm_Object_Item *nxt = NULL;
1177
1178         while(it) {
1179                 nxt = elm_genlist_item_next_get(it);
1180                 elm_object_item_del(it);
1181                 if (it == last_item) {
1182                         break;
1183                 }
1184                 it = nxt;
1185         }
1186
1187         first_item = last_item = NULL;
1188
1189         __COMMON_FUNC_EXIT__;
1190 }
1191
1192 void viewer_list_item_enable_all(void)
1193 {
1194         __COMMON_FUNC_ENTER__;
1195
1196         Elm_Object_Item *it = first_item;
1197
1198         while(it) {
1199                 elm_object_item_disabled_set(it, EINA_FALSE);
1200
1201                 if (it == last_item) {
1202                         break;
1203                 }
1204
1205                 it = elm_genlist_item_next_get(it);
1206         }
1207
1208         __COMMON_FUNC_EXIT__;
1209 }
1210
1211 void viewer_list_item_disable_all(void)
1212 {
1213         __COMMON_FUNC_ENTER__;
1214
1215         Elm_Object_Item *it = first_item;
1216
1217         while(it) {
1218                 elm_object_item_disabled_set(it, EINA_TRUE);
1219
1220                 if (it == last_item) {
1221                         break;
1222                 }
1223
1224                 it = elm_genlist_item_next_get(it);
1225         }
1226
1227         __COMMON_FUNC_EXIT__;
1228 }
1229
1230 Elm_Object_Item* item_get_for_ap(wifi_ap_h ap)
1231 {
1232         __COMMON_FUNC_ENTER__;
1233         if (!ap) {
1234                 __COMMON_FUNC_EXIT__;
1235                 return NULL;
1236         }
1237
1238         char *essid = NULL;
1239         wifi_security_type_e type = WIFI_SECURITY_TYPE_NONE;
1240
1241         if (WIFI_ERROR_NONE != wifi_ap_get_essid(ap, &essid)) {
1242                 __COMMON_FUNC_EXIT__;
1243                 return NULL;
1244         } else if (WIFI_ERROR_NONE != wifi_ap_get_security_type(ap, &type)) {
1245                 __COMMON_FUNC_EXIT__;
1246                 return NULL;
1247         }
1248
1249         Elm_Object_Item *it = first_item;
1250         wlan_security_mode_type_t sec_mode = common_utils_get_sec_mode(type);
1251         while(it) {
1252                 ug_genlist_data_t* gdata = elm_object_item_data_get(it);
1253                 wifi_device_info_t *device_info = NULL;
1254                 if (gdata && (device_info = gdata->device_info)) {
1255                         if (!g_strcmp0(device_info->ssid, essid) && device_info->security_mode == sec_mode) {
1256                                 break;
1257                         }
1258                 }
1259                 if (it == last_item) {
1260                         it = NULL;
1261                         break;
1262                 }
1263                 it = elm_genlist_item_next_get(it);
1264         }
1265
1266         g_free(essid);
1267         __COMMON_FUNC_EXIT__;
1268         return it;
1269 }
1270
1271 Elm_Object_Item* item_get_for_ssid(const char *ssid)
1272 {
1273         Elm_Object_Item *it = first_item;
1274         while (it) {
1275                 ug_genlist_data_t* gdata = elm_object_item_data_get(it);
1276                 wifi_device_info_t *device_info = NULL;
1277                 if (gdata && (device_info = gdata->device_info)) {
1278                         if (!g_strcmp0(device_info->ssid, ssid)) {
1279                                 break;
1280                         }
1281                 }
1282                 if (it == last_item) {
1283                         it = NULL;
1284                         break;
1285                 }
1286                 it = elm_genlist_item_next_get(it);
1287         }
1288
1289         return it;
1290 }