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 guint tethering_param_timer = 0;
31 static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
33 __MOBILE_AP_FUNC_ENTER__;
35 if (data == NULL || obj == NULL) {
36 ERR("Invalid param\n");
40 mh_appdata_t *ad = (mh_appdata_t *)data;
42 ad->setup.visibility_new = !ad->setup.visibility_new;
44 __MOBILE_AP_FUNC_EXIT__;
47 static bool __save_hide_btn_change(mh_appdata_t *ad)
49 __MOBILE_AP_FUNC_ENTER__;
52 ERR("Invalid param\n");
58 ret = tethering_wifi_set_ssid_visibility(ad->handle,
59 ad->setup.visibility_new);
60 if (ret != TETHERING_ERROR_NONE) {
61 ERR("tethering_wifi_set_ssid_visibility is failed : %d\n", ret);
65 __MOBILE_AP_FUNC_EXIT__;
69 static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
71 __MOBILE_AP_FUNC_ENTER__;
73 if (data == NULL || obj == NULL) {
74 ERR("Invalid param\n");
78 mh_appdata_t *ad = (mh_appdata_t *)data;
79 mh_wifi_setting_view_t *st = &ad->setup;
81 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE)
82 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
84 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_NONE;
86 /* update wifi passphrase item */
87 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
88 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
89 elm_object_disabled_set(st->save_button, EINA_FALSE);
91 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
95 elm_genlist_item_update(st->pw_item);
97 __MOBILE_AP_FUNC_EXIT__;
100 static bool __save_security_btn_change(mh_appdata_t *ad)
102 __MOBILE_AP_FUNC_ENTER__;
105 ERR("Invalid param\n");
111 ret = tethering_wifi_set_security_type(ad->handle, ad->setup.security_type_new);
112 if (ret != TETHERING_ERROR_NONE) {
113 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
117 __MOBILE_AP_FUNC_EXIT__;
121 static char *__gl_device_name_title_label_get(void *data, Evas_Object *obj, const char *part)
123 __MOBILE_AP_FUNC_ENTER__;
124 mh_appdata_t *ad = (mh_appdata_t *)data;
125 char *device_name_utf = NULL;
127 char buf[MH_LABEL_LENGTH_MAX] = {0, };
129 if (data == NULL || obj == NULL || part == NULL) {
130 ERR("Invalid param\n");
134 if (!strcmp("elm.text.multiline", part)) {
135 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
136 if (device_name_utf == NULL)
137 ERR("vconf_get_str failed \n");
139 ptr = elm_entry_utf8_to_markup(device_name_utf);
141 ERR("elm_entry_utf8_to_markup is failed\n");
142 free(device_name_utf);
146 g_strlcpy(ad->setup.device_name, ptr,
147 sizeof(ad->setup.device_name));
149 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size><br>%s", STR_MY_DEVICE_NAME, ptr);
151 free(device_name_utf);
157 __MOBILE_AP_FUNC_EXIT__;
161 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
163 __MOBILE_AP_FUNC_ENTER__;
165 if (data == NULL || obj == NULL || part == NULL) {
166 ERR("Invalid param\n");
170 if (!strcmp("elm.text", part))
171 return strdup(STR_HIDE_MY_DEV);
173 __MOBILE_AP_FUNC_EXIT__;
177 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
179 __MOBILE_AP_FUNC_ENTER__;
181 if (data == NULL || obj == NULL || part == NULL) {
182 ERR("Invalid param\n");
186 if (!strcmp("elm.text", part))
187 return strdup(STR_SECURITY_TYPE);
189 __MOBILE_AP_FUNC_EXIT__;
193 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
196 __MOBILE_AP_FUNC_ENTER__;
198 mh_appdata_t *ad = (mh_appdata_t *)data;
199 Evas_Object *btn = NULL;
201 if (data == NULL || obj == NULL || part == NULL) {
202 ERR("Invalid param\n");
206 if (!strcmp("elm.swallow.end", part)) {
207 btn = elm_check_add(obj);
209 ERR("btn is NULL\n");
213 elm_object_style_set(btn, "on&off");
214 evas_object_show(btn);
215 evas_object_pass_events_set(btn, EINA_TRUE);
216 evas_object_propagate_events_set(btn, EINA_FALSE);
217 elm_object_focus_allow_set(btn, EINA_FALSE);
218 elm_check_state_set(btn, ad->setup.visibility_new ? EINA_FALSE : EINA_TRUE);
219 evas_object_smart_callback_add(btn, "changed",
220 __hide_btn_changed_cb, (void *)ad);
221 ad->setup.hide_btn = btn;
224 __MOBILE_AP_FUNC_EXIT__;
228 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
231 __MOBILE_AP_FUNC_ENTER__;
233 mh_appdata_t *ad = (mh_appdata_t *)data;
234 Evas_Object *btn = NULL;
236 if (data == NULL || obj == NULL || part == NULL) {
237 ERR("Invalid param\n");
241 if (!strcmp("elm.swallow.end", part)) {
242 btn = elm_check_add(obj);
243 elm_object_style_set(btn, "on&off");
244 evas_object_show(btn);
245 evas_object_pass_events_set(btn, EINA_TRUE);
246 evas_object_propagate_events_set(btn, EINA_FALSE);
247 elm_check_state_set(btn, ad->setup.security_type_new ==
248 TETHERING_WIFI_SECURITY_TYPE_NONE ?
249 EINA_FALSE : EINA_TRUE);
250 evas_object_smart_callback_add(btn, "changed",
251 __security_btn_changed_cb, (void *)ad);
252 ad->setup.security_btn = btn;
255 __MOBILE_AP_FUNC_EXIT__;
259 static bool __save_wifi_passphrase(mh_appdata_t *ad)
261 __MOBILE_AP_FUNC_ENTER__;
264 ERR("Invalid param\n");
268 mh_wifi_setting_view_t *st = &ad->setup;
271 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
272 if (ret != TETHERING_ERROR_NONE) {
273 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
277 __MOBILE_AP_FUNC_EXIT__;
281 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
284 __MOBILE_AP_FUNC_ENTER__;
286 mh_appdata_t *ad = (mh_appdata_t *)data;
287 mh_wifi_setting_view_t *st = &ad->setup;
288 const char *changed_text;
292 changed_text = elm_entry_entry_get(obj);
293 if (changed_text == NULL) {
294 ERR("elm_entry_entry_get is failed\n");
298 utf8_string = elm_entry_markup_to_utf8(changed_text);
300 if (utf8_string == NULL) {
301 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
303 len = strlen(utf8_string);
304 if (WIFI_PASSPHRASE_LENGTH_MIN <= len) {
305 elm_object_disabled_set(st->save_button, EINA_FALSE);
306 elm_entry_input_panel_return_key_disabled_set(obj, FALSE);
308 elm_object_disabled_set(st->save_button, EINA_TRUE);
309 elm_entry_input_panel_return_key_disabled_set(obj, TRUE);
311 g_strlcpy(st->wifi_passphrase_new, utf8_string,
312 sizeof(st->wifi_passphrase_new));
317 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
318 if (elm_object_focus_get(obj)) {
319 if (elm_entry_is_empty(obj))
320 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
322 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
326 __MOBILE_AP_FUNC_EXIT__;
330 static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj,
333 __MOBILE_AP_FUNC_ENTER__;
336 ERR("The param is NULL\n");
337 __MOBILE_AP_FUNC_EXIT__;
340 char buf[MH_LABEL_LENGTH_MAX] = { 0, };
341 char *fmt = STR_PASSWORD_MIN_MAX;
342 notification_error_e ret;
344 snprintf(buf, sizeof(buf), fmt,
345 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
347 ret = notification_status_message_post(buf);
348 if (ret != NOTIFICATION_ERROR_NONE)
349 ERR("notification_status_message_post() is failed : %d\n", ret);
351 __MOBILE_AP_FUNC_EXIT__;
354 static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
356 __MOBILE_AP_FUNC_ENTER__;
359 ERR("Invalid parameter");
363 elm_object_focus_set(obj, EINA_FALSE);
364 __MOBILE_AP_FUNC_EXIT__;
368 static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
370 __MOBILE_AP_FUNC_ENTER__;
371 evas_object_smart_callback_del(obj, "focused", __pw_entry_focused_cb);
373 elm_object_focus_set(obj, EINA_TRUE);
374 elm_entry_cursor_end_set(obj);
375 __MOBILE_AP_FUNC_EXIT__;
378 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
380 __MOBILE_AP_FUNC_ENTER__;
381 if (elm_object_part_content_get(obj, "elm.swallow.clear"))
382 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
383 elm_object_signal_emit(obj, "elm,state,focus,off", "");
384 __MOBILE_AP_FUNC_EXIT__;
387 static void __pw_entry_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
389 __MOBILE_AP_FUNC_ENTER__;
390 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __pw_entry_show_cb);
392 elm_object_focus_set(obj, EINA_TRUE);
393 elm_entry_cursor_end_set(obj);
394 __MOBILE_AP_FUNC_EXIT__;
397 static void __eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
399 __MOBILE_AP_FUNC_ENTER__;
401 elm_object_text_set(data, "");
402 elm_entry_input_panel_return_key_disabled_set(data, TRUE);
404 __MOBILE_AP_FUNC_EXIT__;
407 static void __pw_entry_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
409 __MOBILE_AP_FUNC_ENTER__;
411 if (obj == NULL || data == NULL) {
415 mh_appdata_t *ad = (mh_appdata_t *)data;
416 mh_wifi_setting_view_t *st = &ad->setup;
417 char buf[MH_LABEL_LENGTH_MAX];
418 char *fmt = STR_PW_GUIDE_TEXT;
420 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
422 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
424 elm_genlist_item_update(st->pw_item);
426 elm_object_part_text_set(obj, "elm.guide", buf);
428 __MOBILE_AP_FUNC_EXIT__;
431 static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent)
433 __MOBILE_AP_FUNC_ENTER__;
435 static Elm_Entry_Filter_Limit_Size limit_filter_data;
436 Evas_Object *entry = NULL;
437 char *fmt = STR_PW_GUIDE_TEXT;
439 Evas_Object * clr_btn = NULL;
440 char buf[MH_LABEL_LENGTH_MAX];
442 if (parent == NULL || data == NULL) {
443 ERR("null param \n");
447 mh_appdata_t *ad = (mh_appdata_t *)data;
448 mh_wifi_setting_view_t *st = &ad->setup;
450 entry = elm_entry_add(parent);
453 ERR("elm_entry_add returns NULL\n");
458 elm_entry_single_line_set(entry, EINA_TRUE);
459 elm_entry_scrollable_set(entry, EINA_TRUE);
460 elm_entry_password_set(entry, EINA_FALSE);
462 evas_object_smart_callback_add(entry, "language,changed",
463 __pw_entry_language_changed_cb, ad);
465 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
466 elm_entry_prediction_allow_set(entry, EINA_FALSE);
467 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
468 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
469 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
470 elm_object_part_text_set(entry, "guide", buf);
471 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
473 limit_filter_data.max_char_count = 0;
474 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
475 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
477 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
478 elm_object_part_text_set(entry, "default", buf);
479 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
480 elm_object_disabled_set(entry, EINA_TRUE);
482 elm_object_item_signal_emit(st->pw_item, "elm,state,rename,hide", "");
485 elm_object_disabled_set(entry, EINA_FALSE);
486 elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
487 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
489 elm_object_text_set(entry, ptr);
492 ERR("elm_entry_utf8_to_markup is failed\n");
496 elm_entry_input_panel_return_key_type_set(entry,
497 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
499 clr_btn = elm_button_add(entry);
500 elm_object_style_set(clr_btn, "search_clear");
501 elm_object_focus_allow_set(clr_btn, EINA_FALSE);
502 elm_object_part_content_set(entry, "elm.swallow.clear", clr_btn);
503 evas_object_smart_callback_add(clr_btn, "clicked", __eraser_btn_clicked_cb, entry);
504 evas_object_show(clr_btn);
506 evas_object_smart_callback_add(entry, "changed",
507 __pw_entry_changed_cb, ad);
508 evas_object_smart_callback_add(entry, "maxlength,reached",
509 __pw_entry_maxlength_reached_cb, ad);
510 evas_object_smart_callback_add(entry, "activated",
511 __pw_entry_activated_cb, NULL);
512 evas_object_smart_callback_add(entry, "focused",
513 __pw_entry_focused_cb, NULL);
514 evas_object_smart_callback_add(entry, "unfocused",
515 __pw_entry_unfocused_cb, NULL);
516 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
517 __pw_entry_show_cb, NULL);
519 elm_object_focus_set(entry, EINA_TRUE);
520 elm_entry_input_panel_show(entry);
521 elm_object_part_content_set(parent, "elm.swallow.content", entry);
523 st->pw_entry = entry;
525 __MOBILE_AP_FUNC_EXIT__;
529 static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part)
531 __MOBILE_AP_FUNC_ENTER__;
537 ERR("data is null \n");
541 if (!strcmp(part, "elm.swallow.content")) {
542 Evas_Object *box = elm_box_add(obj);
543 Evas_Object *label = elm_label_add(box);
544 Evas_Object *layout = elm_layout_add(box);
545 char buf[MH_LABEL_LENGTH_MAX] = {0, };
547 elm_box_align_set(box, 0.0, 0.0);
549 /* Set label for name field */
550 snprintf(buf, MH_LABEL_LENGTH_MAX, "<text align=left><font_size=30>%s</font_size></text>", STR_PASSWORD);
551 elm_object_text_set(label, buf);
552 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
553 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
554 evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), 0, 0);
555 elm_box_pack_end(box, label);
556 evas_object_show(label);
558 /* Set layout for entry field */
559 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
560 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
561 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
563 __get_pw_entry(data, layout);
564 evas_object_show(layout);
565 elm_box_pack_end(box, layout);
567 evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
568 evas_object_show(box);
573 __MOBILE_AP_FUNC_EXIT__;
577 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
579 __MOBILE_AP_FUNC_ENTER__;
581 if (data == NULL || obj == NULL || event_info == NULL) {
582 ERR("param is NULL\n");
586 mh_appdata_t *ad = (mh_appdata_t *)data;
588 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
589 __hide_btn_changed_cb(ad, obj, NULL);
591 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility_new ?
592 EINA_FALSE : EINA_TRUE);
594 __MOBILE_AP_FUNC_EXIT__;
597 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
599 __MOBILE_AP_FUNC_ENTER__;
601 if (data == NULL || obj == NULL || event_info == NULL) {
602 ERR("param is NULL\n");
606 mh_appdata_t *ad = (mh_appdata_t *)data;
608 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
609 __security_btn_changed_cb(data, obj, NULL);
610 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type_new ==
611 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
613 __MOBILE_AP_FUNC_EXIT__;
616 static void __set_genlist_itc(mh_appdata_t *ad)
618 __MOBILE_AP_FUNC_ENTER__;
620 ad->setup.name_itc = elm_genlist_item_class_new();
621 if (ad->setup.name_itc == NULL) {
622 ERR("elm_genlist_item_class_new failed\n");
623 __MOBILE_AP_FUNC_EXIT__;
626 ad->setup.name_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
627 ad->setup.name_itc->func.text_get = __gl_device_name_title_label_get;
628 ad->setup.name_itc->func.content_get = NULL;
629 ad->setup.name_itc->func.state_get = NULL;
630 ad->setup.name_itc->func.del = NULL;
632 ad->setup.hide_itc = elm_genlist_item_class_new();
633 if (ad->setup.hide_itc == NULL) {
634 ERR("elm_genlist_item_class_new failed\n");
635 __MOBILE_AP_FUNC_EXIT__;
638 ad->setup.hide_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
639 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
640 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
641 ad->setup.hide_itc->func.state_get = NULL;
642 ad->setup.hide_itc->func.del = NULL;
644 ad->setup.security_itc = elm_genlist_item_class_new();
645 if (ad->setup.security_itc == NULL) {
646 ERR("elm_genlist_item_class_new failed\n");
647 __MOBILE_AP_FUNC_EXIT__;
650 ad->setup.security_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
651 ad->setup.security_itc->func.text_get = __gl_security_label_get;
652 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
653 ad->setup.security_itc->func.state_get = NULL;
654 ad->setup.security_itc->func.del = NULL;
656 ad->setup.pw_itc = elm_genlist_item_class_new();
657 if (ad->setup.pw_itc == NULL) {
658 ERR("elm_genlist_item_class_new failed\n");
659 __MOBILE_AP_FUNC_EXIT__;
662 ad->setup.pw_itc->item_style = MH_GENLIST_FULL_CONTENT_STYLE;
663 ad->setup.pw_itc->func.text_get = NULL;
664 ad->setup.pw_itc->func.content_get = __gl_pw_content_get;
665 ad->setup.pw_itc->func.state_get = NULL;
666 ad->setup.pw_itc->func.del = NULL;
668 __MOBILE_AP_FUNC_EXIT__;
672 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
674 __MOBILE_AP_FUNC_ENTER__;
681 evas_object_smart_callback_del(st->hide_btn, "changed",
682 __hide_btn_changed_cb);
683 evas_object_smart_callback_del(st->security_btn, "changed",
684 __security_btn_changed_cb);
685 evas_object_smart_callback_del(st->cancel_button, "clicked",
687 evas_object_smart_callback_del(st->save_button, "clicked",
689 evas_object_smart_callback_del(st->genlist, "realized",
692 __MOBILE_AP_FUNC_EXIT__;
695 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
697 if (user_data == NULL) {
698 ERR("Invalid parameter\n");
702 __MOBILE_AP_FUNC_ENTER__;
704 g_source_remove(tethering_param_timer);
706 mh_appdata_t *ad = (mh_appdata_t *)user_data;
708 if (result != TETHERING_ERROR_NONE)
709 ERR("tethering_wifi_reload_settings is failed [0x%X]\n", result);
710 _update_wifi_item(ad, MH_STATE_NONE);
712 __MOBILE_AP_FUNC_EXIT__;
717 static gboolean _update_tethering_param(gpointer data)
719 __MOBILE_AP_FUNC_ENTER__;
720 mh_appdata_t *ad = (mh_appdata_t *)data;
724 ERR("Invalid parameter\n");
728 /* reload wifi settings */
729 ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb,
731 if (ret != TETHERING_ERROR_NONE)
732 ERR("reload_configuration is failed : %d\n", ret);
734 __MOBILE_AP_FUNC_EXIT__;
738 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info)
742 ERR("data is NULL\n");
746 mh_appdata_t *ad = (mh_appdata_t *)data;
747 mh_wifi_setting_view_t *st = &ad->setup;
749 bool is_setting_changed = false;
751 /* handle hide button change */
752 if (st->visibility != st->visibility_new) {
753 ret = __save_hide_btn_change(ad);
755 elm_check_state_set(st->hide_btn, st->visibility ?
756 EINA_FALSE : EINA_TRUE);
758 st->visibility = st->visibility_new;
759 is_setting_changed = true;
762 /* handle security button change */
763 if (st->security_type != st->security_type_new) {
764 ret = __save_security_btn_change(ad);
766 elm_check_state_set(st->security_btn, st->security_type ==
767 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
769 st->security_type = st->security_type_new;
770 is_setting_changed = true;
774 /* handle wifi passphrase change */
775 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
776 ret = __save_wifi_passphrase(ad);
778 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
779 sizeof(st->wifi_passphrase_new));
781 elm_genlist_item_update(st->pw_item);
783 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
784 sizeof(st->wifi_passphrase));
785 is_setting_changed = true;
786 if (ad->main.help_item) {
787 if (ad->main.help_item)
788 elm_genlist_item_update(ad->main.help_item);
793 if (is_setting_changed) {
794 _update_wifi_item(ad, MH_STATE_PROCESS);
796 if (ad->main.help_item)
797 elm_genlist_item_update(ad->main.help_item);
799 /* Here, The Dbus takes some amount of time
800 to set the tethering parameters, due to
801 which UI shows incorrect display, to avoid
802 this issue, CAPI will be called after 0.1sec for smooth
803 transition of UI frames */
804 tethering_param_timer = g_timeout_add(100,
805 _update_tethering_param, ad);
808 elm_naviframe_item_pop(ad->naviframe);
814 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info)
819 ERR("The param is NULL\n");
823 mh_appdata_t *ad = (mh_appdata_t *)data;
825 elm_naviframe_item_pop(ad->naviframe);
830 Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item)
835 ERR("The param is NULL\n");
839 mh_appdata_t *ad = (mh_appdata_t *)data;
840 mh_wifi_setting_view_t *st = &ad->setup;
842 if (st->visibility != st->visibility_new)
843 st->visibility_new = st->visibility;
845 if (st->security_type != st->security_type_new)
846 st->security_type_new = st->security_type;
848 if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) {
849 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
850 sizeof(st->wifi_passphrase_new));
853 __deconstruct_wifi_setup_view(st);
855 if (ad->rename_popup != NULL) {
856 evas_object_del(ad->rename_popup);
857 ad->rename_popup = NULL;
859 ad->setup.navi_it = NULL;
865 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
867 __MOBILE_AP_FUNC_ENTER__;
869 mh_appdata_t *ad = (mh_appdata_t *)data;
870 mh_wifi_setting_view_t *st = &(ad->setup);
871 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
874 char str[MH_LABEL_LENGTH_MAX] = {0, };
878 if (item == st->hide_item)
879 elm_object_item_signal_emit(item, "elm,state,top", "");
880 else if (item == st->security_item)
881 elm_object_item_signal_emit(item, "elm,state,center", "");
882 else if (item == st->pw_item)
883 elm_object_item_signal_emit(item, "elm,state,bottom", "");
885 no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]);
886 for (i = 0; i < no_of_sp; i++) {
887 if (item == st->sp_item[i])
888 elm_object_item_access_unregister(item);
891 if (item == st->hide_item || item == st->security_item) {
892 ao = elm_object_item_access_object_get(item);
893 btn = elm_object_item_part_content_get(item, "on&off");
894 snprintf(str, sizeof(str), "%s, %s", "On/off button",
895 (elm_check_state_get(btn) ? "On" : "Off"));
896 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
899 if (item == st->pw_item) {
900 elm_object_item_access_unregister(item);
901 ao = elm_object_item_access_register(item);
902 snprintf(str, sizeof(str), "%s, %s", STR_PASSWORD, st->wifi_passphrase_new);
903 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
906 __MOBILE_AP_FUNC_EXIT__;
911 static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_info)
913 __MOBILE_AP_FUNC_ENTER__;
916 ERR("The param is NULL\n");
920 mh_appdata_t *ad = (mh_appdata_t *)data;
921 mh_wifi_setting_view_t *st = &ad->setup;
923 elm_object_focus_set(st->pw_entry, EINA_TRUE);
925 __MOBILE_AP_FUNC_EXIT__;
929 Evas_Object *__create_genlist(mh_appdata_t *ad)
931 __MOBILE_AP_FUNC_ENTER__;
938 void *data = (void *)ad;
939 mh_wifi_setting_view_t *st = &ad->setup;
940 Evas_Object *genlist;
942 genlist = elm_genlist_add(ad->naviframe);
943 if (genlist == NULL) {
944 ERR("genlist is NULL\n");
948 elm_object_style_set(genlist, "dialogue");
949 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
950 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
952 __set_genlist_itc(ad);
954 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
955 ELM_GENLIST_ITEM_NONE, NULL, NULL);
956 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
959 elm_object_item_disabled_set(st->name_item, EINA_TRUE);
961 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
962 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
964 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
965 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
967 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
968 ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad);
969 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
970 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
972 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
974 /* End separator is removed because of P131104-03336. It is confirmed by UX team for this case.
975 item = elm_genlist_item_append(genlist, st->sp_itc, NULL, NULL,
976 ELM_GENLIST_ITEM_NONE, NULL, NULL);
977 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
978 st->sp_item[i++] = item;
981 __MOBILE_AP_FUNC_EXIT__;
986 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
996 mh_wifi_setting_view_t *st = &ad->setup;
998 if (ad->setup.navi_it != NULL) {
999 ERR("Wi-Fi setup view already exists\n");
1004 st->genlist = __create_genlist(ad);
1005 if (st->genlist == NULL) {
1006 ERR("__create_genlist returns NULL\n");
1011 st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_BODY_CONFIGURE_MOBILE_HOTSPOT_ABB_US_TMO",
1012 NULL, NULL, st->genlist, NULL);
1013 elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);
1015 elm_naviframe_item_pop_cb_set(st->navi_it, _setting_back_btn_cb, (void *)ad);
1017 btn = elm_button_add(ad->naviframe);
1018 elm_object_style_set(btn, "naviframe/title_cancel");
1019 evas_object_smart_callback_add(btn, "clicked", __cancel_btn_cb, ad);
1020 elm_object_item_part_content_set(st->navi_it, "title_left_btn", btn);
1021 st->cancel_button = btn;
1023 btn = elm_button_add(ad->naviframe);
1024 elm_object_style_set(btn, "naviframe/title_done");
1025 evas_object_smart_callback_add(btn, "clicked", __save_btn_cb, ad);
1026 elm_object_item_part_content_set(st->navi_it, "title_right_btn", btn);
1027 st->save_button = btn;