From dcde5aa89daaa9906b04770ab18def9c146474c4 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Sat, 19 Nov 2022 16:15:22 +0100 Subject: [PATCH] Database & Playlist Viewer: Fix return to WPS from plugin After calling up PictureFlow from the database or from the Playlist Viewer, you would not be returned to the WPS as would be expected when picking a new song, selecting "Go to WPS" or pressing the WPS action button. Change-Id: I902ac9185ebe092d0c4c08804db0a813a32cc39c --- apps/filetypes.c | 2 +- apps/onplay.c | 18 ++++++++++++++---- apps/playlist_viewer.c | 34 +++++++++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/apps/filetypes.c b/apps/filetypes.c index 02d2af282e..24dc0f2e4d 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -618,7 +618,7 @@ int filetype_list_viewers(const char* current_file) int i = viewers[info.selection]; snprintf(plugin, MAX_PATH, "%s/%s." ROCK_EXTENSION, PLUGIN_DIR, filetypes[i].plugin); - plugin_load(plugin, current_file); + ret = plugin_load(plugin, current_file); } return ret; } diff --git a/apps/onplay.c b/apps/onplay.c index 0bb3b6ae3c..0172f96c21 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -1558,6 +1558,8 @@ static bool onplay_load_plugin(void *param) onplay_result = ONPLAY_RELOAD_DIR; else if (ret == PLUGIN_GOTO_PLUGIN) onplay_result = ONPLAY_PLUGIN; + else if (ret == PLUGIN_GOTO_WPS) + onplay_result = ONPLAY_START_PLAY; return false; } @@ -1818,6 +1820,14 @@ static int playlist_insert_shuffled(void) return ONPLAY_RELOAD_DIR; } +static int tree_hotkey_run_plugin(void *param) +{ + if (filetype_load_plugin((const char*)param, selected_file) == PLUGIN_GOTO_WPS) + return ONPLAY_START_PLAY; + + return ONPLAY_RELOAD_DIR; +} + static void hotkey_run_plugin(void) { open_plugin_run(ID2P(LANG_HOTKEY_WPS)); @@ -1866,12 +1876,12 @@ static struct hotkey_assignment hotkey_items[] = { HOTKEY_FUNC(bookmark_create_menu, NULL), ONPLAY_OK }, { HOTKEY_PROPERTIES, LANG_PROPERTIES, - HOTKEY_FUNC(onplay_load_plugin, (void *)"properties"), - ONPLAY_RELOAD_DIR }, + HOTKEY_FUNC(tree_hotkey_run_plugin, (void *)"properties"), + ONPLAY_OK }, #ifdef HAVE_TAGCACHE { HOTKEY_PICTUREFLOW, LANG_ONPLAY_PICTUREFLOW, - HOTKEY_FUNC(onplay_load_plugin, (void *)"pictureflow"), - ONPLAY_RELOAD_DIR }, + HOTKEY_FUNC(tree_hotkey_run_plugin, (void *)"pictureflow"), + ONPLAY_OK }, #endif }; diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 5b6e2991bc..0eaf559c66 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -76,6 +76,7 @@ enum direction enum pv_onplay_result { PV_ONPLAY_USB, PV_ONPLAY_USB_CLOSED, + PV_ONPLAY_WPS_CLOSED, PV_ONPLAY_CLOSED, PV_ONPLAY_ITEM_REMOVED, PV_ONPLAY_CHANGED, @@ -519,9 +520,17 @@ static enum pv_onplay_result open_with(const struct playlist_entry *current_trac strmemccpy(selected_track, current_track->name, sizeof(selected_track)); + int plugin_return = filetype_list_viewers(selected_track); - return (filetype_list_viewers(selected_track) == - PLUGIN_USB_CONNECTED ? PV_ONPLAY_USB_CLOSED : PV_ONPLAY_CLOSED); + switch (plugin_return) + { + case PLUGIN_USB_CONNECTED: + return PV_ONPLAY_USB_CLOSED; + case PLUGIN_GOTO_WPS: + return PV_ONPLAY_WPS_CLOSED; + default: + return PV_ONPLAY_CLOSED; + } } #endif /* HAVE_HOTKEY */ @@ -533,8 +542,17 @@ static enum pv_onplay_result open_pictureflow(const struct playlist_entry *curre strmemccpy(selected_track, current_track->name, sizeof(selected_track)); - return (filetype_load_plugin((void *)"pictureflow", selected_track) == - PLUGIN_USB_CONNECTED ? PV_ONPLAY_USB_CLOSED : PV_ONPLAY_CLOSED); + int plugin_return = filetype_load_plugin((void *)"pictureflow", selected_track); + + switch (plugin_return) + { + case PLUGIN_USB_CONNECTED: + return PV_ONPLAY_USB_CLOSED; + case PLUGIN_GOTO_WPS: + return PV_ONPLAY_WPS_CLOSED; + default: + return PV_ONPLAY_CLOSED; + } } #endif @@ -959,6 +977,8 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) } else if (pv_onplay_result == PV_ONPLAY_USB_CLOSED) return PLAYLIST_VIEWER_USB; + else if (pv_onplay_result == PV_ONPLAY_WPS_CLOSED) + return PLAYLIST_VIEWER_OK; else if (pv_onplay_result == PV_ONPLAY_CLOSED) { if (!open_playlist_viewer(filename, &playlist_lists, true)) @@ -1004,8 +1024,12 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) if (do_plugin != NULL) { - if (do_plugin(current_track) == PV_ONPLAY_USB_CLOSED) + int plugin_result = do_plugin(current_track); + + if (plugin_result == PV_ONPLAY_USB_CLOSED) return PLAYLIST_VIEWER_USB; + else if (plugin_result == PV_ONPLAY_WPS_CLOSED) + return PLAYLIST_VIEWER_OK; else if (!open_playlist_viewer(filename, &playlist_lists, true)) { ret = PLAYLIST_VIEWER_CANCEL;