From 2731144094c8ba324a2936a1f8969d52d3a18713 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 29 Oct 2021 23:11:15 -0400 Subject: exit file browser before running plugins now that the plugin browser is resumable exit it before running plugins this causes a problem with the open plugin shortcuts that call other plugins but its now handled in count limited loop so plugins can run plugins in a chain and overall with less overhead too.. the problem remaining -- the plugin exits on USB, returns to ROOT the browser resumes the directory next time you select plugins making for an unwanted auto return Change-Id: If401f698207cbae824e95d69a378f13456a5dee4 --- apps/root_menu.c | 57 ++++++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 31 deletions(-) (limited to 'apps/root_menu.c') diff --git a/apps/root_menu.c b/apps/root_menu.c index ed6bdfdcca..f731531e16 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -709,47 +709,41 @@ static int load_context_screen(int selection) static int load_plugin_screen(char *key) { - int ret_val; + int ret_val = PLUGIN_ERROR; + int loops = 100; int old_previous = last_screen; int old_global = global_status.last_screen; last_screen = next_screen; global_status.last_screen = (char)next_screen; status_save(); - int opret = open_plugin_get_entry(key, &open_plugin_entry); - char *path = open_plugin_entry.path; - char *param = open_plugin_entry.param; - if (param[0] == '\0') - param = NULL; - - switch (plugin_load(path, param)) + while(loops-- > 0) /* just to keep things from getting out of hand */ { - case PLUGIN_USB_CONNECTED: - ret_val = GO_TO_ROOT; - break; - case PLUGIN_GOTO_WPS: - ret_val = GO_TO_WPS; - break; - case PLUGIN_GOTO_PLUGIN: - ret_val = GO_TO_PLUGIN; - break; - case PLUGIN_OK: - /* Prevents infinite loop with WPS & Plugins*/ - if (old_global == GO_TO_WPS && !audio_status()) - { + int opret = open_plugin_get_entry(key, &open_plugin_entry); + char *path = open_plugin_entry.path; + char *param = open_plugin_entry.param; + if (param[0] == '\0') + param = NULL; + + int ret = plugin_load(path, param); + + if (ret == PLUGIN_USB_CONNECTED) ret_val = GO_TO_ROOT; - break; + else if (ret == PLUGIN_GOTO_WPS) + ret_val = GO_TO_WPS; + else if (ret == PLUGIN_GOTO_PLUGIN) + continue; + else + { + /* Prevents infinite loop with WPS & Plugins*/ + if (ret == PLUGIN_OK && old_global == GO_TO_WPS && !audio_status()) + ret_val = GO_TO_ROOT; + ret_val = GO_TO_PREVIOUS; + last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous; } - /*fallthrough*/ - default: - ret_val = GO_TO_PREVIOUS; - last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous; - break; - } + /* ret_val != GO_TO_PLUGIN */ - if (ret_val != GO_TO_PLUGIN) - { if (opret != OPEN_PLUGIN_NEEDS_FLUSHED || last_screen != GO_TO_WPS) { /* Keep the entry in case of GO_TO_PREVIOUS */ @@ -757,7 +751,8 @@ static int load_plugin_screen(char *key) open_plugin_entry.lang_id = LANG_PREVIOUS_SCREEN; /*open_plugin_add_path(NULL, NULL, NULL);// clear entry */ } - } + break; + } /*while */ return ret_val; } -- cgit v1.2.3