status-desktop/src-cpp/app/modules/startup/controller.cpp

56 lines
1.5 KiB
C++
Raw Normal View History

2022-01-06 19:29:19 +00:00
#include "controller.h"
#include "accounts/service_interface.h"
#include "interfaces/module_controller_delegate_interface.h"
#include "signals.h"
#include <QDebug>
namespace Modules
{
namespace Startup
{
2022-01-20 15:50:10 +00:00
Controller::Controller(ModuleControllerDelegateInterface* delegate,
Accounts::ServiceInterface* accountsService,
QObject* parent)
: QObject(parent)
, m_accountsService(accountsService)
, m_delegate(delegate)
2022-01-06 19:29:19 +00:00
{ }
void Controller::init()
{
QObject::connect(Signals::Manager::instance(), &Signals::Manager::nodeLogin, this, &Controller::onLogin);
QObject::connect(Signals::Manager::instance(), &Signals::Manager::nodeStopped, this, &Controller::onNodeStopped);
QObject::connect(Signals::Manager::instance(), &Signals::Manager::nodeReady, this, &Controller::onNodeReady);
2022-01-06 19:29:19 +00:00
}
void Controller::onLogin(Signals::NodeSignal signal)
{
if(signal.error.isEmpty())
{
m_delegate->userLoggedIn();
}
else
{
qWarning() << "error: methodName=init, errDescription=login error " << signal.error;
}
2022-01-06 19:29:19 +00:00
}
void Controller::onNodeStopped(Signals::NodeSignal signal)
{
// self.events.emit("nodeStopped", Args())
m_accountsService->clear();
m_delegate->emitLogOut();
2022-01-06 19:29:19 +00:00
}
void Controller::onNodeReady(Signals::NodeSignal signal)
{
// self.events.emit("nodeReady", Args())
2022-01-06 19:29:19 +00:00
}
bool Controller::shouldStartWithOnboardingScreen()
{
return m_accountsService->openedAccounts().size() == 0;
2022-01-06 19:29:19 +00:00
}
} // namespace Startup
} // namespace Modules