2022-01-06 19:29:19 +00:00
|
|
|
#include "app_controller.h"
|
|
|
|
#include "accounts/service.h"
|
|
|
|
#include "app_service.h"
|
|
|
|
#include "modules/startup/module.h"
|
2022-01-20 14:48:57 +00:00
|
|
|
#include "modules/main/module.h"
|
2022-01-06 19:29:19 +00:00
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
AppController::AppController()
|
|
|
|
{
|
|
|
|
// result.statusFoundation = statusFoundation
|
|
|
|
|
|
|
|
// # Global
|
|
|
|
// result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
|
|
|
|
// result.localAccountSettingsVariant = newQVariant(singletonInstance.localAccountSettings)
|
|
|
|
// result.localAccountSensitiveSettingsVariant = newQVariant(singletonInstance.localAccountSensitiveSettings)
|
|
|
|
// result.userProfileVariant = newQVariant(singletonInstance.userProfile)
|
|
|
|
// result.globalUtilsVariant = newQVariant(singletonInstance.utils)
|
|
|
|
|
|
|
|
// # Services
|
|
|
|
// result.settingsService = settings_service.newService()
|
|
|
|
// result.nodeConfigurationService = node_configuration_service.newService(statusFoundation.fleetConfiguration,
|
|
|
|
// result.settingsService)
|
|
|
|
// result.osNotificationService = os_notification_service.newService(statusFoundation.status.events)
|
|
|
|
// result.keychainService = keychain_service.newService(statusFoundation.status.events)
|
|
|
|
// result.ethService = eth_service.newService()
|
|
|
|
m_accountsService = new Accounts::Service();
|
|
|
|
// result.networkService = network_service.newService()
|
|
|
|
// result.contactsService = contacts_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
|
|
|
|
// result.chatService = chat_service.newService(statusFoundation.status.events, result.contactsService)
|
|
|
|
// result.communityService = community_service.newService(statusFoundation.status.events)
|
|
|
|
// result.messageService = message_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
|
|
|
|
// result.activityCenterService = activity_center_service.newService(statusFoundation.status.events,
|
|
|
|
// statusFoundation.threadpool, result.chatService)
|
|
|
|
// result.tokenService = token_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
|
|
|
|
// result.settingsService)
|
|
|
|
// result.collectibleService = collectible_service.newService(result.settingsService)
|
|
|
|
// result.walletAccountService = wallet_account_service.newService(statusFoundation.status.events, result.settingsService,
|
|
|
|
// result.accountsService, result.tokenService)
|
|
|
|
// result.transactionService = transaction_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
|
|
|
|
// result.walletAccountService)
|
|
|
|
// result.bookmarkService = bookmark_service.newService()
|
|
|
|
// result.profileService = profile_service.newService()
|
|
|
|
// result.stickersService = stickers_service.newService(
|
|
|
|
// statusFoundation.status.events,
|
|
|
|
// statusFoundation.threadpool,
|
|
|
|
// result.ethService,
|
|
|
|
// result.settingsService,
|
|
|
|
// result.walletAccountService,
|
|
|
|
// result.transactionService,
|
|
|
|
// result.networkService,
|
|
|
|
// result.chatService
|
|
|
|
// )
|
|
|
|
// result.aboutService = about_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
|
|
|
|
// result.settingsService)
|
|
|
|
// result.dappPermissionsService = dapp_permissions_service.newService()
|
|
|
|
// result.languageService = language_service.newService()
|
|
|
|
// # result.mnemonicService = mnemonic_service.newService()
|
|
|
|
// result.privacyService = privacy_service.newService(statusFoundation.status.events, result.settingsService,
|
|
|
|
// result.accountsService)
|
|
|
|
// result.providerService = provider_service.newService(result.dappPermissionsService, result.settingsService)
|
|
|
|
// result.savedAddressService = saved_address_service.newService(statusFoundation.status.events)
|
|
|
|
// result.devicesService = devices_service.newService(statusFoundation.status.events, result.settingsService)
|
|
|
|
// result.mailserversService = mailservers_service.newService(statusFoundation.status.events, statusFoundation.marathon,
|
|
|
|
// result.settingsService, result.nodeConfigurationService, statusFoundation.fleetConfiguration)
|
|
|
|
|
|
|
|
// # Modules
|
|
|
|
m_startupModule = new Modules::Startup::Module(this, /*keychainService,*/ m_accountsService);
|
|
|
|
|
2022-01-20 14:48:57 +00:00
|
|
|
m_mainModule = new Modules::Main::Module(this
|
2022-01-06 19:29:19 +00:00
|
|
|
// statusFoundation.status.events,
|
|
|
|
// result.keychainService,
|
|
|
|
// result.accountsService,
|
|
|
|
// result.chatService,
|
|
|
|
// result.communityService,
|
|
|
|
// result.messageService,
|
|
|
|
// result.tokenService,
|
|
|
|
// result.transactionService,
|
|
|
|
// result.collectibleService,
|
|
|
|
// result.walletAccountService,
|
|
|
|
// result.bookmarkService,
|
|
|
|
// result.profileService,
|
|
|
|
// result.settingsService,
|
|
|
|
// result.contactsService,
|
|
|
|
// result.aboutService,
|
|
|
|
// result.dappPermissionsService,
|
|
|
|
// result.languageService,
|
|
|
|
// # result.mnemonicService,
|
|
|
|
// result.privacyService,
|
|
|
|
// result.providerService,
|
|
|
|
// result.stickersService,
|
|
|
|
// result.activityCenterService,
|
|
|
|
// result.savedAddressService,
|
|
|
|
// result.nodeConfigurationService,
|
|
|
|
// result.devicesService,
|
|
|
|
// result.mailserversService
|
2022-01-20 14:48:57 +00:00
|
|
|
);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
|
|
|
// # Do connections
|
|
|
|
connect();
|
|
|
|
}
|
|
|
|
|
|
|
|
AppController::~AppController()
|
|
|
|
{
|
|
|
|
delete m_startupModule;
|
2022-01-20 14:48:57 +00:00
|
|
|
delete m_mainModule;
|
2022-01-06 19:29:19 +00:00
|
|
|
|
|
|
|
delete m_accountsService;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppController::connect()
|
|
|
|
{
|
|
|
|
// self.statusFoundation.status.events.once("nodeStopped") do(a: Args):
|
|
|
|
// TODO: remove this once accounts are not tracked in the AccountsModel
|
|
|
|
// self.statusFoundation.status.reset()
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppController::startupDidLoad()
|
|
|
|
{
|
|
|
|
// singletonInstance.engine.setRootContextProperty("localAppSettings", self.localAppSettingsVariant)
|
|
|
|
// singletonInstance.engine.setRootContextProperty("localAccountSettings", self.localAccountSettingsVariant)
|
|
|
|
// singletonInstance.engine.load(newQUrl("qrc:///main.qml"))
|
|
|
|
|
|
|
|
// We need to init a language service once qml is loaded
|
|
|
|
// self.languageService.init()
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppController::mainDidLoad()
|
|
|
|
{
|
|
|
|
//self.statusFoundation.onLoggedIn()
|
|
|
|
m_startupModule->moveToAppState();
|
|
|
|
|
|
|
|
//self.mainModule.checkForStoringPassword()
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppController::start()
|
|
|
|
{
|
|
|
|
// self.ethService.init()
|
|
|
|
m_accountsService->init();
|
|
|
|
|
|
|
|
m_startupModule->load();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppController::load()
|
|
|
|
{
|
|
|
|
qWarning() << "TODO: init services and load main module";
|
|
|
|
// self.settingsService.init()
|
|
|
|
// self.nodeConfigurationService.init()
|
|
|
|
// self.contactsService.init()
|
|
|
|
// self.chatService.init()
|
|
|
|
// self.messageService.init()
|
|
|
|
// self.communityService.init()
|
|
|
|
// self.bookmarkService.init()
|
|
|
|
// self.tokenService.init()
|
|
|
|
// self.dappPermissionsService.init()
|
|
|
|
// self.providerService.init()
|
|
|
|
// self.walletAccountService.init()
|
|
|
|
// self.transactionService.init()
|
|
|
|
// self.stickersService.init()
|
|
|
|
// self.networkService.init()
|
|
|
|
// self.activityCenterService.init()
|
|
|
|
// self.savedAddressService.init()
|
|
|
|
// self.aboutService.init()
|
|
|
|
// self.devicesService.init()
|
|
|
|
// self.mailserversService.init()
|
|
|
|
|
|
|
|
// let pubKey = self.settingsService.getPublicKey()
|
|
|
|
// singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)
|
|
|
|
// singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant)
|
|
|
|
// singletonInstance.engine.setRootContextProperty("globalUtils", self.globalUtilsVariant)
|
|
|
|
|
|
|
|
// # other global instances
|
|
|
|
// self.buildAndRegisterLocalAccountSensitiveSettings()
|
|
|
|
// self.buildAndRegisterUserProfile()
|
|
|
|
|
|
|
|
// # load main module
|
2022-01-20 14:48:57 +00:00
|
|
|
m_mainModule->load(
|
|
|
|
// self.statusFoundation.status.events,
|
|
|
|
// self.settingsService,
|
|
|
|
// self.contactsService,
|
|
|
|
// self.chatService,
|
|
|
|
// self.communityService,
|
|
|
|
// self.messageService
|
|
|
|
);
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppController::userLoggedIn()
|
|
|
|
{
|
|
|
|
//self.statusFoundation.status.startMessenger()
|
|
|
|
AppController::load();
|
|
|
|
|
|
|
|
// Once user is logged in and main module is loaded we need to check if it gets here importing mnemonic or not
|
|
|
|
// and delete mnemonic in the first case.
|
|
|
|
auto importedAccount = m_accountsService->getImportedAccount();
|
|
|
|
if(importedAccount.isValid())
|
|
|
|
{
|
|
|
|
// self.privacyService.removeMnemonic();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppController::buildAndRegisterLocalAccountSensitiveSettings()
|
|
|
|
{
|
|
|
|
|
|
|
|
// var pubKey = self.settingsService.getPublicKey()
|
|
|
|
// singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)
|
|
|
|
// singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant)
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppController::buildAndRegisterUserProfile()
|
|
|
|
{
|
|
|
|
// let pubKey = self.settingsService.getPublicKey()
|
|
|
|
// let preferredName = self.settingsService.getPreferredName()
|
|
|
|
// let ensUsernames = self.settingsService.getEnsUsernames()
|
|
|
|
// let firstEnsName = if (ensUsernames.len > 0): ensUsernames[0] else: ""
|
|
|
|
// let sendUserStatus = self.settingsService.getSendStatusUpdates()
|
|
|
|
// // This is still not in use. Read a comment in UserProfile.
|
|
|
|
// // let currentUserStatus = self.settingsService.getCurrentUserStatus()
|
|
|
|
|
|
|
|
// let loggedInAccount = self.accountsService.getLoggedInAccount()
|
|
|
|
// var thumbnail, large: string
|
|
|
|
// for img in loggedInAccount.images:
|
|
|
|
// if(img.imgType == "large"):
|
|
|
|
// large = img.uri
|
|
|
|
// elif(img.imgType == "thumbnail"):
|
|
|
|
// thumbnail = img.uri
|
|
|
|
|
|
|
|
// let meAsContact = self.contactsService.getContactById(pubKey)
|
|
|
|
|
|
|
|
// singletonInstance.userProfile.setFixedData(loggedInAccount.name, loggedInAccount.keyUid, loggedInAccount.identicon,
|
|
|
|
// pubKey)
|
|
|
|
// singletonInstance.userProfile.setPreferredName(preferredName)
|
|
|
|
// singletonInstance.userProfile.setEnsName(meAsContact.name)
|
|
|
|
// singletonInstance.userProfile.setFirstEnsName(firstEnsName)
|
|
|
|
// singletonInstance.userProfile.setThumbnailImage(thumbnail)
|
|
|
|
// singletonInstance.userProfile.setLargeImage(large)
|
|
|
|
// singletonInstance.userProfile.setUserStatus(sendUserStatus)
|
|
|
|
|
|
|
|
// singletonInstance.engine.setRootContextProperty("userProfile", self.userProfileVariant)
|
|
|
|
}
|