Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions applications/main/archive/scenes/archive_scene_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,31 @@ static void archive_run_in_app(ArchiveBrowserView* browser, ArchiveFile_t* selec
if(param != NULL) {
param++;
}
status = loader_start(loader, flipper_app_name[selected->type], param);

if(strcmp(flipper_app_name[selected->type], "U2F") == 0) {
char* tmpType = "/ext/apps/Main/U2F.fap¯";
char* result =
malloc(strlen(tmpType) + strlen(furi_string_get_cstr(selected->path)) + 1);

strcpy(result, tmpType);
strcat(result, furi_string_get_cstr(selected->path));
status = loader_start(loader, "Applications", result);
} else {
status = loader_start(loader, flipper_app_name[selected->type], param);
}
} else {
status = loader_start(
loader, flipper_app_name[selected->type], furi_string_get_cstr(selected->path));
if(strcmp(flipper_app_name[selected->type], "iButton") == 0) {
char* tmpType = "/ext/apps/Main/ibutton.fap¯";
char* result =
malloc(strlen(tmpType) + strlen(furi_string_get_cstr(selected->path)) + 1);

strcpy(result, tmpType);
strcat(result, furi_string_get_cstr(selected->path));
status = loader_start(loader, "Applications", result);
} else {
status = loader_start(
loader, flipper_app_name[selected->type], furi_string_get_cstr(selected->path));
}
}

if(status != LoaderStatusOk) {
Expand Down
58 changes: 48 additions & 10 deletions applications/main/fap_loader/fap_loader_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct FapLoader {
DialogsApp* dialogs;
Gui* gui;
FuriString* fap_path;
FuriString* fap_args;
ViewDispatcher* view_dispatcher;
Loading* loading;
};
Expand Down Expand Up @@ -102,15 +103,31 @@ static bool fap_loader_run_selected_app(FapLoader* loader) {

FURI_LOG_I(TAG, "Loaded in %ums", (size_t)(furi_get_tick() - start));
FURI_LOG_I(TAG, "FAP Loader is starting app");

FuriThread* thread = flipper_application_spawn(loader->app, NULL);
furi_thread_start(thread);
furi_thread_join(thread);

show_error = false;
int ret = furi_thread_get_return_code(thread);

FURI_LOG_I(TAG, "FAP app returned: %i", ret);

if(strcmp(furi_string_get_cstr(loader->fap_args), "false") == 0)
{
FuriThread* thread =
flipper_application_spawn(loader->app, NULL);
furi_thread_start(thread);
furi_thread_join(thread);

show_error = false;
int ret = furi_thread_get_return_code(thread);

FURI_LOG_I(TAG, "FAP app returned: %i", ret);
}
else
{
FuriThread* thread =
flipper_application_spawn(loader->app, (void*)furi_string_get_cstr(loader->fap_args));
furi_thread_start(thread);
furi_thread_join(thread);

show_error = false;
int ret = furi_thread_get_return_code(thread);

FURI_LOG_I(TAG, "FAP app returned: %i", ret);
}
} while(0);

if(show_error) {
Expand Down Expand Up @@ -155,7 +172,27 @@ static bool fap_loader_select_app(FapLoader* loader) {

static FapLoader* fap_loader_alloc(const char* path) {
FapLoader* loader = malloc(sizeof(FapLoader));
loader->fap_path = furi_string_alloc_set(path);

char* tmp = malloc(strlen(path) + 1);
strcpy(tmp, path);
char* new_path;

new_path = strtok(tmp, "¯");

if(new_path) {
loader->fap_path = furi_string_alloc_set(new_path);
} else {
loader->fap_path = furi_string_alloc_set(path);
}

new_path = strtok(NULL, "¯");

if(new_path) {
loader->fap_args = furi_string_alloc_set(new_path);
} else {
loader->fap_args = furi_string_alloc_set("false");
}

loader->storage = furi_record_open(RECORD_STORAGE);
loader->dialogs = furi_record_open(RECORD_DIALOGS);
loader->gui = furi_record_open(RECORD_GUI);
Expand All @@ -172,6 +209,7 @@ static void fap_loader_free(FapLoader* loader) {
loading_free(loader->loading);
view_dispatcher_free(loader->view_dispatcher);
furi_string_free(loader->fap_path);
furi_string_free(loader->fap_args);
furi_record_close(RECORD_GUI);
furi_record_close(RECORD_DIALOGS);
furi_record_close(RECORD_STORAGE);
Expand Down