diff --git a/resources/bootstrap/development/bootstrap.json b/resources/bootstrap/0.6/development/bootstrap.json similarity index 85% rename from resources/bootstrap/development/bootstrap.json rename to resources/bootstrap/0.6/development/bootstrap.json index 71452e331..530e6f5ec 100644 --- a/resources/bootstrap/development/bootstrap.json +++ b/resources/bootstrap/0.6/development/bootstrap.json @@ -5,15 +5,14 @@ "url": "https://vatsim-germany.org:50443/mapping/public/bootstrap" }, { - "url": "http://ubuntu12/public/bootstrap" + "url": "http://ubuntu12/swiftdatastore/public/bootstrap" } ] }, - "dbIcaoReader": { - "url": "http://ubuntu12/vatrep/public" - }, - "dbModelReader": { - "url": "http://ubuntu12/vatrep/public" + "dbHttpPort": 80, + "dbHttpsPort": 443, + "dbRootDirectory": { + "url": "http://ubuntu12/swiftdatastore/public" }, "fsdTestServers": { "containerbase": [ @@ -45,7 +44,7 @@ "containerbase": [ ] }, - "timestampMSecsSinceEpoch": 0, + "timestampMSecsSinceEpoch": 1445201830000, "vatsimBookings": { "url": "http://vatbook.euroutepro.com/xml2.php" }, @@ -59,4 +58,4 @@ "vatsimMetars": { "url": "http://metar.vatsim.net/metar.php" } -} \ No newline at end of file +} diff --git a/resources/bootstrap/productive/bootstrap.json b/resources/bootstrap/0.6/productive/bootstrap.json similarity index 87% rename from resources/bootstrap/productive/bootstrap.json rename to resources/bootstrap/0.6/productive/bootstrap.json index 527bdf7af..5d2b2879b 100644 --- a/resources/bootstrap/productive/bootstrap.json +++ b/resources/bootstrap/0.6/productive/bootstrap.json @@ -5,14 +5,13 @@ "url": "https://vatsim-germany.org:50443/mapping/public/bootstrap" }, { - "url": "http://ubuntu12/public/bootstrap" + "url": "http://ubuntu12/swiftdatastore/public/bootstrap" } ] }, - "dbIcaoReader": { - "url": "https://vatsim-germany.org:50443/mapping/public" - }, - "dbModelReader": { + "dbHttpPort": 5080, + "dbHttpsPort": 50443, + "dbRootDirectory": { "url": "https://vatsim-germany.org:50443/mapping/public" }, "fsdTestServers": { @@ -45,7 +44,7 @@ "containerbase": [ ] }, - "timestampMSecsSinceEpoch": 0, + "timestampMSecsSinceEpoch": 1445201830000, "vatsimBookings": { "url": "http://vatbook.euroutepro.com/xml2.php" }, diff --git a/resources/local.env.template/bootstrap/bootstrap.json b/resources/local.env.template/bootstrap/0.6/bootstrap.json similarity index 84% rename from resources/local.env.template/bootstrap/bootstrap.json rename to resources/local.env.template/bootstrap/0.6/bootstrap.json index 71452e331..5d2b2879b 100644 --- a/resources/local.env.template/bootstrap/bootstrap.json +++ b/resources/local.env.template/bootstrap/0.6/bootstrap.json @@ -5,15 +5,14 @@ "url": "https://vatsim-germany.org:50443/mapping/public/bootstrap" }, { - "url": "http://ubuntu12/public/bootstrap" + "url": "http://ubuntu12/swiftdatastore/public/bootstrap" } ] }, - "dbIcaoReader": { - "url": "http://ubuntu12/vatrep/public" - }, - "dbModelReader": { - "url": "http://ubuntu12/vatrep/public" + "dbHttpPort": 5080, + "dbHttpsPort": 50443, + "dbRootDirectory": { + "url": "https://vatsim-germany.org:50443/mapping/public" }, "fsdTestServers": { "containerbase": [ @@ -45,7 +44,7 @@ "containerbase": [ ] }, - "timestampMSecsSinceEpoch": 0, + "timestampMSecsSinceEpoch": 1445201830000, "vatsimBookings": { "url": "http://vatbook.euroutepro.com/xml2.php" }, @@ -59,4 +58,4 @@ "vatsimMetars": { "url": "http://metar.vatsim.net/metar.php" } -} \ No newline at end of file +} diff --git a/resources/swift_resources.pro b/resources/swift_resources.pro index a4aa17987..582ac63e9 100644 --- a/resources/swift_resources.pro +++ b/resources/swift_resources.pro @@ -7,17 +7,19 @@ CONFIG -= qt OTHER_FILES += data/images/flags/*.png OTHER_FILES += data/images/airlines/*.png OTHER_FILES += swiftDB/*.* -OTHER_FILES += bootstrap/productive/*.* -OTHER_FILES += bootstrap/development/*.* +OTHER_FILES += bootstrap/0.6/productive/*.* +OTHER_FILES += bootstrap/0.6/development/*.* OTHER_FILES += local.env.template/*.* OTHER_FILES += local.env.template/bootstrap/*.* +OTHER_FILES += local.env.template/bootstrap/0.6/*.* COPY_FILES += $$PWD/data/images/flags/*.png COPY_FILES += $$PWD/data/images/airlines/*.png COPY_FILES += $$PWD/swiftDB/*.* -COPY_FILES += $$PWD/bootstrap/productive/*.* -COPY_FILES += $$PWD/bootstrap/development/*.* +COPY_FILES += $$PWD/bootstrap/0.6/productive/*.* +COPY_FILES += $$PWD/bootstrap/0.6/development/*.* COPY_FILES += $$PWD/local.env.template/*.* COPY_FILES += $$PWD/local.env.template/bootstrap/*.* +COPY_FILES += $$PWD/local.env.template/bootstrap/0.6/*.* load(common_post) diff --git a/src/blackcore/data/globalsetup.cpp b/src/blackcore/data/globalsetup.cpp index 20d315031..0da054c2d 100644 --- a/src/blackcore/data/globalsetup.cpp +++ b/src/blackcore/data/globalsetup.cpp @@ -9,6 +9,7 @@ #include "globalsetup.h" #include "blackmisc/math/mathutils.h" +#include "blackmisc/blackmiscfreefunctions.h" #include using namespace BlackMisc; @@ -21,29 +22,55 @@ namespace BlackCore { CGlobalSetup::CGlobalSetup() : ITimestampBased(0), - m_dbIcaoReader("http://ubuntu12/vatrep/public"), - m_dbModelReader("http://ubuntu12/vatrep/public"), + m_dbRootDirectory("http://ubuntu12/swiftdatastore/public"), + m_dbHttpPort(80), + m_dbHttpsPort(443), m_vatsimBookings("http://vatbook.euroutepro.com/xml2.php"), m_vatsimMetars("http://metar.vatsim.net/metar.php"), m_vatsimDataFile(QStringList({ "http://info.vroute.net/vatsim-data.txt" })), m_bootstrap(QStringList({ "https://vatsim-germany.org:50443/mapping/public/bootstrap", "http://ubuntu12/public/bootstrap"})), - m_swiftDbDataFiles(QStringList({ })), + m_swiftDbDataFiles(QStringList({})), m_fsdTestServers({ CServer("swift", "swift Testserver", "vatsim-germany.org", 6809, CUser("1234567", "swift Test User", "", "123456"), true) }) { } + CUrl CGlobalSetup::dbIcaoReader() const + { + return dbRootDirectory(); + } + + CUrl CGlobalSetup::dbModelReader() const + { + return dbRootDirectory(); + } + CUrl CGlobalSetup::dbHomePage() const { - return dbModelReader().withAppendedPath("/page/index.php"); + return dbRootDirectory().withAppendedPath("/page/index.php"); } CUrl CGlobalSetup::dbLoginService() const { - return dbModelReader().withAppendedPath("/service/index.php"); + return dbRootDirectory(). + withAppendedPath("/service/jsonauthenticate.php"). + withSwitchedScheme("https", m_dbHttpsPort); } - bool CGlobalSetup::hasSameType(const QString &type) const + bool CGlobalSetup::dbDebugFlag() const { - return getType() == type.trimmed().toUpper(); + if (!m_dbDebugFlag) { return false; } + + // further checks could go here + return isDevelopment(); + } + + void CGlobalSetup::setServerDebugFlag(bool debug) + { + m_dbDebugFlag = debug; + } + + bool CGlobalSetup::hasSameType(CGlobalSetup &otherSetup) const + { + return this->isDevelopment() == otherSetup.isDevelopment(); } CUrl CGlobalSetup::vatsimMetars() const @@ -61,12 +88,19 @@ namespace BlackCore QString s("timestamp: "); s.append(this->getFormattedUtcTimestampYmdhms()); s.append(separator); + s.append("For development: "); + s.append(boolToYesNo(isDevelopment())); + s.append(separator); + s.append("DB root directory: "); + s.append(dbRootDirectory().convertToQString(i18n)); + s.append(separator); s.append("ICAO DB reader: "); s.append(dbIcaoReader().convertToQString(i18n)); s.append(separator); s.append("Model DB reader: "); s.append(dbModelReader().convertToQString(i18n)); s.append(separator); + s.append("DB home page: "); s.append(dbHomePage().convertToQString(i18n)); s.append(separator); @@ -101,12 +135,12 @@ namespace BlackCore ColumnIndex i = index.frontCasted(); switch (i) { - case IndexDbIcaoReader: - return CVariant::fromValue(this->m_dbIcaoReader); - case IndexDbModelReader: - return CVariant::fromValue(this->m_dbModelReader); - case IndexDbHomePage: - return CVariant::fromValue(this->dbHomePage()); + case IndexDbRootDirectory: + return CVariant::fromValue(this->m_dbRootDirectory); + case IndexDbHttpPort: + return CVariant::fromValue(this->m_dbHttpPort); + case IndexDbHttpsPort: + return CVariant::fromValue(this->m_dbHttpsPort); case IndexDbLoginService: return CVariant::fromValue(this->dbLoginService()); case IndexVatsimData: @@ -136,13 +170,15 @@ namespace BlackCore ColumnIndex i = index.frontCasted(); switch (i) { - case IndexDbIcaoReader: - this->m_dbIcaoReader.setPropertyByIndex(variant, index.copyFrontRemoved()); + case IndexDbRootDirectory: + this->m_dbRootDirectory.setPropertyByIndex(variant, index.copyFrontRemoved()); break; - case IndexDbModelReader: - this->m_dbModelReader.setPropertyByIndex(variant, index.copyFrontRemoved()); + case IndexDbHttpPort: + this->m_dbHttpPort = variant.toInt(); + break; + case IndexDbHttpsPort: + this->m_dbHttpsPort = variant.toInt(); break; - case IndexDbHomePage: case IndexDbLoginService: break; case IndexVatsimData: @@ -165,5 +201,11 @@ namespace BlackCore break; } } + + const QString &CGlobalSetup::versionString() + { + static const QString v("0.6"); + return v; + } } // ns } // ns diff --git a/src/blackcore/data/globalsetup.h b/src/blackcore/data/globalsetup.h index f34cd5b01..9e74e6616 100644 --- a/src/blackcore/data/globalsetup.h +++ b/src/blackcore/data/globalsetup.h @@ -33,9 +33,9 @@ namespace BlackCore //! Properties by index enum ColumnIndex { - IndexDbIcaoReader = BlackMisc::CPropertyIndex::GlobalIndexCGlobalSetup, - IndexDbModelReader, - IndexDbHomePage, + IndexDbRootDirectory = BlackMisc::CPropertyIndex::GlobalIndexCGlobalSetup, + IndexDbHttpPort, + IndexDbHttpsPort, IndexDbLoginService, IndexVatsimBookings, IndexVatsimMetars, @@ -50,11 +50,20 @@ namespace BlackCore //! Destructor. ~CGlobalSetup() {} + //! Root directory of DB + const BlackMisc::Network::CUrl &dbRootDirectory() const { return m_dbRootDirectory; } + //! ICAO Reader location - const BlackMisc::Network::CUrl &dbIcaoReader() const { return m_dbIcaoReader; } + BlackMisc::Network::CUrl dbIcaoReader() const; //! Model Reader protocol - const BlackMisc::Network::CUrl &dbModelReader() const { return m_dbModelReader; } + BlackMisc::Network::CUrl dbModelReader() const; + + //! Http port + int dbHttpPort() const { return m_dbHttpPort; } + + //! Https port + int dbHttpsPort() const { return m_dbHttpsPort; } //! Home page url BlackMisc::Network::CUrl dbHomePage() const; @@ -62,17 +71,17 @@ namespace BlackCore //! Login service BlackMisc::Network::CUrl dbLoginService() const; + //! Debug flag + bool dbDebugFlag() const; + + //! Set debug flag + void setServerDebugFlag(bool debug); + //! URL to read VATSIM bookings const BlackMisc::Network::CUrl &vatsimBookings() const { return m_vatsimBookings; } - //! Type (development, productive)? - const QString &getType() const { return m_type; } - - //! Set type - void setType(const QString &type) { m_type = type.trimmed().toUpper(); } - //! Same type? - bool hasSameType(const QString &type) const; + bool hasSameType(CGlobalSetup &otherSetup) const; //! VATSIM METAR URL BlackMisc::Network::CUrl vatsimMetars() const; @@ -89,6 +98,12 @@ namespace BlackCore //! FSD test servers const BlackMisc::Network::CServerList &fsdTestServers() const { return m_fsdTestServers; } + //! Productive settings? + bool isDevelopment() const { return m_development; } + + //! Productive settings? + void setDevelopment(bool development) { m_development = development; } + //! \copydoc CValueObject::convertToQString QString convertToQString(bool i18n = false) const; @@ -101,18 +116,25 @@ namespace BlackCore //! \copydoc CValueObject::setPropertyByIndex void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index); + //! Schema version + static const QString &versionString(); + private: BLACK_ENABLE_TUPLE_CONVERSION(BlackCore::Data::CGlobalSetup) - QString m_type; //!< dev./productive? - BlackMisc::Network::CUrl m_dbIcaoReader; //!< direct DB ICAO reader - BlackMisc::Network::CUrl m_dbModelReader; //!< direct DB model reader - BlackMisc::Network::CUrl m_vatsimBookings; //!< ATC bookings - BlackMisc::Network::CUrl m_vatsimMetars; //!< METAR data - BlackMisc::Network::CUrlList m_vatsimDataFile; //!< Overall VATSIM data file - BlackMisc::Network::CUrlList m_bootstrap; //!< where we can obtain downloads of these data - BlackMisc::Network::CUrlList m_swiftDbDataFiles; //!< alternative locations of the DB files, if DB is not available - BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers + BlackMisc::Network::CUrl m_dbRootDirectory; //!< Root directory + int m_dbHttpPort = 80; //!< port + int m_dbHttpsPort = 443; //!< SSL port + BlackMisc::Network::CUrl m_vatsimBookings; //!< ATC bookings + BlackMisc::Network::CUrl m_vatsimMetars; //!< METAR data + BlackMisc::Network::CUrlList m_vatsimDataFile; //!< Overall VATSIM data file + BlackMisc::Network::CUrlList m_bootstrap; //!< where we can obtain downloads of these data + BlackMisc::Network::CUrlList m_swiftDbDataFiles; //!< alternative locations of the DB files, if DB is not available + BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers + bool m_development = false; //!< dev. version? + + // 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 hat you are doing }; //! Trait for for global setup data @@ -135,15 +157,16 @@ namespace BlackCore Q_DECLARE_METATYPE(BlackCore::Data::CGlobalSetup) BLACK_DECLARE_TUPLE_CONVERSION(BlackCore::Data::CGlobalSetup, ( attr(o.m_timestampMSecsSinceEpoch), - attr(o.m_type), - attr(o.m_dbIcaoReader), - attr(o.m_dbModelReader), + attr(o.m_dbRootDirectory), + attr(o.m_dbHttpPort), + attr(o.m_dbHttpsPort), attr(o.m_vatsimBookings), attr(o.m_vatsimMetars), attr(o.m_vatsimDataFile), attr(o.m_bootstrap), attr(o.m_swiftDbDataFiles), - attr(o.m_fsdTestServers) + attr(o.m_fsdTestServers), + attr(o.m_development), + attr(o.m_dbDebugFlag, flags < DisabledForJson > ()) )) - #endif // guard diff --git a/src/blackcore/icaodatareader.cpp b/src/blackcore/icaodatareader.cpp index 5c0de52f2..8c476831b 100644 --- a/src/blackcore/icaodatareader.cpp +++ b/src/blackcore/icaodatareader.cpp @@ -164,7 +164,6 @@ namespace BlackCore CUrl CIcaoDataReader::getBaseUrl() const { CUrl baseUrl(this->m_setup.get().dbIcaoReader()); - Q_ASSERT_X(!baseUrl.isEmpty(), Q_FUNC_INFO, "No URL"); return baseUrl; } diff --git a/src/blackcore/modeldatareader.cpp b/src/blackcore/modeldatareader.cpp index dae6dc229..f55a7e7dc 100644 --- a/src/blackcore/modeldatareader.cpp +++ b/src/blackcore/modeldatareader.cpp @@ -329,7 +329,6 @@ namespace BlackCore CUrl CModelDataReader::getBaseUrl() const { CUrl baseUrl(m_setup.get().dbModelReader()); - Q_ASSERT_X(!baseUrl.isEmpty(), Q_FUNC_INFO, "No URL"); return baseUrl; } diff --git a/src/blackcore/setupreader.cpp b/src/blackcore/setupreader.cpp index 88bcbd66f..c589d9eba 100644 --- a/src/blackcore/setupreader.cpp +++ b/src/blackcore/setupreader.cpp @@ -85,15 +85,21 @@ namespace BlackCore QString dir(CProject::getSwiftPrivateResourceDir()); if (dir.isEmpty()) { return false; } - fileName = CFileUtils::appendFilePaths(dir, "bootstrap/setup.json"); + fileName = CFileUtils::appendFilePaths(dir, "bootstrap/" + CGlobalSetup::versionString() + "/bootstrap.json"); QString content(CFileUtils::readFileToString(fileName)); if (content.isEmpty()) { return false; } CGlobalSetup s; s.convertFromJson(content); + s.setDevelopment(true); m_setup.set(s); return true; } + bool CSetupReader::isForDevelopment() + { + return CProject::useDevelopmentSetup(); + } + CUrlList CSetupReader::getRemainingUrls() const { CUrlList urls(m_setup.get().bootstrapUrls().appendPath(appendPathAndFile())); @@ -103,9 +109,9 @@ namespace BlackCore QString CSetupReader::appendPathAndFile() { - return CProject::useDevelopmentSetup() ? - "development/bootstrap.json" : - "productive/bootstrap.json"; + return isForDevelopment() ? + CGlobalSetup::versionString() + "/development/bootstrap.json" : + CGlobalSetup::versionString() + "/productive/bootstrap.json"; } void CSetupReader::ps_parseSetupFile(QNetworkReply *nwReplyPtr) @@ -145,13 +151,12 @@ namespace BlackCore } else { - QString type(urlString.toLower().contains("develop") ? "DEV" : "PRODUCTIVE"); - CGlobalSetup currentSetup(m_setup.get()); + CGlobalSetup currentSetup(m_setup.get()); // from cache CGlobalSetup loadedSetup; loadedSetup.convertFromJson(Json::jsonObjectFromString(setupJson)); - loadedSetup.setType(type); + loadedSetup.setDevelopment(isForDevelopment()); // always update, regardless what persistent setting says if (loadedSetup.getMSecsSinceEpoch() == 0 && lastModified > 0) { loadedSetup.setMSecsSinceEpoch(lastModified); } - bool sameType = loadedSetup.hasSameType(currentSetup.getType()); + bool sameType = loadedSetup.hasSameType(currentSetup); qint64 currentVersionTimestamp = currentSetup.getMSecsSinceEpoch(); qint64 newVersionTimestamp = loadedSetup.getMSecsSinceEpoch(); bool sameVersionLoaded = sameType && (newVersionTimestamp == currentVersionTimestamp); diff --git a/src/blackcore/setupreader.h b/src/blackcore/setupreader.h index ba4815bbd..dfa6e9e5f 100644 --- a/src/blackcore/setupreader.h +++ b/src/blackcore/setupreader.h @@ -54,6 +54,9 @@ namespace BlackCore //! Remaining URLs failed one excluded BlackMisc::Network::CUrlList getRemainingUrls() const; + //! Read for development environment? + static bool isForDevelopment(); + //! Bootstrap URL static QString appendPathAndFile(); };