mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-26 03:39:58 -07:00
@@ -11,6 +11,7 @@
|
||||
#include "commands/move/move.h"
|
||||
#include "commands/pin/pin.h"
|
||||
#include "commands/notification/notification.h"
|
||||
#include "commands/reset/reset.h"
|
||||
|
||||
static void totp_cli_print_unknown_command(const FuriString* unknown_command) {
|
||||
TOTP_CLI_PRINTF(
|
||||
@@ -20,7 +21,8 @@ static void totp_cli_print_unknown_command(const FuriString* unknown_command) {
|
||||
}
|
||||
|
||||
static void totp_cli_handler(Cli* cli, FuriString* args, void* context) {
|
||||
PluginState* plugin_state = (PluginState*)context;
|
||||
TotpCliContext* cli_context = context;
|
||||
PluginState* plugin_state = cli_context->plugin_state;
|
||||
|
||||
FuriString* cmd = furi_string_alloc();
|
||||
|
||||
@@ -55,6 +57,8 @@ static void totp_cli_handler(Cli* cli, FuriString* args, void* context) {
|
||||
totp_cli_command_pin_handle(plugin_state, args, cli);
|
||||
} else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_NOTIFICATION) == 0) {
|
||||
totp_cli_command_notification_handle(plugin_state, args, cli);
|
||||
} else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_RESET) == 0) {
|
||||
totp_cli_command_reset_handle(cli, cli_context->event_queue);
|
||||
} else {
|
||||
totp_cli_print_unknown_command(cmd);
|
||||
}
|
||||
@@ -62,15 +66,22 @@ static void totp_cli_handler(Cli* cli, FuriString* args, void* context) {
|
||||
furi_string_free(cmd);
|
||||
}
|
||||
|
||||
void totp_cli_register_command_handler(PluginState* plugin_state) {
|
||||
TotpCliContext*
|
||||
totp_cli_register_command_handler(PluginState* plugin_state, FuriMessageQueue* event_queue) {
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
TotpCliContext* context = malloc(sizeof(TotpCliContext));
|
||||
furi_check(context != NULL);
|
||||
context->plugin_state = plugin_state;
|
||||
context->event_queue = event_queue;
|
||||
cli_add_command(
|
||||
cli, TOTP_CLI_COMMAND_NAME, CliCommandFlagParallelSafe, totp_cli_handler, plugin_state);
|
||||
cli, TOTP_CLI_COMMAND_NAME, CliCommandFlagParallelSafe, totp_cli_handler, context);
|
||||
furi_record_close(RECORD_CLI);
|
||||
return context;
|
||||
}
|
||||
|
||||
void totp_cli_unregister_command_handler() {
|
||||
void totp_cli_unregister_command_handler(TotpCliContext* context) {
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
cli_delete_command(cli, TOTP_CLI_COMMAND_NAME);
|
||||
furi_record_close(RECORD_CLI);
|
||||
free(context);
|
||||
}
|
||||
Reference in New Issue
Block a user