You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kf5-networkmanager-qt/nm-qt-add-generic-setting.p...

514 lines
16 KiB

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 21f9665..f7abff4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -112,6 +112,7 @@ if (${NETWORKMANAGER_VERSION} VERSION_EQUAL 0.9.10.0 OR ${NETWORKMANAGER_VERSION
set(NetworkManagerQt_SETTINGS_SRCS
${NetworkManagerQt_SETTINGS_SRCS}
settings/teamsetting.cpp
+ settings/genericsetting.cpp
)
set(DBUS_INTERFACE_SRCS
@@ -196,6 +197,7 @@ ecm_generate_headers(NetworkManagerQt_SETTINGS_HEADERS
CdmaSetting
ConnectionSettings
GsmSetting
+ GenericSetting
InfinibandSetting
Ipv4Setting
Ipv6Setting
diff --git a/src/settings/connectionsettings.cpp b/src/settings/connectionsettings.cpp
index 6584280..bf491e5 100644
--- a/src/settings/connectionsettings.cpp
+++ b/src/settings/connectionsettings.cpp
@@ -62,7 +62,9 @@
#if NM_CHECK_VERSION(0, 9, 10)
#include "teamsetting.h"
+#include "genericsetting.h"
#include <nm-setting-team.h>
+#include <nm-setting-generic.h>
#endif
#include <QtCore/QUuid>
@@ -179,6 +181,11 @@ void NetworkManager::ConnectionSettingsPrivate::initSettings(NMBluetoothCapabili
addSetting(Setting::Ptr(new Ipv4Setting()));
addSetting(Setting::Ptr(new Ipv6Setting()));
break;
+ case ConnectionSettings::Generic:
+ addSetting(Setting::Ptr(new GenericSetting()));
+ addSetting(Setting::Ptr(new Ipv4Setting()));
+ addSetting(Setting::Ptr(new Ipv6Setting()));
+ break;
#endif
case ConnectionSettings::Unknown:
default:
@@ -281,6 +288,11 @@ void NetworkManager::ConnectionSettingsPrivate::initSettings(const NetworkManage
addSetting(connectionSettings->setting(Setting::Ipv4));
addSetting(connectionSettings->setting(Setting::Ipv6));
break;
+ case ConnectionSettings::Generic:
+ addSetting(connectionSettings->setting(Setting::Generic));
+ addSetting(connectionSettings->setting(Setting::Ipv4));
+ addSetting(connectionSettings->setting(Setting::Ipv6));
+ break;
#endif
case ConnectionSettings::Unknown:
default:
@@ -321,8 +333,10 @@ NetworkManager::ConnectionSettings::ConnectionType NetworkManager::ConnectionSet
} else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME)) {
type = Wireless;
#if NM_CHECK_VERSION(0, 9, 10)
- } else if (typeString == QLatin1String(NM_SETTING_TEAM_SETTING_NAME)) {
+ } else if (typeString == QLatin1String(NM_SETTING_TEAM_SETTING_NAME)) {
type = Team;
+ } else if (typeString == QLatin1String(NM_SETTING_GENERIC_SETTING_NAME)) {
+ type = Generic;
#endif
}
@@ -380,6 +394,9 @@ QString NetworkManager::ConnectionSettings::typeAsString(NetworkManager::Connect
case Team:
typeString = QLatin1String(NM_SETTING_TEAM_SETTING_NAME);
break;
+ case Generic:
+ typeString = QLatin1String(NM_SETTING_GENERIC_SETTING_NAME);
+ break;
#endif
default:
break;
diff --git a/src/settings/connectionsettings.h b/src/settings/connectionsettings.h
index cdf4a27..ee06384 100644
--- a/src/settings/connectionsettings.h
+++ b/src/settings/connectionsettings.h
@@ -62,7 +62,8 @@ public:
Wired,
Wireless,
#if NM_CHECK_VERSION(0, 9, 10)
- Team
+ Team,
+ Generic
#endif
};
diff --git a/src/settings/genericsetting.cpp b/src/settings/genericsetting.cpp
new file mode 100644
index 0000000..7c3ce5c
--- /dev/null
+++ b/src/settings/genericsetting.cpp
@@ -0,0 +1,73 @@
+/*
+ Copyright 2015 Jan Grulich <jgrulich@redhat.com>
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#include "genericsetting.h"
+#include "genericsetting_p.h"
+
+#include "nmdebug.h"
+
+#include <nm-setting-generic.h>
+
+NetworkManager::GenericSettingPrivate::GenericSettingPrivate()
+ : name(NM_SETTING_GENERIC_SETTING_NAME)
+{ }
+
+NetworkManager::GenericSetting::GenericSetting()
+ : Setting(Setting::Generic)
+ , d_ptr(new GenericSettingPrivate())
+{ }
+
+NetworkManager::GenericSetting::GenericSetting(const Ptr &other)
+ : Setting(other)
+ , d_ptr(new GenericSettingPrivate())
+{
+}
+
+NetworkManager::GenericSetting::~GenericSetting()
+{
+ delete d_ptr;
+}
+
+QString NetworkManager::GenericSetting::name() const
+{
+ Q_D(const GenericSetting);
+
+ return d->name;
+}
+
+void NetworkManager::GenericSetting::fromMap(const QVariantMap &setting)
+{
+ Q_UNUSED(setting);
+}
+
+QVariantMap NetworkManager::GenericSetting::toMap() const
+{
+ QVariantMap setting;
+
+ return setting;
+}
+
+QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::GenericSetting &setting)
+{
+ dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
+ dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
+
+ return dbg.maybeSpace();
+}
diff --git a/src/settings/genericsetting.h b/src/settings/genericsetting.h
new file mode 100644
index 0000000..610568a
--- /dev/null
+++ b/src/settings/genericsetting.h
@@ -0,0 +1,63 @@
+/*
+ Copyright 2015 Jan Grulich <jgrulich@redhat.com>
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef NETWORKMANAGERQT_GENERIC_SETTING_H
+#define NETWORKMANAGERQT_GENERIC_SETTING_H
+
+#include <networkmanagerqt_export.h>
+#include "setting.h"
+
+#include <QtCore/QString>
+
+namespace NetworkManager
+{
+
+class GenericSettingPrivate;
+
+/**
+ * Represents generic setting
+ */
+class NETWORKMANAGERQT_EXPORT GenericSetting : public Setting
+{
+public:
+ typedef QSharedPointer<GenericSetting> Ptr;
+ typedef QList<Ptr> List;
+ GenericSetting();
+ explicit GenericSetting(const Ptr &other);
+ ~GenericSetting();
+
+ QString name() const Q_DECL_OVERRIDE;
+
+ void fromMap(const QVariantMap &setting) Q_DECL_OVERRIDE;
+
+ QVariantMap toMap() const Q_DECL_OVERRIDE;
+
+protected:
+ GenericSettingPrivate *d_ptr;
+
+private:
+ Q_DECLARE_PRIVATE(GenericSetting)
+};
+
+NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const GenericSetting &setting);
+
+}
+
+#endif // NETWORKMANAGERQT_GENERIC_SETTING_H
diff --git a/src/settings/genericsetting_p.h b/src/settings/genericsetting_p.h
new file mode 100644
index 0000000..9f59861
--- /dev/null
+++ b/src/settings/genericsetting_p.h
@@ -0,0 +1,39 @@
+/*
+ Copyright 2015 Jan Grulich <jgrulich@redhat.com>
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef NETWORKMANAGERQT_GENERIC_SETTING_P_H
+#define NETWORKMANAGERQT_GENERIC_SETTING_P_H
+
+#include <QtCore/QString>
+
+namespace NetworkManager
+{
+
+class GenericSettingPrivate
+{
+public:
+ GenericSettingPrivate();
+
+ QString name;
+};
+
+}
+
+#endif // NETWORKMANAGERQT_GENERIC_SETTING_P_H
diff --git a/src/settings/setting.cpp b/src/settings/setting.cpp
index e25972b..a0b6c38 100644
--- a/src/settings/setting.cpp
+++ b/src/settings/setting.cpp
@@ -38,6 +38,7 @@
#include <nm-setting-serial.h>
#if NM_CHECK_VERSION(0, 9, 10)
#include <nm-setting-team.h>
+#include <nm-setting-generic.h>
#endif
#include <nm-setting-vlan.h>
#include <nm-setting-vpn.h>
@@ -136,6 +137,9 @@ QString NetworkManager::Setting::typeAsString(NetworkManager::Setting::SettingTy
case Team:
typeString = QLatin1String(NM_SETTING_TEAM_SETTING_NAME);
break;
+ case NetworkManager::Setting::Generic:
+ typeString = QLatin1String(NM_SETTING_GENERIC_SETTING_NAME);
+ break;
#endif
default:
break;
@@ -187,6 +191,8 @@ NetworkManager::Setting::SettingType NetworkManager::Setting::typeFromString(con
#if NM_CHECK_VERSION(0, 9, 10)
} else if (typeString == QLatin1String(NM_SETTING_TEAM_SETTING_NAME)) {
type = Team;
+ } else if (typeString == QLatin1String(NM_SETTING_GENERIC_SETTING_NAME)) {
+ type = Generic;
#endif
}
diff --git a/src/settings/setting.h b/src/settings/setting.h
index 53dc3af..b725118 100644
--- a/src/settings/setting.h
+++ b/src/settings/setting.h
@@ -44,7 +44,7 @@ public:
typedef QSharedPointer<Setting> Ptr;
typedef QList<Ptr> 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
+ Vpn, Wired, Wireless, WirelessSecurity, Bluetooth, OlpcMesh, Vlan, Wimax, Bond, Bridge, BridgePort, Team, Generic
};
enum SecretFlagType {None = 0, AgentOwned = 0x01, NotSaved = 0x02, NotRequired = 0x04};
Q_DECLARE_FLAGS(SecretFlags, SecretFlagType)
diff --git a/src/settings/template.cpp b/src/settings/template.cpp
index 0e8c7b1..8f23e1c 100644
--- a/src/settings/template.cpp
+++ b/src/settings/template.cpp
@@ -1,5 +1,5 @@
/*
- Copyright 2012-2013 Jan Grulich <jgrulich@redhat.com>
+ Copyright 2012-2015 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -24,13 +24,11 @@
// TODO: Uncomment and replace the template with the setting that you want to implement
//#include <nm-setting-template.h>
-#include <QtCore/QDebug>
-
-NetworkManager::Settings::TemplateSettingPrivate::TemplateSettingPrivate()
- : name(QString("template"))
+NetworkManager::TemplateSettingPrivate::TemplateSettingPrivate()
+// : name(NM_SETTING_TEMPLATE_SETTING_NAME)
{ }
-NetworkManager::Settings::TemplateSetting::TemplateSetting():
+NetworkManager::TemplateSetting::TemplateSetting():
/* TODO: Uncomment and replace the template with the setting that you want to implement
* This setting must also be added into the enum in base class
*/
@@ -38,8 +36,8 @@ NetworkManager::Settings::TemplateSetting::TemplateSetting():
d_ptr(new TemplateSettingPrivate())
{ }
-NetworkManager::Settings::TemplateSetting::TemplateSetting(TemplateSetting *setting)
- : Setting(setting)
+NetworkManager::TemplateSetting::TemplateSetting(const Ptr &other)
+ : Setting(other)
, d_ptr(new TemplateSettingPrivate())
{
/*
@@ -48,19 +46,19 @@ NetworkManager::Settings::TemplateSetting::TemplateSetting(TemplateSetting *sett
*/
}
-NetworkManager::Settings::TemplateSetting::~TemplateSetting()
+NetworkManager::TemplateSetting::~TemplateSetting()
{
delete d_ptr;
}
-QString NetworkManager::Settings::TemplateSetting::name() const
+QString NetworkManager::TemplateSetting::name() const
{
Q_D(const TemplateSetting);
return d->name;
}
-void NetworkManager::Settings::TemplateSetting::fromMap(const QVariantMap &setting)
+void NetworkManager::TemplateSetting::fromMap(const QVariantMap &setting)
{
/*
* if (setting.contains(QLatin1String(NM_SETTING_TEMPLATE_FOO))) {
@@ -70,7 +68,7 @@ void NetworkManager::Settings::TemplateSetting::fromMap(const QVariantMap &setti
*/
}
-QVariantMap NetworkManager::Settings::TemplateSetting::toMap() const
+QVariantMap NetworkManager::TemplateSetting::toMap() const
{
QVariantMap setting;
@@ -84,12 +82,10 @@ QVariantMap NetworkManager::Settings::TemplateSetting::toMap() const
return setting;
}
-void NetworkManager::Settings::TemplateSetting::printSetting()
+QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::TemplateSetting &setting)
{
- NetworkManager::Settings::Setting::printSetting();
+ dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
+ dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
- /*
- * qCDebug(NMQT) << "FOO - " << foo();
- *
- */
+ return dbg.maybeSpace();
}
diff --git a/src/settings/template.h b/src/settings/template.h
index 91d1516..4f9f680 100644
--- a/src/settings/template.h
+++ b/src/settings/template.h
@@ -1,5 +1,5 @@
/*
- Copyright 2012-2013 Jan Grulich <jgrulich@redhat.com>
+ Copyright 2012-2015 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -22,31 +22,32 @@
#define NETWORKMANAGERQT_TEMPLATE_SETTING_H
#include <networkmanagerqt_export.h>
-#include "generictypes.h"
#include "setting.h"
#include <QtCore/QString>
namespace NetworkManager
{
-namespace Settings
-{
+
class TemplateSettingPrivate;
+/**
+ * Represents generic setting
+ */
class NETWORKMANAGERQT_EXPORT TemplateSetting : public Setting
{
public:
+ typedef QSharedPointer<TemplateSetting> Ptr;
+ typedef QList<Ptr> List;
TemplateSetting();
- explicit TemplateSetting(TemplateSetting *);
+ explicit TemplateSetting(const Ptr &other);
~TemplateSetting();
- QString name() const;
-
- void fromMap(const QVariantMap &setting);
+ QString name() const Q_DECL_OVERRIDE;
- QVariantMap toMap() const;
+ void fromMap(const QVariantMap &setting) Q_DECL_OVERRIDE;
- void printSetting();
+ QVariantMap toMap() const Q_DECL_OVERRIDE;
protected:
TemplateSettingPrivate *d_ptr;
@@ -54,7 +55,9 @@ protected:
private:
Q_DECLARE_PRIVATE(TemplateSetting)
};
-}
+
+NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const TemplateSetting &setting);
+
}
#endif // NETWORKMANAGERQT_TEMPLATE_SETTING_H
diff --git a/src/settings/template_p.h b/src/settings/template_p.h
index cc952a5..579f17b 100644
--- a/src/settings/template_p.h
+++ b/src/settings/template_p.h
@@ -1,5 +1,5 @@
/*
- Copyright 2012-2013 Jan Grulich <jgrulich@redhat.com>
+ Copyright 2012-2015 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -25,8 +25,7 @@
namespace NetworkManager
{
-namespace Settings
-{
+
class TemplateSettingPrivate
{
public:
@@ -34,7 +33,7 @@ public:
QString name;
};
-}
+
}
#endif // NETWORKMANAGERQT_TEMPLATE_SETTING_P_H