CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::mod_2fa::OathCodeView Class Reference
Inheritance diagram for cdc::mod_2fa::OathCodeView:
cdc::ui::ViewBase cdc::ui::IView

Public Member Functions

void init (uint16_t slot, const char *name)
 Initializes the code view for a specific account slot.
void onEnter (void *context) override
 Refreshes code state when the view is entered.
void onResume () override
 Refreshes code state when the view resumes.
void onTick (uint32_t nowMs) override
 Updates the TOTP countdown/code once per second.
void render (bool partial) override
 Renders account metadata, code, and validity/progress UI.
ui::InputResult onKey (char key) override
 Handles key actions for back, edit, next (HOTP), and typing.
const char * getName () const override
 Returns the static view identifier.
const char * getFooterHint () const override
 Returns context-aware footer hint text.
Public Member Functions inherited from cdc::ui::ViewBase
virtual ~ViewBase ()=default
void onEnter (void *context) override
void onExit () override
void onResume () override
void onPause () override
void setLifecycleHooks (void(*onHide)(void *), void(*onShow)(void *), void *userData) override
bool needsRender () const override
void markDirty () override
void clearDirty () override
void setFooterHint (const char *hint) override
const char * getFooterHint () const override
Public Member Functions inherited from cdc::ui::IView
virtual ~IView ()=default
virtual bool prefersLightRefresh () const
virtual InputResult onLongPress (char key)

Additional Inherited Members

Protected Member Functions inherited from cdc::ui::ViewBase
void setTitle (const char *title)
const char * getTitle () const
Protected Attributes inherited from cdc::ui::ViewBase
bool dirty_ = true
const char * title_ = nullptr
const char * customFooter_ = nullptr
void(* onHide_ )(void *) = nullptr
void(* onShow_ )(void *) = nullptr
void * lifecycleUserData_ = nullptr

Detailed Description

Definition at line 445 of file TwoFaModule.cpp.

Member Function Documentation

◆ getFooterHint()

const char * cdc::mod_2fa::OathCodeView::getFooterHint ( ) const
inlineoverridevirtual

Returns context-aware footer hint text.

Returns
Footer hint string.

Reimplemented from cdc::ui::IView.

Definition at line 628 of file TwoFaModule.cpp.

References cdc::core::getKeyboard(), and cdc::ui::tr().

◆ getName()

const char * cdc::mod_2fa::OathCodeView::getName ( ) const
inlineoverridevirtual

Returns the static view identifier.

Returns
View name string.

Implements cdc::ui::IView.

Definition at line 622 of file TwoFaModule.cpp.

◆ init()

void cdc::mod_2fa::OathCodeView::init ( uint16_t slot,
const char * name )
inline

Initializes the code view for a specific account slot.

Parameters
slotLogical OATH slot.
nameAccount display name.

Definition at line 452 of file TwoFaModule.cpp.

References name.

◆ onEnter()

void cdc::mod_2fa::OathCodeView::onEnter ( void * context)
inlineoverridevirtual

Refreshes code state when the view is entered.

Parameters
contextOptional enter context (unused).

Implements cdc::ui::IView.

Definition at line 465 of file TwoFaModule.cpp.

References cdc::ui::ViewBase::dirty_, cdc::ui::showToastError(), and cdc::ui::tr().

◆ onKey()

ui::InputResult cdc::mod_2fa::OathCodeView::onKey ( char key)
inlineoverridevirtual

Handles key actions for back, edit, next (HOTP), and typing.

Parameters
keyPressed key code.
Returns
Input handling result for the view stack.

Implements cdc::ui::IView.

Definition at line 587 of file TwoFaModule.cpp.

References cdc::ui::CONSUMED, cdc::core::getKeyboard(), cdc::ui::IGNORED, cdc::ui::ViewBase::markDirty(), cdc::ui::REQUEST_POP, cdc::ui::showToastError(), cdc::ui::showToastSuccess(), cdc::ui::tr(), valid, and cdc::mod_2fa::wizardEdit().

◆ onResume()

void cdc::mod_2fa::OathCodeView::onResume ( )
inlineoverridevirtual

Refreshes code state when the view resumes.

Invariant: onResume is also invoked by modal dismissal, so it must not show a modal (toast) itself. The time-invalid state is rendered inline.

Implements cdc::ui::IView.

Definition at line 481 of file TwoFaModule.cpp.

References cdc::ui::ViewBase::dirty_.

◆ onTick()

void cdc::mod_2fa::OathCodeView::onTick ( uint32_t nowMs)
inlineoverridevirtual

Updates the TOTP countdown/code once per second.

HOTP entries are not regenerated on tick: their code is counter-based and advancing it would consume counters silently.

Parameters
nowMsCurrent uptime in milliseconds.

Reimplemented from cdc::ui::IView.

Definition at line 495 of file TwoFaModule.cpp.

References cdc::ui::ViewBase::markDirty().

◆ render()

void cdc::mod_2fa::OathCodeView::render ( bool partial)
inlineoverridevirtual

Renders account metadata, code, and validity/progress UI.

Parameters
partialtrue for partial redraw, false for full redraw.

Implements cdc::ui::IView.

Definition at line 508 of file TwoFaModule.cpp.

References cdc::ui::ViewBase::clearDirty(), cdc::hal::getDisplayInstance(), cdc::ui::render::printText(), and cdc::ui::tr().


The documentation for this class was generated from the following file: