Commit 36fb1828 authored by Chris Rizzitello's avatar Chris Rizzitello

Clean up detection of plugins.

Signed-off-by: Chris Rizzitello's avatarChris Rizzitello <rizzitello@kde.org>
parent ec743f53
......@@ -611,27 +611,13 @@ bool AtCore::firmwarePluginLoaded() const
QMap<QString, QString> AtCore::findFirmwarePlugins(const QString &path)
{
QMap<QString, QString> detectedPlugins;
QStringList files = QDir(path).entryList(QDir::Files);
for (const QString &f : files) {
for (const QString &f : QDir(path).entryList({AtCoreDirectories::pluginExtFilter}, QDir::Files)) {
QString file = f;
#if defined(Q_OS_WIN)
if (file.endsWith(QStringLiteral(".dll")))
#elif defined(Q_OS_MAC)
if (file.endsWith(QStringLiteral(".dylib")))
#else
if (file.endsWith(QStringLiteral(".so")))
#endif
file = file.split(QChar::fromLatin1('.')).at(0);
else {
continue;
}
file = file.split(QStringLiteral(".")).at(0).toLower().simplified();
if (file.startsWith(QStringLiteral("lib"))) {
file = file.remove(QStringLiteral("lib"));
}
file = file.toLower().simplified();
QString pluginString = path;
pluginString.append(QChar::fromLatin1('/'));
pluginString.append(f);
QString pluginString = QStringLiteral("%1/%2").arg(path, f);
detectedPlugins[file] = pluginString;
qCDebug(ATCORE_PLUGIN) << QStringLiteral("Plugin:[%1]=%2").arg(file, pluginString);
}
......
......@@ -29,4 +29,12 @@ namespace AtCoreDirectories {
, QStringLiteral("@KDE_INSTALL_PLUGINDIR@/AtCore")
, QStringLiteral("@CMAKE_CURRENT_BINARY_DIR@/../plugins")
};
const QString pluginExtFilter =
#if defined(Q_OS_WIN)
QStringLiteral("*.dll");
#elif defined(Q_OS_MAC)
QStringLiteral("*.dylib");
#else
QStringLiteral("*.so");
#endif
}
......@@ -316,23 +316,11 @@ QStringList ProfileManager::detectFWPlugins()
QStringList ProfileManager::firmwaresInPath(const QString &path)
{
QStringList firmwares;
QStringList files = QDir(path).entryList(QDir::Files);
for (QString file : files) {
#if defined(Q_OS_WIN)
if (file.endsWith(QStringLiteral(".dll")))
#elif defined(Q_OS_MAC)
if (file.endsWith(QStringLiteral(".dylib")))
#else
if (file.endsWith(QStringLiteral(".so")))
#endif
file = file.split(QChar::fromLatin1('.')).at(0);
else {
continue;
}
for (QString file : QDir(path).entryList({AtCoreDirectories::pluginExtFilter}, QDir::Files)) {
file = file.split(QStringLiteral(".")).at(0).toLower().simplified();
if (file.startsWith(QStringLiteral("lib"))) {
file = file.remove(QStringLiteral("lib"));
}
file = file.toLower().simplified();
firmwares.append(file);
}
return firmwares;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment