diff options
author | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2016-06-02 12:30:54 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2016-06-02 11:32:10 +0000 |
commit | 6b6b4fea87b7b9063299e4b15adf307f71319cf1 (patch) | |
tree | 844d9655aaab4a240138d1f2e59ab912af474dd4 /src/bluetooth/qbluetoothserviceinfo_osx.mm | |
parent | 6b5ef56a9f4d92c4a50ce098e9cf323f528b29ee (diff) |
QtBluetooth: remove outdate code (OS X/iOS)
Since we now have OS X 10.9 and iOS 7.0 as the minimal required
(SDK and deployment target) - get rid of outdated code-branches
in _SDK_EQUAL_OR_ABOVE etc.
Change-Id: I5f546e8bb746f6b94f26a40460b3caa0af6a531c
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qbluetoothserviceinfo_osx.mm')
-rw-r--r-- | src/bluetooth/qbluetoothserviceinfo_osx.mm | 92 |
1 files changed, 5 insertions, 87 deletions
diff --git a/src/bluetooth/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_osx.mm index f2cba6cf..c51eb1c6 100644 --- a/src/bluetooth/qbluetoothserviceinfo_osx.mm +++ b/src/bluetooth/qbluetoothserviceinfo_osx.mm @@ -45,7 +45,6 @@ #include <QtCore/qloggingcategory.h> #include <QtCore/qvariant.h> -#include <QtCore/qsysinfo.h> #include <QtCore/qglobal.h> #include <QtCore/qmutex.h> #include <QtCore/qmap.h> @@ -57,44 +56,6 @@ 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 ServiceRecordRefGuard -{ -public: - ServiceRecordRefGuard() - : recordRef(Q_NULLPTR) - { - } - explicit ServiceRecordRefGuard(IOBluetoothSDPServiceRecordRef r) - : recordRef(r) - { - } - ~ServiceRecordRefGuard() - { - if (recordRef) // Requires non-NULL pointers. - CFRelease(recordRef); - } - - void reset(IOBluetoothSDPServiceRecordRef r) - { - if (recordRef) - CFRelease(recordRef); - // Take the ownership: - recordRef = r; - } - -private: - IOBluetoothSDPServiceRecordRef recordRef; - - Q_DISABLE_COPY(ServiceRecordRefGuard) -}; - -} - class QBluetoothServiceInfoPrivate { public: @@ -149,44 +110,19 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca return false; } - ServiceRecordRefGuard refGuard; SDPRecord newRecord; -#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) { - newRecord.reset([[IOBluetoothSDPServiceRecord - publishedServiceRecordWithDictionary:serviceDict] retain]); - } else { -#else - { -#endif - 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) << Q_FUNC_INFO << "failed to register a service record"; - return false; - } - - refGuard.reset(recordRef); - newRecord.reset([[IOBluetoothSDPServiceRecord withSDPServiceRecordRef:recordRef] retain]); - // It's weird, but ... it's not possible to release a record ref yet. - } + newRecord.reset([[IOBluetoothSDPServiceRecord + publishedServiceRecordWithDictionary:serviceDict] retain]); if (!newRecord) { qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to register a service record"; - // In case of SDK < 10.9 it's not possible to remove a service record ... - // no way to obtain record handle yet. return false; } BluetoothSDPServiceRecordHandle newRecordHandle = 0; if ([newRecord getServiceRecordHandle:&newRecordHandle] != kIOReturnSuccess) { qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to register a service record"; -#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) - [newRecord removeServiceRecord]; -#endif - // With SDK < 10.9 there is no way to unregister at this point ... + [newRecord removeServiceRecord]; return false; } @@ -212,16 +148,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca } if (!configured) { -#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) { - [newRecord removeServiceRecord]; - } else { -#else - {// Just to balance braces ... -#endif - IOBluetoothRemoveServiceWithRecordHandle(newRecordHandle); - } - + [newRecord removeServiceRecord]; qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to register a service record"; return false; } @@ -248,16 +175,7 @@ bool QBluetoothServiceInfoPrivate::unregisterService() Q_ASSERT_X(serviceRecord, Q_FUNC_INFO, "service registered, but serviceRecord is nil"); -#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) { - [serviceRecord removeServiceRecord]; - } else { -#else - { -#endif - // Assert on newRecordHandle? Is 0 a valid/invalid handle? - IOBluetoothRemoveServiceWithRecordHandle(serviceRecordHandle); - } + [serviceRecord removeServiceRecord]; serviceRecord.reset(nil); |