From fdfa2233fb447a191f5bc564b4fae39234032c95 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 14 Sep 2017 02:25:34 +0200 Subject: [PATCH] Ref T150, Ref T156 cleaned up setup reader * grouped functions together if they are based on the same URLs * renamed functions * Doxygen comments --- src/blackcore/data/globalsetup.cpp | 56 ++++++++++------------- src/blackcore/data/globalsetup.h | 73 +++++++++++++++++------------- 2 files changed, 67 insertions(+), 62 deletions(-) diff --git a/src/blackcore/data/globalsetup.cpp b/src/blackcore/data/globalsetup.cpp index bfb8be213..a5af5d5f4 100644 --- a/src/blackcore/data/globalsetup.cpp +++ b/src/blackcore/data/globalsetup.cpp @@ -79,6 +79,22 @@ namespace BlackCore return this->m_sharedUrls; } + CUrl CGlobalSetup::getCorrespondingSharedUrl(const CUrl &candidate) const + { + CUrlList sameHosts = this->getSwiftSharedUrls().findByHost(candidate.getHost()); + return sameHosts.frontOrDefault(); + } + + CUrlList CGlobalSetup::getSwiftBootstrapFileUrls() const + { + return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::versionString() + "/bootstrap/bootstrap.json"); + } + + CUrlList CGlobalSetup::getSwiftDistributionFileUrls() const + { + return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::versionString() + "/updateinfo/distribution.json"); + } + CUrl CGlobalSetup::getDbHomePageUrl() const { return getDbRootDirectoryUrl().withAppendedPath("/page/index.php"); @@ -134,14 +150,9 @@ namespace BlackCore return this->isDevelopment() == otherSetup.isDevelopment(); } - CUrlList CGlobalSetup::getBootstrapFileUrls() const - { - CUrlList urls(m_sharedUrls); - return urls.appendPath(CGlobalSetup::versionString() + "/bootstrap/bootstrap.json"); - } - QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate) { + if (candidate.isEmpty()) return ""; // not possible static const QString version(QString(CGlobalSetup::versionString()).append("/")); if (candidate.endsWith("bootstrap.json")) { return candidate; } CUrl url(candidate); @@ -164,8 +175,9 @@ namespace BlackCore return url.getFullUrl(); } - CUrl CGlobalSetup::buildDbDataDirectory(const CUrl &candidate) + CUrl CGlobalSetup::buildDbDataDirectoryUrl(const CUrl &candidate) { + if (candidate.isEmpty()) return CUrl(); // not possible static const QString version(QString(versionString()).append("/")); if (candidate.pathEndsWith("dbdata") || candidate.pathEndsWith("dbdata/")) { return candidate; } CUrl url(candidate); @@ -191,18 +203,6 @@ namespace BlackCore return setup; } - CUrlList CGlobalSetup::getDistributionUrls() const - { - const CUrlList urls(m_sharedUrls); - return urls.appendPath(CGlobalSetup::versionString() + "/updateinfo/distribution.json"); - } - - CUrlList CGlobalSetup::getSwiftDbDataFileLocationUrls() const - { - const CUrlList urls(m_sharedUrls); - return urls.appendPath(CGlobalSetup::versionString() + "/dbdata/"); - } - const CUrlList &CGlobalSetup::getSwiftLatestNewsUrls() const { return m_newsUrls; @@ -246,10 +246,10 @@ namespace BlackCore % separator % "Distribution URLs: " - % getDistributionUrls().toQString(i18n) + % getSwiftDistributionFileUrls().toQString(i18n) % separator % "Bootstrap URLs: " - % getBootstrapFileUrls().toQString(i18n) + % getSwiftBootstrapFileUrls().toQString(i18n) % separator % "News URLs: " % getSwiftLatestNewsUrls().toQString(i18n) @@ -277,11 +277,7 @@ namespace BlackCore % getDbHomePageUrl().toQString(i18n) % separator % "DB login service: " - % getDbLoginServiceUrl().toQString(i18n) - % separator - % "swift DB datafile locations: " - % getSwiftDbDataFileLocationUrls().toQString(i18n) - % separator; + % getDbLoginServiceUrl().toQString(i18n); s += "VATSIM bookings: " % getVatsimBookingsUrl().toQString(i18n) @@ -327,12 +323,10 @@ namespace BlackCore return CVariant::fromValue(this->m_vatsimDataFileUrls); case IndexVatsimMetars: return CVariant::fromValue(this->m_vatsimMetarsUrls); - case IndexUpdateInfo: - return CVariant::fromValue(this->getDistributionUrls()); case IndexBootstrapFileUrls: - return CVariant::fromValue(this->getBootstrapFileUrls()); - case IndexSwiftDbFiles: - return CVariant::fromValue(this->getSwiftDbDataFileLocationUrls()); + return CVariant::fromValue(this->getSwiftBootstrapFileUrls()); + case IndexDistributionFileUrls: + return CVariant::fromValue(this->getSwiftDistributionFileUrls()); case IndexSharedUrls: return CVariant::fromValue(this->m_sharedUrls); case IndexNewsUrls: diff --git a/src/blackcore/data/globalsetup.h b/src/blackcore/data/globalsetup.h index 2b9d90a5c..64ddf7e91 100644 --- a/src/blackcore/data/globalsetup.h +++ b/src/blackcore/data/globalsetup.h @@ -51,10 +51,10 @@ namespace BlackCore IndexSwiftDbFiles, IndexSwiftMapUrls, IndexBootstrapFileUrls, + IndexDistributionFileUrls, IndexNewsUrls, IndexOnlineHelpUrls, IndexCrashReportServerUrl, - IndexUpdateInfo, IndexWasLoaded, IndexSharedUrls }; @@ -89,39 +89,55 @@ namespace BlackCore //! Crash report server url BlackMisc::Network::CUrl getCrashReportServerUrl() const { return m_crashReportServerUrl; } + //! Root directory of DB + const BlackMisc::Network::CUrl &getDbRootDirectoryUrl() const { return m_dbRootDirectoryUrl; } + + //! ICAO reader URL + //! \remark based on getDbRootDirectoryUrl + BlackMisc::Network::CUrl getDbIcaoReaderUrl() const; + + //! Model reader URL + //! \remark based on getDbRootDirectoryUrl + BlackMisc::Network::CUrl getDbModelReaderUrl() const; + + //! Airport reader URL + //! \remark based on getDbRootDirectoryUrl + BlackMisc::Network::CUrl getDbAirportReaderUrl() const; + + //! Info data reader URL + //! \remark based on getDbRootDirectoryUrl + BlackMisc::Network::CUrl getDbInfoReaderUrl() const; + //! Home page url + //! \remark based on getDbRootDirectoryUrl BlackMisc::Network::CUrl getDbHomePageUrl() const; - //! Help page URL - BlackMisc::Network::CUrl getHelpPageUrl() const; - //! Legal directory URL + //! \remark based on getDbRootDirectoryUrl BlackMisc::Network::CUrl getLegalDirectoryUrl() const; //! Login service + //! \remark based on getDbRootDirectoryUrl BlackMisc::Network::CUrl getDbLoginServiceUrl() const; //! alpha XSwiftBus files available BlackMisc::Network::CUrl getAlphaXSwiftBusFilesServiceUrl() const; - //! Root directory of DB - const BlackMisc::Network::CUrl &getDbRootDirectoryUrl() const { return m_dbRootDirectoryUrl; } - - //! ICAO reader URL - BlackMisc::Network::CUrl getDbIcaoReaderUrl() const; - - //! Model reader URL - BlackMisc::Network::CUrl getDbModelReaderUrl() const; - - //! Airport reader URL - BlackMisc::Network::CUrl getDbAirportReaderUrl() const; - - //! Info data reader URL - BlackMisc::Network::CUrl getDbInfoReaderUrl() const; - //! Shared URLs const BlackMisc::Network::CUrlList &getSwiftSharedUrls() const; + //! Get pure shared URL as in getSwiftSharedUrls from bootstrap, distribution or other shared URL + //! \remark normally based on one of the getSwiftSharedUrls + BlackMisc::Network::CUrl getCorrespondingSharedUrl(const BlackMisc::Network::CUrl &candidate) const; + + //! Bootstrap URLs + //! \remark based on getSwiftSharedUrls + BlackMisc::Network::CUrlList getSwiftBootstrapFileUrls() const; + + //! Distribution URLs + //! \remark based on getSwiftSharedUrls + BlackMisc::Network::CUrlList getSwiftDistributionFileUrls() const; + //! URL to read VATSIM bookings const BlackMisc::Network::CUrl &getVatsimBookingsUrl() const { return m_vatsimBookingsUrl; } @@ -134,21 +150,16 @@ namespace BlackCore //! VATSIM data file URLs const BlackMisc::Network::CUrlList &getVatsimDataFileUrls() const { return m_vatsimDataFileUrls; } - //! Bootstrap URLs (where the data for the setup itself can be downloaded) - BlackMisc::Network::CUrlList getBootstrapFileUrls() const; - - //! Version and download locations - BlackMisc::Network::CUrlList getDistributionUrls() const; - - //! Alternative locations of swift DB data files - BlackMisc::Network::CUrlList getSwiftDbDataFileLocationUrls() const; - //! Locations of swift DB news const BlackMisc::Network::CUrlList &getSwiftLatestNewsUrls() const; //! Online help URLs const BlackMisc::Network::CUrlList &getOnlineHelpUrls() const; + //! Help page URL + //! \remark working URL evaluated at runtime, based on getOnlineHelpUrls + BlackMisc::Network::CUrl getHelpPageUrl() const; + //! swift map URLs const BlackMisc::Network::CUrlList &getSwiftMapUrls() const; @@ -179,11 +190,11 @@ namespace BlackCore //! Schema version static const QString &versionString(); - //! Build bootstrap file URL + //! Build bootstrap file URL from shared URL static QString buildBootstrapFileUrl(const QString &candidate); - //! Build the full dbdata directory URL - static BlackMisc::Network::CUrl buildDbDataDirectory(const BlackMisc::Network::CUrl &candidate); + //! Build the full dbdata directory URL from shared URL + static BlackMisc::Network::CUrl buildDbDataDirectoryUrl(const BlackMisc::Network::CUrl &candidate); //! Object initialized by JSON file static CGlobalSetup fromJsonFile(const QString &fileNameAndPath);