4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.tizenopensource.org/license
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include <efl_extension.h>
22 #include "mh_view_wifi_setup.h"
23 #include "mh_view_main.h"
24 #include "mh_string.h"
26 static void __gl_realized(void *data, Evas_Object *obj, void *event_info);
27 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info);
28 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info);
30 static void __create_password_item(Evas_Object *genlist, mh_appdata_t *ad);
31 static void __destroy_password_item(mh_appdata_t *ad);
33 static guint tethering_param_timer = 0;
35 static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
37 __MOBILE_AP_FUNC_ENTER__;
39 if (data == NULL || obj == NULL) {
40 ERR("Invalid param\n");
44 mh_appdata_t *ad = (mh_appdata_t *)data;
46 ad->setup.visibility_new = !ad->setup.visibility_new;
48 __MOBILE_AP_FUNC_EXIT__;
51 #ifndef TIZEN_FEATURE_EMULATOR
52 static bool __save_hide_btn_change(mh_appdata_t *ad)
54 __MOBILE_AP_FUNC_ENTER__;
57 ERR("Invalid param\n");
63 ret = tethering_wifi_set_ssid_visibility(ad->handle,
64 ad->setup.visibility_new);
65 if (ret != TETHERING_ERROR_NONE) {
66 ERR("tethering_wifi_set_ssid_visibility is failed : %d\n", ret);
70 __MOBILE_AP_FUNC_EXIT__;
75 static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
77 __MOBILE_AP_FUNC_ENTER__;
79 if (data == NULL || obj == NULL) {
80 ERR("Invalid param\n");
84 mh_appdata_t *ad = (mh_appdata_t *)data;
85 mh_wifi_setting_view_t *st = &ad->setup;
87 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
88 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
89 if (st->pw_item == NULL)
90 __create_password_item(st->genlist, ad);
92 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_NONE;
93 /* Disable password entry */
94 __destroy_password_item(ad);
97 /* update wifi passphrase item */
98 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
99 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
100 elm_object_disabled_set(st->save_button, EINA_FALSE);
102 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
106 elm_genlist_item_update(st->pw_item);
108 __MOBILE_AP_FUNC_EXIT__;
111 static void __check_box_changed_cb(void *data, Evas_Object *obj, void *event_info)
113 __MOBILE_AP_FUNC_ENTER__;
115 if (data == NULL || obj == NULL) {
116 ERR("Invalid param\n");
120 Eina_Bool state = elm_check_state_get(obj);
121 mh_appdata_t *ad = (mh_appdata_t *)data;
122 mh_wifi_setting_view_t *st = &ad->setup;
125 elm_entry_password_set(st->pw_entry, EINA_FALSE);
127 elm_entry_password_set(st->pw_entry, EINA_TRUE);
129 __MOBILE_AP_FUNC_EXIT__;
133 #ifndef TIZEN_FEATURE_EMULATOR
134 static bool __save_security_btn_change(mh_appdata_t *ad)
136 __MOBILE_AP_FUNC_ENTER__;
139 ERR("Invalid param\n");
145 ret = tethering_wifi_set_security_type(ad->handle, ad->setup.security_type_new);
146 if (ret != TETHERING_ERROR_NONE) {
147 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
151 __MOBILE_AP_FUNC_EXIT__;
156 static char *__gl_device_name_title_label_get(void *data, Evas_Object *obj, const char *part)
158 __MOBILE_AP_FUNC_ENTER__;
159 mh_appdata_t *ad = (mh_appdata_t *)data;
160 char *device_name_utf = NULL;
162 char buf[MH_LABEL_LENGTH_MAX] = {0, };
164 if (data == NULL || obj == NULL || part == NULL) {
165 ERR("Invalid param\n");
169 if (!strcmp("elm.text.multiline", part)) {
170 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
171 if (device_name_utf == NULL)
172 ERR("vconf_get_str failed \n");
174 ptr = elm_entry_utf8_to_markup(device_name_utf);
176 ERR("elm_entry_utf8_to_markup is failed\n");
177 free(device_name_utf);
181 g_strlcpy(ad->setup.device_name, ptr,
182 sizeof(ad->setup.device_name));
184 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size><br>%s", STR_MY_DEVICE_NAME, ptr);
186 free(device_name_utf);
192 __MOBILE_AP_FUNC_EXIT__;
196 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
198 __MOBILE_AP_FUNC_ENTER__;
200 if (data == NULL || obj == NULL || part == NULL) {
201 ERR("Invalid param\n");
205 if (!strcmp("elm.text", part))
206 return strdup(STR_HIDE_MY_DEV);
208 __MOBILE_AP_FUNC_EXIT__;
212 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
214 __MOBILE_AP_FUNC_ENTER__;
216 if (data == NULL || obj == NULL || part == NULL) {
217 ERR("Invalid param\n");
221 if (!strcmp("elm.text", part))
222 return strdup(STR_SECURITY_TYPE);
224 __MOBILE_AP_FUNC_EXIT__;
228 static Evas_Object *__gl_hide_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);
244 ERR("btn is NULL\n");
248 elm_object_style_set(btn, "on&off");
249 evas_object_show(btn);
250 evas_object_pass_events_set(btn, EINA_TRUE);
251 evas_object_propagate_events_set(btn, EINA_FALSE);
252 elm_object_focus_allow_set(btn, EINA_FALSE);
253 elm_check_state_set(btn, ad->setup.visibility_new ? EINA_FALSE : EINA_TRUE);
254 evas_object_smart_callback_add(btn, "changed",
255 __hide_btn_changed_cb, (void *)ad);
256 ad->setup.hide_btn = btn;
259 __MOBILE_AP_FUNC_EXIT__;
263 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
266 __MOBILE_AP_FUNC_ENTER__;
268 mh_appdata_t *ad = (mh_appdata_t *)data;
269 Evas_Object *btn = NULL;
271 if (data == NULL || obj == NULL || part == NULL) {
272 ERR("Invalid param\n");
276 if (!strcmp("elm.swallow.end", part)) {
277 btn = elm_check_add(obj);
278 elm_object_style_set(btn, "on&off");
279 evas_object_show(btn);
280 evas_object_pass_events_set(btn, EINA_TRUE);
281 evas_object_propagate_events_set(btn, EINA_FALSE);
282 elm_check_state_set(btn, ad->setup.security_type_new ==
283 TETHERING_WIFI_SECURITY_TYPE_NONE ?
284 EINA_FALSE : EINA_TRUE);
285 evas_object_smart_callback_add(btn, "changed",
286 __security_btn_changed_cb, (void *)ad);
287 ad->setup.security_btn = btn;
290 __MOBILE_AP_FUNC_EXIT__;
294 #ifndef TIZEN_FEATURE_EMULATOR
295 static bool __save_wifi_passphrase(mh_appdata_t *ad)
297 __MOBILE_AP_FUNC_ENTER__;
300 ERR("Invalid param\n");
304 mh_wifi_setting_view_t *st = &ad->setup;
307 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
308 if (ret != TETHERING_ERROR_NONE) {
309 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
313 __MOBILE_AP_FUNC_EXIT__;
318 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
321 __MOBILE_AP_FUNC_ENTER__;
323 mh_appdata_t *ad = (mh_appdata_t *)data;
324 mh_wifi_setting_view_t *st = &ad->setup;
325 const char *changed_text;
329 changed_text = elm_entry_entry_get(obj);
330 if (changed_text == NULL) {
331 ERR("elm_entry_entry_get is failed\n");
335 utf8_string = elm_entry_markup_to_utf8(changed_text);
337 if (utf8_string == NULL) {
338 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
340 len = strlen(utf8_string);
341 if (WIFI_PASSPHRASE_LENGTH_MIN <= len) {
342 elm_object_disabled_set(st->save_button, EINA_FALSE);
343 elm_entry_input_panel_return_key_disabled_set(obj, FALSE);
345 elm_object_disabled_set(st->save_button, EINA_TRUE);
346 elm_entry_input_panel_return_key_disabled_set(obj, TRUE);
348 g_strlcpy(st->wifi_passphrase_new, utf8_string,
349 sizeof(st->wifi_passphrase_new));
354 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
355 if (elm_object_focus_get(obj)) {
356 if (elm_entry_is_empty(obj))
357 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
359 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
363 __MOBILE_AP_FUNC_EXIT__;
367 static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj,
370 __MOBILE_AP_FUNC_ENTER__;
373 ERR("The param is NULL\n");
374 __MOBILE_AP_FUNC_EXIT__;
377 char buf[MH_LABEL_LENGTH_MAX] = { 0, };
378 char *fmt = STR_PASSWORD_MIN_MAX;
379 notification_error_e ret;
381 snprintf(buf, sizeof(buf), fmt,
382 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
384 ret = notification_status_message_post(buf);
385 if (ret != NOTIFICATION_ERROR_NONE)
386 ERR("notification_status_message_post() is failed : %d\n", ret);
388 __MOBILE_AP_FUNC_EXIT__;
391 static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
393 __MOBILE_AP_FUNC_ENTER__;
396 ERR("Invalid parameter");
400 elm_object_focus_set(obj, EINA_FALSE);
401 __MOBILE_AP_FUNC_EXIT__;
405 static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
407 __MOBILE_AP_FUNC_ENTER__;
408 evas_object_smart_callback_del(obj, "focused", __pw_entry_focused_cb);
410 elm_object_focus_set(obj, EINA_TRUE);
411 elm_entry_cursor_end_set(obj);
412 __MOBILE_AP_FUNC_EXIT__;
415 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
417 __MOBILE_AP_FUNC_ENTER__;
418 if (elm_object_part_content_get(obj, "elm.swallow.clear"))
419 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
420 elm_object_signal_emit(obj, "elm,state,focus,off", "");
421 __MOBILE_AP_FUNC_EXIT__;
424 static void __pw_entry_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
426 __MOBILE_AP_FUNC_ENTER__;
427 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __pw_entry_show_cb);
429 elm_object_focus_set(obj, EINA_TRUE);
430 elm_entry_cursor_end_set(obj);
431 __MOBILE_AP_FUNC_EXIT__;
434 static void __eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
436 __MOBILE_AP_FUNC_ENTER__;
438 elm_object_text_set(data, "");
439 elm_entry_input_panel_return_key_disabled_set(data, TRUE);
441 __MOBILE_AP_FUNC_EXIT__;
444 static void __pw_entry_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
446 __MOBILE_AP_FUNC_ENTER__;
448 if (obj == NULL || data == NULL) {
452 mh_appdata_t *ad = (mh_appdata_t *)data;
453 mh_wifi_setting_view_t *st = &ad->setup;
454 char buf[MH_LABEL_LENGTH_MAX];
455 char *fmt = STR_PW_GUIDE_TEXT;
457 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
459 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
461 elm_genlist_item_update(st->pw_item);
463 elm_object_part_text_set(obj, "elm.guide", buf);
465 __MOBILE_AP_FUNC_EXIT__;
468 static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent)
470 __MOBILE_AP_FUNC_ENTER__;
472 static Elm_Entry_Filter_Limit_Size limit_filter_data;
473 Evas_Object *entry = NULL;
474 char *fmt = STR_PW_GUIDE_TEXT;
476 Evas_Object * clr_btn = NULL;
477 char buf[MH_LABEL_LENGTH_MAX];
479 if (parent == NULL || data == NULL) {
480 ERR("null param \n");
484 mh_appdata_t *ad = (mh_appdata_t *)data;
485 mh_wifi_setting_view_t *st = &ad->setup;
487 entry = elm_entry_add(parent);
490 ERR("elm_entry_add returns NULL\n");
495 elm_entry_single_line_set(entry, EINA_TRUE);
496 elm_entry_scrollable_set(entry, EINA_TRUE);
497 elm_entry_password_set(entry, EINA_TRUE);
499 evas_object_smart_callback_add(entry, "language,changed",
500 __pw_entry_language_changed_cb, ad);
502 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
503 elm_entry_prediction_allow_set(entry, EINA_FALSE);
504 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
505 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
506 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
507 elm_object_part_text_set(entry, "guide", buf);
508 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
510 limit_filter_data.max_char_count = 0;
511 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
512 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
514 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
515 elm_object_part_text_set(entry, "default", buf);
516 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
517 elm_object_disabled_set(entry, EINA_TRUE);
519 elm_object_item_signal_emit(st->pw_item, "elm,state,rename,hide", "");
522 elm_object_disabled_set(entry, EINA_FALSE);
523 elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
524 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
526 elm_object_text_set(entry, ptr);
529 ERR("elm_entry_utf8_to_markup is failed\n");
533 elm_entry_input_panel_return_key_type_set(entry,
534 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
536 clr_btn = elm_button_add(entry);
537 elm_object_style_set(clr_btn, "search_clear");
538 elm_object_focus_allow_set(clr_btn, EINA_FALSE);
539 elm_object_part_content_set(entry, "elm.swallow.clear", clr_btn);
540 evas_object_smart_callback_add(clr_btn, "clicked", __eraser_btn_clicked_cb, entry);
541 evas_object_show(clr_btn);
543 evas_object_smart_callback_add(entry, "changed",
544 __pw_entry_changed_cb, ad);
545 evas_object_smart_callback_add(entry, "maxlength,reached",
546 __pw_entry_maxlength_reached_cb, ad);
547 evas_object_smart_callback_add(entry, "activated",
548 __pw_entry_activated_cb, NULL);
549 evas_object_smart_callback_add(entry, "focused",
550 __pw_entry_focused_cb, NULL);
551 evas_object_smart_callback_add(entry, "unfocused",
552 __pw_entry_unfocused_cb, NULL);
553 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
554 __pw_entry_show_cb, NULL);
556 elm_object_focus_set(entry, EINA_TRUE);
557 elm_entry_input_panel_show(entry);
558 elm_object_part_content_set(parent, "elm.swallow.content", entry);
560 st->pw_entry = entry;
562 __MOBILE_AP_FUNC_EXIT__;
566 static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part)
568 __MOBILE_AP_FUNC_ENTER__;
574 ERR("data is null \n");
578 if (!strcmp(part, "elm.swallow.content")) {
579 Evas_Object *box = elm_box_add(obj);
580 Evas_Object *label = elm_label_add(box);
581 Evas_Object *layout = elm_layout_add(box);
582 char buf[MH_LABEL_LENGTH_MAX] = {0, };
584 elm_box_align_set(box, 0.0, 0.0);
586 /* Set label for name field */
587 snprintf(buf, MH_LABEL_LENGTH_MAX, "<text align=left><font_size=30>%s</font_size></text>", STR_PASSWORD);
588 elm_object_text_set(label, buf);
589 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
590 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
591 evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), 0, 0);
592 elm_box_pack_end(box, label);
593 evas_object_show(label);
595 /* Set layout for entry field */
596 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
597 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
598 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
600 __get_pw_entry(data, layout);
601 evas_object_show(layout);
602 elm_box_pack_end(box, layout);
604 evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
605 evas_object_show(box);
610 __MOBILE_AP_FUNC_EXIT__;
614 static char *_gl_pswd_check_box_text_get(void *data,
615 Evas_Object *obj, const char *part)
617 if (!strcmp("elm.text", part))
618 return strdup(STR_SHOW_PASSWORD);
624 static Evas_Object *_gl_pswd_check_box_content_get(void *data,
625 Evas_Object *obj, const char *part)
627 mh_appdata_t *ad = (mh_appdata_t *)data;
628 Evas_Object *check = NULL;
630 if (data == NULL || obj == NULL || part == NULL) {
631 ERR("Invalid param\n");
635 if (!strcmp("elm.swallow.icon", part)) {
636 check = elm_check_add(obj);
637 evas_object_propagate_events_set(check, EINA_FALSE);
639 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
640 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
641 evas_object_smart_callback_add(check, "changed", __check_box_changed_cb, (void *)ad);
643 elm_object_focus_allow_set(check, EINA_FALSE);
651 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
653 __MOBILE_AP_FUNC_ENTER__;
655 if (data == NULL || obj == NULL || event_info == NULL) {
656 ERR("param is NULL\n");
660 mh_appdata_t *ad = (mh_appdata_t *)data;
662 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
663 __hide_btn_changed_cb(ad, obj, NULL);
665 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility_new ?
666 EINA_FALSE : EINA_TRUE);
668 __MOBILE_AP_FUNC_EXIT__;
671 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
673 __MOBILE_AP_FUNC_ENTER__;
675 if (data == NULL || obj == NULL || event_info == NULL) {
676 ERR("param is NULL\n");
680 mh_appdata_t *ad = (mh_appdata_t *)data;
682 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
683 __security_btn_changed_cb(data, obj, NULL);
684 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type_new ==
685 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
687 __MOBILE_AP_FUNC_EXIT__;
690 static void __set_genlist_itc(mh_appdata_t *ad)
692 __MOBILE_AP_FUNC_ENTER__;
694 ad->setup.name_itc = elm_genlist_item_class_new();
695 if (ad->setup.name_itc == NULL) {
696 ERR("elm_genlist_item_class_new failed\n");
697 __MOBILE_AP_FUNC_EXIT__;
700 ad->setup.name_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
701 ad->setup.name_itc->func.text_get = __gl_device_name_title_label_get;
702 ad->setup.name_itc->func.content_get = NULL;
703 ad->setup.name_itc->func.state_get = NULL;
704 ad->setup.name_itc->func.del = NULL;
706 ad->setup.hide_itc = elm_genlist_item_class_new();
707 if (ad->setup.hide_itc == NULL) {
708 ERR("elm_genlist_item_class_new failed\n");
709 __MOBILE_AP_FUNC_EXIT__;
712 ad->setup.hide_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
713 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
714 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
715 ad->setup.hide_itc->func.state_get = NULL;
716 ad->setup.hide_itc->func.del = NULL;
718 ad->setup.security_itc = elm_genlist_item_class_new();
719 if (ad->setup.security_itc == NULL) {
720 ERR("elm_genlist_item_class_new failed\n");
721 __MOBILE_AP_FUNC_EXIT__;
724 ad->setup.security_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
725 ad->setup.security_itc->func.text_get = __gl_security_label_get;
726 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
727 ad->setup.security_itc->func.state_get = NULL;
728 ad->setup.security_itc->func.del = NULL;
730 ad->setup.pw_itc = elm_genlist_item_class_new();
731 if (ad->setup.pw_itc == NULL) {
732 ERR("elm_genlist_item_class_new failed\n");
733 __MOBILE_AP_FUNC_EXIT__;
736 ad->setup.pw_itc->item_style = MH_GENLIST_FULL_CONTENT_STYLE;
737 ad->setup.pw_itc->func.text_get = NULL;
738 ad->setup.pw_itc->func.content_get = __gl_pw_content_get;
739 ad->setup.pw_itc->func.state_get = NULL;
740 ad->setup.pw_itc->func.del = NULL;
742 ad->setup.check_box_itc = elm_genlist_item_class_new();
743 if (ad->setup.check_box_itc == NULL) {
744 ERR("elm_genlist_item_class_new failed\n");
745 __MOBILE_AP_FUNC_EXIT__;
748 ad->setup.check_box_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
749 ad->setup.check_box_itc->func.text_get = _gl_pswd_check_box_text_get;
750 ad->setup.check_box_itc->func.content_get = _gl_pswd_check_box_content_get;
751 ad->setup.check_box_itc->func.state_get = NULL;
752 ad->setup.check_box_itc->func.del = NULL;
754 __MOBILE_AP_FUNC_EXIT__;
758 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
760 __MOBILE_AP_FUNC_ENTER__;
767 evas_object_smart_callback_del(st->hide_btn, "changed",
768 __hide_btn_changed_cb);
769 evas_object_smart_callback_del(st->security_btn, "changed",
770 __security_btn_changed_cb);
771 evas_object_smart_callback_del(st->cancel_button, "clicked",
773 evas_object_smart_callback_del(st->save_button, "clicked",
775 evas_object_smart_callback_del(st->genlist, "realized",
778 __MOBILE_AP_FUNC_EXIT__;
781 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
783 if (user_data == NULL) {
784 ERR("Invalid parameter\n");
788 __MOBILE_AP_FUNC_ENTER__;
790 g_source_remove(tethering_param_timer);
792 mh_appdata_t *ad = (mh_appdata_t *)user_data;
794 if (result != TETHERING_ERROR_NONE)
795 ERR("tethering_wifi_reload_settings is failed [0x%X]\n", result);
796 _update_wifi_item(ad, MH_STATE_NONE);
798 __MOBILE_AP_FUNC_EXIT__;
803 static gboolean _update_tethering_param(gpointer data)
805 __MOBILE_AP_FUNC_ENTER__;
806 mh_appdata_t *ad = (mh_appdata_t *)data;
807 #ifndef TIZEN_FEATURE_EMULATOR
812 ERR("Invalid parameter\n");
816 #ifndef TIZEN_FEATURE_EMULATOR
817 /* reload wifi settings */
818 ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb,
820 if (ret != TETHERING_ERROR_NONE)
821 ERR("reload_configuration is failed : %d\n", ret);
823 __settings_reloaded_cb(TETHERING_ERROR_NONE, (void *)ad);
826 __MOBILE_AP_FUNC_EXIT__;
830 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info)
834 ERR("data is NULL\n");
838 mh_appdata_t *ad = (mh_appdata_t *)data;
839 mh_wifi_setting_view_t *st = &ad->setup;
840 bool is_setting_changed = false;
841 #ifndef TIZEN_FEATURE_EMULATOR
844 /* handle hide button change */
845 if (st->visibility != st->visibility_new) {
846 ret = __save_hide_btn_change(ad);
848 elm_check_state_set(st->hide_btn, st->visibility ?
849 EINA_FALSE : EINA_TRUE);
851 st->visibility = st->visibility_new;
852 is_setting_changed = true;
855 /* handle security button change */
856 if (st->security_type != st->security_type_new) {
857 ret = __save_security_btn_change(ad);
859 elm_check_state_set(st->security_btn, st->security_type ==
860 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
862 st->security_type = st->security_type_new;
863 is_setting_changed = true;
867 /* handle wifi passphrase change */
868 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
869 ret = __save_wifi_passphrase(ad);
871 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
872 sizeof(st->wifi_passphrase_new));
874 elm_genlist_item_update(st->pw_item);
876 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
877 sizeof(st->wifi_passphrase));
878 is_setting_changed = true;
879 if (ad->main.help_item)
880 elm_genlist_item_update(ad->main.help_item);
884 is_setting_changed = true;
885 ad->setup.visibility = ad->setup.visibility_new;
886 ad->setup.security_type = ad->setup.security_type_new;
887 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
888 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
889 sizeof(st->wifi_passphrase));
893 if (is_setting_changed) {
894 _update_wifi_item(ad, MH_STATE_PROCESS);
896 if (ad->main.help_item)
897 elm_genlist_item_update(ad->main.help_item);
899 /* Here, The Dbus takes some amount of time
900 to set the tethering parameters, due to
901 which UI shows incorrect display, to avoid
902 this issue, CAPI will be called after 0.1sec for smooth
903 transition of UI frames */
904 tethering_param_timer = g_timeout_add(100,
905 _update_tethering_param, ad);
908 elm_naviframe_item_pop(ad->naviframe);
914 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info)
919 ERR("The param is NULL\n");
923 mh_appdata_t *ad = (mh_appdata_t *)data;
925 elm_naviframe_item_pop(ad->naviframe);
930 Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item)
935 ERR("The param is NULL\n");
939 mh_appdata_t *ad = (mh_appdata_t *)data;
940 mh_wifi_setting_view_t *st = &ad->setup;
942 if (st->visibility != st->visibility_new)
943 st->visibility_new = st->visibility;
945 if (st->security_type != st->security_type_new)
946 st->security_type_new = st->security_type;
948 if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) {
949 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
950 sizeof(st->wifi_passphrase_new));
953 __deconstruct_wifi_setup_view(st);
955 if (ad->rename_popup != NULL) {
956 evas_object_del(ad->rename_popup);
957 ad->rename_popup = NULL;
959 ad->setup.navi_it = NULL;
960 _ctxpopup_more_button_callback_add(ad);
966 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
968 __MOBILE_AP_FUNC_ENTER__;
970 mh_appdata_t *ad = (mh_appdata_t *)data;
971 mh_wifi_setting_view_t *st = &(ad->setup);
972 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
975 char str[MH_LABEL_LENGTH_MAX] = {0, };
979 if (item == st->hide_item)
980 elm_object_item_signal_emit(item, "elm,state,top", "");
981 else if (item == st->security_item)
982 elm_object_item_signal_emit(item, "elm,state,center", "");
983 else if (item == st->pw_item)
984 elm_object_item_signal_emit(item, "elm,state,bottom", "");
986 no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]);
987 for (i = 0; i < no_of_sp; i++) {
988 if (item == st->sp_item[i])
989 elm_object_item_access_unregister(item);
992 if (item == st->hide_item || item == st->security_item) {
993 ao = elm_object_item_access_object_get(item);
994 btn = elm_object_item_part_content_get(item, "on&off");
995 snprintf(str, sizeof(str), "%s, %s", "On/off button",
996 (elm_check_state_get(btn) ? "On" : "Off"));
997 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1000 if (item == st->pw_item) {
1001 elm_object_item_access_unregister(item);
1002 ao = elm_object_item_access_register(item);
1003 snprintf(str, sizeof(str), "%s, %s", STR_PASSWORD, st->wifi_passphrase_new);
1004 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1007 __MOBILE_AP_FUNC_EXIT__;
1012 static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_info)
1014 __MOBILE_AP_FUNC_ENTER__;
1017 ERR("The param is NULL\n");
1021 mh_appdata_t *ad = (mh_appdata_t *)data;
1022 mh_wifi_setting_view_t *st = &ad->setup;
1024 elm_object_focus_set(st->pw_entry, EINA_TRUE);
1026 __MOBILE_AP_FUNC_EXIT__;
1030 static void __create_password_item(Evas_Object *genlist, mh_appdata_t *ad)
1032 void *data = (void *)ad;
1033 mh_wifi_setting_view_t *st = &ad->setup;
1035 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
1036 ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad);
1037 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
1038 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
1040 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
1042 st->check_box_item = elm_genlist_item_append(genlist, st->check_box_itc, data, NULL,
1043 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1046 static void __destroy_password_item(mh_appdata_t *ad)
1048 mh_wifi_setting_view_t *st = &ad->setup;
1050 elm_object_item_del(st->check_box_item);
1051 st->check_box_item = NULL;
1053 elm_object_item_del(st->pw_item);
1057 Evas_Object *__create_genlist(mh_appdata_t *ad)
1059 __MOBILE_AP_FUNC_ENTER__;
1062 ERR("ad is NULL\n");
1066 void *data = (void *)ad;
1067 mh_wifi_setting_view_t *st = &ad->setup;
1068 Evas_Object *genlist;
1070 genlist = elm_genlist_add(ad->naviframe);
1071 if (genlist == NULL) {
1072 ERR("genlist is NULL\n");
1076 elm_object_style_set(genlist, "dialogue");
1077 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1078 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
1080 __set_genlist_itc(ad);
1082 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
1083 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1084 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1087 elm_object_item_disabled_set(st->name_item, EINA_TRUE);
1089 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
1090 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
1092 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
1093 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
1095 if (st->security_type != TETHERING_WIFI_SECURITY_TYPE_NONE)
1096 __create_password_item(genlist, ad);
1098 __MOBILE_AP_FUNC_EXIT__;
1103 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
1108 ERR("ad is NULL\n");
1113 mh_wifi_setting_view_t *st = &ad->setup;
1115 if (ad->setup.navi_it != NULL) {
1116 ERR("Wi-Fi setup view already exists\n");
1121 st->genlist = __create_genlist(ad);
1122 if (st->genlist == NULL) {
1123 ERR("__create_genlist returns NULL\n");
1128 st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_BODY_CONFIGURE_MOBILE_HOTSPOT_ABB_US_TMO",
1129 NULL, NULL, st->genlist, NULL);
1130 elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);
1132 elm_naviframe_item_pop_cb_set(st->navi_it, _setting_back_btn_cb, (void *)ad);
1134 btn = elm_button_add(ad->naviframe);
1135 elm_object_style_set(btn, "naviframe/title_cancel");
1136 evas_object_smart_callback_add(btn, "clicked", __cancel_btn_cb, ad);
1137 elm_object_item_part_content_set(st->navi_it, "title_left_btn", btn);
1138 st->cancel_button = btn;
1140 btn = elm_button_add(ad->naviframe);
1141 elm_object_style_set(btn, "naviframe/title_done");
1142 evas_object_smart_callback_add(btn, "clicked", __save_btn_cb, ad);
1143 elm_object_item_part_content_set(st->navi_it, "title_right_btn", btn);
1144 st->save_button = btn;