mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-29 12:45:40 +08:00
Ref T169, check minimum mapping tool version
* added min.version in global setup * check in CSwiftData::checkMinimumVersion
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6ce80bbd8e
commit
60656843f8
@@ -9,6 +9,7 @@
|
|||||||
"url": "https://datastore.swift-project.org"
|
"url": "https://datastore.swift-project.org"
|
||||||
},
|
},
|
||||||
"development": false,
|
"development": false,
|
||||||
|
"mappingMinimumVersion" : "0.8.3",
|
||||||
"fsdTestServers": {
|
"fsdTestServers": {
|
||||||
"containerbase": []
|
"containerbase": []
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "blackmisc/network/user.h"
|
#include "blackmisc/network/user.h"
|
||||||
#include "blackmisc/stringutils.h"
|
#include "blackmisc/stringutils.h"
|
||||||
|
|
||||||
|
#include <QVersionNumber>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
@@ -31,11 +32,12 @@ namespace BlackCore
|
|||||||
CGlobalSetup::CGlobalSetup() :
|
CGlobalSetup::CGlobalSetup() :
|
||||||
ITimestampBased(0)
|
ITimestampBased(0)
|
||||||
{
|
{
|
||||||
this->initDefaultUrls();
|
this->initDefaultValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGlobalSetup::initDefaultUrls()
|
void CGlobalSetup::initDefaultValues()
|
||||||
{
|
{
|
||||||
|
m_mappingMinimumVersion = CBuildConfig::getVersionString();
|
||||||
m_dbRootDirectoryUrl = CUrl("https://datastore.swift-project.org/");
|
m_dbRootDirectoryUrl = CUrl("https://datastore.swift-project.org/");
|
||||||
m_vatsimBookingsUrl = CUrl("http://vatbook.euroutepro.com/xml2.php");
|
m_vatsimBookingsUrl = CUrl("http://vatbook.euroutepro.com/xml2.php");
|
||||||
m_vatsimMetarsUrls = CUrlList({"http://metar.vatsim.net/metar.php"});
|
m_vatsimMetarsUrls = CUrlList({"http://metar.vatsim.net/metar.php"});
|
||||||
@@ -87,12 +89,12 @@ namespace BlackCore
|
|||||||
|
|
||||||
CUrlList CGlobalSetup::getSwiftBootstrapFileUrls() const
|
CUrlList CGlobalSetup::getSwiftBootstrapFileUrls() const
|
||||||
{
|
{
|
||||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
|
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrlList CGlobalSetup::getSwiftDistributionFileUrls() const
|
CUrlList CGlobalSetup::getSwiftDistributionFileUrls() const
|
||||||
{
|
{
|
||||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::versionString() + "/updateinfo/distribution.json");
|
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/updateinfo/distribution.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrl CGlobalSetup::getDbHomePageUrl() const
|
CUrl CGlobalSetup::getDbHomePageUrl() const
|
||||||
@@ -168,24 +170,24 @@ namespace BlackCore
|
|||||||
QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate)
|
QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate)
|
||||||
{
|
{
|
||||||
if (candidate.isEmpty()) return ""; // not possible
|
if (candidate.isEmpty()) return ""; // not possible
|
||||||
static const QString version(QString(CGlobalSetup::versionString()).append("/"));
|
static const QString version(QString(CGlobalSetup::schemaVersionString()).append("/"));
|
||||||
if (candidate.endsWith("bootstrap.json")) { return candidate; }
|
if (candidate.endsWith("bootstrap.json")) { return candidate; }
|
||||||
CUrl url(candidate);
|
CUrl url(candidate);
|
||||||
if (candidate.contains("/bootstrap"))
|
if (candidate.contains("/bootstrap"))
|
||||||
{
|
{
|
||||||
url.appendPath("bootstrap.json");
|
url.appendPath("bootstrap.json");
|
||||||
}
|
}
|
||||||
else if (candidate.endsWith(CGlobalSetup::versionString()) || candidate.endsWith(version))
|
else if (candidate.endsWith(CGlobalSetup::schemaVersionString()) || candidate.endsWith(version))
|
||||||
{
|
{
|
||||||
url.appendPath("/bootstrap/bootstrap.json");
|
url.appendPath("/bootstrap/bootstrap.json");
|
||||||
}
|
}
|
||||||
else if (candidate.endsWith("shared") || candidate.endsWith("shared/"))
|
else if (candidate.endsWith("shared") || candidate.endsWith("shared/"))
|
||||||
{
|
{
|
||||||
url.appendPath(CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
|
url.appendPath(CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
url.appendPath("shared/" + CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
|
url.appendPath("shared/" + CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||||
}
|
}
|
||||||
return url.getFullUrl();
|
return url.getFullUrl();
|
||||||
}
|
}
|
||||||
@@ -193,20 +195,20 @@ namespace BlackCore
|
|||||||
CUrl CGlobalSetup::buildDbDataDirectoryUrl(const CUrl &candidate)
|
CUrl CGlobalSetup::buildDbDataDirectoryUrl(const CUrl &candidate)
|
||||||
{
|
{
|
||||||
if (candidate.isEmpty()) return CUrl(); // not possible
|
if (candidate.isEmpty()) return CUrl(); // not possible
|
||||||
static const QString version(QString(versionString()).append("/"));
|
static const QString version(QString(schemaVersionString()).append("/"));
|
||||||
if (candidate.pathEndsWith("dbdata") || candidate.pathEndsWith("dbdata/")) { return candidate; }
|
if (candidate.pathEndsWith("dbdata") || candidate.pathEndsWith("dbdata/")) { return candidate; }
|
||||||
CUrl url(candidate);
|
CUrl url(candidate);
|
||||||
if (candidate.pathEndsWith(versionString()) || candidate.pathEndsWith(version))
|
if (candidate.pathEndsWith(schemaVersionString()) || candidate.pathEndsWith(version))
|
||||||
{
|
{
|
||||||
url.appendPath("/dbdata");
|
url.appendPath("/dbdata");
|
||||||
}
|
}
|
||||||
else if (candidate.pathEndsWith("shared") || candidate.pathEndsWith("shared/"))
|
else if (candidate.pathEndsWith("shared") || candidate.pathEndsWith("shared/"))
|
||||||
{
|
{
|
||||||
url.appendPath(CGlobalSetup::versionString() + "/dbdata/");
|
url.appendPath(CGlobalSetup::schemaVersionString() + "/dbdata/");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
url.appendPath("shared/" + CGlobalSetup::versionString() + "/dbdata/");
|
url.appendPath("shared/" + CGlobalSetup::schemaVersionString() + "/dbdata/");
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@@ -236,6 +238,14 @@ namespace BlackCore
|
|||||||
return testServers;
|
return testServers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CGlobalSetup::isSwiftVersionMinimumMappingVersion() const
|
||||||
|
{
|
||||||
|
if (!this->wasLoaded()) { return false; }
|
||||||
|
if (m_mappingMinimumVersion.isEmpty()) { return false; }
|
||||||
|
const QVersionNumber min = QVersionNumber::fromString(this->getMappingMinimumVersionString());
|
||||||
|
return CBuildConfig::getVersion() >= min;
|
||||||
|
}
|
||||||
|
|
||||||
QString CGlobalSetup::convertToQString(bool i18n) const
|
QString CGlobalSetup::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
return convertToQString(", ", i18n);
|
return convertToQString(", ", i18n);
|
||||||
@@ -255,6 +265,10 @@ namespace BlackCore
|
|||||||
% boolToYesNo(isDevelopment())
|
% boolToYesNo(isDevelopment())
|
||||||
% separator
|
% separator
|
||||||
|
|
||||||
|
% "Mapping min.version: "
|
||||||
|
% this->getMappingMinimumVersionString()
|
||||||
|
% separator
|
||||||
|
|
||||||
% "Distribution URLs: "
|
% "Distribution URLs: "
|
||||||
% getSwiftDistributionFileUrls().toQString(i18n)
|
% getSwiftDistributionFileUrls().toQString(i18n)
|
||||||
% separator
|
% separator
|
||||||
@@ -337,6 +351,7 @@ namespace BlackCore
|
|||||||
case IndexOnlineHelpUrls: return CVariant::fromValue(m_onlineHelpUrls);
|
case IndexOnlineHelpUrls: return CVariant::fromValue(m_onlineHelpUrls);
|
||||||
case IndexCrashReportServerUrl: return CVariant::fromValue(m_crashReportServerUrl);
|
case IndexCrashReportServerUrl: return CVariant::fromValue(m_crashReportServerUrl);
|
||||||
case IndexWasLoaded: return CVariant::fromValue(m_wasLoaded);
|
case IndexWasLoaded: return CVariant::fromValue(m_wasLoaded);
|
||||||
|
case IndexMappingMinimumVersion: return CVariant::fromValue(m_mappingMinimumVersion);
|
||||||
default: return CValueObject::propertyByIndex(index);
|
default: return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -367,11 +382,12 @@ namespace BlackCore
|
|||||||
case IndexSwiftMapUrls: m_mapUrls = variant.value<CUrlList>(); break;
|
case IndexSwiftMapUrls: m_mapUrls = variant.value<CUrlList>(); break;
|
||||||
case IndexCrashReportServerUrl: m_crashReportServerUrl = variant.value<CUrl>(); break;
|
case IndexCrashReportServerUrl: m_crashReportServerUrl = variant.value<CUrl>(); break;
|
||||||
case IndexWasLoaded: m_wasLoaded = variant.toBool(); break;
|
case IndexWasLoaded: m_wasLoaded = variant.toBool(); break;
|
||||||
|
case IndexMappingMinimumVersion: m_mappingMinimumVersion = variant.toQString(); break;
|
||||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &CGlobalSetup::versionString()
|
const QString &CGlobalSetup::schemaVersionString()
|
||||||
{
|
{
|
||||||
// This is not the current swift version, but the schema version
|
// This is not the current swift version, but the schema version
|
||||||
static const QString v("0.7.0");
|
static const QString v("0.7.0");
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ namespace BlackCore
|
|||||||
IndexOnlineHelpUrls,
|
IndexOnlineHelpUrls,
|
||||||
IndexCrashReportServerUrl,
|
IndexCrashReportServerUrl,
|
||||||
IndexWasLoaded,
|
IndexWasLoaded,
|
||||||
IndexSharedUrls
|
IndexSharedUrls,
|
||||||
|
IndexMappingMinimumVersion
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
@@ -174,6 +175,14 @@ namespace BlackCore
|
|||||||
//! Is server a development server?
|
//! Is server a development server?
|
||||||
bool isDevelopment() const { return m_development; }
|
bool isDevelopment() const { return m_development; }
|
||||||
|
|
||||||
|
//! Creating mappings requires at least this version or higher
|
||||||
|
//! \remark only valid if wasLoaded() is \c true
|
||||||
|
const QString &getMappingMinimumVersionString() const { return m_mappingMinimumVersion; }
|
||||||
|
|
||||||
|
//! Meets the minimum mapping version
|
||||||
|
//! \remark only valid if wasLoaded() is \c true
|
||||||
|
bool isSwiftVersionMinimumMappingVersion() const;
|
||||||
|
|
||||||
//! Productive settings?
|
//! Productive settings?
|
||||||
void setDevelopment(bool development) { m_development = development; }
|
void setDevelopment(bool development) { m_development = development; }
|
||||||
|
|
||||||
@@ -189,8 +198,8 @@ namespace BlackCore
|
|||||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
||||||
|
|
||||||
//! Schema version
|
//! Schema version (shared files, bootstrap file)
|
||||||
static const QString &versionString();
|
static const QString &schemaVersionString();
|
||||||
|
|
||||||
//! Build bootstrap file URL from shared URL
|
//! Build bootstrap file URL from shared URL
|
||||||
static QString buildBootstrapFileUrl(const QString &candidate);
|
static QString buildBootstrapFileUrl(const QString &candidate);
|
||||||
@@ -206,6 +215,7 @@ namespace BlackCore
|
|||||||
int m_dbHttpPort = 80; //!< port
|
int m_dbHttpPort = 80; //!< port
|
||||||
int m_dbHttpsPort = 443; //!< SSL port
|
int m_dbHttpsPort = 443; //!< SSL port
|
||||||
bool m_development = false; //!< dev. version?
|
bool m_development = false; //!< dev. version?
|
||||||
|
QString m_mappingMinimumVersion; //!< minimum version
|
||||||
BlackMisc::Network::CUrl m_crashReportServerUrl; //!< crash report server
|
BlackMisc::Network::CUrl m_crashReportServerUrl; //!< crash report server
|
||||||
BlackMisc::Network::CUrl m_dbRootDirectoryUrl; //!< Root directory of DB
|
BlackMisc::Network::CUrl m_dbRootDirectoryUrl; //!< Root directory of DB
|
||||||
BlackMisc::Network::CUrl m_vatsimBookingsUrl; //!< ATC bookings
|
BlackMisc::Network::CUrl m_vatsimBookingsUrl; //!< ATC bookings
|
||||||
@@ -222,7 +232,7 @@ namespace BlackCore
|
|||||||
bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing
|
bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing
|
||||||
|
|
||||||
//! Set the default URLs
|
//! Set the default URLs
|
||||||
void initDefaultUrls();
|
void initDefaultValues();
|
||||||
|
|
||||||
BLACK_METACLASS(
|
BLACK_METACLASS(
|
||||||
CGlobalSetup,
|
CGlobalSetup,
|
||||||
@@ -242,6 +252,7 @@ namespace BlackCore
|
|||||||
BLACK_METAMEMBER(mapUrls),
|
BLACK_METAMEMBER(mapUrls),
|
||||||
BLACK_METAMEMBER(fsdTestServers),
|
BLACK_METAMEMBER(fsdTestServers),
|
||||||
BLACK_METAMEMBER(development),
|
BLACK_METAMEMBER(development),
|
||||||
|
BLACK_METAMEMBER(mappingMinimumVersion),
|
||||||
BLACK_METAMEMBER(dbDebugFlag, BlackMisc::DisabledForJson)
|
BLACK_METAMEMBER(dbDebugFlag, BlackMisc::DisabledForJson)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ void CSwiftData::init()
|
|||||||
this->setWindowTitle(QString("%1 %2").arg(this->windowTitle(), s.getDbHomePageUrl().toQString(true)));
|
this->setWindowTitle(QString("%1 %2").arg(this->windowTitle(), s.getDbHomePageUrl().toQString(true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
sGui->triggerNewVersionCheck(10 * 1000);
|
sGui->triggerNewVersionCheck(15 * 1000);
|
||||||
|
QTimer::singleShot(15 * 1000, this, &CSwiftData::checkMinimumVersion);
|
||||||
emit sGui->startUpCompleted(true);
|
emit sGui->startUpCompleted(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,3 +189,18 @@ void CSwiftData::displayLog()
|
|||||||
{
|
{
|
||||||
ui->comp_MainInfoArea->displayLog();
|
ui->comp_MainInfoArea->displayLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSwiftData::checkMinimumVersion()
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need sApp");
|
||||||
|
if (sApp->getGlobalSetup().isSwiftVersionMinimumMappingVersion())
|
||||||
|
{
|
||||||
|
CLogMessage(this).info("Checked mapping tool version, required '%1', this version '%2'") << sApp->getGlobalSetup().getMappingMinimumVersionString() << CBuildConfig::getVersionString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const CStatusMessage sm = CStatusMessage(this, CStatusMessage::SeverityWarning, "Your are using swift version: '%1'. Creating mappings requires at least '%2'.") << CBuildConfig::getVersionString() << sApp->getGlobalSetup().getMappingMinimumVersionString();
|
||||||
|
CLogMessage::preformatted(sm);
|
||||||
|
this->displayInOverlayWindow(sm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ private:
|
|||||||
|
|
||||||
void displayConsole();
|
void displayConsole();
|
||||||
void displayLog();
|
void displayLog();
|
||||||
|
void checkMinimumVersion();
|
||||||
|
|
||||||
BlackGui::CManagedStatusBar m_statusBar;
|
BlackGui::CManagedStatusBar m_statusBar;
|
||||||
QScopedPointer<Ui::CSwiftData> ui;
|
QScopedPointer<Ui::CSwiftData> ui;
|
||||||
|
|||||||
Reference in New Issue
Block a user