From 137ac555187388dee63a1c0f8fa47638faa27ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=8D=9A=E6=96=87?= Date: Mon, 23 Oct 2017 11:53:44 +0800 Subject: [PATCH] update plugins api version Change-Id: Ifa977978f2ba7cc5795e7f1a10a1b9fe9c6e9923 --- frame/controller/dockpluginscontroller.cpp | 11 +++++++++-- plugins/datetime/datetime.json | 1 + plugins/disk-mount/disk-mount.json | 1 + plugins/network/network.json | 1 + plugins/shutdown/shutdown.json | 1 + plugins/sound/sound.json | 1 + plugins/system-tray/system-tray.json | 1 + plugins/trash/trash.json | 1 + 8 files changed, 16 insertions(+), 2 deletions(-) diff --git a/frame/controller/dockpluginscontroller.cpp b/frame/controller/dockpluginscontroller.cpp index 08177db8d..ba190698f 100644 --- a/frame/controller/dockpluginscontroller.cpp +++ b/frame/controller/dockpluginscontroller.cpp @@ -27,6 +27,8 @@ #include #include +#define API_VERSION "1.0" + DockPluginsController::DockPluginsController(DockItemController *itemControllerInter) : QObject(itemControllerInter), m_itemControllerInter(itemControllerInter) @@ -136,9 +138,14 @@ void DockPluginsController::positionChanged() void DockPluginsController::loadPlugin(const QString &pluginFile) { - qDebug() << "load plugin: " << pluginFile; - QPluginLoader *pluginLoader = new QPluginLoader(pluginFile, this); + const auto meta = pluginLoader->metaData().value("MetaData").toObject(); + if (!meta.contains("api") || meta["api"].toString() != API_VERSION) + { + qWarning() << "plugin api version not matched!" << pluginFile; + return; + } + PluginsItemInterface *interface = qobject_cast(pluginLoader->instance()); if (!interface) { diff --git a/plugins/datetime/datetime.json b/plugins/datetime/datetime.json index 2c63c0851..b9b78cb89 100644 --- a/plugins/datetime/datetime.json +++ b/plugins/datetime/datetime.json @@ -1,2 +1,3 @@ { + "api": "1.0" } diff --git a/plugins/disk-mount/disk-mount.json b/plugins/disk-mount/disk-mount.json index 2c63c0851..b9b78cb89 100644 --- a/plugins/disk-mount/disk-mount.json +++ b/plugins/disk-mount/disk-mount.json @@ -1,2 +1,3 @@ { + "api": "1.0" } diff --git a/plugins/network/network.json b/plugins/network/network.json index 2c63c0851..b9b78cb89 100644 --- a/plugins/network/network.json +++ b/plugins/network/network.json @@ -1,2 +1,3 @@ { + "api": "1.0" } diff --git a/plugins/shutdown/shutdown.json b/plugins/shutdown/shutdown.json index 2c63c0851..b9b78cb89 100644 --- a/plugins/shutdown/shutdown.json +++ b/plugins/shutdown/shutdown.json @@ -1,2 +1,3 @@ { + "api": "1.0" } diff --git a/plugins/sound/sound.json b/plugins/sound/sound.json index 2c63c0851..b9b78cb89 100644 --- a/plugins/sound/sound.json +++ b/plugins/sound/sound.json @@ -1,2 +1,3 @@ { + "api": "1.0" } diff --git a/plugins/system-tray/system-tray.json b/plugins/system-tray/system-tray.json index 2c63c0851..b9b78cb89 100644 --- a/plugins/system-tray/system-tray.json +++ b/plugins/system-tray/system-tray.json @@ -1,2 +1,3 @@ { + "api": "1.0" } diff --git a/plugins/trash/trash.json b/plugins/trash/trash.json index 2c63c0851..b9b78cb89 100644 --- a/plugins/trash/trash.json +++ b/plugins/trash/trash.json @@ -1,2 +1,3 @@ { + "api": "1.0" }