File indexing completed on 2025-03-23 12:49:52
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 "olpcmeshdevice.h" 0009 #include "manager_p.h" 0010 #include "olpcmeshdevice_p.h" 0011 0012 #include "wimaxnsp.h" 0013 0014 NetworkManager::OlpcMeshDevicePrivate::OlpcMeshDevicePrivate(const QString &path, OlpcMeshDevice *q) 0015 : DevicePrivate(path, q) 0016 #ifdef NMQT_STATIC 0017 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) 0018 #else 0019 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) 0020 #endif 0021 { 0022 } 0023 0024 NetworkManager::OlpcMeshDevice::OlpcMeshDevice(const QString &path, QObject *parent) 0025 : Device(*new OlpcMeshDevicePrivate(path, this), parent) 0026 { 0027 Q_D(OlpcMeshDevice); 0028 0029 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); 0030 if (!initialProperties.isEmpty()) { 0031 d->propertiesChanged(initialProperties); 0032 } 0033 } 0034 0035 NetworkManager::OlpcMeshDevice::~OlpcMeshDevice() 0036 { 0037 } 0038 0039 NetworkManager::Device::Type NetworkManager::OlpcMeshDevice::type() const 0040 { 0041 return NetworkManager::Device::OlpcMesh; 0042 } 0043 0044 QString NetworkManager::OlpcMeshDevice::hardwareAddress() const 0045 { 0046 Q_D(const OlpcMeshDevice); 0047 return d->hardwareAddress; 0048 } 0049 0050 uint NetworkManager::OlpcMeshDevice::activeChannel() const 0051 { 0052 Q_D(const OlpcMeshDevice); 0053 return d->activeChannel; 0054 } 0055 0056 NetworkManager::Device::Ptr NetworkManager::OlpcMeshDevice::companionDevice() const 0057 { 0058 Q_D(const OlpcMeshDevice); 0059 return NetworkManager::findNetworkInterface(d->companion); 0060 } 0061 0062 void NetworkManager::OlpcMeshDevicePrivate::propertyChanged(const QString &property, const QVariant &value) 0063 { 0064 Q_Q(OlpcMeshDevice); 0065 0066 if (property == QLatin1String("ActiveChannel")) { 0067 activeChannel = value.toUInt(); 0068 Q_EMIT q->activeChannelChanged(activeChannel); 0069 } else if (property == QLatin1String("HwAddress")) { 0070 hardwareAddress = value.toString(); 0071 Q_EMIT q->hardwareAddressChanged(hardwareAddress); 0072 } else if (property == QLatin1String("Companion")) { 0073 companion = qdbus_cast<QDBusObjectPath>(value).path(); 0074 Q_EMIT q->companionChanged(NetworkManager::findNetworkInterface(companion)); 0075 } else { 0076 DevicePrivate::propertyChanged(property, value); 0077 } 0078 } 0079 0080 #include "moc_olpcmeshdevice.cpp" 0081 #include "moc_olpcmeshdevice_p.cpp"