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");
141 ptr = elm_entry_utf8_to_markup(device_name_utf);
143 ERR("elm_entry_utf8_to_markup is failed\n");
144 free(device_name_utf);
148 g_strlcpy(ad->setup.device_name, ptr,
149 sizeof(ad->setup.device_name));
151 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size><br>%s", STR_MY_DEVICE_NAME, ptr);
153 free(device_name_utf);
159 __MOBILE_AP_FUNC_EXIT__;
163 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
165 __MOBILE_AP_FUNC_ENTER__;
167 if (data == NULL || obj == NULL || part == NULL) {
168 ERR("Invalid param\n");
172 if (!strcmp("elm.text", part)) {
173 return strdup(STR_HIDE_MY_DEV);
176 __MOBILE_AP_FUNC_EXIT__;
180 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
182 __MOBILE_AP_FUNC_ENTER__;
184 if (data == NULL || obj == NULL || part == NULL) {
185 ERR("Invalid param\n");
189 if (!strcmp("elm.text", part)) {
190 return strdup(STR_SECURITY_TYPE);
193 __MOBILE_AP_FUNC_EXIT__;
197 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
200 __MOBILE_AP_FUNC_ENTER__;
202 mh_appdata_t *ad = (mh_appdata_t *)data;
203 Evas_Object *btn = NULL;
205 if (data == NULL || obj == NULL || part == NULL) {
206 ERR("Invalid param\n");
210 if (!strcmp("elm.swallow.end", part)) {
211 btn = elm_check_add(obj);
213 ERR("btn is NULL\n");
217 elm_object_style_set(btn, "on&off");
218 evas_object_show(btn);
219 evas_object_pass_events_set(btn, EINA_TRUE);
220 evas_object_propagate_events_set(btn, EINA_FALSE);
221 elm_object_focus_allow_set(btn, EINA_FALSE);
222 elm_check_state_set(btn, ad->setup.visibility_new ? EINA_FALSE : EINA_TRUE);
223 evas_object_smart_callback_add(btn, "changed",
224 __hide_btn_changed_cb, (void *)ad);
225 ad->setup.hide_btn = btn;
228 __MOBILE_AP_FUNC_EXIT__;
232 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
235 __MOBILE_AP_FUNC_ENTER__;
237 mh_appdata_t *ad = (mh_appdata_t *)data;
238 Evas_Object *btn = NULL;
240 if (data == NULL || obj == NULL || part == NULL) {
241 ERR("Invalid param\n");
245 if (!strcmp("elm.swallow.end", part)) {
246 btn = elm_check_add(obj);
247 elm_object_style_set(btn, "on&off");
248 evas_object_show(btn);
249 evas_object_pass_events_set(btn, EINA_TRUE);
250 evas_object_propagate_events_set(btn, EINA_FALSE);
251 elm_check_state_set(btn, ad->setup.security_type_new ==
252 TETHERING_WIFI_SECURITY_TYPE_NONE ?
253 EINA_FALSE : EINA_TRUE);
254 evas_object_smart_callback_add(btn, "changed",
255 __security_btn_changed_cb, (void *)ad);
256 ad->setup.security_btn = btn;
259 __MOBILE_AP_FUNC_EXIT__;
263 static bool __save_wifi_passphrase(mh_appdata_t *ad)
265 __MOBILE_AP_FUNC_ENTER__;
268 ERR("Invalid param\n");
272 mh_wifi_setting_view_t *st = &ad->setup;
275 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
276 if (ret != TETHERING_ERROR_NONE) {
277 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
281 __MOBILE_AP_FUNC_EXIT__;
285 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
288 __MOBILE_AP_FUNC_ENTER__;
290 mh_appdata_t *ad = (mh_appdata_t *)data;
291 mh_wifi_setting_view_t *st = &ad->setup;
292 const char *changed_text;
296 changed_text = elm_entry_entry_get(obj);
297 if (changed_text == NULL) {
298 ERR("elm_entry_entry_get is failed\n");
302 utf8_string = elm_entry_markup_to_utf8(changed_text);
304 if (utf8_string == NULL) {
305 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
307 len = strlen(utf8_string);
308 if (WIFI_PASSPHRASE_LENGTH_MIN <= len) {
309 elm_object_disabled_set(st->save_button, EINA_FALSE);
310 elm_entry_input_panel_return_key_disabled_set(obj, FALSE);
312 elm_object_disabled_set(st->save_button, EINA_TRUE);
313 elm_entry_input_panel_return_key_disabled_set(obj, TRUE);
315 g_strlcpy(st->wifi_passphrase_new, utf8_string,
316 sizeof(st->wifi_passphrase_new));
321 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
322 if (elm_object_focus_get(obj)) {
323 if (elm_entry_is_empty(obj))
324 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
326 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
330 __MOBILE_AP_FUNC_EXIT__;
334 static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj,
337 __MOBILE_AP_FUNC_ENTER__;
340 ERR("The param is NULL\n");
341 __MOBILE_AP_FUNC_EXIT__;
344 char buf[MH_LABEL_LENGTH_MAX] = { 0, };
345 notification_error_e ret;
347 snprintf(buf, sizeof(buf), STR_PASSWORD_MIN_MAX,
348 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
350 ret = notification_status_message_post(buf);
351 if (ret != NOTIFICATION_ERROR_NONE) {
352 ERR("notification_status_message_post() is failed : %d\n", ret);
355 __MOBILE_AP_FUNC_EXIT__;
358 static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
360 __MOBILE_AP_FUNC_ENTER__;
363 ERR("Invalid parameter");
367 elm_object_focus_set(obj, EINA_FALSE);
368 __MOBILE_AP_FUNC_EXIT__;
372 static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
374 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
375 if (!elm_entry_is_empty(obj))
376 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
378 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
380 elm_object_signal_emit(obj, "elm,state,focus,on", "");
383 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
385 if (elm_object_part_content_get(obj, "elm.swallow.clear"))
386 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
387 elm_object_signal_emit(obj, "elm,state,focus,off", "");
390 static void __eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
392 __MOBILE_AP_FUNC_ENTER__;
394 elm_entry_entry_set(data, "");
395 elm_entry_input_panel_return_key_disabled_set(data, TRUE);
397 __MOBILE_AP_FUNC_EXIT__;
400 static void __pw_entry_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
402 __MOBILE_AP_FUNC_ENTER__;
404 if (obj == NULL || data == NULL) {
408 mh_appdata_t *ad = (mh_appdata_t *)data;
409 mh_wifi_setting_view_t *st = &ad->setup;
410 char buf[MH_LABEL_LENGTH_MAX];
412 snprintf(buf, sizeof(buf), STR_PW_GUIDE_TEXT, WIFI_PASSPHRASE_LENGTH_MIN);
414 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
416 elm_genlist_item_update(st->pw_item);
418 elm_object_part_text_set(obj, "elm.guide", buf);
420 __MOBILE_AP_FUNC_EXIT__;
423 static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent)
425 __MOBILE_AP_FUNC_ENTER__;
427 static Elm_Entry_Filter_Limit_Size limit_filter_data;
428 Evas_Object *entry = NULL;
430 Evas_Object * clr_btn = NULL;
431 char buf[MH_LABEL_LENGTH_MAX];
433 if (parent == NULL || data == NULL) {
434 ERR("null param \n");
438 mh_appdata_t *ad = (mh_appdata_t *)data;
439 mh_wifi_setting_view_t *st = &ad->setup;
441 entry = elm_entry_add(parent);
444 ERR("elm_entry_add returns NULL\n");
449 elm_entry_single_line_set(entry, EINA_TRUE);
450 elm_entry_scrollable_set(entry, EINA_TRUE);
451 elm_entry_password_set(entry, EINA_FALSE);
453 st->pw_entry = entry;
454 evas_object_smart_callback_add(entry, "language,changed",
455 __pw_entry_language_changed_cb, ad);
457 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
458 elm_entry_prediction_allow_set(entry, EINA_FALSE);
459 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
460 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
461 elm_entry_cursor_end_set(entry);
462 snprintf(buf, sizeof(buf), STR_PW_GUIDE_TEXT, WIFI_PASSPHRASE_LENGTH_MIN);
463 elm_object_part_text_set(entry, "elm.guide", buf);
464 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
466 limit_filter_data.max_char_count = 0;
467 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
468 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
470 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
471 elm_object_part_text_set(entry, "default", buf);
472 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
473 elm_object_disabled_set(entry, EINA_TRUE);
475 elm_object_item_signal_emit(st->pw_item, "elm,state,rename,hide", "");
478 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
480 elm_entry_entry_set(entry, ptr);
483 ERR("elm_entry_utf8_to_markup is failed\n");
487 elm_entry_input_panel_return_key_type_set(st->pw_entry,
488 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
490 clr_btn = elm_button_add(entry);
491 elm_object_style_set(clr_btn, "search_clear");
492 elm_object_focus_allow_set(clr_btn, EINA_FALSE);
493 elm_object_part_content_set(entry, "elm.swallow.clear", clr_btn);
494 evas_object_smart_callback_add(clr_btn, "clicked", __eraser_btn_clicked_cb, entry);
495 evas_object_show(clr_btn);
497 evas_object_smart_callback_add(entry, "changed",
498 __pw_entry_changed_cb, ad);
499 evas_object_smart_callback_add(entry, "maxlength,reached",
500 __pw_entry_maxlength_reached_cb, ad);
501 evas_object_smart_callback_add(entry, "activated",
502 __pw_entry_activated_cb, NULL);
503 evas_object_smart_callback_add(entry, "focused",
504 __pw_entry_focused_cb, NULL);
505 evas_object_smart_callback_add(entry, "unfocused",
506 __pw_entry_unfocused_cb, NULL);
508 elm_object_part_content_set(parent, "elm.swallow.content", entry);
510 __MOBILE_AP_FUNC_EXIT__;
514 static char *__gl_pw_text_get(void *data, Evas_Object *obj, const char *part)
516 __MOBILE_AP_FUNC_ENTER__;
517 char buf[MH_LABEL_LENGTH_MAX] = {0, };
519 if (data == NULL || obj == NULL || part == NULL) {
520 ERR("Invalid param\n");
524 if (!strcmp("elm.text.main", part)) {
525 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size>", STR_PASSWORD);
529 __MOBILE_AP_FUNC_EXIT__;
533 static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part)
535 __MOBILE_AP_FUNC_ENTER__;
537 Evas_Object * layout = NULL;
540 ERR("data is null \n");
544 if (!strcmp(part, "elm.icon.entry")) {
545 layout = elm_layout_add(obj);
546 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
547 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
548 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
551 __MOBILE_AP_FUNC_EXIT__;
555 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
557 __MOBILE_AP_FUNC_ENTER__;
559 if (data == NULL || obj == NULL || event_info == NULL) {
560 ERR("param is NULL\n");
564 mh_appdata_t *ad = (mh_appdata_t *)data;
566 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
567 __hide_btn_changed_cb(ad, obj, NULL);
569 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility_new ?
570 EINA_FALSE : EINA_TRUE);
572 __MOBILE_AP_FUNC_EXIT__;
575 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
577 __MOBILE_AP_FUNC_ENTER__;
579 if (data == NULL || obj == NULL || event_info == NULL) {
580 ERR("param is NULL\n");
584 mh_appdata_t *ad = (mh_appdata_t *)data;
586 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
587 __security_btn_changed_cb(data, obj, NULL);
588 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type_new ==
589 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
591 __MOBILE_AP_FUNC_EXIT__;
594 static void __set_genlist_itc(mh_appdata_t *ad)
596 __MOBILE_AP_FUNC_ENTER__;
599 ad->setup.sp_itc = elm_genlist_item_class_new();
600 if (ad->setup.sp_itc == NULL) {
601 ERR("elm_genlist_item_class_new failed\n");
602 __MOBILE_AP_FUNC_EXIT__;
605 ad->setup.sp_itc->item_style = "dialogue/separator";
606 ad->setup.sp_itc->func.text_get = NULL;
607 ad->setup.sp_itc->func.content_get = NULL;
608 ad->setup.sp_itc->func.state_get = NULL;
609 ad->setup.sp_itc->func.del = NULL;
611 ad->setup.name_itc = elm_genlist_item_class_new();
612 if (ad->setup.name_itc == NULL) {
613 ERR("elm_genlist_item_class_new failed\n");
614 __MOBILE_AP_FUNC_EXIT__;
617 ad->setup.name_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
618 ad->setup.name_itc->func.text_get = __gl_device_name_title_label_get;
619 ad->setup.name_itc->func.content_get = NULL;
620 ad->setup.name_itc->func.state_get = NULL;
621 ad->setup.name_itc->func.del = NULL;
623 ad->setup.hide_itc = elm_genlist_item_class_new();
624 if (ad->setup.hide_itc == NULL) {
625 ERR("elm_genlist_item_class_new failed\n");
626 __MOBILE_AP_FUNC_EXIT__;
629 ad->setup.hide_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
630 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
631 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
632 ad->setup.hide_itc->func.state_get = NULL;
633 ad->setup.hide_itc->func.del = NULL;
635 ad->setup.security_itc = elm_genlist_item_class_new();
636 if (ad->setup.security_itc == NULL) {
637 ERR("elm_genlist_item_class_new failed\n");
638 __MOBILE_AP_FUNC_EXIT__;
641 ad->setup.security_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
642 ad->setup.security_itc->func.text_get = __gl_security_label_get;
643 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
644 ad->setup.security_itc->func.state_get = NULL;
645 ad->setup.security_itc->func.del = NULL;
647 ad->setup.pw_itc = elm_genlist_item_class_new();
648 if (ad->setup.pw_itc == NULL) {
649 ERR("elm_genlist_item_class_new failed\n");
650 __MOBILE_AP_FUNC_EXIT__;
653 ad->setup.pw_itc->item_style = "entry.main";
654 ad->setup.pw_itc->func.text_get = __gl_pw_text_get;
655 ad->setup.pw_itc->func.content_get = __gl_pw_content_get;
656 ad->setup.pw_itc->func.state_get = NULL;
657 ad->setup.pw_itc->func.del = NULL;
660 ad->setup.sp2_itc = elm_genlist_item_class_new();
661 if (ad->setup.sp2_itc == NULL) {
662 ERR("elm_genlist_item_class_new failed\n");
663 __MOBILE_AP_FUNC_EXIT__;
666 ad->setup.sp2_itc->item_style = "dialogue/separator.2";
667 ad->setup.sp2_itc->func.text_get = NULL;
668 ad->setup.sp2_itc->func.content_get = NULL;
669 ad->setup.sp2_itc->func.state_get = NULL;
670 ad->setup.sp2_itc->func.del = NULL;
672 __MOBILE_AP_FUNC_EXIT__;
676 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
678 __MOBILE_AP_FUNC_ENTER__;
685 evas_object_smart_callback_del(st->hide_btn, "changed",
686 __hide_btn_changed_cb);
687 evas_object_smart_callback_del(st->security_btn, "changed",
688 __security_btn_changed_cb);
689 evas_object_smart_callback_del(st->cancel_button, "clicked",
691 evas_object_smart_callback_del(st->save_button, "clicked",
693 evas_object_smart_callback_del(st->genlist, "realized",
696 __MOBILE_AP_FUNC_EXIT__;
699 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
701 if (user_data == NULL) {
702 ERR("Invalid parameter\n");
706 __MOBILE_AP_FUNC_ENTER__;
708 mh_appdata_t *ad = (mh_appdata_t *)user_data;
710 if (result != TETHERING_ERROR_NONE)
711 ERR("tethering_wifi_reload_settings is failed [0x%X]\n", result);
712 _update_wifi_item(ad, MH_STATE_NONE);
714 __MOBILE_AP_FUNC_EXIT__;
719 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info)
723 ERR("data is NULL\n");
727 mh_appdata_t *ad = (mh_appdata_t *)data;
728 mh_wifi_setting_view_t *st = &ad->setup;
730 bool is_setting_changed = false;
732 /* handle hide button change */
733 if (st->visibility != st->visibility_new) {
734 ret = __save_hide_btn_change(ad);
736 elm_check_state_set(st->hide_btn, st->visibility ?
737 EINA_FALSE : EINA_TRUE);
739 st->visibility = st->visibility_new;
740 is_setting_changed = true;
743 /* handle security button change */
744 if (st->security_type != st->security_type_new) {
745 ret = __save_security_btn_change(ad);
747 elm_check_state_set(st->security_btn, st->security_type ==
748 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
750 st->security_type = st->security_type_new;
751 is_setting_changed = true;
755 /* handle wifi passphrase change */
756 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
757 ret = __save_wifi_passphrase(ad);
759 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
760 sizeof(st->wifi_passphrase_new));
762 elm_genlist_item_update(st->pw_item);
764 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
765 sizeof(st->wifi_passphrase));
766 is_setting_changed = true;
767 if (ad->main.help_item) {
768 if (ad->main.help_item)
769 elm_genlist_item_update(ad->main.help_item);
774 if (is_setting_changed) {
775 _update_wifi_item(ad, MH_STATE_PROCESS);
777 if (ad->main.help_item)
778 elm_genlist_item_update(ad->main.help_item);
780 /* reload wifi settings */
781 ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb,
783 if (ret != TETHERING_ERROR_NONE)
784 ERR("reload_configuration is failed : %d\n", ret);
787 elm_naviframe_item_pop(ad->naviframe);
793 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info)
798 ERR("The param is NULL\n");
802 mh_appdata_t *ad = (mh_appdata_t *)data;
804 elm_naviframe_item_pop(ad->naviframe);
809 Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item)
814 ERR("The param is NULL\n");
818 mh_appdata_t *ad = (mh_appdata_t *)data;
819 mh_wifi_setting_view_t *st = &ad->setup;
821 if (st->visibility != st->visibility_new) {
822 st->visibility_new = st->visibility;
825 if (st->security_type != st->security_type_new) {
826 st->security_type_new = st->security_type;
829 if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) {
830 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
831 sizeof(st->wifi_passphrase_new));
834 __deconstruct_wifi_setup_view(st);
836 if (ad->rename_popup != NULL) {
837 evas_object_del(ad->rename_popup);
838 ad->rename_popup = NULL;
840 ad->setup.navi_it = NULL;
846 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
848 __MOBILE_AP_FUNC_ENTER__;
850 mh_appdata_t *ad = (mh_appdata_t *)data;
851 mh_wifi_setting_view_t *st = &(ad->setup);
852 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
855 char str[MH_LABEL_LENGTH_MAX] = {0, };
859 if (item == st->hide_item) {
860 elm_object_item_signal_emit(item, "elm,state,top", "");
861 } else if (item == st->security_item) {
862 elm_object_item_signal_emit(item, "elm,state,center", "");
863 } else if (item == st->pw_item) {
864 elm_object_item_signal_emit(item, "elm,state,bottom", "");
865 } else if (item == st->name_item) {
868 no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]);
869 for (i = 0; i < no_of_sp; i++) {
870 if (item == st->sp_item[i])
871 elm_object_item_access_unregister(item);
874 if (item == st->hide_item || item == st->security_item) {
875 ao = elm_object_item_access_object_get(item);
876 btn = elm_object_item_part_content_get(item, "on&off");
877 snprintf(str, sizeof(str), "%s, %s", "On/off button",
878 (elm_check_state_get(btn) ? "On" : "Off"));
879 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
882 if (item == st->pw_item) {
883 elm_object_item_access_unregister(item);
884 ao = elm_object_item_access_register(item);
885 snprintf(str, sizeof(str), "%s, %s", STR_PASSWORD, st->wifi_passphrase_new);
886 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
889 __MOBILE_AP_FUNC_EXIT__;
894 static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_info)
896 __MOBILE_AP_FUNC_ENTER__;
899 ERR("The param is NULL\n");
903 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
904 Evas_Object *layout = NULL;
905 mh_appdata_t *ad = (mh_appdata_t *)data;
907 elm_genlist_item_selected_set(item, EINA_FALSE);
909 layout = elm_layout_add(obj);
910 elm_layout_file_set(layout, FILE_PATH_OF_EDC, "entry_style");
911 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
912 __get_pw_entry(ad, layout);
913 __MOBILE_AP_FUNC_EXIT__;
917 Evas_Object *__create_genlist(mh_appdata_t *ad)
919 __MOBILE_AP_FUNC_ENTER__;
926 void *data = (void *)ad;
927 mh_wifi_setting_view_t *st = &ad->setup;
928 Evas_Object *genlist;
930 genlist = elm_genlist_add(ad->naviframe);
931 if (genlist == NULL) {
932 ERR("genlist is NULL\n");
936 elm_object_style_set(genlist, "dialogue");
937 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
938 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
939 //elm_genlist_realization_mode_set(genlist, EINA_TRUE);
941 __set_genlist_itc(ad);
943 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
944 ELM_GENLIST_ITEM_NONE, NULL, NULL);
945 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
948 elm_object_item_disabled_set(st->name_item, EINA_TRUE);
950 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
951 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
953 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
954 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
956 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
957 ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad);
958 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
959 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
961 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
963 /* End separator is removed because of P131104-03336. It is confirmed by UX team for this case.
964 item = elm_genlist_item_append(genlist, st->sp_itc, NULL, NULL,
965 ELM_GENLIST_ITEM_NONE, NULL, NULL);
966 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
967 st->sp_item[i++] = item;
970 __MOBILE_AP_FUNC_EXIT__;
975 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
985 mh_wifi_setting_view_t *st = &ad->setup;
987 if (ad->setup.navi_it != NULL) {
988 ERR("Wi-Fi setup view already exists\n");
993 st->genlist = __create_genlist(ad);
994 if (st->genlist == NULL) {
995 ERR("__create_genlist returns NULL\n");
1000 st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_MBODY_WI_FI_TETHERING",
1001 NULL, NULL, st->genlist, NULL);
1002 elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);
1004 elm_naviframe_item_pop_cb_set(st->navi_it, _setting_back_btn_cb, (void *)ad);
1006 btn = elm_button_add(ad->naviframe);
1007 elm_object_style_set(btn, "naviframe/title_cancel");
1008 evas_object_smart_callback_add(btn, "clicked", __cancel_btn_cb, ad);
1009 elm_object_item_part_content_set(st->navi_it, "title_left_btn", btn);
1010 st->cancel_button = btn;
1012 btn = elm_button_add(ad->naviframe);
1013 elm_object_style_set(btn, "naviframe/title_done");
1014 evas_object_smart_callback_add(btn, "clicked", __save_btn_cb, ad);
1015 elm_object_item_part_content_set(st->navi_it, "title_right_btn", btn);
1016 st->save_button = btn;