mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
review
This commit is contained in:
parent
fd8702d5a6
commit
e941dbb4a9
2 changed files with 19 additions and 28 deletions
|
@ -47,45 +47,27 @@ PluginManagerPointer PluginManager::getInstance() {
|
||||||
QString getPluginNameFromMetaData(const QJsonObject& object) {
|
QString getPluginNameFromMetaData(const QJsonObject& object) {
|
||||||
static const char* METADATA_KEY = "MetaData";
|
static const char* METADATA_KEY = "MetaData";
|
||||||
static const char* NAME_KEY = "name";
|
static const char* NAME_KEY = "name";
|
||||||
|
|
||||||
if (!object.contains(METADATA_KEY) || !object[METADATA_KEY].isObject()) {
|
if (!object.contains(METADATA_KEY) || !object[METADATA_KEY].isObject()) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
return object[METADATA_KEY][NAME_KEY].toString("");
|
||||||
auto metaDataObject = object[METADATA_KEY].toObject();
|
|
||||||
|
|
||||||
if (!metaDataObject.contains(NAME_KEY) || !metaDataObject[NAME_KEY].isString()) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return metaDataObject[NAME_KEY].toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getPluginIIDFromMetaData(const QJsonObject& object) {
|
QString getPluginIIDFromMetaData(const QJsonObject& object) {
|
||||||
static const char* IID_KEY = "IID";
|
static const char* IID_KEY = "IID";
|
||||||
|
|
||||||
if (!object.contains(IID_KEY) || !object[IID_KEY].isString()) {
|
if (!object.contains(IID_KEY) || !object[IID_KEY].isString()) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return object[IID_KEY].toString();
|
return object[IID_KEY].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPluginInterfaceVersionFromMetaData(const QJsonObject& object) {
|
int getPluginInterfaceVersionFromMetaData(const QJsonObject& object) {
|
||||||
static const char* METADATA_KEY = "MetaData";
|
static const QString METADATA_KEY = "MetaData";
|
||||||
static const char* NAME_KEY = "version";
|
static const QString NAME_KEY = "version";
|
||||||
|
|
||||||
if (!object.contains(METADATA_KEY) || !object[METADATA_KEY].isObject()) {
|
if (!object.contains(METADATA_KEY) || !object[METADATA_KEY].isObject()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return object[METADATA_KEY][NAME_KEY].toInt(0);
|
||||||
auto metaDataObject = object[METADATA_KEY].toObject();
|
|
||||||
|
|
||||||
if (!metaDataObject.contains(NAME_KEY) || !metaDataObject[NAME_KEY].isDouble()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int)(metaDataObject[NAME_KEY].toDouble());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,16 +117,18 @@ const LoaderList& getLoadedPlugins() {
|
||||||
QSharedPointer<QPluginLoader> loader(new QPluginLoader(pluginPath + plugin));
|
QSharedPointer<QPluginLoader> loader(new QPluginLoader(pluginPath + plugin));
|
||||||
|
|
||||||
if (isDisabled(loader->metaData())) {
|
if (isDisabled(loader->metaData())) {
|
||||||
qWarning() << "Plugin" << qPrintable(plugin) << "is disabled";
|
qCWarning(plugins) << "Plugin" << qPrintable(plugin) << "is disabled";
|
||||||
// Skip this one, it's disabled
|
// Skip this one, it's disabled
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPluginInterfaceVersionFromMetaData(loader->metaData()) != HIFI_PLUGIN_INTERFACE_VERSION) {
|
if (getPluginInterfaceVersionFromMetaData(loader->metaData()) != HIFI_PLUGIN_INTERFACE_VERSION) {
|
||||||
qCDebug(plugins) << "Plugin" << qPrintable(plugin) << "interface version doesn't match, not loading:"
|
qCWarning(plugins) << "Plugin" << qPrintable(plugin) << "interface version doesn't match, not loading:"
|
||||||
<< getPluginInterfaceVersionFromMetaData(loader->metaData())
|
<< getPluginInterfaceVersionFromMetaData(loader->metaData())
|
||||||
<< "doesn't match" << HIFI_PLUGIN_INTERFACE_VERSION;
|
<< "doesn't match" << HIFI_PLUGIN_INTERFACE_VERSION;
|
||||||
} else if (loader->load()) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loader->load()) {
|
||||||
qCDebug(plugins) << "Plugin" << qPrintable(plugin) << "loaded successfully";
|
qCDebug(plugins) << "Plugin" << qPrintable(plugin) << "loaded successfully";
|
||||||
loadedPlugins.push_back(loader);
|
loadedPlugins.push_back(loader);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -62,4 +62,11 @@ private:
|
||||||
InputPluginList _inputPlugins;
|
InputPluginList _inputPlugins;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: we should define this value in CMake, and then use CMake
|
||||||
|
// templating to generate the individual plugin.json files, so that we
|
||||||
|
// don't have to update every plugin.json file whenever we update this
|
||||||
|
// value. The value should match "version" in
|
||||||
|
// plugins/*/src/plugin.json
|
||||||
|
// plugins/oculus/src/oculus.json
|
||||||
|
// etc
|
||||||
static const int HIFI_PLUGIN_INTERFACE_VERSION = 1;
|
static const int HIFI_PLUGIN_INTERFACE_VERSION = 1;
|
||||||
|
|
Loading…
Reference in a new issue