summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--dependencies.yaml10
-rw-r--r--src/bluetooth/android/devicediscoverybroadcastreceiver.cpp8
-rw-r--r--src/bluetooth/bluetooth.pro22
-rw-r--r--src/bluetooth/bluez/agent_p.h3
-rw-r--r--src/bluetooth/bluez/bluetoothmanagement.cpp2
-rw-r--r--src/bluetooth/bluez/hcimanager.cpp6
-rw-r--r--src/bluetooth/bluez/obex_agent_p.h3
-rw-r--r--src/bluetooth/darwin/btcentralmanager.mm (renamed from src/bluetooth/osx/osxbtcentralmanager.mm)319
-rw-r--r--src/bluetooth/darwin/btcentralmanager_p.h (renamed from src/bluetooth/osx/osxbtcentralmanager_p.h)23
-rw-r--r--src/bluetooth/darwin/btconnectionmonitor.mm (renamed from src/bluetooth/osx/osxbtconnectionmonitor.mm)21
-rw-r--r--src/bluetooth/darwin/btconnectionmonitor_p.h (renamed from src/bluetooth/osx/osxbluetooth_p.h)22
-rw-r--r--src/bluetooth/darwin/btdelegates.cpp (renamed from src/bluetooth/osx/btdelegates.cpp)0
-rw-r--r--src/bluetooth/darwin/btdelegates_p.h (renamed from src/bluetooth/osx/btdelegates_p.h)0
-rw-r--r--src/bluetooth/darwin/btdeviceinquiry.mm (renamed from src/bluetooth/osx/osxbtdeviceinquiry.mm)14
-rw-r--r--src/bluetooth/darwin/btdeviceinquiry_p.h (renamed from src/bluetooth/osx/osxbtdeviceinquiry_p.h)9
-rw-r--r--src/bluetooth/darwin/btdevicepair.mm (renamed from src/bluetooth/osx/osxbtdevicepair.mm)29
-rw-r--r--src/bluetooth/darwin/btdevicepair_p.h (renamed from src/bluetooth/osx/osxbtdevicepair_p.h)36
-rw-r--r--src/bluetooth/darwin/btgcdtimer.mm (renamed from src/bluetooth/osx/osxbtgcdtimer.mm)10
-rw-r--r--src/bluetooth/darwin/btgcdtimer_p.h (renamed from src/bluetooth/osx/osxbtgcdtimer_p.h)24
-rw-r--r--src/bluetooth/darwin/btl2capchannel.mm (renamed from src/bluetooth/osx/osxbtl2capchannel.mm)16
-rw-r--r--src/bluetooth/darwin/btl2capchannel_p.h (renamed from src/bluetooth/osx/osxbtl2capchannel_p.h)10
-rw-r--r--src/bluetooth/darwin/btledeviceinquiry.mm (renamed from src/bluetooth/osx/osxbtledeviceinquiry.mm)53
-rw-r--r--src/bluetooth/darwin/btledeviceinquiry_p.h (renamed from src/bluetooth/osx/osxbtledeviceinquiry_p.h)21
-rw-r--r--src/bluetooth/darwin/btnotifier.cpp1
-rw-r--r--src/bluetooth/darwin/btnotifier_p.h (renamed from src/bluetooth/osx/osxbtnotifier_p.h)8
-rw-r--r--src/bluetooth/darwin/btobexsession.mm (renamed from src/bluetooth/osx/osxbtobexsession.mm)98
-rw-r--r--src/bluetooth/darwin/btobexsession_p.h (renamed from src/bluetooth/osx/osxbtobexsession_p.h)23
-rw-r--r--src/bluetooth/darwin/btperipheralmanager.mm (renamed from src/bluetooth/osx/osxbtperipheralmanager.mm)139
-rw-r--r--src/bluetooth/darwin/btperipheralmanager_p.h (renamed from src/bluetooth/osx/osxbtperipheralmanager_p.h)16
-rw-r--r--src/bluetooth/darwin/btraii.mm (renamed from src/bluetooth/osx/btraii.mm)21
-rw-r--r--src/bluetooth/darwin/btraii_p.h (renamed from src/bluetooth/osx/btraii_p.h)2
-rw-r--r--src/bluetooth/darwin/btrfcommchannel.mm (renamed from src/bluetooth/osx/osxbtrfcommchannel.mm)16
-rw-r--r--src/bluetooth/darwin/btrfcommchannel_p.h (renamed from src/bluetooth/osx/osxbtrfcommchannel_p.h)10
-rw-r--r--src/bluetooth/darwin/btsdpinquiry.mm (renamed from src/bluetooth/osx/osxbtsdpinquiry.mm)41
-rw-r--r--src/bluetooth/darwin/btsdpinquiry_p.h (renamed from src/bluetooth/osx/osxbtsdpinquiry_p.h)17
-rw-r--r--src/bluetooth/darwin/btservicerecord.mm (renamed from src/bluetooth/osx/osxbtservicerecord.mm)21
-rw-r--r--src/bluetooth/darwin/btservicerecord_p.h (renamed from src/bluetooth/osx/osxbtservicerecord_p.h)10
-rw-r--r--src/bluetooth/darwin/btsocketlistener.mm (renamed from src/bluetooth/osx/osxbtsocketlistener.mm)6
-rw-r--r--src/bluetooth/darwin/btsocketlistener_p.h (renamed from src/bluetooth/osx/osxbtsocketlistener_p.h)14
-rw-r--r--src/bluetooth/darwin/btutility.mm (renamed from src/bluetooth/osx/osxbtutility.mm)52
-rw-r--r--src/bluetooth/darwin/btutility_p.h (renamed from src/bluetooth/osx/osxbtutility_p.h)235
-rw-r--r--src/bluetooth/darwin/darwinbt.pri48
-rw-r--r--src/bluetooth/darwin/uistrings.cpp (renamed from src/bluetooth/osx/uistrings.cpp)0
-rw-r--r--src/bluetooth/darwin/uistrings_p.h (renamed from src/bluetooth/osx/uistrings_p.h)0
-rw-r--r--src/bluetooth/lecmaccalculator.cpp2
-rw-r--r--src/bluetooth/osx/osxbtconnectionmonitor_p.h89
-rw-r--r--src/bluetooth/osx/osxbtnotifier.cpp1
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm57
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_p.h4
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp6
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp4
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_macos.mm (renamed from src/bluetooth/qbluetoothlocaldevice_osx.mm)118
-rw-r--r--src/bluetooth/qbluetoothserver_macos.mm (renamed from src/bluetooth/qbluetoothserver_osx.mm)53
-rw-r--r--src/bluetooth/qbluetoothserver_p.h4
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp4
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_macos.mm (renamed from src/bluetooth/qbluetoothservicediscoveryagent_osx.mm)19
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_p.h4
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp18
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_macos.mm (renamed from src/bluetooth/qbluetoothserviceinfo_osx.mm)19
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_p.h2
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp2
-rw-r--r--src/bluetooth/qbluetoothsocket_macos.mm (renamed from src/bluetooth/qbluetoothsocket_osx.mm)40
-rw-r--r--src/bluetooth/qbluetoothsocket_macos_p.h (renamed from src/bluetooth/qbluetoothsocket_osx_p.h)4
-rw-r--r--src/bluetooth/qbluetoothtransfermanager.cpp2
-rw-r--r--src/bluetooth/qbluetoothtransferreply_macos.mm (renamed from src/bluetooth/qbluetoothtransferreply_osx.mm)41
-rw-r--r--src/bluetooth/qbluetoothtransferreply_macos_p.h (renamed from src/bluetooth/qbluetoothtransferreply_osx_p.h)0
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp48
-rw-r--r--src/bluetooth/qlowenergycontroller_darwin.mm192
-rw-r--r--src/bluetooth/qlowenergycontroller_darwin_p.h6
-rw-r--r--src/bluetooth/windows/windows.pri2
-rw-r--r--src/imports/nfc/qdeclarativendeffilter.cpp2
-rw-r--r--src/nfc/targetemulator.cpp2
-rw-r--r--tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp6
-rw-r--r--tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp8
75 files changed, 992 insertions, 1208 deletions
diff --git a/.qmake.conf b/.qmake.conf
index b3c7403c..85f18db7 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -2,4 +2,4 @@ load(qt_build_config)
DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST
-MODULE_VERSION = 5.15.0
+MODULE_VERSION = 6.0.0
diff --git a/dependencies.yaml b/dependencies.yaml
new file mode 100644
index 00000000..a80be7b8
--- /dev/null
+++ b/dependencies.yaml
@@ -0,0 +1,10 @@
+dependencies:
+ ../qtandroidextras:
+ ref: e3ee40f78d3894b5fc62101de2f25ea2563e579c
+ required: false
+ ../qtbase:
+ ref: 8652c79df0a47264a2d525424484e15744e2462b
+ required: true
+ ../qtdeclarative:
+ ref: d5dc3c4cbdc4455143626d7a3e0f9a9a211515a9
+ required: false
diff --git a/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp b/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
index f1f50516..19023efe 100644
--- a/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
+++ b/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
@@ -72,7 +72,7 @@ static QBitArray initializeMinorCaches()
case QBluetoothDeviceInfo::MiscellaneousDevice:
case QBluetoothDeviceInfo::ComputerDevice:
case QBluetoothDeviceInfo::PhoneDevice:
- case QBluetoothDeviceInfo::LANAccessDevice:
+ case QBluetoothDeviceInfo::NetworkDevice:
case QBluetoothDeviceInfo::AudioVideoDevice:
case QBluetoothDeviceInfo::PeripheralDevice:
case QBluetoothDeviceInfo::ImagingDevice:
@@ -114,7 +114,7 @@ static const MajorClassJavaToQtMapping majorMappings[] = {
{ "HEALTH", QBluetoothDeviceInfo::HealthDevice },
{ "IMAGING", QBluetoothDeviceInfo::ImagingDevice },
{ "MISC", QBluetoothDeviceInfo::MiscellaneousDevice },
- { "NETWORKING", QBluetoothDeviceInfo::LANAccessDevice },
+ { "NETWORKING", QBluetoothDeviceInfo::NetworkDevice },
{ "PERIPHERAL", QBluetoothDeviceInfo::PeripheralDevice },
{ "PHONE", QBluetoothDeviceInfo::PhoneDevice },
{ "TOY", QBluetoothDeviceInfo::ToyDevice },
@@ -130,7 +130,7 @@ static const int minorIndexSizes[] = {
61, // QBluetoothDevice::MiscellaneousDevice
18, // QBluetoothDevice::ComputerDevice
35, // QBluetoothDevice::PhoneDevice
- 62, // QBluetoothDevice::LANAccessDevice
+ 62, // QBluetoothDevice::NetworkDevice
0, // QBluetoothDevice::AudioVideoDevice
56, // QBluetoothDevice::PeripheralDevice
63, // QBluetoothDevice::ImagingDEvice
@@ -227,7 +227,7 @@ static const MinorClassJavaToQtMapping minorMappings[] = {
// QBluetoothDevice::Miscellaneous
{ nullptr, 0 }, // index 61 & separator
- // QBluetoothDevice::LANAccessDevice
+ // QBluetoothDevice::NetworkDevice
{ nullptr, 0 }, // index 62 & separator
// QBluetoothDevice::ImagingDevice
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index f09564cd..b2ed5edf 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -157,20 +157,20 @@ qtConfig(bluez) {
DEFINES += QT_OSX_BLUETOOTH
LIBS_PRIVATE += -framework Foundation -framework IOBluetooth
- include(osx/osxbt.pri)
+ include(darwin/darwinbt.pri)
OBJECTIVE_SOURCES += \
- qbluetoothlocaldevice_osx.mm \
+ qbluetoothlocaldevice_macos.mm \
qbluetoothdevicediscoveryagent_darwin.mm \
- qbluetoothserviceinfo_osx.mm \
- qbluetoothservicediscoveryagent_osx.mm \
- qbluetoothsocket_osx.mm \
- qbluetoothserver_osx.mm \
- qbluetoothtransferreply_osx.mm \
+ qbluetoothserviceinfo_macos.mm \
+ qbluetoothservicediscoveryagent_macos.mm \
+ qbluetoothsocket_macos.mm \
+ qbluetoothserver_macos.mm \
+ qbluetoothtransferreply_macos.mm \
qlowenergycontroller_darwin.mm
- HEADERS += qbluetoothsocket_osx_p.h \
- qbluetoothtransferreply_osx_p.h \
- qlowenergycontroller_darwin_p.h
+ HEADERS += qbluetoothsocket_macos_p.h \
+ qbluetoothtransferreply_macos_p.h \
+ qlowenergycontroller_darwin_p.h
} else:ios|tvos {
DEFINES += QT_IOS_BLUETOOTH
LIBS_PRIVATE += -framework Foundation -framework CoreBluetooth
@@ -183,7 +183,7 @@ qtConfig(bluez) {
qlowenergycontroller_darwin_p.h \
qbluetoothsocket_dummy_p.h
- include(osx/osxbt.pri)
+ include(darwin/darwinbt.pri)
SOURCES += \
qbluetoothlocaldevice_p.cpp \
qbluetoothserviceinfo_p.cpp \
diff --git a/src/bluetooth/bluez/agent_p.h b/src/bluetooth/bluez/agent_p.h
index 32efa62e..7ca177fd 100644
--- a/src/bluetooth/bluez/agent_p.h
+++ b/src/bluetooth/bluez/agent_p.h
@@ -13,11 +13,10 @@
#define AGENT_P_H
#include <QtCore/QObject>
+#include <QtCore/qcontainerfwd.h>
#include <QtDBus/QtDBus>
QT_BEGIN_NAMESPACE
class QByteArray;
-template<class T> class QList;
-template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
diff --git a/src/bluetooth/bluez/bluetoothmanagement.cpp b/src/bluetooth/bluez/bluetoothmanagement.cpp
index 31d3dc02..6a1e8864 100644
--- a/src/bluetooth/bluez/bluetoothmanagement.cpp
+++ b/src/bluetooth/bluez/bluetoothmanagement.cpp
@@ -254,7 +254,7 @@ void BluetoothManagement::_q_readNotifier()
}
default:
qCDebug(QT_BT_BLUEZ) << "BluetoothManagement: Ignored event:"
- << hex << qFromLittleEndian(hdr->cmdCode);
+ << Qt::hex << qFromLittleEndian(hdr->cmdCode);
break;
}
diff --git a/src/bluetooth/bluez/hcimanager.cpp b/src/bluetooth/bluez/hcimanager.cpp
index 2a7c9060..845dfec0 100644
--- a/src/bluetooth/bluez/hcimanager.cpp
+++ b/src/bluetooth/bluez/hcimanager.cpp
@@ -320,7 +320,7 @@ QVector<quint16> HciManager::activeLowEnergyConnections() const
activeLowEnergyHandles.append(info[i].handle);
break;
default:
- qCWarning(QT_BT_BLUEZ) << "Unknown active connection type:" << hex << info[i].type;
+ qCWarning(QT_BT_BLUEZ) << "Unknown active connection type:" << Qt::hex << info[i].type;
break;
}
}
@@ -467,7 +467,7 @@ void HciManager::handleHciEventPacket(const quint8 *data, int size)
return;
}
- qCDebug(QT_BT_BLUEZ) << "HCI event triggered, type:" << hex << header->evt;
+ qCDebug(QT_BT_BLUEZ) << "HCI event triggered, type:" << Qt::hex << header->evt;
switch (header->evt) {
case EVT_ENCRYPT_CHANGE:
@@ -475,7 +475,7 @@ void HciManager::handleHciEventPacket(const quint8 *data, int size)
const evt_encrypt_change *event = (evt_encrypt_change *) data;
qCDebug(QT_BT_BLUEZ) << "HCI Encrypt change, status:"
<< (event->status == 0 ? "Success" : "Failed")
- << "handle:" << hex << event->handle
+ << "handle:" << Qt::hex << event->handle
<< "encrypt:" << event->encrypt;
QBluetoothAddress remoteDevice = addressForConnectionHandle(event->handle);
diff --git a/src/bluetooth/bluez/obex_agent_p.h b/src/bluetooth/bluez/obex_agent_p.h
index 242b2598..b370810d 100644
--- a/src/bluetooth/bluez/obex_agent_p.h
+++ b/src/bluetooth/bluez/obex_agent_p.h
@@ -13,11 +13,10 @@
#define OBEX_AGENT_P_H
#include <QtCore/QObject>
+#include <QtCore/qcontainerfwd.h>
#include <QtDBus/QtDBus>
QT_BEGIN_NAMESPACE
class QByteArray;
-template<class T> class QList;
-template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/darwin/btcentralmanager.mm
index b9a1ae0f..86950302 100644
--- a/src/bluetooth/osx/osxbtcentralmanager.mm
+++ b/src/bluetooth/darwin/btcentralmanager.mm
@@ -40,8 +40,8 @@
#include "qlowenergyserviceprivate_p.h"
#include "qlowenergycharacteristic.h"
#include "qlowenergycontroller.h"
-#include "osxbtcentralmanager_p.h"
-#include "osxbtnotifier_p.h"
+#include "btcentralmanager_p.h"
+#include "btnotifier_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qdebug.h>
@@ -54,7 +54,7 @@ Q_DECLARE_METATYPE(QLowEnergyHandle)
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
NSUInteger qt_countGATTEntries(CBService *service)
{
@@ -91,7 +91,7 @@ ObjCStrongReference<NSError> qt_timeoutNSError(OperationTimeout type)
NSError *nsError = [[NSError alloc] initWithDomain:CBErrorDomain
code:CBErrorOperationCancelled
userInfo:nil];
- return ObjCStrongReference<NSError>(nsError, false /*do not retain, done already*/);
+ return ObjCStrongReference<NSError>(nsError, RetainPolicy::noInitialRetain);
}
auto qt_find_watchdog(const std::vector<GCDTimer> &watchdogs, id object, OperationTimeout type)
@@ -100,17 +100,17 @@ auto qt_find_watchdog(const std::vector<GCDTimer> &watchdogs, id object, Operati
return [other objectUnderWatch] == object && [other timeoutType] == type;});
}
-} // namespace OSXBluetooth
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
QT_USE_NAMESPACE
-@interface QT_MANGLE_NAMESPACE(OSXBTCentralManager) (PrivateAPI)
+@interface QT_MANGLE_NAMESPACE(DarwinBTCentralManager) (PrivateAPI)
-- (void)watchAfter:(id)object timeout:(OSXBluetooth::OperationTimeout)type;
-- (bool)objectIsUnderWatch:(id)object operation:(OSXBluetooth::OperationTimeout)type;
-- (void)stopWatchingAfter:(id)object operation:(OSXBluetooth::OperationTimeout)type;
+- (void)watchAfter:(id)object timeout:(DarwinBluetooth::OperationTimeout)type;
+- (bool)objectIsUnderWatch:(id)object operation:(DarwinBluetooth::OperationTimeout)type;
+- (void)stopWatchingAfter:(id)object operation:(DarwinBluetooth::OperationTimeout)type;
- (void)stopWatchers;
- (void)retrievePeripheralAndConnect;
- (void)connectToPeripheral;
@@ -138,50 +138,50 @@ QT_USE_NAMESPACE
@end
-@implementation QT_MANGLE_NAMESPACE(OSXBTCentralManager)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTCentralManager)
{
@private
CBCentralManager *manager;
- OSXBluetooth::CentralManagerState managerState;
+ DarwinBluetooth::CentralManagerState managerState;
bool disconnectPending;
QBluetoothUuid deviceUuid;
- OSXBluetooth::LECBManagerNotifier *notifier;
+ DarwinBluetooth::LECBManagerNotifier *notifier;
// Quite a verbose service discovery machinery
// (a "graph traversal").
- OSXBluetooth::ObjCStrongReference<NSMutableArray> servicesToVisit;
+ DarwinBluetooth::ObjCStrongReference<NSMutableArray> servicesToVisit;
// The service we're discovering now (included services discovery):
NSUInteger currentService;
// Included services, we'll iterate through at the end of 'servicesToVisit':
- OSXBluetooth::ObjCStrongReference<NSMutableArray> servicesToVisitNext;
+ DarwinBluetooth::ObjCStrongReference<NSMutableArray> servicesToVisitNext;
// We'd like to avoid loops in a services' topology:
- OSXBluetooth::ObjCStrongReference<NSMutableSet> visitedServices;
+ DarwinBluetooth::ObjCStrongReference<NSMutableSet> visitedServices;
QList<QBluetoothUuid> servicesToDiscoverDetails;
- OSXBluetooth::ServiceHash serviceMap;
- OSXBluetooth::CharHash charMap;
- OSXBluetooth::DescHash descMap;
+ DarwinBluetooth::ServiceHash serviceMap;
+ DarwinBluetooth::CharHash charMap;
+ DarwinBluetooth::DescHash descMap;
QLowEnergyHandle lastValidHandle;
bool requestPending;
- OSXBluetooth::RequestQueue requests;
+ DarwinBluetooth::RequestQueue requests;
QLowEnergyHandle currentReadHandle;
- OSXBluetooth::ValueHash valuesToWrite;
+ DarwinBluetooth::ValueHash valuesToWrite;
qint64 timeoutMS;
- std::vector<OSXBluetooth::GCDTimer> timeoutWatchdogs;
+ std::vector<DarwinBluetooth::GCDTimer> timeoutWatchdogs;
CBPeripheral *peripheral;
}
-- (id)initWith:(OSXBluetooth::LECBManagerNotifier *)aNotifier
+- (id)initWith:(DarwinBluetooth::LECBManagerNotifier *)aNotifier
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (self = [super init]) {
manager = nil;
@@ -215,9 +215,9 @@ QT_USE_NAMESPACE
// Strangely enough, I can not reproduce this anymore, so this
// part is simplified now. To be investigated though.
- visitedServices.reset(nil);
- servicesToVisit.reset(nil);
- servicesToVisitNext.reset(nil);
+ visitedServices.reset();
+ servicesToVisit.reset();
+ servicesToVisitNext.reset();
[manager setDelegate:nil];
[manager release];
@@ -237,24 +237,24 @@ QT_USE_NAMESPACE
return peripheral;
}
-- (void)watchAfter:(id)object timeout:(OSXBluetooth::OperationTimeout)type
+- (void)watchAfter:(id)object timeout:(DarwinBluetooth::OperationTimeout)type
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
- GCDTimer newWatcher([[GCDTimerObjC alloc] initWithDelegate:self], false /*do not retain*/);
+ GCDTimer newWatcher([[GCDTimerObjC alloc] initWithDelegate:self], RetainPolicy::noInitialRetain);
[newWatcher watchAfter:object withTimeoutType:type];
timeoutWatchdogs.push_back(newWatcher);
[newWatcher startWithTimeout:timeoutMS step:200];
}
-- (bool)objectIsUnderWatch:(id)object operation:(OSXBluetooth::OperationTimeout)type
+- (bool)objectIsUnderWatch:(id)object operation:(DarwinBluetooth::OperationTimeout)type
{
- return OSXBluetooth::qt_find_watchdog(timeoutWatchdogs, object, type) != timeoutWatchdogs.end();
+ return DarwinBluetooth::qt_find_watchdog(timeoutWatchdogs, object, type) != timeoutWatchdogs.end();
}
-- (void)stopWatchingAfter:(id)object operation:(OSXBluetooth::OperationTimeout)type
+- (void)stopWatchingAfter:(id)object operation:(DarwinBluetooth::OperationTimeout)type
{
- auto pos = OSXBluetooth::qt_find_watchdog(timeoutWatchdogs, object, type);
+ auto pos = DarwinBluetooth::qt_find_watchdog(timeoutWatchdogs, object, type);
if (pos != timeoutWatchdogs.end()) {
[*pos cancelTimer];
timeoutWatchdogs.erase(pos);
@@ -272,7 +272,7 @@ QT_USE_NAMESPACE
{
Q_UNUSED(sender)
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
GCDTimerObjC *watcher = static_cast<GCDTimerObjC *>(sender);
id cbObject = [watcher objectUnderWatch];
@@ -287,31 +287,31 @@ QT_USE_NAMESPACE
const ObjCStrongReference<NSError> nsError(qt_timeoutNSError(type));
switch (type) {
case OperationTimeout::serviceDiscovery:
- qCWarning(QT_BT_OSX, "Timeout in services discovery");
+ qCWarning(QT_BT_DARWIN, "Timeout in services discovery");
[self peripheral:peripheral didDiscoverServices:nsError];
break;
case OperationTimeout::includedServicesDiscovery:
- qCWarning(QT_BT_OSX, "Timeout in included services discovery");
+ qCWarning(QT_BT_DARWIN, "Timeout in included services discovery");
[self peripheral:peripheral didDiscoverIncludedServicesForService:cbObject error:nsError];
break;
case OperationTimeout::characteristicsDiscovery:
- qCWarning(QT_BT_OSX, "Timeout in characteristics discovery");
+ qCWarning(QT_BT_DARWIN, "Timeout in characteristics discovery");
[self peripheral:peripheral didDiscoverCharacteristicsForService:cbObject error:nsError];
break;
case OperationTimeout::characteristicRead:
- qCWarning(QT_BT_OSX, "Timeout while reading a characteristic");
+ qCWarning(QT_BT_DARWIN, "Timeout while reading a characteristic");
[self peripheral:peripheral didUpdateValueForCharacteristic:cbObject error:nsError];
break;
case OperationTimeout::descriptorsDiscovery:
- qCWarning(QT_BT_OSX, "Timeout in descriptors discovery");
+ qCWarning(QT_BT_DARWIN, "Timeout in descriptors discovery");
[self peripheral:peripheral didDiscoverDescriptorsForCharacteristic:cbObject error:nsError];
break;
case OperationTimeout::descriptorRead:
- qCWarning(QT_BT_OSX, "Timeout while reading a descriptor");
+ qCWarning(QT_BT_DARWIN, "Timeout while reading a descriptor");
[self peripheral:peripheral didUpdateValueForDescriptor:cbObject error:nsError];
break;
case OperationTimeout::characteristicWrite:
- qCWarning(QT_BT_OSX, "Timeout while writing a characteristic with response");
+ qCWarning(QT_BT_DARWIN, "Timeout while writing a characteristic with response");
[self peripheral:peripheral didWriteValueForCharacteristic:cbObject error:nsError];
default:;
}
@@ -325,18 +325,18 @@ QT_USE_NAMESPACE
if (!manager) {
// The first time we try to connect, no manager created yet,
// no status update received.
- if (const dispatch_queue_t leQueue = OSXBluetooth::qt_LE_queue()) {
- managerState = OSXBluetooth::CentralManagerUpdating;
+ if (const dispatch_queue_t leQueue = DarwinBluetooth::qt_LE_queue()) {
+ managerState = DarwinBluetooth::CentralManagerUpdating;
manager = [[CBCentralManager alloc] initWithDelegate:self queue:leQueue];
}
if (!manager) {
- managerState = OSXBluetooth::CentralManagerIdle;
- qCWarning(QT_BT_OSX) << "failed to allocate a central manager";
+ managerState = DarwinBluetooth::CentralManagerIdle;
+ qCWarning(QT_BT_DARWIN) << "failed to allocate a central manager";
if (notifier)
emit notifier->CBManagerError(QLowEnergyController::ConnectionError);
}
- } else if (managerState != OSXBluetooth::CentralManagerUpdating) {
+ } else if (managerState != DarwinBluetooth::CentralManagerUpdating) {
[self retrievePeripheralAndConnect];
}
}
@@ -344,11 +344,11 @@ QT_USE_NAMESPACE
- (void)retrievePeripheralAndConnect
{
Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid central manager (nil)");
- Q_ASSERT_X(managerState == OSXBluetooth::CentralManagerIdle,
+ Q_ASSERT_X(managerState == DarwinBluetooth::CentralManagerIdle,
Q_FUNC_INFO, "invalid state");
if ([self isConnected]) {
- qCDebug(QT_BT_OSX) << "already connected";
+ qCDebug(QT_BT_DARWIN) << "already connected";
if (notifier)
emit notifier->connected();
return;
@@ -359,12 +359,12 @@ QT_USE_NAMESPACE
return;
}
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
// Retrieve a peripheral first ...
- ObjCScopedPointer<NSMutableArray> uuids([[NSMutableArray alloc] init]);
+ const ObjCScopedPointer<NSMutableArray> uuids([[NSMutableArray alloc] init], RetainPolicy::noInitialRetain);
if (!uuids) {
- qCWarning(QT_BT_OSX) << "failed to allocate identifiers";
+ qCWarning(QT_BT_DARWIN) << "failed to allocate identifiers";
if (notifier)
emit notifier->CBManagerError(QLowEnergyController::ConnectionError);
return;
@@ -374,9 +374,9 @@ QT_USE_NAMESPACE
const quint128 qtUuidData(deviceUuid.toUInt128());
uuid_t uuidData = {};
std::copy(qtUuidData.data, qtUuidData.data + 16, uuidData);
- const ObjCScopedPointer<NSUUID> nsUuid([[NSUUID alloc] initWithUUIDBytes:uuidData]);
+ const ObjCScopedPointer<NSUUID> nsUuid([[NSUUID alloc] initWithUUIDBytes:uuidData], RetainPolicy::noInitialRetain);
if (!nsUuid) {
- qCWarning(QT_BT_OSX) << "failed to allocate NSUUID identifier";
+ qCWarning(QT_BT_DARWIN) << "failed to allocate NSUUID identifier";
if (notifier)
emit notifier->CBManagerError(QLowEnergyController::ConnectionError);
return;
@@ -387,7 +387,7 @@ QT_USE_NAMESPACE
QT_BT_MAC_AUTORELEASEPOOL;
NSArray *const peripherals = [manager retrievePeripheralsWithIdentifiers:uuids];
if (!peripherals || peripherals.count != 1) {
- qCWarning(QT_BT_OSX) << "failed to retrive a peripheral";
+ qCWarning(QT_BT_DARWIN) << "failed to retrive a peripheral";
if (notifier)
emit notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError);
return;
@@ -399,7 +399,7 @@ QT_USE_NAMESPACE
- (void)connectToPeripheral
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid central manager (nil)");
Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
@@ -407,11 +407,11 @@ QT_USE_NAMESPACE
// The state is still the same - connecting.
if ([self isConnected]) {
- qCDebug(QT_BT_OSX) << "already connected";
+ qCDebug(QT_BT_DARWIN) << "already connected";
if (notifier)
emit notifier->connected();
} else {
- qCDebug(QT_BT_OSX) << "trying to connect";
+ qCDebug(QT_BT_DARWIN) << "trying to connect";
managerState = CentralManagerConnecting;
[manager connectPeripheral:peripheral options:nil];
}
@@ -429,7 +429,7 @@ QT_USE_NAMESPACE
{
[self reset];
- if (managerState == OSXBluetooth::CentralManagerUpdating) {
+ if (managerState == DarwinBluetooth::CentralManagerUpdating) {
disconnectPending = true; // this is for 'didUpdate' method.
if (notifier) {
// We were waiting for the first update
@@ -442,9 +442,9 @@ QT_USE_NAMESPACE
} else {
disconnectPending = false;
if ([self isConnected])
- managerState = OSXBluetooth::CentralManagerDisconnecting;
+ managerState = DarwinBluetooth::CentralManagerDisconnecting;
else
- managerState = OSXBluetooth::CentralManagerIdle;
+ managerState = DarwinBluetooth::CentralManagerIdle;
// We have to call -cancelPeripheralConnection: even
// if not connected (to cancel a pending connect attempt).
@@ -457,7 +457,7 @@ QT_USE_NAMESPACE
- (void)discoverServices
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
Q_ASSERT_X(managerState == CentralManagerIdle, Q_FUNC_INFO, "invalid state");
@@ -477,7 +477,7 @@ QT_USE_NAMESPACE
- (void)discoverIncludedServices
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(managerState == CentralManagerIdle, Q_FUNC_INFO, "invalid state");
Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid manager (nil)");
@@ -492,10 +492,10 @@ QT_USE_NAMESPACE
emit notifier->serviceDiscoveryFinished();
} else {
// 'reset' also calls retain on a parameter.
- servicesToVisitNext.reset(nil);
- servicesToVisit.reset([NSMutableArray arrayWithArray:services]);
+ servicesToVisitNext.reset();
+ servicesToVisit.reset([NSMutableArray arrayWithArray:services], RetainPolicy::doInitialRetain);
currentService = 0;
- visitedServices.reset([NSMutableSet setWithCapacity:peripheral.services.count]);
+ visitedServices.reset([NSMutableSet setWithCapacity:peripheral.services.count], RetainPolicy::doInitialRetain);
CBService *const s = [services objectAtIndex:currentService];
[visitedServices addObject:s];
@@ -511,15 +511,15 @@ QT_USE_NAMESPACE
// can be called concurrently (not waiting for the previous
// discovery to finish).
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(managerState != CentralManagerUpdating, Q_FUNC_INFO, "invalid state");
Q_ASSERT_X(!serviceUuid.isNull(), Q_FUNC_INFO, "invalid service UUID");
Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
if (servicesToDiscoverDetails.contains(serviceUuid)) {
- qCWarning(QT_BT_OSX) << "already discovering for"
- << serviceUuid;
+ qCWarning(QT_BT_DARWIN) << "already discovering for"
+ << serviceUuid;
return;
}
@@ -532,8 +532,8 @@ QT_USE_NAMESPACE
return;
}
- qCWarning(QT_BT_OSX) << "unknown service uuid"
- << serviceUuid;
+ qCWarning(QT_BT_DARWIN) << "unknown service uuid"
+ << serviceUuid;
if (notifier)
emit notifier->CBManagerError(serviceUuid, QLowEnergyService::UnknownError);
@@ -545,7 +545,7 @@ QT_USE_NAMESPACE
// have several 'detail discoveries' active.
Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QT_BT_MAC_AUTORELEASEPOOL;
@@ -574,7 +574,7 @@ QT_USE_NAMESPACE
// several discoveries active.
Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QT_BT_MAC_AUTORELEASEPOOL;
@@ -595,7 +595,7 @@ QT_USE_NAMESPACE
- (void)readDescriptors:(CBService *)service
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
Q_ASSERT_X(managerState != CentralManagerUpdating, Q_FUNC_INFO, "invalid state");
@@ -622,7 +622,7 @@ QT_USE_NAMESPACE
{
Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QT_BT_MAC_AUTORELEASEPOOL;
@@ -635,7 +635,7 @@ QT_USE_NAMESPACE
const QLowEnergyHandle maxHandle = std::numeric_limits<QLowEnergyHandle>::max();
if (nHandles >= maxHandle || lastValidHandle > maxHandle - nHandles) {
// Well, that's unlikely :) But we must be sure.
- qCWarning(QT_BT_OSX) << "can not allocate more handles";
+ qCWarning(QT_BT_DARWIN) << "can not allocate more handles";
if (notifier)
notifier->CBManagerError(serviceUuid, QLowEnergyService::OperationError);
return;
@@ -706,7 +706,7 @@ QT_USE_NAMESPACE
- (void)performNextRequest
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (requestPending || !requests.size())
return;
@@ -727,7 +727,7 @@ QT_USE_NAMESPACE
- (void)performNextReadRequest
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
Q_ASSERT_X(!requestPending, Q_FUNC_INFO, "processing another request");
@@ -739,8 +739,8 @@ QT_USE_NAMESPACE
const LERequest request(requests.dequeue());
if (request.type == LERequest::CharRead) {
if (!charMap.contains(request.handle)) {
- qCWarning(QT_BT_OSX) << "characteristic with handle"
- << request.handle << "not found";
+ qCWarning(QT_BT_DARWIN) << "characteristic with handle"
+ << request.handle << "not found";
return [self performNextRequest];
}
@@ -751,8 +751,8 @@ QT_USE_NAMESPACE
[peripheral readValueForCharacteristic:charMap[request.handle]];
} else {
if (!descMap.contains(request.handle)) {
- qCWarning(QT_BT_OSX) << "descriptor with handle"
- << request.handle << "not found";
+ qCWarning(QT_BT_DARWIN) << "descriptor with handle"
+ << request.handle << "not found";
return [self performNextRequest];
}
@@ -765,7 +765,7 @@ QT_USE_NAMESPACE
- (void)performNextWriteRequest
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
Q_ASSERT_X(!requestPending, Q_FUNC_INFO, "processing another request");
@@ -779,8 +779,8 @@ QT_USE_NAMESPACE
if (request.type == LERequest::DescWrite) {
if (!descMap.contains(request.handle)) {
- qCWarning(QT_BT_OSX) << "handle:" << request.handle
- << "not found";
+ qCWarning(QT_BT_DARWIN) << "handle:" << request.handle
+ << "not found";
return [self performNextRequest];
}
@@ -788,7 +788,7 @@ QT_USE_NAMESPACE
ObjCStrongReference<NSData> data(data_from_bytearray(request.value));
if (!data) {
// Even if qtData.size() == 0, we still need NSData object.
- qCWarning(QT_BT_OSX) << "failed to allocate an NSData object";
+ qCWarning(QT_BT_DARWIN) << "failed to allocate an NSData object";
return [self performNextRequest];
}
@@ -799,8 +799,8 @@ QT_USE_NAMESPACE
return [peripheral writeValue:data.data() forDescriptor:descriptor];
} else {
if (!charMap.contains(request.handle)) {
- qCWarning(QT_BT_OSX) << "characteristic with handle:"
- << request.handle << "not found";
+ qCWarning(QT_BT_DARWIN) << "characteristic with handle:"
+ << request.handle << "not found";
return [self performNextRequest];
}
@@ -825,7 +825,7 @@ QT_USE_NAMESPACE
ObjCStrongReference<NSData> data(data_from_bytearray(request.value));
if (!data) {
// Even if qtData.size() == 0, we still need NSData object.
- qCWarning(QT_BT_OSX) << "failed to allocate NSData object";
+ qCWarning(QT_BT_DARWIN) << "failed to allocate NSData object";
return [self performNextRequest];
}
@@ -851,13 +851,13 @@ QT_USE_NAMESPACE
forCharacteristic:(QLowEnergyHandle)charHandle
onService:(const QBluetoothUuid &)serviceUuid
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle (0)");
if (!charMap.contains(charHandle)) {
- qCWarning(QT_BT_OSX) << "unknown characteristic handle"
- << charHandle;
+ qCWarning(QT_BT_DARWIN) << "unknown characteristic handle"
+ << charHandle;
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::DescriptorWriteError);
@@ -870,7 +870,7 @@ QT_USE_NAMESPACE
// it back, so check _now_ that we really have this descriptor.
const QBluetoothUuid qtUuid(QBluetoothUuid::ClientCharacteristicConfiguration);
if (![self descriptor:qtUuid forCharacteristic:charMap[charHandle]]) {
- qCWarning(QT_BT_OSX) << "no client characteristic configuration found";
+ qCWarning(QT_BT_DARWIN) << "no client characteristic configuration found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::DescriptorWriteError);
@@ -890,14 +890,14 @@ QT_USE_NAMESPACE
- (void)readCharacteristic:(QLowEnergyHandle)charHandle
onService:(const QBluetoothUuid &)serviceUuid
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle (0)");
QT_BT_MAC_AUTORELEASEPOOL;
if (!charMap.contains(charHandle)) {
- qCWarning(QT_BT_OSX) << "characteristic:" << charHandle << "not found";
+ qCWarning(QT_BT_DARWIN) << "characteristic:" << charHandle << "not found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::CharacteristicReadError);
@@ -919,14 +919,14 @@ QT_USE_NAMESPACE
onService:(const QBluetoothUuid &)serviceUuid
withResponse:(bool)withResponse
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle (0)");
QT_BT_MAC_AUTORELEASEPOOL;
if (!charMap.contains(charHandle)) {
- qCWarning(QT_BT_OSX) << "characteristic:" << charHandle << "not found";
+ qCWarning(QT_BT_DARWIN) << "characteristic:" << charHandle << "not found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::CharacteristicWriteError);
@@ -947,12 +947,12 @@ QT_USE_NAMESPACE
- (void)readDescriptor:(QLowEnergyHandle)descHandle
onService:(const QBluetoothUuid &)serviceUuid
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(descHandle, Q_FUNC_INFO, "invalid descriptor handle (0)");
if (!descMap.contains(descHandle)) {
- qCWarning(QT_BT_OSX) << "handle:" << descHandle << "not found";
+ qCWarning(QT_BT_DARWIN) << "handle:" << descHandle << "not found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::DescriptorReadError);
@@ -972,12 +972,12 @@ QT_USE_NAMESPACE
descHandle:(QLowEnergyHandle)descHandle
onService:(const QBluetoothUuid &)serviceUuid
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(descHandle, Q_FUNC_INFO, "invalid descriptor handle (0)");
if (!descMap.contains(descHandle)) {
- qCWarning(QT_BT_OSX) << "handle:" << descHandle << "not found";
+ qCWarning(QT_BT_DARWIN) << "handle:" << descHandle << "not found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::DescriptorWriteError);
@@ -998,14 +998,14 @@ QT_USE_NAMESPACE
- (CBService *)serviceForUUID:(const QBluetoothUuid &)qtUuid
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(!qtUuid.isNull(), Q_FUNC_INFO, "invalid uuid");
Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
- ObjCStrongReference<NSMutableArray> toVisit([NSMutableArray arrayWithArray:peripheral.services], true);
- ObjCStrongReference<NSMutableArray> toVisitNext([[NSMutableArray alloc] init], false);
- ObjCStrongReference<NSMutableSet> visitedNodes([[NSMutableSet alloc] init], false);
+ ObjCStrongReference<NSMutableArray> toVisit([NSMutableArray arrayWithArray:peripheral.services], RetainPolicy::doInitialRetain);
+ ObjCStrongReference<NSMutableArray> toVisitNext([[NSMutableArray alloc] init], RetainPolicy::noInitialRetain);
+ ObjCStrongReference<NSMutableSet> visitedNodes([[NSMutableSet alloc] init], RetainPolicy::noInitialRetain);
while (true) {
for (NSUInteger i = 0, e = [toVisit count]; i < e; ++i) {
@@ -1021,8 +1021,8 @@ QT_USE_NAMESPACE
if (![toVisitNext count])
return nil;
- toVisit.resetWithoutRetain(toVisitNext.take());
- toVisitNext.resetWithoutRetain([[NSMutableArray alloc] init]);
+ toVisit.swap(toVisitNext);
+ toVisitNext.reset([[NSMutableArray alloc] init], RetainPolicy::noInitialRetain);
}
return nil;
@@ -1146,7 +1146,7 @@ QT_USE_NAMESPACE
NSArray *const ds = ch.descriptors;
if (ds && ds.count) {
for (CBDescriptor *d in ds) {
- if (OSXBluetooth::equal_uuids(d.UUID, qtUuid)) {
+ if (DarwinBluetooth::equal_uuids(d.UUID, qtUuid)) {
descriptor = d;
break;
}
@@ -1163,26 +1163,26 @@ QT_USE_NAMESPACE
if ([obj isKindOfClass:[CBCharacteristic class]]) {
CBCharacteristic *const ch = static_cast<CBCharacteristic *>(obj);
if (!charMap.key(ch)) {
- qCWarning(QT_BT_OSX) << "unexpected characteristic, no handle found";
+ qCWarning(QT_BT_DARWIN) << "unexpected characteristic, no handle found";
return false;
}
} else if ([obj isKindOfClass:[CBDescriptor class]]) {
CBDescriptor *const d = static_cast<CBDescriptor *>(obj);
if (!descMap.key(d)) {
- qCWarning(QT_BT_OSX) << "unexpected descriptor, no handle found";
+ qCWarning(QT_BT_DARWIN) << "unexpected descriptor, no handle found";
return false;
}
} else {
- qCWarning(QT_BT_OSX) << "invalid object, characteristic "
- "or descriptor required";
+ qCWarning(QT_BT_DARWIN) << "invalid object, characteristic "
+ "or descriptor required";
return false;
}
if (valuesToWrite.contains(obj)) {
// It can be a result of some previous errors - for example,
// we never got a callback from a previous write.
- qCWarning(QT_BT_OSX) << "already has a cached value for this "
- "object, the value will be replaced";
+ qCWarning(QT_BT_DARWIN) << "already has a cached value for this "
+ "object, the value will be replaced";
}
valuesToWrite[obj] = value;
@@ -1223,19 +1223,13 @@ QT_USE_NAMESPACE
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
const auto state = central.state;
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
- if (state == CBManagerStateUnknown
- || state == CBManagerStateResetting) {
-#else
- if (state == CBCentralManagerStateUnknown
- || state == CBCentralManagerStateResetting) {
-#endif
+ if (state == CBManagerStateUnknown || state == CBManagerStateResetting) {
// We still have to wait, docs say:
// "The current state of the central manager is unknown;
// an update is imminent." or
@@ -1245,11 +1239,7 @@ QT_USE_NAMESPACE
}
// Let's check some states we do not like first:
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
if (state == CBManagerStateUnsupported || state == CBManagerStateUnauthorized) {
-#else
- if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) {
-#endif
if (managerState == CentralManagerUpdating) {
// We tried to connect just to realize, LE is not supported. Report this.
managerState = CentralManagerIdle;
@@ -1266,12 +1256,7 @@ QT_USE_NAMESPACE
return;
}
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
if (state == CBManagerStatePoweredOff) {
-#else
- if (state == CBCentralManagerStatePoweredOff) {
-#endif
-
if (managerState == CentralManagerUpdating) {
managerState = CentralManagerIdle;
// I've seen this instead of Unsupported on OS X.
@@ -1288,11 +1273,7 @@ QT_USE_NAMESPACE
return;
}
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
if (state == CBManagerStatePoweredOn) {
-#else
- if (state == CBCentralManagerStatePoweredOn) {
-#endif
if (managerState == CentralManagerUpdating && !disconnectPending) {
managerState = CentralManagerIdle;
[self retrievePeripheralAndConnect];
@@ -1310,12 +1291,12 @@ QT_USE_NAMESPACE
Q_UNUSED(central)
Q_UNUSED(aPeripheral)
- if (managerState != OSXBluetooth::CentralManagerConnecting) {
+ if (managerState != DarwinBluetooth::CentralManagerConnecting) {
// We called cancel but before disconnected, managed to connect?
return;
}
- managerState = OSXBluetooth::CentralManagerIdle;
+ managerState = DarwinBluetooth::CentralManagerIdle;
if (notifier)
emit notifier->connected();
}
@@ -1327,12 +1308,12 @@ QT_USE_NAMESPACE
Q_UNUSED(aPeripheral)
Q_UNUSED(error)
- if (managerState != OSXBluetooth::CentralManagerConnecting) {
+ if (managerState != DarwinBluetooth::CentralManagerConnecting) {
// Canceled already.
return;
}
- managerState = OSXBluetooth::CentralManagerIdle;
+ managerState = DarwinBluetooth::CentralManagerIdle;
// TODO: better error mapping is required.
if (notifier)
notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError);
@@ -1347,13 +1328,13 @@ QT_USE_NAMESPACE
// Clear internal caches/data.
[self reset];
- if (error && managerState == OSXBluetooth::CentralManagerDisconnecting) {
- managerState = OSXBluetooth::CentralManagerIdle;
- qCWarning(QT_BT_OSX) << "failed to disconnect";
+ if (error && managerState == DarwinBluetooth::CentralManagerDisconnecting) {
+ managerState = DarwinBluetooth::CentralManagerIdle;
+ qCWarning(QT_BT_DARWIN) << "failed to disconnect";
if (notifier)
emit notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError);
} else {
- managerState = OSXBluetooth::CentralManagerIdle;
+ managerState = DarwinBluetooth::CentralManagerIdle;
if (notifier)
emit notifier->disconnected();
}
@@ -1365,12 +1346,13 @@ QT_USE_NAMESPACE
{
Q_UNUSED(aPeripheral)
- if (managerState != OSXBluetooth::CentralManagerDiscovering) {
+ using namespace DarwinBluetooth;
+
+ if (managerState != CentralManagerDiscovering) {
// Canceled by -disconnectFromDevice, or as a result of a timeout.
return;
}
- using namespace OSXBluetooth;
if (![self objectIsUnderWatch:aPeripheral operation:OperationTimeout::serviceDiscovery]) // Timed out already
return;
@@ -1378,7 +1360,7 @@ QT_USE_NAMESPACE
[self stopWatchingAfter:aPeripheral operation:OperationTimeout::serviceDiscovery];
- managerState = OSXBluetooth::CentralManagerIdle;
+ managerState = CentralManagerIdle;
if (error) {
NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
@@ -1396,7 +1378,7 @@ QT_USE_NAMESPACE
Q_UNUSED(aPeripheral)
Q_UNUSED(invalidatedServices)
- qCWarning(QT_BT_OSX) << "The peripheral has modified its services.";
+ qCWarning(QT_BT_DARWIN) << "The peripheral has modified its services.";
// "This method is invoked whenever one or more services of a peripheral have changed.
// A peripheral’s services have changed if:
// * A service is removed from the peripheral’s database
@@ -1410,7 +1392,7 @@ QT_USE_NAMESPACE
// we stop all current operations here, report to QLowEnergyController
// so that it can trigger re-discovery.
[self reset];
- managerState = OSXBluetooth::CentralManagerIdle;
+ managerState = DarwinBluetooth::CentralManagerIdle;
if (notifier)
emit notifier->servicesWereModified();
}
@@ -1420,7 +1402,7 @@ QT_USE_NAMESPACE
{
Q_UNUSED(aPeripheral)
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (managerState != CentralManagerDiscovering) {
// Canceled by disconnectFromDevice or -peripheralDidDisconnect...
@@ -1443,7 +1425,7 @@ QT_USE_NAMESPACE
} else if (service.includedServices && service.includedServices.count) {
// Now we have even more services to do included services discovery ...
if (!servicesToVisitNext)
- servicesToVisitNext.reset([NSMutableArray arrayWithArray:service.includedServices]);
+ servicesToVisitNext.reset([NSMutableArray arrayWithArray:service.includedServices], RetainPolicy::doInitialRetain);
else
[servicesToVisitNext addObjectsFromArray:service.includedServices];
}
@@ -1465,7 +1447,8 @@ QT_USE_NAMESPACE
// No services to visit more on this 'level'.
if (servicesToVisitNext && [servicesToVisitNext count]) {
- servicesToVisit.resetWithoutRetain(servicesToVisitNext.take());
+ servicesToVisit.swap(servicesToVisitNext);
+ servicesToVisitNext.reset();
currentService = 0;
for (const NSUInteger e = [servicesToVisit count]; currentService < e; ++currentService) {
@@ -1482,9 +1465,9 @@ QT_USE_NAMESPACE
// Finally, if we're here, the service discovery is done!
// Release all these things now, no need to prolong their lifetime.
- visitedServices.reset(nil);
- servicesToVisit.reset(nil);
- servicesToVisitNext.reset(nil);
+ visitedServices.reset();
+ servicesToVisit.reset();
+ servicesToVisitNext.reset();
if (notifier)
emit notifier->serviceDiscoveryFinished();
@@ -1502,7 +1485,7 @@ QT_USE_NAMESPACE
return;
}
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (![self objectIsUnderWatch:service operation:OperationTimeout::characteristicsDiscovery])
return;
@@ -1532,7 +1515,7 @@ QT_USE_NAMESPACE
if (!notifier) // Detached.
return;
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QT_BT_MAC_AUTORELEASEPOOL;
@@ -1584,8 +1567,8 @@ QT_USE_NAMESPACE
// updated values ...
// TODO: this must be properly tested.
if (!chHandle) {
- qCCritical(QT_BT_OSX) << "unexpected update notification, "
- "no characteristic handle found";
+ qCCritical(QT_BT_DARWIN) << "unexpected update notification, "
+ "no characteristic handle found";
return;
}
@@ -1618,7 +1601,7 @@ QT_USE_NAMESPACE
QT_BT_MAC_AUTORELEASEPOOL;
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (![self objectIsUnderWatch:characteristic operation:OperationTimeout::descriptorsDiscovery])
return;
@@ -1656,7 +1639,7 @@ QT_USE_NAMESPACE
QT_BT_MAC_AUTORELEASEPOOL;
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (![self objectIsUnderWatch:descriptor operation:OperationTimeout::descriptorRead])
return;
@@ -1712,8 +1695,8 @@ QT_USE_NAMESPACE
}
} else {
if (!dHandle) {
- qCCritical(QT_BT_OSX) << "unexpected value update notification, "
- "no descriptor handle found";
+ qCCritical(QT_BT_DARWIN) << "unexpected value update notification, "
+ "no descriptor handle found";
return;
}
@@ -1745,7 +1728,7 @@ QT_USE_NAMESPACE
// If successful, the error parameter is nil. If unsuccessful,
// the error parameter returns the cause of the failure."
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QT_BT_MAC_AUTORELEASEPOOL;
@@ -1758,8 +1741,8 @@ QT_USE_NAMESPACE
// Error or not, but the cached value has to be deleted ...
const QByteArray valueToReport(valuesToWrite.value(characteristic, QByteArray()));
if (!valuesToWrite.remove(characteristic)) {
- qCWarning(QT_BT_OSX) << "no updated value found "
- "for characteristic";
+ qCWarning(QT_BT_DARWIN) << "no updated value found "
+ "for characteristic";
}
if (error) {
@@ -1786,7 +1769,7 @@ QT_USE_NAMESPACE
return;
}
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QT_BT_MAC_AUTORELEASEPOOL;
@@ -1795,7 +1778,7 @@ QT_USE_NAMESPACE
// Error or not, a value (if any) must be removed.
const QByteArray valueToReport(valuesToWrite.value(descriptor, QByteArray()));
if (!valuesToWrite.remove(descriptor))
- qCWarning(QT_BT_OSX) << "no updated value found";
+ qCWarning(QT_BT_DARWIN) << "no updated value found";
if (error) {
NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
@@ -1820,7 +1803,7 @@ QT_USE_NAMESPACE
if (!notifier)
return;
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QT_BT_MAC_AUTORELEASEPOOL;
@@ -1835,7 +1818,7 @@ QT_USE_NAMESPACE
NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
// In Qt's API it's a descriptor write actually.
emit notifier->CBManagerError(qt_uuid(characteristic.service.UUID),
- QLowEnergyService::DescriptorWriteError);
+ QLowEnergyService::DescriptorWriteError);
} else if (nRemoved) {
const QLowEnergyHandle dHandle = descMap.key(descriptor);
emit notifier->descriptorWritten(dHandle, valueToReport);
diff --git a/src/bluetooth/osx/osxbtcentralmanager_p.h b/src/bluetooth/darwin/btcentralmanager_p.h
index ce348dc6..0b5c8fbb 100644
--- a/src/bluetooth/osx/osxbtcentralmanager_p.h
+++ b/src/bluetooth/darwin/btcentralmanager_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTCENTRALMANAGER_P_H
-#define OSXBTCENTRALMANAGER_P_H
+#ifndef BTCENTRALMANAGER_P_H
+#define BTCENTRALMANAGER_P_H
//
// W A R N I N G
@@ -53,10 +53,9 @@
#include "qlowenergycontroller.h"
#include "qlowenergyservice.h"
-#include "osxbtgcdtimer_p.h"
#include "qbluetoothuuid.h"
-#include "osxbtutility_p.h"
-#include "osxbluetooth_p.h"
+#include "btgcdtimer_p.h"
+#include "btutility_p.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qglobal.h>
@@ -65,13 +64,13 @@
#include <Foundation/Foundation.h>
-@class QT_MANGLE_NAMESPACE(OSXBTCentralManager);
+#include <CoreBluetooth/CoreBluetooth.h>
QT_BEGIN_NAMESPACE
class QLowEnergyServicePrivate;
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
class LECBManagerNotifier;
@@ -129,14 +128,14 @@ typedef QQueue<LERequest> RequestQueue;
// 'NSObject *' will require '__weak' with ARC.
typedef QHash<NSObject *, QByteArray> ValueHash;
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
-@interface QT_MANGLE_NAMESPACE(OSXBTCentralManager) : NSObject<CBCentralManagerDelegate,
- CBPeripheralDelegate,
- QT_MANGLE_NAMESPACE(GCDTimerDelegate)>
-- (id)initWith:(QT_PREPEND_NAMESPACE(OSXBluetooth)::LECBManagerNotifier *)notifier;
+@interface QT_MANGLE_NAMESPACE(DarwinBTCentralManager) : NSObject<CBCentralManagerDelegate,
+ CBPeripheralDelegate,
+ QT_MANGLE_NAMESPACE(GCDTimerDelegate)>
+- (id)initWith:(QT_PREPEND_NAMESPACE(DarwinBluetooth)::LECBManagerNotifier *)notifier;
- (void)dealloc;
- (CBPeripheral *)peripheral;
diff --git a/src/bluetooth/osx/osxbtconnectionmonitor.mm b/src/bluetooth/darwin/btconnectionmonitor.mm
index b777af8e..f9adfde8 100644
--- a/src/bluetooth/osx/osxbtconnectionmonitor.mm
+++ b/src/bluetooth/darwin/btconnectionmonitor.mm
@@ -37,20 +37,13 @@
**
****************************************************************************/
-#include "osxbtconnectionmonitor_p.h"
-#include "osxbtutility_p.h"
+#include "btconnectionmonitor_p.h"
+#include "btutility_p.h"
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
-
-ConnectionMonitor::~ConnectionMonitor()
-{
-}
-
-}
QT_END_NAMESPACE
@@ -58,14 +51,14 @@ QT_END_NAMESPACE
using namespace QT_NAMESPACE;
#endif
-@implementation QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTConnectionMonitor)
{
- QT_PREPEND_NAMESPACE(OSXBluetooth::ConnectionMonitor) *monitor;
+ QT_PREPEND_NAMESPACE(DarwinBluetooth::ConnectionMonitor) *monitor;
IOBluetoothUserNotification *discoveryNotification;
NSMutableArray *foundConnections;
}
-- (id)initWithMonitor:(OSXBluetooth::ConnectionMonitor *)aMonitor
+- (id)initWithMonitor:(DarwinBluetooth::ConnectionMonitor *)aMonitor
{
Q_ASSERT_X(aMonitor, "-initWithMonitor:", "invalid monitor (null)");
@@ -106,7 +99,7 @@ using namespace QT_NAMESPACE;
// All Obj-C objects are autoreleased.
- const QBluetoothAddress deviceAddress(OSXBluetooth::qt_address([device getAddress]));
+ const QBluetoothAddress deviceAddress(DarwinBluetooth::qt_address([device getAddress]));
if (deviceAddress.isNull())
return;
@@ -129,7 +122,7 @@ using namespace QT_NAMESPACE;
[notification unregister];//?
[foundConnections removeObject:notification];
- const QBluetoothAddress deviceAddress(OSXBluetooth::qt_address([device getAddress]));
+ const QBluetoothAddress deviceAddress(DarwinBluetooth::qt_address([device getAddress]));
if (deviceAddress.isNull())
return;
diff --git a/src/bluetooth/osx/osxbluetooth_p.h b/src/bluetooth/darwin/btconnectionmonitor_p.h
index ea1b388f..e3b7b90d 100644
--- a/src/bluetooth/osx/osxbluetooth_p.h
+++ b/src/bluetooth/darwin/btconnectionmonitor_p.h
@@ -37,9 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBLUETOOTH_P_H
-#define OSXBLUETOOTH_P_H
-
+#ifndef BTCONNECTIONMONITOR_P_H
+#define BTCONNECTIONMONITOR_P_H
//
// W A R N I N G
@@ -52,12 +51,21 @@
// We mean it.
//
+#include "qbluetoothaddress.h"
+#include "btdelegates_p.h"
+
#include <QtCore/qglobal.h>
-#include <CoreBluetooth/CoreBluetooth.h>
+#include <Foundation/Foundation.h>
-#ifdef Q_OS_MACOS
#include <IOBluetooth/IOBluetooth.h>
-#endif
-#endif // OSXBLUETOOTH_P_H
+@interface QT_MANGLE_NAMESPACE(DarwinBTConnectionMonitor) : NSObject
+
+- (id)initWithMonitor:(QT_PREPEND_NAMESPACE(DarwinBluetooth::ConnectionMonitor) *)monitor;
+- (void)connectionNotification:(id)notification withDevice:(IOBluetoothDevice *)device;
+- (void)connectionClosedNotification:(id)notification withDevice:(IOBluetoothDevice *)device;
+
+@end
+
+#endif
diff --git a/src/bluetooth/osx/btdelegates.cpp b/src/bluetooth/darwin/btdelegates.cpp
index 531ca1df..531ca1df 100644
--- a/src/bluetooth/osx/btdelegates.cpp
+++ b/src/bluetooth/darwin/btdelegates.cpp
diff --git a/src/bluetooth/osx/btdelegates_p.h b/src/bluetooth/darwin/btdelegates_p.h
index 11fbcc28..11fbcc28 100644
--- a/src/bluetooth/osx/btdelegates_p.h
+++ b/src/bluetooth/darwin/btdelegates_p.h
diff --git a/src/bluetooth/osx/osxbtdeviceinquiry.mm b/src/bluetooth/darwin/btdeviceinquiry.mm
index 3a77c1f7..ad59a4a4 100644
--- a/src/bluetooth/osx/osxbtdeviceinquiry.mm
+++ b/src/bluetooth/darwin/btdeviceinquiry.mm
@@ -37,15 +37,15 @@
**
****************************************************************************/
-#include "osxbtdeviceinquiry_p.h"
-#include "osxbtutility_p.h"
+#include "btdeviceinquiry_p.h"
+#include "btutility_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qdebug.h>
QT_USE_NAMESPACE
-@implementation QT_MANGLE_NAMESPACE(OSXBTDeviceInquiry)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTClassicDeviceInquiry)
{
IOBluetoothDeviceInquiry *m_inquiry;
bool m_active;
@@ -64,7 +64,7 @@ QT_USE_NAMESPACE
[m_inquiry setUpdateNewDeviceNames:NO];//Useless, disable!
m_delegate = delegate;
} else {
- qCCritical(QT_BT_OSX) << "failed to create a device inquiry";
+ qCCritical(QT_BT_DARWIN) << "failed to create a device inquiry";
}
m_active = false;
@@ -103,7 +103,7 @@ QT_USE_NAMESPACE
if (result != kIOReturnSuccess) {
// QtBluetooth will probably convert an error into UnknownError,
// loosing the actual information.
- qCWarning(QT_BT_OSX) << "failed with IOKit error code:" << result;
+ qCWarning(QT_BT_DARWIN) << "failed with IOKit error code:" << result;
m_active = false;
}
@@ -120,7 +120,7 @@ QT_USE_NAMESPACE
if (res != kIOReturnSuccess)
m_active = true;
else
- qCDebug(QT_BT_OSX) << "-stop, success (waiting for 'inquiryComplete')";
+ qCDebug(QT_BT_DARWIN) << "-stop, success (waiting for 'inquiryComplete')";
return res;
}
@@ -143,7 +143,7 @@ QT_USE_NAMESPACE
if (error != kIOReturnSuccess) {
// QtBluetooth has not too many error codes, 'UnknownError' is not really
// useful, report the actual error code here:
- qCWarning(QT_BT_OSX) << "IOKit error code: " << error;
+ qCWarning(QT_BT_DARWIN) << "IOKit error code: " << error;
m_delegate->error(error);
} else {
m_delegate->inquiryFinished();
diff --git a/src/bluetooth/osx/osxbtdeviceinquiry_p.h b/src/bluetooth/darwin/btdeviceinquiry_p.h
index 86ed3fdf..fa4fd01c 100644
--- a/src/bluetooth/osx/osxbtdeviceinquiry_p.h
+++ b/src/bluetooth/darwin/btdeviceinquiry_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTDEVICEINQUIRY_P_H
-#define OSXBTDEVICEINQUIRY_P_H
+#ifndef BTDEVICEINQUIRY_P_H
+#define BTDEVICEINQUIRY_P_H
//
// W A R N I N G
@@ -51,7 +51,6 @@
// We mean it.
//
-#include "osxbluetooth_p.h"
#include "btdelegates_p.h"
#include <QtCore/qglobal.h>
@@ -59,7 +58,9 @@
#include <Foundation/Foundation.h>
#include <IOKit/IOReturn.h>
-@interface QT_MANGLE_NAMESPACE(OSXBTDeviceInquiry) : NSObject<IOBluetoothDeviceInquiryDelegate>
+#include <IOBluetooth/IOBluetooth.h>
+
+@interface QT_MANGLE_NAMESPACE(DarwinBTClassicDeviceInquiry) : NSObject<IOBluetoothDeviceInquiryDelegate>
- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth::DeviceInquiryDelegate) *)delegate;
- (void)dealloc;
diff --git a/src/bluetooth/osx/osxbtdevicepair.mm b/src/bluetooth/darwin/btdevicepair.mm
index 75dbbcad..947385f2 100644
--- a/src/bluetooth/osx/osxbtdevicepair.mm
+++ b/src/bluetooth/darwin/btdevicepair.mm
@@ -37,48 +37,43 @@
**
****************************************************************************/
-#include "osxbtdevicepair_p.h"
-#include "osxbtutility_p.h"
+#include "btdevicepair_p.h"
+#include "btutility_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
ObjCStrongReference<IOBluetoothDevice> device_with_address(const QBluetoothAddress &address)
{
if (address.isNull())
- return ObjCStrongReference<IOBluetoothDevice>(nil, false);
+ return {};
const BluetoothDeviceAddress &iobtAddress = iobluetooth_address(address);
- ObjCStrongReference<IOBluetoothDevice> res([[IOBluetoothDevice deviceWithAddress:&iobtAddress] retain], false);
+ ObjCStrongReference<IOBluetoothDevice> res([IOBluetoothDevice deviceWithAddress:&iobtAddress], RetainPolicy::doInitialRetain);
return res;
}
-PairingDelegate::~PairingDelegate()
-{
-}
-
-}
-
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
QT_USE_NAMESPACE
-@implementation QT_MANGLE_NAMESPACE(OSXBTPairing)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTClassicPairing)
{
QT_PREPEND_NAMESPACE(QBluetoothAddress) m_targetAddress;
bool m_active;
IOBluetoothDevicePair *m_pairing; // The real pairing request
- QT_PREPEND_NAMESPACE(OSXBluetooth)::PairingDelegate *m_object;
+ QT_PREPEND_NAMESPACE(DarwinBluetooth)::PairingDelegate *m_object;
}
- (id)initWithTarget:(const QBluetoothAddress &)address
- delegate:(OSXBluetooth::PairingDelegate *)object
+ delegate:(DarwinBluetooth::PairingDelegate *)object
{
if (self = [super init]) {
Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO, "invalid target address");
@@ -108,17 +103,17 @@ QT_USE_NAMESPACE
QT_BT_MAC_AUTORELEASEPOOL;
- const BluetoothDeviceAddress &iobtAddress = OSXBluetooth::iobluetooth_address(m_targetAddress);
+ const BluetoothDeviceAddress &iobtAddress = DarwinBluetooth::iobluetooth_address(m_targetAddress);
// Device is autoreleased.
IOBluetoothDevice *const device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
if (!device) {
- qCCritical(QT_BT_OSX) << "failed to create a device to pair with";
+ qCCritical(QT_BT_DARWIN) << "failed to create a device to pair with";
return kIOReturnError;
}
m_pairing = [[IOBluetoothDevicePair pairWithDevice:device] retain];
if (!m_pairing) {
- qCCritical(QT_BT_OSX) << "failed to create pair";
+ qCCritical(QT_BT_DARWIN) << "failed to create a device pair";
return kIOReturnError;
}
diff --git a/src/bluetooth/osx/osxbtdevicepair_p.h b/src/bluetooth/darwin/btdevicepair_p.h
index 1a2c7d6b..1b361258 100644
--- a/src/bluetooth/osx/osxbtdevicepair_p.h
+++ b/src/bluetooth/darwin/btdevicepair_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTDEVICEPAIR_P_H
-#define OSXBTDEVICEPAIR_P_H
+#ifndef BTDEVICEPAIR_P_H
+#define BTDEVICEPAIR_P_H
//
// W A R N I N G
@@ -52,47 +52,29 @@
//
#include "qbluetoothaddress.h"
-#include "osxbtutility_p.h"
-#include "osxbluetooth_p.h"
+#include "btdelegates_p.h"
+#include "btutility_p.h"
#include <QtCore/qglobal.h>
#include <Foundation/Foundation.h>
-@class QT_MANGLE_NAMESPACE(OSXBTPairing);
+#include <IOBluetooth/IOBluetooth.h>
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
-
-// C++ delegate.
-class PairingDelegate
-{
-public:
- typedef QT_MANGLE_NAMESPACE(OSXBTPairing) ObjCPairingRequest;
-
- virtual ~PairingDelegate();
-
- virtual void connecting(ObjCPairingRequest *pair) = 0;
- virtual void requestPIN(ObjCPairingRequest *pair) = 0;
- virtual void requestUserConfirmation(ObjCPairingRequest *pair,
- BluetoothNumericValue) = 0;
- virtual void passkeyNotification(ObjCPairingRequest *pair,
- BluetoothPasskey passkey) = 0;
- virtual void error(ObjCPairingRequest *pair, IOReturn errorCode) = 0;
- virtual void pairingFinished(ObjCPairingRequest *pair) = 0;
-};
+namespace DarwinBluetooth {
ObjCStrongReference<IOBluetoothDevice> device_with_address(const QBluetoothAddress &address);
-} // Namespace OSXBluetooth.
+} // Namespace DarwinBluetooth.
QT_END_NAMESPACE
-@interface QT_MANGLE_NAMESPACE(OSXBTPairing) : NSObject<IOBluetoothDevicePairDelegate>
+@interface QT_MANGLE_NAMESPACE(DarwinBTClassicPairing) : NSObject<IOBluetoothDevicePairDelegate>
- (id)initWithTarget:(const QBluetoothAddress &)address
- delegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::PairingDelegate) *)object;
+ delegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth::PairingDelegate) *)object;
- (void)dealloc;
diff --git a/src/bluetooth/osx/osxbtgcdtimer.mm b/src/bluetooth/darwin/btgcdtimer.mm
index 9663ca93..9105a8fb 100644
--- a/src/bluetooth/osx/osxbtgcdtimer.mm
+++ b/src/bluetooth/darwin/btgcdtimer.mm
@@ -37,17 +37,17 @@
**
****************************************************************************/
-#include "osxbtgcdtimer_p.h"
-#include "osxbtutility_p.h"
+#include "btgcdtimer_p.h"
+#include "btutility_p.h"
#include <QtCore/qdebug.h>
#include <algorithm>
QT_USE_NAMESPACE
-using namespace OSXBluetooth;
+using namespace DarwinBluetooth;
-@implementation QT_MANGLE_NAMESPACE(OSXBTGCDTimer) {
+@implementation QT_MANGLE_NAMESPACE(DarwinBTGCDTimer) {
@private
qint64 timeoutMS;
qint64 timeoutStepMS;
@@ -92,7 +92,7 @@ using namespace OSXBluetooth;
}
if (ms <= 0 || stepMS <= 0) {
- qCWarning(QT_BT_OSX, "Invalid timeout/step parameters");
+ qCWarning(QT_BT_DARWIN, "Invalid timeout/step parameters");
return;
}
diff --git a/src/bluetooth/osx/osxbtgcdtimer_p.h b/src/bluetooth/darwin/btgcdtimer_p.h
index 6bd82c9a..dd67d6e8 100644
--- a/src/bluetooth/osx/osxbtgcdtimer_p.h
+++ b/src/bluetooth/darwin/btgcdtimer_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTGCDTIMER_P_H
-#define OSXBTGCDTIMER_P_H
+#ifndef BTGCDTIMER_P_H
+#define BTGCDTIMER_P_H
//
// W A R N I N G
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "osxbtutility_p.h"
+#include "btutility_p.h"
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qglobal.h>
@@ -60,7 +60,7 @@
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
enum class OperationTimeout
{
@@ -74,7 +74,7 @@ enum class OperationTimeout
characteristicWrite
};
-} // namespace OSXBluetooth
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
@@ -83,26 +83,26 @@ QT_END_NAMESPACE
- (void)timeout:(id)sender;
@end
-@interface QT_MANGLE_NAMESPACE(OSXBTGCDTimer) : NSObject
+@interface QT_MANGLE_NAMESPACE(DarwinBTGCDTimer) : NSObject
- (instancetype)initWithDelegate:(id<QT_MANGLE_NAMESPACE(GCDTimerDelegate)>)delegate;
-- (void)watchAfter:(id)object withTimeoutType:(QT_PREPEND_NAMESPACE(OSXBluetooth)::OperationTimeout)type;
+- (void)watchAfter:(id)object withTimeoutType:(QT_PREPEND_NAMESPACE(DarwinBluetooth)::OperationTimeout)type;
- (void)startWithTimeout:(qint64)ms step:(qint64)stepMS;
- (void)handleTimeout;
- (void)cancelTimer;
- (id)objectUnderWatch;
-- (QT_PREPEND_NAMESPACE(OSXBluetooth)::OperationTimeout)timeoutType;
+- (QT_PREPEND_NAMESPACE(DarwinBluetooth)::OperationTimeout)timeoutType;
@end
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
-using GCDTimerObjC = QT_MANGLE_NAMESPACE(OSXBTGCDTimer);
+using GCDTimerObjC = QT_MANGLE_NAMESPACE(DarwinBTGCDTimer);
using GCDTimer = ObjCStrongReference<GCDTimerObjC>;
-} // namespace OSXBluetooth
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
-#endif // OSXBTGCDTIMER_P_H
+#endif // BTGCDTIMER_P_H
diff --git a/src/bluetooth/osx/osxbtl2capchannel.mm b/src/bluetooth/darwin/btl2capchannel.mm
index 03e3a982..e440a0ee 100644
--- a/src/bluetooth/osx/osxbtl2capchannel.mm
+++ b/src/bluetooth/darwin/btl2capchannel.mm
@@ -37,17 +37,17 @@
**
****************************************************************************/
-#include "osxbtl2capchannel_p.h"
+#include "btl2capchannel_p.h"
#include "qbluetoothaddress.h"
-#include "osxbtutility_p.h"
#include "btdelegates_p.h"
+#include "btutility_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qdebug.h>
QT_USE_NAMESPACE
-@implementation QT_MANGLE_NAMESPACE(OSXBTL2CAPChannel)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTL2CAPChannel)
{
QT_PREPEND_NAMESPACE(DarwinBluetooth)::ChannelDelegate *delegate;
IOBluetoothDevice *device;
@@ -110,28 +110,28 @@ QT_USE_NAMESPACE
withPSM:(BluetoothL2CAPChannelID)psm
{
if (address.isNull()) {
- qCCritical(QT_BT_OSX) << "invalid peer address";
+ qCCritical(QT_BT_DARWIN) << "invalid peer address";
return kIOReturnNoDevice;
}
// Can never be called twice.
if (connected || device || channel) {
- qCCritical(QT_BT_OSX) << "connection is already active";
+ qCCritical(QT_BT_DARWIN) << "connection is already active";
return kIOReturnStillOpen;
}
QT_BT_MAC_AUTORELEASEPOOL;
- const BluetoothDeviceAddress iobtAddress = OSXBluetooth::iobluetooth_address(address);
+ const BluetoothDeviceAddress iobtAddress = DarwinBluetooth::iobluetooth_address(address);
device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
if (!device) {
- qCCritical(QT_BT_OSX) << "failed to create a device";
+ qCCritical(QT_BT_DARWIN) << "failed to create a device";
return kIOReturnNoDevice;
}
const IOReturn status = [device openL2CAPChannelAsync:&channel withPSM:psm delegate:self];
if (status != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << "failed to open L2CAP channel";
+ qCCritical(QT_BT_DARWIN) << "failed to open L2CAP channel";
// device is still autoreleased.
device = nil;
return status;
diff --git a/src/bluetooth/osx/osxbtl2capchannel_p.h b/src/bluetooth/darwin/btl2capchannel_p.h
index 42eec8e7..32122fe8 100644
--- a/src/bluetooth/osx/osxbtl2capchannel_p.h
+++ b/src/bluetooth/darwin/btl2capchannel_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTL2CAPCHANNEL_P_H
-#define OSXBTL2CAPCHANNEL_P_H
+#ifndef BTL2CAPCHANNEL_P_H
+#define BTL2CAPCHANNEL_P_H
//
// W A R N I N G
@@ -51,12 +51,12 @@
// We mean it.
//
-#include "osxbluetooth_p.h"
-
#include <QtCore/qglobal.h>
#include <Foundation/Foundation.h>
+#include <IOBluetooth/IOBluetooth.h>
+
#include <cstddef>
QT_BEGIN_NAMESPACE
@@ -71,7 +71,7 @@ class ChannelDelegate;
QT_END_NAMESPACE
-@interface QT_MANGLE_NAMESPACE(OSXBTL2CAPChannel) : NSObject<IOBluetoothL2CAPChannelDelegate>
+@interface QT_MANGLE_NAMESPACE(DarwinBTL2CAPChannel) : NSObject<IOBluetoothL2CAPChannelDelegate>
- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth)::ChannelDelegate *)aDelegate;
- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth)::ChannelDelegate *)aDelegate
diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/darwin/btledeviceinquiry.mm
index 70b96ab7..107ffc5b 100644
--- a/src/bluetooth/osx/osxbtledeviceinquiry.mm
+++ b/src/bluetooth/darwin/btledeviceinquiry.mm
@@ -37,11 +37,11 @@
**
****************************************************************************/
-#include "osxbtledeviceinquiry_p.h"
#include "qbluetoothdeviceinfo.h"
-#include "osxbtnotifier_p.h"
+#include "btledeviceinquiry_p.h"
#include "qbluetoothuuid.h"
-#include "osxbtutility_p.h"
+#include "btnotifier_p.h"
+#include "btutility_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qdebug.h>
@@ -51,7 +51,7 @@
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
QBluetoothUuid qt_uuid(NSUUID *nsUuid)
{
@@ -121,12 +121,12 @@ QT_END_NAMESPACE
QT_USE_NAMESPACE
-@interface QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry)(PrivateAPI)
+@interface QT_MANGLE_NAMESPACE(DarwinBTLEDeviceInquiry)(PrivateAPI)
- (void)stopScanSafe;
- (void)stopNotifier;
@end
-@implementation QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTLEDeviceInquiry)
{
LECBManagerNotifier *notifier;
ObjCScopedPointer<CBCentralManager> manager;
@@ -135,7 +135,7 @@ QT_USE_NAMESPACE
LEInquiryState internalState;
int inquiryTimeoutMS;
- QT_PREPEND_NAMESPACE(OSXBluetooth)::GCDTimer elapsedTimer;
+ QT_PREPEND_NAMESPACE(DarwinBluetooth)::GCDTimer elapsedTimer;
}
-(id)initWithNotifier:(LECBManagerNotifier *)aNotifier
@@ -144,7 +144,7 @@ QT_USE_NAMESPACE
Q_ASSERT(aNotifier);
notifier = aNotifier;
internalState = InquiryStarting;
- inquiryTimeoutMS = OSXBluetooth::defaultLEScanTimeoutMS;
+ inquiryTimeoutMS = DarwinBluetooth::defaultLEScanTimeoutMS;
}
return self;
@@ -182,10 +182,11 @@ QT_USE_NAMESPACE
- (void)startWithTimeout:(int)timeout
{
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
Q_ASSERT(leQueue);
inquiryTimeoutMS = timeout;
- manager.reset([[CBCentralManager alloc] initWithDelegate:self queue:leQueue]);
+ manager.reset([[CBCentralManager alloc] initWithDelegate:self queue:leQueue],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
}
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
@@ -201,30 +202,22 @@ QT_USE_NAMESPACE
Q_ASSERT(notifier);
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
const auto state = central.state;
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
if (state == CBManagerStatePoweredOn) {
-#else
- if (state == CBCentralManagerStatePoweredOn) {
-#endif
if (internalState == InquiryStarting) {
internalState = InquiryActive;
if (inquiryTimeoutMS > 0) {
[elapsedTimer cancelTimer];
- elapsedTimer.resetWithoutRetain([[GCDTimerObjC alloc] initWithDelegate:self]);
+ elapsedTimer.reset([[GCDTimerObjC alloc] initWithDelegate:self], RetainPolicy::noInitialRetain);
[elapsedTimer startWithTimeout:inquiryTimeoutMS step:timeStepMS];
}
[manager scanForPeripheralsWithServices:nil options:nil];
} // Else we ignore.
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
} else if (state == CBManagerStateUnsupported || state == CBManagerStateUnauthorized) {
-#else
- } else if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) {
-#endif
if (internalState == InquiryActive) {
[self stopScanSafe];
// Not sure how this is possible at all,
@@ -237,11 +230,7 @@ QT_USE_NAMESPACE
}
[manager setDelegate:nil];
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
} else if (state == CBManagerStatePoweredOff) {
-#else
- } else if (state == CBCentralManagerStatePoweredOff) {
-#endif
#ifndef Q_OS_MACOS
if (internalState == InquiryStarting) {
@@ -250,7 +239,7 @@ QT_USE_NAMESPACE
// we'll receive 'PoweredOn' state update later.
// No change in internalState. Wait for 30 seconds.
[elapsedTimer cancelTimer];
- elapsedTimer.resetWithoutRetain([[GCDTimerObjC alloc] initWithDelegate:self]);
+ elapsedTimer.reset([[GCDTimerObjC alloc] initWithDelegate:self], RetainPolicy::noInitialRetain);
[elapsedTimer startWithTimeout:powerOffTimeoutMS step:300];
return;
}
@@ -293,12 +282,8 @@ QT_USE_NAMESPACE
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
if (internalState == InquiryActive) {
- const auto state = manager.data().state;
- #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
+ const auto state = manager.get().state;
if (state == CBManagerStatePoweredOn)
- #else
- if (state == CBCentralManagerStatePoweredOn)
- #endif
[manager stopScan];
}
@@ -328,7 +313,7 @@ QT_USE_NAMESPACE
advertisementData:(NSDictionary *)advertisementData
RSSI:(NSNumber *)RSSI
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (central != manager)
return;
@@ -342,14 +327,14 @@ QT_USE_NAMESPACE
QBluetoothUuid deviceUuid;
if (!peripheral.identifier) {
- qCWarning(QT_BT_OSX) << "peripheral without NSUUID";
+ qCWarning(QT_BT_DARWIN) << "peripheral without NSUUID";
return;
}
- deviceUuid = OSXBluetooth::qt_uuid(peripheral.identifier);
+ deviceUuid = DarwinBluetooth::qt_uuid(peripheral.identifier);
if (deviceUuid.isNull()) {
- qCWarning(QT_BT_OSX) << "no way to address peripheral, QBluetoothUuid is null";
+ qCWarning(QT_BT_DARWIN) << "no way to address peripheral, QBluetoothUuid is null";
return;
}
diff --git a/src/bluetooth/osx/osxbtledeviceinquiry_p.h b/src/bluetooth/darwin/btledeviceinquiry_p.h
index d99a93bd..58c66e56 100644
--- a/src/bluetooth/osx/osxbtledeviceinquiry_p.h
+++ b/src/bluetooth/darwin/btledeviceinquiry_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTLEDEVICEINQUIRY_P_H
-#define OSXBTLEDEVICEINQUIRY_P_H
+#ifndef BTLEDEVICEINQUIRY_P_H
+#define BTLEDEVICEINQUIRY_P_H
//
// W A R N I N G
@@ -53,30 +53,31 @@
#include "qbluetoothdevicediscoveryagent.h"
#include "qbluetoothdeviceinfo.h"
-#include "osxbtgcdtimer_p.h"
-#include "osxbtutility_p.h"
-#include "osxbluetooth_p.h"
+#include "btgcdtimer_p.h"
+#include "btutility_p.h"
#include <QtCore/qglobal.h>
#include <QtCore/qlist.h>
#include <Foundation/Foundation.h>
+#include <CoreBluetooth/CoreBluetooth.h>
+
QT_BEGIN_NAMESPACE
class QBluetoothUuid;
-namespace OSXBluetooth
+namespace DarwinBluetooth
{
class LECBManagerNotifier;
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
-using QT_PREPEND_NAMESPACE(OSXBluetooth)::LECBManagerNotifier;
-using QT_PREPEND_NAMESPACE(OSXBluetooth)::ObjCScopedPointer;
+using QT_PREPEND_NAMESPACE(DarwinBluetooth)::LECBManagerNotifier;
+using QT_PREPEND_NAMESPACE(DarwinBluetooth)::ObjCScopedPointer;
enum LEInquiryState
{
@@ -88,7 +89,7 @@ enum LEInquiryState
ErrorLENotSupported
};
-@interface QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry) : NSObject<CBCentralManagerDelegate, QT_MANGLE_NAMESPACE(GCDTimerDelegate)>
+@interface QT_MANGLE_NAMESPACE(DarwinBTLEDeviceInquiry) : NSObject<CBCentralManagerDelegate, QT_MANGLE_NAMESPACE(GCDTimerDelegate)>
- (id)initWithNotifier:(LECBManagerNotifier *)aNotifier;
- (void)dealloc;
diff --git a/src/bluetooth/darwin/btnotifier.cpp b/src/bluetooth/darwin/btnotifier.cpp
new file mode 100644
index 00000000..24f54a09
--- /dev/null
+++ b/src/bluetooth/darwin/btnotifier.cpp
@@ -0,0 +1 @@
+#include "btnotifier_p.h"
diff --git a/src/bluetooth/osx/osxbtnotifier_p.h b/src/bluetooth/darwin/btnotifier_p.h
index 397214d0..e074a225 100644
--- a/src/bluetooth/osx/osxbtnotifier_p.h
+++ b/src/bluetooth/darwin/btnotifier_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTNOTIFIER_P_H
-#define OSXBTNOTIFIER_P_H
+#ifndef BTNOTIFIER_P_H
+#define BTNOTIFIER_P_H
//
// W A R N I N G
@@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
class QLowEnergyServicePrivate;
-namespace OSXBluetooth
+namespace DarwinBluetooth
{
class LECBManagerNotifier : public QObject
@@ -98,7 +98,7 @@ Q_SIGNALS:
void CBManagerError(const QBluetoothUuid &serviceUuid, QLowEnergyService::ServiceError error);
};
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
diff --git a/src/bluetooth/osx/osxbtobexsession.mm b/src/bluetooth/darwin/btobexsession.mm
index 868b2319..ecf010ba 100644
--- a/src/bluetooth/osx/osxbtobexsession.mm
+++ b/src/bluetooth/darwin/btobexsession.mm
@@ -37,9 +37,9 @@
**
****************************************************************************/
-#include "osxbtobexsession_p.h"
#include "qbluetoothaddress.h"
-#include "osxbtutility_p.h"
+#include "btobexsession_p.h"
+#include "btutility_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qvector.h>
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth
+namespace DarwinBluetooth
{
OBEXSessionDelegate::~OBEXSessionDelegate()
@@ -61,6 +61,8 @@ OBEXSessionDelegate::~OBEXSessionDelegate()
namespace {
+using NSDataPtr = NSMutableData *;
+
struct OBEXHeader
{
OBEXHeader() : headerID(0)
@@ -203,7 +205,7 @@ QList<OBEXHeader> qt_bluetooth_headers(const uint8_t *data, std::size_t length)
break;
}
default:
- qCWarning(QT_BT_OSX) << "invalid header format";
+ qCWarning(QT_BT_DARWIN) << "invalid header format";
return empty;
}
@@ -326,7 +328,7 @@ ObjCStrongReference<NSMutableData> next_data_chunk(QIODevice &inputStream, IOBlu
}
ObjCStrongReference<NSMutableData> chunk([NSMutableData dataWithBytes:block.data()
- length:realSize], true);
+ length:realSize], RetainPolicy::doInitialRetain);
if (chunk && [chunk length]) {
// If it actually was the last chunk
// of a length == maxBodySize, we'll
@@ -358,7 +360,7 @@ bool check_connect_event(const OBEXSessionEvent *e, OBEXError &error, OBEXOpCode
response = e->u.connectCommandResponseData.serverResponseOpCode;
return response == kOBEXResponseCodeSuccessWithFinalBit;
} else {
- qCWarning(QT_BT_OSX) << "unexpected event type";
+ qCWarning(QT_BT_DARWIN) << "unexpected event type";
error = kOBEXGeneralError;
return false;
}
@@ -378,7 +380,7 @@ bool check_put_event(const OBEXSessionEvent *e, OBEXError &error, OBEXOpCode &re
return response == kOBEXResponseCodeContinueWithFinalBit ||
response == kOBEXResponseCodeSuccessWithFinalBit;
} else {
- qCWarning(QT_BT_OSX) << "unexpected event type";
+ qCWarning(QT_BT_DARWIN) << "unexpected event type";
error = kOBEXGeneralError;
return false;
}
@@ -395,19 +397,19 @@ bool check_abort_event(const OBEXSessionEvent *e, OBEXError &error, OBEXOpCode &
response = e->u.abortCommandResponseData.serverResponseOpCode;
return response == kOBEXResponseCodeSuccessWithFinalBit;
} else {
- qCWarning(QT_BT_OSX) << "unexpected event type";
+ qCWarning(QT_BT_DARWIN) << "unexpected event type";
return false;
}
}
} // Unnamed namespace.
-} // OSXBluetooth.
+} // namespace DarwinBluetooth.
QT_END_NAMESPACE
QT_USE_NAMESPACE
-@interface QT_MANGLE_NAMESPACE(OSXBTOBEXSession) (PrivateAPI)
+@interface QT_MANGLE_NAMESPACE(DarwinBTOBEXSession) (PrivateAPI)
// OBEXDisconnect returns void - it's considered to be always
// successful. These methods are "private API" - no need to expose them,
@@ -417,14 +419,14 @@ QT_USE_NAMESPACE
@end
-@implementation QT_MANGLE_NAMESPACE(OSXBTOBEXSession)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTOBEXSession)
{
- QT_PREPEND_NAMESPACE(OSXBluetooth)::OBEXSessionDelegate *delegate;
+ QT_PREPEND_NAMESPACE(DarwinBluetooth)::OBEXSessionDelegate *delegate;
IOBluetoothDevice *device;
quint16 channelID;
IOBluetoothOBEXSession *session;
- QT_PREPEND_NAMESPACE(OSXBluetooth)::OBEXRequest currentRequest;
+ QT_PREPEND_NAMESPACE(DarwinBluetooth)::OBEXRequest currentRequest;
bool connected;
bool connectionIDFound;
@@ -448,7 +450,7 @@ QT_USE_NAMESPACE
return 0x1000;
}
-- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::OBEXSessionDelegate) *)aDelegate
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth::OBEXSessionDelegate) *)aDelegate
remoteDevice:(const QBluetoothAddress &)deviceAddress channelID:(quint16)port
{
Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
@@ -457,20 +459,20 @@ QT_USE_NAMESPACE
if (self = [super init]) {
connected = false;
- currentRequest = OSXBluetooth::OBEXNoop;
+ currentRequest = DarwinBluetooth::OBEXNoop;
connectionID = 0;
connectionIDFound = false;
- const BluetoothDeviceAddress addr(OSXBluetooth::iobluetooth_address(deviceAddress));
+ const BluetoothDeviceAddress addr(DarwinBluetooth::iobluetooth_address(deviceAddress));
device = [[IOBluetoothDevice deviceWithAddress:&addr] retain];
if (!device) {
- qCWarning(QT_BT_OSX) << "failed to create an IOBluetoothDevice";
+ qCWarning(QT_BT_DARWIN) << "failed to create an IOBluetoothDevice";
return self;
}
session = [[IOBluetoothOBEXSession alloc] initWithDevice:device channelID:port];
if (!session) {
- qCWarning(QT_BT_OSX) << "failed to create an OBEX session";
+ qCWarning(QT_BT_DARWIN) << "failed to create an OBEX session";
return self;
}
@@ -495,21 +497,21 @@ QT_USE_NAMESPACE
- (OBEXError)OBEXConnect
{
if (!session) {
- qCWarning(QT_BT_OSX) << "invalid session (nil)";
+ qCWarning(QT_BT_DARWIN) << "invalid session (nil)";
return kOBEXGeneralError;
}
// That's a "single-shot" operation:
- Q_ASSERT_X(currentRequest == OSXBluetooth::OBEXNoop, Q_FUNC_INFO,
+ Q_ASSERT_X(currentRequest == DarwinBluetooth::OBEXNoop, Q_FUNC_INFO,
"can not connect in this state (another request is active)");
connected = false;
connectionIDFound = false;
connectionID = 0;
- currentRequest = OSXBluetooth::OBEXConnect;
+ currentRequest = DarwinBluetooth::OBEXConnect;
const OBEXError status = [session OBEXConnect:kOBEXConnectFlagNone
- maxPacketLength:[QT_MANGLE_NAMESPACE(OSXBTOBEXSession) maxPacketLength]
+ maxPacketLength:[QT_MANGLE_NAMESPACE(DarwinBTOBEXSession) maxPacketLength]
optionalHeaders:nullptr
optionalHeadersLength:0
eventSelector:@selector(OBEXConnectHandler:)
@@ -517,7 +519,7 @@ QT_USE_NAMESPACE
refCon:nullptr];
if (status != kOBEXSuccess) {
- currentRequest = OSXBluetooth::OBEXNoop;
+ currentRequest = DarwinBluetooth::OBEXNoop;
// Already connected is still ok for us?
connected = status == kOBEXSessionAlreadyConnectedError;
}
@@ -527,7 +529,7 @@ QT_USE_NAMESPACE
- (void)OBEXConnectHandler:(const OBEXSessionEvent*)event
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(session, Q_FUNC_INFO, "invalid session (nil)");
@@ -538,8 +540,8 @@ QT_USE_NAMESPACE
}
if (currentRequest != OBEXConnect) {
- qCWarning(QT_BT_OSX) << "called while there is no "
- "active connect request";
+ qCWarning(QT_BT_DARWIN) << "called while there is no "
+ "active connect request";
return;
}
@@ -582,7 +584,7 @@ QT_USE_NAMESPACE
- (OBEXError)OBEXAbort
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
@@ -612,13 +614,13 @@ QT_USE_NAMESPACE
- (void)OBEXAbortHandler:(const OBEXSessionEvent*)event
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
if (currentRequest != OBEXAbort) {
- qCWarning(QT_BT_OSX) << "called while there "
- "is no ABORT request";
+ qCWarning(QT_BT_DARWIN) << "called while there "
+ "is no ABORT request";
return;
}
@@ -635,7 +637,7 @@ QT_USE_NAMESPACE
- (OBEXError)OBEXPutFile:(QT_PREPEND_NAMESPACE(QIODevice) *)input withName:(const QString &)name
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (!session || ![self isConnected])
return kOBEXSessionNotConnectedError;
@@ -649,13 +651,13 @@ QT_USE_NAMESPACE
// a payload.
const qint64 fileSize = input->size();
if (fileSize <= 0 || fileSize >= std::numeric_limits<uint32_t>::max()) {
- qCWarning(QT_BT_OSX) << "invalid input file size";
+ qCWarning(QT_BT_DARWIN) << "invalid input file size";
return kOBEXBadArgumentError;
}
- ObjCStrongReference<NSMutableData> headers([[NSMutableData alloc] init], false);
+ ObjCStrongReference<NSMutableData> headers([[NSMutableData alloc] init], RetainPolicy::noInitialRetain);
if (!headers) {
- qCWarning(QT_BT_OSX) << "failed to allocate headers";
+ qCWarning(QT_BT_DARWIN) << "failed to allocate headers";
return kOBEXNoResourcesError;
}
@@ -665,14 +667,14 @@ QT_USE_NAMESPACE
if (connectionIDFound) {
if (!append_four_byte_header(headers, kOBEXHeaderIDConnectionID, connectionID)) {
- qCWarning(QT_BT_OSX) << "failed to append connection ID header";
+ qCWarning(QT_BT_DARWIN) << "failed to append connection ID header";
return kOBEXNoResourcesError;
}
}
if (name.length()) {
if (!append_unicode_header(headers, kOBEXHeaderIDName, name)) {
- qCWarning(QT_BT_OSX) << "failed to append a unicode string";
+ qCWarning(QT_BT_DARWIN) << "failed to append a unicode string";
return kOBEXNoResourcesError;
}
}
@@ -685,7 +687,7 @@ QT_USE_NAMESPACE
if (!chunk || ![chunk length]) {
// We do not support PUT-DELETE (?)
// At least the first chunk is expected to be non-empty.
- qCWarning(QT_BT_OSX) << "invalid input stream";
+ qCWarning(QT_BT_DARWIN) << "invalid input stream";
return kOBEXBadArgumentError;
}
@@ -705,8 +707,8 @@ QT_USE_NAMESPACE
delegate->OBEXPutDataSent([chunk length], fileSize);
bytesSent = [chunk length];
- headersData = headers.take();
- bodyData = chunk.take();
+ headersData = NSDataPtr(headers.release());
+ bodyData = NSDataPtr(chunk.release());
inputStream = input;
} else {
// PUT request failed and we now
@@ -721,7 +723,7 @@ QT_USE_NAMESPACE
- (void)OBEXPutHandler:(const OBEXSessionEvent*)event
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
@@ -732,8 +734,8 @@ QT_USE_NAMESPACE
}
if (currentRequest != OBEXPut) {
- qCWarning(QT_BT_OSX) << "called while the current "
- "request is not a put request";
+ qCWarning(QT_BT_DARWIN) << "called while the current "
+ "request is not a put request";
return;
}
@@ -754,7 +756,7 @@ QT_USE_NAMESPACE
// 0 for the headers length, no more headers.
ObjCStrongReference<NSMutableData> chunk(next_data_chunk(*inputStream, session, 0, lastChunk));
if (!chunk && !lastChunk) {
- qCWarning(QT_BT_OSX) << "failed to allocate the next memory chunk";
+ qCWarning(QT_BT_DARWIN) << "failed to allocate the next memory chunk";
return;
}
@@ -770,7 +772,7 @@ QT_USE_NAMESPACE
refCon:nullptr];
if (status != kOBEXSuccess) {
- qCWarning(QT_BT_OSX) << "failed to send the next memory chunk";
+ qCWarning(QT_BT_DARWIN) << "failed to send the next memory chunk";
currentRequest = OBEXNoop;
if (delegate) // Response code is not important here.
delegate->OBEXPutError(kOBEXNoResourcesError, 0);
@@ -779,7 +781,7 @@ QT_USE_NAMESPACE
} else {
[bodyData release];
bytesSent += [chunk length];
- bodyData = chunk.take();//retained already.
+ bodyData = NSDataPtr(chunk.release());
if (delegate && !inputStream->isSequential())
delegate->OBEXPutDataSent(bytesSent, inputStream->size());
@@ -797,7 +799,7 @@ QT_USE_NAMESPACE
{
Q_ASSERT_X(session, Q_FUNC_INFO, "invalid session (nil)");
- currentRequest = OSXBluetooth::OBEXDisconnect;
+ currentRequest = DarwinBluetooth::OBEXDisconnect;
[session OBEXDisconnect:nullptr
optionalHeadersLength:0
@@ -830,12 +832,12 @@ QT_USE_NAMESPACE
delegate = nullptr;
// This will stop any handler (callback) preventing
// any read/write to potentially deleted objects.
- currentRequest = OSXBluetooth::OBEXNoop;
+ currentRequest = DarwinBluetooth::OBEXNoop;
}
- (bool)hasActiveRequest
{
- return currentRequest != OSXBluetooth::OBEXNoop && !pendingAbort;
+ return currentRequest != DarwinBluetooth::OBEXNoop && !pendingAbort;
}
@end
diff --git a/src/bluetooth/osx/osxbtobexsession_p.h b/src/bluetooth/darwin/btobexsession_p.h
index 49465f24..11c6d226 100644
--- a/src/bluetooth/osx/osxbtobexsession_p.h
+++ b/src/bluetooth/darwin/btobexsession_p.h
@@ -37,6 +37,9 @@
**
****************************************************************************/
+#ifndef BTOBEXSESSION_P_H
+#define BTOBEXSESSION_P_H
+
//
// W A R N I N G
// -------------
@@ -48,14 +51,16 @@
// We mean it.
//
-#include "osxbluetooth_p.h"
-
#include <QtCore/qvariant.h>
#include <QtCore/qglobal.h>
#include <Foundation/Foundation.h>
-@class QT_MANGLE_NAMESPACE(OSXBTOBEXSession);
+#include <IOBluetooth/IOBluetooth.h>
+
+// TODO: all this code must be removed in Qt 6?
+
+@class QT_MANGLE_NAMESPACE(DarwinBTOBEXSession);
QT_BEGIN_NAMESPACE
@@ -63,13 +68,13 @@ class QBluetoothAddress;
class QIODevice;
class QString;
-namespace OSXBluetooth
+namespace DarwinBluetooth
{
class OBEXSessionDelegate
{
public:
- typedef QT_MANGLE_NAMESPACE(OSXBTOBEXSession) ObjCOBEXSession;
+ typedef QT_MANGLE_NAMESPACE(DarwinBTOBEXSession) ObjCOBEXSession;
virtual ~OBEXSessionDelegate();
@@ -93,16 +98,16 @@ enum OBEXRequest {
OBEXAbort
};
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
// OBEX Session, it's a "single-shot" operation as our QBluetoothTransferReply is
// (it does not have an interface to re-send data or re-use the same transfer reply).
// It either succeeds or fails and tries to cleanup in any case.
-@interface QT_MANGLE_NAMESPACE(OSXBTOBEXSession) : NSObject
+@interface QT_MANGLE_NAMESPACE(DarwinBTOBEXSession) : NSObject
-- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::OBEXSessionDelegate) *)aDelegate
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth::OBEXSessionDelegate) *)aDelegate
remoteDevice:(const QBluetoothAddress &)deviceAddress channelID:(quint16)port;
- (void)dealloc;
@@ -129,3 +134,5 @@ QT_END_NAMESPACE
- (bool)hasActiveRequest;
@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtperipheralmanager.mm b/src/bluetooth/darwin/btperipheralmanager.mm
index 39f9808c..3336d8c5 100644
--- a/src/bluetooth/osx/osxbtperipheralmanager.mm
+++ b/src/bluetooth/darwin/btperipheralmanager.mm
@@ -41,9 +41,9 @@
#include "qlowenergycharacteristicdata.h"
#include "qlowenergydescriptordata.h"
-#include "osxbtperipheralmanager_p.h"
+#include "btperipheralmanager_p.h"
#include "qlowenergyservicedata.h"
-#include "osxbtnotifier_p.h"
+#include "btnotifier_p.h"
#include "qbluetooth.h"
#include <QtCore/qdebug.h>
@@ -91,7 +91,7 @@ ObjCStrongReference<CBMutableCharacteristic> create_characteristic(const QLowEne
properties:cb_properties(data)
value:nil
permissions:cb_permissions(data)],
- false /*do not retain*/);
+ RetainPolicy::noInitialRetain);
return ch;
}
@@ -107,7 +107,7 @@ ObjCStrongReference<CBMutableDescriptor> create_descriptor(const QLowEnergyDescr
if (data.uuid() != QBluetoothUuid::CharacteristicUserDescription &&
data.uuid() != QBluetoothUuid::CharacteristicPresentationFormat) {
- qCWarning(QT_BT_OSX) << "unsupported descriptor" << data.uuid();
+ qCWarning(QT_BT_DARWIN) << "unsupported descriptor" << data.uuid();
return {};
}
@@ -118,15 +118,15 @@ ObjCStrongReference<CBMutableDescriptor> create_descriptor(const QLowEnergyDescr
ObjCStrongReference<NSObject> value;
if (data.uuid() == QBluetoothUuid::CharacteristicUserDescription) {
const QString asQString(QString::fromUtf8(data.value()));
- value.reset(asQString.toNSString());
+ value.reset(asQString.toNSString(), RetainPolicy::doInitialRetain); // toNSString is auto-released, we have to retain.
} else {
const auto nsData = data_from_bytearray(data.value());
- value.reset(nsData.data());
+ value.reset(nsData.data(), RetainPolicy::doInitialRetain);
}
const ObjCStrongReference<CBMutableDescriptor> d([[CBMutableDescriptor alloc]
initWithType:cb_uuid(data.uuid())
- value:value], false /*do not retain*/);
+ value:value], RetainPolicy::noInitialRetain);
return d;
}
@@ -159,7 +159,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
}
-@interface QT_MANGLE_NAMESPACE(OSXBTPeripheralManager) (PrivateAPI)
+@interface QT_MANGLE_NAMESPACE(DarwinBTPeripheralManager) (PrivateAPI)
- (void)addConnectedCentral:(CBCentral *)central;
- (void)removeConnectedCentral:(CBCentral *)central;
@@ -177,7 +177,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
@end
-@implementation QT_MANGLE_NAMESPACE(OSXBTPeripheralManager)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTPeripheralManager)
{
ObjCScopedPointer<CBPeripheralManager> manager;
LECBManagerNotifier *notifier;
@@ -213,7 +213,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
notifier = aNotifier;
state = PeripheralState::idle;
nextServiceToAdd = {};
- connectedCentrals.reset([[NSMutableSet alloc] init]);
+ connectedCentrals.reset([[NSMutableSet alloc] init],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
maxNotificationValueLength = std::numeric_limits<NSUInteger>::max();
}
@@ -229,10 +230,11 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
- (QSharedPointer<QLowEnergyServicePrivate>)addService:(const QLowEnergyServiceData &)data
{
using QLES = QLowEnergyService;
+ using namespace DarwinBluetooth;
const auto nEntries = qt_countGATTEntries(data);
if (!nEntries || nEntries > std::numeric_limits<QLowEnergyHandle>::max() - lastHandle) {
- qCCritical(QT_BT_OSX) << "addService: not enough handles";
+ qCCritical(QT_BT_DARWIN) << "addService: not enough handles";
return {};
}
@@ -243,10 +245,10 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
const ObjCStrongReference<CBMutableService>
newCBService([[CBMutableService alloc] initWithType:cbUUID primary:primary],
- false /*do not retain*/);
+ RetainPolicy::noInitialRetain);
if (!newCBService) {
- qCCritical(QT_BT_OSX) << "addService: failed to create CBMutableService";
+ qCCritical(QT_BT_DARWIN) << "addService: failed to create CBMutableService";
return {};
}
@@ -292,10 +294,11 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
QT_BT_MAC_AUTORELEASEPOOL
- advertisementData.reset([[NSMutableDictionary alloc] init]);
+ advertisementData.reset([[NSMutableDictionary alloc] init],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
if (!advertisementData) {
- qCWarning(QT_BT_OSX) << "setParameters: failed to allocate "
- "NSMutableDictonary (advertisementData)";
+ qCWarning(QT_BT_DARWIN) << "setParameters: failed to allocate "
+ "NSMutableDictonary (advertisementData)";
return;
}
@@ -311,10 +314,11 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
if (!data.services().count() && !scanResponse.services().count())
return;
- const ObjCScopedPointer<NSMutableArray> uuids([[NSMutableArray alloc] init]);
+ const ObjCScopedPointer<NSMutableArray> uuids([[NSMutableArray alloc] init],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
if (!uuids) {
- qCWarning(QT_BT_OSX) << "setParameters: failed to allocate "
- "NSMutableArray (services uuids)";
+ qCWarning(QT_BT_DARWIN) << "setParameters: failed to allocate "
+ "NSMutableArray (services uuids)";
return;
}
@@ -340,10 +344,11 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
- (void)startAdvertising
{
state = PeripheralState::waitingForPowerOn;
- if (manager.data())
+ if (manager)
[manager setDelegate:nil];
manager.reset([[CBPeripheralManager alloc] initWithDelegate:self
- queue:OSXBluetooth::qt_LE_queue()]);
+ queue:DarwinBluetooth::qt_LE_queue()],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
}
- (void)stopAdvertising
@@ -370,6 +375,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
- (void)write:(const QByteArray &)value
charHandle:(QLowEnergyHandle)charHandle
{
+ using namespace DarwinBluetooth;
+
if (!notifier)
return;
@@ -383,11 +390,11 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
const auto & range = valueRanges[charHandle];
if (value.size() < int(range.first) || value.size() > int(range.second)
#ifdef Q_OS_IOS
- || value.size() > OSXBluetooth::maxValueLength) {
+ || value.size() > DarwinBluetooth::maxValueLength) {
#else
) {
#endif
- qCWarning(QT_BT_OSX) << "ignoring value of invalid length" << value.size();
+ qCWarning(QT_BT_DARWIN) << "ignoring value of invalid length" << value.size();
return;
}
@@ -398,14 +405,14 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
// We copy data here: sending update requests is async (see sendUpdateRequests),
// by the time we're allowed to actually send them, the data can change again
// and we'll send an 'out of order' value.
- const ObjCStrongReference<NSData> copy([NSData dataWithData:nsData], true);
+ const ObjCStrongReference<NSData> copy([NSData dataWithData:nsData], RetainPolicy::doInitialRetain);
updateQueue.push_back(UpdateRequest{charHandle, copy});
[self sendUpdateRequests];
}
- (void) addServicesToPeripheral
{
- Q_ASSERT(manager.data());
+ Q_ASSERT(manager);
if (nextServiceToAdd < services.size())
[manager addService:services[nextServiceToAdd++]];
@@ -421,11 +428,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
if (peripheral != manager || !notifier)
return;
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
if (peripheral.state == CBManagerStatePoweredOn) {
-#else
- if (peripheral.state == CBPeripheralManagerStatePoweredOn) {
-#endif
// "Bluetooth is currently powered on and is available to use."
if (state == PeripheralState::waitingForPowerOn) {
[manager removeAllServices];
@@ -456,13 +459,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
explicitly added again."
*/
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13)
- if (peripheral.state == CBManagerStateUnauthorized ||
- peripheral.state == CBManagerStateUnsupported) {
-#else
- if (peripheral.state == CBPeripheralManagerStateUnauthorized ||
- peripheral.state == CBPeripheralManagerStateUnsupported) {
-#endif
+ if (peripheral.state == CBManagerStateUnauthorized || peripheral.state == CBManagerStateUnsupported) {
emit notifier->LEnotSupported();
state = PeripheralState::idle;
}
@@ -507,7 +504,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
}
if (nextServiceToAdd == services.size())
- [manager startAdvertising:[advertisementData count] ? advertisementData.data() : nil];
+ [manager startAdvertising:[advertisementData count] ? advertisementData.get() : nil];
else
[self addServicesToPeripheral];
}
@@ -552,14 +549,14 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
const auto handle = charMap.key(request.characteristic);
if (!handle || !charValues.contains(handle)) {
- qCWarning(QT_BT_OSX) << "invalid read request, unknown characteristic";
+ qCWarning(QT_BT_DARWIN) << "invalid read request, unknown characteristic";
[manager respondToRequest:request withResult:CBATTErrorInvalidHandle];
return;
}
const auto &value = charValues[handle];
if (request.offset > [value length]) {
- qCWarning(QT_BT_OSX) << "invalid offset in a read request";
+ qCWarning(QT_BT_DARWIN) << "invalid offset in a read request";
[manager respondToRequest:request withResult:CBATTErrorInvalidOffset];
return;
}
@@ -602,6 +599,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
- (void)peripheralManager:(CBPeripheralManager *)peripheral
didReceiveWriteRequests:(NSArray *)requests
{
+ using namespace DarwinBluetooth;
+
QT_BT_MAC_AUTORELEASEPOOL
if (peripheral != manager || !notifier) {
@@ -639,7 +638,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
value.length = pair.second;
emit notifier->characteristicUpdated(handle, qt_bytearray(value));
const ObjCStrongReference<NSData> copy([NSData dataWithData:value],
- true);
+ RetainPolicy::doInitialRetain);
updateQueue.push_back(UpdateRequest{handle, copy});
}
@@ -670,9 +669,9 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
if (charMap.contains(request.charHandle)) {
if ([connectedCentrals count]
&& maxNotificationValueLength < [request.value length]) {
- qCWarning(QT_BT_OSX) << "value of length" << [request.value length]
- << "will possibly be truncated to"
- << maxNotificationValueLength;
+ qCWarning(QT_BT_DARWIN) << "value of length" << [request.value length]
+ << "will possibly be truncated to"
+ << maxNotificationValueLength;
}
const BOOL res = [manager updateValue:request.value
forCharacteristic:static_cast<CBMutableCharacteristic *>(charMap[request.charHandle])
@@ -753,10 +752,11 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
QT_BT_MAC_AUTORELEASEPOOL
- ObjCScopedPointer<NSMutableArray> included([[NSMutableArray alloc] init]);
+ ObjCScopedPointer<NSMutableArray> included([[NSMutableArray alloc] init],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
if (!included) {
- qCWarning(QT_BT_OSX) << "addIncludedSerivces: failed "
- "to allocate NSMutableArray";
+ qCWarning(QT_BT_DARWIN) << "addIncludedSerivces: failed "
+ "to allocate NSMutableArray";
return;
}
@@ -766,8 +766,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
qtService->includedServices << includedService->serviceUuid();
++lastHandle;
} else {
- qCWarning(QT_BT_OSX) << "can not use" << includedService->serviceUuid()
- << "as included, it has to be added first";
+ qCWarning(QT_BT_DARWIN) << "can not use" << includedService->serviceUuid()
+ << "as included, it has to be added first";
}
}
@@ -784,26 +784,28 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
QT_BT_MAC_AUTORELEASEPOOL
- ObjCScopedPointer<NSMutableArray> newCBChars([[NSMutableArray alloc] init]);
+ ObjCScopedPointer<NSMutableArray> newCBChars([[NSMutableArray alloc] init],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
if (!newCBChars) {
- qCWarning(QT_BT_OSX) << "addCharacteristicsAndDescritptors: "
- "failed to allocate NSMutableArray "
- "(characteristics)";
+ qCWarning(QT_BT_DARWIN) << "addCharacteristicsAndDescritptors: "
+ "failed to allocate NSMutableArray "
+ "(characteristics)";
return;
}
for (const auto &ch : data.characteristics()) {
if (!qt_validate_value_range(ch)) {
- qCWarning(QT_BT_OSX) << "addCharacteristicsAndDescritptors: "
- "invalid value size/min-max length";
+ qCWarning(QT_BT_DARWIN) << "addCharacteristicsAndDescritptors: "
+ "invalid value size/min-max length";
continue;
}
#ifdef Q_OS_IOS
- if (ch.value().length() > OSXBluetooth::maxValueLength) {
- qCWarning(QT_BT_OSX) << "addCharacteristicsAndDescritptors: "
- "value exceeds the maximal permitted "
- "value length (" << OSXBluetooth::maxValueLength
+ if (ch.value().length() > DarwinBluetooth::maxValueLength) {
+ qCWarning(QT_BT_DARWIN) << "addCharacteristicsAndDescritptors: "
+ "value exceeds the maximal permitted "
+ "value length ("
+ << DarwinBluetooth::maxValueLength
<< "octets) on the platform";
continue;
}
@@ -811,15 +813,15 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
const auto cbChar(create_characteristic(ch));
if (!cbChar) {
- qCWarning(QT_BT_OSX) << "addCharacteristicsAndDescritptors: "
- "failed to allocate a characteristic";
+ qCWarning(QT_BT_DARWIN) << "addCharacteristicsAndDescritptors: "
+ "failed to allocate a characteristic";
continue;
}
const auto nsData(mutable_data_from_bytearray(ch.value()));
if (!nsData) {
- qCWarning(QT_BT_OSX) << "addCharacteristicsAndDescritptors: "
- "addService: failed to allocate NSData (char value)";
+ qCWarning(QT_BT_DARWIN) << "addCharacteristicsAndDescritptors: "
+ "addService: failed to allocate NSData (char value)";
continue;
}
@@ -837,11 +839,12 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
charData.properties = ch.properties();
charData.value = ch.value();
- const ObjCScopedPointer<NSMutableArray> newCBDescs([[NSMutableArray alloc] init]);
+ const ObjCScopedPointer<NSMutableArray> newCBDescs([[NSMutableArray alloc] init],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
if (!newCBDescs) {
- qCWarning(QT_BT_OSX) << "addCharacteristicsAndDescritptors: "
- "failed to allocate NSMutableArray "
- "(descriptors)";
+ qCWarning(QT_BT_DARWIN) << "addCharacteristicsAndDescritptors: "
+ "failed to allocate NSMutableArray "
+ "(descriptors)";
continue;
}
@@ -862,13 +865,13 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
}
if ([newCBDescs count])
- cbChar.data().descriptors = newCBDescs.data(); // retains
+ cbChar.data().descriptors = newCBDescs.get();
qtService->characteristicList.insert(declHandle, charData);
}
if ([newCBChars count])
- cbService.characteristics = newCBChars.data();
+ cbService.characteristics = newCBChars.get();
}
- (CBATTError)validateWriteRequest:(CBATTRequest *)request
diff --git a/src/bluetooth/osx/osxbtperipheralmanager_p.h b/src/bluetooth/darwin/btperipheralmanager_p.h
index fcf55698..e09165ac 100644
--- a/src/bluetooth/osx/osxbtperipheralmanager_p.h
+++ b/src/bluetooth/darwin/btperipheralmanager_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTPERIPHERALMANAGER_P_H
-#define OSXBTPERIPHERALMANAGER_P_H
+#ifndef BTPERIPHERALMANAGER_P_H
+#define BTPERIPHERALMANAGER_P_H
//
// W A R N I N G
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "osxbtutility_p.h"
+#include "btutility_p.h"
#include "qlowenergyadvertisingparameters.h"
#include "qlowenergyserviceprivate_p.h"
@@ -71,18 +71,18 @@
#include <Foundation/Foundation.h>
-#include "osxbluetooth_p.h"
+#include <CoreBluetooth/CoreBluetooth.h>
QT_BEGIN_NAMESPACE
class QLowEnergyServiceData;
-namespace OSXBluetooth
+namespace DarwinBluetooth
{
class LECBManagerNotifier;
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
@@ -92,7 +92,7 @@ QT_END_NAMESPACE
QT_USE_NAMESPACE
-using namespace OSXBluetooth;
+using namespace DarwinBluetooth;
template<class Type>
@@ -121,7 +121,7 @@ struct UpdateRequest
using ValueRange = QPair<NSUInteger, NSUInteger>;
-@interface QT_MANGLE_NAMESPACE(OSXBTPeripheralManager) : NSObject<CBPeripheralManagerDelegate>
+@interface QT_MANGLE_NAMESPACE(DarwinBTPeripheralManager) : NSObject<CBPeripheralManagerDelegate>
- (id)initWith:(LECBManagerNotifier *)notifier;
- (void)dealloc;
diff --git a/src/bluetooth/osx/btraii.mm b/src/bluetooth/darwin/btraii.mm
index a1bf2a8d..486c3c14 100644
--- a/src/bluetooth/osx/btraii.mm
+++ b/src/bluetooth/darwin/btraii.mm
@@ -52,13 +52,14 @@ namespace DarwinBluetooth {
StrongReference::StrongReference(void *object, RetainPolicy policy)
: objCInstance(object)
{
- if (policy == RetainPolicy::doInitialRetain)
+ if (objCInstance && policy == RetainPolicy::doInitialRetain)
objCInstance = [getAs<NSObject>() retain];
}
StrongReference::StrongReference(const StrongReference &other)
{
- objCInstance = [other.getAs<NSObject>() retain];
+ if ((objCInstance = other.getAs<NSObject>()))
+ objCInstance = [other.getAs<NSObject>() retain];
}
StrongReference::StrongReference(StrongReference &&other)
@@ -84,9 +85,18 @@ StrongReference &StrongReference::operator = (const StrongReference &other) noex
StrongReference &StrongReference::operator = (StrongReference &&other) noexcept
{
swap(other);
+
return *this;
}
+void *StrongReference::release()
+{
+ void *released = objCInstance;
+ objCInstance = nullptr;
+
+ return released;
+}
+
void StrongReference::reset()
{
[getAs<NSObject>() release];
@@ -98,11 +108,8 @@ void StrongReference::reset(void *obj, RetainPolicy policy)
[getAs<NSObject>() release];
objCInstance = obj;
- if (policy == RetainPolicy::doInitialRetain) {
- auto newInstance = static_cast<NSObject *>(obj);
- Q_ASSERT(newInstance);
- objCInstance = [newInstance retain];
- }
+ if (objCInstance && policy == RetainPolicy::doInitialRetain)
+ objCInstance = [getAs<NSObject>() retain];
}
} // namespace DarwinBluetooth
diff --git a/src/bluetooth/osx/btraii_p.h b/src/bluetooth/darwin/btraii_p.h
index 6053d63b..c7a159cb 100644
--- a/src/bluetooth/osx/btraii_p.h
+++ b/src/bluetooth/darwin/btraii_p.h
@@ -98,6 +98,8 @@ public:
std::swap(objCInstance, other.objCInstance);
}
+ void *release();
+
void reset();
void reset(void *newInstance, RetainPolicy policy);
diff --git a/src/bluetooth/osx/osxbtrfcommchannel.mm b/src/bluetooth/darwin/btrfcommchannel.mm
index d2d3e2f8..0cac3c6d 100644
--- a/src/bluetooth/osx/osxbtrfcommchannel.mm
+++ b/src/bluetooth/darwin/btrfcommchannel.mm
@@ -37,14 +37,14 @@
**
****************************************************************************/
-#include "osxbtrfcommchannel_p.h"
+#include "btrfcommchannel_p.h"
#include "qbluetoothaddress.h"
-#include "osxbtutility_p.h"
#include "btdelegates_p.h"
+#include "btutility_p.h"
QT_USE_NAMESPACE
-@implementation QT_MANGLE_NAMESPACE(OSXBTRFCOMMChannel)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTRFCOMMChannel)
{
QT_PREPEND_NAMESPACE(DarwinBluetooth)::ChannelDelegate *delegate;
IOBluetoothDevice *device;
@@ -103,29 +103,29 @@ QT_USE_NAMESPACE
withChannelID:(BluetoothRFCOMMChannelID)channelID
{
if (address.isNull()) {
- qCCritical(QT_BT_OSX) << "invalid peer address";
+ qCCritical(QT_BT_DARWIN) << "invalid peer address";
return kIOReturnNoDevice;
}
// Can never be called twice.
if (connected || device || channel) {
- qCCritical(QT_BT_OSX) << "connection is already active";
+ qCCritical(QT_BT_DARWIN) << "connection is already active";
return kIOReturnStillOpen;
}
QT_BT_MAC_AUTORELEASEPOOL;
- const BluetoothDeviceAddress iobtAddress = OSXBluetooth::iobluetooth_address(address);
+ const BluetoothDeviceAddress iobtAddress = DarwinBluetooth::iobluetooth_address(address);
device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
if (!device) { // TODO: do I always check this BTW??? Apple's docs say nothing about nil.
- qCCritical(QT_BT_OSX) << "failed to create a device";
+ qCCritical(QT_BT_DARWIN) << "failed to create a device";
return kIOReturnNoDevice;
}
const IOReturn status = [device openRFCOMMChannelAsync:&channel
withChannelID:channelID delegate:self];
if (status != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << "failed to open L2CAP channel";
+ qCCritical(QT_BT_DARWIN) << "failed to open L2CAP channel";
// device is still autoreleased.
device = nil;
return status;
diff --git a/src/bluetooth/osx/osxbtrfcommchannel_p.h b/src/bluetooth/darwin/btrfcommchannel_p.h
index 44416cce..25299092 100644
--- a/src/bluetooth/osx/osxbtrfcommchannel_p.h
+++ b/src/bluetooth/darwin/btrfcommchannel_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTRFCOMMCHANNEL_P_H
-#define OSXBTRFCOMMCHANNEL_P_H
+#ifndef BTRFCOMMCHANNEL_P_H
+#define BTRFCOMMCHANNEL_P_H
//
// W A R N I N G
@@ -51,13 +51,11 @@
// We mean it.
//
-#include "osxbluetooth_p.h"
-
#include <QtCore/qglobal.h>
#include <Foundation/Foundation.h>
-@class QT_MANGLE_NAMESPACE(OSXBTRFCOMMChannel);
+#include <IOBluetooth/IOBluetooth.h>
QT_BEGIN_NAMESPACE
@@ -71,7 +69,7 @@ class ChannelDelegate;
QT_END_NAMESPACE
-@interface QT_MANGLE_NAMESPACE(OSXBTRFCOMMChannel) : NSObject<IOBluetoothRFCOMMChannelDelegate>
+@interface QT_MANGLE_NAMESPACE(DarwinBTRFCOMMChannel) : NSObject<IOBluetoothRFCOMMChannelDelegate>
- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth)::ChannelDelegate *)aDelegate;
- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth)::ChannelDelegate *)aDelegate
diff --git a/src/bluetooth/osx/osxbtsdpinquiry.mm b/src/bluetooth/darwin/btsdpinquiry.mm
index a2b02b1a..468d5445 100644
--- a/src/bluetooth/osx/osxbtsdpinquiry.mm
+++ b/src/bluetooth/darwin/btsdpinquiry.mm
@@ -38,17 +38,17 @@
****************************************************************************/
#include "qbluetoothserviceinfo.h"
-#include "osxbtsdpinquiry_p.h"
+#include "btsdpinquiry_p.h"
#include "qbluetoothuuid.h"
-#include "osxbtutility_p.h"
#include "btdelegates_p.h"
+#include "btutility_p.h"
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
namespace {
@@ -162,7 +162,7 @@ void extract_service_record(IOBluetoothSDPServiceRecord *record, QBluetoothServi
for (NSNumber *key in keys) {
const quint16 attributeID = [key unsignedShortValue];
IOBluetoothSDPDataElement *const element = [attributes objectForKey:key];
- const QVariant attributeValue = OSXBluetooth::extract_attribute_value(element);
+ const QVariant attributeValue = DarwinBluetooth::extract_attribute_value(element);
serviceInfo.setAttribute(attributeID, attributeValue);
}
@@ -200,18 +200,18 @@ QVector<QBluetoothUuid> extract_services_uuids(IOBluetoothDevice *device)
return uuids;
}
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
QT_USE_NAMESPACE
-using namespace OSXBluetooth;
+using namespace DarwinBluetooth;
-@implementation QT_MANGLE_NAMESPACE(OSXBTSDPInquiry)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTSDPInquiry)
{
QT_PREPEND_NAMESPACE(DarwinBluetooth::SDPInquiryDelegate) *delegate;
- IOBluetoothDevice *device;
+ ObjCScopedPointer<IOBluetoothDevice> device;
bool isActive;
}
@@ -230,7 +230,6 @@ using namespace OSXBluetooth;
- (void)dealloc
{
//[device closeConnection]; //??? - synchronous, "In the future this API will be changed to allow asynchronous operation."
- [device release];
[super dealloc];
}
@@ -253,9 +252,9 @@ using namespace OSXBluetooth;
// We first try to allocate "filters":
ObjCScopedPointer<NSMutableArray> array;
if (qtFilters.size()) {
- array.reset([[NSMutableArray alloc] init]);
+ array.reset([[NSMutableArray alloc] init], RetainPolicy::noInitialRetain);
if (!array) {
- qCCritical(QT_BT_OSX) << "failed to allocate an uuid filter";
+ qCCritical(QT_BT_DARWIN) << "failed to allocate an uuid filter";
return kIOReturnError;
}
@@ -266,21 +265,18 @@ using namespace OSXBluetooth;
}
if (int([array count]) != qtFilters.size()) {
- qCCritical(QT_BT_OSX) << "failed to create an uuid filter";
+ qCCritical(QT_BT_DARWIN) << "failed to create an uuid filter";
return kIOReturnError;
}
}
const BluetoothDeviceAddress iobtAddress(iobluetooth_address(address));
- ObjCScopedPointer<IOBluetoothDevice> newDevice([[IOBluetoothDevice deviceWithAddress:&iobtAddress] retain]);
- if (!newDevice) {
- qCCritical(QT_BT_OSX) << "failed to create an IOBluetoothDevice object";
+ device.reset([IOBluetoothDevice deviceWithAddress:&iobtAddress], RetainPolicy::doInitialRetain);
+ if (!device) {
+ qCCritical(QT_BT_DARWIN) << "failed to create an IOBluetoothDevice object";
return kIOReturnError;
}
- ObjCScopedPointer<IOBluetoothDevice> oldDevice(device);
- device = newDevice.data();
-
IOReturn result = kIOReturnSuccess;
if (qtFilters.size())
result = [device performSDPQuery:self uuids:array];
@@ -288,11 +284,10 @@ using namespace OSXBluetooth;
result = [device performSDPQuery:self];
if (result != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << "failed to start an SDP query";
- device = oldDevice.take();
+ qCCritical(QT_BT_DARWIN) << "failed to start an SDP query";
+ device.reset();
} else {
isActive = true;
- newDevice.take();
}
return result;
@@ -303,9 +298,7 @@ using namespace OSXBluetooth;
// There is no API to stop it,
// but there is a 'stop' member-function in Qt and
// after it's called sdpQueryComplete must be somehow ignored.
-
- [device release];
- device = nil;
+ device.reset();
}
- (void)sdpQueryComplete:(IOBluetoothDevice *)aDevice status:(IOReturn)status
diff --git a/src/bluetooth/osx/osxbtsdpinquiry_p.h b/src/bluetooth/darwin/btsdpinquiry_p.h
index e2658670..6cce5703 100644
--- a/src/bluetooth/osx/osxbtsdpinquiry_p.h
+++ b/src/bluetooth/darwin/btsdpinquiry_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTSDPINQUIRY_H
-#define OSXBTSDPINQUIRY_H
+#ifndef BTSDPINQUIRY_H
+#define BTSDPINQUIRY_H
//
// W A R N I N G
@@ -53,7 +53,6 @@
#include "qbluetoothaddress.h"
#include "qbluetoothuuid.h"
-#include "osxbluetooth_p.h"
#include <QtCore/qglobal.h>
#include <QtCore/qlist.h>
@@ -61,7 +60,9 @@
#include <Foundation/Foundation.h>
-@class QT_MANGLE_NAMESPACE(OSXBTSDPInquiry);
+#include <IOBluetooth/IOBluetooth.h>
+
+@class QT_MANGLE_NAMESPACE(DarwinBTSDPInquiry);
QT_BEGIN_NAMESPACE
@@ -72,19 +73,15 @@ namespace DarwinBluetooth {
class SDPInquiryDelegate;
-}
-
-namespace OSXBluetooth {
-
void extract_service_record(IOBluetoothSDPServiceRecord *record, QBluetoothServiceInfo &serviceInfo);
QVariant extract_attribute_value(IOBluetoothSDPDataElement *dataElement);
QVector<QBluetoothUuid> extract_services_uuids(IOBluetoothDevice *device);
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
-@interface QT_MANGLE_NAMESPACE(OSXBTSDPInquiry) : NSObject
+@interface QT_MANGLE_NAMESPACE(DarwinBTSDPInquiry) : NSObject
- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(DarwinBluetooth::SDPInquiryDelegate) *)aDelegate;
- (void)dealloc;
diff --git a/src/bluetooth/osx/osxbtservicerecord.mm b/src/bluetooth/darwin/btservicerecord.mm
index 23d55d13..dd711504 100644
--- a/src/bluetooth/osx/osxbtservicerecord.mm
+++ b/src/bluetooth/darwin/btservicerecord.mm
@@ -38,17 +38,18 @@
****************************************************************************/
#include "qbluetoothserviceinfo.h"
-#include "osxbtservicerecord_p.h"
-#include "osxbluetooth_p.h"
+#include "btservicerecord_p.h"
#include <QtCore/qvariant.h>
#include <QtCore/qdebug.h>
#include <QtCore/qmap.h>
#include <QtCore/qurl.h>
+#include <IOBluetooth/IOBluetooth.h>
+
QT_BEGIN_NAMESPACE
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
//
// Returns a dictionary containing the Bluetooth RFCOMM service definition
@@ -104,37 +105,37 @@ Number variant_to_nsnumber(const QVariant &);
template<>
Number variant_to_nsnumber<unsigned char>(const QVariant &var)
{
- return Number([NSNumber numberWithUnsignedChar:var.value<unsigned char>()], true);
+ return Number([NSNumber numberWithUnsignedChar:var.value<unsigned char>()], RetainPolicy::doInitialRetain);
}
template<>
Number variant_to_nsnumber<unsigned short>(const QVariant &var)
{
- return Number([NSNumber numberWithUnsignedShort:var.value<unsigned short>()], true);
+ return Number([NSNumber numberWithUnsignedShort:var.value<unsigned short>()], RetainPolicy::doInitialRetain);
}
template<>
Number variant_to_nsnumber<unsigned>(const QVariant &var)
{
- return Number([NSNumber numberWithUnsignedInt:var.value<unsigned>()], true);
+ return Number([NSNumber numberWithUnsignedInt:var.value<unsigned>()], RetainPolicy::doInitialRetain);
}
template<>
Number variant_to_nsnumber<char>(const QVariant &var)
{
- return Number([NSNumber numberWithChar:var.value<char>()], true);
+ return Number([NSNumber numberWithChar:var.value<char>()], RetainPolicy::doInitialRetain);
}
template<>
Number variant_to_nsnumber<short>(const QVariant &var)
{
- return Number([NSNumber numberWithShort:var.value<short>()], true);
+ return Number([NSNumber numberWithShort:var.value<short>()], RetainPolicy::doInitialRetain);
}
template<>
Number variant_to_nsnumber<int>(const QVariant &var)
{
- return Number([NSNumber numberWithInt:var.value<int>()], true);
+ return Number([NSNumber numberWithInt:var.value<int>()], RetainPolicy::doInitialRetain);
}
template<class ValueType>
@@ -431,7 +432,7 @@ Dictionary iobluetooth_service_dictionary(const QBluetoothServiceInfo &serviceIn
if (!attributeIds.size())
return dict;
- dict.reset([[NSMutableDictionary alloc] init]);
+ dict.reset([[NSMutableDictionary alloc] init], RetainPolicy::noInitialRetain);
for (quint16 key : attributeIds) {
if (key == QSInfo::ProtocolDescriptorList) // We handle it in a special way.
diff --git a/src/bluetooth/osx/osxbtservicerecord_p.h b/src/bluetooth/darwin/btservicerecord_p.h
index 6b2db8a8..6b5b0374 100644
--- a/src/bluetooth/osx/osxbtservicerecord_p.h
+++ b/src/bluetooth/darwin/btservicerecord_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTSERVICERECORD_P_H
-#define OSXBTSERVICERECORD_P_H
+#ifndef BTSERVICERECORD_P_H
+#define BTSERVICERECORD_P_H
//
// W A R N I N G
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "osxbtutility_p.h"
+#include "btutility_p.h"
#include <QtCore/qglobal.h>
@@ -61,11 +61,11 @@ QT_BEGIN_NAMESPACE
class QBluetoothServiceInfo;
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
ObjCStrongReference<NSMutableDictionary> iobluetooth_service_dictionary(const QBluetoothServiceInfo &serviceInfo);
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
diff --git a/src/bluetooth/osx/osxbtsocketlistener.mm b/src/bluetooth/darwin/btsocketlistener.mm
index 10526b0f..505fec14 100644
--- a/src/bluetooth/osx/osxbtsocketlistener.mm
+++ b/src/bluetooth/darwin/btsocketlistener.mm
@@ -37,15 +37,15 @@
**
****************************************************************************/
-#include "osxbtsocketlistener_p.h"
-#include "osxbtutility_p.h"
+#include "btsocketlistener_p.h"
#include "btdelegates_p.h"
+#include "btutility_p.h"
#include <QtCore/qdebug.h>
QT_USE_NAMESPACE
-@implementation QT_MANGLE_NAMESPACE(OSXBTSocketListener)
+@implementation QT_MANGLE_NAMESPACE(DarwinBTSocketListener)
{
IOBluetoothUserNotification *connectionNotification;
QT_PREPEND_NAMESPACE(DarwinBluetooth::SocketListener) *delegate;
diff --git a/src/bluetooth/osx/osxbtsocketlistener_p.h b/src/bluetooth/darwin/btsocketlistener_p.h
index 3bbce24e..4b9b267a 100644
--- a/src/bluetooth/osx/osxbtsocketlistener_p.h
+++ b/src/bluetooth/darwin/btsocketlistener_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTSOCKETLISTENER_P_H
-#define OSXBTSOCKETLISTENER_P_H
+#ifndef BTSOCKETLISTENER_P_H
+#define BTSOCKETLISTENER_P_H
//
// W A R N I N G
@@ -51,15 +51,11 @@
// We mean it.
//
-#include "osxbluetooth_p.h"
-
#include <QtCore/qglobal.h>
#include <Foundation/Foundation.h>
-// TODO: use the special macros we have to create an
-// alias for a mangled name.
-@class QT_MANGLE_NAMESPACE(OSXBTSocketListener);
+#include <IOBluetooth/IOBluetooth.h>
QT_BEGIN_NAMESPACE
@@ -71,10 +67,10 @@ class SocketListener;
QT_END_NAMESPACE
-// A single OSXBTSocketListener can be started only once with
+// A single DarwinBTSocketListener can be started only once with
// RFCOMM or L2CAP protocol. It must be deleted to stop listening.
-@interface QT_MANGLE_NAMESPACE(OSXBTSocketListener) : NSObject
+@interface QT_MANGLE_NAMESPACE(DarwinBTSocketListener) : NSObject
- (id)initWithListener:(QT_PREPEND_NAMESPACE(DarwinBluetooth::SocketListener) *)aDelegate;
- (void)dealloc;
diff --git a/src/bluetooth/osx/osxbtutility.mm b/src/bluetooth/darwin/btutility.mm
index e17006de..07c22c1c 100644
--- a/src/bluetooth/osx/osxbtutility.mm
+++ b/src/bluetooth/darwin/btutility.mm
@@ -39,7 +39,7 @@
#include "qlowenergycharacteristicdata.h"
#include "qbluetoothaddress.h"
-#include "osxbtutility_p.h"
+#include "btutility_p.h"
#include "qbluetoothuuid.h"
#include <QtCore/qendian.h>
@@ -49,9 +49,7 @@
#import <IOBluetooth/objc/IOBluetoothSDPUUID.h>
#import <CoreFoundation/CoreFoundation.h>
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12, __IPHONE_NA)
#import <CoreBluetooth/CBUUID.h>
-#endif
#endif
@@ -60,17 +58,9 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_IOS_BLUETOOTH
-
-Q_LOGGING_CATEGORY(QT_BT_OSX, "qt.bluetooth.osx")
+Q_LOGGING_CATEGORY(QT_BT_DARWIN, "qt.bluetooth.darwin")
-#else
-
-Q_LOGGING_CATEGORY(QT_BT_OSX, "qt.bluetooth.ios")
-
-#endif
-
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
const int defaultLEScanTimeoutMS = 25000;
// We use it only on iOS for now:
@@ -127,7 +117,7 @@ ObjCStrongReference<IOBluetoothSDPUUID> iobluetooth_uuid(const QBluetoothUuid &u
const quint128 intVal(uuid.toUInt128());
const ObjCStrongReference<IOBluetoothSDPUUID> iobtUUID([IOBluetoothSDPUUID uuidWithBytes:intVal.data
- length:nBytes], true);
+ length:nBytes], RetainPolicy::doInitialRetain);
return iobtUUID;
}
@@ -172,7 +162,7 @@ void qt_test_iobluetooth_runloop()
// dispatcher would suffice. At the moment of writing we do not have such
// event dispatcher, so we only can work on the main thread.
if (CFRunLoopGetMain() != CFRunLoopGetCurrent()) {
- qCWarning(QT_BT_OSX) << "IOBluetooth works only on the main thread or a"
+ qCWarning(QT_BT_DARWIN) << "IOBluetooth works only on the main thread or a"
<< "thread with a running CFRunLoop";
}
}
@@ -206,18 +196,14 @@ QBluetoothUuid qt_uuid(CBUUID *uuid)
std::copy(source, source + 16, qtUuidData.data);
return QBluetoothUuid(qtUuidData);
- } else {
- qCDebug(QT_BT_OSX) << "qt_uuid, invalid CBUUID, 2 or 16 bytes expected, but got "
- << uuid.data.length << " bytes length";
- return QBluetoothUuid();
}
- if (uuid.data.length != 16) // TODO: warning?
- return QBluetoothUuid();
-
+ qCDebug(QT_BT_DARWIN) << "qt_uuid, invalid CBUUID, 2 or 16 bytes expected, but got "
+ << uuid.data.length << " bytes length";
+ return QBluetoothUuid();
}
-CFStrongReference<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid)
+QCFType<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid)
{
const quint128 qtUuidData = qtUuid.toUInt128();
const quint8 *const data = qtUuidData.data;
@@ -228,16 +214,16 @@ CFStrongReference<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid)
data[12], data[13], data[14], data[15]};
CFUUIDRef cfUuid = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, bytes);
- return CFStrongReference<CFUUIDRef>(cfUuid, false);// false == already retained.
+ return cfUuid;
}
ObjCStrongReference<CBUUID> cb_uuid(const QBluetoothUuid &qtUuid)
{
- CFStrongReference<CFUUIDRef> cfUuid(cf_uuid(qtUuid));
+ QCFType<CFUUIDRef> cfUuid(cf_uuid(qtUuid));
if (!cfUuid)
return ObjCStrongReference<CBUUID>();
- ObjCStrongReference<CBUUID> cbUuid([CBUUID UUIDWithCFUUID:cfUuid], true); //true == retain.
+ ObjCStrongReference<CBUUID> cbUuid([CBUUID UUIDWithCFUUID:cfUuid], RetainPolicy::doInitialRetain);
return cbUuid;
}
@@ -326,9 +312,9 @@ QByteArray qt_bytearray(NSObject *obj)
ObjCStrongReference<NSData> data_from_bytearray(const QByteArray & qtData)
{
if (!qtData.size())
- return ObjCStrongReference<NSData>([[NSData alloc] init], false);
+ return ObjCStrongReference<NSData>([[NSData alloc] init], RetainPolicy::noInitialRetain);
- ObjCStrongReference<NSData> result([NSData dataWithBytes:qtData.constData() length:qtData.size()], true);
+ ObjCStrongReference<NSData> result([NSData dataWithBytes:qtData.constData() length:qtData.size()], RetainPolicy::doInitialRetain);
return result;
}
@@ -337,9 +323,9 @@ ObjCStrongReference<NSMutableData> mutable_data_from_bytearray(const QByteArray
using MutableData = ObjCStrongReference<NSMutableData>;
if (!qtData.size())
- return MutableData([[NSMutableData alloc] init], false);
+ return MutableData([[NSMutableData alloc] init], RetainPolicy::noInitialRetain);
- MutableData result([[NSMutableData alloc] initWithLength:qtData.size()], false);
+ MutableData result([[NSMutableData alloc] initWithLength:qtData.size()], RetainPolicy::noInitialRetain);
[result replaceBytesInRange:NSMakeRange(0, qtData.size())
withBytes:qtData.constData()];
return result;
@@ -355,8 +341,8 @@ public:
queue = dispatch_queue_create(label, DISPATCH_QUEUE_SERIAL);
if (!queue) {
- qCCritical(QT_BT_OSX) << "failed to create dispatch queue with label"
- << label;
+ qCCritical(QT_BT_DARWIN) << "failed to create dispatch queue with label"
+ << label;
}
}
~SerialDispatchQueue()
@@ -381,6 +367,6 @@ dispatch_queue_t qt_LE_queue()
return leQueue.data();
}
-}
+} // namespace DarwinBluetooth
QT_END_NAMESPACE
diff --git a/src/bluetooth/osx/osxbtutility_p.h b/src/bluetooth/darwin/btutility_p.h
index c2bc6cf8..b65544e2 100644
--- a/src/bluetooth/osx/osxbtutility_p.h
+++ b/src/bluetooth/darwin/btutility_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef OSXBTUTILITY_P_H
-#define OSXBTUTILITY_P_H
+#ifndef BTUTILITY_P_H
+#define BTUTILITY_P_H
//
// W A R N I N G
@@ -51,230 +51,81 @@
// We mean it.
//
-#include "osxbluetooth_p.h"
+#include "btraii_p.h"
#include <QtCore/qloggingcategory.h>
-#include <QtCore/qscopedpointer.h>
#include <QtCore/qglobal.h>
+#include <QtCore/private/qcore_mac_p.h>
+
#include <Foundation/Foundation.h>
+#include <CoreBluetooth/CoreBluetooth.h>
+
+#ifdef Q_OS_MACOS
+#include <IOBluetooth/IOBluetooth.h>
+#endif // Q_OS_MACOS
+
QT_BEGIN_NAMESPACE
class QLowEnergyCharacteristicData;
class QBluetoothAddress;
class QBluetoothUuid;
-namespace OSXBluetooth {
-
-struct NSObjectDeleter {
- static void cleanup(NSObject *obj)
- {
- [obj release];
- }
-};
+namespace DarwinBluetooth {
template<class T>
-class ObjCScopedPointer : public QScopedPointer<NSObject, NSObjectDeleter>
+class ObjCScopedPointer
{
public:
- // TODO: remove default argument, add 'retain' parameter,
- // add a default ctor??? This will make the semantics more
- // transparent + will simplify the future transition to ARC
- // (if it will ever happen).
- explicit ObjCScopedPointer(T *ptr = nullptr) : QScopedPointer(ptr){}
- operator T*() const
- {
- return data();
- }
-
- T *data()const
+ ObjCScopedPointer() = default;
+ ObjCScopedPointer(T *ptr, RetainPolicy policy)
+ : m_ptr(ptr, policy)
{
- return static_cast<T *>(QScopedPointer::data());
}
-
- T *take()
- {
- return static_cast<T *>(QScopedPointer::take());
- }
-};
-
-#define QT_BT_MAC_AUTORELEASEPOOL const QMacAutoReleasePool pool;
-
-template<class T>
-class ObjCStrongReference {
-public:
- ObjCStrongReference()
- : m_ptr(nil)
+ void swap(ObjCScopedPointer &other)
{
+ m_ptr.swap(other.m_ptr);
}
- ObjCStrongReference(T *obj, bool retain)
+ void reset()
{
- if (retain)
- m_ptr = [obj retain];
- else
- m_ptr = obj; // For example, created with initWithXXXX.
+ m_ptr.reset();
}
- ObjCStrongReference(const ObjCStrongReference &rhs)
+ void reset(T *ptr, RetainPolicy policy)
{
- m_ptr = [rhs.m_ptr retain];
+ m_ptr.reset(ptr, policy);
}
- ObjCStrongReference &operator = (const ObjCStrongReference &rhs)
- {
- // "Old-style" implementation:
- if (this != &rhs && m_ptr != rhs.m_ptr) {
- [m_ptr release];
- m_ptr = [rhs.m_ptr retain];
- }
-
- return *this;
- }
-
-#ifdef Q_COMPILER_RVALUE_REFS
- ObjCStrongReference(ObjCStrongReference &&xval)
- {
- m_ptr = xval.m_ptr;
- xval.m_ptr = nil;
- }
-
- ObjCStrongReference &operator = (ObjCStrongReference &&xval)
- {
- m_ptr = xval.m_ptr;
- xval.m_ptr = nil;
- return *this;
- }
-#endif
-
- ~ObjCStrongReference()
- {
- [m_ptr release];
- }
-
- void reset(T *newVal)
- {
- if (m_ptr != newVal) {
- [m_ptr release];
- m_ptr = [newVal retain];
- }
- }
-
- void resetWithoutRetain(T *newVal)
- {
- if (m_ptr != newVal) {
- [m_ptr release];
- m_ptr = newVal;
- }
- }
-
- operator T *() const
- {
- return m_ptr;
- }
-
- T *data() const
+ operator T*() const
{
- return m_ptr;
+ return m_ptr.getAs<T>();
}
-
- T *take()
+ T *get() const
{
- T * p = m_ptr;
- m_ptr = nil;
- return p;
+ // operator T * above does not work when accessing
+ // properties using '.' syntax.
+ return m_ptr.getAs<T>();
}
private:
- T *m_ptr;
+ // Copy and move disabled by m_ptr:
+ ScopedPointer m_ptr;
};
-// The type 'T' is some XXXRef from CoreFoundation and co.
-// In principle, we can do a trick removing a pointer from a type
-// when template is instantiated, but it's quite a lot of ugly pp-tokens
-// like OSXBluetooth::CFStrongReference<OSXBluetooth::remove_pointer<CFUUIDRref> > strongReference;
-// so instead we use 'T' everywhere, not 'T *' as can expected
-// from a smart pointer.
+#define QT_BT_MAC_AUTORELEASEPOOL const QMacAutoReleasePool pool;
+
template<class T>
-class CFStrongReference {
+class ObjCStrongReference final : public StrongReference {
public:
- CFStrongReference()
- : m_ptr(nullptr)
- {
- }
-
- CFStrongReference(T obj, bool retain)
- : m_ptr(obj)
- {
- if (m_ptr && retain)
- CFRetain(m_ptr);
- }
-
- CFStrongReference(const CFStrongReference &rhs)
- {
- if ((m_ptr = rhs.m_ptr))
- CFRetain(m_ptr);
- }
-
- CFStrongReference &operator = (const CFStrongReference &rhs)
- {
- // "Old-style" implementation:
- if (this != &rhs && m_ptr != rhs.m_ptr) {
- if (m_ptr)
- CFRelease(m_ptr);
- if ((m_ptr = rhs.m_ptr))
- CFRetain(m_ptr);
- }
-
- return *this;
- }
-
-#ifdef Q_COMPILER_RVALUE_REFS
- CFStrongReference(CFStrongReference &&xval)
- {
- m_ptr = xval.m_ptr;
- xval.m_ptr = nullptr;
- }
-
- CFStrongReference &operator = (CFStrongReference &&xval)
- {
- m_ptr = xval.m_ptr;
- xval.m_ptr = nullptr;
- return *this;
- }
-#endif
-
- ~CFStrongReference()
- {
- if (m_ptr)
- CFRelease(m_ptr);
- }
+ using StrongReference::StrongReference;
- void reset(T newVal)
- {
- if (m_ptr != newVal) {
- if (m_ptr)
- CFRelease(m_ptr);
- if ((m_ptr = newVal))
- CFRetain(m_ptr);
- }
- }
-
- operator T() const
- {
- return m_ptr;
- }
-
- T data() const
+ operator T *() const
{
- return m_ptr;
+ return this->getAs<T>();
}
- T take()
+ T *data() const
{
- T p = m_ptr;
- m_ptr = nullptr;
- return p;
+ return this->getAs<T>();
}
-private:
- T m_ptr;
};
QString qt_address(NSString *address);
@@ -292,7 +143,6 @@ void qt_test_iobluetooth_runloop();
#endif // !QT_IOS_BLUETOOTH
QBluetoothUuid qt_uuid(CBUUID *uuid);
-CFStrongReference<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid);
ObjCStrongReference<CBUUID> cb_uuid(const QBluetoothUuid &qtUuid);
bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid);
bool equal_uuids(CBUUID *cbUuid, const QBluetoothUuid &qtUuid);
@@ -307,10 +157,9 @@ dispatch_queue_t qt_LE_queue();
extern const int defaultLEScanTimeoutMS;
extern const int maxValueLength;
-} // namespace OSXBluetooth
+} // namespace DarwinBluetooth
-// Logging category for both OS X and iOS.
-Q_DECLARE_LOGGING_CATEGORY(QT_BT_OSX)
+Q_DECLARE_LOGGING_CATEGORY(QT_BT_DARWIN)
QT_END_NAMESPACE
@@ -331,6 +180,6 @@ QT_END_NAMESPACE
@property (readonly, nonatomic) NSUUID *identifier NS_AVAILABLE(10_7, 5_0);
@end
-#endif
+#endif // QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE
-#endif
+#endif // BTUTILITY_P_H
diff --git a/src/bluetooth/darwin/darwinbt.pri b/src/bluetooth/darwin/darwinbt.pri
new file mode 100644
index 00000000..b419007a
--- /dev/null
+++ b/src/bluetooth/darwin/darwinbt.pri
@@ -0,0 +1,48 @@
+SOURCES += darwin/uistrings.cpp \
+ darwin/btnotifier.cpp \
+ darwin/btdelegates.cpp \
+ darwin/btledeviceinquiry.mm \
+ darwin/btcentralmanager.mm
+
+HEADERS += darwin/uistrings_p.h \
+ darwin/btgcdtimer_p.h \
+ darwin/btraii_p.h \
+ darwin/btdelegates_p.h \
+ darwin/btutility_p.h \
+ darwin/btledeviceinquiry_p.h \
+ darwin/btcentralmanager_p.h \
+ darwin/btnotifier_p.h
+
+OBJECTIVE_SOURCES += darwin/btgcdtimer.mm \
+ darwin/btraii.mm \
+ darwin/btutility.mm
+
+#QMAKE_CXXFLAGS_WARN_ON += -Wno-nullability-completeness
+
+macos {
+ HEADERS += darwin/btdevicepair_p.h \
+ darwin/btdeviceinquiry_p.h \
+ darwin/btconnectionmonitor_p.h \
+ darwin/btsdpinquiry_p.h \
+ darwin/btrfcommchannel_p.h \
+ darwin/btl2capchannel_p.h \
+ darwin/btservicerecord_p.h \
+ darwin/btsocketlistener_p.h \
+ darwin/btobexsession_p.h
+
+ OBJECTIVE_SOURCES += darwin/btdevicepair.mm \
+ darwin/btdeviceinquiry.mm \
+ darwin/btconnectionmonitor.mm \
+ darwin/btsdpinquiry.mm \
+ darwin/btrfcommchannel.mm \
+ darwin/btl2capchannel.mm \
+ darwin/btservicerecord.mm \
+ darwin/btsocketlistener.mm \
+ darwin/btobexsession.mm
+}
+
+macos | ios {
+ HEADERS += darwin/btperipheralmanager_p.h
+
+ OBJECTIVE_SOURCES += darwin/btperipheralmanager.mm
+}
diff --git a/src/bluetooth/osx/uistrings.cpp b/src/bluetooth/darwin/uistrings.cpp
index 7260417f..7260417f 100644
--- a/src/bluetooth/osx/uistrings.cpp
+++ b/src/bluetooth/darwin/uistrings.cpp
diff --git a/src/bluetooth/osx/uistrings_p.h b/src/bluetooth/darwin/uistrings_p.h
index 999a8c6d..999a8c6d 100644
--- a/src/bluetooth/osx/uistrings_p.h
+++ b/src/bluetooth/darwin/uistrings_p.h
diff --git a/src/bluetooth/lecmaccalculator.cpp b/src/bluetooth/lecmaccalculator.cpp
index b150466e..475e46a8 100644
--- a/src/bluetooth/lecmaccalculator.cpp
+++ b/src/bluetooth/lecmaccalculator.cpp
@@ -169,7 +169,7 @@ bool LeCmacCalculator::verify(const QByteArray &message, const quint128 &csrk,
#ifdef CONFIG_LINUX_CRYPTO_API
const quint64 actualMac = calculateMac(message, csrk);
if (actualMac != expectedMac) {
- qCWarning(QT_BT_BLUEZ) << hex << "signature verification failed: calculated mac:"
+ qCWarning(QT_BT_BLUEZ) << Qt::hex << "signature verification failed: calculated mac:"
<< actualMac << "expected mac:" << expectedMac;
return false;
}
diff --git a/src/bluetooth/osx/osxbtconnectionmonitor_p.h b/src/bluetooth/osx/osxbtconnectionmonitor_p.h
deleted file mode 100644
index 679f6124..00000000
--- a/src/bluetooth/osx/osxbtconnectionmonitor_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef OSXBTCONNECTIONMONITOR_P_H
-#define OSXBTCONNECTIONMONITOR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qbluetoothaddress.h"
-#include "osxbluetooth_p.h"
-
-#include <QtCore/qglobal.h>
-
-#include <Foundation/Foundation.h>
-
-@class QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor);
-
-QT_BEGIN_NAMESPACE
-
-namespace OSXBluetooth {
-
-class ConnectionMonitor {
-public:
- typedef QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor) ObjCConnectionMonitor;
-
- virtual ~ConnectionMonitor();
-
- virtual void deviceConnected(const QBluetoothAddress &address) = 0;
- virtual void deviceDisconnected(const QBluetoothAddress &address) = 0;
-};
-
-}
-
-QT_END_NAMESPACE
-
-@interface QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor) : NSObject
-
-- (id)initWithMonitor:(QT_PREPEND_NAMESPACE(OSXBluetooth::ConnectionMonitor) *)monitor;
-- (void)connectionNotification:(id)notification withDevice:(IOBluetoothDevice *)device;
-- (void)connectionClosedNotification:(id)notification withDevice:(IOBluetoothDevice *)device;
-
-@end
-
-#endif
diff --git a/src/bluetooth/osx/osxbtnotifier.cpp b/src/bluetooth/osx/osxbtnotifier.cpp
deleted file mode 100644
index 0e0343cf..00000000
--- a/src/bluetooth/osx/osxbtnotifier.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "osxbtnotifier_p.h"
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm
index d9883d28..9053e564 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm
@@ -40,21 +40,24 @@
#include "qbluetoothdevicediscoveryagent_p.h"
#include "qbluetoothdevicediscoveryagent.h"
-#include "osx/osxbtledeviceinquiry_p.h"
+#include "darwin/btledeviceinquiry_p.h"
+
#ifdef Q_OS_MACOS
-#include "osx/osxbtdeviceinquiry_p.h"
-#include "osx/osxbtsdpinquiry_p.h"
+#include "darwin/btdeviceinquiry_p.h"
+#include "darwin/btsdpinquiry_p.h"
+
+#include <IOBluetooth/IOBluetooth.h>
#endif // Q_OS_MACOS
+
#include "qbluetoothdeviceinfo.h"
-#include "osx/osxbtnotifier_p.h"
-#include "osx/osxbtutility_p.h"
-#include "osx/osxbluetooth_p.h"
-#include "osx/uistrings_p.h"
+#include "darwin/btnotifier_p.h"
+#include "darwin/btutility_p.h"
+#include "darwin/uistrings_p.h"
#include "qbluetoothhostinfo.h"
+#include "darwin/uistrings_p.h"
#include "qbluetoothaddress.h"
-#include "osx/uistrings_p.h"
+#include "darwin/btraii_p.h"
#include "qbluetoothuuid.h"
-#include "osx/btraii_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qscopedpointer.h>
@@ -65,6 +68,8 @@
#include <Foundation/Foundation.h>
+#include <CoreBluetooth/CoreBluetooth.h>
+
QT_BEGIN_NAMESPACE
namespace
@@ -80,10 +85,10 @@ void registerQDeviceDiscoveryMetaType()
}
}
#ifdef Q_OS_MACOS
-using InquiryObjC = QT_MANGLE_NAMESPACE(OSXBTDeviceInquiry);
+using InquiryObjC = QT_MANGLE_NAMESPACE(DarwinBTClassicDeviceInquiry);
#endif // Q_OS_MACOS
-using LEInquiryObjC = QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry);
+using LEInquiryObjC = QT_MANGLE_NAMESPACE(DarwinBTLEDeviceInquiry);
} //namespace
@@ -95,7 +100,7 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(con
adapterAddress(adapter),
startPending(false),
stopPending(false),
- lowEnergySearchTimeout(OSXBluetooth::defaultLEScanTimeoutMS),
+ lowEnergySearchTimeout(DarwinBluetooth::defaultLEScanTimeoutMS),
#ifdef Q_OS_MACOS
requestedMethods(QBluetoothDeviceDiscoveryAgent::ClassicMethod | QBluetoothDeviceDiscoveryAgent::LowEnergyMethod),
#else
@@ -110,7 +115,7 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(con
#ifdef Q_OS_MACOS
IOBluetoothHostController *hostController = [IOBluetoothHostController defaultController];
if (!hostController || [hostController powerState] != kBluetoothHCIPowerStateON) {
- qCCritical(QT_BT_OSX) << "no default host controller or adapter is off";
+ qCCritical(QT_BT_DARWIN) << "no default host controller or adapter is off";
return;
}
controller.reset(hostController, DarwinBluetooth::RetainPolicy::doInitialRetain);
@@ -121,7 +126,7 @@ QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate()
{
if (inquiryLE && agentState != NonActive) {
// We want the LE scan to stop as soon as possible.
- if (dispatch_queue_t leQueue = OSXBluetooth::qt_LE_queue()) {
+ if (dispatch_queue_t leQueue = DarwinBluetooth::qt_LE_queue()) {
// Local variable to be retained ...
LEInquiryObjC *inq = inquiryLE.getAs<LEInquiryObjC>();
dispatch_sync(leQueue, ^{
@@ -187,7 +192,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startClassic()
Q_ASSERT(requestedMethods & QBluetoothDeviceDiscoveryAgent::ClassicMethod);
Q_ASSERT(agentState == NonActive);
- OSXBluetooth::qt_test_iobluetooth_runloop();
+ DarwinBluetooth::qt_test_iobluetooth_runloop();
if (!inquiry) {
// The first Classic scan for this DDA.
@@ -195,7 +200,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startClassic()
DarwinBluetooth::RetainPolicy::noInitialRetain);
if (!inquiry) {
- qCCritical(QT_BT_OSX) << "failed to initialize an Classic device inquiry";
+ qCCritical(QT_BT_DARWIN) << "failed to initialize an Classic device inquiry";
setError(QBluetoothDeviceDiscoveryAgent::UnknownError,
QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STARTED));
emit q_ptr->error(lastError);
@@ -220,7 +225,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startLE()
Q_ASSERT(lastError != QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError);
Q_ASSERT(requestedMethods & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QScopedPointer<LECBManagerNotifier> notifier(new LECBManagerNotifier);
// Connections:
@@ -265,7 +270,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::stop()
Q_ASSERT_X(lastError != QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError,
Q_FUNC_INFO, "called with invalid bluetooth adapter");
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
const bool prevStart = startPending;
startPending = false;
@@ -277,7 +282,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::stop()
if (agentState == ClassicScan) {
const IOReturn res = [inquiry.getAs<InquiryObjC>() stop];
if (res != kIOReturnSuccess) {
- qCWarning(QT_BT_OSX) << "failed to stop";
+ qCWarning(QT_BT_DARWIN) << "failed to stop";
startPending = prevStart;
stopPending = false;
setError(res, QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STOPPED));
@@ -350,9 +355,9 @@ void QBluetoothDeviceDiscoveryAgentPrivate::classicDeviceFound(void *obj)
QT_BT_MAC_AUTORELEASEPOOL;
// Let's collect some info about this device:
- const QBluetoothAddress deviceAddress(OSXBluetooth::qt_address([device getAddress]));
+ const QBluetoothAddress deviceAddress(DarwinBluetooth::qt_address([device getAddress]));
if (deviceAddress.isNull()) {
- qCWarning(QT_BT_OSX) << "invalid Bluetooth address";
+ qCWarning(QT_BT_DARWIN) << "invalid Bluetooth address";
return;
}
@@ -366,7 +371,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::classicDeviceFound(void *obj)
deviceInfo.setCoreConfigurations(QBluetoothDeviceInfo::BaseRateCoreConfiguration);
deviceInfo.setRssi(device.RSSI);
- const QVector<QBluetoothUuid> uuids(OSXBluetooth::extract_services_uuids(device));
+ const QVector<QBluetoothUuid> uuids(DarwinBluetooth::extract_services_uuids(device));
deviceInfo.setServiceUuids(uuids);
deviceFound(deviceInfo);
@@ -430,7 +435,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::LEinquiryError(QBluetoothDeviceDisco
void QBluetoothDeviceDiscoveryAgentPrivate::LEnotSupported()
{
- qCDebug(QT_BT_OSX) << "no Bluetooth LE support";
+ qCDebug(QT_BT_DARWIN) << "no Bluetooth LE support";
#ifdef Q_OS_MACOS
if (requestedMethods & QBluetoothDeviceDiscoveryAgent::ClassicMethod) {
@@ -486,14 +491,14 @@ void QBluetoothDeviceDiscoveryAgentPrivate::deviceFound(const QBluetoothDeviceIn
if (discoveredDevices[i].deviceUuid() == newDeviceInfo.deviceUuid()) {
QBluetoothDeviceInfo::Fields updatedFields = QBluetoothDeviceInfo::Field::None;
if (discoveredDevices[i].rssi() != newDeviceInfo.rssi()) {
- qCDebug(QT_BT_OSX) << "Updating RSSI for" << newDeviceInfo.address()
- << newDeviceInfo.rssi();
+ qCDebug(QT_BT_DARWIN) << "Updating RSSI for" << newDeviceInfo.address()
+ << newDeviceInfo.rssi();
discoveredDevices[i].setRssi(newDeviceInfo.rssi());
updatedFields.setFlag(QBluetoothDeviceInfo::Field::RSSI);
}
if (discoveredDevices[i].manufacturerData() != newDeviceInfo.manufacturerData()) {
- qCDebug(QT_BT_OSX) << "Updating manufacturer data for" << newDeviceInfo.address();
+ qCDebug(QT_BT_DARWIN) << "Updating manufacturer data for" << newDeviceInfo.address();
const QVector<quint16> keys = newDeviceInfo.manufacturerIds();
for (auto key: keys)
discoveredDevices[i].setManufacturerData(key, newDeviceInfo.manufacturerData(key));
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
index c9a35c3d..0bff7138 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
@@ -60,8 +60,8 @@
#endif
#ifdef Q_OS_DARWIN
-#include "osx/btdelegates_p.h"
-#include "osx/btraii_p.h"
+#include "darwin/btdelegates_p.h"
+#include "darwin/btraii_p.h"
#endif // Q_OS_DARWIN
#include <QtCore/QVariantMap>
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
index 159428d4..a2bfdeb6 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
@@ -541,11 +541,11 @@ void QBluetoothDeviceDiscoveryAgentPrivate::processDiscoveredDevice(
} else {
qCDebug(QT_BT_WINDOWS) << "Updating device:" << deviceIt->name() << deviceIt->address();
// merge service uuids
- QList<QBluetoothUuid> uuids = deviceIt->serviceUuids();
+ QVector<QBluetoothUuid> uuids = deviceIt->serviceUuids();
uuids.append(foundDevice.serviceUuids());
- const QSet<QBluetoothUuid> uuidSet = uuids.toSet();
+ const QSet<QBluetoothUuid> uuidSet(uuids.begin(), uuids.end());
if (deviceIt->serviceUuids().count() != uuidSet.count())
- deviceIt->setServiceUuids(uuidSet.toList().toVector());
+ deviceIt->setServiceUuids(uuidSet.values().toVector());
if (deviceIt->coreConfigurations() != foundDevice.coreConfigurations())
deviceIt->setCoreConfigurations(
QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration);
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index 2562395a..01b67921 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -886,7 +886,11 @@ void QBluetoothDeviceDiscoveryAgentPrivate::registerDevice(const QBluetoothDevic
if (iter->address() == info.address()) {
qCDebug(QT_BT_WINRT) << "Updating device" << iter->name() << iter->address();
// merge service uuids
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QVector<QBluetoothUuid> uuids = iter->serviceUuids();
+#else
QList<QBluetoothUuid> uuids = iter->serviceUuids();
+#endif
uuids.append(info.serviceUuids());
const QSet<QBluetoothUuid> uuidSet(uuids.begin(), uuids.end());
if (iter->serviceUuids().count() != uuidSet.count())
diff --git a/src/bluetooth/qbluetoothlocaldevice_osx.mm b/src/bluetooth/qbluetoothlocaldevice_macos.mm
index e7dd9906..ec2accce 100644
--- a/src/bluetooth/qbluetoothlocaldevice_osx.mm
+++ b/src/bluetooth/qbluetoothlocaldevice_macos.mm
@@ -37,12 +37,12 @@
**
****************************************************************************/
-#include "osx/osxbtconnectionmonitor_p.h"
+#include "darwin/btconnectionmonitor_p.h"
#include "qbluetoothlocaldevice_p.h"
#include "qbluetoothlocaldevice.h"
-#include "osx/osxbtdevicepair_p.h"
-#include "osx/osxbtutility_p.h"
-#include "osx/osxbluetooth_p.h"
+#include "darwin/btdevicepair_p.h"
+#include "darwin/btdelegates_p.h"
+#include "darwin/btutility_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qstring.h>
@@ -53,12 +53,14 @@
#include <Foundation/Foundation.h>
+#include <IOBluetooth/IOBluetooth.h>
+
#include <algorithm>
QT_BEGIN_NAMESPACE
-class QBluetoothLocalDevicePrivate : public OSXBluetooth::PairingDelegate,
- public OSXBluetooth::ConnectionMonitor
+class QBluetoothLocalDevicePrivate : public DarwinBluetooth::PairingDelegate,
+ public DarwinBluetooth::ConnectionMonitor
{
friend class QBluetoothLocalDevice;
public:
@@ -74,14 +76,14 @@ public:
private:
// PairingDelegate:
- void connecting(ObjCPairingRequest *pair) override;
- void requestPIN(ObjCPairingRequest *pair) override;
- void requestUserConfirmation(ObjCPairingRequest *pair,
+ void connecting(void *pair) override;
+ void requestPIN(void *pair) override;
+ void requestUserConfirmation(void *pair,
BluetoothNumericValue) override;
- void passkeyNotification(ObjCPairingRequest *pair,
+ void passkeyNotification(void *pair,
BluetoothPasskey passkey) override;
- void error(ObjCPairingRequest *pair, IOReturn errorCode) override;
- void pairingFinished(ObjCPairingRequest *pair) override;
+ void error(void *pair, IOReturn errorCode) override;
+ void pairingFinished(void *pair) override;
// ConnectionMonitor
void deviceConnected(const QBluetoothAddress &deviceAddress) override;
@@ -94,15 +96,16 @@ private:
QBluetoothLocalDevice *q_ptr;
- typedef OSXBluetooth::ObjCScopedPointer<IOBluetoothHostController> HostController;
+ using HostController = DarwinBluetooth::ObjCScopedPointer<IOBluetoothHostController>;
HostController hostController;
- typedef OSXBluetooth::ObjCStrongReference<ObjCPairingRequest> PairingRequest;
- typedef QMap<QBluetoothAddress, PairingRequest> RequestMap;
+ using ObjCPairingRequest = QT_MANGLE_NAMESPACE(DarwinBTClassicPairing);
+ using PairingRequest = DarwinBluetooth::ObjCStrongReference<ObjCPairingRequest>;
+ using RequestMap = QMap<QBluetoothAddress, PairingRequest>;
RequestMap pairingRequests;
-
- OSXBluetooth::ObjCScopedPointer<ObjCConnectionMonitor> connectionMonitor;
+ using ObjCConnectionMonitor = QT_MANGLE_NAMESPACE(DarwinBTConnectionMonitor);
+ DarwinBluetooth::ObjCScopedPointer<ObjCConnectionMonitor> connectionMonitor;
QList<QBluetoothAddress> discoveredDevices;
};
@@ -116,40 +119,43 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice
QT_BT_MAC_AUTORELEASEPOOL;
- HostController defaultController([[IOBluetoothHostController defaultController] retain]);
+ using namespace DarwinBluetooth;
+
+ ObjCScopedPointer<IOBluetoothHostController> defaultController([IOBluetoothHostController defaultController],
+ RetainPolicy::doInitialRetain);
if (!defaultController) {
- qCCritical(QT_BT_OSX) << "failed to init a host controller object";
+ qCCritical(QT_BT_DARWIN) << "failed to init a host controller object";
return;
}
if (!address.isNull()) {
NSString *const hciAddress = [defaultController addressAsString];
if (!hciAddress) {
- qCCritical(QT_BT_OSX) << "failed to obtain an address";
+ qCCritical(QT_BT_DARWIN) << "failed to obtain an address";
return;
}
BluetoothDeviceAddress iobtAddress = {};
if (IOBluetoothNSStringToDeviceAddress(hciAddress, &iobtAddress) != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << "invalid local device's address";
+ qCCritical(QT_BT_DARWIN) << "invalid local device's address";
return;
}
- if (address != OSXBluetooth::qt_address(&iobtAddress)) {
- qCCritical(QT_BT_OSX) << "invalid local device's address";
+ if (address != DarwinBluetooth::qt_address(&iobtAddress)) {
+ qCCritical(QT_BT_DARWIN) << "invalid local device's address";
return;
}
}
- hostController.reset(defaultController.take());
-
+ defaultController.swap(hostController);
// This one is optional, if it fails to initialize, we do not care at all.
- connectionMonitor.reset([[ObjCConnectionMonitor alloc] initWithMonitor:this]);
+ connectionMonitor.reset([[ObjCConnectionMonitor alloc] initWithMonitor:this],
+ DarwinBluetooth::RetainPolicy::noInitialRetain);
}
bool QBluetoothLocalDevicePrivate::isValid() const
{
- return hostController.data();
+ return hostController;
}
void QBluetoothLocalDevicePrivate::requestPairing(const QBluetoothAddress &address, Pairing pairing)
@@ -157,8 +163,9 @@ void QBluetoothLocalDevicePrivate::requestPairing(const QBluetoothAddress &addre
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid local device");
Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO, "invalid device address");
- using OSXBluetooth::device_with_address;
- using OSXBluetooth::ObjCStrongReference;
+ using DarwinBluetooth::device_with_address;
+ using DarwinBluetooth::ObjCStrongReference;
+ using DarwinBluetooth::RetainPolicy;
// That's a really special case on OS X.
if (pairing == QBluetoothLocalDevice::Unpaired)
@@ -179,7 +186,7 @@ void QBluetoothLocalDevicePrivate::requestPairing(const QBluetoothAddress &addre
if ([device isPaired]) {
emitPairingFinished(address, pairing, true);
} else if ([pos.value() start] != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << "failed to start a new pairing request";
+ qCCritical(QT_BT_DARWIN) << "failed to start a new pairing request";
emitError(QBluetoothLocalDevice::PairingError, true);
}
return;
@@ -188,9 +195,10 @@ void QBluetoothLocalDevicePrivate::requestPairing(const QBluetoothAddress &addre
// That's a totally new request ('Paired', since we are here).
// Even if this device is paired (not by our local device), I still create a pairing request,
// it'll just finish with success (skipping any intermediate steps).
- PairingRequest newRequest([[ObjCPairingRequest alloc] initWithTarget:address delegate:this], false);
+ PairingRequest newRequest([[ObjCPairingRequest alloc] initWithTarget:address delegate:this],
+ RetainPolicy::noInitialRetain);
if (!newRequest) {
- qCCritical(QT_BT_OSX) << "failed to allocate a new pairing request";
+ qCCritical(QT_BT_DARWIN) << "failed to allocate a new pairing request";
emitError(QBluetoothLocalDevice::PairingError, true);
return;
}
@@ -199,7 +207,7 @@ void QBluetoothLocalDevicePrivate::requestPairing(const QBluetoothAddress &addre
const IOReturn result = [newRequest start];
if (result != kIOReturnSuccess) {
pairingRequests.erase(pos);
- qCCritical(QT_BT_OSX) << "failed to start a new pairing request";
+ qCCritical(QT_BT_DARWIN) << "failed to start a new pairing request";
emitError(QBluetoothLocalDevice::PairingError, true);
}
}
@@ -209,8 +217,8 @@ QBluetoothLocalDevice::Pairing QBluetoothLocalDevicePrivate::pairingStatus(const
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid local device");
Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO, "invalid address");
- using OSXBluetooth::device_with_address;
- using OSXBluetooth::ObjCStrongReference;
+ using DarwinBluetooth::device_with_address;
+ using DarwinBluetooth::ObjCStrongReference;
QT_BT_MAC_AUTORELEASEPOOL;
@@ -230,30 +238,33 @@ QBluetoothLocalDevice::Pairing QBluetoothLocalDevicePrivate::pairingStatus(const
return QBluetoothLocalDevice::Unpaired;
}
-void QBluetoothLocalDevicePrivate::connecting(ObjCPairingRequest *pair)
+void QBluetoothLocalDevicePrivate::connecting(void *pair)
{
+ // TODO: why unused and if cannot be used - remove?
Q_UNUSED(pair)
}
-void QBluetoothLocalDevicePrivate::requestPIN(ObjCPairingRequest *pair)
+void QBluetoothLocalDevicePrivate::requestPIN(void *pair)
{
+ // TODO: why unused and if cannot be used - remove?
Q_UNUSED(pair)
}
-void QBluetoothLocalDevicePrivate::requestUserConfirmation(ObjCPairingRequest *pair, BluetoothNumericValue intPin)
+void QBluetoothLocalDevicePrivate::requestUserConfirmation(void *pair, BluetoothNumericValue intPin)
{
+ // TODO: why unused and if cannot be used - remove?
Q_UNUSED(pair)
Q_UNUSED(intPin)
}
-void QBluetoothLocalDevicePrivate::passkeyNotification(ObjCPairingRequest *pair,
- BluetoothPasskey passkey)
+void QBluetoothLocalDevicePrivate::passkeyNotification(void *pair, BluetoothPasskey passkey)
{
+ // TODO: why unused and if cannot be used - remove?
Q_UNUSED(pair)
Q_UNUSED(passkey)
}
-void QBluetoothLocalDevicePrivate::error(ObjCPairingRequest *pair, IOReturn errorCode)
+void QBluetoothLocalDevicePrivate::error(void *pair, IOReturn errorCode)
{
Q_UNUSED(pair)
Q_UNUSED(errorCode)
@@ -261,8 +272,9 @@ void QBluetoothLocalDevicePrivate::error(ObjCPairingRequest *pair, IOReturn erro
emitError(QBluetoothLocalDevice::PairingError, false);
}
-void QBluetoothLocalDevicePrivate::pairingFinished(ObjCPairingRequest *pair)
+void QBluetoothLocalDevicePrivate::pairingFinished(void *generic)
{
+ auto pair = static_cast<ObjCPairingRequest *>(generic);
Q_ASSERT_X(pair, Q_FUNC_INFO, "invalid pairing request (nil)");
const QBluetoothAddress &deviceAddress = [pair targetAddress];
@@ -357,7 +369,7 @@ QString QBluetoothLocalDevice::name() const
if (isValid()) {
if (NSString *const nsn = [d_ptr->hostController nameAsString])
return QString::fromNSString(nsn);
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to obtain a name";
+ qCCritical(QT_BT_DARWIN) << Q_FUNC_INFO << "failed to obtain a name";
}
return QString();
@@ -369,11 +381,11 @@ QBluetoothAddress QBluetoothLocalDevice::address() const
if (isValid()) {
if (NSString *const nsa = [d_ptr->hostController addressAsString])
- return QBluetoothAddress(OSXBluetooth::qt_address(nsa));
+ return QBluetoothAddress(DarwinBluetooth::qt_address(nsa));
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to obtain an address";
+ qCCritical(QT_BT_DARWIN) << Q_FUNC_INFO << "failed to obtain an address";
} else {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+ qCWarning(QT_BT_DARWIN) << Q_FUNC_INFO << "invalid local device";
}
return QBluetoothAddress();
@@ -382,7 +394,7 @@ QBluetoothAddress QBluetoothLocalDevice::address() const
void QBluetoothLocalDevice::powerOn()
{
if (!isValid())
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+ qCWarning(QT_BT_DARWIN) << Q_FUNC_INFO << "invalid local device";
}
void QBluetoothLocalDevice::setHostMode(QBluetoothLocalDevice::HostMode mode)
@@ -390,7 +402,7 @@ void QBluetoothLocalDevice::setHostMode(QBluetoothLocalDevice::HostMode mode)
Q_UNUSED(mode)
if (!isValid())
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+ qCWarning(QT_BT_DARWIN) << Q_FUNC_INFO << "invalid local device";
}
QBluetoothLocalDevice::HostMode QBluetoothLocalDevice::hostMode() const
@@ -411,7 +423,7 @@ QList<QBluetoothAddress> QBluetoothLocalDevice::connectedDevices() const
NSArray *const pairedDevices = [IOBluetoothDevice pairedDevices];
for (IOBluetoothDevice *device in pairedDevices) {
if ([device isConnected]) {
- const QBluetoothAddress address(OSXBluetooth::qt_address([device getAddress]));
+ const QBluetoothAddress address(DarwinBluetooth::qt_address([device getAddress]));
if (!address.isNull())
connectedDevices.append(address);
}
@@ -435,7 +447,7 @@ QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices()
QBluetoothLocalDevice defaultAdapter;
if (!defaultAdapter.isValid() || defaultAdapter.address().isNull()) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO <<"no valid device found";
+ qCCritical(QT_BT_DARWIN) << Q_FUNC_INFO <<"no valid device found";
return localDevices;
}
@@ -457,14 +469,14 @@ void QBluetoothLocalDevice::pairingConfirmation(bool confirmation)
void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pairing pairing)
{
if (!isValid())
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+ qCWarning(QT_BT_DARWIN) << Q_FUNC_INFO << "invalid local device";
if (!isValid() || address.isNull()) {
d_ptr->emitError(PairingError, true);
return;
}
- OSXBluetooth::qt_test_iobluetooth_runloop();
+ DarwinBluetooth::qt_test_iobluetooth_runloop();
return d_ptr->requestPairing(address, pairing);
}
@@ -472,7 +484,7 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai
QBluetoothLocalDevice::Pairing QBluetoothLocalDevice::pairingStatus(const QBluetoothAddress &address) const
{
if (!isValid())
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+ qCWarning(QT_BT_DARWIN) << Q_FUNC_INFO << "invalid local device";
if (!isValid() || address.isNull())
return Unpaired;
diff --git a/src/bluetooth/qbluetoothserver_osx.mm b/src/bluetooth/qbluetoothserver_macos.mm
index 83d7e060..4c0210c8 100644
--- a/src/bluetooth/qbluetoothserver_osx.mm
+++ b/src/bluetooth/qbluetoothserver_macos.mm
@@ -37,18 +37,17 @@
**
****************************************************************************/
-#include "osx/osxbtsocketlistener_p.h"
+#include "darwin/btsocketlistener_p.h"
#include "qbluetoothserver_p.h"
// The order is important: a workround for
// a private header included by private header
// (incorrectly handled dependencies).
#include "qbluetoothsocketbase_p.h"
-#include "qbluetoothsocket_osx_p.h"
+#include "qbluetoothsocket_macos_p.h"
#include "qbluetoothlocaldevice.h"
-#include "osx/osxbtutility_p.h"
-#include "osx/osxbluetooth_p.h"
+#include "darwin/btutility_p.h"
#include "qbluetoothserver.h"
#include "qbluetoothsocket.h"
@@ -60,6 +59,8 @@
#include <Foundation/Foundation.h>
+#include <IOBluetooth/IOBluetooth.h>
+
#include <limits>
QT_BEGIN_NAMESPACE
@@ -68,7 +69,7 @@ namespace {
using DarwinBluetooth::RetainPolicy;
using ServiceInfo = QBluetoothServiceInfo;
-using ObjCListener = QT_MANGLE_NAMESPACE(OSXBTSocketListener);
+using ObjCListener = QT_MANGLE_NAMESPACE(DarwinBTSocketListener);
QMap<quint16, QBluetoothServerPrivate *> &busyPSMs()
{
@@ -84,7 +85,7 @@ QMap<quint16, QBluetoothServerPrivate *> &busyChannels()
typedef QMap<quint16, QBluetoothServerPrivate *>::iterator ServerMapIterator;
-}
+} // unnamed namespace
QBluetoothServerPrivate::QBluetoothServerPrivate(ServiceInfo::Protocol type,
@@ -98,7 +99,7 @@ QBluetoothServerPrivate::QBluetoothServerPrivate(ServiceInfo::Protocol type,
port(0)
{
if (serverType == ServiceInfo::UnknownProtocol)
- qCWarning(QT_BT_OSX) << "unknown protocol";
+ qCWarning(QT_BT_DARWIN) << "unknown protocol";
}
QBluetoothServerPrivate::~QBluetoothServerPrivate()
@@ -112,7 +113,7 @@ bool QBluetoothServerPrivate::startListener(quint16 realPort)
Q_ASSERT_X(realPort, Q_FUNC_INFO, "invalid port");
if (serverType == ServiceInfo::UnknownProtocol) {
- qCWarning(QT_BT_OSX) << "invalid protocol";
+ qCWarning(QT_BT_DARWIN) << "invalid protocol";
return false;
}
@@ -228,8 +229,8 @@ void QBluetoothServerPrivate::registerServer(QBluetoothServerPrivate *server, qu
Q_ASSERT_X(!psmIsBusy(port), Q_FUNC_INFO, "port is busy");
busyPSMs()[port] = server;
} else {
- qCWarning(QT_BT_OSX) << "can not register a server "
- "with unknown protocol type";
+ qCWarning(QT_BT_DARWIN) << "can not register a server "
+ "with unknown protocol type";
}
}
@@ -245,7 +246,7 @@ QBluetoothServerPrivate *QBluetoothServerPrivate::registeredServer(quint16 port,
if (it != busyPSMs().end())
return it.value();
} else {
- qCWarning(QT_BT_OSX) << "invalid protocol";
+ qCWarning(QT_BT_DARWIN) << "invalid protocol";
}
return nullptr;
@@ -262,17 +263,17 @@ void QBluetoothServerPrivate::unregisterServer(QBluetoothServerPrivate *server)
if (it != busyChannels().end()) {
busyChannels().erase(it);
} else {
- qCWarning(QT_BT_OSX) << "server is not registered";
+ qCWarning(QT_BT_DARWIN) << "server is not registered";
}
} else if (type == ServiceInfo::L2capProtocol) {
ServerMapIterator it = busyPSMs().find(port);
if (it != busyPSMs().end()) {
busyPSMs().erase(it);
} else {
- qCWarning(QT_BT_OSX) << "server is not registered";
+ qCWarning(QT_BT_DARWIN) << "server is not registered";
}
} else {
- qCWarning(QT_BT_OSX) << "invalid protocol";
+ qCWarning(QT_BT_DARWIN) << "invalid protocol";
}
}
@@ -288,18 +289,18 @@ void QBluetoothServer::close()
bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
{
- OSXBluetooth::qt_test_iobluetooth_runloop();
+ DarwinBluetooth::qt_test_iobluetooth_runloop();
if (d_ptr->listener) {
- qCWarning(QT_BT_OSX) << "already in listen mode, close server first";
+ qCWarning(QT_BT_DARWIN) << "already in listen mode, close server first";
return false;
}
const QBluetoothLocalDevice device(address);
if (!device.isValid()) {
- qCWarning(QT_BT_OSX) << "device does not support Bluetooth or"
- << address.toString()
- << "is not a valid local adapter";
+ qCWarning(QT_BT_DARWIN) << "device does not support Bluetooth or"
+ << address.toString()
+ << "is not a valid local adapter";
d_ptr->m_lastError = UnknownError;
emit error(UnknownError);
return false;
@@ -307,7 +308,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
const QBluetoothLocalDevice::HostMode hostMode = device.hostMode();
if (hostMode == QBluetoothLocalDevice::HostPoweredOff) {
- qCWarning(QT_BT_OSX) << "Bluetooth device is powered off";
+ qCWarning(QT_BT_DARWIN) << "Bluetooth device is powered off";
d_ptr->m_lastError = PoweredOffError;
emit error(PoweredOffError);
return false;
@@ -316,7 +317,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
const ServiceInfo::Protocol type = d_ptr->serverType;
if (type == ServiceInfo::UnknownProtocol) {
- qCWarning(QT_BT_OSX) << "invalid protocol";
+ qCWarning(QT_BT_DARWIN) << "invalid protocol";
d_ptr->m_lastError = UnsupportedProtocolError;
emit error(d_ptr->m_lastError);
return false;
@@ -330,14 +331,14 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
if (port) {
if (type == ServiceInfo::RfcommProtocol) {
if (d_ptr->channelIsBusy(port)) {
- qCWarning(QT_BT_OSX) << "server port:" << port
- << "already registered";
+ qCWarning(QT_BT_DARWIN) << "server port:" << port
+ << "already registered";
d_ptr->m_lastError = ServiceAlreadyRegisteredError;
}
} else {
if (d_ptr->psmIsBusy(port)) {
- qCWarning(QT_BT_OSX) << "server port:" << port
- << "already registered";
+ qCWarning(QT_BT_DARWIN) << "server port:" << port
+ << "already registered";
d_ptr->m_lastError = ServiceAlreadyRegisteredError;
}
}
@@ -352,7 +353,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
}
if (!port) {
- qCWarning(QT_BT_OSX) << "all ports are busy";
+ qCWarning(QT_BT_DARWIN) << "all ports are busy";
d_ptr->m_lastError = ServiceAlreadyRegisteredError;
emit error(d_ptr->m_lastError);
return false;
diff --git a/src/bluetooth/qbluetoothserver_p.h b/src/bluetooth/qbluetoothserver_p.h
index d14dc7b4..a82114ba 100644
--- a/src/bluetooth/qbluetoothserver_p.h
+++ b/src/bluetooth/qbluetoothserver_p.h
@@ -79,8 +79,8 @@ class ServerAcceptanceThread;
#ifdef QT_OSX_BLUETOOTH
-#include "osx/btdelegates_p.h"
-#include "osx/btraii_p.h"
+#include "darwin/btdelegates_p.h"
+#include "darwin/btraii_p.h"
#include <QtCore/qvector.h>
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index e76c2311..f50aa45b 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -308,7 +308,7 @@ QBluetoothAddress QBluetoothServiceDiscoveryAgent::remoteAddress() const
return QBluetoothAddress();
}
-namespace OSXBluetooth {
+namespace DarwinBluetooth {
void qt_test_iobluetooth_runloop();
@@ -327,7 +327,7 @@ void QBluetoothServiceDiscoveryAgent::start(DiscoveryMode mode)
Q_D(QBluetoothServiceDiscoveryAgent);
#ifdef QT_OSX_BLUETOOTH
// Make sure we are on the right thread/have a run loop:
- OSXBluetooth::qt_test_iobluetooth_runloop();
+ DarwinBluetooth::qt_test_iobluetooth_runloop();
#endif
if (d->discoveryState() == QBluetoothServiceDiscoveryAgentPrivate::Inactive
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothservicediscoveryagent_macos.mm
index d8decae1..f6bee6bf 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_macos.mm
@@ -41,11 +41,10 @@
#include "qbluetoothservicediscoveryagent.h"
#include "qbluetoothdevicediscoveryagent.h"
#include "qbluetoothlocaldevice.h"
-#include "osx/osxbtsdpinquiry_p.h"
+#include "darwin/btsdpinquiry_p.h"
#include "qbluetoothhostinfo.h"
-#include "osx/osxbtutility_p.h"
-#include "osx/osxbluetooth_p.h"
-#include "osx/uistrings_p.h"
+#include "darwin/btutility_p.h"
+#include "darwin/uistrings_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qscopedpointer.h>
@@ -56,12 +55,14 @@
#include <Foundation/Foundation.h>
+#include <IOBluetooth/IOBluetooth.h>
+
QT_BEGIN_NAMESPACE
namespace {
using DarwinBluetooth::RetainPolicy;
-using ObjCServiceInquiry = QT_MANGLE_NAMESPACE(OSXBTSDPInquiry);
+using ObjCServiceInquiry = QT_MANGLE_NAMESPACE(DarwinBTSDPInquiry);
}
@@ -153,7 +154,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryFinished(void *generic)
Q_ASSERT_X(discoveredDevices.size() >= 1, Q_FUNC_INFO, "invalid number of devices");
serviceInfo.setDevice(discoveredDevices.at(0));
- OSXBluetooth::extract_service_record(record, serviceInfo);
+ DarwinBluetooth::extract_service_record(record, serviceInfo);
if (!serviceInfo.isValid())
continue;
@@ -175,7 +176,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryError(void *device, IORet
{
Q_UNUSED(device)
- qCWarning(QT_BT_OSX) << "inquiry failed with IOKit code:" << int(errorCode);
+ qCWarning(QT_BT_DARWIN) << "inquiry failed with IOKit code:" << int(errorCode);
discoveredDevices.clear();
// TODO: find a better mapping from IOReturn to QBluetoothServiceDiscoveryAgent::Error.
@@ -194,7 +195,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(cons
QT_BT_MAC_AUTORELEASEPOOL;
- const BluetoothDeviceAddress iobtAddress = OSXBluetooth::iobluetooth_address(deviceAddress);
+ const BluetoothDeviceAddress iobtAddress = DarwinBluetooth::iobluetooth_address(deviceAddress);
IOBluetoothDevice *const device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
if (!device || !device.services) {
if (singleDevice) {
@@ -211,7 +212,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(cons
"invalid number of devices");
serviceInfo.setDevice(discoveredDevices.at(0));
- OSXBluetooth::extract_service_record(record, serviceInfo);
+ DarwinBluetooth::extract_service_record(record, serviceInfo);
if (!serviceInfo.isValid())
continue;
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_p.h b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
index 41410b70..d9b1e5f4 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_p.h
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
@@ -91,8 +91,8 @@ QT_END_NAMESPACE
#endif
#ifdef QT_OSX_BLUETOOTH
-#include "osx/btdelegates_p.h"
-#include "osx/btraii_p.h"
+#include "darwin/btdelegates_p.h"
+#include "darwin/btraii_p.h"
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp
index f1476758..69b6ac06 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp
@@ -285,33 +285,33 @@ void QWinRTBluetoothServiceDiscoveryWorker::processServiceSearchResult(quint64 a
hr = dataReader->ReadByte(&value);
Q_ASSERT_SUCCEEDED(hr);
info.setAttribute(key, value);
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type << "UINT8" << hex << value;
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT8" << Qt::hex << value;
} else if (type == TYPE_UINT16) {
quint16 value;
hr = dataReader->ReadUInt16(&value);
Q_ASSERT_SUCCEEDED(hr);
info.setAttribute(key, value);
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type << "UINT16" << hex << value;
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT16" << Qt::hex << value;
} else if (type == TYPE_UINT32) {
quint32 value;
hr = dataReader->ReadUInt32(&value);
Q_ASSERT_SUCCEEDED(hr);
info.setAttribute(key, value);
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type << "UINT32" << hex << value;
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT32" << Qt::hex << value;
} else if (type == TYPE_SHORT_UUID) {
quint16 value;
hr = dataReader->ReadUInt16(&value);
Q_ASSERT_SUCCEEDED(hr);
const QBluetoothUuid uuid(value);
info.setAttribute(key, uuid);
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type << "UUID" << hex << uuid;
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UUID" << Qt::hex << uuid;
} else if (type == TYPE_LONG_UUID) {
GUID value;
hr = dataReader->ReadGuid(&value);
Q_ASSERT_SUCCEEDED(hr);
const QBluetoothUuid uuid(value);
info.setAttribute(key, uuid);
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type << "UUID" << hex << uuid;
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UUID" << Qt::hex << uuid;
} else if (type == TYPE_STRING) {
BYTE length;
hr = dataReader->ReadByte(&length);
@@ -321,18 +321,18 @@ void QWinRTBluetoothServiceDiscoveryWorker::processServiceSearchResult(quint64 a
Q_ASSERT_SUCCEEDED(hr);
const QString str = QString::fromWCharArray(WindowsGetStringRawBuffer(value.Get(), nullptr));
info.setAttribute(key, str);
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type << "STRING" << str;
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "STRING" << str;
} else if (type == TYPE_SEQUENCE) {
bool ok;
QBluetoothServiceInfo::Sequence sequence = readSequence(dataReader, &ok, nullptr);
if (ok) {
info.setAttribute(key, sequence);
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type << "SEQUENCE" << sequence;
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "SEQUENCE" << sequence;
} else {
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type << "SEQUENCE ERROR";
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "SEQUENCE ERROR";
}
} else {
- qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << hex << key << "TYPE" << dec << type;
+ qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type;
}
hr = iterator->MoveNext(&current);
}
diff --git a/src/bluetooth/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_macos.mm
index 41e4e8b7..b73ae55f 100644
--- a/src/bluetooth/qbluetoothserviceinfo_osx.mm
+++ b/src/bluetooth/qbluetoothserviceinfo_macos.mm
@@ -37,13 +37,12 @@
**
****************************************************************************/
-#include "osx/osxbtservicerecord_p.h"
#include "qbluetoothserviceinfo_p.h"
+#include "darwin/btservicerecord_p.h"
#include "qbluetoothserviceinfo.h"
#include "qbluetoothdeviceinfo.h"
#include "qbluetoothserver_p.h"
-#include "osx/osxbtutility_p.h"
-#include "osx/osxbluetooth_p.h"
+#include "darwin/btutility_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qvariant.h>
@@ -54,6 +53,8 @@
#include <Foundation/Foundation.h>
+#include <IOBluetooth/IOBluetooth.h>
+
QT_BEGIN_NAMESPACE
namespace {
@@ -105,16 +106,16 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca
bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothServiceInfo &info)
{
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
if (isRegistered())
return false;
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
ObjCStrongReference<NSMutableDictionary> serviceDict(iobluetooth_service_dictionary(info));
if (!serviceDict) {
- qCWarning(QT_BT_OSX) << "failed to create a service dictionary";
+ qCWarning(QT_BT_DARWIN) << "failed to create a service dictionary";
return false;
}
@@ -125,14 +126,14 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothServiceInfo &
newRecord.reset([IOBluetoothSDPServiceRecord
publishedServiceRecordWithDictionary:serviceDict], RetainPolicy::doInitialRetain);
if (!newRecord) {
- qCWarning(QT_BT_OSX) << "failed to register a service record";
+ qCWarning(QT_BT_DARWIN) << "failed to register a service record";
return false;
}
BluetoothSDPServiceRecordHandle newRecordHandle = 0;
auto *ioSDPRecord = newRecord.getAs<IOBluetoothSDPServiceRecord>();
if ([ioSDPRecord getServiceRecordHandle:&newRecordHandle] != kIOReturnSuccess) {
- qCWarning(QT_BT_OSX) << "failed to register a service record";
+ qCWarning(QT_BT_DARWIN) << "failed to register a service record";
[ioSDPRecord removeServiceRecord];
return false;
}
@@ -160,7 +161,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothServiceInfo &
if (!configured) {
[ioSDPRecord removeServiceRecord];
- qCWarning(QT_BT_OSX) << "failed to register a service record";
+ qCWarning(QT_BT_DARWIN) << "failed to register a service record";
return false;
}
diff --git a/src/bluetooth/qbluetoothserviceinfo_p.h b/src/bluetooth/qbluetoothserviceinfo_p.h
index 3ed005e1..a51204c6 100644
--- a/src/bluetooth/qbluetoothserviceinfo_p.h
+++ b/src/bluetooth/qbluetoothserviceinfo_p.h
@@ -60,7 +60,7 @@
#include <QVariant>
#ifdef Q_OS_MACOS
-#include "osx/btraii_p.h"
+#include "darwin/btraii_p.h"
#endif
class OrgBluezServiceInterface;
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index e4d85447..972706bd 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -50,7 +50,7 @@
#elif defined(QT_WIN_BLUETOOTH)
#include "qbluetoothsocket_win_p.h"
#elif defined(QT_OSX_BLUETOOTH)
-#include "qbluetoothsocket_osx_p.h"
+#include "qbluetoothsocket_macos_p.h"
#else
#include "qbluetoothsocket_dummy_p.h"
#endif
diff --git a/src/bluetooth/qbluetoothsocket_osx.mm b/src/bluetooth/qbluetoothsocket_macos.mm
index 8af085ac..9c01d0dd 100644
--- a/src/bluetooth/qbluetoothsocket_osx.mm
+++ b/src/bluetooth/qbluetoothsocket_macos.mm
@@ -42,14 +42,14 @@
// the base class for a private socket) - workaround for
// dependencies problem.
#include "qbluetoothsocketbase_p.h"
-#include "qbluetoothsocket_osx_p.h"
+#include "qbluetoothsocket_macos_p.h"
-#include "osx/osxbtrfcommchannel_p.h"
-#include "osx/osxbtl2capchannel_p.h"
+#include "darwin/btrfcommchannel_p.h"
+#include "darwin/btl2capchannel_p.h"
#include "qbluetoothlocaldevice.h"
#include "qbluetoothdeviceinfo.h"
-#include "osx/osxbtutility_p.h"
-#include "osx/uistrings_p.h"
+#include "darwin/btutility_p.h"
+#include "darwin/uistrings_p.h"
#include "qbluetoothsocket.h"
#include <QtCore/qloggingcategory.h>
@@ -63,8 +63,8 @@ QT_BEGIN_NAMESPACE
namespace {
using DarwinBluetooth::RetainPolicy;
-using ObjCL2CAPChannel = QT_MANGLE_NAMESPACE(OSXBTL2CAPChannel);
-using ObjCRFCOMMChannel = QT_MANGLE_NAMESPACE(OSXBTRFCOMMChannel);
+using ObjCL2CAPChannel = QT_MANGLE_NAMESPACE(DarwinBTL2CAPChannel);
+using ObjCRFCOMMChannel = QT_MANGLE_NAMESPACE(DarwinBTRFCOMMChannel);
} // unnamed namespace
@@ -135,7 +135,7 @@ QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const
addr = [l2capChannel.getAs<ObjCL2CAPChannel>() peerAddress];
}
- return OSXBluetooth::qt_address(&addr);
+ return DarwinBluetooth::qt_address(&addr);
}
quint16 QBluetoothSocketPrivate::peerPort() const
@@ -244,7 +244,7 @@ bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoo
Q_UNUSED(socketState)
Q_UNUSED(openMode)
- qCWarning(QT_BT_OSX) << "setting a socket descriptor is not supported by IOBluetooth";
+ qCWarning(QT_BT_DARWIN) << "setting a socket descriptor is not supported by IOBluetooth";
// Noop on macOS.
return true;
}
@@ -261,10 +261,10 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothServiceInfo &serv
{
Q_ASSERT(q_ptr);
- OSXBluetooth::qt_test_iobluetooth_runloop();
+ DarwinBluetooth::qt_test_iobluetooth_runloop();
if (state!= QBluetoothSocket::UnconnectedState && state != QBluetoothSocket::ServiceLookupState) {
- qCWarning(QT_BT_OSX) << "called on a busy socket";
+ qCWarning(QT_BT_DARWIN) << "called on a busy socket";
errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS);
q_ptr->setSocketError(QBluetoothSocket::OperationError);
return;
@@ -272,7 +272,7 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothServiceInfo &serv
// Report this problem early, potentially avoid device discovery:
if (service.socketProtocol() == QBluetoothServiceInfo::UnknownProtocol) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
+ qCWarning(QT_BT_DARWIN) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
errorString = QCoreApplication::translate(SOCKET, SOC_NETWORK_ERROR);
q_ptr->setSocketError(QBluetoothSocket::UnsupportedProtocolError);
return;
@@ -291,8 +291,8 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothServiceInfo &serv
} else {
// Try service discovery.
if (service.serviceUuid().isNull()) {
- qCWarning(QT_BT_OSX) << "No port, no PSM, and no "
- "UUID provided, unable to connect";
+ qCWarning(QT_BT_DARWIN) << "No port, no PSM, and no "
+ "UUID provided, unable to connect";
return;
}
@@ -305,18 +305,18 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address,
{
Q_ASSERT(q_ptr);
- OSXBluetooth::qt_test_iobluetooth_runloop();
+ DarwinBluetooth::qt_test_iobluetooth_runloop();
// Report this problem early, avoid device discovery:
if (socketType == QBluetoothServiceInfo::UnknownProtocol) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
+ qCWarning(QT_BT_DARWIN) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
errorString = QCoreApplication::translate(SOCKET, SOC_NETWORK_ERROR);
q_ptr->setSocketError(QBluetoothSocket::UnsupportedProtocolError);
return;
}
if (state != QBluetoothSocket::UnconnectedState) {
- qCWarning(QT_BT_OSX) << "called on a busy socket";
+ qCWarning(QT_BT_DARWIN) << "called on a busy socket";
errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS);
q_ptr->setSocketError(QBluetoothSocket::OperationError);
return;
@@ -334,10 +334,10 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address,
{
Q_ASSERT(q_ptr);
- OSXBluetooth::qt_test_iobluetooth_runloop();
+ DarwinBluetooth::qt_test_iobluetooth_runloop();
if (socketType == QBluetoothServiceInfo::UnknownProtocol) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
+ qCWarning(QT_BT_DARWIN) << Q_FUNC_INFO << "cannot connect with 'UnknownProtocol' type";
errorString = QCoreApplication::translate(SOCKET, SOC_NETWORK_ERROR);
q_ptr->setSocketError(QBluetoothSocket::UnsupportedProtocolError);
return;
@@ -410,7 +410,7 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address,
} else {
state = oldState;
if (status != kIOReturnSuccess)
- errorString = OSXBluetooth::qt_error_string(status);
+ errorString = DarwinBluetooth::qt_error_string(status);
q_ptr->setSocketError(QBluetoothSocket::UnknownSocketError);
}
}
diff --git a/src/bluetooth/qbluetoothsocket_osx_p.h b/src/bluetooth/qbluetoothsocket_macos_p.h
index 1291878c..93cfbe4c 100644
--- a/src/bluetooth/qbluetoothsocket_osx_p.h
+++ b/src/bluetooth/qbluetoothsocket_macos_p.h
@@ -55,9 +55,9 @@
#include "qbluetoothsocketbase_p.h"
#include "qbluetoothserviceinfo.h"
-#include "osx/btdelegates_p.h"
+#include "darwin/btdelegates_p.h"
#include "qbluetoothsocket.h"
-#include "osx/btraii_p.h"
+#include "darwin/btraii_p.h"
#ifndef QPRIVATELINEARBUFFER_BUFFERSIZE
#define QPRIVATELINEARBUFFER_BUFFERSIZE Q_INT64_C(16384)
diff --git a/src/bluetooth/qbluetoothtransfermanager.cpp b/src/bluetooth/qbluetoothtransfermanager.cpp
index d84f726c..53798e55 100644
--- a/src/bluetooth/qbluetoothtransfermanager.cpp
+++ b/src/bluetooth/qbluetoothtransfermanager.cpp
@@ -43,7 +43,7 @@
#if QT_CONFIG(bluez)
#include "qbluetoothtransferreply_bluez_p.h"
#elif QT_OSX_BLUETOOTH
-#include "qbluetoothtransferreply_osx_p.h"
+#include "qbluetoothtransferreply_macos_p.h"
#else
#if !defined(QT_ANDROID_BLUETOOTH) && !defined(QT_IOS_BLUETOOTH)
#include "dummy/dummy_helper_p.h"
diff --git a/src/bluetooth/qbluetoothtransferreply_osx.mm b/src/bluetooth/qbluetoothtransferreply_macos.mm
index 40a747f8..d05396b9 100644
--- a/src/bluetooth/qbluetoothtransferreply_osx.mm
+++ b/src/bluetooth/qbluetoothtransferreply_macos.mm
@@ -38,11 +38,11 @@
****************************************************************************/
#include "qbluetoothservicediscoveryagent.h"
-#include "qbluetoothtransferreply_osx_p.h"
-#include "osx/osxbtobexsession_p.h"
+#include "qbluetoothtransferreply_macos_p.h"
+#include "darwin/btobexsession_p.h"
#include "qbluetoothserviceinfo.h"
-#include "osx/osxbtutility_p.h"
-#include "osx/uistrings_p.h"
+#include "darwin/btutility_p.h"
+#include "darwin/uistrings_p.h"
#include "qbluetoothuuid.h"
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-class QBluetoothTransferReplyOSXPrivate : OSXBluetooth::OBEXSessionDelegate
+class QBluetoothTransferReplyOSXPrivate : DarwinBluetooth::OBEXSessionDelegate
{
friend class QBluetoothTransferReplyOSX;
public:
@@ -104,7 +104,7 @@ private:
QScopedPointer<QBluetoothServiceDiscoveryAgent> agent;
// The next step is to create an OBEX session:
- typedef OSXBluetooth::ObjCScopedPointer<ObjCOBEXSession> OBEXSession;
+ typedef DarwinBluetooth::ObjCScopedPointer<ObjCOBEXSession> OBEXSession;
OBEXSession session;
// Both success and failure to send - transfer is complete.
@@ -136,13 +136,13 @@ QBluetoothTransferReplyOSXPrivate::~QBluetoothTransferReplyOSXPrivate()
// The OBEX session will be closed then. If
// somehow IOBluetooth/OBEX still has a reference to our
// session, it will not call any of delegate's callbacks.
- if (session.data())
+ if (session)
[session closeSession];
}
bool QBluetoothTransferReplyOSXPrivate::isActive() const
{
- return agent.data() || (session.data() && [session hasActiveRequest]);
+ return agent || (session && [session hasActiveRequest]);
}
bool QBluetoothTransferReplyOSXPrivate::startOPP(const QBluetoothAddress &device)
@@ -171,22 +171,25 @@ bool QBluetoothTransferReplyOSXPrivate::startOPP(const QBluetoothAddress &device
void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &device, quint16 channelID)
{
+ using namespace DarwinBluetooth;
+
Q_ASSERT_X(!session, Q_FUNC_INFO, "session is already active");
error = QBluetoothTransferReply::NoError;
errorString.clear();
if (device.isNull() || !channelID) {
- qCWarning(QT_BT_OSX) << "invalid device address or port";
+ qCWarning(QT_BT_DARWIN) << "invalid device address or port";
setReplyError(QBluetoothTransferReply::HostNotFoundError,
QCoreApplication::translate(TRANSFER_REPLY, TR_INVAL_TARGET));
return;
}
OBEXSession newSession([[ObjCOBEXSession alloc] initWithDelegate:this
- remoteDevice:device channelID:channelID]);
+ remoteDevice:device channelID:channelID],
+ RetainPolicy::noInitialRetain);
if (!newSession) {
- qCWarning(QT_BT_OSX) << "failed to allocate OSXBTOBEXSession object";
+ qCWarning(QT_BT_DARWIN) << "failed to allocate DarwinBTOBEXSession object";
setReplyError(QBluetoothTransferReply::UnknownError,
QCoreApplication::translate(TRANSFER_REPLY, TR_SESSION_NO_START));
@@ -197,11 +200,11 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev
if ((status == kOBEXSuccess || status == kOBEXSessionAlreadyConnectedError)
&& error == QBluetoothTransferReply::NoError) {
- session.reset(newSession.take());
+ session.swap(newSession);
if ([session isConnected])
sendPut();// Connected, send a PUT request.
} else {
- qCWarning(QT_BT_OSX) << "OBEXConnect failed";
+ qCWarning(QT_BT_DARWIN) << "OBEXConnect failed";
if (error == QBluetoothTransferReply::NoError) {
// The error is not set yet.
@@ -218,7 +221,7 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev
void QBluetoothTransferReplyOSXPrivate::sendPut()
{
Q_ASSERT_X(inputStream, Q_FUNC_INFO, "invalid input stream (null)");
- Q_ASSERT_X(session.data(), Q_FUNC_INFO, "invalid OBEX session (nil)");
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
Q_ASSERT_X([session isConnected], Q_FUNC_INFO, "not connected");
Q_ASSERT_X(![session hasActiveRequest], Q_FUNC_INFO,
"session already has an active request");
@@ -268,7 +271,7 @@ void QBluetoothTransferReplyOSXPrivate::OBEXConnectError(OBEXError errorCode, OB
Q_UNUSED(errorCode)
Q_UNUSED(response)
- if (session.data()) {
+ if (session) {
setReplyError(QBluetoothTransferReply::SessionError,
QCoreApplication::translate(TRANSFER_REPLY, TR_CONNECT_FAILED));
} else {
@@ -283,7 +286,7 @@ void QBluetoothTransferReplyOSXPrivate::OBEXConnectError(OBEXError errorCode, OB
void QBluetoothTransferReplyOSXPrivate::OBEXConnectSuccess()
{
// Now that OBEX connect succeeded, we can send an OBEX put request.
- if (!session.data()) {
+ if (!session) {
// We're still in OBEXConnect(), it'll take care of next steps.
return;
}
@@ -355,7 +358,7 @@ QBluetoothTransferReplyOSX::QBluetoothTransferReplyOSX(QIODevice *input,
if (input) {
QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection);
} else {
- qCWarning(QT_BT_OSX) << "invalid input stream (null)";
+ qCWarning(QT_BT_DARWIN) << "invalid input stream (null)";
osx_d_ptr->requestComplete = true;
osx_d_ptr->errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_INVALID_DEVICE);
osx_d_ptr->error = FileNotFoundError;
@@ -394,7 +397,7 @@ bool QBluetoothTransferReplyOSX::abort()
// Reset a delegate.
[osx_d_ptr->session closeSession];
// Should never be called from an OBEX callback!
- osx_d_ptr->session.reset(nullptr);
+ osx_d_ptr->session.reset();
// Not setReplyError, we emit finished only!
osx_d_ptr->requestComplete = true;
@@ -416,7 +419,7 @@ bool QBluetoothTransferReplyOSX::start()
if (!osx_d_ptr->isActive()) {
// Step 0: find a channelID.
if (request().address().isNull()) {
- qCWarning(QT_BT_OSX) << "invalid device address";
+ qCWarning(QT_BT_DARWIN) << "invalid device address";
osx_d_ptr->setReplyError(HostNotFoundError,
QCoreApplication::translate(TRANSFER_REPLY, TR_INVAL_TARGET));
return false;
diff --git a/src/bluetooth/qbluetoothtransferreply_osx_p.h b/src/bluetooth/qbluetoothtransferreply_macos_p.h
index e7b6f683..e7b6f683 100644
--- a/src/bluetooth/qbluetoothtransferreply_osx_p.h
+++ b/src/bluetooth/qbluetoothtransferreply_macos_p.h
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index dfa21004..13d70ef3 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -236,7 +236,7 @@ static void dumpErrorInformation(const QByteArray &response)
}
qCDebug(QT_BT_BLUEZ) << "Error1:" << errorString
- << "last command:" << hex << lastCommand
+ << "last command:" << Qt::hex << lastCommand
<< "handle:" << handle;
}
@@ -351,7 +351,7 @@ void QLowEnergyControllerPrivateBluez::handleGattRequestTimeout()
const Request currentRequest = openRequests.dequeue();
requestPending = false; // reset pending flag
- qCWarning(QT_BT_BLUEZ).nospace() << "****** Request type 0x" << hex << currentRequest.command
+ qCWarning(QT_BT_BLUEZ).nospace() << "****** Request type 0x" << Qt::hex << currentRequest.command
<< " to server/peripheral timed out";
qCWarning(QT_BT_BLUEZ) << "****** Looks like the characteristic or descriptor does NOT act in"
<< "accordance to Bluetooth 4.x spec.";
@@ -408,7 +408,7 @@ void QLowEnergyControllerPrivateBluez::handleGattRequestTimeout()
default:
// not a command used by central role implementation
qCWarning(QT_BT_BLUEZ) << "Missing response for ATT peripheral command: "
- << hex << command;
+ << Qt::hex << command;
break;
}
@@ -983,7 +983,7 @@ void QLowEnergyControllerPrivateBluez::sendPacket(const QByteArray &packet)
// This packet is effectively discarded but the controller can still recover
if (result == -1) {
- qCDebug(QT_BT_BLUEZ) << "Cannot write L2CP packet:" << hex
+ qCDebug(QT_BT_BLUEZ) << "Cannot write L2CP packet:" << Qt::hex
<< packet.toHex()
<< l2cpSocket->errorString();
setError(QLowEnergyController::NetworkError);
@@ -1000,7 +1000,7 @@ void QLowEnergyControllerPrivateBluez::sendNextPendingRequest()
return;
const Request &request = openRequests.head();
-// qCDebug(QT_BT_BLUEZ) << "Sending request, type:" << hex << request.command
+// qCDebug(QT_BT_BLUEZ) << "Sending request, type:" << Qt::hex << request.command
// << request.payload.toHex();
requestPending = true;
@@ -1025,7 +1025,7 @@ QLowEnergyHandle parseReadByTypeCharDiscovery(
else
charData->uuid = convert_uuid128((quint128 *)&data[5]);
- qCDebug(QT_BT_BLUEZ) << "Found handle:" << hex << attributeHandle
+ qCDebug(QT_BT_BLUEZ) << "Found handle:" << Qt::hex << attributeHandle
<< "properties:" << charData->properties
<< "value handle:" << charData->valueHandle
<< "uuid:" << charData->uuid.toString();
@@ -1053,7 +1053,7 @@ QLowEnergyHandle parseReadByTypeIncludeDiscovery(
else
foundServices->append(convert_uuid128((quint128 *) &data[6]));
- qCDebug(QT_BT_BLUEZ) << "Found included service: " << hex
+ qCDebug(QT_BT_BLUEZ) << "Found included service: " << Qt::hex
<< attributeHandle << "uuid:" << *foundServices;
return attributeHandle;
@@ -1130,7 +1130,7 @@ void QLowEnergyControllerPrivateBluez::processReply(
offset += elementLength;
- qCDebug(QT_BT_BLUEZ) << "Found uuid:" << uuid << "start handle:" << hex
+ qCDebug(QT_BT_BLUEZ) << "Found uuid:" << uuid << "start handle:" << Qt::hex
<< start << "end handle:" << end;
QLowEnergyServicePrivate *priv = new QLowEnergyServicePrivate();
@@ -1437,13 +1437,13 @@ void QLowEnergyControllerPrivateBluez::processReply(
quint16 shortUuid = uuid.toUInt16(&ok);
if (ok && shortUuid >= QLowEnergyServicePrivate::PrimaryService
&& shortUuid <= QLowEnergyServicePrivate::Characteristic){
- qCDebug(QT_BT_BLUEZ) << "Suppressing primary/characteristic" << hex << shortUuid;
+ qCDebug(QT_BT_BLUEZ) << "Suppressing primary/characteristic" << Qt::hex << shortUuid;
continue;
}
// ignore value handle
if (descriptorHandle == p->characteristicList[charHandle].valueHandle) {
- qCDebug(QT_BT_BLUEZ) << "Suppressing char handle" << hex << descriptorHandle;
+ qCDebug(QT_BT_BLUEZ) << "Suppressing char handle" << Qt::hex << descriptorHandle;
continue;
}
@@ -1454,7 +1454,7 @@ void QLowEnergyControllerPrivateBluez::processReply(
qCDebug(QT_BT_BLUEZ) << "Descriptor found, uuid:"
<< uuid.toString()
- << "descriptor handle:" << hex << descriptorHandle;
+ << "descriptor handle:" << Qt::hex << descriptorHandle;
}
const QLowEnergyHandle nextPotentialHandle = descriptorHandle + 1;
@@ -1615,7 +1615,7 @@ void QLowEnergyControllerPrivateBluez::sendReadByGroupRequest(
QByteArray data(GRP_TYPE_REQ_HEADER_SIZE, Qt::Uninitialized);
memcpy(data.data(), packet, GRP_TYPE_REQ_HEADER_SIZE);
- qCDebug(QT_BT_BLUEZ) << "Sending read_by_group_type request, startHandle:" << hex
+ qCDebug(QT_BT_BLUEZ) << "Sending read_by_group_type request, startHandle:" << Qt::hex
<< start << "endHandle:" << end << type;
Request request;
@@ -1653,7 +1653,7 @@ void QLowEnergyControllerPrivateBluez::sendReadByTypeRequest(
QByteArray data(READ_BY_TYPE_REQ_HEADER_SIZE, Qt::Uninitialized);
memcpy(data.data(), packet, READ_BY_TYPE_REQ_HEADER_SIZE);
- qCDebug(QT_BT_BLUEZ) << "Sending read_by_type request, startHandle:" << hex
+ qCDebug(QT_BT_BLUEZ) << "Sending read_by_type request, startHandle:" << Qt::hex
<< nextHandle << "endHandle:" << serviceData->endHandle
<< "type:" << attributeType << "packet:" << data.toHex();
@@ -1783,7 +1783,7 @@ void QLowEnergyControllerPrivateBluez::readServiceValuesByOffset(
if (descriptorHandle) {
handleToRead = descriptorHandle;
qCDebug(QT_BT_BLUEZ) << "Reading descriptor via blob request"
- << hex << descriptorHandle;
+ << Qt::hex << descriptorHandle;
} else {
//charHandle is not the char's value handle
QSharedPointer<QLowEnergyServicePrivate> service =
@@ -1792,7 +1792,7 @@ void QLowEnergyControllerPrivateBluez::readServiceValuesByOffset(
&& service->characteristicList.contains(charHandle)) {
handleToRead = service->characteristicList[charHandle].valueHandle;
qCDebug(QT_BT_BLUEZ) << "Reading characteristic via blob request"
- << hex << handleToRead;
+ << Qt::hex << handleToRead;
} else {
Q_ASSERT(false);
}
@@ -1837,9 +1837,9 @@ void QLowEnergyControllerPrivateBluez::processUnsolicitedReply(const QByteArray
if (QT_BT_BLUEZ().isDebugEnabled()) {
if (isNotification)
- qCDebug(QT_BT_BLUEZ) << "Change notification for handle" << hex << changedHandle;
+ qCDebug(QT_BT_BLUEZ) << "Change notification for handle" << Qt::hex << changedHandle;
else
- qCDebug(QT_BT_BLUEZ) << "Change indication for handle" << hex << changedHandle;
+ qCDebug(QT_BT_BLUEZ) << "Change indication for handle" << Qt::hex << changedHandle;
}
const QLowEnergyCharacteristic ch = characteristicForHandle(changedHandle);
@@ -1966,7 +1966,7 @@ void QLowEnergyControllerPrivateBluez::discoverNextDescriptor(
Q_ASSERT(!pendingCharHandles.isEmpty());
Q_ASSERT(!serviceData.isNull());
- qCDebug(QT_BT_BLUEZ) << "Sending find_info request" << hex
+ qCDebug(QT_BT_BLUEZ) << "Sending find_info request" << Qt::hex
<< pendingCharHandles << startingHandle;
quint8 packet[FIND_INFO_REQUEST_HEADER_SIZE];
@@ -2019,7 +2019,7 @@ void QLowEnergyControllerPrivateBluez::sendNextPrepareWriteRequest(
putBtData(offset, &packet[3]); // offset into newValue
qCDebug(QT_BT_BLUEZ) << "Writing long characteristic (prepare):"
- << hex << handle;
+ << Qt::hex << handle;
const int maxAvailablePayload = mtuSize - PREPARE_WRITE_HEADER_SIZE;
@@ -2065,7 +2065,7 @@ void QLowEnergyControllerPrivateBluez::sendExecuteWriteRequest(
memcpy(data.data(), packet, EXECUTE_WRITE_HEADER_SIZE);
qCDebug(QT_BT_BLUEZ) << "Sending Execute Write Request for long characteristic value"
- << hex << attrHandle;
+ << Qt::hex << attrHandle;
Request request;
request.payload = data;
@@ -2143,7 +2143,7 @@ void QLowEnergyControllerPrivateBluez::readCharacteristic(
QByteArray data(READ_REQUEST_HEADER_SIZE, Qt::Uninitialized);
memcpy(data.data(), packet, READ_REQUEST_HEADER_SIZE);
- qCDebug(QT_BT_BLUEZ) << "Targeted reading characteristic" << hex << charHandle;
+ qCDebug(QT_BT_BLUEZ) << "Targeted reading characteristic" << Qt::hex << charHandle;
Request request;
request.payload = data;
@@ -2178,7 +2178,7 @@ void QLowEnergyControllerPrivateBluez::readDescriptor(
QByteArray data(READ_REQUEST_HEADER_SIZE, Qt::Uninitialized);
memcpy(data.data(), packet, READ_REQUEST_HEADER_SIZE);
- qCDebug(QT_BT_BLUEZ) << "Targeted reading descriptor" << hex << descriptorHandle;
+ qCDebug(QT_BT_BLUEZ) << "Targeted reading descriptor" << Qt::hex << descriptorHandle;
Request request;
request.payload = data;
@@ -2714,7 +2714,7 @@ void QLowEnergyControllerPrivateBluez::writeCharacteristicForCentral(const QShar
break;
}
- qCDebug(QT_BT_BLUEZ) << "Writing characteristic" << hex << charHandle
+ qCDebug(QT_BT_BLUEZ) << "Writing characteristic" << Qt::hex << charHandle
<< "(size:" << packet.count() << "with response:"
<< (mode == QLowEnergyService::WriteWithResponse)
<< "signed:" << (mode == QLowEnergyService::WriteSigned) << ")";
@@ -2774,7 +2774,7 @@ void QLowEnergyControllerPrivateBluez::writeDescriptorForCentral(
memcpy(data.data(), packet, WRITE_REQUEST_HEADER_SIZE);
memcpy(&(data.data()[WRITE_REQUEST_HEADER_SIZE]), newValue.constData(), newValue.size());
- qCDebug(QT_BT_BLUEZ) << "Writing descriptor" << hex << descriptorHandle
+ qCDebug(QT_BT_BLUEZ) << "Writing descriptor" << Qt::hex << descriptorHandle
<< "(size:" << size << ")";
Request request;
diff --git a/src/bluetooth/qlowenergycontroller_darwin.mm b/src/bluetooth/qlowenergycontroller_darwin.mm
index 253956e2..bbe7a4a6 100644
--- a/src/bluetooth/qlowenergycontroller_darwin.mm
+++ b/src/bluetooth/qlowenergycontroller_darwin.mm
@@ -38,16 +38,16 @@
**
****************************************************************************/
-#include "osx/osxbtutility_p.h"
-#include "osx/uistrings_p.h"
+#include "darwin/btutility_p.h"
+#include "darwin/uistrings_p.h"
#ifndef Q_OS_TVOS
-#include "osx/osxbtperipheralmanager_p.h"
+#include "darwin/btperipheralmanager_p.h"
#endif // Q_OS_TVOS
#include "qlowenergycontroller_darwin_p.h"
#include "qlowenergyserviceprivate_p.h"
-#include "osx/osxbtcentralmanager_p.h"
+#include "darwin/btcentralmanager_p.h"
#include "qlowenergyservicedata.h"
#include "qbluetoothlocaldevice.h"
@@ -76,11 +76,11 @@ ServicePrivate qt_createLEService(QLowEnergyControllerPrivateDarwin *controller,
CBUUID *const cbUuid = cbService.UUID;
if (!cbUuid) {
- qCDebug(QT_BT_OSX) << "invalid service, UUID is nil";
+ qCDebug(QT_BT_DARWIN) << "invalid service, UUID is nil";
return ServicePrivate();
}
- const QBluetoothUuid qtUuid(OSXBluetooth::qt_uuid(cbUuid));
+ const QBluetoothUuid qtUuid(DarwinBluetooth::qt_uuid(cbUuid));
if (qtUuid.isNull()) // Conversion error is reported by qt_uuid.
return ServicePrivate();
@@ -114,7 +114,7 @@ UUIDList qt_servicesUuids(NSArray *services)
UUIDList uuids;
for (CBService *s in services)
- uuids.append(OSXBluetooth::qt_uuid(s.UUID));
+ uuids.append(DarwinBluetooth::qt_uuid(s.UUID));
return uuids;
}
@@ -122,10 +122,10 @@ UUIDList qt_servicesUuids(NSArray *services)
} // unnamed namespace
#ifndef Q_OS_TVOS
-using ObjCPeripheralManager = QT_MANGLE_NAMESPACE(OSXBTPeripheralManager);
+using ObjCPeripheralManager = QT_MANGLE_NAMESPACE(DarwinBTPeripheralManager);
#endif // Q_OS_TVOS
-using ObjCCentralManager = QT_MANGLE_NAMESPACE(OSXBTCentralManager);
+using ObjCCentralManager = QT_MANGLE_NAMESPACE(DarwinBTCentralManager);
QLowEnergyControllerPrivateDarwin::QLowEnergyControllerPrivateDarwin()
{
@@ -137,7 +137,7 @@ QLowEnergyControllerPrivateDarwin::QLowEnergyControllerPrivateDarwin()
QLowEnergyControllerPrivateDarwin::~QLowEnergyControllerPrivateDarwin()
{
- if (const auto leQueue = OSXBluetooth::qt_LE_queue()) {
+ if (const auto leQueue = DarwinBluetooth::qt_LE_queue()) {
if (role == QLowEnergyController::CentralRole) {
const auto manager = centralManager.getAs<ObjCCentralManager>();
dispatch_sync(leQueue, ^{
@@ -165,7 +165,7 @@ bool QLowEnergyControllerPrivateDarwin::isValid() const
void QLowEnergyControllerPrivateDarwin::init()
{
- using OSXBluetooth::LECBManagerNotifier;
+ using DarwinBluetooth::LECBManagerNotifier;
QScopedPointer<LECBManagerNotifier> notifier(new LECBManagerNotifier);
if (role == QLowEnergyController::PeripheralRole) {
@@ -173,24 +173,24 @@ void QLowEnergyControllerPrivateDarwin::init()
peripheralManager.reset([[ObjCPeripheralManager alloc] initWith:notifier.data()],
DarwinBluetooth::RetainPolicy::noInitialRetain);
if (!peripheralManager) {
- qCWarning(QT_BT_OSX) << "failed to create a peripheral manager";
+ qCWarning(QT_BT_DARWIN) << "failed to create a peripheral manager";
return;
}
#else
- qCWarning(QT_BT_OSX) << "the peripheral role is not supported on your platform";
+ qCWarning(QT_BT_DARWIN) << "the peripheral role is not supported on your platform";
return;
#endif // Q_OS_TVOS
} else {
centralManager.reset([[ObjCCentralManager alloc] initWith:notifier.data()],
DarwinBluetooth::RetainPolicy::noInitialRetain);
if (!centralManager) {
- qCWarning(QT_BT_OSX) << "failed to initialize a central manager";
+ qCWarning(QT_BT_DARWIN) << "failed to initialize a central manager";
return;
}
}
if (!connectSlots(notifier.data()))
- qCWarning(QT_BT_OSX) << "failed to connect to notifier's signal(s)";
+ qCWarning(QT_BT_DARWIN) << "failed to connect to notifier's signal(s)";
// Ownership was taken by central manager.
notifier.take();
@@ -215,9 +215,9 @@ void QLowEnergyControllerPrivateDarwin::connectToDevice()
Q_ASSERT_X(role != QLowEnergyController::PeripheralRole,
Q_FUNC_INFO, "invalid role (peripheral)");
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
if (!leQueue) {
- qCWarning(QT_BT_OSX) << "no LE queue found";
+ qCWarning(QT_BT_DARWIN) << "no LE queue found";
setErrorDescription(QLowEnergyController::UnknownError);
return;
}
@@ -244,7 +244,7 @@ void QLowEnergyControllerPrivateDarwin::disconnectFromDevice()
if (isValid()) {
const auto oldState = state;
- if (dispatch_queue_t leQueue = OSXBluetooth::qt_LE_queue()) {
+ if (dispatch_queue_t leQueue = DarwinBluetooth::qt_LE_queue()) {
setState(QLowEnergyController::ClosingState);
invalidateServices();
@@ -261,8 +261,8 @@ void QLowEnergyControllerPrivateDarwin::disconnectFromDevice()
setState(QLowEnergyController::UnconnectedState);
}
} else {
- qCCritical(QT_BT_OSX) << "qt LE queue is nil, "
- "can not dispatch 'disconnect'";
+ qCCritical(QT_BT_DARWIN) << "qt LE queue is nil, "
+ "can not dispatch 'disconnect'";
}
}
}
@@ -274,7 +274,7 @@ void QLowEnergyControllerPrivateDarwin::discoverServices()
Q_ASSERT_X(role != QLowEnergyController::PeripheralRole,
Q_FUNC_INFO, "invalid role (peripheral)");
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
Q_ASSERT_X(leQueue, Q_FUNC_INFO, "LE queue not found");
setState(QLowEnergyController::DiscoveringState);
@@ -288,17 +288,17 @@ void QLowEnergyControllerPrivateDarwin::discoverServices()
void QLowEnergyControllerPrivateDarwin::discoverServiceDetails(const QBluetoothUuid &serviceUuid)
{
if (state != QLowEnergyController::DiscoveredState) {
- qCWarning(QT_BT_OSX) << "can not discover service details in the current state, "
- "QLowEnergyController::DiscoveredState is expected";
+ qCWarning(QT_BT_DARWIN) << "can not discover service details in the current state, "
+ "QLowEnergyController::DiscoveredState is expected";
return;
}
if (!serviceList.contains(serviceUuid)) {
- qCWarning(QT_BT_OSX) << "unknown service: " << serviceUuid;
+ qCWarning(QT_BT_DARWIN) << "unknown service: " << serviceUuid;
return;
}
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
Q_ASSERT(leQueue);
ServicePrivate qtService(serviceList.value(serviceUuid));
@@ -315,7 +315,7 @@ void QLowEnergyControllerPrivateDarwin::requestConnectionUpdate(const QLowEnergy
{
Q_UNUSED(params);
// TODO: implement this, if possible.
- qCWarning(QT_BT_OSX) << "Connection update not implemented on your platform";
+ qCWarning(QT_BT_DARWIN) << "Connection update not implemented on your platform";
}
void QLowEnergyControllerPrivateDarwin::addToGenericAttributeList(const QLowEnergyServiceData &service,
@@ -332,20 +332,20 @@ QLowEnergyService * QLowEnergyControllerPrivateDarwin::addServiceHelper(const QL
// Three checks below should be removed, they are done in the q_ptr's class.
#ifdef Q_OS_TVOS
Q_UNUSED(service);
- qCDebug(QT_BT_OSX, "peripheral role is not supported on tvOS");
+ qCDebug(QT_BT_DARWIN, "peripheral role is not supported on tvOS");
#else
if (role != QLowEnergyController::PeripheralRole) {
- qCWarning(QT_BT_OSX) << "not in peripheral role";
+ qCWarning(QT_BT_DARWIN) << "not in peripheral role";
return nullptr;
}
if (state != QLowEnergyController::UnconnectedState) {
- qCWarning(QT_BT_OSX) << "invalid state";
+ qCWarning(QT_BT_DARWIN) << "invalid state";
return nullptr;
}
if (!service.isValid()) {
- qCWarning(QT_BT_OSX) << "invalid service";
+ qCWarning(QT_BT_DARWIN) << "invalid service";
return nullptr;
}
@@ -384,14 +384,14 @@ void QLowEnergyControllerPrivateDarwin::_q_serviceDiscoveryFinished()
Q_ASSERT_X(state == QLowEnergyController::DiscoveringState,
Q_FUNC_INFO, "invalid state");
- using namespace OSXBluetooth;
+ using namespace DarwinBluetooth;
QT_BT_MAC_AUTORELEASEPOOL;
NSArray *const services = [centralManager.getAs<ObjCCentralManager>() peripheral].services;
// Now we have to traverse the discovered services tree.
// Essentially it's an iterative version of more complicated code from the
- // OSXBTCentralManager's code.
+ // DarwinBTCentralManager's code.
// All Obj-C entities either auto-release, or guarded by ObjCScopedReferences.
if (services && [services count]) {
QMap<QBluetoothUuid, CBService *> discoveredCBServices;
@@ -405,7 +405,7 @@ void QLowEnergyControllerPrivateDarwin::_q_serviceDiscoveryFinished()
continue;
if (serviceList.contains(newService->uuid)) {
// It's a bit stupid we first created it ...
- qCDebug(QT_BT_OSX) << "discovered service with a duplicated UUID"
+ qCDebug(QT_BT_DARWIN) << "discovered service with a duplicated UUID"
<< newService->uuid;
continue;
}
@@ -413,9 +413,9 @@ void QLowEnergyControllerPrivateDarwin::_q_serviceDiscoveryFinished()
discoveredCBServices.insert(newService->uuid, cbService);
}
- ObjCStrongReference<NSMutableArray> toVisit([[NSMutableArray alloc] initWithArray:services], false);
- ObjCStrongReference<NSMutableArray> toVisitNext([[NSMutableArray alloc] init], false);
- ObjCStrongReference<NSMutableSet> visited([[NSMutableSet alloc] init], false);
+ ObjCStrongReference<NSMutableArray> toVisit([[NSMutableArray alloc] initWithArray:services], RetainPolicy::noInitialRetain);
+ ObjCStrongReference<NSMutableArray> toVisitNext([[NSMutableArray alloc] init], RetainPolicy::noInitialRetain);
+ ObjCStrongReference<NSMutableSet> visited([[NSMutableSet alloc] init], RetainPolicy::noInitialRetain);
while (true) {
for (NSUInteger i = 0, e = [toVisit count]; i < e; ++i) {
@@ -453,11 +453,11 @@ void QLowEnergyControllerPrivateDarwin::_q_serviceDiscoveryFinished()
}
}
- toVisit.resetWithoutRetain(toVisitNext.take());
- toVisitNext.resetWithoutRetain([[NSMutableArray alloc] init]);
+ toVisit.swap(toVisitNext);
+ toVisitNext.reset([[NSMutableArray alloc] init], RetainPolicy::noInitialRetain);
}
} else {
- qCDebug(QT_BT_OSX) << "no services found";
+ qCDebug(QT_BT_DARWIN) << "no services found";
}
for (ServiceMap::const_iterator it = serviceList.constBegin(); it != serviceList.constEnd(); ++it)
@@ -474,8 +474,8 @@ void QLowEnergyControllerPrivateDarwin::_q_serviceDetailsDiscoveryFinished(QShar
Q_ASSERT(service);
if (!serviceList.contains(service->uuid)) {
- qCDebug(QT_BT_OSX) << "unknown service uuid:"
- << service->uuid;
+ qCDebug(QT_BT_DARWIN) << "unknown service uuid:"
+ << service->uuid;
return;
}
@@ -492,7 +492,7 @@ void QLowEnergyControllerPrivateDarwin::_q_servicesWereModified()
{
if (!(state == QLowEnergyController::DiscoveringState
|| state == QLowEnergyController::DiscoveredState)) {
- qCWarning(QT_BT_OSX) << "services were modified while controller is not in Discovered/Discovering state";
+ qCWarning(QT_BT_DARWIN) << "services were modified while controller is not in Discovered/Discovering state";
return;
}
@@ -514,7 +514,7 @@ void QLowEnergyControllerPrivateDarwin::_q_characteristicRead(QLowEnergyHandle c
QLowEnergyCharacteristic characteristic(characteristicForHandle(charHandle));
if (!characteristic.isValid()) {
- qCWarning(QT_BT_OSX) << "unknown characteristic";
+ qCWarning(QT_BT_DARWIN) << "unknown characteristic";
return;
}
@@ -531,14 +531,14 @@ void QLowEnergyControllerPrivateDarwin::_q_characteristicWritten(QLowEnergyHandl
ServicePrivate service(serviceForHandle(charHandle));
if (service.isNull()) {
- qCWarning(QT_BT_OSX) << "can not find service for characteristic handle"
- << charHandle;
+ qCWarning(QT_BT_DARWIN) << "can not find service for characteristic handle"
+ << charHandle;
return;
}
QLowEnergyCharacteristic characteristic(characteristicForHandle(charHandle));
if (!characteristic.isValid()) {
- qCWarning(QT_BT_OSX) << "unknown characteristic";
+ qCWarning(QT_BT_DARWIN) << "unknown characteristic";
return;
}
@@ -567,7 +567,7 @@ void QLowEnergyControllerPrivateDarwin::_q_characteristicUpdated(QLowEnergyHandl
QLowEnergyCharacteristic characteristic(characteristicForHandle(charHandle));
if (!characteristic.isValid()) {
- qCWarning(QT_BT_OSX) << "unknown characteristic";
+ qCWarning(QT_BT_DARWIN) << "unknown characteristic";
return;
}
@@ -584,7 +584,7 @@ void QLowEnergyControllerPrivateDarwin::_q_descriptorRead(QLowEnergyHandle dHand
const QLowEnergyDescriptor qtDescriptor(descriptorForHandle(dHandle));
if (!qtDescriptor.isValid()) {
- qCWarning(QT_BT_OSX) << "unknown descriptor" << dHandle;
+ qCWarning(QT_BT_DARWIN) << "unknown descriptor" << dHandle;
return;
}
@@ -600,7 +600,7 @@ void QLowEnergyControllerPrivateDarwin::_q_descriptorWritten(QLowEnergyHandle dH
const QLowEnergyDescriptor qtDescriptor(descriptorForHandle(dHandle));
if (!qtDescriptor.isValid()) {
- qCWarning(QT_BT_OSX) << "unknown descriptor" << dHandle;
+ qCWarning(QT_BT_DARWIN) << "unknown descriptor" << dHandle;
return;
}
@@ -626,16 +626,16 @@ void QLowEnergyControllerPrivateDarwin::_q_notificationEnabled(QLowEnergyHandle
const QLowEnergyCharacteristic qtChar(characteristicForHandle(charHandle));
if (!qtChar.isValid()) {
- qCWarning(QT_BT_OSX) << "unknown characteristic" << charHandle;
+ qCWarning(QT_BT_DARWIN) << "unknown characteristic" << charHandle;
return;
}
const QLowEnergyDescriptor qtDescriptor =
qtChar.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
if (!qtDescriptor.isValid()) {
- qCWarning(QT_BT_OSX) << "characteristic" << charHandle
- << "does not have a client characteristic "
- "descriptor";
+ qCWarning(QT_BT_DARWIN) << "characteristic" << charHandle
+ << "does not have a client characteristic "
+ "descriptor";
return;
}
@@ -687,8 +687,8 @@ void QLowEnergyControllerPrivateDarwin::_q_CBManagerError(const QBluetoothUuid &
ServicePrivate qtService(serviceList.value(serviceUuid));
qtService->setState(QLowEnergyService::InvalidService);
} else {
- qCDebug(QT_BT_OSX) << "error reported for unknown service"
- << serviceUuid;
+ qCDebug(QT_BT_DARWIN) << "error reported for unknown service"
+ << serviceUuid;
}
}
@@ -696,8 +696,8 @@ void QLowEnergyControllerPrivateDarwin::_q_CBManagerError(const QBluetoothUuid &
QLowEnergyService::ServiceError errorCode)
{
if (!serviceList.contains(serviceUuid)) {
- qCDebug(QT_BT_OSX) << "unknown service uuid:"
- << serviceUuid;
+ qCDebug(QT_BT_DARWIN) << "unknown service uuid:"
+ << serviceUuid;
return;
}
@@ -712,7 +712,7 @@ void QLowEnergyControllerPrivateDarwin::setNotifyValue(QSharedPointer<QLowEnergy
Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
if (role == QLowEnergyController::PeripheralRole) {
- qCWarning(QT_BT_OSX) << "invalid role (peripheral)";
+ qCWarning(QT_BT_DARWIN) << "invalid role (peripheral)";
service->setError(QLowEnergyService::DescriptorWriteError);
return;
}
@@ -722,24 +722,24 @@ void QLowEnergyControllerPrivateDarwin::setNotifyValue(QSharedPointer<QLowEnergy
// With Core Bluetooth we do not write any descriptor,
// but instead call a special method. So it's better to
// intercept wrong data size here:
- qCWarning(QT_BT_OSX) << "client characteristic configuration descriptor"
- "is 2 bytes, but value size is: " << newValue.size();
+ qCWarning(QT_BT_DARWIN) << "client characteristic configuration descriptor"
+ "is 2 bytes, but value size is: " << newValue.size();
service->setError(QLowEnergyService::DescriptorWriteError);
return;
}
if (!serviceList.contains(service->uuid)) {
- qCWarning(QT_BT_OSX) << "no service with uuid:" << service->uuid << "found";
+ qCWarning(QT_BT_DARWIN) << "no service with uuid:" << service->uuid << "found";
return;
}
if (!service->characteristicList.contains(charHandle)) {
- qCDebug(QT_BT_OSX) << "no characteristic with handle:"
- << charHandle << "found";
+ qCDebug(QT_BT_DARWIN) << "no characteristic with handle:"
+ << charHandle << "found";
return;
}
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
Q_ASSERT_X(leQueue, Q_FUNC_INFO, "no LE queue found");
ObjCCentralManager *manager = centralManager.getAs<ObjCCentralManager>();
@@ -758,23 +758,23 @@ void QLowEnergyControllerPrivateDarwin::readCharacteristic(const QSharedPointer<
Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
if (role == QLowEnergyController::PeripheralRole) {
- qCWarning(QT_BT_OSX) << "invalid role (peripheral)";
+ qCWarning(QT_BT_DARWIN) << "invalid role (peripheral)";
return;
}
if (!serviceList.contains(service->uuid)) {
- qCWarning(QT_BT_OSX) << "no service with uuid:"
- << service->uuid << "found";
+ qCWarning(QT_BT_DARWIN) << "no service with uuid:"
+ << service->uuid << "found";
return;
}
if (!service->characteristicList.contains(charHandle)) {
- qCDebug(QT_BT_OSX) << "no characteristic with handle:"
- << charHandle << "found";
+ qCDebug(QT_BT_DARWIN) << "no characteristic with handle:"
+ << charHandle << "found";
return;
}
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
Q_ASSERT_X(leQueue, Q_FUNC_INFO, "no LE queue found");
// Attention! We have to copy UUID.
@@ -795,18 +795,18 @@ void QLowEnergyControllerPrivateDarwin::writeCharacteristic(const QSharedPointer
// (== created by the given LE controller).
if (!serviceList.contains(service->uuid) && !localServices.contains(service->uuid)) {
- qCWarning(QT_BT_OSX) << "no service with uuid:"
- << service->uuid << " found";
+ qCWarning(QT_BT_DARWIN) << "no service with uuid:"
+ << service->uuid << " found";
return;
}
if (!service->characteristicList.contains(charHandle)) {
- qCDebug(QT_BT_OSX) << "no characteristic with handle:"
- << charHandle << " found";
+ qCDebug(QT_BT_DARWIN) << "no characteristic with handle:"
+ << charHandle << " found";
return;
}
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
Q_ASSERT_X(leQueue, Q_FUNC_INFO, "no LE queue found");
// Attention! We have to copy objects!
const QByteArray newValueCopy(newValue);
@@ -826,7 +826,7 @@ void QLowEnergyControllerPrivateDarwin::writeCharacteristic(const QSharedPointer
[manager write:newValueCopy charHandle:charHandle];
});
#else
- qCWarning(QT_BT_OSX) << "peripheral role is not supported on your platform";
+ qCWarning(QT_BT_DARWIN) << "peripheral role is not supported on your platform";
#endif
}
}
@@ -861,19 +861,19 @@ void QLowEnergyControllerPrivateDarwin::readDescriptor(const QSharedPointer<QLow
Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
if (role == QLowEnergyController::PeripheralRole) {
- qCWarning(QT_BT_OSX) << "invalid role (peripheral)";
+ qCWarning(QT_BT_DARWIN) << "invalid role (peripheral)";
return;
}
if (!serviceList.contains(service->uuid)) {
- qCWarning(QT_BT_OSX) << "no service with uuid:"
- << service->uuid << "found";
+ qCWarning(QT_BT_DARWIN) << "no service with uuid:"
+ << service->uuid << "found";
return;
}
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
if (!leQueue) {
- qCWarning(QT_BT_OSX) << "no LE queue found";
+ qCWarning(QT_BT_DARWIN) << "no LE queue found";
return;
}
// Attention! Copy objects!
@@ -895,7 +895,7 @@ void QLowEnergyControllerPrivateDarwin::writeDescriptor(const QSharedPointer<QLo
Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
if (role == QLowEnergyController::PeripheralRole) {
- qCWarning(QT_BT_OSX) << "invalid role (peripheral)";
+ qCWarning(QT_BT_DARWIN) << "invalid role (peripheral)";
return;
}
@@ -903,12 +903,12 @@ void QLowEnergyControllerPrivateDarwin::writeDescriptor(const QSharedPointer<QLo
// (== created by the given LE controller),
// otherwise we can not write anything at all.
if (!serviceList.contains(service->uuid)) {
- qCWarning(QT_BT_OSX) << "no service with uuid:"
- << service->uuid << " found";
+ qCWarning(QT_BT_DARWIN) << "no service with uuid:"
+ << service->uuid << " found";
return;
}
- dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue());
+ dispatch_queue_t leQueue(DarwinBluetooth::qt_LE_queue());
Q_ASSERT_X(leQueue, Q_FUNC_INFO, "no LE queue found");
// Attention! Copy objects!
const QBluetoothUuid serviceUuid(service->uuid);
@@ -981,9 +981,9 @@ void QLowEnergyControllerPrivateDarwin::setErrorDescription(QLowEnergyController
}
}
-bool QLowEnergyControllerPrivateDarwin::connectSlots(OSXBluetooth::LECBManagerNotifier *notifier)
+bool QLowEnergyControllerPrivateDarwin::connectSlots(DarwinBluetooth::LECBManagerNotifier *notifier)
{
- using OSXBluetooth::LECBManagerNotifier;
+ using DarwinBluetooth::LECBManagerNotifier;
Q_ASSERT_X(notifier, Q_FUNC_INFO, "invalid notifier object (null)");
@@ -1032,25 +1032,25 @@ void QLowEnergyControllerPrivateDarwin::startAdvertising(const QLowEnergyAdverti
Q_UNUSED(params)
Q_UNUSED(advertisingData)
Q_UNUSED(scanResponseData)
- qCWarning(QT_BT_OSX) << "advertising is not supported on your platform";
+ qCWarning(QT_BT_DARWIN) << "advertising is not supported on your platform";
#else
if (!isValid())
return _q_CBManagerError(QLowEnergyController::UnknownError);
if (role != QLowEnergyController::PeripheralRole) {
- qCWarning(QT_BT_OSX) << "controller is not a peripheral, cannot start advertising";
+ qCWarning(QT_BT_DARWIN) << "controller is not a peripheral, cannot start advertising";
return;
}
if (state != QLowEnergyController::UnconnectedState) {
- qCWarning(QT_BT_OSX) << "invalid state" << state;
+ qCWarning(QT_BT_DARWIN) << "invalid state" << state;
return;
}
- auto leQueue(OSXBluetooth::qt_LE_queue());
+ auto leQueue(DarwinBluetooth::qt_LE_queue());
if (!leQueue) {
- qCWarning(QT_BT_OSX) << "no LE queue found";
+ qCWarning(QT_BT_DARWIN) << "no LE queue found";
setErrorDescription(QLowEnergyController::UnknownError);
return;
}
@@ -1069,17 +1069,17 @@ void QLowEnergyControllerPrivateDarwin::startAdvertising(const QLowEnergyAdverti
void QLowEnergyControllerPrivateDarwin::stopAdvertising()
{
#ifdef Q_OS_TVOS
- qCWarning(QT_BT_OSX) << "advertising is not supported on your platform";
+ qCWarning(QT_BT_DARWIN) << "advertising is not supported on your platform";
#else
if (!isValid())
return _q_CBManagerError(QLowEnergyController::UnknownError);
if (state != QLowEnergyController::AdvertisingState) {
- qCDebug(QT_BT_OSX) << "cannot stop advertising, called in state" << state;
+ qCDebug(QT_BT_DARWIN) << "cannot stop advertising, called in state" << state;
return;
}
- if (const auto leQueue = OSXBluetooth::qt_LE_queue()) {
+ if (const auto leQueue = DarwinBluetooth::qt_LE_queue()) {
const auto manager = peripheralManager.getAs<ObjCPeripheralManager>();
dispatch_sync(leQueue, ^{
[manager stopAdvertising];
@@ -1087,7 +1087,7 @@ void QLowEnergyControllerPrivateDarwin::stopAdvertising()
setState(QLowEnergyController::UnconnectedState);
} else {
- qCWarning(QT_BT_OSX) << "no LE queue found";
+ qCWarning(QT_BT_DARWIN) << "no LE queue found";
setErrorDescription(QLowEnergyController::UnknownError);
return;
}
diff --git a/src/bluetooth/qlowenergycontroller_darwin_p.h b/src/bluetooth/qlowenergycontroller_darwin_p.h
index 960d7fbc..b285830c 100644
--- a/src/bluetooth/qlowenergycontroller_darwin_p.h
+++ b/src/bluetooth/qlowenergycontroller_darwin_p.h
@@ -54,10 +54,10 @@
#include "qlowenergyserviceprivate_p.h"
#include "qlowenergycontrollerbase_p.h"
#include "qlowenergycontroller.h"
-#include "osx/osxbtnotifier_p.h"
+#include "darwin/btnotifier_p.h"
#include "qbluetoothaddress.h"
+#include "darwin/btraii_p.h"
#include "qbluetoothuuid.h"
-#include "osx/btraii_p.h"
#include <QtCore/qsharedpointer.h>
#include <QtCore/qglobal.h>
@@ -144,7 +144,7 @@ private:
bool appendValue);
void setErrorDescription(QLowEnergyController::Error errorCode);
- bool connectSlots(OSXBluetooth::LECBManagerNotifier *notifier);
+ bool connectSlots(DarwinBluetooth::LECBManagerNotifier *notifier);
DarwinBluetooth::ScopedPointer centralManager;
diff --git a/src/bluetooth/windows/windows.pri b/src/bluetooth/windows/windows.pri
index bf35eaa4..de3d863c 100644
--- a/src/bluetooth/windows/windows.pri
+++ b/src/bluetooth/windows/windows.pri
@@ -1,2 +1,2 @@
-PRIVATE_HEADERS += \
+HEADERS += \
windows/qwinlowenergybluetooth_p.h
diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp
index c382ccd9..96cf4f3a 100644
--- a/src/imports/nfc/qdeclarativendeffilter.cpp
+++ b/src/imports/nfc/qdeclarativendeffilter.cpp
@@ -39,6 +39,8 @@
#include "qdeclarativendeffilter_p.h"
+#include <limits.h>
+
/*!
\qmltype NdefFilter
\instantiates QDeclarativeNdefFilter
diff --git a/src/nfc/targetemulator.cpp b/src/nfc/targetemulator.cpp
index 80555593..4b347208 100644
--- a/src/nfc/targetemulator.cpp
+++ b/src/nfc/targetemulator.cpp
@@ -370,7 +370,7 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command)
return NACK;
default:
- qDebug() << "Unknown opcode for Tag Type 2" << hex << opcode;
+ qDebug() << "Unknown opcode for Tag Type 2" << Qt::hex << opcode;
qDebug() << "command:" << command.toHex();
return NACK;
diff --git a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
index 45b429db..fba65fa1 100644
--- a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
+++ b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
@@ -154,21 +154,21 @@ void tst_QBluetoothDeviceInfo::tst_construction_data()
QTest::newRow("0x000300 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000300)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
- << QBluetoothDeviceInfo::LANAccessDevice
+ << QBluetoothDeviceInfo::NetworkDevice
<< quint8(QBluetoothDeviceInfo::NetworkFullService)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000320 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000320)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
- << QBluetoothDeviceInfo::LANAccessDevice
+ << QBluetoothDeviceInfo::NetworkDevice
<< quint8(QBluetoothDeviceInfo::NetworkLoadFactorOne)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x0003E0 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0003E0)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
- << QBluetoothDeviceInfo::LANAccessDevice
+ << QBluetoothDeviceInfo::NetworkDevice
<< quint8(QBluetoothDeviceInfo::NetworkNoService)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
diff --git a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
index b3caab44..334a950b 100644
--- a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
+++ b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
@@ -243,7 +243,8 @@ void tst_QLowEnergyDescriptor::tst_assignCompare()
QCOMPARE(target.uuid(), QBluetoothUuid());
QCOMPARE(target.value(), QByteArray());
- int index = -1;
+ int index = 0;
+ bool valueFound = false;
QList<QLowEnergyDescriptor> targets;
const QList<QLowEnergyCharacteristic> chars = globalService->characteristics();
for (const QLowEnergyCharacteristic &ch : chars) {
@@ -253,6 +254,7 @@ void tst_QLowEnergyDescriptor::tst_assignCompare()
// try to get a descriptor we can read
if (targets[i].type() == QBluetoothUuid::CharacteristicUserDescription) {
index = i;
+ valueFound = true;
break;
}
}
@@ -263,8 +265,6 @@ void tst_QLowEnergyDescriptor::tst_assignCompare()
if (targets.isEmpty())
QSKIP("No descriptor found despite prior indication.");
- QVERIFY(index != -1);
-
// test assignment operator
target = targets[index];
QVERIFY(target.isValid());
@@ -272,7 +272,7 @@ void tst_QLowEnergyDescriptor::tst_assignCompare()
QVERIFY(!target.name().isEmpty());
QVERIFY(target.handle() > 0);
QVERIFY(!target.uuid().isNull());
- QVERIFY(!target.value().isEmpty());
+ QVERIFY(!valueFound || !target.value().isEmpty());
QVERIFY(target == targets[index]);
QVERIFY(targets[index] == target);