mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T156, allow to interactively resolve setup issues
* interactivelySynchronizeSetup * utility function parseAndSynchronizeSetup, explicit loading of setup * removed m_startSetupReader;
This commit is contained in:
committed by
Mathew Sutcliffe
parent
409a50e8a5
commit
fedcd76a05
@@ -356,8 +356,8 @@ namespace BlackCore
|
||||
});
|
||||
}
|
||||
|
||||
// load setup
|
||||
if (m_startSetupReader && !m_setupReader->isSetupAvailable())
|
||||
//! \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; }
|
||||
@@ -396,14 +396,14 @@ namespace BlackCore
|
||||
CLogMessage::preformatted(msgs);
|
||||
}
|
||||
|
||||
m_started = m_startSetupReader; // only if requested it will be started
|
||||
m_started = true;
|
||||
return m_started;
|
||||
}
|
||||
|
||||
CStatusMessageList CApplication::waitForSetup()
|
||||
CStatusMessageList CApplication::waitForSetup(int timeoutMs)
|
||||
{
|
||||
if (!m_setupReader) { return CStatusMessage(this).error("No setup reader"); }
|
||||
CEventLoop::processEventsUntil(this, &CApplication::setupHandlingCompleted, CNetworkUtils::getLongTimeoutMs(), [this]
|
||||
CEventLoop::processEventsUntil(this, &CApplication::setupHandlingCompleted, timeoutMs, [this]
|
||||
{
|
||||
return m_setupReader->isSetupAvailable();
|
||||
});
|
||||
@@ -718,30 +718,12 @@ namespace BlackCore
|
||||
return m_networkWatchDog && m_networkWatchDog->isSwiftDbAccessible();
|
||||
}
|
||||
|
||||
bool CApplication::hasSetupReader() const
|
||||
{
|
||||
// m_startSetupReader set to false, if something wrong with parsing
|
||||
return m_setupReader && m_startSetupReader;
|
||||
}
|
||||
|
||||
QString CApplication::getLastSuccesfulSetupUrl() const
|
||||
{
|
||||
if (!this->hasSetupReader()) { return ""; }
|
||||
return m_setupReader->getLastSuccessfulSetupUrl();
|
||||
}
|
||||
|
||||
CUrl CApplication::getWorkingSharedUrl() const
|
||||
{
|
||||
if (!m_networkWatchDog || !this->isNetworkAccessible()) { return CUrl(); }
|
||||
return m_networkWatchDog->getWorkingSharedUrl();
|
||||
}
|
||||
|
||||
QString CApplication::getLastSuccesfulDistributionUrl() const
|
||||
{
|
||||
if (!this->hasSetupReader()) { return ""; }
|
||||
return m_setupReader->getLastSuccessfulDistributionUrl();
|
||||
}
|
||||
|
||||
void CApplication::exit(int retcode)
|
||||
{
|
||||
if (instance())
|
||||
@@ -1183,11 +1165,17 @@ namespace BlackCore
|
||||
if (!this->parsingHookIn()) { return false; }
|
||||
|
||||
// setup reader
|
||||
m_startSetupReader = m_setupReader->parseCmdLineArguments();
|
||||
m_setupReader->parseCmdLineArguments();
|
||||
m_parsed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CApplication::parseAndSynchronizeSetup(int timeoutMs)
|
||||
{
|
||||
if (!this->parseAndStartupCheck()) return false;
|
||||
return !this->synchronizeSetup(timeoutMs).hasErrorMessages();
|
||||
}
|
||||
|
||||
bool CApplication::cmdLineErrorMessage(const QString &errorMessage, bool retry) const
|
||||
{
|
||||
Q_UNUSED(retry); // only works with UI version
|
||||
@@ -1220,6 +1208,14 @@ namespace BlackCore
|
||||
return args;
|
||||
}
|
||||
|
||||
QString CApplication::cmdLineArgumentsAsString(bool withExecutable)
|
||||
{
|
||||
QStringList args = QCoreApplication::arguments();
|
||||
if (!withExecutable && !args.isEmpty()) args.removeFirst();
|
||||
if (args.isEmpty()) return "";
|
||||
return args.join(' ');
|
||||
}
|
||||
|
||||
void CApplication::cmdLineHelpMessage()
|
||||
{
|
||||
m_parser.showHelp(); // terminates
|
||||
@@ -1307,6 +1303,34 @@ namespace BlackCore
|
||||
// Setup
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
bool CApplication::hasSetupReader() const
|
||||
{
|
||||
return m_setupReader;
|
||||
}
|
||||
|
||||
CSetupReader *CApplication::getSetupReader() const
|
||||
{
|
||||
return m_setupReader.data();
|
||||
}
|
||||
|
||||
QString CApplication::getLastSuccesfulSetupUrl() const
|
||||
{
|
||||
if (!this->hasSetupReader()) { return ""; }
|
||||
return m_setupReader->getLastSuccessfulSetupUrl();
|
||||
}
|
||||
|
||||
QString CApplication::getLastSuccesfulDistributionUrl() const
|
||||
{
|
||||
if (!this->hasSetupReader()) { return ""; }
|
||||
return m_setupReader->getLastSuccessfulDistributionUrl();
|
||||
}
|
||||
|
||||
CStatusMessageList CApplication::synchronizeSetup(int timeoutMs)
|
||||
{
|
||||
this->requestReloadOfSetupAndVersion();
|
||||
return this->waitForSetup(timeoutMs);
|
||||
}
|
||||
|
||||
CUrlList CApplication::getVatsimMetarUrls() const
|
||||
{
|
||||
if (m_shutdown) { return CUrlList(); }
|
||||
|
||||
@@ -181,9 +181,6 @@ namespace BlackCore
|
||||
//! \remark supposed to be used only in special cases
|
||||
const QNetworkAccessManager *getNetworkAccessManager() const { return m_accessManager; }
|
||||
|
||||
//! Setup reader?
|
||||
bool hasSetupReader() const;
|
||||
|
||||
//! Last setup URL (successfully read)
|
||||
//! \threadsafe
|
||||
QString getLastSuccesfulSetupUrl() const;
|
||||
@@ -192,9 +189,6 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
QString getLastSuccesfulDistributionUrl() const;
|
||||
|
||||
//! Setup already synchronized
|
||||
bool isSetupAvailable() const;
|
||||
|
||||
//! Reload setup and version
|
||||
BlackMisc::CStatusMessageList requestReloadOfSetupAndVersion();
|
||||
|
||||
@@ -312,7 +306,11 @@ namespace BlackCore
|
||||
//! \sa parsingHookIn
|
||||
//! \return true means to continue, false to stop
|
||||
bool parseAndStartupCheck();
|
||||
//! @}
|
||||
|
||||
//! Combined function
|
||||
//! \see parseAndStartupCheck
|
||||
//! \see synchronizeSetup
|
||||
virtual bool parseAndSynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs());
|
||||
|
||||
//! Display error message
|
||||
virtual bool cmdLineErrorMessage(const QString &cmdLineErrorMessage, bool retry = false) const;
|
||||
@@ -323,6 +321,10 @@ namespace BlackCore
|
||||
//! Arguments to be passed to another swift appplication
|
||||
QStringList inheritedArguments(bool withVatlibArgs = true) const;
|
||||
|
||||
//! cmd line arguments as string
|
||||
virtual QString cmdLineArgumentsAsString(bool withExecutable = true);
|
||||
//! @}
|
||||
|
||||
// ----------------------- contexts ----------------------------------------
|
||||
|
||||
//! \name Context / core facade related
|
||||
@@ -364,7 +366,20 @@ namespace BlackCore
|
||||
Context::IContextSimulator *getIContextSimulator();
|
||||
//! @}
|
||||
|
||||
// ----------------------- direct access to some setup data ---------------------------------
|
||||
// ----------------------- setup data ---------------------------------
|
||||
//! Read and wait for setup
|
||||
//! \sa waitForSetup
|
||||
BlackMisc::CStatusMessageList synchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs());
|
||||
|
||||
//! Setup reader?
|
||||
bool hasSetupReader() const;
|
||||
|
||||
//! Access to setup reader
|
||||
//! \remark supposed to be used only in special cases
|
||||
BlackCore::CSetupReader *getSetupReader() const;
|
||||
|
||||
//! Setup already synchronized
|
||||
bool isSetupAvailable() const;
|
||||
|
||||
//! Consolidated version of METAR URLs, either from CGlobalSetup or CVatsimSetup
|
||||
//! \threadsafe
|
||||
@@ -374,15 +389,13 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
BlackMisc::Network::CUrlList getVatsimDataFileUrls() const;
|
||||
|
||||
public slots:
|
||||
//! Graceful shutdown
|
||||
virtual void gracefulShutdown();
|
||||
|
||||
//! Start services, if not yet parsed call CApplication::parse
|
||||
virtual bool start();
|
||||
|
||||
//! Wait for setup data by calling the event loop and waiting until everything is ready
|
||||
BlackMisc::CStatusMessageList waitForSetup();
|
||||
// ------------------------- network -----------------------------------------------
|
||||
|
||||
public:
|
||||
static constexpr int NoRedirects = -1; //!< network request not allowing redirects
|
||||
@@ -463,11 +476,12 @@ namespace BlackCore
|
||||
//! Setup read/synchronized
|
||||
void setupHandlingIsCompleted(bool available);
|
||||
|
||||
//! Startup completed
|
||||
virtual void startupCompleted();
|
||||
//! 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());
|
||||
|
||||
//! Problem with network access manager
|
||||
virtual void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible);
|
||||
//! Startup completed
|
||||
virtual void onStartUpCompleted();
|
||||
|
||||
//! Init class, allows to init from BlackGui::CGuiApplication as well (pseudo virtual)
|
||||
void init(bool withMetadata);
|
||||
@@ -516,7 +530,6 @@ namespace BlackCore
|
||||
QCommandLineOption m_cmdTestCrashpad {"testcrashpad"}; //!< Test a crasphpad upload
|
||||
bool m_parsed = false; //!< Parsing accomplished?
|
||||
bool m_started = false; //!< started with success?
|
||||
bool m_startSetupReader = false; //!< start the setup reader
|
||||
bool m_singleApplication = true; //!< only one instance of that application
|
||||
bool m_alreadyRunning = false; //!< Application already running
|
||||
|
||||
|
||||
Reference in New Issue
Block a user