4 * Copyright 2012 Samsung Electronics Co., Ltd
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
10 * http://www.tizenopensource.org/license
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.
21 #include "common_utils.h"
23 #include "wlan_manager.h"
24 #include "view_detail.h"
25 #include "viewer_list.h"
26 #include "viewer_manager.h"
27 #include "appcoreWrapper.h"
28 #include "i18nmanager.h"
30 #define LIST_ITEM_CONNECTED_AP_FONT_SIZE 28
31 #define LIST_ITEM_CONNECTED_AP_FONT_COLOR "#3B73B6"
32 #define FIRST_ITEM_NUMBER 8
35 static Evas_Object* viewer_list = NULL;
36 static Elm_Object_Item* first_item = NULL;
37 static Elm_Object_Item* last_item = NULL;
39 static Elm_Genlist_Item_Class itc;
40 static Elm_Genlist_Item_Class grouptitle_itc;
41 static Elm_Object_Item* grouptitle = NULL;
43 extern wifi_appdata *ug_app_state;
45 void list_select_cb(void *data, Evas_Object *obj, void *event_info)
47 __COMMON_FUNC_ENTER__;
49 INFO_LOG(UG_NAME_NORMAL,"=================\n");
50 INFO_LOG(UG_NAME_NORMAL," %s %d\n", __func__ ,__LINE__);
51 INFO_LOG(UG_NAME_NORMAL,"=================\n");
58 wifi_device_info_t *device_info = (wifi_device_info_t *)data;
60 DEBUG_LOG(UG_NAME_NORMAL, "ssid [%s]", device_info->ssid);
62 view_detail(device_info, ug_app_state->layout_main);
67 static char* _gl_listview_text_get(void *data, Evas_Object *obj, const char *part)
70 assertm_if(NULL == obj, "NULL!!");
71 assertm_if(NULL == part, "NULL!!");
72 assertm_if(NULL == data, "NULL!!");
74 ug_genlist_data_t* gdata = (ug_genlist_data_t*) data;
75 assertm_if(NULL == gdata, "NULL!!");
76 assertm_if(NULL == gdata->device_info, "NULL!!");
77 assertm_if(NULL == gdata->device_info->ssid, "NULL!!");
78 assertm_if(NULL == gdata->device_info->ap_status_txt, "NULL!!");
80 if (!strncmp(part, "elm.text.1", strlen(part))) {
81 det = g_strdup(gdata->device_info->ssid);
82 assertm_if(NULL == det, "NULL!!");
83 } else if (!strncmp(part, "elm.text.2", strlen(part))) {
84 det = g_strdup(gdata->device_info->ap_status_txt);
85 assertm_if(NULL == det, "NULL!!");
90 static Evas_Object *_gl_listview_content_get(void *data, Evas_Object *obj, const char *part)
92 assertm_if(NULL == obj, "NULL!!");
93 assertm_if(NULL == data, "NULL!!");
94 assertm_if(NULL == part, "NULL!!");
96 ug_genlist_data_t* gdata = (ug_genlist_data_t*) data;
97 Evas_Object* icon = NULL;
99 if (gdata->device_info->ap_image_path == NULL) {
100 /* if there is no ap_image_path (NO AP Found situation) */
101 DEBUG_LOG(UG_NAME_ERR, "Fatal: Image path is NULL");
102 } else if (!strncmp(part, "elm.icon.1", strlen(part))) {
104 icon = elm_image_add(obj);
105 assertm_if(NULL == icon, "NULL!!");
106 elm_image_file_set(icon, gdata->device_info->ap_image_path, NULL);
107 } else if (!strncmp(part, "elm.icon.2", strlen(part))) {
108 if (VIEWER_ITEM_RADIO_MODE_CONNECTING == gdata->radio_mode) {
109 icon = elm_progressbar_add(obj);
110 elm_object_style_set(icon, "list_process");
111 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, 0.5);
112 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
113 elm_progressbar_pulse(icon, TRUE);
115 icon = elm_button_add(obj);
116 assertm_if(NULL == icon, "NULL!!");
117 elm_object_style_set(icon, "reveal");
118 evas_object_smart_callback_add(icon, "clicked", (Evas_Smart_Cb)list_select_cb, gdata->device_info);
119 evas_object_propagate_events_set(icon, EINA_FALSE);
126 static void _gl_listview_del(void* data, Evas_Object* obj)
131 ug_genlist_data_t* gdata = (ug_genlist_data_t*) data;
132 assertm_if(NULL == gdata->device_info->ssid, "NULL!!");
134 DEBUG_LOG(UG_NAME_NORMAL, "del target ssid:[%s]", gdata->device_info->ssid);
136 g_free(gdata->device_info->ap_image_path);
137 g_free(gdata->device_info->ap_status_txt);
138 g_free(gdata->device_info->ssid);
139 wifi_ap_destroy(gdata->device_info->ap);
140 g_free(gdata->device_info);
146 static char* _gl_text_title_get(void *data, Evas_Object *obj, const char *part)
148 assertm_if(NULL == obj, "NULL!!");
149 assertm_if(NULL == part, "NULL!!");
151 return (char*) g_strdup(sc(PACKAGE, I18N_TYPE_WiFi_network));
154 static Evas_Object *_gl_content_title_get(void *data, Evas_Object *obj, const char *part)
156 __COMMON_FUNC_ENTER__;
157 Evas_Object *title_progressbar = NULL;
158 if (HEADER_MODE_SEARCHING == viewer_manager_header_mode_get()) {
159 if (!strcmp(part, "elm.icon")) {
160 title_progressbar = elm_progressbar_add(obj);
161 elm_object_style_set(title_progressbar, "list_process_small");
162 elm_progressbar_horizontal_set(title_progressbar, EINA_TRUE);
163 elm_progressbar_pulse(title_progressbar, EINA_TRUE);
166 __COMMON_FUNC_EXIT__;
167 return title_progressbar;
171 Elm_Object_Item* viewer_list_get_first_item(void)
176 static Elm_Object_Item* viewer_list_get_last_item(void)
181 static void _gl_realized(void *data, Evas_Object *obj, void *event_info)
183 HEADER_MODES header_mode = viewer_manager_header_mode_get();
185 if (header_mode == HEADER_MODE_ACTIVATING ||
186 header_mode == HEADER_MODE_DEACTIVATING ||
187 header_mode == HEADER_MODE_OFF)
190 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
191 int index = (int)elm_genlist_item_index_get(item);
192 int first_item_index = (int)elm_genlist_item_index_get(viewer_list_get_first_item());
193 int last_item_index = (int)elm_genlist_item_index_get(viewer_list_get_last_item());
195 if (last_item_index == FIRST_ITEM_NUMBER)
198 if (first_item_index == -1) {
199 int group_index = (int)elm_genlist_item_index_get(grouptitle);
200 first_item_index = group_index+1;
203 if (first_item_index <= index) {
204 if(index == first_item_index)
205 elm_object_item_signal_emit(item, "elm,state,top", "");
206 else if (index == last_item_index)
207 elm_object_item_signal_emit(item, "elm,state,bottom", "");
209 elm_object_item_signal_emit(item, "elm,state,center", "");
212 elm_genlist_item_update(item);
217 static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
219 __COMMON_FUNC_ENTER__;
220 if (!ug_app_state->passpopup) {
224 common_pswd_popup_destroy(ug_app_state->passpopup);
225 ug_app_state->passpopup = NULL;
226 __COMMON_FUNC_EXIT__;
229 static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
231 __COMMON_FUNC_ENTER__;
232 if (!ug_app_state->passpopup) {
236 wifi_security_type_e sec_mode = 0;
237 wifi_ap_h ap = common_pswd_popup_get_ap(ug_app_state->passpopup);
238 int ret = WLAN_MANAGER_ERR_NONE;
240 const char* szPassword = common_pswd_popup_get_txt(ug_app_state->passpopup);
241 nLen = strlen(szPassword);
242 INFO_LOG(UG_NAME_NORMAL, "password = [%s]", szPassword);
244 wifi_ap_get_security_type(ap, &sec_mode);
246 case WIFI_SECURITY_TYPE_WEP:
248 if (nLen != 5 && nLen != 13 && nLen != 26 && nLen != 10) {
249 winset_popup_mode_set(ug_app_state->popup_manager, POPUP_OPTION_WEP_PSWD_LEN_ERROR, NULL);
250 goto popup_ok_cb_exit;
254 case WIFI_SECURITY_TYPE_WPA_PSK:
255 case WIFI_SECURITY_TYPE_WPA2_PSK:
257 if (nLen < 8 || nLen > 63) {
258 winset_popup_mode_set(ug_app_state->popup_manager, POPUP_OPTION_WPA_PSWD_LEN_ERROR, NULL);
259 goto popup_ok_cb_exit;
264 ERROR_LOG(UG_NAME_SCAN, "Fatal: Wrong security mode : %d", sec_mode);
265 common_pswd_popup_destroy(ug_app_state->passpopup);
266 ug_app_state->passpopup = NULL;
267 goto popup_ok_cb_exit;
270 INFO_LOG(UG_NAME_SCAN, "connect with password comp");
271 ret = wlan_manager_connect_with_password(ap, szPassword);
272 if (WLAN_MANAGER_ERR_NONE == ret) {
273 viewer_manager_header_mode_set(HEADER_MODE_CONNECTING);
275 ERROR_LOG(UG_NAME_SCAN, "wlan error %d", ret);
276 viewer_manager_header_mode_set(HEADER_MODE_ON);
279 common_pswd_popup_destroy(ug_app_state->passpopup);
280 ug_app_state->passpopup = NULL;
284 g_free((gpointer)szPassword);
286 __COMMON_FUNC_EXIT__;
289 static void _wps_pbc_popup_cancel_connecting(void* data, Evas_Object* obj, void* event_info)
291 if (!ug_app_state->passpopup) {
295 wifi_ap_h ap = common_pswd_popup_get_ap(ug_app_state->passpopup);;
296 int ret = wlan_manager_request_disconnection(ap);
297 if (ret == WLAN_MANAGER_ERR_NONE) {
298 INFO_LOG(UG_NAME_NORMAL, "WPS conection cancelled successfully for AP[0x%x]", ap);
300 ERROR_LOG(UG_NAME_NORMAL, "Error!!! wlan_manager_request_disconnection failed for AP[0x%x]", ap);
302 common_pswd_popup_destroy(ug_app_state->passpopup);
303 ug_app_state->passpopup = NULL;
304 viewer_manager_header_mode_set(HEADER_MODE_ON);
308 static void _wps_btn_cb(void* data, Evas_Object* obj, void* event_info)
310 __COMMON_FUNC_ENTER__;
311 if (!ug_app_state->passpopup) {
315 wifi_ap_h ap = common_pswd_popup_get_ap(ug_app_state->passpopup);
316 int ret = wlan_manager_request_wps_connection(ap);
317 if (ret == WLAN_MANAGER_ERR_NONE) {
318 viewer_manager_header_mode_set(HEADER_MODE_CONNECTING);
319 common_pswd_popup_pbc_popup_create(ug_app_state->passpopup, _wps_pbc_popup_cancel_connecting, NULL);
321 ERROR_LOG(UG_NAME_NORMAL, "Error!!! wlan_manager_request_wps_connection failed");
322 common_pswd_popup_destroy(ug_app_state->passpopup);
323 ug_app_state->passpopup = NULL;
325 __COMMON_FUNC_EXIT__;
329 static gint __viewer_list_compare_mode(gconstpointer a, gconstpointer b)
331 Elm_Object_Item *item = (Elm_Object_Item *)a;
333 ug_genlist_data_t* gdata = elm_object_item_data_get(item);
335 VIEWER_ITEM_RADIO_MODES mode = (VIEWER_ITEM_RADIO_MODES)b;
336 if (gdata->radio_mode == mode)
343 static Elm_Object_Item *__wifi_viewer_list_get_item_in_mode(VIEWER_ITEM_RADIO_MODES mode)
345 Elm_Object_Item *item = NULL;
346 GSList *found = g_slist_find_custom(container, (gconstpointer)mode, __viewer_list_compare_mode);
348 INFO_LOG(UG_NAME_NORMAL, "item found in mode [%d]", mode);
355 static void __wifi_viewer_list_request_connection(wifi_device_info_t *device_info)
360 pswd_popup_create_req_data_t popup_info;
361 Evas_Object* navi_frame = NULL;
362 int ret = wlan_manager_request_connection(device_info->ap);;
364 case WLAN_MANAGER_ERR_NONE:
365 INFO_LOG(UG_NAME_NORMAL, "ERROR_NONE");
366 viewer_manager_header_mode_set(HEADER_MODE_CONNECTING);
368 case WLAN_MANAGER_ERR_CONNECT_PASSWORD_NEEDED:
369 memset(&popup_info, 0, sizeof(pswd_popup_create_req_data_t));
370 popup_info.title = device_info->ssid;
371 popup_info.ok_cb = _popup_ok_cb;
372 popup_info.cancel_cb = _popup_cancel_cb;
373 popup_info.show_wps_btn = device_info->wps_mode;
374 popup_info.wps_btn_cb = _wps_btn_cb;
375 popup_info.ap = device_info->ap;
376 popup_info.cb_data = NULL;
377 INFO_LOG(UG_NAME_NORMAL, "Going to create a popup. ug_app_state = 0x%x", ug_app_state);
378 ug_app_state->passpopup = common_pswd_popup_create(ug_app_state->layout_main, PACKAGE, &popup_info);
379 INFO_LOG(UG_NAME_NORMAL, "After create a popup");
380 if (ug_app_state->passpopup == NULL) {
381 INFO_LOG(UG_NAME_ERR, "pass popup create failed !");
385 case WLAN_MANAGER_ERR_CONNECT_EAP_SEC_TYPE:
386 navi_frame = viewer_manager_get_naviframe();
387 ug_app_state->eap_view = create_eap_connect_view(ug_app_state->layout_main, navi_frame, PACKAGE, device_info);
391 ERROR_LOG(UG_NAME_NORMAL, "errro code [%d]", ret);
396 static void viewer_list_item_clicked_cb(void* data, Evas_Object* obj, void* event_info)
398 __COMMON_FUNC_ENTER__;
399 assertm_if(NULL == event_info, "event_info is NULL!!");
400 assertm_if(NULL == data, "data is NULL!!");
401 assertm_if(NULL == obj, "obj is NULL!!");
403 int ret = WLAN_MANAGER_ERR_UNKNOWN;
404 Elm_Object_Item *it = (Elm_Object_Item *)event_info;
405 // Elm_Object_Item *connecting_item = NULL;
406 ug_genlist_data_t *gdata = (ug_genlist_data_t *)elm_object_item_data_get(it);
407 wifi_device_info_t *device_info = (wifi_device_info_t *)data;
409 if (!gdata || !device_info || !device_info->ssid) {
410 ERROR_LOG(UG_NAME_NORMAL, "Error!!! Invalid inout params");
411 __COMMON_FUNC_EXIT__;
415 int item_state = gdata->radio_mode;
416 int current_state = 0;
418 INFO_LOG(UG_NAME_NORMAL, "ssid --- %s", device_info->ssid);
419 INFO_LOG(UG_NAME_NORMAL, "ap --- 0x%x", device_info->ap);
420 INFO_LOG(UG_NAME_NORMAL, "current item_state state is --- %d\n", item_state);
422 switch (item_state) {
423 case VIEWER_ITEM_RADIO_MODE_OFF:
424 current_state = viewer_manager_header_mode_get();
426 INFO_LOG(UG_NAME_NORMAL, "Clicked AP`s information\n");
427 INFO_LOG(UG_NAME_NORMAL, "header mode [%d]", current_state);
429 switch (current_state) {
430 case HEADER_MODE_CONNECTED:
432 __wifi_viewer_list_request_connection(device_info);
435 case HEADER_MODE_CONNECTING:
436 #if 0 // Enable this later when two connect requests is supported by libnet.
437 /* Try connecting to the selected AP */
438 connecting_item = __wifi_viewer_list_get_item_in_mode(VIEWER_ITEM_RADIO_MODE_CONNECTING);
439 viewer_manager_header_mode_set(HEADER_MODE_ON);
440 wlan_manager_request_connection(device_info->ap);
442 /* Disconnect the connecting AP */
443 if (connecting_item) {
444 ug_genlist_data_t *connecting_gdata = elm_object_item_data_get(connecting_item);
445 if (connecting_gdata) {
446 wlan_manager_request_disconnection(connecting_gdata->device_info->ap);
451 case HEADER_MODE_OFF:
452 case HEADER_MODE_SEARCHING:
453 case HEADER_MODE_ACTIVATING:
454 case HEADER_MODE_DISCONNECTING:
455 case HEADER_MODE_DEACTIVATING:
457 INFO_LOG(UG_NAME_NORMAL, "Ignore the item click");
462 case VIEWER_ITEM_RADIO_MODE_CONNECTED:
463 INFO_LOG(UG_NAME_NORMAL, "want to disconnect for connected item");
464 ret = wlan_manager_request_disconnection(device_info->ap);
465 if(ret == WLAN_MANAGER_ERR_NONE){
466 viewer_manager_header_mode_set(HEADER_MODE_DISCONNECTING);
470 case VIEWER_ITEM_RADIO_MODE_CONNECTING:
471 INFO_LOG(UG_NAME_NORMAL, "want to cancel connecting for connected item");
472 ret = wlan_manager_request_disconnection(device_info->ap);
473 if(ret == WLAN_MANAGER_ERR_NONE){
474 viewer_manager_header_mode_set(HEADER_MODE_CANCEL_CONNECTING);
479 ret = WLAN_MANAGER_ERR_UNKNOWN;
483 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
485 __COMMON_FUNC_EXIT__;
489 static char *viewer_list_get_device_status_txt(wifi_device_info_t *wifi_device, VIEWER_ITEM_RADIO_MODES mode)
491 char *status_txt = NULL;
492 char *ret_txt = NULL;
493 /* The strings are currently hard coded. It will be replaced with string ids later */
494 if (VIEWER_ITEM_RADIO_MODE_CONNECTING == mode || VIEWER_ITEM_RADIO_MODE_WPS_CONNECTING == mode) {
495 status_txt = g_strdup(sc(PACKAGE, I18N_TYPE_Connecting));
496 } else if (VIEWER_ITEM_RADIO_MODE_CONNECTED == mode) {
497 status_txt = g_strdup_printf("<color=%s><b>%s</b></color>", LIST_ITEM_CONNECTED_AP_FONT_COLOR, sc(PACKAGE, I18N_TYPE_Connected));
498 } else if (VIEWER_ITEM_RADIO_MODE_DISCONNECTING == mode) {
499 status_txt = g_strdup(sc(PACKAGE, I18N_TYPE_Disconnecting));
500 } else if (VIEWER_ITEM_RADIO_MODE_OFF == mode) {
501 status_txt = common_utils_get_ap_security_type_info_txt(PACKAGE, wifi_device);
503 status_txt = g_strdup(WIFI_UNKNOWN_DEVICE_STATUS_STR);
504 INFO_LOG(UG_NAME_NORMAL, "Invalid mode: %d", mode);
506 ret_txt = g_strdup_printf("%s", status_txt);
511 Evas_Object* viewer_list_create(Evas_Object *win)
513 __COMMON_FUNC_ENTER__;
515 assertm_if(NULL == win, "NULL!!");
517 assertm_if(NULL != viewer_list, "Err!!");
518 viewer_list = elm_genlist_add(win);
521 elm_object_style_set(viewer_list, "dialogue");
522 assertm_if(NULL == viewer_list, "NULL!!");
524 elm_genlist_mode_set(viewer_list, ELM_LIST_LIMIT);
526 evas_object_size_hint_weight_set(viewer_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
527 evas_object_size_hint_align_set(viewer_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
529 itc.item_style = "dialogue/2text.2icon.3.tb";
530 itc.func.text_get = _gl_listview_text_get;
531 itc.func.content_get = _gl_listview_content_get;
532 itc.func.state_get = NULL;
533 itc.func.del = _gl_listview_del;
535 first_item = last_item = NULL;
537 evas_object_smart_callback_add(viewer_list, "realized", _gl_realized, NULL);
538 __COMMON_FUNC_EXIT__;
542 int viewer_list_destroy(void)
544 __COMMON_FUNC_ENTER__;
546 assertm_if(NULL == viewer_list, "NULL!!");
547 viewer_list_item_clear();
548 evas_object_del(viewer_list);
551 __COMMON_FUNC_EXIT__;
555 void viewer_list_title_item_del()
558 elm_object_item_del(grouptitle);
563 void viewer_list_title_item_update()
565 elm_genlist_item_update(grouptitle);
568 int viewer_list_title_item_set(void)
570 if (viewer_list_item_size_get() == 0 && !grouptitle) {
571 // To use multiline textblock/entry/editfield in genlist, set height_for_width mode
572 // then the item's height is calculated while the item's width fits to genlist width.
573 elm_genlist_mode_set(viewer_list, ELM_LIST_COMPRESS);
575 grouptitle_itc.item_style = "dialogue/title";
576 grouptitle_itc.func.text_get = _gl_text_title_get;
577 grouptitle_itc.func.content_get = _gl_content_title_get;
578 grouptitle_itc.func.state_get = NULL;
579 grouptitle_itc.func.del = NULL;
581 assertm_if(NULL != grouptitle, "Err!!");
583 grouptitle = elm_genlist_item_append(viewer_list,
587 ELM_GENLIST_ITEM_NONE,
591 assertm_if(NULL == grouptitle, "NULL!!");
593 elm_genlist_item_select_mode_set(grouptitle, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
601 int viewer_list_item_radio_mode_set(Elm_Object_Item* item, VIEWER_ITEM_RADIO_MODES mode)
603 __COMMON_FUNC_ENTER__;
605 INFO_LOG(COMMON_NAME_ERR, "item is NULL");
609 ug_genlist_data_t* gdata = (ug_genlist_data_t *) elm_object_item_data_get(item);
610 if (NULL == gdata || NULL == gdata->device_info) {
611 INFO_LOG(COMMON_NAME_ERR, "gdata or device_info is NULL");
615 if (gdata->radio_mode == mode) {
616 INFO_LOG(UG_NAME_NORMAL, "[%s] is already in requested state", gdata->device_info->ssid);
620 INFO_LOG(UG_NAME_NORMAL, "[%s] AP Item State Transition from [%d] --> [%d]", gdata->device_info->ssid, gdata->radio_mode, mode);
621 gdata->radio_mode = mode;
622 if (gdata->device_info->ap_status_txt) {
623 g_free(gdata->device_info->ap_status_txt);
624 gdata->device_info->ap_status_txt = viewer_list_get_device_status_txt(gdata->device_info, mode);
627 elm_genlist_item_update(item);
629 __COMMON_FUNC_EXIT__;
633 Elm_Object_Item* viewer_list_item_insert_after(wifi_ap_h ap, Elm_Object_Item *after)
635 Elm_Object_Item* ret = NULL;
636 wifi_security_type_e sec_type;
639 assertm_if(NULL == viewer_list, "NULL!!");
643 wifi_device_info_t *wifi_device = NULL;
646 wifi_device = wlan_manager_profile_device_info_blank_create();
650 wifi_device = g_new0(wifi_device_info_t, 1);
651 if (WIFI_ERROR_NONE != wifi_ap_clone(&(wifi_device->ap), ap)) {
652 goto FREE_DEVICE_INFO;
653 } else if (WIFI_ERROR_NONE != wifi_ap_get_essid(ap, &(wifi_device->ssid))) {
654 goto FREE_DEVICE_INFO;
655 } else if (WIFI_ERROR_NONE != wifi_ap_get_rssi(ap, &(wifi_device->rssi))) {
656 goto FREE_DEVICE_INFO;
657 } else if (WIFI_ERROR_NONE != wifi_ap_get_security_type (ap, &sec_type)) {
658 goto FREE_DEVICE_INFO;
659 } else if (WIFI_ERROR_NONE != wifi_ap_is_wps_supported (ap, &(wifi_device->wps_mode))) {
660 goto FREE_DEVICE_INFO;
662 wifi_device->security_mode = common_utils_get_sec_mode(sec_type);
663 wifi_device->ap_image_path = common_utils_get_device_icon(WIFI_APP_IMAGE_DIR, wifi_device);
664 wifi_device->ap_status_txt = viewer_list_get_device_status_txt(wifi_device, VIEWER_ITEM_RADIO_MODE_OFF);
666 ug_genlist_data_t* gdata = g_new0(ug_genlist_data_t, 1);
667 gdata->device_info = wifi_device;
668 gdata->radio_mode = VIEWER_ITEM_RADIO_MODE_OFF;
670 if (!after) { /* If the after item is NULL then insert it as first item */
674 ret = elm_genlist_item_insert_after(
679 after, /*after than*/
680 ELM_GENLIST_ITEM_NONE, /*flags*/
681 viewer_list_item_clicked_cb,/*func*/
682 wifi_device);/*func_data*/
685 assertm_if(NULL == ret, "NULL!!");
688 DEBUG_LOG(UG_NAME_NORMAL,
689 "* item add complete item [0x%x] ssid:[%s] security[%d] size:[%d]",
692 wifi_device->security_mode,
693 viewer_list_item_size_get());
695 if (after == grouptitle) {
705 elm_genlist_item_update(ret);
709 if (!ret && wifi_device) {
710 wifi_ap_destroy(wifi_device->ap);
711 g_free(wifi_device->ap_image_path);
712 g_free(wifi_device->ap_status_txt);
713 g_free(wifi_device->ssid);
720 void viewer_list_item_del(Elm_Object_Item *it)
725 if (it == first_item) {
726 first_item = elm_genlist_item_next_get(first_item);
727 } else if (it == last_item) {
728 last_item = elm_genlist_item_prev_get(last_item);
730 elm_object_item_del(it);
733 int viewer_list_item_size_get()
735 __COMMON_FUNC_ENTER__;
737 Elm_Object_Item *it = first_item;
743 it = elm_genlist_item_next_get(it);
746 __COMMON_FUNC_EXIT__;
750 void viewer_list_item_clear(void)
752 __COMMON_FUNC_ENTER__;
754 Elm_Object_Item *it = first_item;
755 Elm_Object_Item *nxt = NULL;
758 nxt = elm_genlist_item_next_get(it);
759 elm_object_item_del(it);
765 first_item = last_item = NULL;
767 __COMMON_FUNC_EXIT__;
770 void viewer_list_item_enable_all(void)
772 __COMMON_FUNC_ENTER__;
774 Elm_Object_Item *it = first_item;
777 elm_object_item_disabled_set(it, EINA_FALSE);
780 it = elm_genlist_item_next_get(it);
783 __COMMON_FUNC_EXIT__;
786 void viewer_list_item_disable_all(void)
788 __COMMON_FUNC_ENTER__;
790 Elm_Object_Item *it = first_item;
793 elm_object_item_disabled_set(it, EINA_TRUE);
796 it = elm_genlist_item_next_get(it);
799 __COMMON_FUNC_EXIT__;
802 Elm_Object_Item* item_get_for_ap(wifi_ap_h ap)
804 __COMMON_FUNC_ENTER__;
806 __COMMON_FUNC_EXIT__;
811 wifi_security_type_e type = WIFI_SECURITY_TYPE_NONE;
813 if (WIFI_ERROR_NONE != wifi_ap_get_essid(ap, &essid)) {
814 __COMMON_FUNC_EXIT__;
816 } else if (WIFI_ERROR_NONE != wifi_ap_get_security_type(ap, &type)) {
817 __COMMON_FUNC_EXIT__;
821 Elm_Object_Item *it = first_item;
822 wlan_security_mode_type_t sec_mode = common_utils_get_sec_mode(type);
824 ug_genlist_data_t* gdata = elm_object_item_data_get(it);
825 wifi_device_info_t *device_info = NULL;
826 if (gdata && (device_info = gdata->device_info)) {
827 if (!g_strcmp0(device_info->ssid, essid) && device_info->security_mode == sec_mode)
830 if (it == last_item) {
834 it = elm_genlist_item_next_get(it);
838 __COMMON_FUNC_EXIT__;