From 838df4c9ea67d390e609d7919cbdc1ca0bb26412 Mon Sep 17 00:00:00 2001 From: gornekich Date: Wed, 2 Feb 2022 18:58:52 +0300 Subject: [PATCH] [FL-2229] New assets paths (#978) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * assets: change resources paths * apps: rework nfc, irda and subghz with new assets path * subghz: remove unused paths * subghz: fix incorrect path * badusb and u2f fix Co-authored-by: あく Co-authored-by: nminaylov --- .../archive/helpers/archive_browser.h | 2 +- .../scenes/bad_usb_scene_file_select.c | 2 +- applications/irda/scene/irda_app_scene.h | 4 ++-- applications/nfc/helpers/nfc_emv_parser.c | 7 +++--- .../subghz/scenes/subghz_scene_read_raw.c | 2 +- .../subghz/scenes/subghz_scene_save_name.c | 2 +- applications/subghz/subghz.c | 8 +++---- applications/subghz/subghz_cli.c | 8 +++---- applications/subghz/subghz_i.c | 20 ++++++------------ applications/u2f/u2f_data.c | 4 ++-- .../irda/{universal => assets}/tv.ir | 0 assets/resources/nfc/{emv => assets}/aid.nfc | 0 .../nfc/{emv => assets}/country_code.nfc | 0 .../nfc/{emv => assets}/currency_code.nfc | 0 .../resources/subghz/{ => assets}/came_atomo | 0 .../subghz/{ => assets}/keeloq_mfcodes | 0 .../subghz/{ => assets}/keeloq_mfcodes_user | 0 .../subghz/{ => assets}/nice_flor_s_rx | 0 .../subghz/{ => assets}/nice_flor_s_tx | 0 assets/resources/u2f/{ => assets}/cert.der | Bin .../resources/u2f/{ => assets}/cert_key.u2f | 0 lib/subghz/protocols/subghz_protocol_common.h | 2 -- lib/subghz/protocols/subghz_protocol_raw.c | 7 +----- 23 files changed, 28 insertions(+), 40 deletions(-) mode change 100644 => 100755 applications/subghz/subghz_i.c rename assets/resources/irda/{universal => assets}/tv.ir (100%) rename assets/resources/nfc/{emv => assets}/aid.nfc (100%) rename assets/resources/nfc/{emv => assets}/country_code.nfc (100%) rename assets/resources/nfc/{emv => assets}/currency_code.nfc (100%) rename assets/resources/subghz/{ => assets}/came_atomo (100%) rename assets/resources/subghz/{ => assets}/keeloq_mfcodes (100%) rename assets/resources/subghz/{ => assets}/keeloq_mfcodes_user (100%) rename assets/resources/subghz/{ => assets}/nice_flor_s_rx (100%) rename assets/resources/subghz/{ => assets}/nice_flor_s_tx (100%) rename assets/resources/u2f/{ => assets}/cert.der (100%) rename assets/resources/u2f/{ => assets}/cert_key.u2f (100%) mode change 100644 => 100755 lib/subghz/protocols/subghz_protocol_raw.c diff --git a/applications/archive/helpers/archive_browser.h b/applications/archive/helpers/archive_browser.h index 519fab75..44bce914 100644 --- a/applications/archive/helpers/archive_browser.h +++ b/applications/archive/helpers/archive_browser.h @@ -8,7 +8,7 @@ static const char* tab_default_paths[] = { [ArchiveTabFavorites] = "/any/favorites", [ArchiveTabIButton] = "/any/ibutton", [ArchiveTabNFC] = "/any/nfc", - [ArchiveTabSubGhz] = "/any/subghz/saved", + [ArchiveTabSubGhz] = "/any/subghz", [ArchiveTabLFRFID] = "/any/lfrfid", [ArchiveTabIrda] = "/any/irda", [ArchiveTabBrowser] = "/any", diff --git a/applications/bad_usb/scenes/bad_usb_scene_file_select.c b/applications/bad_usb/scenes/bad_usb_scene_file_select.c index 2ba673bc..678a003c 100644 --- a/applications/bad_usb/scenes/bad_usb_scene_file_select.c +++ b/applications/bad_usb/scenes/bad_usb_scene_file_select.c @@ -19,7 +19,7 @@ void bad_usb_scene_file_select_on_enter(void* context) { BadUsbApp* bad_usb = context; if(bad_usb_file_select(bad_usb)) { - scene_manager_next_scene(bad_usb->scene_manager, BadUsbAppViewWork); + scene_manager_next_scene(bad_usb->scene_manager, BadUsbSceneWork); } else { //scene_manager_previous_scene(bad_usb->scene_manager); view_dispatcher_stop(bad_usb->view_dispatcher); diff --git a/applications/irda/scene/irda_app_scene.h b/applications/irda/scene/irda_app_scene.h index 81915924..9de48e18 100644 --- a/applications/irda/scene/irda_app_scene.h +++ b/applications/irda/scene/irda_app_scene.h @@ -159,7 +159,7 @@ class IrdaAppSceneUniversalTV : public IrdaAppSceneUniversalCommon { public: void on_enter(IrdaApp* app) final; IrdaAppSceneUniversalTV() - : IrdaAppSceneUniversalCommon("/ext/irda/universal/tv.ir") { + : IrdaAppSceneUniversalCommon("/ext/irda/assets/tv.ir") { } ~IrdaAppSceneUniversalTV() { } @@ -169,7 +169,7 @@ class IrdaAppSceneUniversalAudio : public IrdaAppSceneUniversalCommon { public: void on_enter(IrdaApp* app) final; IrdaAppSceneUniversalAudio() - : IrdaAppSceneUniversalCommon("/ext/irda/universal/audio.ir") { + : IrdaAppSceneUniversalCommon("/ext/irda/assets/audio.ir") { } ~IrdaAppSceneUniversalAudio() { } diff --git a/applications/nfc/helpers/nfc_emv_parser.c b/applications/nfc/helpers/nfc_emv_parser.c index 54c6c203..4012ff45 100755 --- a/applications/nfc/helpers/nfc_emv_parser.c +++ b/applications/nfc/helpers/nfc_emv_parser.c @@ -44,7 +44,7 @@ bool nfc_emv_parser_get_aid_name( for(uint8_t i = 0; i < aid_len; i++) { string_cat_printf(key, "%02X", aid[i]); } - if(nfc_emv_parser_search_data(storage, "/ext/nfc/emv/aid.nfc", key, aid_name)) { + if(nfc_emv_parser_search_data(storage, "/ext/nfc/assets/aid.nfc", key, aid_name)) { parsed = true; } string_clear(key); @@ -58,7 +58,7 @@ bool nfc_emv_parser_get_country_name( bool parsed = false; string_t key; string_init_printf(key, "%04X", country_code); - if(nfc_emv_parser_search_data(storage, "/ext/nfc/emv/country_code.nfc", key, country_name)) { + if(nfc_emv_parser_search_data(storage, "/ext/nfc/assets/country_code.nfc", key, country_name)) { parsed = true; } string_clear(key); @@ -72,7 +72,8 @@ bool nfc_emv_parser_get_currency_name( bool parsed = false; string_t key; string_init_printf(key, "%04X", currency_code); - if(nfc_emv_parser_search_data(storage, "/ext/nfc/emv/currency_code.nfc", key, currency_name)) { + if(nfc_emv_parser_search_data( + storage, "/ext/nfc/assets/currency_code.nfc", key, currency_name)) { parsed = true; } string_clear(key); diff --git a/applications/subghz/scenes/subghz_scene_read_raw.c b/applications/subghz/scenes/subghz_scene_read_raw.c index 481138dc..170d3c7d 100644 --- a/applications/subghz/scenes/subghz_scene_read_raw.c +++ b/applications/subghz/scenes/subghz_scene_read_raw.c @@ -23,7 +23,7 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) { path_extract_filename_no_ext(string_get_cstr(temp_str), temp_str); strcpy(subghz->file_name, string_get_cstr(temp_str)); string_printf( - temp_str, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION); + temp_str, "%s/%s%s", SUBGHZ_APP_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION); subghz_protocol_raw_set_last_file_name( (SubGhzProtocolRAW*)subghz->txrx->protocol_result, string_get_cstr(temp_str)); diff --git a/applications/subghz/scenes/subghz_scene_save_name.c b/applications/subghz/scenes/subghz_scene_save_name.c index 142ba7c9..ee1df00f 100644 --- a/applications/subghz/scenes/subghz_scene_save_name.c +++ b/applications/subghz/scenes/subghz_scene_save_name.c @@ -39,7 +39,7 @@ void subghz_scene_save_name_on_enter(void* context) { dev_name_empty); ValidatorIsFile* validator_is_file = - validator_is_file_alloc_init(SUBGHZ_APP_PATH_FOLDER, SUBGHZ_APP_EXTENSION); + validator_is_file_alloc_init(SUBGHZ_APP_FOLDER, SUBGHZ_APP_EXTENSION); text_input_set_validator(text_input, validator_is_file_callback, validator_is_file); view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTextInput); diff --git a/applications/subghz/subghz.c b/applications/subghz/subghz.c index f13c86d6..4f442562 100644 --- a/applications/subghz/subghz.c +++ b/applications/subghz/subghz.c @@ -284,10 +284,10 @@ int32_t subghz_app(void* p) { //Load database bool load_database = - subghz_parser_load_keeloq_file(subghz->txrx->parser, "/ext/subghz/keeloq_mfcodes"); - subghz_parser_load_keeloq_file(subghz->txrx->parser, "/ext/subghz/keeloq_mfcodes_user"); - subghz_parser_load_nice_flor_s_file(subghz->txrx->parser, "/ext/subghz/nice_flor_s_rx"); - subghz_parser_load_came_atomo_file(subghz->txrx->parser, "/ext/subghz/came_atomo"); + subghz_parser_load_keeloq_file(subghz->txrx->parser, "/ext/subghz/assets/keeloq_mfcodes"); + subghz_parser_load_keeloq_file(subghz->txrx->parser, "/ext/subghz/assets/keeloq_mfcodes_user"); + subghz_parser_load_nice_flor_s_file(subghz->txrx->parser, "/ext/subghz/assets/nice_flor_s_rx"); + subghz_parser_load_came_atomo_file(subghz->txrx->parser, "/ext/subghz/assets/came_atomo"); // Check argument and run corresponding scene if(p && subghz_key_load(subghz, p)) { diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c index b91b9a4b..c54533d9 100644 --- a/applications/subghz/subghz_cli.c +++ b/applications/subghz/subghz_cli.c @@ -215,10 +215,10 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) { furi_check(instance->stream); SubGhzParser* parser = subghz_parser_alloc(); - subghz_parser_load_keeloq_file(parser, "/ext/subghz/keeloq_mfcodes"); - subghz_parser_load_keeloq_file(parser, "/ext/subghz/keeloq_mfcodes_user"); - subghz_parser_load_nice_flor_s_file(parser, "/ext/subghz/nice_flor_s_rx"); - subghz_parser_load_came_atomo_file(parser, "/ext/subghz/came_atomo"); + subghz_parser_load_keeloq_file(parser, "/ext/subghz/assets/keeloq_mfcodes"); + subghz_parser_load_keeloq_file(parser, "/ext/subghz/assets/keeloq_mfcodes_user"); + subghz_parser_load_nice_flor_s_file(parser, "/ext/subghz/assets/nice_flor_s_rx"); + subghz_parser_load_came_atomo_file(parser, "/ext/subghz/assets/came_atomo"); subghz_parser_enable_dump_text(parser, subghz_cli_command_rx_text_callback, instance); // Configure radio diff --git a/applications/subghz/subghz_i.c b/applications/subghz/subghz_i.c old mode 100644 new mode 100755 index 5a1f67fe..87537ca2 --- a/applications/subghz/subghz_i.c +++ b/applications/subghz/subghz_i.c @@ -284,7 +284,7 @@ bool subghz_get_next_name_file(SubGhz* subghz) { if(strcmp(subghz->file_name, "")) { //get the name of the next free file storage_get_next_filename( - storage, SUBGHZ_RAW_PATH_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION, temp_str); + storage, SUBGHZ_RAW_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION, temp_str); strcpy(subghz->file_name, string_get_cstr(temp_str)); res = true; @@ -319,15 +319,9 @@ bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name) { dialog_message_show_storage_error(subghz->dialogs, "Cannot create\nfolder"); break; } - // Create saved directory if necessary - if(!storage_simply_mkdir(storage, SUBGHZ_APP_PATH_FOLDER)) { - dialog_message_show_storage_error(subghz->dialogs, "Cannot create\nfolder"); - break; - } // First remove subghz device file if it was saved - string_printf( - dev_file_name, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, dev_name, SUBGHZ_APP_EXTENSION); + string_printf(dev_file_name, "%s/%s%s", SUBGHZ_APP_FOLDER, dev_name, SUBGHZ_APP_EXTENSION); if(!storage_simply_remove(storage, string_get_cstr(dev_file_name))) { break; @@ -386,7 +380,7 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) { // Input events and views are managed by file_select bool res = dialog_file_select_show( subghz->dialogs, - SUBGHZ_APP_PATH_FOLDER, + SUBGHZ_APP_FOLDER, SUBGHZ_APP_EXTENSION, subghz->file_name, sizeof(subghz->file_name), @@ -394,7 +388,7 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) { if(res) { string_printf( - file_name, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION); + file_name, "%s/%s%s", SUBGHZ_APP_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION); res = subghz_key_load(subghz, string_get_cstr(file_name)); } @@ -413,10 +407,10 @@ bool subghz_rename_file(SubGhz* subghz) { Storage* storage = furi_record_open("storage"); string_init_printf( - old_path, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, subghz->file_name_tmp, SUBGHZ_APP_EXTENSION); + old_path, "%s/%s%s", SUBGHZ_APP_FOLDER, subghz->file_name_tmp, SUBGHZ_APP_EXTENSION); string_init_printf( - new_path, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION); + new_path, "%s/%s%s", SUBGHZ_APP_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION); FS_Error fs_result = storage_common_rename(storage, string_get_cstr(old_path), string_get_cstr(new_path)); @@ -439,7 +433,7 @@ bool subghz_delete_file(SubGhz* subghz) { Storage* storage = furi_record_open("storage"); string_t file_path; string_init_printf( - file_path, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, subghz->file_name_tmp, SUBGHZ_APP_EXTENSION); + file_path, "%s/%s%s", SUBGHZ_APP_FOLDER, subghz->file_name_tmp, SUBGHZ_APP_EXTENSION); bool result = storage_simply_remove(storage, string_get_cstr(file_path)); furi_record_close("storage"); diff --git a/applications/u2f/u2f_data.c b/applications/u2f/u2f_data.c index 1de86164..f517d222 100644 --- a/applications/u2f/u2f_data.c +++ b/applications/u2f/u2f_data.c @@ -8,8 +8,8 @@ #define TAG "U2F" #define U2F_DATA_FOLDER "/any/u2f/" -#define U2F_CERT_FILE U2F_DATA_FOLDER "cert.der" -#define U2F_CERT_KEY_FILE U2F_DATA_FOLDER "cert_key.u2f" +#define U2F_CERT_FILE U2F_DATA_FOLDER "assets/cert.der" +#define U2F_CERT_KEY_FILE U2F_DATA_FOLDER "assets/cert_key.u2f" #define U2F_KEY_FILE U2F_DATA_FOLDER "key.u2f" #define U2F_CNT_FILE U2F_DATA_FOLDER "cnt.u2f" diff --git a/assets/resources/irda/universal/tv.ir b/assets/resources/irda/assets/tv.ir similarity index 100% rename from assets/resources/irda/universal/tv.ir rename to assets/resources/irda/assets/tv.ir diff --git a/assets/resources/nfc/emv/aid.nfc b/assets/resources/nfc/assets/aid.nfc similarity index 100% rename from assets/resources/nfc/emv/aid.nfc rename to assets/resources/nfc/assets/aid.nfc diff --git a/assets/resources/nfc/emv/country_code.nfc b/assets/resources/nfc/assets/country_code.nfc similarity index 100% rename from assets/resources/nfc/emv/country_code.nfc rename to assets/resources/nfc/assets/country_code.nfc diff --git a/assets/resources/nfc/emv/currency_code.nfc b/assets/resources/nfc/assets/currency_code.nfc similarity index 100% rename from assets/resources/nfc/emv/currency_code.nfc rename to assets/resources/nfc/assets/currency_code.nfc diff --git a/assets/resources/subghz/came_atomo b/assets/resources/subghz/assets/came_atomo similarity index 100% rename from assets/resources/subghz/came_atomo rename to assets/resources/subghz/assets/came_atomo diff --git a/assets/resources/subghz/keeloq_mfcodes b/assets/resources/subghz/assets/keeloq_mfcodes similarity index 100% rename from assets/resources/subghz/keeloq_mfcodes rename to assets/resources/subghz/assets/keeloq_mfcodes diff --git a/assets/resources/subghz/keeloq_mfcodes_user b/assets/resources/subghz/assets/keeloq_mfcodes_user similarity index 100% rename from assets/resources/subghz/keeloq_mfcodes_user rename to assets/resources/subghz/assets/keeloq_mfcodes_user diff --git a/assets/resources/subghz/nice_flor_s_rx b/assets/resources/subghz/assets/nice_flor_s_rx similarity index 100% rename from assets/resources/subghz/nice_flor_s_rx rename to assets/resources/subghz/assets/nice_flor_s_rx diff --git a/assets/resources/subghz/nice_flor_s_tx b/assets/resources/subghz/assets/nice_flor_s_tx similarity index 100% rename from assets/resources/subghz/nice_flor_s_tx rename to assets/resources/subghz/assets/nice_flor_s_tx diff --git a/assets/resources/u2f/cert.der b/assets/resources/u2f/assets/cert.der similarity index 100% rename from assets/resources/u2f/cert.der rename to assets/resources/u2f/assets/cert.der diff --git a/assets/resources/u2f/cert_key.u2f b/assets/resources/u2f/assets/cert_key.u2f similarity index 100% rename from assets/resources/u2f/cert_key.u2f rename to assets/resources/u2f/assets/cert_key.u2f diff --git a/lib/subghz/protocols/subghz_protocol_common.h b/lib/subghz/protocols/subghz_protocol_common.h index 155b6a89..1441e4d5 100644 --- a/lib/subghz/protocols/subghz_protocol_common.h +++ b/lib/subghz/protocols/subghz_protocol_common.h @@ -15,9 +15,7 @@ #define DURATION_DIFF(x, y) ((x < y) ? (y - x) : (x - y)) #define SUBGHZ_APP_FOLDER "/any/subghz" -#define SUBGHZ_APP_PATH_FOLDER "/any/subghz/saved" #define SUBGHZ_RAW_FOLDER "/ext/subghz" -#define SUBGHZ_RAW_PATH_FOLDER "/ext/subghz/saved" #define SUBGHZ_APP_EXTENSION ".sub" #define SUBGHZ_ENCODER_UPLOAD_MAX_SIZE 2048 diff --git a/lib/subghz/protocols/subghz_protocol_raw.c b/lib/subghz/protocols/subghz_protocol_raw.c old mode 100644 new mode 100755 index 9f36cdce..8b2bcf19 --- a/lib/subghz/protocols/subghz_protocol_raw.c +++ b/lib/subghz/protocols/subghz_protocol_raw.c @@ -176,15 +176,10 @@ bool subghz_protocol_raw_save_to_file_init( if(!storage_simply_mkdir(instance->storage, SUBGHZ_RAW_FOLDER)) { break; } - // Create saved directory if necessary - if(!storage_simply_mkdir(instance->storage, SUBGHZ_RAW_PATH_FOLDER)) { - break; - } string_set(instance->file_name, dev_name); // First remove subghz device file if it was saved - string_printf( - dev_file_name, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, dev_name, SUBGHZ_APP_EXTENSION); + string_printf(dev_file_name, "%s/%s%s", SUBGHZ_RAW_FOLDER, dev_name, SUBGHZ_APP_EXTENSION); if(!storage_simply_remove(instance->storage, string_get_cstr(dev_file_name))) { break;