diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/osx/osxbtutility_p.h | 5 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothserviceinfo_osx.mm | 45 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocket_osx_p.h | 2 |
3 files changed, 49 insertions, 3 deletions
diff --git a/src/bluetooth/osx/osxbtutility_p.h b/src/bluetooth/osx/osxbtutility_p.h index 1a69e485..1c20c91a 100644 --- a/src/bluetooth/osx/osxbtutility_p.h +++ b/src/bluetooth/osx/osxbtutility_p.h @@ -154,6 +154,11 @@ public: { return m_ptr; } + + T *data() const + { + return m_ptr; + } private: T *m_ptr; }; diff --git a/src/bluetooth/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_osx.mm index 59a631b0..2ab2c9f1 100644 --- a/src/bluetooth/qbluetoothserviceinfo_osx.mm +++ b/src/bluetooth/qbluetoothserviceinfo_osx.mm @@ -57,6 +57,29 @@ QT_BEGIN_NAMESPACE +namespace { + +// This is not in osxbtutility_p, since it's not required +// in general and just fixes the problem with SDK < 10.9, +// where we have to care about about IOBluetoothSDPServiceRecordRef. +class ServiceRecordDeleter +{ +public: + ServiceRecordDeleter(IOBluetoothSDPServiceRecordRef r) + : recordRef(r) + { + } + ~ServiceRecordDeleter() + { + if (recordRef) // Requires non-NULL pointers. + CFRelease(recordRef); + } + + IOBluetoothSDPServiceRecordRef recordRef; +}; + +} + class QBluetoothServiceInfoPrivate { public: @@ -119,8 +142,26 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca return false; } - SDPRecord newRecord([[IOBluetoothSDPServiceRecord - publishedServiceRecordWithDictionary:serviceDict] retain]); + SDPRecord newRecord; + +#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_NA) + newRecord.reset([[IOBluetoothSDPServiceRecord + publishedServiceRecordWithDictionary:serviceDict] retain]); + +#else + IOBluetoothSDPServiceRecordRef recordRef = Q_NULLPTR; + // With ARC this will require a different cast? + const IOReturn status = IOBluetoothAddServiceDict((CFDictionaryRef)serviceDict.data(), &recordRef); + if (status != kIOReturnSuccess) { + qCWarning(QT_BT_OSX) << "QBluetoothServiceInfoPrivate::registerService(), " + "failed to create register a service record"; + return false; + } + + const ServiceRecordDeleter refGuard(recordRef); + newRecord.reset([[IOBluetoothSDPServiceRecord withSDPServiceRecordRef:recordRef] retain]); + // It's weird, but ... it's not possible to release a record ref yet! +#endif if (!newRecord) { qCWarning(QT_BT_OSX) << "QBluetoothServiceInfoPrivate::registerService(), " diff --git a/src/bluetooth/qbluetoothsocket_osx_p.h b/src/bluetooth/qbluetoothsocket_osx_p.h index 2823c4f0..31389ec0 100644 --- a/src/bluetooth/qbluetoothsocket_osx_p.h +++ b/src/bluetooth/qbluetoothsocket_osx_p.h @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE class QBluetoothServiceDiscoveryAgent; class QBluetoothAddress; -class QBluetoothSocketPrivate : public QObject, public OSXBluetooth::ChannelDelegate +class QBluetoothSocketPrivate : public QBluetoothSocketPrivateBase, public OSXBluetooth::ChannelDelegate { friend class QBluetoothSocket; friend class QBluetoothServer; |