7#include "wiredsetting.h"
9#include "wiredsetting_p.h"
13#define NM_SETTING_WIRED_ASSIGNED_MAC_ADDRESS "assigned-mac-address"
15NetworkManager::WiredSettingPrivate::WiredSettingPrivate()
16 : name(NM_SETTING_WIRED_SETTING_NAME)
25 autoNegotiate =
false;
31NetworkManager::WiredSetting::WiredSetting()
32 : Setting(Setting::Wired)
33 , d_ptr(new WiredSettingPrivate())
37NetworkManager::WiredSetting::WiredSetting(
const WiredSetting::Ptr &other)
39 , d_ptr(new WiredSettingPrivate())
41 setPort(other->port());
42 setSpeed(other->speed());
43 setDuplexType(other->duplexType());
44 setAutoNegotiate(other->autoNegotiate());
45 setGenerateMacAddressMask(other->generateMacAddressMask());
46 setMacAddress(other->macAddress());
47 setClonedMacAddress(other->clonedMacAddress());
48 setMacAddressBlacklist(other->macAddressBlacklist());
50 setS390Subchannels(other->s390Subchannels());
51 setS390NetType(other->s390NetType());
52 setS390Options(other->s390Options());
53 setWakeOnLan(other->wakeOnLan());
54 setWakeOnLanPassword(other->wakeOnLanPassword());
55 setAssignedMacAddress(other->assignedMacAddress());
58NetworkManager::WiredSetting::~WiredSetting()
70void NetworkManager::WiredSetting::setPort(NetworkManager::WiredSetting::PortType port)
77NetworkManager::WiredSetting::PortType NetworkManager::WiredSetting::port()
const
79 Q_D(
const WiredSetting);
84void NetworkManager::WiredSetting::setSpeed(quint32 speed)
91quint32 NetworkManager::WiredSetting::speed()
const
93 Q_D(
const WiredSetting);
98void NetworkManager::WiredSetting::setDuplexType(NetworkManager::WiredSetting::DuplexType type)
105NetworkManager::WiredSetting::DuplexType NetworkManager::WiredSetting::duplexType()
const
107 Q_D(
const WiredSetting);
112void NetworkManager::WiredSetting::setAutoNegotiate(
bool autoNegotiate)
116 d->autoNegotiate = autoNegotiate;
119bool NetworkManager::WiredSetting::autoNegotiate()
const
121 Q_D(
const WiredSetting);
123 return d->autoNegotiate;
126QString NetworkManager::WiredSetting::generateMacAddressMask()
const
128 Q_D(
const WiredSetting);
130 return d->generateMacAddressMask;
133void NetworkManager::WiredSetting::setGenerateMacAddressMask(
const QString &mask)
137 d->generateMacAddressMask = mask;
140void NetworkManager::WiredSetting::setMacAddress(
const QByteArray &address)
147QByteArray NetworkManager::WiredSetting::macAddress()
const
149 Q_D(
const WiredSetting);
151 return d->macAddress;
154void NetworkManager::WiredSetting::setClonedMacAddress(
const QByteArray &address)
161QByteArray NetworkManager::WiredSetting::clonedMacAddress()
const
163 Q_D(
const WiredSetting);
165 return d->clonedMacAddress;
168void NetworkManager::WiredSetting::setMacAddressBlacklist(
const QStringList &list)
172 d->macAddressBlacklist =
list;
175QStringList NetworkManager::WiredSetting::macAddressBlacklist()
const
177 Q_D(
const WiredSetting);
179 return d->macAddressBlacklist;
182void NetworkManager::WiredSetting::setMtu(quint32 mtu)
189quint32 NetworkManager::WiredSetting::mtu()
const
191 Q_D(
const WiredSetting);
196void NetworkManager::WiredSetting::setS390Subchannels(
const QStringList &channels)
200 d->s390Subchannels = channels;
203QStringList NetworkManager::WiredSetting::s390Subchannels()
const
205 Q_D(
const WiredSetting);
207 return d->s390Subchannels;
210void NetworkManager::WiredSetting::setS390NetType(NetworkManager::WiredSetting::S390Nettype type)
214 d->s390NetType =
type;
217NetworkManager::WiredSetting::S390Nettype NetworkManager::WiredSetting::s390NetType()
const
219 Q_D(
const WiredSetting);
221 return d->s390NetType;
228 d->s390Options = options;
233 Q_D(
const WiredSetting);
235 return d->s390Options;
240 Q_D(
const WiredSetting);
252QString NetworkManager::WiredSetting::wakeOnLanPassword()
const
254 Q_D(
const WiredSetting);
256 return d->wakeOnLanPassword;
259void NetworkManager::WiredSetting::setWakeOnLanPassword(
const QString &password)
263 d->wakeOnLanPassword = password;
266void NetworkManager::WiredSetting::setAssignedMacAddress(
const QString &assignedMacAddress)
270 d->assignedMacAddress = assignedMacAddress;
273QString NetworkManager::WiredSetting::assignedMacAddress()
const
275 Q_D(
const WiredSetting);
277 return d->assignedMacAddress;
282 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_PORT))) {
287 }
else if (port ==
"aui") {
289 }
else if (port ==
"bnc") {
291 }
else if (port ==
"mii") {
296 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_SPEED))) {
297 setSpeed(setting.value(
QLatin1String(NM_SETTING_WIRED_SPEED)).toUInt());
300 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_DUPLEX))) {
303 if (duplex ==
"half") {
305 }
else if (duplex ==
"full") {
310 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE))) {
311 setAutoNegotiate(setting.value(
QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE)).toBool());
314 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK))) {
315 setGenerateMacAddressMask(setting.value(
QLatin1String(NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK)).toString());
318 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS))) {
319 setMacAddress(setting.value(
QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS)).toByteArray());
322 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_CLONED_MAC_ADDRESS))) {
323 setClonedMacAddress(setting.value(
QLatin1String(NM_SETTING_WIRED_CLONED_MAC_ADDRESS)).toByteArray());
326 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST))) {
327 setMacAddressBlacklist(setting.value(
QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST)).toStringList());
331 setMtu(setting.value(
QLatin1String(NM_SETTING_WIRED_MTU)).toUInt());
334 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_S390_SUBCHANNELS))) {
335 setS390Subchannels(setting.value(
QLatin1String(NM_SETTING_WIRED_S390_SUBCHANNELS)).toStringList());
338 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_S390_NETTYPE))) {
341 if (nettype ==
"qeth") {
342 setS390NetType(Qeth);
343 }
else if (nettype ==
"lcs") {
345 }
else if (nettype ==
"ctc") {
350 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_S390_OPTIONS))) {
352 if (setting.value(
QLatin1String(NM_SETTING_WIRED_S390_OPTIONS)).canConvert<QDBusArgument>()) {
354 tmp = qdbus_cast<NMStringMap>(arg);
361 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN))) {
365 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD))) {
366 setWakeOnLanPassword(setting.value(
QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD)).toString());
369 if (setting.contains(
QLatin1String(NM_SETTING_WIRED_ASSIGNED_MAC_ADDRESS))) {
370 setAssignedMacAddress(setting.value(
QLatin1String(NM_SETTING_WIRED_ASSIGNED_MAC_ADDRESS)).toString());
397 if (autoNegotiate()) {
398 setting.insert(
QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE), autoNegotiate());
400 setting.insert(
QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE), autoNegotiate());
401 setting.insert(
QLatin1String(NM_SETTING_WIRED_SPEED), speed());
403 switch (duplexType()) {
405 setting.insert(
QLatin1String(NM_SETTING_WIRED_DUPLEX),
"half");
408 setting.insert(
QLatin1String(NM_SETTING_WIRED_DUPLEX),
"full");
410 case UnknownDuplexType:
415 if (!generateMacAddressMask().isEmpty()) {
416 setting.insert(
QLatin1String(NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK), generateMacAddressMask());
419 if (!macAddress().isEmpty()) {
420 setting.insert(
QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS), macAddress());
422 if (!clonedMacAddress().isEmpty()) {
423 setting.insert(
QLatin1String(NM_SETTING_WIRED_CLONED_MAC_ADDRESS), clonedMacAddress());
425 if (!macAddressBlacklist().isEmpty()) {
426 setting.insert(
QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST), macAddressBlacklist());
431 if (!s390Subchannels().isEmpty()) {
432 setting.insert(
QLatin1String(NM_SETTING_WIRED_S390_SUBCHANNELS), s390Subchannels());
435 switch (s390NetType()) {
437 setting.insert(
QLatin1String(NM_SETTING_WIRED_S390_NETTYPE),
"qeth");
440 setting.insert(
QLatin1String(NM_SETTING_WIRED_S390_NETTYPE),
"lcs");
443 setting.insert(
QLatin1String(NM_SETTING_WIRED_S390_NETTYPE),
"ctc");
449 if (!s390Options().isEmpty()) {
453 setting.insert(
QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN), (uint)wakeOnLan());
455 if (!wakeOnLanPassword().isEmpty()) {
456 setting.insert(
QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD), wakeOnLanPassword());
459 if (!assignedMacAddress().isEmpty()) {
460 setting.insert(
QLatin1String(NM_SETTING_WIRED_ASSIGNED_MAC_ADDRESS), assignedMacAddress());
468 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
469 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
471 dbg.
nospace() << NM_SETTING_WIRED_PORT <<
": " << setting.port() <<
'\n';
472 dbg.
nospace() << NM_SETTING_WIRED_SPEED <<
": " << setting.speed() <<
'\n';
473 dbg.
nospace() << NM_SETTING_WIRED_DUPLEX <<
": " << setting.duplexType() <<
'\n';
474 dbg.
nospace() << NM_SETTING_WIRED_AUTO_NEGOTIATE <<
": " << setting.autoNegotiate() <<
'\n';
475 dbg.
nospace() << NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK <<
": " << setting.generateMacAddressMask() <<
'\n';
476 dbg.
nospace() << NM_SETTING_WIRED_MAC_ADDRESS <<
": " << setting.macAddress() <<
'\n';
477 dbg.
nospace() << NM_SETTING_WIRED_CLONED_MAC_ADDRESS <<
": " << setting.clonedMacAddress() <<
'\n';
478 dbg.
nospace() << NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST <<
": " << setting.macAddressBlacklist() <<
'\n';
479 dbg.
nospace() << NM_SETTING_WIRED_MTU <<
": " << setting.mtu() <<
'\n';
480 dbg.
nospace() << NM_SETTING_WIRED_S390_SUBCHANNELS <<
": " << setting.s390Subchannels() <<
'\n';
481 dbg.
nospace() << NM_SETTING_WIRED_S390_NETTYPE <<
": " << setting.s390NetType() <<
'\n';
482 dbg.
nospace() << NM_SETTING_WIRED_S390_OPTIONS <<
": " << setting.s390Options() <<
'\n';
483 dbg.
nospace() << NM_SETTING_WIRED_WAKE_ON_LAN <<
": " << setting.wakeOnLan() <<
'\n';
484 dbg.
nospace() << NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD <<
": " << setting.wakeOnLanPassword() <<
'\n';
485 dbg.
nospace() << NM_SETTING_WIRED_ASSIGNED_MAC_ADDRESS <<
": " << setting.assignedMacAddress() <<
'\n';
Represents wired setting.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
Type type(const QSqlDatabase &db)
PostalAddress address(const QVariant &location)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
This class allows querying the underlying system to discover the available network interfaces and rea...
@ Full
The host is connected to a network, and appears to be able to reach the full Internet.
NETWORKMANAGERQT_EXPORT bool checkVersion(const int x, const int y, const int z)
Checks if NetworkManager version is at least x.y.z.
T value(const Key &key, const T &defaultValue) const const
QVariant fromValue(T &&value)