Jelajahi Sumber

Merge totp from https://github.com/akopachov/flipper-zero_authenticator

# Conflicts:
#	totp/cli/cli.h
#	totp/cli/cli_shared_methods.c
#	totp/cli/plugins/automation/automation.c
#	totp/cli/plugins/export/export.c
#	totp/cli/plugins/notification/notification.c
#	totp/cli/plugins/pin/pin.c
Willy-JL 9 bulan lalu
induk
melakukan
59c83bc0ca

+ 1 - 1
totp/.gitsubtree

@@ -1,2 +1,2 @@
 https://github.com/xMasterX/all-the-plugins dev base_pack/totp e4bf49882c5f590746e35583d821a926c757d9e7
-https://github.com/akopachov/flipper-zero_authenticator master totp bc9acd9fd860bcffeaea5641b3f6a4d04e342bae
+https://github.com/akopachov/flipper-zero_authenticator master totp 6e9b94b319a8dc945b82e8185f3981ce49f3246d

+ 4 - 0
totp/.ofwcatalog/CHANGELOG.md

@@ -1,5 +1,9 @@
 # Changelog
 
+## v 5.17.3 - Apr 11 2025
+
+* fix: compatibility with SDK version 1.3 f7 ([#256](https://github.com/akopachov/flipper-zero_authenticator/issues/256))
+
 ## v5.17.1 - 26 Mar 2025
 
 * fix: HOTP counter is not increasing when "OK" button long-pressed ([#253](https://github.com/akopachov/flipper-zero_authenticator/issues/253))

+ 1 - 1
totp/application.fam

@@ -7,7 +7,7 @@ App(
     requires=["gui", "cli", "dialogs", "storage", "input", "notification", "bt"],
     stack_size=2 * 1024,
     order=20,
-    fap_version="5.171",
+    fap_version="5.173",
     fap_author="Alexander Kopachov (@akopachov)",
     fap_description="Software-based TOTP/HOTP authenticator for Flipper Zero device",
     fap_weburl="https://github.com/akopachov/flipper-zero_authenticator",

+ 10 - 4
totp/cli/cli.c

@@ -21,6 +21,12 @@
 #include "cli_plugin_interface.h"
 #include "../app_api_interface.h"
 
+#if !(__has_include(<toolbox/cli/cli_registry.h>))
+#define cli_registry_add_command cli_add_command
+#define cli_registry_delete_command cli_delete_command
+#define CliRegistry Cli
+#endif
+
 struct TotpCliContext {
     PluginState* plugin_state;
     CompositeApiResolver* plugin_api_resolver;
@@ -152,7 +158,7 @@ static void totp_cli_handler(PipeSide* pipe, FuriString* args, void* context) {
 }
 
 TotpCliContext* totp_cli_register_command_handler(PluginState* plugin_state) {
-    Cli* cli = furi_record_open(RECORD_CLI);
+    CliRegistry* cli = furi_record_open(RECORD_CLI);
     TotpCliContext* context = malloc(sizeof(TotpCliContext));
     furi_check(context != NULL);
     context->plugin_state = plugin_state;
@@ -161,15 +167,15 @@ TotpCliContext* totp_cli_register_command_handler(PluginState* plugin_state) {
     composite_api_resolver_add(context->plugin_api_resolver, firmware_api_interface);
     composite_api_resolver_add(context->plugin_api_resolver, application_api_interface);
 
-    cli_add_command(
+    cli_registry_add_command(
         cli, TOTP_CLI_COMMAND_NAME, CliCommandFlagParallelSafe, totp_cli_handler, context);
     furi_record_close(RECORD_CLI);
     return context;
 }
 
 void totp_cli_unregister_command_handler(TotpCliContext* context) {
-    Cli* cli = furi_record_open(RECORD_CLI);
-    cli_delete_command(cli, TOTP_CLI_COMMAND_NAME);
+    CliRegistry* cli = furi_record_open(RECORD_CLI);
+    cli_registry_delete_command(cli, TOTP_CLI_COMMAND_NAME);
 
     composite_api_resolver_free(context->plugin_api_resolver);
 

+ 6 - 1
totp/cli/cli.h

@@ -1,7 +1,12 @@
 #pragma once
 
 #include <cli/cli.h>
-
+#if __has_include(<toolbox/cli/cli_command.h>)
+#include <toolbox/cli/cli_command.h>
+#endif
+#if __has_include(<toolbox/cli/cli_registry.h>)
+#include <toolbox/cli/cli_registry.h>
+#endif
 #include "../types/plugin_state.h"
 
 typedef struct TotpCliContext TotpCliContext;

+ 2 - 0
totp/cli/cli_helpers.h

@@ -33,6 +33,8 @@ extern "C" {
 #define TOTP_CLI_PRINTF_INFO(format, ...) \
     TOTP_CLI_PRINTF_COLORFUL(TOTP_CLI_COLOR_INFO, format, ##__VA_ARGS__)
 
+#define TOTP_CLI_NL() TOTP_CLI_PRINTF("\r\n")
+
 #define TOTP_CLI_LOCK_UI(plugin_state)                                  \
     Scene __previous_scene = plugin_state->current_scene;               \
     totp_scene_director_activate_scene(plugin_state, TotpSceneStandby); \

+ 2 - 2
totp/cli/cli_shared_methods.c

@@ -43,7 +43,7 @@ bool totp_cli_read_line(PipeSide* pipe, FuriString* out_str, bool mask_user_inpu
             pipe_receive(pipe, &c2, 1);
             pipe_receive(pipe, &c2, 1);
         } else if(c == CliKeyETX) {
-            printf("\r\n");
+            TOTP_CLI_NL();
             return false;
         } else if(
             (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
@@ -62,7 +62,7 @@ bool totp_cli_read_line(PipeSide* pipe, FuriString* out_str, bool mask_user_inpu
                 furi_string_left(out_str, out_str_size - 1);
             }
         } else if(c == CliKeyCR) {
-            printf("\r\n");
+            TOTP_CLI_NL();
             break;
         }
     }

+ 2 - 2
totp/cli/plugins/automation/automation.c

@@ -131,7 +131,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
                 print_initial_delay(
                     plugin_state->automation_initial_delay, TOTP_CLI_COLOR_SUCCESS);
                 TOTP_CLI_PRINTF_SUCCESS(" sec.]");
-                printf("\r\n");
+                TOTP_CLI_NL();
             } else {
                 TOTP_CLI_PRINT_ERROR_UPDATING_CONFIG_FILE();
             }
@@ -154,7 +154,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
             TOTP_CLI_PRINTF_INFO(" [");
             print_initial_delay(plugin_state->automation_initial_delay, TOTP_CLI_COLOR_INFO);
             TOTP_CLI_PRINTF_INFO(" sec.]");
-            printf("\r\n");
+            TOTP_CLI_NL();
         }
     } while(false);
 

+ 2 - 2
totp/cli/plugins/export/export.c

@@ -90,7 +90,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
 
     size_t original_index = totp_token_info_iterator_get_current_token_index(iterator_context);
 
-    printf("\r\n");
+    TOTP_CLI_NL();
     TOTP_CLI_PRINTF("# --- EXPORT LIST BEGIN ---\r\n");
 
     for(size_t i = 0; i < total_count; i++) {
@@ -116,7 +116,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
         } else {
             TOTP_CLI_PRINTF("&period=%" PRIu8, token_info->duration);
         }
-        printf("\r\n");
+        TOTP_CLI_NL();
     }
 
     TOTP_CLI_PRINTF("# --- EXPORT LIST END ---\r\n\r\n");

+ 2 - 2
totp/cli/plugins/notification/notification.c

@@ -67,7 +67,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
             if(totp_config_file_update_notification_method(plugin_state)) {
                 TOTP_CLI_PRINTF_SUCCESS("Notification method is set to ");
                 totp_cli_command_notification_print_method(new_method, TOTP_CLI_COLOR_SUCCESS);
-                printf("\r\n");
+                TOTP_CLI_NL();
             } else {
                 TOTP_CLI_PRINT_ERROR_UPDATING_CONFIG_FILE();
             }
@@ -77,7 +77,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
             TOTP_CLI_PRINTF_INFO("Current notification method is ");
             totp_cli_command_notification_print_method(
                 plugin_state->notification_method, TOTP_CLI_COLOR_INFO);
-            printf("\r\n");
+            TOTP_CLI_NL();
         }
     } while(false);
 

+ 1 - 1
totp/cli/plugins/pin/pin.c

@@ -65,7 +65,7 @@ static bool totp_cli_read_pin(PipeSide* pipe, uint8_t* pin, uint8_t* pin_length)
                 TOTP_CLI_DELETE_LAST_CHAR();
             }
         } else if(c == CliKeyCR) {
-            printf("\r\n");
+            TOTP_CLI_NL();
             break;
         }
     }

+ 1 - 1
totp/version.h

@@ -2,4 +2,4 @@
 
 #define TOTP_APP_VERSION_MAJOR (5)
 #define TOTP_APP_VERSION_MINOR (17)
-#define TOTP_APP_VERSION_PATCH (1)
+#define TOTP_APP_VERSION_PATCH (3)