9#include "accesspoint_p.h"
11#include "wirelessdevice.h"
15NetworkManager::AccessPointPrivate::AccessPointPrivate(
const QString &path, AccessPoint *q)
26 , mode(AccessPoint::Unknown)
34NetworkManager::AccessPoint::Capabilities NetworkManager::AccessPointPrivate::convertCapabilities(
int caps)
36 NetworkManager::AccessPoint::Capabilities capFlags;
37 if (caps & NM_802_11_AP_FLAGS_PRIVACY) {
38 capFlags |= AccessPoint::Privacy;
44NetworkManager::AccessPoint::WpaFlags NetworkManager::AccessPointPrivate::convertWpaFlags(uint theirFlags)
46 return (AccessPoint::WpaFlags)theirFlags;
49NetworkManager::AccessPoint::AccessPoint(
const QString &path,
QObject *parent)
51 , d_ptr(new AccessPointPrivate(
path, this))
57 NetworkManagerPrivate::FDO_DBUS_PROPERTIES,
63 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path);
64 if (!initialProperties.isEmpty()) {
65 d->propertiesChanged(initialProperties);
69NetworkManager::AccessPoint::~AccessPoint()
77 Q_D(
const AccessPoint);
83 Q_D(
const AccessPoint);
84 return d->hardwareAddress;
89 Q_D(
const AccessPoint);
90 return d->capabilities;
95 Q_D(
const AccessPoint);
101 Q_D(
const AccessPoint);
107 Q_D(
const AccessPoint);
113 Q_D(
const AccessPoint);
119 Q_D(
const AccessPoint);
125 Q_D(
const AccessPoint);
126 return d->maxBitRate;
131 Q_D(
const AccessPoint);
137 Q_D(
const AccessPoint);
138 return d->signalStrength;
143 Q_D(
const AccessPoint);
151 case NM_802_11_MODE_UNKNOWN:
154 case NM_802_11_MODE_ADHOC:
157 case NM_802_11_MODE_INFRA:
160 case NM_802_11_MODE_AP:
164 qCDebug(NMQT) << Q_FUNC_INFO <<
"Unhandled mode" <<
mode;
169void NetworkManager::AccessPointPrivate::dbusPropertiesChanged(
const QString &interfaceName,
170 const QVariantMap &properties,
173 Q_UNUSED(invalidatedProperties);
174 if (interfaceName ==
QLatin1String(
"org.freedesktop.NetworkManager.AccessPoint")) {
175 propertiesChanged(properties);
179void NetworkManager::AccessPointPrivate::propertiesChanged(
const QVariantMap &properties)
185 QVariantMap::const_iterator it =
properties.constBegin();
187 const QString
property = it.key();
188 if (property == QLatin1String(
"Flags")) {
190 Q_EMIT q->capabilitiesChanged(capabilities);
191 }
else if (property == QLatin1String(
"WpaFlags")) {
192 wpaFlags = convertWpaFlags(it->toUInt());
193 Q_EMIT q->wpaFlagsChanged(wpaFlags);
194 }
else if (property == QLatin1String(
"RsnFlags")) {
195 rsnFlags = convertWpaFlags(it->toUInt());
196 Q_EMIT q->rsnFlagsChanged(rsnFlags);
197 }
else if (property == QLatin1String(
"Ssid")) {
198 rawSsid = it->toByteArray();
200 Q_EMIT q->ssidChanged(ssid);
201 }
else if (property == QLatin1String(
"Frequency")) {
202 frequency = it->toUInt();
203 Q_EMIT q->frequencyChanged(frequency);
204 }
else if (property == QLatin1String(
"HwAddress")) {
205 hardwareAddress = it->toString();
206 }
else if (property == QLatin1String(
"Mode")) {
207 mode = q->convertOperationMode(it->toUInt());
208 }
else if (property == QLatin1String(
"MaxBitrate")) {
209 maxBitRate = it->toUInt();
210 Q_EMIT q->bitRateChanged(maxBitRate);
211 }
else if (property == QLatin1String(
"Strength")) {
212 signalStrength = it->toInt();
213 Q_EMIT q->signalStrengthChanged(signalStrength);
214 }
else if (property == QLatin1String(
"LastSeen")) {
215 lastSeen = it->toInt();
216 Q_EMIT q->lastSeenChanged(lastSeen);
218 qCDebug(NMQT) << Q_FUNC_INFO <<
"Unhandled property" << property;
224#include "moc_accesspoint.cpp"
225#include "moc_accesspoint_p.cpp"
Represents an access point.
QString hardwareAddress() const
AccessPoint::WpaFlags wpaFlags() const
static OperationMode convertOperationMode(uint mode)
Helper method to convert wire representation of operation mode to enum.
OperationMode mode() const
int signalStrength() const
OperationMode
The access point's current operating mode.
@ Unknown
not associated with a network
@ ApMode
access point in an infrastructure network
@ Infra
a station in an infrastructure wireless network
@ Adhoc
part of an adhoc network
AccessPoint::WpaFlags rsnFlags() const
Capabilities capabilities() const
QByteArray rawSsid() const
Capabilities capabilities()
QString path(const QString &relativePath)
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QDBusConnection sessionBus()
QDBusConnection systemBus()
QString fromUtf8(QByteArrayView str)