mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
refs #846, return CStatusMessageList instead bool, more detailed info
* renamed to ps_setupHandlingCompleted * removed m_startUpCompleted
This commit is contained in:
committed by
Mathew Sutcliffe
parent
0fc34be74f
commit
83dad62d4b
@@ -134,7 +134,7 @@ namespace BlackCore
|
|||||||
// global setup
|
// global setup
|
||||||
sApp = this;
|
sApp = this;
|
||||||
this->m_setupReader.reset(new CSetupReader(this));
|
this->m_setupReader.reset(new CSetupReader(this));
|
||||||
connect(this->m_setupReader.data(), &CSetupReader::setupAvailable, this, &CApplication::ps_setupAvailable);
|
connect(this->m_setupReader.data(), &CSetupReader::setupHandlingCompleted, this, &CApplication::ps_setupHandlingCompleted);
|
||||||
connect(this->m_setupReader.data(), &CSetupReader::updateInfoAvailable, this, &CApplication::updateInfoAvailable);
|
connect(this->m_setupReader.data(), &CSetupReader::updateInfoAvailable, this, &CApplication::updateInfoAvailable);
|
||||||
|
|
||||||
this->m_parser.addOptions(this->m_setupReader->getCmdLineOptions());
|
this->m_parser.addOptions(this->m_setupReader->getCmdLineOptions());
|
||||||
@@ -317,7 +317,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return CStatusMessage(getLogCategories(), CStatusMessage::SeverityError, "No reader for setup/version");
|
return CStatusMessage(this).error("No reader for setup/version");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,29 +516,29 @@ namespace BlackCore
|
|||||||
eventLoop.exec();
|
eventLoop.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CApplication::useContexts(const CCoreFacadeConfig &coreConfig)
|
CStatusMessageList CApplication::useContexts(const CCoreFacadeConfig &coreConfig)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this function after parsing");
|
Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this function after parsing");
|
||||||
|
|
||||||
this->m_useContexts = true;
|
this->m_useContexts = true;
|
||||||
this->m_coreFacadeConfig = coreConfig;
|
this->m_coreFacadeConfig = coreConfig;
|
||||||
|
|
||||||
|
// if not yet initialized, init web data services
|
||||||
if (!this->m_useWebData)
|
if (!this->m_useWebData)
|
||||||
{
|
{
|
||||||
bool s = this->useWebDataServices(CWebReaderFlags::AllReaders, CDatabaseReaderConfigList::forPilotClient());
|
const CStatusMessageList msgs = this->useWebDataServices(CWebReaderFlags::AllReaders, CDatabaseReaderConfigList::forPilotClient());
|
||||||
if (!s) { return false; }
|
if (msgs.hasErrorMessages()) { return msgs; }
|
||||||
}
|
}
|
||||||
return this->startCoreFacade(); // will do nothing if setup is not yet loaded
|
return this->startCoreFacadeAndWebDataServices(); // will do nothing if setup is not yet loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CApplication::useWebDataServices(const CWebReaderFlags::WebReader webReaders, const CDatabaseReaderConfigList &dbReaderConfig)
|
CStatusMessageList CApplication::useWebDataServices(const CWebReaderFlags::WebReader webReaders, const CDatabaseReaderConfigList &dbReaderConfig)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(this->m_webDataServices.isNull(), Q_FUNC_INFO, "Services already started");
|
Q_ASSERT_X(this->m_webDataServices.isNull(), Q_FUNC_INFO, "Services already started");
|
||||||
BLACK_VERIFY_X(QSslSocket::supportsSsl(), Q_FUNC_INFO, "No SSL");
|
BLACK_VERIFY_X(QSslSocket::supportsSsl(), Q_FUNC_INFO, "No SSL");
|
||||||
if (!QSslSocket::supportsSsl())
|
if (!QSslSocket::supportsSsl())
|
||||||
{
|
{
|
||||||
this->cmdLineErrorMessage("No SSL supported, can`t be used");
|
return CStatusMessage(this).error("No SSL supported, can`t be used");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_webReadersUsed = webReaders;
|
this->m_webReadersUsed = webReaders;
|
||||||
@@ -547,11 +547,12 @@ namespace BlackCore
|
|||||||
return this->startWebDataServices();
|
return this->startWebDataServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CApplication::startCoreFacade()
|
CStatusMessageList CApplication::startCoreFacadeAndWebDataServices()
|
||||||
{
|
{
|
||||||
if (!this->m_useContexts) { return true; } // we do not use context, so no need to startup
|
Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this function after parsing");
|
||||||
if (!this->m_parsed) { return false; }
|
|
||||||
if (!this->m_setupReader || !this->m_setupReader->isSetupAvailable()) { return false; }
|
if (!this->m_useContexts) { return CStatusMessage(this).error("No need to start core facade"); } // we do not use context, so no need to startup
|
||||||
|
if (!this->m_setupReader || !this->m_setupReader->isSetupAvailable()) { return CStatusMessage(this).error("No setup reader or setup available"); }
|
||||||
|
|
||||||
Q_ASSERT_X(this->m_coreFacade.isNull(), Q_FUNC_INFO, "Cannot alter facade");
|
Q_ASSERT_X(this->m_coreFacade.isNull(), Q_FUNC_INFO, "Cannot alter facade");
|
||||||
Q_ASSERT_X(this->m_setupReader, Q_FUNC_INFO, "No facade without setup possible");
|
Q_ASSERT_X(this->m_setupReader, Q_FUNC_INFO, "No facade without setup possible");
|
||||||
@@ -559,29 +560,35 @@ namespace BlackCore
|
|||||||
|
|
||||||
this->startWebDataServices();
|
this->startWebDataServices();
|
||||||
|
|
||||||
CLogMessage(this).info("Will start core facade now");
|
const CStatusMessageList msgs(CStatusMessage(this).info("Will start core facade now"));
|
||||||
this->m_coreFacade.reset(new CCoreFacade(this->m_coreFacadeConfig));
|
this->m_coreFacade.reset(new CCoreFacade(this->m_coreFacadeConfig));
|
||||||
emit this->coreFacadeStarted();
|
emit this->coreFacadeStarted();
|
||||||
return true;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CApplication::startWebDataServices()
|
CStatusMessageList CApplication::startWebDataServices()
|
||||||
{
|
{
|
||||||
if (!this->m_useWebData) { return true; }
|
Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this function after parsing");
|
||||||
if (!this->m_parsed) { return false; }
|
|
||||||
if (!this->m_setupReader || !this->m_setupReader->isSetupAvailable()) { return false; }
|
if (!this->m_useWebData) { return CStatusMessage(this).warning("No need to start web data services"); }
|
||||||
|
if (!this->m_setupReader || !this->m_setupReader->isSetupAvailable()) { return CStatusMessage(this).error("No setup reader or setup available"); }
|
||||||
|
|
||||||
Q_ASSERT_X(this->m_setupReader, Q_FUNC_INFO, "No web data services without setup possible");
|
Q_ASSERT_X(this->m_setupReader, Q_FUNC_INFO, "No web data services without setup possible");
|
||||||
|
CStatusMessageList msgs;
|
||||||
if (!this->m_webDataServices)
|
if (!this->m_webDataServices)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Will start web data services now");
|
msgs.push_back(CStatusMessage(this).info("Will start web data services now"));
|
||||||
this->m_webDataServices.reset(
|
this->m_webDataServices.reset(
|
||||||
new CWebDataServices(this->m_webReadersUsed, this->m_dbReaderConfig, {}, this)
|
new CWebDataServices(this->m_webReadersUsed, this->m_dbReaderConfig, {}, this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msgs.push_back(CStatusMessage(this).info("Web data services already running"));
|
||||||
|
}
|
||||||
|
|
||||||
emit webDataServicesStarted(true);
|
emit webDataServicesStarted(true);
|
||||||
return true;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CApplication::initLogging()
|
void CApplication::initLogging()
|
||||||
@@ -606,7 +613,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
// dev. system
|
// dev. system
|
||||||
this->m_cmdDevelopment = QCommandLineOption({ "dev", "development" },
|
this->m_cmdDevelopment = QCommandLineOption({ "dev", "development" },
|
||||||
QCoreApplication::translate("application", "Dev.system feature?"),
|
QCoreApplication::translate("application", "Dev. system features?"),
|
||||||
"development");
|
"development");
|
||||||
this->addParserOption(this->m_cmdDevelopment);
|
this->addParserOption(this->m_cmdDevelopment);
|
||||||
|
|
||||||
@@ -695,14 +702,16 @@ namespace BlackCore
|
|||||||
this->m_fileLogger->close();
|
this->m_fileLogger->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CApplication::ps_setupAvailable(bool available)
|
void CApplication::ps_setupHandlingCompleted(bool available)
|
||||||
{
|
{
|
||||||
if (available)
|
if (available)
|
||||||
{
|
{
|
||||||
this->m_started = this->asyncWebAndContextStart();
|
// start follow ups when setup is avaialable
|
||||||
|
const CStatusMessageList msgs = this->asyncWebAndContextStart();
|
||||||
|
this->m_started = msgs.isSuccess();
|
||||||
}
|
}
|
||||||
this->m_startUpCompleted = true;
|
|
||||||
emit setupAvailable(available);
|
emit this->setupHandlingCompleted(available);
|
||||||
|
|
||||||
if (this->m_signalStartup)
|
if (this->m_signalStartup)
|
||||||
{
|
{
|
||||||
@@ -715,13 +724,15 @@ namespace BlackCore
|
|||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CApplication::asyncWebAndContextStart()
|
CStatusMessageList CApplication::asyncWebAndContextStart()
|
||||||
{
|
{
|
||||||
if (this->m_started) { return true; }
|
if (this->m_started) { return CStatusMessage(this).info("Already started "); }
|
||||||
|
|
||||||
// follow up startups
|
// follow up startups
|
||||||
bool s = this->startWebDataServices();
|
CStatusMessageList msgs = this->startWebDataServices();
|
||||||
return s && this->startCoreFacade();
|
if (msgs.isFailure()) return msgs;
|
||||||
|
msgs.push_back(this->startCoreFacadeAndWebDataServices());
|
||||||
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CApplication::severeStartupProblem(const CStatusMessage &message)
|
void CApplication::severeStartupProblem(const CStatusMessage &message)
|
||||||
@@ -995,19 +1006,19 @@ namespace BlackCore
|
|||||||
#ifdef BLACK_USE_CRASHPAD
|
#ifdef BLACK_USE_CRASHPAD
|
||||||
base::FilePath qstringToFilePath(const QString &str)
|
base::FilePath qstringToFilePath(const QString &str)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
# ifdef Q_OS_WIN
|
||||||
return base::FilePath(str.toStdWString());
|
return base::FilePath(str.toStdWString());
|
||||||
#else
|
# else
|
||||||
return base::FilePath(str.toStdString());
|
return base::FilePath(str.toStdString());
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void CApplication::initCrashHandler()
|
BlackMisc::CStatusMessageList CApplication::initCrashHandler()
|
||||||
{
|
{
|
||||||
#ifdef BLACK_USE_CRASHPAD
|
#ifdef BLACK_USE_CRASHPAD
|
||||||
// No crash handling for unit tests
|
// No crash handling for unit tests
|
||||||
if (isUnitTest()) { return; }
|
if (isUnitTest()) { return CStatusMessage(this).info("No crash handler for unit tests"); }
|
||||||
|
|
||||||
static const QString extension = CBuildConfig::isRunningOnWindowsNtPlatform() ? ".exe" : QString();
|
static const QString extension = CBuildConfig::isRunningOnWindowsNtPlatform() ? ".exe" : QString();
|
||||||
static const QString handler = CDirectoryUtils::applicationDirectoryPath() + "/" + "swift_crashpad_handler" + extension;
|
static const QString handler = CDirectoryUtils::applicationDirectoryPath() + "/" + "swift_crashpad_handler" + extension;
|
||||||
@@ -1018,8 +1029,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (!QFileInfo::exists(handler))
|
if (!QFileInfo::exists(handler))
|
||||||
{
|
{
|
||||||
CLogMessage(this).warning("%1 not found. Cannot init crash handler!") << handler;
|
return CStatusMessage(this).warning("%1 not found. Cannot init crash handler!") << handler;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrl serverUrl;
|
CUrl serverUrl;
|
||||||
@@ -1037,6 +1047,9 @@ namespace BlackCore
|
|||||||
m_crashpadClient->StartHandler(qstringToFilePath(handler), qstringToFilePath(database),
|
m_crashpadClient->StartHandler(qstringToFilePath(handler), qstringToFilePath(database),
|
||||||
serverUrl.getFullUrl().toStdString(), annotations, {}, false);
|
serverUrl.getFullUrl().toStdString(), annotations, {}, false);
|
||||||
m_crashpadClient->UseHandler();
|
m_crashpadClient->UseHandler();
|
||||||
|
return CStatusMessage(this).info("Using crash handler");
|
||||||
|
#else
|
||||||
|
return CStatusMessage(this).info("Not using crash handler");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -265,11 +265,11 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Init the contexts part and start core facade
|
//! Init the contexts part and start core facade
|
||||||
//! \sa coreFacadeStarted
|
//! \sa coreFacadeStarted
|
||||||
bool useContexts(const CCoreFacadeConfig &coreConfig);
|
BlackMisc::CStatusMessageList useContexts(const CCoreFacadeConfig &coreConfig);
|
||||||
|
|
||||||
//! Init web data services and start them
|
//! Init web data services and start them
|
||||||
//! \sa webDataServicesStarted
|
//! \sa webDataServicesStarted
|
||||||
bool useWebDataServices(const CWebReaderFlags::WebReader webReader, const BlackCore::Db::CDatabaseReaderConfigList &dbReaderConfig);
|
BlackMisc::CStatusMessageList useWebDataServices(const CWebReaderFlags::WebReader webReader, const BlackCore::Db::CDatabaseReaderConfigList &dbReaderConfig);
|
||||||
|
|
||||||
//! Get the facade
|
//! Get the facade
|
||||||
CCoreFacade *getCoreFacade() { return m_coreFacade.data(); }
|
CCoreFacade *getCoreFacade() { return m_coreFacade.data(); }
|
||||||
@@ -344,8 +344,8 @@ namespace BlackCore
|
|||||||
const BlackMisc::CSlot<void(QNetworkReply *)> &callback);
|
const BlackMisc::CSlot<void(QNetworkReply *)> &callback);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Setup available (cache, web load, ..)
|
//! Setup available (cache, web load, ..) or failed to load setup
|
||||||
void setupAvailable(bool success);
|
void setupHandlingCompleted(bool success);
|
||||||
|
|
||||||
//! Update info available (cache, web load)
|
//! Update info available (cache, web load)
|
||||||
void updateInfoAvailable(bool success);
|
void updateInfoAvailable(bool success);
|
||||||
@@ -362,7 +362,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
//! Setup read/synchronized
|
//! Setup read/synchronized
|
||||||
void ps_setupAvailable(bool available);
|
void ps_setupHandlingCompleted(bool available);
|
||||||
|
|
||||||
//! Startup completed
|
//! Startup completed
|
||||||
virtual void ps_startupCompleted();
|
virtual void ps_startupCompleted();
|
||||||
@@ -381,7 +381,7 @@ namespace BlackCore
|
|||||||
virtual bool parsingHookIn() { return true; }
|
virtual bool parsingHookIn() { return true; }
|
||||||
|
|
||||||
//! Can be used to start special services
|
//! Can be used to start special services
|
||||||
virtual bool startHookIn() { return true; }
|
virtual BlackMisc::CStatusMessageList startHookIn() { return BlackMisc::CStatusMessageList(); }
|
||||||
|
|
||||||
//! Flag set or explicitly set to true
|
//! Flag set or explicitly set to true
|
||||||
bool isSetOrTrue(const QCommandLineOption &option) const;
|
bool isSetOrTrue(const QCommandLineOption &option) const;
|
||||||
@@ -393,11 +393,11 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Start the core facade
|
//! Start the core facade
|
||||||
//! \note does nothing when setup is not yet loaded
|
//! \note does nothing when setup is not yet loaded
|
||||||
bool startCoreFacade();
|
BlackMisc::CStatusMessageList startCoreFacadeAndWebDataServices();
|
||||||
|
|
||||||
//! Start the web data services
|
//! Start the web data services
|
||||||
//! \note does nothing when setup is not yet loaded
|
//! \note does nothing when setup is not yet loaded
|
||||||
bool startWebDataServices();
|
BlackMisc::CStatusMessageList startWebDataServices();
|
||||||
|
|
||||||
//! executable name
|
//! executable name
|
||||||
static const QString &executable();
|
static const QString &executable();
|
||||||
@@ -415,7 +415,6 @@ namespace BlackCore
|
|||||||
QCommandLineOption m_cmdClearCache {"clearcache"}; //!< Clear cache
|
QCommandLineOption m_cmdClearCache {"clearcache"}; //!< Clear cache
|
||||||
bool m_parsed = false; //!< Parsing accomplished?
|
bool m_parsed = false; //!< Parsing accomplished?
|
||||||
bool m_started = false; //!< started with success?
|
bool m_started = false; //!< started with success?
|
||||||
bool m_startUpCompleted = false; //!< startup phase completed? Can mean startup failed
|
|
||||||
bool m_startSetupReader = false; //!< start the setup reader
|
bool m_startSetupReader = false; //!< start the setup reader
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -429,7 +428,7 @@ namespace BlackCore
|
|||||||
bool initIsRunningInDeveloperEnvironment() const;
|
bool initIsRunningInDeveloperEnvironment() const;
|
||||||
|
|
||||||
//! Async. start when setup is loaded
|
//! Async. start when setup is loaded
|
||||||
bool asyncWebAndContextStart();
|
BlackMisc::CStatusMessageList asyncWebAndContextStart();
|
||||||
|
|
||||||
//! Implementation for getFromNetwork(), postToNetwork() and headerFromNetwork()
|
//! Implementation for getFromNetwork(), postToNetwork() and headerFromNetwork()
|
||||||
QNetworkReply *httpRequestImpl(const QNetworkRequest &request,
|
QNetworkReply *httpRequestImpl(const QNetworkRequest &request,
|
||||||
@@ -457,7 +456,7 @@ namespace BlackCore
|
|||||||
bool m_autoSaveSettings = true;//!< automatically saving all settings
|
bool m_autoSaveSettings = true;//!< automatically saving all settings
|
||||||
|
|
||||||
// -------------- crashpad -----------------
|
// -------------- crashpad -----------------
|
||||||
void initCrashHandler();
|
BlackMisc::CStatusMessageList initCrashHandler();
|
||||||
void crashDumpUploadEnabledChanged();
|
void crashDumpUploadEnabledChanged();
|
||||||
|
|
||||||
#ifdef BLACK_USE_CRASHPAD
|
#ifdef BLACK_USE_CRASHPAD
|
||||||
|
|||||||
Reference in New Issue
Block a user