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.
20 #include <efl_assist.h>
21 #include <efl_extension.h>
24 #include "common_pswd_popup.h"
25 #include "common_generate_pin.h"
26 #include "i18nmanager.h"
29 #define EDJ_GRP_POPUP_PBC_BUTTON_LAYOUT "popup_pbc_button_layout"
30 #define EDJ_GRP_POPUP_WPS_PIN_LAYOUT "popup_wps_pin_layout"
32 #define MAX_PBC_TIMEOUT_SECS 120 // Time in seconds
33 #define PASSWORD_LENGTH 64
35 static Elm_Genlist_Item_Class g_wps_itc;
36 static Elm_Genlist_Item_Class g_check_box_itc;
37 static Elm_Genlist_Item_Class g_pswd_entry_itc;
38 static gboolean wps_options_click = FALSE;
39 static gboolean keypad_state = FALSE;
41 static void __popup_entry_changed_cb(void* data, Evas_Object* obj, void* event_info)
43 Evas_Object *btn_ok = NULL;
44 pswd_popup_t *pswd_popup_data = NULL;
45 char* entry_str = NULL;
46 unsigned short int passwd_length = 0;
52 pswd_popup_data = (pswd_popup_t *) data;
53 entry_str = passwd_popup_get_txt(pswd_popup_data);
54 if (entry_str != NULL)
55 passwd_length = strlen(entry_str);
57 btn_ok = elm_object_part_content_get(pswd_popup_data->popup, "button2");
59 if (pswd_popup_data->sec_type == WIFI_SECURITY_TYPE_WEP) {
60 if (passwd_length > 0) {
61 elm_object_disabled_set(btn_ok, EINA_FALSE);
62 elm_entry_input_panel_return_key_disabled_set(obj,
65 elm_object_disabled_set(btn_ok, EINA_TRUE);
66 elm_entry_input_panel_return_key_disabled_set(obj,
69 } else if (pswd_popup_data->sec_type == WIFI_SECURITY_TYPE_WPA2_PSK ||
70 pswd_popup_data->sec_type == WIFI_SECURITY_TYPE_WPA_PSK) {
71 if (passwd_length > 7) {
72 elm_object_disabled_set(btn_ok, EINA_FALSE);
73 elm_entry_input_panel_return_key_disabled_set(obj,
76 elm_object_disabled_set(btn_ok, EINA_TRUE);
77 elm_entry_input_panel_return_key_disabled_set(obj,
82 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
83 if (elm_object_focus_get(obj)) {
84 if (elm_entry_is_empty(obj)) {
85 elm_object_signal_emit(obj,
86 "elm,state,clear,hidden", "");
88 elm_object_signal_emit(obj,
89 "elm,state,clear,visible", "");
98 static void __popup_entry_maxlength_reached(void *data, Evas_Object *obj,
101 common_utils_send_message_to_net_popup("Password length",
102 "Lengthy Password", "notification", NULL);
105 static void __common_pbc_popup_destroy(pbc_popup_t *pbc_popup_data)
107 __COMMON_FUNC_ENTER__;
108 if (!pbc_popup_data) {
112 if (pbc_popup_data->checker == 0) {
113 pbc_popup_data->checker = 1;
115 if (pbc_popup_data->timer != NULL) {
116 ecore_timer_del(pbc_popup_data->timer);
117 pbc_popup_data->timer = NULL;
120 if (pbc_popup_data->pin != NULL) {
121 g_free(pbc_popup_data->pin);
122 pbc_popup_data->pin = NULL;
125 if (pbc_popup_data->popup != NULL) {
126 evas_object_hide(pbc_popup_data->popup);
127 evas_object_del(pbc_popup_data->popup);
128 pbc_popup_data->popup = NULL;
130 g_free(pbc_popup_data);
132 __COMMON_FUNC_EXIT__;
136 static Eina_Bool _fn_pb_timer_bar(void *data)
143 pswd_popup_t *pswd_popup_data = (pswd_popup_t *)data;
144 pbc_popup_t *pbc_popup_data = pswd_popup_data->pbc_popup_data;
145 if (!pbc_popup_data || pbc_popup_data->timer == NULL ||
146 pbc_popup_data->progressbar == NULL) {
147 return ECORE_CALLBACK_CANCEL;
149 time_diff = difftime(current_time, pswd_popup_data->start_time);
150 pbc_popup_data->value = (double)(time_diff/(double)MAX_PBC_TIMEOUT_SECS);
151 if (pbc_popup_data->value >= 1) {
152 if (pbc_popup_data->checker == 0) {
153 __COMMON_FUNC_ENTER__;
155 Evas_Object *cancel_btn = elm_object_part_content_get(
156 pbc_popup_data->popup, "button1");
157 evas_object_smart_callback_call(cancel_btn, "clicked", NULL);
159 __COMMON_FUNC_EXIT__;
161 return ECORE_CALLBACK_CANCEL;
163 val = val - time_diff;
164 int remain_mins = (int)(val);
166 remain_secs = remain_mins % 60;
169 char *remaining_time_str = g_strdup_printf(
170 "<font_size=40><align=center>%02d:%02d</align></font_size>",
171 remain_mins, remain_secs);
172 elm_object_text_set(pbc_popup_data->timer_label, remaining_time_str);
173 /* INFO_LOG(UG_NAME_NORMAL, "pbc_popup_data->value = %lf;"
174 "remain_mins = %d; remain_secs = %d; remaining_time_str = %s",
175 pbc_popup_data->value, remain_mins, remain_secs, remaining_time_str); */
176 g_free(remaining_time_str);
178 elm_progressbar_value_set(pbc_popup_data->progressbar, pbc_popup_data->value);
180 return ECORE_CALLBACK_RENEW;
183 static Eina_Bool _enable_scan_updates_cb(void *data)
185 /* Lets enable the scan updates */
186 wlan_manager_enable_scan_result_update();
188 /* Reset the ecore timer handle */
189 common_util_manager_ecore_scan_update_timer_reset();
191 return ECORE_CALLBACK_CANCEL;
194 static void __pbc_popup_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
196 __COMMON_FUNC_ENTER__;
198 pbc_popup_t *pbc_data = (pbc_popup_t *)data;
199 Evas_Object *layout = NULL;
202 retm_if(pbc_data == NULL || pbc_data->popup == NULL);
203 layout = elm_object_content_get(pbc_data->popup);
205 if (pbc_data->wps_type == POPUP_WPS_BTN) {
206 g_snprintf(str, 1024, sc(PACKAGE,
207 I18N_TYPE_Press_WPS_On_Your_Wi_Fi_Access_Point), 2);
208 elm_object_domain_translatable_part_text_set(layout,
209 "elm.text.description", PACKAGE, str);
210 } else if (pbc_data->wps_type == POPUP_WPS_PIN) {
211 g_snprintf(str, 1024, sc(PACKAGE,
212 I18N_TYPE_Enter_PIN_number_on_your_WIFI_access_point),
214 elm_object_domain_translatable_part_text_set(layout,
215 "elm.text.description", PACKAGE, str);
217 __COMMON_FUNC_EXIT__;
220 void create_pbc_popup(pswd_popup_t *pswd_popup_data, Evas_Smart_Cb cancel_cb,
221 void *cancel_cb_data, popup_type_t type, char *pin)
223 if (!pswd_popup_data) {
226 Evas_Object *popup = NULL;
227 Evas_Object *progressbar = NULL;
228 Evas_Object *timer_label = NULL;
232 pbc_popup_t *pbc_popup_data = NULL;
233 pbc_popup_data = g_new0(pbc_popup_t, 1);
235 popup_btn_info_t popup_btn_data;
236 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
237 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
238 popup_btn_data.btn1_cb = cancel_cb;
239 popup_btn_data.btn1_data = cancel_cb_data;
240 popup = common_utils_show_info_popup(pswd_popup_data->win, &popup_btn_data);
242 if (type == POPUP_WPS_BTN) {
243 elm_object_domain_translatable_part_text_set(popup, "title,text",
244 PACKAGE, "IDS_WIFI_BUTTON_WPS_BUTTON");
245 } else if (type == POPUP_WPS_PIN) {
246 elm_object_domain_translatable_part_text_set(popup, "title,text",
247 PACKAGE, "IDS_WIFI_SK_WPS_PIN" );
250 layout = elm_layout_add(popup);
251 if (layout == NULL) {
255 if (type == POPUP_WPS_BTN) {
256 elm_layout_file_set(layout, CUSTOM_EDITFIELD_PATH,
257 EDJ_GRP_POPUP_PBC_BUTTON_LAYOUT);
258 g_snprintf(buf, sizeof(buf), sc(pswd_popup_data->str_pkg_name,
259 I18N_TYPE_Press_WPS_On_Your_Wi_Fi_Access_Point), 2);
260 elm_object_domain_translatable_part_text_set(layout,
261 "elm.text.description", PACKAGE, buf);
262 } else if (type == POPUP_WPS_PIN) {
263 elm_layout_file_set(layout, CUSTOM_EDITFIELD_PATH,
264 EDJ_GRP_POPUP_WPS_PIN_LAYOUT);
265 g_snprintf(buf, sizeof(buf),
266 sc(pswd_popup_data->str_pkg_name,
267 I18N_TYPE_Enter_PIN_number_on_your_WIFI_access_point),
269 elm_object_domain_translatable_part_text_set(layout,
270 "elm.text.description", PACKAGE, buf);
272 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
274 progressbar = elm_progressbar_add(layout);
275 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
276 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
277 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
278 elm_progressbar_value_set(progressbar, 0.0);
280 timer_label = elm_label_add(layout);
281 elm_label_line_wrap_set(timer_label, ELM_WRAP_MIXED);
282 elm_object_text_set(timer_label, _("<font_size=40><align=center>02:00</align></font_size>"));
283 evas_object_size_hint_weight_set(timer_label, EVAS_HINT_EXPAND, 0.0);
284 evas_object_size_hint_align_set(timer_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
285 evas_object_show(timer_label);
287 elm_object_part_content_set(layout, "slider", progressbar);
288 elm_object_part_content_set(layout, "timer_label", timer_label);
290 pbc_popup_data->checker = 0;
291 pbc_popup_data->value = 0.0;
292 pbc_popup_data->progressbar = progressbar;
293 pbc_popup_data->timer_label = timer_label;
294 pbc_popup_data->popup = popup;
295 pbc_popup_data->wps_type = type;
296 pbc_popup_data->pin = g_strdup(pin);
297 time(&(pswd_popup_data->start_time));
298 pbc_popup_data->timer = ecore_timer_add(1.0, _fn_pb_timer_bar, pswd_popup_data);
299 evas_object_show(progressbar);
300 evas_object_smart_callback_add(popup, "language,changed",
301 __pbc_popup_language_changed_cb, pbc_popup_data);
302 evas_object_show(popup);
303 elm_object_content_set(popup, layout);
304 pswd_popup_data->pbc_popup_data = pbc_popup_data;
306 evas_object_hide(pswd_popup_data->popup);
311 static char *_gl_wps_text_get(void *data, Evas_Object *obj, const char *part)
313 if (!strcmp("elm.text", part)) {
315 snprintf(buf, 1023, "%s", sc(PACKAGE, (int)data));
316 return g_strdup(dgettext(PACKAGE, buf));
321 static void _gl_realized(void *data, Evas_Object *obj, void *event_info)
326 int index = (int)elm_object_item_data_get(event_info);
328 if (index == I18N_TYPE_WPS_PIN) {
329 elm_object_item_signal_emit(event_info, "elm,state,bottomline,hide", "");
333 void create_wps_options_popup(Evas_Object *win_main,
334 pswd_popup_t *pswd_popup_data,
335 pswd_popup_create_req_data_t *popup_info)
337 if (!win_main || !popup_info || !pswd_popup_data) {
341 Evas_Object *popup = NULL;
342 Evas_Object *genlist = NULL;
343 static Elm_Genlist_Item_Class wps_itc;
345 popup = elm_popup_add(win_main);
349 ecore_imf_input_panel_hide();
351 txt = evas_textblock_text_utf8_to_markup(NULL, popup_info->title);
352 elm_object_domain_translatable_part_text_set(popup,
353 "title,text", PACKAGE, txt);
355 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
357 genlist = elm_genlist_add(popup);
358 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND,
360 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
361 elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
362 evas_object_smart_callback_add(genlist, "realized", _gl_realized, NULL);
364 wps_itc.item_style = WIFI_GENLIST_1LINE_TEXT_STYLE;
365 wps_itc.func.text_get = _gl_wps_text_get;
366 wps_itc.func.content_get = NULL;
367 wps_itc.func.state_get = NULL;
368 wps_itc.func.del = NULL;
370 elm_genlist_item_append(genlist, &wps_itc,
371 (void*)I18N_TYPE_WPS_Button, NULL,
372 ELM_GENLIST_ITEM_NONE, popup_info->wps_btn_cb,
373 popup_info->cb_data);
374 elm_genlist_item_append(genlist, &wps_itc,
375 (void*)I18N_TYPE_WPS_PIN, NULL,
376 ELM_GENLIST_ITEM_NONE, popup_info->wps_pin_cb,
377 popup_info->cb_data);
379 evas_object_show(genlist);
381 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
382 popup_info->cancel_cb, popup_info->cb_data);
383 elm_object_content_set(popup, genlist);
384 evas_object_show(popup);
385 elm_object_focus_set(popup, EINA_TRUE);
387 pswd_popup_data->wps_options_popup = popup;
389 evas_object_hide(pswd_popup_data->popup);
392 static char *_passwd_popup_wps_item_text_get(void *data, Evas_Object *obj,
395 if (!strcmp("elm.text", part)) {
397 snprintf(buf, 1023, "%s", sc(PACKAGE, I18N_TYPE_WPS));
403 static Evas_Object *_passwd_popup_wps_item_content_get(void *data,
404 Evas_Object *obj, const char *part)
406 Evas_Object *icon = NULL;
408 if (!strcmp("elm.swallow.icon", part)) {
410 icon = elm_image_add(obj);
411 retvm_if(NULL == icon, NULL);
413 elm_image_file_set(icon, CUSTOM_EDITFIELD_PATH, "wifi_icon_wps.png");
414 evas_object_color_set(icon, 2, 61, 132, 153);
416 evas_object_size_hint_min_set(icon, DEFAULT_BUTTON_CIRCLE_SIZE, DEFAULT_BUTTON_CIRCLE_SIZE);
421 static void _entry_edit_mode_show_cb(void *data, Evas *e, Evas_Object *obj,
424 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW,
425 _entry_edit_mode_show_cb);
427 elm_object_focus_set(obj, EINA_TRUE);
430 static void __popup_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
435 elm_object_focus_set(obj, EINA_FALSE);
438 static Evas_Object* _gl_pswd_entry_item_content_get(void *data,
439 Evas_Object *obj, const char *part)
441 if (obj == NULL || data == NULL) {
446 Evas_Object *entry = NULL;
447 Evas_Object *editfield = NULL;
449 static Elm_Entry_Filter_Limit_Size limit_filter_data;
450 pswd_popup_t *pswd_popup_data = (pswd_popup_t *)data;
452 if (!g_strcmp0(part, "elm.icon.entry")) {
453 editfield = elm_layout_add(obj);
454 elm_layout_theme_set(editfield, "layout", "editfield", "singleline");
455 evas_object_size_hint_align_set(editfield, EVAS_HINT_FILL, 0.0);
456 evas_object_size_hint_weight_set(editfield, EVAS_HINT_EXPAND, 0.0);
457 entry = elm_entry_add(editfield);
458 elm_entry_single_line_set(entry, EINA_TRUE);
459 elm_entry_scrollable_set(entry, EINA_TRUE);
460 elm_entry_password_set(entry, EINA_TRUE);
461 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
462 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
463 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0.0);
464 if (!g_strcmp0(pswd_popup_data->str_pkg_name, "wifi-qs")) {
465 elm_entry_input_panel_imdata_set(entry,
466 "type=systempopup", 16);
468 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
469 elm_entry_input_panel_layout_set(entry,
470 ELM_INPUT_PANEL_LAYOUT_PASSWORD);
471 elm_object_domain_translatable_part_text_set(entry, "elm.guide",
472 PACKAGE, "IDS_WIFI_HEADER_PASSWORD");
473 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
475 limit_filter_data.max_char_count = PASSWORD_LENGTH;
476 elm_entry_markup_filter_append(entry,
477 elm_entry_filter_limit_size, &limit_filter_data);
479 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
480 elm_entry_input_panel_return_key_type_set(entry, return_key_type);
481 elm_entry_input_panel_return_key_disabled_set(entry, EINA_TRUE);
482 evas_object_smart_callback_add(entry, "activated",
483 __popup_entry_activated_cb, data);
484 evas_object_smart_callback_add(entry, "changed",
485 __popup_entry_changed_cb, data);
486 evas_object_smart_callback_add(entry, "preedit,changed",
487 __popup_entry_changed_cb, data);
488 evas_object_smart_callback_add(entry, "maxlength,reached",
489 __popup_entry_maxlength_reached, NULL);
490 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
491 _entry_edit_mode_show_cb, NULL);
492 elm_object_part_content_set(editfield, "elm.swallow.content", entry);
494 pswd_popup_data->entry = entry;
496 elm_entry_input_panel_show(entry);
503 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
509 Eina_Bool state = elm_check_state_get(obj);
511 elm_entry_password_set((Evas_Object *)data, EINA_FALSE);
513 elm_entry_password_set((Evas_Object *)data, EINA_TRUE);
516 static char *_gl_pswd_check_box_item_text_get(void *data, Evas_Object *obj,
519 if (!strcmp("elm.text", part)) {
521 snprintf(buf, 1023, "%s", sc(PACKAGE, I18N_TYPE_Show_password));
528 static Evas_Object *_gl_pswd_check_box_item_content_get(void *data,
529 Evas_Object *obj, const char *part)
531 Evas_Object *check = NULL;
532 pswd_popup_t *pswd_popup_data = (pswd_popup_t *)data;
534 if (!strcmp("elm.swallow.end", part)) {
535 check = elm_check_add(obj);
536 evas_object_propagate_events_set(check, EINA_FALSE);
538 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
539 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
540 evas_object_smart_callback_add(check, "changed",
541 _chk_changed_cb, pswd_popup_data->entry);
543 elm_object_focus_allow_set(check, EINA_FALSE);
550 static void _gl_pswd_check_box_sel(void *data, Evas_Object *obj, void *ei)
552 __COMMON_FUNC_ENTER__;
553 Elm_Object_Item *item = NULL;
555 item = (Elm_Object_Item *)ei;
560 pswd_popup_t *pswd_popup_data = (pswd_popup_t *)data;
562 Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.right");
564 elm_genlist_item_selected_set(item, EINA_FALSE);
566 Eina_Bool state = elm_check_state_get(ck);
567 elm_check_state_set(ck, !state);
568 if (pswd_popup_data) {
569 _chk_changed_cb(pswd_popup_data->entry, ck, NULL);
573 static void _passwd_popup_keypad_off_cb(void *data, Evas_Object *obj,
580 pswd_popup_t *pop_info = (pswd_popup_t *)data;
582 keypad_state = FALSE;
584 if (wps_options_click == TRUE) {
585 wps_options_click = FALSE;
587 if (pop_info->wps_btn_cb != NULL) {
588 pop_info->wps_btn_cb(NULL, NULL, NULL);
591 INFO_LOG(UG_NAME_NORMAL,"Keypad is down");
594 static void _passwd_popup_keypad_on_cb(void *data, Evas_Object *obj,
602 INFO_LOG(UG_NAME_NORMAL,"Keypad is up");
605 static void popup_animation_finish_cb(void *data, Evas_Object *obj, void *event_info)
607 __COMMON_FUNC_ENTER__;
608 Elm_Object_Item *item = (Elm_Object_Item *) data;
609 Evas_Object *entry = NULL;
611 entry = elm_object_item_part_content_get(item, "elm.icon.entry");
612 elm_entry_input_panel_show(entry);
613 elm_entry_input_panel_show_on_demand_set(entry, EINA_FALSE);
614 elm_object_focus_set(entry, EINA_TRUE);
616 __COMMON_FUNC_EXIT__;
619 static void _common_wps_options_popup_cb(void* data, Evas_Object* obj,
622 __COMMON_FUNC_ENTER__;
624 if (!event_info || !data) {
628 pswd_popup_t *pop_info = (pswd_popup_t *) data;
629 Elm_Object_Item *item = event_info;
630 elm_genlist_item_selected_set(item, EINA_FALSE);
632 if (keypad_state == FALSE) {
633 if (pop_info->wps_btn_cb != NULL)
634 pop_info->wps_btn_cb(NULL, NULL, NULL);
636 wps_options_click = TRUE;
637 ecore_imf_input_panel_hide();
640 __COMMON_FUNC_EXIT__;
643 pswd_popup_t *create_passwd_popup(Evas_Object *conformant,Evas_Object *win_main,
644 const char *pkg_name, pswd_popup_create_req_data_t *popup_info)
646 Evas_Object *passpopup = NULL;
647 Evas_Object *genlist = NULL;
648 Evas_Object *btn_ok = NULL;
650 __COMMON_FUNC_ENTER__;
652 if (!win_main || !popup_info || !pkg_name) {
656 pswd_popup_t *pswd_popup_data = g_new0(pswd_popup_t, 1);
658 if (popup_info->ap) {
659 if (WIFI_ERROR_NONE !=
660 wifi_ap_clone(&(pswd_popup_data->ap), popup_info->ap)) {
661 g_free(pswd_popup_data);
666 /* Hidden Wi-Fi network does not have handle */
669 wps_options_click = FALSE;
670 /* Lets disable the scan updates so that the UI is not refreshed un necessarily */
671 wlan_manager_disable_scan_result_update();
673 popup_btn_info_t popup_btn_data;
674 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
676 popup_btn_data.title_txt = popup_info->title;
677 popup_btn_data.btn1_cb = popup_info->cancel_cb;
678 popup_btn_data.btn1_data = popup_info->cb_data;
679 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
680 popup_btn_data.btn2_cb = popup_info->ok_cb;
681 popup_btn_data.btn2_data = popup_info->cb_data;
682 popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
684 passpopup = common_utils_show_info_popup(win_main, &popup_btn_data);
687 ERROR_LOG(UG_NAME_ERR, "Could not initialize popup");
691 pswd_popup_data->win = win_main;
692 pswd_popup_data->conf = conformant;
693 pswd_popup_data->str_pkg_name = pkg_name;
694 pswd_popup_data->popup = passpopup;
695 pswd_popup_data->sec_type = popup_info->sec_type;
696 pswd_popup_data->curr_ap_name = g_strdup(popup_info->title);
697 pswd_popup_data->show_wps_btn = popup_info->show_wps_btn;
698 pswd_popup_data->wps_btn_cb = popup_info->wps_btn_cb;
700 /* Hide the Okay button until the password is entered */
701 btn_ok = elm_object_part_content_get(passpopup, "button2");
702 elm_object_disabled_set(btn_ok, TRUE);
703 #ifdef ACCESSIBLITY_FEATURE
704 Evas_Object *eo = NULL;
705 Evas_Object *ao = NULL;
706 eo = elm_layout_edje_get(passpopup);
707 const Evas_Object *po = edje_object_part_object_get(eo, "elm.text.title");
708 ao = elm_access_object_get(po);
709 elm_access_info_set(ao, ELM_ACCESS_INFO, popup_info->title);
712 genlist = elm_genlist_add(passpopup);
713 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
714 elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
715 evas_object_size_hint_weight_set(genlist,
716 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
717 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
719 /* Entry genlist item */
720 g_pswd_entry_itc.item_style = "entry";
721 g_pswd_entry_itc.func.text_get = NULL;
722 g_pswd_entry_itc.func.content_get = _gl_pswd_entry_item_content_get;
723 g_check_box_itc.func.state_get = NULL;
724 g_check_box_itc.func.del = NULL;
726 Elm_Object_Item * entry_item = elm_genlist_item_append(genlist,
727 &g_pswd_entry_itc, pswd_popup_data,
728 NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
730 /* Checkbox genlist item */
731 g_check_box_itc.item_style = WIFI_GENLIST_1LINE_TEXT_ICON_STYLE;
732 g_check_box_itc.func.text_get = _gl_pswd_check_box_item_text_get;
733 g_check_box_itc.func.content_get = _gl_pswd_check_box_item_content_get;
734 g_check_box_itc.func.state_get = NULL;
735 g_check_box_itc.func.del = NULL;
737 elm_genlist_item_append(genlist, &g_check_box_itc, pswd_popup_data,
738 NULL, ELM_GENLIST_ITEM_NONE,
739 _gl_pswd_check_box_sel, pswd_popup_data);
741 if (popup_info->show_wps_btn) {
742 /* WPS options genlist item */
743 g_wps_itc.item_style = WIFI_GENLIST_1LINE_TEXT_ICON_STYLE;
744 g_wps_itc.func.text_get = _passwd_popup_wps_item_text_get;
745 g_wps_itc.func.content_get = _passwd_popup_wps_item_content_get;
746 g_wps_itc.func.state_get = NULL;
747 g_wps_itc.func.del = NULL;
749 pswd_popup_data->wps_options_item = elm_genlist_item_append(genlist,
750 &g_wps_itc, NULL, NULL, ELM_GENLIST_ITEM_NONE,
751 _common_wps_options_popup_cb, pswd_popup_data);
754 evas_object_show(genlist);
756 elm_object_content_set(passpopup, genlist);
758 evas_object_smart_callback_add(passpopup, "show,finished",
759 popup_animation_finish_cb, entry_item);
760 evas_object_show(passpopup);
762 evas_object_smart_callback_add(pswd_popup_data->conf,
763 "virtualkeypad,state,on", _passwd_popup_keypad_on_cb,
765 evas_object_smart_callback_add(pswd_popup_data->conf,
766 "virtualkeypad,state,off", _passwd_popup_keypad_off_cb,
769 __COMMON_FUNC_EXIT__;
770 return pswd_popup_data;
773 char *passwd_popup_get_txt(pswd_popup_t *pswd_popup_data)
775 if (pswd_popup_data) {
776 Evas_Object *entry = pswd_popup_data->entry;
777 return elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
783 wifi_ap_h passwd_popup_get_ap(pswd_popup_t *pswd_popup_data)
785 if (pswd_popup_data) {
786 return pswd_popup_data->ap;
792 void current_popup_free(pswd_popup_t *pswd_popup_data, popup_type_t type)
794 if (pswd_popup_data == NULL) {
800 Evas_Object *curr_popup = NULL;
802 if (type == POPUP_WPS_OPTIONS) {
803 if (pswd_popup_data->wps_options_popup) {
804 evas_object_hide(pswd_popup_data->wps_options_popup);
805 evas_object_del(pswd_popup_data->wps_options_popup);
806 pswd_popup_data->wps_options_popup = NULL;
808 evas_object_show(pswd_popup_data->popup);
809 curr_popup = pswd_popup_data->popup;
812 rotation = common_utils_get_rotate_angle(APPCORE_RM_UNKNOWN);
813 if (rotation != -1) {
814 g_snprintf(buf, sizeof(buf), "elm,state,orient,%d", rotation);
815 SECURE_INFO_LOG(UG_NAME_NORMAL, "Rotation signal - %s", buf);
816 elm_layout_signal_emit(curr_popup, buf, "elm");
820 void passwd_popup_hide(pswd_popup_t *pswd_popup_data)
822 if (pswd_popup_data == NULL) {
826 if (pswd_popup_data->popup != NULL) {
827 evas_object_hide(pswd_popup_data->popup);
831 void passwd_popup_show(pswd_popup_t *pswd_popup_data)
833 if (pswd_popup_data == NULL) {
837 if (pswd_popup_data->popup != NULL) {
838 evas_object_show(pswd_popup_data->popup);
842 void passwd_popup_free(pswd_popup_t *pswd_popup_data)
844 __COMMON_FUNC_ENTER__;
846 if (pswd_popup_data == NULL) {
850 if (pswd_popup_data->conf) {
851 if (keypad_state == TRUE)
852 keypad_state = FALSE;
853 evas_object_smart_callback_del(pswd_popup_data->conf,
854 "virtualkeypad,state,on",
855 _passwd_popup_keypad_on_cb);
856 evas_object_smart_callback_del(pswd_popup_data->conf,
857 "virtualkeypad,state,off",
858 _passwd_popup_keypad_off_cb);
861 if (pswd_popup_data->curr_ap_name != NULL) {
862 g_free(pswd_popup_data->curr_ap_name);
863 pswd_popup_data->curr_ap_name = NULL;
866 if (pswd_popup_data->info_popup != NULL) {
867 evas_object_del(pswd_popup_data->info_popup);
868 pswd_popup_data->info_popup = NULL;
869 INFO_LOG(UG_NAME_NORMAL, "info popup deleted");
872 if (pswd_popup_data->pbc_popup_data) {
873 __common_pbc_popup_destroy(pswd_popup_data->pbc_popup_data);
874 pswd_popup_data->pbc_popup_data = NULL;
875 INFO_LOG(UG_NAME_NORMAL, "wps pbc popup deleted");
878 if (pswd_popup_data->popup != NULL) {
879 evas_object_del(pswd_popup_data->popup);
880 pswd_popup_data->popup = NULL;
881 INFO_LOG(UG_NAME_NORMAL, "password popup deleted");
884 if (pswd_popup_data->wps_options_popup != NULL) {
885 evas_object_del(pswd_popup_data->wps_options_popup);
886 pswd_popup_data->wps_options_popup = NULL;
887 INFO_LOG(UG_NAME_NORMAL, "wps option popup deleted");
890 /* Hidden Wi-Fi network does not have handle */
891 if (pswd_popup_data->ap)
892 wifi_ap_destroy(pswd_popup_data->ap);
894 g_free(pswd_popup_data);
896 /* A delay is needed to get the smooth Input panel closing animation effect */
897 common_util_managed_ecore_scan_update_timer_add(0.1,
898 _enable_scan_updates_cb, NULL);
900 __COMMON_FUNC_EXIT__;