Add support for configuring the wired network
This commit is contained in:
parent
15539812b7
commit
e1f01118ed
5
debian/changelog
vendored
5
debian/changelog
vendored
@ -1,3 +1,8 @@
|
|||||||
|
libnymea-networkmanager (1.5.0) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
|
||||||
|
-- jenkins <developer@nymea.io> Fri, 23 Sep 2022 16:33:36 +0200
|
||||||
|
|
||||||
libnymea-networkmanager (1.4.1) jammy; urgency=medium
|
libnymea-networkmanager (1.4.1) jammy; urgency=medium
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -183,13 +183,22 @@ public:
|
|||||||
QDBusObjectPath ip4Config() const;
|
QDBusObjectPath ip4Config() const;
|
||||||
QList<QDBusObjectPath> availableConnections() const;
|
QList<QDBusObjectPath> availableConnections() const;
|
||||||
|
|
||||||
// Method
|
|
||||||
void disconnectDevice();
|
void disconnectDevice();
|
||||||
|
|
||||||
static QString deviceTypeToString(const NetworkDeviceType &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);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void deviceChanged();
|
||||||
|
void stateChanged(const NetworkDeviceState &state);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onStateChanged(uint newState, uint oldState, uint reason);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList readIpAddresses(const QString &property, const QString &interface);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDBusInterface *m_networkDeviceInterface = nullptr;
|
QDBusInterface *m_networkDeviceInterface = nullptr;
|
||||||
QDBusObjectPath m_objectPath;
|
QDBusObjectPath m_objectPath;
|
||||||
@ -215,17 +224,6 @@ private:
|
|||||||
|
|
||||||
QList<QDBusObjectPath> m_availableConnections;
|
QList<QDBusObjectPath> m_availableConnections;
|
||||||
|
|
||||||
private:
|
|
||||||
QStringList readIpAddresses(const QString &property, const QString &interface);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onStateChanged(uint newState, uint oldState, uint reason);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void deviceChanged();
|
|
||||||
void stateChanged(const NetworkDeviceState &state);
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, NetworkDevice *device);
|
QDebug operator<<(QDebug debug, NetworkDevice *device);
|
||||||
|
|||||||
@ -46,6 +46,8 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
/*! Constructs a new \l{NetworkManager} object with the given \a parent. */
|
/*! Constructs a new \l{NetworkManager} object with the given \a parent. */
|
||||||
NetworkManager::NetworkManager(QObject *parent) :
|
NetworkManager::NetworkManager(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
@ -222,7 +224,7 @@ NetworkManager::NetworkManagerError NetworkManager::connectWifi(const QString &i
|
|||||||
|
|
||||||
NetworkManager::NetworkManagerError NetworkManager::startAccessPoint(const QString &interface, const QString &ssid, const QString &password)
|
NetworkManager::NetworkManagerError NetworkManager::startAccessPoint(const QString &interface, const QString &ssid, const QString &password)
|
||||||
{
|
{
|
||||||
qCDebug(dcNetworkManager()) << "Start an access point for" << interface << "SSID:" << ssid << "password:" << password;
|
qCDebug(dcNetworkManager()) << "Starting access point for" << interface << "SSID:" << ssid << "password:" << password;
|
||||||
|
|
||||||
// Check interface
|
// Check interface
|
||||||
if (!getNetworkDevice(interface))
|
if (!getNetworkDevice(interface))
|
||||||
@ -303,6 +305,224 @@ NetworkManager::NetworkManagerError NetworkManager::startAccessPoint(const QStri
|
|||||||
return NetworkManagerErrorNoError;
|
return NetworkManagerErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkManager::NetworkManagerError NetworkManager::createWiredAutoConnection(const QString &interface)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Creating auto connection for" << interface;
|
||||||
|
|
||||||
|
NetworkDevice *networkDevice = getNetworkDevice(interface);
|
||||||
|
if (!networkDevice) {
|
||||||
|
return NetworkManagerErrorNetworkInterfaceNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap ethernetMode {
|
||||||
|
{"duplex", "full"}
|
||||||
|
};
|
||||||
|
|
||||||
|
QVariantMap connectionSettings {
|
||||||
|
{"id", "auto"},
|
||||||
|
{"autoconnect", true},
|
||||||
|
{"uuid", QUuid::createUuid().toString().remove(QRegExp("[{}]"))},
|
||||||
|
{"type", "802-3-ethernet"}
|
||||||
|
};
|
||||||
|
|
||||||
|
QVariantMap ipv4Settings {
|
||||||
|
{"method", "auto"}
|
||||||
|
};
|
||||||
|
|
||||||
|
QVariantMap ipv6Settings {
|
||||||
|
{"method", "auto"}
|
||||||
|
};
|
||||||
|
|
||||||
|
ConnectionSettings settings;
|
||||||
|
settings.insert("connection", connectionSettings);
|
||||||
|
settings.insert("ipv4", ipv4Settings);
|
||||||
|
settings.insert("ipv6", ipv6Settings);
|
||||||
|
settings.insert("802-3-ethernet", ethernetMode);
|
||||||
|
|
||||||
|
// Remove old configuration (if there is any)
|
||||||
|
foreach (NetworkConnection *connection, m_networkSettings->connections()) {
|
||||||
|
if (connection->id() == connectionSettings.value("id")) {
|
||||||
|
connection->deleteConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add connection
|
||||||
|
QDBusObjectPath connectionObjectPath = m_networkSettings->addConnection(settings);
|
||||||
|
if (connectionObjectPath.path().isEmpty())
|
||||||
|
return NetworkManagerErrorUnknownError;
|
||||||
|
|
||||||
|
|
||||||
|
qCDebug(dcNetworkManager()) << "Connection added" << connectionObjectPath.path();
|
||||||
|
|
||||||
|
// Activate connection
|
||||||
|
QDBusMessage query = m_networkManagerInterface->call("ActivateConnection",
|
||||||
|
QVariant::fromValue(connectionObjectPath),
|
||||||
|
QVariant::fromValue(networkDevice->objectPath()),
|
||||||
|
QVariant::fromValue(QDBusObjectPath("/")));
|
||||||
|
if (query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();
|
||||||
|
return NetworkManagerErrorUnknownError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NetworkManagerErrorNoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkManager::NetworkManagerError NetworkManager::createWiredManualConnection(const QString &interface, const QHostAddress &ip, quint8 prefix, const QHostAddress &gateway, const QHostAddress &dns)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Creating manual connection for" << interface << ip << prefix << gateway << dns;
|
||||||
|
|
||||||
|
NetworkDevice *networkDevice = getNetworkDevice(interface);
|
||||||
|
if (!networkDevice) {
|
||||||
|
return NetworkManagerErrorNetworkInterfaceNotFound;
|
||||||
|
}
|
||||||
|
if (ip.isNull() || prefix < 8) {
|
||||||
|
return NetworkManagerErrorInvalidConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap ethernetMode {
|
||||||
|
{"duplex", "full"}
|
||||||
|
};
|
||||||
|
|
||||||
|
QVariantMap connectionSettings {
|
||||||
|
{"id", "manual"},
|
||||||
|
{"autoconnect", true},
|
||||||
|
{"uuid", QUuid::createUuid().toString().remove(QRegExp("[{}]"))},
|
||||||
|
{"type", "802-3-ethernet"}
|
||||||
|
};
|
||||||
|
|
||||||
|
NMIntListList addresses;
|
||||||
|
QList<uint> address;
|
||||||
|
address << inet_addr(ip.toString().toLocal8Bit().data());
|
||||||
|
address << prefix;
|
||||||
|
address << inet_addr(gateway.toString().toLocal8Bit().data());
|
||||||
|
addresses << address;
|
||||||
|
|
||||||
|
NMVariantMapList addressData;
|
||||||
|
addressData.append({{"address", ip.toString()}, {"prefix", prefix}});
|
||||||
|
|
||||||
|
QVariantMap ipv4Settings {
|
||||||
|
{"method", "manual"},
|
||||||
|
{"addresses", QVariant::fromValue(addresses)}, // Deprecated but for our supported platforms still required
|
||||||
|
{"address-data", QVariant::fromValue(addressData)} // New style, but ignored by NM as long as addresses is still supported and given
|
||||||
|
};
|
||||||
|
if (!dns.isNull()) {
|
||||||
|
ipv4Settings.insert("dns", QVariant::fromValue(NMIntList{inet_addr(dns.toString().toLocal8Bit().data())}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is ignored if addresses is given, but it's required once the deprecated addresses entry is removed
|
||||||
|
if (!gateway.isNull()) {
|
||||||
|
ipv4Settings.insert("gateway", gateway.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap ipv6Settings {
|
||||||
|
{"method", "disabled"}
|
||||||
|
};
|
||||||
|
|
||||||
|
ConnectionSettings settings;
|
||||||
|
settings.insert("connection", connectionSettings);
|
||||||
|
settings.insert("ipv4", ipv4Settings);
|
||||||
|
settings.insert("ipv6", ipv6Settings);
|
||||||
|
settings.insert("802-3-ethernet", ethernetMode);
|
||||||
|
|
||||||
|
// Remove old configuration (if there is any)
|
||||||
|
foreach (NetworkConnection *connection, m_networkSettings->connections()) {
|
||||||
|
if (connection->id() == connectionSettings.value("id")) {
|
||||||
|
connection->deleteConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add connection
|
||||||
|
QDBusObjectPath connectionObjectPath = m_networkSettings->addConnection(settings);
|
||||||
|
if (connectionObjectPath.path().isEmpty())
|
||||||
|
return NetworkManagerErrorUnknownError;
|
||||||
|
|
||||||
|
|
||||||
|
qCDebug(dcNetworkManager()) << "Connection added" << connectionObjectPath.path();
|
||||||
|
|
||||||
|
// Activate connection
|
||||||
|
QDBusMessage query = m_networkManagerInterface->call("ActivateConnection",
|
||||||
|
QVariant::fromValue(connectionObjectPath),
|
||||||
|
QVariant::fromValue(networkDevice->objectPath()),
|
||||||
|
QVariant::fromValue(QDBusObjectPath("/")));
|
||||||
|
if (query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();
|
||||||
|
return NetworkManagerErrorUnknownError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NetworkManagerErrorNoError;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkManager::NetworkManagerError NetworkManager::createSharedConnection(const QString &interface, const QHostAddress &ip, quint8 prefix)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Starting shared connection for" << interface;
|
||||||
|
|
||||||
|
NetworkDevice *networkDevice = getNetworkDevice(interface);
|
||||||
|
if (!networkDevice) {
|
||||||
|
return NetworkManagerErrorNetworkInterfaceNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap connectionSettings;
|
||||||
|
connectionSettings.insert("id", "shared");
|
||||||
|
connectionSettings.insert("autoconnect", true);
|
||||||
|
connectionSettings.insert("uuid", QUuid::createUuid().toString().remove("{").remove("}"));
|
||||||
|
connectionSettings.insert("type", "802-3-ethernet");
|
||||||
|
|
||||||
|
NMIntListList addresses;
|
||||||
|
QList<uint> address;
|
||||||
|
address << inet_addr(ip.toString().toLocal8Bit().data());
|
||||||
|
address << prefix;
|
||||||
|
address << 0;
|
||||||
|
addresses << address;
|
||||||
|
|
||||||
|
NMVariantMapList addressData;
|
||||||
|
addressData.append({{"address", ip.toString()}, {"prefix", prefix}});
|
||||||
|
|
||||||
|
QVariantMap ipv4Settings {
|
||||||
|
{"method", "shared"}
|
||||||
|
};
|
||||||
|
if (!ip.isNull()) {
|
||||||
|
ipv4Settings.insert("addresses", QVariant::fromValue(addresses)); // Deprecated but for our supported platforms still required
|
||||||
|
ipv4Settings.insert("address-data", QVariant::fromValue(addressData)); // New style, but ignored by NM as long as addresses is still supported and given
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap ipv6Settings;
|
||||||
|
ipv6Settings.insert("method", "disabled");
|
||||||
|
|
||||||
|
// Build connection object
|
||||||
|
ConnectionSettings settings;
|
||||||
|
settings.insert("connection", connectionSettings);
|
||||||
|
settings.insert("ipv4", ipv4Settings);
|
||||||
|
settings.insert("ipv6", ipv6Settings);
|
||||||
|
|
||||||
|
// Remove old configuration (if there is any)
|
||||||
|
foreach (NetworkConnection *connection, m_networkSettings->connections()) {
|
||||||
|
if (connection->id() == connectionSettings.value("id")) {
|
||||||
|
connection->deleteConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add connection
|
||||||
|
QDBusObjectPath connectionObjectPath = m_networkSettings->addConnection(settings);
|
||||||
|
if (connectionObjectPath.path().isEmpty())
|
||||||
|
return NetworkManagerErrorUnknownError;
|
||||||
|
|
||||||
|
|
||||||
|
qCDebug(dcNetworkManager()) << "Connection added" << connectionObjectPath.path();
|
||||||
|
|
||||||
|
// Activate connection
|
||||||
|
QDBusMessage query = m_networkManagerInterface->call("ActivateConnection",
|
||||||
|
QVariant::fromValue(connectionObjectPath),
|
||||||
|
QVariant::fromValue(networkDevice->objectPath()),
|
||||||
|
QVariant::fromValue(QDBusObjectPath("/")));
|
||||||
|
if (query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();
|
||||||
|
return NetworkManagerErrorUnknownError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NetworkManagerErrorNoError;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns true if the networking of this \l{NetworkManager} is enabled. */
|
/*! Returns true if the networking of this \l{NetworkManager} is enabled. */
|
||||||
bool NetworkManager::networkingEnabled() const
|
bool NetworkManager::networkingEnabled() const
|
||||||
{
|
{
|
||||||
@ -630,13 +850,13 @@ void NetworkManager::onPropertiesChanged(const QVariantMap &properties)
|
|||||||
|
|
||||||
void NetworkManager::onWirelessDeviceChanged()
|
void NetworkManager::onWirelessDeviceChanged()
|
||||||
{
|
{
|
||||||
WirelessNetworkDevice *networkDevice = static_cast<WirelessNetworkDevice *>(sender());
|
WirelessNetworkDevice *networkDevice = qobject_cast<WirelessNetworkDevice *>(sender());
|
||||||
emit wirelessDeviceChanged(networkDevice);
|
emit wirelessDeviceChanged(networkDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::onWiredDeviceChanged()
|
void NetworkManager::onWiredDeviceChanged()
|
||||||
{
|
{
|
||||||
WiredNetworkDevice *networkDevice = static_cast<WiredNetworkDevice *>(sender());
|
WiredNetworkDevice *networkDevice = qobject_cast<WiredNetworkDevice *>(sender());
|
||||||
emit wiredDeviceChanged(networkDevice);
|
emit wiredDeviceChanged(networkDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusServiceWatcher>
|
#include <QDBusServiceWatcher>
|
||||||
|
#include <QHostAddress>
|
||||||
|
|
||||||
#include "networksettings.h"
|
#include "networksettings.h"
|
||||||
#include "wirednetworkdevice.h"
|
#include "wirednetworkdevice.h"
|
||||||
@ -85,7 +86,8 @@ public:
|
|||||||
NetworkManagerErrorWirelessNetworkingDisabled,
|
NetworkManagerErrorWirelessNetworkingDisabled,
|
||||||
NetworkManagerErrorWirelessConnectionFailed,
|
NetworkManagerErrorWirelessConnectionFailed,
|
||||||
NetworkManagerErrorNetworkingDisabled,
|
NetworkManagerErrorNetworkingDisabled,
|
||||||
NetworkManagerErrorNetworkManagerNotAvailable
|
NetworkManagerErrorNetworkManagerNotAvailable,
|
||||||
|
NetworkManagerErrorInvalidConfiguration,
|
||||||
};
|
};
|
||||||
Q_ENUM(NetworkManagerError)
|
Q_ENUM(NetworkManagerError)
|
||||||
|
|
||||||
@ -110,6 +112,9 @@ public:
|
|||||||
|
|
||||||
NetworkManagerError connectWifi(const QString &interface, const QString &ssid, const QString &password, bool hidden = false);
|
NetworkManagerError connectWifi(const QString &interface, const QString &ssid, const QString &password, bool hidden = false);
|
||||||
NetworkManagerError startAccessPoint(const QString &interface, const QString &ssid, const QString &password);
|
NetworkManagerError startAccessPoint(const QString &interface, const QString &ssid, const QString &password);
|
||||||
|
NetworkManagerError createWiredAutoConnection(const QString &interface);
|
||||||
|
NetworkManagerError createWiredManualConnection(const QString &interface, const QHostAddress &ip, quint8 prefix, const QHostAddress &gateway, const QHostAddress &dns);
|
||||||
|
NetworkManagerError createSharedConnection(const QString& interface, const QHostAddress &ip, quint8 prefix);
|
||||||
|
|
||||||
// Networking
|
// Networking
|
||||||
bool networkingEnabled() const;
|
bool networkingEnabled() const;
|
||||||
|
|||||||
@ -46,6 +46,10 @@
|
|||||||
NetworkSettings::NetworkSettings(QObject *parent) :
|
NetworkSettings::NetworkSettings(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
|
qDBusRegisterMetaType<NMVariantMapList>();
|
||||||
|
qDBusRegisterMetaType<NMIntListList>();
|
||||||
|
qDBusRegisterMetaType<NMIntList>();
|
||||||
|
|
||||||
m_settingsInterface = new QDBusInterface(NetworkManagerUtils::networkManagerServiceString(), NetworkManagerUtils::settingsPathString(), NetworkManagerUtils::settingsInterfaceString(), QDBusConnection::systemBus(), this);
|
m_settingsInterface = new QDBusInterface(NetworkManagerUtils::networkManagerServiceString(), NetworkManagerUtils::settingsPathString(), NetworkManagerUtils::settingsInterfaceString(), QDBusConnection::systemBus(), this);
|
||||||
if(!m_settingsInterface->isValid()) {
|
if(!m_settingsInterface->isValid()) {
|
||||||
qCWarning(dcNetworkManager()) << "Invalid DBus network settings interface";
|
qCWarning(dcNetworkManager()) << "Invalid DBus network settings interface";
|
||||||
|
|||||||
@ -41,6 +41,15 @@
|
|||||||
|
|
||||||
class NetworkConnection;
|
class NetworkConnection;
|
||||||
|
|
||||||
|
typedef QList<QVariantMap> NMVariantMapList;
|
||||||
|
Q_DECLARE_METATYPE(NMVariantMapList)
|
||||||
|
|
||||||
|
typedef QList<QList<uint>> NMIntListList;
|
||||||
|
Q_DECLARE_METATYPE(NMIntListList)
|
||||||
|
|
||||||
|
typedef QList<uint> NMIntList;
|
||||||
|
Q_DECLARE_METATYPE(NMIntList)
|
||||||
|
|
||||||
class NetworkSettings : public QObject
|
class NetworkSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@ -58,11 +58,11 @@ WiredNetworkDevice::WiredNetworkDevice(const QDBusObjectPath &objectPath, QObjec
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setMacAddress(m_wiredInterface->property("HwAddress").toString());
|
m_macAddress = m_wiredInterface->property("HwAddress").toString();
|
||||||
setBitRate(m_wiredInterface->property("Bitrate").toInt());
|
m_bitRate = m_wiredInterface->property("Bitrate").toInt();
|
||||||
setPluggedIn(m_wiredInterface->property("Carrier").toBool());
|
m_pluggedIn = m_wiredInterface->property("Carrier").toBool();
|
||||||
|
|
||||||
QDBusConnection::systemBus().connect(NetworkManagerUtils::networkManagerServiceString(), this->objectPath().path(), NetworkManagerUtils::wiredInterfaceString(), "PropertiesChanged", this, SLOT(propertiesChanged(QVariantMap)));
|
QDBusConnection::systemBus().connect(NetworkManagerUtils::networkManagerServiceString(), this->objectPath().path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(propertiesChanged(QString, QVariantMap, QStringList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Returns the mac address of this \l{WiredNetworkDevice}. */
|
/*! Returns the mac address of this \l{WiredNetworkDevice}. */
|
||||||
@ -83,26 +83,16 @@ bool WiredNetworkDevice::pluggedIn() const
|
|||||||
return m_pluggedIn;
|
return m_pluggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiredNetworkDevice::setMacAddress(const QString &macAddress)
|
void WiredNetworkDevice::propertiesChanged(const QString &interface_name, const QVariantMap &changed_properties, const QStringList &invalidated_properties)
|
||||||
{
|
{
|
||||||
m_macAddress = macAddress;
|
Q_UNUSED(interface_name)
|
||||||
}
|
Q_UNUSED(invalidated_properties)
|
||||||
|
if (changed_properties.contains("Carrier")) {
|
||||||
void WiredNetworkDevice::setBitRate(int bitRate)
|
m_pluggedIn = changed_properties.value("Carrier").toBool();
|
||||||
{
|
emit pluggedInChanged(m_pluggedIn);
|
||||||
m_bitRate = bitRate;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void WiredNetworkDevice::setPluggedIn(bool pluggedIn)
|
|
||||||
{
|
|
||||||
m_pluggedIn = pluggedIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WiredNetworkDevice::propertiesChanged(const QVariantMap &properties)
|
|
||||||
{
|
|
||||||
if (properties.contains("Carrier"))
|
|
||||||
setPluggedIn(properties.value("Carrier").toBool());
|
|
||||||
|
|
||||||
|
emit deviceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, WiredNetworkDevice *networkDevice)
|
QDebug operator<<(QDebug debug, WiredNetworkDevice *networkDevice)
|
||||||
|
|||||||
@ -46,6 +46,12 @@ public:
|
|||||||
int bitRate() const;
|
int bitRate() const;
|
||||||
bool pluggedIn() const;
|
bool pluggedIn() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void pluggedInChanged(bool pluggedIn);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void propertiesChanged(const QString &interface_name, const QVariantMap &changed_properties, const QStringList &invalidated_properties);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDBusInterface *m_wiredInterface = nullptr;
|
QDBusInterface *m_wiredInterface = nullptr;
|
||||||
|
|
||||||
@ -53,13 +59,6 @@ private:
|
|||||||
int m_bitRate = 0;
|
int m_bitRate = 0;
|
||||||
bool m_pluggedIn = false;
|
bool m_pluggedIn = false;
|
||||||
|
|
||||||
void setMacAddress(const QString &macAddress);
|
|
||||||
void setBitRate(int bitRate);
|
|
||||||
void setPluggedIn(bool pluggedIn);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void propertiesChanged(const QVariantMap &properties);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, WiredNetworkDevice *networkDevice);
|
QDebug operator<<(QDebug debug, WiredNetworkDevice *networkDevice);
|
||||||
|
|||||||
@ -219,28 +219,31 @@ void WirelessNetworkDevice::accessPointRemoved(const QDBusObjectPath &objectPath
|
|||||||
accessPoint->deleteLater();
|
accessPoint->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WirelessNetworkDevice::propertiesChanged(const QVariantMap &properties)
|
void WirelessNetworkDevice::propertiesChanged(const QString &interface_name, const QVariantMap &changed_properties, const QStringList &invalidated_properties)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(interface_name)
|
||||||
|
Q_UNUSED(invalidated_properties)
|
||||||
|
|
||||||
//qCDebug(dcNetworkManager()) << "WirelessNetworkDevice: Property changed" << properties;
|
//qCDebug(dcNetworkManager()) << "WirelessNetworkDevice: Property changed" << properties;
|
||||||
|
|
||||||
if (properties.contains("Bitrate")) {
|
if (changed_properties.contains("Bitrate")) {
|
||||||
m_bitRate = properties.value("Bitrate").toInt() / 1000;
|
m_bitRate = changed_properties.value("Bitrate").toInt() / 1000;
|
||||||
emit bitRateChanged(m_bitRate);
|
emit bitRateChanged(m_bitRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.contains("Mode")) {
|
if (changed_properties.contains("Mode")) {
|
||||||
m_wirelessMode = static_cast<WirelessMode>(m_wirelessInterface->property("Mode").toUInt());
|
m_wirelessMode = static_cast<WirelessMode>(m_wirelessInterface->property("Mode").toUInt());
|
||||||
emit wirelessModeChanged(m_wirelessMode);
|
emit wirelessModeChanged(m_wirelessMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: available since 1.12 (-1 means never scanned)
|
// Note: available since 1.12 (-1 means never scanned)
|
||||||
if (properties.contains("LastScan")) {
|
if (changed_properties.contains("LastScan")) {
|
||||||
m_lastScan = m_wirelessInterface->property("LastScan").toInt();
|
m_lastScan = m_wirelessInterface->property("LastScan").toInt();
|
||||||
emit lastScanChanged(m_lastScan);
|
emit lastScanChanged(m_lastScan);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.contains("ActiveAccessPoint")) {
|
if (changed_properties.contains("ActiveAccessPoint")) {
|
||||||
setActiveAccessPoint(qdbus_cast<QDBusObjectPath>(properties.value("ActiveAccessPoint")));
|
setActiveAccessPoint(qdbus_cast<QDBusObjectPath>(changed_properties.value("ActiveAccessPoint")));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit deviceChanged();
|
emit deviceChanged();
|
||||||
|
|||||||
@ -78,7 +78,7 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void accessPointAdded(const QDBusObjectPath &objectPath);
|
void accessPointAdded(const QDBusObjectPath &objectPath);
|
||||||
void accessPointRemoved(const QDBusObjectPath &objectPath);
|
void accessPointRemoved(const QDBusObjectPath &objectPath);
|
||||||
void propertiesChanged(const QVariantMap &properties);
|
void propertiesChanged(const QString &interface_name, const QVariantMap &changed_properties, const QStringList &invalidated_properties);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDBusInterface *m_wirelessInterface = nullptr;
|
QDBusInterface *m_wirelessInterface = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user