diff options
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | dependencies.yaml | 10 | ||||
-rw-r--r-- | src/bluetooth/android/devicediscoverybroadcastreceiver.cpp | 8 | ||||
-rw-r--r-- | src/bluetooth/bluetooth.pro | 22 | ||||
-rw-r--r-- | src/bluetooth/bluez/bluetoothmanagement.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/bluez/hcimanager.cpp | 6 | ||||
-rw-r--r-- | src/bluetooth/darwin/btcentralmanager.mm (renamed from src/bluetooth/osx/osxbtcentralmanager.mm) | 257 | ||||
-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) | 25 | ||||
-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) | 28 | ||||
-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.cpp | 1 | ||||
-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) | 86 | ||||
-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) | 79 | ||||
-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) | 0 | ||||
-rw-r--r-- | src/bluetooth/darwin/btraii_p.h (renamed from src/bluetooth/osx/btraii_p.h) | 0 | ||||
-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) | 22 | ||||
-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) | 7 | ||||
-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) | 34 | ||||
-rw-r--r-- | src/bluetooth/darwin/btutility_p.h (renamed from src/bluetooth/osx/osxbtutility_p.h) | 25 | ||||
-rw-r--r-- | src/bluetooth/darwin/darwinbt.pri | 48 | ||||
-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.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtconnectionmonitor_p.h | 89 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtnotifier.cpp | 1 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm | 57 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_p.h | 4 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp | 6 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp | 4 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothlocaldevice_macos.mm (renamed from src/bluetooth/qbluetoothlocaldevice_osx.mm) | 101 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothserver_macos.mm (renamed from src/bluetooth/qbluetoothserver_osx.mm) | 53 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothserver_p.h | 4 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothservicediscoveryagent.cpp | 4 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothservicediscoveryagent_macos.mm (renamed from src/bluetooth/qbluetoothservicediscoveryagent_osx.mm) | 19 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothservicediscoveryagent_p.h | 4 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp | 18 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothserviceinfo_macos.mm (renamed from src/bluetooth/qbluetoothserviceinfo_osx.mm) | 19 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothserviceinfo_p.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocket.cpp | 2 | ||||
-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.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply_macos.mm (renamed from src/bluetooth/qbluetoothtransferreply_osx.mm) | 22 | ||||
-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.cpp | 48 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_darwin.mm | 182 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_darwin_p.h | 6 | ||||
-rw-r--r-- | src/bluetooth/windows/windows.pri | 2 | ||||
-rw-r--r-- | src/nfc/targetemulator.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp | 6 |
71 files changed, 824 insertions, 867 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..14a47c4e --- /dev/null +++ b/dependencies.yaml @@ -0,0 +1,10 @@ +dependencies: + ../qtandroidextras: + ref: e3542a8c8ce2a8dc1b3ef0a550f5b785c820e5a3 + required: false + ../qtbase: + ref: 8b91c6831546f884437122ce243b8a08c328a13c + required: true + ../qtdeclarative: + ref: 7b2e90258c2e4719d41c5306c3d55a604ef1520b + 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/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/osx/osxbtcentralmanager.mm b/src/bluetooth/darwin/btcentralmanager.mm index b9a1ae0f..dd3cbb73 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) { @@ -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; @@ -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]; @@ -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]); 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; @@ -376,7 +376,7 @@ QT_USE_NAMESPACE std::copy(qtUuidData.data, qtUuidData.data + 16, uuidData); const ObjCScopedPointer<NSUUID> nsUuid([[NSUUID alloc] initWithUUIDBytes:uuidData]); 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)"); @@ -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,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; } @@ -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,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; - 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 +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); @@ -1396,7 +1397,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 +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; @@ -1584,8 +1585,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 +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; @@ -1712,8 +1713,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 +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; @@ -1758,8 +1759,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 +1787,7 @@ QT_USE_NAMESPACE return; } - using namespace OSXBluetooth; + using namespace DarwinBluetooth; QT_BT_MAC_AUTORELEASEPOOL; @@ -1795,7 +1796,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 +1821,7 @@ QT_USE_NAMESPACE if (!notifier) return; - using namespace OSXBluetooth; + using namespace DarwinBluetooth; QT_BT_MAC_AUTORELEASEPOOL; @@ -1835,7 +1836,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..2c212c2d 100644 --- a/src/bluetooth/osx/osxbtdevicepair.mm +++ b/src/bluetooth/darwin/btdevicepair.mm @@ -37,15 +37,15 @@ ** ****************************************************************************/ -#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) { @@ -57,28 +57,23 @@ ObjCStrongReference<IOBluetoothDevice> device_with_address(const QBluetoothAddre 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..b3f29035 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,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; @@ -342,14 +342,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..ba48aab0 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() @@ -203,7 +203,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; } @@ -358,7 +358,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 +378,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 +395,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 +417,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 +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,20 +457,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 +495,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 +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)"); @@ -538,8 +538,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 +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,13 +612,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 +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; @@ -649,13 +649,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); if (!headers) { - qCWarning(QT_BT_OSX) << "failed to allocate headers"; + qCWarning(QT_BT_DARWIN) << "failed to allocate headers"; return kOBEXNoResourcesError; } @@ -665,14 +665,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 +685,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; } @@ -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)"); @@ -732,8 +732,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 +754,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 +770,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); @@ -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/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..d4713ace 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> @@ -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 {}; } @@ -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; @@ -232,7 +232,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) 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 {}; } @@ -246,7 +246,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) false /*do not retain*/); if (!newCBService) { - qCCritical(QT_BT_OSX) << "addService: failed to create CBMutableService"; + qCCritical(QT_BT_DARWIN) << "addService: failed to create CBMutableService"; return {}; } @@ -294,8 +294,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) advertisementData.reset([[NSMutableDictionary alloc] init]); if (!advertisementData) { - qCWarning(QT_BT_OSX) << "setParameters: failed to allocate " - "NSMutableDictonary (advertisementData)"; + qCWarning(QT_BT_DARWIN) << "setParameters: failed to allocate " + "NSMutableDictonary (advertisementData)"; return; } @@ -313,8 +313,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) const ObjCScopedPointer<NSMutableArray> uuids([[NSMutableArray alloc] init]); 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; } @@ -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,11 +383,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; } @@ -552,14 +552,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; } @@ -670,9 +670,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]) @@ -755,8 +755,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) ObjCScopedPointer<NSMutableArray> included([[NSMutableArray alloc] init]); 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"; } } @@ -786,24 +786,25 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) ObjCScopedPointer<NSMutableArray> newCBChars([[NSMutableArray alloc] init]); 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 +812,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; } @@ -839,9 +840,9 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) const ObjCScopedPointer<NSMutableArray> newCBDescs([[NSMutableArray alloc] init]); if (!newCBDescs) { - qCWarning(QT_BT_OSX) << "addCharacteristicsAndDescritptors: " - "failed to allocate NSMutableArray " - "(descriptors)"; + qCWarning(QT_BT_DARWIN) << "addCharacteristicsAndDescritptors: " + "failed to allocate NSMutableArray " + "(descriptors)"; continue; } 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..a1bf2a8d 100644 --- a/src/bluetooth/osx/btraii.mm +++ b/src/bluetooth/darwin/btraii.mm diff --git a/src/bluetooth/osx/btraii_p.h b/src/bluetooth/darwin/btraii_p.h index 6053d63b..6053d63b 100644 --- a/src/bluetooth/osx/btraii_p.h +++ b/src/bluetooth/darwin/btraii_p.h 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..336d7541 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,15 +200,15 @@ 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; @@ -255,7 +255,7 @@ using namespace OSXBluetooth; if (qtFilters.size()) { array.reset([[NSMutableArray alloc] init]); 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,7 +266,7 @@ 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; } } @@ -274,7 +274,7 @@ using namespace OSXBluetooth; 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"; + qCCritical(QT_BT_DARWIN) << "failed to create an IOBluetoothDevice object"; return kIOReturnError; } @@ -288,7 +288,7 @@ using namespace OSXBluetooth; result = [device performSDPQuery:self]; if (result != kIOReturnSuccess) { - qCCritical(QT_BT_OSX) << "failed to start an SDP query"; + qCCritical(QT_BT_DARWIN) << "failed to start an SDP query"; device = oldDevice.take(); } else { isActive = true; 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..82067558 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 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..6f223a82 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: @@ -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,15 +196,11 @@ 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) @@ -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..3108b515 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,21 +51,25 @@ // We mean it. // -#include "osxbluetooth_p.h" - #include <QtCore/qloggingcategory.h> #include <QtCore/qscopedpointer.h> #include <QtCore/qglobal.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 { +namespace DarwinBluetooth { struct NSObjectDeleter { static void cleanup(NSObject *obj) @@ -189,7 +193,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,10 +311,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 +334,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 27220a09..263ab9ca 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 5376ad2f..71cf77f1 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp @@ -880,7 +880,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..805c882a 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; }; @@ -118,25 +121,25 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice HostController defaultController([[IOBluetoothHostController defaultController] retain]); 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; } } @@ -157,8 +160,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) @@ -179,7 +182,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; @@ -190,7 +193,7 @@ void QBluetoothLocalDevicePrivate::requestPairing(const QBluetoothAddress &addre // it'll just finish with success (skipping any intermediate steps). PairingRequest newRequest([[ObjCPairingRequest alloc] initWithTarget:address delegate:this], false); 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 +202,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 +212,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 +233,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 +267,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 +364,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 +376,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 +389,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 +397,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 +418,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 +442,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 +464,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 +479,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(¤t); } 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 f74c14f8..dd347e21 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..986d5e15 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. @@ -177,7 +177,7 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev 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; @@ -186,7 +186,7 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev OBEXSession newSession([[ObjCOBEXSession alloc] initWithDelegate:this remoteDevice:device channelID:channelID]); 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)); @@ -201,7 +201,7 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev 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. @@ -355,7 +355,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; @@ -416,7 +416,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..34e6cab4 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; } @@ -457,7 +457,7 @@ void QLowEnergyControllerPrivateDarwin::_q_serviceDiscoveryFinished() toVisitNext.resetWithoutRetain([[NSMutableArray alloc] init]); } } 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/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; |