diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2019-09-25 10:08:37 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2019-09-26 09:21:01 +0200 |
commit | b6f02da91d580aebbba9b2604a27b6d71f837e37 (patch) | |
tree | da7ff86d0fa140d1e9772686870558f92e78e1d3 | |
parent | 06096df58fd819f7a84ad0f58335de6bf943467b (diff) |
IO/CoreBluetooth - clean the code up for Qt6
Make naming more consistent - merge two namespaces 'OSXBluetooth' and
(the recent one) 'DarwinBluetooth' into one named 'DarwinBluetooth', since
CoreBluetooth is supported by: tvOS, watchOS, iOS and macOS (aka Darwin).
Change-Id: I8e7b0f3626f8982ea06493eef8abf058501197f4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
33 files changed, 236 insertions, 276 deletions
diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/osx/osxbtcentralmanager.mm index b9a1ae0f..13437961 100644 --- a/src/bluetooth/osx/osxbtcentralmanager.mm +++ b/src/bluetooth/osx/osxbtcentralmanager.mm @@ -54,7 +54,7 @@ Q_DECLARE_METATYPE(QLowEnergyHandle) QT_BEGIN_NAMESPACE -namespace OSXBluetooth { +namespace DarwinBluetooth { NSUInteger qt_countGATTEntries(CBService *service) { @@ -100,7 +100,7 @@ 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 @@ -108,9 +108,9 @@ QT_USE_NAMESPACE @interface QT_MANGLE_NAMESPACE(OSXBTCentralManager) (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; @@ -142,46 +142,46 @@ QT_USE_NAMESPACE { @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; @@ -237,9 +237,9 @@ 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*/); [newWatcher watchAfter:object withTimeoutType:type]; @@ -247,14 +247,14 @@ QT_USE_NAMESPACE [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]; @@ -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; + managerState = DarwinBluetooth::CentralManagerIdle; qCWarning(QT_BT_OSX) << "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,7 +344,7 @@ 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]) { @@ -359,7 +359,7 @@ QT_USE_NAMESPACE return; } - using namespace OSXBluetooth; + using namespace DarwinBluetooth; // Retrieve a peripheral first ... ObjCScopedPointer<NSMutableArray> uuids([[NSMutableArray alloc] init]); @@ -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)"); @@ -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)"); @@ -511,7 +511,7 @@ 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"); @@ -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; @@ -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"); @@ -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"); @@ -851,7 +851,7 @@ 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)"); @@ -890,7 +890,7 @@ 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)"); @@ -919,7 +919,7 @@ 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)"); @@ -947,7 +947,7 @@ 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)"); @@ -972,7 +972,7 @@ 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)"); @@ -998,7 +998,7 @@ 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)"); @@ -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; } @@ -1223,7 +1223,7 @@ QT_USE_NAMESPACE - (void)centralManagerDidUpdateState:(CBCentralManager *)central { - using namespace OSXBluetooth; + using namespace DarwinBluetooth; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability-new" @@ -1310,12 +1310,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 +1327,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 +1347,13 @@ QT_USE_NAMESPACE // Clear internal caches/data. [self reset]; - if (error && managerState == OSXBluetooth::CentralManagerDisconnecting) { - managerState = OSXBluetooth::CentralManagerIdle; + if (error && managerState == DarwinBluetooth::CentralManagerDisconnecting) { + managerState = DarwinBluetooth::CentralManagerIdle; qCWarning(QT_BT_OSX) << "failed to disconnect"; if (notifier) emit notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError); } else { - managerState = OSXBluetooth::CentralManagerIdle; + managerState = DarwinBluetooth::CentralManagerIdle; if (notifier) emit notifier->disconnected(); } @@ -1365,12 +1365,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 +1379,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); @@ -1410,7 +1411,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 +1421,7 @@ QT_USE_NAMESPACE { Q_UNUSED(aPeripheral) - using namespace OSXBluetooth; + using namespace DarwinBluetooth; if (managerState != CentralManagerDiscovering) { // Canceled by disconnectFromDevice or -peripheralDidDisconnect... @@ -1502,7 +1503,7 @@ QT_USE_NAMESPACE return; } - using namespace OSXBluetooth; + using namespace DarwinBluetooth; if (![self objectIsUnderWatch:service operation:OperationTimeout::characteristicsDiscovery]) return; @@ -1532,7 +1533,7 @@ QT_USE_NAMESPACE if (!notifier) // Detached. return; - using namespace OSXBluetooth; + using namespace DarwinBluetooth; QT_BT_MAC_AUTORELEASEPOOL; @@ -1618,7 +1619,7 @@ QT_USE_NAMESPACE QT_BT_MAC_AUTORELEASEPOOL; - using namespace OSXBluetooth; + using namespace DarwinBluetooth; if (![self objectIsUnderWatch:characteristic operation:OperationTimeout::descriptorsDiscovery]) return; @@ -1656,7 +1657,7 @@ QT_USE_NAMESPACE QT_BT_MAC_AUTORELEASEPOOL; - using namespace OSXBluetooth; + using namespace DarwinBluetooth; if (![self objectIsUnderWatch:descriptor operation:OperationTimeout::descriptorRead]) return; @@ -1745,7 +1746,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; @@ -1786,7 +1787,7 @@ QT_USE_NAMESPACE return; } - using namespace OSXBluetooth; + using namespace DarwinBluetooth; QT_BT_MAC_AUTORELEASEPOOL; @@ -1820,7 +1821,7 @@ QT_USE_NAMESPACE if (!notifier) return; - using namespace OSXBluetooth; + using namespace DarwinBluetooth; QT_BT_MAC_AUTORELEASEPOOL; diff --git a/src/bluetooth/osx/osxbtcentralmanager_p.h b/src/bluetooth/osx/osxbtcentralmanager_p.h index ce348dc6..d6db55ee 100644 --- a/src/bluetooth/osx/osxbtcentralmanager_p.h +++ b/src/bluetooth/osx/osxbtcentralmanager_p.h @@ -65,13 +65,11 @@ #include <Foundation/Foundation.h> -@class QT_MANGLE_NAMESPACE(OSXBTCentralManager); - QT_BEGIN_NAMESPACE class QLowEnergyServicePrivate; -namespace OSXBluetooth { +namespace DarwinBluetooth { class LECBManagerNotifier; @@ -129,14 +127,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; +- (id)initWith:(QT_PREPEND_NAMESPACE(DarwinBluetooth)::LECBManagerNotifier *)notifier; - (void)dealloc; - (CBPeripheral *)peripheral; diff --git a/src/bluetooth/osx/osxbtconnectionmonitor.mm b/src/bluetooth/osx/osxbtconnectionmonitor.mm index b777af8e..f70c4a05 100644 --- a/src/bluetooth/osx/osxbtconnectionmonitor.mm +++ b/src/bluetooth/osx/osxbtconnectionmonitor.mm @@ -44,13 +44,6 @@ QT_BEGIN_NAMESPACE -namespace OSXBluetooth { - -ConnectionMonitor::~ConnectionMonitor() -{ -} - -} QT_END_NAMESPACE @@ -60,12 +53,12 @@ using namespace QT_NAMESPACE; @implementation QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor) { - 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/osxbtconnectionmonitor_p.h b/src/bluetooth/osx/osxbtconnectionmonitor_p.h index 679f6124..40bda611 100644 --- a/src/bluetooth/osx/osxbtconnectionmonitor_p.h +++ b/src/bluetooth/osx/osxbtconnectionmonitor_p.h @@ -53,6 +53,7 @@ #include "qbluetoothaddress.h" #include "osxbluetooth_p.h" +#include "btdelegates_p.h" #include <QtCore/qglobal.h> @@ -62,25 +63,11 @@ 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; +- (id)initWithMonitor:(QT_PREPEND_NAMESPACE(DarwinBluetooth::ConnectionMonitor) *)monitor; - (void)connectionNotification:(id)notification withDevice:(IOBluetoothDevice *)device; - (void)connectionClosedNotification:(id)notification withDevice:(IOBluetoothDevice *)device; diff --git a/src/bluetooth/osx/osxbtdevicepair.mm b/src/bluetooth/osx/osxbtdevicepair.mm index 75dbbcad..dc36cac5 100644 --- a/src/bluetooth/osx/osxbtdevicepair.mm +++ b/src/bluetooth/osx/osxbtdevicepair.mm @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE -namespace OSXBluetooth { +namespace DarwinBluetooth { ObjCStrongReference<IOBluetoothDevice> device_with_address(const QBluetoothAddress &address) { @@ -57,12 +57,7 @@ ObjCStrongReference<IOBluetoothDevice> device_with_address(const QBluetoothAddre return res; } -PairingDelegate::~PairingDelegate() -{ -} - -} - +} // namespace DarwinBluetooth QT_END_NAMESPACE @@ -74,11 +69,11 @@ QT_USE_NAMESPACE 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,7 +103,7 @@ 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) { diff --git a/src/bluetooth/osx/osxbtdevicepair_p.h b/src/bluetooth/osx/osxbtdevicepair_p.h index 1a2c7d6b..35913167 100644 --- a/src/bluetooth/osx/osxbtdevicepair_p.h +++ b/src/bluetooth/osx/osxbtdevicepair_p.h @@ -54,6 +54,7 @@ #include "qbluetoothaddress.h" #include "osxbtutility_p.h" #include "osxbluetooth_p.h" +#include "btdelegates_p.h" #include <QtCore/qglobal.h> @@ -63,36 +64,18 @@ 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> - (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/osx/osxbtgcdtimer.mm index 9663ca93..a3e154f2 100644 --- a/src/bluetooth/osx/osxbtgcdtimer.mm +++ b/src/bluetooth/osx/osxbtgcdtimer.mm @@ -45,7 +45,7 @@ #include <algorithm> QT_USE_NAMESPACE -using namespace OSXBluetooth; +using namespace DarwinBluetooth; @implementation QT_MANGLE_NAMESPACE(OSXBTGCDTimer) { @private diff --git a/src/bluetooth/osx/osxbtgcdtimer_p.h b/src/bluetooth/osx/osxbtgcdtimer_p.h index 6bd82c9a..266a4c98 100644 --- a/src/bluetooth/osx/osxbtgcdtimer_p.h +++ b/src/bluetooth/osx/osxbtgcdtimer_p.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 @@ -85,22 +85,22 @@ QT_END_NAMESPACE @interface QT_MANGLE_NAMESPACE(OSXBTGCDTimer) : 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 GCDTimer = ObjCStrongReference<GCDTimerObjC>; -} // namespace OSXBluetooth +} // namespace DarwinBluetooth QT_END_NAMESPACE diff --git a/src/bluetooth/osx/osxbtl2capchannel.mm b/src/bluetooth/osx/osxbtl2capchannel.mm index 03e3a982..73364b71 100644 --- a/src/bluetooth/osx/osxbtl2capchannel.mm +++ b/src/bluetooth/osx/osxbtl2capchannel.mm @@ -122,7 +122,7 @@ QT_USE_NAMESPACE 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"; diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/osx/osxbtledeviceinquiry.mm index 70b96ab7..ba288ae5 100644 --- a/src/bluetooth/osx/osxbtledeviceinquiry.mm +++ b/src/bluetooth/osx/osxbtledeviceinquiry.mm @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE -namespace OSXBluetooth { +namespace DarwinBluetooth { QBluetoothUuid qt_uuid(NSUUID *nsUuid) { @@ -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,7 +182,7 @@ 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]); @@ -201,7 +201,7 @@ 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) @@ -328,7 +328,7 @@ QT_USE_NAMESPACE advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { - using namespace OSXBluetooth; + using namespace DarwinBluetooth; if (central != manager) return; @@ -346,7 +346,7 @@ QT_USE_NAMESPACE 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"; diff --git a/src/bluetooth/osx/osxbtledeviceinquiry_p.h b/src/bluetooth/osx/osxbtledeviceinquiry_p.h index d99a93bd..5cd41e71 100644 --- a/src/bluetooth/osx/osxbtledeviceinquiry_p.h +++ b/src/bluetooth/osx/osxbtledeviceinquiry_p.h @@ -66,17 +66,17 @@ 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 { diff --git a/src/bluetooth/osx/osxbtnotifier_p.h b/src/bluetooth/osx/osxbtnotifier_p.h index 397214d0..2e9c61eb 100644 --- a/src/bluetooth/osx/osxbtnotifier_p.h +++ b/src/bluetooth/osx/osxbtnotifier_p.h @@ -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/osx/osxbtobexsession.mm index 868b2319..38c7a477 100644 --- a/src/bluetooth/osx/osxbtobexsession.mm +++ b/src/bluetooth/osx/osxbtobexsession.mm @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -namespace OSXBluetooth +namespace DarwinBluetooth { OBEXSessionDelegate::~OBEXSessionDelegate() @@ -401,7 +401,7 @@ bool check_abort_event(const OBEXSessionEvent *e, OBEXError &error, OBEXOpCode & } } // Unnamed namespace. -} // OSXBluetooth. +} // namespace DarwinBluetooth. QT_END_NAMESPACE @@ -419,12 +419,12 @@ QT_USE_NAMESPACE @implementation QT_MANGLE_NAMESPACE(OSXBTOBEXSession) { - 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 +448,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,11 +457,11 @@ 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"; @@ -500,13 +500,13 @@ QT_USE_NAMESPACE } // 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] @@ -517,7 +517,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 +527,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)"); @@ -582,7 +582,7 @@ QT_USE_NAMESPACE - (OBEXError)OBEXAbort { - using namespace OSXBluetooth; + using namespace DarwinBluetooth; Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)"); @@ -612,7 +612,7 @@ 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)"); @@ -635,7 +635,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; @@ -721,7 +721,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)"); @@ -797,7 +797,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 +830,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/osx/osxbtobexsession_p.h index 49465f24..ecf44cff 100644 --- a/src/bluetooth/osx/osxbtobexsession_p.h +++ b/src/bluetooth/osx/osxbtobexsession_p.h @@ -55,6 +55,8 @@ #include <Foundation/Foundation.h> +// TODO: all this code must be removed in Qt 6? + @class QT_MANGLE_NAMESPACE(OSXBTOBEXSession); QT_BEGIN_NAMESPACE @@ -63,7 +65,7 @@ class QBluetoothAddress; class QIODevice; class QString; -namespace OSXBluetooth +namespace DarwinBluetooth { class OBEXSessionDelegate @@ -93,7 +95,7 @@ enum OBEXRequest { OBEXAbort }; -} +} // namespace DarwinBluetooth QT_END_NAMESPACE @@ -102,7 +104,7 @@ QT_END_NAMESPACE // It either succeeds or fails and tries to cleanup in any case. @interface QT_MANGLE_NAMESPACE(OSXBTOBEXSession) : 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; diff --git a/src/bluetooth/osx/osxbtperipheralmanager.mm b/src/bluetooth/osx/osxbtperipheralmanager.mm index 39f9808c..204ecb20 100644 --- a/src/bluetooth/osx/osxbtperipheralmanager.mm +++ b/src/bluetooth/osx/osxbtperipheralmanager.mm @@ -343,7 +343,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) if (manager.data()) [manager setDelegate:nil]; manager.reset([[CBPeripheralManager alloc] initWithDelegate:self - queue:OSXBluetooth::qt_LE_queue()]); + queue:DarwinBluetooth::qt_LE_queue()]); } - (void)stopAdvertising @@ -383,7 +383,7 @@ 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 @@ -800,11 +800,12 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) } #ifdef Q_OS_IOS - if (ch.value().length() > OSXBluetooth::maxValueLength) { + if (ch.value().length() > DarwinBluetooth::maxValueLength) { qCWarning(QT_BT_OSX) << "addCharacteristicsAndDescritptors: " "value exceeds the maximal permitted " - "value length (" << OSXBluetooth::maxValueLength - << "octets) on the platform"; + "value length (" + << DarwinBluetooth::maxValueLength + << "octets) on the platform"; continue; } #endif diff --git a/src/bluetooth/osx/osxbtperipheralmanager_p.h b/src/bluetooth/osx/osxbtperipheralmanager_p.h index fcf55698..72f6efb4 100644 --- a/src/bluetooth/osx/osxbtperipheralmanager_p.h +++ b/src/bluetooth/osx/osxbtperipheralmanager_p.h @@ -77,12 +77,12 @@ 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> diff --git a/src/bluetooth/osx/osxbtrfcommchannel.mm b/src/bluetooth/osx/osxbtrfcommchannel.mm index d2d3e2f8..8154a842 100644 --- a/src/bluetooth/osx/osxbtrfcommchannel.mm +++ b/src/bluetooth/osx/osxbtrfcommchannel.mm @@ -115,7 +115,7 @@ QT_USE_NAMESPACE 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"; diff --git a/src/bluetooth/osx/osxbtsdpinquiry.mm b/src/bluetooth/osx/osxbtsdpinquiry.mm index a2b02b1a..02d03033 100644 --- a/src/bluetooth/osx/osxbtsdpinquiry.mm +++ b/src/bluetooth/osx/osxbtsdpinquiry.mm @@ -48,7 +48,7 @@ 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,13 +200,13 @@ 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) { diff --git a/src/bluetooth/osx/osxbtsdpinquiry_p.h b/src/bluetooth/osx/osxbtsdpinquiry_p.h index e2658670..ea3b99f6 100644 --- a/src/bluetooth/osx/osxbtsdpinquiry_p.h +++ b/src/bluetooth/osx/osxbtsdpinquiry_p.h @@ -72,15 +72,11 @@ 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 diff --git a/src/bluetooth/osx/osxbtservicerecord.mm b/src/bluetooth/osx/osxbtservicerecord.mm index 23d55d13..18e7a58b 100644 --- a/src/bluetooth/osx/osxbtservicerecord.mm +++ b/src/bluetooth/osx/osxbtservicerecord.mm @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE -namespace OSXBluetooth { +namespace DarwinBluetooth { // // Returns a dictionary containing the Bluetooth RFCOMM service definition diff --git a/src/bluetooth/osx/osxbtservicerecord_p.h b/src/bluetooth/osx/osxbtservicerecord_p.h index 6b2db8a8..685a7274 100644 --- a/src/bluetooth/osx/osxbtservicerecord_p.h +++ b/src/bluetooth/osx/osxbtservicerecord_p.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/osxbtutility.mm b/src/bluetooth/osx/osxbtutility.mm index e17006de..a6cf16c4 100644 --- a/src/bluetooth/osx/osxbtutility.mm +++ b/src/bluetooth/osx/osxbtutility.mm @@ -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 @@ -70,7 +68,7 @@ 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: @@ -381,6 +379,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/osx/osxbtutility_p.h index c2bc6cf8..fb0d6b09 100644 --- a/src/bluetooth/osx/osxbtutility_p.h +++ b/src/bluetooth/osx/osxbtutility_p.h @@ -65,7 +65,7 @@ class QLowEnergyCharacteristicData; class QBluetoothAddress; class QBluetoothUuid; -namespace OSXBluetooth { +namespace DarwinBluetooth { struct NSObjectDeleter { static void cleanup(NSObject *obj) @@ -189,7 +189,7 @@ private: // 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; +// like DarwinBluetooth::CFStrongReference<DarwinBluetooth::remove_pointer<CFUUIDRref>> strongReference; // so instead we use 'T' everywhere, not 'T *' as can expected // from a smart pointer. template<class T> @@ -307,7 +307,7 @@ 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) @@ -331,6 +331,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 // OSXBTUTILITY_P_H diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm index d9883d28..1ed74b9f 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm @@ -95,7 +95,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 @@ -121,7 +121,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 +187,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. @@ -220,7 +220,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 +265,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; @@ -350,7 +350,7 @@ 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"; return; @@ -366,7 +366,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); diff --git a/src/bluetooth/qbluetoothlocaldevice_osx.mm b/src/bluetooth/qbluetoothlocaldevice_osx.mm index e7dd9906..c39ae100 100644 --- a/src/bluetooth/qbluetoothlocaldevice_osx.mm +++ b/src/bluetooth/qbluetoothlocaldevice_osx.mm @@ -43,6 +43,7 @@ #include "osx/osxbtdevicepair_p.h" #include "osx/osxbtutility_p.h" #include "osx/osxbluetooth_p.h" +#include "osx/btdelegates_p.h" #include <QtCore/qloggingcategory.h> #include <QtCore/qstring.h> @@ -57,8 +58,8 @@ 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 +75,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 +95,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(OSXBTPairing); + using PairingRequest = DarwinBluetooth::ObjCStrongReference<ObjCPairingRequest>; + using RequestMap = QMap<QBluetoothAddress, PairingRequest>; RequestMap pairingRequests; - - OSXBluetooth::ObjCScopedPointer<ObjCConnectionMonitor> connectionMonitor; + using ObjCConnectionMonitor = QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor); + DarwinBluetooth::ObjCScopedPointer<ObjCConnectionMonitor> connectionMonitor; QList<QBluetoothAddress> discoveredDevices; }; @@ -135,7 +137,7 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice return; } - if (address != OSXBluetooth::qt_address(&iobtAddress)) { + if (address != DarwinBluetooth::qt_address(&iobtAddress)) { qCCritical(QT_BT_OSX) << "invalid local device's address"; return; } @@ -157,8 +159,8 @@ 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; // That's a really special case on OS X. if (pairing == QBluetoothLocalDevice::Unpaired) @@ -209,8 +211,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 +232,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 +266,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]; @@ -369,7 +375,7 @@ 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"; } else { @@ -411,7 +417,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); } @@ -464,7 +470,7 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai return; } - OSXBluetooth::qt_test_iobluetooth_runloop(); + DarwinBluetooth::qt_test_iobluetooth_runloop(); return d_ptr->requestPairing(address, pairing); } diff --git a/src/bluetooth/qbluetoothserver_osx.mm b/src/bluetooth/qbluetoothserver_osx.mm index 83d7e060..0970dac9 100644 --- a/src/bluetooth/qbluetoothserver_osx.mm +++ b/src/bluetooth/qbluetoothserver_osx.mm @@ -84,7 +84,7 @@ QMap<quint16, QBluetoothServerPrivate *> &busyChannels() typedef QMap<quint16, QBluetoothServerPrivate *>::iterator ServerMapIterator; -} +} // unnamed namespace QBluetoothServerPrivate::QBluetoothServerPrivate(ServiceInfo::Protocol type, @@ -288,7 +288,7 @@ 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"; 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_osx.mm index d8decae1..6c3ed79d 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm +++ b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm @@ -153,7 +153,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; @@ -194,7 +194,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 +211,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/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_osx.mm index 41e4e8b7..ac8e6b33 100644 --- a/src/bluetooth/qbluetoothserviceinfo_osx.mm +++ b/src/bluetooth/qbluetoothserviceinfo_osx.mm @@ -105,12 +105,12 @@ 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) { diff --git a/src/bluetooth/qbluetoothsocket_osx.mm b/src/bluetooth/qbluetoothsocket_osx.mm index f74c14f8..cd1206cc 100644 --- a/src/bluetooth/qbluetoothsocket_osx.mm +++ b/src/bluetooth/qbluetoothsocket_osx.mm @@ -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 @@ -261,7 +261,7 @@ 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"; @@ -305,7 +305,7 @@ 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) { @@ -334,7 +334,7 @@ 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"; @@ -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/qbluetoothtransferreply_osx.mm b/src/bluetooth/qbluetoothtransferreply_osx.mm index 40a747f8..af357d53 100644 --- a/src/bluetooth/qbluetoothtransferreply_osx.mm +++ b/src/bluetooth/qbluetoothtransferreply_osx.mm @@ -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. diff --git a/src/bluetooth/qlowenergycontroller_darwin.mm b/src/bluetooth/qlowenergycontroller_darwin.mm index 253956e2..7cdf114c 100644 --- a/src/bluetooth/qlowenergycontroller_darwin.mm +++ b/src/bluetooth/qlowenergycontroller_darwin.mm @@ -80,7 +80,7 @@ ServicePrivate qt_createLEService(QLowEnergyControllerPrivateDarwin *controller, 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; } @@ -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) { @@ -215,7 +215,7 @@ 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"; setErrorDescription(QLowEnergyController::UnknownError); @@ -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(); @@ -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); @@ -298,7 +298,7 @@ void QLowEnergyControllerPrivateDarwin::discoverServiceDetails(const QBluetoothU 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)); @@ -384,7 +384,7 @@ 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; @@ -739,7 +739,7 @@ void QLowEnergyControllerPrivateDarwin::setNotifyValue(QSharedPointer<QLowEnergy 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>(); @@ -774,7 +774,7 @@ void QLowEnergyControllerPrivateDarwin::readCharacteristic(const QSharedPointer< 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. @@ -806,7 +806,7 @@ void QLowEnergyControllerPrivateDarwin::writeCharacteristic(const QSharedPointer 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); @@ -871,7 +871,7 @@ void QLowEnergyControllerPrivateDarwin::readDescriptor(const QSharedPointer<QLow 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"; return; @@ -908,7 +908,7 @@ void QLowEnergyControllerPrivateDarwin::writeDescriptor(const QSharedPointer<QLo 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)"); @@ -1048,7 +1048,7 @@ void QLowEnergyControllerPrivateDarwin::startAdvertising(const QLowEnergyAdverti return; } - auto leQueue(OSXBluetooth::qt_LE_queue()); + auto leQueue(DarwinBluetooth::qt_LE_queue()); if (!leQueue) { qCWarning(QT_BT_OSX) << "no LE queue found"; setErrorDescription(QLowEnergyController::UnknownError); @@ -1079,7 +1079,7 @@ void QLowEnergyControllerPrivateDarwin::stopAdvertising() 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]; diff --git a/src/bluetooth/qlowenergycontroller_darwin_p.h b/src/bluetooth/qlowenergycontroller_darwin_p.h index 960d7fbc..1f34457e 100644 --- a/src/bluetooth/qlowenergycontroller_darwin_p.h +++ b/src/bluetooth/qlowenergycontroller_darwin_p.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; |