#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
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);
+}
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
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:
{
__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;
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)
__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;
+}
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);
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
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})
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")
--- /dev/null
+/*
+ * 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);
+ }
+ }
+ }
+
+ }
+}
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;
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);
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) {
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
"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;
+}
int viewer_manager_create_scan_btn(void);
void viewer_manager_eap_view_deref(void);
+void viewer_manager_show_interface(void);
#ifdef __cplusplus
}
//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: