use of org.eclipse.kura.web.shared.model.GwtWifiRadioMode in project kura by eclipse.
the class GwtNetworkServiceImpl method privateFindNetInterfaceConfigurations.
@SuppressWarnings({ "unchecked", "rawtypes" })
private List<GwtNetInterfaceConfig> privateFindNetInterfaceConfigurations() throws GwtKuraException {
s_logger.debug("Starting");
List<GwtNetInterfaceConfig> gwtNetConfigs = new ArrayList<GwtNetInterfaceConfig>();
NetworkAdminService nas = null;
try {
nas = ServiceLocator.getInstance().getService(NetworkAdminService.class);
} catch (Throwable t) {
s_logger.warn("Exception", t);
return gwtNetConfigs;
}
ModemManagerService modemManagerService = null;
try {
modemManagerService = ServiceLocator.getInstance().getService(ModemManagerService.class);
} catch (Throwable t) {
s_logger.warn("{ModemManagerService} Exception", t);
}
WifiClientMonitorService wifiClientMonitorService = null;
try {
wifiClientMonitorService = ServiceLocator.getInstance().getService(WifiClientMonitorService.class);
} catch (Throwable t) {
s_logger.warn("{WifiClientMonitorService} Exception", t);
}
try {
GwtNetInterfaceConfig gwtNetConfig = null;
for (NetInterfaceConfig<? extends NetInterfaceAddressConfig> netIfConfig : nas.getNetworkInterfaceConfigs()) {
s_logger.debug("Getting config for {} with type {}", netIfConfig.getName(), netIfConfig.getType());
s_logger.debug("Interface State: {}", netIfConfig.getState());
if (netIfConfig.getType() == NetInterfaceType.WIFI) {
gwtNetConfig = new GwtWifiNetInterfaceConfig();
} else if (netIfConfig.getType() == NetInterfaceType.MODEM) {
gwtNetConfig = new GwtModemInterfaceConfig();
((GwtModemInterfaceConfig) gwtNetConfig).setModemId(((ModemInterface) netIfConfig).getModemIdentifier());
((GwtModemInterfaceConfig) gwtNetConfig).setManufacturer(((ModemInterface) netIfConfig).getManufacturer());
((GwtModemInterfaceConfig) gwtNetConfig).setModel(((ModemInterface) netIfConfig).getModel());
List<String> technologyList = new ArrayList<String>();
List<ModemTechnologyType> technologyTypes = ((ModemInterface) netIfConfig).getTechnologyTypes();
if (technologyTypes != null) {
for (ModemTechnologyType techType : technologyTypes) {
technologyList.add(techType.name());
}
}
((GwtModemInterfaceConfig) gwtNetConfig).setNetworkTechnology(technologyList);
} else {
gwtNetConfig = new GwtNetInterfaceConfig();
gwtNetConfig.setHwRssi("N/A");
}
gwtNetConfig.setName(netIfConfig.getName());
gwtNetConfig.setHwName(netIfConfig.getName());
if (netIfConfig.getType() != null) {
gwtNetConfig.setHwType(netIfConfig.getType().name());
}
if (netIfConfig.getState() != null) {
gwtNetConfig.setHwState(netIfConfig.getState().name());
}
s_logger.debug("MAC: {}", NetUtil.hardwareAddressToString(netIfConfig.getHardwareAddress()));
gwtNetConfig.setHwAddress(NetUtil.hardwareAddressToString(netIfConfig.getHardwareAddress()));
gwtNetConfig.setHwDriver(netIfConfig.getDriver());
gwtNetConfig.setHwDriverVersion(netIfConfig.getDriverVersion());
gwtNetConfig.setHwFirmware(netIfConfig.getFirmwareVersion());
gwtNetConfig.setHwMTU(netIfConfig.getMTU());
if (netIfConfig.getUsbDevice() != null) {
gwtNetConfig.setHwUsbDevice(netIfConfig.getUsbDevice().getUsbDevicePath());
} else {
gwtNetConfig.setHwUsbDevice("N/A");
}
List<? extends NetInterfaceAddressConfig> addressConfigs = netIfConfig.getNetInterfaceAddresses();
if (addressConfigs != null && !addressConfigs.isEmpty()) {
for (NetInterfaceAddressConfig addressConfig : addressConfigs) {
// current status - not configuration!
if (addressConfig.getAddress() != null) {
s_logger.debug("current address: {}", addressConfig.getAddress().getHostAddress());
}
if (addressConfig.getNetworkPrefixLength() >= 0 && addressConfig.getNetworkPrefixLength() <= 32) {
s_logger.debug("current prefix length: {}", addressConfig.getNetworkPrefixLength());
}
if (addressConfig.getNetmask() != null) {
s_logger.debug("current netmask: {}", addressConfig.getNetmask().getHostAddress());
}
List<NetConfig> netConfigs = addressConfig.getConfigs();
if (netConfigs != null && !netConfigs.isEmpty()) {
boolean isNatEnabled = false;
boolean isDhcpServerEnabled = false;
for (NetConfig netConfig : netConfigs) {
if (netConfig instanceof NetConfigIP4) {
s_logger.debug("Setting up NetConfigIP4 with status {}", ((NetConfigIP4) netConfig).getStatus().toString());
// we are enabled - for LAN or WAN?
if (((NetConfigIP4) netConfig).getStatus() == NetInterfaceStatus.netIPv4StatusEnabledLAN) {
gwtNetConfig.setStatus(GwtNetIfStatus.netIPv4StatusEnabledLAN.name());
} else if (((NetConfigIP4) netConfig).getStatus() == NetInterfaceStatus.netIPv4StatusEnabledWAN) {
gwtNetConfig.setStatus(GwtNetIfStatus.netIPv4StatusEnabledWAN.name());
} else {
gwtNetConfig.setStatus(GwtNetIfStatus.netIPv4StatusDisabled.name());
}
if (((NetConfigIP4) netConfig).isDhcp()) {
gwtNetConfig.setConfigMode(GwtNetIfConfigMode.netIPv4ConfigModeDHCP.name());
// since DHCP - populate current data
if (addressConfig.getAddress() != null) {
gwtNetConfig.setIpAddress(addressConfig.getAddress().getHostAddress());
} else {
gwtNetConfig.setIpAddress("");
}
if (addressConfig.getNetworkPrefixLength() >= 0 && addressConfig.getNetworkPrefixLength() <= 32) {
gwtNetConfig.setSubnetMask(NetworkUtil.getNetmaskStringForm(addressConfig.getNetworkPrefixLength()));
} else {
if (addressConfig.getNetmask() != null) {
gwtNetConfig.setSubnetMask(addressConfig.getNetmask().getHostAddress());
} else {
gwtNetConfig.setSubnetMask("");
}
}
if (addressConfig.getGateway() != null) {
gwtNetConfig.setGateway(addressConfig.getGateway().getHostAddress());
} else {
gwtNetConfig.setGateway("");
}
// DHCP supplied DNS servers
StringBuffer sb = new StringBuffer();
List<? extends IPAddress> dnsServers = addressConfig.getDnsServers();
if (dnsServers != null && !dnsServers.isEmpty()) {
String sep = "";
for (IPAddress dnsServer : dnsServers) {
sb.append(sep).append(dnsServer.getHostAddress());
sep = "\n";
}
s_logger.debug("DNS Servers: {}", sb);
gwtNetConfig.setReadOnlyDnsServers(sb.toString());
} else {
s_logger.debug("DNS Servers: [empty String]");
gwtNetConfig.setReadOnlyDnsServers("");
}
} else {
gwtNetConfig.setConfigMode(GwtNetIfConfigMode.netIPv4ConfigModeManual.name());
// TODO - should we throw an error if current state doesn't match configuration?
if (((NetConfigIP4) netConfig).getAddress() != null) {
gwtNetConfig.setIpAddress(((NetConfigIP4) netConfig).getAddress().getHostAddress());
} else {
gwtNetConfig.setIpAddress("");
}
if (((NetConfigIP4) netConfig).getSubnetMask() != null) {
gwtNetConfig.setSubnetMask(((NetConfigIP4) netConfig).getSubnetMask().getHostAddress());
} else {
gwtNetConfig.setSubnetMask("");
}
if (((NetConfigIP4) netConfig).getGateway() != null) {
s_logger.debug("Gateway for {} is: {}", netIfConfig.getName(), ((NetConfigIP4) netConfig).getGateway().getHostAddress());
gwtNetConfig.setGateway(((NetConfigIP4) netConfig).getGateway().getHostAddress());
} else {
gwtNetConfig.setGateway("");
}
}
// Custom DNS servers
StringBuffer sb = new StringBuffer();
List<IP4Address> dnsServers = ((NetConfigIP4) netConfig).getDnsServers();
if (dnsServers != null && !dnsServers.isEmpty()) {
for (IP4Address dnsServer : dnsServers) {
if (!dnsServer.getHostAddress().equals("127.0.0.1")) {
sb.append(' ').append(dnsServer.getHostAddress());
}
}
s_logger.debug("DNS Servers: {}", sb);
gwtNetConfig.setDnsServers(sb.toString().trim());
} else {
s_logger.debug("DNS Servers: [empty String]");
gwtNetConfig.setDnsServers("");
}
// Search domains
sb = new StringBuffer();
List<IP4Address> winsServers = ((NetConfigIP4) netConfig).getWinsServers();
if (winsServers != null && !winsServers.isEmpty()) {
for (IP4Address winServer : winsServers) {
sb.append(winServer.getHostAddress());
sb.append("\n");
}
s_logger.debug("Search Domains: {}", sb);
gwtNetConfig.setSearchDomains(sb.toString());
} else {
s_logger.debug("Search Domains: [empty String]");
gwtNetConfig.setSearchDomains("");
}
}
// config
if (netConfig instanceof WifiConfig) {
s_logger.debug("Setting up WifiConfigIP4");
WifiConfig wifiConfig = (WifiConfig) netConfig;
GwtWifiConfig gwtWifiConfig = new GwtWifiConfig();
// mode
if (wifiConfig.getMode() == WifiMode.MASTER) {
gwtWifiConfig.setWirelessMode(GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.name());
// set as the access point config for this interface
((GwtWifiNetInterfaceConfig) gwtNetConfig).setAccessPointWifiConfig(gwtWifiConfig);
} else if (wifiConfig.getMode() == WifiMode.INFRA) {
gwtWifiConfig.setWirelessMode(GwtWifiWirelessMode.netWifiWirelessModeStation.name());
// set as the station config for this interface
((GwtWifiNetInterfaceConfig) gwtNetConfig).setStationWifiConfig(gwtWifiConfig);
} else if (wifiConfig.getMode() == WifiMode.ADHOC) {
gwtWifiConfig.setWirelessMode(GwtWifiWirelessMode.netWifiWirelessModeAdHoc.name());
// set as the adhoc config for this interface
((GwtWifiNetInterfaceConfig) gwtNetConfig).setAdhocWifiConfig(gwtWifiConfig);
}
// ssid
gwtWifiConfig.setWirelessSsid(wifiConfig.getSSID());
// driver
gwtWifiConfig.setDriver(wifiConfig.getDriver());
// security
if (wifiConfig.getSecurity() == WifiSecurity.SECURITY_WPA) {
gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA.name());
} else if (wifiConfig.getSecurity() == WifiSecurity.SECURITY_WPA2) {
gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA2.name());
} else if (wifiConfig.getSecurity() == WifiSecurity.SECURITY_WPA_WPA2) {
gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA_WPA2.name());
} else if (wifiConfig.getSecurity() == WifiSecurity.SECURITY_WEP) {
gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWEP.name());
} else {
gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityNONE.name());
}
if (wifiConfig.getPairwiseCiphers() == WifiCiphers.CCMP_TKIP) {
gwtWifiConfig.setPairwiseCiphers(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name());
} else if (wifiConfig.getPairwiseCiphers() == WifiCiphers.TKIP) {
gwtWifiConfig.setPairwiseCiphers(GwtWifiCiphers.netWifiCiphers_TKIP.name());
} else if (wifiConfig.getPairwiseCiphers() == WifiCiphers.CCMP) {
gwtWifiConfig.setPairwiseCiphers(GwtWifiCiphers.netWifiCiphers_CCMP.name());
}
if (wifiConfig.getGroupCiphers() == WifiCiphers.CCMP_TKIP) {
gwtWifiConfig.setGroupCiphers(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name());
} else if (wifiConfig.getGroupCiphers() == WifiCiphers.TKIP) {
gwtWifiConfig.setGroupCiphers(GwtWifiCiphers.netWifiCiphers_TKIP.name());
} else if (wifiConfig.getGroupCiphers() == WifiCiphers.CCMP) {
gwtWifiConfig.setGroupCiphers(GwtWifiCiphers.netWifiCiphers_CCMP.name());
}
// bgscan
WifiBgscan wifiBgscan = wifiConfig.getBgscan();
if (wifiBgscan != null) {
if (wifiBgscan.getModule() == WifiBgscanModule.NONE) {
gwtWifiConfig.setBgscanModule(GwtWifiBgscanModule.netWifiBgscanMode_NONE.name());
} else if (wifiBgscan.getModule() == WifiBgscanModule.SIMPLE) {
gwtWifiConfig.setBgscanModule(GwtWifiBgscanModule.netWifiBgscanMode_SIMPLE.name());
} else if (wifiBgscan.getModule() == WifiBgscanModule.LEARN) {
gwtWifiConfig.setBgscanModule(GwtWifiBgscanModule.netWifiBgscanMode_LEARN.name());
}
gwtWifiConfig.setBgscanRssiThreshold(wifiBgscan.getRssiThreshold());
gwtWifiConfig.setBgscanShortInterval(wifiBgscan.getShortInterval());
gwtWifiConfig.setBgscanLongInterval(wifiBgscan.getLongInterval());
}
// ping access point?
gwtWifiConfig.setPingAccessPoint(wifiConfig.pingAccessPoint());
// ignore SSID?
gwtWifiConfig.setIgnoreSSID(wifiConfig.ignoreSSID());
// passkey
Password psswd = wifiConfig.getPasskey();
if (psswd != null) {
String password = new String(psswd.getPassword());
gwtWifiConfig.setPassword(password);
}
// channel
int[] channels = wifiConfig.getChannels();
if (channels != null) {
ArrayList<Integer> alChannels = new ArrayList<Integer>();
for (int channel : channels) {
alChannels.add(new Integer(channel));
}
gwtWifiConfig.setChannels(alChannels);
}
// radio mode
GwtWifiRadioMode gwtWifiRadioMode = null;
if (wifiConfig.getRadioMode() != null) {
switch(wifiConfig.getRadioMode()) {
case RADIO_MODE_80211a:
gwtWifiRadioMode = GwtWifiRadioMode.netWifiRadioModeA;
break;
case RADIO_MODE_80211b:
gwtWifiRadioMode = GwtWifiRadioMode.netWifiRadioModeB;
break;
case RADIO_MODE_80211g:
gwtWifiRadioMode = GwtWifiRadioMode.netWifiRadioModeBG;
break;
case RADIO_MODE_80211nHT20:
case RADIO_MODE_80211nHT40above:
case RADIO_MODE_80211nHT40below:
gwtWifiRadioMode = GwtWifiRadioMode.netWifiRadioModeBGN;
break;
default:
break;
}
}
if (gwtWifiRadioMode != null) {
gwtWifiConfig.setRadioMode(gwtWifiRadioMode.name());
}
// set the currently active mode based on the address config
WifiMode activeWirelessMode = ((WifiInterfaceAddressConfig) addressConfig).getMode();
if (activeWirelessMode == WifiMode.MASTER) {
((GwtWifiNetInterfaceConfig) gwtNetConfig).setWirelessMode(GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.name());
gwtNetConfig.setHwRssi("N/A");
} else if (activeWirelessMode == WifiMode.INFRA) {
((GwtWifiNetInterfaceConfig) gwtNetConfig).setWirelessMode(GwtWifiWirelessMode.netWifiWirelessModeStation.name());
if (wifiClientMonitorService != null) {
if (wifiConfig.getMode().equals(WifiMode.INFRA)) {
if (gwtNetConfig.getStatus().equals(GwtNetIfStatus.netIPv4StatusDisabled.name())) {
gwtNetConfig.setHwRssi("N/A");
} else {
try {
int rssi = wifiClientMonitorService.getSignalLevel(netIfConfig.getName(), wifiConfig.getSSID());
s_logger.debug("Setting Received Signal Strength to {}", rssi);
gwtNetConfig.setHwRssi(Integer.toString(rssi));
} catch (KuraException e) {
s_logger.warn("Failed", e);
}
}
}
}
} else if (activeWirelessMode == WifiMode.ADHOC) {
((GwtWifiNetInterfaceConfig) gwtNetConfig).setWirelessMode(GwtWifiWirelessMode.netWifiWirelessModeAdHoc.name());
gwtNetConfig.setHwRssi("N/A");
} else {
((GwtWifiNetInterfaceConfig) gwtNetConfig).setWirelessMode(GwtWifiWirelessMode.netWifiWirelessModeDisabled.name());
gwtNetConfig.setHwRssi("N/A");
}
}
if (netConfig instanceof ModemConfig) {
s_logger.debug("Setting up ModemConfig");
ModemConfig modemConfig = (ModemConfig) netConfig;
GwtModemInterfaceConfig gwtModemConfig = (GwtModemInterfaceConfig) gwtNetConfig;
if (modemManagerService != null) {
UsbDevice usbDevice = netIfConfig.getUsbDevice();
String modemServiceId = null;
if (usbDevice != null) {
modemServiceId = netIfConfig.getUsbDevice().getUsbPort();
} else {
Collection<CellularModem> modemServices = modemManagerService.getAllModemServices();
for (CellularModem modemService : modemServices) {
ModemDevice modemDevice = modemService.getModemDevice();
if (modemDevice instanceof SerialModemDevice) {
modemServiceId = modemDevice.getProductName();
break;
}
}
}
if (modemServiceId != null) {
CellularModem cellModemService = modemManagerService.getModemService(modemServiceId);
if (cellModemService != null) {
try {
String imei = cellModemService.getSerialNumber();
s_logger.debug("Setting IMEI/MEID to {}", imei);
gwtModemConfig.setHwSerial(imei);
} catch (KuraException e) {
s_logger.warn("Failed to get IMEI from modem", e);
}
try {
int rssi = cellModemService.getSignalStrength();
s_logger.debug("Setting Received Signal Strength to {}", rssi);
gwtModemConfig.setHwRssi(Integer.toString(rssi));
} catch (KuraException e) {
s_logger.warn("Failed to get Received Signal Strength from modem", e);
}
try {
String sModel = cellModemService.getModel();
((GwtModemInterfaceConfig) gwtNetConfig).setModel(sModel);
} catch (KuraException e) {
s_logger.warn("Failed to get model information from modem", e);
}
try {
boolean gpsSupported = cellModemService.isGpsSupported();
s_logger.debug("Setting GPS supported to {}", gpsSupported);
((GwtModemInterfaceConfig) gwtNetConfig).setGpsSupported(gpsSupported);
} catch (KuraException e) {
s_logger.warn("Failed to get GPS supported from modem", e);
}
}
}
}
// set as DHCP - populate current address
gwtModemConfig.setConfigMode(GwtNetIfConfigMode.netIPv4ConfigModeDHCP.name());
if (addressConfig.getAddress() != null) {
gwtModemConfig.setIpAddress(addressConfig.getAddress().getHostAddress());
}
if (addressConfig.getNetmask() != null) {
gwtModemConfig.setSubnetMask(addressConfig.getNetmask().getHostAddress());
}
gwtModemConfig.setDialString(modemConfig.getDialString());
AuthType authType = modemConfig.getAuthType();
if (authType == AuthType.AUTO) {
gwtModemConfig.setAuthType(GwtModemAuthType.netModemAuthAUTO);
} else if (authType == AuthType.CHAP) {
gwtModemConfig.setAuthType(GwtModemAuthType.netModemAuthCHAP);
} else if (authType == AuthType.PAP) {
gwtModemConfig.setAuthType(GwtModemAuthType.netModemAuthPAP);
} else {
gwtModemConfig.setAuthType(GwtModemAuthType.netModemAuthNONE);
}
gwtModemConfig.setUsername(modemConfig.getUsername());
gwtModemConfig.setPassword(modemConfig.getPassword());
gwtModemConfig.setPppNum(modemConfig.getPppNumber());
gwtModemConfig.setResetTimeout(modemConfig.getResetTimeout());
gwtModemConfig.setPersist(modemConfig.isPersist());
gwtModemConfig.setMaxFail(modemConfig.getMaxFail());
gwtModemConfig.setIdle(modemConfig.getIdle());
gwtModemConfig.setActiveFilter(modemConfig.getActiveFilter());
gwtModemConfig.setLcpEchoInterval(modemConfig.getLcpEchoInterval());
gwtModemConfig.setLcpEchoFailure(modemConfig.getLcpEchoFailure());
gwtModemConfig.setGpsEnabled(modemConfig.isGpsEnabled());
gwtModemConfig.setProfileID(modemConfig.getProfileID());
PdpType pdpType = modemConfig.getPdpType();
if (pdpType == PdpType.IP) {
gwtModemConfig.setPdpType(GwtModemPdpType.netModemPdpIP);
} else if (pdpType == PdpType.PPP) {
gwtModemConfig.setPdpType(GwtModemPdpType.netModemPdpPPP);
} else if (pdpType == PdpType.IPv6) {
gwtModemConfig.setPdpType(GwtModemPdpType.netModemPdpIPv6);
} else {
gwtModemConfig.setPdpType(GwtModemPdpType.netModemPdpUnknown);
}
gwtModemConfig.setApn(modemConfig.getApn());
gwtModemConfig.setDataCompression(modemConfig.getDataCompression());
gwtModemConfig.setHeaderCompression(modemConfig.getHeaderCompression());
ModemConnectionStatus connectionStatus = ((ModemInterfaceAddressConfig) addressConfig).getConnectionStatus();
if (connectionStatus == ModemConnectionStatus.DISCONNECTED) {
gwtModemConfig.setHwState(NetInterfaceState.DISCONNECTED.name());
} else if (connectionStatus == ModemConnectionStatus.CONNECTING) {
gwtModemConfig.setHwState(NetInterfaceState.IP_CONFIG.name());
} else if (connectionStatus == ModemConnectionStatus.CONNECTED) {
gwtModemConfig.setHwState(NetInterfaceState.ACTIVATED.name());
} else {
gwtModemConfig.setHwState(NetInterfaceState.UNKNOWN.name());
}
gwtModemConfig.setConnectionType(((ModemInterfaceAddressConfig) addressConfig).getConnectionType().name());
}
if (netConfig instanceof DhcpServerConfigIP4) {
s_logger.debug("Setting up DhcpServerConfigIP4: {} to {}", ((DhcpServerConfigIP4) netConfig).getRangeStart().getHostAddress(), ((DhcpServerConfigIP4) netConfig).getRangeEnd().getHostAddress());
s_logger.debug("Setting up DhcpServerConfigIP4: {}", ((DhcpServerConfigIP4) netConfig).toString());
isDhcpServerEnabled = ((DhcpServerConfigIP4) netConfig).isEnabled();
gwtNetConfig.setRouterDhcpBeginAddress(((DhcpServerConfigIP4) netConfig).getRangeStart().getHostAddress());
gwtNetConfig.setRouterDhcpEndAddress(((DhcpServerConfigIP4) netConfig).getRangeEnd().getHostAddress());
gwtNetConfig.setRouterDhcpSubnetMask(((DhcpServerConfigIP4) netConfig).getSubnetMask().getHostAddress());
gwtNetConfig.setRouterDhcpDefaultLease(((DhcpServerConfigIP4) netConfig).getDefaultLeaseTime());
gwtNetConfig.setRouterDhcpMaxLease(((DhcpServerConfigIP4) netConfig).getMaximumLeaseTime());
gwtNetConfig.setRouterDnsPass(((DhcpServerConfigIP4) netConfig).isPassDns());
}
if (netConfig instanceof FirewallAutoNatConfig) {
s_logger.debug("Setting up FirewallAutoNatConfig");
isNatEnabled = true;
}
// TODO - only dealing with IPv4 right now
}
// set up the DHCP and NAT config
if (isDhcpServerEnabled && isNatEnabled) {
s_logger.debug("setting router mode to DHCP and NAT");
gwtNetConfig.setRouterMode(GwtNetRouterMode.netRouterDchpNat.name());
} else if (isDhcpServerEnabled && !isNatEnabled) {
s_logger.debug("setting router mode to DHCP only");
gwtNetConfig.setRouterMode(GwtNetRouterMode.netRouterDchp.name());
} else if (!isDhcpServerEnabled && isNatEnabled) {
s_logger.debug("setting router mode to NAT only");
gwtNetConfig.setRouterMode(GwtNetRouterMode.netRouterNat.name());
} else {
s_logger.debug("setting router mode to disabled");
gwtNetConfig.setRouterMode(GwtNetRouterMode.netRouterOff.name());
}
}
}
}
gwtNetConfigs.add(gwtNetConfig);
}
} catch (Throwable t) {
KuraExceptionHandler.handle(t);
}
s_logger.debug("Returning");
return gwtNetConfigs;
}
use of org.eclipse.kura.web.shared.model.GwtWifiRadioMode in project kura by eclipse.
the class TabWirelessUi method initForm.
private void initForm() {
// Wireless Mode
this.labelWireless.setText(MSGS.netWifiWirelessMode());
this.wireless.addItem(MessageUtils.get("netWifiWirelessModeStation"));
this.wireless.addItem(MessageUtils.get("netWifiWirelessModeAccessPoint"));
this.wireless.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.wireless.getSelectedItemText().equals(MessageUtils.get("netWifiWirelessModeStation"))) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipWirelessModeStation()));
} else {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipWirelessModeAccessPoint()));
}
}
});
this.wireless.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
this.wireless.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
// String accessPointName= WIFI_MODE_ACCESS_POINT_MESSAGE;
// String stationModeName= WIFI_MODE_STATION_MESSAGE;
// if (tcpTab.getStatus().equals(IPV4_STATUS_WAN_MESSAGE) &&
// wireless.getSelectedItemText().equals(accessPointName)) {
// helpWireless.setText(MSGS.netWifiWirelessEnabledForWANError());
// groupWireless.setValidationState(ValidationState.ERROR);
// }else{
TabWirelessUi.this.helpWireless.setText("");
TabWirelessUi.this.groupWireless.setValidationState(ValidationState.NONE);
if (TabWirelessUi.this.wireless.getSelectedItemText().equals(WIFI_MODE_STATION_MESSAGE)) {
// Use Values from station config
TabWirelessUi.this.activeConfig = TabWirelessUi.this.selectedNetIfConfig.getStationWifiConfig();
} else {
// use values from access point config
TabWirelessUi.this.activeConfig = TabWirelessUi.this.selectedNetIfConfig.getAccessPointWifiConfig();
}
TabWirelessUi.this.netTabs.adjustInterfaceTabs();
setPasswordValidation();
update();
}
});
// SSID
this.labelSsid.setText(MSGS.netWifiNetworkName());
this.ssid.setMaxLength(MAX_SSID_LENGTH);
this.ssid.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.ssid.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipNetworkName()));
}
}
});
this.ssid.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
this.buttonSsid.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (!TabWirelessUi.this.ssidInit) {
initSsid();
TabWirelessUi.this.ssidDataProvider.getList().clear();
TabWirelessUi.this.searching.setVisible(true);
TabWirelessUi.this.noSsid.setVisible(false);
TabWirelessUi.this.ssidGrid.setVisible(false);
TabWirelessUi.this.scanFail.setVisible(false);
}
initModal();
loadSsidData();
}
});
// Radio Mode
this.labelRadio.setText(MSGS.netWifiRadioMode());
this.radio.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.radio.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipRadioMode()));
}
}
});
this.radio.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
for (GwtWifiRadioMode mode : GwtWifiRadioMode.values()) {
if (mode != GwtWifiRadioMode.netWifiRadioModeA) {
// We don't support 802.11a yet
this.radio.addItem(MessageUtils.get(mode.name()));
}
}
// Wireless Security
this.labelSecurity.setText(MSGS.netWifiWirelessSecurity());
this.security.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.security.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipSecurity()));
}
}
});
this.security.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
for (GwtWifiSecurity mode : GwtWifiSecurity.values()) {
this.security.addItem(MessageUtils.get(mode.name()));
}
this.security.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
setPasswordValidation();
refreshForm();
checkPassword();
}
});
// Password
this.labelPassword.setText(MSGS.netWifiWirelessPassword());
this.password.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.password.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipPassword()));
}
}
});
this.password.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
this.buttonPassword.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
EntryClassUi.showWaitModal();
TabWirelessUi.this.buttonPassword.setEnabled(false);
final GwtWifiConfig gwtWifiConfig = getGwtWifiConfig();
TabWirelessUi.this.gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
TabWirelessUi.this.gwtNetworkService.verifyWifiCredentials(token, TabWirelessUi.this.selectedNetIfConfig.getName(), gwtWifiConfig, new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
EntryClassUi.hideWaitModal();
TabWirelessUi.this.buttonPassword.setEnabled(true);
showPasswordVerificationStatus(MSGS.netWifiPasswordVerificationFailed());
}
@Override
public void onSuccess(Boolean result) {
if (!result.booleanValue()) {
showPasswordVerificationStatus(MSGS.netWifiPasswordVerificationFailed());
} else {
showPasswordVerificationStatus(MSGS.netWifiPasswordVerificationSuccess());
}
EntryClassUi.hideWaitModal();
TabWirelessUi.this.buttonPassword.setEnabled(true);
}
});
}
});
}
});
this.password.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
if (TabWirelessUi.this.groupVerify.isVisible() && !TabWirelessUi.this.verify.getText().equals(TabWirelessUi.this.password.getText())) {
TabWirelessUi.this.groupVerify.setValidationState(ValidationState.ERROR);
} else {
TabWirelessUi.this.groupVerify.setValidationState(ValidationState.NONE);
}
}
});
this.password.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
refreshForm();
checkPassword();
}
});
// Verify Password
this.labelVerify.setText(MSGS.netWifiWirelessVerifyPassword());
this.verify.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.verify.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipPassword()));
}
}
});
this.verify.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
this.verify.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (TabWirelessUi.this.password != null && !TabWirelessUi.this.verify.getText().equals(TabWirelessUi.this.password.getText())) {
TabWirelessUi.this.helpVerify.setText(MSGS.netWifiWirelessPasswordDoesNotMatch());
TabWirelessUi.this.groupVerify.setValidationState(ValidationState.ERROR);
} else {
TabWirelessUi.this.helpVerify.setText("");
TabWirelessUi.this.groupVerify.setValidationState(ValidationState.NONE);
}
}
});
// Pairwise ciphers
this.labelPairwise.setText(MSGS.netWifiWirelessPairwiseCiphers());
this.pairwise.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.pairwise.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipPairwiseCiphers()));
}
}
});
this.pairwise.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
for (GwtWifiCiphers ciphers : GwtWifiCiphers.values()) {
this.pairwise.addItem(MessageUtils.get(ciphers.name()));
}
this.pairwise.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
refreshForm();
}
});
// Groupwise Ciphers
this.labelGroup.setText(MSGS.netWifiWirelessGroupCiphers());
this.group.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.group.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiWirelessGroupCiphers()));
}
}
});
this.group.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
for (GwtWifiCiphers ciphers : GwtWifiCiphers.values()) {
this.group.addItem(MessageUtils.get(ciphers.name()));
}
this.group.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
refreshForm();
}
});
// Bgscan module
this.labelBgscan.setText(MSGS.netWifiWirelessBgscanModule());
this.bgscan.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.bgscan.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipBgScan()));
}
}
});
this.bgscan.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
for (GwtWifiBgscanModule module : GwtWifiBgscanModule.values()) {
this.bgscan.addItem(MessageUtils.get(module.name()));
}
this.bgscan.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
refreshForm();
}
});
// BgScan RSSI threshold
this.labelRssi.setText(MSGS.netWifiWirelessBgscanSignalStrengthThreshold());
// TODO: DW - RSSI slider
/*
* rssi.addSlideStartHandler(new SlideStartHandler<Double>() {
*
* @Override
* public void onSlideStart(SlideStartEvent<Double> event) {
* if (rssi.isEnabled()) {
* helpText.clear();
* helpText.add(new Span(MSGS.netWifiToolTipBgScanStrength()));
* }
* }
* });
* rssi.addSlideStopHandler(new SlideStopHandler<Double>() {
*
* @Override
* public void onSlideStop(SlideStopEvent<Double> event) {
* resetHelp();
* }
* });
*/
// Bgscan short Interval
this.labelShortI.setText(MSGS.netWifiWirelessBgscanShortInterval());
this.shortI.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.shortI.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipBgScanShortInterval()));
}
}
});
this.shortI.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
this.shortI.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (TabWirelessUi.this.shortI.getText().trim().contains(".") || TabWirelessUi.this.shortI.getText().trim().contains("-") || !TabWirelessUi.this.shortI.getText().trim().matches("[0-9]+")) {
TabWirelessUi.this.groupShortI.setValidationState(ValidationState.ERROR);
} else {
TabWirelessUi.this.groupShortI.setValidationState(ValidationState.NONE);
}
}
});
// Bgscan long interval
this.labelLongI.setText(MSGS.netWifiWirelessBgscanLongInterval());
this.longI.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.longI.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipBgScanLongInterval()));
}
}
});
this.longI.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
this.longI.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (TabWirelessUi.this.longI.getText().trim().contains(".") || TabWirelessUi.this.longI.getText().trim().contains("-") || !TabWirelessUi.this.longI.getText().trim().matches("[0-9]+")) {
TabWirelessUi.this.groupLongI.setValidationState(ValidationState.ERROR);
} else {
TabWirelessUi.this.groupLongI.setValidationState(ValidationState.NONE);
}
}
});
// Ping Access Point ----
this.labelPing.setText(MSGS.netWifiWirelessPingAccessPoint());
this.radio1.setText(MSGS.trueLabel());
this.radio1.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.radio1.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipPingAccessPoint()));
}
}
});
this.radio1.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
this.radio2.setText(MSGS.falseLabel());
this.radio2.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.radio2.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipPingAccessPoint()));
}
}
});
this.radio2.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
// Ignore Broadcast SSID
this.labelIgnore.setText(MSGS.netWifiWirelessIgnoreSSID());
this.radio3.setText(MSGS.trueLabel());
this.radio3.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.radio3.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipIgnoreSSID()));
}
}
});
this.radio3.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
this.radio4.setText(MSGS.falseLabel());
this.radio4.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (TabWirelessUi.this.radio4.isEnabled()) {
TabWirelessUi.this.helpText.clear();
TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipIgnoreSSID()));
}
}
});
this.radio4.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
resetHelp();
}
});
// Channel Grid
initGrid();
this.helpTitle.setText(MSGS.netHelpTitle());
}
use of org.eclipse.kura.web.shared.model.GwtWifiRadioMode in project kura by eclipse.
the class WirelessConfigTab method onRender.
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setLayout(new FitLayout());
setId("network-wireless");
FormData formData = new FormData();
formData.setWidth(250);
m_formPanel = new FormPanel();
m_formPanel.setFrame(false);
m_formPanel.setBodyBorder(false);
m_formPanel.setHeaderVisible(false);
m_formPanel.setLayout(new FlowLayout());
m_formPanel.setStyleAttribute("min-width", "775px");
m_formPanel.setStyleAttribute("padding-left", "30px");
FieldSet fieldSet = new FieldSet();
FormLayout layoutAccount = new FormLayout();
layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM);
fieldSet.setLayout(layoutAccount);
fieldSet.setBorders(false);
//
// Tool Tip Box
//
toolTipField.setText(defaultToolTip);
fieldSet.add(toolTipField);
//
// Wireless Mode
//
m_wirelessModeListStore = new ListStore<GwtWifiWirelessModeModel>();
/*
m_wirelessModeListStore.add(new GwtWifiWirelessModeModel(GwtWifiWirelessMode.netWifiWirelessModeDisabled,
MessageUtils.get("netWifiWirelessModeDisabled"),
MSGS.netWifiToolTipWirelessModeDisabled()));
*/
m_wirelessModeListStore.add(new GwtWifiWirelessModeModel(GwtWifiWirelessMode.netWifiWirelessModeStation, MessageUtils.get("netWifiWirelessModeStation"), MSGS.netWifiToolTipWirelessModeStation()));
m_wirelessModeListStore.add(new GwtWifiWirelessModeModel(GwtWifiWirelessMode.netWifiWirelessModeAccessPoint, MessageUtils.get("netWifiWirelessModeAccessPoint"), MSGS.netWifiToolTipWirelessModeAccessPoint()));
/*
m_wirelessModeListStore.add(new GwtWifiWirelessModeModel(GwtWifiWirelessMode.netWifiWirelessModeAdHoc,
MessageUtils.get("netWifiWirelessModeAdHoc"),
MSGS.netWifiToolTipWirelessModeAdhoc()));
*/
m_modeCombo = new ComboBox<GwtWifiWirelessModeModel>();
m_modeCombo.setName("comboMode");
m_modeCombo.setDisplayField(GwtWifiWirelessModeModel.NAME);
m_modeCombo.setFieldLabel(MSGS.netWifiWirelessMode());
m_modeCombo.setEditable(false);
m_modeCombo.setTypeAhead(true);
m_modeCombo.setTriggerAction(TriggerAction.ALL);
m_modeCombo.addStyleName("kura-combobox");
m_modeCombo.setStore(m_wirelessModeListStore);
m_modeCombo.setTemplate(getTemplate());
m_modeCombo.setValue(m_wirelessModeListStore.findModel(GwtWifiWirelessModeModel.MODE, GwtWifiWirelessMode.netWifiWirelessModeStation.name()));
m_modeCombo.setValidator(new Validator() {
public String validate(Field<?> field, String value) {
if (m_tcpIpConfigTab.getStatus().equals(GwtNetIfStatus.netIPv4StatusEnabledWAN) && value.equals(MessageUtils.get(GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.name()))) {
return MSGS.netWifiWirelessEnabledForWANError();
}
return null;
}
});
m_modeCombo.addSelectionChangedListener(new SelectionChangedListener<GwtWifiWirelessModeModel>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtWifiWirelessModeModel> se) {
// Station mode selected
if (GwtWifiWirelessMode.netWifiWirelessModeStation.equals(se.getSelectedItem().getMode())) {
// Use values from station config
m_activeWifiConfig = m_selectNetIfConfig.getStationWifiConfig();
} else {
// Use values from access point config
m_activeWifiConfig = m_selectNetIfConfig.getAccessPointWifiConfig();
}
setPasswordValidation();
setValues(false);
refreshForm();
}
});
m_modeCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipWirelessMode()));
m_modeCombo.addPlugin(m_dirtyPlugin);
Button ssidPickerButton = new Button("", AbstractImagePrototype.create(Resources.INSTANCE.magnifier16()), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
m_wifiNetworksWindow = createWifiNetworksWindow();
m_wifiNetworksWindow.show();
m_wifiHotspotLoader.load();
}
});
//
// SSID
//
m_ssidField = new TextFieldWithButton<String>(ssidPickerButton, 10);
m_ssidField.setAllowBlank(true);
m_ssidField.setId("ssid-input");
m_ssidField.setName("ssid");
m_ssidField.setFieldLabel(MSGS.netWifiNetworkName());
m_ssidField.setEnabled(true, false);
m_ssidField.addPlugin(m_dirtyPlugin);
m_ssidField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipNetworkName()));
m_ssidField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
m_ssidField.setMaxLength(MAX_SSID_LENGTH);
//
// Radio Mode
//
m_radioModeCombo = new SimpleComboBox<String>();
m_radioModeCombo.setName("radioMode");
m_radioModeCombo.setFieldLabel(MSGS.netWifiRadioMode());
m_radioModeCombo.setEditable(false);
m_radioModeCombo.setTypeAhead(true);
m_radioModeCombo.setTriggerAction(TriggerAction.ALL);
for (GwtWifiRadioMode mode : GwtWifiRadioMode.values()) {
if (mode != GwtWifiRadioMode.netWifiRadioModeA) {
// we don't support 802.11a yet
m_radioModeCombo.add(MessageUtils.get(mode.name()));
}
}
m_radioModeCombo.setSimpleValue(MessageUtils.get(GwtWifiRadioMode.netWifiRadioModeBGN.name()));
m_radioModeCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
refreshForm();
}
});
m_radioModeCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipRadioMode()));
m_radioModeCombo.addStyleName("kura-combobox");
m_radioModeCombo.addPlugin(m_dirtyPlugin);
//
// Wireless Security
//
m_securityCombo = new SimpleComboBox<String>();
m_securityCombo.setName("security");
m_securityCombo.setFieldLabel(MSGS.netWifiWirelessSecurity());
m_securityCombo.setEditable(false);
m_securityCombo.setTypeAhead(true);
m_securityCombo.setTriggerAction(TriggerAction.ALL);
m_securityCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
for (GwtWifiSecurity mode : GwtWifiSecurity.values()) {
m_securityCombo.add(MessageUtils.get(mode.name()));
}
m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA2.name()));
m_securityCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
setPasswordValidation();
refreshForm();
}
});
m_securityCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipSecurity()));
m_securityCombo.addStyleName("kura-combobox");
m_securityCombo.addPlugin(m_dirtyPlugin);
Button passwordButton = new Button("", AbstractImagePrototype.create(Resources.INSTANCE.connect16()), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
m_passwordField.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.hourglass16()));
m_passwordField.setEnabled(true, false);
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
GwtWifiConfig gwtWifiConfig = getGwtWifiConfig();
gwtNetworkService.verifyWifiCredentials(token, m_selectNetIfConfig.getName(), gwtWifiConfig, new AsyncCallback<Boolean>() {
public void onSuccess(Boolean result) {
Log.warn("verifyWifiCredentials() :: result=" + result);
if (!result.booleanValue()) {
m_passwordField.setValue("");
}
m_passwordField.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.connect16()));
m_passwordField.setEnabled(true, true);
}
public void onFailure(Throwable caught) {
Log.warn("verifyWifiCredentials() :: caught: " + caught.toString());
m_passwordField.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.connect16()));
m_passwordField.setEnabled(true, true);
}
});
}
});
}
});
//
// Password
//
m_passwordField = new TextFieldWithButton<String>(passwordButton, 10);
m_passwordField.setId("wifi-password");
m_passwordField.setName("password");
m_passwordField.setFieldLabel(MSGS.netWifiWirelessPassword());
m_passwordField.setPassword(true);
m_passwordField.setRegex(PASSWORD_REGEX_ANY);
m_passwordField.getMessages().setRegexText(MSGS.netWifiWirelessInvalidWPAPassword());
m_passwordField.addPlugin(m_dirtyPlugin);
m_passwordField.setAutoValidate(true);
m_passwordField.setAllowBlank(false);
m_passwordField.addKeyListener(new KeyListener() {
@Override
public void componentKeyUp(ComponentEvent event) {
super.componentKeyUp(event);
m_verifyPasswordField.validate();
}
});
m_passwordField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipPassword()));
m_passwordField.addListener(Events.OnChange, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
setPasswordValidation();
refreshForm();
}
});
//
// Verify Password
//
m_verifyPasswordField = new TextField<String>();
m_verifyPasswordField.setName("verifyPassword");
m_verifyPasswordField.setFieldLabel(MSGS.netWifiWirelessVerifyPassword());
m_verifyPasswordField.setPassword(true);
m_verifyPasswordField.addPlugin(m_dirtyPlugin);
// TODO:
m_verifyPasswordField.getMessages().setInvalidText("Invalid text 123");
m_verifyPasswordField.setAutoValidate(true);
m_verifyPasswordField.setAllowBlank(false);
m_verifyPasswordField.setValidator(new Validator() {
public String validate(Field<?> field, String value) {
if (m_modeCombo != null && GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.equals(m_modeCombo.getValue().getMode())) {
// Check that the verify password field matches
if (m_passwordField == null || !value.equals(m_passwordField.getValue())) {
return MSGS.netWifiWirelessPasswordDoesNotMatch();
}
}
return null;
}
});
m_verifyPasswordField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipVerifyPassword()));
m_verifyPasswordField.addStyleName("kura-textfield");
// pairwise ciphers
m_pairwiseCiphersCombo = new SimpleComboBox<String>();
m_pairwiseCiphersCombo.setName("pairwiseCiphers");
m_pairwiseCiphersCombo.setFieldLabel(MSGS.netWifiWirelessPairwiseCiphers());
m_pairwiseCiphersCombo.setEditable(false);
m_pairwiseCiphersCombo.setTypeAhead(true);
m_pairwiseCiphersCombo.setTriggerAction(TriggerAction.ALL);
// m_pairwiseCiphersCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
for (GwtWifiCiphers ciphers : GwtWifiCiphers.values()) {
m_pairwiseCiphersCombo.add(MessageUtils.get(ciphers.name()));
}
m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
m_pairwiseCiphersCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
refreshForm();
}
});
m_pairwiseCiphersCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipPairwiseCiphers()));
m_pairwiseCiphersCombo.addStyleName("kura-combobox");
m_pairwiseCiphersCombo.addPlugin(m_dirtyPlugin);
// group ciphers
m_groupCiphersCombo = new SimpleComboBox<String>();
m_groupCiphersCombo.setName("groupCiphers");
m_groupCiphersCombo.setFieldLabel(MSGS.netWifiWirelessGroupCiphers());
m_groupCiphersCombo.setEditable(false);
m_groupCiphersCombo.setTypeAhead(true);
m_groupCiphersCombo.setTriggerAction(TriggerAction.ALL);
// m_groupCiphersCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
for (GwtWifiCiphers ciphers : GwtWifiCiphers.values()) {
m_groupCiphersCombo.add(MessageUtils.get(ciphers.name()));
}
m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
m_groupCiphersCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
refreshForm();
}
});
m_groupCiphersCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipGroupCiphers()));
m_groupCiphersCombo.addStyleName("kura-combobox");
m_groupCiphersCombo.addPlugin(m_dirtyPlugin);
// bgscan module
m_bgscanModuleCombo = new SimpleComboBox<String>();
m_bgscanModuleCombo.setName("groupCiphers");
m_bgscanModuleCombo.setFieldLabel(MSGS.netWifiWirelessBgscanModule());
m_bgscanModuleCombo.setEditable(false);
m_bgscanModuleCombo.setTypeAhead(true);
m_bgscanModuleCombo.setTriggerAction(TriggerAction.ALL);
m_bgscanModuleCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
for (GwtWifiBgscanModule module : GwtWifiBgscanModule.values()) {
m_bgscanModuleCombo.add(MessageUtils.get(module.name()));
}
m_bgscanModuleCombo.setSimpleValue(MessageUtils.get(GwtWifiBgscanModule.netWifiBgscanMode_NONE.name()));
m_bgscanModuleCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
refreshForm();
}
});
m_bgscanModuleCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipBgScan()));
m_bgscanModuleCombo.addStyleName("kura-combobox");
m_bgscanModuleCombo.addPlugin(m_dirtyPlugin);
// bgscan RSSI Threshold
m_bgscanRssiThresholdSlider = new Slider();
m_bgscanRssiThresholdSlider.setWidth(200);
m_bgscanRssiThresholdSlider.setIncrement(1);
m_bgscanRssiThresholdSlider.setMinValue(-90);
m_bgscanRssiThresholdSlider.setMaxValue(-20);
m_bgscanRssiThresholdSlider.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipBgScanStrength()));
m_bgscanRssiThresholdSlider.setClickToChange(false);
m_bgscanRssiThresholdSliderField = new SliderField(m_bgscanRssiThresholdSlider);
m_bgscanRssiThresholdSliderField.setFieldLabel(MSGS.netWifiWirelessBgscanSignalStrengthThreshold());
// bgscan short interval
m_bgscanShortIntervalField = new NumberField();
m_bgscanShortIntervalField.setPropertyEditorType(Integer.class);
m_bgscanShortIntervalField.setAllowDecimals(false);
m_bgscanShortIntervalField.setAllowNegative(false);
m_bgscanShortIntervalField.setAllowBlank(true);
m_bgscanShortIntervalField.setName("bgscanShortInterval");
m_bgscanShortIntervalField.setFieldLabel(MSGS.netWifiWirelessBgscanShortInterval());
m_bgscanShortIntervalField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipBgScanShortInterval()));
m_bgscanShortIntervalField.addPlugin(m_dirtyPlugin);
// m_bgscanShortInterval.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
// bgscan long interval
m_bgscanLongIntervalField = new NumberField();
m_bgscanLongIntervalField.setPropertyEditorType(Integer.class);
m_bgscanLongIntervalField.setAllowDecimals(false);
m_bgscanLongIntervalField.setAllowNegative(false);
m_bgscanLongIntervalField.setAllowBlank(true);
m_bgscanLongIntervalField.setName("bgscanLongInterval");
m_bgscanLongIntervalField.setFieldLabel(MSGS.netWifiWirelessBgscanLongInterval());
m_bgscanLongIntervalField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipBgScanLongInterval()));
m_bgscanLongIntervalField.addPlugin(m_dirtyPlugin);
m_pingAccessPointRadioTrue = new Radio();
m_pingAccessPointRadioTrue.setBoxLabel(MSGS.trueLabel());
m_pingAccessPointRadioTrue.setItemId("true");
m_pingAccessPointRadioTrue.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipPingAccessPoint()));
m_pingAccessPointRadioFalse = new Radio();
m_pingAccessPointRadioFalse.setBoxLabel(MSGS.falseLabel());
m_pingAccessPointRadioFalse.setItemId("false");
m_pingAccessPointRadioFalse.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipPingAccessPoint()));
m_pingAccessPointRadioGroup = new RadioGroup();
m_pingAccessPointRadioGroup.setName("pingAccessPoint");
m_pingAccessPointRadioGroup.setFieldLabel(MSGS.netWifiWirelessPingAccessPoint());
m_pingAccessPointRadioGroup.add(m_pingAccessPointRadioTrue);
m_pingAccessPointRadioGroup.add(m_pingAccessPointRadioFalse);
m_pingAccessPointRadioGroup.addPlugin(m_dirtyPlugin);
m_pingAccessPointRadioGroup.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
m_ignoreSsidRadioTrue = new Radio();
m_ignoreSsidRadioTrue.setBoxLabel(MSGS.trueLabel());
m_ignoreSsidRadioTrue.setItemId("true");
m_ignoreSsidRadioTrue.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipIgnoreSSID()));
m_ignoreSsidRadioFalse = new Radio();
m_ignoreSsidRadioFalse.setBoxLabel(MSGS.falseLabel());
m_ignoreSsidRadioFalse.setItemId("false");
m_ignoreSsidRadioFalse.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipIgnoreSSID()));
m_ignoreSsidRadioGroup = new RadioGroup();
m_ignoreSsidRadioGroup.setName("ignoreSSID");
m_ignoreSsidRadioGroup.setFieldLabel(MSGS.netWifiWirelessIgnoreSSID());
m_ignoreSsidRadioGroup.add(m_ignoreSsidRadioTrue);
m_ignoreSsidRadioGroup.add(m_ignoreSsidRadioFalse);
m_ignoreSsidRadioGroup.addPlugin(m_dirtyPlugin);
m_ignoreSsidRadioGroup.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
//
// Channel
//
GroupingStore<GwtWifiChannelModel> grtoupingStore = new GroupingStore<GwtWifiChannelModel>();
grtoupingStore.setMonitorChanges(true);
grtoupingStore.add(GwtWifiChannelModel.getChannels());
grtoupingStore.groupBy("band");
ColumnConfig channel = new ColumnConfig("name", "All Available Channels", 20);
ColumnConfig frequency = new ColumnConfig("frequency", "Frequency (MHz)", 10);
ColumnConfig band = new ColumnConfig("band", "Spectrum Band", 20);
List<ColumnConfig> channelColumnConfig = new ArrayList<ColumnConfig>();
channelColumnConfig.add(m_checkboxChannelSelectionModel.getColumn());
channelColumnConfig.add(channel);
channelColumnConfig.add(frequency);
channelColumnConfig.add(band);
final ColumnModel columnModel = new ColumnModel(channelColumnConfig);
m_channelGroupingView = new GroupingView() {
@Override
protected void onMouseDown(GridEvent<ModelData> ge) {
El hd = ge.getTarget(".x-grid-group-hd", 10);
El target = ge.getTargetEl();
if (hd != null && target.hasStyleName(m_uncheckedStyle) || target.hasStyleName(m_checkedStyle)) {
boolean checked = !ge.getTargetEl().hasStyleName(m_uncheckedStyle);
checked = !checked;
if (checked) {
ge.getTargetEl().replaceStyleName(m_uncheckedStyle, m_checkedStyle);
} else {
ge.getTargetEl().replaceStyleName(m_checkedStyle, m_uncheckedStyle);
}
Element group = (Element) findGroup(ge.getTarget());
if (group != null) {
NodeList<Element> rows = El.fly(group).select(".x-grid3-row");
List<ModelData> temp = new ArrayList<ModelData>();
for (int i = 0; i < rows.getLength(); i++) {
Element r = rows.getItem(i);
int idx = findRowIndex(r);
ModelData m = grid.getStore().getAt(idx);
temp.add(m);
}
if (checked) {
grid.getSelectionModel().select(temp, true);
} else {
grid.getSelectionModel().deselect(temp);
}
}
return;
}
super.onMouseDown(ge);
}
};
m_channelGroupingView.setShowGroupedColumn(false);
m_channelGroupingView.setForceFit(true);
m_channelGroupingView.setShowDirtyCells(true);
m_channelGroupingView.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
String f = columnModel.getColumnById(data.field).getHeader();
String l = data.models.size() == 1 ? "Item" : "Items";
return "<div class='x-grid3-group-checker'><div class='" + m_uncheckedStyle + "'> </div></div> " + f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
}
});
final Grid<GwtWifiChannelModel> channelGrid = new Grid<GwtWifiChannelModel>(grtoupingStore, columnModel);
channelGrid.setView(m_channelGroupingView);
channelGrid.setBorders(true);
channelGrid.addPlugin(m_checkboxChannelSelectionModel);
channelGrid.setSelectionModel(m_checkboxChannelSelectionModel);
channelGrid.addPlugin(m_dirtyPlugin);
m_channelPanel = new ContentPanel();
m_channelPanel.setHeading("Select Channel(s)");
m_channelPanel.setCollapsible(true);
m_channelPanel.setFrame(true);
m_channelPanel.setSize(430, 200);
m_channelPanel.setLayout(new FitLayout());
m_channelPanel.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
m_channelPanel.add(channelGrid);
m_channelPanel.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipChannels()));
m_checkboxChannelSelectionModel.addSelectionChangedListener(new SelectionChangedListener<GwtWifiChannelModel>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtWifiChannelModel> se) {
updateSelectedChannels(se.getSelection());
}
});
// Adjust the number of channels shown based on defined property
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtDeviceService.findDeviceConfiguration(token, new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {
public void onSuccess(ListLoadResult<GwtGroupedNVPair> results) {
if (results != null) {
List<GwtGroupedNVPair> pairs = results.getData();
if (pairs != null) {
for (GwtGroupedNVPair pair : pairs) {
String name = pair.getName();
if (name != null && name.equals("devLastWifiChannel")) {
int topChannel = Integer.parseInt(pair.getValue());
// Remove channels 12 and 13
if (topChannel < MAX_WIFI_CHANNEL) {
channelGrid.getStore().remove(MAX_WIFI_CHANNEL - 1);
channelGrid.getStore().remove(MAX_WIFI_CHANNEL - 2);
}
}
}
}
}
}
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
}
});
}
});
fieldSet.add(m_modeCombo, formData);
fieldSet.add(m_ssidField, formData);
fieldSet.add(m_radioModeCombo, formData);
fieldSet.add(m_securityCombo, formData);
fieldSet.add(m_passwordField, formData);
fieldSet.add(m_verifyPasswordField, formData);
fieldSet.add(m_pairwiseCiphersCombo, formData);
fieldSet.add(m_groupCiphersCombo, formData);
fieldSet.add(m_bgscanModuleCombo, formData);
fieldSet.add(m_bgscanRssiThresholdSliderField, formData);
fieldSet.add(m_bgscanShortIntervalField, formData);
fieldSet.add(m_bgscanLongIntervalField, formData);
fieldSet.add(m_pingAccessPointRadioGroup, formData);
fieldSet.add(m_ignoreSsidRadioGroup, formData);
fieldSet.add(m_channelPanel, formData);
if ((m_securityCombo.getSimpleValue().equals(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA2.name()))) || (m_securityCombo.getSimpleValue().equals(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA.name()))) || (m_securityCombo.getSimpleValue().equals(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA_WPA2.name())))) {
if (GwtWifiWirelessMode.netWifiWirelessModeStation.equals(m_modeCombo.getValue().getMode())) {
m_pairwiseCiphersCombo.setEnabled(true);
m_groupCiphersCombo.setEnabled(true);
} else {
// m_pairwiseCiphersCombo.setEnabled(false); // enable it for AP mode as well
m_pairwiseCiphersCombo.setEnabled(true);
m_groupCiphersCombo.setEnabled(false);
}
} else {
m_pairwiseCiphersCombo.setEnabled(false);
m_groupCiphersCombo.setEnabled(false);
}
m_formPanel.add(fieldSet);
m_formPanel.setScrollMode(Scroll.AUTO);
add(m_formPanel);
setScrollMode(Scroll.AUTOX);
m_initialized = true;
}
use of org.eclipse.kura.web.shared.model.GwtWifiRadioMode in project kura by eclipse.
the class TabWirelessUi method getGwtWifiConfig.
private GwtWifiConfig getGwtWifiConfig() {
GwtWifiConfig gwtWifiConfig = new GwtWifiConfig();
// mode
GwtWifiWirelessMode wifiMode;
if (this.wireless.getSelectedItemText().equals(MessageUtils.get(WIFI_MODE_STATION))) {
wifiMode = GwtWifiWirelessMode.netWifiWirelessModeStation;
} else {
wifiMode = GwtWifiWirelessMode.netWifiWirelessModeAccessPoint;
}
gwtWifiConfig.setWirelessMode(wifiMode.name());
// ssid
gwtWifiConfig.setWirelessSsid(GwtSafeHtmlUtils.htmlUnescape(this.ssid.getText().trim()));
// driver
String driver = "";
if (GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.equals(wifiMode)) {
driver = this.selectedNetIfConfig.getAccessPointWifiConfig().getDriver();
} else if (GwtWifiWirelessMode.netWifiWirelessModeAdHoc.equals(wifiMode)) {
driver = this.selectedNetIfConfig.getAdhocWifiConfig().getDriver();
} else if (GwtWifiWirelessMode.netWifiWirelessModeStation.equals(wifiMode)) {
driver = this.selectedNetIfConfig.getStationWifiConfig().getDriver();
}
// use previous value
gwtWifiConfig.setDriver(driver);
// radio mode
String radioValue = this.radio.getSelectedItemText();
for (GwtWifiRadioMode mode : GwtWifiRadioMode.values()) {
if (MessageUtils.get(mode.name()).equals(radioValue)) {
gwtWifiConfig.setRadioMode(mode.name());
}
}
// channels
Set<GwtWifiChannelModel> lSelectedChannels = this.selectionModel.getSelectedSet();
ArrayList<Integer> alChannels = new ArrayList<Integer>();
for (GwtWifiChannelModel item : lSelectedChannels) {
alChannels.add(new Integer(item.getChannel()));
}
if (alChannels.isEmpty()) {
alChannels.add(1);
}
gwtWifiConfig.setChannels(alChannels);
// security
String secValue = this.security.getSelectedItemText();
for (GwtWifiSecurity sec : GwtWifiSecurity.values()) {
if (MessageUtils.get(sec.name()).equals(secValue)) {
gwtWifiConfig.setSecurity(sec.name());
}
}
// Pairwise Ciphers
String pairWiseCiphersValue = this.pairwise.getSelectedItemText();
for (GwtWifiCiphers ciphers : GwtWifiCiphers.values()) {
if (MessageUtils.get(ciphers.name()).equals(pairWiseCiphersValue)) {
gwtWifiConfig.setPairwiseCiphers(ciphers.name());
}
}
// Group Ciphers value
String groupCiphersValue = this.group.getSelectedItemText();
for (GwtWifiCiphers ciphers : GwtWifiCiphers.values()) {
if (MessageUtils.get(ciphers.name()).equals(groupCiphersValue)) {
gwtWifiConfig.setGroupCiphers(ciphers.name());
}
}
// bgscan
String bgscanModuleValue = this.bgscan.getSelectedItemText();
for (GwtWifiBgscanModule module : GwtWifiBgscanModule.values()) {
if (MessageUtils.get(module.name()).equals(bgscanModuleValue)) {
gwtWifiConfig.setBgscanModule(module.name());
}
}
// gwtWifiConfig.setBgscanRssiThreshold(rssi.getValue().intValue());
gwtWifiConfig.setBgscanShortInterval(Integer.parseInt(this.shortI.getText()));
gwtWifiConfig.setBgscanLongInterval(Integer.parseInt(this.longI.getText()));
// password
if (this.groupPassword.getValidationState().equals(ValidationState.NONE)) {
gwtWifiConfig.setPassword(this.password.getText());
}
// ping access point
gwtWifiConfig.setPingAccessPoint(this.radio1.getValue());
// ignore SSID
gwtWifiConfig.setIgnoreSSID(this.radio3.getValue());
return gwtWifiConfig;
}
use of org.eclipse.kura.web.shared.model.GwtWifiRadioMode in project kura by eclipse.
the class GwtNetworkServiceImpl method getWifiConfig.
private WifiConfig getWifiConfig(GwtWifiConfig gwtWifiConfig) {
WifiConfig wifiConfig = null;
if (gwtWifiConfig != null) {
wifiConfig = new WifiConfig();
String mode = gwtWifiConfig.getWirelessMode();
if (mode != null && mode.equals(GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.name())) {
wifiConfig.setMode(WifiMode.MASTER);
} else if (mode != null && mode.equals(GwtWifiWirelessMode.netWifiWirelessModeStation.name())) {
wifiConfig.setMode(WifiMode.INFRA);
} else if (mode != null && mode.equals(GwtWifiWirelessMode.netWifiWirelessModeAdHoc.name())) {
wifiConfig.setMode(WifiMode.ADHOC);
} else {
wifiConfig.setMode(WifiMode.UNKNOWN);
}
// ssid
wifiConfig.setSSID(GwtSafeHtmlUtils.htmlUnescape(gwtWifiConfig.getWirelessSsid()));
// driver
wifiConfig.setDriver(gwtWifiConfig.getDriver());
// radio mode
GwtWifiRadioMode radioMode = gwtWifiConfig.getRadioModeEnum();
if (radioMode == GwtWifiRadioMode.netWifiRadioModeA) {
wifiConfig.setRadioMode(WifiRadioMode.RADIO_MODE_80211a);
wifiConfig.setHardwareMode("a");
} else if (radioMode.equals(GwtWifiRadioMode.netWifiRadioModeB)) {
wifiConfig.setRadioMode(WifiRadioMode.RADIO_MODE_80211b);
wifiConfig.setHardwareMode("b");
} else if (radioMode.equals(GwtWifiRadioMode.netWifiRadioModeBG)) {
wifiConfig.setRadioMode(WifiRadioMode.RADIO_MODE_80211g);
wifiConfig.setHardwareMode("g");
} else if (radioMode.equals(GwtWifiRadioMode.netWifiRadioModeBGN)) {
wifiConfig.setRadioMode(WifiRadioMode.RADIO_MODE_80211nHT20);
wifiConfig.setHardwareMode("n");
}
// channel
ArrayList<Integer> alChannels = gwtWifiConfig.getChannels();
if (alChannels != null) {
int[] channels = new int[alChannels.size()];
for (int i = 0; i < channels.length; i++) {
channels[i] = alChannels.get(i).intValue();
}
wifiConfig.setChannels(channels);
}
// security
wifiConfig.setSecurity(WifiSecurity.SECURITY_NONE);
String security = gwtWifiConfig.getSecurity();
if (security != null) {
if (security.equals(GwtWifiSecurity.netWifiSecurityWPA.name())) {
// wifiConfig.setSecurity(WifiSecurity.KEY_MGMT_PSK);
wifiConfig.setSecurity(WifiSecurity.SECURITY_WPA);
} else if (security.equals(GwtWifiSecurity.netWifiSecurityWPA2.name())) {
// wifiConfig.setSecurity(WifiSecurity.KEY_MGMT_PSK);
wifiConfig.setSecurity(WifiSecurity.SECURITY_WPA2);
} else if (security.equals(GwtWifiSecurity.netWifiSecurityWPA_WPA2.name())) {
// wifiConfig.setSecurity(WifiSecurity.KEY_MGMT_PSK);
wifiConfig.setSecurity(WifiSecurity.SECURITY_WPA_WPA2);
} else if (security.equals(GwtWifiSecurity.netWifiSecurityWEP.name())) {
// wifiConfig.setSecurity(WifiSecurity.PAIR_WEP104);
wifiConfig.setSecurity(WifiSecurity.SECURITY_WEP);
}
}
String pairwiseCiphers = gwtWifiConfig.getPairwiseCiphers();
if (pairwiseCiphers != null) {
if (pairwiseCiphers.equals(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name())) {
wifiConfig.setPairwiseCiphers(WifiCiphers.CCMP_TKIP);
} else if (pairwiseCiphers.equals(GwtWifiCiphers.netWifiCiphers_TKIP.name())) {
wifiConfig.setPairwiseCiphers(WifiCiphers.TKIP);
} else if (pairwiseCiphers.equals(GwtWifiCiphers.netWifiCiphers_CCMP.name())) {
wifiConfig.setPairwiseCiphers(WifiCiphers.CCMP);
}
}
String groupCiphers = gwtWifiConfig.getGroupCiphers();
if (groupCiphers != null) {
if (groupCiphers.equals(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name())) {
wifiConfig.setGroupCiphers(WifiCiphers.CCMP_TKIP);
} else if (groupCiphers.equals(GwtWifiCiphers.netWifiCiphers_TKIP.name())) {
wifiConfig.setGroupCiphers(WifiCiphers.TKIP);
} else if (groupCiphers.equals(GwtWifiCiphers.netWifiCiphers_CCMP.name())) {
wifiConfig.setGroupCiphers(WifiCiphers.CCMP);
}
}
// bgscan
String bgscanModule = gwtWifiConfig.getBgscanModule();
if (bgscanModule != null) {
WifiBgscanModule wifiBgscanModule = null;
if (bgscanModule.equals(GwtWifiBgscanModule.netWifiBgscanMode_NONE.name())) {
wifiBgscanModule = WifiBgscanModule.NONE;
} else if (bgscanModule.equals(GwtWifiBgscanModule.netWifiBgscanMode_SIMPLE.name())) {
wifiBgscanModule = WifiBgscanModule.SIMPLE;
} else if (bgscanModule.equals(GwtWifiBgscanModule.netWifiBgscanMode_LEARN.name())) {
wifiBgscanModule = WifiBgscanModule.LEARN;
}
int bgscanRssiThreshold = gwtWifiConfig.getBgscanRssiThreshold();
int bgscanShortInterval = gwtWifiConfig.getBgscanShortInterval();
int bgscanLongInterval = gwtWifiConfig.getBgscanLongInterval();
WifiBgscan wifiBgscan = new WifiBgscan(wifiBgscanModule, bgscanShortInterval, bgscanRssiThreshold, bgscanLongInterval);
wifiConfig.setBgscan(wifiBgscan);
}
// passkey
wifiConfig.setPasskey(gwtWifiConfig.getPassword());
// ping access point?
wifiConfig.setPingAccessPoint(gwtWifiConfig.pingAccessPoint());
// ignore SSID?
wifiConfig.setIgnoreSSID(gwtWifiConfig.ignoreSSID());
// broadcast SSID
wifiConfig.setBroadcast(!gwtWifiConfig.ignoreSSID());
}
return wifiConfig;
}
Aggregations