Archive apps use switches for easier additions

This commit is contained in:
Willy-JL
2023-07-03 18:06:28 +02:00
parent f96993493d
commit 5520fd3d66
@@ -27,16 +27,20 @@ bool archive_app_is_available(void* context, const char* path) {
furi_assert(path);
ArchiveAppTypeEnum app = archive_get_app_type(path);
bool res = false;
if(app == ArchiveAppTypeU2f) {
Storage* storage = furi_record_open(RECORD_STORAGE);
bool file_exists = storage_file_exists(storage, U2F_KEY_FILE) &&
storage_file_exists(storage, U2F_CNT_FILE);
furi_record_close(RECORD_STORAGE);
return file_exists;
} else {
return false;
Storage* storage = furi_record_open(RECORD_STORAGE);
switch(app) {
case ArchiveAppTypeU2f:
res = storage_file_exists(storage, U2F_KEY_FILE) &&
storage_file_exists(storage, U2F_CNT_FILE);
break;
default:
break;
}
furi_record_close(RECORD_STORAGE);
return res;
}
bool archive_app_read_dir(void* context, const char* path) {
@@ -48,10 +52,11 @@ bool archive_app_read_dir(void* context, const char* path) {
ArchiveAppTypeEnum app = archive_get_app_type(path);
if(app == ArchiveAppTypeU2f) {
switch(app) {
case ArchiveAppTypeU2f:
archive_add_app_item(browser, "/app:u2f/U2F Token");
return true;
} else {
default:
return false;
}
}
@@ -64,16 +69,19 @@ void archive_app_delete_file(void* context, const char* path) {
ArchiveAppTypeEnum app = archive_get_app_type(path);
bool res = false;
if(app == ArchiveAppTypeU2f) {
Storage* fs_api = furi_record_open(RECORD_STORAGE);
Storage* fs_api = furi_record_open(RECORD_STORAGE);
switch(app) {
case ArchiveAppTypeU2f:
res = (storage_common_remove(fs_api, U2F_KEY_FILE) == FSE_OK);
res |= (storage_common_remove(fs_api, U2F_CNT_FILE) == FSE_OK);
furi_record_close(RECORD_STORAGE);
if(archive_is_favorite("/app:u2f/U2F Token")) {
archive_favorites_delete("/app:u2f/U2F Token");
}
break;
default:
break;
}
furi_record_close(RECORD_STORAGE);
if(res) {
archive_file_array_rm_selected(browser);