Core: Support disabling Addon by FreeCAD version

If package.xml metadata file exists, it is scanned for FreeCAD version
compatibility before the Addon is loaded. If the Addon specifies that it is
explicitly not compatible with the current version of FreeCAD, the Addon is
not loaded.
This commit is contained in:
Chris Hennes
2022-03-08 23:17:03 -06:00
parent 907ef395f4
commit f122061424
6 changed files with 81 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2021 Chris Hennes <chennes@pioneerlibrarysystem.org> *
* Copyright (c) 2022 FreeCAD Project Association *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@@ -456,6 +456,23 @@ bool Metadata::satisfies(const Meta::Dependency& dep)
return true;
}
bool App::Metadata::supportsCurrentFreeCAD() const
{
static auto fcVersion = Meta::Version();
if (fcVersion == Meta::Version()) {
std::map<std::string, std::string>& config = App::Application::Config();
std::stringstream ss;
ss << config["BuildVersionMajor"] << "." << config["BuildVersionMinor"] << "." << config["BuildRevision"].empty() ? "0" : config["BuildRevision"];
fcVersion = Meta::Version(ss.str());
}
if (_freecadmin != Meta::Version() && _freecadmin > fcVersion)
return false;
else if (_freecadmax != Meta::Version() && _freecadmax < fcVersion)
return false;
return true;
}
void Metadata::appendToElement(DOMElement* root) const
{
appendSimpleXMLNode(root, "name", _name);