BluezQt

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

KDE's Doxygen guidelines are available online.