diff --git a/autotests/settings/iptunnelsettingtest.cpp b/autotests/settings/iptunnelsettingtest.cpp index 17db0b0..8915bd0 100644 --- a/autotests/settings/iptunnelsettingtest.cpp +++ b/autotests/settings/iptunnelsettingtest.cpp @@ -1,106 +1,110 @@ /* Copyright 2018 Pranav Gade This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "iptunnelsettingtest.h" #include "settings/iptunnelsetting.h" #include #include +#if !NM_CHECK_VERSION(1, 12, 0) +#define NM_SETTING_IP_TUNNEL_FLAGS "flags" +#endif + void IpTunnelSettingTest::testSetting_data() { QTest::addColumn("mode"); QTest::addColumn("pathMtuDiscovery"); QTest::addColumn("encapsulationLimit"); QTest::addColumn("flags"); QTest::addColumn("flowLabel"); QTest::addColumn("mtu"); QTest::addColumn("tos"); QTest::addColumn("ttl"); QTest::addColumn("inputKey"); QTest::addColumn("local"); QTest::addColumn("parent"); QTest::addColumn("outputKey"); QTest::addColumn("remote"); QTest::newRow("setting1") << (quint32)2 // mode << false // pathMtuDiscovery << (quint32)1 // encapsulationLimit << (quint32)0x02 // flags << (quint32)1 // flowLabel << (quint32)1 // mtu << (quint32)1 // tos << (quint32)1 // ttl << QString("key") // inputKey << QString("abc") // local << QString("par") // parent << QString("out") // outputKey << QString("rem"); // remote } void IpTunnelSettingTest::testSetting() { QFETCH(quint32, mode); QFETCH(bool, pathMtuDiscovery); QFETCH(quint32, encapsulationLimit); QFETCH(quint32, flags); QFETCH(quint32, flowLabel); QFETCH(quint32, mtu); QFETCH(quint32, tos); QFETCH(quint32, ttl); QFETCH(QString, inputKey); QFETCH(QString, local); QFETCH(QString, parent); QFETCH(QString, outputKey); QFETCH(QString, remote); QVariantMap map; map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MODE), mode); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), pathMtuDiscovery); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), encapsulationLimit); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS), flags); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL), flowLabel); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MTU), mtu); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TOS), tos); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TTL), ttl); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY), inputKey); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL), local); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT), parent); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY), outputKey); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE), remote); NetworkManager::IpTunnelSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(IpTunnelSettingTest) diff --git a/autotests/settings/ovsbridgesettingtest.cpp b/autotests/settings/ovsbridgesettingtest.cpp index 404e4ec..4fb0003 100644 --- a/autotests/settings/ovsbridgesettingtest.cpp +++ b/autotests/settings/ovsbridgesettingtest.cpp @@ -1,70 +1,79 @@ /* Copyright 2018 Pranav Gade This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "ovsbridgesettingtest.h" #include "settings/ovsbridgesetting.h" #include #include +#if !NM_CHECK_VERSION(1, 10, 0) +#define NM_SETTING_OVS_BRIDGE_SETTING_NAME "ovs-bridge" +#define NM_SETTING_OVS_BRIDGE_FAIL_MODE "fail-mode" +#define NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE "mcast-snooping-enable" +#define NM_SETTING_OVS_BRIDGE_RSTP_ENABLE "rstp-enable" +#define NM_SETTING_OVS_BRIDGE_STP_ENABLE "stp-enable" +#endif + + void OvsBridgeSettingTest::testSetting_data() { QTest::addColumn("mcastSnoopingEnable"); QTest::addColumn("rstpEnable"); QTest::addColumn("stpEnable"); QTest::addColumn("failMode"); QTest::newRow("setting1") << true // mcastSnoopingEnable << true // rstpEnable << true // stpEnable << QString("secure"); // failMode } void OvsBridgeSettingTest::testSetting() { QFETCH(bool, mcastSnoopingEnable); QFETCH(bool, rstpEnable); QFETCH(bool, stpEnable); QFETCH(QString, failMode); QVariantMap map; map.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE), mcastSnoopingEnable); map.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_RSTP_ENABLE), rstpEnable); map.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_STP_ENABLE), stpEnable); map.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_FAIL_MODE), failMode); NetworkManager::OvsBridgeSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(OvsBridgeSettingTest) diff --git a/autotests/settings/ovsinterfacesettingtest.cpp b/autotests/settings/ovsinterfacesettingtest.cpp index e95060d..5c84d0d 100644 --- a/autotests/settings/ovsinterfacesettingtest.cpp +++ b/autotests/settings/ovsinterfacesettingtest.cpp @@ -1,58 +1,62 @@ /* Copyright 2018 Pranav Gade This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "ovsinterfacesettingtest.h" #include "settings/ovsinterfacesetting.h" #include #include +#if !NM_CHECK_VERSION(1, 10, 0) +#define NM_SETTING_OVS_INTERFACE_TYPE "type" +#endif + void OvsInterfaceSettingTest::testSetting_data() { QTest::addColumn("type"); QTest::newRow("setting1") << QString("internal"); // type } void OvsInterfaceSettingTest::testSetting() { QFETCH(QString, type); QVariantMap map; map.insert(QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE), type); NetworkManager::OvsInterfaceSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } -QTEST_MAIN(OvsInterfaceSettingTest) \ No newline at end of file +QTEST_MAIN(OvsInterfaceSettingTest) diff --git a/autotests/settings/proxysettingtest.cpp b/autotests/settings/proxysettingtest.cpp index 005f86b..1fbd40f 100644 --- a/autotests/settings/proxysettingtest.cpp +++ b/autotests/settings/proxysettingtest.cpp @@ -1,70 +1,77 @@ /* Copyright 2018 Pranav Gade This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "proxysettingtest.h" #include "settings/proxysetting.h" #include #include +#if !NM_CHECK_VERSION(1, 6, 0) +#define NM_SETTING_PROXY_BROWSER_ONLY "browser-only" +#define NM_SETTING_PROXY_METHOD "method" +#define NM_SETTING_PROXY_PAC_SCRIPT "pac-script" +#define NM_SETTING_PROXY_PAC_URL "pac-url" +#endif + void ProxySettingTest::testSetting_data() { QTest::addColumn("browserOnly"); QTest::addColumn("method"); QTest::addColumn("pacScript"); QTest::addColumn("pacUrl"); QTest::newRow("setting1") << false // browserOnly << (quint32)1 // method << QString("script") // pacScript << QString("url"); // pacUrl } void ProxySettingTest::testSetting() { QFETCH(bool, browserOnly); QFETCH(quint32, method); QFETCH(QString, pacScript); QFETCH(QString, pacUrl); QVariantMap map; map.insert(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY), browserOnly); map.insert(QLatin1String(NM_SETTING_PROXY_METHOD), method); map.insert(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT), pacScript); map.insert(QLatin1String(NM_SETTING_PROXY_PAC_URL), pacUrl); NetworkManager::ProxySetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(ProxySettingTest) diff --git a/autotests/settings/usersettingtest.cpp b/autotests/settings/usersettingtest.cpp index 5966628..518bde1 100644 --- a/autotests/settings/usersettingtest.cpp +++ b/autotests/settings/usersettingtest.cpp @@ -1,63 +1,67 @@ /* Copyright 2018 Pranav Gade This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "usersettingtest.h" #include "settings/usersetting.h" #include #include +#if !NM_CHECK_VERSION(1, 8, 0) +#define NM_SETTING_USER_DATA "data" +#endif + void UserSettingTest::testSetting_data() { QTest::addColumn("data"); NMStringMap data; data.insert("dat", "abc"); QTest::newRow("setting1") << data; // data } void UserSettingTest::testSetting() { QFETCH(NMStringMap, data); QVariantMap map; map.insert(QLatin1String(NM_SETTING_USER_DATA), QVariant::fromValue(data)); NetworkManager::UserSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); NMStringMap stringMap1 = map.value(QLatin1String(NM_SETTING_USER_DATA)).value(); NMStringMap stringMap2 = map1.value(QLatin1String(NM_SETTING_USER_DATA)).value(); NMStringMap::const_iterator it = stringMap1.constBegin(); while (it != stringMap1.constEnd()) { QCOMPARE(it.value(), stringMap2.value(it.key())); ++it; } } QTEST_MAIN(UserSettingTest) diff --git a/src/settings/iptunnelsetting.cpp b/src/settings/iptunnelsetting.cpp index 77d4c49..3c5d0b1 100644 --- a/src/settings/iptunnelsetting.cpp +++ b/src/settings/iptunnelsetting.cpp @@ -1,392 +1,392 @@ /* Copyright Pranav Gade This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "iptunnelsetting.h" #include "iptunnelsetting_p.h" #include -#if NM_CHECK_VERSION(1, 12, 0) +#if !NM_CHECK_VERSION(1, 12, 0) #define NM_SETTING_IP_TUNNEL_FLAGS "flags" #endif NetworkManager::IpTunnelSettingPrivate::IpTunnelSettingPrivate() : name(NM_SETTING_IP_TUNNEL_SETTING_NAME) , mode(IpTunnelSetting::Unknown) , pathMtuDiscovery(true) , encapsulationLimit(0) , flags(IpTunnelSetting::None) , flowLabel(0) , mtu(0) , tos(0) , ttl(0) { } NetworkManager::IpTunnelSetting::IpTunnelSetting() : Setting(Setting::IpTunnel) , d_ptr(new IpTunnelSettingPrivate()) { } NetworkManager::IpTunnelSetting::IpTunnelSetting(const Ptr &other) : Setting(other) , d_ptr(new IpTunnelSettingPrivate()) { setMode(other->mode()); setPathMtuDiscovery(other->pathMtuDiscovery()); setEncapsulationLimit(other->encapsulationLimit()); setFlags(other->flags()); setFlowLabel(other->flowLabel()); setMtu(other->mtu()); setTos(other->tos()); setTtl(other->ttl()); setInputKey(other->inputKey()); setLocal(other->local()); setOutputKey(other->outputKey()); setParent(other->parent()); setRemote(other->remote()); } NetworkManager::IpTunnelSetting::~IpTunnelSetting() { delete d_ptr; } QString NetworkManager::IpTunnelSetting::name() const { Q_D(const IpTunnelSetting); return d->name; } void NetworkManager::IpTunnelSetting::setMode(NetworkManager::IpTunnelSetting::Mode mode) { Q_D(IpTunnelSetting); d->mode = mode; } NetworkManager::IpTunnelSetting::Mode NetworkManager::IpTunnelSetting::mode() const { Q_D(const IpTunnelSetting); return d->mode; } void NetworkManager::IpTunnelSetting::setPathMtuDiscovery(bool discovery) { Q_D(IpTunnelSetting); d->pathMtuDiscovery = discovery; } bool NetworkManager::IpTunnelSetting::pathMtuDiscovery() const { Q_D(const IpTunnelSetting); return d->pathMtuDiscovery; } void NetworkManager::IpTunnelSetting::setEncapsulationLimit(quint32 limit) { Q_D(IpTunnelSetting); d->encapsulationLimit = limit; } quint32 NetworkManager::IpTunnelSetting::encapsulationLimit() const { Q_D(const IpTunnelSetting); return d->encapsulationLimit; } void NetworkManager::IpTunnelSetting::setFlags(NetworkManager::IpTunnelSetting::Flags flags) { Q_D(IpTunnelSetting); d->flags = flags; } NetworkManager::IpTunnelSetting::Flags NetworkManager::IpTunnelSetting::flags() const { Q_D(const IpTunnelSetting); return d->flags; } void NetworkManager::IpTunnelSetting::setFlowLabel(quint32 label) { Q_D(IpTunnelSetting); d->flowLabel = label; } quint32 NetworkManager::IpTunnelSetting::flowLabel() const { Q_D(const IpTunnelSetting); return d->flowLabel; } void NetworkManager::IpTunnelSetting::setMtu(quint32 mtu) { Q_D(IpTunnelSetting); d->mtu = mtu; } quint32 NetworkManager::IpTunnelSetting::mtu() const { Q_D(const IpTunnelSetting); return d->mtu; } void NetworkManager::IpTunnelSetting::setTos(quint32 tos) { Q_D(IpTunnelSetting); d->tos = tos; } quint32 NetworkManager::IpTunnelSetting::tos() const { Q_D(const IpTunnelSetting); return d->tos; } void NetworkManager::IpTunnelSetting::setTtl(quint32 ttl) { Q_D(IpTunnelSetting); d->ttl = ttl; } quint32 NetworkManager::IpTunnelSetting::ttl() const { Q_D(const IpTunnelSetting); return d->ttl; } void NetworkManager::IpTunnelSetting::setInputKey(const QString &key) { Q_D(IpTunnelSetting); d->inputKey = key; } QString NetworkManager::IpTunnelSetting::inputKey() const { Q_D(const IpTunnelSetting); return d->inputKey; } void NetworkManager::IpTunnelSetting::setLocal(const QString &local) { Q_D(IpTunnelSetting); d->local = local; } QString NetworkManager::IpTunnelSetting::local() const { Q_D(const IpTunnelSetting); return d->local; } void NetworkManager::IpTunnelSetting::setParent(const QString &parent) { Q_D(IpTunnelSetting); d->parent = parent; } QString NetworkManager::IpTunnelSetting::parent() const { Q_D(const IpTunnelSetting); return d->parent; } void NetworkManager::IpTunnelSetting::setOutputKey(const QString &key) { Q_D(IpTunnelSetting); d->outputKey = key; } QString NetworkManager::IpTunnelSetting::outputKey() const { Q_D(const IpTunnelSetting); return d->outputKey; } void NetworkManager::IpTunnelSetting::setRemote(const QString &remote) { Q_D(IpTunnelSetting); d->remote = remote; } QString NetworkManager::IpTunnelSetting::remote() const { Q_D(const IpTunnelSetting); return d->remote; } void NetworkManager::IpTunnelSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_MODE))) { setMode((Mode)setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_MODE)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY))) { setPathMtuDiscovery(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT))) { setEncapsulationLimit(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS))) { setFlags((Flag)setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL))) { setFlowLabel(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_MTU))) { setMtu(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_MTU)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_TOS))) { setTos(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_TOS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_TTL))) { setTtl(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_TTL)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY))) { setInputKey(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL))) { setLocal(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT))) { setParent(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY))) { setOutputKey(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE))) { setRemote(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE)).toString()); } } QVariantMap NetworkManager::IpTunnelSetting::toMap() const { QVariantMap setting; setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), pathMtuDiscovery()); if (mode() != Unknown) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MODE), (int)mode()); } if (encapsulationLimit() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), encapsulationLimit()); } if (flags() > None) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS), (int)flags()); } if (flowLabel() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL), flowLabel()); } if (mtu() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MTU), mtu()); } if (tos() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TOS), tos()); } if (ttl() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TTL), ttl()); } if (!inputKey().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY), inputKey()); } if (!local().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL), local()); } if (!parent().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT), parent()); } if (!outputKey().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY), outputKey()); } if (!remote().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE), remote()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::IpTunnelSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_MODE << ": " << setting.mode() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY << ": " << setting.pathMtuDiscovery() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT << ": " << setting.encapsulationLimit() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_FLAGS << ": " << setting.flags() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_FLOW_LABEL << ": " << setting.flowLabel() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_MTU << ": " << setting.mtu() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_TOS << ": " << setting.tos() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_TTL << ": " << setting.ttl() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_INPUT_KEY << ": " << setting.inputKey() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_LOCAL << ": " << setting.local() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_PARENT << ": " << setting.parent() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_OUTPUT_KEY << ": " << setting.outputKey() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_REMOTE << ": " << setting.remote() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/proxysetting.cpp b/src/settings/proxysetting.cpp index 8eb5a1e..78f3306 100644 --- a/src/settings/proxysetting.cpp +++ b/src/settings/proxysetting.cpp @@ -1,175 +1,174 @@ /* Copyright Pranav Gade This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "proxysetting.h" #include "proxysetting_p.h" #include #if !NM_CHECK_VERSION(1, 6, 0) #define NM_SETTING_PROXY_SETTING_NAME "proxy" #define NM_SETTING_PROXY_BROWSER_ONLY "browser-only" #define NM_SETTING_PROXY_METHOD "method" #define NM_SETTING_PROXY_PAC_SCRIPT "pac-script" #define NM_SETTING_PROXY_PAC_URL "pac-url" #endif - NetworkManager::ProxySettingPrivate::ProxySettingPrivate() : name(NM_SETTING_PROXY_SETTING_NAME) , browserOnly(false) , method(ProxySetting::None) { } NetworkManager::ProxySetting::ProxySetting() : Setting(Setting::Proxy) , d_ptr(new ProxySettingPrivate()) { } NetworkManager::ProxySetting::ProxySetting(const Ptr &other) : Setting(other) , d_ptr(new ProxySettingPrivate()) { setBrowserOnly(other->browserOnly()); setMethod(other->method()); setPacScript(other->pacScript()); setPacUrl(other->pacUrl()); } NetworkManager::ProxySetting::~ProxySetting() { delete d_ptr; } QString NetworkManager::ProxySetting::name() const { Q_D(const ProxySetting); return d->name; } void NetworkManager::ProxySetting::setBrowserOnly(bool browserOnly) { Q_D(ProxySetting); d->browserOnly = browserOnly; } bool NetworkManager::ProxySetting::browserOnly() const { Q_D(const ProxySetting); return d->browserOnly; } void NetworkManager::ProxySetting::setMethod(NetworkManager::ProxySetting::Mode method) { Q_D(ProxySetting); d->method = method; } NetworkManager::ProxySetting::Mode NetworkManager::ProxySetting::method() const { Q_D(const ProxySetting); return d->method; } void NetworkManager::ProxySetting::setPacScript(const QString &script) { Q_D(ProxySetting); d->pacScript = script; } QString NetworkManager::ProxySetting::pacScript() const { Q_D(const ProxySetting); return d->pacScript; } void NetworkManager::ProxySetting::setPacUrl(const QString &url) { Q_D(ProxySetting); d->pacUrl = url; } QString NetworkManager::ProxySetting::pacUrl() const { Q_D(const ProxySetting); return d->pacUrl; } void NetworkManager::ProxySetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY))) { setBrowserOnly(setting.value(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PROXY_METHOD))) { setMethod((Mode)setting.value(QLatin1String(NM_SETTING_PROXY_METHOD)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT))) { setPacScript(setting.value(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_PROXY_PAC_URL))) { setPacUrl(setting.value(QLatin1String(NM_SETTING_PROXY_PAC_URL)).toString()); } } QVariantMap NetworkManager::ProxySetting::toMap() const { QVariantMap setting; setting.insert(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY), browserOnly()); if (method() > 0) { setting.insert(QLatin1String(NM_SETTING_PROXY_METHOD), (int)method()); } if (!pacScript().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT), pacScript()); } if (!pacUrl().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_PROXY_PAC_URL), pacUrl()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::ProxySetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_PROXY_BROWSER_ONLY << ": " << setting.browserOnly() << '\n'; dbg.nospace() << NM_SETTING_PROXY_METHOD << ": " << setting.method() << '\n'; dbg.nospace() << NM_SETTING_PROXY_PAC_SCRIPT << ": " << setting.pacScript() << '\n'; dbg.nospace() << NM_SETTING_PROXY_PAC_URL << ": " << setting.pacUrl() << '\n'; return dbg.maybeSpace(); }