M*LIB: non-inlined strings, FuriString primitive (#1795)
* Quicksave 1 * Header stage complete * Source stage complete * Lint & merge fixes * Includes * Documentation step 1 * FBT: output free size considering BT STACK * Documentation step 2 * py lint * Fix music player plugin * unit test stage 1: string allocator, mem, getters, setters, appends, compare, search. * unit test: string equality * unit test: string replace * unit test: string start_with, end_with * unit test: string trim * unit test: utf-8 * Rename * Revert fw_size changes * Simplify CLI backspace handling * Simplify CLI character insert * Merge fixes * Furi: correct filenaming and spelling * Bt: remove furi string include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -14,10 +14,10 @@ void picopass_scene_device_info_widget_callback(
|
||||
void picopass_scene_device_info_on_enter(void* context) {
|
||||
Picopass* picopass = context;
|
||||
|
||||
string_t credential_str;
|
||||
string_t wiegand_str;
|
||||
string_init(credential_str);
|
||||
string_init(wiegand_str);
|
||||
FuriString* credential_str;
|
||||
FuriString* wiegand_str;
|
||||
credential_str = furi_string_alloc();
|
||||
wiegand_str = furi_string_alloc();
|
||||
|
||||
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
|
||||
|
||||
@@ -26,25 +26,31 @@ void picopass_scene_device_info_on_enter(void* context) {
|
||||
Widget* widget = picopass->widget;
|
||||
|
||||
size_t bytesLength = 1 + pacs->record.bitLength / 8;
|
||||
string_set_str(credential_str, "");
|
||||
furi_string_set(credential_str, "");
|
||||
for(uint8_t i = PICOPASS_BLOCK_LEN - bytesLength; i < PICOPASS_BLOCK_LEN; i++) {
|
||||
string_cat_printf(credential_str, " %02X", pacs->credential[i]);
|
||||
furi_string_cat_printf(credential_str, " %02X", pacs->credential[i]);
|
||||
}
|
||||
|
||||
if(pacs->record.valid) {
|
||||
string_cat_printf(
|
||||
furi_string_cat_printf(
|
||||
wiegand_str, "FC: %u CN: %u", pacs->record.FacilityCode, pacs->record.CardNumber);
|
||||
} else {
|
||||
string_cat_printf(wiegand_str, "%d bits", pacs->record.bitLength);
|
||||
furi_string_cat_printf(wiegand_str, "%d bits", pacs->record.bitLength);
|
||||
}
|
||||
|
||||
widget_add_string_element(
|
||||
widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, string_get_cstr(wiegand_str));
|
||||
widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(wiegand_str));
|
||||
widget_add_string_element(
|
||||
widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(credential_str));
|
||||
widget,
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
FontSecondary,
|
||||
furi_string_get_cstr(credential_str));
|
||||
|
||||
string_clear(credential_str);
|
||||
string_clear(wiegand_str);
|
||||
furi_string_free(credential_str);
|
||||
furi_string_free(wiegand_str);
|
||||
|
||||
widget_add_button_element(
|
||||
picopass->widget,
|
||||
|
@@ -15,12 +15,12 @@ void picopass_scene_read_card_success_widget_callback(
|
||||
|
||||
void picopass_scene_read_card_success_on_enter(void* context) {
|
||||
Picopass* picopass = context;
|
||||
string_t credential_str;
|
||||
string_t wiegand_str;
|
||||
string_t sio_str;
|
||||
string_init(credential_str);
|
||||
string_init(wiegand_str);
|
||||
string_init(sio_str);
|
||||
FuriString* credential_str;
|
||||
FuriString* wiegand_str;
|
||||
FuriString* sio_str;
|
||||
credential_str = furi_string_alloc();
|
||||
wiegand_str = furi_string_alloc();
|
||||
sio_str = furi_string_alloc();
|
||||
|
||||
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
|
||||
|
||||
@@ -32,10 +32,10 @@ void picopass_scene_read_card_success_on_enter(void* context) {
|
||||
Widget* widget = picopass->widget;
|
||||
|
||||
if(pacs->record.bitLength == 0) {
|
||||
string_cat_printf(wiegand_str, "Read Failed");
|
||||
furi_string_cat_printf(wiegand_str, "Read Failed");
|
||||
|
||||
if(pacs->se_enabled) {
|
||||
string_cat_printf(credential_str, "SE enabled");
|
||||
furi_string_cat_printf(credential_str, "SE enabled");
|
||||
}
|
||||
|
||||
widget_add_button_element(
|
||||
@@ -47,20 +47,20 @@ void picopass_scene_read_card_success_on_enter(void* context) {
|
||||
|
||||
} else {
|
||||
size_t bytesLength = 1 + pacs->record.bitLength / 8;
|
||||
string_set_str(credential_str, "");
|
||||
furi_string_set(credential_str, "");
|
||||
for(uint8_t i = PICOPASS_BLOCK_LEN - bytesLength; i < PICOPASS_BLOCK_LEN; i++) {
|
||||
string_cat_printf(credential_str, " %02X", pacs->credential[i]);
|
||||
furi_string_cat_printf(credential_str, " %02X", pacs->credential[i]);
|
||||
}
|
||||
|
||||
if(pacs->record.valid) {
|
||||
string_cat_printf(
|
||||
furi_string_cat_printf(
|
||||
wiegand_str, "FC: %u CN: %u", pacs->record.FacilityCode, pacs->record.CardNumber);
|
||||
} else {
|
||||
string_cat_printf(wiegand_str, "%d bits", pacs->record.bitLength);
|
||||
furi_string_cat_printf(wiegand_str, "%d bits", pacs->record.bitLength);
|
||||
}
|
||||
|
||||
if(pacs->sio) {
|
||||
string_cat_printf(sio_str, "+SIO");
|
||||
furi_string_cat_printf(sio_str, "+SIO");
|
||||
}
|
||||
|
||||
widget_add_button_element(
|
||||
@@ -79,15 +79,21 @@ void picopass_scene_read_card_success_on_enter(void* context) {
|
||||
}
|
||||
|
||||
widget_add_string_element(
|
||||
widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, string_get_cstr(wiegand_str));
|
||||
widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(wiegand_str));
|
||||
widget_add_string_element(
|
||||
widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(credential_str));
|
||||
widget,
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
FontSecondary,
|
||||
furi_string_get_cstr(credential_str));
|
||||
widget_add_string_element(
|
||||
widget, 64, 42, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(sio_str));
|
||||
widget, 64, 42, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(sio_str));
|
||||
|
||||
string_clear(credential_str);
|
||||
string_clear(wiegand_str);
|
||||
string_clear(sio_str);
|
||||
furi_string_free(credential_str);
|
||||
furi_string_free(wiegand_str);
|
||||
furi_string_free(sio_str);
|
||||
|
||||
view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewWidget);
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#include "../picopass_i.h"
|
||||
#include "m-string.h"
|
||||
#include <lib/toolbox/random_name.h>
|
||||
#include <gui/modules/validators.h>
|
||||
#include <toolbox/path.h>
|
||||
@@ -31,22 +30,22 @@ void picopass_scene_save_name_on_enter(void* context) {
|
||||
PICOPASS_DEV_NAME_MAX_LEN,
|
||||
dev_name_empty);
|
||||
|
||||
string_t folder_path;
|
||||
string_init(folder_path);
|
||||
FuriString* folder_path;
|
||||
folder_path = furi_string_alloc();
|
||||
|
||||
if(string_end_with_str_p(picopass->dev->load_path, PICOPASS_APP_EXTENSION)) {
|
||||
path_extract_dirname(string_get_cstr(picopass->dev->load_path), folder_path);
|
||||
if(furi_string_end_with(picopass->dev->load_path, PICOPASS_APP_EXTENSION)) {
|
||||
path_extract_dirname(furi_string_get_cstr(picopass->dev->load_path), folder_path);
|
||||
} else {
|
||||
string_set_str(folder_path, PICOPASS_APP_FOLDER);
|
||||
furi_string_set(folder_path, PICOPASS_APP_FOLDER);
|
||||
}
|
||||
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
string_get_cstr(folder_path), PICOPASS_APP_EXTENSION, picopass->dev->dev_name);
|
||||
furi_string_get_cstr(folder_path), PICOPASS_APP_EXTENSION, picopass->dev->dev_name);
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewTextInput);
|
||||
|
||||
string_clear(folder_path);
|
||||
furi_string_free(folder_path);
|
||||
}
|
||||
|
||||
bool picopass_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
|
Reference in New Issue
Block a user