NetworkManagerQt

wimaxdevice.cpp
1/*
2 SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net>
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 "wimaxdevice.h"
9#include "manager_p.h"
10#include "wimaxdevice_p.h"
11
12#include "nmdebug.h"
13
14#include <QDBusMetaType>
15
16NetworkManager::WimaxDevicePrivate::WimaxDevicePrivate(const QString &path, WimaxDevice *q)
17 : DevicePrivate(path, q)
18#ifdef NMQT_STATIC
19 , wimaxIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
20#else
21 , wimaxIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
22#endif
23{
24 qDBusRegisterMetaType<QList<QDBusObjectPath>>();
25 const QList<QDBusObjectPath> nsps = wimaxIface.nsps();
26 for (const QDBusObjectPath &op : nsps) {
27 nspMap.insert(op.path(), NetworkManager::WimaxNsp::Ptr());
28 // qCDebug(NMQT) << " " << op.path();
29 }
30}
31
33 : Device(*new WimaxDevicePrivate(path, this), parent)
34{
36
37 connect(&d->wimaxIface, &OrgFreedesktopNetworkManagerDeviceWiMaxInterface::NspAdded, d, &WimaxDevicePrivate::nspAdded);
38 connect(&d->wimaxIface, &OrgFreedesktopNetworkManagerDeviceWiMaxInterface::NspRemoved, d, &WimaxDevicePrivate::nspRemoved);
39
40 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->wimaxIface.staticInterfaceName(), path);
41 if (!initialProperties.isEmpty()) {
42 d->propertiesChanged(initialProperties);
43 }
44}
45
49
54
56{
57 Q_D(const WimaxDevice);
58 return d->nspMap.keys();
59}
60
62{
63 Q_D(const WimaxDevice);
64 return findNsp(d->activeNsp);
65}
66
68{
69 Q_D(const WimaxDevice);
70 return d->hardwareAddress;
71}
72
74{
75 Q_D(const WimaxDevice);
76 return d->bsid;
77}
78
80{
81 Q_D(const WimaxDevice);
82 return d->centerFrequency;
83}
84
86{
87 Q_D(const WimaxDevice);
88 return d->cinr;
89}
90
92{
93 Q_D(const WimaxDevice);
94 return d->rssi;
95}
96
98{
99 Q_D(const WimaxDevice);
100 return d->txPower;
101}
102
104{
105 Q_D(const WimaxDevice);
108 if (mapIt != d->nspMap.constEnd() && !mapIt.value().isNull()) {
109 nsp = mapIt.value();
110 } else {
112 d->nspMap.insert(uni, nsp);
113 }
114
115 return nsp;
116}
117
118void NetworkManager::WimaxDevicePrivate::nspAdded(const QDBusObjectPath &nspPath)
119{
120 // qCDebug(NMQT) << nspPath.path();
121 Q_Q(WimaxDevice);
122 if (!nspMap.contains(nspPath.path())) {
123 nspMap.insert(nspPath.path(), NetworkManager::WimaxNsp::Ptr());
124 Q_EMIT q->nspAppeared(nspPath.path());
125 }
126}
127
128void NetworkManager::WimaxDevicePrivate::nspRemoved(const QDBusObjectPath &nspPath)
129{
130 // qCDebug(NMQT) << nspPath.path();
131 Q_Q(WimaxDevice);
132 if (!nspMap.contains(nspPath.path())) {
133 qCDebug(NMQT) << "Access point list lookup failed for " << nspPath.path();
134 }
135 Q_EMIT q->nspDisappeared(nspPath.path());
136 nspMap.remove(nspPath.path());
137}
138
139void NetworkManager::WimaxDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
140{
141 Q_Q(WimaxDevice);
142
143 if (property == QLatin1String("ActiveNsp")) {
144 activeNsp = qdbus_cast<QDBusObjectPath>(value).path();
145 Q_EMIT q->activeNspChanged(activeNsp);
146 } else if (property == QLatin1String("HwAddress")) {
147 hardwareAddress = value.toString();
148 Q_EMIT q->hardwareAddressChanged(hardwareAddress);
149 } else if (property == QLatin1String("Bsid")) {
150 bsid = value.toString();
151 Q_EMIT q->bsidChanged(bsid);
152 } else if (property == QLatin1String("CenterFrequency")) {
153 centerFrequency = value.toUInt();
154 Q_EMIT q->centerFrequencyChanged(centerFrequency);
155 } else if (property == QLatin1String("Cinr")) {
156 cinr = value.toInt();
157 Q_EMIT q->cinrChanged(cinr);
158 } else if (property == QLatin1String("Rssi")) {
159 rssi = value.toInt();
160 Q_EMIT q->rssiChanged(rssi);
161 } else if (property == QLatin1String("TxPower")) {
162 txPower = value.toInt();
163 Q_EMIT q->txPowerChanged(txPower);
164 } else {
165 DevicePrivate::propertyChanged(property, value);
166 }
167}
168
169#include "moc_wimaxdevice.cpp"
170#include "moc_wimaxdevice_p.cpp"
This class represents a common device interface.
Definition device.h:34
Type
Device type.
Definition device.h:191
@ Wimax
WiMax WWAN technology.
Definition device.h:199
Wimax network interface.
Definition wimaxdevice.h:25
WimaxNsp::Ptr activeNsp() const
Identifier of the NSP this interface is currently associated with.
NetworkManager::WimaxNsp::Ptr findNsp(const QString &uni) const
Finds NSP object given its Unique Network Identifier.
int rssi() const
RSSI of the current radio link in dBm.
WimaxDevice(const QString &path, QObject *parent=nullptr)
Creates a new WimaxDevice object.
QStringList nsps() const
List of network service providers currently visible to the hardware.
QString hardwareAddress() const
The hardware address currently used by the network interface.
QString bsid() const
The ID of the serving base station as received from the network.
~WimaxDevice() override
Destroys a WimaxDevice object.
uint centerFrequency() const
Center frequency (in KHz) of the radio channel the device is using to communicate with the network wh...
int txPower() const
Average power of the last burst transmitted by the device, in units of 0.5 dBm.
Type type() const override
Return the type.
int cinr() const
CINR (Carrier to Interference + Noise Ratio) of the current radio link in dB.
Wimax network service provider (access point)
Definition wimaxnsp.h:24
QString path(const QString &relativePath)
QString path() const const
ConstIterator
const_iterator constEnd() const const
T value(const Key &key, const T &defaultValue) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
int toInt(bool *ok) const const
QString toString() const const
uint toUInt(bool *ok) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:01:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.