4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.tizenopensource.org/license
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include <efl_extension.h>
22 #include "mh_view_wifi_setup.h"
23 #include "mh_string.h"
25 static void __gl_realized(void *data, Evas_Object *obj, void *event_info);
26 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info);
27 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info);
29 static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
31 __MOBILE_AP_FUNC_ENTER__;
33 if (data == NULL || obj == NULL) {
34 ERR("Invalid param\n");
38 mh_appdata_t *ad = (mh_appdata_t *)data;
40 ad->setup.visibility_new = !ad->setup.visibility_new;
42 __MOBILE_AP_FUNC_EXIT__;
45 static bool __save_hide_btn_change(mh_appdata_t *ad)
47 __MOBILE_AP_FUNC_ENTER__;
50 ERR("Invalid param\n");
56 ret = tethering_wifi_set_ssid_visibility(ad->handle,
57 ad->setup.visibility_new);
58 if (ret != TETHERING_ERROR_NONE) {
59 ERR("tethering_wifi_set_ssid_visibility is failed : %d\n", ret);
63 __MOBILE_AP_FUNC_EXIT__;
67 static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
69 __MOBILE_AP_FUNC_ENTER__;
71 if (data == NULL || obj == NULL) {
72 ERR("Invalid param\n");
76 mh_appdata_t *ad = (mh_appdata_t *)data;
77 mh_wifi_setting_view_t *st = &ad->setup;
79 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE)
80 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
82 st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_NONE;
84 /* update wifi passphrase item */
85 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
86 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
87 elm_object_disabled_set(st->save_button, EINA_FALSE);
89 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
93 elm_genlist_item_update(st->pw_item);
95 __MOBILE_AP_FUNC_EXIT__;
98 static bool __save_security_btn_change(mh_appdata_t *ad)
100 __MOBILE_AP_FUNC_ENTER__;
103 ERR("Invalid param\n");
109 ret = tethering_wifi_set_security_type(ad->handle, ad->setup.security_type_new);
110 if (ret != TETHERING_ERROR_NONE) {
111 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
115 __MOBILE_AP_FUNC_EXIT__;
119 static char *__gl_device_name_title_label_get(void *data, Evas_Object *obj, const char *part)
121 __MOBILE_AP_FUNC_ENTER__;
122 mh_appdata_t *ad = (mh_appdata_t *)data;
123 char *device_name_utf = NULL;
125 char buf[MH_LABEL_LENGTH_MAX] = {0, };
127 if (data == NULL || obj == NULL || part == NULL) {
128 ERR("Invalid param\n");
132 if (!strcmp("elm.text.multiline", part)) {
133 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
134 if (device_name_utf == NULL)
135 ERR("vconf_get_str failed \n");
137 ptr = elm_entry_utf8_to_markup(device_name_utf);
139 ERR("elm_entry_utf8_to_markup is failed\n");
140 free(device_name_utf);
144 g_strlcpy(ad->setup.device_name, ptr,
145 sizeof(ad->setup.device_name));
147 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size><br>%s", STR_MY_DEVICE_NAME, ptr);
149 free(device_name_utf);
155 __MOBILE_AP_FUNC_EXIT__;
159 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
161 __MOBILE_AP_FUNC_ENTER__;
163 if (data == NULL || obj == NULL || part == NULL) {
164 ERR("Invalid param\n");
168 if (!strcmp("elm.text", part))
169 return strdup(STR_HIDE_MY_DEV);
171 __MOBILE_AP_FUNC_EXIT__;
175 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
177 __MOBILE_AP_FUNC_ENTER__;
179 if (data == NULL || obj == NULL || part == NULL) {
180 ERR("Invalid param\n");
184 if (!strcmp("elm.text", part))
185 return strdup(STR_SECURITY_TYPE);
187 __MOBILE_AP_FUNC_EXIT__;
191 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
194 __MOBILE_AP_FUNC_ENTER__;
196 mh_appdata_t *ad = (mh_appdata_t *)data;
197 Evas_Object *btn = NULL;
199 if (data == NULL || obj == NULL || part == NULL) {
200 ERR("Invalid param\n");
204 if (!strcmp("elm.swallow.end", part)) {
205 btn = elm_check_add(obj);
207 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_object_focus_allow_set(btn, EINA_FALSE);
216 elm_check_state_set(btn, ad->setup.visibility_new ? EINA_FALSE : EINA_TRUE);
217 evas_object_smart_callback_add(btn, "changed",
218 __hide_btn_changed_cb, (void *)ad);
219 ad->setup.hide_btn = btn;
222 __MOBILE_AP_FUNC_EXIT__;
226 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
229 __MOBILE_AP_FUNC_ENTER__;
231 mh_appdata_t *ad = (mh_appdata_t *)data;
232 Evas_Object *btn = NULL;
234 if (data == NULL || obj == NULL || part == NULL) {
235 ERR("Invalid param\n");
239 if (!strcmp("elm.swallow.end", part)) {
240 btn = elm_check_add(obj);
241 elm_object_style_set(btn, "on&off");
242 evas_object_show(btn);
243 evas_object_pass_events_set(btn, EINA_TRUE);
244 evas_object_propagate_events_set(btn, EINA_FALSE);
245 elm_check_state_set(btn, ad->setup.security_type_new ==
246 TETHERING_WIFI_SECURITY_TYPE_NONE ?
247 EINA_FALSE : EINA_TRUE);
248 evas_object_smart_callback_add(btn, "changed",
249 __security_btn_changed_cb, (void *)ad);
250 ad->setup.security_btn = btn;
253 __MOBILE_AP_FUNC_EXIT__;
257 static bool __save_wifi_passphrase(mh_appdata_t *ad)
259 __MOBILE_AP_FUNC_ENTER__;
262 ERR("Invalid param\n");
266 mh_wifi_setting_view_t *st = &ad->setup;
269 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
270 if (ret != TETHERING_ERROR_NONE) {
271 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
275 __MOBILE_AP_FUNC_EXIT__;
279 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
282 __MOBILE_AP_FUNC_ENTER__;
284 mh_appdata_t *ad = (mh_appdata_t *)data;
285 mh_wifi_setting_view_t *st = &ad->setup;
286 const char *changed_text;
290 changed_text = elm_entry_entry_get(obj);
291 if (changed_text == NULL) {
292 ERR("elm_entry_entry_get is failed\n");
296 utf8_string = elm_entry_markup_to_utf8(changed_text);
298 if (utf8_string == NULL) {
299 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
301 len = strlen(utf8_string);
302 if (WIFI_PASSPHRASE_LENGTH_MIN <= len) {
303 elm_object_disabled_set(st->save_button, EINA_FALSE);
304 elm_entry_input_panel_return_key_disabled_set(obj, FALSE);
306 elm_object_disabled_set(st->save_button, EINA_TRUE);
307 elm_entry_input_panel_return_key_disabled_set(obj, TRUE);
309 g_strlcpy(st->wifi_passphrase_new, utf8_string,
310 sizeof(st->wifi_passphrase_new));
315 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
316 if (elm_object_focus_get(obj)) {
317 if (elm_entry_is_empty(obj))
318 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
320 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
324 __MOBILE_AP_FUNC_EXIT__;
328 static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj,
331 __MOBILE_AP_FUNC_ENTER__;
334 ERR("The param is NULL\n");
335 __MOBILE_AP_FUNC_EXIT__;
338 char buf[MH_LABEL_LENGTH_MAX] = { 0, };
339 char *fmt = STR_PASSWORD_MIN_MAX;
340 notification_error_e ret;
342 snprintf(buf, sizeof(buf), fmt,
343 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
345 ret = notification_status_message_post(buf);
346 if (ret != NOTIFICATION_ERROR_NONE)
347 ERR("notification_status_message_post() is failed : %d\n", ret);
349 __MOBILE_AP_FUNC_EXIT__;
352 static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
354 __MOBILE_AP_FUNC_ENTER__;
357 ERR("Invalid parameter");
361 elm_object_focus_set(obj, EINA_FALSE);
362 __MOBILE_AP_FUNC_EXIT__;
366 static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
368 __MOBILE_AP_FUNC_ENTER__;
369 evas_object_smart_callback_del(obj, "focused", __pw_entry_focused_cb);
371 elm_object_focus_set(obj, EINA_TRUE);
372 elm_entry_cursor_end_set(obj);
373 __MOBILE_AP_FUNC_EXIT__;
376 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
378 __MOBILE_AP_FUNC_ENTER__;
379 if (elm_object_part_content_get(obj, "elm.swallow.clear"))
380 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
381 elm_object_signal_emit(obj, "elm,state,focus,off", "");
382 __MOBILE_AP_FUNC_EXIT__;
385 static void __pw_entry_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
387 __MOBILE_AP_FUNC_ENTER__;
388 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __pw_entry_show_cb);
390 elm_object_focus_set(obj, EINA_TRUE);
391 elm_entry_cursor_end_set(obj);
392 __MOBILE_AP_FUNC_EXIT__;
395 static void __eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
397 __MOBILE_AP_FUNC_ENTER__;
399 elm_object_text_set(data, "");
400 elm_entry_input_panel_return_key_disabled_set(data, TRUE);
402 __MOBILE_AP_FUNC_EXIT__;
405 static void __pw_entry_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
407 __MOBILE_AP_FUNC_ENTER__;
409 if (obj == NULL || data == NULL) {
413 mh_appdata_t *ad = (mh_appdata_t *)data;
414 mh_wifi_setting_view_t *st = &ad->setup;
415 char buf[MH_LABEL_LENGTH_MAX];
416 char *fmt = STR_PW_GUIDE_TEXT;
418 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
420 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
422 elm_genlist_item_update(st->pw_item);
424 elm_object_part_text_set(obj, "elm.guide", buf);
426 __MOBILE_AP_FUNC_EXIT__;
429 static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent)
431 __MOBILE_AP_FUNC_ENTER__;
433 static Elm_Entry_Filter_Limit_Size limit_filter_data;
434 Evas_Object *entry = NULL;
435 char *fmt = STR_PW_GUIDE_TEXT;
437 Evas_Object * clr_btn = NULL;
438 char buf[MH_LABEL_LENGTH_MAX];
440 if (parent == NULL || data == NULL) {
441 ERR("null param \n");
445 mh_appdata_t *ad = (mh_appdata_t *)data;
446 mh_wifi_setting_view_t *st = &ad->setup;
448 entry = elm_entry_add(parent);
451 ERR("elm_entry_add returns NULL\n");
456 elm_entry_single_line_set(entry, EINA_TRUE);
457 elm_entry_scrollable_set(entry, EINA_TRUE);
458 elm_entry_password_set(entry, EINA_FALSE);
460 evas_object_smart_callback_add(entry, "language,changed",
461 __pw_entry_language_changed_cb, ad);
463 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
464 elm_entry_prediction_allow_set(entry, EINA_FALSE);
465 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
466 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
467 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
468 elm_object_part_text_set(entry, "guide", buf);
469 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
471 limit_filter_data.max_char_count = 0;
472 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
473 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
475 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
476 elm_object_part_text_set(entry, "default", buf);
477 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
478 elm_object_disabled_set(entry, EINA_TRUE);
480 elm_object_item_signal_emit(st->pw_item, "elm,state,rename,hide", "");
483 elm_object_disabled_set(entry, EINA_FALSE);
484 elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
485 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
487 elm_object_text_set(entry, ptr);
490 ERR("elm_entry_utf8_to_markup is failed\n");
494 elm_entry_input_panel_return_key_type_set(entry,
495 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
497 clr_btn = elm_button_add(entry);
498 elm_object_style_set(clr_btn, "search_clear");
499 elm_object_focus_allow_set(clr_btn, EINA_FALSE);
500 elm_object_part_content_set(entry, "elm.swallow.clear", clr_btn);
501 evas_object_smart_callback_add(clr_btn, "clicked", __eraser_btn_clicked_cb, entry);
502 evas_object_show(clr_btn);
504 evas_object_smart_callback_add(entry, "changed",
505 __pw_entry_changed_cb, ad);
506 evas_object_smart_callback_add(entry, "maxlength,reached",
507 __pw_entry_maxlength_reached_cb, ad);
508 evas_object_smart_callback_add(entry, "activated",
509 __pw_entry_activated_cb, NULL);
510 evas_object_smart_callback_add(entry, "focused",
511 __pw_entry_focused_cb, NULL);
512 evas_object_smart_callback_add(entry, "unfocused",
513 __pw_entry_unfocused_cb, NULL);
514 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
515 __pw_entry_show_cb, NULL);
517 elm_object_focus_set(entry, EINA_TRUE);
518 elm_entry_input_panel_show(entry);
519 elm_object_part_content_set(parent, "elm.swallow.content", entry);
521 st->pw_entry = entry;
523 __MOBILE_AP_FUNC_EXIT__;
527 static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part)
529 __MOBILE_AP_FUNC_ENTER__;
535 ERR("data is null \n");
539 if (!strcmp(part, "elm.swallow.content")) {
540 Evas_Object *box = elm_box_add(obj);
541 Evas_Object *label = elm_label_add(box);
542 Evas_Object *layout = elm_layout_add(box);
543 char buf[MH_LABEL_LENGTH_MAX] = {0, };
545 elm_box_align_set(box, 0.0, 0.0);
547 /* Set label for name field */
548 snprintf(buf, MH_LABEL_LENGTH_MAX, "<text align=left><font_size=30>%s</font_size></text>", STR_PASSWORD);
549 elm_object_text_set(label, buf);
550 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
551 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
552 evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), 0, 0);
553 elm_box_pack_end(box, label);
554 evas_object_show(label);
556 /* Set layout for entry field */
557 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
558 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
559 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
561 __get_pw_entry(data, layout);
562 evas_object_show(layout);
563 elm_box_pack_end(box, layout);
565 evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
566 evas_object_show(box);
571 __MOBILE_AP_FUNC_EXIT__;
575 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
577 __MOBILE_AP_FUNC_ENTER__;
579 if (data == NULL || obj == NULL || event_info == NULL) {
580 ERR("param is NULL\n");
584 mh_appdata_t *ad = (mh_appdata_t *)data;
586 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
587 __hide_btn_changed_cb(ad, obj, NULL);
589 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility_new ?
590 EINA_FALSE : EINA_TRUE);
592 __MOBILE_AP_FUNC_EXIT__;
595 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
597 __MOBILE_AP_FUNC_ENTER__;
599 if (data == NULL || obj == NULL || event_info == NULL) {
600 ERR("param is NULL\n");
604 mh_appdata_t *ad = (mh_appdata_t *)data;
606 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
607 __security_btn_changed_cb(data, obj, NULL);
608 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type_new ==
609 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
611 __MOBILE_AP_FUNC_EXIT__;
614 static void __set_genlist_itc(mh_appdata_t *ad)
616 __MOBILE_AP_FUNC_ENTER__;
618 ad->setup.name_itc = elm_genlist_item_class_new();
619 if (ad->setup.name_itc == NULL) {
620 ERR("elm_genlist_item_class_new failed\n");
621 __MOBILE_AP_FUNC_EXIT__;
624 ad->setup.name_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
625 ad->setup.name_itc->func.text_get = __gl_device_name_title_label_get;
626 ad->setup.name_itc->func.content_get = NULL;
627 ad->setup.name_itc->func.state_get = NULL;
628 ad->setup.name_itc->func.del = NULL;
630 ad->setup.hide_itc = elm_genlist_item_class_new();
631 if (ad->setup.hide_itc == NULL) {
632 ERR("elm_genlist_item_class_new failed\n");
633 __MOBILE_AP_FUNC_EXIT__;
636 ad->setup.hide_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
637 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
638 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
639 ad->setup.hide_itc->func.state_get = NULL;
640 ad->setup.hide_itc->func.del = NULL;
642 ad->setup.security_itc = elm_genlist_item_class_new();
643 if (ad->setup.security_itc == NULL) {
644 ERR("elm_genlist_item_class_new failed\n");
645 __MOBILE_AP_FUNC_EXIT__;
648 ad->setup.security_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
649 ad->setup.security_itc->func.text_get = __gl_security_label_get;
650 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
651 ad->setup.security_itc->func.state_get = NULL;
652 ad->setup.security_itc->func.del = NULL;
654 ad->setup.pw_itc = elm_genlist_item_class_new();
655 if (ad->setup.pw_itc == NULL) {
656 ERR("elm_genlist_item_class_new failed\n");
657 __MOBILE_AP_FUNC_EXIT__;
660 ad->setup.pw_itc->item_style = MH_GENLIST_FULL_CONTENT_STYLE;
661 ad->setup.pw_itc->func.text_get = NULL;
662 ad->setup.pw_itc->func.content_get = __gl_pw_content_get;
663 ad->setup.pw_itc->func.state_get = NULL;
664 ad->setup.pw_itc->func.del = NULL;
666 __MOBILE_AP_FUNC_EXIT__;
670 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
672 __MOBILE_AP_FUNC_ENTER__;
679 evas_object_smart_callback_del(st->hide_btn, "changed",
680 __hide_btn_changed_cb);
681 evas_object_smart_callback_del(st->security_btn, "changed",
682 __security_btn_changed_cb);
683 evas_object_smart_callback_del(st->cancel_button, "clicked",
685 evas_object_smart_callback_del(st->save_button, "clicked",
687 evas_object_smart_callback_del(st->genlist, "realized",
690 __MOBILE_AP_FUNC_EXIT__;
693 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
695 if (user_data == NULL) {
696 ERR("Invalid parameter\n");
700 __MOBILE_AP_FUNC_ENTER__;
702 mh_appdata_t *ad = (mh_appdata_t *)user_data;
704 if (result != TETHERING_ERROR_NONE)
705 ERR("tethering_wifi_reload_settings is failed [0x%X]\n", result);
706 _update_wifi_item(ad, MH_STATE_NONE);
708 __MOBILE_AP_FUNC_EXIT__;
713 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info)
717 ERR("data is NULL\n");
721 mh_appdata_t *ad = (mh_appdata_t *)data;
722 mh_wifi_setting_view_t *st = &ad->setup;
724 bool is_setting_changed = false;
726 /* handle hide button change */
727 if (st->visibility != st->visibility_new) {
728 ret = __save_hide_btn_change(ad);
730 elm_check_state_set(st->hide_btn, st->visibility ?
731 EINA_FALSE : EINA_TRUE);
733 st->visibility = st->visibility_new;
734 is_setting_changed = true;
737 /* handle security button change */
738 if (st->security_type != st->security_type_new) {
739 ret = __save_security_btn_change(ad);
741 elm_check_state_set(st->security_btn, st->security_type ==
742 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
744 st->security_type = st->security_type_new;
745 is_setting_changed = true;
749 /* handle wifi passphrase change */
750 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
751 ret = __save_wifi_passphrase(ad);
753 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
754 sizeof(st->wifi_passphrase_new));
756 elm_genlist_item_update(st->pw_item);
758 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
759 sizeof(st->wifi_passphrase));
760 is_setting_changed = true;
761 if (ad->main.help_item) {
762 if (ad->main.help_item)
763 elm_genlist_item_update(ad->main.help_item);
768 if (is_setting_changed) {
769 _update_wifi_item(ad, MH_STATE_PROCESS);
771 if (ad->main.help_item)
772 elm_genlist_item_update(ad->main.help_item);
774 /* reload wifi settings */
775 ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb,
777 if (ret != TETHERING_ERROR_NONE)
778 ERR("reload_configuration is failed : %d\n", ret);
781 elm_naviframe_item_pop(ad->naviframe);
787 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info)
792 ERR("The param is NULL\n");
796 mh_appdata_t *ad = (mh_appdata_t *)data;
798 elm_naviframe_item_pop(ad->naviframe);
803 Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item)
808 ERR("The param is NULL\n");
812 mh_appdata_t *ad = (mh_appdata_t *)data;
813 mh_wifi_setting_view_t *st = &ad->setup;
815 if (st->visibility != st->visibility_new)
816 st->visibility_new = st->visibility;
818 if (st->security_type != st->security_type_new)
819 st->security_type_new = st->security_type;
821 if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) {
822 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
823 sizeof(st->wifi_passphrase_new));
826 __deconstruct_wifi_setup_view(st);
828 if (ad->rename_popup != NULL) {
829 evas_object_del(ad->rename_popup);
830 ad->rename_popup = NULL;
832 ad->setup.navi_it = NULL;
838 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
840 __MOBILE_AP_FUNC_ENTER__;
842 mh_appdata_t *ad = (mh_appdata_t *)data;
843 mh_wifi_setting_view_t *st = &(ad->setup);
844 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
847 char str[MH_LABEL_LENGTH_MAX] = {0, };
851 if (item == st->hide_item)
852 elm_object_item_signal_emit(item, "elm,state,top", "");
853 else if (item == st->security_item)
854 elm_object_item_signal_emit(item, "elm,state,center", "");
855 else if (item == st->pw_item)
856 elm_object_item_signal_emit(item, "elm,state,bottom", "");
858 no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]);
859 for (i = 0; i < no_of_sp; i++) {
860 if (item == st->sp_item[i])
861 elm_object_item_access_unregister(item);
864 if (item == st->hide_item || item == st->security_item) {
865 ao = elm_object_item_access_object_get(item);
866 btn = elm_object_item_part_content_get(item, "on&off");
867 snprintf(str, sizeof(str), "%s, %s", "On/off button",
868 (elm_check_state_get(btn) ? "On" : "Off"));
869 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
872 if (item == st->pw_item) {
873 elm_object_item_access_unregister(item);
874 ao = elm_object_item_access_register(item);
875 snprintf(str, sizeof(str), "%s, %s", STR_PASSWORD, st->wifi_passphrase_new);
876 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
879 __MOBILE_AP_FUNC_EXIT__;
884 static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_info)
886 __MOBILE_AP_FUNC_ENTER__;
889 ERR("The param is NULL\n");
893 mh_appdata_t *ad = (mh_appdata_t *)data;
894 mh_wifi_setting_view_t *st = &ad->setup;
896 elm_object_focus_set(st->pw_entry, EINA_TRUE);
898 __MOBILE_AP_FUNC_EXIT__;
902 Evas_Object *__create_genlist(mh_appdata_t *ad)
904 __MOBILE_AP_FUNC_ENTER__;
911 void *data = (void *)ad;
912 mh_wifi_setting_view_t *st = &ad->setup;
913 Evas_Object *genlist;
915 genlist = elm_genlist_add(ad->naviframe);
916 if (genlist == NULL) {
917 ERR("genlist is NULL\n");
921 elm_object_style_set(genlist, "dialogue");
922 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
923 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
925 __set_genlist_itc(ad);
927 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
928 ELM_GENLIST_ITEM_NONE, NULL, NULL);
929 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
932 elm_object_item_disabled_set(st->name_item, EINA_TRUE);
934 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
935 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
937 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
938 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
940 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
941 ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad);
942 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
943 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
945 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
947 /* End separator is removed because of P131104-03336. It is confirmed by UX team for this case.
948 item = elm_genlist_item_append(genlist, st->sp_itc, NULL, NULL,
949 ELM_GENLIST_ITEM_NONE, NULL, NULL);
950 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
951 st->sp_item[i++] = item;
954 __MOBILE_AP_FUNC_EXIT__;
959 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
969 mh_wifi_setting_view_t *st = &ad->setup;
971 if (ad->setup.navi_it != NULL) {
972 ERR("Wi-Fi setup view already exists\n");
977 st->genlist = __create_genlist(ad);
978 if (st->genlist == NULL) {
979 ERR("__create_genlist returns NULL\n");
984 st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_MBODY_WI_FI_TETHERING",
985 NULL, NULL, st->genlist, NULL);
986 elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);
988 elm_naviframe_item_pop_cb_set(st->navi_it, _setting_back_btn_cb, (void *)ad);
990 btn = elm_button_add(ad->naviframe);
991 elm_object_style_set(btn, "naviframe/title_cancel");
992 evas_object_smart_callback_add(btn, "clicked", __cancel_btn_cb, ad);
993 elm_object_item_part_content_set(st->navi_it, "title_left_btn", btn);
994 st->cancel_button = btn;
996 btn = elm_button_add(ad->naviframe);
997 elm_object_style_set(btn, "naviframe/title_done");
998 evas_object_smart_callback_add(btn, "clicked", __save_btn_cb, ad);
999 elm_object_item_part_content_set(st->navi_it, "title_right_btn", btn);
1000 st->save_button = btn;