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
This commit is contained in:
William Wilgus 2021-10-29 23:11:15 -04:00 committed by William Wilgus
parent 684565b8f3
commit 2731144094
2 changed files with 38 additions and 32 deletions

View file

@ -435,7 +435,7 @@ static void ft_load_font(char *file)
int ft_enter(struct tree_context* c) int ft_enter(struct tree_context* c)
{ {
int rc = GO_TO_PREVIOUS; int rc = GO_TO_PREVIOUS;
static char buf[MAX_PATH]; char buf[MAX_PATH];
struct entry* file = tree_get_entry_at(c, c->selected_item); struct entry* file = tree_get_entry_at(c, c->selected_item);
if (!file) if (!file)
@ -641,6 +641,8 @@ int ft_enter(struct tree_context* c)
splash(HZ, ID2P(LANG_PARTY_MODE)); splash(HZ, ID2P(LANG_PARTY_MODE));
break; break;
} }
#ifdef PLUGINS_RUN_IN_BROWSER /* Stay in the filetree to run a plugin */
switch (plugin_load(plugin, argument)) switch (plugin_load(plugin, argument))
{ {
case PLUGIN_GOTO_WPS: case PLUGIN_GOTO_WPS:
@ -664,6 +666,10 @@ int ft_enter(struct tree_context* c)
default: default:
break; break;
} }
#else /* Exit the filetree to run a plugin */
plugin_open(plugin, argument);
rc = GO_TO_PLUGIN;
#endif
break; break;
} }
@ -687,6 +693,7 @@ int ft_enter(struct tree_context* c)
plugin = filetype_get_plugin(file, plugin_path, sizeof(plugin_path)); plugin = filetype_get_plugin(file, plugin_path, sizeof(plugin_path));
if (plugin) if (plugin)
{ {
#ifdef PLUGINS_RUN_IN_BROWSER /* Stay in the filetree to run a plugin */
switch (plugin_load(plugin, argument)) switch (plugin_load(plugin, argument))
{ {
case PLUGIN_USB_CONNECTED: case PLUGIN_USB_CONNECTED:
@ -705,6 +712,10 @@ int ft_enter(struct tree_context* c)
default: default:
break; break;
} }
#else /* Exit the filetree to run a plugin */
plugin_open(plugin, argument);
rc = GO_TO_PLUGIN;
#endif
} }
break; break;
} }

View file

@ -709,47 +709,41 @@ static int load_context_screen(int selection)
static int load_plugin_screen(char *key) 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_previous = last_screen;
int old_global = global_status.last_screen; int old_global = global_status.last_screen;
last_screen = next_screen; last_screen = next_screen;
global_status.last_screen = (char)next_screen; global_status.last_screen = (char)next_screen;
status_save(); status_save();
int opret = open_plugin_get_entry(key, &open_plugin_entry); while(loops-- > 0) /* just to keep things from getting out of hand */
char *path = open_plugin_entry.path;
char *param = open_plugin_entry.param;
if (param[0] == '\0')
param = NULL;
switch (plugin_load(path, param))
{ {
case PLUGIN_USB_CONNECTED: int opret = open_plugin_get_entry(key, &open_plugin_entry);
ret_val = GO_TO_ROOT; char *path = open_plugin_entry.path;
break; char *param = open_plugin_entry.param;
case PLUGIN_GOTO_WPS: if (param[0] == '\0')
ret_val = GO_TO_WPS; param = NULL;
break;
case PLUGIN_GOTO_PLUGIN: int ret = plugin_load(path, param);
ret_val = GO_TO_PLUGIN;
break; if (ret == PLUGIN_USB_CONNECTED)
case PLUGIN_OK:
/* Prevents infinite loop with WPS & Plugins*/
if (old_global == GO_TO_WPS && !audio_status())
{
ret_val = GO_TO_ROOT; 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) if (opret != OPEN_PLUGIN_NEEDS_FLUSHED || last_screen != GO_TO_WPS)
{ {
/* Keep the entry in case of GO_TO_PREVIOUS */ /* 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_entry.lang_id = LANG_PREVIOUS_SCREEN;
/*open_plugin_add_path(NULL, NULL, NULL);// clear entry */ /*open_plugin_add_path(NULL, NULL, NULL);// clear entry */
} }
} break;
} /*while */
return ret_val; return ret_val;
} }