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_string.h"
25 static void __gl_realized(void *data, Evas_Object *obj, void *event_info);
26 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info);
27 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info);
29 static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
31 __MOBILE_AP_FUNC_ENTER__;
33 if (data == NULL || obj == NULL) {
34 ERR("Invalid param\n");
38 mh_appdata_t *ad = (mh_appdata_t *)data;
40 ad->setup.visibility_new = !ad->setup.visibility_new;
42 __MOBILE_AP_FUNC_EXIT__;
45 static bool __save_hide_btn_change(mh_appdata_t *ad)
47 __MOBILE_AP_FUNC_ENTER__;
50 ERR("Invalid param\n");
56 ret = tethering_wifi_set_ssid_visibility(ad->handle,
57 ad->setup.visibility_new);
58 if (ret != TETHERING_ERROR_NONE) {
59 ERR("tethering_wifi_set_ssid_visibility is failed : %d\n", ret);
63 __MOBILE_AP_FUNC_EXIT__;
67 static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
69 __MOBILE_AP_FUNC_ENTER__;
71 if (data == NULL || obj == NULL) {
72 ERR("Invalid param\n");
76 mh_appdata_t *ad = (mh_appdata_t *)data;
77 mh_wifi_setting_view_t *st = &ad->setup;
79 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE)
80 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
82 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_NONE;
84 /* update wifi passphrase item */
85 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
86 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
87 elm_object_disabled_set(st->save_button, EINA_FALSE);
89 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
90 if (st->pw_entry == NULL || elm_entry_entry_get(st->pw_entry) == NULL ||
91 strlen(elm_entry_entry_get(st->pw_entry)) == 0)
92 elm_object_disabled_set(st->save_button, EINA_TRUE);
96 elm_genlist_item_update(st->pw_item);
98 __MOBILE_AP_FUNC_EXIT__;
101 static bool __save_security_btn_change(mh_appdata_t *ad)
103 __MOBILE_AP_FUNC_ENTER__;
106 ERR("Invalid param\n");
112 ret = tethering_wifi_set_security_type(ad->handle, ad->setup.security_type_new);
113 if (ret != TETHERING_ERROR_NONE) {
114 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
118 __MOBILE_AP_FUNC_EXIT__;
122 static char *__gl_device_name_title_label_get(void *data, Evas_Object *obj, const char *part)
124 __MOBILE_AP_FUNC_ENTER__;
125 mh_appdata_t *ad = (mh_appdata_t *)data;
126 char *device_name_utf = NULL;
128 char buf[MH_LABEL_LENGTH_MAX] = {0, };
130 if (data == NULL || obj == NULL || part == NULL) {
131 ERR("Invalid param\n");
135 if (!strcmp("elm.text.multiline", part)) {
136 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
137 if (device_name_utf == NULL)
138 ERR("vconf_get_str failed \n");
140 ptr = elm_entry_utf8_to_markup(device_name_utf);
142 ERR("elm_entry_utf8_to_markup is failed\n");
143 free(device_name_utf);
147 g_strlcpy(ad->setup.device_name, ptr,
148 sizeof(ad->setup.device_name));
150 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size><br>%s", STR_MY_DEVICE_NAME, ptr);
152 free(device_name_utf);
158 __MOBILE_AP_FUNC_EXIT__;
162 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
164 __MOBILE_AP_FUNC_ENTER__;
166 if (data == NULL || obj == NULL || part == NULL) {
167 ERR("Invalid param\n");
171 if (!strcmp("elm.text", part))
172 return strdup(STR_HIDE_MY_DEV);
174 __MOBILE_AP_FUNC_EXIT__;
178 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
180 __MOBILE_AP_FUNC_ENTER__;
182 if (data == NULL || obj == NULL || part == NULL) {
183 ERR("Invalid param\n");
187 if (!strcmp("elm.text", part))
188 return strdup(STR_SECURITY_TYPE);
190 __MOBILE_AP_FUNC_EXIT__;
194 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
197 __MOBILE_AP_FUNC_ENTER__;
199 mh_appdata_t *ad = (mh_appdata_t *)data;
200 Evas_Object *btn = NULL;
202 if (data == NULL || obj == NULL || part == NULL) {
203 ERR("Invalid param\n");
207 if (!strcmp("elm.swallow.end", part)) {
208 btn = elm_check_add(obj);
210 ERR("btn is NULL\n");
214 elm_object_style_set(btn, "on&off");
215 evas_object_show(btn);
216 evas_object_pass_events_set(btn, EINA_TRUE);
217 evas_object_propagate_events_set(btn, EINA_FALSE);
218 elm_object_focus_allow_set(btn, EINA_FALSE);
219 elm_check_state_set(btn, ad->setup.visibility_new ? EINA_FALSE : EINA_TRUE);
220 evas_object_smart_callback_add(btn, "changed",
221 __hide_btn_changed_cb, (void *)ad);
222 ad->setup.hide_btn = btn;
225 __MOBILE_AP_FUNC_EXIT__;
229 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
232 __MOBILE_AP_FUNC_ENTER__;
234 mh_appdata_t *ad = (mh_appdata_t *)data;
235 Evas_Object *btn = NULL;
237 if (data == NULL || obj == NULL || part == NULL) {
238 ERR("Invalid param\n");
242 if (!strcmp("elm.swallow.end", part)) {
243 btn = elm_check_add(obj);
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_check_state_set(btn, ad->setup.security_type_new ==
249 TETHERING_WIFI_SECURITY_TYPE_NONE ?
250 EINA_FALSE : EINA_TRUE);
251 evas_object_smart_callback_add(btn, "changed",
252 __security_btn_changed_cb, (void *)ad);
253 ad->setup.security_btn = btn;
256 __MOBILE_AP_FUNC_EXIT__;
260 static bool __save_wifi_passphrase(mh_appdata_t *ad)
262 __MOBILE_AP_FUNC_ENTER__;
265 ERR("Invalid param\n");
269 mh_wifi_setting_view_t *st = &ad->setup;
272 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
273 if (ret != TETHERING_ERROR_NONE) {
274 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
278 __MOBILE_AP_FUNC_EXIT__;
282 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
285 __MOBILE_AP_FUNC_ENTER__;
287 mh_appdata_t *ad = (mh_appdata_t *)data;
288 mh_wifi_setting_view_t *st = &ad->setup;
289 const char *changed_text;
293 changed_text = elm_entry_entry_get(obj);
294 if (changed_text == NULL) {
295 ERR("elm_entry_entry_get is failed\n");
299 utf8_string = elm_entry_markup_to_utf8(changed_text);
301 if (utf8_string == NULL) {
302 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
304 len = strlen(utf8_string);
305 if (WIFI_PASSPHRASE_LENGTH_MIN <= len) {
306 elm_object_disabled_set(st->save_button, EINA_FALSE);
307 elm_entry_input_panel_return_key_disabled_set(obj, FALSE);
309 elm_object_disabled_set(st->save_button, EINA_TRUE);
310 elm_entry_input_panel_return_key_disabled_set(obj, TRUE);
312 g_strlcpy(st->wifi_passphrase_new, utf8_string,
313 sizeof(st->wifi_passphrase_new));
318 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
319 if (elm_object_focus_get(obj)) {
320 if (elm_entry_is_empty(obj))
321 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
323 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
327 __MOBILE_AP_FUNC_EXIT__;
331 static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj,
334 __MOBILE_AP_FUNC_ENTER__;
337 ERR("The param is NULL\n");
338 __MOBILE_AP_FUNC_EXIT__;
341 char buf[MH_LABEL_LENGTH_MAX] = { 0, };
342 char *fmt = STR_PASSWORD_MIN_MAX;
343 notification_error_e ret;
345 snprintf(buf, sizeof(buf), fmt,
346 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
348 ret = notification_status_message_post(buf);
349 if (ret != NOTIFICATION_ERROR_NONE)
350 ERR("notification_status_message_post() is failed : %d\n", ret);
352 __MOBILE_AP_FUNC_EXIT__;
355 static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
357 __MOBILE_AP_FUNC_ENTER__;
360 ERR("Invalid parameter");
364 elm_object_focus_set(obj, EINA_FALSE);
365 __MOBILE_AP_FUNC_EXIT__;
369 static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
371 __MOBILE_AP_FUNC_ENTER__;
372 evas_object_smart_callback_del(obj, "focused", __pw_entry_focused_cb);
374 elm_object_focus_set(obj, EINA_TRUE);
375 elm_entry_cursor_end_set(obj);
376 __MOBILE_AP_FUNC_EXIT__;
379 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
381 __MOBILE_AP_FUNC_ENTER__;
382 if (elm_object_part_content_get(obj, "elm.swallow.clear"))
383 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
384 elm_object_signal_emit(obj, "elm,state,focus,off", "");
385 __MOBILE_AP_FUNC_EXIT__;
388 static void __pw_entry_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
390 __MOBILE_AP_FUNC_ENTER__;
391 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __pw_entry_show_cb);
393 elm_object_focus_set(obj, EINA_TRUE);
394 elm_entry_cursor_end_set(obj);
395 __MOBILE_AP_FUNC_EXIT__;
398 static void __eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
400 __MOBILE_AP_FUNC_ENTER__;
402 elm_object_text_set(data, "");
403 elm_entry_input_panel_return_key_disabled_set(data, TRUE);
405 __MOBILE_AP_FUNC_EXIT__;
408 static void __pw_entry_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
410 __MOBILE_AP_FUNC_ENTER__;
412 if (obj == NULL || data == NULL) {
416 mh_appdata_t *ad = (mh_appdata_t *)data;
417 mh_wifi_setting_view_t *st = &ad->setup;
418 char buf[MH_LABEL_LENGTH_MAX];
419 char *fmt = STR_PW_GUIDE_TEXT;
421 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
423 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
425 elm_genlist_item_update(st->pw_item);
427 elm_object_part_text_set(obj, "elm.guide", buf);
429 __MOBILE_AP_FUNC_EXIT__;
432 static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent)
434 __MOBILE_AP_FUNC_ENTER__;
436 static Elm_Entry_Filter_Limit_Size limit_filter_data;
437 Evas_Object *entry = NULL;
438 char *fmt = STR_PW_GUIDE_TEXT;
440 Evas_Object * clr_btn = NULL;
441 char buf[MH_LABEL_LENGTH_MAX];
443 if (parent == NULL || data == NULL) {
444 ERR("null param \n");
448 mh_appdata_t *ad = (mh_appdata_t *)data;
449 mh_wifi_setting_view_t *st = &ad->setup;
451 entry = elm_entry_add(parent);
454 ERR("elm_entry_add returns NULL\n");
459 elm_entry_single_line_set(entry, EINA_TRUE);
460 elm_entry_scrollable_set(entry, EINA_TRUE);
461 elm_entry_password_set(entry, EINA_FALSE);
463 evas_object_smart_callback_add(entry, "language,changed",
464 __pw_entry_language_changed_cb, ad);
466 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
467 elm_entry_prediction_allow_set(entry, EINA_FALSE);
468 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
469 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
470 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
471 elm_object_part_text_set(entry, "guide", buf);
472 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
474 limit_filter_data.max_char_count = 0;
475 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
476 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
478 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
479 elm_object_part_text_set(entry, "default", buf);
480 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
481 elm_object_disabled_set(entry, EINA_TRUE);
483 elm_object_item_signal_emit(st->pw_item, "elm,state,rename,hide", "");
486 elm_object_disabled_set(entry, EINA_FALSE);
487 elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
488 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
490 elm_object_text_set(entry, ptr);
493 ERR("elm_entry_utf8_to_markup is failed\n");
497 elm_entry_input_panel_return_key_type_set(entry,
498 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
500 clr_btn = elm_button_add(entry);
501 elm_object_style_set(clr_btn, "search_clear");
502 elm_object_focus_allow_set(clr_btn, EINA_FALSE);
503 elm_object_part_content_set(entry, "elm.swallow.clear", clr_btn);
504 evas_object_smart_callback_add(clr_btn, "clicked", __eraser_btn_clicked_cb, entry);
505 evas_object_show(clr_btn);
507 evas_object_smart_callback_add(entry, "changed",
508 __pw_entry_changed_cb, ad);
509 evas_object_smart_callback_add(entry, "maxlength,reached",
510 __pw_entry_maxlength_reached_cb, ad);
511 evas_object_smart_callback_add(entry, "activated",
512 __pw_entry_activated_cb, NULL);
513 evas_object_smart_callback_add(entry, "focused",
514 __pw_entry_focused_cb, NULL);
515 evas_object_smart_callback_add(entry, "unfocused",
516 __pw_entry_unfocused_cb, NULL);
517 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
518 __pw_entry_show_cb, NULL);
520 elm_object_focus_set(entry, EINA_TRUE);
521 elm_entry_input_panel_show(entry);
522 elm_object_part_content_set(parent, "elm.swallow.content", entry);
524 st->pw_entry = entry;
526 __MOBILE_AP_FUNC_EXIT__;
530 static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part)
532 __MOBILE_AP_FUNC_ENTER__;
538 ERR("data is null \n");
542 if (!strcmp(part, "elm.swallow.content")) {
543 Evas_Object *box = elm_box_add(obj);
544 Evas_Object *label = elm_label_add(box);
545 Evas_Object *layout = elm_layout_add(box);
546 char buf[MH_LABEL_LENGTH_MAX] = {0, };
548 elm_box_align_set(box, 0.0, 0.0);
550 /* Set label for name field */
551 snprintf(buf, MH_LABEL_LENGTH_MAX, "<text align=left><font_size=30>%s</font_size></text>", STR_PASSWORD);
552 elm_object_text_set(label, buf);
553 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
554 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
555 evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), 0, 0);
556 elm_box_pack_end(box, label);
557 evas_object_show(label);
559 /* Set layout for entry field */
560 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
561 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
562 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
564 __get_pw_entry(data, layout);
565 evas_object_show(layout);
566 elm_box_pack_end(box, layout);
568 evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
569 evas_object_show(box);
574 __MOBILE_AP_FUNC_EXIT__;
578 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
580 __MOBILE_AP_FUNC_ENTER__;
582 if (data == NULL || obj == NULL || event_info == NULL) {
583 ERR("param is NULL\n");
587 mh_appdata_t *ad = (mh_appdata_t *)data;
589 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
590 __hide_btn_changed_cb(ad, obj, NULL);
592 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility_new ?
593 EINA_FALSE : EINA_TRUE);
595 __MOBILE_AP_FUNC_EXIT__;
598 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
600 __MOBILE_AP_FUNC_ENTER__;
602 if (data == NULL || obj == NULL || event_info == NULL) {
603 ERR("param is NULL\n");
607 mh_appdata_t *ad = (mh_appdata_t *)data;
609 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
610 __security_btn_changed_cb(data, obj, NULL);
611 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type_new ==
612 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
614 __MOBILE_AP_FUNC_EXIT__;
617 static void __set_genlist_itc(mh_appdata_t *ad)
619 __MOBILE_AP_FUNC_ENTER__;
621 ad->setup.name_itc = elm_genlist_item_class_new();
622 if (ad->setup.name_itc == NULL) {
623 ERR("elm_genlist_item_class_new failed\n");
624 __MOBILE_AP_FUNC_EXIT__;
627 ad->setup.name_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
628 ad->setup.name_itc->func.text_get = __gl_device_name_title_label_get;
629 ad->setup.name_itc->func.content_get = NULL;
630 ad->setup.name_itc->func.state_get = NULL;
631 ad->setup.name_itc->func.del = NULL;
633 ad->setup.hide_itc = elm_genlist_item_class_new();
634 if (ad->setup.hide_itc == NULL) {
635 ERR("elm_genlist_item_class_new failed\n");
636 __MOBILE_AP_FUNC_EXIT__;
639 ad->setup.hide_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
640 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
641 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
642 ad->setup.hide_itc->func.state_get = NULL;
643 ad->setup.hide_itc->func.del = NULL;
645 ad->setup.security_itc = elm_genlist_item_class_new();
646 if (ad->setup.security_itc == NULL) {
647 ERR("elm_genlist_item_class_new failed\n");
648 __MOBILE_AP_FUNC_EXIT__;
651 ad->setup.security_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
652 ad->setup.security_itc->func.text_get = __gl_security_label_get;
653 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
654 ad->setup.security_itc->func.state_get = NULL;
655 ad->setup.security_itc->func.del = NULL;
657 ad->setup.pw_itc = elm_genlist_item_class_new();
658 if (ad->setup.pw_itc == NULL) {
659 ERR("elm_genlist_item_class_new failed\n");
660 __MOBILE_AP_FUNC_EXIT__;
663 ad->setup.pw_itc->item_style = MH_GENLIST_FULL_CONTENT_STYLE;
664 ad->setup.pw_itc->func.text_get = NULL;
665 ad->setup.pw_itc->func.content_get = __gl_pw_content_get;
666 ad->setup.pw_itc->func.state_get = NULL;
667 ad->setup.pw_itc->func.del = NULL;
669 __MOBILE_AP_FUNC_EXIT__;
673 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
675 __MOBILE_AP_FUNC_ENTER__;
682 evas_object_smart_callback_del(st->hide_btn, "changed",
683 __hide_btn_changed_cb);
684 evas_object_smart_callback_del(st->security_btn, "changed",
685 __security_btn_changed_cb);
686 evas_object_smart_callback_del(st->cancel_button, "clicked",
688 evas_object_smart_callback_del(st->save_button, "clicked",
690 evas_object_smart_callback_del(st->genlist, "realized",
693 __MOBILE_AP_FUNC_EXIT__;
696 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
698 if (user_data == NULL) {
699 ERR("Invalid parameter\n");
703 __MOBILE_AP_FUNC_ENTER__;
705 mh_appdata_t *ad = (mh_appdata_t *)user_data;
707 if (result != TETHERING_ERROR_NONE)
708 ERR("tethering_wifi_reload_settings is failed [0x%X]\n", result);
709 _update_wifi_item(ad, MH_STATE_NONE);
711 __MOBILE_AP_FUNC_EXIT__;
716 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info)
720 ERR("data is NULL\n");
724 mh_appdata_t *ad = (mh_appdata_t *)data;
725 mh_wifi_setting_view_t *st = &ad->setup;
727 bool is_setting_changed = false;
729 /* handle hide button change */
730 if (st->visibility != st->visibility_new) {
731 ret = __save_hide_btn_change(ad);
733 elm_check_state_set(st->hide_btn, st->visibility ?
734 EINA_FALSE : EINA_TRUE);
736 st->visibility = st->visibility_new;
737 is_setting_changed = true;
740 /* handle security button change */
741 if (st->security_type != st->security_type_new) {
742 ret = __save_security_btn_change(ad);
744 elm_check_state_set(st->security_btn, st->security_type ==
745 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
747 st->security_type = st->security_type_new;
748 is_setting_changed = true;
752 /* handle wifi passphrase change */
753 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
754 ret = __save_wifi_passphrase(ad);
756 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
757 sizeof(st->wifi_passphrase_new));
759 elm_genlist_item_update(st->pw_item);
761 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
762 sizeof(st->wifi_passphrase));
763 is_setting_changed = true;
764 if (ad->main.help_item) {
765 if (ad->main.help_item)
766 elm_genlist_item_update(ad->main.help_item);
771 if (is_setting_changed) {
772 _update_wifi_item(ad, MH_STATE_PROCESS);
774 if (ad->main.help_item)
775 elm_genlist_item_update(ad->main.help_item);
777 /* reload wifi settings */
778 ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb,
780 if (ret != TETHERING_ERROR_NONE)
781 ERR("reload_configuration is failed : %d\n", ret);
784 elm_naviframe_item_pop(ad->naviframe);
790 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info)
795 ERR("The param is NULL\n");
799 mh_appdata_t *ad = (mh_appdata_t *)data;
801 elm_naviframe_item_pop(ad->naviframe);
806 Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item)
811 ERR("The param is NULL\n");
815 mh_appdata_t *ad = (mh_appdata_t *)data;
816 mh_wifi_setting_view_t *st = &ad->setup;
818 if (st->visibility != st->visibility_new)
819 st->visibility_new = st->visibility;
821 if (st->security_type != st->security_type_new)
822 st->security_type_new = st->security_type;
824 if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) {
825 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
826 sizeof(st->wifi_passphrase_new));
829 __deconstruct_wifi_setup_view(st);
831 if (ad->rename_popup != NULL) {
832 evas_object_del(ad->rename_popup);
833 ad->rename_popup = NULL;
835 ad->setup.navi_it = NULL;
841 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
843 __MOBILE_AP_FUNC_ENTER__;
845 mh_appdata_t *ad = (mh_appdata_t *)data;
846 mh_wifi_setting_view_t *st = &(ad->setup);
847 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
850 char str[MH_LABEL_LENGTH_MAX] = {0, };
854 if (item == st->hide_item)
855 elm_object_item_signal_emit(item, "elm,state,top", "");
856 else if (item == st->security_item)
857 elm_object_item_signal_emit(item, "elm,state,center", "");
858 else if (item == st->pw_item)
859 elm_object_item_signal_emit(item, "elm,state,bottom", "");
861 no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]);
862 for (i = 0; i < no_of_sp; i++) {
863 if (item == st->sp_item[i])
864 elm_object_item_access_unregister(item);
867 if (item == st->hide_item || item == st->security_item) {
868 ao = elm_object_item_access_object_get(item);
869 btn = elm_object_item_part_content_get(item, "on&off");
870 snprintf(str, sizeof(str), "%s, %s", "On/off button",
871 (elm_check_state_get(btn) ? "On" : "Off"));
872 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
875 if (item == st->pw_item) {
876 elm_object_item_access_unregister(item);
877 ao = elm_object_item_access_register(item);
878 snprintf(str, sizeof(str), "%s, %s", STR_PASSWORD, st->wifi_passphrase_new);
879 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
882 __MOBILE_AP_FUNC_EXIT__;
887 static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_info)
889 __MOBILE_AP_FUNC_ENTER__;
892 ERR("The param is NULL\n");
896 mh_appdata_t *ad = (mh_appdata_t *)data;
897 mh_wifi_setting_view_t *st = &ad->setup;
899 elm_object_focus_set(st->pw_entry, EINA_TRUE);
901 __MOBILE_AP_FUNC_EXIT__;
905 Evas_Object *__create_genlist(mh_appdata_t *ad)
907 __MOBILE_AP_FUNC_ENTER__;
914 void *data = (void *)ad;
915 mh_wifi_setting_view_t *st = &ad->setup;
916 Evas_Object *genlist;
918 genlist = elm_genlist_add(ad->naviframe);
919 if (genlist == NULL) {
920 ERR("genlist is NULL\n");
924 elm_object_style_set(genlist, "dialogue");
925 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
926 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
928 __set_genlist_itc(ad);
930 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
931 ELM_GENLIST_ITEM_NONE, NULL, NULL);
932 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
935 elm_object_item_disabled_set(st->name_item, EINA_TRUE);
937 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
938 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
940 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
941 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
943 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
944 ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad);
945 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
946 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
948 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
950 /* End separator is removed because of P131104-03336. It is confirmed by UX team for this case.
951 item = elm_genlist_item_append(genlist, st->sp_itc, NULL, NULL,
952 ELM_GENLIST_ITEM_NONE, NULL, NULL);
953 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
954 st->sp_item[i++] = item;
957 __MOBILE_AP_FUNC_EXIT__;
962 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
972 mh_wifi_setting_view_t *st = &ad->setup;
974 if (ad->setup.navi_it != NULL) {
975 ERR("Wi-Fi setup view already exists\n");
980 st->genlist = __create_genlist(ad);
981 if (st->genlist == NULL) {
982 ERR("__create_genlist returns NULL\n");
987 st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_MBODY_WI_FI_TETHERING",
988 NULL, NULL, st->genlist, NULL);
989 elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);
991 elm_naviframe_item_pop_cb_set(st->navi_it, _setting_back_btn_cb, (void *)ad);
993 btn = elm_button_add(ad->naviframe);
994 elm_object_style_set(btn, "naviframe/title_cancel");
995 evas_object_smart_callback_add(btn, "clicked", __cancel_btn_cb, ad);
996 elm_object_item_part_content_set(st->navi_it, "title_left_btn", btn);
997 st->cancel_button = btn;
999 btn = elm_button_add(ad->naviframe);
1000 elm_object_style_set(btn, "naviframe/title_done");
1001 evas_object_smart_callback_add(btn, "clicked", __save_btn_cb, ad);
1002 elm_object_item_part_content_set(st->navi_it, "title_right_btn", btn);
1003 st->save_button = btn;