X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmh_view_wifi_setup.c;h=16e281afc9a92c26d1815367511e2b0bc68474bc;hb=21d5a23be4ae607e5a1171aa8ff82dce9ce0a56b;hp=8bd31115bbdbbd68a8f8aacde7d97c6b55e375f3;hpb=89ab9f5efeadb756db98b86325497b845958ce4d;p=apps%2Fnative%2Fug-mobile-ap.git diff --git a/src/mh_view_wifi_setup.c b/src/mh_view_wifi_setup.c index 8bd3111..16e281a 100755 --- a/src/mh_view_wifi_setup.c +++ b/src/mh_view_wifi_setup.c @@ -20,12 +20,18 @@ #include "mh_popup.h" #include "mh_view_wifi_setup.h" +#include "mh_view_main.h" #include "mh_string.h" static void __gl_realized(void *data, Evas_Object *obj, void *event_info); static void __cancel_btn_cb(void *data, Evas_Object *object, void *event_info); static void __save_btn_cb(void *data, Evas_Object *object, void *event_info); +static void __create_password_item(Evas_Object *genlist, mh_appdata_t *ad); +static void __destroy_password_item(mh_appdata_t *ad); + +static guint tethering_param_timer = 0; + static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info) { __MOBILE_AP_FUNC_ENTER__; @@ -76,10 +82,15 @@ static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_ mh_appdata_t *ad = (mh_appdata_t *)data; mh_wifi_setting_view_t *st = &ad->setup; - if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) + if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) { st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK; - else + if (st->pw_item == NULL) + __create_password_item(st->genlist, ad); + } else { st->security_type_new = TETHERING_WIFI_SECURITY_TYPE_NONE; + /* Disable password entry */ + __destroy_password_item(ad); + } /* update wifi passphrase item */ if (st->security_type_new == TETHERING_WIFI_SECURITY_TYPE_NONE) { @@ -87,9 +98,6 @@ static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_ elm_object_disabled_set(st->save_button, EINA_FALSE); } else { elm_object_item_disabled_set(st->pw_item, EINA_FALSE); - if (st->pw_entry == NULL || elm_entry_entry_get(st->pw_entry) == NULL || - strlen(elm_entry_entry_get(st->pw_entry)) == 0) - elm_object_disabled_set(st->save_button, EINA_TRUE); } if (st->pw_item) @@ -98,6 +106,28 @@ static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_ __MOBILE_AP_FUNC_EXIT__; } +static void __check_box_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + __MOBILE_AP_FUNC_ENTER__; + + if (data == NULL || obj == NULL) { + ERR("Invalid param\n"); + return; + } + + Eina_Bool state = elm_check_state_get(obj); + mh_appdata_t *ad = (mh_appdata_t *)data; + mh_wifi_setting_view_t *st = &ad->setup; + + if (state) + elm_entry_password_set(st->pw_entry, EINA_FALSE); + else + elm_entry_password_set(st->pw_entry, EINA_TRUE); + + __MOBILE_AP_FUNC_EXIT__; + return; +} + static bool __save_security_btn_change(mh_appdata_t *ad) { __MOBILE_AP_FUNC_ENTER__; @@ -134,9 +164,8 @@ static char *__gl_device_name_title_label_get(void *data, Evas_Object *obj, cons if (!strcmp("elm.text.multiline", part)) { device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR); - if (device_name_utf == NULL) { + if (device_name_utf == NULL) ERR("vconf_get_str failed \n"); - } ptr = elm_entry_utf8_to_markup(device_name_utf); if (ptr == NULL) { @@ -169,9 +198,8 @@ static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part) return NULL; } - if (!strcmp("elm.text", part)) { + if (!strcmp("elm.text", part)) return strdup(STR_HIDE_MY_DEV); - } __MOBILE_AP_FUNC_EXIT__; return NULL; @@ -186,9 +214,8 @@ static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *p return NULL; } - if (!strcmp("elm.text", part)) { + if (!strcmp("elm.text", part)) return strdup(STR_SECURITY_TYPE); - } __MOBILE_AP_FUNC_EXIT__; return NULL; @@ -349,9 +376,8 @@ static void __pw_entry_maxlength_reached_cb(void *data, Evas_Object *obj, WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX); ret = notification_status_message_post(buf); - if (ret != NOTIFICATION_ERROR_NONE) { + if (ret != NOTIFICATION_ERROR_NONE) ERR("notification_status_message_post() is failed : %d\n", ret); - } __MOBILE_AP_FUNC_EXIT__; } @@ -373,7 +399,7 @@ static void __pw_entry_activated_cb(void *data, Evas_Object *obj, void *event_in static void __pw_entry_focused_cb(void *data, Evas_Object *obj, void *event_info) { __MOBILE_AP_FUNC_ENTER__; - evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __pw_entry_focused_cb); + evas_object_smart_callback_del(obj, "focused", __pw_entry_focused_cb); elm_object_focus_set(obj, EINA_TRUE); elm_entry_cursor_end_set(obj); @@ -462,9 +488,8 @@ static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent) elm_entry_single_line_set(entry, EINA_TRUE); elm_entry_scrollable_set(entry, EINA_TRUE); - elm_entry_password_set(entry, EINA_FALSE); + elm_entry_password_set(entry, EINA_TRUE); - st->pw_entry = entry; evas_object_smart_callback_add(entry, "language,changed", __pw_entry_language_changed_cb, ad); @@ -499,7 +524,7 @@ static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent) } } - elm_entry_input_panel_return_key_type_set(st->pw_entry, + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE); clr_btn = elm_button_add(entry); @@ -522,32 +547,14 @@ static Evas_Object *__get_pw_entry(void *data, Evas_Object *parent) evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __pw_entry_show_cb, NULL); -// elm_entry_editable_set(entry, EINA_TRUE); elm_object_focus_set(entry, EINA_TRUE); elm_entry_input_panel_show(entry); elm_object_part_content_set(parent, "elm.swallow.content", entry); - __MOBILE_AP_FUNC_EXIT__; - return st->pw_entry; -} - -static char *__gl_pw_text_get(void *data, Evas_Object *obj, const char *part) -{ - __MOBILE_AP_FUNC_ENTER__; - char buf[MH_LABEL_LENGTH_MAX] = {0, }; - - if (data == NULL || obj == NULL || part == NULL) { - ERR("Invalid param\n"); - return NULL; - } - - if (!strcmp("elm.text.main", part)) { - snprintf(buf, MH_LABEL_LENGTH_MAX, "%s", STR_PASSWORD); - return strdup(buf); - } + st->pw_entry = entry; __MOBILE_AP_FUNC_EXIT__; - return NULL; + return st->pw_entry; } static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char *part) @@ -568,14 +575,14 @@ static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char Evas_Object *layout = elm_layout_add(box); char buf[MH_LABEL_LENGTH_MAX] = {0, }; - elm_box_align_set(box, 0.5, 0.5); + elm_box_align_set(box, 0.0, 0.0); /* Set label for name field */ snprintf(buf, MH_LABEL_LENGTH_MAX, "%s", STR_PASSWORD); elm_object_text_set(label, buf); evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND); - evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10)); + evas_object_size_hint_padding_set(label, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10), 0, 0); elm_box_pack_end(box, label); evas_object_show(label); @@ -591,13 +598,50 @@ static Evas_Object *__gl_pw_content_get(void *data, Evas_Object *obj, const char evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h)); evas_object_show(box); - return box; + return box; } __MOBILE_AP_FUNC_EXIT__; return NULL; } +static char *_gl_pswd_check_box_text_get(void *data, + Evas_Object *obj, const char *part) +{ + if (!strcmp("elm.text", part)) + return strdup(STR_SHOW_PASSWORD); + + return NULL; + +} + +static Evas_Object *_gl_pswd_check_box_content_get(void *data, + Evas_Object *obj, const char *part) +{ + mh_appdata_t *ad = (mh_appdata_t *)data; + Evas_Object *check = NULL; + + if (data == NULL || obj == NULL || part == NULL) { + ERR("Invalid param\n"); + return NULL; + } + + if (!strcmp("elm.swallow.icon", part)) { + check = elm_check_add(obj); + evas_object_propagate_events_set(check, EINA_FALSE); + + evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_smart_callback_add(check, "changed", __check_box_changed_cb, (void *)ad); + + elm_object_focus_allow_set(check, EINA_FALSE); + + return check; + } + return NULL; +} + + static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info) { __MOBILE_AP_FUNC_ENTER__; @@ -641,19 +685,6 @@ static void __set_genlist_itc(mh_appdata_t *ad) { __MOBILE_AP_FUNC_ENTER__; -#if 0 /* not used */ - ad->setup.sp_itc = elm_genlist_item_class_new(); - if (ad->setup.sp_itc == NULL) { - ERR("elm_genlist_item_class_new failed\n"); - __MOBILE_AP_FUNC_EXIT__; - return; - } - ad->setup.sp_itc->item_style = "dialogue/separator"; - ad->setup.sp_itc->func.text_get = NULL; - ad->setup.sp_itc->func.content_get = NULL; - ad->setup.sp_itc->func.state_get = NULL; - ad->setup.sp_itc->func.del = NULL; -#endif ad->setup.name_itc = elm_genlist_item_class_new(); if (ad->setup.name_itc == NULL) { ERR("elm_genlist_item_class_new failed\n"); @@ -702,19 +733,18 @@ static void __set_genlist_itc(mh_appdata_t *ad) ad->setup.pw_itc->func.state_get = NULL; ad->setup.pw_itc->func.del = NULL; -#if 0 /* not used */ - ad->setup.sp2_itc = elm_genlist_item_class_new(); - if (ad->setup.sp2_itc == NULL) { + ad->setup.check_box_itc = elm_genlist_item_class_new(); + if (ad->setup.check_box_itc == NULL) { ERR("elm_genlist_item_class_new failed\n"); __MOBILE_AP_FUNC_EXIT__; return; } - ad->setup.sp2_itc->item_style = "dialogue/separator.2"; - ad->setup.sp2_itc->func.text_get = NULL; - ad->setup.sp2_itc->func.content_get = NULL; - ad->setup.sp2_itc->func.state_get = NULL; - ad->setup.sp2_itc->func.del = NULL; -#endif + ad->setup.check_box_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE; + ad->setup.check_box_itc->func.text_get = _gl_pswd_check_box_text_get; + ad->setup.check_box_itc->func.content_get = _gl_pswd_check_box_content_get; + ad->setup.check_box_itc->func.state_get = NULL; + ad->setup.check_box_itc->func.del = NULL; + __MOBILE_AP_FUNC_EXIT__; return; } @@ -751,6 +781,8 @@ static void __settings_reloaded_cb(tethering_error_e result, void *user_data) __MOBILE_AP_FUNC_ENTER__; + g_source_remove(tethering_param_timer); + mh_appdata_t *ad = (mh_appdata_t *)user_data; if (result != TETHERING_ERROR_NONE) @@ -762,6 +794,27 @@ static void __settings_reloaded_cb(tethering_error_e result, void *user_data) return; } +static gboolean _update_tethering_param(gpointer data) +{ + __MOBILE_AP_FUNC_ENTER__; + mh_appdata_t *ad = (mh_appdata_t *)data; + int ret; + + if (ad == NULL) { + ERR("Invalid parameter\n"); + return FALSE; + } + + /* reload wifi settings */ + ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb, + (void *)ad); + if (ret != TETHERING_ERROR_NONE) + ERR("reload_configuration is failed : %d\n", ret); + + __MOBILE_AP_FUNC_EXIT__; + return FALSE; +} + static void __save_btn_cb(void *data, Evas_Object *object, void *event_info) { DBG("+\n"); @@ -804,7 +857,7 @@ static void __save_btn_cb(void *data, Evas_Object *object, void *event_info) if (ret == false) { g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase, sizeof(st->wifi_passphrase_new)); - if(st->pw_item) + if (st->pw_item) elm_genlist_item_update(st->pw_item); } else { g_strlcpy(st->wifi_passphrase, st->wifi_passphrase_new, @@ -823,11 +876,13 @@ static void __save_btn_cb(void *data, Evas_Object *object, void *event_info) if (ad->main.help_item) elm_genlist_item_update(ad->main.help_item); - /* reload wifi settings */ - ret = tethering_wifi_reload_settings(ad->handle, __settings_reloaded_cb, - (void *)ad); - if (ret != TETHERING_ERROR_NONE) - ERR("reload_configuration is failed : %d\n", ret); + /* Here, The Dbus takes some amount of time + to set the tethering parameters, due to + which UI shows incorrect display, to avoid + this issue, CAPI will be called after 0.1sec for smooth + transition of UI frames */ + tethering_param_timer = g_timeout_add(100, + _update_tethering_param, ad); } elm_naviframe_item_pop(ad->naviframe); @@ -864,13 +919,11 @@ Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item) mh_appdata_t *ad = (mh_appdata_t *)data; mh_wifi_setting_view_t *st = &ad->setup; - if (st->visibility != st->visibility_new) { + if (st->visibility != st->visibility_new) st->visibility_new = st->visibility; - } - if (st->security_type != st->security_type_new) { + if (st->security_type != st->security_type_new) st->security_type_new = st->security_type; - } if (strcmp(st->wifi_passphrase_new, st->wifi_passphrase)) { g_strlcpy(st->wifi_passphrase_new, st->wifi_passphrase, @@ -884,6 +937,7 @@ Eina_Bool _setting_back_btn_cb(void *data, Elm_Object_Item *navi_item) ad->rename_popup = NULL; } ad->setup.navi_it = NULL; + _ctxpopup_more_button_callback_add(ad); DBG("-\n"); return EINA_TRUE; @@ -902,14 +956,12 @@ static void __gl_realized(void *data, Evas_Object *obj, void *event_info) int no_of_sp; int i; - if (item == st->hide_item) { + if (item == st->hide_item) elm_object_item_signal_emit(item, "elm,state,top", ""); - } else if (item == st->security_item) { + else if (item == st->security_item) elm_object_item_signal_emit(item, "elm,state,center", ""); - } else if (item == st->pw_item) { + else if (item == st->pw_item) elm_object_item_signal_emit(item, "elm,state,bottom", ""); - } else if (item == st->name_item) { - } no_of_sp = sizeof(st->sp_item) / sizeof(st->sp_item[0]); for (i = 0; i < no_of_sp; i++) { @@ -946,21 +998,43 @@ static void __select_passphrase_item(void *data, Evas_Object *obj, void *event_i return; } - Elm_Object_Item *item = (Elm_Object_Item *)event_info; - Evas_Object *layout = NULL; mh_appdata_t *ad = (mh_appdata_t *)data; + mh_wifi_setting_view_t *st = &ad->setup; - elm_genlist_item_selected_set(item, EINA_FALSE); - - layout = elm_layout_add(obj); - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - __get_pw_entry(ad, layout); + elm_object_focus_set(st->pw_entry, EINA_TRUE); - evas_object_show(layout); __MOBILE_AP_FUNC_EXIT__; return; } +static void __create_password_item(Evas_Object *genlist, mh_appdata_t *ad) +{ + void *data = (void *)ad; + mh_wifi_setting_view_t *st = &ad->setup; + + st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL, + ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad); + if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE) + elm_object_item_disabled_set(st->pw_item, EINA_TRUE); + else + elm_object_item_disabled_set(st->pw_item, EINA_FALSE); + + st->check_box_item = elm_genlist_item_append(genlist, st->check_box_itc, data, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); +} + +static void __destroy_password_item(mh_appdata_t *ad) +{ + void *data = (void *)ad; + mh_wifi_setting_view_t *st = &ad->setup; + + elm_object_item_del(st->check_box_item); + st->check_box_item = NULL; + + elm_object_item_del(st->pw_item); + st->pw_item = NULL; +} + Evas_Object *__create_genlist(mh_appdata_t *ad) { __MOBILE_AP_FUNC_ENTER__; @@ -983,7 +1057,6 @@ Evas_Object *__create_genlist(mh_appdata_t *ad) elm_object_style_set(genlist, "dialogue"); elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); evas_object_smart_callback_add(genlist, "realized", __gl_realized, ad); - //elm_genlist_realization_mode_set(genlist, EINA_TRUE); __set_genlist_itc(ad); @@ -1000,19 +1073,8 @@ Evas_Object *__create_genlist(mh_appdata_t *ad) st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL, ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data); - st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL, - ELM_GENLIST_ITEM_NONE, __select_passphrase_item, ad); - if (st->security_type == TETHERING_WIFI_SECURITY_TYPE_NONE) - elm_object_item_disabled_set(st->pw_item, EINA_TRUE); - else - elm_object_item_disabled_set(st->pw_item, EINA_FALSE); - -/* End separator is removed because of P131104-03336. It is confirmed by UX team for this case. - item = elm_genlist_item_append(genlist, st->sp_itc, NULL, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - st->sp_item[i++] = item; -*/ + if (st->security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) + __create_password_item(genlist, ad); __MOBILE_AP_FUNC_EXIT__; @@ -1044,7 +1106,7 @@ void mh_draw_wifi_setup_view(mh_appdata_t *ad) return; } - st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_MBODY_WI_FI_TETHERING", + st->navi_it = elm_naviframe_item_push(ad->naviframe, "IDS_MOBILEAP_BODY_CONFIGURE_MOBILE_HOTSPOT_ABB_US_TMO", NULL, NULL, st->genlist, NULL); elm_object_item_domain_text_translatable_set(st->navi_it, PKGNAME, EINA_TRUE);