MX 1 год назад
Родитель
Сommit
311bb96211

+ 1 - 1
application.fam

@@ -7,7 +7,7 @@ App(
     requires=["gui", "cli", "dialogs", "storage", "input", "notification", "bt"],
     stack_size=2 * 1024,
     order=20,
-    fap_version="5.130",
+    fap_version="5.140",
     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",

+ 8 - 4
services/config/config.c

@@ -738,15 +738,19 @@ bool totp_config_file_ensure_latest_encryption(
     uint8_t pin_length) {
     bool result = true;
     if(plugin_state->crypto_settings.crypto_version < CRYPTO_LATEST_VERSION) {
-        FURI_LOG_I(LOGGING_TAG, "Migration crypto from v%" PRIu8 " to v%" PRIu8 " is needed", plugin_state->crypto_settings.crypto_version, CRYPTO_LATEST_VERSION);
-        
+        FURI_LOG_I(
+            LOGGING_TAG,
+            "Migration crypto from v%" PRIu8 " to v%" PRIu8 " is needed",
+            plugin_state->crypto_settings.crypto_version,
+            CRYPTO_LATEST_VERSION);
+
 #ifndef TOTP_OBSOLETE_CRYPTO_V1_COMPATIBILITY_ENABLED
-        if (plugin_state->crypto_settings.crypto_version == 1) {
+        if(plugin_state->crypto_settings.crypto_version == 1) {
             furi_crash("Authenticator: Crypto v1 is not supported");
         }
 #endif
 #ifndef TOTP_OBSOLETE_CRYPTO_V2_COMPATIBILITY_ENABLED
-        if (plugin_state->crypto_settings.crypto_version == 2) {
+        if(plugin_state->crypto_settings.crypto_version == 2) {
             furi_crash("Authenticator: Crypto v2 is not supported");
         }
 #endif

+ 13 - 2
services/idle_timeout/idle_timeout.c

@@ -3,7 +3,7 @@
 #include <furi/core/timer.h>
 
 #define IDLE_TIMER_CHECK_PERIODICITY_SEC (1)
-#define SEC_TO_TICKS(sec) ((sec)*1000)
+#define SEC_TO_TICKS(sec) ((sec) * 1000)
 
 struct IdleTimeoutContext {
     FuriTimer* timer;
@@ -13,10 +13,12 @@ struct IdleTimeoutContext {
     uint16_t timeout_sec;
     uint16_t idle_period_sec;
     bool idle_handled;
+    bool is_paused;
 };
 
 static void idle_timer_callback(void* context) {
     IdleTimeoutContext* instance = context;
+    if(instance->is_paused) return;
     if(instance->activity_reported) {
         instance->idle_period_sec = 0;
         instance->idle_handled = false;
@@ -44,6 +46,7 @@ IdleTimeoutContext* idle_timeout_alloc(
     instance->timeout_sec = timeout_sec;
     instance->on_idle_callback = on_idle_callback;
     instance->on_idle_callback_context = on_idle_callback_context;
+    instance->is_paused = false;
     return instance;
 }
 
@@ -55,6 +58,14 @@ void idle_timeout_stop(IdleTimeoutContext* context) {
     furi_timer_stop(context->timer);
 }
 
+void idle_timeout_pause(IdleTimeoutContext* context) {
+    context->is_paused = true;
+}
+
+void idle_timeout_resume(IdleTimeoutContext* context) {
+    context->is_paused = false;
+}
+
 void idle_timeout_report_activity(IdleTimeoutContext* context) {
     context->activity_reported = true;
 }
@@ -63,4 +74,4 @@ void idle_timeout_free(IdleTimeoutContext* context) {
     furi_timer_stop(context->timer);
     furi_timer_free(context->timer);
     free(context);
-}
+}

+ 13 - 1
services/idle_timeout/idle_timeout.h

@@ -31,6 +31,18 @@ void idle_timeout_start(IdleTimeoutContext* context);
  */
 void idle_timeout_stop(IdleTimeoutContext* context);
 
+/**
+ * @brief Pauses IDLE timeout
+ * @param context IDLE timeout context
+ */
+void idle_timeout_pause(IdleTimeoutContext* context);
+
+/**
+ * @brief Resumes paused IDLE timeout
+ * @param context IDLE timeout context
+ */
+void idle_timeout_resume(IdleTimeoutContext* context);
+
 /**
  * @brief Reports activity to IDLE timeout
  * @param context IDLE timeout context
@@ -41,4 +53,4 @@ void idle_timeout_report_activity(IdleTimeoutContext* context);
  * @brief Disposes IDLE timeout and releases all the resources
  * @param context IDLE timeout context
  */
-void idle_timeout_free(IdleTimeoutContext* context);
+void idle_timeout_free(IdleTimeoutContext* context);

+ 2 - 2
types/token_info.c

@@ -8,8 +8,8 @@
 #include "common.h"
 #include "../services/crypto/crypto_facade.h"
 
-#define ESTIMATE_BASE32_PLAIN_LENGTH(base32_length) ((base32_length)*0.625f)
-#define ESTIMATE_BASE64_PLAIN_LENGTH(base64_length) ((base64_length)*0.75f)
+#define ESTIMATE_BASE32_PLAIN_LENGTH(base32_length) ((base32_length) * 0.625f)
+#define ESTIMATE_BASE64_PLAIN_LENGTH(base64_length) ((base64_length) * 0.75f)
 
 TokenInfo* token_info_alloc() {
     TokenInfo* tokenInfo = malloc(sizeof(TokenInfo));

+ 15 - 6
ui/scenes/add_new_token/totp_scene_add_new_token.c

@@ -34,7 +34,6 @@ typedef struct {
     size_t token_name_length;
     char* token_secret;
     size_t token_secret_length;
-    bool saved;
     Control selected_control;
     int16_t screen_y_offset;
     TokenHashAlgo algo;
@@ -98,7 +97,14 @@ static void ask_user_input(
         strlcpy(input_result.user_input, *user_input, INPUT_BUFFER_SIZE);
     }
 
+    if(plugin_state->idle_timeout_context != NULL) {
+        idle_timeout_pause(plugin_state->idle_timeout_context);
+    }
     totp_input_text(plugin_state->gui, header, &input_result);
+    if(plugin_state->idle_timeout_context != NULL) {
+        idle_timeout_report_activity(plugin_state->idle_timeout_context);
+        idle_timeout_resume(plugin_state->idle_timeout_context);
+    }
     if(input_result.success) {
         if(*user_input != NULL) {
             free(*user_input);
@@ -139,11 +145,14 @@ void totp_scene_add_new_token_activate(PluginState* plugin_state) {
     SceneState* scene_state = malloc(sizeof(SceneState));
     furi_check(scene_state != NULL);
     plugin_state->current_scene_state = scene_state;
-    scene_state->token_name = "Name";
+    scene_state->token_name = strdup("Name");
+    furi_check(scene_state->token_name != NULL);
     scene_state->token_name_length = strlen(scene_state->token_name);
-    scene_state->token_secret = "Secret";
+    scene_state->token_secret = strdup("Secret");
+    furi_check(scene_state->token_secret != NULL);
     scene_state->token_secret_length = strlen(scene_state->token_secret);
-    scene_state->initial_counter = "Counter";
+    scene_state->initial_counter = strdup("Counter");
+    furi_check(scene_state->initial_counter != NULL);
     scene_state->initial_counter_length = strlen(scene_state->initial_counter);
 
     scene_state->screen_y_offset = 0;
@@ -372,7 +381,7 @@ bool totp_scene_add_new_token_handle_event(
             break;
         }
         case InputKeyBack:
-            totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken);
+            totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu);
             break;
         default:
             break;
@@ -384,7 +393,7 @@ bool totp_scene_add_new_token_handle_event(
 
 void totp_scene_add_new_token_deactivate(PluginState* plugin_state) {
     if(plugin_state->current_scene_state == NULL) return;
-    SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
+    SceneState* scene_state = plugin_state->current_scene_state;
     free(scene_state->token_name);
     free(scene_state->token_secret);
 

+ 1 - 2
ui/scenes/generate_token/totp_scene_generate_token.c

@@ -426,14 +426,13 @@ bool totp_scene_generate_token_handle_event(
             break;
         }
         case InputKeyOk:
+            totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu);
             break;
         case InputKeyBack:
             break;
         default:
             break;
         }
-    } else if(event->input.type == InputTypeShort && event->input.key == InputKeyOk) {
-        totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu);
     }
 
     return true;

+ 4 - 2
ui/ui_controls.c

@@ -39,8 +39,10 @@ void ui_control_text_box_render(
             1);
     }
 
-    canvas_draw_str_aligned(
-        canvas, TEXT_BOX_MARGIN + 2, TEXT_BOX_MARGIN + 3 + y, AlignLeft, AlignTop, text);
+    if(text != NULL) {
+        canvas_draw_str_aligned(
+            canvas, TEXT_BOX_MARGIN + 2, TEXT_BOX_MARGIN + 3 + y, AlignLeft, AlignTop, text);
+    }
 }
 
 void ui_control_select_render(

+ 1 - 1
version.h

@@ -1,5 +1,5 @@
 #pragma once
 
 #define TOTP_APP_VERSION_MAJOR (5)
-#define TOTP_APP_VERSION_MINOR (13)
+#define TOTP_APP_VERSION_MINOR (14)
 #define TOTP_APP_VERSION_PATCH (0)