summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/bluez/bluez5_helper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth/bluez/bluez5_helper.cpp')
-rw-r--r--src/bluetooth/bluez/bluez5_helper.cpp22
1 files changed, 22 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