29constexpr size_t MAX_LOCKSCREEN_ITEMS = 8;
34 for (
auto& s : s_items.slots)
if (s.used && s.plugin == plugin)
return &s;
42 cdc::ui::ConfirmView view{};
43 void* plugin =
nullptr;
44 uint32_t action_id = 0;
58void onAlertResult(uint32_t answer)
60 void* p = s_alert.plugin;
61 uint32_t action_id = s_alert.action_id;
62 s_alert.active =
false;
63 s_alert.plugin =
nullptr;
67void onAlertYes(
void*) { onAlertResult(1); }
68void onAlertNo(
void*) { onAlertResult(0); }
75 for (
auto& s : s_items.slots) {
76 if (!s.used)
continue;
85 if (
auto* slot = slotFor(plugin)) {
91 if (s_alert.active && s_alert.plugin == plugin) {
92 s_alert.active =
false;
93 s_alert.plugin =
nullptr;
109 LockscreenRegistration* slot =
nullptr;
110 for (
auto& s : cdc::plugin_manager::s_items.slots) {
111 if (s.used && s.plugin == plugin) { slot = &s;
break; }
115 slot = cdc::plugin_manager::s_items.allocate(slot_id);
119 slot->action_id = action_id;
120 std::strncpy(slot->label_key, label_key,
sizeof(slot->label_key) - 1);
121 slot->label_key[
sizeof(slot->label_key) - 1] =
'\0';
146 cdc::plugin_manager::s_alert.plugin = plugin;
147 cdc::plugin_manager::s_alert.action_id = action_id;
148 cdc::plugin_manager::s_alert.active =
true;
149 cdc::plugin_manager::s_alert.view.init(cp.c_str(),
150 cdc::plugin_manager::toConfirmIcon(icon));
151 cdc::plugin_manager::s_alert.view.setOnConfirm(&cdc::plugin_manager::onAlertYes,
nullptr);
152 cdc::plugin_manager::s_alert.view.setOnCancel (&cdc::plugin_manager::onAlertNo,
nullptr);
153 vs.showModal(&cdc::plugin_manager::s_alert.view);
Internal registry of plugin lockscreen quick-actions.
Discovers, loads, runs and unloads WASM plugins on the badge.
Owned WAMR module instance + per-plugin state.
Fixed-capacity, 1-based slot table for host-API resources.
static PluginManager & instance() noexcept
void dispatchActionTo(Plugin *plugin, uint32_t action_id, uint32_t idx, uint32_t user_data)
static ViewStack & instance()
Returns singleton view-stack instance.
int host_lockscreen_alert(const char *text, uint8_t icon, uint32_t action_id)
Raise a persistent Y/N alert over whatever is on screen, lock screen included, that stays until the u...
int host_lockscreen_register_action(const char *label_key, uint32_t action_id)
Publish (or replace) the plugin's lockscreen quick-action.
int host_lockscreen_unregister_action(void)
Remove the plugin's lockscreen quick-action.
CDC Badge OS plugin host API - canonical C ABI contract.
#define HOST_ERR_NO_CAPABILITY
#define HOST_ERR_INVALID_ARG
#define HOST_ERR_NO_MEMORY
void * plg_get_active_plugin(void)
Internal UTF-8 <-> CP437 helpers for the plugin host API boundary.
std::string toDisplay(const char *utf8)
Decode a UTF-8 (with optional HTML entities) string into CP437 bytes.
uint8_t collectLockscreenItems(LockscreenRegistration *out, uint8_t max)
void clearLockscreenRegistrationFor(void *plugin)