BluezQt

adapter.cpp
1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2014 David Rosca <nowrep@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "adapter.h"
10#include "adapter_p.h"
11#include "device.h"
12#include "device_p.h"
13#include "pendingcall.h"
14
15namespace BluezQt
16{
17Adapter::Adapter(const QString &path, const QVariantMap &properties)
18 : QObject()
19 , d(new AdapterPrivate(path, properties))
20{
21}
22
23Adapter::~Adapter() = default;
24
25AdapterPtr Adapter::toSharedPtr() const
26{
27 return d->q.toStrongRef();
28}
29
30QString Adapter::ubi() const
31{
32 return d->m_bluezAdapter->path();
33}
34
35QString Adapter::address() const
36{
37 return d->m_address;
38}
39
40QString Adapter::name() const
41{
42 return d->m_alias;
43}
44
46{
47 return new PendingCall(d->setDBusProperty(QStringLiteral("Alias"), name), PendingCall::ReturnVoid, this);
48}
49
50QString Adapter::systemName() const
51{
52 return d->m_name;
53}
54
55quint32 Adapter::adapterClass() const
56{
57 return d->m_adapterClass;
58}
59
61{
62 return d->m_powered;
63}
64
66{
67 return new PendingCall(d->setDBusProperty(QStringLiteral("Powered"), powered), PendingCall::ReturnVoid, this);
68}
69
71{
72 return d->m_discoverable;
73}
74
76{
77 return new PendingCall(d->setDBusProperty(QStringLiteral("Discoverable"), discoverable), PendingCall::ReturnVoid, this);
78}
79
80quint32 Adapter::discoverableTimeout() const
81{
82 return d->m_discoverableTimeout;
83}
84
86{
87 return new PendingCall(d->setDBusProperty(QStringLiteral("DiscoverableTimeout"), timeout), PendingCall::ReturnVoid, this);
88}
89
91{
92 return d->m_pairable;
93}
94
96{
97 return new PendingCall(d->setDBusProperty(QStringLiteral("Pairable"), pairable), PendingCall::ReturnVoid, this);
98}
99
100quint32 Adapter::pairableTimeout() const
101{
102 return d->m_pairableTimeout;
103}
104
106{
107 return new PendingCall(d->setDBusProperty(QStringLiteral("PairableTimeout"), timeout), PendingCall::ReturnVoid, this);
108}
109
111{
112 return d->m_discovering;
113}
114
115QStringList Adapter::uuids() const
116{
117 return d->m_uuids;
118}
119
120QString Adapter::modalias() const
121{
122 return d->m_modalias;
123}
124
125GattManagerPtr Adapter::gattManager() const
126{
127 return d->m_gattManager;
128}
129
130LEAdvertisingManagerPtr Adapter::leAdvertisingManager() const
131{
132 return d->m_leAdvertisingManager;
133}
134
135MediaPtr Adapter::media() const
136{
137 return d->m_media;
138}
139
140QList<DevicePtr> Adapter::devices() const
141{
142 return d->m_devices;
143}
144
145DevicePtr Adapter::deviceForAddress(const QString &address) const
146{
147 for (DevicePtr device : std::as_const(d->m_devices)) {
148 if (device->address() == address) {
149 return device;
150 }
151 }
152 return DevicePtr();
153}
154
156{
157 return new PendingCall(d->m_bluezAdapter->StartDiscovery(), PendingCall::ReturnVoid, this);
158}
159
161{
162 return new PendingCall(d->m_bluezAdapter->StopDiscovery(), PendingCall::ReturnVoid, this);
163}
164
166{
167 return new PendingCall(d->m_bluezAdapter->RemoveDevice(QDBusObjectPath(device->ubi())), PendingCall::ReturnVoid, this);
168}
169
170PendingCall* Adapter::setDiscoveryFilter(const QVariantMap& filter)
171{
172 return new PendingCall(d->m_bluezAdapter->SetDiscoveryFilter(filter), PendingCall::ReturnVoid, this);
173}
174
176{
177 return new PendingCall(d->m_bluezAdapter->GetDiscoveryFilters(), PendingCall::ReturnStringList, this);
178}
179
180} // namespace BluezQt
181
182#include "moc_adapter.cpp"
PendingCall * getDiscoveryFilters()
Get the discovery filters for the caller.
Definition adapter.cpp:175
bool isPairable() const
Returns whether the adapter is pairable with other devices.
Definition adapter.cpp:90
PendingCall * setPowered(bool powered)
Sets the powered state of the adapter.
Definition adapter.cpp:65
PendingCall * startDiscovery()
Starts device discovery.
Definition adapter.cpp:155
PendingCall * setPairable(bool pairable)
Sets the pairable state of the adapter.
Definition adapter.cpp:95
AdapterPtr toSharedPtr() const
Returns a shared pointer from this.
Definition adapter.cpp:25
DevicePtr deviceForAddress(const QString &address) const
Returns a device for specified address.
Definition adapter.cpp:145
bool isDiscoverable() const
Returns whether the adapter is discoverable by other devices.
Definition adapter.cpp:70
PendingCall * removeDevice(DevicePtr device)
Removes the specified device.
Definition adapter.cpp:165
PendingCall * setDiscoveryFilter(const QVariantMap &filter)
Set the discovery filter for the caller.
Definition adapter.cpp:170
bool isPowered() const
Returns whether the adapter is powered on.
Definition adapter.cpp:60
GattManagerPtr gattManager() const
Returns the GATT manager interface for the adapter.
Definition adapter.cpp:125
PendingCall * setDiscoverable(bool discoverable)
Sets the discoverable state of the adapter.
Definition adapter.cpp:75
bool isDiscovering()
Returns whether the adapter is discovering for other devices.
Definition adapter.cpp:110
PendingCall * setName(const QString &name)
Sets the name of the adapter.
Definition adapter.cpp:45
PendingCall * stopDiscovery()
Stops device discovery.
Definition adapter.cpp:160
PendingCall * setDiscoverableTimeout(quint32 timeout)
Sets the discoverable timeout of the adapter.
Definition adapter.cpp:85
PendingCall * setPairableTimeout(quint32 timeout)
Sets the pairable timeout of the adapter.
Definition adapter.cpp:105
Pending method call.
Definition pendingcall.h:35
QString path(const QString &relativePath)
KGuiItem properties()
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:56:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.