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,
|
2022-02-21 18:03:38 +00:00
|
|
|
Accounts::ServiceInterface* accountsService,
|
|
|
|
QObject* parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_accountsService(accountsService)
|
|
|
|
, m_delegate(delegate)
|
2022-01-06 19:29:19 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
void Controller::init()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
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)
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
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)
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
// 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)
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
// self.events.emit("nodeReady", Args())
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Controller::shouldStartWithOnboardingScreen()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
return m_accountsService->openedAccounts().size() == 0;
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
} // namespace Startup
|
2022-02-21 18:03:38 +00:00
|
|
|
} // namespace Modules
|