2022-01-06 19:29:19 +00:00
|
|
|
#include "module.h"
|
2022-01-20 15:50:10 +00:00
|
|
|
#include "../interfaces/module_onboarding_delegate_interface.h"
|
2022-01-06 19:29:19 +00:00
|
|
|
#include "accounts/generated_account.h"
|
|
|
|
#include "accounts/service_interface.h"
|
|
|
|
#include "controller.h"
|
|
|
|
#include "singleton.h"
|
|
|
|
#include "view.h"
|
2022-01-20 15:50:10 +00:00
|
|
|
#include <QDebug>
|
2022-01-06 19:29:19 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QQmlContext>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace Modules
|
|
|
|
{
|
|
|
|
namespace Startup
|
|
|
|
{
|
|
|
|
namespace Onboarding
|
|
|
|
{
|
2022-01-20 15:50:10 +00:00
|
|
|
Module::Module(Modules::Startup::ModuleOnboardingDelegateInterface* delegate,
|
2022-02-21 18:03:38 +00:00
|
|
|
Accounts::ServiceInterface* accountsService)
|
|
|
|
: m_delegate(delegate)
|
2022-01-06 19:29:19 +00:00
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_controller = new Controller(this, accountsService);
|
|
|
|
m_view = new View(this);
|
|
|
|
m_moduleLoaded = false;
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Module::~Module()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
delete m_controller;
|
|
|
|
delete m_view;
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::load()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("onboardingModule", m_view);
|
|
|
|
m_controller->init();
|
|
|
|
m_view->load();
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
QVector<Accounts::GeneratedAccountDto> gAcc = m_controller->getGeneratedAccounts();
|
|
|
|
QVector<Item> accounts;
|
|
|
|
foreach(const Accounts::GeneratedAccountDto& acc, gAcc)
|
|
|
|
{
|
|
|
|
accounts << Item(acc.id, acc.alias, acc.identicon, acc.address, acc.keyUid);
|
|
|
|
}
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
m_view->setAccountList(accounts);
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Module::isLoaded()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
return m_moduleLoaded;
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::viewDidLoad()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_moduleLoaded = true;
|
|
|
|
m_delegate->onboardingDidLoad();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::setSelectedAccountByIndex(int index)
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_controller->setSelectedAccountByIndex(index);
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::storeSelectedAccountAndLogin(QString password)
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_controller->storeSelectedAccountAndLogin(password);
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
void Module::setupAccountError()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_view->setupAccountError();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Accounts::GeneratedAccountDto Module::getImportedAccount()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
return m_controller->getImportedAccount();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Module::validateMnemonic(QString mnemonic)
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
return m_controller->validateMnemonic(mnemonic);
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::importMnemonic(QString mnemonic)
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_controller->importMnemonic(mnemonic);
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::importAccountError()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_view->importAccountError();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::importAccountSuccess()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_view->importAccountSuccess();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
} // namespace Onboarding
|
|
|
|
} // namespace Startup
|
2022-02-21 18:03:38 +00:00
|
|
|
} // namespace Modules
|