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);
90 if (st->pw_entry == NULL || elm_entry_entry_get(st->pw_entry) == NULL ||
91 strlen(elm_entry_entry_get(st->pw_entry)) == 0)
92 elm_object_disabled_set(st->save_button, EINA_TRUE);
96 elm_genlist_item_update(st->pw_item);
98 __MOBILE_AP_FUNC_EXIT__;
101 static bool __save_security_btn_change(mh_appdata_t *ad)
103 __MOBILE_AP_FUNC_ENTER__;
106 ERR("Invalid param\n");
112 ret = tethering_wifi_set_security_type(ad->handle, ad->setup.security_type_new);
113 if (ret != TETHERING_ERROR_NONE) {
114 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
118 __MOBILE_AP_FUNC_EXIT__;
122 static char *__gl_device_name_title_label_get(void *data, Evas_Object *obj, const char *part)
124 __MOBILE_AP_FUNC_ENTER__;
125 mh_appdata_t *ad = (mh_appdata_t *)data;
126 char *device_name_utf = NULL;
128 char buf[MH_LABEL_LENGTH_MAX] = {0, };
130 if (data == NULL || obj == NULL || part == NULL) {
131 ERR("Invalid param\n");
135 if (!strcmp("elm.text.multiline", part)) {
136 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
137 if (device_name_utf == NULL) {
138 ERR("vconf_get_str failed \n");
141 ptr = elm_entry_utf8_to_markup(device_name_utf);
143 ERR("elm_entry_utf8_to_markup is failed\n");
144 free(device_name_utf);
148 g_strlcpy(ad->setup.device_name, ptr,
149 sizeof(ad->setup.device_name));
151 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size><br>%s", STR_MY_DEVICE_NAME, ptr);
153 free(device_name_utf);
159 __MOBILE_AP_FUNC_EXIT__;
163 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
165 __MOBILE_AP_FUNC_ENTER__;
167 if (data == NULL || obj == NULL || part == NULL) {
168 ERR("Invalid param\n");
172 if (!strcmp("elm.text", part)) {
173 return strdup(STR_HIDE_MY_DEV);
176 __MOBILE_AP_FUNC_EXIT__;
180 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
182 __MOBILE_AP_FUNC_ENTER__;
184 if (data == NULL || obj == NULL || part == NULL) {
185 ERR("Invalid param\n");
189 if (!strcmp("elm.text", part)) {
190 return strdup(STR_SECURITY_TYPE);
193 __MOBILE_AP_FUNC_EXIT__;
197 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
200 __MOBILE_AP_FUNC_ENTER__;
202 mh_appdata_t *ad = (mh_appdata_t *)data;
203 Evas_Object *btn = NULL;
205 if (data == NULL || obj == NULL || part == NULL) {
206 ERR("Invalid param\n");
210 if (!strcmp("elm.swallow.end", part)) {
211 btn = elm_check_add(obj);
213 ERR("btn is NULL\n");
217 elm_object_style_set(btn, "on&off");
218 evas_object_show(btn);
219 evas_object_pass_events_set(btn, EINA_TRUE);
220 evas_object_propagate_events_set(btn, EINA_FALSE);
221 elm_object_focus_allow_set(btn, EINA_FALSE);
222 elm_check_state_set(btn, ad->setup.visibility_new ? EINA_FALSE : EINA_TRUE);
223 evas_object_smart_callback_add(btn, "changed",
224 __hide_btn_changed_cb, (void *)ad);
225 ad->setup.hide_btn = btn;
228 __MOBILE_AP_FUNC_EXIT__;
232 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
235 __MOBILE_AP_FUNC_ENTER__;
237 mh_appdata_t *ad = (mh_appdata_t *)data;
238 Evas_Object *btn = NULL;
240 if (data == NULL || obj == NULL || part == NULL) {
241 ERR("Invalid param\n");
245 if (!strcmp("elm.swallow.end", part)) {
246 btn = elm_check_add(obj);
247 elm_object_style_set(btn, "on&off");
248 evas_object_show(btn);
249 evas_object_pass_events_set(btn, EINA_TRUE);
250 evas_object_propagate_events_set(btn, EINA_FALSE);
251 elm_check_state_set(btn, ad->setup.security_type_new ==
252 TETHERING_WIFI_SECURITY_TYPE_NONE ?
253 EINA_FALSE : EINA_TRUE);
254 evas_object_smart_callback_add(btn, "changed",
255 __security_btn_changed_cb, (void *)ad);
256 ad->setup.security_btn = btn;
259 __MOBILE_AP_FUNC_EXIT__;
263 static bool __save_wifi_passphrase(mh_appdata_t *ad)
265 __MOBILE_AP_FUNC_ENTER__;
268 ERR("Invalid param\n");
272 mh_wifi_setting_view_t *st = &ad->setup;
275 ret = tethering_wifi_set_passphrase(ad->handle, st->wifi_passphrase_new);
276 if (ret != TETHERING_ERROR_NONE) {
277 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
281 __MOBILE_AP_FUNC_EXIT__;
285 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
288 __MOBILE_AP_FUNC_ENTER__;
290 mh_appdata_t *ad = (mh_appdata_t *)data;
291 mh_wifi_setting_view_t *st = &ad->setup;
292 const char *changed_text;
296 changed_text = elm_entry_entry_get(obj);
297 if (changed_text == NULL) {
298 ERR("elm_entry_entry_get is failed\n");
302 utf8_string = elm_entry_markup_to_utf8(changed_text);
304 if (utf8_string == NULL) {
305 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
307 len = strlen(utf8_string);
308 if (WIFI_PASSPHRASE_LENGTH_MIN <= len) {
309 elm_object_disabled_set(st->save_button, EINA_FALSE);
310 elm_entry_input_panel_return_key_disabled_set(obj, FALSE);
312 elm_object_disabled_set(st->save_button, EINA_TRUE);
313 elm_entry_input_panel_return_key_disabled_set(obj, TRUE);
315 g_strlcpy(st->wifi_passphrase_new, utf8_string,
316 sizeof(st->wifi_passphrase_new));
321 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
322 if (elm_object_focus_get(obj)) {
323 if (elm_entry_is_empty(obj))
324 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
326 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
330 __MOBILE_AP_FUNC_EXIT__;
334 static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj,
337 __MOBILE_AP_FUNC_ENTER__;
340 ERR("The param is NULL\n");
341 __MOBILE_AP_FUNC_EXIT__;
344 char buf[MH_LABEL_LENGTH_MAX] = { 0, };
345 char *fmt = STR_PASSWORD_MIN_MAX;
346 notification_error_e ret;
348 snprintf(buf, sizeof(buf), fmt,
349 WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
351 ret = notification_status_message_post(buf);
352 if (ret != NOTIFICATION_ERROR_NONE) {
353 ERR("notification_status_message_post() is failed : %d\n", ret);
356 __MOBILE_AP_FUNC_EXIT__;
359 static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
361 __MOBILE_AP_FUNC_ENTER__;
364 ERR("Invalid parameter");
368 elm_object_focus_set(obj, EINA_FALSE);
369 __MOBILE_AP_FUNC_EXIT__;
373 static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
375 __MOBILE_AP_FUNC_ENTER__;
376 evas_object_smart_callback_del(obj, "focused", __pw_entry_focused_cb);
378 elm_object_focus_set(obj, EINA_TRUE);
379 elm_entry_cursor_end_set(obj);
380 __MOBILE_AP_FUNC_EXIT__;
383 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
385 __MOBILE_AP_FUNC_ENTER__;
386 if (elm_object_part_content_get(obj, "elm.swallow.clear"))
387 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
388 elm_object_signal_emit(obj, "elm,state,focus,off", "");
389 __MOBILE_AP_FUNC_EXIT__;
392 static void __pw_entry_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
394 __MOBILE_AP_FUNC_ENTER__;
395 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __pw_entry_show_cb);
397 elm_object_focus_set(obj, EINA_TRUE);
398 elm_entry_cursor_end_set(obj);
399 __MOBILE_AP_FUNC_EXIT__;
402 static void __eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
404 __MOBILE_AP_FUNC_ENTER__;
406 elm_object_text_set(data, "");
407 elm_entry_input_panel_return_key_disabled_set(data, TRUE);
409 __MOBILE_AP_FUNC_EXIT__;
412 static void __pw_entry_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
414 __MOBILE_AP_FUNC_ENTER__;
416 if (obj == NULL || data == NULL) {
420 mh_appdata_t *ad = (mh_appdata_t *)data;
421 mh_wifi_setting_view_t *st = &ad->setup;
422 char buf[MH_LABEL_LENGTH_MAX];
423 char *fmt = STR_PW_GUIDE_TEXT;
425 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
427 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
429 elm_genlist_item_update(st->pw_item);
431 elm_object_part_text_set(obj, "elm.guide", buf);
433 __MOBILE_AP_FUNC_EXIT__;
436 static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent)
438 __MOBILE_AP_FUNC_ENTER__;
440 static Elm_Entry_Filter_Limit_Size limit_filter_data;
441 Evas_Object *entry = NULL;
442 char *fmt = STR_PW_GUIDE_TEXT;
444 Evas_Object * clr_btn = NULL;
445 char buf[MH_LABEL_LENGTH_MAX];
447 if (parent == NULL || data == NULL) {
448 ERR("null param \n");
452 mh_appdata_t *ad = (mh_appdata_t *)data;
453 mh_wifi_setting_view_t *st = &ad->setup;
455 entry = elm_entry_add(parent);
458 ERR("elm_entry_add returns NULL\n");
463 elm_entry_single_line_set(entry, EINA_TRUE);
464 elm_entry_scrollable_set(entry, EINA_TRUE);
465 elm_entry_password_set(entry, EINA_FALSE);
467 evas_object_smart_callback_add(entry, "language,changed",
468 __pw_entry_language_changed_cb, ad);
470 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
471 elm_entry_prediction_allow_set(entry, EINA_FALSE);
472 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
473 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
474 snprintf(buf, sizeof(buf), fmt, WIFI_PASSPHRASE_LENGTH_MIN);
475 elm_object_part_text_set(entry, "guide", buf);
476 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
478 limit_filter_data.max_char_count = 0;
479 limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
480 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
482 if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) {
483 elm_object_part_text_set(entry, "default", buf);
484 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
485 elm_object_disabled_set(entry, EINA_TRUE);
487 elm_object_item_signal_emit(st->pw_item, "elm,state,rename,hide", "");
490 elm_object_disabled_set(entry, EINA_FALSE);
491 elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
492 ptr = elm_entry_utf8_to_markup(st->wifi_passphrase_new);
494 elm_object_text_set(entry, ptr);
497 ERR("elm_entry_utf8_to_markup is failed\n");
501 elm_entry_input_panel_return_key_type_set(entry,
502 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
504 clr_btn = elm_button_add(entry);
505 elm_object_style_set(clr_btn, "search_clear");
506 elm_object_focus_allow_set(clr_btn, EINA_FALSE);
507 elm_object_part_content_set(entry, "elm.swallow.clear", clr_btn);
508 evas_object_smart_callback_add(clr_btn, "clicked", __eraser_btn_clicked_cb, entry);
509 evas_object_show(clr_btn);
511 evas_object_smart_callback_add(entry, "changed",
512 __pw_entry_changed_cb, ad);
513 evas_object_smart_callback_add(entry, "maxlength,reached",
514 __pw_entry_maxlength_reached_cb, ad);
515 evas_object_smart_callback_add(entry, "activated",
516 __pw_entry_activated_cb, NULL);
517 evas_object_smart_callback_add(entry, "focused",
518 __pw_entry_focused_cb, NULL);
519 evas_object_smart_callback_add(entry, "unfocused",
520 __pw_entry_unfocused_cb, NULL);
521 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
522 __pw_entry_show_cb, NULL);
524 elm_object_focus_set(entry, EINA_TRUE);
525 elm_entry_input_panel_show(entry);
526 elm_object_part_content_set(parent, "elm.swallow.content", entry);
528 st->pw_entry = entry;
530 __MOBILE_AP_FUNC_EXIT__;
534 static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part)
536 __MOBILE_AP_FUNC_ENTER__;
542 ERR("data is null \n");
546 if (!strcmp(part, "elm.swallow.content")) {
547 Evas_Object *box = elm_box_add(obj);
548 Evas_Object *ibox = elm_box_add(box);
549 Evas_Object *tpadding = evas_object_rectangle_add(box);
550 Evas_Object *lpadding = evas_object_rectangle_add(ibox);
551 Evas_Object *label = elm_label_add(ibox);
552 Evas_Object *layout = elm_layout_add(box);
553 char buf[MH_LABEL_LENGTH_MAX] = {0, };
555 elm_box_align_set(box, 0.0, 0.0);
557 /* Set rectangle for top padding */
558 evas_object_size_hint_min_set(tpadding, 0, ELM_SCALE_SIZE(10));
559 evas_object_size_hint_padding_set(tpadding, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10));
560 evas_object_color_set(tpadding, 255, 255, 255, 0);
561 evas_object_show(tpadding);
562 elm_box_pack_end(box, tpadding);
564 /* Set internal box */
565 evas_object_size_hint_align_set(ibox, 0.0, 0.0);
566 evas_object_size_hint_padding_set(ibox, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(20), 0);
567 elm_box_horizontal_set(ibox, EINA_TRUE);
568 elm_box_pack_end(box, ibox);
570 /* Set rectangle for left padding */
571 evas_object_size_hint_min_set(lpadding, ELM_SCALE_SIZE(15), ELM_SCALE_SIZE(10));
572 evas_object_size_hint_padding_set(lpadding, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10));
573 evas_object_color_set(lpadding, 255, 255, 255, 0);
574 evas_object_show(lpadding);
575 elm_box_pack_end(ibox, lpadding);
576 evas_object_show(ibox);
578 /* Set label for name field */
579 snprintf(buf, MH_LABEL_LENGTH_MAX, "<text align=left><font_size=30>%s</font_size></text>", STR_PASSWORD);
580 elm_object_text_set(label, buf);
581 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
582 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
583 evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), 0, 0);
584 elm_box_pack_end(ibox, label);
585 evas_object_show(label);
587 /* Set layout for entry field */
588 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
589 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
590 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
592 __get_pw_entry(data, layout);
593 evas_object_show(layout);
594 elm_box_pack_end(box, layout);
596 evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
597 evas_object_show(box);
602 __MOBILE_AP_FUNC_EXIT__;
606 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
608 __MOBILE_AP_FUNC_ENTER__;
610 if (data == NULL || obj == NULL || event_info == NULL) {
611 ERR("param is NULL\n");
615 mh_appdata_t *ad = (mh_appdata_t *)data;
617 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
618 __hide_btn_changed_cb(ad, obj, NULL);
620 elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility_new ?
621 EINA_FALSE : EINA_TRUE);
623 __MOBILE_AP_FUNC_EXIT__;
626 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
628 __MOBILE_AP_FUNC_ENTER__;
630 if (data == NULL || obj == NULL || event_info == NULL) {
631 ERR("param is NULL\n");
635 mh_appdata_t *ad = (mh_appdata_t *)data;
637 elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
638 __security_btn_changed_cb(data, obj, NULL);
639 elm_check_state_set(ad->setup.security_btn, ad->setup.security_type_new ==
640 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
642 __MOBILE_AP_FUNC_EXIT__;
645 static void __set_genlist_itc(mh_appdata_t *ad)
647 __MOBILE_AP_FUNC_ENTER__;
650 ad->setup.sp_itc = elm_genlist_item_class_new();
651 if (ad->setup.sp_itc == NULL) {
652 ERR("elm_genlist_item_class_new failed\n");
653 __MOBILE_AP_FUNC_EXIT__;
656 ad->setup.sp_itc->item_style = "dialogue/separator";
657 ad->setup.sp_itc->func.text_get = NULL;
658 ad->setup.sp_itc->func.content_get = NULL;
659 ad->setup.sp_itc->func.state_get = NULL;
660 ad->setup.sp_itc->func.del = NULL;
662 ad->setup.name_itc = elm_genlist_item_class_new();
663 if (ad->setup.name_itc == NULL) {
664 ERR("elm_genlist_item_class_new failed\n");
665 __MOBILE_AP_FUNC_EXIT__;
668 ad->setup.name_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
669 ad->setup.name_itc->func.text_get = __gl_device_name_title_label_get;
670 ad->setup.name_itc->func.content_get = NULL;
671 ad->setup.name_itc->func.state_get = NULL;
672 ad->setup.name_itc->func.del = NULL;
674 ad->setup.hide_itc = elm_genlist_item_class_new();
675 if (ad->setup.hide_itc == NULL) {
676 ERR("elm_genlist_item_class_new failed\n");
677 __MOBILE_AP_FUNC_EXIT__;
680 ad->setup.hide_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
681 ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
682 ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
683 ad->setup.hide_itc->func.state_get = NULL;
684 ad->setup.hide_itc->func.del = NULL;
686 ad->setup.security_itc = elm_genlist_item_class_new();
687 if (ad->setup.security_itc == NULL) {
688 ERR("elm_genlist_item_class_new failed\n");
689 __MOBILE_AP_FUNC_EXIT__;
692 ad->setup.security_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
693 ad->setup.security_itc->func.text_get = __gl_security_label_get;
694 ad->setup.security_itc->func.content_get = __gl_security_icon_get;
695 ad->setup.security_itc->func.state_get = NULL;
696 ad->setup.security_itc->func.del = NULL;
698 ad->setup.pw_itc = elm_genlist_item_class_new();
699 if (ad->setup.pw_itc == NULL) {
700 ERR("elm_genlist_item_class_new failed\n");
701 __MOBILE_AP_FUNC_EXIT__;
704 ad->setup.pw_itc->item_style = MH_GENLIST_FULL_CONTENT_STYLE;
705 ad->setup.pw_itc->func.text_get = NULL;
706 ad->setup.pw_itc->func.content_get = __gl_pw_content_get;
707 ad->setup.pw_itc->func.state_get = NULL;
708 ad->setup.pw_itc->func.del = NULL;
711 ad->setup.sp2_itc = elm_genlist_item_class_new();
712 if (ad->setup.sp2_itc == NULL) {
713 ERR("elm_genlist_item_class_new failed\n");
714 __MOBILE_AP_FUNC_EXIT__;
717 ad->setup.sp2_itc->item_style = "dialogue/separator.2";
718 ad->setup.sp2_itc->func.text_get = NULL;
719 ad->setup.sp2_itc->func.content_get = NULL;
720 ad->setup.sp2_itc->func.state_get = NULL;
721 ad->setup.sp2_itc->func.del = NULL;
723 __MOBILE_AP_FUNC_EXIT__;
727 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
729 __MOBILE_AP_FUNC_ENTER__;
736 evas_object_smart_callback_del(st->hide_btn, "changed",
737 __hide_btn_changed_cb);
738 evas_object_smart_callback_del(st->security_btn, "changed",
739 __security_btn_changed_cb);
740 evas_object_smart_callback_del(st->cancel_button, "clicked",
742 evas_object_smart_callback_del(st->save_button, "clicked",
744 evas_object_smart_callback_del(st->genlist, "realized",
747 __MOBILE_AP_FUNC_EXIT__;
750 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
752 if (user_data == NULL) {
753 ERR("Invalid parameter\n");
757 __MOBILE_AP_FUNC_ENTER__;
759 mh_appdata_t *ad = (mh_appdata_t *)user_data;
761 if (result != TETHERING_ERROR_NONE)
762 ERR("tethering_wifi_reload_settings is failed [0x%X]\n", result);
763 _update_wifi_item(ad, MH_STATE_NONE);
765 __MOBILE_AP_FUNC_EXIT__;
770 static void __save_btn_cb(void *data, Evas_Object *object, void *event_info)
774 ERR("data is NULL\n");
778 mh_appdata_t *ad = (mh_appdata_t *)data;
779 mh_wifi_setting_view_t *st = &ad->setup;
781 bool is_setting_changed = false;
783 /* handle hide button change */
784 if (st->visibility != st->visibility_new) {
785 ret = __save_hide_btn_change(ad);
787 elm_check_state_set(st->hide_btn, st->visibility ?
788 EINA_FALSE : EINA_TRUE);
790 st->visibility = st->visibility_new;
791 is_setting_changed = true;
794 /* handle security button change */
795 if (st->security_type != st->security_type_new) {
796 ret = __save_security_btn_change(ad);
798 elm_check_state_set(st->security_btn, st->security_type ==
799 TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
801 st->security_type = st->security_type_new;
802 is_setting_changed = true;
806 /* handle wifi passphrase change */
807 if (strcmp(st->wifi_passphrase, st->wifi_passphrase_new)) {
808 ret = __save_wifi_passphrase(ad);
810 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
811 sizeof(st->wifi_passphrase_new));
813 elm_genlist_item_update(st->pw_item);
815 g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new,
816 sizeof(st->wifi_passphrase));
817 is_setting_changed = true;
818 if (ad->main.help_item) {
819 if (ad->main.help_item)
820 elm_genlist_item_update(ad->main.help_item);
825 if (is_setting_changed) {
826 _update_wifi_item(ad, MH_STATE_PROCESS);
828 if (ad->main.help_item)
829 elm_genlist_item_update(ad->main.help_item);
831 /* reload wifi settings */
832 ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb,
834 if (ret != TETHERING_ERROR_NONE)
835 ERR("reload_configuration is failed : %d\n", ret);
838 elm_naviframe_item_pop(ad->naviframe);
844 static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info)
849 ERR("The param is NULL\n");
853 mh_appdata_t *ad = (mh_appdata_t *)data;
855 elm_naviframe_item_pop(ad->naviframe);
860 Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item)
865 ERR("The param is NULL\n");
869 mh_appdata_t *ad = (mh_appdata_t *)data;
870 mh_wifi_setting_view_t *st = &ad->setup;
872 if (st->visibility != st->visibility_new) {
873 st->visibility_new = st->visibility;
876 if (st->security_type != st->security_type_new) {
877 st->security_type_new = st->security_type;
880 if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) {
881 g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase,
882 sizeof(st->wifi_passphrase_new));
885 __deconstruct_wifi_setup_view(st);
887 if (ad->rename_popup != NULL) {
888 evas_object_del(ad->rename_popup);
889 ad->rename_popup = NULL;
891 ad->setup.navi_it = NULL;
897 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
899 __MOBILE_AP_FUNC_ENTER__;
901 mh_appdata_t *ad = (mh_appdata_t *)data;
902 mh_wifi_setting_view_t *st = &(ad->setup);
903 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
906 char str[MH_LABEL_LENGTH_MAX] = {0, };
910 if (item == st->hide_item) {
911 elm_object_item_signal_emit(item, "elm,state,top", "");
912 } else if (item == st->security_item) {
913 elm_object_item_signal_emit(item, "elm,state,center", "");
914 } else if (item == st->pw_item) {
915 elm_object_item_signal_emit(item, "elm,state,bottom", "");
916 } else if (item == st->name_item) {
919 no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]);
920 for (i = 0; i < no_of_sp; i++) {
921 if (item == st->sp_item[i])
922 elm_object_item_access_unregister(item);
925 if (item == st->hide_item || item == st->security_item) {
926 ao = elm_object_item_access_object_get(item);
927 btn = elm_object_item_part_content_get(item, "on&off");
928 snprintf(str, sizeof(str), "%s, %s", "On/off button",
929 (elm_check_state_get(btn) ? "On" : "Off"));
930 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
933 if (item == st->pw_item) {
934 elm_object_item_access_unregister(item);
935 ao = elm_object_item_access_register(item);
936 snprintf(str, sizeof(str), "%s, %s", STR_PASSWORD, st->wifi_passphrase_new);
937 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
940 __MOBILE_AP_FUNC_EXIT__;
945 static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_info)
947 __MOBILE_AP_FUNC_ENTER__;
950 ERR("The param is NULL\n");
954 mh_appdata_t *ad = (mh_appdata_t *)data;
955 mh_wifi_setting_view_t *st = &ad->setup;
957 elm_object_focus_set(st->pw_entry, EINA_TRUE);
959 __MOBILE_AP_FUNC_EXIT__;
963 Evas_Object *__create_genlist(mh_appdata_t *ad)
965 __MOBILE_AP_FUNC_ENTER__;
972 void *data = (void *)ad;
973 mh_wifi_setting_view_t *st = &ad->setup;
974 Evas_Object *genlist;
976 genlist = elm_genlist_add(ad->naviframe);
977 if (genlist == NULL) {
978 ERR("genlist is NULL\n");
982 elm_object_style_set(genlist, "dialogue");
983 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
984 evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad);
985 //elm_genlist_realization_mode_set(genlist, EINA_TRUE);
987 __set_genlist_itc(ad);
989 st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
990 ELM_GENLIST_ITEM_NONE, NULL, NULL);
991 elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
994 elm_object_item_disabled_set(st->name_item, EINA_TRUE);
996 st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
997 ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
999 st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
1000 ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
1002 st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
1003 ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad);
1004 if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
1005 elm_object_item_disabled_set(st->pw_item, EINA_TRUE);
1007 elm_object_item_disabled_set(st->pw_item, EINA_FALSE);
1009 /* End separator is removed because of P131104-03336. It is confirmed by UX team for this case.
1010 item = elm_genlist_item_append(genlist, st->sp_itc, NULL, NULL,
1011 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1012 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1013 st->sp_item[i++] = item;
1016 __MOBILE_AP_FUNC_EXIT__;
1021 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
1026 ERR("ad is NULL\n");
1031 mh_wifi_setting_view_t *st = &ad->setup;
1033 if (ad->setup.navi_it != NULL) {
1034 ERR("Wi-Fi setup view already exists\n");
1039 st->genlist = __create_genlist(ad);
1040 if (st->genlist == NULL) {
1041 ERR("__create_genlist returns NULL\n");
1046 st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_MBODY_WI_FI_TETHERING",
1047 NULL, NULL, st->genlist, NULL);
1048 elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);
1050 elm_naviframe_item_pop_cb_set(st->navi_it, _setting_back_btn_cb, (void *)ad);
1052 btn = elm_button_add(ad->naviframe);
1053 elm_object_style_set(btn, "naviframe/title_cancel");
1054 evas_object_smart_callback_add(btn, "clicked", __cancel_btn_cb, ad);
1055 elm_object_item_part_content_set(st->navi_it, "title_left_btn", btn);
1056 st->cancel_button = btn;
1058 btn = elm_button_add(ad->naviframe);
1059 elm_object_style_set(btn, "naviframe/title_done");
1060 evas_object_smart_callback_add(btn, "clicked", __save_btn_cb, ad);
1061 elm_object_item_part_content_set(st->navi_it, "title_right_btn", btn);
1062 st->save_button = btn;