mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +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
@@ -15,6 +15,7 @@
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
#include <QVersionNumber>
|
||||
#include <QJsonObject>
|
||||
#include <QStringList>
|
||||
#include <QStringBuilder>
|
||||
@@ -31,11 +32,12 @@ namespace BlackCore
|
||||
CGlobalSetup::CGlobalSetup() :
|
||||
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_vatsimBookingsUrl = CUrl("http://vatbook.euroutepro.com/xml2.php");
|
||||
m_vatsimMetarsUrls = CUrlList({"http://metar.vatsim.net/metar.php"});
|
||||
@@ -87,12 +89,12 @@ namespace BlackCore
|
||||
|
||||
CUrlList CGlobalSetup::getSwiftBootstrapFileUrls() const
|
||||
{
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||
}
|
||||
|
||||
CUrlList CGlobalSetup::getSwiftDistributionFileUrls() const
|
||||
{
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::versionString() + "/updateinfo/distribution.json");
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/updateinfo/distribution.json");
|
||||
}
|
||||
|
||||
CUrl CGlobalSetup::getDbHomePageUrl() const
|
||||
@@ -168,24 +170,24 @@ namespace BlackCore
|
||||
QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate)
|
||||
{
|
||||
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; }
|
||||
CUrl url(candidate);
|
||||
if (candidate.contains("/bootstrap"))
|
||||
{
|
||||
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");
|
||||
}
|
||||
else if (candidate.endsWith("shared") || candidate.endsWith("shared/"))
|
||||
{
|
||||
url.appendPath(CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
|
||||
url.appendPath(CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||
}
|
||||
else
|
||||
{
|
||||
url.appendPath("shared/" + CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
|
||||
url.appendPath("shared/" + CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||
}
|
||||
return url.getFullUrl();
|
||||
}
|
||||
@@ -193,20 +195,20 @@ namespace BlackCore
|
||||
CUrl CGlobalSetup::buildDbDataDirectoryUrl(const CUrl &candidate)
|
||||
{
|
||||
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; }
|
||||
CUrl url(candidate);
|
||||
if (candidate.pathEndsWith(versionString()) || candidate.pathEndsWith(version))
|
||||
if (candidate.pathEndsWith(schemaVersionString()) || candidate.pathEndsWith(version))
|
||||
{
|
||||
url.appendPath("/dbdata");
|
||||
}
|
||||
else if (candidate.pathEndsWith("shared") || candidate.pathEndsWith("shared/"))
|
||||
{
|
||||
url.appendPath(CGlobalSetup::versionString() + "/dbdata/");
|
||||
url.appendPath(CGlobalSetup::schemaVersionString() + "/dbdata/");
|
||||
}
|
||||
else
|
||||
{
|
||||
url.appendPath("shared/" + CGlobalSetup::versionString() + "/dbdata/");
|
||||
url.appendPath("shared/" + CGlobalSetup::schemaVersionString() + "/dbdata/");
|
||||
}
|
||||
return url;
|
||||
}
|
||||
@@ -236,6 +238,14 @@ namespace BlackCore
|
||||
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
|
||||
{
|
||||
return convertToQString(", ", i18n);
|
||||
@@ -255,6 +265,10 @@ namespace BlackCore
|
||||
% boolToYesNo(isDevelopment())
|
||||
% separator
|
||||
|
||||
% "Mapping min.version: "
|
||||
% this->getMappingMinimumVersionString()
|
||||
% separator
|
||||
|
||||
% "Distribution URLs: "
|
||||
% getSwiftDistributionFileUrls().toQString(i18n)
|
||||
% separator
|
||||
@@ -337,6 +351,7 @@ namespace BlackCore
|
||||
case IndexOnlineHelpUrls: return CVariant::fromValue(m_onlineHelpUrls);
|
||||
case IndexCrashReportServerUrl: return CVariant::fromValue(m_crashReportServerUrl);
|
||||
case IndexWasLoaded: return CVariant::fromValue(m_wasLoaded);
|
||||
case IndexMappingMinimumVersion: return CVariant::fromValue(m_mappingMinimumVersion);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
@@ -367,11 +382,12 @@ namespace BlackCore
|
||||
case IndexSwiftMapUrls: m_mapUrls = variant.value<CUrlList>(); break;
|
||||
case IndexCrashReportServerUrl: m_crashReportServerUrl = variant.value<CUrl>(); break;
|
||||
case IndexWasLoaded: m_wasLoaded = variant.toBool(); break;
|
||||
case IndexMappingMinimumVersion: m_mappingMinimumVersion = variant.toQString(); 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
|
||||
static const QString v("0.7.0");
|
||||
|
||||
@@ -57,7 +57,8 @@ namespace BlackCore
|
||||
IndexOnlineHelpUrls,
|
||||
IndexCrashReportServerUrl,
|
||||
IndexWasLoaded,
|
||||
IndexSharedUrls
|
||||
IndexSharedUrls,
|
||||
IndexMappingMinimumVersion
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
@@ -174,6 +175,14 @@ namespace BlackCore
|
||||
//! Is server a development server?
|
||||
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?
|
||||
void setDevelopment(bool development) { m_development = development; }
|
||||
|
||||
@@ -189,8 +198,8 @@ namespace BlackCore
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
||||
|
||||
//! Schema version
|
||||
static const QString &versionString();
|
||||
//! Schema version (shared files, bootstrap file)
|
||||
static const QString &schemaVersionString();
|
||||
|
||||
//! Build bootstrap file URL from shared URL
|
||||
static QString buildBootstrapFileUrl(const QString &candidate);
|
||||
@@ -202,27 +211,28 @@ namespace BlackCore
|
||||
static CGlobalSetup fromJsonFile(const QString &fileNameAndPath);
|
||||
|
||||
private:
|
||||
bool m_wasLoaded = false; //!< Loaded from web
|
||||
int m_dbHttpPort = 80; //!< port
|
||||
int m_dbHttpsPort = 443; //!< SSL port
|
||||
bool m_development = false; //!< dev. version?
|
||||
BlackMisc::Network::CUrl m_crashReportServerUrl; //!< crash report server
|
||||
BlackMisc::Network::CUrl m_dbRootDirectoryUrl; //!< Root directory of DB
|
||||
BlackMisc::Network::CUrl m_vatsimBookingsUrl; //!< ATC bookings
|
||||
BlackMisc::Network::CUrlList m_vatsimMetarsUrls; //!< METAR data
|
||||
BlackMisc::Network::CUrlList m_vatsimStatusFileUrls; //!< Status file, where to find the VATSIM files (METAR, data, ATIS, other status files)
|
||||
BlackMisc::Network::CUrlList m_vatsimDataFileUrls; //!< Overall VATSIM data file / merely for bootstrapping the first time
|
||||
BlackMisc::Network::CUrlList m_sharedUrls; //!< where we can obtain shared info files such as bootstrap, ..
|
||||
BlackMisc::Network::CUrlList m_newsUrls; //!< where we can obtain latest news
|
||||
BlackMisc::Network::CUrlList m_onlineHelpUrls; //!< online help URLs
|
||||
BlackMisc::Network::CUrlList m_mapUrls; //!< swift map URLs
|
||||
BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers
|
||||
bool m_wasLoaded = false; //!< Loaded from web
|
||||
int m_dbHttpPort = 80; //!< port
|
||||
int m_dbHttpsPort = 443; //!< SSL port
|
||||
bool m_development = false; //!< dev. version?
|
||||
QString m_mappingMinimumVersion; //!< minimum version
|
||||
BlackMisc::Network::CUrl m_crashReportServerUrl; //!< crash report server
|
||||
BlackMisc::Network::CUrl m_dbRootDirectoryUrl; //!< Root directory of DB
|
||||
BlackMisc::Network::CUrl m_vatsimBookingsUrl; //!< ATC bookings
|
||||
BlackMisc::Network::CUrlList m_vatsimMetarsUrls; //!< METAR data
|
||||
BlackMisc::Network::CUrlList m_vatsimStatusFileUrls; //!< Status file, where to find the VATSIM files (METAR, data, ATIS, other status files)
|
||||
BlackMisc::Network::CUrlList m_vatsimDataFileUrls; //!< Overall VATSIM data file / merely for bootstrapping the first time
|
||||
BlackMisc::Network::CUrlList m_sharedUrls; //!< where we can obtain shared info files such as bootstrap, ..
|
||||
BlackMisc::Network::CUrlList m_newsUrls; //!< where we can obtain latest news
|
||||
BlackMisc::Network::CUrlList m_onlineHelpUrls; //!< online help URLs
|
||||
BlackMisc::Network::CUrlList m_mapUrls; //!< swift map URLs
|
||||
BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers
|
||||
|
||||
// transient members, to be switched on/off via GUI or set from reader
|
||||
bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing
|
||||
|
||||
//! Set the default URLs
|
||||
void initDefaultUrls();
|
||||
void initDefaultValues();
|
||||
|
||||
BLACK_METACLASS(
|
||||
CGlobalSetup,
|
||||
@@ -242,6 +252,7 @@ namespace BlackCore
|
||||
BLACK_METAMEMBER(mapUrls),
|
||||
BLACK_METAMEMBER(fsdTestServers),
|
||||
BLACK_METAMEMBER(development),
|
||||
BLACK_METAMEMBER(mappingMinimumVersion),
|
||||
BLACK_METAMEMBER(dbDebugFlag, BlackMisc::DisabledForJson)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -112,7 +112,8 @@ void CSwiftData::init()
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -188,3 +189,18 @@ void CSwiftData::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 displayLog();
|
||||
void checkMinimumVersion();
|
||||
|
||||
BlackGui::CManagedStatusBar m_statusBar;
|
||||
QScopedPointer<Ui::CSwiftData> ui;
|
||||
|
||||
Reference in New Issue
Block a user