-
Notifications
You must be signed in to change notification settings - Fork 92
fix(keycard): Improve exception handling #19546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cc75836
fix(keycard): Improve exception handling
alexjba 6e1bc7f
fix: Determine the keycard lib based on a single param
alexjba 85ef118
fix(onboarding): Delay the keycard detection for when keycard is needed
alexjba 9feac10
chore(keycard): Add tests for `keycardRequested` signal
alexjba 5334eeb
feat(keycard): Add support for keycard channel events
alexjba e65e925
fix: Nim constants clean-up
alexjba eaf6eb2
feat(Keycard): Adding a keycard info drawer for Android to guide the …
alexjba 9507b39
fix: Update waiting for keycard text in the keycard drawer
alexjba 2b2143d
fix(KeycardChannelDrawer): Separate the state machine from the UI com…
alexjba 7ed783a
fix: Move keycard channel state constants closer to where it's used
alexjba 3d8ca12
fix(Android): Extend keycard drawer states
alexjba e953836
chore: Add translations
alexjba 6cad1a7
fix: User needs to be able to dismiss the keycard drawer without gett…
alexjba c713a2a
fix(Login): Selecting a keycard account should not automatically trig…
alexjba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import ./io_interface | ||
| import app/core/eventemitter | ||
| import app_service/service/keycardV2/service as keycard_serviceV2 | ||
|
|
||
| type | ||
| Controller* = ref object of RootObj | ||
| delegate: io_interface.AccessInterface | ||
| events: EventEmitter | ||
|
|
||
| proc newController*( | ||
| delegate: io_interface.AccessInterface, | ||
| events: EventEmitter | ||
| ): Controller = | ||
| result = Controller() | ||
| result.delegate = delegate | ||
| result.events = events | ||
|
|
||
| proc delete*(self: Controller) = | ||
| discard | ||
|
|
||
| proc init*(self: Controller) = | ||
| # Listen to channel state changes | ||
| self.events.on(keycard_serviceV2.SIGNAL_KEYCARD_CHANNEL_STATE_UPDATED) do(e: Args): | ||
| let args = keycard_serviceV2.KeycardChannelStateArg(e) | ||
| self.delegate.setKeycardChannelState(args.state) | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| type | ||
| AccessInterface* {.pure inheritable.} = ref object of RootObj | ||
| ## Abstract class for any input/interaction with this module. | ||
|
|
||
| method delete*(self: AccessInterface) {.base.} = | ||
| raise newException(ValueError, "No implementation available") | ||
|
|
||
| method load*(self: AccessInterface) {.base.} = | ||
| raise newException(ValueError, "No implementation available") | ||
|
|
||
| method isLoaded*(self: AccessInterface): bool {.base.} = | ||
| raise newException(ValueError, "No implementation available") | ||
|
|
||
| # View Delegate Interface | ||
| # Delegate for the view must be declared here due to use of QtObject and multi | ||
| # inheritance, which is not well supported in Nim. | ||
| method viewDidLoad*(self: AccessInterface) {.base.} = | ||
| raise newException(ValueError, "No implementation available") | ||
|
|
||
| method setKeycardChannelState*(self: AccessInterface, state: string) {.base.} = | ||
| raise newException(ValueError, "No implementation available") | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import nimqml | ||
|
|
||
| import io_interface, view, controller | ||
| import app/global/global_singleton | ||
| import app/core/eventemitter | ||
|
|
||
| export io_interface | ||
|
|
||
| type | ||
| Module* = ref object of io_interface.AccessInterface | ||
| view: View | ||
| viewVariant: QVariant | ||
| controller: Controller | ||
| moduleLoaded: bool | ||
|
|
||
| proc newModule*( | ||
| events: EventEmitter, | ||
| ): Module = | ||
| result = Module() | ||
| result.view = view.newView(result) | ||
| result.viewVariant = newQVariant(result.view) | ||
| result.controller = controller.newController(result, events) | ||
| result.moduleLoaded = false | ||
|
|
||
| singletonInstance.engine.setRootContextProperty("keycardChannelModule", result.viewVariant) | ||
|
|
||
| method delete*(self: Module) = | ||
| self.view.delete | ||
| self.viewVariant.delete | ||
| self.controller.delete | ||
|
|
||
| method load*(self: Module) = | ||
| self.controller.init() | ||
| self.view.load() | ||
|
|
||
| method isLoaded*(self: Module): bool = | ||
| return self.moduleLoaded | ||
|
|
||
| proc checkIfModuleDidLoad(self: Module) = | ||
| self.moduleLoaded = true | ||
|
|
||
| method viewDidLoad*(self: Module) = | ||
| self.checkIfModuleDidLoad() | ||
|
|
||
| method setKeycardChannelState*(self: Module, state: string) = | ||
| self.view.setKeycardChannelState(state) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import nimqml | ||
|
|
||
| import ./io_interface | ||
|
|
||
| QtObject: | ||
| type | ||
| View* = ref object of QObject | ||
| delegate: io_interface.AccessInterface | ||
| keycardChannelState: string # Operational channel state | ||
|
|
||
| proc setup(self: View) | ||
| proc delete*(self: View) | ||
| proc newView*(delegate: io_interface.AccessInterface): View = | ||
| new(result, delete) | ||
| result.delegate = delegate | ||
| result.setup() | ||
|
|
||
| proc load*(self: View) = | ||
| self.delegate.viewDidLoad() | ||
|
|
||
| proc keycardChannelStateChanged*(self: View) {.signal.} | ||
| proc setKeycardChannelState*(self: View, value: string) = | ||
| if self.keycardChannelState == value: | ||
| return | ||
| self.keycardChannelState = value | ||
| self.keycardChannelStateChanged() | ||
| proc getKeycardChannelState*(self: View): string {.slot.} = | ||
| return self.keycardChannelState | ||
| QtProperty[string] keycardChannelState: | ||
| read = getKeycardChannelState | ||
| write = setKeycardChannelState | ||
| notify = keycardChannelStateChanged | ||
|
|
||
| proc keycardDismissed*(self: View) {.slot.} = | ||
| self.setKeycardChannelState("") | ||
|
|
||
| proc setup(self: View) = | ||
| self.QObject.setup | ||
|
|
||
| proc delete*(self: View) = | ||
| self.QObject.delete | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A password should be set in both cases, regular/keycard user, while pin only for the keycard user, that's why only password was checked. It's not incorrect this way ofc.