CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::mod_password::PasswordModule Class Reference

#include <PasswordModule.h>

Inheritance diagram for cdc::mod_password::PasswordModule:
cdc::core::ModuleBase cdc::core::IModule cdc::core::IService

Public Member Functions

bool init () override
 Initializes module resources, translations, commands, and slot mapping.
void stop () override
 Stops the password module and frees list resources.
const char * getVersion () const override
 Returns the module version string.
uint8_t getMenuItems (core::ModuleMenuItem *items, uint8_t maxItems) override
 Provides main-menu entry for password module UI.
core::IModule::SlotRequest getSlotRequest () const override
 Declares slot requirements for password storage.
void setSlotRange (const core::IModule::SlotRange &range) override
 Stores assigned Tropic slot range for this module.
bool exportBackup (cJSON *out) override
 Exports all vault entries into the module's backup section.
core::IModule::BackupResult importBackup (const cJSON *in) override
 Restores vault entries from the module's backup section.
Public Member Functions inherited from cdc::core::ModuleBase
 ModuleBase (const char *name)
 Constructs a module base with the given module name.
const char * getName () const override
 Returns the module name supplied to the constructor.
ServiceState getState () const override
 Returns the current service state.
bool start () override
 Default start() implementation performing the standard transition.
Public Member Functions inherited from cdc::core::IModule
virtual ui::IViewgetEntryView ()
 Returns the module's entry view (main view when selected from menu).
virtual uint8_t getLockScreenContextItems (LockScreenContextItem *items, uint8_t maxItems)
 Returns the module's lock screen context menu items.
virtual void onUnlock ()
 Called when device is unlocked.
virtual void onLock ()
 Called when device is locked.
virtual void onUsbConnect ()
 Called when USB is connected.
virtual void onUsbDisconnect ()
 Called when USB is disconnected.
virtual void onTick (uint32_t nowMs)
 Called periodically (optional tick for background work).
Public Member Functions inherited from cdc::core::IService
virtual ~IService ()=default

Static Public Member Functions

static PasswordModule & instance ()
 Returns singleton password module instance.

Additional Inherited Members

Protected Attributes inherited from cdc::core::ModuleBase
const char * name_ = nullptr
ServiceState state_ = ServiceState::UNINITIALIZED

Detailed Description

Definition at line 9 of file PasswordModule.h.

Member Function Documentation

◆ exportBackup()

bool cdc::mod_password::PasswordModule::exportBackup ( cJSON * out)
overridevirtual

Exports all vault entries into the module's backup section.

Writes schema_ver and an entries array; each element carries the full set of stored fields. Passwords are stored in plaintext because the backup container itself is encrypted. Returns false when there are no entries.

Parameters
outcJSON object that forms the module's section in the backup file.
Returns
true if at least one entry was exported.

Reimplemented from cdc::core::IModule.

Definition at line 938 of file PasswordModule.cpp.

References cdc::core::TropicStorage::forEachSlot(), cdc::core::TropicStorage::instance(), cdc::mod_password::PasswordStore::instance(), cdc::mod_password::kSchemaVer, cdc::mod_password::PasswordEntry::notes, cdc::mod_password::PasswordEntry::password, cdc::mod_password::PasswordEntry::title, cdc::mod_password::PasswordEntry::totpSlot, cdc::mod_password::PasswordEntry::url, and cdc::mod_password::PasswordEntry::username.

◆ getMenuItems()

uint8_t cdc::mod_password::PasswordModule::getMenuItems ( core::ModuleMenuItem * items,
uint8_t maxItems )
overridevirtual

Provides main-menu entry for password module UI.

Parameters
itemsOutput array for menu items.
maxItemsMaximum writable entries in items.
Returns
Number of populated menu items.

Reimplemented from cdc::core::IModule.

Definition at line 905 of file PasswordModule.cpp.

References cdc::core::ModuleBase::getName(), cdc::mod_password::PasswordStore::instance(), cdc::core::MAIN_MENU, cdc::mod_password::onListMenu(), cdc::mod_password::onListSelect(), cdc::mod_password::rebuildList(), cdc::mod_password::s_listView, cdc::mod_password::s_viewsInitialized, cdc::ui::showToastError(), and cdc::ui::tr().

◆ getSlotRequest()

core::IModule::SlotRequest cdc::mod_password::PasswordModule::getSlotRequest ( ) const
overridevirtual

Declares slot requirements for password storage.

Returns
Slot request structure.

Reimplemented from cdc::core::IModule.

Definition at line 892 of file PasswordModule.cpp.

References cdc::core::ModuleBase::getName(), cdc::core::IModule::SlotRequest::mapName, and cdc::core::IModule::SlotRequest::minRmemSlots.

◆ getVersion()

const char * cdc::mod_password::PasswordModule::getVersion ( ) const
inlineoverridevirtual

Returns the module version string.

Returns
Pointer to a null-terminated version string.

Implements cdc::core::IModule.

Definition at line 14 of file PasswordModule.h.

◆ importBackup()

core::IModule::BackupResult cdc::mod_password::PasswordModule::importBackup ( const cJSON * in)
overridevirtual

Restores vault entries from the module's backup section.

Best-effort upsert by title; malformed or unstorable entries are skipped and counted, never aborting the restore.

Parameters
incJSON object holding the previously exported section.
Returns
Tally of imported and failed records.

Reimplemented from cdc::core::IModule.

Definition at line 1047 of file PasswordModule.cpp.

References cdc::ui::importJsonArray(), cdc::mod_password::importPasswordEntry(), cdc::mod_password::PasswordStore::instance(), cdc::mod_password::kSchemaVer, LOG_W, and TAG.

◆ init()

◆ instance()

PasswordModule & cdc::mod_password::PasswordModule::instance ( )
static

Returns singleton password module instance.

Returns
Module singleton reference.

Definition at line 845 of file PasswordModule.cpp.

Referenced by cdc::mod_password::rebuildList().

◆ setSlotRange()

void cdc::mod_password::PasswordModule::setSlotRange ( const core::IModule::SlotRange & range)
overridevirtual

Stores assigned Tropic slot range for this module.

Parameters
rangeSlot assignment provided by registry.

Reimplemented from cdc::core::IModule.

Definition at line 884 of file PasswordModule.cpp.

◆ stop()

void cdc::mod_password::PasswordModule::stop ( )
overridevirtual

Stops the password module and frees list resources.

Reimplemented from cdc::core::ModuleBase.

Definition at line 875 of file PasswordModule.cpp.

References cdc::mod_password::freeListBuffers().


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