From: Prasadam Prashath Kumar Date: Thu, 17 Sep 2020 11:02:38 +0000 (+0530) Subject: Add Wlan Multi Interface UI X-Git-Tag: accepted/tizen/6.0/unified/20201030.122945^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b50975f26b5502910a189de32087c8efa2266348;p=apps%2Fnative%2Fug-wifi-efl.git Add Wlan Multi Interface UI - Initialize the Multi Interface handlers - Display the Wlan interface buttons Change-Id: I2cb743fb2996e83fe766e0828f79efb88b650037 Signed-off-by: Prasadam Prashath Kumar --- diff --git a/common/common.h b/common/common.h index 3497f58..ce70f47 100644 --- a/common/common.h +++ b/common/common.h @@ -61,6 +61,8 @@ extern "C" #define MAIN_LAYOUT_EDJ_PATH \ "/usr/apps/wifi-efl-ug/res/edje/main_layout.edj" +#define CUSTOM_WLAN_BTN_EDJ_PATH \ + "/usr/apps/wifi-efl-ug/res/edje/custom_wlan_buttons.edj" /* Log Level */ #define COMMON_LOG_DEBUG LOG_DEBUG #define COMMON_LOG_INFO LOG_INFO diff --git a/common/wlan_connection.c b/common/wlan_connection.c index 6d6e25f..2160052 100644 --- a/common/wlan_connection.c +++ b/common/wlan_connection.c @@ -264,3 +264,9 @@ void wlan_connect_cleanup(void) next_item.pin = NULL; } } + +void wlan_connect_set_handle(wifi_manager_h *wifi) +{ + wifi_handle = wifi; + INFO_LOG(UG_NAME_NORMAL, "handle [%p] wifi[%p]", wifi_handle, wifi); +} diff --git a/common/wlan_connection.h b/common/wlan_connection.h index 066a03d..28e3b2b 100644 --- a/common/wlan_connection.h +++ b/common/wlan_connection.h @@ -44,6 +44,7 @@ gboolean wlan_is_same_with_current(wifi_manager_ap_h ap); void wlan_connect_cleanup(void); void wlan_connect_next(); void wlan_go_fast_next(); +void wlan_connect_set_handle(wifi_manager_h *wifi); #ifdef __cplusplus } #endif diff --git a/common/wlan_manager.c b/common/wlan_manager.c index 3bb421a..e824233 100644 --- a/common/wlan_manager.c +++ b/common/wlan_manager.c @@ -340,6 +340,9 @@ static void wlan_manager_device_state_changed_cb( wlan_mgr_event_info_t event_info; memset(&event_info, 0, sizeof(event_info)); + int index = GPOINTER_TO_INT(user_data); + + INFO_LOG(UG_NAME_NORMAL, "state [%d] ifname[%s] index[%d]", state, manager_object->ifname[index], index); switch (state) { case WIFI_MANAGER_DEVICE_STATE_ACTIVATED: @@ -441,9 +444,9 @@ static void wlan_manager_register_cbs(void) { __COMMON_FUNC_ENTER__; - wifi_manager_set_device_state_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_device_state_changed_cb, NULL); - wifi_manager_set_connection_state_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_connection_state_changed_cb, NULL); - wifi_manager_set_rssi_level_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_rssi_level_changed_cb, NULL); + wifi_manager_set_device_state_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_device_state_changed_cb, GINT_TO_POINTER(manager_object->active_wifi_index)); + wifi_manager_set_connection_state_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_connection_state_changed_cb, GINT_TO_POINTER(manager_object->active_wifi_index)); + wifi_manager_set_rssi_level_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_rssi_level_changed_cb, GINT_TO_POINTER(manager_object->active_wifi_index)); memset(&scan_req_data, 0, sizeof(scan_req_data)); scan_req_data.req_type = WLAN_MANAGER_REQ_TYPE_SCAN_RESULT; @@ -1063,6 +1066,7 @@ int wlan_manager_set_autoscan_mode(wlan_manager_autoscan_mode_e mode) void wlan_manager_set_active_wifi_index(wlan_manager_wifi_iface_index_e index) { manager_object->active_wifi_index = index; + wlan_connect_set_handle(&( manager_object->wifi[manager_object->active_wifi_index])); } int wlan_mgr_get_index_from_ifname(const char *ifname) @@ -1113,3 +1117,13 @@ int wlan_manager_get_available_interface(void) __COMMON_FUNC_EXIT__; return ret; } + +char* wlan_manager_get_ifname(int index) +{ + return manager_object->ifname[index]; +} + +int wlan_manager_get_interface_count(void) +{ + return manager_object->interface_count; +} diff --git a/common/wlan_manager.h b/common/wlan_manager.h index 17cdc0a..716aa7e 100644 --- a/common/wlan_manager.h +++ b/common/wlan_manager.h @@ -272,6 +272,8 @@ void wlan_manager_set_active_wifi_index(wlan_manager_wifi_iface_index_e index); int wlan_manager_get_available_interface(void); bool wlan_manager_interface_cb(char *ifname, void *user_data); int wlan_mgr_get_index_from_ifname(const char *ifname); +char* wlan_manager_get_ifname(int index); +int wlan_manager_get_interface_count(void); //// profile refresh ///////////////////////////////////////////// void wlan_manager_scanned_profile_refresh(void); diff --git a/packaging/wifi-efl-ug.spec b/packaging/wifi-efl-ug.spec index 20ec30b..0e19fb1 100644 --- a/packaging/wifi-efl-ug.spec +++ b/packaging/wifi-efl-ug.spec @@ -1,6 +1,6 @@ Name: wifi-efl-ug Summary: Wi-Fi UI Gadget for TIZEN -Version: 1.1.2 +Version: 1.1.3 Release: 1 Group: App/Network License: Flora-1.1 diff --git a/ui-gadget/edc/CMakeLists.txt b/ui-gadget/edc/CMakeLists.txt index 353d328..15b622a 100644 --- a/ui-gadget/edc/CMakeLists.txt +++ b/ui-gadget/edc/CMakeLists.txt @@ -2,7 +2,7 @@ SET(EDC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) SET(IMAGE_DIR ${CMAKE_SOURCE_DIR}/res/images) SET(FONT_DIR ${CMAKE_SOURCE_DIR}/res/fonts) SET(EDC_FILES custom_editfield.edc custom_popup.edc oobe_buttons.edc custom_genlist.edc - main_layout.edc setup_wizard.edc + main_layout.edc setup_wizard.edc custom_wlan_buttons.edc ) FOREACH(edc_file ${EDC_FILES}) @@ -16,4 +16,4 @@ FOREACH(edc_file ${EDC_FILES}) ENDFOREACH() INSTALL(DIRECTORY ${EDC_DIR}/ DESTINATION ${APP_INSTALL_DIR}/wifi-efl-ug/res/edje - FILES_MATCHING PATTERN "*.edj") \ No newline at end of file + FILES_MATCHING PATTERN "*.edj") diff --git a/ui-gadget/edc/custom_wlan_buttons.edc b/ui-gadget/edc/custom_wlan_buttons.edc new file mode 100644 index 0000000..f0e2095 --- /dev/null +++ b/ui-gadget/edc/custom_wlan_buttons.edc @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +collections { + base_scale: 1.8; + + group { + name: "elm/button/base/wlan_buttons/wlan"; + parts { + part { + name: "bg"; + scale:1; + type: RECT; + description { + state: "default" 0.0; + min: 200 30; + max: 200 30; + color: 0 0 0 0; + visible: 1; + } + description { + state: "focused" 0.0; + color: 0 0 255 1; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 0; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + fixed: 1 1; + rel1.to: "bg"; + rel2.to: "bg"; + align: 0.5 0.5; + min: 200 20; + max: 200 20; + color: 0 0 0 255; + text { + font: "SamsungOne600"; + size: 24; + min: 0 1; + align: 0.5 0.5; + } + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + color: 0 0 255 255; + } + description { + state: "unfocused" 0.0; + inherit: "default" 0.0; + color: 0 0 0 255; + } + } + + part { + name: "over"; + scale: 1; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + } + } + + } + + programs { + program { + name: "mouse_click"; + source: "over"; + signal: "mouse,clicked,1"; + script { + emit("elm,action,click", ""); + } + } + + program { + name: "focus_in"; + signal: "elm,action,focus"; + source: "elm"; + script { + set_state(PART:"elm.text", "focused", 0.0); + } + } + program { + name: "focus_out"; + signal: "elm,action,btnunfocus"; + source: "elm"; + script { + set_state(PART:"elm.text", "default", 0.0); + } + } + } + + } +} diff --git a/ui-gadget/viewer_manager.c b/ui-gadget/viewer_manager.c index 6a6cd83..3562d6b 100644 --- a/ui-gadget/viewer_manager.c +++ b/ui-gadget/viewer_manager.c @@ -53,7 +53,9 @@ typedef struct viewer_manager_object { Evas_Object *sw_hidden_btn; Evas_Object *sw_scan_btn; + Evas_Object *ifname_btn[WLAN_MANAGER_WIFI_IFACE_MAX]; char *ifname[WLAN_MANAGER_WIFI_IFACE_MAX]; + Evas_Object *on_off_check; Elm_Object_Item *item_wifi_onoff; char *item_wifi_onoff_text; @@ -772,6 +774,7 @@ static Evas_Object *_gl_wifi_onoff_content_get(void *data, style = "on&off"; c = elm_check_add(obj); + manager_object->on_off_check = c; elm_object_style_set(c, style); evas_object_propagate_events_set(c, EINA_FALSE); evas_object_smart_callback_add(c, "changed", __power_onoff_cb, NULL); @@ -998,6 +1001,7 @@ static void viewer_manager_setup_wizard_scan_btn_set(Eina_Bool show_state) static Eina_Bool viewer_manager_scan_button_set(Eina_Bool show_state) { + return EINA_TRUE; //This code may reuse __COMMON_FUNC_ENTER__; if (manager_object == NULL) { @@ -1556,6 +1560,7 @@ Evas_Object *viewer_manager_naviframe_power_item_get(void) int viewer_manager_create_scan_btn(void) { + return 0; //This code may reuse again __COMMON_FUNC_ENTER__; if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD || ug_app_state->ug_type == UG_VIEW_OOBE @@ -2497,3 +2502,109 @@ void viewer_manager_rotate_top_setupwizard_layout(void) "location,horizontal", "elm"); } } + +void __unset_other_wlan_btns(int selected) +{ + for(int i=0; i< WLAN_MANAGER_WIFI_IFACE_MAX; i++) { + if (i != selected && manager_object->ifname_btn[i]) + elm_object_signal_emit(manager_object->ifname_btn[i], "elm,action,btnunfocus", "elm"); + } +} + +static void __ifname_btn_callback(void *data, + Evas_Object *obj, void *event_info) +{ + __COMMON_FUNC_ENTER__; + int wlan_ret; + bool activated; + int index = GPOINTER_TO_INT(data); + + __unset_other_wlan_btns(index); //unset focus on other buttons, need to change this logic to genlist item + + INFO_LOG(UG_NAME_NORMAL, "btn clicked on interface btn [%d] ", index ); + wlan_manager_set_active_wifi_index(index); + + wlan_ret = wlan_manager_is_activated(&activated); + if (WIFI_MANAGER_ERROR_NONE == wlan_ret) { + INFO_LOG(UG_NAME_NORMAL, "Wi-Fi activated status: [%d]", activated); + if (activated == EINA_FALSE) { + INFO_LOG(UG_NAME_NORMAL, "clear the view"); + elm_check_state_set(manager_object->on_off_check, EINA_FALSE); + viewer_manager_hide(VIEWER_WINSET_SUB_CONTENTS); + viewer_list_item_clear(); + viewer_manager_onoff_description_item_set(TRUE); + } else { + elm_check_state_set(manager_object->on_off_check, EINA_TRUE); + viewer_manager_show(VIEWER_WINSET_SUB_CONTENTS); + viewer_manager_onoff_description_item_set(FALSE); + viewer_list_item_enable_all(); + viewer_manager_show(VIEWER_WINSET_SEARCHING); + viewer_manager_header_mode_set(HEADER_MODE_SEARCHING); + + int scan_result = wlan_manager_scan(); + if (scan_result != WLAN_MANAGER_ERR_NONE) { + INFO_LOG(UG_NAME_NORMAL, "scan got error"); + viewer_manager_hide(VIEWER_WINSET_SEARCHING); + } + } + + } else + INFO_LOG(UG_NAME_NORMAL, "Wi-Fi get activated failed: [%d]", activated); + + __COMMON_FUNC_EXIT__; + +} + + +void viewer_manager_show_interface(void) +{ + __COMMON_FUNC_ENTER__; + if (ug_app_state->ug_type == UG_VIEW_SETUP_WIZARD + || ug_app_state->ug_type == UG_VIEW_OOBE) { + __COMMON_FUNC_EXIT__; + return; + } + + Evas_Object *box = NULL; + int ifname_count = wlan_manager_get_interface_count(); + + box = elm_box_add(manager_object->nav); + if (!box) { + ERROR_LOG(UG_NAME_NORMAL, "Error creating box"); + return; + } + elm_box_horizontal_set(box, EINA_TRUE); + + if (ifname_count < WLAN_MANAGER_WIFI_IFACE_WLAN2) + return; + + for (int i = 0; i < WLAN_MANAGER_WIFI_IFACE_MAX; i++) { + if (!wlan_manager_get_ifname(i)) + continue; + manager_object->ifname_btn[i] = elm_button_add(box); + if (!manager_object->ifname_btn[i]) { + ERROR_LOG(UG_NAME_NORMAL, "Error creating toolbar"); + return; + } + DEBUG_LOG(UG_NAME_NORMAL, " index:ifname[%d : %s]", i, wlan_manager_get_ifname(i)); + elm_theme_extension_add(NULL, CUSTOM_WLAN_BTN_EDJ_PATH); + elm_object_style_set(manager_object->ifname_btn[i], "wlan_buttons/wlan"); + elm_object_text_set(manager_object->ifname_btn[i], wlan_manager_get_ifname(i)); + evas_object_size_hint_align_set(manager_object->ifname_btn[i], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(manager_object->ifname_btn[i], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + if (ug_app_state->ug_type == UG_VIEW_IOT_COMMON) + evas_object_size_hint_padding_set(manager_object->ifname_btn[i], 40, 40, 0, 40); + + evas_object_smart_callback_add(manager_object->ifname_btn[i], "clicked", __ifname_btn_callback, GINT_TO_POINTER(i)); + + /* Set box into "toolbar" swallow part */ + elm_object_item_part_content_set(manager_object->navi_it, "toolbar", box); + evas_object_show(manager_object->ifname_btn[i]); + + elm_box_pack_end(box, manager_object->ifname_btn[i]); + } + elm_object_signal_emit(manager_object->ifname_btn[0], "elm,action,focus", "elm"); + __COMMON_FUNC_EXIT__; + return; +} diff --git a/ui-gadget/viewer_manager.h b/ui-gadget/viewer_manager.h index c120eda..b1a2f2a 100644 --- a/ui-gadget/viewer_manager.h +++ b/ui-gadget/viewer_manager.h @@ -92,6 +92,7 @@ void viewer_manager_update_hidden_btn(void); int viewer_manager_create_scan_btn(void); void viewer_manager_eap_view_deref(void); +void viewer_manager_show_interface(void); #ifdef __cplusplus } diff --git a/ui-gadget/wifi-efl-UG.c b/ui-gadget/wifi-efl-UG.c index 7c861d3..bd0050f 100644 --- a/ui-gadget/wifi-efl-UG.c +++ b/ui-gadget/wifi-efl-UG.c @@ -184,20 +184,25 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, //Finds the number of wifi devices attached wlan_manager_get_available_interface(); - switch (wlan_manager_start()) { - case WLAN_MANAGER_ERR_NONE: - break; - - case WLAN_MANAGER_ERR_ALREADY_REGISTERED: - break; - - default: - ERROR_LOG(UG_NAME_NORMAL, "Cannot start wlan_manager"); - - __COMMON_FUNC_EXIT__; - return ugd->base; + //Initialize wifi handler for detected wlan interfaces + for (int i = 0; i < WLAN_MANAGER_WIFI_IFACE_MAX; i++) { + if(!wlan_manager_get_ifname(i)) + continue; + wlan_manager_set_active_wifi_index(i); + + switch (wlan_manager_start()) { + case WLAN_MANAGER_ERR_NONE: + case WLAN_MANAGER_ERR_ALREADY_REGISTERED: + break; + + default: + ERROR_LOG(UG_NAME_NORMAL, "Cannot start wlan_manager"); + __COMMON_FUNC_EXIT__; + return ugd->base; + } } - + viewer_manager_show_interface(); + wlan_manager_set_active_wifi_index(0); state = wlan_manager_state_get(); switch (state) { case WLAN_MANAGER_OFF: