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
45PendingCall *Adapter::setName(const QString &name)
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
60bool Adapter::isPowered() const
61{
62 return d->m_powered;
63}
64
65PendingCall *Adapter::setPowered(bool powered)
66{
67 return new PendingCall(d->setDBusProperty(QStringLiteral("Powered"), powered), PendingCall::ReturnVoid, this);
68}
69
70bool Adapter::isDiscoverable() const
71{
72 return d->m_discoverable;
73}
74
75PendingCall *Adapter::setDiscoverable(bool discoverable)
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
85PendingCall *Adapter::setDiscoverableTimeout(quint32 timeout)
86{
87 return new PendingCall(d->setDBusProperty(QStringLiteral("DiscoverableTimeout"), timeout), PendingCall::ReturnVoid, this);
88}
89
90bool Adapter::isPairable() const
91{
92 return d->m_pairable;
93}
94
95PendingCall *Adapter::setPairable(bool pairable)
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
105PendingCall *Adapter::setPairableTimeout(quint32 timeout)
106{
107 return new PendingCall(d->setDBusProperty(QStringLiteral("PairableTimeout"), timeout), PendingCall::ReturnVoid, this);
108}
109
110bool Adapter::isDiscovering()
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
155PendingCall *Adapter::startDiscovery()
156{
157 return new PendingCall(d->m_bluezAdapter->StartDiscovery(), PendingCall::ReturnVoid, this);
158}
159
160PendingCall *Adapter::stopDiscovery()
161{
162 return new PendingCall(d->m_bluezAdapter->StopDiscovery(), PendingCall::ReturnVoid, this);
163}
164
165PendingCall *Adapter::removeDevice(DevicePtr device)
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
175PendingCall* Adapter::getDiscoveryFilters()
176{
177 return new PendingCall(d->m_bluezAdapter->GetDiscoveryFilters(), PendingCall::ReturnStringList, this);
178}
179
180} // namespace BluezQt
181
182#include "moc_adapter.cpp"
Pending method call.
QString path(const QString &relativePath)
KGuiItem properties()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.