修改版本号机制,修改插件版本校验机制。

This commit is contained in:
iaom 2022-05-27 09:42:15 +08:00
parent 6009d862ca
commit cb1201a283
5 changed files with 17 additions and 4 deletions

View File

@ -2,7 +2,7 @@ QT += core gui dbus KWindowSystem xml x11extras
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
VERSION = 1.0.0
VERSION = 2.2.3
DEFINES += VERSION='\\"$${VERSION}\\"'
TARGET = ukui-search
TEMPLATE = app

View File

@ -1,5 +1,5 @@
QT += core xml widgets dbus concurrent sql
VERSION = 1.1.0
VERSION = 2.2.3
DEFINES += VERSION='\\"$${VERSION}\\"'
TARGET = ukui-search

View File

@ -1,6 +1,7 @@
#ifndef SEARCHPLUGINIFACE_H
#define SEARCHPLUGINIFACE_H
#define SearchPluginIface_iid "org.ukui.ukui-search.plugin-iface.SearchPluginInterface"
#define SEARCH_PLUGIN_IFACE_VERSION "1.1.0"
#include <QString>
#include <QIcon>

View File

@ -1,6 +1,7 @@
#ifndef SEARCHTASKPLUGINIFACE_H
#define SEARCHTASKPLUGINIFACE_H
#define SearchTaskPluginIface_iid "org.ukui.ukui-search.plugin-iface.SearchTaskPluginIface"
#define SEARCH_TASK_PLUGIN_IFACE_VERSION "1.0.0"
#include <QObject>
#include <QtPlugin>

View File

@ -31,9 +31,20 @@ PluginManager::PluginManager(QObject *parent) : QObject(parent)
Q_FOREACH(QString fileName, pluginsDir.entryList(QDir::Files)) {
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
// version check
QString type = pluginLoader.metaData().value("MetaData").toObject().value("type").toString();
QString version = pluginLoader.metaData().value("MetaData").toObject().value("version").toString();
if (version != VERSION) {
qWarning() << "Plugin version check failed:" << fileName << "version," << "iface version : " << VERSION;
if(type == "SEARCH_PLUGIN") {
if (version != SEARCH_PLUGIN_IFACE_VERSION) {
qWarning() << "SEARCH_PLUGIN version check failed:" << fileName << "version:" << version << "iface version : " << SEARCH_PLUGIN_IFACE_VERSION;
continue;
}
} else if(type == "SEARCH_TASK_PLUGIN") {
if (version != SEARCH_TASK_PLUGIN_IFACE_VERSION) {
qWarning() << "SEARCH_TASK_PLUGIN_IFACE_VERSION version check failed:" << fileName << "version:" << version << "iface version : " << SEARCH_TASK_PLUGIN_IFACE_VERSION;
continue;
}
} else {
qWarning() << "Unsupport plugin:" << fileName << "type:" << type;
continue;
}