From d579f1f6684d2a690361e90d5d9fb498cc800c99 Mon Sep 17 00:00:00 2001 From: Priya Kohli Date: Fri, 9 Jun 2017 09:22:43 +0530 Subject: [PATCH] In case of Auto Configuration displaying DHCP IP Configuration values. In case wire is disconnected then displaying "000.000.000.000" Change-Id: Iee83630d7936af817bbf3c5539bd28532691a8c7 Signed-off-by: Priya Kohli --- src/layout/layout_network.c | 11 +++----- src/view/view_new_network.c | 68 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/src/layout/layout_network.c b/src/layout/layout_network.c index eee1b3b..7b453b6 100644 --- a/src/layout/layout_network.c +++ b/src/layout/layout_network.c @@ -227,8 +227,6 @@ static void _network_type_option_selected(struct _priv *priv, int id, /* Hide wireless network list */ elm_object_signal_emit(priv->ly, SIG_WIRELESS_EXISTS, SRC_ELM); -/* listmgr_hide_grid(priv->listmgr, LIST_WIRELESS, - PART_WIRELESS_LIST);*/ viewmgr_update_view(VIEW_WIRELESS_LIST, GRID_HIDE, NULL); elm_object_signal_emit(priv->ly, SIG_LOADING_STOP, SRC_ELM); @@ -244,15 +242,13 @@ static void _network_type_option_selected(struct _priv *priv, int id, SETTING_TRACE("New network"); elm_object_text_set(priv->action_btn, STR_RETRY); - /* Hide wireless network list */ + /* Hide wireless network list */ elm_object_signal_emit(priv->ly, SIG_WIRELESS_EXISTS, SRC_ELM); - /*listmgr_hide_grid(priv->listmgr, LIST_WIRELESS, - PART_WIRELESS_LIST);*/ viewmgr_update_view(VIEW_WIRELESS_LIST, GRID_UPDATE, NULL); elm_object_signal_emit(priv->ly, SIG_LOADING_STOP, SRC_ELM); elm_object_part_text_set(priv->ly, PART_NO_NETWORK_TEXT, ""); - /* Show wired network status */ + /* Show wired network status */ elm_object_part_content_set(priv->ly, "part.wired.area", priv->wired_layout); evas_object_show(priv->wired_layout); @@ -260,7 +256,8 @@ static void _network_type_option_selected(struct _priv *priv, int id, /* Set network type as wired */ elm_object_text_set(priv->network_type_btn, STR_WIRED); -// viewmgr_pop_all_views(); + viewmgr_remove_view(VIEW_NEW_NETWORK); + if (!viewmgr_add_view(view_new_network_get_vclass(), priv->wired)) { _ERR("Add new network view failed."); return; diff --git a/src/view/view_new_network.c b/src/view/view_new_network.c index 449e7d1..1d59be2 100644 --- a/src/view/view_new_network.c +++ b/src/view/view_new_network.c @@ -16,6 +16,7 @@ #include #include +#include #include "common/viewmgr.h" #include "common/layoutmgr.h" @@ -107,6 +108,7 @@ struct _priv { }; static bool _update_entry_input_state(struct _priv *priv); +static void _set_default_config_values(struct _priv *priv); static inline bool _check_entry_filled(Evas_Object *entry) { @@ -808,12 +810,14 @@ static void _destroy_ip_type_popup(struct _priv *priv) static void _ip_type_option_selected(struct _priv *priv, int id, Evas_Object *obj) { + SETTING_TRACE_BEGIN; switch (id) { case TYPE_AUTOMATICALLY: SETTING_TRACE("Automatic IP"); elm_object_text_set(priv->ip_type_btn, str_config_type_opt[0]); - _update_entry_input_state(priv); priv->ip_menu = 0; + _set_default_config_values(priv); + _update_entry_input_state(priv); elm_object_disabled_set(priv->content_manual->address_ip, EINA_TRUE); elm_object_disabled_set(priv->content_manual->address_subnet, EINA_TRUE); elm_object_disabled_set(priv->content_manual->address_gateway, EINA_TRUE); @@ -825,8 +829,8 @@ static void _ip_type_option_selected(struct _priv *priv, int id, case TYPE_MANUALLY: SETTING_TRACE("Manual IP"); elm_object_text_set(priv->ip_type_btn, str_config_type_opt[1]); - _update_entry_input_state(priv); priv->ip_menu = 1; + _update_entry_input_state(priv); elm_object_disabled_set(priv->content_manual->address_ip, EINA_FALSE); elm_object_disabled_set(priv->content_manual->address_subnet, EINA_FALSE); elm_object_disabled_set(priv->content_manual->address_gateway, EINA_FALSE); @@ -925,6 +929,7 @@ static void _dns_type_option_selected(struct _priv *priv, int id, elm_object_text_set(priv->dns_type_btn, str_config_type_opt[0]); priv->dns_menu = 0; elm_object_disabled_set(priv->content_manual->address_dns, EINA_TRUE); + _set_default_config_values(priv); _update_entry_input_state(priv); break; @@ -1045,6 +1050,58 @@ static input_handler _dnsconfig_type_option_input_handler = { .clicked = _dns_type_clicked_cb, }; +static void _set_default_config_values(struct _priv *priv) +{ + SETTING_TRACE_BEGIN; + char *address = "000.000.000.000"; + char **ip_text = NULL; + + struct _content_manual *content = priv->content_manual; + + if (get_ethernet_profile(priv->conn)) + _DBG("Profile not found "); + + if(priv->ip_menu == 0) + { + /* IP address entry */ + get_address(priv->conn, IP_ADDRESS, &address); + ip_text = g_strsplit(address, ".", 5); + elm_entry_entry_set(content->ip1, ip_text[0]); + elm_entry_entry_set(content->ip2, ip_text[1]); + elm_entry_entry_set(content->ip3, ip_text[2]); + elm_entry_entry_set(content->ip4, ip_text[3]); + + /* Subnet mask entry */ + get_address(priv->conn, SUBNET_MASK, &address); + ip_text = g_strsplit(address, ".", 5); + elm_entry_entry_set(content->sub_ip1, ip_text[0]); + elm_entry_entry_set(content->sub_ip2, ip_text[1]); + elm_entry_entry_set(content->sub_ip3, ip_text[2]); + elm_entry_entry_set(content->sub_ip4, ip_text[3]); + + /* Gateway address entry */ + get_address(priv->conn, GATEWAY_ADDRESS, &address); + ip_text = g_strsplit(address, ".", 5); + elm_entry_entry_set(content->gateway_ip1, ip_text[0]); + elm_entry_entry_set(content->gateway_ip2, ip_text[1]); + elm_entry_entry_set(content->gateway_ip3, ip_text[2]); + elm_entry_entry_set(content->gateway_ip4, ip_text[3]); + } + + if(priv->dns_menu == 0) + { + /* DNS address entry */ + get_address(priv->conn, DNS_ADDRESS, &address); + ip_text = g_strsplit(address, ".", 5); + elm_entry_entry_set(content->dns_ip1, ip_text[0]); + elm_entry_entry_set(content->dns_ip2, ip_text[1]); + elm_entry_entry_set(content->dns_ip3, ip_text[2]); + elm_entry_entry_set(content->dns_ip4, ip_text[3]); + } + if(strcmp(address, "000.000.000.000")) + free(address); +} + static bool _draw_config_buttons(struct _priv *priv) { Evas_Object *ip_btn, *dns_btn; @@ -1229,6 +1286,8 @@ static void _create_content_manual(struct _priv *priv) priv->content_manual = content; + _set_default_config_values(priv);//Set automatic configuration values + elm_object_disabled_set(priv->content_manual->address_ip, EINA_TRUE); elm_object_disabled_set(priv->content_manual->address_subnet, EINA_TRUE); elm_object_disabled_set(priv->content_manual->address_gateway, EINA_TRUE); @@ -1317,12 +1376,13 @@ static Evas_Object *_create(Evas_Object *win, void *data) priv->conn = data; priv->input_panel_show = false; + priv->ip_menu = 0; + priv->dns_menu = 0; + _create_content_manual(priv); elm_object_part_content_set(base, "part.content.area", priv->content_manual->layout); - priv->ip_menu = 0; - priv->dns_menu = 0; if (!viewmgr_set_view_data(VIEW_NEW_NETWORK, priv)) { _ERR("Set view data failed."); -- 2.7.4