refactor: Use same mode for all contexts

This commit is contained in:
Lars Toenning
2024-12-23 13:49:24 +01:00
parent 740d1a9590
commit 391c08ce38
7 changed files with 41 additions and 119 deletions

View File

@@ -62,14 +62,7 @@ CStatusMessageList CSwiftGuiStdApplication::startHookIn()
msgs.push_back(m);
}
CCoreFacadeConfig runtimeConfig;
switch (coreMode)
{
case CoreModes::Distributed: runtimeConfig = CCoreFacadeConfig::remote(dBusAddress); break;
default:
case CoreModes::Standalone: runtimeConfig = CCoreFacadeConfig::local(dBusAddress); break;
}
CCoreFacadeConfig runtimeConfig = coreModeToCoreFacadeConfig(coreMode, dBusAddress);
const CStatusMessageList contextMsgs = this->initContextsAndStartCoreFacade(runtimeConfig);
msgs.push_back(contextMsgs);
return contextMsgs;
@@ -95,3 +88,14 @@ CSwiftGuiStdApplication *CSwiftGuiStdApplication::instance()
{
return qobject_cast<CSwiftGuiStdApplication *>(CApplication::instance());
}
CCoreFacadeConfig CSwiftGuiStdApplication::coreModeToCoreFacadeConfig(CoreModes::CoreMode coreMode,
const QString &dBusAddress)
{
switch (coreMode)
{
case CoreModes::Distributed: return CCoreFacadeConfig(CCoreFacadeConfig::Remote, dBusAddress);
case CoreModes::Standalone: return CCoreFacadeConfig(CCoreFacadeConfig::Local, dBusAddress); break;
default: Q_ASSERT_X(false, Q_FUNC_INFO, "Not handled core mode");
}
}

View File

@@ -11,6 +11,7 @@
#include <QObject>
#include <QString>
#include "core/coremodeenums.h"
#include "gui/guiapplication.h"
/*!
@@ -36,6 +37,9 @@ protected:
virtual swift::misc::CStatusMessageList startHookIn() override;
private:
static swift::core::CCoreFacadeConfig coreModeToCoreFacadeConfig(swift::core::CoreModes::CoreMode,
const QString &dBusAddress);
QCommandLineOption m_cmdFacadeMode { { "c", "core" },
QCoreApplication::translate("main", "Core mode: (d)istributed, (s)tandalone."),
"coremode" }; //!< Facade startup mode