7#include "adslsetting.h"
8#include "adslsetting_p.h"
13NetworkManager::AdslSettingPrivate::AdslSettingPrivate()
14 : name(NM_SETTING_ADSL_SETTING_NAME)
15 , passwordFlags(Setting::
None)
17 , encapsulation(AdslSetting::UnknownEncapsulation)
23NetworkManager::AdslSetting::AdslSetting()
24 : Setting(Setting::Adsl)
25 , d_ptr(new AdslSettingPrivate())
29NetworkManager::AdslSetting::AdslSetting(
const AdslSetting::Ptr &other)
31 , d_ptr(new AdslSettingPrivate())
33 setUsername(other->username());
34 setPassword(other->password());
35 setProtocol(other->protocol());
36 setPasswordFlags(other->passwordFlags());
37 setProtocol(other->protocol());
38 setEncapsulation(other->encapsulation());
43NetworkManager::AdslSetting::~AdslSetting()
55void NetworkManager::AdslSetting::setUsername(
const QString &username)
59 d->username = username;
62QString NetworkManager::AdslSetting::username()
const
64 Q_D(
const AdslSetting);
69void NetworkManager::AdslSetting::setPassword(
const QString &password)
73 d->password = password;
76QString NetworkManager::AdslSetting::password()
const
78 Q_D(
const AdslSetting);
87 d->passwordFlags = flags;
92 Q_D(
const AdslSetting);
94 return d->passwordFlags;
97void NetworkManager::AdslSetting::setProtocol(NetworkManager::AdslSetting::Protocol protocol)
101 d->protocol = protocol;
104NetworkManager::AdslSetting::Protocol NetworkManager::AdslSetting::protocol()
const
106 Q_D(
const AdslSetting);
111void NetworkManager::AdslSetting::setEncapsulation(NetworkManager::AdslSetting::Encapsulation encapsulation)
115 d->encapsulation = encapsulation;
118NetworkManager::AdslSetting::Encapsulation NetworkManager::AdslSetting::encapsulation()
const
120 Q_D(
const AdslSetting);
122 return d->encapsulation;
125void NetworkManager::AdslSetting::setVpi(quint32 vpi)
132quint32 NetworkManager::AdslSetting::vpi()
const
134 Q_D(
const AdslSetting);
139void NetworkManager::AdslSetting::setVci(quint32 vci)
146quint32 NetworkManager::AdslSetting::vci()
const
148 Q_D(
const AdslSetting);
153QStringList NetworkManager::AdslSetting::needSecrets(
bool requestNew)
const
157 if ((password().isEmpty() || requestNew) && !passwordFlags().testFlag(NotRequired)) {
166 if (setting.contains(
QLatin1String(NM_SETTING_ADSL_USERNAME))) {
167 setUsername(setting.value(
QLatin1String(NM_SETTING_ADSL_USERNAME)).toString());
170 if (setting.contains(
QLatin1String(NM_SETTING_ADSL_PASSWORD))) {
171 setPassword(setting.value(
QLatin1String(NM_SETTING_ADSL_PASSWORD)).toString());
174 if (setting.contains(
QLatin1String(NM_SETTING_ADSL_PASSWORD_FLAGS))) {
178 if (setting.contains(
QLatin1String(NM_SETTING_ADSL_PROTOCOL))) {
181 if (protocol ==
QLatin1String(NM_SETTING_ADSL_PROTOCOL_PPPOA)) {
183 }
else if (protocol ==
QLatin1String(NM_SETTING_ADSL_PROTOCOL_PPPOE)) {
185 }
else if (protocol ==
QLatin1String(NM_SETTING_ADSL_PROTOCOL_IPOATM)) {
190 if (setting.contains(
QLatin1String(NM_SETTING_ADSL_ENCAPSULATION))) {
191 const QString encapsulation = setting.value(
QLatin1String(NM_SETTING_ADSL_ENCAPSULATION)).toString();
193 if (encapsulation ==
QLatin1String(NM_SETTING_ADSL_ENCAPSULATION_VCMUX)) {
194 setEncapsulation(Vcmux);
195 }
else if (encapsulation ==
QLatin1String(NM_SETTING_ADSL_ENCAPSULATION_LLC)) {
196 setEncapsulation(Llc);
201 setVpi(setting.value(
QLatin1String(NM_SETTING_ADSL_VPI)).toUInt());
205 setVci(setting.value(
QLatin1String(NM_SETTING_ADSL_VCI)).toUInt());
213 if (!username().isEmpty()) {
214 setting.insert(
QLatin1String(NM_SETTING_ADSL_USERNAME), username());
217 if (!password().isEmpty()) {
218 setting.insert(
QLatin1String(NM_SETTING_ADSL_PASSWORD), password());
221 if (passwordFlags() != None) {
222 setting.insert(
QLatin1String(NM_SETTING_ADSL_PASSWORD_FLAGS), (
int)passwordFlags());
225 switch (protocol()) {
235 case UnknownProtocol:
239 switch (encapsulation()) {
246 case UnknownEncapsulation:
263 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
264 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
266 dbg.
nospace() << NM_SETTING_ADSL_USERNAME <<
": " << setting.username() <<
'\n';
267 dbg.
nospace() << NM_SETTING_ADSL_PASSWORD <<
": " << setting.password() <<
'\n';
268 dbg.
nospace() << NM_SETTING_ADSL_PASSWORD_FLAGS <<
": " << setting.passwordFlags() <<
'\n';
269 dbg.
nospace() << NM_SETTING_ADSL_PROTOCOL <<
": " << setting.protocol() <<
'\n';
270 dbg.
nospace() << NM_SETTING_ADSL_ENCAPSULATION <<
": " << setting.encapsulation() <<
'\n';
271 dbg.
nospace() << NM_SETTING_ADSL_VPI <<
": " << setting.vpi() <<
'\n';
272 dbg.
nospace() << NM_SETTING_ADSL_VCI <<
": " << setting.vci() <<
'\n';
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.