mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Ref T367, Ref T400 global setup flags for web and file reading
This commit is contained in:
@@ -37,6 +37,11 @@ namespace BlackCore
|
||||
this->initDefaultValues();
|
||||
}
|
||||
|
||||
bool CGlobalSetup::wasLoaded() const
|
||||
{
|
||||
return this->wasLoadedFromWeb() || this->wasLoadedFromFile();
|
||||
}
|
||||
|
||||
void CGlobalSetup::initDefaultValues()
|
||||
{
|
||||
m_mappingMinimumVersion = CBuildConfig::getVersionString();
|
||||
@@ -52,7 +57,6 @@ namespace BlackCore
|
||||
"http://swift-project.org/datastore/shared/"
|
||||
});
|
||||
|
||||
// spare: "https://vatsim-germany.org:50443/datastore/shared"
|
||||
m_newsUrls = CUrlList({ "http://swift-project.org/" });
|
||||
m_onlineHelpUrls = CUrlList({ "https://datastore.swift-project.org/page/swifthelpdispatcher.html" });
|
||||
m_mapUrls = CUrlList({ "map.swift-project.org/" });
|
||||
@@ -256,7 +260,7 @@ namespace BlackCore
|
||||
|
||||
bool CGlobalSetup::isSwiftVersionMinimumMappingVersion() const
|
||||
{
|
||||
if (!this->wasLoaded()) { return false; }
|
||||
if (!this->wasLoadedFromWeb()) { return false; }
|
||||
if (m_mappingMinimumVersion.isEmpty()) { return false; }
|
||||
const QVersionNumber min = QVersionNumber::fromString(this->getMappingMinimumVersionString());
|
||||
return CBuildConfig::getVersion() >= min;
|
||||
@@ -274,7 +278,9 @@ namespace BlackCore
|
||||
% this->getFormattedUtcTimestampYmdhms()
|
||||
% separator
|
||||
% QStringLiteral("Global setup loaded: ")
|
||||
% boolToYesNo(this->wasLoaded())
|
||||
% boolToYesNo(this->wasLoadedFromWeb())
|
||||
% QStringLiteral("/")
|
||||
% boolToYesNo(this->wasLoadedFromFile())
|
||||
% separator
|
||||
|
||||
% QStringLiteral("For development: ")
|
||||
@@ -366,7 +372,8 @@ namespace BlackCore
|
||||
case IndexSwiftMapUrls: return CVariant::fromValue(m_mapUrls);
|
||||
case IndexOnlineHelpUrls: return CVariant::fromValue(m_onlineHelpUrls);
|
||||
case IndexCrashReportServerUrl: return CVariant::fromValue(m_crashReportServerUrl);
|
||||
case IndexWasLoaded: return CVariant::fromValue(m_wasLoaded);
|
||||
case IndexWasLoadedFromWeb: return CVariant::fromValue(m_wasLoadedFromWeb);
|
||||
case IndexWasLoadedFromFile: return CVariant::fromValue(m_wasLoadedFromFile);
|
||||
case IndexMappingMinimumVersion: return CVariant::fromValue(m_mappingMinimumVersion);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -397,7 +404,8 @@ namespace BlackCore
|
||||
case IndexOnlineHelpUrls: m_onlineHelpUrls = variant.value<CUrlList>(); break;
|
||||
case IndexSwiftMapUrls: m_mapUrls = variant.value<CUrlList>(); break;
|
||||
case IndexCrashReportServerUrl: m_crashReportServerUrl = variant.value<CUrl>(); break;
|
||||
case IndexWasLoaded: m_wasLoaded = variant.toBool(); break;
|
||||
case IndexWasLoadedFromWeb: m_wasLoadedFromWeb = variant.toBool(); break;
|
||||
case IndexWasLoadedFromFile: m_wasLoadedFromFile = variant.toBool(); break;
|
||||
case IndexMappingMinimumVersion: m_mappingMinimumVersion = variant.toQString(); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ namespace BlackCore
|
||||
IndexNewsUrls,
|
||||
IndexOnlineHelpUrls,
|
||||
IndexCrashReportServerUrl,
|
||||
IndexWasLoaded,
|
||||
IndexWasLoadedFromWeb,
|
||||
IndexWasLoadedFromFile,
|
||||
IndexSharedUrls,
|
||||
IndexMappingMinimumVersion
|
||||
};
|
||||
@@ -78,10 +79,19 @@ namespace BlackCore
|
||||
CGlobalSetup();
|
||||
|
||||
//! Has data loaded from web
|
||||
bool wasLoaded() const { return m_wasLoaded; }
|
||||
bool wasLoadedFromWeb() const { return m_wasLoadedFromWeb; }
|
||||
|
||||
//! Mark as loaded
|
||||
void markAsLoaded(bool loaded) { m_wasLoaded = loaded; }
|
||||
//! Has data loaded from file
|
||||
bool wasLoadedFromFile() const { return m_wasLoadedFromFile; }
|
||||
|
||||
//! Loaded (web/file)
|
||||
bool wasLoaded() const;
|
||||
|
||||
//! Mark as loaded from web
|
||||
void markAsLoadedFromWeb(bool loaded) { m_wasLoadedFromWeb = loaded; }
|
||||
|
||||
//! Mark as loaded from file
|
||||
void markAsLoadedFromFile(bool loaded) { m_wasLoadedFromFile = loaded; }
|
||||
|
||||
//! Http port
|
||||
int getDbHttpPort() const { return m_dbHttpPort; }
|
||||
@@ -227,22 +237,23 @@ namespace BlackCore
|
||||
static CGlobalSetup fromJsonFile(const QString &fileNameAndPath, bool acceptCacheFormat);
|
||||
|
||||
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?
|
||||
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 loaded from setup file
|
||||
bool m_wasLoadedFromWeb = false; //!< Loaded from web
|
||||
bool m_wasLoadedFromFile = false; //!< Loaded from local file
|
||||
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 loaded from setup file
|
||||
BlackMisc::Network::CUrl m_ncepGlobalForecastSystemUrl; //!< NCEP GFS url
|
||||
|
||||
// transient members, to be switched on/off via GUI or set from reader
|
||||
@@ -253,7 +264,8 @@ namespace BlackCore
|
||||
|
||||
BLACK_METACLASS(
|
||||
CGlobalSetup,
|
||||
BLACK_METAMEMBER(wasLoaded),
|
||||
BLACK_METAMEMBER(wasLoadedFromWeb),
|
||||
BLACK_METAMEMBER(wasLoadedFromFile),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch),
|
||||
BLACK_METAMEMBER(crashReportServerUrl),
|
||||
BLACK_METAMEMBER(dbRootDirectoryUrl),
|
||||
|
||||
@@ -294,7 +294,7 @@ namespace BlackCore
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
if (!force && !this->isSwiftDbAccessible()) { return; }
|
||||
const CGlobalSetup gs = sApp->getGlobalSetup();
|
||||
if (!gs.wasLoaded()) { return; }
|
||||
if (!gs.wasLoadedFromWeb()) { return; }
|
||||
const CUrl pingUrl = gs.getDbClientPingServiceUrl(type);
|
||||
sApp->getFromNetwork(pingUrl, { this, &CNetworkWatchdog::replyPingClientService });
|
||||
}
|
||||
|
||||
@@ -332,9 +332,10 @@ namespace BlackCore
|
||||
{
|
||||
CGlobalSetup s;
|
||||
s.convertFromJson(content);
|
||||
s.setDevelopment(true);
|
||||
m_setup.set(s);
|
||||
return CStatusMessage(this).info("Setup cache updated from local file '%1'") << fn;
|
||||
s.markAsLoadedFromFile(true);
|
||||
const CStatusMessage setMsg = m_setup.set(s);
|
||||
const CStatusMessage setInfo = CStatusMessage(this).info("Setup cache updated from local file '%1'") << fn;
|
||||
return setMsg.isSuccess() ? setInfo : setMsg;
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
@@ -370,7 +371,7 @@ namespace BlackCore
|
||||
const CGlobalSetup currentSetup = m_setup.get();
|
||||
CGlobalSetup loadedSetup;
|
||||
loadedSetup.convertFromJson(setupJson);
|
||||
loadedSetup.markAsLoaded(true);
|
||||
loadedSetup.markAsLoadedFromWeb(true);
|
||||
const CUrl sharedUrl(loadedSetup.getCorrespondingSharedUrl(url));
|
||||
if (!sharedUrl.isEmpty()) { emit this->successfullyReadSharedUrl(sharedUrl); }
|
||||
|
||||
@@ -640,7 +641,7 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool cacheAvailable = m_setup.get().wasLoaded();
|
||||
const bool cacheAvailable = m_setup.get().wasLoadedFromWeb();
|
||||
available = cacheAvailable && m_bootstrapMode != Explicit;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user