diff --git a/libnymea-networkmanager/networkmanager.cpp b/libnymea-networkmanager/networkmanager.cpp index cb446f1..8ee8c38 100644 --- a/libnymea-networkmanager/networkmanager.cpp +++ b/libnymea-networkmanager/networkmanager.cpp @@ -260,6 +260,10 @@ NetworkManager::NetworkManagerError NetworkManager::startAccessPoint(const QStri if (!wirelessNetworkDevice) return NetworkManagerErrorInvalidNetworkDeviceType; + + if (!wirelessNetworkDevice->wirelessCapabilities().testFlag(WirelessNetworkDevice::WirelessCapabilityAP)) + return NetworkManagerErrorUnsupportedFeature; + // Note: https://developer.gnome.org/NetworkManager/stable/ref-settings.html // Create network settings for access point diff --git a/libnymea-networkmanager/networkmanager.h b/libnymea-networkmanager/networkmanager.h index bb5edf5..b7abf9e 100644 --- a/libnymea-networkmanager/networkmanager.h +++ b/libnymea-networkmanager/networkmanager.h @@ -88,6 +88,7 @@ class NetworkManager : public QObject NetworkManagerErrorNetworkingDisabled, NetworkManagerErrorNetworkManagerNotAvailable, NetworkManagerErrorInvalidConfiguration, + NetworkManagerErrorUnsupportedFeature }; Q_ENUM(NetworkManagerError) diff --git a/libnymea-networkmanager/wirelessnetworkdevice.cpp b/libnymea-networkmanager/wirelessnetworkdevice.cpp index f12e977..75930a3 100644 --- a/libnymea-networkmanager/wirelessnetworkdevice.cpp +++ b/libnymea-networkmanager/wirelessnetworkdevice.cpp @@ -90,6 +90,7 @@ WirelessNetworkDevice::WirelessNetworkDevice(const QDBusObjectPath &objectPath, readAccessPoints(); m_macAddress = m_wirelessInterface->property("HwAddress").toString(); + m_wirelessCapabilities = static_cast(m_wirelessInterface->property("WirelessCapabilities").toUInt()); m_wirelessMode = static_cast(m_wirelessInterface->property("Mode").toUInt()); m_bitRate = m_wirelessInterface->property("Bitrate").toInt() / 1000; setActiveAccessPoint(qdbus_cast(m_wirelessInterface->property("ActiveAccessPoint"))); @@ -107,6 +108,11 @@ int WirelessNetworkDevice::bitRate() const return m_bitRate; } +WirelessNetworkDevice::WirelessCapabilities WirelessNetworkDevice::wirelessCapabilities() const +{ + return m_wirelessCapabilities; +} + WirelessNetworkDevice::WirelessMode WirelessNetworkDevice::wirelessMode() const { return m_wirelessMode; @@ -236,6 +242,11 @@ void WirelessNetworkDevice::processProperties(const QVariantMap &properties) emit wirelessModeChanged(m_wirelessMode); } + if (properties.contains("WirelessCapabilities")) { + m_wirelessCapabilities = static_cast(m_wirelessInterface->property("WirelessCapabilities").toUInt()); + emit wirelessCapabilitiesChanged(m_wirelessCapabilities); + } + // Note: available since 1.12 (-1 means never scanned) if (properties.contains("LastScan")) { m_lastScan = m_wirelessInterface->property("LastScan").toInt(); @@ -262,6 +273,7 @@ QDebug operator<<(QDebug debug, WirelessNetworkDevice *device) { debug.nospace() << "WirelessNetworkDevice(" << device->interface() << ", "; debug.nospace() << device->macAddress() << ", "; + debug.nospace() << device->wirelessCapabilities() << ", "; debug.nospace() << device->wirelessMode() << ", "; debug.nospace() << device->bitRate() << " [Mb/s], "; debug.nospace() << device->deviceStateString() << ") "; diff --git a/libnymea-networkmanager/wirelessnetworkdevice.h b/libnymea-networkmanager/wirelessnetworkdevice.h index 51095fd..4b0280e 100644 --- a/libnymea-networkmanager/wirelessnetworkdevice.h +++ b/libnymea-networkmanager/wirelessnetworkdevice.h @@ -54,11 +54,30 @@ class WirelessNetworkDevice : public NetworkDevice }; Q_ENUM(WirelessMode) + enum WirelessCapability { + WirelessCapabilityNone = 0x0000, + WirelessCapabilityCipherWEP40 = 0x0001, + WirelessCapabilityCipherWEP104 = 0x0002, + WirelessCapabilityCipherTKIP = 0x0004, + WirelessCapabilityCipherCCMP = 0x0008, + WirelessCapabilityWPA = 0x0010, + WirelessCapabilityRSN = 0x0020, + WirelessCapabilityAP = 0x0040, + WirelessCapabilityAdHoc = 0x0080, + WirelessCapabilityFreqValid = 0x0100, + WirelessCapability2Ghz = 0x0200, + WirelessCapability5Ghz = 0x0400, + }; + Q_ENUM(WirelessCapability) + Q_DECLARE_FLAGS(WirelessCapabilities, WirelessCapability) + Q_FLAG(WirelessCapabilities) + explicit WirelessNetworkDevice(const QDBusObjectPath &objectPath, QObject *parent = nullptr); // Properties QString macAddress() const; int bitRate() const; + WirelessCapabilities wirelessCapabilities() const; WirelessMode wirelessMode() const; WirelessAccessPoint *activeAccessPoint(); @@ -72,6 +91,7 @@ class WirelessNetworkDevice : public NetworkDevice signals: void bitRateChanged(int bitRate); + void wirelessCapabilitiesChanged(WirelessCapabilities wirelessCapabilities); void wirelessModeChanged(WirelessMode mode); void lastScanChanged(int lastScan); @@ -87,6 +107,7 @@ private slots: int m_bitRate; QString m_macAddress; + WirelessCapabilities m_wirelessCapabilities = WirelessCapabilityNone; WirelessMode m_wirelessMode = WirelessModeUnknown; int m_lastScan = -1; QDBusObjectPath m_activeAccessPointObjectPath;