13#include <QtCore/qoperatingsystemversion.h>
14#include <QtCore/qcoreapplication.h>
15#include <QtCore/qloggingcategory.h>
16#include <QtCore/qstring.h>
17#include <QtCore/qglobal.h>
18#include <QtCore/qdebug.h>
19#include <QtCore/qlist.h>
21#include <Foundation/Foundation.h>
23#include <IOBluetooth/IOBluetooth.h>
37 m_deviceAdapterAddress(localAddress),
52void QBluetoothServiceDiscoveryAgentPrivate::start(
const QBluetoothAddress &deviceAddress)
64 IOBluetoothHostController *
const hc = [IOBluetoothHostController defaultController];
65 if (![hc powerState]) {
79 IOReturn
result = kIOReturnSuccess;
81 if (uuidFilter.
size())
86 if (
result != kIOReturnSuccess) {
88 SDPInquiryError(nil,
result);
93void QBluetoothServiceDiscoveryAgentPrivate::stop()
105void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryFinished(
void *generic)
107 auto device =
static_cast<IOBluetoothDevice *
>(
generic);
115 NSArray *
const records =
device.services;
116 qCDebug(QT_BT_DARWIN) <<
"SDP finished for device" << [
device nameOrAddress]
117 <<
", services found:" << [records
count];
118 for (IOBluetoothSDPServiceRecord *
record in records) {
122 qCDebug(QT_BT_DARWIN) <<
"Processing service" << [
record getServiceName];
127 qCDebug(QT_BT_DARWIN) <<
"Discarding invalid service";
132 && uuidFilter.
size()) {
134 bool match = !serviceId.isNull() && uuidFilter.
contains(serviceId);
137 for (
const auto &uuid : classUuids) {
149 if (!isDuplicatedService(serviceInfo)) {
162void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryError(
void *
device, IOReturn errorCode)
166 qCWarning(QT_BT_DARWIN) <<
"inquiry failed with IOKit code:" << int(errorCode);
179void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(
const QBluetoothAddress &deviceAddress)
186 IOBluetoothDevice *
const device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
195 NSArray *
const records =
device.services;
196 for (IOBluetoothSDPServiceRecord *
record in records) {
199 "invalid number of devices");
207 if (!uuidFilter.
isEmpty() && !serviceHasMatchingUuid(serviceInfo))
210 if (!isDuplicatedService(serviceInfo)) {
220bool QBluetoothServiceDiscoveryAgentPrivate::serviceHasMatchingUuid(
const QBluetoothServiceInfo &serviceInfo)
const
222 for (
const auto &requestedUuid : uuidFilter) {
IOBluetoothDevice * device
#define QT_BT_MAC_AUTORELEASEPOOL
QBluetoothAddress deviceAddress
~QBluetoothServiceDiscoveryAgentPrivate()
QList< QBluetoothServiceInfo > discoveredServices
void _q_serviceDiscoveryFinished()
QBluetoothServiceDiscoveryAgentPrivate(QBluetoothServiceDiscoveryAgent *qp, const QBluetoothAddress &deviceAdapter)
QBluetoothServiceDiscoveryAgent * q_ptr
QList< QBluetoothDeviceInfo > discoveredDevices
QBluetoothServiceDiscoveryAgent::Error error
QBluetoothServiceDiscoveryAgent::DiscoveryMode DiscoveryMode()
void serviceDiscovered(const QBluetoothServiceInfo &info)
This signal is emitted when the Bluetooth service described by info is discovered.
void errorOccurred(QBluetoothServiceDiscoveryAgent::Error error)
This signal is emitted when an error occurs.
void canceled()
This signal is triggered when the service discovery was canceled via a call to \l stop().
QBluetoothUuid serviceUuid() const
This is a convenience function.
void setDevice(const QBluetoothDeviceInfo &info)
Sets the Bluetooth device that provides this service to device.
bool isValid() const
Returns true if the QBluetoothServiceInfo object is valid, otherwise returns false.
QList< QBluetoothUuid > serviceClassUuids() const
Returns a list of UUIDs describing the service classes that this service conforms to.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
static QOperatingSystemVersion current()
[0]
static constexpr QOperatingSystemVersionBase MacOSBigSur
\variable QOperatingSystemVersion::MacOSBigSur
void extract_service_record(IOBluetoothSDPServiceRecord *record, QBluetoothServiceInfo &serviceInfo)
BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &qAddress)
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define qCWarning(category,...)
#define qCDebug(category,...)
GLenum GLenum GLsizei count
#define Q_ASSERT_X(cond, x, msg)
const char SERVICE_DISCOVERY[]
const char SD_MINIMAL_FAILED[]
const char DD_UNKNOWN_ERROR[]
QT_BEGIN_NAMESPACE const char DEV_DISCOVERY[]
const char SD_LOCAL_DEV_OFF[]
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
bool contains(const AT &t) const noexcept