9#include "vpnsetting_p.h"
11NetworkManager::VpnSettingPrivate::VpnSettingPrivate()
12 : name(NM_SETTING_VPN_SETTING_NAME)
18NetworkManager::VpnSetting::VpnSetting()
19 : Setting(Setting::Vpn)
20 , d_ptr(new VpnSettingPrivate())
24NetworkManager::VpnSetting::VpnSetting(
const Ptr &other)
26 , d_ptr(new VpnSettingPrivate())
28 setServiceType(other->serviceType());
29 setUsername(other->username());
30 setData(other->data());
31 setSecrets(other->secrets());
32 setPersistent(other->persistent());
33 setTimeout(other->timeout());
36NetworkManager::VpnSetting::~VpnSetting()
48bool NetworkManager::VpnSetting::persistent()
const
55void NetworkManager::VpnSetting::setPersistent(
bool persistent)
59 d->persistent = persistent;
62uint NetworkManager::VpnSetting::timeout()
const
64 Q_D(
const VpnSetting);
69void NetworkManager::VpnSetting::setTimeout(uint timeout)
76void NetworkManager::VpnSetting::setServiceType(
const QString &type)
80 d->serviceType =
type;
83QString NetworkManager::VpnSetting::serviceType()
const
85 Q_D(
const VpnSetting);
87 return d->serviceType;
90void NetworkManager::VpnSetting::setUsername(
const QString &username)
94 d->username = username;
97QString NetworkManager::VpnSetting::username()
const
99 Q_D(
const VpnSetting);
104void NetworkManager::VpnSetting::setData(
const NMStringMap &data)
111NMStringMap NetworkManager::VpnSetting::data()
const
113 Q_D(
const VpnSetting);
118void NetworkManager::VpnSetting::setSecrets(
const NMStringMap &secrets)
122 d->secrets = secrets;
125NMStringMap NetworkManager::VpnSetting::secrets()
const
127 Q_D(
const VpnSetting);
132void NetworkManager::VpnSetting::secretsFromMap(
const QVariantMap &secrets)
134 if (secrets.contains(
QLatin1String(NM_SETTING_VPN_SECRETS))) {
135 setSecrets(qdbus_cast<NMStringMap>(secrets.value(
QLatin1String(NM_SETTING_VPN_SECRETS))));
139QVariantMap NetworkManager::VpnSetting::secretsToMap()
const
141 QVariantMap secretsMap;
142 if (!secrets().isEmpty()) {
152 if (setting.contains(
QLatin1String(NM_SETTING_VPN_SERVICE_TYPE))) {
153 setServiceType(setting.value(
QLatin1String(NM_SETTING_VPN_SERVICE_TYPE)).toString());
156 if (setting.contains(
QLatin1String(NM_SETTING_VPN_USER_NAME))) {
157 setUsername(setting.value(
QLatin1String(NM_SETTING_VPN_USER_NAME)).toString());
161 setData(qdbus_cast<NMStringMap>(setting.value(
QLatin1String(NM_SETTING_VPN_DATA))));
164 if (setting.contains(
QLatin1String(NM_SETTING_VPN_SECRETS))) {
165 setSecrets(qdbus_cast<NMStringMap>(setting.value(
QLatin1String(NM_SETTING_VPN_SECRETS))));
168 if (setting.contains(
QLatin1String(NM_SETTING_VPN_PERSISTENT))) {
169 setPersistent(setting.value(
QLatin1String(NM_SETTING_VPN_PERSISTENT)).toBool());
172 if (setting.contains(
QLatin1String(NM_SETTING_VPN_TIMEOUT))) {
173 setTimeout(setting.value(
QLatin1String(NM_SETTING_VPN_TIMEOUT)).toUInt());
181 if (!serviceType().isEmpty()) {
182 setting.insert(
QLatin1String(NM_SETTING_VPN_SERVICE_TYPE), serviceType());
185 if (!username().isEmpty()) {
186 setting.insert(
QLatin1String(NM_SETTING_VPN_USER_NAME), username());
189 if (!data().isEmpty()) {
193 if (!secrets().isEmpty()) {
197 setting.insert(
QLatin1String(NM_SETTING_VPN_PERSISTENT), persistent());
198 setting.insert(
QLatin1String(NM_SETTING_VPN_TIMEOUT), timeout());
209 if (list.
count() % 2 == 0) {
210 for (
int i = 0; i < list.
count(); i += 2) {
211 if (d->secrets.contains(list[i])) {
212 d->secrets.remove(list[i]);
214 d->secrets.insert(list[i], list[i + 1]);
225 for (
auto it = values.
begin(); it != values.
end(); ++it) {
226 list << it.key() << it.
value();
234 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
235 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
237 dbg.
nospace() << NM_SETTING_VPN_SERVICE_TYPE <<
": " << setting.serviceType() <<
'\n';
238 dbg.
nospace() << NM_SETTING_VPN_USER_NAME <<
": " << setting.username() <<
'\n';
239 dbg.
nospace() << NM_SETTING_VPN_DATA <<
": " << setting.data() <<
'\n';
240 dbg.
nospace() << NM_SETTING_VPN_PERSISTENT <<
": " << setting.persistent() <<
'\n';
241 dbg.
nospace() << NM_SETTING_VPN_TIMEOUT <<
": " << setting.timeout() <<
'\n';
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
NMStringMap secretsToStringMap() const override
secretsToStringMap is a convenience function to get the secrets to map of strings.
void secretsFromStringMap(const NMStringMap &map) override
secretsFromStringMap is a convenience function to set the secrets from a map of strings.
Type type(const QSqlDatabase &db)
qsizetype count() const const
T value(qsizetype i) const const
iterator insert(const Key &key, const T &value)
QString join(QChar separator) const const
QVariant fromValue(T &&value)