This commit is contained in:
RogueMaster
2022-11-12 08:37:29 -05:00
parent ffbbc7ecde
commit 4b9f353c78
11 changed files with 524 additions and 497 deletions

View File

@@ -59,13 +59,13 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) {
ArchiveFile_t* selected = ArchiveFile_t* selected =
files_array_get(model->files, model->item_idx - model->array_offset); files_array_get(model->files, model->item_idx - model->array_offset);
menu[0] = furi_string_alloc_set("Run in app"); menu[0] = furi_string_alloc_set("Run in app");
menu[1] = furi_string_alloc_set("Pin"); menu[1] = furi_string_alloc_set("Pin");
menu[2] = furi_string_alloc_set("Rename"); menu[2] = furi_string_alloc_set("Rename");
menu[3] = furi_string_alloc_set("Delete"); menu[3] = furi_string_alloc_set("Delete");
ArchiveFile_t* selected = files_array_get(model->files, model->item_idx - model->array_offset); ArchiveFile_t* selected =
files_array_get(model->files, model->item_idx - model->array_offset);
if((selected->fav) || (model->tab_idx == ArchiveTabFavorites)) { if((selected->fav) || (model->tab_idx == ArchiveTabFavorites)) {
furi_string_set(menu[1], "Unpin"); furi_string_set(menu[1], "Unpin");
@@ -278,7 +278,8 @@ static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) {
furi_string_set(str_buf, file->custom_name); furi_string_set(str_buf, file->custom_name);
} else { } else {
file_type = ArchiveFileTypeUnknown; file_type = ArchiveFileTypeUnknown;
path_extract_filename(file->path, str_buf, archive_is_known_app(file->type)); path_extract_filename(
file->path, str_buf, archive_is_known_app(file->type));
} }
} else { } else {
path_extract_filename(file->path, str_buf, archive_is_known_app(file->type)); path_extract_filename(file->path, str_buf, archive_is_known_app(file->type));
@@ -387,7 +388,8 @@ static bool is_file_list_load_required(ArchiveBrowserViewModel* model) {
} }
if(((model->array_offset + array_size) < model->item_cnt) && if(((model->array_offset + array_size) < model->item_cnt) &&
(model->item_idx > (int32_t)(model->array_offset + array_size - FILE_LIST_BUF_LEN / 4))) { (model->item_idx >
(int32_t)(model->array_offset + array_size - FILE_LIST_BUF_LEN / 4))) {
return true; return true;
} }
@@ -468,7 +470,8 @@ static bool archive_view_input(InputEvent* event, void* context) {
((model->item_idx - 1) + model->item_cnt) % model->item_cnt; ((model->item_idx - 1) + model->item_cnt) % model->item_cnt;
if(is_file_list_load_required(model)) { if(is_file_list_load_required(model)) {
model->list_loading = true; model->list_loading = true;
browser->callback(ArchiveBrowserEventLoadPrevItems, browser->context); browser->callback(
ArchiveBrowserEventLoadPrevItems, browser->context);
} }
if(move_fav_mode) { if(move_fav_mode) {
browser->callback(ArchiveBrowserEventFavMoveUp, browser->context); browser->callback(ArchiveBrowserEventFavMoveUp, browser->context);
@@ -477,10 +480,12 @@ static bool archive_view_input(InputEvent* event, void* context) {
model->item_idx = (model->item_idx + 1) % model->item_cnt; model->item_idx = (model->item_idx + 1) % model->item_cnt;
if(is_file_list_load_required(model)) { if(is_file_list_load_required(model)) {
model->list_loading = true; model->list_loading = true;
browser->callback(ArchiveBrowserEventLoadNextItems, browser->context); browser->callback(
ArchiveBrowserEventLoadNextItems, browser->context);
} }
if(move_fav_mode) { if(move_fav_mode) {
browser->callback(ArchiveBrowserEventFavMoveDown, browser->context); browser->callback(
ArchiveBrowserEventFavMoveDown, browser->context);
} }
} }
}, },
@@ -498,9 +503,11 @@ static bool archive_view_input(InputEvent* event, void* context) {
if(event->type == InputTypeShort) { if(event->type == InputTypeShort) {
if(favorites) { if(favorites) {
if(move_fav_mode) { if(move_fav_mode) {
browser->callback(ArchiveBrowserEventSaveFavMove, browser->context); browser->callback(
ArchiveBrowserEventSaveFavMove, browser->context);
} else { } else {
browser->callback(ArchiveBrowserEventFileMenuRun, browser->context); browser->callback(
ArchiveBrowserEventFileMenuRun, browser->context);
} }
} else if(folder) { } else if(folder) {
browser->callback(ArchiveBrowserEventEnterDir, browser->context); browser->callback(ArchiveBrowserEventEnterDir, browser->context);

View File

@@ -468,8 +468,7 @@ static int32_t ducky_script_execute_next(BadUsbScript* bad_usb, File* script_fil
FURI_LOG_E( FURI_LOG_E(
WORKER_TAG, "Forbidden empty line at line %u", bad_usb->st.line_cur); WORKER_TAG, "Forbidden empty line at line %u", bad_usb->st.line_cur);
} else { } else {
FURI_LOG_E( FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_usb->st.line_cur);
WORKER_TAG, "Unknown command at line %u", bad_usb->st.line_cur);
} }
return SCRIPT_STATE_ERROR; return SCRIPT_STATE_ERROR;
} else { } else {

View File

@@ -302,24 +302,11 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
int32_t elapsed_secs_img2 = (elapsed_secs % 60) % 4; int32_t elapsed_secs_img2 = (elapsed_secs % 60) % 4;
// int32_t elapsed_secs_img3 = (elapsed_secs % 60) % 4; // int32_t elapsed_secs_img3 = (elapsed_secs % 60) % 4;
static const Icon* const count_anim[5] = { static const Icon* const count_anim[5] = {
&I_HappyFlipper_128x64, &I_HappyFlipper_128x64, &I_G0ku, &I_g0ku_1, &I_g0ku_2, &I_g0ku_3};
&I_G0ku,
&I_g0ku_1,
&I_g0ku_2,
&I_g0ku_3
};
static const Icon* const count_anim2[4] = { static const Icon* const count_anim2[4] = {
&I_EviWaiting1_18x21, &I_EviWaiting1_18x21, &I_EviWaiting2_18x21, &I_EviSmile1_18x21, &I_EviSmile2_18x21};
&I_EviWaiting2_18x21,
&I_EviSmile1_18x21,
&I_EviSmile2_18x21
};
static const Icon* const count_anim3[4] = { static const Icon* const count_anim3[4] = {
&I_frame_01, &I_frame_01, &I_frame_02, &I_frame_03, &I_frame_02};
&I_frame_02,
&I_frame_03,
&I_frame_02
};
canvas_draw_icon(canvas, -5, 15, count_anim[elapsed_secs_img]); canvas_draw_icon(canvas, -5, 15, count_anim[elapsed_secs_img]);
canvas_draw_icon(canvas, 90, 0, count_anim2[elapsed_secs_img2]); canvas_draw_icon(canvas, 90, 0, count_anim2[elapsed_secs_img2]);
canvas_draw_icon(canvas, 110, 5, count_anim3[elapsed_secs_img2]); canvas_draw_icon(canvas, 110, 5, count_anim3[elapsed_secs_img2]);

View File

@@ -43,7 +43,8 @@ bool nfc_scene_passport_auth_load(Nfc* nfc) {
FuriString* file_path; FuriString* file_path;
file_path = furi_string_alloc(); file_path = furi_string_alloc();
bool res = dialog_file_browser_show(nfc->dev->dialogs, file_path, mrtd_app_folder, &browser_options); bool res =
dialog_file_browser_show(nfc->dev->dialogs, file_path, mrtd_app_folder, &browser_options);
furi_string_free(mrtd_app_folder); furi_string_free(mrtd_app_folder);
@@ -56,7 +57,8 @@ bool nfc_scene_passport_auth_load(Nfc* nfc) {
true); true);
nfc_scene_passport_auth_on_enter(nfc); nfc_scene_passport_auth_on_enter(nfc);
variable_item_list_set_selected_item(nfc->variable_item_list, NfcScenePassportAuthSelectAuth); variable_item_list_set_selected_item(
nfc->variable_item_list, NfcScenePassportAuthSelectAuth);
} }
return res; return res;

View File

@@ -41,8 +41,8 @@ void nfc_scene_passport_auth_save_name_on_enter(void* context) {
furi_string_set(folder_path, NFC_APP_FOLDER); furi_string_set(folder_path, NFC_APP_FOLDER);
} }
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init( ValidatorIsFile* validator_is_file =
furi_string_get_cstr(folder_path), NFC_APP_EXTENSION, NULL); validator_is_file_alloc_init(furi_string_get_cstr(folder_path), NFC_APP_EXTENSION, NULL);
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file); text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextInput); view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextInput);
@@ -57,7 +57,8 @@ bool nfc_scene_passport_auth_save_name_on_event(void* context, SceneManagerEvent
if(event.type == SceneManagerEventTypeCustom) { if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventTextInputDone) { if(event.event == NfcCustomEventTextInputDone) {
if(mrtd_auth_params_save(nfc->dev->storage, nfc->dev->dialogs, &mrtd_data->auth, nfc->text_store)) { if(mrtd_auth_params_save(
nfc->dev->storage, nfc->dev->dialogs, &mrtd_data->auth, nfc->text_store)) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess); scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
consumed = true; consumed = true;
} else { } else {

View File

@@ -37,7 +37,8 @@ void nfc_scene_passport_read_auth_on_enter(void* context) {
FuriString* temp_str; FuriString* temp_str;
temp_str = furi_string_alloc(); temp_str = furi_string_alloc();
furi_string_set(temp_str, "\e#Passport\n"); furi_string_set(temp_str, "\e#Passport\n");
furi_string_cat_printf(temp_str, "Auth.method: %s\n", mrtd_auth_method_string(mrtd_data->auth_method_used)); furi_string_cat_printf(
temp_str, "Auth.method: %s\n", mrtd_auth_method_string(mrtd_data->auth_method_used));
// TODO: indicate BAC / PACE used // TODO: indicate BAC / PACE used
uint16_t lds_version = mrtd_data->files.EF_COM.lds_version; uint16_t lds_version = mrtd_data->files.EF_COM.lds_version;

View File

@@ -92,7 +92,9 @@ bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) {
consumed = true; consumed = true;
} else if(event.event == NfcWorkerEventReadPassport) { } else if(event.event == NfcWorkerEventReadPassport) {
notification_message(nfc->notifications, &sequence_success); notification_message(nfc->notifications, &sequence_success);
FURI_LOG_D("NFC", "Read passport, auth: %d, success: %d", FURI_LOG_D(
"NFC",
"Read passport, auth: %d, success: %d",
nfc->dev->dev_data.mrtd_data.auth.method, nfc->dev->dev_data.mrtd_data.auth.method,
nfc->dev->dev_data.mrtd_data.auth_success); nfc->dev->dev_data.mrtd_data.auth_success);
if(nfc->dev->dev_data.mrtd_data.auth_success) { if(nfc->dev->dev_data.mrtd_data.auth_success) {

View File

@@ -46,7 +46,6 @@ bool mrtd_auth_method_parse_string(MrtdAuthMethod* method, const char* str) {
return false; return false;
} }
uint8_t mrtd_bac_check_digit(const char* input, const uint8_t length) { uint8_t mrtd_bac_check_digit(const char* input, const uint8_t length) {
const uint8_t num_weights = 3; const uint8_t num_weights = 3;
uint8_t weights[] = {7, 3, 1}; uint8_t weights[] = {7, 3, 1};

View File

@@ -605,16 +605,17 @@ bool mrtd_authenticate(MrtdApplication* app) {
return true; return true;
} }
bool mrtd_auth_params_save(Storage* storage, DialogsApp* dialogs, MrtdAuthData* auth_data, const char* file_name) { bool mrtd_auth_params_save(
return mrtd_auth_params_save_file(storage, dialogs, auth_data, file_name, MRTD_APP_FOLDER, MRTD_APP_EXTENSION); Storage* storage,
DialogsApp* dialogs,
MrtdAuthData* auth_data,
const char* file_name) {
return mrtd_auth_params_save_file(
storage, dialogs, auth_data, file_name, MRTD_APP_FOLDER, MRTD_APP_EXTENSION);
} }
void mrtd_date_prepare_format_string(MrtdDate date, FuriString* format_string) { void mrtd_date_prepare_format_string(MrtdDate date, FuriString* format_string) {
furi_string_printf( furi_string_printf(format_string, "%02u%02u%02u", date.year, date.month, date.day);
format_string, "%02u%02u%02u",
date.year,
date.month,
date.day);
} }
bool mrtd_date_parse_format_string(MrtdDate* date, FuriString* format_string) { bool mrtd_date_parse_format_string(MrtdDate* date, FuriString* format_string) {
@@ -633,7 +634,13 @@ bool mrtd_date_parse_format_string(MrtdDate* date, FuriString* format_string) {
return true; return true;
} }
bool mrtd_auth_params_save_file(Storage* storage, DialogsApp* dialogs, MrtdAuthData* auth_data, const char* file_name, const char* folder, const char* extension) { bool mrtd_auth_params_save_file(
Storage* storage,
DialogsApp* dialogs,
MrtdAuthData* auth_data,
const char* file_name,
const char* folder,
const char* extension) {
furi_assert(auth_data); furi_assert(auth_data);
bool saved = false; bool saved = false;
@@ -650,7 +657,8 @@ bool mrtd_auth_params_save_file(Storage* storage, DialogsApp* dialogs, MrtdAuthD
// Open file // Open file
if(!flipper_format_file_open_always(file, furi_string_get_cstr(temp_str))) break; if(!flipper_format_file_open_always(file, furi_string_get_cstr(temp_str))) break;
// Write header // Write header
if(!flipper_format_write_header_cstr(file, mrtd_auth_file_header, mrtd_auth_file_version)) break; if(!flipper_format_write_header_cstr(file, mrtd_auth_file_header, mrtd_auth_file_version))
break;
// Write auth method // Write auth method
furi_string_set(temp_str, mrtd_auth_method_string(auth_data->method)); furi_string_set(temp_str, mrtd_auth_method_string(auth_data->method));
@@ -679,7 +687,12 @@ bool mrtd_auth_params_save_file(Storage* storage, DialogsApp* dialogs, MrtdAuthD
return saved; return saved;
} }
bool mrtd_auth_params_load(Storage* storage, DialogsApp* dialogs, MrtdAuthData* auth_data, const char* file_path, bool show_dialog) { bool mrtd_auth_params_load(
Storage* storage,
DialogsApp* dialogs,
MrtdAuthData* auth_data,
const char* file_path,
bool show_dialog) {
furi_assert(storage); furi_assert(storage);
furi_assert(dialogs); furi_assert(dialogs);
furi_assert(auth_data); furi_assert(auth_data);
@@ -702,7 +715,8 @@ bool mrtd_auth_params_load(Storage* storage, DialogsApp* dialogs, MrtdAuthData*
uint32_t version = 0; uint32_t version = 0;
if(!flipper_format_read_header(file, temp_str, &version)) break; if(!flipper_format_read_header(file, temp_str, &version)) break;
FURI_LOG_D(TAG, "Version: %s", furi_string_get_cstr(temp_str)); FURI_LOG_D(TAG, "Version: %s", furi_string_get_cstr(temp_str));
if(furi_string_cmp_str(temp_str, mrtd_auth_file_header) || (version != mrtd_auth_file_version)) { if(furi_string_cmp_str(temp_str, mrtd_auth_file_header) ||
(version != mrtd_auth_file_version)) {
deprecated_version = true; deprecated_version = true;
break; break;
} }

View File

@@ -23,7 +23,22 @@ bool mrtd_select_app(MrtdApplication* app, AIDValue aid);
bool mrtd_authenticate(MrtdApplication* app); bool mrtd_authenticate(MrtdApplication* app);
bool mrtd_read_parse_file(MrtdApplication* app, EFFile file); bool mrtd_read_parse_file(MrtdApplication* app, EFFile file);
bool mrtd_auth_params_save(Storage* storage, DialogsApp* dialogs, MrtdAuthData* auth_data, const char* file_name); bool mrtd_auth_params_save(
bool mrtd_auth_params_save_file(Storage* storage, DialogsApp* dialogs, MrtdAuthData* auth_data, const char* file_name, const char* folder, const char* extension); Storage* storage,
DialogsApp* dialogs,
MrtdAuthData* auth_data,
const char* file_name);
bool mrtd_auth_params_save_file(
Storage* storage,
DialogsApp* dialogs,
MrtdAuthData* auth_data,
const char* file_name,
const char* folder,
const char* extension);
bool mrtd_auth_params_load(Storage* storage, DialogsApp* dialogs, MrtdAuthData* auth_data, const char* file_path, bool show_dialog); bool mrtd_auth_params_load(
Storage* storage,
DialogsApp* dialogs,
MrtdAuthData* auth_data,
const char* file_path,
bool show_dialog);