|
@@ -11,6 +11,7 @@
|
|
|
#include "commands/move/move.h"
|
|
#include "commands/move/move.h"
|
|
|
#include "commands/pin/pin.h"
|
|
#include "commands/pin/pin.h"
|
|
|
#include "commands/notification/notification.h"
|
|
#include "commands/notification/notification.h"
|
|
|
|
|
+#include "commands/reset/reset.h"
|
|
|
|
|
|
|
|
static void totp_cli_print_unknown_command(const FuriString* unknown_command) {
|
|
static void totp_cli_print_unknown_command(const FuriString* unknown_command) {
|
|
|
TOTP_CLI_PRINTF(
|
|
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) {
|
|
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();
|
|
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);
|
|
totp_cli_command_pin_handle(plugin_state, args, cli);
|
|
|
} else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_NOTIFICATION) == 0) {
|
|
} else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_NOTIFICATION) == 0) {
|
|
|
totp_cli_command_notification_handle(plugin_state, args, cli);
|
|
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 {
|
|
} else {
|
|
|
totp_cli_print_unknown_command(cmd);
|
|
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);
|
|
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);
|
|
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_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);
|
|
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* cli = furi_record_open(RECORD_CLI);
|
|
|
cli_delete_command(cli, TOTP_CLI_COMMAND_NAME);
|
|
cli_delete_command(cli, TOTP_CLI_COMMAND_NAME);
|
|
|
furi_record_close(RECORD_CLI);
|
|
furi_record_close(RECORD_CLI);
|
|
|
|
|
+ free(context);
|
|
|
}
|
|
}
|