diff options
author | Mike Krus <mike.krus@kdab.com> | 2016-09-26 23:30:26 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2016-09-28 07:10:41 +0000 |
commit | e53f828a1644fab1821a7696c190777a3bbb1880 (patch) | |
tree | b6ac55419308a4de3e95c9c83d83031012d3a430 | |
parent | 9dba73f30505ed7c220055788fba3cd201848fdb (diff) |
Handle iOS 10 deprecated data structures
iOS 10 (and tvOS 10) deprecates CBCentralManagerState enum
(and associated values). Replaced by CBManagerState enum.
Change-Id: I1c1bb0691403deaa6330949516846961c76865f5
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/bluetooth/osx/osxbtcentralmanager.mm | 21 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtledeviceinquiry.mm | 13 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/osx/osxbtcentralmanager.mm index 6afe03c0..e32a82da 100644 --- a/src/bluetooth/osx/osxbtcentralmanager.mm +++ b/src/bluetooth/osx/osxbtcentralmanager.mm @@ -1072,10 +1072,19 @@ QT_USE_NAMESPACE { using namespace OSXBluetooth; +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) + const CBManagerState state = central.state; +#else const CBCentralManagerState state = central.state; +#endif +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) + if (state == CBManagerStateUnknown + || state == CBManagerStateResetting) { +#else if (state == CBCentralManagerStateUnknown || state == CBCentralManagerStateResetting) { +#endif // We still have to wait, docs say: // "The current state of the central manager is unknown; // an update is imminent." or @@ -1085,7 +1094,11 @@ QT_USE_NAMESPACE } // Let's check some states we do not like first: +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) + if (state == CBManagerStateUnsupported || state == CBManagerStateUnauthorized) { +#else if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) { +#endif if (managerState == CentralManagerUpdating) { // We tried to connect just to realize, LE is not supported. Report this. managerState = CentralManagerIdle; @@ -1101,7 +1114,11 @@ QT_USE_NAMESPACE return; } +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) + if (state == CBManagerStatePoweredOff) { +#else if (state == CBCentralManagerStatePoweredOff) { +#endif managerState = CentralManagerIdle; if (managerState == CentralManagerUpdating) { // I've seen this instead of Unsupported on OS X. @@ -1116,7 +1133,11 @@ QT_USE_NAMESPACE return; } +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) + if (state == CBManagerStatePoweredOn) { +#else if (state == CBCentralManagerStatePoweredOn) { +#endif if (managerState == CentralManagerUpdating && !disconnectPending) { managerState = CentralManagerIdle; [self retrievePeripheralAndConnect]; diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/osx/osxbtledeviceinquiry.mm index f3a95820..5cf9b193 100644 --- a/src/bluetooth/osx/osxbtledeviceinquiry.mm +++ b/src/bluetooth/osx/osxbtledeviceinquiry.mm @@ -204,8 +204,13 @@ using namespace QT_NAMESPACE; dispatch_queue_t leQueue(qt_LE_queue()); Q_ASSERT(leQueue); +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) + const CBManagerState cbState(central.state); + if (cbState == CBManagerStatePoweredOn) { +#else const CBCentralManagerState cbState(central.state); if (cbState == CBCentralManagerStatePoweredOn) { +#endif if (internalState == InquiryStarting) { internalState = InquiryActive; // Scan time is actually 10 seconds. Having a block with such delay can prevent @@ -220,7 +225,11 @@ using namespace QT_NAMESPACE; }); [manager scanForPeripheralsWithServices:nil options:nil]; } // Else we ignore. +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) + } else if (state == CBManagerStateUnsupported || state == CBManagerStateUnauthorized) { +#else } else if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) { +#endif if (internalState == InquiryActive) { [manager stopScan]; // Not sure how this is possible at all, probably, can never happen. @@ -230,7 +239,11 @@ using namespace QT_NAMESPACE; } [manager setDelegate:nil]; +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) + } else if (cbState == CBManagerStatePoweredOff) { +#else } else if (cbState == CBCentralManagerStatePoweredOff) { +#endif if (internalState == InquiryStarting) { #ifndef Q_OS_OSX // On iOS a user can see at this point an alert asking to enable |