7#include <QtCore/qvariant.h>
8#include <QtCore/qdebug.h>
9#include <QtCore/qurl.h>
11#include <IOBluetooth/IOBluetooth.h>
22typedef ObjCStrongReference<NSMutableDictionary> Dictionary;
23typedef ObjCStrongReference<IOBluetoothSDPUUID> SDPUUid;
24typedef ObjCStrongReference<NSNumber> Number;
27typedef QSInfo::AttributeId AttributeId;
40 if (serviceUuid.isNull()) {
50 const int size = uuid.minimumSize();
52 if (serviceUuid.isNull())
65template<
class IntType>
104template<
class ValueType>
112 const Number
num(variant_to_nsnumber<ValueType>(
var));
113 [dict setObject:
num forKey:[NSString stringWithFormat:
@"%x", int(
key)]];
125 if (!
string.isEmpty()) {
126 if (NSString *
const nsString =
string.toNSString())
127 [dict setObject:nsString forKey:[NSString stringWithFormat:
@"%x", int(
key)]];
140 [dict setObject:ioUUID forKey:[NSString stringWithFormat:
@"%x", int(
key)]];
158template<
class ValueType>
161template<
class ValueType>
169 const Number
num(variant_to_nsnumber<ValueType>(
var));
183 NSDictionary* dict = @{
184 @"DataElementType" : [NSNumber numberWithInt:1],
185 @"DataElementSize" : [NSNumber numberWithInt:2],
186 @"DataElementValue" :
num
189 [
list addObject: dict];
201 if (!
string.isEmpty()) {
202 if (NSString *
const nsString =
string.toNSString())
203 [
list addObject:nsString];
216 [
list addObject:ioUUID];
241 NSMutableArray *
const descriptorList = [NSMutableArray
array];
243 IOBluetoothSDPUUID *
const l2capUUID = [IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16L2CAP];
244 NSArray *
const l2capList = [NSArray arrayWithObject:l2capUUID];
246 [descriptorList addObject:l2capList];
248 IOBluetoothSDPUUID *
const rfcommUUID = [IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16RFCOMM];
249 NSMutableDictionary *
const rfcommDict = [NSMutableDictionary
dictionary];
250 [rfcommDict setObject:[NSNumber numberWithInt:1] forKey:
@"DataElementType"];
251 [rfcommDict setObject:[NSNumber numberWithInt:1] forKey:
@"DataElementSize"];
252 [rfcommDict setObject:[NSNumber numberWithInt:channelID] forKey:
@"DataElementValue"];
254 NSMutableArray *
const rfcommList = [NSMutableArray
array];
255 [rfcommList addObject:rfcommUUID];
256 [rfcommList addObject:rfcommDict];
258 [descriptorList addObject:rfcommList];
259 [dict setObject:descriptorList forKey:[NSString stringWithFormat:
@"%x",
260 kBluetoothSDPAttributeIdentifierProtocolDescriptorList]];
272 NSMutableArray *
const descriptorList = [NSMutableArray
array];
273 NSMutableArray *
const l2capList = [NSMutableArray
array];
275 IOBluetoothSDPUUID *
const l2capUUID = [IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16L2CAP];
276 [l2capList addObject:l2capUUID];
278 NSMutableDictionary *
const l2capDict = [NSMutableDictionary
dictionary];
279 [l2capDict setObject:[NSNumber numberWithInt:1] forKey:
@"DataElementType"];
280 [l2capDict setObject:[NSNumber numberWithInt:2] forKey:
@"DataElementSize"];
281 [l2capDict setObject:[NSNumber numberWithInt:psm] forKey:
@"DataElementValue"];
282 [l2capList addObject:l2capDict];
284 [descriptorList addObject:l2capList];
285 [dict setObject:descriptorList forKey:[NSString stringWithFormat:
@"%x",
286 kBluetoothSDPAttributeIdentifierProtocolDescriptorList]];
296 if (
var.
typeId() == QMetaType::QString) {
299 }
else if (
var.
userType() == qMetaTypeId<QBluetoothUuid>()) {
306 case QSInfo::ServiceRecordHandle:
307 case QSInfo::ServiceRecordState:
308 case QSInfo::ServiceInfoTimeToLive:
309 add_attribute<unsigned>(
var,
list);
311 case QSInfo::BluetoothProfileDescriptorList:
314 case QSInfo::ServiceAvailability:
315 add_attribute<unsigned char>(
var,
list);
317 case QSInfo::IconUrl:
318 case QSInfo::DocumentationUrl:
319 case QSInfo::ClientExecutableUrl:
337 if (
var.
typeId() == QMetaType::QString) {
340 }
else if (
var.
userType() == qMetaTypeId<QBluetoothUuid>()) {
346 case QSInfo::ServiceRecordHandle:
347 case QSInfo::ServiceRecordState:
348 case QSInfo::ServiceInfoTimeToLive:
351 case QSInfo::ServiceAvailability:
354 case QSInfo::IconUrl:
355 case QSInfo::DocumentationUrl:
356 case QSInfo::ClientExecutableUrl:
374 NSMutableArray *
const nested = [NSMutableArray
array];
375 [
list addObject:nested];
377 const Sequence sequence(
var.
value<Sequence>());
399 NSMutableArray *
const list = [NSMutableArray
array];
400 const Sequence sequence(
var.
value<Sequence>());
401 for (
const QVariant &element : sequence) {
405 [dict setObject:
list forKey:[NSString stringWithFormat:
@"%x", int(
key)]];
417 if (!attributeIds.
size())
423 if (
key == QSInfo::ProtocolDescriptorList)
#define QT_BT_MAC_AUTORELEASEPOOL
int protocolServiceMultiplexer() const
This is a convenience function.
QBluetoothUuid serviceUuid() const
This is a convenience function.
QBluetoothServiceInfo::Protocol socketProtocol() const
Returns the protocol that the QBluetoothServiceInfo object uses.
QList< quint16 > attributes() const
Returns a list of all attribute ids that the QBluetoothServiceInfo object has.
QVariant attribute(quint16 attributeId) const
Returns the value of the attribute attributeId.
int serverChannel() const
This is a convenience function.
qsizetype size() const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
int typeId() const
Returns the storage type of the value stored in the variant.
bool isNull() const
Returns true if this is a null variant, false otherwise.
bool canConvert(QMetaType targetType) const
Number variant_to_nsnumber< unsigned short >(const QVariant &var)
bool add_sequence_attribute(const QVariant &var, AttributeId key, NSMutableArray *list)
void add_attribute< QString >(const QVariant &var, AttributeId key, Dictionary dict)
void add_attribute< QBluetoothUuid >(const QVariant &var, AttributeId key, Dictionary dict)
void add_attribute< unsigned short >(const QVariant &var, NSMutableArray *list)
void add_attribute(const QVariant &var, AttributeId key, Dictionary dict)
Number variant_to_nsnumber< short >(const QVariant &var)
Number variant_to_nsnumber< char >(const QVariant &var)
void add_rfcomm_protocol_descriptor_list(uint16 channelID, Dictionary dict)
ObjCStrongReference< IOBluetoothSDPUUID > iobluetooth_uuid(const QBluetoothUuid &uuid)
Number variant_to_nsnumber< int >(const QVariant &var)
Number variant_to_nsnumber< unsigned char >(const QVariant &var)
void add_l2cap_protocol_descriptor_list(uint16 psm, Dictionary dict)
Dictionary iobluetooth_service_dictionary(const QBluetoothServiceInfo &serviceInfo)
Number variant_to_nsnumber< unsigned >(const QVariant &var)
Number variant_to_nsnumber(const QVariant &)
void add_attribute< QUrl >(const QVariant &var, AttributeId key, Dictionary dict)
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei const GLchar *const * string
[0]
#define Q_ASSERT_X(cond, x, msg)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
QFuture< QSet< QString > > dictionary