NetworkManagerQt

wimaxnsp.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 "manager_p.h"
9#include "nmdebug.h"
10#include "wimaxdevice.h"
11#include "wimaxnsp_p.h"
12
13namespace NetworkManager
14{
15NetworkManager::WimaxNsp::NetworkType convertNetworkType(uint type)
16{
17 switch (type) {
18 case 0:
19 return NetworkManager::WimaxNsp::Unknown;
20 case 1:
21 return NetworkManager::WimaxNsp::Home;
22 case 2:
23 return NetworkManager::WimaxNsp::Partner;
24 case 3:
25 return NetworkManager::WimaxNsp::RoamingPartner;
26 }
27 return NetworkManager::WimaxNsp::Unknown;
28}
29
30}
31
32NetworkManager::WimaxNspPrivate::WimaxNspPrivate(const QString &path, WimaxNsp *q)
33#ifdef NMQT_STATIC
34 : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
35#else
36 : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
37#endif
38 , networkType(WimaxNsp::Unknown)
39 , signalQuality(0)
40 , q_ptr(q)
41{
42}
43
44NetworkManager::WimaxNsp::WimaxNsp(const QString &path, QObject *parent)
45 : QObject(parent)
46 , d_ptr(new WimaxNspPrivate(path, this))
47{
48 Q_D(WimaxNsp);
49 d->uni = path;
50 if (d->iface.isValid()) {
51 connect(&d->iface, &OrgFreedesktopNetworkManagerWiMaxNspInterface::PropertiesChanged, d, &WimaxNspPrivate::propertiesChanged);
52 d->networkType = convertNetworkType(d->iface.networkType());
53 d->name = d->iface.name();
54 d->signalQuality = d->iface.signalQuality();
55 }
56}
57
58NetworkManager::WimaxNsp::~WimaxNsp()
59{
60 Q_D(WimaxNsp);
61 delete d;
62}
63
64QString NetworkManager::WimaxNsp::uni() const
65{
66 Q_D(const WimaxNsp);
67 return d->uni;
68}
69
75
77{
78 Q_D(const WimaxNsp);
79 return d->name;
80}
81
83{
84 Q_D(const WimaxNsp);
85 return d->signalQuality;
86}
87
88void NetworkManager::WimaxNspPrivate::propertiesChanged(const QVariantMap &properties)
89{
90 Q_Q(WimaxNsp);
91
92 QVariantMap::const_iterator it = properties.constBegin();
93 while (it != properties.constEnd()) {
94 const QString property = it.key();
95 if (property == QLatin1String("Name")) {
96 name = it->toString();
97 Q_EMIT q->nameChanged(name);
98 } else if (property == QLatin1String("NetworkType")) {
99 networkType = convertNetworkType(it->toUInt());
100 Q_EMIT q->networkTypeChanged(networkType);
101 } else if (property == QLatin1String("SignalQuality")) {
102 signalQuality = it->toUInt();
103 Q_EMIT q->signalQualityChanged(signalQuality);
104 } else {
105 qCWarning(NMQT) << Q_FUNC_INFO << "Unhandled property" << property;
106 }
107 ++it;
108 }
109}
110
111#include "moc_wimaxnsp.cpp"
112#include "moc_wimaxnsp_p.cpp"
Wimax network service provider (access point)
Definition wimaxnsp.h:24
QString name() const
The name of the NSP.
Definition wimaxnsp.cpp:76
NetworkType
network types a NSP can have
Definition wimaxnsp.h:32
NetworkType networkType() const
The network type of the NSP.
Definition wimaxnsp.cpp:70
uint signalQuality() const
The current signal quality of the NSP, in percent.
Definition wimaxnsp.cpp:82
QString path(const QString &relativePath)
This class allows querying the underlying system to discover the available network interfaces and rea...
Definition accesspoint.h:21
QDBusConnection sessionBus()
QDBusConnection systemBus()
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
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.