From 79cd26807393a41693e040370be3502448ffc3aa Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 26 Sep 2011 00:55:00 +0300 Subject: [PATCH] Changed: #1193 Now plugin system reads plugin information from plugin-spec file(ovqt_plugin_*.xml) for each plugin. --- .../src/extension_system/iplugin.h | 6 - .../src/extension_system/iplugin_spec.h | 2 +- .../src/extension_system/plugin_manager.cpp | 90 ++++---- .../src/extension_system/plugin_manager.h | 19 +- .../src/extension_system/plugin_spec.cpp | 205 +++++++++++++----- .../src/extension_system/plugin_spec.h | 23 +- .../tools/3d/object_viewer_qt/src/main.cpp | 2 +- 7 files changed, 222 insertions(+), 125 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin.h index 864028501..973f80e14 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin.h @@ -95,12 +95,6 @@ public: @endcode */ virtual void setNelContext(NLMISC::INelContext *nelContext) = 0; - - virtual QString name() const = 0; - virtual QString version() const = 0; - virtual QString vendor() const = 0; - virtual QString description() const = 0; - virtual QStringList dependencies() const = 0; }; }; //namespace ExtensionSystem diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_spec.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_spec.h index 45895c36f..2aefbb894 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_spec.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_spec.h @@ -37,8 +37,8 @@ struct State { Invalid = 1, Read, - Loaded, Resolved, + Loaded, Initialized, Running, Stopped, diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp index 3b2431a07..bcd90e351 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp @@ -26,13 +26,14 @@ namespace ExtensionSystem { -CPluginManager::CPluginManager(QObject *parent) +PluginManager::PluginManager(QObject *parent) :IPluginManager(parent), - m_settings(0) + m_settings(0), + m_extension("xml") { } -CPluginManager::~CPluginManager() +PluginManager::~PluginManager() { writeSettings(); stopAll(); @@ -40,7 +41,7 @@ CPluginManager::~CPluginManager() qDeleteAll(m_pluginSpecs); } -void CPluginManager::addObject(QObject *obj) +void PluginManager::addObject(QObject *obj) { QWriteLocker lock(&m_lock); if (obj == 0) @@ -60,7 +61,7 @@ void CPluginManager::addObject(QObject *obj) Q_EMIT objectAdded(obj); } -void CPluginManager::removeObject(QObject *obj) +void PluginManager::removeObject(QObject *obj) { if (obj == 0) { @@ -80,25 +81,25 @@ void CPluginManager::removeObject(QObject *obj) m_allObjects.removeAll(obj); } -QList CPluginManager::allObjects() const +QList PluginManager::allObjects() const { return m_allObjects; } -void CPluginManager::loadPlugins() +void PluginManager::loadPlugins() { - Q_FOREACH (CPluginSpec *spec, m_pluginSpecs) - setPluginState(spec, State::Loaded); - - Q_FOREACH (CPluginSpec *spec, m_pluginSpecs) + Q_FOREACH (PluginSpec *spec, m_pluginSpecs) setPluginState(spec, State::Resolved); - QList queue = loadQueue(); + QList queue = loadQueue(); - Q_FOREACH (CPluginSpec *spec, queue) + Q_FOREACH (PluginSpec *spec, queue) + setPluginState(spec, State::Loaded); + + Q_FOREACH (PluginSpec *spec, queue) setPluginState(spec, State::Initialized); - QListIterator it(queue); + QListIterator it(queue); it.toBack(); while (it.hasPrevious()) setPluginState(it.previous(), State::Running); @@ -106,34 +107,34 @@ void CPluginManager::loadPlugins() Q_EMIT pluginsChanged(); } -QStringList CPluginManager::getPluginPaths() const +QStringList PluginManager::getPluginPaths() const { return m_pluginPaths; } -void CPluginManager::setPluginPaths(const QStringList &paths) +void PluginManager::setPluginPaths(const QStringList &paths) { m_pluginPaths = paths; readPluginPaths(); readSettings(); } -QList CPluginManager::plugins() const +QList PluginManager::plugins() const { return m_ipluginSpecs; } -void CPluginManager::setSettings(QSettings *settings) +void PluginManager::setSettings(QSettings *settings) { m_settings = settings; } -QSettings *CPluginManager::settings() const +QSettings *PluginManager::settings() const { return m_settings; } -void CPluginManager::readSettings() +void PluginManager::readSettings() { if (m_settings) { @@ -141,7 +142,7 @@ void CPluginManager::readSettings() m_settings->beginGroup("PluginManager"); blackList = m_settings->value("BlackList").toStringList(); m_settings->endGroup(); - Q_FOREACH (CPluginSpec *spec, m_pluginSpecs) + Q_FOREACH (PluginSpec *spec, m_pluginSpecs) { QString pluginName = spec->fileName(); @@ -154,14 +155,13 @@ void CPluginManager::readSettings() } } -void CPluginManager::writeSettings() +void PluginManager::writeSettings() { if (m_settings) { QStringList blackList; - Q_FOREACH(CPluginSpec *spec, m_pluginSpecs) + Q_FOREACH(PluginSpec *spec, m_pluginSpecs) { - nlinfo(spec->fileName().toStdString().c_str()); if (!spec->isEnabled()) blackList.push_back(spec->fileName()); } @@ -172,7 +172,7 @@ void CPluginManager::writeSettings() } } -void CPluginManager::readPluginPaths() +void PluginManager::readPluginPaths() { qDeleteAll(m_pluginSpecs); m_pluginSpecs.clear(); @@ -183,11 +183,7 @@ void CPluginManager::readPluginPaths() while (!searchPaths.isEmpty()) { const QDir dir(searchPaths.takeFirst()); -#ifdef Q_OS_WIN - const QFileInfoList files = dir.entryInfoList(QStringList() << QString("ovqt_plugin_*.dll"), QDir::Files); -#else - const QFileInfoList files = dir.entryInfoList(QStringList() << QString("libovqt_plugin_*.so"), QDir::Files); -#endif + const QFileInfoList files = dir.entryInfoList(QStringList() << QString("ovqt_plugin_*.%1").arg(m_extension), QDir::Files); Q_FOREACH (const QFileInfo &file, files) pluginsList << file.absoluteFilePath(); const QFileInfoList dirs = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot); @@ -197,9 +193,9 @@ void CPluginManager::readPluginPaths() Q_FOREACH (const QString &pluginFile, pluginsList) { - CPluginSpec *spec = new CPluginSpec; - spec->setFileName(pluginFile); + PluginSpec *spec = new PluginSpec; spec->m_pluginManager = this; + spec->setSpecFileName(pluginFile); m_pluginSpecs.append(spec); m_ipluginSpecs.append(spec); } @@ -207,7 +203,7 @@ void CPluginManager::readPluginPaths() Q_EMIT pluginsChanged(); } -void CPluginManager::setPluginState(CPluginSpec *spec, int destState) +void PluginManager::setPluginState(PluginSpec *spec, int destState) { if (spec->hasError() || spec->state() != destState-1) return; @@ -233,7 +229,7 @@ void CPluginManager::setPluginState(CPluginSpec *spec, int destState) default: break; } - Q_FOREACH (const CPluginSpec *depSpec, spec->dependencySpecs()) + Q_FOREACH (const PluginSpec *depSpec, spec->dependencySpecs()) { if (depSpec->state() != destState) { @@ -256,19 +252,19 @@ void CPluginManager::setPluginState(CPluginSpec *spec, int destState) } } -QList CPluginManager::loadQueue() +QList PluginManager::loadQueue() { - QList queue; - Q_FOREACH(CPluginSpec *spec, m_pluginSpecs) + QList queue; + Q_FOREACH(PluginSpec *spec, m_pluginSpecs) { - QList circularityCheckQueue; + QList circularityCheckQueue; loadQueue(spec, queue, circularityCheckQueue); } return queue; } -bool CPluginManager::loadQueue(CPluginSpec *spec, QList &queue, - QList &circularityCheckQueue) +bool PluginManager::loadQueue(PluginSpec *spec, QList &queue, + QList &circularityCheckQueue) { if (queue.contains(spec)) return true; @@ -295,7 +291,7 @@ bool CPluginManager::loadQueue(CPluginSpec *spec, QList &queue, } // add dependencies - Q_FOREACH (CPluginSpec *depSpec, spec->dependencySpecs()) + Q_FOREACH (PluginSpec *depSpec, spec->dependencySpecs()) { if (!loadQueue(depSpec, queue, circularityCheckQueue)) { @@ -311,17 +307,17 @@ bool CPluginManager::loadQueue(CPluginSpec *spec, QList &queue, return true; } -void CPluginManager::stopAll() +void PluginManager::stopAll() { - QList queue = loadQueue(); - Q_FOREACH (CPluginSpec *spec, queue) + QList queue = loadQueue(); + Q_FOREACH (PluginSpec *spec, queue) setPluginState(spec, State::Stopped); } -void CPluginManager::deleteAll() +void PluginManager::deleteAll() { - QList queue = loadQueue(); - QListIterator it(queue); + QList queue = loadQueue(); + QListIterator it(queue); it.toBack(); while (it.hasPrevious()) { diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.h index 4ef3b2208..9ab1ae135 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.h @@ -29,15 +29,15 @@ namespace ExtensionSystem { class IPlugin; -class CPluginSpec; +class PluginSpec; -class CPluginManager : public IPluginManager +class PluginManager : public IPluginManager { Q_OBJECT public: - CPluginManager(QObject *parent = 0); - ~CPluginManager(); + PluginManager(QObject *parent = 0); + ~PluginManager(); // Object pool operations virtual void addObject(QObject *obj); @@ -49,7 +49,7 @@ public: virtual QStringList getPluginPaths() const; virtual void setPluginPaths(const QStringList &paths); virtual QList plugins() const; - QList loadQueue(); + QList loadQueue(); // Settings virtual void setSettings(QSettings *settings); @@ -58,21 +58,22 @@ public: void writeSettings(); private: - void setPluginState(CPluginSpec *spec, int destState); + void setPluginState(PluginSpec *spec, int destState); void readPluginPaths(); - bool loadQueue(CPluginSpec *spec, QList &queue, QList &circularityCheckQueue); + bool loadQueue(PluginSpec *spec, QList &queue, QList &circularityCheckQueue); void stopAll(); void deleteAll(); mutable QReadWriteLock m_lock; QSettings *m_settings; - QList m_pluginSpecs; + QString m_extension; + QList m_pluginSpecs; QList m_ipluginSpecs; QStringList m_pluginPaths; QList m_allObjects; -}; // class CPluginManager +}; // class PluginManager } // namespace ExtensionSystem diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp index 6e15e1181..030f9507b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp @@ -16,12 +16,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// Project includes #include "plugin_spec.h" #include "iplugin.h" #include "iplugin_manager.h" #include "nel/misc/app_context.h" +#include "nel/misc/debug.h" +// Qt includes #include #include #include @@ -30,8 +33,17 @@ namespace ExtensionSystem { +const char *const PLUGIN_SPEC_NAME = "name"; +const char *const PLUGIN_SPEC_VENDOR = "vendor"; +const char *const PLUGIN_SPEC_VERSION = "version"; +const char *const PLUGIN_SPEC_LIBRARY_NAME = "library-name"; +const char *const PLUGIN_SPEC_DESCRIPTION = "description"; +const char *const PLUGIN_SPEC_DEPENDENCIES = "dependencies"; +const char *const PLUGIN_SPEC_DEPENDENCY = "dependency"; +const char *const PLUGIN_SPEC_DEPENDENCY_NAME = "plugin-name"; +const char *const PLUGIN_SPEC_DEPENDENCY_VERSION = "version"; -CPluginSpec::CPluginSpec() +PluginSpec::PluginSpec() : m_location(""), m_filePath(""), m_fileName(""), @@ -39,6 +51,8 @@ CPluginSpec::CPluginSpec() m_version(""), m_vendor(""), m_description(""), + m_nameSpecFile(""), + m_suffix(""), m_state(State::Invalid), m_enabled(true), m_enabledStartup(true), @@ -47,104 +61,195 @@ CPluginSpec::CPluginSpec() m_plugin(0), m_pluginManager(0) { +#ifdef Q_OS_WIN +# ifdef DEBUG + m_suffix = "_d.dll"; +# else + m_suffix = "_r.dll"; +# endif +#else + m_suffix = ".so"; +#endif } -QString CPluginSpec::name() const +QString PluginSpec::name() const { return m_name; } -QString CPluginSpec::version() const +QString PluginSpec::version() const { return m_version; } -QString CPluginSpec::vendor() const +QString PluginSpec::vendor() const { return m_vendor; } -QString CPluginSpec::description() const +QString PluginSpec::description() const { return m_description; } -QString CPluginSpec::location() const +QString PluginSpec::location() const { return m_location; } -QString CPluginSpec::filePath() const +QString PluginSpec::filePath() const { return m_filePath; } -QString CPluginSpec::fileName() const +QString PluginSpec::fileName() const { return m_fileName; } -IPlugin *CPluginSpec::plugin() const +IPlugin *PluginSpec::plugin() const { return m_plugin; } -int CPluginSpec::state() const +int PluginSpec::state() const { return m_state; } -bool CPluginSpec::hasError() const +bool PluginSpec::hasError() const { return m_hasError; } -QString CPluginSpec::errorString() const +QString PluginSpec::errorString() const { return m_errorString; } -QList CPluginSpec::dependencySpecs() const +QList PluginSpec::dependencySpecs() const { return m_dependencySpecs; } -bool CPluginSpec::setFileName(const QString &fileName) +bool PluginSpec::setFileName(const QString &fileName) { - QFile file(fileName); + m_fileName = fileName + m_suffix; + m_filePath = m_location + "/" + m_fileName; + + nlinfo(m_filePath.toStdString().c_str()); + QFile file(m_filePath); if (!file.exists()) - return reportError(QCoreApplication::translate("CPluginSpec", "File does not exist: %1").arg(file.fileName())); + return reportError(QCoreApplication::translate("PluginSpec", "File does not exist: %1").arg(file.fileName())); if (!file.open(QIODevice::ReadOnly)) - return reportError(QCoreApplication::translate("CPluginSpec", "Could not open file for read: %1").arg(file.fileName())); + return reportError(QCoreApplication::translate("PluginSpec", "Could not open file for read: %1").arg(file.fileName())); + return true; +} + +bool PluginSpec::setSpecFileName(const QString &specFileName) +{ + m_nameSpecFile = specFileName; + + QFile file(specFileName); + if (!file.exists()) + return reportError(QCoreApplication::translate("PluginSpec", "Spec file does not exist: %1").arg(file.fileName())); QFileInfo fileInfo(file); m_location = fileInfo.absolutePath(); - m_filePath = fileInfo.absoluteFilePath(); - m_fileName = fileInfo.fileName(); + readSpec(); + return true; +} +bool PluginSpec::readSpec() +{ + QFile file(m_nameSpecFile); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return reportError(QCoreApplication::translate("PluginSpec", "Could not open spec file for read: %1").arg(file.fileName())); + + QXmlStreamReader reader(&file); + while (!reader.atEnd()) + { + if (reader.isStartElement()) + parseSpec(reader); + reader.readNext(); + } + if (reader.hasError()) + return reportError(QCoreApplication::translate("PluginSpec", "Error parsing file %1: %2, at line %3, column %4") + .arg(file.fileName()) + .arg(reader.errorString()) + .arg(reader.lineNumber()) + .arg(reader.columnNumber())); m_state = State::Read; return true; } -void CPluginSpec::setEnabled(bool enabled) +void PluginSpec::parseSpec(QXmlStreamReader &reader) +{ + QString elemName = reader.name().toString(); + reader.readNext(); + if (reader.isCharacters()) + { + QString elemText = reader.text().toString(); + if (elemName == PLUGIN_SPEC_LIBRARY_NAME) + setFileName(elemText); + if (elemName == PLUGIN_SPEC_NAME) + m_name = elemText; + if (elemName == PLUGIN_SPEC_VERSION) + m_version = elemText; + if (elemName == PLUGIN_SPEC_VENDOR) + m_vendor = elemText; + if (elemName == PLUGIN_SPEC_DESCRIPTION) + m_description = elemText; + if (elemName == PLUGIN_SPEC_DEPENDENCIES) + parseDependency(reader); + } +} + +void PluginSpec::parseDependency(QXmlStreamReader &reader) +{ + QString elemName; + while (!reader.atEnd() && (elemName != PLUGIN_SPEC_DEPENDENCIES)) + { + reader.readNext(); + elemName = reader.name().toString(); + if (reader.isStartElement() && (elemName == PLUGIN_SPEC_DEPENDENCY)) + { + // Read name dependency plugin + QString dependencyName = reader.attributes().value(PLUGIN_SPEC_DEPENDENCY_NAME).toString(); + if (dependencyName.isEmpty()) + { + reader.raiseError(QCoreApplication::translate("CPluginSpec", "'%1' misses attribute '%2'") + .arg(PLUGIN_SPEC_DEPENDENCY) + .arg(PLUGIN_SPEC_DEPENDENCY_NAME)); + return; + } + // Read version dependency plugin + QString dependencyVersion = reader.attributes().value(PLUGIN_SPEC_DEPENDENCY_VERSION).toString(); + + m_dependencies.push_back(dependencyName); + } + } +} + +void PluginSpec::setEnabled(bool enabled) { m_enabled = enabled; } -bool CPluginSpec::isEnabled() const +bool PluginSpec::isEnabled() const { return m_enabled; } -bool CPluginSpec::loadLibrary() +bool PluginSpec::loadLibrary() { if (m_hasError) return false; - if (m_state != State::Read) + if (m_state != State::Resolved) { if (m_state == State::Loaded) return true; - return reportError(QCoreApplication::translate("CPluginSpec", "Loading the library failed because state != Resolved")); + return reportError(QCoreApplication::translate("PluginSpec", "Loading the library failed because state != Resolved")); } QPluginLoader loader(m_filePath); @@ -155,38 +260,32 @@ bool CPluginSpec::loadLibrary() if (!pluginObject) { loader.unload(); - return reportError(QCoreApplication::translate("CPluginSpec", "Plugin is not valid (does not derive from IPlugin)")); + return reportError(QCoreApplication::translate("PluginSpec", "Plugin is not valid (does not derive from IPlugin)")); } pluginObject->setNelContext(&NLMISC::INelContext::getInstance()); - m_name = pluginObject->name(); - m_version = pluginObject->version(); - m_vendor = pluginObject->vendor(); - m_description = pluginObject->description(); - m_state = State::Loaded; m_plugin = pluginObject; return true; } -bool CPluginSpec::resolveDependencies(const QList &specs) +bool PluginSpec::resolveDependencies(const QList &specs) { if (m_hasError) return false; - if (m_state != State::Loaded) + if (m_state != State::Read) { - m_errorString = QCoreApplication::translate("CPluginSpec", "Resolving dependencies failed because state != Read"); + m_errorString = QCoreApplication::translate("PluginSpec", "Resolving dependencies failed because state != Read"); m_hasError = true; return false; } - QList resolvedDependencies; - QStringList dependencies = m_plugin->dependencies(); - Q_FOREACH(const QString &dependency, dependencies) + QList resolvedDependencies; + Q_FOREACH(const QString &dependency, m_dependencies) { - CPluginSpec *found = 0; + PluginSpec *found = 0; - Q_FOREACH(CPluginSpec *spec, specs) + Q_FOREACH(PluginSpec *spec, specs) { if (QString::compare(dependency, spec->name(), Qt::CaseInsensitive) == 0) { @@ -199,7 +298,7 @@ bool CPluginSpec::resolveDependencies(const QList &specs) m_hasError = true; if (!m_errorString.isEmpty()) m_errorString.append(QLatin1Char('\n')); - m_errorString.append(QCoreApplication::translate("CPluginSpec", "Could not resolve dependency '%1'") + m_errorString.append(QCoreApplication::translate("PluginSpec", "Could not resolve dependency '%1'") .arg(dependency)); continue; } @@ -209,34 +308,32 @@ bool CPluginSpec::resolveDependencies(const QList &specs) return false; m_dependencySpecs = resolvedDependencies; - m_state = State::Resolved; - return true; } -bool CPluginSpec::initializePlugin() +bool PluginSpec::initializePlugin() { if (m_hasError) return false; - if (m_state != State::Resolved) + if (m_state != State::Loaded) { if (m_state == State::Initialized) return true; - return reportError(QCoreApplication::translate("CPluginSpec", "Initializing the plugin failed because state != Resolved)")); + return reportError(QCoreApplication::translate("PluginSpec", "Initializing the plugin failed because state != Loaded)")); } if (!m_plugin) - return reportError(QCoreApplication::translate("CPluginSpec", "Internal error: have no plugin instance to initialize")); + return reportError(QCoreApplication::translate("PluginSpec", "Internal error: have no plugin instance to initialize")); QString err; if (!m_plugin->initialize(m_pluginManager, &err)) - return reportError(QCoreApplication::translate("CPluginSpec", "Plugin initialization failed: %1").arg(err)); + return reportError(QCoreApplication::translate("PluginSpec", "Plugin initialization failed: %1").arg(err)); m_state = State::Initialized; return true; } -bool CPluginSpec::initializeExtensions() +bool PluginSpec::initializeExtensions() { if (m_hasError) return false; @@ -244,17 +341,17 @@ bool CPluginSpec::initializeExtensions() { if (m_state == State::Running) return true; - return reportError(QCoreApplication::translate("CPluginSpec", "Cannot perform extensionsInitialized because state != Initialized")); + return reportError(QCoreApplication::translate("PluginSpec", "Cannot perform extensionsInitialized because state != Initialized")); } if (!m_plugin) - return reportError(QCoreApplication::translate("CPluginSpec", "Internal error: have no plugin instance to perform extensionsInitialized")); + return reportError(QCoreApplication::translate("PluginSpec", "Internal error: have no plugin instance to perform extensionsInitialized")); m_plugin->extensionsInitialized(); m_state = State::Running; return true; } -void CPluginSpec::stop() +void PluginSpec::stop() { if (!m_plugin) return; @@ -262,7 +359,7 @@ void CPluginSpec::stop() m_state = State::Stopped; } -void CPluginSpec::kill() +void PluginSpec::kill() { if (!m_plugin) return; @@ -271,17 +368,17 @@ void CPluginSpec::kill() m_state = State::Deleted; } -void CPluginSpec::setEnabledStartup(bool enabled) +void PluginSpec::setEnabledStartup(bool enabled) { m_enabledStartup = enabled; } -bool CPluginSpec::isEnabledStartup() const +bool PluginSpec::isEnabledStartup() const { return m_enabledStartup; } -bool CPluginSpec::reportError(const QString &err) +bool PluginSpec::reportError(const QString &err) { m_errorString = err; m_hasError = true; diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.h index 5d9605de7..c28980d69 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.h @@ -21,12 +21,14 @@ #include "iplugin_spec.h" -#include "QtCore/QList" +#include +#include +#include namespace ExtensionSystem { -class CPluginSpec: public IPluginSpec +class PluginSpec: public IPluginSpec { public: virtual QString name() const; @@ -44,18 +46,22 @@ public: virtual int state() const; virtual bool hasError() const; virtual QString errorString() const; - QList dependencySpecs() const; + QList dependencySpecs() const; /// Enables/disables load this plugin after restart the program virtual void setEnabled(bool enabled); virtual bool isEnabled() const; private: - CPluginSpec(); + PluginSpec(); bool setFileName(const QString &fileName); + bool setSpecFileName(const QString &specFileName); + bool readSpec(); + void parseSpec(QXmlStreamReader &reader); + void parseDependency(QXmlStreamReader &reader); bool loadLibrary(); - bool resolveDependencies(const QList &specs); + bool resolveDependencies(const QList &specs); bool initializePlugin(); bool initializeExtensions(); void stop(); @@ -77,16 +83,19 @@ private: QString m_vendor; QString m_description; + QString m_nameSpecFile; + QString m_suffix; int m_state; bool m_enabled, m_enabledStartup; bool m_hasError; QString m_errorString; + QStringList m_dependencies; IPlugin *m_plugin; IPluginManager *m_pluginManager; - QList m_dependencySpecs; + QList m_dependencySpecs; - friend class CPluginManager; + friend class PluginManager; }; } // namespace ExtensionSystem diff --git a/code/nel/tools/3d/object_viewer_qt/src/main.cpp b/code/nel/tools/3d/object_viewer_qt/src/main.cpp index 1ddcc5565..4b904bdc6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/main.cpp @@ -148,7 +148,7 @@ sint main(int argc, char **argv) NLMISC::CLibrary::addLibPath((qApp->applicationDirPath() + QString("/../PlugIns/nel")).toStdString()); #endif - ExtensionSystem::CPluginManager pluginManager; + ExtensionSystem::PluginManager pluginManager; pluginManager.setSettings(settings); QStringList pluginPaths; #if !defined(NL_OS_MAC)