summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/osx
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2016-06-10 07:35:32 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-06-10 07:35:37 +0200
commit3c5aa0bb759684b989ee590e223ee16ae11af35d (patch)
tree1c42974b07885b2de4a6ee807d6fb83d679bfcd2 /src/bluetooth/osx
parentc032c9f27cddf41ef0d0688d2d0e8b41348c9f22 (diff)
parentdb55878a269450d7a8f559e5d3862403eba7fbc8 (diff)
Merge remote-tracking branch 'gerrit/dev' into btle
Diffstat (limited to 'src/bluetooth/osx')
-rw-r--r--src/bluetooth/osx/osxbtcentralmanager.mm174
-rw-r--r--src/bluetooth/osx/osxbtdeviceinquiry.mm8
-rw-r--r--src/bluetooth/osx/osxbtdevicepair.mm18
-rw-r--r--src/bluetooth/osx/osxbtl2capchannel.mm8
-rw-r--r--src/bluetooth/osx/osxbtledeviceinquiry.mm79
-rw-r--r--src/bluetooth/osx/osxbtobexsession.mm38
-rw-r--r--src/bluetooth/osx/osxbtrfcommchannel.mm8
-rw-r--r--src/bluetooth/osx/osxbtsdpinquiry.mm8
8 files changed, 97 insertions, 244 deletions
diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/osx/osxbtcentralmanager.mm
index 3b0e098d..55a06021 100644
--- a/src/bluetooth/osx/osxbtcentralmanager.mm
+++ b/src/bluetooth/osx/osxbtcentralmanager.mm
@@ -43,7 +43,6 @@
#include "osxbtnotifier_p.h"
#include <QtCore/qloggingcategory.h>
-#include <QtCore/qsysinfo.h>
#include <QtCore/qdebug.h>
#include <algorithm>
@@ -171,7 +170,7 @@ QT_END_NAMESPACE
if (!manager) {
managerState = OSXBluetooth::CentralManagerIdle;
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate a central manager";
+ qCWarning(QT_BT_OSX) << "failed to allocate a central manager";
if (notifier)
emit notifier->CBManagerError(QLowEnergyController::ConnectionError);
}
@@ -187,7 +186,7 @@ QT_END_NAMESPACE
Q_FUNC_INFO, "invalid state");
if ([self isConnected]) {
- qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "already connected";
+ qCDebug(QT_BT_OSX) << "already connected";
if (notifier)
emit notifier->connected();
return;
@@ -203,62 +202,37 @@ QT_END_NAMESPACE
// Retrieve a peripheral first ...
ObjCScopedPointer<NSMutableArray> uuids([[NSMutableArray alloc] init]);
if (!uuids) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate identifiers";
+ qCWarning(QT_BT_OSX) << "failed to allocate identifiers";
if (notifier)
emit notifier->CBManagerError(QLowEnergyController::ConnectionError);
return;
}
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_7_0)
- if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_7_0)) {
- const quint128 qtUuidData(deviceUuid.toUInt128());
- // STATIC_ASSERT on sizes would be handy!
- uuid_t uuidData = {};
- std::copy(qtUuidData.data, qtUuidData.data + 16, uuidData);
- const ObjCScopedPointer<NSUUID> nsUuid([[NSUUID alloc] initWithUUIDBytes:uuidData]);
- if (!nsUuid) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate NSUUID identifier";
- if (notifier)
- emit notifier->CBManagerError(QLowEnergyController::ConnectionError);
- return;
- }
- [uuids addObject:nsUuid];
- // With the latest CoreBluetooth, we can synchronously retrive peripherals:
- QT_BT_MAC_AUTORELEASEPOOL;
- NSArray *const peripherals = [manager retrievePeripheralsWithIdentifiers:uuids];
- if (!peripherals || peripherals.count != 1) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to retrive a peripheral";
- if (notifier)
- emit notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError);
- return;
- }
-
- peripheral = [static_cast<CBPeripheral *>([peripherals objectAtIndex:0]) retain];
- [self connectToPeripheral];
- return;
- }
-#endif
- // Either SDK or the target is below 10.9/7.0
- if (![manager respondsToSelector:@selector(retrievePeripherals:)]) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to retrive a peripheral";
+ const quint128 qtUuidData(deviceUuid.toUInt128());
+ uuid_t uuidData = {};
+ 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";
if (notifier)
- emit notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError);
+ emit notifier->CBManagerError(QLowEnergyController::ConnectionError);
return;
}
- OSXBluetooth::CFStrongReference<CFUUIDRef> cfUuid(OSXBluetooth::cf_uuid(deviceUuid));
- if (!cfUuid) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to create CFUUID object";
+ [uuids addObject:nsUuid];
+ // With the latest CoreBluetooth, we can synchronously retrive peripherals:
+ QT_BT_MAC_AUTORELEASEPOOL;
+ NSArray *const peripherals = [manager retrievePeripheralsWithIdentifiers:uuids];
+ if (!peripherals || peripherals.count != 1) {
+ qCWarning(QT_BT_OSX) << "failed to retrive a peripheral";
if (notifier)
- emit notifier->CBManagerError(QLowEnergyController::ConnectionError);
+ emit notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError);
return;
}
- // With ARC this cast will be illegal:
- [uuids addObject:(id)cfUuid.data()];
- // Unfortunately, with old Core Bluetooth this call is asynchronous ...
- managerState = OSXBluetooth::CentralManagerConnecting;
- [manager performSelector:@selector(retrievePeripherals:) withObject:uuids.data()];
+
+ peripheral = [static_cast<CBPeripheral *>([peripherals objectAtIndex:0]) retain];
+ [self connectToPeripheral];
}
- (void)connectToPeripheral
@@ -270,11 +244,11 @@ QT_END_NAMESPACE
// The state is still the same - connecting.
if ([self isConnected]) {
- qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "already connected";
+ qCDebug(QT_BT_OSX) << "already connected";
if (notifier)
emit notifier->connected();
} else {
- qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "trying to connect";
+ qCDebug(QT_BT_OSX) << "trying to connect";
managerState = OSXBluetooth::CentralManagerConnecting;
[manager connectPeripheral:peripheral options:nil];
}
@@ -285,18 +259,7 @@ QT_END_NAMESPACE
if (!peripheral)
return false;
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_7_0)
- using OSXBluetooth::qt_OS_limit;
-
- if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_7_0))
- return peripheral.state == CBPeripheralStateConnected;
-#endif
- // Either SDK or the target is below 10.9/7.0 ...
- if (![peripheral respondsToSelector:@selector(isConnected)])
- return false;
-
- // Ugly cast to deal with id being a pointer ...
- return reinterpret_cast<quintptr>([peripheral performSelector:@selector(isConnected)]);
+ return peripheral.state == CBPeripheralStateConnected;
}
- (void)disconnectFromDevice
@@ -389,7 +352,7 @@ QT_END_NAMESPACE
Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
if (servicesToDiscoverDetails.contains(serviceUuid)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO <<"already discovering for "
+ qCWarning(QT_BT_OSX) << "already discovering for"
<< serviceUuid;
return;
}
@@ -402,7 +365,7 @@ QT_END_NAMESPACE
return;
}
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown service uuid "
+ qCWarning(QT_BT_OSX) << "unknown service uuid"
<< serviceUuid;
if (notifier) {
@@ -499,7 +462,7 @@ QT_END_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) << Q_FUNC_INFO << "can not allocate more handles";
+ qCWarning(QT_BT_OSX) << "can not allocate more handles";
if (notifier)
notifier->CBManagerError(serviceUuid, QLowEnergyService::OperationError);
return;
@@ -603,7 +566,7 @@ QT_END_NAMESPACE
const LERequest request(requests.dequeue());
if (request.type == LERequest::CharRead) {
if (!charMap.contains(request.handle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "characteristic with handle"
+ qCWarning(QT_BT_OSX) << "characteristic with handle"
<< request.handle << "not found";
return [self performNextRequest];
}
@@ -613,7 +576,7 @@ QT_END_NAMESPACE
[peripheral readValueForCharacteristic:charMap[request.handle]];
} else {
if (!descMap.contains(request.handle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "descriptor with handle"
+ qCWarning(QT_BT_OSX) << "descriptor with handle"
<< request.handle << "not found";
return [self performNextRequest];
}
@@ -640,8 +603,8 @@ QT_END_NAMESPACE
if (request.type == LERequest::DescWrite) {
if (!descMap.contains(request.handle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "handle: "
- << request.handle << " not found";
+ qCWarning(QT_BT_OSX) << "handle:" << request.handle
+ << "not found";
return [self performNextRequest];
}
@@ -649,8 +612,7 @@ QT_END_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) << Q_FUNC_INFO << "failed "
- "to allocate an NSData object";
+ qCWarning(QT_BT_OSX) << "failed to allocate an NSData object";
return [self performNextRequest];
}
@@ -661,8 +623,8 @@ QT_END_NAMESPACE
return [peripheral writeValue:data.data() forDescriptor:descriptor];
} else {
if (!charMap.contains(request.handle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "characteristic with "
- "handle: " << request.handle << " not found";
+ qCWarning(QT_BT_OSX) << "characteristic with handle:"
+ << request.handle << "not found";
return [self performNextRequest];
}
@@ -687,7 +649,7 @@ QT_END_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) << Q_FUNC_INFO << "failed to allocate NSData object";
+ qCWarning(QT_BT_OSX) << "failed to allocate NSData object";
return [self performNextRequest];
}
@@ -717,8 +679,7 @@ QT_END_NAMESPACE
Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle (0)");
if (!charMap.contains(charHandle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO
- << "unknown characteristic handle "
+ qCWarning(QT_BT_OSX) << "unknown characteristic handle"
<< charHandle;
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
@@ -732,8 +693,7 @@ QT_END_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) << Q_FUNC_INFO
- << "no client characteristic configuration found";
+ qCWarning(QT_BT_OSX) << "no client characteristic configuration found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::DescriptorWriteError);
@@ -760,7 +720,7 @@ QT_END_NAMESPACE
QT_BT_MAC_AUTORELEASEPOOL;
if (!charMap.contains(charHandle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "characteristic: " << charHandle << " not found";
+ qCWarning(QT_BT_OSX) << "characteristic:" << charHandle << "not found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::CharacteristicReadError);
@@ -789,8 +749,7 @@ QT_END_NAMESPACE
QT_BT_MAC_AUTORELEASEPOOL;
if (!charMap.contains(charHandle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "characteristic: "
- << charHandle << " not found";
+ qCWarning(QT_BT_OSX) << "characteristic:" << charHandle << "not found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::CharacteristicWriteError);
@@ -816,8 +775,7 @@ QT_END_NAMESPACE
Q_ASSERT_X(descHandle, Q_FUNC_INFO, "invalid descriptor handle (0)");
if (!descMap.contains(descHandle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "handle:"
- << descHandle << "not found";
+ qCWarning(QT_BT_OSX) << "handle:" << descHandle << "not found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::DescriptorReadError);
@@ -842,8 +800,7 @@ QT_END_NAMESPACE
Q_ASSERT_X(descHandle, Q_FUNC_INFO, "invalid descriptor handle (0)");
if (!descMap.contains(descHandle)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "handle: "
- << descHandle << " not found";
+ qCWarning(QT_BT_OSX) << "handle:" << descHandle << "not found";
if (notifier) {
emit notifier->CBManagerError(serviceUuid,
QLowEnergyService::DescriptorWriteError);
@@ -1029,27 +986,25 @@ QT_END_NAMESPACE
if ([obj isKindOfClass:[CBCharacteristic class]]) {
CBCharacteristic *const ch = static_cast<CBCharacteristic *>(obj);
if (!charMap.key(ch)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unexpected "
- "characteristic, no handle found";
+ qCWarning(QT_BT_OSX) << "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) << Q_FUNC_INFO << "unexpected "
- "descriptor, no handle found";
+ qCWarning(QT_BT_OSX) << "unexpected descriptor, no handle found";
return false;
}
} else {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid object, "
- "characteristic or descriptor required";
+ qCWarning(QT_BT_OSX) << "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) << Q_FUNC_INFO << "already has a cached value for this "
+ qCWarning(QT_BT_OSX) << "already has a cached value for this "
"object, the value will be replaced";
}
@@ -1132,30 +1087,6 @@ QT_END_NAMESPACE
}
}
-- (void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals
-{
- Q_UNUSED(central)
-
- // This method is required for iOS before 7.0 and OS X below 10.9.
- Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid central manager (nil)");
-
- if (managerState != OSXBluetooth::CentralManagerConnecting) {
- // Canceled by calling -disconnectFromDevice method.
- return;
- }
-
- managerState = OSXBluetooth::CentralManagerIdle;
-
- if (!peripherals || peripherals.count != 1) {
- qCDebug(QT_BT_OSX) << Q_FUNC_INFO <<"unexpected number of peripherals (!= 1)";
- if (notifier)
- emit notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError);
- } else {
- peripheral = [static_cast<CBPeripheral *>([peripherals objectAtIndex:0]) retain];
- [self connectToPeripheral];
- }
-}
-
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)aPeripheral
{
Q_UNUSED(central)
@@ -1200,7 +1131,7 @@ QT_END_NAMESPACE
if (error && managerState == OSXBluetooth::CentralManagerDisconnecting) {
managerState = OSXBluetooth::CentralManagerIdle;
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to disconnect";
+ qCWarning(QT_BT_OSX) << "failed to disconnect";
if (notifier)
emit notifier->CBManagerError(QLowEnergyController::UnknownRemoteDeviceError);
} else {
@@ -1381,7 +1312,7 @@ QT_END_NAMESPACE
// updated values ...
// TODO: this must be properly tested.
if (!chHandle) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "unexpected update notification, "
+ qCCritical(QT_BT_OSX) << "unexpected update notification, "
"no characteristic handle found";
return;
}
@@ -1492,7 +1423,7 @@ QT_END_NAMESPACE
}
} else {
if (!dHandle) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "unexpected value update notification, "
+ qCCritical(QT_BT_OSX) << "unexpected value update notification, "
"no descriptor handle found";
return;
}
@@ -1535,8 +1466,8 @@ QT_END_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) << Q_FUNC_INFO << "no updated value found"
- " for characteristic";
+ qCWarning(QT_BT_OSX) << "no updated value found "
+ "for characteristic";
}
if (error) {
@@ -1571,7 +1502,7 @@ QT_END_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) << Q_FUNC_INFO << "no updated value found";
+ qCWarning(QT_BT_OSX) << "no updated value found";
if (error) {
NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
@@ -1579,8 +1510,7 @@ QT_END_NAMESPACE
QLowEnergyService::DescriptorWriteError);
} else {
const QLowEnergyHandle dHandle = descMap.key(descriptor);
- Q_ASSERT_X(dHandle, Q_FUNC_INFO,
- "descriptor not found in the descriptors map");
+ Q_ASSERT_X(dHandle, Q_FUNC_INFO, "descriptor not found in the descriptors map");
emit notifier->descriptorWritten(dHandle, valueToReport);
}
diff --git a/src/bluetooth/osx/osxbtdeviceinquiry.mm b/src/bluetooth/osx/osxbtdeviceinquiry.mm
index d38110c7..870a9c88 100644
--- a/src/bluetooth/osx/osxbtdeviceinquiry.mm
+++ b/src/bluetooth/osx/osxbtdeviceinquiry.mm
@@ -78,8 +78,7 @@ using namespace QT_NAMESPACE;
[m_inquiry setUpdateNewDeviceNames:NO];//Useless, disable!
m_delegate = delegate;
} else {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create "
- "a device inquiry";
+ qCCritical(QT_BT_OSX) << "failed to create a device inquiry";
}
m_active = false;
@@ -118,8 +117,7 @@ using namespace QT_NAMESPACE;
if (result != kIOReturnSuccess) {
// QtBluetooth will probably convert an error into UnknownError,
// loosing the actual information.
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO <<"failed with "
- "IOKit error code: " << result;
+ qCWarning(QT_BT_OSX) << "failed with IOKit error code:" << result;
m_active = false;
}
@@ -159,7 +157,7 @@ using namespace QT_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) << Q_FUNC_INFO << "IOKit error code: " << error;
+ qCWarning(QT_BT_OSX) << "IOKit error code: " << error;
m_delegate->error(sender, error);
} else {
m_delegate->inquiryFinished(sender);
diff --git a/src/bluetooth/osx/osxbtdevicepair.mm b/src/bluetooth/osx/osxbtdevicepair.mm
index 737a312f..e2d96ce4 100644
--- a/src/bluetooth/osx/osxbtdevicepair.mm
+++ b/src/bluetooth/osx/osxbtdevicepair.mm
@@ -41,7 +41,6 @@
#include "osxbtutility_p.h"
#include <QtCore/qloggingcategory.h>
-#include <QtCore/qsysinfo.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -91,18 +90,8 @@ using namespace QT_NAMESPACE;
- (void)dealloc
{
-#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9)
- // Stop also sets a delegate to nil (Apple's docs).
- // 10.9 only.
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9)
- [m_pairing stop];
- else
- [m_pairing setDelegate:nil];
-#else
- [m_pairing setDelegate:nil];
-#endif
+ [m_pairing stop];
[m_pairing release];
-
[super dealloc];
}
@@ -119,14 +108,13 @@ using namespace QT_NAMESPACE;
// Device is autoreleased.
IOBluetoothDevice *const device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
if (!device) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create a device "
- "to pair with";
+ qCCritical(QT_BT_OSX) << "failed to create a device to pair with";
return kIOReturnError;
}
m_pairing = [[IOBluetoothDevicePair pairWithDevice:device] retain];
if (!m_pairing) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create pair";
+ qCCritical(QT_BT_OSX) << "failed to create pair";
return kIOReturnError;
}
diff --git a/src/bluetooth/osx/osxbtl2capchannel.mm b/src/bluetooth/osx/osxbtl2capchannel.mm
index 2d596654..3156c0d2 100644
--- a/src/bluetooth/osx/osxbtl2capchannel.mm
+++ b/src/bluetooth/osx/osxbtl2capchannel.mm
@@ -106,13 +106,13 @@ using namespace QT_NAMESPACE;
withPSM:(BluetoothL2CAPChannelID)psm
{
if (address.isNull()) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "invalid peer address";
+ qCCritical(QT_BT_OSX) << "invalid peer address";
return kIOReturnNoDevice;
}
// Can never be called twice.
if (connected || device || channel) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "connection is already active";
+ qCCritical(QT_BT_OSX) << "connection is already active";
return kIOReturnStillOpen;
}
@@ -121,13 +121,13 @@ using namespace QT_NAMESPACE;
const BluetoothDeviceAddress iobtAddress = OSXBluetooth::iobluetooth_address(address);
device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
if (!device) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create a device";
+ qCCritical(QT_BT_OSX) << "failed to create a device";
return kIOReturnNoDevice;
}
const IOReturn status = [device openL2CAPChannelAsync:&channel withPSM:psm delegate:self];
if (status != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to open L2CAP channel";
+ qCCritical(QT_BT_OSX) << "failed to open L2CAP channel";
// device is still autoreleased.
device = nil;
return status;
diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/osx/osxbtledeviceinquiry.mm
index 88370fa6..58cecccc 100644
--- a/src/bluetooth/osx/osxbtledeviceinquiry.mm
+++ b/src/bluetooth/osx/osxbtledeviceinquiry.mm
@@ -43,7 +43,6 @@
#include "osxbtutility_p.h"
#include <QtCore/qloggingcategory.h>
-#include <QtCore/qsysinfo.h>
#include <QtCore/qdebug.h>
#include "corebluetoothwrapper_p.h"
@@ -52,8 +51,6 @@ QT_BEGIN_NAMESPACE
namespace OSXBluetooth {
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_6_0)
-
QBluetoothUuid qt_uuid(NSUUID *nsUuid)
{
if (!nsUuid)
@@ -66,38 +63,6 @@ QBluetoothUuid qt_uuid(NSUUID *nsUuid)
return QBluetoothUuid(qtUuidData);
}
-#endif
-
-QBluetoothUuid qt_uuid(CFUUIDRef uuid)
-{
- if (!uuid)
- return QBluetoothUuid();
-
- const CFUUIDBytes data = CFUUIDGetUUIDBytes(uuid);
- quint128 qtUuidData = {{data.byte0, data.byte1, data.byte2, data.byte3,
- data.byte4, data.byte5, data.byte6, data.byte7,
- data.byte8, data.byte9, data.byte10, data.byte11,
- data.byte12, data.byte13, data.byte14, data.byte15}};
-
- return QBluetoothUuid(qtUuidData);
-}
-
-typedef ObjCStrongReference<NSString> StringStrongReference;
-
-StringStrongReference uuid_as_nsstring(CFUUIDRef uuid)
-{
- // We use the UUDI's string representation as a key in a dictionary.
- if (!uuid)
- return StringStrongReference();
-
- CFStringRef cfStr = CFUUIDCreateString(kCFAllocatorDefault, uuid);
- if (!cfStr)
- return StringStrongReference();
-
- // Imporant: with ARC this will require a different cast/ownership!
- return StringStrongReference((NSString *)cfStr, false);
-}
-
}
@@ -301,47 +266,23 @@ using namespace QT_NAMESPACE;
QBluetoothUuid deviceUuid;
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_7_0)
- if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_7_0)) {
- if (!peripheral.identifier) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "peripheral without NSUUID";
- return;
- }
- if ([uuids containsObject:peripheral.identifier]) {
- // We already know this peripheral ...
- return;
- }
- [uuids addObject:peripheral.identifier];
- deviceUuid = OSXBluetooth::qt_uuid(peripheral.identifier);
+ if (!peripheral.identifier) {
+ qCWarning(QT_BT_OSX) << "peripheral without NSUUID";
+ return;
}
-#endif
- // Either SDK or the target is below 10.9/7.0:
- // The property UUID was finally removed in iOS 9, we have
- // to avoid compilation errors ...
- if (deviceUuid.isNull()) {
- CFUUIDRef cfUUID = Q_NULLPTR;
- if ([peripheral respondsToSelector:@selector(UUID)]) {
- // This will require a bridged cast if we switch to ARC ...
- cfUUID = reinterpret_cast<CFUUIDRef>([peripheral performSelector:@selector(UUID)]);
- }
-
- if (!cfUUID) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "peripheral without CFUUID";
- return;
- }
-
- StringStrongReference key(uuid_as_nsstring(cfUUID));
- if ([uuids containsObject:key.data()])
- return; // We've seen this peripheral before ...
- [uuids addObject:key.data()];
- deviceUuid = OSXBluetooth::qt_uuid(cfUUID);
+ if ([uuids containsObject:peripheral.identifier]) {
+ // We already know this peripheral ...
+ return;
}
+ [uuids addObject:peripheral.identifier];
+ deviceUuid = OSXBluetooth::qt_uuid(peripheral.identifier);
+
if (deviceUuid.isNull()) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "no way to address peripheral, QBluetoothUuid is null";
+ qCWarning(QT_BT_OSX) << "no way to address peripheral, QBluetoothUuid is null";
return;
}
diff --git a/src/bluetooth/osx/osxbtobexsession.mm b/src/bluetooth/osx/osxbtobexsession.mm
index 4e4013f3..9fd82487 100644
--- a/src/bluetooth/osx/osxbtobexsession.mm
+++ b/src/bluetooth/osx/osxbtobexsession.mm
@@ -203,7 +203,7 @@ QList<OBEXHeader> qt_bluetooth_headers(const uint8_t *data, std::size_t length)
break;
}
default:
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid header format";
+ qCWarning(QT_BT_OSX) << "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) << Q_FUNC_INFO << "unexpected event type";
+ qCWarning(QT_BT_OSX) << "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) << Q_FUNC_INFO << "unexpected event type";
+ qCWarning(QT_BT_OSX) << "unexpected event type";
error = kOBEXGeneralError;
return false;
}
@@ -395,7 +395,7 @@ bool check_abort_event(const OBEXSessionEvent *e, OBEXError &error, OBEXOpCode &
response = e->u.abortCommandResponseData.serverResponseOpCode;
return response == kOBEXResponseCodeSuccessWithFinalBit;
} else {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unexpected event type";
+ qCWarning(QT_BT_OSX) << "unexpected event type";
return false;
}
}
@@ -447,13 +447,13 @@ using namespace QT_NAMESPACE;
const BluetoothDeviceAddress addr(OSXBluetooth::iobluetooth_address(deviceAddress));
device = [[IOBluetoothDevice deviceWithAddress:&addr] retain];
if (!device) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an IOBluetoothDevice";
+ qCWarning(QT_BT_OSX) << "failed to create an IOBluetoothDevice";
return self;
}
session = [[IOBluetoothOBEXSession alloc] initWithDevice:device channelID:port];
if (!session) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an OBEX session";
+ qCWarning(QT_BT_OSX) << "failed to create an OBEX session";
return self;
}
@@ -478,7 +478,7 @@ using namespace QT_NAMESPACE;
- (OBEXError)OBEXConnect
{
if (!session) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid session (nil)";
+ qCWarning(QT_BT_OSX) << "invalid session (nil)";
return kOBEXGeneralError;
}
@@ -521,7 +521,7 @@ using namespace QT_NAMESPACE;
}
if (currentRequest != OBEXConnect) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called while there is no "
+ qCWarning(QT_BT_OSX) << "called while there is no "
"active connect request";
return;
}
@@ -600,7 +600,7 @@ using namespace QT_NAMESPACE;
Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
if (currentRequest != OBEXAbort) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called while there "
+ qCWarning(QT_BT_OSX) << "called while there "
"is no ABORT request";
return;
}
@@ -632,13 +632,13 @@ using namespace QT_NAMESPACE;
// a payload.
const qint64 fileSize = input->size();
if (fileSize <= 0 || fileSize >= std::numeric_limits<uint32_t>::max()) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid input file size";
+ qCWarning(QT_BT_OSX) << "invalid input file size";
return kOBEXBadArgumentError;
}
ObjCStrongReference<NSMutableData> headers([[NSMutableData alloc] init], false);
if (!headers) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate headers";
+ qCWarning(QT_BT_OSX) << "failed to allocate headers";
return kOBEXNoResourcesError;
}
@@ -648,16 +648,14 @@ using namespace QT_NAMESPACE;
if (connectionIDFound) {
if (!append_four_byte_header(headers, kOBEXHeaderIDConnectionID, connectionID)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
- "append connection ID header";
+ qCWarning(QT_BT_OSX) << "failed to append connection ID header";
return kOBEXNoResourcesError;
}
}
if (name.length()) {
if (!append_unicode_header(headers, kOBEXHeaderIDName, name)) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to append "
- "a unicode string";
+ qCWarning(QT_BT_OSX) << "failed to append a unicode string";
return kOBEXNoResourcesError;
}
}
@@ -670,7 +668,7 @@ using namespace QT_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) << Q_FUNC_INFO << "invalid input stream";
+ qCWarning(QT_BT_OSX) << "invalid input stream";
return kOBEXBadArgumentError;
}
@@ -717,7 +715,7 @@ using namespace QT_NAMESPACE;
}
if (currentRequest != OBEXPut) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called while the current "
+ qCWarning(QT_BT_OSX) << "called while the current "
"request is not a put request";
return;
}
@@ -739,8 +737,7 @@ using namespace QT_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) << Q_FUNC_INFO << "failed to "
- "allocate the next memory chunk";
+ qCWarning(QT_BT_OSX) << "failed to allocate the next memory chunk";
return;
}
@@ -756,8 +753,7 @@ using namespace QT_NAMESPACE;
refCon:Q_NULLPTR];
if (status != kOBEXSuccess) {
- qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
- "send the next memory chunk";
+ qCWarning(QT_BT_OSX) << "failed to send the next memory chunk";
currentRequest = OBEXNoop;
if (delegate) // Response code is not important here.
delegate->OBEXPutError(kOBEXNoResourcesError, 0);
diff --git a/src/bluetooth/osx/osxbtrfcommchannel.mm b/src/bluetooth/osx/osxbtrfcommchannel.mm
index b2ee8b64..08e8c53a 100644
--- a/src/bluetooth/osx/osxbtrfcommchannel.mm
+++ b/src/bluetooth/osx/osxbtrfcommchannel.mm
@@ -99,13 +99,13 @@ using namespace QT_NAMESPACE;
withChannelID:(BluetoothRFCOMMChannelID)channelID
{
if (address.isNull()) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "invalid peer address";
+ qCCritical(QT_BT_OSX) << "invalid peer address";
return kIOReturnNoDevice;
}
// Can never be called twice.
if (connected || device || channel) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "connection is already active";
+ qCCritical(QT_BT_OSX) << "connection is already active";
return kIOReturnStillOpen;
}
@@ -114,14 +114,14 @@ using namespace QT_NAMESPACE;
const BluetoothDeviceAddress iobtAddress = OSXBluetooth::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) << Q_FUNC_INFO << "failed to create a device";
+ qCCritical(QT_BT_OSX) << "failed to create a device";
return kIOReturnNoDevice;
}
const IOReturn status = [device openRFCOMMChannelAsync:&channel
withChannelID:channelID delegate:self];
if (status != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to open L2CAP channel";
+ qCCritical(QT_BT_OSX) << "failed to open L2CAP channel";
// device is still autoreleased.
device = nil;
return status;
diff --git a/src/bluetooth/osx/osxbtsdpinquiry.mm b/src/bluetooth/osx/osxbtsdpinquiry.mm
index 28dc2342..490ae234 100644
--- a/src/bluetooth/osx/osxbtsdpinquiry.mm
+++ b/src/bluetooth/osx/osxbtsdpinquiry.mm
@@ -190,7 +190,7 @@ using namespace OSXBluetooth;
if (qtFilters.size()) {
array.reset([[NSMutableArray alloc] init]);
if (!array) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate an uuid filter";
+ qCCritical(QT_BT_OSX) << "failed to allocate an uuid filter";
return kIOReturnError;
}
@@ -201,7 +201,7 @@ using namespace OSXBluetooth;
}
if (int([array count]) != qtFilters.size()) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an uuid filter";
+ qCCritical(QT_BT_OSX) << "failed to create an uuid filter";
return kIOReturnError;
}
}
@@ -209,7 +209,7 @@ using namespace OSXBluetooth;
const BluetoothDeviceAddress iobtAddress(iobluetooth_address(address));
ObjCScopedPointer<IOBluetoothDevice> newDevice([[IOBluetoothDevice deviceWithAddress:&iobtAddress] retain]);
if (!newDevice) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an IOBluetoothDevice object";
+ qCCritical(QT_BT_OSX) << "failed to create an IOBluetoothDevice object";
return kIOReturnError;
}
@@ -223,7 +223,7 @@ using namespace OSXBluetooth;
result = [device performSDPQuery:self];
if (result != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to start an SDP query";
+ qCCritical(QT_BT_OSX) << "failed to start an SDP query";
device = oldDevice.take();
} else {
isActive = true;