diff --git a/resources/share/shared/bootstrap/bootstrap.json b/resources/share/shared/bootstrap/bootstrap.json index 4d174d549..92f59d697 100644 --- a/resources/share/shared/bootstrap/bootstrap.json +++ b/resources/share/shared/bootstrap/bootstrap.json @@ -67,6 +67,5 @@ }, "ssrEquipmentHelpUrl": { "url": "https://en.wikipedia.org/wiki/Equipment_codes#Surveillance_equipment_codes" - }, - "wasLoadedFromFile": false + } } diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index 5ce985ff3..298123004 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -149,10 +149,6 @@ namespace BlackCore // global setup m_setupReader.reset(new CSetupReader(this)); - connect(m_setupReader.data(), &CSetupReader::setupHandlingCompleted, this, &CApplication::onSetupHandlingCompleted, Qt::QueuedConnection); - connect(m_setupReader.data(), &CSetupReader::setupHandlingCompleted, this, &CApplication::setupHandlingCompleted, Qt::QueuedConnection); // hand thru - - this->addParserOptions(m_setupReader->getCmdLineOptions()); // add options from reader // check for updates m_gitHubPackagesReader.reset(new CGitHubPackagesReader(this)); @@ -380,13 +376,7 @@ namespace BlackCore }); } - //! \fixme KB 9/17 waiting for setup reader here is supposed to be replaced by explicitly waiting for reader - if (!m_setupReader->isSetupAvailable()) - { - msgs = this->requestReloadOfSetupAndVersion(); - if (msgs.isFailure()) { break; } - if (msgs.isSuccess()) { msgs.push_back(this->waitForSetup()); } - } + Q_ASSERT_X(m_setupReader && m_setupReader->isSetupAvailable(), Q_FUNC_INFO, "Setup not available"); // start hookin msgs.push_back(this->startHookIn()); @@ -413,62 +403,12 @@ namespace BlackCore return m_started; } - CStatusMessageList CApplication::waitForSetup(int timeoutMs) - { - if (!m_setupReader) { return CStatusMessage(this).error(u"No setup reader"); } - CEventLoop eventLoop(this); - eventLoop.stopWhen(this, &CApplication::setupHandlingCompleted); - if (!m_setupReader->isSetupAvailable()) - { - eventLoop.exec(timeoutMs); - } - - // setup handling completed with success or failure, or we run into time out - CStatusMessageList msgs; - if (!eventLoop.isGuardAlive()) - { - msgs.push_back(CStatusMessage(this).error(u"Setup not available, already shutting down.")); - return msgs; - } - bool forced = false; - if (!m_setupReader->isSetupAvailable()) - { - forced = true; - m_setupReader->forceAvailabilityUpdate(); // maybe web reading still hanging - } - if (m_setupReader->isSetupAvailable()) - { - msgs.push_back(CStatusMessage(this).info(forced ? QStringLiteral("Setup available after forcing (so likely web read still pending)") : QStringLiteral("Setup available"))); - return msgs; - } - - // getting here means no "real" read success, and NO available cache - msgs.push_back(CStatusMessage(this).error(u"Setup not available, setup reading failed or timed out.")); - if (m_setupReader->getLastSetupReadErrorMessages().hasErrorMessages()) - { - msgs.push_back(m_setupReader->getLastSetupReadErrorMessages()); - } - if (m_setupReader->hasCmdLineBootstrapUrl()) - { - msgs.push_back(CStatusMessage(this).info(u"Bootstrap URL cmd line argument '%1'") << m_setupReader->getCmdLineBootstrapUrl()); - } - return msgs; - } - bool CApplication::isSetupAvailable() const { if (m_shutdown || !m_setupReader) { return false; } return m_setupReader->isSetupAvailable(); } - CStatusMessageList CApplication::requestReloadOfSetupAndVersion() - { - if (m_shutdown) { return CStatusMessage(this).warning(u"Shutting down, not reading"); } - if (!m_setupReader) { return CStatusMessage(this).error(u"No reader for setup/version"); } - Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed"); - return m_setupReader->asyncLoad(); - } - bool CApplication::hasMinimumMappingVersion() const { return (this->getGlobalSetup().isSwiftVersionMinimumMappingVersion()); @@ -1103,7 +1043,6 @@ namespace BlackCore if (m_setupReader) { - m_setupReader->gracefulShutdown(); m_setupReader.reset(); } @@ -1448,15 +1387,26 @@ namespace BlackCore if (!this->parsingHookIn()) { return false; } // setup reader - m_setupReader->parseCmdLineArguments(); m_parsed = true; return true; } - bool CApplication::parseAndSynchronizeSetup(int timeoutMs) + bool CApplication::parseAndLoadSetup() { if (!this->parseAndStartupCheck()) return false; - return !this->synchronizeSetup(timeoutMs).hasErrorMessages(); + const CStatusMessageList msgs = loadSetup(); + + if (msgs.isFailure()) + { + displaySetupLoadFailure(msgs); + } + return msgs.isSuccess(); + } + + void CApplication::displaySetupLoadFailure(BlackMisc::CStatusMessageList) + { + // Ignore for CLI application + // Already logged to console } bool CApplication::cmdLineWarningMessage(const QString &text, const QString &informativeText) const @@ -1656,17 +1606,14 @@ namespace BlackCore return m_setupReader.data(); } - QString CApplication::getLastSuccesfulSetupUrl() const + CStatusMessageList CApplication::loadSetup() { - if (!this->hasSetupReader()) { return {}; } - return m_setupReader->getLastSuccessfulSetupUrl(); - } - - CStatusMessageList CApplication::synchronizeSetup(int timeoutMs) - { - const CStatusMessageList requestMsgs = this->requestReloadOfSetupAndVersion(); - if (requestMsgs.isFailure()) { return requestMsgs; } // request already failed - return this->waitForSetup(timeoutMs); + if (m_shutdown) { return CStatusMessage(this).warning(u"Shutting down, not reading"); } + if (!m_setupReader) { return CStatusMessage(this).error(u"No reader for setup/version"); } + Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed"); + const CStatusMessageList requestMsgs = m_setupReader->loadSetup(); + onSetupHandlingCompleted(requestMsgs.isSuccess()); + return requestMsgs; } CUrlList CApplication::getVatsimMetarUrls() const diff --git a/src/blackcore/application.h b/src/blackcore/application.h index f493fe588..4726bca0c 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -298,8 +298,8 @@ namespace BlackCore //! Combined function //! \see parseAndStartupCheck - //! \see synchronizeSetup - virtual bool parseAndSynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs()); + //! \see loadSetup + bool parseAndLoadSetup(); //! Display warning message virtual bool cmdLineWarningMessage(const QString &text, const QString &informativeText = "") const; @@ -406,20 +406,9 @@ namespace BlackCore // ----------------------- setup data --------------------------------- - //! Last setup URL (successfully read) - //! \threadsafe - QString getLastSuccesfulSetupUrl() const; - - //! Reload setup and version - BlackMisc::CStatusMessageList requestReloadOfSetupAndVersion(); - //! Minimum mapping version check virtual bool hasMinimumMappingVersion() const; - //! Read and wait for setup - //! \sa waitForSetup - BlackMisc::CStatusMessageList synchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs()); - //! Setup reader? bool hasSetupReader() const; @@ -570,9 +559,6 @@ namespace BlackCore //! @} signals: - //! Setup available (cache, web load, ..) or failed to load setup - void setupHandlingCompleted(bool success); - //! Update info available (cache, web load) void updateInfoAvailable(bool success); @@ -597,13 +583,12 @@ namespace BlackCore void aboutToShutdown(); protected: + //! Display the failures caused by loading the setup file + virtual void displaySetupLoadFailure(BlackMisc::CStatusMessageList msgs); + //! Setup read/synchronized void onSetupHandlingCompleted(bool available); - //! Wait for setup data by calling the event loop and waiting until everything is ready - //! \remark requires parsing upfront - BlackMisc::CStatusMessageList waitForSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs()); - //! Startup completed virtual void onStartUpCompleted(); @@ -672,6 +657,9 @@ namespace BlackCore std::atomic_bool m_shutdownInProgress { false }; //!< shutdown in progress? private: + //! Read the setup + BlackMisc::CStatusMessageList loadSetup(); + //! Problem with network access manager void onChangedNetworkAccessibility(QNetworkAccessManager::NetworkAccessibility accessible); diff --git a/src/blackcore/data/globalsetup.cpp b/src/blackcore/data/globalsetup.cpp index 8562dacc7..7b7556781 100644 --- a/src/blackcore/data/globalsetup.cpp +++ b/src/blackcore/data/globalsetup.cpp @@ -33,11 +33,6 @@ namespace BlackCore::Data this->initDefaultValues(); } - bool CGlobalSetup::wasLoaded() const - { - return this->wasLoadedFromFile(); - } - void CGlobalSetup::initDefaultValues() { m_mappingMinimumVersion = CBuildConfig::getVersionString(); @@ -87,17 +82,6 @@ namespace BlackCore::Data return 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::schemaVersionString() + "/bootstrap/" + CSwiftDirectories::bootstrapFileName()); - } - CUrlList CGlobalSetup::getSwiftUpdateInfoFileUrls() const { return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/updateinfo/updateinfo.json"); @@ -179,31 +163,6 @@ namespace BlackCore::Data m_dbDebugFlag = debug; } - QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate) - { - if (candidate.isEmpty()) return {}; // not possible - static const QString version(QString(CGlobalSetup::schemaVersionString()).append("/")); - if (candidate.endsWith(CSwiftDirectories::bootstrapFileName())) { return candidate; } - CUrl url(candidate); - if (candidate.contains("/bootstrap")) - { - url.appendPath(CSwiftDirectories::bootstrapFileName()); - } - else if (candidate.endsWith(CGlobalSetup::schemaVersionString()) || candidate.endsWith(version)) - { - url.appendPath("/bootstrap/" + CSwiftDirectories::bootstrapFileName()); - } - else if (candidate.endsWith("shared") || candidate.endsWith("shared/")) - { - url.appendPath(CGlobalSetup::schemaVersionString() + "/bootstrap/" + CSwiftDirectories::bootstrapFileName()); - } - else - { - url.appendPath("shared/" + CGlobalSetup::schemaVersionString() + "/bootstrap/" + CSwiftDirectories::bootstrapFileName()); - } - return url.getFullUrl(); - } - CUrl CGlobalSetup::buildDbDataDirectoryUrl(const CUrl &candidate) { if (candidate.isEmpty()) return CUrl(); // not possible @@ -257,11 +216,11 @@ namespace BlackCore::Data QString CGlobalSetup::convertToQString(const QString &separator, bool i18n) const { QString s = - u"timestamp: " % this->getFormattedUtcTimestampYmdhms() % separator % u"Global setup loaded: " % boolToYesNo(this->wasLoadedFromFile()) % separator + u"timestamp: " % this->getFormattedUtcTimestampYmdhms() % separator % u"Global setup loaded: " % u"Mapping min.version: " % this->getMappingMinimumVersionString() % separator - % u"Distribution URLs: " % getSwiftUpdateInfoFileUrls().toQString(i18n) % separator % u"Bootstrap URLs: " % getSwiftBootstrapFileUrls().toQString(i18n) % separator % u"Help URLs: " % m_onlineHelpUrls.toQString(i18n) % separator; + % u"Distribution URLs: " % getSwiftUpdateInfoFileUrls().toQString(i18n) % separator % u"Help URLs: " % m_onlineHelpUrls.toQString(i18n) % separator; s += u"DB root directory: " % getDbRootDirectoryUrl().toQString(i18n) % separator % u"ICAO DB reader: " % getDbIcaoReaderUrl().toQString(i18n) % separator % u"Model DB reader: " % getDbModelReaderUrl().toQString(i18n) % separator % u"Airport DB reader: " % getDbAirportReaderUrl().toQString(i18n) % separator % u"DB home page: " % getDbHomePageUrl().toQString(i18n) % separator % u"DB login service: " % getDbLoginServiceUrl().toQString(i18n) % separator % u"DB client ping service: " % getDbClientPingServiceUrl().toQString(i18n); s += @@ -292,12 +251,10 @@ namespace BlackCore::Data case IndexVatsimServer: return QVariant::fromValue(m_vatsimServerFileUrl); case IndexVatsimHttpFsd: return QVariant::fromValue(m_vatsimFsdHttpUrl); case IndexVatsimMetars: return QVariant::fromValue(m_vatsimMetarsUrls); - case IndexBootstrapFileUrls: return QVariant::fromValue(this->getSwiftBootstrapFileUrls()); case IndexUpdateInfoFileUrls: return QVariant::fromValue(this->getSwiftUpdateInfoFileUrls()); case IndexSharedUrls: return QVariant::fromValue(m_sharedUrls); case IndexOnlineHelpUrls: return QVariant::fromValue(m_onlineHelpUrls); case IndexCrashReportServerUrl: return QVariant::fromValue(m_crashReportServerUrl); - case IndexWasLoadedFromFile: return QVariant::fromValue(m_wasLoadedFromFile); case IndexMappingMinimumVersion: return QVariant::fromValue(m_mappingMinimumVersion); case IndexPredefinedServers: return QVariant::fromValue(m_predefinedServers); default: return CValueObject::propertyByIndex(index); @@ -332,7 +289,6 @@ namespace BlackCore::Data case IndexSharedUrls: m_sharedUrls = variant.value(); break; case IndexOnlineHelpUrls: m_onlineHelpUrls = variant.value(); break; case IndexCrashReportServerUrl: m_crashReportServerUrl = variant.value(); break; - case IndexWasLoadedFromFile: m_wasLoadedFromFile = variant.toBool(); break; case IndexMappingMinimumVersion: m_mappingMinimumVersion = variant.toString(); break; case IndexPredefinedServers: m_predefinedServers = variant.value(); break; default: CValueObject::setPropertyByIndex(index, variant); break; diff --git a/src/blackcore/data/globalsetup.h b/src/blackcore/data/globalsetup.h index fa8ec84b2..d0782ec75 100644 --- a/src/blackcore/data/globalsetup.h +++ b/src/blackcore/data/globalsetup.h @@ -47,12 +47,9 @@ namespace BlackCore::Data IndexVatsimServer, IndexVatsimHttpFsd, IndexSwiftDbFiles, - IndexBootstrapFileUrls, IndexUpdateInfoFileUrls, IndexOnlineHelpUrls, IndexCrashReportServerUrl, - IndexWasLoadedFromWeb, - IndexWasLoadedFromFile, IndexSharedUrls, IndexMappingMinimumVersion, IndexPredefinedServers @@ -72,15 +69,6 @@ namespace BlackCore::Data //! Default constructor CGlobalSetup(); - //! Has data loaded from file - bool wasLoadedFromFile() const { return m_wasLoadedFromFile; } - - //! Loaded (web/file) - bool wasLoaded() const; - - //! Mark as loaded from file - void markAsLoadedFromFile(bool loaded) { m_wasLoadedFromFile = loaded; } - //! Http port int getDbHttpPort() const { return m_dbHttpPort; } @@ -144,14 +132,6 @@ namespace BlackCore::Data //! 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 getSwiftUpdateInfoFileUrls() const; @@ -216,9 +196,6 @@ namespace BlackCore::Data //! Schema version (shared files, bootstrap file) static const QString &schemaVersionString(); - //! Build bootstrap file URL from shared URL - static QString buildBootstrapFileUrl(const QString &candidate); - //! Build the full dbdata directory URL from shared URL static BlackMisc::Network::CUrl buildDbDataDirectoryUrl(const BlackMisc::Network::CUrl &candidate); @@ -226,7 +203,6 @@ namespace BlackCore::Data static CGlobalSetup fromJsonFile(const QString &fileNameAndPath, bool acceptCacheFormat); private: - bool m_wasLoadedFromFile = false; //!< Loaded from local file int m_dbHttpPort = 80; //!< port int m_dbHttpsPort = 443; //!< SSL port qint64 m_pingIntervalSecs = 180; //!< seconds between datastore pings @@ -252,7 +228,6 @@ namespace BlackCore::Data BLACK_METACLASS( CGlobalSetup, - BLACK_METAMEMBER(wasLoadedFromFile), BLACK_METAMEMBER(timestampMSecsSinceEpoch), BLACK_METAMEMBER(crashReportServerUrl), BLACK_METAMEMBER(dbRootDirectoryUrl), @@ -275,16 +250,6 @@ namespace BlackCore::Data BLACK_METAMEMBER(dbDebugFlag) ); }; - - //! Trait for global setup data - struct TGlobalSetup : public BlackMisc::TDataTrait - { - //! Key in data cache - static const char *key() { return "bootstrap"; } - - //! First load is synchronous - static constexpr bool isPinned() { return true; } - }; } // ns Q_DECLARE_METATYPE(BlackCore::Data::CGlobalSetup) diff --git a/src/blackcore/setupreader.cpp b/src/blackcore/setupreader.cpp index 465cfc548..e6a097275 100644 --- a/src/blackcore/setupreader.cpp +++ b/src/blackcore/setupreader.cpp @@ -34,162 +34,41 @@ using namespace BlackCore::Data; namespace BlackCore { - CSetupReader::CSetupReader(QObject *parent) : QObject(parent), - m_cmdBootstrapUrl { - { "url", "bootstrapurl" }, - QCoreApplication::translate("application", "Bootstrap URL, e.g. https://datastore.swift-project.org/shared"), - "bootstrapurl", - (sApp->getApplicationInfo().isUnitTest()) ? unitTestBootstrapUrl() : "" - }, - m_cmdBootstrapMode { - { "bmode", "bootstrapmode" }, - QCoreApplication::translate("application", "Bootstrap mode: explicit, implicit, cache(-only)"), - "bootstrapmode", - "explicit" - } + CSetupReader::CSetupReader(QObject *parent) : QObject(parent) {} - QList CSetupReader::getCmdLineOptions() const - { - return QList { { m_cmdBootstrapUrl, m_cmdBootstrapMode } }; - } - - CStatusMessageList CSetupReader::asyncLoad() + CStatusMessageList CSetupReader::loadSetup() { CStatusMessageList msgs; - if (m_localSetupFileValue.isEmpty()) - { - // TODO Check if file exists or is broken - msgs = this->readLocalBootstrapFile(CSwiftDirectories::shareDirectory() + "/shared/bootstrap/bootstrap.json"); - } - else - { - msgs = this->readLocalBootstrapFile(m_localSetupFileValue); - } - msgs.push_back(this->manageSetupAvailability(false, msgs.isSuccess())); + msgs = this->readLocalBootstrapFile(); + m_setupAvailable = msgs.isSuccess(); return msgs; } - bool CSetupReader::parseCmdLineArguments() + CStatusMessageList CSetupReader::readLocalBootstrapFile() { - // copy vars at beginning to simplify a threadsafe version in the future - const QString cmdLineBootstrapUrl = this->getCmdLineBootstrapUrl(); - BootstrapMode bootstrapMode = stringToEnum(sApp->getParserValue(m_cmdBootstrapMode)); - const bool ignoreCmdBootstrapUrl = m_ignoreCmdBootstrapUrl; - const bool checkCmdBootstrapUrl = m_checkCmdBootstrapUrl; - const QString bootstrapUrlFileValue = CGlobalSetup::buildBootstrapFileUrl(cmdLineBootstrapUrl); - QString localSetupFileValue; - const QUrl url(bootstrapUrlFileValue); - const QString urlString(url.toString()); - bool ok = false; + const QString fileName = CSwiftDirectories::bootstrapResourceFilePath(); + // TODO Check if file exists or is broken - if (urlString.isEmpty() && bootstrapMode == Explicit) - { - bootstrapMode = Implicit; // no URL, we use implicit mode - } - - do - { - // check on local file - if (url.isLocalFile()) - { - localSetupFileValue = url.toLocalFile(); - const QFile f(localSetupFileValue); - if (!f.exists()) - { - sApp->cmdLineErrorMessage(QStringLiteral("File '%1' does not exist)").arg(localSetupFileValue)); - break; - } - } - - // check on explicit URL - if (bootstrapMode == Explicit) - { - if (!url.isLocalFile()) - { - bool retry = false; - - // "retry" possible in some cases - do - { - if (ignoreCmdBootstrapUrl || !checkCmdBootstrapUrl || CNetworkUtils::canConnect(url, CNetworkUtils::getLongTimeoutMs())) // cppcheck-suppress knownConditionTrueFalse - { - ok = true; - break; - } - retry = sApp->cmdLineErrorMessage(QStringLiteral("URL '%1' not reachable").arg(urlString), "", true); - } - while (retry); - } - } - } - while (false); - - m_localSetupFileValue = localSetupFileValue; - m_bootstrapUrlFileValue = bootstrapUrlFileValue; - m_bootstrapMode = bootstrapMode; - return ok; - } - - void CSetupReader::gracefulShutdown() - { - m_shutdown = true; - } - - void CSetupReader::forceAvailabilityUpdate() - { - this->manageSetupAvailability(false, false); // fake a failed web read - } - - CSetupReader::BootstrapMode CSetupReader::stringToEnum(const QString &s) - { - const QString bsm(s.toLower().trimmed()); - if (bsm.startsWith("expl")) { return Explicit; } - if (bsm.startsWith("cache")) { return CacheOnly; } - return Implicit; - } - - const QString &CSetupReader::unitTestBootstrapUrl() - { - static const QString url("https://datastore.swift-project.org/shared"); - return url; - } - - CStatusMessageList CSetupReader::readLocalBootstrapFile(const QString &fileName) - { if (fileName.isEmpty()) { return CStatusMessage(this).error(u"No file name for local bootstrap file"); } if (!sApp || sApp->isShuttingDown()) { return CStatusMessage(this).error(u"No sApp, shutting down?"); } - QString fn; const QFile file(fileName); if (!file.exists()) { - // relative name? - const QString dir(sApp->getCmdSwiftPrivateSharedDir()); - if (dir.isEmpty()) { return CStatusMessage(this).error(u"Empty shared directory '%1' for bootstrap file") << dir; } - - // no version for local files, as those come with the current code - fn = CFileUtils::appendFilePaths(dir, "bootstrap/" + CSwiftDirectories::bootstrapFileName()); - } - else - { - fn = fileName; + return CStatusMessage(this).error(u"File '%1' not existing") << fileName; } - const QString content(CFileUtils::readFileToString(fn)); - if (content.isEmpty()) { return CStatusMessage(this).error(u"File '%1' not existing or empty") << fn; } + const QString content(CFileUtils::readFileToString(fileName)); + if (content.isEmpty()) { return CStatusMessage(this).error(u"File '%1' empty") << fileName; } try { - CGlobalSetup s; - s.convertFromJson(content); - s.markAsLoadedFromFile(true); - const CStatusMessage setMsg = m_setup.set(s); - const CStatusMessage setInfo = CStatusMessage(this).info(u"Setup cache updated from local file '%1'") << fn; - return setMsg.isSuccess() ? setInfo : setMsg; + m_setup.convertFromJson(content); + return CStatusMessage(this).info(u"Setup loaded from local file '%1'") << fileName; } catch (const CJsonException &ex) { - return CStatusMessage::fromJsonException(ex, this, QStringLiteral("Parsing local setup file '%1'").arg(fn)); + return CStatusMessage::fromJsonException(ex, this, QStringLiteral("Parsing local setup file '%1'").arg(fileName)); } } @@ -199,136 +78,8 @@ namespace BlackCore return cats; } - bool CSetupReader::hasCmdLineBootstrapUrl() const - { - return !this->getCmdLineBootstrapUrl().isEmpty(); - } - - QString CSetupReader::getCmdLineBootstrapUrl() const - { - if (m_ignoreCmdBootstrapUrl) return {}; - return sApp->getParserValue(m_cmdBootstrapUrl); - } - - void CSetupReader::setIgnoreCmdLineBootstrapUrl(bool ignore) - { - m_ignoreCmdBootstrapUrl = ignore; - this->parseCmdLineArguments(); // T156 this part not threadsafe, currently not a real problem as setup reader runs in main thread - } - CGlobalSetup CSetupReader::getSetup() const { - return m_setup.get(); - } - - bool CSetupReader::hasCachedSetup() const - { - const CGlobalSetup cachedSetup = m_setup.get(); - const bool cacheAvailable = cachedSetup.wasLoaded(); - return cacheAvailable; - } - - QDateTime CSetupReader::getSetupCacheTimestamp() const - { - return m_setup.getTimestamp(); - } - - bool CSetupReader::prefillCacheWithLocalResourceBootstrapFile() - { - if (m_shutdown) { return false; } - m_setup.synchronize(); // make sure it is loaded - const CGlobalSetup cachedSetup = m_setup.get(); - const bool cacheAvailable = cachedSetup.wasLoaded(); - if (cacheAvailable) - { - CLogMessage(this).info(u"Setup cache prefill (bootstrap already cached, no prefill needed"); - return false; - } - const QString fn = CSwiftDirectories::bootstrapResourceFilePath(); - const CStatusMessageList msgs = this->readLocalBootstrapFile(fn); - CLogMessage::preformatted(msgs); - return true; - } - - QString CSetupReader::getLastSuccessfulSetupUrl() const - { - QReadLocker l(&m_lockSetup); - return m_lastSuccessfulSetupUrl; - } - - void CSetupReader::synchronize() - { - m_setup.synchronize(); - } - - CStatusMessageList CSetupReader::getLastSetupReadErrorMessages() const - { - QReadLocker l(&m_lockSetup); - return m_setupReadErrorMsgs; - } - - const QString &CSetupReader::getBootstrapUrlFile() const - { - if (!m_localSetupFileValue.isEmpty()) { return m_localSetupFileValue; } - return m_bootstrapUrlFileValue; - } - - QString CSetupReader::getBootstrapModeAsString() const - { - switch (m_bootstrapMode) - { - case CacheOnly: return QStringLiteral("cache only"); - case Explicit: return QStringLiteral("explicit"); - case Implicit: return QStringLiteral("implicit"); - default: break; - } - return {}; - } - - void CSetupReader::setLastSetupReadErrorMessages(const CStatusMessageList &messages) - { - QWriteLocker l(&m_lockSetup); - m_setupReadErrorMsgs = messages.getErrorMessages(); - } - - void CSetupReader::networkReplyProgress(int logId, qint64 current, qint64 max, const QUrl &url) - { - Q_UNUSED(url) - Q_UNUSED(logId) - Q_UNUSED(current) - Q_UNUSED(max) - } - - CStatusMessageList CSetupReader::manageSetupAvailability(bool webRead, bool localRead) - { - Q_ASSERT_X(!(webRead && localRead), Q_FUNC_INFO, "Local and web read together seems to be wrong"); - CStatusMessageList msgs; - - bool available = false; - if (webRead || localRead) - { - available = true; - } - else - { - const bool cacheAvailable = m_setup.get().wasLoaded(); // loaded from web or file - available = cacheAvailable && m_bootstrapMode != Explicit; - } - - if (available && !webRead && !localRead) - { - msgs.push_back(CStatusMessage(this, CStatusMessage::SeverityInfo, u"Setup available, but not updated this time")); - } - else if (!available) - { - msgs.push_back(CStatusMessage(this, CStatusMessage::SeverityError, u"Setup not available")); - if (m_bootstrapMode == Explicit) - { - msgs.push_back(CStatusMessage(this, CStatusMessage::SeverityError, u"Mode is 'explicit', likely URL '" % m_bootstrapUrlFileValue % u"' is not reachable")); - } - } - m_setupAvailable = available; - emit this->setupHandlingCompleted(available); - return msgs; + return m_setup; } } // namespace diff --git a/src/blackcore/setupreader.h b/src/blackcore/setupreader.h index c62f433ac..fbb708c60 100644 --- a/src/blackcore/setupreader.h +++ b/src/blackcore/setupreader.h @@ -22,10 +22,6 @@ #include #include -namespace BlackMisc -{ - class CLogCategoryList; -} namespace BlackCoreTest { class CTestConnectivity; @@ -39,144 +35,38 @@ namespace BlackCore //! \note This class is no(!) BlackCore::CThreadedReader as it will be loaded once during startup //! and reading setup data is fast. The read file is also called "bootstrap" file as it tells //! swift which data and versions are located where. Without that file we cannot start. - //! Once the file is in place (i.e. in the cache) it can be automatically updated. //! - //! \sa BlackCore::Data::TGlobalSetup //! \sa BlackMisc::Db::TUpdateInfo class BLACKCORE_EXPORT CSetupReader : public QObject { Q_OBJECT - friend class CApplication; //!< only using class friend class BlackCoreTest::CTestConnectivity; public: //! Categories static const QStringList &getLogCategories(); - //! Has a given cmd line argument for bootstrap URL? - bool hasCmdLineBootstrapUrl() const; + //! Constructor + explicit CSetupReader(QObject *parent); - //! CMD line argument for bootstrap URL - QString getCmdLineBootstrapUrl() const; + //! Load the setup. If the setup is already loaded, the setup is reloaded + BlackMisc::CStatusMessageList loadSetup(); - //! Ignore the bootstrap URL + //! Setup available? //! \threadsafe - void setIgnoreCmdLineBootstrapUrl(bool ignore); - - //! Check connection of the bootstrap URL - //! \threadsafe - void setCheckCmdLineBootstrapUrl(bool check) { m_checkCmdBootstrapUrl = check; } + bool isSetupAvailable() const { return m_setupAvailable; } //! Current setup (reader URLs, DB location, crash server) //! \remarks aka "bootstrap file" //! \threadsafe Data::CGlobalSetup getSetup() const; - //! Has cached setup ("bootstrap") data? - //! \threadsafe - bool hasCachedSetup() const; - - //! Get setup cache timestamp - //! \threadsafe - QDateTime getSetupCacheTimestamp() const; - - //! Load the cache file local bootstrap file - //! \remark can be used during installation as failover - //! \threadsafe - bool prefillCacheWithLocalResourceBootstrapFile(); - - //! Last distribution URL successfully read - //! \threadsafe - QString getLastSuccessfulSetupUrl() const; - - //! Synchronize the caches - void synchronize(); - - //! Last setup parsing error messages (if any) - BlackMisc::CStatusMessageList getLastSetupReadErrorMessages() const; - - //! Get bootstrap URL, either m_bootstrapUrlFileValue or m_localSetupFileValue - const QString &getBootstrapUrlFile() const; - - //! Mode as string - QString getBootstrapModeAsString() const; - - signals: - //! Setup fetched or failed (from web, cache, or local file)? - void setupHandlingCompleted(bool available); - - //! Message about the loading status - void setupLoadingMessages(const BlackMisc::CStatusMessageList &messages); - - protected: - //! Constructor - explicit CSetupReader(QObject *parent); - - //! Load the data - BlackMisc::CStatusMessageList asyncLoad(); - - //! Parse cmd line arguments - bool parseCmdLineArguments(); - - //! Add cmd line arguments to BlackCore::CApplication - QList getCmdLineOptions() const; - - //! Terminate - void gracefulShutdown(); - - //! Setup available? - //! \threadsafe - bool isSetupAvailable() const { return m_setupAvailable; } - - //! Force an availability update - //! \remark check for cached setup if the read check never got triggered - void forceAvailabilityUpdate(); - private: - //! Bootstrap mode - enum BootstrapMode - { - Implicit, - Explicit, - CacheOnly - }; - - std::atomic m_shutdown { false }; //!< shutdown in progress std::atomic m_setupAvailable { false }; //!< setup available? - std::atomic m_ignoreCmdBootstrapUrl { false }; //!< ignore the explicitly set bootstrap URL - std::atomic m_checkCmdBootstrapUrl { true }; //!< check connection on CMD bootstrap URL - std::atomic_int m_bootstrapReadErrors { 0 }; //!< failed bootstrap reads - std::atomic_int m_updateInfoReadErrors { 0 }; //!< failed version info reads - QString m_localSetupFileValue; //!< Local file for setup, passed by cmd line arguments - QString m_bootstrapUrlFileValue; //!< Bootstrap URL if not local - BootstrapMode m_bootstrapMode = Explicit; //!< How to bootstrap - BlackMisc::Network::CUrlList m_bootstrapUrls; //!< location of setup files - QCommandLineOption m_cmdBootstrapUrl; //!< bootstrap URL - QCommandLineOption m_cmdBootstrapMode; //!< bootstrap mode - mutable QReadWriteLock m_lockSetup; //!< lock for setup - mutable QReadWriteLock m_lockUpdateInfo; //!< lock for update info - QString m_lastSuccessfulSetupUrl; //!< last successful read setup URL - BlackMisc::CStatusMessageList m_setupReadErrorMsgs; //!< last parsing error messages - BlackMisc::CData m_setup { this }; //!< data cache setup + Data::CGlobalSetup m_setup {}; //!< data setup - //! Read by local individual file and update cache from that - BlackMisc::CStatusMessageList readLocalBootstrapFile(const QString &fileName); - - //! Emit the availability signal and state and trigger follow up actions - //! \threadsafe - BlackMisc::CStatusMessageList manageSetupAvailability(bool webRead, bool localRead = false); - - //! Set last setup parsing messages - void setLastSetupReadErrorMessages(const BlackMisc::CStatusMessageList &messages); - - //! Progress - void networkReplyProgress(int logId, qint64 current, qint64 max, const QUrl &url); - - //! Convert string to bootstrap mode - static BootstrapMode stringToEnum(const QString &s); - - //! Bootsrap URL used for unit tests - static const QString &unitTestBootstrapUrl(); + //! Read by local file + BlackMisc::CStatusMessageList readLocalBootstrapFile(); }; } // ns diff --git a/src/blackgui/components/copyconfigurationcomponent.cpp b/src/blackgui/components/copyconfigurationcomponent.cpp index a9b13df09..8c519fa68 100644 --- a/src/blackgui/components/copyconfigurationcomponent.cpp +++ b/src/blackgui/components/copyconfigurationcomponent.cpp @@ -377,12 +377,6 @@ namespace BlackGui::Components { this->initMultiSimulatorCache(&m_modelCaches, file); } - else if (file.contains(CSwiftDirectories::bootstrapFileName())) - { - CData setup { this }; //!< data cache setup - const CGlobalSetup s = CGlobalSetup::fromJsonFile(file, true); - setup.set(s); - } } // allow the cache files to be generated before we will override them diff --git a/src/blackgui/components/copyconfigurationdialog.cpp b/src/blackgui/components/copyconfigurationdialog.cpp index a5c4dcc27..3a0bd93fd 100644 --- a/src/blackgui/components/copyconfigurationdialog.cpp +++ b/src/blackgui/components/copyconfigurationdialog.cpp @@ -37,11 +37,6 @@ namespace BlackGui::Components ui->comp_CopyConfiguration->setNameFilterDisables(disable); } - void CCopyConfigurationDialog::setWithBootstrapFile(bool withBootstrapFile) - { - ui->comp_CopyConfiguration->setWithBootstrapFile(withBootstrapFile); - } - bool CCopyConfigurationDialog::event(QEvent *event) { if (CGuiApplication::triggerShowHelp(this, event)) { return true; } diff --git a/src/blackgui/components/copyconfigurationdialog.h b/src/blackgui/components/copyconfigurationdialog.h index b6e3b4f59..c7a1dd973 100644 --- a/src/blackgui/components/copyconfigurationdialog.h +++ b/src/blackgui/components/copyconfigurationdialog.h @@ -41,9 +41,6 @@ namespace BlackGui::Components //! \copydoc QFileSystemModel::setNameFilterDisables void setNameFilterDisables(bool disable); - //! \copydoc CCopyConfigurationComponent::setWithBootstrapFile - void setWithBootstrapFile(bool withBootstrapFile); - protected: //! \copydoc QObject::event virtual bool event(QEvent *event) override; diff --git a/src/blackgui/components/setuploadingdialog.cpp b/src/blackgui/components/setuploadingdialog.cpp index ad683a703..6d02e3430 100644 --- a/src/blackgui/components/setuploadingdialog.cpp +++ b/src/blackgui/components/setuploadingdialog.cpp @@ -5,16 +5,11 @@ #include "blackgui/components/copymodelsfromotherswiftversionsdialog.h" #include "ui_setuploadingdialog.h" #include "blackgui/guiapplication.h" -#include "blackcore/data/globalsetup.h" #include "blackcore/setupreader.h" #include "blackmisc/swiftdirectories.h" -#include "blackmisc/directoryutils.h" -#include "blackmisc/network/urllist.h" #include #include -#include -#include using namespace BlackMisc; using namespace BlackMisc::Network; @@ -27,30 +22,15 @@ namespace BlackGui::Components ui(new Ui::CSetupLoadingDialog) { Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need sApp"); - if (this->hasSetupReader()) - { - // reset if it was temporarily ignored - sApp->getSetupReader()->setIgnoreCmdLineBootstrapUrl(false); - connect(sApp, &CGuiApplication::setupHandlingCompleted, this, &CSetupLoadingDialog::onSetupHandlingCompleted); - } ui->setupUi(this); - connect(ui->pb_IgnoreExplicitBootstrapUrl, &QPushButton::clicked, this, &CSetupLoadingDialog::tryAgainWithoutBootstrapUrl); - connect(ui->pb_LoadFromDisk, &QPushButton::clicked, this, &CSetupLoadingDialog::prefillSetupCache); - connect(ui->pb_Help, &QPushButton::clicked, this, &CSetupLoadingDialog::openHelpPage); - connect(ui->pb_CopyFromSwift, &QPushButton::clicked, this, &CSetupLoadingDialog::copyFromOtherSwiftVersions); - connect(ui->pb_OpemDirectory, &QPushButton::clicked, this, &CSetupLoadingDialog::openDirectory); - connect(ui->pb_TryToFix, &QPushButton::clicked, this, &CSetupLoadingDialog::tryToFix); - QPushButton *retry = ui->bb_Dialog->button(QDialogButtonBox::Retry); - retry->setDefault(true); + const QString bootstrapPath = CSwiftDirectories::bootstrapResourceFilePath(); + ui->lbl_ownBootstrap->setText("Your boostrap.json file is available at " + bootstrapPath + ""); - this->displaySetupCacheInfo(); - this->displayCmdBoostrapUrl(); - this->displayGlobalSetup(); - this->displayOtherVersionsInfo(); - - ui->comp_Messages->hideFilterBar(); // saves space, we only expect aview messages + // hide unnecessary details + ui->comp_Messages->hideFilterBar(); + ui->comp_Messages->showDetails(false); } CSetupLoadingDialog::CSetupLoadingDialog(const CStatusMessageList &msgs, QWidget *parent) : CSetupLoadingDialog(parent) { @@ -59,124 +39,4 @@ namespace BlackGui::Components CSetupLoadingDialog::~CSetupLoadingDialog() {} - - bool CSetupLoadingDialog::hasCachedSetup() const - { - return this->hasSetupReader() && sApp->getSetupReader()->hasCachedSetup(); - } - - bool CSetupLoadingDialog::hasSetupReader() const - { - return sApp && sApp->hasSetupReader(); - } - - void CSetupLoadingDialog::displayCmdBoostrapUrl() - { - if (!sApp->hasSetupReader()) { return; } - ui->le_CmdLine->setText(sApp->cmdLineArgumentsAsString()); - ui->le_BootstrapMode->setText(sApp->getSetupReader()->getBootstrapModeAsString()); - - const QString bsUrl = sApp->getSetupReader()->getCmdLineBootstrapUrl(); - ui->pb_IgnoreExplicitBootstrapUrl->setVisible(!bsUrl.isEmpty()); - ui->le_BootstrapUrl->setText(bsUrl); - } - - void CSetupLoadingDialog::displayGlobalSetup() - { - const QString gs = sApp->getGlobalSetup().convertToQString("\n", true); - Q_UNUSED(gs) - // ui->comp_Messages->appendPlainTextToConsole(gs); - //! \fixme create plain text console for this (used to be part of the log component, changed by issue T36) - } - - void CSetupLoadingDialog::openHelpPage() - { - const CUrl url = sApp->getGlobalSetup().getHelpPageUrl("bootstrap"); - if (url.isEmpty()) { return; } - QDesktopServices::openUrl(url); - } - - void CSetupLoadingDialog::tryAgainWithoutBootstrapUrl() - { - if (!sApp->hasSetupReader()) { return; } - sApp->getSetupReader()->setIgnoreCmdLineBootstrapUrl(true); - this->accept(); - } - - void CSetupLoadingDialog::tryToFix() - { - this->prefillSetupCache(); - QPushButton *retry = ui->bb_Dialog->button(QDialogButtonBox::Retry); - if (!retry) { return; } - - QPointer myself(this); - QTimer::singleShot(2000, this, [=] { - if (!sApp || !myself) { return; } - retry->click(); - }); - } - - void CSetupLoadingDialog::prefillSetupCache() - { - if (!sApp || sApp->isShuttingDown()) { return; } - if (!this->hasSetupReader()) { return; } - sApp->getSetupReader()->prefillCacheWithLocalResourceBootstrapFile(); - this->displaySetupCacheInfo(); - } - - void CSetupLoadingDialog::displaySetupCacheInfo() - { - if (this->hasSetupReader()) - { - // reset if it was temporarily ignored - const CSetupReader *sr = sApp->getSetupReader(); - const QDateTime setupTs = sr->getSetupCacheTimestamp(); - static const QDateTime zeroTime = QDateTime::fromMSecsSinceEpoch(0); - ui->le_SetupCache->setText(setupTs.isValid() && setupTs > zeroTime ? - setupTs.toString(Qt::ISODateWithMs) : - "No cache timestamp"); - } - else - { - ui->le_SetupCache->setText("No setup reader"); - } - - const bool hasCachedSetup = this->hasCachedSetup(); - ui->pb_LoadFromDisk->setEnabled(!hasCachedSetup); - ui->pb_LoadFromDisk->setToolTip(hasCachedSetup ? "Cached setup already available" : "No cached setup"); - ui->pb_TryToFix->setEnabled(!hasCachedSetup); - } - - void CSetupLoadingDialog::displayOtherVersionsInfo() - { - const int other = CSwiftDirectories::applicationDataDirectoriesCount() - 1; - ui->le_OtherSwiftVersions->setText(QStringLiteral("There is/are %1 other swift version(s) installed").arg(other)); - ui->pb_CopyFromSwift->setEnabled(other > 0); - } - - void CSetupLoadingDialog::openDirectory() - { - const QUrl url = QUrl::fromLocalFile(CSwiftDirectories::normalizedApplicationDataDirectory()); - QDesktopServices::openUrl(url); - } - - void CSetupLoadingDialog::copyFromOtherSwiftVersions() - { - if (!m_copyFromOtherSwiftVersion) - { - CCopyModelsFromOtherSwiftVersionsDialog *d = new CCopyModelsFromOtherSwiftVersionsDialog(this); - d->setModal(true); - m_copyFromOtherSwiftVersion.reset(d); - } - - const int r = m_copyFromOtherSwiftVersion->exec(); - Q_UNUSED(r); - this->displaySetupCacheInfo(); - } - - void CSetupLoadingDialog::onSetupHandlingCompleted(bool success) - { - Q_UNUSED(success); - this->displaySetupCacheInfo(); - } } // ns diff --git a/src/blackgui/components/setuploadingdialog.h b/src/blackgui/components/setuploadingdialog.h index 7f86d155e..2a30fe54b 100644 --- a/src/blackgui/components/setuploadingdialog.h +++ b/src/blackgui/components/setuploadingdialog.h @@ -15,19 +15,14 @@ namespace Ui } namespace BlackGui::Components { - class CCopyModelsFromOtherSwiftVersionsDialog; - /*! - * Setup dialog, if something goes wrong allows to copy bootstrap file + * Setup dialog, if loading the boostrap file fails */ class CSetupLoadingDialog : public QDialog { Q_OBJECT public: - //! Ctor - explicit CSetupLoadingDialog(QWidget *parent = nullptr); - //! Ctor with messages CSetupLoadingDialog(const BlackMisc::CStatusMessageList &msgs, QWidget *parent = nullptr); @@ -36,46 +31,9 @@ namespace BlackGui::Components private: QScopedPointer ui; - QScopedPointer m_copyFromOtherSwiftVersion; - //! Cached setup available? - bool hasCachedSetup() const; - - //! Setup reader? - bool hasSetupReader() const; - - //! Display bootstrap URL - void displayCmdBoostrapUrl(); - - //! Display global setup - void displayGlobalSetup(); - - //! Open the help page - void openHelpPage(); - - //! Try again without explicit bootstrap URL - void tryAgainWithoutBootstrapUrl(); - - //! Try to fix - void tryToFix(); - - //! Prefill setup cache - void prefillSetupCache(); - - //! Display the setup cache info - void displaySetupCacheInfo(); - - //! Display other versions info - void displayOtherVersionsInfo(); - - //! Open directory - void openDirectory(); - - //! Copy from other swift versions - void copyFromOtherSwiftVersions(); - - //! Setup loading has been completed - void onSetupHandlingCompleted(bool success); + //! Ctor + explicit CSetupLoadingDialog(QWidget *parent = nullptr); }; } // ns diff --git a/src/blackgui/components/setuploadingdialog.ui b/src/blackgui/components/setuploadingdialog.ui index 793f7e379..298f28505 100644 --- a/src/blackgui/components/setuploadingdialog.ui +++ b/src/blackgui/components/setuploadingdialog.ui @@ -17,7 +17,7 @@ - Loading the setup ("bootstrap file") + Loading the setup file failed true @@ -36,173 +36,29 @@ 6 - - - Setup and caches + + + <html><head/><body><p><span style=" font-weight:600;">Loading the setup file (bootstrap.json) has failed!</span> This file is required for <span style=" font-style:italic;">swift</span> to work properly. Fix the errors mentioned below and restart swift. You can also replace your bootstrap.json with the latest version available <a href="https://raw.githubusercontent.com/swift-project/pilotclient/main/resources/share/shared/bootstrap/bootstrap.json"><span style=" text-decoration: underline; color:#0000ff;">from GitHub.</span></a></p></body></html> + + + Qt::RichText + + + true + + + true + + + + + + + TextLabel + + + true - - - 6 - - - 6 - - - 6 - - - - - <html><head/><body><p>The mode: 'implicit' means no URL is provided and the value is obtained from an existing setup. 'explicit' means an URL is provided via command line arguments.</p></body></html> - - - true - - - - - - - Mode: - - - - - - - Timestamp of the setup cache. - - - true - - - - - - - Command: - - - - - - - Where the bootstrap file is located - - - Bootstrap URL: - - - - - - - <html><head/><body><p>The bootstrap URL provided by command line options. This is where the setup data are loaded from.</p></body></html> - - - true - - - - - - - The command line. - - - true - - - - - - - Setup cache: - - - - - - - Copy over: - - - - - - - load the cache data from disk, i.e. from the file which came with the installer - - - from disk - - - - - - - <html><head/><body><p><span style=" font-size:9pt; font-weight:600;">Loading the setup (aka &quot;bootstrap file&quot;) has failed!</span><span style=" font-size:9pt;"> This file is required for </span><span style=" font-size:9pt; font-style:italic;">swift</span><span style=" font-size:9pt;"> to work properly. You can try to load the file again (&quot;Retry&quot;) or give up (&quot;Cancel&quot;). If you have set an explicit bootstrap URL, you can also ignore this URL and use cached setup data (if there are any). If all goes wrong, you can try to load the setup cache from disk.</span></p></body></html> - - - Qt::RichText - - - true - - - - - - - ignore the bootstrap URL and try to read from cache - - - ignore - - - - - - - open dir. - - - - - - - help page - - - - - - - Info about other swift versions installed - - - true - - - - - - - copy cache data from another swift version - - - copy over - - - - - - - try to fix - - - - @@ -236,7 +92,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Retry + QDialogButtonBox::Close @@ -250,18 +106,6 @@ 1 - - le_CmdLine - le_BootstrapMode - le_BootstrapUrl - pb_IgnoreExplicitBootstrapUrl - le_SetupCache - pb_LoadFromDisk - pb_Help - le_OtherSwiftVersions - pb_CopyFromSwift - pb_OpemDirectory - diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index e74569f01..d877bd7d4 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -129,7 +129,6 @@ namespace BlackGui { CGuiApplication::registerMetadata(); CApplication::init(false); // base class without metadata - if (this->hasSetupReader()) { this->getSetupReader()->setCheckCmdLineBootstrapUrl(false); } // no connect checks on setup reader (handled with interactive setup loading) CGuiApplication::adjustPalette(); this->setWindowIcon(icon); this->settingsChanged(); @@ -138,9 +137,6 @@ namespace BlackGui connect(&m_styleSheetUtility, &CStyleSheetUtility::styleSheetsChanged, this, &CGuiApplication::onStyleSheetsChanged, Qt::QueuedConnection); connect(this, &CGuiApplication::startUpCompleted, this, &CGuiApplication::superviseWindowMinSizes, Qt::QueuedConnection); - - // splash screen - connect(this->getSetupReader(), &CSetupReader::setupLoadingMessages, this, &CGuiApplication::displaySplashMessages, Qt::QueuedConnection); } } @@ -1094,48 +1090,21 @@ namespace BlackGui m_minHeightChars = heightChars; } - bool CGuiApplication::interactivelySynchronizeSetup(int timeoutMs) + void CGuiApplication::displaySetupLoadFailure(BlackMisc::CStatusMessageList msgs) { - bool ok = false; - do + if (msgs.hasErrorMessages()) { - const CStatusMessageList msgs = this->synchronizeSetup(timeoutMs); - if (msgs.hasErrorMessages()) + CSetupLoadingDialog dialog(msgs, BlackGui::CGuiApplication::mainApplicationWidget()); + if (sGui) { - CSetupLoadingDialog dialog(msgs, this->mainApplicationWidget()); - if (sGui) - { - static const QString style = sGui->getStyleSheetUtility().styles( - { CStyleSheetUtility::fileNameFonts(), - CStyleSheetUtility::fileNameStandardWidget() }); - dialog.setStyleSheet(style); - } + static const QString style = sGui->getStyleSheetUtility().styles( + { CStyleSheetUtility::fileNameFonts(), + CStyleSheetUtility::fileNameStandardWidget() }); + dialog.setStyleSheet(style); + } - const int r = dialog.exec(); - if (r == QDialog::Rejected) - { - break; // exit with false state, as file was not loaded - } - else - { - // run loop again and sync again - } - } - else - { - // setup loaded - ok = true; - break; - } + dialog.exec(); } - while (!ok); - return ok; - } - - bool CGuiApplication::parseAndSynchronizeSetup(int timeoutMs) - { - if (!this->parseAndStartupCheck()) { return false; } - return this->interactivelySynchronizeSetup(timeoutMs); } QDialog::DialogCode CGuiApplication::showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent) diff --git a/src/blackgui/guiapplication.h b/src/blackgui/guiapplication.h index 6e6a5a66e..f1594da66 100644 --- a/src/blackgui/guiapplication.h +++ b/src/blackgui/guiapplication.h @@ -217,13 +217,8 @@ namespace BlackGui //! \deprecated kept for experimental tests void setMinimumSizeInCharacters(int widthChars, int heightChars); - //! Wait for setup, in case it fails display a dialog how to continue - bool interactivelySynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs()); - - //! Combined function - //! \see parseAndStartupCheck - //! \see interactivelySynchronizeSetup - virtual bool parseAndSynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs()) override; + //! \copydoc BlackCore::CApplication::displaySetupLoadFailure + void displaySetupLoadFailure(BlackMisc::CStatusMessageList msgs) override; //! Show close dialog //! \remark will modify CApplication::saveSettingsOnShutdown diff --git a/src/swiftcore/main.cpp b/src/swiftcore/main.cpp index 8542cedee..eaa60597f 100644 --- a/src/swiftcore/main.cpp +++ b/src/swiftcore/main.cpp @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) a.addDBusAddressOption(); a.addVatlibOptions(); a.addAudioOptions(); - if (!a.parseAndSynchronizeSetup()) { return EXIT_FAILURE; } + if (!a.parseAndLoadSetup()) { return EXIT_FAILURE; } const QString dBusAdress(a.getCmdDBusAddressValue()); a.useContexts(CCoreFacadeConfig::forCoreAllLocalInDBus(dBusAdress)); diff --git a/src/swiftdata/main.cpp b/src/swiftdata/main.cpp index c9ac65e3c..c0a36d91e 100644 --- a/src/swiftdata/main.cpp +++ b/src/swiftdata/main.cpp @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) CGuiApplication a(CApplicationInfo::swiftMappingTool(), CApplicationInfo::MappingTool, CIcons::swiftDatabase48()); a.setSignalStartupAutomatically(false); // application will signal startup on its own a.splashScreen(CIcons::swiftDatabase256()); - if (!a.parseAndSynchronizeSetup()) { return EXIT_FAILURE; } + if (!a.parseAndLoadSetup()) { return EXIT_FAILURE; } a.useWebDataServices(BlackCore::CWebReaderFlags::AllSwiftDbReaders, CDatabaseReaderConfigList::forMappingTool()); a.useFacadeNoContexts(); if (!a.start()) diff --git a/src/swiftguistandard/main.cpp b/src/swiftguistandard/main.cpp index 672674617..0c1ec8714 100644 --- a/src/swiftguistandard/main.cpp +++ b/src/swiftguistandard/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) a.setSignalStartupAutomatically(false); // application will signal startup on its own a.splashScreen(CIcons::swift256()); a.setMinimumSizeInCharacters(60, 42); // experimental - if (!a.parseAndSynchronizeSetup()) { return EXIT_FAILURE; } + if (!a.parseAndLoadSetup()) { return EXIT_FAILURE; } if (!a.hasSetupReader() || !a.start()) { a.gracefulShutdown(); diff --git a/src/swiftlauncher/main.cpp b/src/swiftlauncher/main.cpp index 287d29acf..fad459a89 100644 --- a/src/swiftlauncher/main.cpp +++ b/src/swiftlauncher/main.cpp @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) CGuiApplication a(CApplicationInfo::swiftLauncher(), CApplicationInfo::Laucher, CIcons::swiftLauncher1024()); a.addVatlibOptions(); // so it can be passed (hand over) to started applications a.addParserOption({ { "i", "installer" }, QCoreApplication::translate("main", "Installer setup.") }); - if (!a.parseAndSynchronizeSetup()) { return EXIT_FAILURE; } + if (!a.parseAndLoadSetup()) { return EXIT_FAILURE; } a.useWebDataServices(BlackCore::CWebReaderFlags::AllSwiftDbReaders, CDatabaseReaderConfigList::forLauncher()); a.useFacadeNoContexts(); if (!a.start()) diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index 5ed386a80..f5bf7f200 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -129,11 +129,6 @@ void CSwiftLauncher::installerMode() const QDir dir = CSwiftDirectories::logDirectory(); if (!dir.exists()) { break; } - if (sGui && sGui->getSetupReader()) - { - sGui->getSetupReader()->prefillCacheWithLocalResourceBootstrapFile(); - } - for (const CSimulatorInfo &sim : CSimulatorInfo::allSimulatorsSet()) { this->synchronizeCache(sim); diff --git a/tests/blackcore/context/testcontext/testcontext.cpp b/tests/blackcore/context/testcontext/testcontext.cpp index a3460e111..d20ef2a44 100644 --- a/tests/blackcore/context/testcontext/testcontext.cpp +++ b/tests/blackcore/context/testcontext/testcontext.cpp @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) BLACKTEST_INIT(BlackCoreTest::CTestContext) CApplication a(CApplicationInfo::UnitTest); a.addVatlibOptions(); - const bool setup = a.parseAndSynchronizeSetup(); + const bool setup = a.parseAndLoadSetup(); if (!setup) { qWarning() << "No setup loaded"; } int r = EXIT_FAILURE; if (a.start()) diff --git a/tests/blackcore/testconnectivity/testconnectivity.cpp b/tests/blackcore/testconnectivity/testconnectivity.cpp index ff3ae8c16..fdc93c246 100644 --- a/tests/blackcore/testconnectivity/testconnectivity.cpp +++ b/tests/blackcore/testconnectivity/testconnectivity.cpp @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) BLACKTEST_INIT(BlackCoreTest::CTestConnectivity) CApplication a(CApplicationInfo::UnitTest); a.addVatlibOptions(); - const bool setup = a.parseAndSynchronizeSetup(); + const bool setup = a.parseAndLoadSetup(); if (!setup) { qWarning() << "No setup loaded"; } int r = EXIT_FAILURE; if (a.start())