refactor(general): old `AppService` is renamed to `StatusFoundation`

`AppService` is renamed to `StatusFoundation` cause it doesn't contain
any more anything related to services. And it is moved to other location
`/src/app/core`. It contains a foundation for the app.

This part will rarely change
This commit is contained in:
Sale Djenic 2021-11-17 14:13:20 +01:00
parent e72b2d1007
commit 1ccc98af98
34 changed files with 306 additions and 239 deletions

View File

@ -67,7 +67,7 @@ proc changeLanguage(locale: string) =
type type
AppController* = ref object of RootObj AppController* = ref object of RootObj
appService: AppService statusFoundation: StatusFoundation
# Global # Global
localAppSettingsVariant: QVariant localAppSettingsVariant: QVariant
localAccountSettingsVariant: QVariant localAccountSettingsVariant: QVariant
@ -126,14 +126,14 @@ proc mainDidLoad*(self: AppController)
# At the end of refactoring this will be moved to # At the end of refactoring this will be moved to
# appropriate place or removed: # appropriate place or removed:
proc connect(self: AppController) = proc connect(self: AppController) =
self.appService.status.events.once("loginCompleted") do(a: Args): self.statusFoundation.status.events.once("loginCompleted") do(a: Args):
var args = AccountArgs(a) var args = AccountArgs(a)
self.profile.init(args.account) self.profile.init(args.account)
################################################# #################################################
proc newAppController*(appService: AppService): AppController = proc newAppController*(statusFoundation: StatusFoundation): AppController =
result = AppController() result = AppController()
result.appService = appService result.statusFoundation = statusFoundation
# Global # Global
result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings) result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
@ -142,21 +142,21 @@ proc newAppController*(appService: AppService): AppController =
result.userProfileVariant = newQVariant(singletonInstance.userProfile) result.userProfileVariant = newQVariant(singletonInstance.userProfile)
# Services # Services
result.osNotificationService = os_notification_service.newService(appService.status.events) result.osNotificationService = os_notification_service.newService(statusFoundation.status.events)
result.keychainService = keychain_service.newService(appService.status.events) result.keychainService = keychain_service.newService(statusFoundation.status.events)
result.settingService = setting_service.newService() result.settingService = setting_service.newService()
result.settingsService = settings_service.newService() result.settingsService = settings_service.newService()
result.accountsService = accounts_service.newService() result.accountsService = accounts_service.newService()
result.contactsService = contacts_service.newService(appService.status.events, appService.threadpool) result.contactsService = contacts_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
result.chatService = chat_service.newService(result.contactsService) result.chatService = chat_service.newService(result.contactsService)
result.communityService = community_service.newService(result.chatService) result.communityService = community_service.newService(result.chatService)
result.messageService = message_service.newService(appService.status.events, appService.threadpool) result.messageService = message_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
result.tokenService = token_service.newService(appService.status.events, appService.threadpool, result.settingService, result.tokenService = token_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
result.settingsService) result.settingService, result.settingsService)
result.collectibleService = collectible_service.newService(result.settingService) result.collectibleService = collectible_service.newService(result.settingService)
result.walletAccountService = wallet_account_service.newService(appService.status.events, result.settingService, result.walletAccountService = wallet_account_service.newService(statusFoundation.status.events, result.settingService,
result.tokenService) result.tokenService)
result.transactionService = transaction_service.newService(appService.status.events, appService.threadpool, result.transactionService = transaction_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
result.walletAccountService) result.walletAccountService)
result.bookmarkService = bookmark_service.newService() result.bookmarkService = bookmark_service.newService()
result.profileService = profile_service.newService() result.profileService = profile_service.newService()
@ -171,14 +171,14 @@ proc newAppController*(appService: AppService): AppController =
# Modules # Modules
result.startupModule = startup_module.newModule[AppController]( result.startupModule = startup_module.newModule[AppController](
result, result,
appService.status.events, statusFoundation.status.events,
appService.status.fleet, statusFoundation.status.fleet,
result.keychainService, result.keychainService,
result.accountsService result.accountsService
) )
result.mainModule = main_module.newModule[AppController]( result.mainModule = main_module.newModule[AppController](
result, result,
appService.status.events, statusFoundation.status.events,
result.keychainService, result.keychainService,
result.accountsService, result.accountsService,
result.chatService, result.chatService,
@ -204,18 +204,18 @@ proc newAppController*(appService: AppService): AppController =
################################################# #################################################
# At the end of refactoring this will be moved to # At the end of refactoring this will be moved to
# appropriate place or removed: # appropriate place or removed:
result.profile = profile.newController(appService.status, appService, changeLanguage) result.profile = profile.newController(statusFoundation.status, statusFoundation, changeLanguage)
result.connect() result.connect()
################################################# #################################################
# Adding status and appService here now is just because of having a controll # Adding status and statusFoundation here now is just because of having a controll
# over order of execution while we integrating this refactoring architecture # over order of execution while we integrating this refactoring architecture
# into the current app state. # into the current app state.
# Once we complete refactoring process we will get rid of "status" part/lib. # Once we complete refactoring process we will get rid of "status" part/lib.
# #
# This to will be adapted to appropriate modules later: # This to will be adapted to appropriate modules later:
# result.login = login.newController(appService.status, appService) # result.login = login.newController(statusFoundation.status, statusFoundation)
# result.onboarding = onboarding.newController(appService.status) # result.onboarding = onboarding.newController(statusFoundation.status)
# singletonInstance.engine.setRootContextProperty("loginModel", result.login.variant) # singletonInstance.engine.setRootContextProperty("loginModel", result.login.variant)
# singletonInstance.engine.setRootContextProperty("onboardingModel", result.onboarding.variant) # singletonInstance.engine.setRootContextProperty("onboardingModel", result.onboarding.variant)
#result.connect() #result.connect()
@ -269,7 +269,7 @@ proc startupDidLoad*(self: AppController) =
setLanguage(locale) setLanguage(locale)
proc mainDidLoad*(self: AppController) = proc mainDidLoad*(self: AppController) =
self.appService.onLoggedIn() self.statusFoundation.onLoggedIn()
self.startupModule.moveToAppState() self.startupModule.moveToAppState()
self.mainModule.checkForStoringPassword() self.mainModule.checkForStoringPassword()
@ -279,8 +279,14 @@ proc start*(self: AppController) =
self.startupModule.load() self.startupModule.load()
proc load(self: AppController) = proc load*(self: AppController) =
# init services which are available only if a user is logged in #################################################
# Once SettingService gets added, `pubKey` should be fetched from there, instead the following line:
let pubKey = self.statusFoundation.status.settings.getSetting[:string](Setting.PublicKey, "0x0")
singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)
singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant)
#################################################
self.settingService.init() self.settingService.init()
self.contactsService.init() self.contactsService.init()
self.chatService.init() self.chatService.init()
@ -300,14 +306,14 @@ proc load(self: AppController) =
self.buildAndRegisterUserProfile() self.buildAndRegisterUserProfile()
# load main module # load main module
self.mainModule.load(self.appService.status.events, self.chatService, self.communityService, self.messageService) self.mainModule.load(self.statusFoundation.status.events, self.chatService, self.communityService, self.messageService)
proc userLoggedIn*(self: AppController) = proc userLoggedIn*(self: AppController) =
################################################# #################################################
# At the end of refactoring this will be removed: # At the end of refactoring this will be removed:
let loggedInUser = self.accountsService.getLoggedInAccount() let loggedInUser = self.accountsService.getLoggedInAccount()
let account = Account(name: loggedInUser.name, keyUid: loggedInUser.keyUid) let account = Account(name: loggedInUser.name, keyUid: loggedInUser.keyUid)
self.appService.status.events.emit("loginCompleted", AccountArgs(account: account)) self.statusFoundation.status.events.emit("loginCompleted", AccountArgs(account: account))
################################################# #################################################
self.load() self.load()

View File

@ -14,15 +14,15 @@ type ChatController* = ref object
view*: ChatsView view*: ChatsView
status*: Status status*: Status
variant*: QVariant variant*: QVariant
appService: AppService statusFoundation: StatusFoundation
uriToOpen: string uriToOpen: string
proc newController*(status: Status, appService: AppService, uriToOpen: string): ChatController = proc newController*(status: Status, statusFoundation: StatusFoundation, uriToOpen: string): ChatController =
result = ChatController() result = ChatController()
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.uriToOpen = uriToOpen result.uriToOpen = uriToOpen
result.view = newChatsView(status, appService) result.view = newChatsView(status, statusFoundation)
result.variant = newQVariant(result.view) result.variant = newQVariant(result.view)
proc delete*(self: ChatController) = proc delete*(self: ChatController) =

View File

@ -184,7 +184,16 @@ proc handleChatEvents(self: ChatController) =
self.view.communities.markNotificationsAsRead(markAsReadProps) self.view.communities.markNotificationsAsRead(markAsReadProps)
proc handleMailserverEvents(self: ChatController) = proc handleMailserverEvents(self: ChatController) =
let mailserverWorker = self.appService.marathon[MailserverWorker().name] let mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
# TODO: test mailserver topics when joining chat
self.status.events.on("channelJoined") do(e:Args):
let task = IsActiveMailserverAvailableTaskArg(
`method`: "isActiveMailserverAvailable",
vptr: cast[ByteAddress](self.view.vptr),
slot: "isActiveMailserverResult"
)
mailserverWorker.start(task)
self.status.events.on("mailserverAvailable") do(e:Args): self.status.events.on("mailserverAvailable") do(e:Args):
self.view.messageView.setLoadingMessages(true) self.view.messageView.setLoadingMessages(true)
let task = RequestMessagesTaskArg( let task = RequestMessagesTaskArg(

View File

@ -6,6 +6,27 @@ proc handleSignals(self: ChatController) =
var data = MessageSignal(e) var data = MessageSignal(e)
self.status.chat.update(data.chats, data.messages, data.emojiReactions, data.communities, data.membershipRequests, data.pinnedMessages, data.activityCenterNotification, data.statusUpdates, data.deletedMessages) self.status.chat.update(data.chats, data.messages, data.emojiReactions, data.communities, data.membershipRequests, data.pinnedMessages, data.activityCenterNotification, data.statusUpdates, data.deletedMessages)
self.status.events.on(SignalType.DiscoverySummary.event) do(e:Args):
## Handle mailserver peers being added and removed
var data = DiscoverySummarySignal(e)
let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = PeerSummaryChangeTaskArg(
`method`: "peerSummaryChange",
peers: data.enodes
)
mailserverWorker.start(task)
self.status.events.on(SignalType.PeerStats.event) do(e:Args):
var data = PeerStatsSignal(e)
let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = PeerSummaryChangeTaskArg(
`method`: "peerSummaryChange",
peers: data.peers
)
mailserverWorker.start(task)
self.status.events.on(SignalType.EnvelopeSent.event) do(e:Args): self.status.events.on(SignalType.EnvelopeSent.event) do(e:Args):
var data = EnvelopeSentSignal(e) var data = EnvelopeSentSignal(e)
self.status.messages.updateStatus(data.messageIds) self.status.messages.updateStatus(data.messageIds)
@ -21,22 +42,12 @@ proc handleSignals(self: ChatController) =
var data = CommunitySignal(e) var data = CommunitySignal(e)
self.view.communities.addCommunityToList(data.community) self.view.communities.addCommunityToList(data.community)
self.status.events.on(SignalType.HistoryRequestStarted.event) do(e:Args): self.status.events.on(SignalType.MailserverRequestCompleted.event) do(e:Args):
self.view.messageView.setLoadingMessages(true) # TODO: if the signal contains a cursor, request additional messages
# else:
self.view.hideLoadingIndicator()
self.status.events.on(SignalType.HistoryRequestCompleted.event) do(e:Args): self.status.events.on(SignalType.MailserverRequestExpired.event) do(e:Args):
self.view.messageView.setLoadingMessages(false) # TODO: retry mailserver request up to N times or change mailserver
# If > N, then
self.status.events.on(SignalType.HistoryRequestFailed.event) do(e:Args): self.view.hideLoadingIndicator()
self.view.messageView.setLoadingMessages(false)
let mailserverWorker = self.appService.marathon[MailserverWorker().name]
self.status.events.on(SignalType.MailserverAvailable.event) do(e:Args):
var data = MailserverAvailableSignal(e)
info "active mailserver changed", node=data.address, topics="mailserver-interaction"
self.view.messageView.setLoadingMessages(true)
let task = RequestMessagesTaskArg(
`method`: "requestMessages",
vptr: cast[ByteAddress](self.view.vptr)
)
mailserverWorker.start(task)

View File

@ -3,6 +3,7 @@ import status/[status]
import status/utils as status_utils import status/utils as status_utils
import status/chat as status_chat import status/chat as status_chat
import status/messages as status_messages import status/messages as status_messages
import status/mailservers
import status/contacts as status_contacts import status/contacts as status_contacts
import status/ens as status_ens import status/ens as status_ens
import status/chat/[chat] import status/chat/[chat]
@ -43,7 +44,7 @@ proc getLinkPreviewData[T](self: T, slot: string, link: string, uuid: string) =
link: link, link: link,
uuid: uuid uuid: uuid
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
const asyncActivityNotificationLoadTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const asyncActivityNotificationLoadTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[AsyncActivityNotificationLoadTaskArg](argEncoded) let arg = decode[AsyncActivityNotificationLoadTaskArg](argEncoded)
@ -64,13 +65,13 @@ proc asyncActivityNotificationLoad[T](self: T, slot: string) =
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot slot: slot
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type type
ChatsView* = ref object of QAbstractListModel ChatsView* = ref object of QAbstractListModel
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
formatInputView: FormatInputView formatInputView: FormatInputView
ensView: EnsView ensView: EnsView
channelView*: ChannelView channelView*: ChannelView
@ -85,6 +86,7 @@ QtObject:
communities*: CommunitiesView communities*: CommunitiesView
replyTo: string replyTo: string
connected: bool connected: bool
timelineChat: Chat
pubKey*: string pubKey*: string
proc setup(self: ChatsView) = self.QAbstractListModel.setup proc setup(self: ChatsView) = self.QAbstractListModel.setup
@ -101,16 +103,16 @@ QtObject:
self.communities.delete self.communities.delete
self.QAbstractListModel.delete self.QAbstractListModel.delete
proc newChatsView*(status: Status, appService: AppService): ChatsView = proc newChatsView*(status: Status, statusFoundation: StatusFoundation): ChatsView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.formatInputView = newFormatInputView() result.formatInputView = newFormatInputView()
result.ensView = newEnsView(status, appService) result.ensView = newEnsView(status, statusFoundation)
result.communities = newCommunitiesView(status) result.communities = newCommunitiesView(status)
result.activityNotificationList = newActivityNotificationList(status) result.activityNotificationList = newActivityNotificationList(status)
result.channelView = newChannelView(status, appService, result.communities, result.activityNotificationList) result.channelView = newChannelView(status, statusFoundation, result.communities, result.activityNotificationList)
result.messageView = newMessageView(status, appService, result.channelView, result.communities) result.messageView = newMessageView(status, statusFoundation, result.channelView, result.communities)
result.connected = false result.connected = false
result.reactions = newReactionView( result.reactions = newReactionView(
status, status,
@ -118,7 +120,7 @@ QtObject:
result.messageView.pinnedMessagesList.addr, result.messageView.pinnedMessagesList.addr,
result.channelView.activeChannel result.channelView.activeChannel
) )
result.stickers = newStickersView(status, appService, result.channelView.activeChannel) result.stickers = newStickersView(status, statusFoundation, result.channelView.activeChannel)
result.gif = newGifView() result.gif = newGifView()
result.groups = newGroupsView(status,result.channelView.activeChannel) result.groups = newGroupsView(status,result.channelView.activeChannel)
result.transactions = newTransactionsView(status) result.transactions = newTransactionsView(status)
@ -207,18 +209,6 @@ QtObject:
return status_ens.userNameOrAlias(self.status.chat.getContacts()[pubKey]) return status_ens.userNameOrAlias(self.status.chat.getContacts()[pubKey])
generateAlias(pubKey) generateAlias(pubKey)
proc getProfileThumbnail*(self: ChatsView, pubKey: string): string {.slot.} =
if self.status.chat.getContacts().hasKey(pubKey):
return self.status.chat.getContacts()[pubKey].identityImage.thumbnail
else:
return ""
proc getProfileImageLarge*(self: ChatsView, pubKey: string): string {.slot.} =
if self.status.chat.getContacts().hasKey(pubKey):
return self.status.chat.getContacts()[pubKey].identityImage.large
else:
return ""
proc activityNotificationsChanged*(self: ChatsView) {.signal.} proc activityNotificationsChanged*(self: ChatsView) {.signal.}
proc getActivityNotificationList(self: ChatsView): QVariant {.slot.} = proc getActivityNotificationList(self: ChatsView): QVariant {.slot.} =
@ -242,6 +232,12 @@ QtObject:
self.activityNotificationList.addActivityNotificationItemToList(activityCenterNotification) self.activityNotificationList.addActivityNotificationItemToList(activityCenterNotification)
self.activityNotificationsChanged() self.activityNotificationsChanged()
proc setActiveChannelToTimeline*(self: ChatsView) {.slot.} =
if not self.channelView.activeChannel.chatItem.isNil:
self.channelView.previousActiveChannelIndex = self.channelView.chats.chats.findIndexById(self.channelView.activeChannel.id)
self.channelView.activeChannel.setChatItem(self.timelineChat)
self.activeChannelChanged()
proc updateUsernames*(self:ChatsView, contacts: seq[Profile]) = proc updateUsernames*(self:ChatsView, contacts: seq[Profile]) =
if contacts.len > 0: if contacts.len > 0:
# Updating usernames for all the messages list # Updating usernames for all the messages list
@ -270,6 +266,9 @@ QtObject:
discard self.channelView.chats.addChatItemToList(chatItem) discard self.channelView.chats.addChatItemToList(chatItem)
self.messageView.messagePushed(self.messageView.messageList[chatItem.id].count - 1) self.messageView.messagePushed(self.messageView.messageList[chatItem.id].count - 1)
proc setTimelineChat*(self: ChatsView, chatItem: Chat) =
self.timelineChat = chatItem
proc copyToClipboard*(self: ChatsView, content: string) {.slot.} = proc copyToClipboard*(self: ChatsView, content: string) {.slot.} =
setClipBoardText(content) setClipBoardText(content)
@ -309,8 +308,16 @@ QtObject:
self.messageView.removeChat(chatId) self.messageView.removeChat(chatId)
proc toggleReaction*(self: ChatsView, messageId: string, emojiId: int) {.slot.} = proc toggleReaction*(self: ChatsView, messageId: string, emojiId: int) {.slot.} =
if self.channelView.activeChannel.id == status_utils.getTimelineChatId():
let message = self.messageView.messageList[status_utils.getTimelineChatId()].getMessageById(messageId)
self.reactions.toggle(messageId, message.chatId, emojiId)
else:
self.reactions.toggle(messageId, self.channelView.activeChannel.id, emojiId) self.reactions.toggle(messageId, self.channelView.activeChannel.id, emojiId)
proc removeMessagesFromTimeline*(self: ChatsView, chatId: string) =
self.messageView.messageList[status_utils.getTimelineChatId()].deleteMessagesByChatId(chatId)
self.channelView.activeChannelChanged()
proc updateChats*(self: ChatsView, chats: seq[Chat]) = proc updateChats*(self: ChatsView, chats: seq[Chat]) =
for chat in chats: for chat in chats:
if (chat.communityId != ""): if (chat.communityId != ""):
@ -376,6 +383,17 @@ QtObject:
QtProperty[QVariant] transactions: QtProperty[QVariant] transactions:
read = getTransactions read = getTransactions
proc isActiveMailserverResult(self: ChatsView, resultEncoded: string) {.slot.} =
let isActiveMailserverAvailable = decode[bool](resultEncoded)
if isActiveMailserverAvailable:
self.messageView.setLoadingMessages(true)
let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = RequestMessagesTaskArg(`method`: "requestMessages")
mailserverWorker.start(task)
proc requestAllHistoricMessagesResult(self: ChatsView, resultEncoded: string) {.slot.} =
self.messageView.setLoadingMessages(true)
proc createCommunityChannel*(self: ChatsView, communityId: string, name: string, description: string, categoryId: string): string {.slot.} = proc createCommunityChannel*(self: ChatsView, communityId: string, name: string, description: string, categoryId: string): string {.slot.} =
try: try:
@ -420,7 +438,7 @@ QtObject:
proc requestMoreMessages*(self: ChatsView, fetchRange: int) {.slot.} = proc requestMoreMessages*(self: ChatsView, fetchRange: int) {.slot.} =
self.messageView.loadingMessages = true self.messageView.loadingMessages = true
self.messageView.loadingMessagesChanged(true) self.messageView.loadingMessagesChanged(true)
let mailserverWorker = self.appService.marathon[MailserverWorker().name] let mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
let task = RequestMessagesTaskArg( `method`: "requestMoreMessages", chatId: self.channelView.activeChannel.id) let task = RequestMessagesTaskArg( `method`: "requestMoreMessages", chatId: self.channelView.activeChannel.id)
mailserverWorker.start(task) mailserverWorker.start(task)
@ -436,6 +454,8 @@ QtObject:
proc pushPinnedMessages*(self: ChatsView, pinnedMessages: var seq[Message]) = proc pushPinnedMessages*(self: ChatsView, pinnedMessages: var seq[Message]) =
self.messageView.pushPinnedMessages(pinnedMessages) self.messageView.pushPinnedMessages(pinnedMessages)
proc hideLoadingIndicator*(self: ChatsView) {.slot.} =
self.messageView.hideLoadingIndicator()
proc deleteMessage*(self: ChatsView, channelId: string, messageId: string): bool = proc deleteMessage*(self: ChatsView, channelId: string, messageId: string): bool =
result = self.messageView.deleteMessage(channelId, messageId) result = self.messageView.deleteMessage(channelId, messageId)
@ -468,6 +488,15 @@ QtObject:
proc markMessageAsSent*(self: ChatsView, chat: string, messageId: string) = proc markMessageAsSent*(self: ChatsView, chat: string, messageId: string) =
self.messageView.markMessageAsSent(chat, messageId) self.messageView.markMessageAsSent(chat, messageId)
# TODO: this method was created just to test the store functionality.
# It should be removed, once peer management is added to status-go
proc requestAllHistoricMessages(self: ChatsView) {.slot.} =
debug "Requesting messages"
# TODO: the mailservers must change depending on whether we are using wakuV1 or wakuV2
# in the meantime I'm hardcoding a specific mailserver
echo self.status.mailservers.setMailserver("16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD")
echo self.status.mailservers.requestAllHistoricMessages()
proc switchTo*(self: ChatsView, communityId: string, channelId: string, proc switchTo*(self: ChatsView, communityId: string, channelId: string,
messageId: string) = messageId: string) =
## This method displays community with communityId as an active one (if ## This method displays community with communityId as an active one (if
@ -531,7 +560,7 @@ QtObject:
# Once this part gets refactored os notification service from the services will be used # Once this part gets refactored os notification service from the services will be used
# instead fetching that service from the "core/main" # instead fetching that service from the "core/main"
#self.appService.osNotificationService.showNotification(title, message, details, useOSNotifications) #self.statusFoundation.osNotificationService.showNotification(title, message, details, useOSNotifications)
## ##
## ##
################################################# #################################################

View File

@ -31,7 +31,7 @@ const asyncMarkAllReadTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.}
QtObject: QtObject:
type ChannelView* = ref object of QObject type ChannelView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
communities*: CommunitiesView communities*: CommunitiesView
chats*: ChannelsList chats*: ChannelsList
activeChannel*: ChatItemView activeChannel*: ChatItemView
@ -46,10 +46,10 @@ QtObject:
self.contextChannel.delete self.contextChannel.delete
self.QObject.delete self.QObject.delete
proc newChannelView*(status: Status, appService: AppService, communities: CommunitiesView, activityNotificationList: ActivityNotificationList): ChannelView = proc newChannelView*(status: Status, statusFoundation: StatusFoundation, communities: CommunitiesView, activityNotificationList: ActivityNotificationList): ChannelView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.chats = newChannelsList(status) result.chats = newChannelsList(status)
result.activeChannel = newChatItemView(status) result.activeChannel = newChatItemView(status)
result.contextChannel = newChatItemView(status) result.contextChannel = newChatItemView(status)
@ -117,7 +117,7 @@ QtObject:
slot: "onAsyncMarkMessagesRead", slot: "onAsyncMarkMessagesRead",
chatId: chatId, chatId: chatId,
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
################################################# #################################################

View File

@ -30,20 +30,20 @@ proc resolveEns[T](self: T, slot: string, ens: string, uuid: string) =
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot, ens: ens, uuid: uuid slot: slot, ens: ens, uuid: uuid
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type EnsView* = ref object of QObject type EnsView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
proc setup(self: EnsView) = self.QObject.setup proc setup(self: EnsView) = self.QObject.setup
proc delete*(self: EnsView) = self.QObject.delete proc delete*(self: EnsView) = self.QObject.delete
proc newEnsView*(status: Status, appService: AppService): EnsView = proc newEnsView*(status: Status, statusFoundation: StatusFoundation): EnsView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.setup result.setup
proc isEnsVerified*(self: EnsView, id: string): bool {.slot.} = proc isEnsVerified*(self: EnsView, id: string): bool {.slot.} =

View File

@ -23,7 +23,7 @@ type
QtObject: QtObject:
type MessageView* = ref object of QAbstractListModel type MessageView* = ref object of QAbstractListModel
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
messageList*: OrderedTable[string, ChatMessageList] messageList*: OrderedTable[string, ChatMessageList]
pinnedMessagesList*: OrderedTable[string, ChatMessageList] pinnedMessagesList*: OrderedTable[string, ChatMessageList]
channelView*: ChannelView channelView*: ChannelView
@ -46,10 +46,10 @@ QtObject:
self.channelOpenTime = initTable[string, int64]() self.channelOpenTime = initTable[string, int64]()
self.QAbstractListModel.delete self.QAbstractListModel.delete
proc newMessageView*(status: Status, appService: AppService, channelView: ChannelView, communitiesView: CommunitiesView): MessageView = proc newMessageView*(status: Status, statusFoundation: StatusFoundation, channelView: ChannelView, communitiesView: CommunitiesView): MessageView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.channelView = channelView result.channelView = channelView
result.communities = communitiesView result.communities = communitiesView
result.messageList = initOrderedTable[string, ChatMessageList]() result.messageList = initOrderedTable[string, ChatMessageList]()
@ -293,7 +293,7 @@ QtObject:
discard discard
# Not refactored yet, will be once we have corresponding qml part done. # Not refactored yet, will be once we have corresponding qml part done.
# self.setLoadingHistoryMessages(channelId, true) # self.setLoadingHistoryMessages(channelId, true)
# self.appService.chatService.loadMoreMessagesForChannel(channelId) # self.statusFoundation.chatService.loadMoreMessagesForChannel(channelId)
proc onMessagesLoaded*(self: MessageView, chatId: string, messages: var seq[Message]) = proc onMessagesLoaded*(self: MessageView, chatId: string, messages: var seq[Message]) =
self.pushMessages(messages) self.pushMessages(messages)
@ -323,7 +323,7 @@ QtObject:
proc fillGaps*(self: MessageView, messageId: string) {.slot.} = proc fillGaps*(self: MessageView, messageId: string) {.slot.} =
self.setLoadingMessages(true) self.setLoadingMessages(true)
let mailserverWorker = self.appService.marathon[MailserverWorker().name] let mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
let task = FillGapsTaskArg( `method`: "fillGaps", chatId: self.channelView.activeChannel.id, messageIds: @[messageId]) let task = FillGapsTaskArg( `method`: "fillGaps", chatId: self.channelView.activeChannel.id, messageIds: @[messageId])
mailserverWorker.start(task) mailserverWorker.start(task)

View File

@ -52,7 +52,7 @@ proc estimate[T](self: T, slot: string, packId: int, address: string, price: str
price: price, price: price,
uuid: uuid uuid: uuid
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
const obtainAvailableStickerPacksTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const obtainAvailableStickerPacksTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[ObtainAvailableStickerPacksTaskArg](argEncoded) let arg = decode[ObtainAvailableStickerPacksTaskArg](argEncoded)
@ -68,14 +68,14 @@ proc obtainAvailableStickerPacks[T](self: T, slot: string) =
tptr: cast[ByteAddress](obtainAvailableStickerPacksTask), tptr: cast[ByteAddress](obtainAvailableStickerPacksTask),
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot, slot: slot,
running: cast[ByteAddress](addr self.appService.threadpool.running) running: cast[ByteAddress](addr self.statusFoundation.threadpool.running)
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type StickersView* = ref object of QObject type StickersView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
activeChannel: ChatItemView activeChannel: ChatItemView
stickerPacks*: StickerPackList stickerPacks*: StickerPackList
recentStickers*: StickerList recentStickers*: StickerList
@ -86,11 +86,11 @@ QtObject:
proc delete*(self: StickersView) = proc delete*(self: StickersView) =
self.QObject.delete self.QObject.delete
proc newStickersView*(status: Status, appService: AppService, activeChannel: ChatItemView): StickersView = proc newStickersView*(status: Status, statusFoundation: StatusFoundation, activeChannel: ChatItemView): StickersView =
new(result, delete) new(result, delete)
result = StickersView() result = StickersView()
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.stickerPacks = newStickerPackList() result.stickerPacks = newStickerPackList()
result.recentStickers = newStickerList() result.recentStickers = newStickerList()
result.activeChannel = activeChannel result.activeChannel = activeChannel

View File

@ -10,17 +10,16 @@ import
export status_lib_status export status_lib_status
export marathon, task_runner, signals_manager export marathon, task_runner, signals_manager
type AppService* = ref object # AppService should be renamed to "Foundation" type StatusFoundation* = ref object
status*: Status # in one point of time this should be completely removed status*: Status # in one point of time this should be completely removed
# foundation
threadpool*: ThreadPool threadpool*: ThreadPool
marathon*: Marathon marathon*: Marathon
signalsManager*: SignalsManager signalsManager*: SignalsManager
mailserverController*: MailserverController mailserverController*: MailserverController
mailserverWorker*: MailserverWorker mailserverWorker*: MailserverWorker
proc newAppService*(status: Status): AppService = proc newStatusFoundation*(status: Status): StatusFoundation =
result = AppService() result = StatusFoundation()
result.status = status result.status = status
result.mailserverController = newMailserverController(status) result.mailserverController = newMailserverController(status)
result.mailserverWorker = newMailserverWorker(cast[ByteAddress](result.mailserverController.vptr)) result.mailserverWorker = newMailserverWorker(cast[ByteAddress](result.mailserverController.vptr))
@ -28,11 +27,11 @@ proc newAppService*(status: Status): AppService =
result.marathon = newMarathon(result.mailserverWorker) result.marathon = newMarathon(result.mailserverWorker)
result.signalsManager = newSignalsManager(status.events) result.signalsManager = newSignalsManager(status.events)
proc delete*(self: AppService) = proc delete*(self: StatusFoundation) =
self.threadpool.teardown() self.threadpool.teardown()
self.marathon.teardown() self.marathon.teardown()
self.signalsManager.delete() self.signalsManager.delete()
proc onLoggedIn*(self: AppService) = proc onLoggedIn*(self: StatusFoundation) =
self.marathon.onLoggedIn() self.marathon.onLoggedIn()
self.osNotificationService.onLoggedIn() self.osNotificationService.onLoggedIn()

View File

@ -8,16 +8,16 @@ logScope:
topics = "node" topics = "node"
type NodeController* = ref object type NodeController* = ref object
appService: AppService statusFoundation: StatusFoundation
view*: NodeView view*: NodeView
variant*: QVariant variant*: QVariant
networkAccessMananger*: QNetworkAccessManager networkAccessMananger*: QNetworkAccessManager
isWakuV2: bool isWakuV2: bool
proc newController*(appService: AppService, nam: QNetworkAccessManager): NodeController = proc newController*(statusFoundation: StatusFoundation, nam: QNetworkAccessManager): NodeController =
result = NodeController() result = NodeController()
result.appService = appService result.statusFoundation = statusFoundation
result.view = newNodeView(appService) result.view = newNodeView(statusFoundation)
result.variant = newQVariant(result.view) result.variant = newQVariant(result.view)
result.networkAccessMananger = nam result.networkAccessMananger = nam
@ -26,30 +26,30 @@ proc delete*(self: NodeController) =
delete self.view delete self.view
proc setPeers(self: NodeController, peers: seq[string]) = proc setPeers(self: NodeController, peers: seq[string]) =
self.appService.status.network.peerSummaryChange(peers) self.statusFoundation.status.network.peerSummaryChange(peers)
self.view.setPeerSize(peers.len) self.view.setPeerSize(peers.len)
proc init*(self: NodeController) = proc init*(self: NodeController) =
self.isWakuV2 = self.appService.status.settings.getWakuVersion() == 2 self.isWakuV2 = self.statusFoundation.status.settings.getWakuVersion() == 2
self.appService.status.events.on(SignalType.Wallet.event) do(e:Args): self.statusFoundation.status.events.on(SignalType.Wallet.event) do(e:Args):
self.view.setLastMessage($WalletSignal(e).blockNumber) self.view.setLastMessage($WalletSignal(e).blockNumber)
self.appService.status.events.on(SignalType.DiscoverySummary.event) do(e:Args): self.statusFoundation.status.events.on(SignalType.DiscoverySummary.event) do(e:Args):
var data = DiscoverySummarySignal(e) var data = DiscoverySummarySignal(e)
self.setPeers(data.enodes) self.setPeers(data.enodes)
self.appService.status.events.on(SignalType.PeerStats.event) do(e:Args): self.statusFoundation.status.events.on(SignalType.PeerStats.event) do(e:Args):
var data = PeerStatsSignal(e) var data = PeerStatsSignal(e)
self.setPeers(data.peers) self.setPeers(data.peers)
self.appService.status.events.on(SignalType.Stats.event) do (e:Args): self.statusFoundation.status.events.on(SignalType.Stats.event) do (e:Args):
self.view.setStats(StatsSignal(e).stats) self.view.setStats(StatsSignal(e).stats)
if not self.isWakuV2: self.view.fetchBitsSet() if not self.isWakuV2: self.view.fetchBitsSet()
self.appService.status.events.on(SignalType.ChroniclesLogs.event) do(e:Args): self.statusFoundation.status.events.on(SignalType.ChroniclesLogs.event) do(e:Args):
self.view.log(ChroniclesLogsSignal(e).content) self.view.log(ChroniclesLogsSignal(e).content)
self.view.init() self.view.init()
self.setPeers(self.appService.status.network.fetchPeers()) self.setPeers(self.statusFoundation.status.network.fetchPeers())

View File

@ -23,12 +23,12 @@ proc bloomFiltersBitsSet[T](self: T, slot: string) =
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot slot: slot
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type NodeView* = ref object of QObject type NodeView* = ref object of QObject
appService: AppService statusFoundation: StatusFoundation
callResult: string callResult: string
lastMessage*: string lastMessage*: string
wakuBloomFilterMode*: bool wakuBloomFilterMode*: bool
@ -41,9 +41,9 @@ QtObject:
proc setup(self: NodeView) = proc setup(self: NodeView) =
self.QObject.setup self.QObject.setup
proc newNodeView*(appService: AppService): NodeView = proc newNodeView*(statusFoundation: StatusFoundation): NodeView =
new(result) new(result)
result.appService = appService result.statusFoundation = statusFoundation
result.callResult = "Use this tool to call JSONRPC methods" result.callResult = "Use this tool to call JSONRPC methods"
result.lastMessage = "" result.lastMessage = ""
result.wakuBloomFilterMode = false result.wakuBloomFilterMode = false
@ -72,7 +72,7 @@ QtObject:
notify = callResultChanged notify = callResultChanged
proc onSend*(self: NodeView, inputJSON: string) {.slot.} = proc onSend*(self: NodeView, inputJSON: string) {.slot.} =
self.setCallResult(self.appService.status.node.sendRPCMessageRaw(inputJSON)) self.setCallResult(self.statusFoundation.status.node.sendRPCMessageRaw(inputJSON))
echo "Done!: ", self.callResult echo "Done!: ", self.callResult
proc onMessage*(self: NodeView, message: string) {.slot.} = proc onMessage*(self: NodeView, message: string) {.slot.} =
@ -114,20 +114,20 @@ QtObject:
notify = initialized notify = initialized
proc setWakuBloomFilterMode*(self: NodeView, bloomFilterMode: bool) {.slot.} = proc setWakuBloomFilterMode*(self: NodeView, bloomFilterMode: bool) {.slot.} =
let statusGoResult = self.appService.status.settings.setBloomFilterMode(bloomFilterMode) let statusGoResult = self.statusFoundation.status.settings.setBloomFilterMode(bloomFilterMode)
if statusGoResult.error != "": if statusGoResult.error != "":
error "Error saving updated node config", msg=statusGoResult.error error "Error saving updated node config", msg=statusGoResult.error
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
proc init*(self: NodeView) {.slot.} = proc init*(self: NodeView) {.slot.} =
let nodeConfig = self.appService.status.settings.getNodeConfig() let nodeConfig = self.statusFoundation.status.settings.getNodeConfig()
self.wakuBloomFilterMode = self.appService.status.settings.getSetting[:bool](Setting.WakuBloomFilterMode) self.wakuBloomFilterMode = self.statusFoundation.status.settings.getSetting[:bool](Setting.WakuBloomFilterMode)
self.fullNode = nodeConfig["WakuConfig"]["FullNode"].getBool() self.fullNode = nodeConfig["WakuConfig"]["FullNode"].getBool()
self.wakuV2LightClient = nodeConfig["WakuV2Config"]{"LightClient"}.getBool() self.wakuV2LightClient = nodeConfig["WakuV2Config"]{"LightClient"}.getBool()
self.initialized() self.initialized()
proc wakuVersion*(self: NodeView): int {.slot.} = proc wakuVersion*(self: NodeView): int {.slot.} =
var fleetStr = self.appService.status.settings.getSetting[:string](Setting.Fleet) var fleetStr = self.statusFoundation.status.settings.getSetting[:string](Setting.Fleet)
let fleet = parseEnum[Fleet](fleetStr) let fleet = parseEnum[Fleet](fleetStr)
let isWakuV2 = if fleet == WakuV2Prod or fleet == WakuV2Test: true else: false let isWakuV2 = if fleet == WakuV2Prod or fleet == WakuV2Test: true else: false
if isWakuV2: return 2 if isWakuV2: return 2
@ -147,7 +147,7 @@ QtObject:
BloomFilterMode = true BloomFilterMode = true
FullNode = false FullNode = false
let statusGoResult = self.appService.status.settings.setBloomLevel(BloomFilterMode, FullNode) let statusGoResult = self.statusFoundation.status.settings.setBloomLevel(BloomFilterMode, FullNode)
if statusGoResult.error != "": if statusGoResult.error != "":
error "Error saving updated node config", msg=statusGoResult.error error "Error saving updated node config", msg=statusGoResult.error
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
@ -210,7 +210,7 @@ QtObject:
notify = initialized notify = initialized
proc setWakuV2LightClient*(self: NodeView, enabled: bool) {.slot.} = proc setWakuV2LightClient*(self: NodeView, enabled: bool) {.slot.} =
let statusGoResult = self.appService.status.settings.setV2LightMode(enabled) let statusGoResult = self.statusFoundation.status.settings.setV2LightMode(enabled)
if statusGoResult.error != "": if statusGoResult.error != "":
error "Error saving updated node config", msg=statusGoResult.error error "Error saving updated node config", msg=statusGoResult.error
else: else:

View File

@ -21,14 +21,14 @@ type ProfileController* = ref object
view*: ProfileView view*: ProfileView
variant*: QVariant variant*: QVariant
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
proc newController*(status: Status, appService: AppService, proc newController*(status: Status, statusFoundation: StatusFoundation,
changeLanguage: proc(locale: string)): ProfileController = changeLanguage: proc(locale: string)): ProfileController =
result = ProfileController() result = ProfileController()
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.view = newProfileView(status, appService, changeLanguage) result.view = newProfileView(status, statusFoundation, changeLanguage)
result.variant = newQVariant(result.view) result.variant = newQVariant(result.view)
proc delete*(self: ProfileController) = proc delete*(self: ProfileController) =

View File

@ -32,7 +32,7 @@ QtObject:
fleets*: Fleets fleets*: Fleets
network*: NetworkView network*: NetworkView
status*: Status status*: Status
appService: AppService statusFoundation: StatusFoundation
changeLanguage*: proc(locale: string) changeLanguage*: proc(locale: string)
ens*: EnsManager ens*: EnsManager
@ -51,7 +51,7 @@ QtObject:
if not self.mailservers.isNil: self.mailservers.delete if not self.mailservers.isNil: self.mailservers.delete
self.QObject.delete self.QObject.delete
proc newProfileView*(status: Status, appService: AppService, proc newProfileView*(status: Status, statusFoundation: StatusFoundation,
changeLanguage: proc(locale: string)): ProfileView = changeLanguage: proc(locale: string)): ProfileView =
new(result, delete) new(result, delete)
result = ProfileView() result = ProfileView()
@ -61,12 +61,12 @@ QtObject:
result.devices = newDevicesView(status) result.devices = newDevicesView(status)
result.network = newNetworkView(status) result.network = newNetworkView(status)
result.mnemonic = newMnemonicView(status) result.mnemonic = newMnemonicView(status)
result.mailservers = newMailserversView(status, appService) result.mailservers = newMailserversView(status, statusFoundation)
result.ens = newEnsManager(status, appService) result.ens = newEnsManager(status, statusFoundation)
result.fleets = newFleets(status) result.fleets = newFleets(status)
result.changeLanguage = changeLanguage result.changeLanguage = changeLanguage
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.setup result.setup
proc initialized*(self: ProfileView) {.signal.} proc initialized*(self: ProfileView) {.signal.}
@ -188,7 +188,7 @@ QtObject:
# Once this part gets refactored os notification service from the services will be used # Once this part gets refactored os notification service from the services will be used
# instead fetching that service from the "core/main" # instead fetching that service from the "core/main"
#self.appService.osNotificationService.showNotification(title, message, details, useOSNotifications) #self.statusFoundation.osNotificationService.showNotification(title, message, details, useOSNotifications)
proc logDir*(self: ProfileView): string {.slot.} = proc logDir*(self: ProfileView): string {.slot.} =
url_fromLocalFile(constants.LOGDIR) url_fromLocalFile(constants.LOGDIR)

View File

@ -32,12 +32,12 @@ proc lookupContact[T](self: T, slot: string, value: string) =
slot: slot, slot: slot,
value: value value: value
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type ContactsView* = ref object of QObject type ContactsView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
contactList*: ContactList contactList*: ContactList
contactRequests*: ContactList contactRequests*: ContactList
addedContacts*: ContactList addedContacts*: ContactList
@ -55,10 +55,10 @@ QtObject:
self.blockedContacts.delete self.blockedContacts.delete
self.QObject.delete self.QObject.delete
proc newContactsView*(status: Status, appService: AppService): ContactsView = proc newContactsView*(status: Status, statusFoundation: StatusFoundation): ContactsView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.contactList = newContactList() result.contactList = newContactList()
result.contactRequests = newContactList() result.contactRequests = newContactList()
result.addedContacts = newContactList() result.addedContacts = newContactList()

View File

@ -39,7 +39,7 @@ proc validate[T](self: T, slot: string, ens: string, isStatus: bool, usernames:
isStatus: isStatus, isStatus: isStatus,
usernames: usernames usernames: usernames
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
const detailsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const detailsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let let
@ -70,14 +70,14 @@ proc details[T](self: T, slot: string, username: string) =
slot: slot, slot: slot,
username: username username: username
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type EnsManager* = ref object of QAbstractListModel type EnsManager* = ref object of QAbstractListModel
usernames*: seq[string] usernames*: seq[string]
pendingUsernames*: HashSet[string] pendingUsernames*: HashSet[string]
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
proc setup(self: EnsManager) = self.QAbstractListModel.setup proc setup(self: EnsManager) = self.QAbstractListModel.setup
@ -85,11 +85,11 @@ QtObject:
self.usernames = @[] self.usernames = @[]
self.QAbstractListModel.delete self.QAbstractListModel.delete
proc newEnsManager*(status: Status, appService: AppService): EnsManager = proc newEnsManager*(status: Status, statusFoundation: StatusFoundation): EnsManager =
new(result, delete) new(result, delete)
result.usernames = @[] result.usernames = @[]
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.pendingUsernames = initHashSet[string]() result.pendingUsernames = initHashSet[string]()
result.setup result.setup

View File

@ -13,9 +13,8 @@ logScope:
QtObject: QtObject:
type MailserversView* = ref object of QObject type MailserversView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
mailserversList*: MailServersList mailserversList*: MailServersList
activeMailserver: string
proc setup(self: MailserversView) = proc setup(self: MailserversView) =
self.QObject.setup self.QObject.setup
@ -24,10 +23,10 @@ QtObject:
self.mailserversList.delete self.mailserversList.delete
self.QObject.delete self.QObject.delete
proc newMailserversView*(status: Status, appService: AppService): MailserversView = proc newMailserversView*(status: Status, statusFoundation: StatusFoundation): MailserversView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.mailserversList = newMailServersList() result.mailserversList = newMailServersList()
result.setup result.setup
@ -40,16 +39,21 @@ QtObject:
QtProperty[QVariant] list: QtProperty[QVariant] list:
read = getMailserversList read = getMailserversList
proc activeMailserverChanged*(self: MailserversView, activeMailserver: string) {.signal.} proc activeMailserverChanged*(self: MailserversView, activeMailserverName: string) {.signal.}
proc setActiveMailserver*(self: MailserversView, activeMailserver: string) = proc getActiveMailserver(self: MailserversView): string {.slot.} =
self.activeMailserver = activeMailserver let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = GetActiveMailserverTaskArg(
`method`: "getActiveMailserver",
vptr: cast[ByteAddress](self.vptr),
slot: "getActiveMailserverResult"
)
mailserverWorker.start(task)
proc getActiveMailserverResult*(self: MailserversView, activeMailserver: string) {.slot.} =
self.activeMailserverChanged(activeMailserver) self.activeMailserverChanged(activeMailserver)
QtProperty[string] activeMailserver:
read = activeMailserver
notify = activeMailserverChanged
proc getAutomaticSelection(self: MailserversView): bool {.slot.} = proc getAutomaticSelection(self: MailserversView): bool {.slot.} =
self.status.settings.getPinnedMailserver() == "" self.status.settings.getPinnedMailserver() == ""
@ -62,10 +66,19 @@ QtObject:
proc enableAutomaticSelection(self: MailserversView, value: bool) {.slot.} = proc enableAutomaticSelection(self: MailserversView, value: bool) {.slot.} =
if value: if value:
self.activeMailserverChanged(self.activeMailserver)
self.status.settings.pinMailserver() self.status.settings.pinMailserver()
else: else:
self.activeMailserverChanged("") let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = GetActiveMailserverTaskArg(
`method`: "getActiveMailserver",
vptr: cast[ByteAddress](self.vptr),
slot: "getActiveMailserverResult2"
)
mailserverWorker.start(task)
proc getActiveMailserverResult2(self: MailserversView, activeMailserver: string) {.slot.} =
self.status.settings.pinMailserver(activeMailserver)
proc save(self: MailserversView, name: string, address: string) {.slot.} = proc save(self: MailserversView, name: string, address: string) {.slot.} =
self.status.settings.saveMailserver(name, address) self.status.settings.saveMailserver(name, address)

View File

@ -9,15 +9,15 @@ logScope:
type UtilsController* = ref object type UtilsController* = ref object
status*: Status status*: Status
appService: AppService statusFoundation: StatusFoundation
view*: UtilsView view*: UtilsView
variant*: QVariant variant*: QVariant
proc newController*(status: Status, appService: AppService): UtilsController = proc newController*(status: Status, statusFoundation: StatusFoundation): UtilsController =
result = UtilsController() result = UtilsController()
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.view = newUtilsView(status, appService) result.view = newUtilsView(status, statusFoundation)
result.variant = newQVariant(result.view) result.variant = newQVariant(result.view)
proc delete*(self: UtilsController) = proc delete*(self: UtilsController) =

View File

@ -21,7 +21,7 @@ type CheckForNewVersionTaskArg = ref object of QObjectTaskArg
QtObject: QtObject:
type UtilsView* = ref object of QObject type UtilsView* = ref object of QObject
status*: Status status*: Status
appService: AppService statusFoundation: StatusFoundation
newVersion*: string newVersion*: string
proc setup(self: UtilsView) = proc setup(self: UtilsView) =
@ -35,11 +35,11 @@ QtObject:
proc delete*(self: UtilsView) = proc delete*(self: UtilsView) =
self.QObject.delete self.QObject.delete
proc newUtilsView*(status: Status, appService: AppService): UtilsView = proc newUtilsView*(status: Status, statusFoundation: StatusFoundation): UtilsView =
new(result, delete) new(result, delete)
result = UtilsView() result = UtilsView()
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.setup result.setup
proc getOs*(self: UtilsView): string {.slot.} = proc getOs*(self: UtilsView): string {.slot.} =
@ -168,7 +168,7 @@ QtObject:
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot slot: slot
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
proc latestVersionSuccess*(self: UtilsView, latestVersionJSON: string) {.slot.} = proc latestVersionSuccess*(self: UtilsView, latestVersionJSON: string) {.slot.} =
let latestVersionObj = parseJSON(latestVersionJSON) let latestVersionObj = parseJSON(latestVersionJSON)

View File

@ -14,15 +14,15 @@ logScope:
type WalletController* = ref object type WalletController* = ref object
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
view*: WalletView view*: WalletView
variant*: QVariant variant*: QVariant
proc newController*(status: Status, appService: AppService): WalletController = proc newController*(status: Status, statusFoundation: StatusFoundation): WalletController =
result = WalletController() result = WalletController()
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.view = newWalletView(status, appService) result.view = newWalletView(status, statusFoundation)
result.variant = newQVariant(result.view) result.variant = newQVariant(result.view)
proc delete*(self: WalletController) = proc delete*(self: WalletController) =

View File

@ -10,7 +10,7 @@ QtObject:
type type
WalletView* = ref object of QAbstractListModel WalletView* = ref object of QAbstractListModel
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
accountsView: AccountsView accountsView: AccountsView
collectiblesView: CollectiblesView collectiblesView: CollectiblesView
transactionsView*: TransactionsView transactionsView*: TransactionsView
@ -37,19 +37,19 @@ QtObject:
proc setup(self: WalletView) = proc setup(self: WalletView) =
self.QAbstractListModel.setup self.QAbstractListModel.setup
proc newWalletView*(status: Status, appService: AppService): WalletView = proc newWalletView*(status: Status, statusFoundation: StatusFoundation): WalletView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.accountsView = newAccountsView(status) result.accountsView = newAccountsView(status)
result.collectiblesView = newCollectiblesView(status, appService, result.accountsView) result.collectiblesView = newCollectiblesView(status, statusFoundation, result.accountsView)
result.transactionsView = newTransactionsView(status, appService, result.accountsView) result.transactionsView = newTransactionsView(status, statusFoundation, result.accountsView)
result.tokensView = newTokensView(status, appService, result.accountsView) result.tokensView = newTokensView(status, statusFoundation, result.accountsView)
result.gasView = newGasView(status, appService) result.gasView = newGasView(status, statusFoundation)
result.dappBrowserView = newDappBrowserView(status, result.accountsView) result.dappBrowserView = newDappBrowserView(status, result.accountsView)
result.historyView = newHistoryView(status, appService, result.accountsView, result.transactionsView) result.historyView = newHistoryView(status, statusFoundation, result.accountsView, result.transactionsView)
result.balanceView = newBalanceView(status, appService, result.accountsView, result.transactionsView, result.historyView) result.balanceView = newBalanceView(status, statusFoundation, result.accountsView, result.transactionsView, result.historyView)
result.utilsView = newUtilsView() result.utilsView = newUtilsView()
result.isNonArchivalNode = false result.isNonArchivalNode = false

View File

@ -35,12 +35,12 @@ proc initBalances[T](self: T, slot: string, address: string, tokenList: seq[stri
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot, address: address, tokenList: tokenList slot: slot, address: address, tokenList: tokenList
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type BalanceView* = ref object of QObject type BalanceView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
totalFiatBalance: string totalFiatBalance: string
accountsView: AccountsView accountsView: AccountsView
transactionsView*: TransactionsView transactionsView*: TransactionsView
@ -49,10 +49,10 @@ QtObject:
proc setup(self: BalanceView) = self.QObject.setup proc setup(self: BalanceView) = self.QObject.setup
proc delete(self: BalanceView) = self.QObject.delete proc delete(self: BalanceView) = self.QObject.delete
proc newBalanceView*(status: Status, appService: AppService, accountsView: AccountsView, transactionsView: TransactionsView, historyView: HistoryView): BalanceView = proc newBalanceView*(status: Status, statusFoundation: StatusFoundation, accountsView: AccountsView, transactionsView: TransactionsView, historyView: HistoryView): BalanceView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.totalFiatBalance = "" result.totalFiatBalance = ""
result.accountsView = accountsView result.accountsView = accountsView
result.transactionsView = transactionsView result.transactionsView = transactionsView

View File

@ -44,14 +44,14 @@ proc loadCollectibles[T](self: T, slot: string, address: string, collectiblesTyp
tptr: cast[ByteAddress](loadCollectiblesTask), tptr: cast[ByteAddress](loadCollectiblesTask),
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot, address: address, collectiblesType: collectiblesType, slot: slot, address: address, collectiblesType: collectiblesType,
running: cast[ByteAddress](addr self.appService.threadpool.running) running: cast[ByteAddress](addr self.statusFoundation.threadpool.running)
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type CollectiblesView* = ref object of QObject type CollectiblesView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
accountsView*: AccountsView accountsView*: AccountsView
currentCollectiblesLists*: CollectiblesList currentCollectiblesLists*: CollectiblesList
@ -60,10 +60,10 @@ QtObject:
self.currentCollectiblesLists.delete self.currentCollectiblesLists.delete
self.QObject.delete self.QObject.delete
proc newCollectiblesView*(status: Status, appService: AppService, accountsView: AccountsView): CollectiblesView = proc newCollectiblesView*(status: Status, statusFoundation: StatusFoundation, accountsView: AccountsView): CollectiblesView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.currentCollectiblesLists = newCollectiblesList() result.currentCollectiblesLists = newCollectiblesList()
result.accountsView = accountsView # TODO: not ideal but a solution for now result.accountsView = accountsView # TODO: not ideal but a solution for now
result.setup result.setup

View File

@ -31,7 +31,7 @@ proc getGasPredictions[T](self: T, slot: string) =
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot slot: slot
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
logScope: logScope:
topics = "gas-view" topics = "gas-view"
@ -39,17 +39,17 @@ logScope:
QtObject: QtObject:
type GasView* = ref object of QObject type GasView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
gasPrice: string gasPrice: string
defaultGasLimit: string defaultGasLimit: string
proc setup(self: GasView) = self.QObject.setup proc setup(self: GasView) = self.QObject.setup
proc delete(self: GasView) = self.QObject.delete proc delete(self: GasView) = self.QObject.delete
proc newGasView*(status: Status, appService: AppService): GasView = proc newGasView*(status: Status, statusFoundation: StatusFoundation): GasView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.gasPrice = "0" result.gasPrice = "0"
result.defaultGasLimit = "21000" result.defaultGasLimit = "21000"
result.setup result.setup

View File

@ -40,12 +40,12 @@ proc loadTransactions*[T](self: T, slot: string, address: string, toBlock: Uint2
limit: limit, limit: limit,
loadMore: loadMore loadMore: loadMore
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type HistoryView* = ref object of QObject type HistoryView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
accountsView: AccountsView accountsView: AccountsView
transactionsView*: TransactionsView transactionsView*: TransactionsView
fetchingHistoryState: Table[string, bool] fetchingHistoryState: Table[string, bool]
@ -53,11 +53,11 @@ QtObject:
proc setup(self: HistoryView) = self.QObject.setup proc setup(self: HistoryView) = self.QObject.setup
proc delete(self: HistoryView) = self.QObject.delete proc delete(self: HistoryView) = self.QObject.delete
proc newHistoryView*(status: Status, appService: AppService, proc newHistoryView*(status: Status, statusFoundation: StatusFoundation,
accountsView: AccountsView, transactionsView: TransactionsView): HistoryView = accountsView: AccountsView, transactionsView: TransactionsView): HistoryView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.fetchingHistoryState = initTable[string, bool]() result.fetchingHistoryState = initTable[string, bool]()
result.accountsView = accountsView result.accountsView = accountsView
result.transactionsView = transactionsView result.transactionsView = transactionsView

View File

@ -53,12 +53,12 @@ proc getTokenDetails[T](self: T, slot: string, chainId: int, address: string) =
slot: slot, slot: slot,
chainId: chainId, chainId: chainId,
address: address) address: address)
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type TokenList* = ref object of QAbstractListModel type TokenList* = ref object of QAbstractListModel
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
tokens*: seq[Erc20Contract] tokens*: seq[Erc20Contract]
isCustom*: bool isCustom*: bool
@ -85,11 +85,11 @@ QtObject:
self.isCustom = true self.isCustom = true
self.endResetModel() self.endResetModel()
proc newTokenList*(status: Status, appService: AppService): TokenList = proc newTokenList*(status: Status, statusFoundation: StatusFoundation): TokenList =
new(result, delete) new(result, delete)
result.tokens = @[] result.tokens = @[]
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.setup result.setup
proc rowData(self: TokenList, index: int, column: string): string {.slot.} = proc rowData(self: TokenList, index: int, column: string): string {.slot.} =

View File

@ -11,7 +11,7 @@ logScope:
QtObject: QtObject:
type TokensView* = ref object of QObject type TokensView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
accountsView: AccountsView accountsView: AccountsView
currentAssetList*: AssetList currentAssetList*: AssetList
defaultTokenList: TokenList defaultTokenList: TokenList
@ -24,14 +24,14 @@ QtObject:
self.customTokenList.delete self.customTokenList.delete
self.QObject.delete self.QObject.delete
proc newTokensView*(status: Status, appService: AppService, accountsView: AccountsView): TokensView = proc newTokensView*(status: Status, statusFoundation: StatusFoundation, accountsView: AccountsView): TokensView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.accountsView = accountsView result.accountsView = accountsView
result.currentAssetList = newAssetList() result.currentAssetList = newAssetList()
result.defaultTokenList = newTokenList(status, appService) result.defaultTokenList = newTokenList(status, statusFoundation)
result.customTokenList = newTokenList(status, appService) result.customTokenList = newTokenList(status, statusFoundation)
result.setup result.setup
proc hasAsset*(self: TokensView, symbol: string): bool {.slot.} = proc hasAsset*(self: TokensView, symbol: string): bool {.slot.} =

View File

@ -53,7 +53,7 @@ proc sendTransaction[T](self: T, slot: string, from_addr: string, to: string, as
gasPrice: gasPrice, password: password, uuid: uuid, gasPrice: gasPrice, password: password, uuid: uuid,
isEIP1559Enabled: isEIP1559Enabled, maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas isEIP1559Enabled: isEIP1559Enabled, maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
const watchTransactionTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const watchTransactionTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let let
@ -68,12 +68,12 @@ proc watchTransaction[T](self: T, slot: string, transactionHash: string) =
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot, transactionHash: transactionHash slot: slot, transactionHash: transactionHash
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type TransactionsView* = ref object of QObject type TransactionsView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
accountsView*: AccountsView accountsView*: AccountsView
currentTransactions*: TransactionList currentTransactions*: TransactionList
@ -82,10 +82,10 @@ QtObject:
self.currentTransactions.delete self.currentTransactions.delete
self.QObject.delete self.QObject.delete
proc newTransactionsView*(status: Status, appService: AppService, accountsView: AccountsView): TransactionsView = proc newTransactionsView*(status: Status, statusFoundation: StatusFoundation, accountsView: AccountsView): TransactionsView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.accountsView = accountsView # TODO: not ideal but a solution for now result.accountsView = accountsView # TODO: not ideal but a solution for now
result.currentTransactions = newTransactionList() result.currentTransactions = newTransactionList()
result.setup result.setup

View File

@ -14,15 +14,15 @@ logScope:
type WalletController* = ref object type WalletController* = ref object
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
view*: WalletView view*: WalletView
variant*: QVariant variant*: QVariant
proc newController*(status: Status, appService: AppService): WalletController = proc newController*(status: Status, statusFoundation: StatusFoundation): WalletController =
result = WalletController() result = WalletController()
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.view = newWalletView(status, appService) result.view = newWalletView(status, statusFoundation)
result.variant = newQVariant(result.view) result.variant = newQVariant(result.view)
proc delete*(self: WalletController) = proc delete*(self: WalletController) =

View File

@ -13,7 +13,7 @@ QtObject:
type type
WalletView* = ref object of QAbstractListModel WalletView* = ref object of QAbstractListModel
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
accountsView: AccountsView accountsView: AccountsView
collectiblesView: CollectiblesView collectiblesView: CollectiblesView
settingsView*: SettingsView settingsView*: SettingsView
@ -33,16 +33,16 @@ QtObject:
proc setup(self: WalletView) = proc setup(self: WalletView) =
self.QAbstractListModel.setup self.QAbstractListModel.setup
proc newWalletView*(status: Status, appService: AppService): WalletView = proc newWalletView*(status: Status, statusFoundation: StatusFoundation): WalletView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.accountsView = newAccountsView(status) result.accountsView = newAccountsView(status)
result.collectiblesView = newCollectiblesView(status, appService) result.collectiblesView = newCollectiblesView(status, statusFoundation)
result.settingsView = newSettingsView() result.settingsView = newSettingsView()
result.networksView = newNetworksView(status) result.networksView = newNetworksView(status)
result.cryptoServiceController = newCryptoServiceController(status, appService) result.cryptoServiceController = newCryptoServiceController(status, statusFoundation)
result.savedAddressesView = newSavedAddressesView(status, appService) result.savedAddressesView = newSavedAddressesView(status, statusFoundation)
result.setup result.setup
proc getAccounts(self: WalletView): QVariant {.slot.} = proc getAccounts(self: WalletView): QVariant {.slot.} =

View File

@ -28,7 +28,7 @@ const asyncGetCryptoServicesTask: Task = proc(argEncoded: string) {.gcsafe, nimc
QtObject: QtObject:
type CryptoServiceController* = ref object of QObject type CryptoServiceController* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
cryptoServiceModel: CryptoServiceModel cryptoServiceModel: CryptoServiceModel
servicesFetched: bool servicesFetched: bool
@ -39,11 +39,11 @@ QtObject:
self.cryptoServiceModel.delete self.cryptoServiceModel.delete
self.QObject.delete self.QObject.delete
proc newCryptoServiceController*(status: Status, appService: AppService): proc newCryptoServiceController*(status: Status, statusFoundation: StatusFoundation):
CryptoServiceController = CryptoServiceController =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.cryptoServiceModel = newCryptoServiceModel() result.cryptoServiceModel = newCryptoServiceModel()
result.servicesFetched = false result.servicesFetched = false
result.setup result.setup
@ -68,7 +68,7 @@ QtObject:
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: "onAsyncFetchCryptoServices" slot: "onAsyncFetchCryptoServices"
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
################################################# #################################################
proc fetchCryptoServicesFetched*(self:CryptoServiceController) {.signal.} proc fetchCryptoServicesFetched*(self:CryptoServiceController) {.signal.}

View File

@ -24,7 +24,7 @@ proc loadCollections[T](self: T, slot: string, address: string) =
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot, address: address, slot: slot, address: address,
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
type type
LoadAssetsTaskArg = ref object of QObjectTaskArg LoadAssetsTaskArg = ref object of QObjectTaskArg
@ -46,12 +46,12 @@ proc loadAssets[T](self: T, slot: string, address: string, collectionSlug: strin
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot, address: address, collectionSlug: collectionSlug, limit: 200 slot: slot, address: address, collectionSlug: collectionSlug, limit: 200
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type CollectiblesView* = ref object of QObject type CollectiblesView* = ref object of QObject
status: Status status: Status
appService: AppService statusFoundation: StatusFoundation
collections: CollectionList collections: CollectionList
isLoading: bool isLoading: bool
assets: Table[string, AssetList] assets: Table[string, AssetList]
@ -64,10 +64,10 @@ QtObject:
list.delete list.delete
self.QObject.delete self.QObject.delete
proc newCollectiblesView*(status: Status, appService: AppService): CollectiblesView = proc newCollectiblesView*(status: Status, statusFoundation: StatusFoundation): CollectiblesView =
new(result, delete) new(result, delete)
result.status = status result.status = status
result.appService = appService result.statusFoundation = statusFoundation
result.collections = newCollectionList() result.collections = newCollectionList()
result.assets = initTable[string, AssetList]() result.assets = initTable[string, AssetList]()
result.isLoading = false result.isLoading = false

View File

@ -37,7 +37,7 @@ proc loadSavedAddresses[T](self: T, slot: string) =
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),
slot: slot slot: slot
) )
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
const addSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const addSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let let
@ -57,7 +57,7 @@ proc addSavedAddress[T](self: T, slot, name, address: string) =
except: except:
raise newException(ValueError, "Error parsing address") raise newException(ValueError, "Error parsing address")
arg.savedAddress = SavedAddress(name: name, address: addressParsed) arg.savedAddress = SavedAddress(name: name, address: addressParsed)
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
const deleteSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const deleteSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let let
@ -77,7 +77,7 @@ proc deleteSavedAddress[T](self: T, slot, address: string) =
except: except:
raise newException(ValueError, "Error parsing address") raise newException(ValueError, "Error parsing address")
arg.address = addressParsed arg.address = addressParsed
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
const editSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const editSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let let
@ -97,14 +97,14 @@ proc editSavedAddress[T](self: T, slot, name, address: string) =
except: except:
raise newException(ValueError, "Error parsing address") raise newException(ValueError, "Error parsing address")
arg.savedAddress = SavedAddress(name: name, address: addressParsed) arg.savedAddress = SavedAddress(name: name, address: addressParsed)
self.appService.threadpool.start(arg) self.statusFoundation.threadpool.start(arg)
QtObject: QtObject:
type type
SavedAddressesView* = ref object of QObject SavedAddressesView* = ref object of QObject
# no need to store the seq[SavedAddress] value in `loadResult`, as it is # no need to store the seq[SavedAddress] value in `loadResult`, as it is
# set in self.savedAddresses # set in self.savedAddresses
appService: AppService statusFoundation: StatusFoundation
addEditResult: SavedAddressResult[void] addEditResult: SavedAddressResult[void]
deleteResult: SavedAddressResult[void] deleteResult: SavedAddressResult[void]
loadResult: SavedAddressResult[void] loadResult: SavedAddressResult[void]
@ -117,10 +117,10 @@ QtObject:
self.savedAddresses.delete self.savedAddresses.delete
self.QObject.delete self.QObject.delete
proc newSavedAddressesView*(status: Status, appService: AppService): SavedAddressesView = proc newSavedAddressesView*(status: Status, statusFoundation: StatusFoundation): SavedAddressesView =
new(result, delete) new(result, delete)
result.addEditResult = SavedAddressResult[void].ok() result.addEditResult = SavedAddressResult[void].ok()
result.appService = appService result.statusFoundation = statusFoundation
result.deleteResult = SavedAddressResult[void].ok() result.deleteResult = SavedAddressResult[void].ok()
result.savedAddresses = newSavedAddressesList() result.savedAddresses = newSavedAddressesList()
result.setup result.setup

View File

@ -38,8 +38,8 @@ proc mainProc() =
fleetConfig = readFile(joinPath(getAppDir(), fleets)) fleetConfig = readFile(joinPath(getAppDir(), fleets))
status = statuslib.newStatusInstance(fleetConfig) status = statuslib.newStatusInstance(fleetConfig)
let appService = newAppService(status) let statusFoundation = newStatusFoundation(status)
defer: appService.delete() defer: statusFoundation.delete()
status.initNode(STATUSGODIR, KEYSTOREDIR) status.initNode(STATUSGODIR, KEYSTOREDIR)
@ -50,7 +50,7 @@ proc mainProc() =
let app = newQGuiApplication() let app = newQGuiApplication()
defer: app.delete() defer: app.delete()
let appController = newAppController(appService) let appController = newAppController(statusFoundation)
defer: appController.delete() defer: appController.delete()
let resources = let resources =
@ -117,7 +117,7 @@ proc mainProc() =
# We need this global variable in order to be able to access the application # We need this global variable in order to be able to access the application
# from the non-closure callback passed to `statusgo_backend.setSignalEventCallback` # from the non-closure callback passed to `statusgo_backend.setSignalEventCallback`
signalsManagerQObjPointer = cast[pointer](appService.signalsManager.vptr) signalsManagerQObjPointer = cast[pointer](statusFoundation.signalsManager.vptr)
defer: defer:
signalsManagerQObjPointer = nil signalsManagerQObjPointer = nil
@ -133,23 +133,23 @@ proc mainProc() =
let logFile = fmt"app_{getTime().toUnix}.log" let logFile = fmt"app_{getTime().toUnix}.log"
discard defaultChroniclesStream.outputs[1].open(LOGDIR & logFile, fmAppend) discard defaultChroniclesStream.outputs[1].open(LOGDIR & logFile, fmAppend)
var wallet = wallet.newController(status, appService) var wallet = wallet.newController(status, statusFoundation)
defer: wallet.delete() defer: wallet.delete()
singletonInstance.engine.setRootContextProperty("walletModel", wallet.variant) singletonInstance.engine.setRootContextProperty("walletModel", wallet.variant)
var wallet2 = walletV2.newController(status, appService) var wallet2 = walletV2.newController(status, statusFoundation)
defer: wallet2.delete() defer: wallet2.delete()
singletonInstance.engine.setRootContextProperty("walletV2Model", wallet2.variant) singletonInstance.engine.setRootContextProperty("walletV2Model", wallet2.variant)
var chat = chat.newController(status, appService, OPENURI) var chat = chat.newController(status, statusFoundation, OPENURI)
defer: chat.delete() defer: chat.delete()
singletonInstance.engine.setRootContextProperty("chatsModel", chat.variant) singletonInstance.engine.setRootContextProperty("chatsModel", chat.variant)
var node = node.newController(appService, netAccMgr) var node = node.newController(statusFoundation, netAccMgr)
defer: node.delete() defer: node.delete()
singletonInstance.engine.setRootContextProperty("nodeModel", node.variant) singletonInstance.engine.setRootContextProperty("nodeModel", node.variant)
var utilsController = utilsView.newController(status, appService) var utilsController = utilsView.newController(status, statusFoundation)
defer: utilsController.delete() defer: utilsController.delete()
singletonInstance.engine.setRootContextProperty("utilsModel", utilsController.variant) singletonInstance.engine.setRootContextProperty("utilsModel", utilsController.variant)
@ -204,9 +204,9 @@ proc mainProc() =
# 2. Re-init controllers that don't require a running node # 2. Re-init controllers that don't require a running node
initControllers() initControllers()
var signalsManagerQVariant = newQVariant(appService.signalsManager) var signalsManagerQVariant = newQVariant(statusFoundation.signalsManager)
defer: signalsManagerQVariant.delete() defer: signalsManagerQVariant.delete()
var mailserverControllerQVariant = newQVariant(appService.mailserverController) var mailserverControllerQVariant = newQVariant(statusFoundation.mailserverController)
defer: mailserverControllerQVariant.delete() defer: mailserverControllerQVariant.delete()
singletonInstance.engine.setRootContextProperty("signals", signalsManagerQVariant) singletonInstance.engine.setRootContextProperty("signals", signalsManagerQVariant)