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 __create_password_item(Evas_Object *genlist, mh_appdata_t *ad);
30 static void __destroy_password_item(mh_appdata_t *ad);
32 static guint tethering_param_timer = 0;
34 static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
36 __MOBILE_AP_FUNC_ENTER__;
38 if (data == NULL || obj == NULL) {
39 ERR("Invalid param\n");
43 mh_appdata_t *ad = (mh_appdata_t *)data;
45 ad->setup.visibility_new = !ad->setup.visibility_new;
47 __MOBILE_AP_FUNC_EXIT__;
50 static bool __save_hide_btn_change(mh_appdata_t *ad)
52 __MOBILE_AP_FUNC_ENTER__;
55 ERR("Invalid param\n");
61 ret = tethering_wifi_set_ssid_visibility(ad->handle,
62 ad->setup.visibility_new);
63 if (ret != TETHERING_ERROR_NONE) {
64 ERR("tethering_wifi_set_ssid_visibility is failed : %d\n", ret);
68 __MOBILE_AP_FUNC_EXIT__;
72 static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
74 __MOBILE_AP_FUNC_ENTER__;
76 if (data == NULL || obj == NULL) {
77 ERR("Invalid param\n");
81 mh_appdata_t *ad = (mh_appdata_t *)data;
82 mh_wifi_setting_view_t *st = &ad->setup;
84 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
85 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
86 if (st->pw_item == NULL)
87 __create_password_item(st->genlist, ad);
89 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_NONE;
90 /* Disable password entry */
91 __destroy_password_item(ad);
94 /* update wifi passphrase item */
95 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
96 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
97 elm_object_disabled_set(st->save_button, EINA_FALSE);
99 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
103 elm_genlist_item_update(st->pw_item);
105 __MOBILE_AP_FUNC_EXIT__;
108 static void __check_box_changed_cb(void *data, Evas_Object *obj, void *event_info)
110 __MOBILE_AP_FUNC_ENTER__;
112 if (data == NULL || obj == NULL) {
113 ERR("Invalid param\n");
117 Eina_Bool state = elm_check_state_get(obj);
118 mh_appdata_t *ad = (mh_appdata_t *)data;
119 mh_wifi_setting_view_t *st = &ad->setup;
122 elm_entry_password_set(st->pw_entry, EINA_FALSE);
124 elm_entry_password_set(st->pw_entry, EINA_TRUE);
126 __MOBILE_AP_FUNC_EXIT__;
130 static bool __save_security_btn_change(mh_appdata_t *ad)
132 __MOBILE_AP_FUNC_ENTER__;
135 ERR("Invalid param\n");
141 ret = tethering_wifi_set_security_type(ad->handle, ad->setup.security_type_new);
142 if (ret != TETHERING_ERROR_NONE) {
143 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
147 __MOBILE_AP_FUNC_EXIT__;
151 static char *__gl_device_name_title_label_get(void *data, Evas_Object *obj, const char *part)
153 __MOBILE_AP_FUNC_ENTER__;
154 mh_appdata_t *ad = (mh_appdata_t *)data;
155 char *device_name_utf = NULL;
157 char buf[MH_LABEL_LENGTH_MAX] = {0, };
159 if (data == NULL || obj == NULL || part == NULL) {
160 ERR("Invalid param\n");
164 if (!strcmp("elm.text.multiline", part)) {
165 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
166 if (device_name_utf == NULL)
167 ERR("vconf_get_str failed \n");
169 ptr = elm_entry_utf8_to_markup(device_name_utf);
171 ERR("elm_entry_utf8_to_markup is failed\n");
172 free(device_name_utf);
176 g_strlcpy(ad->setup.device_name, ptr,
177 sizeof(ad->setup.device_name));
179 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size><br>%s", STR_MY_DEVICE_NAME, ptr);
181 free(device_name_utf);
187 __MOBILE_AP_FUNC_EXIT__;
191 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
193 __MOBILE_AP_FUNC_ENTER__;
195 if (data == NULL || obj == NULL || part == NULL) {
196 ERR("Invalid param\n");
200 if (!strcmp("elm.text", part))
201 return strdup(STR_HIDE_MY_DEV);
203 __MOBILE_AP_FUNC_EXIT__;
207 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
209 __MOBILE_AP_FUNC_ENTER__;
211 if (data == NULL || obj == NULL || part == NULL) {
212 ERR("Invalid param\n");
216 if (!strcmp("elm.text", part))
217 return strdup(STR_SECURITY_TYPE);
219 __MOBILE_AP_FUNC_EXIT__;
223 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
226 __MOBILE_AP_FUNC_ENTER__;
228 mh_appdata_t *ad = (mh_appdata_t *)data;
229 Evas_Object *btn = NULL;
231 if (data == NULL || obj == NULL || part == NULL) {
232 ERR("Invalid param\n");
236 if (!strcmp("elm.swallow.end", part)) {
237 btn = elm_check_add(obj);
239 ERR("btn is NULL\n");
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_object_focus_allow_set(btn, EINA_FALSE);
248 elm_check_state_set(btn, ad->setup.visibility_new ? EINA_FALSE : EINA_TRUE);
249 evas_object_smart_callback_add(btn, "changed",
250 __hide_btn_changed_cb, (void *)ad);
251 ad->setup.hide_btn = btn;
254 __MOBILE_AP_FUNC_EXIT__;
258 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
261 __MOBILE_AP_FUNC_ENTER__;
263 mh_appdata_t *ad = (mh_appdata_t *)data;
264 Evas_Object *btn = NULL;
266 if (data == NULL || obj == NULL || part == NULL) {
267 ERR("Invalid param\n");
271 if (!strcmp("elm.swallow.end", part)) {
272 btn = elm_check_add(obj);
273 elm_object_style_set(btn, "on&off");
274 evas_object_show(btn);
275 evas_object_pass_events_set(btn, EINA_TRUE);
276 evas_object_propagate_events_set(btn, EINA_FALSE);
277 elm_check_state_set(btn, ad->setup.security_type_new ==
278 TETHERING_WIFI_SECURITY_TYPE_NONE ?
279 EINA_FALSE : EINA_TRUE);
280 evas_object_smart_callback_add(btn, "changed",
281 __security_btn_changed_cb, (void *)ad);
282 ad->setup.security_btn = btn;
285 __MOBILE_AP_FUNC_EXIT__;
289 static bool __save_wifi_passphrase(mh_appdata_t *ad)
291 __MOBILE_AP_FUNC_ENTER__;
294 ERR("Invalid param\n");
298 mh_wifi_setting_view_t *st = &ad->setup;
301 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
302 if (ret != TETHERING_ERROR_NONE) {
303 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
307 __MOBILE_AP_FUNC_EXIT__;
311 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
314 __MOBILE_AP_FUNC_ENTER__;
316 mh_appdata_t *ad = (mh_appdata_t *)data;
317 mh_wifi_setting_view_t *st = &ad->setup;
318 const char *changed_text;
322 changed_text = elm_entry_entry_get(obj);
323 if (changed_text == NULL) {
324 ERR("elm_entry_entry_get is failed\n");
328 utf8_string = elm_entry_markup_to_utf8(changed_text);
330 if (utf8_string == NULL) {
331 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
333 len = strlen(utf8_string);
334 if (WIFI_PASSPHRASE_LENGTH_MIN <= len) {
335 elm_object_disabled_set(st->save_button, EINA_FALSE);
336 elm_entry_input_panel_return_key_disabled_set(obj, FALSE);
338 elm_object_disabled_set(st->save_button, EINA_TRUE);
339 elm_entry_input_panel_return_key_disabled_set(obj, TRUE);
341 g_strlcpy(st->wifi_passphrase_new, utf8_string,
342 sizeof(st->wifi_passphrase_new));
347 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
348 if (elm_object_focus_get(obj)) {
349 if (elm_entry_is_empty(obj))
350 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
352 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
356 __MOBILE_AP_FUNC_EXIT__;
360 static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj,
363 __MOBILE_AP_FUNC_ENTER__;
366 ERR("The param is NULL\n");
367 __MOBILE_AP_FUNC_EXIT__;
370 char buf[MH_LABEL_LENGTH_MAX] = { 0, };
371 char *fmt = STR_PASSWORD_MIN_MAX;
372 notification_error_e ret;
374 snprintf(buf, sizeof(buf), fmt,
375 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
377 ret = notification_status_message_post(buf);
378 if (ret != NOTIFICATION_ERROR_NONE)
379 ERR("notification_status_message_post() is failed : %d\n", ret);
381 __MOBILE_AP_FUNC_EXIT__;
384 static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
386 __MOBILE_AP_FUNC_ENTER__;
389 ERR("Invalid parameter");
393 elm_object_focus_set(obj, EINA_FALSE);
394 __MOBILE_AP_FUNC_EXIT__;
398 static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
400 __MOBILE_AP_FUNC_ENTER__;
401 evas_object_smart_callback_del(obj, "focused", __pw_entry_focused_cb);
403 elm_object_focus_set(obj, EINA_TRUE);
404 elm_entry_cursor_end_set(obj);
405 __MOBILE_AP_FUNC_EXIT__;
408 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
410 __MOBILE_AP_FUNC_ENTER__;
411 if (elm_object_part_content_get(obj, "elm.swallow.clear"))
412 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
413 elm_object_signal_emit(obj, "elm,state,focus,off", "");
414 __MOBILE_AP_FUNC_EXIT__;
417 static void __pw_entry_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
419 __MOBILE_AP_FUNC_ENTER__;
420 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __pw_entry_show_cb);
422 elm_object_focus_set(obj, EINA_TRUE);
423 elm_entry_cursor_end_set(obj);
424 __MOBILE_AP_FUNC_EXIT__;
427 static void __eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
429 __MOBILE_AP_FUNC_ENTER__;
431 elm_object_text_set(data, "");
432 elm_entry_input_panel_return_key_disabled_set(data, TRUE);
434 __MOBILE_AP_FUNC_EXIT__;
437 static void __pw_entry_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
439 __MOBILE_AP_FUNC_ENTER__;
441 if (obj == NULL || data == NULL) {
445 mh_appdata_t *ad = (mh_appdata_t *)data;
446 mh_wifi_setting_view_t *st = &ad->setup;
447 char buf[MH_LABEL_LENGTH_MAX];
448 char *fmt = STR_PW_GUIDE_TEXT;
450 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
452 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
454 elm_genlist_item_update(st->pw_item);
456 elm_object_part_text_set(obj, "elm.guide", buf);
458 __MOBILE_AP_FUNC_EXIT__;
461 static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent)
463 __MOBILE_AP_FUNC_ENTER__;
465 static Elm_Entry_Filter_Limit_Size limit_filter_data;
466 Evas_Object *entry = NULL;
467 char *fmt = STR_PW_GUIDE_TEXT;
469 Evas_Object * clr_btn = NULL;
470 char buf[MH_LABEL_LENGTH_MAX];
472 if (parent == NULL || data == NULL) {
473 ERR("null param \n");
477 mh_appdata_t *ad = (mh_appdata_t *)data;
478 mh_wifi_setting_view_t *st = &ad->setup;
480 entry = elm_entry_add(parent);
483 ERR("elm_entry_add returns NULL\n");
488 elm_entry_single_line_set(entry, EINA_TRUE);
489 elm_entry_scrollable_set(entry, EINA_TRUE);
490 elm_entry_password_set(entry, EINA_TRUE);
492 evas_object_smart_callback_add(entry, "language,changed",
493 __pw_entry_language_changed_cb, ad);
495 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
496 elm_entry_prediction_allow_set(entry, EINA_FALSE);
497 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
498 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
499 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
500 elm_object_part_text_set(entry, "guide", buf);
501 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
503 limit_filter_data.max_char_count = 0;
504 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
505 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
507 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
508 elm_object_part_text_set(entry, "default", buf);
509 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
510 elm_object_disabled_set(entry, EINA_TRUE);
512 elm_object_item_signal_emit(st->pw_item, "elm,state,rename,hide", "");
515 elm_object_disabled_set(entry, EINA_FALSE);
516 elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
517 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
519 elm_object_text_set(entry, ptr);
522 ERR("elm_entry_utf8_to_markup is failed\n");
526 elm_entry_input_panel_return_key_type_set(entry,
527 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
529 clr_btn = elm_button_add(entry);
530 elm_object_style_set(clr_btn, "search_clear");
531 elm_object_focus_allow_set(clr_btn, EINA_FALSE);
532 elm_object_part_content_set(entry, "elm.swallow.clear", clr_btn);
533 evas_object_smart_callback_add(clr_btn, "clicked", __eraser_btn_clicked_cb, entry);
534 evas_object_show(clr_btn);
536 evas_object_smart_callback_add(entry, "changed",
537 __pw_entry_changed_cb, ad);
538 evas_object_smart_callback_add(entry, "maxlength,reached",
539 __pw_entry_maxlength_reached_cb, ad);
540 evas_object_smart_callback_add(entry, "activated",
541 __pw_entry_activated_cb, NULL);
542 evas_object_smart_callback_add(entry, "focused",
543 __pw_entry_focused_cb, NULL);
544 evas_object_smart_callback_add(entry, "unfocused",
545 __pw_entry_unfocused_cb, NULL);
546 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
547 __pw_entry_show_cb, NULL);
549 elm_object_focus_set(entry, EINA_TRUE);
550 elm_entry_input_panel_show(entry);
551 elm_object_part_content_set(parent, "elm.swallow.content", entry);
553 st->pw_entry = entry;
555 __MOBILE_AP_FUNC_EXIT__;
559 static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part)
561 __MOBILE_AP_FUNC_ENTER__;
567 ERR("data is null \n");
571 if (!strcmp(part, "elm.swallow.content")) {
572 Evas_Object *box = elm_box_add(obj);
573 Evas_Object *label = elm_label_add(box);
574 Evas_Object *layout = elm_layout_add(box);
575 char buf[MH_LABEL_LENGTH_MAX] = {0, };
577 elm_box_align_set(box, 0.0, 0.0);
579 /* Set label for name field */
580 snprintf(buf, MH_LABEL_LENGTH_MAX, "<text align=left><font_size=30>%s</font_size></text>", STR_PASSWORD);
581 elm_object_text_set(label, buf);
582 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
583 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
584 evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), 0, 0);
585 elm_box_pack_end(box, label);
586 evas_object_show(label);
588 /* Set layout for entry field */
589 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
590 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
591 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
593 __get_pw_entry(data, layout);
594 evas_object_show(layout);
595 elm_box_pack_end(box, layout);
597 evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
598 evas_object_show(box);
603 __MOBILE_AP_FUNC_EXIT__;
607 static char *_gl_pswd_check_box_text_get(void *data,
608 Evas_Object *obj, const char *part)
610 if (!strcmp("elm.text", part))
611 return strdup(STR_SHOW_PASSWORD);
617 static Evas_Object *_gl_pswd_check_box_content_get(void *data,
618 Evas_Object *obj, const char *part)
620 mh_appdata_t *ad = (mh_appdata_t *)data;
621 Evas_Object *check = NULL;
623 if (data == NULL || obj == NULL || part == NULL) {
624 ERR("Invalid param\n");
628 if (!strcmp("elm.swallow.icon", part)) {
629 check = elm_check_add(obj);
630 evas_object_propagate_events_set(check, EINA_FALSE);
632 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
633 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
634 evas_object_smart_callback_add(check, "changed", __check_box_changed_cb, (void *)ad);
636 elm_object_focus_allow_set(check, EINA_FALSE);
644 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
646 __MOBILE_AP_FUNC_ENTER__;
648 if (data == NULL || obj == NULL || event_info == NULL) {
649 ERR("param is NULL\n");
653 mh_appdata_t *ad = (mh_appdata_t *)data;
655 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
656 __hide_btn_changed_cb(ad, obj, NULL);
658 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility_new ?
659 EINA_FALSE : EINA_TRUE);
661 __MOBILE_AP_FUNC_EXIT__;
664 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
666 __MOBILE_AP_FUNC_ENTER__;
668 if (data == NULL || obj == NULL || event_info == NULL) {
669 ERR("param is NULL\n");
673 mh_appdata_t *ad = (mh_appdata_t *)data;
675 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
676 __security_btn_changed_cb(data, obj, NULL);
677 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type_new ==
678 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
680 __MOBILE_AP_FUNC_EXIT__;
683 static void __set_genlist_itc(mh_appdata_t *ad)
685 __MOBILE_AP_FUNC_ENTER__;
687 ad->setup.name_itc = elm_genlist_item_class_new();
688 if (ad->setup.name_itc == NULL) {
689 ERR("elm_genlist_item_class_new failed\n");
690 __MOBILE_AP_FUNC_EXIT__;
693 ad->setup.name_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
694 ad->setup.name_itc->func.text_get = __gl_device_name_title_label_get;
695 ad->setup.name_itc->func.content_get = NULL;
696 ad->setup.name_itc->func.state_get = NULL;
697 ad->setup.name_itc->func.del = NULL;
699 ad->setup.hide_itc = elm_genlist_item_class_new();
700 if (ad->setup.hide_itc == NULL) {
701 ERR("elm_genlist_item_class_new failed\n");
702 __MOBILE_AP_FUNC_EXIT__;
705 ad->setup.hide_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
706 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
707 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
708 ad->setup.hide_itc->func.state_get = NULL;
709 ad->setup.hide_itc->func.del = NULL;
711 ad->setup.security_itc = elm_genlist_item_class_new();
712 if (ad->setup.security_itc == NULL) {
713 ERR("elm_genlist_item_class_new failed\n");
714 __MOBILE_AP_FUNC_EXIT__;
717 ad->setup.security_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
718 ad->setup.security_itc->func.text_get = __gl_security_label_get;
719 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
720 ad->setup.security_itc->func.state_get = NULL;
721 ad->setup.security_itc->func.del = NULL;
723 ad->setup.pw_itc = elm_genlist_item_class_new();
724 if (ad->setup.pw_itc == NULL) {
725 ERR("elm_genlist_item_class_new failed\n");
726 __MOBILE_AP_FUNC_EXIT__;
729 ad->setup.pw_itc->item_style = MH_GENLIST_FULL_CONTENT_STYLE;
730 ad->setup.pw_itc->func.text_get = NULL;
731 ad->setup.pw_itc->func.content_get = __gl_pw_content_get;
732 ad->setup.pw_itc->func.state_get = NULL;
733 ad->setup.pw_itc->func.del = NULL;
735 ad->setup.check_box_itc = elm_genlist_item_class_new();
736 if (ad->setup.check_box_itc == NULL) {
737 ERR("elm_genlist_item_class_new failed\n");
738 __MOBILE_AP_FUNC_EXIT__;
741 ad->setup.check_box_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
742 ad->setup.check_box_itc->func.text_get = _gl_pswd_check_box_text_get;
743 ad->setup.check_box_itc->func.content_get = _gl_pswd_check_box_content_get;
744 ad->setup.check_box_itc->func.state_get = NULL;
745 ad->setup.check_box_itc->func.del = NULL;
747 __MOBILE_AP_FUNC_EXIT__;
751 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
753 __MOBILE_AP_FUNC_ENTER__;
760 evas_object_smart_callback_del(st->hide_btn, "changed",
761 __hide_btn_changed_cb);
762 evas_object_smart_callback_del(st->security_btn, "changed",
763 __security_btn_changed_cb);
764 evas_object_smart_callback_del(st->cancel_button, "clicked",
766 evas_object_smart_callback_del(st->save_button, "clicked",
768 evas_object_smart_callback_del(st->genlist, "realized",
771 __MOBILE_AP_FUNC_EXIT__;
774 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
776 if (user_data == NULL) {
777 ERR("Invalid parameter\n");
781 __MOBILE_AP_FUNC_ENTER__;
783 g_source_remove(tethering_param_timer);
785 mh_appdata_t *ad = (mh_appdata_t *)user_data;
787 if (result != TETHERING_ERROR_NONE)
788 ERR("tethering_wifi_reload_settings is failed [0x%X]\n", result);
789 _update_wifi_item(ad, MH_STATE_NONE);
791 __MOBILE_AP_FUNC_EXIT__;
796 static gboolean _update_tethering_param(gpointer data)
798 __MOBILE_AP_FUNC_ENTER__;
799 mh_appdata_t *ad = (mh_appdata_t *)data;
803 ERR("Invalid parameter\n");
807 /* reload wifi settings */
808 ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb,
810 if (ret != TETHERING_ERROR_NONE)
811 ERR("reload_configuration is failed : %d\n", ret);
813 __MOBILE_AP_FUNC_EXIT__;
817 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info)
821 ERR("data is NULL\n");
825 mh_appdata_t *ad = (mh_appdata_t *)data;
826 mh_wifi_setting_view_t *st = &ad->setup;
828 bool is_setting_changed = false;
830 /* handle hide button change */
831 if (st->visibility != st->visibility_new) {
832 ret = __save_hide_btn_change(ad);
834 elm_check_state_set(st->hide_btn, st->visibility ?
835 EINA_FALSE : EINA_TRUE);
837 st->visibility = st->visibility_new;
838 is_setting_changed = true;
841 /* handle security button change */
842 if (st->security_type != st->security_type_new) {
843 ret = __save_security_btn_change(ad);
845 elm_check_state_set(st->security_btn, st->security_type ==
846 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
848 st->security_type = st->security_type_new;
849 is_setting_changed = true;
853 /* handle wifi passphrase change */
854 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
855 ret = __save_wifi_passphrase(ad);
857 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
858 sizeof(st->wifi_passphrase_new));
860 elm_genlist_item_update(st->pw_item);
862 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
863 sizeof(st->wifi_passphrase));
864 is_setting_changed = true;
865 if (ad->main.help_item) {
866 if (ad->main.help_item)
867 elm_genlist_item_update(ad->main.help_item);
872 if (is_setting_changed) {
873 _update_wifi_item(ad, MH_STATE_PROCESS);
875 if (ad->main.help_item)
876 elm_genlist_item_update(ad->main.help_item);
878 /* Here, The Dbus takes some amount of time
879 to set the tethering parameters, due to
880 which UI shows incorrect display, to avoid
881 this issue, CAPI will be called after 0.1sec for smooth
882 transition of UI frames */
883 tethering_param_timer = g_timeout_add(100,
884 _update_tethering_param, ad);
887 elm_naviframe_item_pop(ad->naviframe);
893 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info)
898 ERR("The param is NULL\n");
902 mh_appdata_t *ad = (mh_appdata_t *)data;
904 elm_naviframe_item_pop(ad->naviframe);
909 Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item)
914 ERR("The param is NULL\n");
918 mh_appdata_t *ad = (mh_appdata_t *)data;
919 mh_wifi_setting_view_t *st = &ad->setup;
921 if (st->visibility != st->visibility_new)
922 st->visibility_new = st->visibility;
924 if (st->security_type != st->security_type_new)
925 st->security_type_new = st->security_type;
927 if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) {
928 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
929 sizeof(st->wifi_passphrase_new));
932 __deconstruct_wifi_setup_view(st);
934 if (ad->rename_popup != NULL) {
935 evas_object_del(ad->rename_popup);
936 ad->rename_popup = NULL;
938 ad->setup.navi_it = NULL;
944 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
946 __MOBILE_AP_FUNC_ENTER__;
948 mh_appdata_t *ad = (mh_appdata_t *)data;
949 mh_wifi_setting_view_t *st = &(ad->setup);
950 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
953 char str[MH_LABEL_LENGTH_MAX] = {0, };
957 if (item == st->hide_item)
958 elm_object_item_signal_emit(item, "elm,state,top", "");
959 else if (item == st->security_item)
960 elm_object_item_signal_emit(item, "elm,state,center", "");
961 else if (item == st->pw_item)
962 elm_object_item_signal_emit(item, "elm,state,bottom", "");
964 no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]);
965 for (i = 0; i < no_of_sp; i++) {
966 if (item == st->sp_item[i])
967 elm_object_item_access_unregister(item);
970 if (item == st->hide_item || item == st->security_item) {
971 ao = elm_object_item_access_object_get(item);
972 btn = elm_object_item_part_content_get(item, "on&off");
973 snprintf(str, sizeof(str), "%s, %s", "On/off button",
974 (elm_check_state_get(btn) ? "On" : "Off"));
975 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
978 if (item == st->pw_item) {
979 elm_object_item_access_unregister(item);
980 ao = elm_object_item_access_register(item);
981 snprintf(str, sizeof(str), "%s, %s", STR_PASSWORD, st->wifi_passphrase_new);
982 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
985 __MOBILE_AP_FUNC_EXIT__;
990 static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_info)
992 __MOBILE_AP_FUNC_ENTER__;
995 ERR("The param is NULL\n");
999 mh_appdata_t *ad = (mh_appdata_t *)data;
1000 mh_wifi_setting_view_t *st = &ad->setup;
1002 elm_object_focus_set(st->pw_entry, EINA_TRUE);
1004 __MOBILE_AP_FUNC_EXIT__;
1008 static void __create_password_item(Evas_Object *genlist, mh_appdata_t *ad)
1010 void *data = (void *)ad;
1011 mh_wifi_setting_view_t *st = &ad->setup;
1013 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
1014 ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad);
1015 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
1016 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
1018 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
1020 st->check_box_item = elm_genlist_item_append(genlist, st->check_box_itc, data, NULL,
1021 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1024 static void __destroy_password_item(mh_appdata_t *ad)
1026 void *data = (void *)ad;
1027 mh_wifi_setting_view_t *st = &ad->setup;
1029 elm_object_item_del(st->check_box_item);
1030 st->check_box_item = NULL;
1032 elm_object_item_del(st->pw_item);
1036 Evas_Object *__create_genlist(mh_appdata_t *ad)
1038 __MOBILE_AP_FUNC_ENTER__;
1041 ERR("ad is NULL\n");
1045 void *data = (void *)ad;
1046 mh_wifi_setting_view_t *st = &ad->setup;
1047 Evas_Object *genlist;
1049 genlist = elm_genlist_add(ad->naviframe);
1050 if (genlist == NULL) {
1051 ERR("genlist is NULL\n");
1055 elm_object_style_set(genlist, "dialogue");
1056 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1057 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
1059 __set_genlist_itc(ad);
1061 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
1062 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1063 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1066 elm_object_item_disabled_set(st->name_item, EINA_TRUE);
1068 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
1069 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
1071 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
1072 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
1074 if (st->security_type != TETHERING_WIFI_SECURITY_TYPE_NONE)
1075 __create_password_item(genlist, ad);
1077 __MOBILE_AP_FUNC_EXIT__;
1082 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
1087 ERR("ad is NULL\n");
1092 mh_wifi_setting_view_t *st = &ad->setup;
1094 if (ad->setup.navi_it != NULL) {
1095 ERR("Wi-Fi setup view already exists\n");
1100 st->genlist = __create_genlist(ad);
1101 if (st->genlist == NULL) {
1102 ERR("__create_genlist returns NULL\n");
1107 st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_BODY_CONFIGURE_MOBILE_HOTSPOT_ABB_US_TMO",
1108 NULL, NULL, st->genlist, NULL);
1109 elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);
1111 elm_naviframe_item_pop_cb_set(st->navi_it, _setting_back_btn_cb, (void *)ad);
1113 btn = elm_button_add(ad->naviframe);
1114 elm_object_style_set(btn, "naviframe/title_cancel");
1115 evas_object_smart_callback_add(btn, "clicked", __cancel_btn_cb, ad);
1116 elm_object_item_part_content_set(st->navi_it, "title_left_btn", btn);
1117 st->cancel_button = btn;
1119 btn = elm_button_add(ad->naviframe);
1120 elm_object_style_set(btn, "naviframe/title_done");
1121 evas_object_smart_callback_add(btn, "clicked", __save_btn_cb, ad);
1122 elm_object_item_part_content_set(st->navi_it, "title_right_btn", btn);
1123 st->save_button = btn;