Warning, file /frameworks/networkmanager-qt/src/wimaxdevice.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net>
0003     SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #include "wimaxdevice.h"
0009 #include "manager_p.h"
0010 #include "wimaxdevice_p.h"
0011 
0012 #include "nmdebug.h"
0013 
0014 NetworkManager::WimaxDevicePrivate::WimaxDevicePrivate(const QString &path, WimaxDevice *q)
0015     : DevicePrivate(path, q)
0016 #ifdef NMQT_STATIC
0017     , wimaxIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
0018 #else
0019     , wimaxIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
0020 #endif
0021 {
0022     qDBusRegisterMetaType<QList<QDBusObjectPath>>();
0023     const QList<QDBusObjectPath> nsps = wimaxIface.nsps();
0024     for (const QDBusObjectPath &op : nsps) {
0025         nspMap.insert(op.path(), NetworkManager::WimaxNsp::Ptr());
0026         // qCDebug(NMQT) << "  " << op.path();
0027     }
0028 }
0029 
0030 NetworkManager::WimaxDevice::WimaxDevice(const QString &path, QObject *parent)
0031     : Device(*new WimaxDevicePrivate(path, this), parent)
0032 {
0033     Q_D(WimaxDevice);
0034 
0035     connect(&d->wimaxIface, &OrgFreedesktopNetworkManagerDeviceWiMaxInterface::NspAdded, d, &WimaxDevicePrivate::nspAdded);
0036     connect(&d->wimaxIface, &OrgFreedesktopNetworkManagerDeviceWiMaxInterface::NspRemoved, d, &WimaxDevicePrivate::nspRemoved);
0037 
0038     QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->wimaxIface.staticInterfaceName(), path);
0039     if (!initialProperties.isEmpty()) {
0040         d->propertiesChanged(initialProperties);
0041     }
0042 }
0043 
0044 NetworkManager::WimaxDevice::~WimaxDevice()
0045 {
0046 }
0047 
0048 NetworkManager::Device::Type NetworkManager::WimaxDevice::type() const
0049 {
0050     return NetworkManager::Device::Wimax;
0051 }
0052 
0053 QStringList NetworkManager::WimaxDevice::nsps() const
0054 {
0055     Q_D(const WimaxDevice);
0056     return d->nspMap.keys();
0057 }
0058 
0059 NetworkManager::WimaxNsp::Ptr NetworkManager::WimaxDevice::activeNsp() const
0060 {
0061     Q_D(const WimaxDevice);
0062     return findNsp(d->activeNsp);
0063 }
0064 
0065 QString NetworkManager::WimaxDevice::hardwareAddress() const
0066 {
0067     Q_D(const WimaxDevice);
0068     return d->hardwareAddress;
0069 }
0070 
0071 QString NetworkManager::WimaxDevice::bsid() const
0072 {
0073     Q_D(const WimaxDevice);
0074     return d->bsid;
0075 }
0076 
0077 uint NetworkManager::WimaxDevice::centerFrequency() const
0078 {
0079     Q_D(const WimaxDevice);
0080     return d->centerFrequency;
0081 }
0082 
0083 int NetworkManager::WimaxDevice::cinr() const
0084 {
0085     Q_D(const WimaxDevice);
0086     return d->cinr;
0087 }
0088 
0089 int NetworkManager::WimaxDevice::rssi() const
0090 {
0091     Q_D(const WimaxDevice);
0092     return d->rssi;
0093 }
0094 
0095 int NetworkManager::WimaxDevice::txPower() const
0096 {
0097     Q_D(const WimaxDevice);
0098     return d->txPower;
0099 }
0100 
0101 NetworkManager::WimaxNsp::Ptr NetworkManager::WimaxDevice::findNsp(const QString &uni) const
0102 {
0103     Q_D(const WimaxDevice);
0104     NetworkManager::WimaxNsp::Ptr nsp;
0105     QMap<QString, NetworkManager::WimaxNsp::Ptr>::ConstIterator mapIt = d->nspMap.constFind(uni);
0106     if (mapIt != d->nspMap.constEnd() && !mapIt.value().isNull()) {
0107         nsp = mapIt.value();
0108     } else {
0109         nsp = NetworkManager::WimaxNsp::Ptr(new NetworkManager::WimaxNsp(uni), &QObject::deleteLater);
0110         d->nspMap.insert(uni, nsp);
0111     }
0112 
0113     return nsp;
0114 }
0115 
0116 void NetworkManager::WimaxDevicePrivate::nspAdded(const QDBusObjectPath &nspPath)
0117 {
0118     // qCDebug(NMQT) << nspPath.path();
0119     Q_Q(WimaxDevice);
0120     if (!nspMap.contains(nspPath.path())) {
0121         nspMap.insert(nspPath.path(), NetworkManager::WimaxNsp::Ptr());
0122         Q_EMIT q->nspAppeared(nspPath.path());
0123     }
0124 }
0125 
0126 void NetworkManager::WimaxDevicePrivate::nspRemoved(const QDBusObjectPath &nspPath)
0127 {
0128     // qCDebug(NMQT) << nspPath.path();
0129     Q_Q(WimaxDevice);
0130     if (!nspMap.contains(nspPath.path())) {
0131         qCDebug(NMQT) << "Access point list lookup failed for " << nspPath.path();
0132     }
0133     Q_EMIT q->nspDisappeared(nspPath.path());
0134     nspMap.remove(nspPath.path());
0135 }
0136 
0137 void NetworkManager::WimaxDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
0138 {
0139     Q_Q(WimaxDevice);
0140 
0141     if (property == QLatin1String("ActiveNsp")) {
0142         activeNsp = qdbus_cast<QDBusObjectPath>(value).path();
0143         Q_EMIT q->activeNspChanged(activeNsp);
0144     } else if (property == QLatin1String("HwAddress")) {
0145         hardwareAddress = value.toString();
0146         Q_EMIT q->hardwareAddressChanged(hardwareAddress);
0147     } else if (property == QLatin1String("Bsid")) {
0148         bsid = value.toString();
0149         Q_EMIT q->bsidChanged(bsid);
0150     } else if (property == QLatin1String("CenterFrequency")) {
0151         centerFrequency = value.toUInt();
0152         Q_EMIT q->centerFrequencyChanged(centerFrequency);
0153     } else if (property == QLatin1String("Cinr")) {
0154         cinr = value.toInt();
0155         Q_EMIT q->cinrChanged(cinr);
0156     } else if (property == QLatin1String("Rssi")) {
0157         rssi = value.toInt();
0158         Q_EMIT q->rssiChanged(rssi);
0159     } else if (property == QLatin1String("TxPower")) {
0160         txPower = value.toInt();
0161         Q_EMIT q->txPowerChanged(txPower);
0162     } else {
0163         DevicePrivate::propertyChanged(property, value);
0164     }
0165 }