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