summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-12-04 14:51:27 +0100
committerSimon Rettberg2018-12-04 14:51:27 +0100
commitea79392ce726186e6a2107a00977ae9d5ce8598d (patch)
tree0ed714c1350bde7b7d75e54268d21eed51896b29
parent[loginform] configurable icon for login form (diff)
downloadslxgreeter-ea79392ce726186e6a2107a00977ae9d5ce8598d.tar.gz
slxgreeter-ea79392ce726186e6a2107a00977ae9d5ce8598d.tar.xz
slxgreeter-ea79392ce726186e6a2107a00977ae9d5ce8598d.zip
Namereplace: Try to call external tool to translate username
Mainly used to achieve case insentive login
-rw-r--r--src/namereplace.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/namereplace.cpp b/src/namereplace.cpp
index cc93025..0e203f3 100644
--- a/src/namereplace.cpp
+++ b/src/namereplace.cpp
@@ -4,8 +4,10 @@
#include <QFile>
#include <QTextStream>
#include <QDebug>
+#include <QProcess>
#define SOURCE_FILE "/opt/openslx/lightdm/login-regexp"
+#define LOOKUP_PROCESS "/opt/openslx/pam/get_username"
static QList< QPair< QRegularExpression, QString > > list;
@@ -61,9 +63,22 @@ void NameReplace::loadSubs()
void NameReplace::replace(QString& input)
{
- if (list.isEmpty())
- return;
- for (auto &brumm : list) {
- input = input.replace(brumm.first, brumm.second);
+ if (!list.isEmpty()) {
+ for (auto &brumm : list) {
+ input = input.replace(brumm.first, brumm.second);
+ }
+ }
+ QProcess getCaps;
+ getCaps.start(LOOKUP_PROCESS, QStringList(input));
+ getCaps.waitForFinished(100);
+ QString output = QString::fromLocal8Bit(getCaps.readAllStandardOutput());
+ int idx = output.indexOf('\n');
+ if (idx != -1) {
+ output = output.left(idx);
+ }
+ if (output.length() == input.length()) {
+ input = output;
+ } else {
+ qDebug() << "Not replacing" << input << "by" << output;
}
}