CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
VcardModule.cpp File Reference
#include "mod_vcard/VcardModule.h"
#include "mod_vcard/VcardWizard.h"
#include "mod_vcard/vcard_store.h"
#include "cdc_msg/MessageTransfer.h"
#include "serial_cmd/ICommandRegistry.h"
#include "serial_cmd/SubCommand.h"
#include "serial_cmd/Console.h"
#include "cdc_core/ModuleRegistry.h"
#include "cdc_core/EventBus.h"
#include "cdc_core/Raii.h"
#include "cdc_ui/BackupImport.h"
#include "cJSON.h"
#include "cdc_ui/I18n.h"
#include "cdc_ui/ViewStack.h"
#include "cdc_views/ListView.h"
#include "cdc_views/InfoView.h"
#include "cdc_views/ConfirmView.h"
#include "cdc_views/ContextMenuView.h"
#include "cdc_views/QRCodeView.h"
#include "esp_timer.h"
#include "cdc_views/ToastView.h"
#include "cdc_log.h"
#include "esp_attr.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include <cstring>
#include <cstdio>
#include <cstdlib>

Go to the source code of this file.

Namespaces

namespace  cdc
namespace  cdc::mod_vcard

Enumerations

enum  cdc::mod_vcard::MainMenuItem {
  cdc::mod_vcard::MENU_MY_VCARD = 0 , cdc::mod_vcard::MENU_EDIT_MY_VCARD , cdc::mod_vcard::MENU_SEND , cdc::mod_vcard::MENU_RECEIVED ,
  cdc::mod_vcard::MENU_COUNT
}
 Main-menu item identifiers. More...

Functions

static const char * cdc::mod_vcard::mstr (uint16_t offset)
static void cdc::mod_vcard::registerStrings ()
static void cdc::mod_vcard::rebuildMainMenu ()
 Rebuilds the vCard main menu.
static void cdc::mod_vcard::onMainMenuSelect (uint16_t index, void *userData)
 Handles main-menu actions for local vCard operations and sharing.
static void cdc::mod_vcard::openReceivedList ()
 Lazily wires callbacks, rebuilds and pushes the received-contacts list.
static void cdc::mod_vcard::rebuildReceivedList ()
 Rebuilds the received-contacts list from the store (sorted by name).
static void cdc::mod_vcard::showVcardDetails (const char *title, const char *raw, bool withActions)
 Renders a vCard's parsed fields into a scrollable InfoView.
static void cdc::mod_vcard::showVcardQr (const char *raw, const char *fallbackTitle)
 Shows a vCard as a QR code, titled with the contact name.
static void cdc::mod_vcard::onReceivedViewMenu (void *userData)
 Detail-view context menu (key 3): edit / forward / QR / delete the currently shown contact.
static bool cdc::mod_vcard::deliverVcard (const uint8_t *data, uint32_t len, const char *, const char *)
 Delivers a received vCard into the contact store.
static void cdc::mod_vcard::onReceivedSelect (uint16_t index, void *userData)
 Opens the detail view (with action menu) for the selected contact.
static void cdc::mod_vcard::ctxReceivedAdd ()
 Context-menu action: create a new stored contact via the wizard.
static void cdc::mod_vcard::ctxReceivedEdit ()
 Context-menu action: edit the active stored contact via the wizard.
static void cdc::mod_vcard::ctxReceivedQr ()
 Context-menu action: show the active contact as a QR code.
static void cdc::mod_vcard::ctxReceivedForward ()
 Context-menu action: forward the active contact to a nearby badge.
static void cdc::mod_vcard::onReceivedDeleteConfirm (void *userData)
 Confirm-dialog handler: deletes the contact and refreshes the list.
static void cdc::mod_vcard::ctxReceivedDelete ()
 Context-menu action: confirm and delete the active contact.
static void cdc::mod_vcard::onReceivedMenu (uint16_t index, void *userData)
 List context menu (key 3): add a contact; for a selected entry also edit / forward / delete it.
static const char * cdc::mod_vcard::getMyVcardLockscreenLabel ()
 Returns the localized label for the lock-screen quick action.
static void cdc::mod_vcard::onMyVcardLockscreenSelect ()
 Lock-screen quick action: shows the own vCard as a QR code. Falls back to a toast when no vCard has been configured yet.
static void cdc::mod_vcard::vcard_session_clear ()
static void cdc::mod_vcard::vcard_idle_fired (void *)
static void cdc::mod_vcard::vcard_arm_idle_timer ()
static bool cdc::mod_vcard::vcardLineInterceptor (const char *line)
 Intercepts multiline vCard paste input, accumulates lines, and stops at "---".
static void cdc::mod_vcard::cmdVcardSet (const char *args)
 Serial command entering multiline vCard paste mode.
static void cdc::mod_vcard::vcardPrintLines (char *out)
 Prints a NUL-terminated vCard buffer line by line as CRLF output.
static void cdc::mod_vcard::cmdVcardGet (const char *args)
 Serial command printing a stored vCard.
static void cdc::mod_vcard::cmdVcardList (const char *args)
 Serial command listing received vCards as "<id> <display name>".
static void cdc::mod_vcard::cmdVcardDelete (const char *args)
 Serial command deleting a stored vCard.
static void cdc::mod_vcard::cmdVcard (const char *args)
static void cdc::mod_vcard::registerSerialCommands ()
 Registers serial commands exposed by vCard module.
static bool cdc::mod_vcard::importReceivedVcard (const cJSON *je, void *user)
 Imports one received vCard string into storage.
void mod_vcard_register ()
 Registers vCard module initializer in global module registry.

Variables

static const char * TAG = "VCARD"
constexpr ui::I18nEntry cdc::mod_vcard::kStrings []
static constexpr uint16_t cdc::mod_vcard::STR_VCARD = 0
static constexpr uint16_t cdc::mod_vcard::STR_MY_VCARD = 1
static constexpr uint16_t cdc::mod_vcard::STR_NEARBY = 2
static constexpr uint16_t cdc::mod_vcard::STR_SCAN = 3
static constexpr uint16_t cdc::mod_vcard::STR_STOP_SCAN = 4
static constexpr uint16_t cdc::mod_vcard::STR_ADVERTISING = 5
static constexpr uint16_t cdc::mod_vcard::STR_STOP_ADV = 6
static constexpr uint16_t cdc::mod_vcard::STR_EXCHANGE = 7
static constexpr uint16_t cdc::mod_vcard::STR_NO_PEERS = 8
static constexpr uint16_t cdc::mod_vcard::STR_SCANNING = 9
static constexpr uint16_t cdc::mod_vcard::STR_EXCHANGE_REQ = 10
static constexpr uint16_t cdc::mod_vcard::STR_ACCEPT = 11
static constexpr uint16_t cdc::mod_vcard::STR_DECLINE = 12
static constexpr uint16_t cdc::mod_vcard::STR_EXCHANGE_OK = 13
static constexpr uint16_t cdc::mod_vcard::STR_EXCHANGE_FAIL = 14
static constexpr uint16_t cdc::mod_vcard::STR_CONNECTING = 15
static constexpr uint16_t cdc::mod_vcard::STR_EDIT_MY_VCARD = 16
static constexpr uint16_t cdc::mod_vcard::STR_NO_VCARD = 17
static constexpr uint16_t cdc::mod_vcard::STR_SAVED = 18
static constexpr uint16_t cdc::mod_vcard::STR_GIVEN_NAME = 19
static constexpr uint16_t cdc::mod_vcard::STR_FAMILY_NAME = 20
static constexpr uint16_t cdc::mod_vcard::STR_FORMATTED_NAME = 21
static constexpr uint16_t cdc::mod_vcard::STR_ORGANIZATION = 22
static constexpr uint16_t cdc::mod_vcard::STR_POSITION = 23
static constexpr uint16_t cdc::mod_vcard::STR_EMAIL = 24
static constexpr uint16_t cdc::mod_vcard::STR_TEL_CELL = 25
static constexpr uint16_t cdc::mod_vcard::STR_TEL_HOME = 26
static constexpr uint16_t cdc::mod_vcard::STR_TEL_WORK = 27
static constexpr uint16_t cdc::mod_vcard::STR_URL = 28
static constexpr uint16_t cdc::mod_vcard::STR_TELEGRAM = 29
static constexpr uint16_t cdc::mod_vcard::STR_SIGNAL = 30
static constexpr uint16_t cdc::mod_vcard::STR_MATRIX = 31
static constexpr uint16_t cdc::mod_vcard::STR_THREEMA = 32
static constexpr uint16_t cdc::mod_vcard::STR_SOCIAL_PROFILE = 33
static constexpr uint16_t cdc::mod_vcard::STR_NOTE = 34
static constexpr uint16_t cdc::mod_vcard::STR_SEND = 35
static constexpr uint16_t cdc::mod_vcard::STR_RECEIVED = 36
static constexpr uint16_t cdc::mod_vcard::STR_RECEIVED_TITLE = 37
static constexpr uint16_t cdc::mod_vcard::STR_NO_RECEIVED = 38
static constexpr uint16_t cdc::mod_vcard::STR_SHOW_QR = 39
static constexpr uint16_t cdc::mod_vcard::STR_FORWARD = 40
static constexpr uint16_t cdc::mod_vcard::STR_CONFIRM_DELETE = 41
static const uint16_t cdc::mod_vcard::s_wizardStepOffsets [16]
static ui::ListView cdc::mod_vcard::s_mainMenu
 View instances used by vCard module UI flow.
static bool cdc::mod_vcard::s_viewsInitialized = false
static ui::ListItem cdc::mod_vcard::s_mainMenuItems [MENU_COUNT] = {}
static ui::ListView cdc::mod_vcard::s_receivedMenu
static bool cdc::mod_vcard::s_receivedInitialized = false
static ui::ListItem cdc::mod_vcard::s_recvItems [VCARD_MAX_CARDS]
static char cdc::mod_vcard::s_recvLabels [VCARD_MAX_CARDS][64]
static uint16_t cdc::mod_vcard::s_recvSlots [VCARD_MAX_CARDS]
static uint16_t cdc::mod_vcard::s_recvCount = 0
static uint16_t cdc::mod_vcard::s_activeSlot = 0
static char cdc::mod_vcard::s_vcardBuf [VCARD_MAX_LEN+64]
static int cdc::mod_vcard::s_vcardBufPos = 0
static bool cdc::mod_vcard::s_vcardInputMode = false
static int cdc::mod_vcard::s_vcardSetSlot = -1
static esp_timer_handle_t cdc::mod_vcard::s_vcardIdleTimer = nullptr
static constexpr int64_t cdc::mod_vcard::VCARD_IDLE_LIMIT_US = 30 * 1000000LL
static const serial::SubCommand cdc::mod_vcard::kVcardSubs []
static constexpr int cdc::mod_vcard::kSchemaVer = 1
 Schema version written to and expected from the vCard backup section.

Function Documentation

◆ mod_vcard_register()

void mod_vcard_register ( )

Registers vCard module initializer in global module registry.

Definition at line 983 of file VcardModule.cpp.

References cdc::core::ModuleRegistry::instance(), and cdc::core::ModuleRegistry::registerInitializer().

Variable Documentation

◆ TAG

const char* TAG = "VCARD"
static

Definition at line 30 of file VcardModule.cpp.