4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (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 <vconf-keys.h>
22 #include <ui-gadget.h>
23 #include <app_control_internal.h>
24 #include <efl_extension.h>
25 #include <wifi-manager.h>
29 #include "viewer_list.h"
30 #include "i18nmanager.h"
31 #include "common_utils.h"
32 #include "winset_popup.h"
33 #include "viewer_manager.h"
34 #include "view_ime_hidden.h"
35 #include "view_advanced.h"
36 #include "view_detail.h"
39 wifi_manager_security_type_e sec_mode;
41 wifi_device_info_t *device_info;
42 Evas_Object *confirm_popup;
45 typedef struct viewer_manager_object {
47 Elm_Object_Item *navi_it;
48 Evas_Object *scan_button;
49 Evas_Object *next_button;
50 Evas_Object *prev_button;
53 Evas_Object *sw_hidden_btn;
54 Evas_Object *sw_scan_btn;
56 Elm_Object_Item *item_wifi_onoff;
57 char *item_wifi_onoff_text;
59 Elm_Object_Item *item_onoff_description;
60 char *item_onoff_description_text;
62 HEADER_MODES header_mode;
63 Evas_Object *ctxpopup;
64 bool is_first_time_no_profiles;
67 hidden_ap_data_t *hidden_popup_data;
68 } viewer_manager_object;
72 Elm_Object_Item *last_appended_item;
73 int total_items_added;
74 } view_manager_list_update_info_t;
76 static viewer_manager_object *manager_object = NULL;
78 extern wifi_appdata *ug_app_state;
80 static Elm_Genlist_Item_Class wifi_onoff_itc;
81 static Elm_Genlist_Item_Class onoff_description_itc;
83 static GList *wifi_device_list = NULL;
84 static Eina_Bool rotate_flag = EINA_FALSE;
86 static bool show_more = TRUE;
88 static wifi_emulator_sample_s wifi_samples[] = {
89 {"datanetwork", WIFI_MANAGER_SECURITY_TYPE_WPA_PSK, 1},
90 {"ureadyinternet", WIFI_MANAGER_SECURITY_TYPE_EAP, 0},
91 {"uready", WIFI_MANAGER_SECURITY_TYPE_EAP, 1},
92 {"setup", WIFI_MANAGER_SECURITY_TYPE_NONE, 0},
93 {"Tizen", WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK, 1},
95 static int wifi_sample_count = sizeof(wifi_samples) / sizeof(wifi_samples[0]);
97 static void _hidden_button_callback(void* data, Evas_Object* obj, void* event_info);
98 static void viewer_manager_hidden_confirm_cleanup(void);
100 extern genlist_info_t g_genlist_info[WIFI_GENLIST_STYLE_MAX];
101 extern content_size_info_t g_content_size_info;
103 #ifdef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
104 static void _launch_wifi_direct_app(void)
106 int ret = APP_CONTROL_ERROR_NONE;
107 app_control_h app_control;
109 app_control_create(&app_control);
110 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
111 app_control_set_launch_mode(app_control, APP_CONTROL_LAUNCH_MODE_GROUP);
112 app_control_set_app_id(app_control, "ug-setting-wifidirect-efl");
114 ret = app_control_send_launch_request(app_control, NULL, NULL);
115 if (ret == APP_CONTROL_ERROR_NONE)
116 INFO_LOG(UG_NAME_NORMAL, "Launch Wi-Fi Direct successful");
118 ERROR_LOG(UG_NAME_NORMAL, "Fail to launch Wi-Fi Direct");
120 app_control_destroy(app_control);
124 static gboolean viewer_manager_is_passwd_popup_exists(void)
126 if (ug_app_state->passpopup != NULL)
132 void language_changed_refresh()
134 if (UG_VIEW_SETUP_WIZARD == ug_app_state->ug_type) {
135 elm_genlist_realized_items_update(manager_object->list);
136 viewer_manager_refresh();
140 void viewer_manager_update_item_favorite_status(wifi_manager_ap_h ap)
145 Elm_Object_Item *target_item = item_get_for_ap(ap);
146 if (target_item == NULL)
149 ug_genlist_data_t *gdata = NULL;
151 gdata = (ug_genlist_data_t *)elm_object_item_data_get(target_item);
152 if (gdata == NULL || gdata->device_info == NULL) {
153 INFO_LOG(COMMON_NAME_ERR, "gdata or device_info is NULL");
157 gdata->radio_mode = VIEWER_ITEM_RADIO_MODE_OFF;
158 if (gdata->device_info->ap_status_txt) {
159 g_free(gdata->device_info->ap_status_txt);
160 gdata->device_info->ap_status_txt =
161 common_utils_get_ap_security_type_info_txt(PACKAGE,
162 gdata->device_info, false);
165 if (target_item != NULL)
166 elm_genlist_item_update(target_item);
169 void power_control(void)
171 __COMMON_FUNC_ENTER__;
174 cur_state = viewer_manager_header_mode_get();
176 INFO_LOG(UG_NAME_NORMAL, "current state %d\n", cur_state);
181 case HEADER_MODE_OFF:
182 case HEADER_MODE_ACTIVATING:
183 ug_app_state->is_first_scan = true;
184 ret = wlan_manager_power_on();
186 case WLAN_MANAGER_ERR_NONE:
187 viewer_manager_show(VIEWER_WINSET_SEARCHING);
188 viewer_manager_header_mode_set(HEADER_MODE_ACTIVATING);
189 viewer_manager_create_scan_btn();
191 if (_is_emulator()) {
192 wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_ACTIVATE,
193 1000, wlan_manager_emulator_power_on, NULL);
197 #if defined TIZEN_TETHERING_ENABLE
198 case WLAN_MANAGER_ERR_WIFI_TETHERING_OCCUPIED:
199 winset_popup_mode_set(ug_app_state->popup_manager,
200 POPUP_OPTION_POWER_ON_FAILED_TETHERING_OCCUPIED, NULL);
203 case WLAN_MANAGER_ERR_WIFI_AP_TETHERING_OCCUPIED:
204 winset_popup_mode_set(ug_app_state->popup_manager,
205 POPUP_OPTION_POWER_ON_FAILED_TETHERING_AP_OCCUPIED, NULL);
210 viewer_manager_header_mode_set(HEADER_MODE_OFF);
211 INFO_LOG(UG_NAME_NORMAL, "power on failed. ret = %d", ret);
218 case HEADER_MODE_CONNECTING:
219 case HEADER_MODE_CONNECTED:
220 case HEADER_MODE_SEARCHING:
221 ret = wlan_manager_power_off();
223 case WLAN_MANAGER_ERR_NONE:
224 viewer_manager_show(VIEWER_WINSET_SEARCHING);
225 viewer_manager_header_mode_set(HEADER_MODE_DEACTIVATING);
227 // Lets ignore all the scan updates because we are powering off now.
228 wlan_manager_disable_scan_result_update();
229 if (_is_emulator()) {
230 wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_DEACTIVATE,
231 500, wlan_manager_emulator_power_off, NULL);
236 INFO_LOG(UG_NAME_NORMAL, "power off failed. ret = %d", ret);
242 case HEADER_MODE_DEACTIVATING:
244 INFO_LOG(UG_NAME_NORMAL, "Powering off in progress. Let it complete. \n");
248 __COMMON_FUNC_EXIT__;
251 static void _transition_finished_main_cb(void *data, Evas_Object *obj, void *event_info)
253 __COMMON_FUNC_ENTER__;
255 view_manager_view_type_t top_view_id;
257 top_view_id = (view_manager_view_type_t)evas_object_data_get(
258 obj, SCREEN_TYPE_ID_KEY);
260 if (data == elm_naviframe_top_item_get(obj)) {
261 /* We are now in main view */
262 if (viewer_manager_is_passwd_popup_exists() == TRUE) {
263 top_view_id = VIEW_MANAGER_VIEW_TYPE_PASSWD_POPUP;
265 top_view_id = VIEW_MANAGER_VIEW_TYPE_MAIN;
266 if (wifi_is_scan_required() == true)
267 viewer_manager_request_scan();
269 evas_object_data_set(obj, SCREEN_TYPE_ID_KEY,
270 (void *)VIEW_MANAGER_VIEW_TYPE_MAIN);
272 viewer_manager_rotate_top_setupwizard_layout();
275 INFO_LOG(UG_NAME_NORMAL, "top view id = %d", top_view_id);
277 switch (top_view_id) {
278 case VIEW_MANAGER_VIEW_TYPE_MAIN:
279 /* Lets enable the scan updates */
280 wlan_manager_enable_scan_result_update();
283 case VIEW_MANAGER_VIEW_TYPE_DETAIL:
284 case VIEW_MANAGER_VIEW_TYPE_EAP:
285 case VIEW_MANAGER_VIEW_TYPE_PASSWD_POPUP:
287 /* Lets disable the scan updates so that the UI is not refreshed */
288 wlan_manager_disable_scan_result_update();
289 if (top_view_id == VIEW_MANAGER_VIEW_TYPE_PASSWD_POPUP)
290 passwd_popup_show(ug_app_state->passpopup);
294 __COMMON_FUNC_EXIT__;
297 static void _lbutton_click_cb(void *data, Evas_Object *obj, void *event_info)
299 __COMMON_FUNC_ENTER__;
301 app_control_h app_control;
304 ret = app_control_create(&app_control);
305 if (ret != APP_CONTROL_ERROR_NONE) {
306 INFO_LOG(UG_NAME_ERR, "app_control_create failed: %d", ret);
310 app_control_add_extra_data(app_control, "result", "lbutton_click");
311 ug_send_result(ug_app_state->ug, app_control);
313 app_control_destroy(app_control);
314 ug_destroy_me(ug_app_state->ug);
316 __COMMON_FUNC_EXIT__;
319 static void _rbutton_click_cb(void *data, Evas_Object *obj, void *event_info)
321 __COMMON_FUNC_ENTER__;
323 app_control_h app_control;
326 ret = app_control_create(&app_control);
327 if (ret != APP_CONTROL_ERROR_NONE) {
328 INFO_LOG(UG_NAME_ERR, "app_control_create failed: %d", ret);
332 app_control_add_extra_data(app_control, "result", "rbutton_click");
333 ug_send_result(ug_app_state->ug, app_control);
335 app_control_destroy(app_control);
336 ug_destroy_me(ug_app_state->ug);
338 __COMMON_FUNC_EXIT__;
341 static void __back_cb(void *data, Evas_Object *obj, void *event_info)
343 __COMMON_FUNC_ENTER__;
345 if ((view_manager_view_type_t)evas_object_data_get(obj, SCREEN_TYPE_ID_KEY) !=
346 VIEW_MANAGER_VIEW_TYPE_MAIN) {
347 eext_naviframe_back_cb(data, obj, event_info);
348 __COMMON_FUNC_EXIT__;
352 if (viewer_manager_is_passwd_popup_exists() == TRUE ||
353 ug_app_state->bAlive == EINA_FALSE) {
354 __COMMON_FUNC_EXIT__;
360 __COMMON_FUNC_EXIT__;
363 static Eina_Bool _back_sk_cb(void *data, Elm_Object_Item *it)
365 __COMMON_FUNC_ENTER__;
367 if (ug_app_state->bAlive == EINA_FALSE) {
368 __COMMON_FUNC_EXIT__;
374 __COMMON_FUNC_EXIT__;
378 #ifdef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
379 static gboolean __activate_more_btn(gpointer pdata)
383 if (ug_app_state->timeout) {
384 g_source_remove(ug_app_state->timeout);
385 ug_app_state->timeout = 0;
392 static void _ctxpopup_item_select_cb(void *data, Evas_Object *obj,
395 const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
397 SECURE_INFO_LOG(UG_NAME_NORMAL, "text(%s) is clicked\n", label);
399 if (g_strcmp0(label, sc(PACKAGE, I18N_TYPE_Advanced)) == 0)
401 else if (g_strcmp0(label, sc(PACKAGE, I18N_TYPE_Find_Hidden_Network)) == 0)
402 _hidden_button_callback(data, obj, event_info);
404 #ifdef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
405 else if (g_strcmp0(label, sc(PACKAGE, I18N_TYPE_WiFi_direct)) == 0) {
407 ug_app_state->timeout = g_timeout_add(300, __activate_more_btn, NULL);
408 _launch_wifi_direct_app();
412 if (manager_object->ctxpopup) {
413 evas_object_del(manager_object->ctxpopup);
414 manager_object->ctxpopup = NULL;
418 static void _ctxpopup_del_cb(void *data,
419 Evas_Object *obj, void *event_info)
421 __COMMON_FUNC_ENTER__;
426 evas_object_del(manager_object->ctxpopup);
427 manager_object->ctxpopup = NULL;
429 __COMMON_FUNC_EXIT__;
432 static void _ctxpopup_move(Evas_Object *parent)
434 __COMMON_FUNC_ENTER__;
439 Evas_Coord y = 0, w = 0, h = 0;
442 elm_win_screen_size_get(parent, NULL, &y, &w, &h);
443 rotate_angle = elm_win_rotation_get(parent);
445 if (0 == rotate_angle || 180 == rotate_angle)
446 evas_object_move(manager_object->ctxpopup, w/2, h);
448 evas_object_move(manager_object->ctxpopup, h/2, w);
450 __COMMON_FUNC_EXIT__;
453 static void _ctxpopup_move_to_button(Evas_Object *ctxpopup, Evas_Object *btn)
455 Evas_Coord x, y, w, h;
456 evas_object_geometry_get(btn, &x, &y, &w, &h);
457 evas_object_move(ctxpopup, x + (w / 2), y + h);
460 static void _ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
463 __COMMON_FUNC_ENTER__;
468 Evas_Object *_win_main = data;
471 evas_object_del(manager_object->ctxpopup);
472 manager_object->ctxpopup = NULL;
474 _ctxpopup_move(_win_main);
475 evas_object_show(manager_object->ctxpopup);
476 rotate_flag = EINA_FALSE;
479 __COMMON_FUNC_EXIT__;
482 static void _ctxpopup_rotate_cb(void *data, Evas_Object *obj, void *event_info)
485 __COMMON_FUNC_ENTER__;
490 Evas_Object *_win_main = data;
492 _ctxpopup_move(_win_main);
493 evas_object_show(manager_object->ctxpopup);
495 __COMMON_FUNC_EXIT__;
498 static void _ctxpopup_resize_cb(void *data, Evas *e, Evas_Object *obj,
501 __COMMON_FUNC_ENTER__;
503 if (manager_object->ctxpopup)
504 rotate_flag = EINA_TRUE;
506 rotate_flag = EINA_FALSE;
508 __COMMON_FUNC_EXIT__;
511 static void _ctxpopup_delete_cb(void *data, Evas *e, Evas_Object *obj,
514 __COMMON_FUNC_ENTER__;
516 Evas_Object *navi = (Evas_Object *)data;
517 Evas_Object *ctx = obj;
525 evas_object_smart_callback_del(ctx, "dismissed",
526 _ctxpopup_dismissed_cb);
527 evas_object_event_callback_del(navi, EVAS_CALLBACK_RESIZE,
528 _ctxpopup_resize_cb);
529 evas_object_smart_callback_del(elm_object_top_widget_get(ctx),
530 "rotation,changed", _ctxpopup_rotate_cb);
531 evas_object_event_callback_del_full(ctx, EVAS_CALLBACK_DEL,
532 _ctxpopup_delete_cb, navi);
534 __COMMON_FUNC_EXIT__;
538 static void _more_button_cb(void *data, Evas_Object *obj, void *event_info)
540 Evas_Object *_win_main = (Evas_Object*)data;
541 HEADER_MODES current_state;
542 struct ug_data *ugd = NULL;
543 Evas_Object *parent = NULL;
544 Elm_Object_Item *item = NULL;
547 ugd = (struct ug_data *)ug_app_state->gadget;
548 retm_if(ugd == NULL || show_more == FALSE);
550 parent = ugd->win_main;
551 if (!parent || !manager_object)
554 current_state = viewer_manager_header_mode_get();
556 if (manager_object->ctxpopup)
557 evas_object_del(manager_object->ctxpopup);
559 ps_mode = common_util_get_system_registry(VCONFKEY_SETAPPL_PSMODE);
560 INFO_LOG(UG_NAME_NORMAL, "PS mode - [%d]", ps_mode);
562 manager_object->ctxpopup = elm_ctxpopup_add(parent);
563 elm_ctxpopup_auto_hide_disabled_set(manager_object->ctxpopup, EINA_TRUE);
564 elm_object_style_set(manager_object->ctxpopup, "more/default");
565 eext_object_event_callback_add(manager_object->ctxpopup, EEXT_CALLBACK_BACK,
566 _ctxpopup_del_cb, NULL);
567 eext_object_event_callback_add(manager_object->ctxpopup, EEXT_CALLBACK_MORE,
568 _ctxpopup_del_cb, NULL);
569 evas_object_smart_callback_add(manager_object->ctxpopup, "dismissed",
570 _ctxpopup_dismissed_cb, _win_main);
571 evas_object_event_callback_add(manager_object->ctxpopup, EVAS_CALLBACK_DEL,
572 _ctxpopup_delete_cb, parent);
573 evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE,
574 _ctxpopup_resize_cb, _win_main);
575 evas_object_smart_callback_add(elm_object_top_widget_get(manager_object->ctxpopup),
576 "rotation,changed", _ctxpopup_rotate_cb, _win_main);
578 if (current_state != HEADER_MODE_OFF &&
579 current_state != HEADER_MODE_DEACTIVATING) {
580 item = elm_ctxpopup_item_append(manager_object->ctxpopup,
581 "IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK", NULL,
582 _ctxpopup_item_select_cb, parent);
583 elm_object_item_domain_text_translatable_set(item, PACKAGE, EINA_TRUE);
586 item = elm_ctxpopup_item_append(manager_object->ctxpopup,
587 "IDS_ST_BODY_ADVANCED", NULL,
588 _ctxpopup_item_select_cb, parent);
589 elm_object_item_domain_text_translatable_set(item, PACKAGE, EINA_TRUE);
591 #ifdef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
592 if (ps_mode <= SETTING_PSMODE_POWERFUL &&
593 current_state != HEADER_MODE_OFF &&
594 current_state != HEADER_MODE_DEACTIVATING) {
595 item = elm_ctxpopup_item_append(manager_object->ctxpopup,
596 "IDS_WIFI_BODY_WI_FI_DIRECT_ABB", NULL,
597 _ctxpopup_item_select_cb, parent);
598 elm_object_item_domain_text_translatable_set(item, PACKAGE, EINA_TRUE);
602 elm_ctxpopup_direction_priority_set(manager_object->ctxpopup,
603 ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UNKNOWN,
604 ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN);
606 if (wifi_get_ug_type() == UG_VIEW_IOT_COMMON)
607 _ctxpopup_move_to_button(manager_object->ctxpopup, obj);
609 _ctxpopup_move(_win_main);
611 evas_object_show(manager_object->ctxpopup);
614 static void __refresh_scan_callback(void *data,
615 Evas_Object *obj, void *event_info)
617 __COMMON_FUNC_ENTER__;
620 HEADER_MODES current_state;
621 current_state = viewer_manager_header_mode_get();
623 switch (current_state) {
625 case HEADER_MODE_CONNECTED:
626 viewer_manager_show(VIEWER_WINSET_SEARCHING);
627 viewer_manager_header_mode_set(HEADER_MODE_SEARCHING);
629 scan_result = wlan_manager_scan();
630 if (scan_result != WLAN_MANAGER_ERR_NONE) {
631 viewer_manager_hide(VIEWER_WINSET_SEARCHING);
632 viewer_manager_header_mode_set(current_state);
640 __COMMON_FUNC_EXIT__;
643 static void __power_onoff_cb(void *data, Evas_Object *obj, void *event_info)
645 __COMMON_FUNC_ENTER__;
647 Elm_Object_Item *item = NULL;
648 const char *object_type;
649 HEADER_MODES current_mode;
651 item = (Elm_Object_Item *)event_info;
652 object_type = evas_object_type_get(obj);
654 current_mode = viewer_manager_header_mode_get();
655 ug_app_state->is_wifi_scan_indication_block = 0;
657 if (current_mode == HEADER_MODE_ACTIVATING ||
658 current_mode == HEADER_MODE_DEACTIVATING) {
659 if (g_strcmp0(object_type, "elm_genlist") == 0)
660 elm_genlist_item_selected_set(item, EINA_FALSE);
662 __COMMON_FUNC_EXIT__;
666 if (g_strcmp0(object_type, "elm_check") == 0) {
667 Eina_Bool check_mode = elm_check_state_get(obj);
669 if (check_mode == TRUE && current_mode == HEADER_MODE_OFF) {
670 elm_check_state_set(obj, EINA_FALSE);
672 } else if (check_mode != TRUE && current_mode != HEADER_MODE_OFF) {
675 } else if (g_strcmp0(object_type, "elm_genlist") == 0) {
680 elm_genlist_item_update(item);
681 elm_genlist_item_selected_set(item, EINA_FALSE);
684 __COMMON_FUNC_EXIT__;
687 static char *_gl_wifi_onoff_text_get(void *data, Evas_Object *obj, const char *part)
690 int ug_type = GPOINTER_TO_INT(data);
692 retvm_if(NULL == manager_object, NULL);
694 if (!strcmp(g_genlist_info[WIFI_GENLIST_1LINE_STYLE].text_part, part)) {
695 if (ug_type == UG_VIEW_OOBE) {
696 det = g_strdup_printf("<font_size=%d>%s</font_size>",
697 g_content_size_info.mid_font,
698 manager_object->header_mode == HEADER_MODE_SEARCHING ?
699 sc(PACKAGE, I18N_TYPE_Scanning) :
700 manager_object->item_wifi_onoff_text);
702 det = g_strdup(manager_object->item_wifi_onoff_text);
709 static char *_gl_helper_text_get(void *data, Evas_Object *obj, const char *part)
713 retvm_if(NULL == manager_object, NULL);
715 if (!strcmp(g_genlist_info[WIFI_GENLIST_MULTILINE_STYLE].sub_text_part, part)) {
716 det = g_strdup(manager_object->item_onoff_description_text);
717 assertm_if(NULL == det, "NULL!!");
723 static Evas_Object* _gl_helper_content_get(void *data, Evas_Object *obj, const char *part)
725 retvm_if(NULL == manager_object, NULL);
727 Evas_Object *box, *top_padding, *label;
728 char* det = g_strdup_printf("<align=center><font_size=%d>%s</font_size></align>",
729 g_content_size_info.big_font,
730 manager_object->item_onoff_description_text);
732 assertm_if(NULL == det, "NULL!!");
734 box = elm_box_add(obj);
735 elm_box_horizontal_set(box, EINA_FALSE);
737 top_padding = evas_object_rectangle_add(evas_object_evas_get(obj));
738 evas_object_size_hint_min_set(top_padding, ELM_SCALE_SIZE(40), ELM_SCALE_SIZE(50));
739 evas_object_size_hint_max_set(top_padding, ELM_SCALE_SIZE(40), ELM_SCALE_SIZE(50));
740 evas_object_color_set(top_padding, 0, 0, 0, 0);
741 evas_object_show(top_padding);
742 elm_box_pack_end(box, top_padding);
744 label = elm_label_add(box);
745 elm_object_text_set(label, det);
746 evas_object_show(label);
747 elm_box_pack_end(box, label);
752 static Evas_Object *_gl_wifi_onoff_content_get(void *data,
753 Evas_Object *obj, const char *part)
755 if (manager_object == NULL)
758 Evas_Object *c = NULL;
759 int ug_type = GPOINTER_TO_INT(data);
761 const char *content_part = (ug_type == UG_VIEW_IOT_COMMON)
762 ? g_genlist_info[WIFI_GENLIST_1LINE_STYLE].content_part
763 : g_genlist_info[WIFI_GENLIST_1LINE_STYLE].sub_content_part;
765 // On&Off toggle button
766 if (!strcmp(content_part, part)) {
767 if (ug_type == UG_VIEW_OOBE)
772 c = elm_check_add(obj);
773 elm_object_style_set(c, style);
774 evas_object_propagate_events_set(c, EINA_FALSE);
775 evas_object_smart_callback_add(c, "changed", __power_onoff_cb, NULL);
777 if (manager_object->header_mode == HEADER_MODE_OFF
778 || manager_object->header_mode == HEADER_MODE_DEACTIVATING)
779 elm_check_state_set(c, EINA_FALSE);
781 elm_check_state_set(c, EINA_TRUE);
783 evas_object_size_hint_align_set(c, EVAS_HINT_FILL, EVAS_HINT_FILL);
784 evas_object_size_hint_weight_set(c, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
787 // OOBE: Progress icon
788 if (ug_type == UG_VIEW_OOBE
789 && !strcmp(g_genlist_info[WIFI_GENLIST_1LINE_STYLE].content_part, part)) {
790 if (manager_object->header_mode == HEADER_MODE_SEARCHING) {
791 c = elm_progressbar_add(obj);
792 elm_object_style_set(c, "process_small");
793 evas_object_size_hint_align_set(c, EVAS_HINT_FILL, 0.5);
794 evas_object_size_hint_weight_set(c,
795 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
796 elm_progressbar_pulse(c, TRUE);
802 if (ug_type == UG_VIEW_OOBE && !strcmp("elm.swallow.icon.2", part)) {
803 c = elm_button_add(obj);
804 elm_object_style_set(c, "scan");
805 evas_object_size_hint_align_set(c, EVAS_HINT_FILL, EVAS_HINT_FILL);
806 evas_object_size_hint_weight_set(c, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
807 elm_object_domain_translatable_text_set(c, PACKAGE, "IDS_WIFI_BUTTON_SCAN");
808 evas_object_smart_callback_add(c, "clicked", __refresh_scan_callback, NULL);
810 if (manager_object->header_mode == HEADER_MODE_SEARCHING)
811 elm_object_disabled_set(c, EINA_TRUE);
813 elm_object_disabled_set(c, EINA_FALSE);
819 static void __viewer_manager_wifi_onoff_item_create(Evas_Object* genlist, int ug_type)
821 __COMMON_FUNC_ENTER__;
823 manager_object->item_wifi_onoff_text = g_strdup(sc(PACKAGE, I18N_TYPE_Wi_Fi));
825 wifi_onoff_itc.item_style = g_genlist_info[WIFI_GENLIST_1LINE_STYLE].style_name;
826 wifi_onoff_itc.func.text_get = _gl_wifi_onoff_text_get;
827 wifi_onoff_itc.func.content_get = _gl_wifi_onoff_content_get;
828 wifi_onoff_itc.func.state_get = NULL;
829 wifi_onoff_itc.func.del = NULL;
831 manager_object->item_wifi_onoff = elm_genlist_item_append(genlist,
832 &wifi_onoff_itc, GINT_TO_POINTER(ug_type), NULL, ELM_GENLIST_ITEM_NONE,
835 elm_genlist_item_select_mode_set(manager_object->item_wifi_onoff, ELM_OBJECT_SELECT_MODE_NONE);
836 __COMMON_FUNC_EXIT__;
839 static void __viewer_manager_onoff_description_item_create(void)
841 __COMMON_FUNC_ENTER__;
843 manager_object->item_onoff_description_text = g_strdup(sc(PACKAGE,
844 I18N_TYPE_Turn_on_wifi_to_view_available_networks));
846 if (wifi_get_ug_type() != UG_VIEW_IOT_COMMON) {
847 onoff_description_itc.item_style = g_genlist_info[WIFI_GENLIST_MULTILINE_STYLE].style_name;
848 onoff_description_itc.func.text_get = _gl_helper_text_get;
849 onoff_description_itc.func.content_get = NULL;
851 onoff_description_itc.item_style = g_genlist_info[WIFI_GENLIST_FULL_STYLE].style_name;
852 onoff_description_itc.func.text_get = NULL;
853 onoff_description_itc.func.content_get = _gl_helper_content_get;
856 onoff_description_itc.func.state_get = NULL;
857 onoff_description_itc.func.del = NULL;
859 __COMMON_FUNC_EXIT__;
862 static void viewer_manager_onoff_description_item_set(bool state)
864 __COMMON_FUNC_ENTER__;
866 if (manager_object == NULL) {
867 __COMMON_FUNC_EXIT__;
871 if (state && manager_object->item_onoff_description == NULL) {
872 manager_object->item_onoff_description = elm_genlist_item_append(manager_object->list,
873 &onoff_description_itc, NULL, NULL, ELM_GENLIST_ITEM_NONE,
875 } else if (!state && manager_object->item_onoff_description != NULL) {
876 elm_object_item_del(manager_object->item_onoff_description);
877 manager_object->item_onoff_description = NULL;
880 __COMMON_FUNC_EXIT__;
883 static void _hidden_button_callback(void* data, Evas_Object* obj, void* event_info)
885 __COMMON_FUNC_ENTER__;
887 view_hidden_ap_popup_create(ug_app_state->layout_main, PACKAGE);
889 __COMMON_FUNC_EXIT__;
892 static void __viewer_manager_hidden_button_create(Evas_Object *genlist)
894 __COMMON_FUNC_ENTER__;
896 if (manager_object->sw_hidden_btn != NULL ||
897 ug_app_state->ug_type != UG_VIEW_SETUP_WIZARD) {
898 __COMMON_FUNC_EXIT__;
902 Evas_Object *btn = NULL;
903 Evas_Object *layout = NULL;
904 Elm_Object_Item *navi_it = NULL;
906 navi_it = elm_naviframe_top_item_get(manager_object->nav);
907 layout = elm_object_item_content_get(navi_it);
909 btn = elm_button_add(layout);
910 elm_object_style_set(btn, "default");
911 evas_object_propagate_events_set(btn, EINA_FALSE);
913 evas_object_smart_callback_add(btn, "clicked", _hidden_button_callback,
915 elm_object_domain_translatable_text_set(btn, PACKAGE,
916 "IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK");
917 elm_object_part_content_set(layout, "button1", btn);
919 switch (viewer_manager_header_mode_get()) {
920 case HEADER_MODE_ACTIVATING:
921 case HEADER_MODE_DEACTIVATING:
922 case HEADER_MODE_SEARCHING:
923 elm_object_disabled_set(btn, EINA_TRUE);
926 elm_object_disabled_set(btn, EINA_FALSE);
930 evas_object_show(btn);
931 manager_object->sw_hidden_btn = btn;
933 __COMMON_FUNC_EXIT__;
937 static void __viewer_manager_setup_wizard_scan_btn_create(Evas_Object *genlist)
939 __COMMON_FUNC_ENTER__;
941 if (manager_object->sw_scan_btn != NULL ||
942 ug_app_state->ug_type != UG_VIEW_SETUP_WIZARD) {
943 __COMMON_FUNC_EXIT__;
947 Evas_Object *btn = NULL;
948 Evas_Object *layout = NULL;
949 Elm_Object_Item *navi_it = NULL;
951 navi_it = elm_naviframe_top_item_get(manager_object->nav);
952 layout = elm_object_item_content_get(navi_it);
954 btn = elm_button_add(layout);
955 elm_object_style_set(btn, "default");
956 evas_object_propagate_events_set(btn, EINA_FALSE);
958 evas_object_smart_callback_add(btn, "clicked", __refresh_scan_callback,
960 elm_object_domain_translatable_text_set(btn, PACKAGE,
961 "IDS_WIFI_BUTTON_SCAN");
962 elm_object_part_content_set(layout, "button2", btn);
964 switch (viewer_manager_header_mode_get()) {
965 case HEADER_MODE_ACTIVATING:
966 case HEADER_MODE_DEACTIVATING:
967 case HEADER_MODE_SEARCHING:
968 elm_object_disabled_set(btn, EINA_TRUE);
971 elm_object_disabled_set(btn, EINA_FALSE);
975 evas_object_show(btn);
976 manager_object->sw_scan_btn = btn;
978 __COMMON_FUNC_EXIT__;
981 static void viewer_manager_setup_wizard_scan_btn_set(Eina_Bool show_state)
983 __COMMON_FUNC_ENTER__;
985 if (ug_app_state->ug_type != UG_VIEW_SETUP_WIZARD ||
986 manager_object == NULL ||
987 manager_object->sw_scan_btn == NULL) {
988 __COMMON_FUNC_EXIT__;
992 elm_object_disabled_set(manager_object->sw_scan_btn, !show_state);
994 __COMMON_FUNC_EXIT__;
997 static Eina_Bool viewer_manager_scan_button_set(Eina_Bool show_state)
999 __COMMON_FUNC_ENTER__;
1001 if (manager_object == NULL) {
1002 __COMMON_FUNC_EXIT__;
1006 if (manager_object->scan_button == NULL)
1007 viewer_manager_create_scan_btn();
1009 /* TODO: need to check VIEW_MANAGER_VIEW_TYPE_MAIN ?
1010 * Evas_Object* navi_frame = viewer_manager_get_naviframe();
1011 * view_manager_view_type_t top_view_id =
1012 * (view_manager_view_type_t)evas_object_data_get(
1013 * navi_frame, SCREEN_TYPE_ID_KEY);
1016 if (show_state == EINA_TRUE && manager_object->scan_button != NULL)
1017 elm_object_disabled_set(manager_object->scan_button, EINA_FALSE);
1018 else if (show_state == EINA_FALSE && manager_object->scan_button != NULL)
1019 elm_object_disabled_set(manager_object->scan_button, EINA_TRUE);
1021 viewer_manager_setup_wizard_scan_btn_set(show_state);
1023 __COMMON_FUNC_EXIT__;
1027 static void __ea_setup_wizard_back_cb(void *data, Evas_Object *obj,
1030 if ((view_manager_view_type_t)evas_object_data_get(obj, SCREEN_TYPE_ID_KEY) !=
1031 VIEW_MANAGER_VIEW_TYPE_MAIN) {
1032 eext_naviframe_back_cb(data, obj, event_info);
1036 if (viewer_manager_is_passwd_popup_exists() == TRUE ||
1037 ug_app_state->bAlive == EINA_FALSE) {
1041 _lbutton_click_cb(data, obj, event_info);
1044 static void __viewer_manager_create_setup_wizard_content(Evas_Object *layout)
1046 __COMMON_FUNC_ENTER__;
1048 Elm_Object_Item *navi_it = NULL;
1050 elm_layout_file_set(layout, SETUP_WIZARD_EDJ_PATH, "main_pwlock");
1051 elm_object_domain_translatable_part_text_set(layout, "text.title",
1052 PACKAGE, sc(PACKAGE, I18N_TYPE_Wi_Fi));
1054 eext_object_event_callback_add(manager_object->nav, EEXT_CALLBACK_BACK,
1055 __ea_setup_wizard_back_cb, NULL);
1057 __viewer_manager_wifi_onoff_item_create(manager_object->list, UG_VIEW_SETUP_WIZARD);
1058 __viewer_manager_onoff_description_item_create();
1060 elm_object_part_content_set(layout, "elm.swallow.content",
1061 manager_object->list);
1063 navi_it = elm_naviframe_item_push(manager_object->nav, NULL, NULL, NULL, layout, NULL);
1064 elm_naviframe_item_title_enabled_set(navi_it, EINA_FALSE, EINA_FALSE);
1066 evas_object_data_set(manager_object->nav, SCREEN_TYPE_ID_KEY,
1067 (void *)VIEW_MANAGER_VIEW_TYPE_MAIN);
1068 evas_object_smart_callback_add(manager_object->nav,
1069 "transition,finished", _transition_finished_main_cb, navi_it);
1071 Evas_Object *prev_btn = elm_button_add(layout);
1072 elm_object_style_set(prev_btn, "bottom");
1073 elm_object_part_content_set(layout, "button.prev", prev_btn);
1074 elm_object_text_set(prev_btn, sc(PACKAGE, I18N_TYPE_Prev));
1075 evas_object_smart_callback_add(prev_btn, "clicked", _lbutton_click_cb, manager_object);
1076 manager_object->prev_button = prev_btn;
1078 Evas_Object *next_btn = elm_button_add(layout);
1079 elm_object_style_set(next_btn, "bottom");
1080 elm_object_part_content_set(layout, "button.next", next_btn);
1081 elm_object_text_set(next_btn, sc(PACKAGE, I18N_TYPE_Next));
1082 evas_object_smart_callback_add(next_btn, "clicked", _rbutton_click_cb, manager_object);
1083 manager_object->next_button = next_btn;
1085 __COMMON_FUNC_EXIT__;
1088 static void __viewer_manager_create_wifi_ug_content(Evas_Object *layout,
1089 Evas_Object *_win_main)
1091 __COMMON_FUNC_ENTER__;
1093 Elm_Object_Item *navi_it = NULL;
1094 Evas_Object *back_btn = NULL;
1095 Evas_Object *more_btn = NULL;
1096 int ug_type = wifi_get_ug_type();
1098 if (ug_type == UG_VIEW_IOT_COMMON) {
1099 elm_layout_file_set(layout, MAIN_LAYOUT_EDJ_PATH, "main_layout");
1101 elm_layout_theme_set(layout, "layout", "application", "default");
1102 edje_object_signal_emit(elm_layout_edje_get(layout), "elm,state,show,content", "elm");
1103 edje_object_signal_emit(elm_layout_edje_get(layout), "elm,bg,show,group_list", "elm");
1106 __viewer_manager_wifi_onoff_item_create(manager_object->list, ug_type);
1107 __viewer_manager_onoff_description_item_create();
1109 elm_object_part_content_set(layout, "elm.swallow.content", manager_object->list);
1111 eext_object_event_callback_add(manager_object->nav, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1113 back_btn = elm_button_add(manager_object->nav);
1114 elm_object_style_set(back_btn, "naviframe/back_btn/default");
1115 evas_object_smart_callback_add(back_btn, "clicked", __back_cb, _win_main);
1116 elm_object_focus_allow_set(back_btn, EINA_FALSE);
1118 manager_object->navi_it = navi_it = elm_naviframe_item_push(manager_object->nav,
1119 sc(PACKAGE, I18N_TYPE_Wi_Fi), back_btn, NULL,
1121 evas_object_data_set(manager_object->nav, SCREEN_TYPE_ID_KEY,
1122 (void *)VIEW_MANAGER_VIEW_TYPE_MAIN);
1123 evas_object_smart_callback_add(manager_object->nav,
1124 "transition,finished", _transition_finished_main_cb, navi_it);
1126 more_btn = elm_button_add(manager_object->nav);
1127 evas_object_smart_callback_add(more_btn, "clicked",
1128 _more_button_cb, _win_main);
1130 if (ug_app_state->ug_type == UG_VIEW_IOT_COMMON) {
1131 elm_object_style_set(more_btn, "naviframe/more");
1132 elm_object_item_part_content_set(navi_it, "title_content", more_btn);
1134 elm_object_style_set(more_btn, "naviframe/more/default");
1135 elm_object_item_part_content_set(navi_it, "toolbar_more_btn", more_btn);
1138 elm_naviframe_item_pop_cb_set(navi_it, _back_sk_cb, NULL);
1140 __COMMON_FUNC_EXIT__;
1143 static void __viewer_manager_create_oobe_content(Evas_Object *layout,
1144 Evas_Object *_win_main)
1146 __COMMON_FUNC_ENTER__;
1148 Elm_Object_Item *navi_it = NULL;
1150 elm_layout_theme_set(layout, "layout", "application", "default");
1151 edje_object_signal_emit(elm_layout_edje_get(layout), "elm,state,show,content", "elm");
1152 edje_object_signal_emit(elm_layout_edje_get(layout), "elm,bg,show,group_list", "elm");
1154 __viewer_manager_wifi_onoff_item_create(manager_object->list, UG_VIEW_OOBE);
1155 __viewer_manager_onoff_description_item_create();
1157 elm_object_part_content_set(layout, "elm.swallow.content", manager_object->list);
1159 eext_object_event_callback_add(manager_object->nav, EEXT_CALLBACK_BACK,
1160 eext_naviframe_back_cb, NULL);
1162 manager_object->navi_it = navi_it = elm_naviframe_item_push(manager_object->nav,
1163 NULL, NULL, NULL, layout, NULL);
1165 elm_naviframe_item_title_enabled_set(manager_object->navi_it, EINA_FALSE, EINA_FALSE);
1166 evas_object_data_set(manager_object->nav, SCREEN_TYPE_ID_KEY,
1167 (void *)VIEW_MANAGER_VIEW_TYPE_MAIN);
1168 evas_object_smart_callback_add(manager_object->nav,
1169 "transition,finished", _transition_finished_main_cb, navi_it);
1170 elm_naviframe_item_pop_cb_set(navi_it, _back_sk_cb, NULL);
1172 __COMMON_FUNC_EXIT__;
1175 #if 0 /* not used */
1176 Evas_Object *viewer_manager_create_bg(Evas_Object *parent, char *style)
1180 bg = elm_bg_add(parent);
1181 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
1185 elm_object_style_set(bg, style);
1187 elm_win_resize_object_add(parent, bg);
1188 evas_object_show(bg);
1194 Evas_Object *viewer_manager_create(Evas_Object *_parent, Evas_Object *_win_main)
1196 __COMMON_FUNC_ENTER__;
1198 retvm_if(NULL == _parent, NULL);
1199 if (manager_object != NULL) {
1200 free(manager_object);
1201 manager_object = NULL;
1204 Evas_Object *layout = NULL;
1205 Evas_Object *view_content = NULL;
1207 manager_object = g_new0(viewer_manager_object, 1);
1208 retvm_if(NULL == manager_object, NULL);
1210 /* Add Full Layout */
1211 layout = elm_layout_add(_parent);
1212 retvm_if(NULL == layout, NULL);
1214 elm_layout_theme_set(layout, "layout", "application", "default");
1215 evas_object_size_hint_weight_set(layout,
1216 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1217 edje_object_signal_emit(elm_layout_edje_get(layout),
1218 "elm,state,show,content", "elm");
1219 edje_object_signal_emit(elm_layout_edje_get(layout),
1220 "elm,bg,show,group_list", "elm");
1221 edje_object_signal_emit(elm_layout_edje_get(layout),
1222 "elm,state,show,indicator", "elm");
1225 manager_object->nav = elm_naviframe_add(layout);
1226 assertm_if(NULL == manager_object->nav, "manager_object->nav is NULL");
1227 elm_object_part_content_set(layout,
1228 "elm.swallow.content", manager_object->nav);
1229 elm_naviframe_prev_btn_auto_pushed_set(manager_object->nav, EINA_FALSE);
1230 eext_object_event_callback_add(manager_object->nav, EEXT_CALLBACK_MORE,
1231 eext_naviframe_more_cb, NULL);
1233 /* Add layout for custom styles */
1234 elm_theme_extension_add(NULL, CUSTOM_EDITFIELD_PATH);
1236 if (ug_app_state->ug_type == UG_VIEW_OOBE)
1237 elm_theme_extension_add(NULL, OOBE_BUTTONS_EDJ_PATH);
1239 /* Add MainView Layout */
1240 view_content = elm_layout_add(manager_object->nav);
1243 manager_object->list = viewer_list_create(view_content);
1244 assertm_if(NULL == manager_object->list, "manager_object->list is NULL");
1246 /* Add app setup-wizard/wifi-ug specific contents */
1247 if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD)
1248 __viewer_manager_create_setup_wizard_content(view_content);
1249 else if (ug_app_state->ug_type == UG_VIEW_OOBE)
1250 __viewer_manager_create_oobe_content(view_content, _win_main);
1252 __viewer_manager_create_wifi_ug_content(view_content, _win_main);
1254 if(_is_emulator()) {
1255 int state = wlan_manager_state_get();
1256 if(state == WLAN_MANAGER_UNCONNECTED) {
1257 viewer_manager_header_mode_set(HEADER_MODE_ON);
1258 wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_ACTIVATE,
1259 1000, wlan_manager_emulator_power_on, NULL);
1261 viewer_manager_header_mode_set(HEADER_MODE_OFF);
1262 wifi_emulator_create_event_timer(WIFI_EMUL_EVENT_TIMER_DEACTIVATE,
1263 500, wlan_manager_emulator_power_off, NULL);
1267 evas_object_show(layout);
1268 elm_object_focus_set(layout, EINA_TRUE);
1270 __COMMON_FUNC_EXIT__;
1274 void viewer_manager_destroy(void)
1276 __COMMON_FUNC_ENTER__;
1278 if (wifi_device_list != NULL) {
1279 g_list_free(wifi_device_list);
1280 wifi_device_list = NULL;
1283 if (manager_object != NULL) {
1284 viewer_manager_cleanup_views();
1286 if (manager_object->item_wifi_onoff_text) {
1287 g_free(manager_object->item_wifi_onoff_text);
1288 manager_object->item_wifi_onoff_text = NULL;
1291 if (manager_object->item_onoff_description) {
1292 g_free(manager_object->item_onoff_description_text);
1293 manager_object->item_onoff_description = NULL;
1296 g_free(manager_object);
1297 manager_object = NULL;
1300 __COMMON_FUNC_EXIT__;
1303 Eina_Bool viewer_manager_show(VIEWER_WINSETS winset)
1305 __COMMON_FUNC_ENTER__;
1307 assertm_if(NULL == manager_object, "Manager object is NULL");
1310 case VIEWER_WINSET_SEARCHING:
1311 viewer_manager_scan_button_set(EINA_FALSE);
1312 viewer_list_item_disable_all();
1315 case VIEWER_WINSET_SUB_CONTENTS:
1316 assertm_if(NULL == manager_object->list, "List is NULL");
1318 viewer_list_title_item_set(manager_object->item_wifi_onoff);
1319 if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD) {
1320 __viewer_manager_hidden_button_create(manager_object->list);
1321 __viewer_manager_setup_wizard_scan_btn_create(
1322 manager_object->list);
1326 case VIEWER_WINSET_SEARCHING_GRP_TITLE:
1327 viewer_manager_scan_button_set(EINA_FALSE);
1334 __COMMON_FUNC_EXIT__;
1338 static void __viewer_manager_hidden_btn_del(void)
1340 __COMMON_FUNC_ENTER__;
1342 if (manager_object->sw_hidden_btn) {
1343 evas_object_del(manager_object->sw_hidden_btn);
1344 manager_object->sw_hidden_btn = NULL;
1347 __COMMON_FUNC_EXIT__;
1350 static void __viewer_manager_setup_wizard_scan_btn_del(void)
1352 if (ug_app_state->ug_type != UG_VIEW_SETUP_WIZARD)
1355 __COMMON_FUNC_ENTER__;
1357 if (manager_object->sw_scan_btn) {
1358 evas_object_del(manager_object->sw_scan_btn);
1359 manager_object->sw_scan_btn = NULL;
1362 __COMMON_FUNC_EXIT__;
1365 Eina_Bool viewer_manager_hide(VIEWER_WINSETS winset)
1367 __COMMON_FUNC_ENTER__;
1370 case VIEWER_WINSET_SEARCHING:
1371 /* searching view */
1372 viewer_manager_scan_button_set(EINA_TRUE);
1373 viewer_list_item_enable_all();
1376 case VIEWER_WINSET_SUB_CONTENTS:
1377 /* hidden AP and WPS PBC */
1378 if (ug_app_state->passpopup) {
1379 passwd_popup_free(ug_app_state->passpopup);
1380 ug_app_state->passpopup = NULL;
1383 if (ug_app_state->eap_view) {
1384 eap_connect_data_free(ug_app_state->eap_view);
1385 ug_app_state->eap_view = NULL;
1388 if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD) {
1389 __viewer_manager_hidden_btn_del();
1390 __viewer_manager_setup_wizard_scan_btn_del();
1392 viewer_list_title_item_del();
1399 __COMMON_FUNC_EXIT__;
1404 /* Unused function */
1405 Eina_Bool viewer_manager_genlist_item_update(Elm_Object_Item* item)
1407 __COMMON_FUNC_ENTER__;
1409 __COMMON_FUNC_EXIT__;
1414 elm_genlist_item_update(item);
1416 __COMMON_FUNC_EXIT__;
1421 void viewer_manager_update_hidden_btn(void)
1423 if (ug_app_state->ug_type != UG_VIEW_SETUP_WIZARD)
1426 __COMMON_FUNC_ENTER__;
1427 retm_if(NULL == manager_object->sw_hidden_btn);
1429 switch (viewer_manager_header_mode_get()) {
1430 case HEADER_MODE_ACTIVATING:
1431 case HEADER_MODE_DEACTIVATING:
1432 case HEADER_MODE_SEARCHING:
1433 elm_object_disabled_set(manager_object->sw_hidden_btn,
1437 elm_object_disabled_set(manager_object->sw_hidden_btn,
1442 __COMMON_FUNC_EXIT__;
1445 void viewer_manager_update_setup_wizard_scan_btn(void)
1447 if (ug_app_state->ug_type != UG_VIEW_SETUP_WIZARD)
1450 __COMMON_FUNC_ENTER__;
1451 retm_if(NULL == manager_object->sw_scan_btn);
1453 switch (viewer_manager_header_mode_get()) {
1454 case HEADER_MODE_ACTIVATING:
1455 case HEADER_MODE_DEACTIVATING:
1456 case HEADER_MODE_SEARCHING:
1457 elm_object_disabled_set(manager_object->sw_scan_btn,
1461 elm_object_disabled_set(manager_object->sw_scan_btn,
1466 __COMMON_FUNC_EXIT__;
1469 void viewer_manager_setup_wizard_button_controller()
1471 __COMMON_FUNC_ENTER__;
1474 wifi_manager_connection_state_e connection_state;
1476 ret = wlan_manager_get_connection_state(&connection_state);
1477 if (ret != WIFI_MANAGER_ERROR_NONE)
1478 INFO_LOG(UG_NAME_NORMAL, "Failed to retrieve connection state ret [%d]", ret);
1480 if (manager_object->prev_button != NULL &&
1481 ug_app_state->lbutton_setup_wizard_prev != NULL) {
1482 elm_object_text_set(manager_object->prev_button,
1483 sc(PACKAGE, I18N_TYPE_Prev));
1486 if (connection_state == WIFI_MANAGER_CONNECTION_STATE_CONNECTED) {
1487 if (manager_object->next_button != NULL &&
1488 ug_app_state->rbutton_setup_wizard_next != NULL) {
1489 elm_object_text_set(manager_object->next_button,
1490 sc(PACKAGE, I18N_TYPE_Next));
1493 if (manager_object->next_button != NULL &&
1494 ug_app_state->rbutton_setup_wizard_skip != NULL) {
1495 elm_object_text_set(manager_object->next_button,
1496 sc(PACKAGE, I18N_TYPE_Skip));
1500 if (manager_object->sw_hidden_btn != NULL) {
1501 elm_object_domain_translatable_text_set(
1502 manager_object->sw_hidden_btn, PACKAGE,
1503 "IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK");
1506 if (manager_object->sw_scan_btn != NULL) {
1507 elm_object_domain_translatable_text_set(
1508 manager_object->sw_scan_btn, PACKAGE,
1509 "IDS_WIFI_BUTTON_SCAN");
1513 static void viewer_manager_pop_naviframe_item(void)
1515 __COMMON_FUNC_ENTER__;
1517 view_manager_view_type_t top_viewID;
1519 top_viewID = viewer_manager_view_type_get();
1520 if (top_viewID == VIEW_MANAGER_VIEW_TYPE_DETAIL)
1521 elm_naviframe_item_pop(viewer_manager_get_naviframe());
1523 __COMMON_FUNC_EXIT__;
1526 Evas_Object *viewer_manager_naviframe_power_item_get(void)
1528 __COMMON_FUNC_ENTER__;
1530 Elm_Object_Item *navi_it = NULL;
1531 Evas_Object *layout = NULL;
1533 if (manager_object == NULL)
1536 navi_it = elm_naviframe_top_item_get(manager_object->nav);
1538 if (navi_it == NULL) {
1539 ERROR_LOG(UG_NAME_ERR, "navi_it is NULL");
1543 if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD) {
1544 layout = elm_object_item_content_get(navi_it);
1546 __COMMON_FUNC_EXIT__;
1547 return elm_object_part_content_get(layout, "title_right_btn");
1551 __COMMON_FUNC_EXIT__;
1552 return elm_object_item_part_content_get(navi_it, "title_right_btn");
1555 // For IoT Common profile.
1556 Evas_Object *viewer_maanger_create_scan_list_btn(Evas_Object *parent)
1558 Evas_Object *btn = elm_button_add(parent);
1562 elm_object_style_set(btn, "border");
1563 elm_object_domain_translatable_text_set(btn, PACKAGE,
1564 "IDS_WIFI_BUTTON_SCAN");
1565 evas_object_smart_callback_add(btn, "clicked", __refresh_scan_callback, NULL);
1570 int viewer_manager_create_scan_btn(void)
1572 __COMMON_FUNC_ENTER__;
1573 if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD
1574 || ug_app_state->ug_type == UG_VIEW_OOBE
1575 || ug_app_state->ug_type == UG_VIEW_IOT_COMMON
1576 || manager_object->scan_button) {
1577 __COMMON_FUNC_EXIT__;
1580 Evas_Object *btn = elm_button_add(manager_object->nav);
1581 /* Use "bottom" style button */
1583 ERROR_LOG(UG_NAME_NORMAL, "Error creating toolbar");
1586 elm_object_style_set(btn, "bottom");
1587 elm_object_domain_translatable_text_set(btn, PACKAGE,
1588 "IDS_WIFI_BUTTON_SCAN");
1589 evas_object_smart_callback_add(btn, "clicked", __refresh_scan_callback, NULL);
1591 /* Set button into "toolbar" swallow part */
1592 elm_object_item_part_content_set(manager_object->navi_it, "toolbar", btn);
1593 manager_object->scan_button = btn;
1594 evas_object_show(manager_object->scan_button);
1595 __COMMON_FUNC_EXIT__;
1599 void viewer_manager_header_mode_set(HEADER_MODES new_mode)
1601 __COMMON_FUNC_ENTER__;
1603 HEADER_MODES old_mode;
1604 if (manager_object == NULL)
1607 if (HEADER_MODE_OFF > new_mode || HEADER_MODE_MAX <= new_mode) {
1608 ERROR_LOG(UG_NAME_ERR, "Invalid mode %d", new_mode);
1612 old_mode = manager_object->header_mode;
1613 if (old_mode == new_mode) {
1614 if (new_mode == HEADER_MODE_OFF && manager_object->scan_button) {
1615 evas_object_del(manager_object->scan_button);
1616 manager_object->scan_button = NULL;
1621 DEBUG_LOG(UG_NAME_NORMAL, "Header mode %d --> %d", old_mode, new_mode);
1623 manager_object->header_mode = new_mode;
1626 case HEADER_MODE_OFF:
1627 viewer_manager_onoff_description_item_set(TRUE);
1628 if (manager_object->scan_button) {
1629 evas_object_del(manager_object->scan_button);
1630 manager_object->scan_button = NULL;
1632 if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD) {
1633 __viewer_manager_hidden_btn_del();
1634 __viewer_manager_setup_wizard_scan_btn_del();
1636 ug_app_state->is_wifi_scan_indication_block = 0;
1638 case HEADER_MODE_ON:
1639 case HEADER_MODE_CONNECTED:
1640 viewer_manager_onoff_description_item_set(FALSE);
1641 viewer_manager_scan_button_set(EINA_TRUE);
1647 if (manager_object->item_wifi_onoff != NULL)
1648 elm_genlist_item_update(manager_object->item_wifi_onoff);
1649 viewer_list_title_item_update();
1650 if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD) {
1651 viewer_manager_update_hidden_btn();
1652 viewer_manager_update_setup_wizard_scan_btn();
1653 viewer_manager_setup_wizard_button_controller();
1656 __COMMON_FUNC_EXIT__;
1659 HEADER_MODES viewer_manager_header_mode_get(void)
1661 return manager_object->header_mode;
1664 Evas_Object* viewer_manager_get_naviframe()
1666 return manager_object->nav;
1669 void viewer_manager_refresh_ap_info(Elm_Object_Item *item)
1674 ug_genlist_data_t *gdata = elm_object_item_data_get(item);
1678 wifi_device_info_t *wifi_device = gdata->device_info;
1682 wifi_manager_ap_refresh(wifi_device->ap);
1687 static gboolean __viewer_manager_list_scroll_to_top(void *data)
1690 elm_genlist_item_bring_in((Elm_Object_Item *)data, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1695 void viewer_manager_move_to_top(void)
1697 __COMMON_FUNC_ENTER__;
1699 Elm_Object_Item * first_item = NULL;
1701 if (manager_object == NULL || manager_object->list == NULL)
1704 first_item = elm_genlist_first_item_get(manager_object->list);
1705 if (first_item == NULL)
1708 common_util_managed_idle_add(__viewer_manager_list_scroll_to_top, first_item);
1710 __COMMON_FUNC_EXIT__;
1713 Elm_Object_Item *viewer_manager_move_item_to_top(Elm_Object_Item *old_item)
1715 __COMMON_FUNC_ENTER__;
1717 Elm_Object_Item *first_item = viewer_list_get_first_item();
1718 ug_genlist_data_t *gdata = NULL, *first_it_gdata = NULL;
1720 if (!old_item || !first_item) {
1721 __COMMON_FUNC_EXIT__;
1725 gdata = elm_object_item_data_get(old_item);
1726 if (!gdata || !gdata->device_info) {
1727 __COMMON_FUNC_EXIT__;
1731 if (old_item != first_item) {
1732 first_it_gdata = elm_object_item_data_get(first_item);
1733 elm_object_item_data_set(first_item, gdata);
1734 elm_object_item_data_set(old_item, first_it_gdata);
1736 if (first_item != NULL)
1737 elm_genlist_item_update(first_item);
1738 if (old_item != NULL)
1739 elm_genlist_item_update(old_item);
1742 __COMMON_FUNC_EXIT__;
1746 void viewer_manager_update_rssi(void)
1749 wifi_manager_ap_h ap;
1751 ret = wlan_manager_get_connected_ap(&ap);
1752 if (WIFI_MANAGER_ERROR_NONE != ret)
1755 Elm_Object_Item *item = item_get_for_ap(ap);
1757 wifi_manager_ap_destroy(ap);
1761 ug_genlist_data_t* gdata = elm_object_item_data_get(item);
1762 if (gdata && gdata->device_info) {
1765 if (WIFI_MANAGER_ERROR_NONE != wifi_manager_ap_get_rssi(ap, &rssi)) {
1766 wifi_manager_ap_destroy(ap);
1768 } else if (gdata->device_info->rssi != rssi) {
1769 wifi_manager_ap_refresh(gdata->device_info->ap);
1770 gdata->device_info->rssi = rssi;
1772 g_free(gdata->device_info->ap_image_path);
1774 common_utils_get_device_icon(gdata->device_info,
1775 &gdata->device_info->ap_image_path);
1778 elm_genlist_item_update(item);
1782 wifi_manager_ap_destroy(ap);
1785 static gint compare(gconstpointer a, gconstpointer b)
1787 bool favorite1 = false, favorite2 = false;
1788 wifi_manager_connection_state_e state1 = 0, state2 = 0;
1790 wifi_device_info_t *wifi_device1 = (wifi_device_info_t*)a;
1791 wifi_device_info_t *wifi_device2 = (wifi_device_info_t*)b;
1793 wifi_manager_ap_get_connection_state(wifi_device1->ap, &state1);
1794 wifi_manager_ap_get_connection_state(wifi_device2->ap, &state2);
1796 if (state1 != state2) {
1797 if (state1 == WIFI_MANAGER_CONNECTION_STATE_CONNECTED)
1799 if (state2 == WIFI_MANAGER_CONNECTION_STATE_CONNECTED)
1802 if (state1 == WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION)
1804 if (state2 == WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION)
1807 if (state1 == WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION)
1809 if (state2 == WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION)
1813 wifi_manager_ap_is_favorite(wifi_device1->ap, &favorite1);
1814 wifi_manager_ap_is_favorite(wifi_device2->ap, &favorite2);
1816 if (favorite1 != favorite2) {
1817 if (favorite1 == true)
1819 if (favorite2 == true)
1823 if (manager_object->sort_type == I18N_TYPE_Alphabetical) {
1824 return strcasecmp((const char *)wifi_device1->ssid,
1825 (const char *)wifi_device2->ssid);
1827 return ((wifi_device1->rssi >= wifi_device2->rssi) ? -1 : 1);
1831 static bool wifi_update_list_for_each_ap(wifi_manager_ap_h ap, void *user_data)
1833 int *profile_size = (int *)user_data;
1834 wifi_device_info_t *wifi_device = NULL;
1836 wifi_device = view_list_item_device_info_create(ap);
1837 if (wifi_device == NULL)
1840 wifi_device_list = g_list_insert_sorted(wifi_device_list, wifi_device, compare);
1846 static wifi_device_info_t *view_list_item_emulator_device_info_create(int index)
1848 wifi_device_info_t* wifi_device = NULL;
1850 wifi_device = g_try_new0(wifi_device_info_t, 1);
1851 retvm_if(NULL == wifi_device, NULL);
1853 wifi_device->ap = NULL;
1854 wifi_device->ssid = g_strdup(wifi_samples[index].ssid);
1855 wifi_device->rssi = 100;
1856 wifi_device->security_mode = wifi_samples[index].security;
1857 wifi_device->wps_mode = wifi_samples[index].wps;
1858 common_utils_get_device_icon(wifi_device, &wifi_device->ap_image_path);
1863 static void wifi_update_list_for_emulator_ap(void)
1866 wifi_device_info_t *wifi_device = NULL;
1868 for (index = 0; index < wifi_sample_count; ++index) {
1869 wifi_device = view_list_item_emulator_device_info_create(index);
1870 if (wifi_device == NULL)
1873 wifi_device_list = g_list_insert_sorted(wifi_device_list, wifi_device, compare);
1874 INFO_LOG(UG_NAME_NORMAL, "wifi_device_list added device(%s)", wifi_device->ssid);
1878 static int viewer_manager_update_list_all(char *ssid)
1880 int i, profiles_list_size = 0;
1881 Elm_Object_Item *item = NULL;
1882 GList* list_of_device ;
1883 wifi_device_info_t *wifi_device = NULL;
1886 __COMMON_FUNC_ENTER__;
1888 view_manager_list_update_info_t update_info;
1889 memset(&update_info, 0, sizeof(update_info));
1891 manager_object->sort_type = _convert_vconf_to_sort_by_value(
1892 common_util_get_system_registry(VCONF_SORT_BY));
1894 if (_is_emulator()) {
1895 profiles_list_size = wifi_sample_count;
1896 wifi_update_list_for_emulator_ap();
1898 wlan_manager_foreach_found_ap(wifi_update_list_for_each_ap, &profiles_list_size);
1900 list_of_device = wifi_device_list;
1901 for (i = 0; i < profiles_list_size && list_of_device != NULL; i++) {
1902 wifi_device = (wifi_device_info_t*)list_of_device->data;
1903 if (ssid == NULL || g_strcmp0(ssid, wifi_device->ssid) == 0) {
1904 item = viewer_list_item_insert_after(wifi_device, update_info.last_appended_item);
1906 update_info.last_appended_item = item;
1907 update_info.total_items_added++;
1912 list_of_device = list_of_device->next;
1915 if (wifi_device_list != NULL) {
1916 g_list_free(wifi_device_list);
1917 wifi_device_list = NULL;
1920 // OOBE: hidden AP, IOT: scan button
1921 viewer_list_last_item_set(update_info.last_appended_item);
1922 INFO_LOG(UG_NAME_NORMAL, "total items added = %d", update_info.total_items_added);
1924 if (0 == update_info.total_items_added) {
1925 /* Check if whether it's the first time we get no profiles,
1926 * if so, send one more scan request. This avoids the issue of
1927 * showing 'No Wi-Fi AP found' during launch time.
1929 if (manager_object->is_first_time_no_profiles == false) {
1930 HEADER_MODES current_state;
1931 int scan_result = WLAN_MANAGER_ERR_NONE;
1932 current_state = viewer_manager_header_mode_get();
1934 viewer_manager_show(VIEWER_WINSET_SEARCHING);
1935 viewer_manager_header_mode_set(HEADER_MODE_SEARCHING);
1937 scan_result = wlan_manager_scan();
1938 if (scan_result != WLAN_MANAGER_ERR_NONE) {
1939 viewer_manager_hide(VIEWER_WINSET_SEARCHING);
1940 viewer_manager_header_mode_set(current_state);
1943 manager_object->is_first_time_no_profiles = true;
1945 /* if there is no scan_data, generate No-AP item */
1946 item = viewer_list_item_insert_after(NULL, NULL);
1948 elm_genlist_item_select_mode_set(item,
1949 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1955 wifi_emulator_remove_event_timer(WIFI_EMUL_EVENT_TIMER_SCAN);
1957 __COMMON_FUNC_EXIT__;
1961 Eina_Bool viewer_manager_refresh(void)
1966 INFO_LOG(UG_NAME_SCAN, "viewer manager refresh");
1968 if (manager_object == NULL)
1971 header_state = viewer_manager_header_mode_get();
1972 if (header_state == HEADER_MODE_CONNECTING ||
1973 header_state == HEADER_MODE_ACTIVATING ||
1974 header_state == HEADER_MODE_DEACTIVATING) {
1978 viewer_list_item_disable_all();
1979 viewer_list_item_clear();
1981 state = wlan_manager_state_get();
1982 if (WLAN_MANAGER_ERROR == state || WLAN_MANAGER_OFF == state) {
1983 /* Some body requested to refresh the list
1984 * while the WLAN manager is OFF or Unable to get the profile state
1986 INFO_LOG(UG_NAME_ERR, "WLAN Manager state: %d", state);
1988 viewer_manager_header_mode_set(HEADER_MODE_OFF);
1993 wifi_manager_ap_h ap = wlan_manager_get_ap_with_state(state);
1994 viewer_manager_update_list_all(NULL);
1995 if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD) {
1996 __viewer_manager_hidden_button_create(manager_object->list);
1997 __viewer_manager_setup_wizard_scan_btn_create(
1998 manager_object->list);
2001 if (WLAN_MANAGER_CONNECTING == state) {
2002 INFO_LOG(UG_NAME_NORMAL, "Wi-Fi is connecting");
2004 Elm_Object_Item* target_item = item_get_for_ap(ap);
2006 viewer_manager_header_mode_set(HEADER_MODE_CONNECTING);
2007 viewer_list_item_radio_mode_set(target_item,
2008 VIEWER_ITEM_RADIO_MODE_CONNECTING);
2009 } else if (WLAN_MANAGER_CONNECTED == state) {
2010 INFO_LOG(UG_NAME_NORMAL, "Wi-Fi is connected");
2012 Elm_Object_Item* target_item = item_get_for_ap(ap);
2014 target_item = viewer_manager_move_item_to_top(target_item);
2015 viewer_manager_header_mode_set(HEADER_MODE_CONNECTED);
2016 viewer_list_item_radio_mode_set(target_item,
2017 VIEWER_ITEM_RADIO_MODE_CONNECTED);
2019 INFO_LOG(UG_NAME_NORMAL, "Wi-Fi state: %d", state);
2021 viewer_manager_header_mode_set(HEADER_MODE_ON);
2023 wifi_manager_ap_destroy(ap);
2025 INFO_LOG(UG_NAME_SCAN, "viewer manager refresh finished");
2030 static void hidden_ap_connect_ok_cb(void *data,
2031 Evas_Object *obj, void *event_info)
2033 __COMMON_FUNC_ENTER__;
2035 hidden_ap_data_t *hidden_ap_data = (hidden_ap_data_t *)data;
2036 if (hidden_ap_data == NULL) {
2037 __COMMON_FUNC_EXIT__;
2041 char* szPassword = NULL;
2042 wifi_manager_ap_h ap;
2044 int ret = wlan_manager_ap_create(hidden_ap_data->ssid, &ap);
2045 if (WIFI_MANAGER_ERROR_NONE != ret) {
2046 ERROR_LOG(UG_NAME_ERR, "Failed to create an AP handle. Err = %d", ret);
2051 SECURE_INFO_LOG(UG_NAME_NORMAL, "Hidden AP[%s]. Sec mode = %d. Connect ok cb",
2052 hidden_ap_data->ssid, hidden_ap_data->sec_mode);
2054 switch (hidden_ap_data->sec_mode) {
2055 case WIFI_MANAGER_SECURITY_TYPE_NONE:
2056 INFO_LOG(UG_NAME_NORMAL, "OPEN: event %p; passpopup %p",
2057 event_info, ug_app_state->passpopup);
2059 wifi_manager_ap_set_security_type(ap, WIFI_MANAGER_SECURITY_TYPE_NONE);
2062 case WIFI_MANAGER_SECURITY_TYPE_WEP:
2063 case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
2064 case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
2065 szPassword = passwd_popup_get_txt(ug_app_state->passpopup);
2066 wifi_manager_ap_set_security_type(ap, hidden_ap_data->sec_mode);
2068 int ret = wifi_manager_ap_set_passphrase(ap, szPassword);
2069 if (ret != WIFI_MANAGER_ERROR_NONE)
2070 INFO_LOG(UG_NAME_ERR, "Failed to set passpharse [%d]" , ret);
2074 passwd_popup_free(ug_app_state->passpopup);
2075 ug_app_state->passpopup = NULL;
2079 INFO_LOG(UG_NAME_NORMAL, "Fatal: Unknown Sec mode: %d",
2080 hidden_ap_data->sec_mode);
2082 goto hidden_ap_connect_end;
2085 wlan_manager_connect(ap);
2087 hidden_ap_connect_end:
2088 wifi_manager_ap_destroy(ap);
2091 viewer_manager_hidden_confirm_cleanup();
2093 __COMMON_FUNC_EXIT__;
2096 static void hidden_ap_connect_cancel_cb(void *data, Evas_Object *obj,
2099 __COMMON_FUNC_ENTER__;
2101 hidden_ap_data_t *hidden_ap_data = (hidden_ap_data_t *)data;
2102 if (hidden_ap_data == NULL) {
2103 __COMMON_FUNC_EXIT__;
2107 switch (hidden_ap_data->sec_mode) {
2108 case WIFI_MANAGER_SECURITY_TYPE_NONE:
2109 INFO_LOG(UG_NAME_NORMAL, "This hidden AP is Open");
2112 case WIFI_MANAGER_SECURITY_TYPE_WEP:
2113 case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
2114 case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
2115 INFO_LOG(UG_NAME_NORMAL, "Hidden AP Secured");
2117 passwd_popup_free(ug_app_state->passpopup);
2118 ug_app_state->passpopup = NULL;
2122 INFO_LOG(UG_NAME_NORMAL, "Fatal: Unknown Sec mode: %d",
2123 hidden_ap_data->sec_mode);
2127 viewer_manager_request_scan();
2128 viewer_manager_hidden_confirm_cleanup();
2130 __COMMON_FUNC_EXIT__;
2133 static void __hidden_ap_cancel_mouseup_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
2135 __COMMON_FUNC_ENTER__;
2137 Evas_Event_Mouse_Up *event = event_info;
2139 if (event->button == 3)
2140 hidden_ap_connect_cancel_cb(data, obj, event_info);
2142 __COMMON_FUNC_EXIT__;
2145 static void __hidden_ap_cancel_keydown_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
2147 __COMMON_FUNC_ENTER__;
2149 Evas_Event_Key_Down *event = event_info;
2151 if (g_strcmp0(event->keyname, "XF86Back") == 0)
2152 hidden_ap_connect_cancel_cb(data, obj, event_info);
2154 __COMMON_FUNC_EXIT__;
2157 void viewer_manager_eap_view_deref(void)
2159 __COMMON_FUNC_ENTER__;
2161 ug_app_state->eap_view = NULL;
2163 __COMMON_FUNC_EXIT__;
2166 void viewer_manager_specific_scan_response_hlr(
2167 GSList *bss_info_list, void *user_data)
2169 hidden_ap_data_t *hidden_ap_data = NULL;
2170 const char *ssid = (const char *)user_data;
2171 wifi_manager_security_type_e sec_mode = 0;
2172 bool favorite = false;
2173 ug_genlist_data_t* gdata = NULL;
2174 Evas_Object *popup = NULL;
2175 int hidden_ap_count = (int)g_slist_length(bss_info_list);
2176 Elm_Object_Item *item = NULL;
2178 viewer_manager_hide(VIEWER_WINSET_SEARCHING);
2179 viewer_manager_header_mode_set(HEADER_MODE_ON);
2181 if (view_hidden_ap_popup_data_get() == NULL) {
2182 ERROR_LOG(UG_NAME_RESP, "Popup is already destroyed");
2188 * We will delete the popup anyway
2190 view_hidden_ap_popup_destroy();
2193 ERROR_LOG(UG_NAME_RESP, "SSID is empty");
2197 INFO_LOG(UG_NAME_RESP, "Recieved %s(%d) hidden Wi-Fi networks",
2198 ssid, hidden_ap_count);
2199 viewer_list_item_clear();
2200 hidden_ap_count = viewer_manager_update_list_all((char *)ssid);
2201 INFO_LOG(UG_NAME_NORMAL, "Found %s(%d) Wi-Fi networks", ssid,
2204 if (hidden_ap_count > 1)
2207 viewer_manager_refresh();
2208 if (hidden_ap_count == 0) {
2209 INFO_LOG(UG_NAME_ERR, "no ap found");
2210 common_utils_send_message_to_net_popup("Network connection popup",
2211 "no ap found", "toast_popup", NULL);
2212 /*Recreate the popup*/
2213 view_hidden_ap_popup_create(ug_app_state->layout_main, PACKAGE);
2217 item = item_get_for_ssid(ssid);
2219 gdata = elm_object_item_data_get(item);
2220 if (gdata == NULL || gdata->device_info == NULL ||
2221 gdata->radio_mode == VIEWER_ITEM_RADIO_MODE_CONNECTED)
2223 sec_mode = gdata->device_info->security_mode;
2224 gdata->device_info->is_hidden = true;
2225 wifi_manager_ap_is_favorite(gdata->device_info->ap, &favorite);
2226 if (favorite == true) {
2227 wlan_manager_connect(gdata->device_info->ap);
2231 /* Only if there is one AP found then we need Users further action */
2233 case WIFI_MANAGER_SECURITY_TYPE_NONE:
2234 SECURE_INFO_LOG(UG_NAME_NORMAL, "%s open network found", ssid);
2236 hidden_ap_data = g_new0(hidden_ap_data_t, 1);
2237 hidden_ap_data->sec_mode = sec_mode;
2238 hidden_ap_data->ssid = g_strdup(ssid);
2240 popup_btn_info_t popup_btn_data;
2241 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
2242 popup_btn_data.title_txt = g_strdup(ssid);
2243 popup_btn_data.sub_title_txt = NULL;
2244 popup_btn_data.info_txt = "IDS_WIFI_BODY_A_WI_FI_NETWORK_HAS_BEEN_DETECTED_YOU_WILL_BE_CONNECTED";
2245 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
2246 popup_btn_data.btn1_cb = hidden_ap_connect_cancel_cb;
2247 popup_btn_data.btn1_data = popup_btn_data.btn2_data = hidden_ap_data;
2248 popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
2249 popup_btn_data.btn2_cb = hidden_ap_connect_ok_cb;
2251 popup = common_utils_show_info_popup(ug_app_state->layout_main,
2253 g_free(popup_btn_data.title_txt);
2255 hidden_ap_data->confirm_popup = popup;
2257 evas_object_event_callback_add(popup,
2258 EVAS_CALLBACK_MOUSE_UP,
2259 __hidden_ap_cancel_mouseup_cb,
2261 evas_object_event_callback_add(popup,
2262 EVAS_CALLBACK_KEY_DOWN,
2263 __hidden_ap_cancel_keydown_cb,
2266 manager_object->hidden_popup_data = hidden_ap_data;
2269 case WIFI_MANAGER_SECURITY_TYPE_EAP:
2270 SECURE_INFO_LOG(UG_NAME_NORMAL, "%s IEEE8021X found", ssid);
2272 wifi_device_info_t device_info;
2273 wifi_manager_ap_h ap;
2275 wlan_manager_ap_create(ssid, &ap);
2276 wifi_manager_ap_set_security_type(ap, WIFI_MANAGER_SECURITY_TYPE_EAP);
2278 struct ug_data *ugd = (struct ug_data *)ug_app_state->gadget;
2280 memset(&device_info, 0, sizeof(device_info));
2281 device_info.security_mode = WIFI_MANAGER_SECURITY_TYPE_EAP;
2282 device_info.ssid = (char *)ssid;
2283 device_info.ap = ap;
2285 UG_TYPE ug_type = wifi_get_ug_type();
2286 ug_app_state->eap_view =
2287 create_eap_view(ug_type == UG_VIEW_OOBE ?
2288 ug_app_state->parent_layout : ug_app_state->layout_main,
2290 ug_app_state->conformant,
2291 PACKAGE, &device_info,
2292 viewer_manager_eap_view_deref);
2294 wifi_manager_ap_destroy(ap);
2298 case WIFI_MANAGER_SECURITY_TYPE_WEP:
2299 case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
2300 case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
2301 SECURE_INFO_LOG(UG_NAME_NORMAL,
2302 "Secured(%d) %s found", sec_mode, ssid);
2304 pswd_popup_create_req_data_t popup_info;
2306 hidden_ap_data = g_try_new0(hidden_ap_data_t, 1);
2307 if (hidden_ap_data == NULL) {
2308 ERROR_LOG(UG_NAME_RESP, "Memory allocation error.");
2311 hidden_ap_data->sec_mode = sec_mode;
2312 hidden_ap_data->ssid = g_strdup(ssid);
2313 if (gdata && gdata->device_info) {
2314 hidden_ap_data->device_info = view_list_item_device_info_create(
2315 gdata->device_info->ap);
2317 memset(&popup_info, 0, sizeof(pswd_popup_create_req_data_t));
2318 /* Wi-Fi hidden network cannot be connected by WPS method.
2319 * In addition, Wi-Fi network info is also impossible to be set.
2320 * It's ConnMan agent limitation.
2321 * Do not use WPS method in here.
2323 popup_info.title = (char *)ssid;
2324 popup_info.sub_title = common_utils_get_ap_security_type_info_txt(PACKAGE,
2325 gdata->device_info, false);
2326 popup_info.ok_cb = hidden_ap_connect_ok_cb;
2327 popup_info.cancel_cb = hidden_ap_connect_cancel_cb;
2328 popup_info.cb_data = hidden_ap_data;
2329 popup_info.sec_type = sec_mode;
2331 ug_app_state->passpopup =
2332 create_passwd_popup(
2333 ug_app_state->conformant,
2334 ug_app_state->layout_main,
2335 PACKAGE, &popup_info);
2336 if (ug_app_state->passpopup == NULL)
2337 INFO_LOG(UG_NAME_ERR, "Fail to create password popup");
2339 manager_object->hidden_popup_data = hidden_ap_data;
2340 g_free(popup_info.sub_title);
2344 INFO_LOG(UG_NAME_NORMAL, "Unknown security mode: %d", sec_mode);
2353 wifi_device_info_t *view_list_item_device_info_create(wifi_manager_ap_h ap)
2356 wifi_device_info_t* wifi_device = NULL;
2359 wifi_device = g_try_new0(wifi_device_info_t, 1);
2360 retvm_if(NULL == wifi_device, NULL);
2362 if (WIFI_MANAGER_ERROR_NONE != wifi_manager_ap_clone(&(wifi_device->ap), ap))
2363 goto FREE_DEVICE_INFO;
2364 else if (WIFI_MANAGER_ERROR_NONE != wifi_manager_ap_get_essid(ap, &(wifi_device->ssid)))
2365 goto FREE_DEVICE_INFO;
2366 else if (WIFI_MANAGER_ERROR_NONE != wifi_manager_ap_get_rssi(ap, &(wifi_device->rssi)))
2367 goto FREE_DEVICE_INFO;
2368 else if (WIFI_MANAGER_ERROR_NONE != wifi_manager_ap_get_security_type(ap, &(wifi_device->security_mode)))
2369 goto FREE_DEVICE_INFO;
2370 else if (WIFI_MANAGER_ERROR_NONE != wifi_manager_ap_is_wps_supported(ap, &(wifi_device->wps_mode)))
2371 goto FREE_DEVICE_INFO;
2373 common_utils_get_device_icon(wifi_device, &wifi_device->ap_image_path);
2378 if (ret == false && wifi_device) {
2379 wifi_manager_ap_destroy(wifi_device->ap);
2380 g_free(wifi_device->ap_image_path);
2381 g_free(wifi_device->ap_status_txt);
2382 g_free(wifi_device->ssid);
2383 g_free(wifi_device);
2392 view_manager_view_type_t viewer_manager_view_type_get(void)
2394 __COMMON_FUNC_ENTER__;
2396 Evas_Object* navi_frame = NULL;
2397 view_manager_view_type_t top_view_id;
2399 navi_frame = viewer_manager_get_naviframe();
2400 top_view_id = (view_manager_view_type_t)evas_object_data_get(
2402 SCREEN_TYPE_ID_KEY);
2404 __COMMON_FUNC_EXIT__;
2408 void viewer_manager_request_scan(void)
2410 __COMMON_FUNC_ENTER__;
2412 HEADER_MODES current_state;
2414 current_state = viewer_manager_header_mode_get();
2416 if (current_state == HEADER_MODE_ON ||
2417 current_state == HEADER_MODE_CONNECTED) {
2420 INFO_LOG(UG_NAME_NORMAL, "Time to make a scan..");
2422 viewer_manager_show(VIEWER_WINSET_SEARCHING_GRP_TITLE);
2423 viewer_manager_header_mode_set(HEADER_MODE_SEARCHING);
2425 scan_result = wlan_manager_scan();
2426 if (scan_result != WLAN_MANAGER_ERR_NONE)
2427 viewer_manager_header_mode_set(current_state);
2430 __COMMON_FUNC_EXIT__;
2433 void viewer_manager_ctxpopup_cleanup(void)
2435 if (manager_object->ctxpopup) {
2436 evas_object_del(manager_object->ctxpopup);
2437 manager_object->ctxpopup = NULL;
2441 void viewer_manager_hidden_confirm_cleanup(void)
2443 if (manager_object == NULL)
2446 hidden_ap_data_t *hidden_data = manager_object->hidden_popup_data;
2448 if (hidden_data != NULL) {
2449 if (hidden_data->confirm_popup != NULL) {
2450 evas_object_del(hidden_data->confirm_popup);
2451 hidden_data->confirm_popup = NULL;
2454 if (hidden_data->device_info)
2455 g_free(hidden_data->device_info);
2456 g_free(hidden_data->ssid);
2457 g_free(hidden_data);
2459 manager_object->hidden_popup_data = NULL;
2463 void viewer_manager_cleanup_views(void)
2465 viewer_manager_ctxpopup_cleanup();
2467 viewer_manager_pop_naviframe_item();
2468 view_hidden_ap_popup_delete();
2469 viewer_manager_hidden_confirm_cleanup();
2472 void viewer_manager_rotate_top_setupwizard_layout(void)
2474 Evas_Object *layout = NULL;
2475 struct ug_data *ugd;
2477 Elm_Object_Item *navi_it = NULL;
2479 navi_it = elm_naviframe_top_item_get(manager_object->nav);
2480 layout = elm_object_item_content_get(navi_it);
2482 ugd = (struct ug_data *)ug_app_state->gadget;
2483 change_ang = elm_win_rotation_get(ugd->win_main);
2484 if (change_ang == 0 || change_ang == 180) {
2485 common_utils_contents_rotation_adjust(UG_EVENT_ROTATE_PORTRAIT);
2486 edje_object_signal_emit((Evas_Object *)elm_layout_edje_get(layout),
2487 "location,vertical", "elm");
2489 common_utils_contents_rotation_adjust(UG_EVENT_ROTATE_LANDSCAPE);
2490 edje_object_signal_emit((Evas_Object *)elm_layout_edje_get(layout),
2491 "location,horizontal", "elm");