1/*
2 SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com>
3 SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#include "wimaxsetting.h"
9#include "wimaxsetting_p.h"
10
11#include <QDebug>
12
13NetworkManager::WimaxSettingPrivate::WimaxSettingPrivate()
14 : name(NM_SETTING_WIMAX_SETTING_NAME)
15{
16}
17
18NetworkManager::WimaxSetting::WimaxSetting()
19 : Setting(Setting::Wimax)
20 , d_ptr(new WimaxSettingPrivate())
21{
22}
23
24NetworkManager::WimaxSetting::WimaxSetting(const Ptr &other)
25 : Setting(other)
26 , d_ptr(new WimaxSettingPrivate())
27{
28 setNetworkName(other->networkName());
29 setMacAddress(other->macAddress());
30}
31
32NetworkManager::WimaxSetting::~WimaxSetting()
33{
34 delete d_ptr;
35}
36
37QString NetworkManager::WimaxSetting::name() const
38{
39 Q_D(const WimaxSetting);
40
41 return d->name;
42}
43
44void NetworkManager::WimaxSetting::setNetworkName(const QString &name)
45{
46 Q_D(WimaxSetting);
47
48 d->networkName = name;
49}
50
51QString NetworkManager::WimaxSetting::networkName() const
52{
53 Q_D(const WimaxSetting);
54
55 return d->networkName;
56}
57
58void NetworkManager::WimaxSetting::setMacAddress(const QByteArray &address)
59{
60 Q_D(WimaxSetting);
61
62 d->macAddress = address;
63}
64
65QByteArray NetworkManager::WimaxSetting::macAddress() const
66{
67 Q_D(const WimaxSetting);
68
69 return d->macAddress;
70}
71
72void NetworkManager::WimaxSetting::fromMap(const QVariantMap &setting)
73{
74 if (setting.contains(key: QLatin1String(NM_SETTING_WIMAX_NETWORK_NAME))) {
75 setNetworkName(setting.value(key: QLatin1String(NM_SETTING_WIMAX_NETWORK_NAME)).toString());
76 }
77
78 if (setting.contains(key: QLatin1String(NM_SETTING_WIMAX_MAC_ADDRESS))) {
79 setMacAddress(setting.value(key: QLatin1String(NM_SETTING_WIMAX_MAC_ADDRESS)).toByteArray());
80 }
81}
82
83QVariantMap NetworkManager::WimaxSetting::toMap() const
84{
85 QVariantMap setting;
86
87 if (!networkName().isEmpty()) {
88 setting.insert(key: QLatin1String(NM_SETTING_WIMAX_NETWORK_NAME), value: networkName());
89 }
90
91 if (!macAddress().isEmpty()) {
92 setting.insert(key: QLatin1String(NM_SETTING_WIMAX_MAC_ADDRESS), value: macAddress());
93 }
94
95 return setting;
96}
97
98QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::WimaxSetting &setting)
99{
100 dbg.nospace() << "type: " << setting.typeAsString(type: setting.type()) << '\n';
101 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
102
103 dbg.nospace() << NM_SETTING_WIMAX_NETWORK_NAME << ": " << setting.networkName() << '\n';
104 dbg.nospace() << NM_SETTING_WIMAX_MAC_ADDRESS << ": " << setting.macAddress() << '\n';
105
106 return dbg.maybeSpace();
107}
108

source code of networkmanager-qt/src/settings/wimaxsetting.cpp