NetworkManagerQt

fakenetwork/wirelessdevice.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "wirelessdevice.h"
8
9#include <QDBusConnection>
10
11WirelessDevice::WirelessDevice(QObject *parent)
12 : Device(parent)
13 , m_activeAccessPoint(QDBusObjectPath("/"))
14 , m_bitrate(0)
15 , m_mode(2)
16 , m_wirelessCapabilities(0)
17 , m_accessPointCounter(0)
18{
19}
20
21WirelessDevice::~WirelessDevice()
22{
23 for (auto it = m_accessPoints.cbegin(); it != m_accessPoints.cend(); ++it) {
24 const QDBusObjectPath &ap = it.key();
26 Q_EMIT AccessPointRemoved(ap);
27 }
28
29 qDeleteAll(m_accessPoints);
30
31 QVariantMap map;
33 Q_EMIT PropertiesChanged(map);
34}
35
36QList<QDBusObjectPath> WirelessDevice::accessPoints() const
37{
38 return m_accessPoints.keys();
39}
40
41QDBusObjectPath WirelessDevice::activeAccessPoint() const
42{
43 return m_activeAccessPoint;
44}
45
46uint WirelessDevice::bitrate() const
47{
48 return m_bitrate;
49}
50
51QString WirelessDevice::hwAddress() const
52{
53 return m_hwAddress;
54}
55
56uint WirelessDevice::mode() const
57{
58 return m_mode;
59}
60
61QString WirelessDevice::permHwAddress() const
62{
63 return m_permHwAddress;
64}
65
66uint WirelessDevice::wirelessCapabilities() const
67{
68 return m_wirelessCapabilities;
69}
70
71void WirelessDevice::addAccessPoint(AccessPoint *accessPoint)
72{
73 QString newApPath = QString("/org/kde/fakenetwork/AccessPoints/") + QString::number(m_accessPointCounter++);
74 accessPoint->setAccessPointPath(newApPath);
75 m_accessPoints.insert(QDBusObjectPath(newApPath), accessPoint);
77
78 Q_EMIT AccessPointAdded(QDBusObjectPath(newApPath));
79}
80
81void WirelessDevice::removeAccessPoint(AccessPoint *accessPoint)
82{
83 m_accessPoints.remove(QDBusObjectPath(accessPoint->accessPointPath()));
84
85 Q_EMIT AccessPointRemoved(QDBusObjectPath(accessPoint->accessPointPath()));
86}
87
88void WirelessDevice::setActiveAccessPoint(const QString &activeAccessPoint)
89{
90 m_activeAccessPoint = QDBusObjectPath(activeAccessPoint);
91}
92
93void WirelessDevice::setBitrate(uint bitrate)
94{
95 m_bitrate = bitrate;
96}
97
98void WirelessDevice::setHwAddress(const QString &hwAddress)
99{
100 m_hwAddress = hwAddress;
101}
102
103void WirelessDevice::setMode(uint mode)
104{
105 m_mode = mode;
106}
107
108void WirelessDevice::setPermHwAddress(const QString &permHwAddress)
109{
110 m_permHwAddress = permHwAddress;
111}
112
113void WirelessDevice::setState(uint state)
114{
115 Device::setState(state);
116
117 // TODO: set speed, etc.
118}
119
120void WirelessDevice::setWirelessCapabilities(uint capabilities)
121{
122 m_wirelessCapabilities = capabilities;
123}
124
125QList<QDBusObjectPath> WirelessDevice::GetAccessPoints()
126{
127 return m_accessPoints.keys();
128}
129
130QList<QDBusObjectPath> WirelessDevice::GetAllAccessPoints()
131{
132 return m_accessPoints.keys();
133}
134
135void WirelessDevice::RequestScan(const QVariantMap &options)
136{
137 Q_UNUSED(options);
138}
139
140#include "moc_wirelessdevice.cpp"
Capabilities capabilities()
bool registerObject(const QString &path, QObject *object, RegisterOptions options)
QDBusConnection sessionBus()
void unregisterObject(const QString &path, UnregisterMode mode)
QString path() const const
const_iterator cbegin() const const
const_iterator cend() const const
iterator insert(const Key &key, const T &value)
QList< Key > keys() const const
size_type remove(const Key &key)
Q_EMITQ_EMIT
QString number(double n, char format, int precision)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:16 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.