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 (!g_strcmp0(part, "elm.text.main.left")) {
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 = "1line";
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, EA_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 (!g_strcmp0(part, "elm.text.main.left")) {
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;
407 Evas_Object *ic = NULL;
409 ic = elm_layout_add(obj);
410 retvm_if(NULL == ic, NULL);
412 if (!g_strcmp0(part, "elm.icon.1")) {
413 elm_layout_theme_set(ic, "layout", "list/B/type.3", "default");
416 icon = elm_image_add(ic);
417 retvm_if(NULL == icon, NULL);
419 elm_image_file_set(icon, CUSTOM_EDITFIELD_PATH, "wifi_icon_wps.png");
420 evas_object_color_set(icon, 2, 61, 132, 153);
422 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
423 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
424 elm_object_part_content_set(ic, "elm.swallow.content", icon);
429 static void _entry_edit_mode_show_cb(void *data, Evas *e, Evas_Object *obj,
432 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW,
433 _entry_edit_mode_show_cb);
435 elm_object_focus_set(obj, EINA_TRUE);
438 static void __popup_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
443 elm_object_focus_set(obj, EINA_FALSE);
446 static Evas_Object* _gl_pswd_entry_item_content_get(void *data,
447 Evas_Object *obj, const char *part)
449 if (obj == NULL || data == NULL) {
454 Evas_Object *entry = NULL;
455 Evas_Object *editfield = NULL;
457 static Elm_Entry_Filter_Limit_Size limit_filter_data;
458 pswd_popup_t *pswd_popup_data = (pswd_popup_t *)data;
460 if (!g_strcmp0(part, "elm.icon.entry")) {
461 editfield = elm_layout_add(obj);
462 elm_layout_theme_set(editfield, "layout", "editfield", "singleline");
463 evas_object_size_hint_align_set(editfield, EVAS_HINT_FILL, 0.0);
464 evas_object_size_hint_weight_set(editfield, EVAS_HINT_EXPAND, 0.0);
465 entry = elm_entry_add(editfield);
466 elm_entry_single_line_set(entry, EINA_TRUE);
467 elm_entry_scrollable_set(entry, EINA_TRUE);
468 elm_entry_password_set(entry, EINA_TRUE);
469 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
470 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
471 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0.0);
472 if (!g_strcmp0(pswd_popup_data->str_pkg_name, "wifi-qs")) {
473 elm_entry_input_panel_imdata_set(entry,
474 "type=systempopup", 16);
476 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
477 elm_entry_input_panel_layout_set(entry,
478 ELM_INPUT_PANEL_LAYOUT_PASSWORD);
479 elm_object_domain_translatable_part_text_set(entry, "elm.guide",
480 PACKAGE, "IDS_WIFI_HEADER_PASSWORD");
481 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
483 limit_filter_data.max_char_count = PASSWORD_LENGTH;
484 elm_entry_markup_filter_append(entry,
485 elm_entry_filter_limit_size, &limit_filter_data);
487 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
488 elm_entry_input_panel_return_key_type_set(entry, return_key_type);
489 elm_entry_input_panel_return_key_disabled_set(entry, EINA_TRUE);
490 evas_object_smart_callback_add(entry, "activated",
491 __popup_entry_activated_cb, data);
492 evas_object_smart_callback_add(entry, "changed",
493 __popup_entry_changed_cb, data);
494 evas_object_smart_callback_add(entry, "preedit,changed",
495 __popup_entry_changed_cb, data);
496 evas_object_smart_callback_add(entry, "maxlength,reached",
497 __popup_entry_maxlength_reached, NULL);
498 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
499 _entry_edit_mode_show_cb, NULL);
500 elm_object_part_content_set(editfield, "elm.swallow.content", entry);
502 pswd_popup_data->entry = entry;
504 elm_entry_input_panel_show(entry);
511 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
517 Eina_Bool state = elm_check_state_get(obj);
519 elm_entry_password_set((Evas_Object *)data, EINA_FALSE);
521 elm_entry_password_set((Evas_Object *)data, EINA_TRUE);
524 static char *_gl_pswd_check_box_item_text_get(void *data, Evas_Object *obj,
527 if (!g_strcmp0(part, "elm.text")) {
529 snprintf(buf, 1023, "%s", sc(PACKAGE, I18N_TYPE_Show_password));
536 static Evas_Object *_gl_pswd_check_box_item_content_get(void *data,
537 Evas_Object *obj, const char *part)
539 Evas_Object *check = NULL;
540 pswd_popup_t *pswd_popup_data = (pswd_popup_t *)data;
542 if(!g_strcmp0(part, "elm.swallow.end")) {
543 check = elm_check_add(obj);
544 evas_object_propagate_events_set(check, EINA_FALSE);
546 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
547 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
548 evas_object_smart_callback_add(check, "changed",
549 _chk_changed_cb, pswd_popup_data->entry);
551 elm_object_focus_allow_set(check, EINA_FALSE);
558 static void _gl_pswd_check_box_sel(void *data, Evas_Object *obj, void *ei)
560 __COMMON_FUNC_ENTER__;
561 Elm_Object_Item *item = NULL;
563 item = (Elm_Object_Item *)ei;
568 pswd_popup_t *pswd_popup_data = (pswd_popup_t *)data;
570 Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.right");
572 elm_genlist_item_selected_set(item, EINA_FALSE);
574 Eina_Bool state = elm_check_state_get(ck);
575 elm_check_state_set(ck, !state);
576 if (pswd_popup_data) {
577 _chk_changed_cb(pswd_popup_data->entry, ck, NULL);
581 static void _passwd_popup_keypad_off_cb(void *data, Evas_Object *obj,
588 pswd_popup_t *pop_info = (pswd_popup_t *)data;
590 keypad_state = FALSE;
592 if (wps_options_click == TRUE) {
593 wps_options_click = FALSE;
595 if (pop_info->wps_btn_cb != NULL) {
596 pop_info->wps_btn_cb(NULL, NULL, NULL);
599 INFO_LOG(UG_NAME_NORMAL,"Keypad is down");
602 static void _passwd_popup_keypad_on_cb(void *data, Evas_Object *obj,
610 INFO_LOG(UG_NAME_NORMAL,"Keypad is up");
613 static void popup_animation_finish_cb(void *data, Evas_Object *obj, void *event_info)
615 __COMMON_FUNC_ENTER__;
616 Elm_Object_Item *item = (Elm_Object_Item *) data;
617 Evas_Object *entry = NULL;
619 entry = elm_object_item_part_content_get(item, "elm.icon.entry");
620 elm_entry_input_panel_show(entry);
621 elm_entry_input_panel_show_on_demand_set(entry, EINA_FALSE);
622 elm_object_focus_set(entry, EINA_TRUE);
624 __COMMON_FUNC_EXIT__;
627 static void _common_wps_options_popup_cb(void* data, Evas_Object* obj,
630 __COMMON_FUNC_ENTER__;
632 if (!event_info || !data) {
636 pswd_popup_t *pop_info = (pswd_popup_t *) data;
637 Elm_Object_Item *item = event_info;
638 elm_genlist_item_selected_set(item, EINA_FALSE);
640 if (keypad_state == FALSE) {
641 if (pop_info->wps_btn_cb != NULL)
642 pop_info->wps_btn_cb(NULL, NULL, NULL);
644 wps_options_click = TRUE;
645 ecore_imf_input_panel_hide();
648 __COMMON_FUNC_EXIT__;
651 pswd_popup_t *create_passwd_popup(Evas_Object *conformant,Evas_Object *win_main,
652 const char *pkg_name, pswd_popup_create_req_data_t *popup_info)
654 Evas_Object *passpopup = NULL;
655 Evas_Object *genlist = NULL;
656 Evas_Object *btn_ok = NULL;
657 Evas_Object *box = NULL;
659 __COMMON_FUNC_ENTER__;
661 if (!win_main || !popup_info || !pkg_name) {
665 pswd_popup_t *pswd_popup_data = g_new0(pswd_popup_t, 1);
667 if (popup_info->ap) {
668 if (WIFI_ERROR_NONE !=
669 wifi_ap_clone(&(pswd_popup_data->ap), popup_info->ap)) {
670 g_free(pswd_popup_data);
675 /* Hidden Wi-Fi network does not have handle */
678 wps_options_click = FALSE;
679 /* Lets disable the scan updates so that the UI is not refreshed un necessarily */
680 wlan_manager_disable_scan_result_update();
682 popup_btn_info_t popup_btn_data;
683 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
685 popup_btn_data.title_txt = popup_info->title;
686 popup_btn_data.btn1_cb = popup_info->cancel_cb;
687 popup_btn_data.btn1_data = popup_info->cb_data;
688 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
689 popup_btn_data.btn2_cb = popup_info->ok_cb;
690 popup_btn_data.btn2_data = popup_info->cb_data;
691 popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
693 passpopup = common_utils_show_info_popup(win_main, &popup_btn_data);
696 ERROR_LOG(UG_NAME_ERR, "Could not initialize popup");
700 pswd_popup_data->win = win_main;
701 pswd_popup_data->conf = conformant;
702 pswd_popup_data->str_pkg_name = pkg_name;
703 pswd_popup_data->popup = passpopup;
704 pswd_popup_data->sec_type = popup_info->sec_type;
705 pswd_popup_data->curr_ap_name = g_strdup(popup_info->title);
706 pswd_popup_data->show_wps_btn = popup_info->show_wps_btn;
707 pswd_popup_data->wps_btn_cb = popup_info->wps_btn_cb;
709 /* Hide the Okay button until the password is entered */
710 btn_ok = elm_object_part_content_get(passpopup, "button2");
711 elm_object_disabled_set(btn_ok, TRUE);
712 #ifdef ACCESSIBLITY_FEATURE
713 Evas_Object *eo = NULL;
714 Evas_Object *ao = NULL;
715 eo = elm_layout_edje_get(passpopup);
716 const Evas_Object *po = edje_object_part_object_get(eo, "elm.text.title");
717 ao = elm_access_object_get(po);
718 elm_access_info_set(ao, ELM_ACCESS_INFO, popup_info->title);
721 box = elm_box_add(passpopup);
722 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
724 genlist = elm_genlist_add(box);
725 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
726 elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
727 evas_object_size_hint_weight_set(genlist,
728 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
729 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
731 /* Entry genlist item */
732 g_pswd_entry_itc.item_style = "entry";
733 g_pswd_entry_itc.func.text_get = NULL;
734 g_pswd_entry_itc.func.content_get = _gl_pswd_entry_item_content_get;
735 g_check_box_itc.func.state_get = NULL;
736 g_check_box_itc.func.del = NULL;
738 Elm_Object_Item * entry_item = elm_genlist_item_append(genlist,
739 &g_pswd_entry_itc, pswd_popup_data,
740 NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
742 /* Checkbox genlist item */
743 g_check_box_itc.item_style = "type1";
744 g_check_box_itc.func.text_get = _gl_pswd_check_box_item_text_get;
745 g_check_box_itc.func.content_get = _gl_pswd_check_box_item_content_get;
746 g_check_box_itc.func.state_get = NULL;
747 g_check_box_itc.func.del = NULL;
749 elm_genlist_item_append(genlist, &g_check_box_itc, pswd_popup_data,
750 NULL, ELM_GENLIST_ITEM_NONE,
751 _gl_pswd_check_box_sel, pswd_popup_data);
753 if (popup_info->show_wps_btn) {
754 /* WPS options genlist item */
755 g_wps_itc.item_style = "1line";
756 g_wps_itc.func.text_get = _passwd_popup_wps_item_text_get;
757 g_wps_itc.func.content_get = _passwd_popup_wps_item_content_get;
758 g_wps_itc.func.state_get = NULL;
759 g_wps_itc.func.del = NULL;
761 pswd_popup_data->wps_options_item = elm_genlist_item_append(genlist,
762 &g_wps_itc, NULL, NULL, ELM_GENLIST_ITEM_NONE,
763 _common_wps_options_popup_cb, pswd_popup_data);
766 evas_object_show(genlist);
767 elm_box_pack_end(box, genlist);
768 evas_object_size_hint_min_set(box, -1, ELM_SCALE_SIZE(100));
769 elm_object_content_set(passpopup, box);
771 evas_object_smart_callback_add(passpopup, "show,finished",
772 popup_animation_finish_cb, entry_item);
773 evas_object_show(passpopup);
775 evas_object_smart_callback_add(pswd_popup_data->conf,
776 "virtualkeypad,state,on", _passwd_popup_keypad_on_cb,
778 evas_object_smart_callback_add(pswd_popup_data->conf,
779 "virtualkeypad,state,off", _passwd_popup_keypad_off_cb,
782 __COMMON_FUNC_EXIT__;
783 return pswd_popup_data;
786 char *passwd_popup_get_txt(pswd_popup_t *pswd_popup_data)
788 if (pswd_popup_data) {
789 Evas_Object *entry = pswd_popup_data->entry;
790 return elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
796 wifi_ap_h passwd_popup_get_ap(pswd_popup_t *pswd_popup_data)
798 if (pswd_popup_data) {
799 return pswd_popup_data->ap;
805 void current_popup_free(pswd_popup_t *pswd_popup_data, popup_type_t type)
807 if (pswd_popup_data == NULL) {
813 Evas_Object *curr_popup = NULL;
815 if (type == POPUP_WPS_OPTIONS) {
816 if (pswd_popup_data->wps_options_popup) {
817 evas_object_hide(pswd_popup_data->wps_options_popup);
818 evas_object_del(pswd_popup_data->wps_options_popup);
819 pswd_popup_data->wps_options_popup = NULL;
821 evas_object_show(pswd_popup_data->popup);
822 curr_popup = pswd_popup_data->popup;
825 rotation = common_utils_get_rotate_angle(APPCORE_RM_UNKNOWN);
826 if (rotation != -1) {
827 g_snprintf(buf, sizeof(buf), "elm,state,orient,%d", rotation);
828 SECURE_INFO_LOG(UG_NAME_NORMAL, "Rotation signal - %s", buf);
829 elm_layout_signal_emit(curr_popup, buf, "elm");
833 void passwd_popup_hide(pswd_popup_t *pswd_popup_data)
835 if (pswd_popup_data == NULL) {
839 if (pswd_popup_data->popup != NULL) {
840 evas_object_hide(pswd_popup_data->popup);
844 void passwd_popup_show(pswd_popup_t *pswd_popup_data)
846 if (pswd_popup_data == NULL) {
850 if (pswd_popup_data->popup != NULL) {
851 evas_object_show(pswd_popup_data->popup);
855 void passwd_popup_free(pswd_popup_t *pswd_popup_data)
857 __COMMON_FUNC_ENTER__;
859 if (pswd_popup_data == NULL) {
863 if (pswd_popup_data->conf) {
864 if (keypad_state == TRUE)
865 keypad_state = FALSE;
866 evas_object_smart_callback_del(pswd_popup_data->conf,
867 "virtualkeypad,state,on",
868 _passwd_popup_keypad_on_cb);
869 evas_object_smart_callback_del(pswd_popup_data->conf,
870 "virtualkeypad,state,off",
871 _passwd_popup_keypad_off_cb);
874 if (pswd_popup_data->curr_ap_name != NULL) {
875 g_free(pswd_popup_data->curr_ap_name);
876 pswd_popup_data->curr_ap_name = NULL;
879 if (pswd_popup_data->info_popup != NULL) {
880 evas_object_del(pswd_popup_data->info_popup);
881 pswd_popup_data->info_popup = NULL;
882 INFO_LOG(UG_NAME_NORMAL, "info popup deleted");
885 if (pswd_popup_data->pbc_popup_data) {
886 __common_pbc_popup_destroy(pswd_popup_data->pbc_popup_data);
887 pswd_popup_data->pbc_popup_data = NULL;
888 INFO_LOG(UG_NAME_NORMAL, "wps pbc popup deleted");
891 if (pswd_popup_data->popup != NULL) {
892 evas_object_del(pswd_popup_data->popup);
893 pswd_popup_data->popup = NULL;
894 INFO_LOG(UG_NAME_NORMAL, "password popup deleted");
897 if (pswd_popup_data->wps_options_popup != NULL) {
898 evas_object_del(pswd_popup_data->wps_options_popup);
899 pswd_popup_data->wps_options_popup = NULL;
900 INFO_LOG(UG_NAME_NORMAL, "wps option popup deleted");
903 /* Hidden Wi-Fi network does not have handle */
904 if (pswd_popup_data->ap)
905 wifi_ap_destroy(pswd_popup_data->ap);
907 g_free(pswd_popup_data);
909 /* A delay is needed to get the smooth Input panel closing animation effect */
910 common_util_managed_ecore_scan_update_timer_add(0.1,
911 _enable_scan_updates_cb, NULL);
913 __COMMON_FUNC_EXIT__;