mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
refactor: Add separate swift data application
This commit is contained in:
@@ -7,6 +7,8 @@ add_executable(swiftdata WIN32
|
|||||||
swiftdata.h
|
swiftdata.h
|
||||||
swiftdata.ui
|
swiftdata.ui
|
||||||
swiftdatamenus.cpp
|
swiftdatamenus.cpp
|
||||||
|
swiftdataapplication.cpp
|
||||||
|
swiftdataapplication.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "misc/crashhandler.h"
|
#include "misc/crashhandler.h"
|
||||||
#include "misc/icons.h"
|
#include "misc/icons.h"
|
||||||
#include "swiftdata.h"
|
#include "swiftdata.h"
|
||||||
|
#include "swiftdataapplication.h"
|
||||||
|
|
||||||
using namespace swift::misc;
|
using namespace swift::misc;
|
||||||
using namespace swift::core;
|
using namespace swift::core;
|
||||||
@@ -23,19 +24,25 @@ int main(int argc, char *argv[])
|
|||||||
Q_UNUSED(qa)
|
Q_UNUSED(qa)
|
||||||
|
|
||||||
CCrashHandler::instance()->init();
|
CCrashHandler::instance()->init();
|
||||||
CGuiApplication a(CApplicationInfo::swiftMappingTool(), CApplicationInfo::MappingTool, CIcons::swiftDatabase48());
|
|
||||||
if (!a.parseCommandLineArgsAndLoadSetup()) { return EXIT_FAILURE; }
|
int r = 0;
|
||||||
a.splashScreen(CIcons::swiftDatabase256());
|
|
||||||
a.initAndStartWebDataServices(swift::core::CWebReaderFlags::AllSwiftDbReaders,
|
|
||||||
CDatabaseReaderConfigList::forMappingTool());
|
|
||||||
a.startCoreFacadeWithoutContexts();
|
|
||||||
if (!a.start())
|
|
||||||
{
|
{
|
||||||
a.gracefulShutdown();
|
// CGuiApplication a(CApplicationInfo::swiftMappingTool(), CApplicationInfo::MappingTool,
|
||||||
return EXIT_FAILURE;
|
// CIcons::swiftDatabase48());
|
||||||
|
CSwiftDataApplication a; // application with contexts
|
||||||
|
if (!a.parseCommandLineArgsAndLoadSetup()) { return EXIT_FAILURE; }
|
||||||
|
a.splashScreen(CIcons::swiftDatabase256());
|
||||||
|
a.initAndStartWebDataServices(swift::core::CWebReaderFlags::AllSwiftDbReaders,
|
||||||
|
CDatabaseReaderConfigList::forMappingTool());
|
||||||
|
a.startCoreFacadeWithoutContexts();
|
||||||
|
if (!a.start())
|
||||||
|
{
|
||||||
|
a.gracefulShutdown();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
CSwiftData w;
|
||||||
|
w.show();
|
||||||
|
r = a.exec();
|
||||||
}
|
}
|
||||||
CSwiftData w;
|
|
||||||
w.show();
|
|
||||||
int r = a.exec();
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Ui
|
|||||||
namespace swift::core
|
namespace swift::core
|
||||||
{
|
{
|
||||||
class CWebDataServices;
|
class CWebDataServices;
|
||||||
}
|
} // namespace swift::core
|
||||||
namespace swift::gui::components
|
namespace swift::gui::components
|
||||||
{
|
{
|
||||||
class CAutoPublishDialog;
|
class CAutoPublishDialog;
|
||||||
|
|||||||
61
src/swiftdata/swiftdataapplication.cpp
Normal file
61
src/swiftdata/swiftdataapplication.cpp
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
#include "swiftdataapplication.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "core/corefacadeconfig.h"
|
||||||
|
#include "core/coremodeenums.h"
|
||||||
|
#include "misc/dbusserver.h"
|
||||||
|
#include "misc/icons.h"
|
||||||
|
|
||||||
|
using namespace swift::misc;
|
||||||
|
using namespace swift::core;
|
||||||
|
|
||||||
|
CSwiftDataApplication::CSwiftDataApplication()
|
||||||
|
: CGuiApplication(CApplicationInfo::swiftMappingTool(), CApplicationInfo::MappingTool, CIcons::swiftDatabase48())
|
||||||
|
{
|
||||||
|
// this->addParserOption(m_cmdFacadeMode);
|
||||||
|
// this->addDBusAddressOption();
|
||||||
|
// this->addNetworkOptions();
|
||||||
|
// this->addAudioOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
CStatusMessageList CSwiftDataApplication::startHookIn()
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed cmd line arguments");
|
||||||
|
|
||||||
|
QString dBusAddress(this->getCmdDBusAddressValue());
|
||||||
|
const QString coreModeStr =
|
||||||
|
this->isParserOptionSet(m_cmdFacadeMode) ? this->getParserValue(m_cmdFacadeMode) : QString();
|
||||||
|
CoreModes::CoreMode coreMode = CoreModes::stringToCoreMode(coreModeStr);
|
||||||
|
|
||||||
|
CStatusMessageList msgs;
|
||||||
|
|
||||||
|
CCoreFacadeConfig runtimeConfig = coreModeToCoreFacadeConfig(coreMode, dBusAddress);
|
||||||
|
const CStatusMessageList contextMsgs = this->initContextsAndStartCoreFacade(runtimeConfig);
|
||||||
|
msgs.push_back(contextMsgs);
|
||||||
|
return contextMsgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSwiftDataApplication::parsingHookIn() { return CGuiApplication::parsingHookIn(); }
|
||||||
|
|
||||||
|
CSwiftDataApplication *CSwiftDataApplication::instance()
|
||||||
|
{
|
||||||
|
return qobject_cast<CSwiftDataApplication *>(CApplication::instance());
|
||||||
|
}
|
||||||
|
|
||||||
|
CCoreFacadeConfig CSwiftDataApplication::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");
|
||||||
|
return CCoreFacadeConfig(CCoreFacadeConfig::NotUsed, dBusAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/swiftdata/swiftdataapplication.h
Normal file
48
src/swiftdata/swiftdataapplication.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef SWIFTDATAAPPLICATION_H
|
||||||
|
#define SWIFTDATAAPPLICATION_H
|
||||||
|
|
||||||
|
#include <QCommandLineOption>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "core/coremodeenums.h"
|
||||||
|
#include "gui/guiapplication.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Specialized GUI application for swift pilot client.
|
||||||
|
* Handles parsing of some specialized CMD line argumenets and startup of core
|
||||||
|
*/
|
||||||
|
class CSwiftDataApplication : public swift::gui::CGuiApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
CSwiftDataApplication();
|
||||||
|
|
||||||
|
//! Single instance
|
||||||
|
CSwiftDataApplication *instance();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Parsing of special CMD args
|
||||||
|
virtual bool parsingHookIn() override;
|
||||||
|
|
||||||
|
//! Start facade by cmd arguments
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SWIFTDATAAPPLICATION_H
|
||||||
Reference in New Issue
Block a user