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.
19 #include <efl_extension.h>
22 #include "mh_view_wifi_setup.h"
23 #include "mh_view_main.h"
24 #include "mh_string.h"
26 static void __gl_realized(void *data, Evas_Object *obj, void *event_info);
27 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info);
28 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info);
30 static void __create_password_item(Evas_Object *genlist, mh_appdata_t *ad);
31 static void __destroy_password_item(mh_appdata_t *ad);
33 static guint tethering_param_timer = 0;
35 static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
37 __MOBILE_AP_FUNC_ENTER__;
39 if (data == NULL || obj == NULL) {
40 ERR("Invalid param\n");
44 mh_appdata_t *ad = (mh_appdata_t *)data;
46 ad->setup.visibility_new = !ad->setup.visibility_new;
48 __MOBILE_AP_FUNC_EXIT__;
51 static bool __save_hide_btn_change(mh_appdata_t *ad)
53 __MOBILE_AP_FUNC_ENTER__;
56 ERR("Invalid param\n");
62 ret = tethering_wifi_set_ssid_visibility(ad->handle,
63 ad->setup.visibility_new);
64 if (ret != TETHERING_ERROR_NONE) {
65 ERR("tethering_wifi_set_ssid_visibility is failed : %d\n", ret);
69 __MOBILE_AP_FUNC_EXIT__;
73 static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
75 __MOBILE_AP_FUNC_ENTER__;
77 if (data == NULL || obj == NULL) {
78 ERR("Invalid param\n");
82 mh_appdata_t *ad = (mh_appdata_t *)data;
83 mh_wifi_setting_view_t *st = &ad->setup;
85 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
86 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
87 if (st->pw_item == NULL)
88 __create_password_item(st->genlist, ad);
90 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_NONE;
91 /* Disable password entry */
92 __destroy_password_item(ad);
95 /* update wifi passphrase item */
96 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
97 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
98 elm_object_disabled_set(st->save_button, EINA_FALSE);
100 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
104 elm_genlist_item_update(st->pw_item);
106 __MOBILE_AP_FUNC_EXIT__;
109 static void __check_box_changed_cb(void *data, Evas_Object *obj, void *event_info)
111 __MOBILE_AP_FUNC_ENTER__;
113 if (data == NULL || obj == NULL) {
114 ERR("Invalid param\n");
118 Eina_Bool state = elm_check_state_get(obj);
119 mh_appdata_t *ad = (mh_appdata_t *)data;
120 mh_wifi_setting_view_t *st = &ad->setup;
123 elm_entry_password_set(st->pw_entry, EINA_FALSE);
125 elm_entry_password_set(st->pw_entry, EINA_TRUE);
127 __MOBILE_AP_FUNC_EXIT__;
131 static bool __save_security_btn_change(mh_appdata_t *ad)
133 __MOBILE_AP_FUNC_ENTER__;
136 ERR("Invalid param\n");
142 ret = tethering_wifi_set_security_type(ad->handle, ad->setup.security_type_new);
143 if (ret != TETHERING_ERROR_NONE) {
144 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
148 __MOBILE_AP_FUNC_EXIT__;
152 static char *__gl_device_name_title_label_get(void *data, Evas_Object *obj, const char *part)
154 __MOBILE_AP_FUNC_ENTER__;
155 mh_appdata_t *ad = (mh_appdata_t *)data;
156 char *device_name_utf = NULL;
158 char buf[MH_LABEL_LENGTH_MAX] = {0, };
160 if (data == NULL || obj == NULL || part == NULL) {
161 ERR("Invalid param\n");
165 if (!strcmp("elm.text.multiline", part)) {
166 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
167 if (device_name_utf == NULL)
168 ERR("vconf_get_str failed \n");
170 ptr = elm_entry_utf8_to_markup(device_name_utf);
172 ERR("elm_entry_utf8_to_markup is failed\n");
173 free(device_name_utf);
177 g_strlcpy(ad->setup.device_name, ptr,
178 sizeof(ad->setup.device_name));
180 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size><br>%s", STR_MY_DEVICE_NAME, ptr);
182 free(device_name_utf);
188 __MOBILE_AP_FUNC_EXIT__;
192 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
194 __MOBILE_AP_FUNC_ENTER__;
196 if (data == NULL || obj == NULL || part == NULL) {
197 ERR("Invalid param\n");
201 if (!strcmp("elm.text", part))
202 return strdup(STR_HIDE_MY_DEV);
204 __MOBILE_AP_FUNC_EXIT__;
208 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
210 __MOBILE_AP_FUNC_ENTER__;
212 if (data == NULL || obj == NULL || part == NULL) {
213 ERR("Invalid param\n");
217 if (!strcmp("elm.text", part))
218 return strdup(STR_SECURITY_TYPE);
220 __MOBILE_AP_FUNC_EXIT__;
224 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
227 __MOBILE_AP_FUNC_ENTER__;
229 mh_appdata_t *ad = (mh_appdata_t *)data;
230 Evas_Object *btn = NULL;
232 if (data == NULL || obj == NULL || part == NULL) {
233 ERR("Invalid param\n");
237 if (!strcmp("elm.swallow.end", part)) {
238 btn = elm_check_add(obj);
240 ERR("btn is NULL\n");
244 elm_object_style_set(btn, "on&off");
245 evas_object_show(btn);
246 evas_object_pass_events_set(btn, EINA_TRUE);
247 evas_object_propagate_events_set(btn, EINA_FALSE);
248 elm_object_focus_allow_set(btn, EINA_FALSE);
249 elm_check_state_set(btn, ad->setup.visibility_new ? EINA_FALSE : EINA_TRUE);
250 evas_object_smart_callback_add(btn, "changed",
251 __hide_btn_changed_cb, (void *)ad);
252 ad->setup.hide_btn = btn;
255 __MOBILE_AP_FUNC_EXIT__;
259 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
262 __MOBILE_AP_FUNC_ENTER__;
264 mh_appdata_t *ad = (mh_appdata_t *)data;
265 Evas_Object *btn = NULL;
267 if (data == NULL || obj == NULL || part == NULL) {
268 ERR("Invalid param\n");
272 if (!strcmp("elm.swallow.end", part)) {
273 btn = elm_check_add(obj);
274 elm_object_style_set(btn, "on&off");
275 evas_object_show(btn);
276 evas_object_pass_events_set(btn, EINA_TRUE);
277 evas_object_propagate_events_set(btn, EINA_FALSE);
278 elm_check_state_set(btn, ad->setup.security_type_new ==
279 TETHERING_WIFI_SECURITY_TYPE_NONE ?
280 EINA_FALSE : EINA_TRUE);
281 evas_object_smart_callback_add(btn, "changed",
282 __security_btn_changed_cb, (void *)ad);
283 ad->setup.security_btn = btn;
286 __MOBILE_AP_FUNC_EXIT__;
290 static bool __save_wifi_passphrase(mh_appdata_t *ad)
292 __MOBILE_AP_FUNC_ENTER__;
295 ERR("Invalid param\n");
299 mh_wifi_setting_view_t *st = &ad->setup;
302 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
303 if (ret != TETHERING_ERROR_NONE) {
304 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
308 __MOBILE_AP_FUNC_EXIT__;
312 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
315 __MOBILE_AP_FUNC_ENTER__;
317 mh_appdata_t *ad = (mh_appdata_t *)data;
318 mh_wifi_setting_view_t *st = &ad->setup;
319 const char *changed_text;
323 changed_text = elm_entry_entry_get(obj);
324 if (changed_text == NULL) {
325 ERR("elm_entry_entry_get is failed\n");
329 utf8_string = elm_entry_markup_to_utf8(changed_text);
331 if (utf8_string == NULL) {
332 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
334 len = strlen(utf8_string);
335 if (WIFI_PASSPHRASE_LENGTH_MIN <= len) {
336 elm_object_disabled_set(st->save_button, EINA_FALSE);
337 elm_entry_input_panel_return_key_disabled_set(obj, FALSE);
339 elm_object_disabled_set(st->save_button, EINA_TRUE);
340 elm_entry_input_panel_return_key_disabled_set(obj, TRUE);
342 g_strlcpy(st->wifi_passphrase_new, utf8_string,
343 sizeof(st->wifi_passphrase_new));
348 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
349 if (elm_object_focus_get(obj)) {
350 if (elm_entry_is_empty(obj))
351 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
353 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
357 __MOBILE_AP_FUNC_EXIT__;
361 static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj,
364 __MOBILE_AP_FUNC_ENTER__;
367 ERR("The param is NULL\n");
368 __MOBILE_AP_FUNC_EXIT__;
371 char buf[MH_LABEL_LENGTH_MAX] = { 0, };
372 char *fmt = STR_PASSWORD_MIN_MAX;
373 notification_error_e ret;
375 snprintf(buf, sizeof(buf), fmt,
376 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
378 ret = notification_status_message_post(buf);
379 if (ret != NOTIFICATION_ERROR_NONE)
380 ERR("notification_status_message_post() is failed : %d\n", ret);
382 __MOBILE_AP_FUNC_EXIT__;
385 static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
387 __MOBILE_AP_FUNC_ENTER__;
390 ERR("Invalid parameter");
394 elm_object_focus_set(obj, EINA_FALSE);
395 __MOBILE_AP_FUNC_EXIT__;
399 static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
401 __MOBILE_AP_FUNC_ENTER__;
402 evas_object_smart_callback_del(obj, "focused", __pw_entry_focused_cb);
404 elm_object_focus_set(obj, EINA_TRUE);
405 elm_entry_cursor_end_set(obj);
406 __MOBILE_AP_FUNC_EXIT__;
409 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
411 __MOBILE_AP_FUNC_ENTER__;
412 if (elm_object_part_content_get(obj, "elm.swallow.clear"))
413 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
414 elm_object_signal_emit(obj, "elm,state,focus,off", "");
415 __MOBILE_AP_FUNC_EXIT__;
418 static void __pw_entry_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
420 __MOBILE_AP_FUNC_ENTER__;
421 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __pw_entry_show_cb);
423 elm_object_focus_set(obj, EINA_TRUE);
424 elm_entry_cursor_end_set(obj);
425 __MOBILE_AP_FUNC_EXIT__;
428 static void __eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
430 __MOBILE_AP_FUNC_ENTER__;
432 elm_object_text_set(data, "");
433 elm_entry_input_panel_return_key_disabled_set(data, TRUE);
435 __MOBILE_AP_FUNC_EXIT__;
438 static void __pw_entry_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
440 __MOBILE_AP_FUNC_ENTER__;
442 if (obj == NULL || data == NULL) {
446 mh_appdata_t *ad = (mh_appdata_t *)data;
447 mh_wifi_setting_view_t *st = &ad->setup;
448 char buf[MH_LABEL_LENGTH_MAX];
449 char *fmt = STR_PW_GUIDE_TEXT;
451 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
453 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
455 elm_genlist_item_update(st->pw_item);
457 elm_object_part_text_set(obj, "elm.guide", buf);
459 __MOBILE_AP_FUNC_EXIT__;
462 static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent)
464 __MOBILE_AP_FUNC_ENTER__;
466 static Elm_Entry_Filter_Limit_Size limit_filter_data;
467 Evas_Object *entry = NULL;
468 char *fmt = STR_PW_GUIDE_TEXT;
470 Evas_Object * clr_btn = NULL;
471 char buf[MH_LABEL_LENGTH_MAX];
473 if (parent == NULL || data == NULL) {
474 ERR("null param \n");
478 mh_appdata_t *ad = (mh_appdata_t *)data;
479 mh_wifi_setting_view_t *st = &ad->setup;
481 entry = elm_entry_add(parent);
484 ERR("elm_entry_add returns NULL\n");
489 elm_entry_single_line_set(entry, EINA_TRUE);
490 elm_entry_scrollable_set(entry, EINA_TRUE);
491 elm_entry_password_set(entry, EINA_TRUE);
493 evas_object_smart_callback_add(entry, "language,changed",
494 __pw_entry_language_changed_cb, ad);
496 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
497 elm_entry_prediction_allow_set(entry, EINA_FALSE);
498 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
499 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
500 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
501 elm_object_part_text_set(entry, "guide", buf);
502 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
504 limit_filter_data.max_char_count = 0;
505 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
506 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
508 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
509 elm_object_part_text_set(entry, "default", buf);
510 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
511 elm_object_disabled_set(entry, EINA_TRUE);
513 elm_object_item_signal_emit(st->pw_item, "elm,state,rename,hide", "");
516 elm_object_disabled_set(entry, EINA_FALSE);
517 elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
518 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
520 elm_object_text_set(entry, ptr);
523 ERR("elm_entry_utf8_to_markup is failed\n");
527 elm_entry_input_panel_return_key_type_set(entry,
528 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
530 clr_btn = elm_button_add(entry);
531 elm_object_style_set(clr_btn, "search_clear");
532 elm_object_focus_allow_set(clr_btn, EINA_FALSE);
533 elm_object_part_content_set(entry, "elm.swallow.clear", clr_btn);
534 evas_object_smart_callback_add(clr_btn, "clicked", __eraser_btn_clicked_cb, entry);
535 evas_object_show(clr_btn);
537 evas_object_smart_callback_add(entry, "changed",
538 __pw_entry_changed_cb, ad);
539 evas_object_smart_callback_add(entry, "maxlength,reached",
540 __pw_entry_maxlength_reached_cb, ad);
541 evas_object_smart_callback_add(entry, "activated",
542 __pw_entry_activated_cb, NULL);
543 evas_object_smart_callback_add(entry, "focused",
544 __pw_entry_focused_cb, NULL);
545 evas_object_smart_callback_add(entry, "unfocused",
546 __pw_entry_unfocused_cb, NULL);
547 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
548 __pw_entry_show_cb, NULL);
550 elm_object_focus_set(entry, EINA_TRUE);
551 elm_entry_input_panel_show(entry);
552 elm_object_part_content_set(parent, "elm.swallow.content", entry);
554 st->pw_entry = entry;
556 __MOBILE_AP_FUNC_EXIT__;
560 static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part)
562 __MOBILE_AP_FUNC_ENTER__;
568 ERR("data is null \n");
572 if (!strcmp(part, "elm.swallow.content")) {
573 Evas_Object *box = elm_box_add(obj);
574 Evas_Object *label = elm_label_add(box);
575 Evas_Object *layout = elm_layout_add(box);
576 char buf[MH_LABEL_LENGTH_MAX] = {0, };
578 elm_box_align_set(box, 0.0, 0.0);
580 /* Set label for name field */
581 snprintf(buf, MH_LABEL_LENGTH_MAX, "<text align=left><font_size=30>%s</font_size></text>", STR_PASSWORD);
582 elm_object_text_set(label, buf);
583 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
584 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
585 evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), 0, 0);
586 elm_box_pack_end(box, label);
587 evas_object_show(label);
589 /* Set layout for entry field */
590 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
591 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
592 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
594 __get_pw_entry(data, layout);
595 evas_object_show(layout);
596 elm_box_pack_end(box, layout);
598 evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
599 evas_object_show(box);
604 __MOBILE_AP_FUNC_EXIT__;
608 static char *_gl_pswd_check_box_text_get(void *data,
609 Evas_Object *obj, const char *part)
611 if (!strcmp("elm.text", part))
612 return strdup(STR_SHOW_PASSWORD);
618 static Evas_Object *_gl_pswd_check_box_content_get(void *data,
619 Evas_Object *obj, const char *part)
621 mh_appdata_t *ad = (mh_appdata_t *)data;
622 Evas_Object *check = NULL;
624 if (data == NULL || obj == NULL || part == NULL) {
625 ERR("Invalid param\n");
629 if (!strcmp("elm.swallow.icon", part)) {
630 check = elm_check_add(obj);
631 evas_object_propagate_events_set(check, EINA_FALSE);
633 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
634 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
635 evas_object_smart_callback_add(check, "changed", __check_box_changed_cb, (void *)ad);
637 elm_object_focus_allow_set(check, EINA_FALSE);
645 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
647 __MOBILE_AP_FUNC_ENTER__;
649 if (data == NULL || obj == NULL || event_info == NULL) {
650 ERR("param is NULL\n");
654 mh_appdata_t *ad = (mh_appdata_t *)data;
656 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
657 __hide_btn_changed_cb(ad, obj, NULL);
659 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility_new ?
660 EINA_FALSE : EINA_TRUE);
662 __MOBILE_AP_FUNC_EXIT__;
665 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
667 __MOBILE_AP_FUNC_ENTER__;
669 if (data == NULL || obj == NULL || event_info == NULL) {
670 ERR("param is NULL\n");
674 mh_appdata_t *ad = (mh_appdata_t *)data;
676 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
677 __security_btn_changed_cb(data, obj, NULL);
678 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type_new ==
679 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
681 __MOBILE_AP_FUNC_EXIT__;
684 static void __set_genlist_itc(mh_appdata_t *ad)
686 __MOBILE_AP_FUNC_ENTER__;
688 ad->setup.name_itc = elm_genlist_item_class_new();
689 if (ad->setup.name_itc == NULL) {
690 ERR("elm_genlist_item_class_new failed\n");
691 __MOBILE_AP_FUNC_EXIT__;
694 ad->setup.name_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
695 ad->setup.name_itc->func.text_get = __gl_device_name_title_label_get;
696 ad->setup.name_itc->func.content_get = NULL;
697 ad->setup.name_itc->func.state_get = NULL;
698 ad->setup.name_itc->func.del = NULL;
700 ad->setup.hide_itc = elm_genlist_item_class_new();
701 if (ad->setup.hide_itc == NULL) {
702 ERR("elm_genlist_item_class_new failed\n");
703 __MOBILE_AP_FUNC_EXIT__;
706 ad->setup.hide_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
707 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
708 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
709 ad->setup.hide_itc->func.state_get = NULL;
710 ad->setup.hide_itc->func.del = NULL;
712 ad->setup.security_itc = elm_genlist_item_class_new();
713 if (ad->setup.security_itc == NULL) {
714 ERR("elm_genlist_item_class_new failed\n");
715 __MOBILE_AP_FUNC_EXIT__;
718 ad->setup.security_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
719 ad->setup.security_itc->func.text_get = __gl_security_label_get;
720 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
721 ad->setup.security_itc->func.state_get = NULL;
722 ad->setup.security_itc->func.del = NULL;
724 ad->setup.pw_itc = elm_genlist_item_class_new();
725 if (ad->setup.pw_itc == NULL) {
726 ERR("elm_genlist_item_class_new failed\n");
727 __MOBILE_AP_FUNC_EXIT__;
730 ad->setup.pw_itc->item_style = MH_GENLIST_FULL_CONTENT_STYLE;
731 ad->setup.pw_itc->func.text_get = NULL;
732 ad->setup.pw_itc->func.content_get = __gl_pw_content_get;
733 ad->setup.pw_itc->func.state_get = NULL;
734 ad->setup.pw_itc->func.del = NULL;
736 ad->setup.check_box_itc = elm_genlist_item_class_new();
737 if (ad->setup.check_box_itc == NULL) {
738 ERR("elm_genlist_item_class_new failed\n");
739 __MOBILE_AP_FUNC_EXIT__;
742 ad->setup.check_box_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
743 ad->setup.check_box_itc->func.text_get = _gl_pswd_check_box_text_get;
744 ad->setup.check_box_itc->func.content_get = _gl_pswd_check_box_content_get;
745 ad->setup.check_box_itc->func.state_get = NULL;
746 ad->setup.check_box_itc->func.del = NULL;
748 __MOBILE_AP_FUNC_EXIT__;
752 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
754 __MOBILE_AP_FUNC_ENTER__;
761 evas_object_smart_callback_del(st->hide_btn, "changed",
762 __hide_btn_changed_cb);
763 evas_object_smart_callback_del(st->security_btn, "changed",
764 __security_btn_changed_cb);
765 evas_object_smart_callback_del(st->cancel_button, "clicked",
767 evas_object_smart_callback_del(st->save_button, "clicked",
769 evas_object_smart_callback_del(st->genlist, "realized",
772 __MOBILE_AP_FUNC_EXIT__;
775 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
777 if (user_data == NULL) {
778 ERR("Invalid parameter\n");
782 __MOBILE_AP_FUNC_ENTER__;
784 g_source_remove(tethering_param_timer);
786 mh_appdata_t *ad = (mh_appdata_t *)user_data;
788 if (result != TETHERING_ERROR_NONE)
789 ERR("tethering_wifi_reload_settings is failed [0x%X]\n", result);
790 _update_wifi_item(ad, MH_STATE_NONE);
792 __MOBILE_AP_FUNC_EXIT__;
797 static gboolean _update_tethering_param(gpointer data)
799 __MOBILE_AP_FUNC_ENTER__;
800 mh_appdata_t *ad = (mh_appdata_t *)data;
804 ERR("Invalid parameter\n");
808 /* reload wifi settings */
809 ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb,
811 if (ret != TETHERING_ERROR_NONE)
812 ERR("reload_configuration is failed : %d\n", ret);
814 __MOBILE_AP_FUNC_EXIT__;
818 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info)
822 ERR("data is NULL\n");
826 mh_appdata_t *ad = (mh_appdata_t *)data;
827 mh_wifi_setting_view_t *st = &ad->setup;
829 bool is_setting_changed = false;
831 /* handle hide button change */
832 if (st->visibility != st->visibility_new) {
833 ret = __save_hide_btn_change(ad);
835 elm_check_state_set(st->hide_btn, st->visibility ?
836 EINA_FALSE : EINA_TRUE);
838 st->visibility = st->visibility_new;
839 is_setting_changed = true;
842 /* handle security button change */
843 if (st->security_type != st->security_type_new) {
844 ret = __save_security_btn_change(ad);
846 elm_check_state_set(st->security_btn, st->security_type ==
847 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
849 st->security_type = st->security_type_new;
850 is_setting_changed = true;
854 /* handle wifi passphrase change */
855 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
856 ret = __save_wifi_passphrase(ad);
858 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
859 sizeof(st->wifi_passphrase_new));
861 elm_genlist_item_update(st->pw_item);
863 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
864 sizeof(st->wifi_passphrase));
865 is_setting_changed = true;
866 if (ad->main.help_item) {
867 if (ad->main.help_item)
868 elm_genlist_item_update(ad->main.help_item);
873 if (is_setting_changed) {
874 _update_wifi_item(ad, MH_STATE_PROCESS);
876 if (ad->main.help_item)
877 elm_genlist_item_update(ad->main.help_item);
879 /* Here, The Dbus takes some amount of time
880 to set the tethering parameters, due to
881 which UI shows incorrect display, to avoid
882 this issue, CAPI will be called after 0.1sec for smooth
883 transition of UI frames */
884 tethering_param_timer = g_timeout_add(100,
885 _update_tethering_param, ad);
888 elm_naviframe_item_pop(ad->naviframe);
894 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info)
899 ERR("The param is NULL\n");
903 mh_appdata_t *ad = (mh_appdata_t *)data;
905 elm_naviframe_item_pop(ad->naviframe);
910 Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item)
915 ERR("The param is NULL\n");
919 mh_appdata_t *ad = (mh_appdata_t *)data;
920 mh_wifi_setting_view_t *st = &ad->setup;
922 if (st->visibility != st->visibility_new)
923 st->visibility_new = st->visibility;
925 if (st->security_type != st->security_type_new)
926 st->security_type_new = st->security_type;
928 if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) {
929 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
930 sizeof(st->wifi_passphrase_new));
933 __deconstruct_wifi_setup_view(st);
935 if (ad->rename_popup != NULL) {
936 evas_object_del(ad->rename_popup);
937 ad->rename_popup = NULL;
939 ad->setup.navi_it = NULL;
940 _ctxpopup_more_button_callback_add(ad);
946 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
948 __MOBILE_AP_FUNC_ENTER__;
950 mh_appdata_t *ad = (mh_appdata_t *)data;
951 mh_wifi_setting_view_t *st = &(ad->setup);
952 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
955 char str[MH_LABEL_LENGTH_MAX] = {0, };
959 if (item == st->hide_item)
960 elm_object_item_signal_emit(item, "elm,state,top", "");
961 else if (item == st->security_item)
962 elm_object_item_signal_emit(item, "elm,state,center", "");
963 else if (item == st->pw_item)
964 elm_object_item_signal_emit(item, "elm,state,bottom", "");
966 no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]);
967 for (i = 0; i < no_of_sp; i++) {
968 if (item == st->sp_item[i])
969 elm_object_item_access_unregister(item);
972 if (item == st->hide_item || item == st->security_item) {
973 ao = elm_object_item_access_object_get(item);
974 btn = elm_object_item_part_content_get(item, "on&off");
975 snprintf(str, sizeof(str), "%s, %s", "On/off button",
976 (elm_check_state_get(btn) ? "On" : "Off"));
977 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
980 if (item == st->pw_item) {
981 elm_object_item_access_unregister(item);
982 ao = elm_object_item_access_register(item);
983 snprintf(str, sizeof(str), "%s, %s", STR_PASSWORD, st->wifi_passphrase_new);
984 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
987 __MOBILE_AP_FUNC_EXIT__;
992 static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_info)
994 __MOBILE_AP_FUNC_ENTER__;
997 ERR("The param is NULL\n");
1001 mh_appdata_t *ad = (mh_appdata_t *)data;
1002 mh_wifi_setting_view_t *st = &ad->setup;
1004 elm_object_focus_set(st->pw_entry, EINA_TRUE);
1006 __MOBILE_AP_FUNC_EXIT__;
1010 static void __create_password_item(Evas_Object *genlist, mh_appdata_t *ad)
1012 void *data = (void *)ad;
1013 mh_wifi_setting_view_t *st = &ad->setup;
1015 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
1016 ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad);
1017 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
1018 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
1020 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
1022 st->check_box_item = elm_genlist_item_append(genlist, st->check_box_itc, data, NULL,
1023 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1026 static void __destroy_password_item(mh_appdata_t *ad)
1028 void *data = (void *)ad;
1029 mh_wifi_setting_view_t *st = &ad->setup;
1031 elm_object_item_del(st->check_box_item);
1032 st->check_box_item = NULL;
1034 elm_object_item_del(st->pw_item);
1038 Evas_Object *__create_genlist(mh_appdata_t *ad)
1040 __MOBILE_AP_FUNC_ENTER__;
1043 ERR("ad is NULL\n");
1047 void *data = (void *)ad;
1048 mh_wifi_setting_view_t *st = &ad->setup;
1049 Evas_Object *genlist;
1051 genlist = elm_genlist_add(ad->naviframe);
1052 if (genlist == NULL) {
1053 ERR("genlist is NULL\n");
1057 elm_object_style_set(genlist, "dialogue");
1058 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1059 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
1061 __set_genlist_itc(ad);
1063 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
1064 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1065 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1068 elm_object_item_disabled_set(st->name_item, EINA_TRUE);
1070 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
1071 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
1073 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
1074 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
1076 if (st->security_type != TETHERING_WIFI_SECURITY_TYPE_NONE)
1077 __create_password_item(genlist, ad);
1079 __MOBILE_AP_FUNC_EXIT__;
1084 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
1089 ERR("ad is NULL\n");
1094 mh_wifi_setting_view_t *st = &ad->setup;
1096 if (ad->setup.navi_it != NULL) {
1097 ERR("Wi-Fi setup view already exists\n");
1102 st->genlist = __create_genlist(ad);
1103 if (st->genlist == NULL) {
1104 ERR("__create_genlist returns NULL\n");
1109 st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_BODY_CONFIGURE_MOBILE_HOTSPOT_ABB_US_TMO",
1110 NULL, NULL, st->genlist, NULL);
1111 elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);
1113 elm_naviframe_item_pop_cb_set(st->navi_it, _setting_back_btn_cb, (void *)ad);
1115 btn = elm_button_add(ad->naviframe);
1116 elm_object_style_set(btn, "naviframe/title_cancel");
1117 evas_object_smart_callback_add(btn, "clicked", __cancel_btn_cb, ad);
1118 elm_object_item_part_content_set(st->navi_it, "title_left_btn", btn);
1119 st->cancel_button = btn;
1121 btn = elm_button_add(ad->naviframe);
1122 elm_object_style_set(btn, "naviframe/title_done");
1123 evas_object_smart_callback_add(btn, "clicked", __save_btn_cb, ad);
1124 elm_object_item_part_content_set(st->navi_it, "title_right_btn", btn);
1125 st->save_button = btn;