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 | |
14 | NetworkManager::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 | |
24 | NetworkManager::BluetoothDevice::BluetoothDevice(const QString &path, QObject *parent) |
25 | : ModemDevice(*new BluetoothDevicePrivate(path, this), parent) |
26 | { |
27 | Q_D(BluetoothDevice); |
28 | |
29 | QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(interfaceName: d->btIface.staticInterfaceName(), path); |
30 | if (!initialProperties.isEmpty()) { |
31 | d->propertiesChanged(properties: initialProperties); |
32 | } |
33 | |
34 | } |
35 | |
36 | NetworkManager::BluetoothDevice::~BluetoothDevice() |
37 | { |
38 | } |
39 | |
40 | NetworkManager::Device::Type NetworkManager::BluetoothDevice::type() const |
41 | { |
42 | return NetworkManager::Device::Bluetooth; |
43 | } |
44 | |
45 | void 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 | |
61 | NetworkManager::BluetoothDevice::Capabilities NetworkManager::BluetoothDevice::bluetoothCapabilities() const |
62 | { |
63 | Q_D(const BluetoothDevice); |
64 | return d->btCapabilities; |
65 | } |
66 | |
67 | QString NetworkManager::BluetoothDevice::hardwareAddress() const |
68 | { |
69 | Q_D(const BluetoothDevice); |
70 | return d->hardwareAddress; |
71 | } |
72 | |
73 | QString 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" |
81 | |