diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-01-05 12:12:52 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-01-05 12:13:16 +0100 |
commit | a3cf9d99b303baaca0d1b0fbaa1b1923c06d18cc (patch) | |
tree | f6343d37558880cd0e93ae9229a5cdf0ac16dc56 /src | |
parent | 2c1d2691e853812a06d435ffcf61e17f82edb224 (diff) | |
parent | aea5e3971986b4beba395985108fcad2c0c98c37 (diff) |
Merge remote-tracking branch 'gerrit/5.6' into dev
Change-Id: I97b51eb3fe2040711c00da67bbb1954fc2e65c1f
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/bluez/bluez5_helper.cpp | 22 | ||||
-rw-r--r-- | src/bluetooth/bluez/bluez5_helper_p.h | 2 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtcentralmanager.mm | 1 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtutility_p.h | 3 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothserviceinfo_bluez.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocket_osx_p.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply_bluez.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller.cpp | 1 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_android.cpp | 8 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_osx.mm | 18 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_osx_p.h | 6 | ||||
-rw-r--r-- | src/nfc/qnearfieldtarget.cpp | 2 |
12 files changed, 44 insertions, 25 deletions
diff --git a/src/bluetooth/bluez/bluez5_helper.cpp b/src/bluetooth/bluez/bluez5_helper.cpp index 384b9979..14e064e1 100644 --- a/src/bluetooth/bluez/bluez5_helper.cpp +++ b/src/bluetooth/bluez/bluez5_helper.cpp @@ -339,4 +339,26 @@ QString findAdapterForAddress(const QBluetoothAddress &wantedAddress, bool *ok = return QString(); // nothing matching found } +/* + Removes every character that cannot be used in QDbusObjectPath + + See QDbusUtil::isValidObjectPath(QString) for more details. + */ +QString sanitizeNameForDBus(const QString &text) +{ + QString appName = text; + for (int i = 0; i < appName.length(); i++) { + ushort us = appName[i].unicode(); + bool valid = (us >= 'a' && us <= 'z') + || (us >= 'A' && us <= 'Z') + || (us >= '0' && us <= '9') + || (us == '_'); + + if (!valid) + appName[i] = QLatin1Char('_'); + } + + return appName; +} + QT_END_NAMESPACE diff --git a/src/bluetooth/bluez/bluez5_helper_p.h b/src/bluetooth/bluez/bluez5_helper_p.h index a3f164b0..019fe635 100644 --- a/src/bluetooth/bluez/bluez5_helper_p.h +++ b/src/bluetooth/bluez/bluez5_helper_p.h @@ -59,6 +59,8 @@ QT_BEGIN_NAMESPACE bool isBluez5(); +QString sanitizeNameForDBus(const QString& text); + QString findAdapterForAddress(const QBluetoothAddress &wantedAddress, bool *ok); class QtBluezDiscoveryManagerPrivate; diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/osx/osxbtcentralmanager.mm index e197a78c..21ba1b81 100644 --- a/src/bluetooth/osx/osxbtcentralmanager.mm +++ b/src/bluetooth/osx/osxbtcentralmanager.mm @@ -43,7 +43,6 @@ #include <algorithm> #include <limits> - Q_DECLARE_METATYPE(QLowEnergyCharacteristic) Q_DECLARE_METATYPE(QLowEnergyDescriptor) Q_DECLARE_METATYPE(QLowEnergyHandle) diff --git a/src/bluetooth/osx/osxbtutility_p.h b/src/bluetooth/osx/osxbtutility_p.h index 3506b0d1..8816d6f3 100644 --- a/src/bluetooth/osx/osxbtutility_p.h +++ b/src/bluetooth/osx/osxbtutility_p.h @@ -94,8 +94,7 @@ public: } }; -typedef ObjCScopedPointer<NSAutoreleasePool> AutoreleasePool; -#define QT_BT_MAC_AUTORELEASEPOOL const OSXBluetooth::AutoreleasePool pool([[NSAutoreleasePool alloc] init]) +#define QT_BT_MAC_AUTORELEASEPOOL const QMacAutoReleasePool pool; template<class T> class ObjCStrongReference { diff --git a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp index e3fa81d1..d18f4bb1 100644 --- a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp +++ b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp @@ -294,7 +294,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca // create path profilePath = profilePathTemplate; profilePath.append(QString::fromLatin1("/%1%2/%3"). - arg(QCoreApplication::applicationName()). + arg(sanitizeNameForDBus(QCoreApplication::applicationName())). arg(QCoreApplication::applicationPid()). arg(pathCounter.fetchAndAddOrdered(1))); diff --git a/src/bluetooth/qbluetoothsocket_osx_p.h b/src/bluetooth/qbluetoothsocket_osx_p.h index cfd653d3..969dcef6 100644 --- a/src/bluetooth/qbluetoothsocket_osx_p.h +++ b/src/bluetooth/qbluetoothsocket_osx_p.h @@ -98,7 +98,7 @@ public: quint16 peerPort() const; void _q_readNotify(); - void _q_writeNotify(); + void _q_writeNotify() Q_DECL_OVERRIDE; private: // Create a socket from an external source (without connectToService). diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp index f7f72873..3362b2c1 100644 --- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp +++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp @@ -91,7 +91,7 @@ QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, con m_agent_path = agentPath; m_agent_path.append(QStringLiteral("/%1%2/%3"). - arg(QCoreApplication::applicationName()). + arg(sanitizeNameForDBus(QCoreApplication::applicationName())). arg(QCoreApplication::applicationPid()). arg(agentPathCounter.fetchAndAddOrdered(1))); diff --git a/src/bluetooth/qlowenergycontroller.cpp b/src/bluetooth/qlowenergycontroller.cpp index e39df97c..3fb68e19 100644 --- a/src/bluetooth/qlowenergycontroller.cpp +++ b/src/bluetooth/qlowenergycontroller.cpp @@ -226,6 +226,7 @@ void QLowEnergyControllerPrivate::setError( break; case QLowEnergyController::NoError: return; + default: case QLowEnergyController::UnknownError: errorString = QLowEnergyController::tr("Unknown Error"); break; diff --git a/src/bluetooth/qlowenergycontroller_android.cpp b/src/bluetooth/qlowenergycontroller_android.cpp index fd4ea753..cb08b6f9 100644 --- a/src/bluetooth/qlowenergycontroller_android.cpp +++ b/src/bluetooth/qlowenergycontroller_android.cpp @@ -326,6 +326,14 @@ void QLowEnergyControllerPrivate::connectionUpdated( if (newState == QLowEnergyController::UnconnectedState && !(oldState == QLowEnergyController::UnconnectedState || oldState == QLowEnergyController::ConnectingState)) { + + // Invalidate the services if the disconnect came from the remote end. + // Qtherwise we disconnected via QLowEnergyController::disconnectDevice() which + // triggered invalidation already + if (!serviceList.isEmpty()) { + Q_ASSERT(oldState != QLowEnergyController::ClosingState); + invalidateServices(); + } emit q->disconnected(); } else if (newState == QLowEnergyController::ConnectedState && oldState != QLowEnergyController::ConnectedState ) { diff --git a/src/bluetooth/qlowenergycontroller_osx.mm b/src/bluetooth/qlowenergycontroller_osx.mm index e38442e2..a0b33a95 100644 --- a/src/bluetooth/qlowenergycontroller_osx.mm +++ b/src/bluetooth/qlowenergycontroller_osx.mm @@ -132,7 +132,6 @@ UUIDList qt_servicesUuids(NSArray *services) QLowEnergyControllerPrivateOSX::QLowEnergyControllerPrivateOSX(QLowEnergyController *q) : q_ptr(q), - isConnecting(false), lastError(QLowEnergyController::NoError), controllerState(QLowEnergyController::UnconnectedState), addressType(QLowEnergyController::PublicAddress) @@ -165,7 +164,6 @@ QLowEnergyControllerPrivateOSX::QLowEnergyControllerPrivateOSX(QLowEnergyControl : q_ptr(q), deviceUuid(deviceInfo.deviceUuid()), deviceName(deviceInfo.name()), - isConnecting(false), lastError(QLowEnergyController::NoError), controllerState(QLowEnergyController::UnconnectedState), addressType(QLowEnergyController::PublicAddress) @@ -214,20 +212,18 @@ void QLowEnergyControllerPrivateOSX::_q_connected() controllerState = QLowEnergyController::ConnectedState; - if (!isConnecting) { - emit q_ptr->stateChanged(QLowEnergyController::ConnectedState); - emit q_ptr->connected(); - } + emit q_ptr->stateChanged(QLowEnergyController::ConnectedState); + emit q_ptr->connected(); } void QLowEnergyControllerPrivateOSX::_q_disconnected() { controllerState = QLowEnergyController::UnconnectedState; - if (!isConnecting) { - emit q_ptr->stateChanged(QLowEnergyController::UnconnectedState); - emit q_ptr->disconnected(); - } + invalidateServices(); + emit q_ptr->stateChanged(QLowEnergyController::UnconnectedState); + emit q_ptr->disconnected(); + } void QLowEnergyControllerPrivateOSX::_q_serviceDiscoveryFinished() @@ -512,8 +508,6 @@ void QLowEnergyControllerPrivateOSX::connectToDevice() Q_FUNC_INFO, "invalid state"); Q_ASSERT_X(!deviceUuid.isNull(), Q_FUNC_INFO, "invalid private controller (no device uuid)"); - Q_ASSERT_X(!isConnecting, Q_FUNC_INFO, - "recursive connectToDevice call"); dispatch_queue_t leQueue(OSXBluetooth::qt_LE_queue()); if (!leQueue) { diff --git a/src/bluetooth/qlowenergycontroller_osx_p.h b/src/bluetooth/qlowenergycontroller_osx_p.h index 2d1b2e95..4694203a 100644 --- a/src/bluetooth/qlowenergycontroller_osx_p.h +++ b/src/bluetooth/qlowenergycontroller_osx_p.h @@ -148,12 +148,6 @@ private: QLowEnergyController *q_ptr; QBluetoothUuid deviceUuid; QString deviceName; - // To be sure we set controller's state correctly - // (Connecting or Connected) we have to know if we're - // still inside connectToDevice - this is important, - // if a peripheral is _already_ connected from Core Bluetooth's - // point of view. - bool isConnecting; QString errorString; QLowEnergyController::Error lastError; diff --git a/src/nfc/qnearfieldtarget.cpp b/src/nfc/qnearfieldtarget.cpp index 0d57e5f3..1cb8d30c 100644 --- a/src/nfc/qnearfieldtarget.cpp +++ b/src/nfc/qnearfieldtarget.cpp @@ -135,7 +135,7 @@ static const quint16 crc_tbl[16] = { */ quint16 qNfcChecksum(const char *data, uint len) { - register quint16 crc = 0x6363; + quint16 crc = 0x6363; uchar c; const uchar *p = reinterpret_cast<const uchar *>(data); while (len--) { |