From 54fe1dbea8cf01c51dc1dfa89ba98e9251db9ece Mon Sep 17 00:00:00 2001 From: Alexander Kopachov Date: Wed, 20 Sep 2023 14:36:47 +0200 Subject: [PATCH] Implemented #203 (#204) * Initial changes on #203 * Fixiing builds * Dropped auto-gen file * Fixing build * Cleaning up sonar build * Few more * Trying another approach * Fixing ufbt-fm * Few more * One more * Dropped useless stuff * Removed unpublished `fal_embedded=True` as it is not yet available * CLang format changes * Updated .editorconfig for .json files --------- Co-authored-by: akopachov --- application.fam | 54 +++++++++++++++------------------------------ config/app/config.h | 44 ++++++++++++++++++------------------ totp_app.c | 4 ++-- 3 files changed, 42 insertions(+), 60 deletions(-) diff --git a/application.fam b/application.fam index c4c2cdf4eb8..46600ed72d0 100644 --- a/application.fam +++ b/application.fam @@ -4,15 +4,7 @@ App( apptype=FlipperAppType.EXTERNAL, entry_point="totp_app", cdefines=["APP_TOTP"], - requires=[ - "gui", - "cli", - "dialogs", - "storage", - "input", - "notification", - "bt" - ], + requires=["gui", "cli", "dialogs", "storage", "input", "notification", "bt"], stack_size=2 * 1024, order=20, fap_version="5.00", @@ -47,11 +39,11 @@ App( "wolfcrypt/src/hash.c", "wolfcrypt/src/sha.c", "wolfcrypt/src/sha256.c", - "wolfcrypt/src/sha512.c" + "wolfcrypt/src/sha512.c", ], cflags=["-Wno-error"], cdefines=["HAVE_CONFIG_H"], - cincludes=["config/wolfssl"] + cincludes=["config/wolfssl"], ), ], ) @@ -61,9 +53,7 @@ App( apptype=FlipperAppType.PLUGIN, entry_point="totp_cli_timezone_plugin_ep", requires=["totp"], - sources=[ - "cli/plugins/timezone/timezone.c", - "cli/cli_shared_methods.c"], + sources=["cli/plugins/timezone/timezone.c", "cli/cli_shared_methods.c"], ) App( @@ -91,7 +81,8 @@ App( "cli/plugins/list/list.c", "cli/cli_shared_methods.c", "cli/plugins/list/formatters/table/list_output_formatter_table.c", - "cli/plugins/list/formatters/tsv/list_output_formatter_tsv.c"], + "cli/plugins/list/formatters/tsv/list_output_formatter_tsv.c", + ], ) App( @@ -103,7 +94,8 @@ App( "cli/plugins/details/details.c", "cli/cli_shared_methods.c", "cli/plugins/details/formatters/table/details_output_formatter_table.c", - "cli/plugins/details/formatters/tsv/details_output_formatter_tsv.c"], + "cli/plugins/details/formatters/tsv/details_output_formatter_tsv.c", + ], ) App( @@ -114,7 +106,8 @@ App( sources=[ "cli/plugins/modify/add/add.c", "cli/plugins/modify/common.c", - "cli/cli_shared_methods.c"], + "cli/cli_shared_methods.c", + ], ) App( @@ -125,7 +118,8 @@ App( sources=[ "cli/plugins/modify/update/update.c", "cli/plugins/modify/common.c", - "cli/cli_shared_methods.c"], + "cli/cli_shared_methods.c", + ], ) App( @@ -133,9 +127,7 @@ App( apptype=FlipperAppType.PLUGIN, entry_point="totp_cli_delete_plugin_ep", requires=["totp"], - sources=[ - "cli/plugins/delete/delete.c", - "cli/cli_shared_methods.c"], + sources=["cli/plugins/delete/delete.c", "cli/cli_shared_methods.c"], ) App( @@ -143,9 +135,7 @@ App( apptype=FlipperAppType.PLUGIN, entry_point="totp_cli_move_plugin_ep", requires=["totp"], - sources=[ - "cli/plugins/move/move.c", - "cli/cli_shared_methods.c"], + sources=["cli/plugins/move/move.c", "cli/cli_shared_methods.c"], ) App( @@ -153,9 +143,7 @@ App( apptype=FlipperAppType.PLUGIN, entry_point="totp_cli_reset_plugin_ep", requires=["totp"], - sources=[ - "cli/plugins/reset/reset.c", - "cli/cli_shared_methods.c"], + sources=["cli/plugins/reset/reset.c", "cli/cli_shared_methods.c"], ) App( @@ -163,9 +151,7 @@ App( apptype=FlipperAppType.PLUGIN, entry_point="totp_cli_pin_plugin_ep", requires=["totp"], - sources=[ - "cli/plugins/pin/pin.c", - "cli/cli_shared_methods.c"], + sources=["cli/plugins/pin/pin.c", "cli/cli_shared_methods.c"], ) App( @@ -173,9 +159,7 @@ App( apptype=FlipperAppType.PLUGIN, entry_point="totp_cli_automation_plugin_ep", requires=["totp"], - sources=[ - "cli/plugins/automation/automation.c", - "cli/cli_shared_methods.c"], + sources=["cli/plugins/automation/automation.c", "cli/cli_shared_methods.c"], ) App( @@ -183,7 +167,5 @@ App( apptype=FlipperAppType.PLUGIN, entry_point="totp_cli_notification_plugin_ep", requires=["totp"], - sources=[ - "cli/plugins/notification/notification.c", - "cli/cli_shared_methods.c"], + sources=["cli/plugins/notification/notification.c", "cli/cli_shared_methods.c"], ) diff --git a/config/app/config.h b/config/app/config.h index c813b94f7b2..aea829616d8 100644 --- a/config/app/config.h +++ b/config/app/config.h @@ -1,3 +1,25 @@ +// List of compatible firmwares +#define TOTP_FIRMWARE_OFFICIAL_STABLE (1) +#define TOTP_FIRMWARE_OFFICIAL_DEV (2) +#define TOTP_FIRMWARE_XTREME_UL (3) +// End of list + +#if __has_include("ufbt_def.h") +#include "ufbt_def.h" +#endif + +#ifndef TOTP_TARGET_FIRMWARE +#if defined(TARGET_FIRMWARE_OFFICIAL) || defined(FW_ORIGIN_Official) +#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_OFFICIAL_STABLE +#elif defined(TARGET_FIRMWARE_UNLEASHED) || defined(FW_ORIGIN_Unleashed) +#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME_UL +#elif defined(TARGET_FIRMWARE_XTREME) || defined(FW_ORIGIN_Xtreme) +#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME_UL +#else +#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_OFFICIAL_STABLE +#endif +#endif + // Application automatic lock timeout if user IDLE. (ticks) #ifndef TOTP_AUTO_LOCK_IDLE_TIMEOUT_SEC #define TOTP_AUTO_LOCK_IDLE_TIMEOUT_SEC (60) @@ -21,25 +43,3 @@ #ifndef TOTP_UI_NO_ADD_NEW_TOKEN #define TOTP_UI_ADD_NEW_TOKEN_ENABLED #endif - -// List of compatible firmwares -#define TOTP_FIRMWARE_OFFICIAL_STABLE (1) -#define TOTP_FIRMWARE_OFFICIAL_DEV (2) -#define TOTP_FIRMWARE_XTREME_UL (3) -// End of list - -// Checking FlipC.org definitions (https://github.com/playmean/fap-list/issues/9) -#if defined(TARGET_FIRMWARE_OFFICIAL) -#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_OFFICIAL_STABLE -#elif defined(TARGET_FIRMWARE_UNLEASHED) -#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME_UL -#elif defined(TARGET_FIRMWARE_XTREME) -#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME_UL -#endif -// End of FlipC.org definition checks - -// If target firmware is not yet set, default it to OFW because there is no chance to force Flipper Devices to update their build pipelines :angry:. -// I'm still using Xtreme firmware, it is still the best one and I highly recommend it to everybody. -#ifndef TOTP_TARGET_FIRMWARE -#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_OFFICIAL_STABLE -#endif diff --git a/totp_app.c b/totp_app.c index adfd4a9a5ac..f49cb6b717d 100644 --- a/totp_app.c +++ b/totp_app.c @@ -230,14 +230,14 @@ int32_t totp_app() { return 254; } - TotpCliContext* cli_context = totp_cli_register_command_handler(plugin_state); - if(!totp_activate_initial_scene(plugin_state)) { FURI_LOG_E(LOGGING_TAG, "An error ocurred during activating initial scene\r\n"); totp_plugin_state_free(plugin_state); return 253; } + TotpCliContext* cli_context = totp_cli_register_command_handler(plugin_state); + // Affecting dolphin level dolphin_deed(DolphinDeedPluginStart);