diff --git a/src/app/core/signals/remote_signals/signal_type.nim b/src/app/core/signals/remote_signals/signal_type.nim index 57ad3aa15e..d6cc3926d2 100644 --- a/src/app/core/signals/remote_signals/signal_type.nim +++ b/src/app/core/signals/remote_signals/signal_type.nim @@ -50,6 +50,7 @@ type SignalType* {.pure.} = enum WakuFetchingBackupProgress = "waku.fetching.backup.progress" WakuBackedUpProfile = "waku.backedup.profile" WakuBackedUpSettings = "waku.backedup.settings" + WakuBackedUpKeycards = "waku.backedup.keycards" Unknown proc event*(self:SignalType):string = diff --git a/src/app/core/signals/remote_signals/waku_backed_up_keycards.nim b/src/app/core/signals/remote_signals/waku_backed_up_keycards.nim new file mode 100644 index 0000000000..1d3abb5ae0 --- /dev/null +++ b/src/app/core/signals/remote_signals/waku_backed_up_keycards.nim @@ -0,0 +1,14 @@ +import json +import base + +import ../../../../app_service/service/wallet_account/[key_pair_dto] + +type WakuBackedUpKeycardsSignal* = ref object of Signal + keycards*: seq[KeyPairDto] + +proc fromEvent*(T: type WakuBackedUpKeycardsSignal, event: JsonNode): WakuBackedUpKeycardsSignal = + result = WakuBackedUpKeycardsSignal() + + if event["event"]{"backedUpKeycards"} != nil: + for jsonKc in event["event"]["backedUpKeycards"]: + result.keycards.add(jsonKc.toKeyPairDto()) \ No newline at end of file diff --git a/src/app/core/signals/signals_manager.nim b/src/app/core/signals/signals_manager.nim index 149a6552dc..714ce890c0 100644 --- a/src/app/core/signals/signals_manager.nim +++ b/src/app/core/signals/signals_manager.nim @@ -105,6 +105,7 @@ QtObject: of SignalType.WakuFetchingBackupProgress: WakuFetchingBackupProgressSignal.fromEvent(jsonSignal) of SignalType.WakuBackedUpProfile: WakuBackedUpProfileSignal.fromEvent(jsonSignal) of SignalType.WakuBackedUpSettings: WakuBackedUpSettingsSignal.fromEvent(jsonSignal) + of SignalType.WakuBackedUpKeycards: WakuBackedUpKeycardsSignal.fromEvent(jsonSignal) else: Signal() result.signalType = signalType diff --git a/src/app/core/signals/types.nim b/src/app/core/signals/types.nim index 9cc747b446..942a70c7b5 100644 --- a/src/app/core/signals/types.nim +++ b/src/app/core/signals/types.nim @@ -2,8 +2,8 @@ import ./remote_signals/[base, chronicles_logs, community, discovery_summary, envelope, expired, mailserver, messages, peerstats, signal_type, stats, wallet, whisper_filter, keycard, update_available, status_updates, waku_backed_up_profile, - waku_backed_up_settings, waku_fetching_backup_progress] + waku_backed_up_settings, waku_backed_up_keycards, waku_fetching_backup_progress] export base, chronicles_logs, community, discovery_summary, envelope, expired, mailserver, messages, peerstats, signal_type, stats, wallet, whisper_filter, keycard, update_available, status_updates, waku_backed_up_profile, - waku_backed_up_settings, waku_fetching_backup_progress + waku_backed_up_settings, waku_backed_up_keycards, waku_fetching_backup_progress diff --git a/src/app/modules/main/profile_section/privacy/controller.nim b/src/app/modules/main/profile_section/privacy/controller.nim index 516646a60a..541a8930ac 100644 --- a/src/app/modules/main/profile_section/privacy/controller.nim +++ b/src/app/modules/main/profile_section/privacy/controller.nim @@ -126,4 +126,7 @@ proc authenticateLoggedInUser*(self: Controller) = var data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_PRIVACY_SECTION_MODULE_AUTH_IDENTIFIER) if singletonInstance.userProfile.getIsKeycardUser(): data.keyUid = singletonInstance.userProfile.getKeyUid() - self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data) \ No newline at end of file + self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data) + +proc backupData*(self: Controller): int64 = + return self.generalService.backupData() \ No newline at end of file diff --git a/src/app/modules/main/profile_section/privacy/io_interface.nim b/src/app/modules/main/profile_section/privacy/io_interface.nim index 0d6619f5f8..2bdffb7e59 100644 --- a/src/app/modules/main/profile_section/privacy/io_interface.nim +++ b/src/app/modules/main/profile_section/privacy/io_interface.nim @@ -72,4 +72,7 @@ method tryRemoveFromKeyChain*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") method onUserAuthenticated*(self: AccessInterface, pin: string, password: string, keyUid: string) {.base.} = + raise newException(ValueError, "No implementation available") + +method backupData*(self: AccessInterface): int64 {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/profile_section/privacy/module.nim b/src/app/modules/main/profile_section/privacy/module.nim index 167566bfb4..6e5b013277 100644 --- a/src/app/modules/main/profile_section/privacy/module.nim +++ b/src/app/modules/main/profile_section/privacy/module.nim @@ -117,4 +117,7 @@ method onUserAuthenticated*(self: Module, pin: string, password: string, keyUid: if pin.len > 0: self.controller.storeToKeychain(pin) else: - self.controller.storeToKeychain(password) \ No newline at end of file + self.controller.storeToKeychain(password) + +method backupData*(self: Module): int64 = + return self.controller.backupData() \ No newline at end of file diff --git a/src/app/modules/main/profile_section/privacy/view.nim b/src/app/modules/main/profile_section/privacy/view.nim index 4354e9078c..0027706452 100644 --- a/src/app/modules/main/profile_section/privacy/view.nim +++ b/src/app/modules/main/profile_section/privacy/view.nim @@ -77,4 +77,6 @@ QtObject: proc tryRemoveFromKeyChain*(self: View) {.slot.} = self.delegate.tryRemoveFromKeyChain() - \ No newline at end of file + + proc backupData*(self: View): int {.slot.} = + return self.delegate.backupData().int \ No newline at end of file diff --git a/src/app/modules/startup/module.nim b/src/app/modules/startup/module.nim index f5a491748b..600332013f 100644 --- a/src/app/modules/startup/module.nim +++ b/src/app/modules/startup/module.nim @@ -32,6 +32,8 @@ const FetchingFromWakuCommunities = "communities" const FetchingFromWakuCommunitiesIcon = "communities" const FetchingFromWakuSettings = "settings" const FetchingFromWakuSettingsIcon = "settings" +const FetchingFromWakuKeycards = "keycards" +const FetchingFromWakuKeycardIcon = "keycard" type Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface @@ -338,7 +340,8 @@ proc prepareAndInitFetchingData[T](self: Module[T]) = (FetchingFromWakuProfile, FetchingFromWakuProfileIcon), (FetchingFromWakuContacts, FetchingFromWakuContactsIcon), (FetchingFromWakuCommunities, FetchingFromWakuCommunitiesIcon), - (FetchingFromWakuSettings, FetchingFromWakuSettingsIcon) + (FetchingFromWakuSettings, FetchingFromWakuSettingsIcon), + (FetchingFromWakuKeycards, FetchingFromWakuKeycardIcon) ] self.view.createAndInitFetchingDataModel(listOfEntitiesWeExpectToBeSynced) diff --git a/src/app_service/service/general/service.nim b/src/app_service/service/general/service.nim index 9e7731aa24..5bbde4bfa8 100644 --- a/src/app_service/service/general/service.nim +++ b/src/app_service/service/general/service.nim @@ -93,4 +93,11 @@ QtObject: if(not response.error.isNil): error "could not set display name" except Exception as e: - error "error: ", procName="fetchWakuMessages", errName = e.name, errDesription = e.msg \ No newline at end of file + error "error: ", procName="fetchWakuMessages", errName = e.name, errDesription = e.msg + + proc backupData*(self: Service): int64 = + try: + let response = status_general.backupData() + return response.result.getInt + except Exception as e: + error "error: ", procName="backupData", errName = e.name, errDesription = e.msg \ No newline at end of file diff --git a/src/backend/general.nim b/src/backend/general.nim index 1a3e8f80cc..4cb89aa222 100644 --- a/src/backend/general.nim +++ b/src/backend/general.nim @@ -78,3 +78,7 @@ proc initKeystore*(keystoreDir: string): RpcResponse[JsonNode] {.raises: [Except except RpcException as e: error "error", methodName = "initKeystore", exception=e.msg raise newException(RpcException, e.msg) + +proc backupData*(): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [] + result = callPrivateRPC("backupData".prefix, payload) \ No newline at end of file diff --git a/ui/app/AppLayouts/Onboarding/views/ProfileFetchingView.qml b/ui/app/AppLayouts/Onboarding/views/ProfileFetchingView.qml index eae7f9c675..d88ca4ad45 100644 --- a/ui/app/AppLayouts/Onboarding/views/ProfileFetchingView.qml +++ b/ui/app/AppLayouts/Onboarding/views/ProfileFetchingView.qml @@ -92,6 +92,8 @@ Item { return qsTr("Community membership") case Constants.onboarding.profileFetching.entity.settings: return qsTr("Settings") + case Constants.onboarding.profileFetching.entity.keycards: + return qsTr("Keycards") } } } diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 7fbc8a7055..577f0a1b4b 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -223,6 +223,7 @@ StatusSectionLayout { implicitHeight: parent.height devicesStore: root.store.devicesStore + privacyStore: root.store.privacyStore sectionTitle: root.store.getNameForSubsection(Constants.settingsSubsection.devicesSettings) contentWidth: d.contentWidth } diff --git a/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml b/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml index e0f854bdc5..f3c30735c2 100644 --- a/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml +++ b/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml @@ -36,4 +36,8 @@ QtObject { function tryRemoveFromKeyChain() { root.privacyModule.tryRemoveFromKeyChain() } + + function backupData() { + return root.privacyModule.backupData() + } } diff --git a/ui/app/AppLayouts/Profile/views/DevicesView.qml b/ui/app/AppLayouts/Profile/views/DevicesView.qml index 35ec931a77..23d28e76f9 100644 --- a/ui/app/AppLayouts/Profile/views/DevicesView.qml +++ b/ui/app/AppLayouts/Profile/views/DevicesView.qml @@ -18,6 +18,7 @@ SettingsContentBase { id: root property DevicesStore devicesStore + property PrivacyStore privacyStore property bool isSyncing: false @@ -229,6 +230,18 @@ SettingsContentBase { }, 10000); } } + + StatusButton { + id: backupBtn + anchors.top: syncAllBtn.bottom + anchors.topMargin: Style.current.padding + anchors.horizontalCenter: listView.horizontalCenter + text: qsTr("Backup Data") + onClicked : { + let lastUpdate = root.privacyStore.backupData() * 1000 + console.log("Backup done at: ", LocaleUtils.formatDateTime(lastUpdate)) + } + } } Timer { diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 093d9487ac..7e2db8cdf1 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -364,6 +364,7 @@ QtObject { readonly property string contacts: "contacts" readonly property string communities: "communities" readonly property string settings: "settings" + readonly property string keycards: "keycards" } } } diff --git a/vendor/status-go b/vendor/status-go index 60e1978bb5..93de01e32e 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 60e1978bb5917078830aab13e1f2e1b3da17e865 +Subproject commit 93de01e32e8e8bfa57e0c1f76b525b815cf0c08d