diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-01-05 14:20:42 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-01-05 14:23:14 +0100 |
commit | 302fc3cbda9a68c8d606e31702beac75cb5021d3 (patch) | |
tree | b88604342ecd8c4b069db7e20576f2fb061c8213 /src/bluetooth/bluez | |
parent | a3e2b199366c7a8f71842369cf266107a3b38490 (diff) | |
parent | a3cf9d99b303baaca0d1b0fbaa1b1923c06d18cc (diff) |
Merge remote-tracking branch 'gerrit/dev' into neard
Conflicts:
src/bluetooth/qlowenergycontroller.cpp
Change-Id: I28b116deb3fa87169432eb2d94b70894359a9057
Diffstat (limited to 'src/bluetooth/bluez')
-rw-r--r-- | src/bluetooth/bluez/bluez5_helper.cpp | 22 | ||||
-rw-r--r-- | src/bluetooth/bluez/bluez5_helper_p.h | 2 |
2 files changed, 24 insertions, 0 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; |