From 2aa5ed431f5abd0449466d4fff45ac73d372140e Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 10 Oct 2017 00:16:27 +0100 Subject: [PATCH] Ref T167, utility functions in CCoreFacadeConfig and better check in SwiftGuiStd::displayDBusReconnectDialog --- src/blackcore/application.h | 3 +++ src/blackcore/corefacadeconfig.cpp | 29 +++++++++++++++++++++------- src/blackcore/corefacadeconfig.h | 9 +++++++++ src/swiftguistandard/swiftguistd.cpp | 6 ++++-- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 22ce3d41a..9b1c9a9ff 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -343,6 +343,9 @@ namespace BlackCore //! \sa m_useContexts we use or we will use contexts bool supportsContexts() const; + //! The core facade config + const CCoreFacadeConfig &getCoreFacadeConfig() const { return m_coreFacadeConfig; } + //! Init the contexts part and start core facade //! \sa coreFacadeStarted //! \remark requires setup loaded diff --git a/src/blackcore/corefacadeconfig.cpp b/src/blackcore/corefacadeconfig.cpp index 72e505d1a..f3c1c13e7 100644 --- a/src/blackcore/corefacadeconfig.cpp +++ b/src/blackcore/corefacadeconfig.cpp @@ -26,22 +26,37 @@ namespace BlackCore bool CCoreFacadeConfig::requiresDBusConnection() const { - return (this->m_application == Remote || - this->m_audio == Remote || - this->m_network == Remote || - this->m_ownAircraft == Remote || - this->m_simulator == Remote); + return this->any(Remote); + } + + bool CCoreFacadeConfig::any(CCoreFacadeConfig::ContextMode mode) const + { + return (this->m_application == mode || + this->m_audio == mode || + this->m_network == mode || + this->m_ownAircraft == mode || + this->m_simulator == mode); + } + + bool CCoreFacadeConfig::anyRemote() const + { + return this->any(Remote); + } + + bool CCoreFacadeConfig::anyLocalInDBusServer() const + { + return this->any(LocalInDBusServer); } CCoreFacadeConfig CCoreFacadeConfig::forCoreAllLocalInDBus(const QString &dbusBootstrapAddress) { - const CCoreFacadeConfig cfg(CCoreFacadeConfig::LocalInDbusServer, dbusBootstrapAddress); + const CCoreFacadeConfig cfg(CCoreFacadeConfig::LocalInDBusServer, dbusBootstrapAddress); return cfg; } CCoreFacadeConfig CCoreFacadeConfig::forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress) { - CCoreFacadeConfig cfg(CCoreFacadeConfig::LocalInDbusServer, dbusBootstrapAddress); + CCoreFacadeConfig cfg(CCoreFacadeConfig::LocalInDBusServer, dbusBootstrapAddress); cfg.m_audio = CCoreFacadeConfig::NotUsed; return cfg; } diff --git a/src/blackcore/corefacadeconfig.h b/src/blackcore/corefacadeconfig.h index e3dcdea60..8890f1199 100644 --- a/src/blackcore/corefacadeconfig.h +++ b/src/blackcore/corefacadeconfig.h @@ -86,6 +86,15 @@ namespace BlackCore //! DBus address? bool hasDBusAddress() const { return !this->m_dbusAddress.isEmpty(); } + //! Any context in given mode + bool any(ContextMode mode) const; + + //! Any remote context? + bool anyRemote() const; + + //! Any local in DBus context? + bool anyLocalInDBusServer() const; + //! Predefined for Core static CCoreFacadeConfig forCoreAllLocalInDBus(const QString &dbusBootstrapAddress = ""); diff --git a/src/swiftguistandard/swiftguistd.cpp b/src/swiftguistandard/swiftguistd.cpp index 8d0c282f1..bacb3ecb2 100644 --- a/src/swiftguistandard/swiftguistd.cpp +++ b/src/swiftguistandard/swiftguistd.cpp @@ -13,6 +13,7 @@ #include "blackcore/context/contextsimulator.h" #include "blackcore/network.h" #include "blackcore/webdataservices.h" +#include "blackcore/corefacadeconfig.h" #include "blackgui/components/infobarstatuscomponent.h" #include "blackgui/components/logcomponent.h" #include "blackgui/components/settingscomponent.h" @@ -447,12 +448,13 @@ void SwiftGuiStd::displayLog() void SwiftGuiStd::displayDBusReconnectDialog() { + if (m_displayingDBusReconnect) { return; } if (!sGui || sGui->isShuttingDown()) { return; } if (!sGui->getCoreFacade()) { return; } - if (m_displayingDBusReconnect) { return; } + if (!sGui->getCoreFacadeConfig().requiresDBusConnection()) { return; } m_displayingDBusReconnect = true; const QString dBusAddress = sGui->getCoreFacade()->getDBusAddress(); - static const QString informativeText("Do you want to try to reconnect? 'Abort' will close the GUI. DBus: '%1'"); + static const QString informativeText("Do you want to try to reconnect? 'Abort' will close the GUI.\n\nDBus: '%1'"); QMessageBox msgBox(this); msgBox.setIcon(QMessageBox::Critical); msgBox.setText("swift core not reachable!");