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 "olpcmeshdevice.h"
9#include "manager_p.h"
10#include "olpcmeshdevice_p.h"
11
12#include "wimaxnsp.h"
13
14NetworkManager::OlpcMeshDevicePrivate::OlpcMeshDevicePrivate(const QString &path, OlpcMeshDevice *q)
15 : DevicePrivate(path, q)
16#ifdef NMQT_STATIC
17 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
18#else
19 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
20#endif
21{
22}
23
24NetworkManager::OlpcMeshDevice::OlpcMeshDevice(const QString &path, QObject *parent)
25 : Device(*new OlpcMeshDevicePrivate(path, this), parent)
26{
27 Q_D(OlpcMeshDevice);
28
29 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(interfaceName: d->iface.staticInterfaceName(), path);
30 if (!initialProperties.isEmpty()) {
31 d->propertiesChanged(properties: initialProperties);
32 }
33}
34
35NetworkManager::OlpcMeshDevice::~OlpcMeshDevice()
36{
37}
38
39NetworkManager::Device::Type NetworkManager::OlpcMeshDevice::type() const
40{
41 return NetworkManager::Device::OlpcMesh;
42}
43
44QString NetworkManager::OlpcMeshDevice::hardwareAddress() const
45{
46 Q_D(const OlpcMeshDevice);
47 return d->hardwareAddress;
48}
49
50uint NetworkManager::OlpcMeshDevice::activeChannel() const
51{
52 Q_D(const OlpcMeshDevice);
53 return d->activeChannel;
54}
55
56NetworkManager::Device::Ptr NetworkManager::OlpcMeshDevice::companionDevice() const
57{
58 Q_D(const OlpcMeshDevice);
59 return NetworkManager::findNetworkInterface(uni: d->companion);
60}
61
62void NetworkManager::OlpcMeshDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
63{
64 Q_Q(OlpcMeshDevice);
65
66 if (property == QLatin1String("ActiveChannel")) {
67 activeChannel = value.toUInt();
68 Q_EMIT q->activeChannelChanged(activeChannel);
69 } else if (property == QLatin1String("HwAddress")) {
70 hardwareAddress = value.toString();
71 Q_EMIT q->hardwareAddressChanged(hardwareAddress);
72 } else if (property == QLatin1String("Companion")) {
73 companion = qdbus_cast<QDBusObjectPath>(v: value).path();
74 Q_EMIT q->companionChanged(device: NetworkManager::findNetworkInterface(uni: companion));
75 } else {
76 DevicePrivate::propertyChanged(property, value);
77 }
78}
79
80#include "moc_olpcmeshdevice.cpp"
81#include "moc_olpcmeshdevice_p.cpp"
82

source code of networkmanager-qt/src/olpcmeshdevice.cpp