2022-01-06 19:29:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "account.h"
|
|
|
|
#include "generated_account.h"
|
|
|
|
#include "service_interface.h"
|
2022-02-22 08:02:34 +00:00
|
|
|
|
2022-01-06 19:29:19 +00:00
|
|
|
#include <QString>
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
namespace Accounts
|
|
|
|
{
|
|
|
|
class Service : public ServiceInterface
|
|
|
|
{
|
|
|
|
private:
|
2022-02-21 18:03:38 +00:00
|
|
|
QVector<GeneratedAccountDto> m_generatedAccounts;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
bool m_isFirstTimeAccountLogin = false;
|
2022-02-21 18:03:38 +00:00
|
|
|
AccountDto m_loggedInAccount;
|
|
|
|
GeneratedAccountDto m_importedAccount;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
|
|
|
public:
|
2022-02-21 18:03:38 +00:00
|
|
|
void init() override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QVector<AccountDto> openedAccounts() override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
QVector<GeneratedAccountDto> generatedAccounts() override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
bool setupAccount(const QString& accountId, const QString& password) override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
AccountDto getLoggedInAccount() override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
GeneratedAccountDto getImportedAccount() override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
bool isFirstTimeAccountLogin() override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QString validateMnemonic(const QString& mnemonic) override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
bool importMnemonic(const QString& mnemonic) override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QString login(const AccountDto& account, const QString& password) override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
void clear() override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QString generateAlias(const QString& publicKey) override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QString generateIdenticon(const QString& publicKey) override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
bool verifyAccountPassword(const QString& account, const QString& password) override;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
DerivedAccounts
|
|
|
|
storeDerivedAccounts(const QString& accountId, const QString& hashedPassword, const QVector<QString>& paths);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QJsonObject getAccountDataForAccountId(const QString& accountId);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QJsonArray getSubaccountDataForAccountId(const QString& accountId);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QJsonObject getAccountSettings(const QString& accountId, const QString& installationId);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
AccountDto saveAccountAndLogin(const QString& hashedPassword,
|
|
|
|
const QJsonObject& account,
|
|
|
|
const QJsonArray& subaccounts,
|
|
|
|
const QJsonObject& settings,
|
|
|
|
const QJsonObject& config);
|
2022-01-06 19:29:19 +00:00
|
|
|
};
|
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
} // namespace Accounts
|