14static const char*
TAG =
"VCARD_WIZ";
151 }
else if (
s_wizard.data.given_name[0]) {
160 uint16_t maxLen = ref.
maxLen;
195 LOG_W(
TAG,
"save failed: %s", err[0] ? err :
"(no detail)");
198 :
ui::tr(
"core.failed")));
226 size_t len = strlen(text);
227 if (len > cap) len = cap;
228 memcpy(field, text, len);
243 uint16_t savedOffset, uint16_t failedOffset) {
252 s_wizard.returnAnchor = returnAnchor;
260 s_wizard.returnAnchor = returnAnchor;
274 s_wizard.returnAnchor = returnAnchor;
284 s_wizard.returnAnchor = returnAnchor;
Internationalization with English fallbacks in code and overlay translations loaded at runtime from a...
CDC Log: logging over TinyUSB CDC and UART.
#define LOG_W(tag, fmt,...)
static void start(ui::IView *returnAnchor)
Starts the wizard with an empty struct.
static void editReceived(ui::IView *returnAnchor, uint16_t slot, DoneCallback onDone)
Starts the wizard prefilled with a stored contact for editing.
static void configure(StringResolver resolver, const uint16_t *titleOffsets, uint16_t savedOffset, uint16_t failedOffset)
Configures the wizard with i18n callbacks. Must be called before start() or edit() so step titles can...
static void startReceived(ui::IView *returnAnchor, DoneCallback onDone)
Starts the wizard to create a new stored contact (received list).
void(*)() DoneCallback
Callback fired after a successful save, before returning to the anchor view. Lets the caller refresh ...
static void edit(ui::IView *returnAnchor)
Starts the wizard prefilled with the currently stored own vCard. Falls back to start() when no vCard ...
const char *(*)(uint16_t offset) StringResolver
Resolves a localized step title.
static ViewStack & instance()
Returns singleton view-stack instance.
void popToAnchor(IView *anchor)
Pops views until the specified anchor view is the current view.
void push(IView *view, void *context=nullptr)
static char * fCell(vcard_data_t *d)
static WizardState s_wizard
static char * fOrg(vcard_data_t *d)
static void onStepSave(const char *text)
Forward declaration of the single per-step save handler.
static VcardWizard::StringResolver s_resolver
WizardTarget
Save destination for the wizard's generated vCard.
@ RECEIVED_NEW
Add a new stored contact.
@ RECEIVED_EDIT
Overwrite the stored contact at editSlot.
@ OWN
Persist via vcard_store_set_own().
static char * fTele(vcard_data_t *d)
static void wizardFinish()
Persists wizard data and returns to the anchor view on success.
static char * fMatrix(vcard_data_t *d)
static char * fTitle(vcard_data_t *d)
static char * fGiven(vcard_data_t *d)
WizardStepId
Step indices into the wizard's title offset table. Order must match s_steps[] below.
static char * fWork(vcard_data_t *d)
static char * fSocial(vcard_data_t *d)
static uint16_t s_savedOffset
static char * fFn(vcard_data_t *d)
static char * fUrl(vcard_data_t *d)
static ui::T9InputView s_t9Input
static void pushCurrentStep()
Pushes the T9 input view for the current wizard step. Prefills the input with the current field value...
static char * fHome(vcard_data_t *d)
static uint16_t s_failedOffset
static const char * stepTitle(uint8_t step)
Returns the localized title for a wizard step via the configured resolver.
static const uint16_t * s_titleOffsets
static char * fEmail(vcard_data_t *d)
static char * fNote(vcard_data_t *d)
static char * fSig(vcard_data_t *d)
static char * fFamily(vcard_data_t *d)
static const FieldRef k_steps[STEP_COUNT]
Step descriptor table. Step order is fixed at compile time. The maximum input length for each step is...
static char * fThreema(vcard_data_t *d)
const char * tr(const char *key)
Look up a translation by string key.
void showToastSuccess(const char *message, uint16_t durationMs=1500)
Shows a success toast message.
void showToastError(const char *message, uint16_t durationMs=1500)
Shows an error toast message.
Maps a step ID to the matching field inside vcard_data_t.
char *(* get)(vcard_data_t *d)
Holds the wizard's running state between callback firings.
VcardWizard::DoneCallback onDone
Structured representation of an own vCard for editor/wizard use.
size_t vcard_store_get_own(char *out, size_t max_len)
Retrieves local own-vCard text.
bool vcard_store_set_own(const char *vcard, size_t len, char *err, size_t err_len)
Stores local own-vCard after validation and field filtering.
bool vcard_store_update(uint16_t slot, const char *vcard, size_t len, char *err, size_t err_len)
Overwrites the vCard stored at slot in place after validation.
size_t vcard_store_get(uint16_t slot, char *out, size_t max_len)
Retrieves raw vCard text from slot.
bool vcard_parse_to_struct(const char *raw, vcard_data_t *out)
Parses vCard 4.0 raw text into a structured vcard_data_t.
bool vcard_store_add(const char *vcard, size_t len, char *err, size_t err_len)
Adds peer vCard to first free slot after validation and duplicate check.
size_t vcard_generate_from_struct(const vcard_data_t *data, char *out_buf, size_t buf_len)
Generates vCard 4.0 text from a structured vcard_data_t. Empty fields are omitted....