mirror of https://github.com/nymea/nymea.git
Introduce API versioning
parent
1fe5e6554e
commit
1822fb10f2
|
|
@ -847,15 +847,35 @@ void DeviceManagerImplementation::loadPlugins()
|
|||
continue;
|
||||
}
|
||||
|
||||
// Check plugin API version compatibility
|
||||
QLibrary lib(fi.absoluteFilePath());
|
||||
QString *version = reinterpret_cast<QString*>(lib.resolve("nymea_plugin_api_version"));
|
||||
if (!version) {
|
||||
qCWarning(dcDeviceManager()).nospace() << "Unable to resolve version in plugin " << entry << ". Not loading plugin.";
|
||||
loader.unload();
|
||||
lib.unload();
|
||||
continue;
|
||||
}
|
||||
lib.unload();
|
||||
QStringList parts = version->split('.');
|
||||
QStringList coreParts = QString(DEVICE_PLUGIN_API_VERSION).split('.');
|
||||
if (parts.length() != 2 || parts.at(0).toInt() != coreParts.at(0).toInt() || parts.at(1).toInt() > coreParts.at(1).toInt()) {
|
||||
qCWarning(dcDeviceManager()).nospace() << "Plugin API mismatch for " << entry << ". Core API: " << DEVICE_PLUGIN_API_VERSION << ", Plugin API: " << *version;
|
||||
loader.unload();
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginMetadata metaData(loader.metaData().value("MetaData").toObject());
|
||||
if (!metaData.isValid()) {
|
||||
qCWarning(dcDeviceManager()) << "Plugin metadata not valid for" << entry;
|
||||
loader.unload();
|
||||
continue;
|
||||
}
|
||||
|
||||
DevicePlugin *pluginIface = qobject_cast<DevicePlugin *>(loader.instance());
|
||||
if (!pluginIface) {
|
||||
qCWarning(dcDeviceManager) << "Could not get plugin instance of" << entry;
|
||||
loader.unload();
|
||||
continue;
|
||||
}
|
||||
loadPlugin(pluginIface, metaData);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"
|
|||
JSON_PROTOCOL_VERSION_MAJOR=2
|
||||
JSON_PROTOCOL_VERSION_MINOR=2
|
||||
REST_API_VERSION=1
|
||||
DEVICE_PLUGIN_API_VERSION_MAJOR=0
|
||||
DEVICE_PLUGIN_API_VERSION_MINOR=1
|
||||
|
||||
COPYRIGHT_YEAR_FROM=2013
|
||||
COPYRIGHT_YEAR_TO=2019
|
||||
|
|
@ -12,7 +14,8 @@ COPYRIGHT_YEAR_TO=2019
|
|||
DEFINES += NYMEA_VERSION_STRING=\\\"$${NYMEA_VERSION_STRING}\\\" \
|
||||
JSON_PROTOCOL_VERSION=\\\"$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}\\\" \
|
||||
REST_API_VERSION=\\\"$${REST_API_VERSION}\\\" \
|
||||
COPYRIGHT_YEAR_STRING=\\\"$${COPYRIGHT_YEAR_FROM}-$${COPYRIGHT_YEAR_TO}\\\"
|
||||
COPYRIGHT_YEAR_STRING=\\\"$${COPYRIGHT_YEAR_FROM}-$${COPYRIGHT_YEAR_TO}\\\" \
|
||||
DEVICE_PLUGIN_API_VERSION=\\\"$${DEVICE_PLUGIN_API_VERSION_MAJOR}.$${DEVICE_PLUGIN_API_VERSION_MINOR}\\\"
|
||||
|
||||
QT *= network websockets bluetooth dbus
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue