Skip to content

Commit

Permalink
fix: wireless tab and cellular tab will show up when only ipv6 is ena…
Browse files Browse the repository at this point in the history
…bled [backport release-5.4.0] (#5001)

fix: wireless tab and cellular tab will show up when only ipv6 is enabled (#4999)

* fix: added boolean for ipv6

* Update TabIp6Ui.java

* fix: management of ipv6 and modes with wireless

Signed-off-by: MMaiero <[email protected]>

* fix: condition to detect status change

Signed-off-by: Marcello Martina <[email protected]>

---------

Signed-off-by: MMaiero <[email protected]>
Signed-off-by: Marcello Martina <[email protected]>
Co-authored-by: MMaiero <[email protected]>
Co-authored-by: Marcello Martina <[email protected]>
(cherry picked from commit 423a7a4)

Co-authored-by: G_Ivo <[email protected]>
  • Loading branch information
github-actions[bot] and GregoryIvo authored Nov 20, 2023
1 parent 0f8b6de commit 8dc9032
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
*******************************************************************************/
Expand All @@ -24,8 +24,6 @@
import org.eclipse.kura.web.shared.model.GwtSession;
import org.eclipse.kura.web.shared.model.GwtWifiNetInterfaceConfig;
import org.eclipse.kura.web.shared.model.GwtWifiWirelessMode;
import org.eclipse.kura.web.shared.service.GwtNetworkService;
import org.eclipse.kura.web.shared.service.GwtNetworkServiceAsync;
import org.gwtbootstrap3.client.ui.AnchorListItem;
import org.gwtbootstrap3.client.ui.NavbarNav;
import org.gwtbootstrap3.client.ui.PanelBody;
Expand All @@ -45,13 +43,14 @@ public class NetworkTabsUi extends Composite {
.get(GwtNetIfStatus.netIPv4StatusUnmanaged.name());
private static final String IPV4_STATUS_ENABLED_LAN_MESSAGE = MessageUtils
.get(GwtNetIfStatus.netIPv4StatusEnabledLAN.name());
private static final String IPV6_STATUS_DISABLED_MESSAGE = MessageUtils
.get(GwtNetIfStatus.netIPv6StatusDisabled.name());

private static NetworkTabsUiUiBinder uiBinder = GWT.create(NetworkTabsUiUiBinder.class);

interface NetworkTabsUiUiBinder extends UiBinder<Widget, NetworkTabsUi> {
}

private final GwtNetworkServiceAsync gwtNetworkService = GWT.create(GwtNetworkService.class);
private static final Messages MSGS = GWT.create(Messages.class);

private boolean isNet2 = false;
Expand Down Expand Up @@ -146,8 +145,8 @@ private void initIp6Tab() {

private void initWirelessTab(final boolean isNet2) {
this.wirelessTabAnchorItem = new AnchorListItem(MSGS.netWifiWireless());
this.wirelessTab = new TabWirelessUi(this.session, this.ip4Tab, this.set8021xTab, this.net8021xTabAnchorItem,
this, isNet2);
this.wirelessTab = new TabWirelessUi(this.session, this.ip4Tab, this.ip6Tab, this.set8021xTab,
this.net8021xTabAnchorItem, this, isNet2);

this.wirelessTabAnchorItem.addClickHandler(event -> {
setSelected(NetworkTabsUi.this.wirelessTabAnchorItem);
Expand Down Expand Up @@ -287,6 +286,7 @@ private void removeAllTabs() {
private void arrangeOptionalTabs() {
boolean isIpv4EnabledLAN = this.ip4Tab.getStatus().equals(IPV4_STATUS_ENABLED_LAN_MESSAGE);
boolean isIpv4Disabled = this.ip4Tab.getStatus().equals(IPV4_STATUS_DISABLED_MESSAGE);
boolean isIpv6Disabled = this.ip6Tab.getStatus().equals(IPV6_STATUS_DISABLED_MESSAGE);
boolean isWirelessAP = this.wirelessTab.getWirelessMode() != null
&& this.wirelessTab.getWirelessMode().name().equals(WIFI_ACCESS_POINT);
boolean isDhcp = this.ip4Tab.isDhcp();
Expand All @@ -296,14 +296,14 @@ private void arrangeOptionalTabs() {
InterfaceConfigWrapper wrapper = new InterfaceConfigWrapper(this.netIfConfig);

if (wrapper.isWireless()) {
showWirelessTabs(isIpv4Disabled || isUnmanagedSelected());
showWirelessTabs(isIPInterfacesDisabled(isIpv4Disabled, isIpv6Disabled) || isUnmanagedSelected());
if (!isWirelessAP) {
includeDhcpNat = false;
}
} else if (wrapper.isModem()) {
includeDhcpNat = false;
this.modemGpsTabAnchorItem.setEnabled(wrapper.isGpsSupported() && !isUnmanagedSelected());
showModemTabs(isIpv4Disabled || isUnmanagedSelected());
showModemTabs(isIPInterfacesDisabled(isIpv4Disabled, isIpv6Disabled) || isUnmanagedSelected());
} else {
showEthernetTabs();
if (wrapper.isLoopback()) {
Expand All @@ -316,11 +316,15 @@ private void arrangeOptionalTabs() {
this.dhcp4NatTabAnchorItem.setEnabled(includeDhcpNat);
this.ip6TabAnchorItem.setEnabled(!isUnmanagedSelected());

if (isIpv4Disabled || isUnmanagedSelected()) {
if (isIPInterfacesDisabled(isIpv4Disabled, isIpv6Disabled) || isUnmanagedSelected()) {
removeOptionalTabs();
}
}

private boolean isIPInterfacesDisabled(boolean isIpv4Disabled, boolean isIpv6Disabled) {
return isIpv4Disabled && isIpv6Disabled;
}

private void showWirelessTabs(boolean interfaceNotEnabled) {
removeTab(this.modemTabAnchorItem);
removeTab(this.modemGpsTabAnchorItem);
Expand Down Expand Up @@ -412,11 +416,7 @@ private void refreshAllVisibleTabs() {
*/

public boolean isDirty() {
if (this.visibleTabs.contains(this.ip4TabAnchorItem) && this.ip4Tab.isDirty()) {
return true;
}

if (this.visibleTabs.contains(this.ip6TabAnchorItem) && this.ip6Tab.isDirty()) {
if ((this.visibleTabs.contains(this.ip4TabAnchorItem) && this.ip4Tab.isDirty()) || (this.visibleTabs.contains(this.ip6TabAnchorItem) && this.ip6Tab.isDirty())) {
return true;
}

Expand Down Expand Up @@ -540,11 +540,7 @@ public boolean isValid() {
return false;
}

if (this.visibleTabs.contains(this.wirelessTabAnchorItem) && !this.wirelessTab.isValid()) {
return false;
}

if (this.visibleTabs.contains(this.modemTabAnchorItem) && !this.modemTab.isValid()) {
if ((this.visibleTabs.contains(this.wirelessTabAnchorItem) && !this.wirelessTab.isValid()) || (this.visibleTabs.contains(this.modemTabAnchorItem) && !this.modemTab.isValid())) {
return false;
}

Expand Down Expand Up @@ -604,18 +600,18 @@ private void setSelected(AnchorListItem item) {

class InterfaceConfigWrapper {

private GwtNetInterfaceConfig config;
private final GwtNetInterfaceConfig config;

public InterfaceConfigWrapper(GwtNetInterfaceConfig config) {
this.config = config;
}

public boolean isWireless() {
return (this.config instanceof GwtWifiNetInterfaceConfig);
return this.config instanceof GwtWifiNetInterfaceConfig;
}

public boolean isModem() {
return (this.config instanceof GwtModemInterfaceConfig);
return this.config instanceof GwtModemInterfaceConfig;
}

public boolean isGpsSupported() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2023 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -190,6 +190,10 @@ public TabIp6Ui(GwtSession currentSession, NetworkTabsUi netTabs) {
initListBoxes();
initTextBoxes();
}

public String getStatus() {
return this.status.getSelectedItemText();
}

private void initLabels() {
this.labelStatus.setText(MSGS.netIPv6Status());
Expand Down Expand Up @@ -225,6 +229,7 @@ private void initListBoxes() {
}

private void initStatusField() {
this.status.clear();
this.status.addItem(MessageUtils.get(STATUS_DISABLED), STATUS_DISABLED);
this.status.addItem(MessageUtils.get(STATUS_LAN), STATUS_LAN);
this.status.addItem(MessageUtils.get(STATUS_WAN), STATUS_WAN);
Expand Down Expand Up @@ -355,7 +360,7 @@ private void initPriorityField() {
}
});
}

private void initMtuField() {
this.mtu.addMouseOverHandler(event -> {
if (this.mtu.isEnabled()) {
Expand Down Expand Up @@ -685,7 +690,7 @@ private void updateConfigWithSelectedValues(GwtNetInterfaceConfig updatedNetIf)
}

updatedNetIf.setIpv6Privacy(this.privacy.getSelectedValue());

if (this.mtu.getValue() != null) {
updatedNetIf.setIpv6Mtu(this.mtu.getValue());
}
Expand Down Expand Up @@ -802,7 +807,7 @@ private void fillFormWithCachedConfig() {
break;
}
}

this.mtu.setValue(this.selectedNetIfConfig.get().getIpv6Mtu());

this.tabs.updateTabs();
Expand All @@ -814,4 +819,4 @@ public void clear() {
// Not needed
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ interface TabWirelessUiUiBinder extends UiBinder<Widget, TabWirelessUi> {
private static final int MAX_SSID_LENGTH = 32;

private final GwtSession session;
private final TabIp4Ui tcpTab;
private final TabIp4Ui tcp4Tab;
private final TabIp6Ui tcp6Tab;
private final NetworkTabsUi netTabs;
private final Tab8021xUi wireless8021x;
private final ListDataProvider<GwtWifiHotspotEntry> ssidDataProvider = new ListDataProvider<>();
Expand All @@ -156,7 +157,8 @@ interface TabWirelessUiUiBinder extends UiBinder<Widget, TabWirelessUi> {
private boolean ssidInit;
private boolean isNet2;
private GwtWifiNetInterfaceConfig selectedNetIfConfig;
private String tcpStatus;
private String tcp4Status;
private String tcp6Status;

GwtWifiConfig activeConfig;
GwtWifiChannelModel previousSelection;
Expand Down Expand Up @@ -344,12 +346,13 @@ interface TabWirelessUiUiBinder extends UiBinder<Widget, TabWirelessUi> {
@UiField
Text unavailableChannelErrorText;

public TabWirelessUi(GwtSession currentSession, TabIp4Ui tcp, Tab8021xUi wireless8021x,
public TabWirelessUi(GwtSession currentSession, TabIp4Ui tcp4, TabIp6Ui tcp6, Tab8021xUi wireless8021x,
AnchorListItem wireless8021xTabAnchorItem, NetworkTabsUi tabs, final boolean isNet2) {
this.ssidInit = false;
initWidget(uiBinder.createAndBindUi(this));
this.session = currentSession;
this.tcpTab = tcp;
this.tcp4Tab = tcp4;
this.tcp6Tab = tcp6;
this.netTabs = tabs;
this.wireless8021x = wireless8021x;
this.wireless8021xTabAnchorItem = wireless8021xTabAnchorItem;
Expand All @@ -362,28 +365,43 @@ public TabWirelessUi(GwtSession currentSession, TabIp4Ui tcp, Tab8021xUi wireles
initRegDomErrorModal();
setPasswordValidation();

this.tcpTab.status.addChangeHandler(event -> {
if (TabWirelessUi.this.selectedNetIfConfig != null) {
// set the default values for wireless mode if tcp/ip status was changed
String tcpIpStatus = TabWirelessUi.this.tcpTab.getStatus();
if (!tcpIpStatus.equals(TabWirelessUi.this.tcpStatus)) {
if (tcpIpStatus.equals(MessageUtils.get(GwtNetIfStatus.netIPv4StatusEnabledWAN.name()))) {
TabWirelessUi.this.activeConfig = TabWirelessUi.this.selectedNetIfConfig.getStationWifiConfig();
} else {
TabWirelessUi.this.activeConfig = TabWirelessUi.this.selectedNetIfConfig.getActiveWifiConfig();
}
this.tcp4Tab.status.addChangeHandler(event -> {
evalActiveConfig();

TabWirelessUi.this.tcpStatus = tcpIpStatus;
TabWirelessUi.this.netTabs.updateTabs();
}
}
update();
});

this.tcp6Tab.status.addChangeHandler(event -> {
evalActiveConfig();

update();
});

logger.info("Constructor done.");
}

private void evalActiveConfig() {
if (TabWirelessUi.this.selectedNetIfConfig != null) {
// set the default values for wireless mode if tcp/ip status was changed
String tcpIp4Status = TabWirelessUi.this.tcp4Tab.getStatus();
String tcpIp6Status = TabWirelessUi.this.tcp6Tab.getStatus();
boolean isStatusChanged = !tcpIp4Status.equals(TabWirelessUi.this.tcp4Status)
|| !tcpIp6Status.equals(TabWirelessUi.this.tcp6Status);

if (isStatusChanged) {
if (tcpIp4Status.equals(MessageUtils.get(GwtNetIfStatus.netIPv4StatusEnabledWAN.name())) || tcpIp6Status.equals(MessageUtils.get(GwtNetIfStatus.netIPv4StatusEnabledWAN.name()))) {
TabWirelessUi.this.activeConfig = TabWirelessUi.this.selectedNetIfConfig.getStationWifiConfig();
} else {
TabWirelessUi.this.activeConfig = TabWirelessUi.this.selectedNetIfConfig.getActiveWifiConfig();
}

TabWirelessUi.this.tcp4Status = tcpIp4Status;
TabWirelessUi.this.tcp6Status = tcpIp6Status;
TabWirelessUi.this.netTabs.updateTabs();
}
}
}

@UiHandler(value = { "wireless", "ssid", "radio", "security", "password", "verify", "pairwise", "group", "bgscan",
"longI", "shortI", "radio1", "radio2", "radio3", "radio4", "rssi", "channelList", "countryCode" })
public void onChange(ChangeEvent e) {
Expand Down Expand Up @@ -436,8 +454,9 @@ public boolean isValid() {
@Override
public void setNetInterface(GwtNetInterfaceConfig config) {
setDirty(true);
if (this.tcpStatus == null || this.selectedNetIfConfig != config) {
this.tcpStatus = this.tcpTab.getStatus();
if (this.tcp4Status == null || this.tcp6Status == null || this.selectedNetIfConfig != config) {
this.tcp4Status = this.tcp4Tab.getStatus();
this.tcp6Status = this.tcp6Tab.getStatus();
}
if (config instanceof GwtWifiNetInterfaceConfig) {
this.selectedNetIfConfig = (GwtWifiNetInterfaceConfig) config;
Expand Down Expand Up @@ -523,6 +542,7 @@ private void changeRadioModeToBand(boolean isNet2) {

private void update() {
setValues();
this.netTabs.updateTabs();
refreshForm();
setPasswordValidation();
}
Expand Down Expand Up @@ -644,10 +664,11 @@ private void setBandFromRadioMode(String radioModeValue) {
private void refreshForm() {
logger.info("Start refreshForm");

String tcpipStatus = this.tcpTab.getStatus();
String tcpip4Status = this.tcp4Tab.getStatus();
String tcpip6Status = this.tcp6Tab.getStatus();

// Tcp/IP disabled
if (tcpipStatus.equals(GwtNetIfStatus.netIPv4StatusDisabled.name())) {
if (tcpip4Status.equals(GwtNetIfStatus.netIPv4StatusDisabled.name()) && tcpip6Status.equals(GwtNetIfStatus.netIPv4StatusDisabled.name())) {
setForm(false);
} else {
setForm(true);
Expand All @@ -656,7 +677,7 @@ private void refreshForm() {

add8021xFromSecurityDropdown();

if (tcpipStatus.equals(IPV4_STATUS_WAN_MESSAGE)) {
if (tcpip4Status.equals(IPV4_STATUS_WAN_MESSAGE) || tcpip6Status.equals(IPV4_STATUS_WAN_MESSAGE)) {
this.wireless.setEnabled(false);
}
this.groupVerify.setVisible(false);
Expand All @@ -667,7 +688,7 @@ private void refreshForm() {
remove8021xFromSecurityDropdown();

// disable access point when TCP/IP is set to WAN
if (tcpipStatus.equals(IPV4_STATUS_WAN_MESSAGE)) {
if (tcpip4Status.equals(IPV4_STATUS_WAN_MESSAGE) || tcpip6Status.equals(IPV4_STATUS_WAN_MESSAGE)) {
setForm(false);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2020 Eurotech and/or its affiliates and others
* Copyright (c) 2011, 2023 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -21,7 +21,10 @@ public enum GwtNetIfStatus implements Serializable, IsSerializable {
netIPv4StatusUnmanaged("Unmanaged"),
netIPv4StatusL2Only("L2Only"),
netIPv4StatusEnabledLAN("LAN"),
netIPv4StatusEnabledWAN("WAN");
netIPv4StatusEnabledWAN("WAN"),
netIPv6StatusDisabled("Disabled"),
netIPv6StatusEnabledLAN("LAN"),
netIPv6StatusEnabledWAN("WAN");

private String status;

Expand Down

0 comments on commit 8dc9032

Please sign in to comment.