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 <notification.h>
20 #include "mh_view_wifi_setup.h"
22 static void __back_btn_cb(void *data, Evas_Object *obj, void *event_info);
23 static void __gl_realized(void *data, Evas_Object *obj, void *event_info);
25 static void __input_panel_event_cb(void *data, Ecore_IMF_Context *ctx, int value)
28 ERR("data is NULL\n");
32 mh_appdata_t *ad = (mh_appdata_t *)data;
33 mh_wifi_setting_view_t *st = &ad->setup;
35 ad->imf_state = value;
37 if (st->navi_it == NULL) {
38 DBG("naviframe item is not pushed yet\n");
42 if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW &&
43 (ad->rotate_state == UG_EVENT_ROTATE_LANDSCAPE ||
44 ad->rotate_state == UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN)) {
45 DBG("ECORE_IMF_INPUT_PANEL_STATE_SHOW and Landscape mode\n");
46 elm_naviframe_item_title_visible_set(st->navi_it, EINA_FALSE);
47 } else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
48 DBG("ECORE_IMF_INPUT_PANEL_STATE_HIDE\n");
49 elm_naviframe_item_title_visible_set(st->navi_it, EINA_TRUE);
55 static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
57 __MOBILE_AP_FUNC_ENTER__;
59 if (data == NULL || obj == NULL) {
60 ERR("Invalid param\n");
64 mh_appdata_t *ad = (mh_appdata_t *)data;
67 ret = tethering_wifi_set_ssid_visibility(ad->handle,
68 !ad->setup.visibility);
69 if (ret != TETHERING_ERROR_NONE) {
70 ERR("tethering_wifi_set_ssid_visibility is failed : %d\n", ret);
74 ad->setup.visibility = !ad->setup.visibility;
76 __MOBILE_AP_FUNC_EXIT__;
79 static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
81 __MOBILE_AP_FUNC_ENTER__;
83 if (data == NULL || obj == NULL) {
84 ERR("Invalid param\n");
88 mh_appdata_t *ad = (mh_appdata_t *)data;
91 if (ad->setup.security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
92 ad->setup.security_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
94 ad->setup.security_type = TETHERING_WIFI_SECURITY_TYPE_NONE;
96 ret = tethering_wifi_set_security_type(ad->handle, ad->setup.security_type);
97 if (ret != TETHERING_ERROR_NONE) {
98 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
102 elm_genlist_item_update(ad->setup.pw_item);
104 __MOBILE_AP_FUNC_EXIT__;
107 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
109 __MOBILE_AP_FUNC_ENTER__;
111 if (data == NULL || obj == NULL || part == NULL) {
112 ERR("Invalid param\n");
116 if (strcmp(part, "elm.text") != 0) {
117 ERR("Invalid param\n");
121 __MOBILE_AP_FUNC_EXIT__;
122 return strdup(_("IDS_MOBILEAP_BODY_HIDE_MY_DEVICE"));
125 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
127 __MOBILE_AP_FUNC_ENTER__;
129 if (data == NULL || obj == NULL || part == NULL) {
130 ERR("Invalid param\n");
134 if (strcmp(part, "elm.text") != 0) {
135 ERR("Invalid param\n");
139 __MOBILE_AP_FUNC_EXIT__;
140 return strdup(_("IDS_MOBILEAP_BODY_SECURITY"));
143 static char *__gl_name_label_get(void *data, Evas_Object *obj, const char *part)
145 __MOBILE_AP_FUNC_ENTER__;
147 if (data == NULL || obj == NULL || part == NULL) {
148 ERR("Invalid param\n");
152 if (strcmp(part, "elm.text") != 0) {
153 ERR("Invalid param : %s\n", part);
157 mh_appdata_t *ad = (mh_appdata_t *)data;
158 char label[MH_LABEL_LENGTH_MAX] = {0, };
159 char name_change_label[MH_LABEL_LENGTH_MAX] = {0, };
160 char path[MH_LABEL_LENGTH_MAX] = {0, };
161 char *device_name = NULL;
163 DBG("Device name : %s\n", ad->setup.device_name);
165 device_name = elm_entry_utf8_to_markup(ad->setup.device_name);
166 if (device_name == NULL) {
167 ERR("elm_entry_utf8_to_markup is failed\n");
171 snprintf(path, sizeof(path), "%s > %s",
172 S_("IDS_COM_BODY_SETTINGS"),
173 _("IDS_ST_BODY_ABOUT_PHONE"));
174 snprintf(name_change_label, sizeof(name_change_label),
175 _("IDS_MOBILEAP_BODY_DEVICE_NAME_CAN_BE_CHANGED_IN_PS"),
177 snprintf(label, sizeof(label), "%s: %s<br>%s",
178 _("IDS_MOBILEAP_BODY_DEVICE_NAME"),
183 __MOBILE_AP_FUNC_EXIT__;
185 return strdup(label);
188 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
191 __MOBILE_AP_FUNC_ENTER__;
193 if (data == NULL || obj == NULL || part == NULL) {
194 ERR("Invalid param\n");
198 if (strcmp(part, "elm.icon") != 0) {
199 ERR("Invalid param\n");
203 mh_appdata_t *ad = (mh_appdata_t *)data;
204 Evas_Object *btn = NULL;
206 btn = elm_check_add(obj);
208 ERR("btn is NULL\n");
211 elm_object_style_set(btn, "on&off");
212 evas_object_show(btn);
213 evas_object_pass_events_set(btn, EINA_TRUE);
214 evas_object_propagate_events_set(btn, EINA_FALSE);
215 elm_check_state_set(btn, ad->setup.visibility ? EINA_FALSE : EINA_TRUE);
216 evas_object_smart_callback_add(btn, "changed",
217 __hide_btn_changed_cb, (void *)ad);
219 ad->setup.hide_btn = btn;
221 __MOBILE_AP_FUNC_EXIT__;
225 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
228 __MOBILE_AP_FUNC_ENTER__;
230 if (data == NULL || obj == NULL || part == NULL) {
231 ERR("Invalid param\n");
235 if (strcmp(part, "elm.icon") != 0) {
236 ERR("Invalid param\n");
240 mh_appdata_t *ad = (mh_appdata_t *)data;
241 Evas_Object *btn = NULL;
243 btn = elm_check_add(obj);
245 elm_object_style_set(btn, "on&off");
246 evas_object_show(btn);
247 evas_object_pass_events_set(btn, EINA_TRUE);
248 evas_object_propagate_events_set(btn, EINA_FALSE);
249 elm_check_state_set(btn, ad->setup.security_type ==
250 TETHERING_WIFI_SECURITY_TYPE_NONE ?
251 EINA_FALSE : EINA_TRUE);
252 evas_object_smart_callback_add(btn, "changed",
253 __security_btn_changed_cb, (void *)ad);
255 ad->setup.security_btn = btn;
257 __MOBILE_AP_FUNC_EXIT__;
261 static Eina_Bool __save_wifi_passphrase(mh_appdata_t *ad)
263 __MOBILE_AP_FUNC_ENTER__;
266 ERR("Invalid param\n");
270 mh_wifi_setting_view_t *st = &ad->setup;
273 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
274 if (ret != TETHERING_ERROR_NONE) {
275 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
279 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new, sizeof(st->wifi_passphrase));
281 __MOBILE_AP_FUNC_EXIT__;
286 static void __passphrase_maxlength_reached_cb(void *data, Evas_Object *obj,
289 __MOBILE_AP_FUNC_ENTER__;
291 if (data == NULL || obj == NULL) {
292 ERR("The param is NULL\n");
296 mh_appdata_t *ad = (mh_appdata_t *)data;
297 char buf[MH_LABEL_LENGTH_MAX] = {0, };
300 ecore_imf_input_panel_hide();
301 elm_object_focus_set(ad->setup.pw_entry, EINA_FALSE);
303 if (__save_wifi_passphrase(ad) == EINA_FALSE) {
304 ERR("__save_wifi_passphrase is failed\n");
307 snprintf(buf, sizeof(buf),
308 _("IDS_MOBILEAP_POP_PASSWORD_MUST_CONTAIN_AT_LEAST_PD_CHARACTERS_AND_NOT_EXCEED_PD_CHARACTERS"),
309 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
311 ret = notification_status_message_post(buf);
312 if (ret != NOTIFICATION_ERROR_NONE)
313 ERR("notification_status_message_post() is failed : %d\n", ret);
315 __MOBILE_AP_FUNC_EXIT__;
318 static void __passphrase_activated_cb(void *data, Evas_Object *obj,
321 __MOBILE_AP_FUNC_ENTER__;
323 if (data == NULL || obj == NULL) {
324 ERR("Invalid param\n");
328 mh_appdata_t *ad = (mh_appdata_t *)data;
332 ecore_imf_input_panel_hide();
333 elm_object_focus_set(ad->setup.pw_entry, EINA_FALSE);
335 if (strlen(ad->setup.wifi_passphrase_new) < WIFI_PASSPHRASE_LENGTH_MIN) {
336 DBG("Password is shorter than %d\n", WIFI_PASSPHRASE_LENGTH_MIN);
337 ret = notification_status_message_post(_("IDS_ST_BODY_ENTER_PASSWORD_OF_AT_LEAST_8_CHARACTERS"));
338 if (ret != NOTIFICATION_ERROR_NONE)
339 ERR("notification_status_message_post() is failed : %d\n", ret);
341 ptr = elm_entry_utf8_to_markup(ad->setup.wifi_passphrase);
343 elm_entry_entry_set(ad->setup.pw_entry, ptr);
346 ERR("elm_entry_utf8_to_markup is failed\n");
352 if (__save_wifi_passphrase(ad) == EINA_FALSE) {
353 ERR("__save_wifi_passphrase is failed\n");
356 __MOBILE_AP_FUNC_EXIT__;
361 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
364 __MOBILE_AP_FUNC_ENTER__;
366 if (data == NULL || obj == NULL) {
367 ERR("Invalid param\n");
371 mh_appdata_t *ad = (mh_appdata_t *)data;
372 mh_wifi_setting_view_t *st = &ad->setup;
373 const char *changed_text;
376 changed_text = elm_entry_entry_get(st->pw_entry);
377 if (changed_text == NULL) {
378 ERR("elm_entry_entry_get is failed\n");
382 utf8_string = elm_entry_markup_to_utf8(changed_text);
383 if (utf8_string == NULL) {
384 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
386 g_strlcpy(st->wifi_passphrase_new, utf8_string,
387 sizeof(st->wifi_passphrase_new));
391 if (!elm_object_focus_get(st->pw_entry)) {
395 if (elm_entry_is_empty(st->pw_entry)) {
396 elm_object_item_signal_emit(st->pw_item,
397 "elm,state,eraser,hide", "");
399 elm_object_item_signal_emit(st->pw_item,
400 "elm,state,eraser,show", "");
403 __MOBILE_AP_FUNC_EXIT__;
409 static void __pw_entry_focused_cb(void *data, Evas_Object *obj,
412 __MOBILE_AP_FUNC_ENTER__;
414 if (data == NULL || obj == NULL) {
415 ERR("Invalid param\n");
419 mh_appdata_t *ad = (mh_appdata_t *)data;
420 mh_wifi_setting_view_t *st = &ad->setup;
422 if (!elm_entry_is_empty(st->pw_entry)) {
423 elm_entry_cursor_end_set(st->pw_entry);
424 elm_object_item_signal_emit(st->pw_item,
425 "elm,state,eraser,show", "");
428 __MOBILE_AP_FUNC_EXIT__;
434 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj,
437 __MOBILE_AP_FUNC_ENTER__;
439 if (data == NULL || obj == NULL) {
440 ERR("Invalid param\n");
444 mh_appdata_t *ad = (mh_appdata_t *)data;
445 mh_wifi_setting_view_t *st = &ad->setup;
447 elm_object_item_signal_emit(st->pw_item,
448 "elm,state,eraser,hide", "");
450 __MOBILE_AP_FUNC_EXIT__;
456 static void __pw_layout_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
458 __MOBILE_AP_FUNC_ENTER__;
460 if (data == NULL || obj == NULL) {
461 ERR("Invalid param\n");
465 mh_appdata_t *ad = (mh_appdata_t *)data;
466 mh_wifi_setting_view_t *st = &ad->setup;
468 elm_entry_entry_set(st->pw_entry, "");
470 __MOBILE_AP_FUNC_EXIT__;
476 static char *__gl_pw_text_get(void *data, Evas_Object *obj, const char *part)
478 __MOBILE_AP_FUNC_ENTER__;
480 if (data == NULL || obj == NULL || part == NULL) {
481 ERR("Invalid parameter\n");
485 if (g_strcmp0(part, "elm.text") != 0) {
486 ERR("Invalid part : %s\n", part);
490 __MOBILE_AP_FUNC_EXIT__;
491 return strdup(_("IDS_MOBILEAP_BODY_PASSWORD"));
494 static Evas_Object *__gl_pw_icon_get(void *data, Evas_Object *obj,
497 __MOBILE_AP_FUNC_ENTER__;
499 if (data == NULL || obj == NULL || part == NULL) {
500 ERR("Invalid param\n");
504 if (g_strcmp0(part, "elm.icon.entry") == 0) {
505 static Elm_Entry_Filter_Limit_Size limit_filter_data;
507 mh_appdata_t *ad = (mh_appdata_t *)data;
508 mh_wifi_setting_view_t *st = &ad->setup;
509 Evas_Object *entry = NULL;
511 Ecore_IMF_Context *imf_context;
513 entry = elm_entry_add(obj);
515 ERR("elm_entry_add returns NULL\n");
520 /* Set single line of entry */
521 elm_entry_scrollable_set(entry, EINA_TRUE);
522 elm_entry_single_line_set(entry, EINA_TRUE);
523 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
524 elm_entry_select_allow_set(entry, EINA_FALSE);
525 elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
527 /* Set the maximum length filter for passphrase entry */
528 limit_filter_data.max_char_count = 0;
529 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
530 elm_entry_markup_filter_append(entry,
531 elm_entry_filter_limit_size, &limit_filter_data);
533 DBG("security_type : %d\n", st->security_type);
534 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE) {
535 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase);
537 elm_entry_entry_set(entry, ptr);
540 ERR("elm_entry_utf8_to_markup is failed\n");
543 /* Set editable mode */
544 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
545 elm_object_disabled_set(entry, EINA_TRUE);
547 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
549 elm_entry_entry_set(entry, ptr);
552 ERR("elm_entry_utf8_to_markup is failed\n");
556 evas_object_smart_callback_add(entry, "maxlength,reached",
557 __passphrase_maxlength_reached_cb, data);
558 evas_object_smart_callback_add(entry, "activated",
559 __passphrase_activated_cb, data);
560 evas_object_smart_callback_add(entry, "changed",
561 __pw_entry_changed_cb, data);
562 evas_object_smart_callback_add(entry, "focused",
563 __pw_entry_focused_cb, data);
564 evas_object_smart_callback_add(entry, "unfocused",
565 __pw_entry_unfocused_cb, data);
567 imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(entry);
568 if (imf_context == NULL) {
569 ERR("elm_entry_imf_context_get() is failed\n");
571 ecore_imf_context_input_panel_event_callback_add(imf_context,
572 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
573 __input_panel_event_cb, (void *)ad);
576 elm_object_item_signal_emit(st->pw_item,
577 "elm,state,rename,hide", "");
578 if (!elm_entry_is_empty(entry)) {
579 elm_object_item_signal_emit(st->pw_item,
580 "elm,state,eraser,hide", "");
583 elm_object_part_text_set(entry, "elm.guide",
584 S_("IDS_COM_BODY_ENTER_PASSWORD"));
586 evas_object_show(entry);
587 st->pw_entry = entry;
589 __MOBILE_AP_FUNC_EXIT__;
591 } else if (g_strcmp0(part, "elm.icon.eraser") == 0) {
592 Evas_Object *btn = elm_button_add(obj);
593 elm_object_style_set(btn, "editfield_clear");
594 evas_object_smart_callback_add(btn, "clicked", __pw_layout_eraser_clicked_cb, data);
597 DBG("Unknown part : %s\n", part);
603 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
605 __MOBILE_AP_FUNC_ENTER__;
607 if (data == NULL || obj == NULL || event_info == NULL) {
608 ERR("param is NULL\n");
612 mh_appdata_t *ad = (mh_appdata_t *)data;
614 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
616 __hide_btn_changed_cb(data, obj, NULL);
617 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility ?
618 EINA_FALSE : EINA_TRUE);
620 __MOBILE_AP_FUNC_EXIT__;
623 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
625 __MOBILE_AP_FUNC_ENTER__;
627 if (data == NULL || obj == NULL || event_info == NULL) {
628 ERR("param is NULL\n");
632 mh_appdata_t *ad = (mh_appdata_t *)data;
634 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
636 __security_btn_changed_cb(data, obj, NULL);
637 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type ==
638 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
640 __MOBILE_AP_FUNC_EXIT__;
643 static void __free_genlist_itc(mh_appdata_t *ad)
645 __MOBILE_AP_FUNC_ENTER__;
647 elm_genlist_item_class_free(ad->setup.sp_itc);
648 elm_genlist_item_class_free(ad->setup.hide_itc);
649 elm_genlist_item_class_free(ad->setup.security_itc);
650 elm_genlist_item_class_free(ad->setup.pw_itc);
651 elm_genlist_item_class_free(ad->setup.name_itc);
653 __MOBILE_AP_FUNC_EXIT__;
657 static void __set_genlist_itc(mh_appdata_t *ad)
659 __MOBILE_AP_FUNC_ENTER__;
661 ad->setup.sp_itc = elm_genlist_item_class_new();
662 ad->setup.sp_itc->item_style = "dialogue/separator";
663 ad->setup.sp_itc->func.text_get = NULL;
664 ad->setup.sp_itc->func.content_get = NULL;
665 ad->setup.sp_itc->func.state_get = NULL;
666 ad->setup.sp_itc->func.del = NULL;
668 ad->setup.hide_itc = elm_genlist_item_class_new();
669 ad->setup.hide_itc->item_style = "dialogue/1text.1icon";
670 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
671 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
672 ad->setup.hide_itc->func.state_get = NULL;
673 ad->setup.hide_itc->func.del = NULL;
675 ad->setup.security_itc = elm_genlist_item_class_new();
676 ad->setup.security_itc->item_style = "dialogue/1text.1icon";
677 ad->setup.security_itc->func.text_get = __gl_security_label_get;
678 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
679 ad->setup.security_itc->func.state_get = NULL;
680 ad->setup.security_itc->func.del = NULL;
682 ad->setup.pw_itc = elm_genlist_item_class_new();
683 ad->setup.pw_itc->item_style = "dialogue/editfield/title";
684 ad->setup.pw_itc->func.text_get = __gl_pw_text_get;
685 ad->setup.pw_itc->func.content_get = __gl_pw_icon_get;
686 ad->setup.pw_itc->func.state_get = NULL;
687 ad->setup.pw_itc->func.del = NULL;
689 ad->setup.name_itc = elm_genlist_item_class_new();
690 ad->setup.name_itc->item_style = "multiline/1text";
691 ad->setup.name_itc->func.text_get = __gl_name_label_get;
692 ad->setup.name_itc->func.content_get = NULL;
693 ad->setup.name_itc->func.state_get = NULL;
694 ad->setup.name_itc->func.del = NULL;
696 ad->setup.end_sp_itc = elm_genlist_item_class_new();
697 ad->setup.end_sp_itc->item_style = "dialogue/separator";
698 ad->setup.end_sp_itc->func.text_get = NULL;
699 ad->setup.end_sp_itc->func.content_get = NULL;
700 ad->setup.end_sp_itc->func.state_get = NULL;
701 ad->setup.end_sp_itc->func.del = NULL;
703 __MOBILE_AP_FUNC_EXIT__;
707 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
709 __MOBILE_AP_FUNC_ENTER__;
716 if (st->pw_entry == NULL) {
717 ERR("pw_entry is NULL");
721 evas_object_smart_callback_del(st->hide_btn, "changed",
722 __hide_btn_changed_cb);
723 evas_object_smart_callback_del(st->security_btn, "changed",
724 __security_btn_changed_cb);
726 evas_object_smart_callback_del(st->pw_entry,
728 __passphrase_maxlength_reached_cb);
729 evas_object_smart_callback_del(st->pw_entry,
731 __passphrase_activated_cb);
733 evas_object_smart_callback_del(st->back_btn, "clicked",
735 evas_object_smart_callback_del(st->genlist, "realized",
739 st->security_btn = NULL;
744 __MOBILE_AP_FUNC_EXIT__;
747 static void __back_btn_cb(void *data, Evas_Object *obj, void *event_info)
749 __MOBILE_AP_FUNC_ENTER__;
752 ERR("The param is NULL\n");
756 mh_appdata_t *ad = (mh_appdata_t *)data;
757 mh_wifi_setting_view_t *st = &ad->setup;
762 imf_state = ecore_imf_input_panel_hide();
763 elm_object_focus_set(st->pw_entry, EINA_FALSE);
765 if (strlen(st->wifi_passphrase_new) < WIFI_PASSPHRASE_LENGTH_MIN) {
766 DBG("Password is shorter than %d\n", WIFI_PASSPHRASE_LENGTH_MIN);
767 ret = notification_status_message_post(_("IDS_ST_BODY_ENTER_PASSWORD_OF_AT_LEAST_8_CHARACTERS"));
768 if (ret != NOTIFICATION_ERROR_NONE)
769 ERR("notification_status_message_post() is failed : %d\n", ret);
771 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase);
773 elm_entry_entry_set(st->pw_entry, ptr);
776 ERR("elm_entry_utf8_to_markup is failed\n");
782 if (g_strcmp0(st->wifi_passphrase, st->wifi_passphrase_new) != 0) {
783 if (__save_wifi_passphrase(ad) == EINA_FALSE) {
784 ERR("__save_wifi_passphrase is failed\n");
788 if (imf_state == EINA_TRUE) {
789 DBG("IMF is hided\n");
793 if (ad->main.need_recover_wifi_tethering == true) {
794 DBG("Turn on Wi-Fi tethering again\n");
795 _update_wifi_item(ad, MH_STATE_PROCESS);
796 if (ad->main.help_item)
797 elm_genlist_item_update(ad->main.help_item);
799 ret = tethering_enable(ad->handle, TETHERING_TYPE_WIFI);
800 if (ret != TETHERING_ERROR_NONE) {
801 ERR("Wi-Fi tethering on is failed : %d\n", ret);
802 _update_wifi_item(ad, MH_STATE_NONE);
803 ad->main.need_recover_wifi_tethering = false;
807 __deconstruct_wifi_setup_view(st);
809 evas_object_del(ad->setup.genlist);
810 __free_genlist_itc(ad);
812 elm_naviframe_item_pop(ad->naviframe);
814 __MOBILE_AP_FUNC_EXIT__;
817 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
819 __MOBILE_AP_FUNC_ENTER__;
821 mh_appdata_t *ad = (mh_appdata_t *)data;
822 mh_wifi_setting_view_t *st = &(ad->setup);
823 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
826 char str[MH_LABEL_LENGTH_MAX] = {0, };
829 if (item == st->hide_item) {
830 DBG("Hide item is realized\n");
831 elm_object_item_signal_emit(item, "elm,state,top", "");
832 } else if (item == st->security_item) {
833 DBG("Security item is realized\n");
834 elm_object_item_signal_emit(item, "elm,state,center", "");
835 } else if (item == st->pw_item) {
836 DBG("Password item is realized\n");
837 elm_object_item_signal_emit(item, "elm,state,bottom", "");
838 } else if (item == st->name_item) {
839 DBG("Name item is realized\n");
842 for (i = 0; i < 2; i++) {
843 if (item == st->sp_item[i])
844 elm_object_item_access_unregister(item);
847 if (item == st->hide_item || item == st->security_item) {
848 ao = elm_object_item_access_object_get(item);
849 btn = elm_object_item_part_content_get(item, "on&off");
850 snprintf(str, sizeof(str), "%s, %s", "On/off button",
851 (elm_check_state_get(btn) ? "On" : "Off"));
852 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
855 __MOBILE_AP_FUNC_EXIT__;
860 Evas_Object *__create_genlist(mh_appdata_t *ad)
862 __MOBILE_AP_FUNC_ENTER__;
869 void *data = (void *)ad;
870 mh_wifi_setting_view_t *st = &ad->setup;
871 Evas_Object *genlist;
872 Elm_Object_Item *item;
875 genlist = elm_genlist_add(ad->naviframe);
876 if (genlist == NULL) {
877 ERR("genlist is NULL\n");
881 elm_object_style_set(genlist, "dialogue");
882 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
883 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
885 __set_genlist_itc(ad);
886 item = elm_genlist_item_append(genlist, st->sp_itc, NULL, NULL,
887 ELM_GENLIST_ITEM_NONE, NULL, NULL);
888 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
889 st->sp_item[i++] = item;
891 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
892 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
894 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
895 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
897 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
898 ELM_GENLIST_ITEM_NONE, NULL, NULL);
899 elm_genlist_item_select_mode_set(st->pw_item, ELM_OBJECT_SELECT_MODE_NONE);
901 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
902 ELM_GENLIST_ITEM_NONE, NULL, NULL);
903 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
905 item = elm_genlist_item_append(genlist, st->end_sp_itc, NULL, NULL,
906 ELM_GENLIST_ITEM_NONE, NULL, NULL);
907 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
908 st->sp_item[i++] = item;
911 __MOBILE_AP_FUNC_EXIT__;
916 char *__slide_title_access_info_cb(void *data, Evas_Object *obj)
919 Elm_Object_Item *navi_it;
924 navi_it = (Elm_Object_Item *) data;
925 label = elm_object_item_part_content_get(navi_it, "elm.swallow.title");
929 info = elm_object_text_get(label);
933 buf = eina_strbuf_new();
934 eina_strbuf_append(buf, info);
936 ret = eina_strbuf_string_steal(buf);
937 eina_strbuf_free(buf);
941 static void __title_clicked_cb(void *data, Evas_Object *obj, void *event_info)
944 Elm_Object_Item *navi_it = event_info;
948 label = elm_object_item_part_content_get(navi_it, "elm.swallow.title");
952 elm_label_slide_go(label);
955 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
957 __MOBILE_AP_FUNC_ENTER__;
964 mh_wifi_setting_view_t *st = &ad->setup;
969 if (st->genlist != NULL) {
970 ERR("Wi-Fi setup view already exists\n");
974 st->genlist = __create_genlist(ad);
975 if (st->genlist == NULL) {
976 ERR("__create_genlist returns NULL\n");
980 st->back_btn = elm_button_add(ad->naviframe);
981 if (st->back_btn == NULL) {
982 ERR("elm_button_add returns NULL\n");
985 elm_object_style_set(st->back_btn, "naviframe/back_btn/default");
986 evas_object_smart_callback_add(st->back_btn, "clicked",
988 elm_object_focus_allow_set(st->back_btn, EINA_FALSE);
990 st->navi_it = elm_naviframe_item_push(ad->naviframe,
992 st->back_btn, NULL, st->genlist, NULL);
995 label = _create_slide_title(ad->naviframe, _("IDS_MOBILEAP_MBODY_WI_FI_TETHERING_SETTINGS"));
996 elm_object_item_part_content_set(st->navi_it, "elm.swallow.title", label);
997 evas_object_smart_callback_add(ad->naviframe, "title,clicked", __title_clicked_cb, NULL);
999 ao = elm_object_item_access_object_get(st->navi_it);
1001 elm_access_info_set(ao, ELM_ACCESS_TYPE, "title");
1002 elm_access_info_cb_set(ao, ELM_ACCESS_INFO,
1003 __slide_title_access_info_cb, st->navi_it);
1004 elm_object_focus_set(ao, EINA_TRUE);
1007 /* Realize genlist item forcely since UIFW doesn't make realize to avoid crash on landscape mode*/
1008 elm_genlist_item_update(st->pw_item);
1010 __MOBILE_AP_FUNC_EXIT__;
1016 evas_object_del(st->back_btn);
1018 evas_object_del(st->genlist);
1020 st->back_btn = NULL;