/* * SPDX-FileCopyrightText: 2013 Aleix Pol Gonzalez * * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ #include "BackendNotifierFactory.h" #include #include #include #include #include BackendNotifierFactory::BackendNotifierFactory() = default; QList BackendNotifierFactory::allBackends() const { QList ret; const auto libraryPaths = QCoreApplication::instance()->libraryPaths(); for (const QString &path : libraryPaths) { QDir dir(path + QStringLiteral("/discover-notifier/")); const auto files = dir.entryList(QDir::Files); for (const QString &file : files) { QString fullPath = dir.absoluteFilePath(file); QPluginLoader loader(fullPath); loader.load(); ret += qobject_cast(loader.instance()); if (ret.last() == nullptr) { qWarning() << "couldn't load" << fullPath << "because" << loader.errorString(); ret.removeLast(); } } } if (ret.isEmpty()) qWarning() << "couldn't find any notifier backend" << QCoreApplication::instance()->libraryPaths(); return ret; }