fix types and network device notifications
This commit is contained in:
parent
24276d393c
commit
28f6263ec0
@ -334,6 +334,7 @@ void JsonTypes::init()
|
|||||||
s_wirelessAccessPoint.insert("macAddress", basicTypeToString(QVariant::String));
|
s_wirelessAccessPoint.insert("macAddress", basicTypeToString(QVariant::String));
|
||||||
s_wirelessAccessPoint.insert("frequency", basicTypeToString(QVariant::Double));
|
s_wirelessAccessPoint.insert("frequency", basicTypeToString(QVariant::Double));
|
||||||
s_wirelessAccessPoint.insert("signalStrength", basicTypeToString(QVariant::Int));
|
s_wirelessAccessPoint.insert("signalStrength", basicTypeToString(QVariant::Int));
|
||||||
|
s_wirelessAccessPoint.insert("protected", basicTypeToString(QVariant::Bool));
|
||||||
|
|
||||||
// WiredNetworkDevice
|
// WiredNetworkDevice
|
||||||
s_wiredNetworkDevice.insert("interface", basicTypeToString(QVariant::String));
|
s_wiredNetworkDevice.insert("interface", basicTypeToString(QVariant::String));
|
||||||
@ -396,6 +397,7 @@ QVariantMap JsonTypes::allTypes()
|
|||||||
allTypes.insert("ConfigurationError", configurationError());
|
allTypes.insert("ConfigurationError", configurationError());
|
||||||
allTypes.insert("NetworkManagerError", networkManagerError());
|
allTypes.insert("NetworkManagerError", networkManagerError());
|
||||||
allTypes.insert("NetworkManagerState", networkManagerState());
|
allTypes.insert("NetworkManagerState", networkManagerState());
|
||||||
|
allTypes.insert("NetworkDeviceState", networkDeviceState());
|
||||||
|
|
||||||
allTypes.insert("StateType", stateTypeDescription());
|
allTypes.insert("StateType", stateTypeDescription());
|
||||||
allTypes.insert("StateDescriptor", stateDescriptorDescription());
|
allTypes.insert("StateDescriptor", stateDescriptorDescription());
|
||||||
@ -979,7 +981,7 @@ QVariantMap JsonTypes::packWirelessAccessPoint(WirelessAccessPoint *wirelessAcce
|
|||||||
wirelessAccessPointVariant.insert("macAddress", wirelessAccessPoint->macAddress());
|
wirelessAccessPointVariant.insert("macAddress", wirelessAccessPoint->macAddress());
|
||||||
wirelessAccessPointVariant.insert("frequency", wirelessAccessPoint->frequency());
|
wirelessAccessPointVariant.insert("frequency", wirelessAccessPoint->frequency());
|
||||||
wirelessAccessPointVariant.insert("signalStrength", wirelessAccessPoint->signalStrength());
|
wirelessAccessPointVariant.insert("signalStrength", wirelessAccessPoint->signalStrength());
|
||||||
|
wirelessAccessPointVariant.insert("protected", wirelessAccessPoint->isProtected());
|
||||||
return wirelessAccessPointVariant;
|
return wirelessAccessPointVariant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,6 +48,7 @@
|
|||||||
#include "cloud/cloudconnection.h"
|
#include "cloud/cloudconnection.h"
|
||||||
|
|
||||||
#include "networkmanager/networkmanager.h"
|
#include "networkmanager/networkmanager.h"
|
||||||
|
#include "networkmanager/networkdevice.h"
|
||||||
#include "networkmanager/wirednetworkdevice.h"
|
#include "networkmanager/wirednetworkdevice.h"
|
||||||
#include "networkmanager/wirelessnetworkdevice.h"
|
#include "networkmanager/wirelessnetworkdevice.h"
|
||||||
#include "networkmanager/wirelessaccesspoint.h"
|
#include "networkmanager/wirelessaccesspoint.h"
|
||||||
|
|||||||
@ -57,7 +57,7 @@ NetworkDevice::NetworkDevice(const QDBusObjectPath &objectPath, QObject *parent)
|
|||||||
m_autoconnect = m_networkDeviceInterface->property("Autoconnect").toBool();
|
m_autoconnect = m_networkDeviceInterface->property("Autoconnect").toBool();
|
||||||
|
|
||||||
m_deviceState = NetworkDeviceState(m_networkDeviceInterface->property("State").toUInt());
|
m_deviceState = NetworkDeviceState(m_networkDeviceInterface->property("State").toUInt());
|
||||||
m_deviceType = DeviceType(m_networkDeviceInterface->property("DeviceType").toUInt());
|
m_deviceType = NetworkDeviceType(m_networkDeviceInterface->property("NetworkDeviceType").toUInt());
|
||||||
|
|
||||||
m_activeConnection = qdbus_cast<QDBusObjectPath>(m_networkDeviceInterface->property("ActiveConnection"));
|
m_activeConnection = qdbus_cast<QDBusObjectPath>(m_networkDeviceInterface->property("ActiveConnection"));
|
||||||
m_ip4Config = qdbus_cast<QDBusObjectPath>(m_networkDeviceInterface->property("Ip4Config"));
|
m_ip4Config = qdbus_cast<QDBusObjectPath>(m_networkDeviceInterface->property("Ip4Config"));
|
||||||
@ -136,7 +136,7 @@ NetworkDevice::NetworkDeviceStateReason NetworkDevice::deviceStateReason() const
|
|||||||
return m_deviceStateReason;
|
return m_deviceStateReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkDevice::DeviceType NetworkDevice::deviceType() const
|
NetworkDevice::NetworkDeviceType NetworkDevice::deviceType() const
|
||||||
{
|
{
|
||||||
return m_deviceType;
|
return m_deviceType;
|
||||||
}
|
}
|
||||||
@ -164,12 +164,12 @@ void NetworkDevice::disconnectDevice()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NetworkDevice::deviceTypeToString(const NetworkDevice::DeviceType &deviceType)
|
QString NetworkDevice::deviceTypeToString(const NetworkDevice::NetworkDeviceType &deviceType)
|
||||||
{
|
{
|
||||||
QMetaObject metaObject = NetworkDevice::staticMetaObject;
|
QMetaObject metaObject = NetworkDevice::staticMetaObject;
|
||||||
int enumIndex = metaObject.indexOfEnumerator(QString("DeviceType").toLatin1().data());
|
int enumIndex = metaObject.indexOfEnumerator(QString("NetworkDeviceType").toLatin1().data());
|
||||||
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
||||||
return QString(metaEnum.valueToKey(deviceType)).remove("DeviceType");
|
return QString(metaEnum.valueToKey(deviceType)).remove("NetworkDeviceType");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NetworkDevice::deviceStateToString(const NetworkDevice::NetworkDeviceState &deviceState)
|
QString NetworkDevice::deviceStateToString(const NetworkDevice::NetworkDeviceState &deviceState)
|
||||||
@ -192,8 +192,10 @@ void NetworkDevice::onStateChanged(uint newState, uint oldState, uint reason)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(oldState);
|
Q_UNUSED(oldState);
|
||||||
qCDebug(dcNetworkManager()) << m_interface << "--> State changed:" << deviceStateToString(NetworkDeviceState(newState)) << ":" << deviceStateReasonToString(NetworkDeviceStateReason(reason));
|
qCDebug(dcNetworkManager()) << m_interface << "--> State changed:" << deviceStateToString(NetworkDeviceState(newState)) << ":" << deviceStateReasonToString(NetworkDeviceStateReason(reason));
|
||||||
m_deviceState = NetworkDeviceState(newState);
|
if (m_deviceState != NetworkDeviceState(newState)) {
|
||||||
emit deviceChanged();
|
m_deviceState = NetworkDeviceState(newState);
|
||||||
|
emit deviceChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, NetworkDevice *device)
|
QDebug operator<<(QDebug debug, NetworkDevice *device)
|
||||||
|
|||||||
@ -35,7 +35,7 @@ namespace guhserver {
|
|||||||
class NetworkDevice : public QObject
|
class NetworkDevice : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_ENUMS(DeviceType)
|
Q_ENUMS(NetworkDeviceType)
|
||||||
Q_ENUMS(NetworkDeviceState)
|
Q_ENUMS(NetworkDeviceState)
|
||||||
Q_ENUMS(NetworkDeviceStateReason)
|
Q_ENUMS(NetworkDeviceStateReason)
|
||||||
|
|
||||||
@ -122,26 +122,26 @@ public:
|
|||||||
NetworkDeviceStateReasonParentManagedChanged = 62
|
NetworkDeviceStateReasonParentManagedChanged = 62
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DeviceType {
|
enum NetworkDeviceType {
|
||||||
DeviceTypeUnknown = 0,
|
NetworkDeviceTypeUnknown = 0,
|
||||||
DeviceTypeEthernet = 1,
|
NetworkDeviceTypeEthernet = 1,
|
||||||
DeviceTypeWifi = 2,
|
NetworkDeviceTypeWifi = 2,
|
||||||
DeviceTypeBluetooth = 5,
|
NetworkDeviceTypeBluetooth = 5,
|
||||||
DeviceTypeOlpcMesh = 6,
|
NetworkDeviceTypeOlpcMesh = 6,
|
||||||
DeviceTypeWiMax = 7,
|
NetworkDeviceTypeWiMax = 7,
|
||||||
DeviceTypeModem = 8,
|
NetworkDeviceTypeModem = 8,
|
||||||
DeviceTypeInfiniBand = 9,
|
NetworkDeviceTypeInfiniBand = 9,
|
||||||
DeviceTypeBond = 10,
|
NetworkDeviceTypeBond = 10,
|
||||||
DeviceTypeVLan = 11,
|
NetworkDeviceTypeVLan = 11,
|
||||||
DeviceTypeAdsl = 12,
|
NetworkDeviceTypeAdsl = 12,
|
||||||
DeviceTypeBridge = 13,
|
NetworkDeviceTypeBridge = 13,
|
||||||
DeviceTypeGeneric = 14,
|
NetworkDeviceTypeGeneric = 14,
|
||||||
DeviceTypeTeam = 15,
|
NetworkDeviceTypeTeam = 15,
|
||||||
DeviceTypeTun = 16,
|
NetworkDeviceTypeTun = 16,
|
||||||
DeviceTypeIpTunnel = 17,
|
NetworkDeviceTypeIpTunnel = 17,
|
||||||
DeviceTypeMacVLan = 18,
|
NetworkDeviceTypeMacVLan = 18,
|
||||||
DeviceTypeVXLan = 19,
|
NetworkDeviceTypeVXLan = 19,
|
||||||
DeviceTypeVEth = 20,
|
NetworkDeviceTypeVEth = 20,
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit NetworkDevice(const QDBusObjectPath &objectPath, QObject *parent = 0);
|
explicit NetworkDevice(const QDBusObjectPath &objectPath, QObject *parent = 0);
|
||||||
@ -163,7 +163,7 @@ public:
|
|||||||
QString deviceStateString() const;
|
QString deviceStateString() const;
|
||||||
|
|
||||||
NetworkDeviceStateReason deviceStateReason() const;
|
NetworkDeviceStateReason deviceStateReason() const;
|
||||||
DeviceType deviceType() const;
|
NetworkDeviceType deviceType() const;
|
||||||
|
|
||||||
QDBusObjectPath activeConnection() const;
|
QDBusObjectPath activeConnection() const;
|
||||||
QDBusObjectPath ip4Config() const;
|
QDBusObjectPath ip4Config() const;
|
||||||
@ -172,7 +172,7 @@ public:
|
|||||||
// Method
|
// Method
|
||||||
void disconnectDevice();
|
void disconnectDevice();
|
||||||
|
|
||||||
static QString deviceTypeToString(const DeviceType &deviceType);
|
static QString deviceTypeToString(const NetworkDeviceType &deviceType);
|
||||||
static QString deviceStateToString(const NetworkDeviceState &deviceState);
|
static QString deviceStateToString(const NetworkDeviceState &deviceState);
|
||||||
static QString deviceStateReasonToString(const NetworkDeviceStateReason &deviceStateReason);
|
static QString deviceStateReasonToString(const NetworkDeviceStateReason &deviceStateReason);
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ private:
|
|||||||
bool m_autoconnect;
|
bool m_autoconnect;
|
||||||
NetworkDeviceState m_deviceState;
|
NetworkDeviceState m_deviceState;
|
||||||
NetworkDeviceStateReason m_deviceStateReason;
|
NetworkDeviceStateReason m_deviceStateReason;
|
||||||
DeviceType m_deviceType;
|
NetworkDeviceType m_deviceType;
|
||||||
|
|
||||||
QDBusObjectPath m_activeConnection;
|
QDBusObjectPath m_activeConnection;
|
||||||
QDBusObjectPath m_ip4Config;
|
QDBusObjectPath m_ip4Config;
|
||||||
@ -213,4 +213,9 @@ QDebug operator<<(QDebug debug, NetworkDevice *device);
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
Q_DECLARE_METATYPE(NetworkDevice::NetworkDeviceType)
|
||||||
|
Q_DECLARE_METATYPE(NetworkDevice::NetworkDeviceState)
|
||||||
|
Q_DECLARE_METATYPE(NetworkDevice::NetworkDeviceStateReason)
|
||||||
|
|
||||||
#endif // NETWORKDEVICE_H
|
#endif // NETWORKDEVICE_H
|
||||||
|
|||||||
@ -155,8 +155,8 @@ NetworkManager::NetworkManagerError NetworkManager::connectWifi(const QString &i
|
|||||||
|
|
||||||
QVariantMap wirelessSettings;
|
QVariantMap wirelessSettings;
|
||||||
wirelessSettings.insert("ssid", ssid.toUtf8());
|
wirelessSettings.insert("ssid", ssid.toUtf8());
|
||||||
wirelessSettings.insert("security", "802-11-wireless-security");
|
|
||||||
wirelessSettings.insert("mode", "infrastructure");
|
wirelessSettings.insert("mode", "infrastructure");
|
||||||
|
wirelessSettings.insert("security", "802-11-wireless-security");
|
||||||
|
|
||||||
QVariantMap wirelessSecuritySettings;
|
QVariantMap wirelessSecuritySettings;
|
||||||
wirelessSecuritySettings.insert("auth-alg", "open");
|
wirelessSecuritySettings.insert("auth-alg", "open");
|
||||||
@ -173,11 +173,16 @@ NetworkManager::NetworkManagerError NetworkManager::connectWifi(const QString &i
|
|||||||
ConnectionSettings settings;
|
ConnectionSettings settings;
|
||||||
settings.insert("connection", connectionSettings);
|
settings.insert("connection", connectionSettings);
|
||||||
settings.insert("802-11-wireless", wirelessSettings);
|
settings.insert("802-11-wireless", wirelessSettings);
|
||||||
settings.insert("802-11-wireless-security", wirelessSecuritySettings);
|
|
||||||
settings.insert("ipv4", ipv4Settings);
|
settings.insert("ipv4", ipv4Settings);
|
||||||
settings.insert("ipv6", ipv6Settings);
|
settings.insert("ipv6", ipv6Settings);
|
||||||
|
settings.insert("802-11-wireless-security", wirelessSecuritySettings);
|
||||||
|
|
||||||
// TODO: check if connection exists
|
// Remove old configuration (if there is any)
|
||||||
|
foreach (NetworkConnection *connection, m_networkSettings->connections()) {
|
||||||
|
if (connection->id() == connectionSettings.value("id")) {
|
||||||
|
connection->deleteConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add connection
|
// Add connection
|
||||||
QDBusObjectPath connectionObjectPath = m_networkSettings->addConnection(settings);
|
QDBusObjectPath connectionObjectPath = m_networkSettings->addConnection(settings);
|
||||||
@ -312,9 +317,9 @@ void NetworkManager::onDeviceAdded(const QDBusObjectPath &deviceObjectPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create object
|
// Create object
|
||||||
NetworkDevice::DeviceType deviceType = NetworkDevice::DeviceType(networkDeviceInterface.property("DeviceType").toUInt());
|
NetworkDevice::NetworkDeviceType deviceType = NetworkDevice::NetworkDeviceType(networkDeviceInterface.property("NetworkDeviceType").toUInt());
|
||||||
switch (deviceType) {
|
switch (deviceType) {
|
||||||
case NetworkDevice::DeviceTypeWifi: {
|
case NetworkDevice::NetworkDeviceTypeWifi: {
|
||||||
WirelessNetworkDevice *wirelessNetworkDevice = new WirelessNetworkDevice(deviceObjectPath, this);
|
WirelessNetworkDevice *wirelessNetworkDevice = new WirelessNetworkDevice(deviceObjectPath, this);
|
||||||
qCDebug(dcNetworkManager()) << "[+]" << wirelessNetworkDevice;
|
qCDebug(dcNetworkManager()) << "[+]" << wirelessNetworkDevice;
|
||||||
m_wifiAvailable = true;
|
m_wifiAvailable = true;
|
||||||
@ -324,7 +329,7 @@ void NetworkManager::onDeviceAdded(const QDBusObjectPath &deviceObjectPath)
|
|||||||
emit wirelessDeviceAdded(wirelessNetworkDevice);
|
emit wirelessDeviceAdded(wirelessNetworkDevice);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NetworkDevice::DeviceTypeEthernet: {
|
case NetworkDevice::NetworkDeviceTypeEthernet: {
|
||||||
WiredNetworkDevice *wiredNetworkDevice = new WiredNetworkDevice(deviceObjectPath, this);
|
WiredNetworkDevice *wiredNetworkDevice = new WiredNetworkDevice(deviceObjectPath, this);
|
||||||
qCDebug(dcNetworkManager()) << "[+]" << wiredNetworkDevice;
|
qCDebug(dcNetworkManager()) << "[+]" << wiredNetworkDevice;
|
||||||
m_networkDevices.insert(deviceObjectPath, wiredNetworkDevice);
|
m_networkDevices.insert(deviceObjectPath, wiredNetworkDevice);
|
||||||
|
|||||||
@ -53,6 +53,11 @@ QDBusObjectPath NetworkSettings::addConnection(const ConnectionSettings &setting
|
|||||||
return query.arguments().at(0).value<QDBusObjectPath>();
|
return query.arguments().at(0).value<QDBusObjectPath>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<NetworkConnection *> NetworkSettings::connections() const
|
||||||
|
{
|
||||||
|
return m_connections.values();
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkSettings::loadConnections()
|
void NetworkSettings::loadConnections()
|
||||||
{
|
{
|
||||||
QDBusMessage query = m_settingsInterface->call("ListConnections");
|
QDBusMessage query = m_settingsInterface->call("ListConnections");
|
||||||
@ -79,13 +84,14 @@ void NetworkSettings::connectionAdded(const QDBusObjectPath &objectPath)
|
|||||||
NetworkConnection *connection = new NetworkConnection(objectPath, this);
|
NetworkConnection *connection = new NetworkConnection(objectPath, this);
|
||||||
m_connections.insert(objectPath, connection);
|
m_connections.insert(objectPath, connection);
|
||||||
|
|
||||||
//qCDebug(dcNetworkManager()) << "Settings: [+]" << connection;
|
qCDebug(dcNetworkManager()) << "Settings: [+]" << connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkSettings::connectionRemoved(const QDBusObjectPath &objectPath)
|
void NetworkSettings::connectionRemoved(const QDBusObjectPath &objectPath)
|
||||||
{
|
{
|
||||||
Q_UNUSED(objectPath);
|
NetworkConnection *connection = m_connections.take(objectPath);
|
||||||
//qCDebug(dcNetworkManager()) << "Settings: [-]" << objectPath.path();
|
qCDebug(dcNetworkManager()) << "Settings: [-]" << connection;
|
||||||
|
connection->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkSettings::propertiesChanged(const QVariantMap &properties)
|
void NetworkSettings::propertiesChanged(const QVariantMap &properties)
|
||||||
|
|||||||
@ -40,6 +40,7 @@ public:
|
|||||||
explicit NetworkSettings(QObject *parent = 0);
|
explicit NetworkSettings(QObject *parent = 0);
|
||||||
|
|
||||||
QDBusObjectPath addConnection(const ConnectionSettings &settings);
|
QDBusObjectPath addConnection(const ConnectionSettings &settings);
|
||||||
|
QList<NetworkConnection *> connections() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDBusInterface *m_settingsInterface;
|
QDBusInterface *m_settingsInterface;
|
||||||
|
|||||||
@ -26,7 +26,8 @@ namespace guhserver {
|
|||||||
|
|
||||||
WirelessAccessPoint::WirelessAccessPoint(const QDBusObjectPath &objectPath, QObject *parent) :
|
WirelessAccessPoint::WirelessAccessPoint(const QDBusObjectPath &objectPath, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_objectPath(objectPath)
|
m_objectPath(objectPath),
|
||||||
|
m_securityFlags(0)
|
||||||
{
|
{
|
||||||
QDBusInterface accessPointInterface(serviceString, m_objectPath.path(), accessPointInterfaceString, QDBusConnection::systemBus());
|
QDBusInterface accessPointInterface(serviceString, m_objectPath.path(), accessPointInterfaceString, QDBusConnection::systemBus());
|
||||||
if(!accessPointInterface.isValid()) {
|
if(!accessPointInterface.isValid()) {
|
||||||
@ -40,6 +41,7 @@ WirelessAccessPoint::WirelessAccessPoint(const QDBusObjectPath &objectPath, QObj
|
|||||||
setFrequency(accessPointInterface.property("Frequency").toDouble() / 1000);
|
setFrequency(accessPointInterface.property("Frequency").toDouble() / 1000);
|
||||||
setSignalStrength(accessPointInterface.property("Strength").toUInt());
|
setSignalStrength(accessPointInterface.property("Strength").toUInt());
|
||||||
setSecurityFlags(WirelessAccessPoint::ApSecurityModes(accessPointInterface.property("WpaFlags").toUInt()));
|
setSecurityFlags(WirelessAccessPoint::ApSecurityModes(accessPointInterface.property("WpaFlags").toUInt()));
|
||||||
|
setIsProtected((bool)accessPointInterface.property("Flags").toUInt());
|
||||||
|
|
||||||
QDBusConnection::systemBus().connect(serviceString, objectPath.path(), accessPointInterfaceString, "PropertiesChanged", this, SLOT(onPropertiesChanged(QVariantMap)));
|
QDBusConnection::systemBus().connect(serviceString, objectPath.path(), accessPointInterfaceString, "PropertiesChanged", this, SLOT(onPropertiesChanged(QVariantMap)));
|
||||||
}
|
}
|
||||||
@ -90,6 +92,16 @@ void WirelessAccessPoint::setSignalStrength(const int &signalStrength)
|
|||||||
emit signalStrengthChanged();
|
emit signalStrengthChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WirelessAccessPoint::setIsProtected(const bool &isProtected)
|
||||||
|
{
|
||||||
|
m_isProtected = isProtected;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WirelessAccessPoint::isProtected() const
|
||||||
|
{
|
||||||
|
return m_isProtected;
|
||||||
|
}
|
||||||
|
|
||||||
WirelessAccessPoint::ApSecurityModes WirelessAccessPoint::securityFlags() const
|
WirelessAccessPoint::ApSecurityModes WirelessAccessPoint::securityFlags() const
|
||||||
{
|
{
|
||||||
return m_securityFlags;
|
return m_securityFlags;
|
||||||
@ -109,7 +121,7 @@ void WirelessAccessPoint::onPropertiesChanged(const QVariantMap &properties)
|
|||||||
|
|
||||||
QDebug operator<<(QDebug debug, WirelessAccessPoint *accessPoint)
|
QDebug operator<<(QDebug debug, WirelessAccessPoint *accessPoint)
|
||||||
{
|
{
|
||||||
return debug.nospace() << "AccessPoint(" << accessPoint->signalStrength() << "%, " << accessPoint->frequency()<< " GHz, " << accessPoint->ssid() << ")";
|
return debug.nospace() << "AccessPoint(" << accessPoint->signalStrength() << "%, " << accessPoint->frequency()<< " GHz, " << accessPoint->ssid() << ", " << (accessPoint->isProtected() ? "protected" : "open" ) << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,16 +58,10 @@ public:
|
|||||||
QDBusObjectPath objectPath() const;
|
QDBusObjectPath objectPath() const;
|
||||||
|
|
||||||
QString ssid() const;
|
QString ssid() const;
|
||||||
void setSsid(const QString &ssid);
|
|
||||||
|
|
||||||
QString macAddress() const;
|
QString macAddress() const;
|
||||||
void setMacAddress(const QString &macAddress);
|
|
||||||
|
|
||||||
double frequency() const;
|
double frequency() const;
|
||||||
void setFrequency(const double &frequency);
|
|
||||||
|
|
||||||
int signalStrength() const;
|
int signalStrength() const;
|
||||||
void setSignalStrength(const int &signalStrength);
|
bool isProtected() const;
|
||||||
|
|
||||||
WirelessAccessPoint::ApSecurityModes securityFlags() const;
|
WirelessAccessPoint::ApSecurityModes securityFlags() const;
|
||||||
void setSecurityFlags(const WirelessAccessPoint::ApSecurityModes &securityFlags);
|
void setSecurityFlags(const WirelessAccessPoint::ApSecurityModes &securityFlags);
|
||||||
@ -78,8 +72,15 @@ private:
|
|||||||
QString m_macAddress;
|
QString m_macAddress;
|
||||||
double m_frequency;
|
double m_frequency;
|
||||||
int m_signalStrength;
|
int m_signalStrength;
|
||||||
|
bool m_isProtected;
|
||||||
WirelessAccessPoint::ApSecurityModes m_securityFlags;
|
WirelessAccessPoint::ApSecurityModes m_securityFlags;
|
||||||
|
|
||||||
|
void setSsid(const QString &ssid);
|
||||||
|
void setMacAddress(const QString &macAddress);
|
||||||
|
void setFrequency(const double &frequency);
|
||||||
|
void setSignalStrength(const int &signalStrength);
|
||||||
|
void setIsProtected(const bool &isProtected);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalStrengthChanged();
|
void signalStrengthChanged();
|
||||||
|
|
||||||
|
|||||||
@ -126,15 +126,28 @@ void WirelessNetworkDevice::setMacAddress(const QString &macAddress)
|
|||||||
|
|
||||||
void WirelessNetworkDevice::setBitrate(const int &bitRate)
|
void WirelessNetworkDevice::setBitrate(const int &bitRate)
|
||||||
{
|
{
|
||||||
m_bitRate = bitRate / 1000;
|
if (m_bitRate != bitRate / 1000) {
|
||||||
|
m_bitRate = bitRate / 1000;
|
||||||
|
emit deviceChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WirelessNetworkDevice::setActiveAccessPoint(const QDBusObjectPath &activeAccessPointObjectPath)
|
void WirelessNetworkDevice::setActiveAccessPoint(const QDBusObjectPath &activeAccessPointObjectPath)
|
||||||
{
|
{
|
||||||
if (m_accessPointsTable.contains(activeAccessPointObjectPath)) {
|
if (m_activeAccessPointObjectPath != activeAccessPointObjectPath) {
|
||||||
m_activeAccessPoint = m_accessPointsTable.value(activeAccessPointObjectPath);
|
m_activeAccessPointObjectPath = activeAccessPointObjectPath;
|
||||||
} else {
|
if (m_accessPointsTable.contains(m_activeAccessPointObjectPath)) {
|
||||||
m_activeAccessPoint = Q_NULLPTR;
|
if (m_activeAccessPoint)
|
||||||
|
disconnect(m_activeAccessPoint, &WirelessAccessPoint::signalStrengthChanged, this, &WirelessNetworkDevice::deviceChanged);
|
||||||
|
|
||||||
|
// Set new access point object
|
||||||
|
m_activeAccessPoint = m_accessPointsTable.value(activeAccessPointObjectPath);
|
||||||
|
// Update the device when the signalstrength changed
|
||||||
|
connect(m_activeAccessPoint, &WirelessAccessPoint::signalStrengthChanged, this, &WirelessNetworkDevice::deviceChanged);
|
||||||
|
} else {
|
||||||
|
m_activeAccessPoint = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
emit deviceChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,8 +191,6 @@ void WirelessNetworkDevice::propertiesChanged(const QVariantMap &properties)
|
|||||||
|
|
||||||
if (properties.contains("ActiveAccessPoint"))
|
if (properties.contains("ActiveAccessPoint"))
|
||||||
setActiveAccessPoint(qdbus_cast<QDBusObjectPath>(properties.value("ActiveAccessPoint")));
|
setActiveAccessPoint(qdbus_cast<QDBusObjectPath>(properties.value("ActiveAccessPoint")));
|
||||||
|
|
||||||
emit deviceChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, WirelessNetworkDevice *manager)
|
QDebug operator<<(QDebug debug, WirelessNetworkDevice *manager)
|
||||||
|
|||||||
@ -60,6 +60,7 @@ private:
|
|||||||
QString m_macAddress;
|
QString m_macAddress;
|
||||||
int m_bitRate;
|
int m_bitRate;
|
||||||
WirelessAccessPoint *m_activeAccessPoint;
|
WirelessAccessPoint *m_activeAccessPoint;
|
||||||
|
QDBusObjectPath m_activeAccessPointObjectPath;
|
||||||
|
|
||||||
QHash<QDBusObjectPath, WirelessAccessPoint *> m_accessPointsTable;
|
QHash<QDBusObjectPath, WirelessAccessPoint *> m_accessPointsTable;
|
||||||
|
|
||||||
|
|||||||
@ -1108,6 +1108,21 @@
|
|||||||
"LoggingSourceStates",
|
"LoggingSourceStates",
|
||||||
"LoggingSourceRules"
|
"LoggingSourceRules"
|
||||||
],
|
],
|
||||||
|
"NetworkDeviceState": [
|
||||||
|
"NetworkDeviceStateUnknown",
|
||||||
|
"NetworkDeviceStateUnmanaged",
|
||||||
|
"NetworkDeviceStateUnavailable",
|
||||||
|
"NetworkDeviceStateDisconnected",
|
||||||
|
"NetworkDeviceStatePrepare",
|
||||||
|
"NetworkDeviceStateConfig",
|
||||||
|
"NetworkDeviceStateNeedAuth",
|
||||||
|
"NetworkDeviceStateIpConfig",
|
||||||
|
"NetworkDeviceStateIpCheck",
|
||||||
|
"NetworkDeviceStateSecondaries",
|
||||||
|
"NetworkDeviceStateActivated",
|
||||||
|
"NetworkDeviceStateDeactivating",
|
||||||
|
"NetworkDeviceStateFailed"
|
||||||
|
],
|
||||||
"NetworkManagerError": [
|
"NetworkManagerError": [
|
||||||
"NetworkManagerErrorNoError",
|
"NetworkManagerErrorNoError",
|
||||||
"NetworkManagerErrorUnknownError",
|
"NetworkManagerErrorUnknownError",
|
||||||
@ -1372,6 +1387,7 @@
|
|||||||
"WirelessAccessPoint": {
|
"WirelessAccessPoint": {
|
||||||
"frequency": "Double",
|
"frequency": "Double",
|
||||||
"macAddress": "String",
|
"macAddress": "String",
|
||||||
|
"protected": "Bool",
|
||||||
"signalStrength": "Int",
|
"signalStrength": "Int",
|
||||||
"ssid": "String"
|
"ssid": "String"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user