Alexander Kopachov пре 2 година
родитељ
комит
afe7e561fd
8 измењених фајлова са 93 додато и 6 уклоњено
  1. 4 0
      cli/cli.c
  2. 11 3
      cli/cli.h
  3. 1 1
      cli/cli_helpers.h
  4. 1 1
      cli/commands/add/add.c
  5. 1 1
      cli/commands/update/update.c
  6. 55 0
      cli/common_command_arguments.h
  7. 9 0
      ui/canvas_extensions.h
  8. 11 0
      ui/common_dialogs.h

+ 4 - 0
cli/cli.c

@@ -16,6 +16,10 @@
 #include "commands/automation/automation.h"
 #include "commands/details/details.h"
 
+struct TotpCliContext {
+    PluginState* plugin_state;
+};
+
 static void totp_cli_print_unknown_command(const FuriString* unknown_command) {
     TOTP_CLI_PRINTF_ERROR(
         "Command \"%s\" is unknown. Use \"" TOTP_CLI_COMMAND_HELP

+ 11 - 3
cli/cli.h

@@ -3,9 +3,17 @@
 #include <cli/cli.h>
 #include "../types/plugin_state.h"
 
-typedef struct {
-    PluginState* plugin_state;
-} TotpCliContext;
+typedef struct TotpCliContext TotpCliContext;
 
+/**
+ * @brief Registers TOTP CLI handler
+ * @param plugin_state application state
+ * @return TOTP CLI context
+ */
 TotpCliContext* totp_cli_register_command_handler(PluginState* plugin_state);
+
+/**
+ * @brief Unregisters TOTP CLI handler
+ * @param context application state
+ */
 void totp_cli_unregister_command_handler(TotpCliContext* context);

+ 1 - 1
cli/cli_helpers.h

@@ -111,6 +111,6 @@ void totp_cli_print_error_updating_config_file();
 void totp_cli_print_error_loading_token_info();
 
 /**
- * @brief Prints message to let user knwo that command is processing now
+ * @brief Prints message to let user know that command is processing now
  */
 void totp_cli_print_processing();

+ 1 - 1
cli/commands/add/add.c

@@ -54,7 +54,7 @@ static TotpIteratorUpdateTokenResult
 
     // Reading token secret
     furi_string_reset(temp_str);
-    TOTP_CLI_PRINTF("Enter token secret and confirm with [ENTER]\r\n");
+    TOTP_CLI_PRINTF("Enter token secret and confirm with [ENTER]:\r\n");
     if(!totp_cli_read_line(context_t->cli, temp_str, mask_user_input)) {
         totp_cli_delete_last_line();
         furi_string_secure_free(temp_str);

+ 1 - 1
cli/commands/update/update.c

@@ -83,7 +83,7 @@ static TotpIteratorUpdateTokenResult
     if(update_token_secret) {
         // Reading token secret
         furi_string_reset(temp_str);
-        TOTP_CLI_PRINTF("Enter token secret and confirm with [ENTER]\r\n");
+        TOTP_CLI_PRINTF("Enter token secret and confirm with [ENTER]:\r\n");
         bool token_secret_read = totp_cli_read_line(context_t->cli, temp_str, mask_user_input);
         totp_cli_delete_last_line();
         if(!token_secret_read) {

+ 55 - 0
cli/common_command_arguments.h

@@ -18,32 +18,87 @@
 #define TOTP_CLI_COMMAND_ARG_SECRET_ENCODING_PREFIX "-e"
 #define TOTP_CLI_COMMAND_ARG_SECRET_ENCODING "encoding"
 
+/**
+ * @brief Prints information about unknown argument
+ * @param arg 
+ */
 void totp_cli_printf_unknown_argument(const FuriString* arg);
 
+/**
+ * @brief Prints information about missed required argument
+ * @param arg 
+ */
 void totp_cli_printf_missed_argument_value(char* arg);
 
+/**
+ * @brief Tries to read token hashing algo
+ * @param token_info token info to set parsed algo to if successfully read and parsed
+ * @param arg argument to parse
+ * @param args rest of arguments
+ * @param[out] parsed will be set to \c true if token hashing algo sucecssfully read and parsed; \c false otherwise
+ * @return \c true if \c arg represents token hashing algo argument; \c false otherwise
+ */
 bool totp_cli_try_read_algo(TokenInfo* token_info, FuriString* arg, FuriString* args, bool* parsed);
 
+/**
+ * @brief Tries to read token digits count
+ * @param token_info token info to set parsed digits count to if successfully read and parsed
+ * @param arg argument to parse
+ * @param args rest of arguments
+ * @param[out] parsed will be set to \c true if token digits count sucecssfully read and parsed; \c false otherwise
+ * @return \c true if \c arg represents token digits count argument; \c false otherwise
+ */
 bool totp_cli_try_read_digits(
     TokenInfo* token_info,
     const FuriString* arg,
     FuriString* args,
     bool* parsed);
 
+/**
+ * @brief Tries to read token duration
+ * @param token_info token info to set parsed duration to if successfully read and parsed
+ * @param arg argument to parse
+ * @param args rest of arguments
+ * @param[out] parsed will be set to \c true if token duration sucecssfully read and parsed; \c false otherwise
+ * @return \c true if \c arg represents token duration argument; \c false otherwise
+ */
 bool totp_cli_try_read_duration(
     TokenInfo* token_info,
     const FuriString* arg,
     FuriString* args,
     bool* parsed);
 
+/**
+ * @brief Tries to read token automation features
+ * @param token_info token info to set parsed automation features to if successfully read and parsed
+ * @param arg argument to parse
+ * @param args rest of arguments
+ * @param[out] parsed will be set to \c true if token automation features sucecssfully read and parsed; \c false otherwise
+ * @return \c true if \c arg represents token automation features argument; \c false otherwise
+ */
 bool totp_cli_try_read_automation_features(
     TokenInfo* token_info,
     FuriString* arg,
     FuriString* args,
     bool* parsed);
 
+/**
+ * @brief Tries to read unsecure flag
+ * @param arg argument to parse
+ * @param[out] parsed will be set to \c true if unsecure flag sucecssfully read and parsed; \c false otherwise
+ * @param[out] unsecure_flag will be set to parsed unsecure flag state if read and parsed successfully
+ * @return \c true if \c arg represents unsecure flag argument; \c false otherwise
+ */
 bool totp_cli_try_read_unsecure_flag(const FuriString* arg, bool* parsed, bool* unsecure_flag);
 
+/**
+ * @brief Tries to read plain token secret encoding
+ * @param arg argument to parse
+ * @param args rest of arguments
+ * @param[out] parsed will be set to \c true if plain token secret encoding sucecssfully read and parsed; \c false otherwise
+ * @param[out] secret_encoding will be set to parsed plain token secret encoding if read and parsed successfully
+ * @return \c true if \c arg represents plain token secret encoding argument; \c false otherwise
+ */
 bool totp_cli_try_read_plain_token_secret_encoding(
     FuriString* arg,
     FuriString* args,

+ 9 - 0
ui/canvas_extensions.h

@@ -4,6 +4,15 @@
 #include <gui/gui.h>
 #include <font_info.h>
 
+/**
+ * @brief Draw string using given font
+ * @param canvas canvas to draw string at
+ * @param x horizontal position
+ * @param y vertical position
+ * @param text string to draw
+ * @param text_length string length
+ * @param font font to be used to draw string
+ */
 void canvas_draw_str_ex(
     Canvas* canvas,
     uint8_t x,

+ 11 - 0
ui/common_dialogs.h

@@ -3,5 +3,16 @@
 #include <dialogs/dialogs.h>
 #include "../types/plugin_state.h"
 
+/**
+ * @brief Shows standard dialog about the fact that error occurred when loading config file
+ * @param plugin_state application state
+ * @return dialog button which user pressed to close the dialog
+ */
 DialogMessageButton totp_dialogs_config_loading_error(PluginState* plugin_state);
+
+/**
+ * @brief Shows standard dialog about the fact that error occurred when updating config file
+ * @param plugin_state application state
+ * @return dialog button which user pressed to close the dialog
+ */
 DialogMessageButton totp_dialogs_config_updating_error(PluginState* plugin_state);