dde-dock: API version check

This commit is contained in:
Hualet Wang 2015-07-20 09:51:52 +08:00
parent dea0ca42ca
commit 61d09fb6c0
2 changed files with 6 additions and 1 deletions

View File

@ -12,6 +12,7 @@ TARGET = dde-dock
TEMPLATE = app
INCLUDEPATH += src/ ../libs/
DEFINES += PLUGIN_API_VERSION=1.0
SOURCES += \
src/main.cpp \

View File

@ -51,11 +51,15 @@ void DockPluginManager::onDockModeChanged(Dock::DockMode newMode,
// private methods
DockPluginProxy * DockPluginManager::loadPlugin(const QString &path)
{
// check the file type
if (!QLibrary::isLibrary(path)) return NULL;
QPluginLoader * pluginLoader = new QPluginLoader(path);
// TODO: API version check;
// check the apiVersion the plugin uses
double apiVersion = pluginLoader->metaData()["MetaData"].toObject()["api_version"].toDouble();
if (apiVersion != PLUGIN_API_VERSION) return NULL;
QObject *plugin = pluginLoader->instance();