diff --git a/interface/src/main.cpp b/interface/src/main.cpp index cfde65a845..a5aa8004da 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -370,6 +370,17 @@ int main(int argc, const char* argv[]) { if (parser.isSet(getPluginsOption)) { auto pluginManager = PluginManager::getInstance(); + QJsonObject pluginsJson; + for (const auto &plugin : pluginManager->getPluginInfo()) { + QJsonObject data; + data["data"] = plugin.metaData; + data["loaded"] = plugin.loaded; + data["disabled"] = plugin.disabled; + data["filteredOut"] = plugin.filteredOut; + data["wrongVersion"] = plugin.wrongVersion; + pluginsJson[plugin.name] = data; + } + QJsonObject inputJson; for (const auto &plugin : pluginManager->getInputPlugins()) { QJsonObject data; @@ -406,15 +417,16 @@ int main(int argc, const char* argv[]) { codecsJson[plugin->getName()] = data; } - QJsonObject staticJson; - staticJson["steamAvailable"] = (pluginManager->getSteamClientPlugin() != nullptr); - staticJson["oculusAvailable"] = (pluginManager->getOculusPlatformPlugin() != nullptr); + QJsonObject platformsJson; + platformsJson["steamAvailable"] = (pluginManager->getSteamClientPlugin() != nullptr); + platformsJson["oculusAvailable"] = (pluginManager->getOculusPlatformPlugin() != nullptr); QJsonObject root; - root["input"] = inputJson; - root["display"] = displayJson; - root["codec"] = codecsJson; - root["staticPlugins"] = staticJson; + root["plugins"] = pluginsJson; + root["inputs"] = inputJson; + root["displays"] = displayJson; + root["codecs"] = codecsJson; + root["platforms"] = platformsJson; std::cout << QJsonDocument(root).toJson().toStdString() << "\n"; diff --git a/libraries/plugins/src/plugins/PluginManager.cpp b/libraries/plugins/src/plugins/PluginManager.cpp index 759686300a..0281a012d2 100644 --- a/libraries/plugins/src/plugins/PluginManager.cpp +++ b/libraries/plugins/src/plugins/PluginManager.cpp @@ -72,12 +72,12 @@ int getPluginInterfaceVersionFromMetaData(const QJsonObject& object) { QStringList preferredDisplayPlugins; QStringList disabledDisplays; QStringList disabledInputs; +std::vector pluginInfo; bool isDisabled(QJsonObject metaData) { auto name = getPluginNameFromMetaData(metaData); auto iid = getPluginIIDFromMetaData(metaData); - qDebug() << "Name = " << name << "; iid =" << iid; if (iid == DisplayProvider_iid || iid == SteamClientProvider_iid || iid == OculusPlatformProvider_iid) { return disabledDisplays.contains(name); } else if (iid == InputProvider_iid) { @@ -127,18 +127,28 @@ int PluginManager::instantiate() { qCDebug(plugins) << "Attempting plugin" << qPrintable(plugin); auto loader = QSharedPointer::create(pluginPath + plugin); const QJsonObject pluginMetaData = loader->metaData(); + + PluginInfo info; + info.name = plugin; + info.metaData = pluginMetaData; + #if defined(HIFI_PLUGINMANAGER_DEBUG) QJsonDocument metaDataDoc(pluginMetaData); qCInfo(plugins) << "Metadata for " << qPrintable(plugin) << ": " << QString(metaDataDoc.toJson()); #endif if (isDisabled(pluginMetaData)) { qCWarning(plugins) << "Plugin" << qPrintable(plugin) << "is disabled"; + info.disabled = true; + pluginInfo.push_back(info); + // Skip this one, it's disabled continue; } if (!_pluginFilter(pluginMetaData)) { qCDebug(plugins) << "Plugin" << qPrintable(plugin) << "doesn't pass provided filter"; + info.filteredOut = true; + pluginInfo.push_back(info); continue; } @@ -146,16 +156,22 @@ int PluginManager::instantiate() { qCWarning(plugins) << "Plugin" << qPrintable(plugin) << "interface version doesn't match, not loading:" << getPluginInterfaceVersionFromMetaData(pluginMetaData) << "doesn't match" << HIFI_PLUGIN_INTERFACE_VERSION; + + info.wrongVersion = true; + pluginInfo.push_back(info); continue; } if (loader->load()) { qCDebug(plugins) << "Plugin" << qPrintable(plugin) << "loaded successfully"; + info.loaded = true; loadedPlugins.push_back(loader); } else { qCDebug(plugins) << "Plugin" << qPrintable(plugin) << "failed to load:"; qCDebug(plugins) << " " << qPrintable(loader->errorString()); } + + pluginInfo.push_back(info); } } else { qWarning() << "pluginPath does not exit..." << pluginDir; @@ -164,6 +180,11 @@ int PluginManager::instantiate() { return loadedPlugins; } +std::vector PluginManager::getPluginInfo() const { + getLoadedPlugins(); // This builds the pluginInfo list + return pluginInfo; +} + const CodecPluginList& PluginManager::getCodecPlugins() { static CodecPluginList codecPlugins; static std::once_flag once; diff --git a/libraries/plugins/src/plugins/PluginManager.h b/libraries/plugins/src/plugins/PluginManager.h index c35db5a91e..b529472e1f 100644 --- a/libraries/plugins/src/plugins/PluginManager.h +++ b/libraries/plugins/src/plugins/PluginManager.h @@ -12,6 +12,8 @@ #include #include +#include +#include #include "Forward.h" @@ -39,6 +41,49 @@ class PluginManager : public QObject, public Dependency { Q_OBJECT public: + + /** + * @brief Information about known plugins + * + */ + struct PluginInfo { + /** + * @brief Plugin metadata + */ + QJsonObject metaData; + + /** + * @brief Filename + * + */ + QString name; + + /** + * @brief Whether the plugin has been disabled + * + */ + bool disabled = false; + + /** + * @brief Whether the plugin has been filtered out by a filter + * + */ + bool filteredOut = false; + + /** + * @brief Whether the plugin has been not loaded because it's the wrong version + * + */ + bool wrongVersion = false; + + /** + * @brief Whether the plugin has been loaded successfully + * + */ + bool loaded = false; + }; + + static PluginManagerPointer getInstance(); /** @@ -217,6 +262,15 @@ public: bool getEnableOculusPluginSetting() { return _enableOculusPluginSetting.get(); } void setEnableOculusPluginSetting(bool value); + /** + * @brief Returns information about known plugins + * + * This is a function for informative/debugging purposes. + * + * @return std::vector + */ + std::vector getPluginInfo() const; + signals: void inputDeviceRunningChanged(const QString& pluginName, bool isRunning, const QStringList& runningDevices);