diff --git a/autotests/settings/CMakeLists.txt b/autotests/settings/CMakeLists.txt index 07a80a8..9e3db57 100644 --- a/autotests/settings/CMakeLists.txt +++ b/autotests/settings/CMakeLists.txt @@ -1,38 +1,40 @@ macro(NETWORKMANAGERQT_AUTOTESTS) foreach(_testname ${ARGN}) ecm_add_test(${_testname}.cpp LINK_LIBRARIES Qt5::Test KF5NetworkManagerQt_static) endforeach(_testname) endmacro(NETWORKMANAGERQT_AUTOTESTS) NETWORKMANAGERQT_AUTOTESTS( 8021xsettingtest adslsettingtest bluetoothsettingtest bondsettingtest bridgesettingtest bridgeportsettingtest cdmasettingtest connectionsettingtest gsmsettingtest infinibandsettingtest iptunnelsettingtest ipv4settingtest ipv6settingtest olpcmeshsettingtest ovsbridgesettingtest ovsinterfacesettingtest + ovspatchsettingtest + ovsportsettingtest pppsettingtest pppoesettingtest proxysettingtest serialsettingtest tunsettingtest usersettingtest vlansettingtest vxlansettingtest vpnsettingtest wimaxsettingtest wiredsettingtest wirelesssettingtest wirelesssecuritysettingtest ) diff --git a/autotests/settings/ovspatchsettingtest.cpp b/autotests/settings/ovspatchsettingtest.cpp new file mode 100644 index 0000000..e779642 --- /dev/null +++ b/autotests/settings/ovspatchsettingtest.cpp @@ -0,0 +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 "ovspatchsettingtest.h" + +#include "settings/ovspatchsetting.h" + +#include + +#include + +#if !NM_CHECK_VERSION(1, 10, 0) +#define NM_SETTING_OVS_PATCH_PEER "peer" +#endif + +void OvsPatchSettingTest::testSetting_data() +{ + QTest::addColumn("peer"); + + QTest::newRow("setting1") + << QString("abc"); // peer +} + +void OvsPatchSettingTest::testSetting() +{ + QFETCH(QString, peer); + + QVariantMap map; + + map.insert(QLatin1String(NM_SETTING_OVS_PATCH_PEER), peer); + + NetworkManager::OvsPatchSetting 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(OvsPatchSettingTest) diff --git a/autotests/settings/ovspatchsettingtest.h b/autotests/settings/ovspatchsettingtest.h new file mode 100644 index 0000000..a78eb11 --- /dev/null +++ b/autotests/settings/ovspatchsettingtest.h @@ -0,0 +1,35 @@ +/* + 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 . +*/ + +#ifndef NETWORKMANAGERQT_OVS_PATCH_SETTING_TEST_H +#define NETWORKMANAGERQT_OVS_PATCH_SETTING_TEST_H + +#include + +class OvsPatchSettingTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testSetting_data(); + void testSetting(); +}; + +#endif // NETWORKMANAGERQT_OVS_PATCH_SETTING_TEST_H diff --git a/autotests/settings/ovsportsettingtest.cpp b/autotests/settings/ovsportsettingtest.cpp new file mode 100644 index 0000000..0666d90 --- /dev/null +++ b/autotests/settings/ovsportsettingtest.cpp @@ -0,0 +1,87 @@ +/* + 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 "ovsportsettingtest.h" + +#include "settings/ovsportsetting.h" + +#include + +#include + +#if !NM_CHECK_VERSION(1, 10, 0) +#define NM_SETTING_OVS_PORT_VLAN_MODE "vlan-mode" +#define NM_SETTING_OVS_PORT_TAG "tag" +#define NM_SETTING_OVS_PORT_LACP "lacp" +#define NM_SETTING_OVS_PORT_BOND_MODE "bond-mode" +#define NM_SETTING_OVS_PORT_BOND_UPDELAY "bond-updelay" +#define NM_SETTING_OVS_PORT_BOND_DOWNDELAY "bond-downdelay" +#endif + +void OvsPortSettingTest::testSetting_data() +{ + QTest::addColumn("bondDowndelay"); + QTest::addColumn("bondUpdelay"); + QTest::addColumn("tag"); + QTest::addColumn("lacp"); + QTest::addColumn("bondMode"); + QTest::addColumn("vlanMode"); + + QTest::newRow("setting1") + << (quint32)1 // bondDowndelay + << (quint32)1 // bondUpdelay + << (quint32)1 // tag + << QString("off") // lacp + << QString("active-backup") // bondMode + << QString("trunk"); // vlanMode +} + +void OvsPortSettingTest::testSetting() +{ + QFETCH(quint32, bondDowndelay); + QFETCH(quint32, bondUpdelay); + QFETCH(quint32, tag); + QFETCH(QString, lacp); + QFETCH(QString, bondMode); + QFETCH(QString, vlanMode); + + QVariantMap map; + + map.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_DOWNDELAY), bondDowndelay); + map.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_UPDELAY), bondUpdelay); + map.insert(QLatin1String(NM_SETTING_OVS_PORT_TAG), tag); + map.insert(QLatin1String(NM_SETTING_OVS_PORT_LACP), lacp); + map.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_MODE), bondMode); + map.insert(QLatin1String(NM_SETTING_OVS_PORT_VLAN_MODE), vlanMode); + + NetworkManager::OvsPortSetting 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(OvsPortSettingTest) diff --git a/autotests/settings/ovsportsettingtest.h b/autotests/settings/ovsportsettingtest.h new file mode 100644 index 0000000..96db8cd --- /dev/null +++ b/autotests/settings/ovsportsettingtest.h @@ -0,0 +1,35 @@ +/* + 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 . +*/ + +#ifndef NETWORKMANAGERQT_OVS_PORT_SETTING_TEST_H +#define NETWORKMANAGERQT_OVS_PORT_SETTING_TEST_H + +#include + +class OvsPortSettingTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testSetting_data(); + void testSetting(); +}; + +#endif // NETWORKMANAGERQT_OVS_PORT_SETTING_TEST_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7975034..dd1b8a7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,282 +1,284 @@ # add_subdirectory(dbus) include_directories( ${NETWORKMANAGER_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/dbus ${CMAKE_CURRENT_SOURCE_DIR}/settings ) set(NetworkManagerQt_PART_SRCS device.cpp accesspoint.cpp activeconnection.cpp adsldevice.cpp bluetoothdevice.cpp bonddevice.cpp bridgedevice.cpp connection.cpp dhcp4config.cpp dhcp6config.cpp devicestatistics.cpp dnsconfiguration.cpp dnsdomain.cpp infinibanddevice.cpp ipaddress.cpp iproute.cpp ipconfig.cpp manager.cpp modemdevice.cpp olpcmeshdevice.cpp secretagent.cpp settings.cpp utils.cpp vlandevice.cpp vpnconnection.cpp vpnplugin.cpp wimaxdevice.cpp wimaxnsp.cpp wireddevice.cpp wirelessdevice.cpp wirelessnetwork.cpp generictypes.cpp genericdevice.cpp gredevice.cpp iptunneldevice.cpp macvlandevice.cpp teamdevice.cpp tundevice.cpp vethdevice.cpp wimaxdevice.cpp wimaxnsp.cpp ) set(NetworkManagerQt_SETTINGS_SRCS settings/adslsetting.cpp settings/bluetoothsetting.cpp settings/bondsetting.cpp settings/bridgesetting.cpp settings/bridgeportsetting.cpp settings/cdmasetting.cpp settings/connectionsettings.cpp settings/gsmsetting.cpp settings/iptunnelsetting.cpp settings/ipv4setting.cpp settings/ipv6setting.cpp settings/infinibandsetting.cpp settings/olpcmeshsetting.cpp settings/ovsbridgesetting.cpp settings/ovsinterfacesetting.cpp + settings/ovspatchsetting.cpp + settings/ovsportsetting.cpp settings/pppsetting.cpp settings/pppoesetting.cpp settings/proxysetting.cpp settings/setting.cpp settings/serialsetting.cpp settings/security8021xsetting.cpp #settings/template.cpp settings/vlansetting.cpp settings/vpnsetting.cpp settings/wimaxsetting.cpp settings/wiredsetting.cpp settings/wirelesssetting.cpp settings/wirelesssecuritysetting.cpp settings/teamsetting.cpp settings/genericsetting.cpp settings/tunsetting.cpp settings/usersetting.cpp settings/vxlansetting.cpp ) set(DBUS_INTERFACE_SRCS dbus/accesspointinterface.cpp dbus/activeconnectioninterface.cpp dbus/adsldeviceinterface.cpp dbus/agentmanagerinterface.cpp dbus/bluetoothdeviceinterface.cpp dbus/bonddeviceinterface.cpp dbus/bridgedeviceinterface.cpp dbus/connectioninterface.cpp dbus/deviceinterface.cpp dbus/devicestatisticsinterface.cpp dbus/dhcp4configinterface.cpp dbus/dhcp6configinterface.cpp dbus/dnsmanagerinterface.cpp dbus/genericdeviceinterface.cpp dbus/gredeviceinterface.cpp dbus/checkpointinterface.cpp dbus/infinibanddeviceinterface.cpp dbus/iptunneldeviceinterface.cpp dbus/ip4configinterface.cpp dbus/ip6configinterface.cpp dbus/macsecdeviceinterface.cpp dbus/macvlandeviceinterface.cpp dbus/modemdeviceinterface.cpp dbus/networkmanagerinterface.cpp dbus/olpcmeshdeviceinterface.cpp dbus/pppinterface.cpp dbus/secretagentadaptor.cpp dbus/settingsinterface.cpp dbus/teamdeviceinterface.cpp dbus/tundeviceinterface.cpp dbus/vethdeviceinterface.cpp dbus/vlandeviceinterface.cpp dbus/vpnconnectioninterface.cpp dbus/vpnplugininterface.cpp dbus/vxlandeviceinterface.cpp dbus/wimaxdeviceinterface.cpp dbus/wimaxnspinterface.cpp dbus/wireddeviceinterface.cpp dbus/wirelessdeviceinterface.cpp ) add_library(KF5NetworkManagerQt SHARED ${NetworkManagerQt_PART_SRCS} ${NetworkManagerQt_SETTINGS_SRCS} ${DBUS_INTERFACE_SRCS}) generate_export_header(KF5NetworkManagerQt EXPORT_FILE_NAME ${NetworkManagerQt_BINARY_DIR}/networkmanagerqt/networkmanagerqt_export.h BASE_NAME NetworkManagerQt) add_library(KF5::NetworkManagerQt ALIAS KF5NetworkManagerQt) target_include_directories(KF5NetworkManagerQt INTERFACE "$") # for examples to build target_include_directories(KF5NetworkManagerQt PUBLIC "$") target_link_libraries(KF5NetworkManagerQt PUBLIC Qt5::Core Qt5::Network Qt5::DBus) set_target_properties(KF5NetworkManagerQt PROPERTIES VERSION ${NETWORKMANAGERQT_VERSION_STRING} SOVERSION ${NETWORKMANAGERQT_SOVERSION} EXPORT_NAME NetworkManagerQt ) if (${NETWORKMANAGER_VERSION} VERSION_EQUAL 1.0.0 OR ${NETWORKMANAGER_VERSION} VERSION_GREATER 1.0.0) target_include_directories(KF5NetworkManagerQt PUBLIC ${NM-CORE_INCLUDE_DIRS}) else() target_include_directories(KF5NetworkManagerQt PUBLIC ${NETWORKMANAGER_INCLUDE_DIRS} SYSTEM PUBLIC ${NM-UTIL_INCLUDE_DIRS} ${NM-GLIB_INCLUDE_DIRS}) endif() ########### static lib for tests ############### add_library(KF5NetworkManagerQt_static STATIC ${NetworkManagerQt_PART_SRCS} ${NetworkManagerQt_SETTINGS_SRCS} ${DBUS_INTERFACE_SRCS}) set_target_properties(KF5NetworkManagerQt_static PROPERTIES COMPILE_FLAGS -DNMQT_STATIC=1) target_link_libraries(KF5NetworkManagerQt_static PUBLIC Qt5::Core Qt5::Network Qt5::DBus) target_include_directories(KF5NetworkManagerQt_static PUBLIC "$") ecm_generate_headers(NetworkManagerQt_CamelCase_HEADERS HEADER_NAMES AccessPoint ActiveConnection AdslDevice BluetoothDevice BondDevice BridgeDevice Connection Device DeviceStatistics Dhcp4Config Dhcp6Config DnsConfiguration DnsDomain GenericDevice GenericTypes GreDevice InfinibandDevice IpAddress IpConfig IpRoute IpTunnelDevice MacVlanDevice Manager ModemDevice OlpcMeshDevice SecretAgent Settings TeamDevice TunDevice Utils VethDevice VlanDevice VpnConnection VpnPlugin WimaxDevice WimaxNsp WiredDevice WirelessDevice WirelessNetwork REQUIRED_HEADERS NetworkManagerQt_HEADERS PREFIX NetworkManagerQt ) ecm_generate_headers(NetworkManagerQt_SETTINGS_CamelCase_HEADERS HEADER_NAMES AdslSetting BluetoothSetting BondSetting BridgeSetting BridgePortSetting CdmaSetting ConnectionSettings GsmSetting GenericSetting InfinibandSetting IpTunnelSetting Ipv4Setting Ipv6Setting OlpcMeshSetting PppoeSetting PppSetting Security8021xSetting SerialSetting Setting TeamSetting TunSetting VlanSetting VpnSetting WimaxSetting WiredSetting WirelessSecuritySetting WirelessSetting RELATIVE settings REQUIRED_HEADERS NetworkManagerQt_SETTINGS_HEADERS PREFIX NetworkManagerQt ) install(TARGETS KF5NetworkManagerQt EXPORT KF5NetworkManagerQtTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${NetworkManagerQt_CamelCase_HEADERS} ${NetworkManagerQt_SETTINGS_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/NetworkManagerQt/NetworkManagerQt COMPONENT Devel ) install(FILES ${NetworkManagerQt_BINARY_DIR}/networkmanagerqt/networkmanagerqt_export.h ${NetworkManagerQt_HEADERS} ${NetworkManagerQt_SETTINGS_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/NetworkManagerQt/networkmanagerqt COMPONENT Devel ) if(BUILD_QCH) ecm_add_qch( KF5NetworkManagerQt_QCH NAME NetworkManagerQt BASE_NAME KF5NetworkManagerQt VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${NetworkManagerQt_HEADERS} ${NetworkManagerQt_SETTINGS_HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS Qt5Core_QCH Qt5Network_QCH Qt5DBus_QCH BLANK_MACROS NETWORKMANAGERQT_EXPORT NETWORKMANAGERQT_DEPRECATED NETWORKMANAGERQT_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME NetworkManagerQt LIB_NAME KF5NetworkManagerQt DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/NetworkManagerQt) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/settings/ovspatchsetting.cpp b/src/settings/ovspatchsetting.cpp new file mode 100644 index 0000000..2e2578d --- /dev/null +++ b/src/settings/ovspatchsetting.cpp @@ -0,0 +1,99 @@ +/* + 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 "ovspatchsetting.h" +#include "ovspatchsetting_p.h" + +#include + +#if !NM_CHECK_VERSION(1, 10, 0) +#define NM_SETTING_OVS_PATCH_SETTING_NAME "ovs-patch" +#define NM_SETTING_OVS_PATCH_PEER "peer" +#endif + +NetworkManager::OvsPatchSettingPrivate::OvsPatchSettingPrivate() + : name(NM_SETTING_OVS_PATCH_SETTING_NAME) +{ } + +NetworkManager::OvsPatchSetting::OvsPatchSetting() + : Setting(Setting::OvsPatch) + , d_ptr(new OvsPatchSettingPrivate()) +{ } + +NetworkManager::OvsPatchSetting::OvsPatchSetting(const Ptr &other) + : Setting(other) + , d_ptr(new OvsPatchSettingPrivate()) +{ + setPeer(other->peer()); +} + +NetworkManager::OvsPatchSetting::~OvsPatchSetting() +{ + delete d_ptr; +} + +QString NetworkManager::OvsPatchSetting::name() const +{ + Q_D(const OvsPatchSetting); + + return d->name; +} + +void NetworkManager::OvsPatchSetting::setPeer(const QString &peer) +{ + Q_D(OvsPatchSetting); + + d->peer = peer; +} + +QString NetworkManager::OvsPatchSetting::peer() const +{ + Q_D(const OvsPatchSetting); + + return d->peer; +} + +void NetworkManager::OvsPatchSetting::fromMap(const QVariantMap &setting) +{ + if (setting.contains(QLatin1String(NM_SETTING_OVS_PATCH_PEER))) { + setPeer(setting.value(QLatin1String(NM_SETTING_OVS_PATCH_PEER)).toString()); + } +} + +QVariantMap NetworkManager::OvsPatchSetting::toMap() const +{ + QVariantMap setting; + + if (!peer().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_OVS_PATCH_PEER), peer()); + } + + return setting; +} + +QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::OvsPatchSetting &setting) +{ + dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; + dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; + + dbg.nospace() << NM_SETTING_OVS_PATCH_PEER << ": " << setting.peer() << '\n'; + + return dbg.maybeSpace(); +} diff --git a/src/settings/ovspatchsetting.h b/src/settings/ovspatchsetting.h new file mode 100644 index 0000000..8c1ea1b --- /dev/null +++ b/src/settings/ovspatchsetting.h @@ -0,0 +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 . +*/ + +#ifndef NETWORKMANAGERQT_OVS_PATCH_SETTING_H +#define NETWORKMANAGERQT_OVS_PATCH_SETTING_H + +#include +#include "setting.h" + +#include + +namespace NetworkManager +{ + +class OvsPatchSettingPrivate; + +/** + * Represents OvsPatch setting + */ +class NETWORKMANAGERQT_EXPORT OvsPatchSetting : public Setting +{ +public: + typedef QSharedPointer Ptr; + typedef QList List; + + OvsPatchSetting(); + explicit OvsPatchSetting(const Ptr &other); + ~OvsPatchSetting() override; + + QString name() const override; + + void setPeer(const QString &peer); + QString peer() const; + + void fromMap(const QVariantMap &setting) override; + + QVariantMap toMap() const override; + +protected: + OvsPatchSettingPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(OvsPatchSetting) +}; + +NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const OvsPatchSetting &setting); + +} + +#endif // NETWORKMANAGERQT_OVS_PATCH_SETTING_H diff --git a/src/settings/ovspatchsetting_p.h b/src/settings/ovspatchsetting_p.h new file mode 100644 index 0000000..6ec61dd --- /dev/null +++ b/src/settings/ovspatchsetting_p.h @@ -0,0 +1,42 @@ +/* + 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 . +*/ + +#ifndef NETWORKMANAGERQT_OVS_PATCH_SETTING_P_H +#define NETWORKMANAGERQT_OVS_PATCH_SETTING_P_H + +#include + +namespace NetworkManager +{ + +class OvsPatchSettingPrivate +{ +public: + OvsPatchSettingPrivate(); + + QString name; + + QString peer; +}; + +} + +#endif // NETWORKMANAGERQT_OVS_PATCH_SETTING_P_H + diff --git a/src/settings/ovsportsetting.cpp b/src/settings/ovsportsetting.cpp new file mode 100644 index 0000000..f098984 --- /dev/null +++ b/src/settings/ovsportsetting.cpp @@ -0,0 +1,227 @@ +/* + 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 "ovsportsetting.h" +#include "ovsportsetting_p.h" + +#include + +#if !NM_CHECK_VERSION(1, 10, 0) +#define NM_SETTING_OVS_PORT_SETTING_NAME "ovs-port" +#define NM_SETTING_OVS_PORT_VLAN_MODE "vlan-mode" +#define NM_SETTING_OVS_PORT_TAG "tag" +#define NM_SETTING_OVS_PORT_LACP "lacp" +#define NM_SETTING_OVS_PORT_BOND_MODE "bond-mode" +#define NM_SETTING_OVS_PORT_BOND_UPDELAY "bond-updelay" +#define NM_SETTING_OVS_PORT_BOND_DOWNDELAY "bond-downdelay" +#endif + +NetworkManager::OvsPortSettingPrivate::OvsPortSettingPrivate() + : name(NM_SETTING_OVS_PORT_SETTING_NAME) + , bondDowndelay(0) + , bondUpdelay(0) + , tag(0) +{ } + +NetworkManager::OvsPortSetting::OvsPortSetting() + : Setting(Setting::OvsPort) + , d_ptr(new OvsPortSettingPrivate()) +{ } + +NetworkManager::OvsPortSetting::OvsPortSetting(const Ptr &other) + : Setting(other) + , d_ptr(new OvsPortSettingPrivate()) +{ + setBondDowndelay(other->bondDowndelay()); + setBondUpdelay(other->bondUpdelay()); + setTag(other->tag()); + setBondMode(other->bondMode()); + setLacp(other->lacp()); + setVlanMode(other->vlanMode()); +} + +NetworkManager::OvsPortSetting::~OvsPortSetting() +{ + delete d_ptr; +} + +QString NetworkManager::OvsPortSetting::name() const +{ + Q_D(const OvsPortSetting); + + return d->name; +} + +void NetworkManager::OvsPortSetting::setBondDowndelay(quint32 delay) +{ + Q_D(OvsPortSetting); + + d->bondDowndelay = delay; +} + +quint32 NetworkManager::OvsPortSetting::bondDowndelay() const +{ + Q_D(const OvsPortSetting); + + return d->bondDowndelay; +} + +void NetworkManager::OvsPortSetting::setBondUpdelay(quint32 delay) +{ + Q_D(OvsPortSetting); + + d->bondUpdelay = delay; +} + +quint32 NetworkManager::OvsPortSetting::bondUpdelay() const +{ + Q_D(const OvsPortSetting); + + return d->bondUpdelay; +} + +void NetworkManager::OvsPortSetting::setTag(quint32 tag) +{ + Q_D(OvsPortSetting); + + d->tag = tag; +} + +quint32 NetworkManager::OvsPortSetting::tag() const +{ + Q_D(const OvsPortSetting); + + return d->tag; +} + +void NetworkManager::OvsPortSetting::setBondMode(const QString &mode) +{ + Q_D(OvsPortSetting); + + d->bondMode = mode; +} + +QString NetworkManager::OvsPortSetting::bondMode() const +{ + Q_D(const OvsPortSetting); + + return d->bondMode; +} + +void NetworkManager::OvsPortSetting::setLacp(const QString &lacp) +{ + Q_D(OvsPortSetting); + + d->lacp = lacp; +} + +QString NetworkManager::OvsPortSetting::lacp() const +{ + Q_D(const OvsPortSetting); + + return d->lacp; +} + +void NetworkManager::OvsPortSetting::setVlanMode(const QString &mode) +{ + Q_D(OvsPortSetting); + + d->vlanMode = mode; +} + +QString NetworkManager::OvsPortSetting::vlanMode() const +{ + Q_D(const OvsPortSetting); + + return d->vlanMode; +} + +void NetworkManager::OvsPortSetting::fromMap(const QVariantMap &setting) +{ + if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_BOND_UPDELAY))) { + setBondUpdelay(setting.value(QLatin1String(NM_SETTING_OVS_PORT_BOND_UPDELAY)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_BOND_DOWNDELAY))) { + setBondDowndelay(setting.value(QLatin1String(NM_SETTING_OVS_PORT_BOND_DOWNDELAY)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_TAG))) { + setTag(setting.value(QLatin1String(NM_SETTING_OVS_PORT_TAG)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_BOND_MODE))) { + setBondMode(setting.value(QLatin1String(NM_SETTING_OVS_PORT_BOND_MODE)).toString()); + } + + if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_LACP))) { + setLacp(setting.value(QLatin1String(NM_SETTING_OVS_PORT_LACP)).toString()); + } + + if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_VLAN_MODE))) { + setVlanMode(setting.value(QLatin1String(NM_SETTING_OVS_PORT_VLAN_MODE)).toString()); + } +} + +QVariantMap NetworkManager::OvsPortSetting::toMap() const +{ + QVariantMap setting; + + if (bondUpdelay() > 0) { + setting.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_UPDELAY), bondUpdelay()); + } + + if (bondDowndelay() > 0) { + setting.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_DOWNDELAY), bondDowndelay()); + } + + if (tag() > 0) { + setting.insert(QLatin1String(NM_SETTING_OVS_PORT_TAG), tag()); + } + + if (!bondMode().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_MODE), bondMode()); + } + + if (!lacp().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_OVS_PORT_LACP), lacp()); + } + + if (!vlanMode().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_OVS_PORT_VLAN_MODE), vlanMode()); + } + + return setting; +} + +QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::OvsPortSetting &setting) +{ + dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; + dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; + + dbg.nospace() << NM_SETTING_OVS_PORT_BOND_UPDELAY << ": " << setting.bondUpdelay() << '\n'; + dbg.nospace() << NM_SETTING_OVS_PORT_BOND_DOWNDELAY << ": " << setting.bondDowndelay() << '\n'; + dbg.nospace() << NM_SETTING_OVS_PORT_TAG << ": " << setting.tag() << '\n'; + dbg.nospace() << NM_SETTING_OVS_PORT_BOND_MODE << ": " << setting.bondMode() << '\n'; + dbg.nospace() << NM_SETTING_OVS_PORT_LACP << ": " << setting.lacp() << '\n'; + dbg.nospace() << NM_SETTING_OVS_PORT_VLAN_MODE << ": " << setting.vlanMode() << '\n'; + + return dbg.maybeSpace(); +} diff --git a/src/settings/ovsportsetting.h b/src/settings/ovsportsetting.h new file mode 100644 index 0000000..15d5463 --- /dev/null +++ b/src/settings/ovsportsetting.h @@ -0,0 +1,80 @@ +/* + 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 . +*/ + +#ifndef NETWORKMANAGERQTOVS_PORT_SETTING_H +#define NETWORKMANAGERQTOVS_PORT_SETTING_H + +#include +#include "setting.h" + +namespace NetworkManager +{ + +class OvsPortSettingPrivate; + +/** + * Represents OvsPort setting + */ +class NETWORKMANAGERQT_EXPORT OvsPortSetting : public Setting +{ +public: + typedef QSharedPointer Ptr; + typedef QList List; + + OvsPortSetting(); + explicit OvsPortSetting(const Ptr &other); + ~OvsPortSetting() override; + + QString name() const override; + + void setBondDowndelay(quint32 delay); + quint32 bondDowndelay() const; + + void setBondUpdelay(quint32 delay); + quint32 bondUpdelay() const; + + void setTag(quint32 tag); + quint32 tag() const; + + void setBondMode(const QString &mode); + QString bondMode() const; + + void setLacp(const QString &lacp); + QString lacp() const; + + void setVlanMode(const QString &mode); + QString vlanMode() const; + + void fromMap(const QVariantMap &setting) override; + + QVariantMap toMap() const override; + +protected: + OvsPortSettingPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(OvsPortSetting) +}; + +NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const OvsPortSetting &setting); + +} + +#endif // NETWORKMANAGERQT_OVS_PORT_SETTING_H diff --git a/src/settings/ovsportsetting_p.h b/src/settings/ovsportsetting_p.h new file mode 100644 index 0000000..44bd7e4 --- /dev/null +++ b/src/settings/ovsportsetting_p.h @@ -0,0 +1,47 @@ +/* + 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 . +*/ + +#ifndef NETWORKMANAGERQT_OVS_PORT_SETTING_P_H +#define NETWORKMANAGERQT_OVS_PORT_SETTING_P_H + +#include + +namespace NetworkManager +{ + +class OvsPortSettingPrivate +{ +public: + OvsPortSettingPrivate(); + + QString name; + + quint32 bondDowndelay; + quint32 bondUpdelay; + quint32 tag; + QString bondMode; + QString lacp; + QString vlanMode; +}; + +} + +#endif // NETWORKMANAGERQT_OVS_PORT_SETTING_P_H + diff --git a/src/settings/setting.cpp b/src/settings/setting.cpp index b7fce75..7c69f22 100644 --- a/src/settings/setting.cpp +++ b/src/settings/setting.cpp @@ -1,306 +1,316 @@ /* Copyright 2012-2013 Jan Grulich 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 "setting.h" #undef signals #include #include #define signals Q_SIGNALS #include namespace NetworkManager { class SettingPrivate { public: SettingPrivate(); Setting::SettingType type; bool initialized; }; QDebug operator <<(QDebug dbg, const Setting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; return dbg.maybeSpace(); } } NetworkManager::SettingPrivate::SettingPrivate(): type(Setting::Wired), initialized(false) { } QString NetworkManager::Setting::typeAsString(NetworkManager::Setting::SettingType type) { QString typeString; switch (type) { case Cdma: typeString = QLatin1String(NM_SETTING_CDMA_SETTING_NAME); break; case Gsm: typeString = QLatin1String(NM_SETTING_GSM_SETTING_NAME); break; case Bluetooth: typeString = QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME); break; case Ipv4: typeString = QLatin1String(NM_SETTING_IP4_CONFIG_SETTING_NAME); break; case Ipv6: typeString = QLatin1String(NM_SETTING_IP6_CONFIG_SETTING_NAME); break; case Ppp: typeString = QLatin1String(NM_SETTING_PPP_SETTING_NAME); break; case Pppoe: typeString = QLatin1String(NM_SETTING_PPPOE_SETTING_NAME); break; case Security8021x: typeString = QLatin1String(NM_SETTING_802_1X_SETTING_NAME); break; case Serial: typeString = QLatin1String(NM_SETTING_SERIAL_SETTING_NAME); break; case Vpn: typeString = QLatin1String(NM_SETTING_VPN_SETTING_NAME); break; case Wired: typeString = QLatin1String(NM_SETTING_WIRED_SETTING_NAME); break; case Wireless: typeString = QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME); break; case WirelessSecurity: typeString = QLatin1String(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); break; case OlpcMesh: typeString = QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME); break; case Vlan: typeString = QLatin1String(NM_SETTING_VLAN_SETTING_NAME); break; case Wimax: typeString = QLatin1String(NM_SETTING_WIMAX_SETTING_NAME); break; case Bond: typeString = QLatin1String(NM_SETTING_BOND_SETTING_NAME); break; case Bridge: typeString = QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME); break; case Team: typeString = QLatin1String(NM_SETTING_TEAM_SETTING_NAME); break; case Vxlan: typeString = QLatin1String(NM_SETTING_VXLAN_SETTING_NAME); break; case IpTunnel: typeString = QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME); break; case Proxy: typeString = QLatin1String(NM_SETTING_PROXY_SETTING_NAME); break; case User: typeString = QLatin1String(NM_SETTING_USER_SETTING_NAME); break; case OvsInterface: typeString = QLatin1String(NM_SETTING_OVS_INTERFACE_SETTING_NAME); break; case OvsBridge: typeString = QLatin1String(NM_SETTING_OVS_BRIDGE_SETTING_NAME); break; + case OvsPatch: + typeString = QLatin1String(NM_SETTING_OVS_PATCH_SETTING_NAME); + break; + case OvsPort: + typeString = QLatin1String(NM_SETTING_OVS_PORT_SETTING_NAME); + break; case NetworkManager::Setting::Generic: typeString = QLatin1String(NM_SETTING_GENERIC_SETTING_NAME); break; default: break; } return typeString; } NetworkManager::Setting::SettingType NetworkManager::Setting::typeFromString(const QString &typeString) { SettingType type = Wired; if (typeString == QLatin1String(NM_SETTING_CDMA_SETTING_NAME)) { type = Cdma; } else if (typeString == QLatin1String(NM_SETTING_GSM_SETTING_NAME)) { type = Gsm; } else if (typeString == QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME)) { type = Bluetooth; } else if (typeString == QLatin1String(NM_SETTING_IP4_CONFIG_SETTING_NAME)) { type = Ipv4; } else if (typeString == QLatin1String(NM_SETTING_IP6_CONFIG_SETTING_NAME)) { type = Ipv6; } else if (typeString == QLatin1String(NM_SETTING_PPP_SETTING_NAME)) { type = Ppp; } else if (typeString == QLatin1String(NM_SETTING_PPPOE_SETTING_NAME)) { type = Pppoe; } else if (typeString == QLatin1String(NM_SETTING_SERIAL_SETTING_NAME)) { type = Serial; } else if (typeString == QLatin1String(NM_SETTING_802_1X_SETTING_NAME)) { type = Security8021x; } else if (typeString == QLatin1String(NM_SETTING_VPN_SETTING_NAME)) { type = Vpn; } else if (typeString == QLatin1String(NM_SETTING_WIRED_SETTING_NAME)) { type = Wired; } else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME)) { type = Wireless; } else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)) { type = WirelessSecurity; } else if (typeString == QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME)) { type = OlpcMesh; } else if (typeString == QLatin1String(NM_SETTING_VLAN_SETTING_NAME)) { type = Vlan; } else if (typeString == QLatin1String(NM_SETTING_WIMAX_SETTING_NAME)) { type = Wimax; } else if (typeString == QLatin1String(NM_SETTING_BOND_SETTING_NAME)) { type = Bond; } else if (typeString == QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME)) { type = Bridge; } else if (typeString == QLatin1String(NM_SETTING_TEAM_SETTING_NAME)) { type = Team; } else if (typeString == QLatin1String(NM_SETTING_VXLAN_SETTING_NAME)) { type = Vxlan; } else if (typeString == QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME)) { type = IpTunnel; } else if (typeString == QLatin1String(NM_SETTING_GENERIC_SETTING_NAME)) { type = Generic; } else if (typeString == QLatin1String(NM_SETTING_USER_SETTING_NAME)) { type = User; } else if (typeString == QLatin1String(NM_SETTING_PROXY_SETTING_NAME)) { type = Proxy; } else if (typeString == QLatin1String(NM_SETTING_OVS_INTERFACE_SETTING_NAME)) { type = OvsInterface; } else if (typeString == QLatin1String(NM_SETTING_OVS_BRIDGE_SETTING_NAME)) { type = OvsBridge; + } else if (typeString == QLatin1String(NM_SETTING_OVS_PATCH_SETTING_NAME)) { + type = OvsPatch; + } else if (typeString == QLatin1String(NM_SETTING_OVS_PORT_SETTING_NAME)) { + type = OvsPort; } return type; } NetworkManager::Setting::Setting(SettingType type) : d_ptr(new SettingPrivate()) { setType(type); } NetworkManager::Setting::Setting(const NetworkManager::Setting::Ptr &setting) : d_ptr(new SettingPrivate()) { setInitialized(!setting->isNull()); setType(setting->type()); } NetworkManager::Setting::~Setting() { delete d_ptr; } void NetworkManager::Setting::fromMap(const QVariantMap &map) { Q_UNUSED(map); } QVariantMap NetworkManager::Setting::toMap() const { return QVariantMap(); } QStringList NetworkManager::Setting::needSecrets(bool requestNew) const { Q_UNUSED(requestNew); return QStringList(); } QString NetworkManager::Setting::name() const { return QString(); } void NetworkManager::Setting::secretsFromMap(const QVariantMap &map) { Q_UNUSED(map); } void NetworkManager::Setting::secretsFromStringMap(const NMStringMap &map) { QVariantMap secretsMap; NMStringMap::ConstIterator i = map.constBegin(); while (i != map.constEnd()) { secretsMap.insert(i.key(), i.value()); ++i; } secretsFromMap(secretsMap); } QVariantMap NetworkManager::Setting::secretsToMap() const { return QVariantMap(); } NMStringMap NetworkManager::Setting::secretsToStringMap() const { NMStringMap ret; QVariantMap secretsMap = secretsToMap(); QVariantMap::ConstIterator i = secretsMap.constBegin(); while (i != secretsMap.constEnd()) { ret.insert(i.key(), i.value().toString()); ++i; } return ret; } void NetworkManager::Setting::setInitialized(bool initialized) { Q_D(Setting); d->initialized = initialized; } bool NetworkManager::Setting::isNull() const { Q_D(const Setting); return !d->initialized; } void NetworkManager::Setting::setType(NetworkManager::Setting::SettingType type) { Q_D(Setting); d->type = type; } NetworkManager::Setting::SettingType NetworkManager::Setting::type() const { Q_D(const Setting); return d->type; } diff --git a/src/settings/setting.h b/src/settings/setting.h index 7376233..87d4afe 100644 --- a/src/settings/setting.h +++ b/src/settings/setting.h @@ -1,158 +1,160 @@ /* Copyright 2012-2013 Jan Grulich 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 . */ #ifndef NETWORKMANAGERQT_SETTING_H #define NETWORKMANAGERQT_SETTING_H #include #include "generictypes.h" #undef signals #include #define signals Q_SIGNALS #include #include #include #include namespace NetworkManager { class SettingPrivate; /** * Base class for all kinds of setting */ class NETWORKMANAGERQT_EXPORT Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum SettingType { Adsl, Cdma, Gsm, Infiniband, Ipv4, Ipv6, Ppp, Pppoe, Security8021x, Serial, Vpn, Wired, Wireless, WirelessSecurity, Bluetooth, OlpcMesh, Vlan, Wimax, Bond, Bridge, BridgePort, Team, Generic, Tun, Vxlan, IpTunnel, Proxy, User, OvsBridge, - OvsInterface + OvsInterface, + OvsPatch, + OvsPort }; enum SecretFlagType { None = 0, AgentOwned = 0x01, NotSaved = 0x02, NotRequired = 0x04 }; Q_DECLARE_FLAGS(SecretFlags, SecretFlagType) enum MacAddressRandomization { MacAddressRandomizationDefault = 0, MacAddressRandomizationNever, MacAddressRandomizationAlways }; static QString typeAsString(SettingType type); static SettingType typeFromString(const QString &type); explicit Setting(SettingType type); explicit Setting(const Ptr &setting); virtual ~Setting(); /** * @brief Must be reimplemented, default implementation does nothing */ virtual void fromMap(const QVariantMap &map); /** * @brief Must be reimplemented, default implementationd does nothing */ virtual QVariantMap toMap() const; virtual void secretsFromMap(const QVariantMap &map); /** * @brief secretsFromStringMap is a convenience function * to set the secrets from a map of strings. * @param map to extract secrets from */ virtual void secretsFromStringMap(const NMStringMap &map); virtual QVariantMap secretsToMap() const; /** * @brief secretsToStringMap is a convenience function * to get the secrets to map of strings. * @return string map with current secrets */ virtual NMStringMap secretsToStringMap() const; virtual QStringList needSecrets(bool requestNew = false) const; /** * @brief Must be reimplemented, default implementationd does nothing */ virtual QString name() const; void setInitialized(bool initialized); bool isNull() const; void setType(SettingType type); SettingType type() const; protected: SettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(Setting) }; Q_DECLARE_OPERATORS_FOR_FLAGS(Setting::SecretFlags) NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Setting &setting); } #endif // NETWORKMANAGERQT_SETTING_H