Пример #1
0
void PluginManager::scanPlugins(bool initialScan) {
    if (initialScan) {
        QFileInfoList list = _pluginPath.entryInfoList();
        for (QFileInfo info : list) {
            QPluginLoader* loader = new QPluginLoader(info.absoluteFilePath(), this);
            QJsonObject metaData = loader->metaData().value("MetaData").toObject();

            const QString name = metaData.value("name").toString("Unknown");
            const QString role = metaData.value("role").toString("Unknown");

            // Ensure IID is inserted.
            metaData.insert("IID", loader->metaData().value("IID"));

            AdamantPluginInfo* data = new AdamantPluginInfo;
            data->state = PluginState::Unknown;
            data->name = name;
            data->role = role;
            data->metaData = metaData;
            data->instance = nullptr;
            data->script = nullptr;
            data->loader = nullptr;
            data->file = info;
            data->lastModified = info.lastModified();
            _pluginsByRole.insertMulti(role, data);

            emit pluginDiscovered(name);

            loader->deleteLater();
        }
    }
}
Пример #2
0
void DefaultManager::dump_metadata(const QPluginLoader& loader) const
{
	const auto meta = loader.metaData();
	qDebug() << meta.value("MetaData").toObject().value("name");
	qDebug() << meta.value("MetaData").toObject().value("version");
	qDebug() << meta.value("MetaData").toObject().value("dependencies");
}
Пример #3
0
void plugin_factory::load_all()
{
	auto file_list = QDir(plugindir_).entryInfoList(
			QDir::Files | QDir::NoDotAndDotDot);
	for (auto const &info : file_list) {
		auto p = info.absoluteFilePath();
		QPluginLoader *ld;
		if ((ld = load_plugin(p)) != 0) {
			qDebug() << "Loaded plugin" << p;
			plugins_.insert(ld->metaData().value("IID").toString(), ld);
		} else
			qDebug() << p << "is not an acv plugin";
	}
}