Warning: That file was not part of the compilation database. It may have many parsing errors.

1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtBluetooth module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QBLUETOOTHSERVICEINFO_H
41#define QBLUETOOTHSERVICEINFO_H
42
43#include <QtBluetooth/qtbluetoothglobal.h>
44
45#include <QtBluetooth/QBluetoothUuid>
46#include <QtBluetooth/QBluetoothAddress>
47
48#include <QtCore/QMetaType>
49#include <QtCore/QList>
50#include <QtCore/QSharedPointer>
51#include <QtCore/QVariant>
52
53#include <QtCore/QDebug>
54
55QT_BEGIN_NAMESPACE
56
57class QBluetoothServiceInfoPrivate;
58class QBluetoothDeviceInfo;
59
60class Q_BLUETOOTH_EXPORT QBluetoothServiceInfo
61{
62public:
63 enum AttributeId {
64 ServiceRecordHandle = 0x0000,
65 ServiceClassIds = 0x0001,
66 ServiceRecordState = 0x0002,
67 ServiceId = 0x0003,
68 ProtocolDescriptorList = 0x0004,
69 BrowseGroupList = 0x0005,
70 LanguageBaseAttributeIdList = 0x0006,
71 ServiceInfoTimeToLive = 0x0007,
72 ServiceAvailability = 0x0008,
73 BluetoothProfileDescriptorList = 0x0009,
74 DocumentationUrl = 0x000A,
75 ClientExecutableUrl = 0x000B,
76 IconUrl = 0x000C,
77 AdditionalProtocolDescriptorList = 0x000D,
78 PrimaryLanguageBase = 0x0100,
79 ServiceName = PrimaryLanguageBase + 0x0000,
80 ServiceDescription = PrimaryLanguageBase + 0x0001,
81 ServiceProvider = PrimaryLanguageBase + 0x0002
82 };
83
84 enum Protocol {
85 UnknownProtocol,
86 L2capProtocol,
87 RfcommProtocol
88 };
89
90 class Sequence : public QList<QVariant>
91 {
92 public:
93 Sequence() { }
94 Sequence(const QList<QVariant> &list) : QList<QVariant>(list) { }
95 };
96
97 class Alternative : public QList<QVariant>
98 {
99 public:
100 Alternative() { }
101 Alternative(const QList<QVariant> &list) : QList<QVariant>(list) { }
102 };
103
104 QBluetoothServiceInfo();
105 QBluetoothServiceInfo(const QBluetoothServiceInfo &other);
106 ~QBluetoothServiceInfo();
107
108 bool isValid() const;
109 bool isComplete() const;
110
111 void setDevice(const QBluetoothDeviceInfo &info);
112 QBluetoothDeviceInfo device() const;
113
114 void setAttribute(quint16 attributeId, const QVariant &value);
115 void setAttribute(quint16 attributeId, const QBluetoothUuid &value);
116 void setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Sequence &value);
117 void setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Alternative &value);
118 QVariant attribute(quint16 attributeId) const;
119 QList<quint16> attributes() const;
120 bool contains(quint16 attributeId) const;
121 void removeAttribute(quint16 attributeId);
122
123 inline void setServiceName(const QString &name);
124 inline QString serviceName() const;
125 inline void setServiceDescription(const QString &description);
126 inline QString serviceDescription() const;
127 inline void setServiceProvider(const QString &provider);
128 inline QString serviceProvider() const;
129
130 QBluetoothServiceInfo::Protocol socketProtocol() const;
131 int protocolServiceMultiplexer() const;
132 int serverChannel() const;
133
134 QBluetoothServiceInfo::Sequence protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const;
135
136 inline void setServiceAvailability(quint8 availability);
137 inline quint8 serviceAvailability() const;
138
139 inline void setServiceUuid(const QBluetoothUuid &uuid);
140 inline QBluetoothUuid serviceUuid() const;
141
142 QList<QBluetoothUuid> serviceClassUuids() const;
143
144 QBluetoothServiceInfo &operator=(const QBluetoothServiceInfo &other);
145
146 bool isRegistered() const;
147 bool registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress());
148 bool unregisterService();
149
150protected:
151 friend Q_BLUETOOTH_EXPORT QDebug operator<<(QDebug, const QBluetoothServiceInfo &);
152
153protected:
154 QSharedPointer<QBluetoothServiceInfoPrivate> d_ptr;
155};
156
157QT_END_NAMESPACE
158
159Q_DECLARE_METATYPE(QBluetoothServiceInfo)
160Q_DECLARE_METATYPE(QBluetoothServiceInfo::Sequence)
161Q_DECLARE_METATYPE(QBluetoothServiceInfo::Alternative)
162
163QT_BEGIN_NAMESPACE
164
165inline void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothUuid &value)
166{
167 setAttribute(attributeId, value: QVariant::fromValue(value));
168}
169
170inline void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Sequence &value)
171{
172 setAttribute(attributeId, value: QVariant::fromValue(value));
173}
174
175inline void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Alternative &value)
176{
177 setAttribute(attributeId, value: QVariant::fromValue(value));
178}
179
180inline void QBluetoothServiceInfo::setServiceName(const QString &name)
181{
182 setAttribute(attributeId: ServiceName, value: QVariant::fromValue(value: name));
183}
184
185inline QString QBluetoothServiceInfo::serviceName() const
186{
187 return attribute(attributeId: ServiceName).toString();
188}
189
190inline void QBluetoothServiceInfo::setServiceDescription(const QString &description)
191{
192 setAttribute(attributeId: ServiceDescription, value: QVariant::fromValue(value: description));
193}
194
195inline QString QBluetoothServiceInfo::serviceDescription() const
196{
197 return attribute(attributeId: ServiceDescription).toString();
198}
199
200inline void QBluetoothServiceInfo::setServiceProvider(const QString &provider)
201{
202 setAttribute(attributeId: ServiceProvider, value: QVariant::fromValue(value: provider));
203}
204
205inline QString QBluetoothServiceInfo::serviceProvider() const
206{
207 return attribute(attributeId: ServiceProvider).toString();
208}
209
210inline void QBluetoothServiceInfo::setServiceAvailability(quint8 availability)
211{
212 setAttribute(attributeId: ServiceAvailability, value: QVariant::fromValue(value: availability));
213}
214
215inline quint8 QBluetoothServiceInfo::serviceAvailability() const
216{
217 return attribute(attributeId: ServiceAvailability).toUInt();
218}
219
220inline void QBluetoothServiceInfo::setServiceUuid(const QBluetoothUuid &uuid)
221{
222 setAttribute(attributeId: ServiceId, value: uuid);
223}
224
225inline QBluetoothUuid QBluetoothServiceInfo::serviceUuid() const
226{
227 return attribute(attributeId: ServiceId).value<QBluetoothUuid>();
228}
229QT_END_NAMESPACE
230
231#endif
232

Warning: That file was not part of the compilation database. It may have many parsing errors.

source code of qtconnectivity/src/bluetooth/qbluetoothserviceinfo.h