NetworkManagerQt

bluetoothdevice.cpp
1/*
2 SPDX-FileCopyrightText: 2011 Lamarque Souza <lamarque@kde.org>
3 SPDX-FileCopyrightText: 2011 Will Stephenson <wstephenson@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#include "bluetoothdevice.h"
9#include "bluetoothdevice_p.h"
10#include "manager_p.h"
11
12#include "nmdebug.h"
13
14NetworkManager::BluetoothDevicePrivate::BluetoothDevicePrivate(const QString &path, BluetoothDevice *q)
15 : ModemDevicePrivate(path, q)
16#ifdef NMQT_STATIC
17 , btIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
18#else
19 , btIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
20#endif
21{
22}
23
25 : ModemDevice(*new BluetoothDevicePrivate(path, this), parent)
26{
28
29 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->btIface.staticInterfaceName(), path);
30 if (!initialProperties.isEmpty()) {
31 d->propertiesChanged(initialProperties);
32 }
33
34}
35
39
44
45void NetworkManager::BluetoothDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
46{
47 Q_Q(BluetoothDevice);
48
49 if (property == QLatin1String("Name")) {
50 name = value.toString();
51 Q_EMIT q->nameChanged(name);
52 } else if (property == QLatin1String("HwAddress")) {
53 hardwareAddress = value.toString();
54 } else if (property == QLatin1String("BtCapabilities")) {
55 btCapabilities = static_cast<NetworkManager::BluetoothDevice::Capabilities>(value.toUInt());
56 } else {
57 DevicePrivate::propertyChanged(property, value);
58 }
59}
60
61NetworkManager::BluetoothDevice::Capabilities NetworkManager::BluetoothDevice::bluetoothCapabilities() const
62{
63 Q_D(const BluetoothDevice);
64 return d->btCapabilities;
65}
66
67QString NetworkManager::BluetoothDevice::hardwareAddress() const
68{
69 Q_D(const BluetoothDevice);
70 return d->hardwareAddress;
71}
72
73QString NetworkManager::BluetoothDevice::name() const
74{
75 Q_D(const BluetoothDevice);
76 return d->name;
77}
78
79#include "moc_bluetoothdevice.cpp"
80#include "moc_bluetoothdevice_p.cpp"
A bluetooth device interface.
~BluetoothDevice() override
Destroys a BluetoothDevice object.
Type type() const override
The NetworkInterface type.
BluetoothDevice(const QString &path, QObject *parent=nullptr)
Creates a new BluetoothDevice object.
Type
Device type.
Definition device.h:191
@ Bluetooth
network bluetooth device (usually a cell phone)
Definition device.h:197
Represents a generic modem device, generally defined by the modemCapabilities() it exposes and at the...
Definition modemdevice.h:24
QString path(const QString &relativePath)
QString toString() const const
uint toUInt(bool *ok) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:21 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.