8#include "gsmsetting_p.h"
10#define NM_SETTING_GSM_NETWORK_TYPE "network-type"
11#define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands"
15NetworkManager::GsmSettingPrivate::GsmSettingPrivate()
16 : name(NM_SETTING_GSM_SETTING_NAME)
25NetworkManager::GsmSetting::GsmSetting()
26 : Setting(Setting::Gsm)
27 , d_ptr(new GsmSettingPrivate())
31NetworkManager::GsmSetting::GsmSetting(
const Ptr &other)
33 , d_ptr(new GsmSettingPrivate())
35 setNumber(other->number());
36 setUsername(other->username());
37 setPassword(other->password());
38 setPasswordFlags(other->passwordFlags());
40 setNetworkId(other->networkId());
41 setNetworkType(other->networkType());
43 setPinFlags(other->pinFlags());
44 setAllowedBand(other->allowedBand());
45 setHomeOnly(other->homeOnly());
46 setDeviceId(other->deviceId());
47 setSimId(other->simId());
48 setSimOperatorId(other->simOperatorId());
51NetworkManager::GsmSetting::~GsmSetting()
58 Q_D(
const GsmSetting);
63void NetworkManager::GsmSetting::setNumber(
const QString &number)
70QString NetworkManager::GsmSetting::number()
const
72 Q_D(
const GsmSetting);
77void NetworkManager::GsmSetting::setUsername(
const QString &username)
81 d->username = username;
84QString NetworkManager::GsmSetting::username()
const
91void NetworkManager::GsmSetting::setPassword(
const QString &password)
95 d->password = password;
98QString NetworkManager::GsmSetting::password()
const
105void NetworkManager::GsmSetting::setPasswordFlags(GsmSetting::SecretFlags flags)
109 d->passwordFlags = flags;
112NetworkManager::GsmSetting::SecretFlags NetworkManager::GsmSetting::passwordFlags()
const
116 return d->passwordFlags;
119void NetworkManager::GsmSetting::setApn(
const QString &apn)
126QString NetworkManager::GsmSetting::apn()
const
133void NetworkManager::GsmSetting::setNetworkId(
const QString &
id)
140QString NetworkManager::GsmSetting::networkId()
const
151 d->networkType = type;
154NetworkManager::GsmSetting::NetworkType NetworkManager::GsmSetting::networkType()
const
158 return d->networkType;
161void NetworkManager::GsmSetting::setPin(
const QString &pin)
168QString NetworkManager::GsmSetting::pin()
const
175void NetworkManager::GsmSetting::setPinFlags(GsmSetting::SecretFlags flags)
182NetworkManager::GsmSetting::SecretFlags NetworkManager::GsmSetting::pinFlags()
const
193 d->allowedBand = band;
196quint32 NetworkManager::GsmSetting::allowedBand()
const
200 return d->allowedBand;
203void NetworkManager::GsmSetting::setHomeOnly(
bool homeOnly)
207 d->homeOnly = homeOnly;
210bool NetworkManager::GsmSetting::homeOnly()
const
217void NetworkManager::GsmSetting::setDeviceId(
const QString &
id)
224QString NetworkManager::GsmSetting::deviceId()
const
231void NetworkManager::GsmSetting::setSimId(
const QString &
id)
238QString NetworkManager::GsmSetting::simId()
const
245void NetworkManager::GsmSetting::setSimOperatorId(
const QString &
id)
249 d->simOperatorId = id;
252QString NetworkManager::GsmSetting::simOperatorId()
const
256 return d->simOperatorId;
259void NetworkManager::GsmSetting::secretsFromMap(
const QVariantMap &secrets)
261 if (secrets.contains(QLatin1String(NM_SETTING_GSM_PASSWORD))) {
262 setPassword(secrets.value(QLatin1String(NM_SETTING_GSM_PASSWORD)).
toString());
265 if (secrets.contains(QLatin1String(NM_SETTING_GSM_PIN))) {
266 setPin(secrets.value(QLatin1String(NM_SETTING_GSM_PIN)).
toString());
270QVariantMap NetworkManager::GsmSetting::secretsToMap()
const
274 if (!password().isEmpty()) {
275 secrets.insert(QLatin1String(NM_SETTING_GSM_PASSWORD), password());
278 if (!pin().isEmpty()) {
279 secrets.insert(QLatin1String(NM_SETTING_GSM_PIN), pin());
285QStringList NetworkManager::GsmSetting::needSecrets(
bool requestNew)
const
289 if ((password().isEmpty() || requestNew) && !passwordFlags().testFlag(NotRequired)) {
290 list << QLatin1String(NM_SETTING_GSM_PASSWORD);
293 if ((pin().isEmpty() || requestNew) && !pinFlags().testFlag(NotRequired)) {
294 list << QLatin1String(NM_SETTING_GSM_PIN);
302 if (setting.contains(
QLatin1String(NM_SETTING_GSM_NUMBER))) {
303 setNumber(setting.value(
QLatin1String(NM_SETTING_GSM_NUMBER)).toString());
306 if (setting.contains(
QLatin1String(NM_SETTING_GSM_USERNAME))) {
307 setUsername(setting.value(
QLatin1String(NM_SETTING_GSM_USERNAME)).toString());
311 if (setting.contains(
QLatin1String(NM_SETTING_GSM_PASSWORD))) {
312 setPassword(setting.value(
QLatin1String(NM_SETTING_GSM_PASSWORD)).toString());
315 if (setting.contains(
QLatin1String(NM_SETTING_GSM_PASSWORD_FLAGS))) {
316 setPasswordFlags((SecretFlags)setting.value(
QLatin1String(NM_SETTING_GSM_PASSWORD_FLAGS)).toInt());
320 setApn(setting.value(
QLatin1String(NM_SETTING_GSM_APN)).toString());
323 if (setting.contains(
QLatin1String(NM_SETTING_GSM_NETWORK_ID))) {
324 setNetworkId(setting.value(
QLatin1String(NM_SETTING_GSM_NETWORK_ID)).toString());
327 if (setting.contains(
QLatin1String(NM_SETTING_GSM_NETWORK_TYPE))) {
333 setPin(setting.value(
QLatin1String(NM_SETTING_GSM_PIN)).toString());
336 if (setting.contains(
QLatin1String(NM_SETTING_GSM_PIN_FLAGS))) {
337 setPinFlags((SecretFlags)setting.value(
QLatin1String(NM_SETTING_GSM_PIN_FLAGS)).toInt());
340 if (setting.contains(
QLatin1String(NM_SETTING_GSM_ALLOWED_BANDS))) {
344 if (setting.contains(
QLatin1String(NM_SETTING_GSM_HOME_ONLY))) {
345 setHomeOnly(setting.value(
QLatin1String(NM_SETTING_GSM_HOME_ONLY)).toBool());
348 if (setting.contains(
QLatin1String(NM_SETTING_GSM_DEVICE_ID))) {
349 setDeviceId(setting.value(
QLatin1String(NM_SETTING_GSM_DEVICE_ID)).toString());
352 if (setting.contains(
QLatin1String(NM_SETTING_GSM_SIM_ID))) {
353 setSimId(setting.value(
QLatin1String(NM_SETTING_GSM_SIM_ID)).toString());
356 if (setting.contains(
QLatin1String(NM_SETTING_GSM_SIM_OPERATOR_ID))) {
357 setSimOperatorId(setting.value(
QLatin1String(NM_SETTING_GSM_SIM_OPERATOR_ID)).toString());
365 if (!number().isEmpty()) {
366 setting.insert(
QLatin1String(NM_SETTING_GSM_NUMBER), number());
369 if (!username().isEmpty()) {
370 setting.insert(
QLatin1String(NM_SETTING_GSM_USERNAME), username());
374 if (!password().isEmpty()) {
375 setting.insert(
QLatin1String(NM_SETTING_GSM_PASSWORD), password());
380 if (!apn().isEmpty()) {
384 if (!networkId().isEmpty()) {
385 setting.insert(
QLatin1String(NM_SETTING_GSM_NETWORK_ID), networkId());
388 if (networkType() != -1) {
389 setting.insert(
QLatin1String(NM_SETTING_GSM_NETWORK_TYPE), networkType());
392 if (!pin().isEmpty()) {
396 setting.insert(
QLatin1String(NM_SETTING_GSM_PIN_FLAGS), (
int)pinFlags());
398 if (allowedBand() != 1) {
399 setting.insert(
QLatin1String(NM_SETTING_GSM_ALLOWED_BANDS), allowedBand());
402 setting.insert(
QLatin1String(NM_SETTING_GSM_HOME_ONLY), homeOnly());
405 if (!deviceId().isEmpty()) {
406 setting.insert(
QLatin1String(NM_SETTING_GSM_DEVICE_ID), deviceId());
409 if (!simId().isEmpty()) {
410 setting.insert(
QLatin1String(NM_SETTING_GSM_SIM_ID), simId());
413 if (!simOperatorId().isEmpty()) {
414 setting.insert(
QLatin1String(NM_SETTING_GSM_SIM_OPERATOR_ID), simOperatorId());
422 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
423 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
425 dbg.
nospace() << NM_SETTING_GSM_NUMBER <<
": " << setting.number() <<
'\n';
426 dbg.
nospace() << NM_SETTING_GSM_USERNAME <<
": " << setting.username() <<
'\n';
427 dbg.
nospace() << NM_SETTING_GSM_PASSWORD <<
": " << setting.password() <<
'\n';
428 dbg.
nospace() << NM_SETTING_GSM_PASSWORD_FLAGS <<
": " << setting.passwordFlags() <<
'\n';
429 dbg.
nospace() << NM_SETTING_GSM_APN <<
": " << setting.apn() <<
'\n';
430 dbg.
nospace() << NM_SETTING_GSM_NETWORK_ID <<
": " << setting.networkId() <<
'\n';
431 dbg.
nospace() << NM_SETTING_GSM_NETWORK_TYPE <<
": " << setting.networkType() <<
'\n';
432 dbg.
nospace() << NM_SETTING_GSM_ALLOWED_BANDS <<
": " << setting.allowedBand() <<
'\n';
433 dbg.
nospace() << NM_SETTING_GSM_PIN <<
": " << setting.pin() <<
'\n';
434 dbg.
nospace() << NM_SETTING_GSM_PIN_FLAGS <<
": " << setting.pinFlags() <<
'\n';
435 dbg.
nospace() << NM_SETTING_GSM_HOME_ONLY <<
": " << setting.homeOnly() <<
'\n';
436 dbg.
nospace() << NM_SETTING_GSM_DEVICE_ID <<
": " << setting.deviceId() <<
'\n';
437 dbg.
nospace() << NM_SETTING_GSM_SIM_ID <<
": " << setting.simId() <<
'\n';
438 dbg.
nospace() << NM_SETTING_GSM_SIM_OPERATOR_ID <<
": " << setting.simOperatorId() <<
'\n';
void setNetworkType(NetworkType type)
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.
void setAllowedBand(quint32 band)
char * toString(const EngineQuery &query)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
This class allows querying the underlying system to discover the available network interfaces and rea...
iterator insert(const_iterator before, parameter_type value)