MX 2 лет назад
Родитель
Сommit
d2d908eea5

+ 2 - 2
apps_broken_by_last_refactors/nfc_maker/strnlen.c → apps_broken_by_last_refactors/nfc_maker/newstrnlen.c

@@ -1,6 +1,6 @@
-#include "strnlen.h"
+#include "newstrnlen.h"
 
-size_t strnlen(const char* s, size_t maxlen) {
+size_t newstrnlen(const char* s, size_t maxlen) {
     size_t len;
 
     for(len = 0; len < maxlen; len++, s++) {

+ 1 - 1
apps_broken_by_last_refactors/nfc_maker/strnlen.h → apps_broken_by_last_refactors/nfc_maker/newstrnlen.h

@@ -3,4 +3,4 @@
 
 #include <stddef.h>
 
-size_t strnlen(const char* s, size_t maxlen);
+size_t newstrnlen(const char* s, size_t maxlen);

+ 4 - 5
apps_broken_by_last_refactors/nfc_maker/nfc_maker.h

@@ -1,6 +1,3 @@
-#pragma once
-
-#include <furi.h>
 #include <gui/gui.h>
 #include <gui/view.h>
 #include <gui/modules/validators.h>
@@ -14,9 +11,11 @@
 #include "scenes/nfc_maker_scene.h"
 #include <lib/flipper_format/flipper_format.h>
 #include <toolbox/name_generator.h>
-#include <applications/main/nfc/nfc_app_i.h>
 #include <furi_hal_bt.h>
-#include "strnlen.h"
+#include "newstrnlen.h"
+
+#define NFC_MK_APP_FOLDER EXT_PATH("nfc")
+#define NFC_MK_APP_EXTENSION ".nfc"
 
 #define MAC_INPUT_LEN GAP_MAC_ADDR_SIZE
 #define MAIL_INPUT_LEN 128

+ 6 - 6
apps_broken_by_last_refactors/nfc_maker/nfc_maker_validators.c

@@ -2,15 +2,15 @@
 #include "nfc_maker_validators.h"
 #include <storage/storage.h>
 
-struct ValidatorIsFile {
+struct NFCMakerValidatorIsFile {
     char* app_path_folder;
     const char* app_extension;
     char* current_name;
 };
 
-bool validator_is_file_callback(const char* text, FuriString* error, void* context) {
+bool nfc_maker_validator_is_file_callback(const char* text, FuriString* error, void* context) {
     furi_assert(context);
-    ValidatorIsFile* instance = context;
+    NFCMakerValidatorIsFile* instance = context;
 
     if(instance->current_name != NULL) {
         if(strcmp(instance->current_name, text) == 0) {
@@ -34,11 +34,11 @@ bool validator_is_file_callback(const char* text, FuriString* error, void* conte
     return ret;
 }
 
-ValidatorIsFile* validator_is_file_alloc_init(
+NFCMakerValidatorIsFile* nfc_maker_validator_is_file_alloc_init(
     const char* app_path_folder,
     const char* app_extension,
     const char* current_name) {
-    ValidatorIsFile* instance = malloc(sizeof(ValidatorIsFile));
+    NFCMakerValidatorIsFile* instance = malloc(sizeof(NFCMakerValidatorIsFile));
 
     instance->app_path_folder = strdup(app_path_folder);
     instance->app_extension = app_extension;
@@ -49,7 +49,7 @@ ValidatorIsFile* validator_is_file_alloc_init(
     return instance;
 }
 
-void validator_is_file_free(ValidatorIsFile* instance) {
+void nfc_maker_validator_is_file_free(NFCMakerValidatorIsFile* instance) {
     furi_assert(instance);
     free(instance->app_path_folder);
     free(instance->current_name);

+ 4 - 4
apps_broken_by_last_refactors/nfc_maker/nfc_maker_validators.h

@@ -5,16 +5,16 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-typedef struct ValidatorIsFile ValidatorIsFile;
+typedef struct NFCMakerValidatorIsFile NFCMakerValidatorIsFile;
 
-ValidatorIsFile* validator_is_file_alloc_init(
+NFCMakerValidatorIsFile* nfc_maker_validator_is_file_alloc_init(
     const char* app_path_folder,
     const char* app_extension,
     const char* current_name);
 
-void validator_is_file_free(ValidatorIsFile* instance);
+void nfc_maker_validator_is_file_free(NFCMakerValidatorIsFile* instance);
 
-bool validator_is_file_callback(const char* text, FuriString* error, void* context);
+bool nfc_maker_validator_is_file_callback(const char* text, FuriString* error, void* context);
 
 #ifdef __cplusplus
 }

+ 13 - 12
apps_broken_by_last_refactors/nfc_maker/scenes/nfc_maker_scene_result.c

@@ -1,4 +1,5 @@
 #include "../nfc_maker.h"
+#include <furi_hal_random.h>
 
 enum PopupEvent {
     PopupEventExit,
@@ -17,7 +18,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
 
     FlipperFormat* file = flipper_format_file_alloc(furi_record_open(RECORD_STORAGE));
     FuriString* path = furi_string_alloc();
-    furi_string_printf(path, NFC_APP_FOLDER "/%s" NFC_APP_EXTENSION, app->save_buf);
+    furi_string_printf(path, NFC_MK_APP_FOLDER "/%s" NFC_MK_APP_EXTENSION, app->save_buf);
 
     uint32_t pages = 135;
     size_t size = pages * 4;
@@ -104,15 +105,15 @@ void nfc_maker_scene_result_on_enter(void* context) {
                 vcard,
                 "FN:%s%s%s\r\n",
                 app->small_buf1,
-                strnlen(app->small_buf2, SMALL_INPUT_LEN) ? " " : "",
+                newstrnlen(app->small_buf2, SMALL_INPUT_LEN) ? " " : "",
                 app->small_buf2);
-            if(strnlen(app->mail_buf, MAIL_INPUT_LEN)) {
+            if(newstrnlen(app->mail_buf, MAIL_INPUT_LEN)) {
                 furi_string_cat_printf(vcard, "EMAIL:%s\r\n", app->mail_buf);
             }
-            if(strnlen(app->phone_buf, PHONE_INPUT_LEN)) {
+            if(newstrnlen(app->phone_buf, PHONE_INPUT_LEN)) {
                 furi_string_cat_printf(vcard, "TEL:%s\r\n", app->phone_buf);
             }
-            if(strnlen(app->big_buf, BIG_INPUT_LEN)) {
+            if(newstrnlen(app->big_buf, BIG_INPUT_LEN)) {
                 furi_string_cat_printf(vcard, "URL:%s\r\n", app->big_buf);
             }
             furi_string_cat_printf(vcard, "END:VCARD\r\n");
@@ -127,7 +128,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
             tnf = 0x01; // NFC Forum well-known type [NFC RTD]
             type = "\x55";
 
-            data_len = strnlen(app->big_buf, BIG_INPUT_LEN);
+            data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
             payload_len = data_len + 1;
             payload = malloc(payload_len);
 
@@ -140,7 +141,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
             tnf = 0x01; // NFC Forum well-known type [NFC RTD]
             type = "\x55";
 
-            data_len = strnlen(app->mail_buf, MAIL_INPUT_LEN);
+            data_len = newstrnlen(app->mail_buf, MAIL_INPUT_LEN);
             payload_len = data_len + 1;
             payload = malloc(payload_len);
 
@@ -153,7 +154,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
             tnf = 0x01; // NFC Forum well-known type [NFC RTD]
             type = "\x55";
 
-            data_len = strnlen(app->phone_buf, PHONE_INPUT_LEN);
+            data_len = newstrnlen(app->phone_buf, PHONE_INPUT_LEN);
             payload_len = data_len + 1;
             payload = malloc(payload_len);
 
@@ -166,7 +167,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
             tnf = 0x01; // NFC Forum well-known type [NFC RTD]
             type = "\x54";
 
-            data_len = strnlen(app->big_buf, BIG_INPUT_LEN);
+            data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
             payload_len = data_len + 3;
             payload = malloc(payload_len);
 
@@ -181,7 +182,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
             tnf = 0x01; // NFC Forum well-known type [NFC RTD]
             type = "\x55";
 
-            data_len = strnlen(app->big_buf, BIG_INPUT_LEN);
+            data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
             payload_len = data_len + 1;
             payload = malloc(payload_len);
 
@@ -194,8 +195,8 @@ void nfc_maker_scene_result_on_enter(void* context) {
             tnf = 0x02; // Media-type [RFC 2046]
             type = "application/vnd.wfa.wsc";
 
-            uint8_t ssid_len = strnlen(app->small_buf1, SMALL_INPUT_LEN);
-            uint8_t pass_len = strnlen(app->small_buf2, SMALL_INPUT_LEN);
+            uint8_t ssid_len = newstrnlen(app->small_buf1, SMALL_INPUT_LEN);
+            uint8_t pass_len = newstrnlen(app->small_buf2, SMALL_INPUT_LEN);
             uint8_t data_len = ssid_len + pass_len;
             payload_len = data_len + 39;
             payload = malloc(payload_len);

+ 4 - 3
apps_broken_by_last_refactors/nfc_maker/scenes/nfc_maker_scene_save.c

@@ -26,9 +26,10 @@ void nfc_maker_scene_save_on_enter(void* context) {
         BIG_INPUT_LEN,
         true);
 
-    ValidatorIsFile* validator_is_file =
-        validator_is_file_alloc_init(NFC_APP_FOLDER, NFC_APP_EXTENSION, NULL);
-    nfc_maker_text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
+    NFCMakerValidatorIsFile* validator_is_file =
+        nfc_maker_validator_is_file_alloc_init(NFC_MK_APP_FOLDER, NFC_MK_APP_EXTENSION, NULL);
+    nfc_maker_text_input_set_validator(
+        text_input, nfc_maker_validator_is_file_callback, validator_is_file);
 
     view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
 }