diff --git a/apps/filetree.c b/apps/filetree.c
index d4681ae..6a6a568 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -552,22 +552,31 @@ int ft_enter(struct tree_context* c)

/* plugin file */
case FILE_ATTR_ROCK:
+ {
+ int ret;
if (global_settings.party_mode && audio_status()) {
splash(HZ, ID2P(LANG_PARTY_MODE));
break;
}
-
- if (plugin_load(buf,NULL) == PLUGIN_USB_CONNECTED)
+ ret = plugin_load(buf,NULL);
+ switch (ret)
{
- if(*c->dirfilter > NUM_FILTER_MODES)
- /* leave sub-browsers after usb, doing
- otherwise might be confusing to the user */
- exit_func = true;
- else
- reload_dir = true;
+ case PLUGIN_USB_CONNECTED:
+ break;
+ case PLUGIN_GOTO_WPS:
+ play = true;
+ break;
+ default:
+ if(*c->dirfilter > NUM_FILTER_MODES)
+ /* leave sub-browsers after usb, doing
+ otherwise might be confusing to the user */
+ exit_func = true;
+ else
+ reload_dir = true;
+ break;
}
break;
-
+ }
case FILE_ATTR_CUE:
display_cuesheet_content(buf);
break;
@@ -584,8 +593,11 @@ int ft_enter(struct tree_context* c)
plugin = filetype_get_plugin(file);
if (plugin)
{
- if (plugin_load(plugin,buf) == PLUGIN_USB_CONNECTED)
+ int ret = plugin_load(plugin,buf);
+ if (ret == PLUGIN_USB_CONNECTED)
reload_dir = true;
+ else if (ret == PLUGIN_GOTO_WPS)
+ play = true;
}
break;
}
diff --git a/apps/plugin.c b/apps/plugin.c
index ff80776..4df1e08 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -664,6 +664,7 @@ static const struct plugin_api rockbox_api = {
int plugin_load(const char* plugin, const void* parameter)
{
int rc;
+ int i;
int oldbars;
struct plugin_header *hdr;
#ifdef SIMULATOR
@@ -804,8 +805,6 @@ int plugin_load(const char* plugin, const void* parameter)
#endif /* LCD_DEPTH */
#endif /* HAVE_LCD_BITMAP */

- lcd_clear_display();
- lcd_update();

#ifdef HAVE_REMOTE_LCD
#if LCD_REMOTE_DEPTH > 1
@@ -814,32 +813,27 @@ int plugin_load(const char* plugin, const void* parameter)
#else
lcd_remote_set_drawmode(DRMODE_SOLID);
#endif
- lcd_remote_clear_display();
-
-
- lcd_remote_update();
+#endif

+ if (rc != PLUGIN_GOTO_WPS)
+ {
+ FOR_NB_SCREENS(i)
+ {
+ screens[i].clear_display();
+ screens[i].update()
+ }
+ }

-#endif
viewportmanager_set_statusbar(oldbars);
if (pfn_tsr_exit == NULL)
plugin_loaded = false;

sim_plugin_close(pd);

- switch (rc) {
- case PLUGIN_OK:
- break;
-
- case PLUGIN_USB_CONNECTED:
- return PLUGIN_USB_CONNECTED;
-
- default:
- splash(HZ*2, str(LANG_PLUGIN_ERROR));
- break;
- }
+ if (rc == PLUGIN_ERROR)
+ splash(HZ*2, str(LANG_PLUGIN_ERROR));

- return PLUGIN_OK;
+ return rc;
}

/* Returns a pointer to the portion of the plugin buffer that is not already
diff --git a/apps/plugin.h b/apps/plugin.h
index db16800..d0c1fa2 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -139,6 +139,7 @@ void* plugin_get_buffer(size_t *buffer_size);
enum plugin_status {
PLUGIN_OK = 0,
PLUGIN_USB_CONNECTED,
+ PLUGIN_GOTO_WPS,
PLUGIN_ERROR = -1,
};

diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 11822ba..4b181b6 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -54,6 +54,8 @@ PLUGIN_HEADER
#define PF_CONTEXT ACTION_STD_CONTEXT
#define PF_BACK ACTION_STD_CANCEL
#define PF_MENU ACTION_STD_MENU
+#define PF_WPS ACTION_TREE_WPS
+
#define PF_QUIT (LAST_ACTION_PLACEHOLDER + 1)

#if !defined(HAVE_SCROLLWHEEL)
@@ -2008,6 +2010,10 @@ void update_scroll_animation(void)
void cleanup(void *parameter)
{
(void) parameter;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+ rb->cpu_boost(false);
+#endif
+ end_pf_thread();
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */

@@ -2136,6 +2142,7 @@ int settings_menu(void)
Show the main menu
*/
enum {
+ PF_GOTO_WPS,
#if PF_PLAYBACK_CAPABLE
PF_MENU_PLAYBACK_CONTROL,
#endif
@@ -2154,12 +2161,15 @@ int main_menu(void)
#endif

MENUITEM_STRINGLIST(main_menu,"PictureFlow Main Menu",NULL,
+ "Go to WPS",
#if PF_PLAYBACK_CAPABLE
"Playback Control",
#endif
"Settings", "Return", "Quit");
while (1) {
switch (rb->do_menu(&main_menu,&selection, NULL, false)) {
+ case PF_GOTO_WPS: /* WPS */
+ return -2;
#if PF_PLAYBACK_CAPABLE
case PF_MENU_PLAYBACK_CONTROL: /* Playback Control */
playback_control(NULL);
@@ -2169,10 +2179,8 @@ int main_menu(void)
result = settings_menu();
if ( result != 0 ) return result;
break;
-
case PF_MENU_RETURN:
return 0;
-
case PF_MENU_QUIT:
return -1;

@@ -2400,6 +2408,7 @@ play:
old_shuffle = shuffle;
}
#endif
+
/**
Draw the current album name
*/
@@ -2656,7 +2665,8 @@ int main(void)
switch (button) {
case PF_QUIT:
return PLUGIN_OK;
-
+ case PF_WPS:
+ return PLUGIN_GOTO_WPS;
case PF_BACK:
if ( pf_state == pf_show_tracks )
{
@@ -2668,12 +2678,12 @@ int main(void)
if (pf_state == pf_idle || pf_state == pf_scrolling)
return PLUGIN_OK;
break;
-
case PF_MENU:
#ifdef USEGSLIB
grey_show(false);
#endif
ret = main_menu();
+ if ( ret == -2 ) return PLUGIN_GOTO_WPS;
if ( ret == -1 ) return PLUGIN_OK;
if ( ret != 0 ) return ret;
#ifdef USEGSLIB
@@ -2708,7 +2718,6 @@ int main(void)
#endif
}
break;
-
default:
if (rb->default_event_handler_ex(button, cleanup, NULL)
== SYS_USB_CONNECTED)
@@ -2747,9 +2756,6 @@ enum plugin_status plugin_start(const void *parameter)
#endif
#endif
ret = main();
-#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(false);
-#endif
if ( ret == PLUGIN_OK ) {
if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS,
CONFIG_VERSION))
@@ -2759,7 +2765,6 @@ enum plugin_status plugin_start(const void *parameter)
}
}

- end_pf_thread();
cleanup(NULL);
return ret;
}
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index 3c74b79..2d3959a 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -535,10 +535,8 @@ int start_shuffled_play(void)
return 1;
}

-int main_menu(void)
+enum plugin_status main_menu(void)
{
- bool exit = false;
-
MENUITEM_STRINGLIST(menu, "Main Menu", NULL,
"Generate Folder List",
"Edit Folder List",
@@ -547,69 +545,72 @@ int main_menu(void)
"Play Shuffled",
"Quit");

- switch (rb->do_menu(&menu, NULL, NULL, false))
+ while (true)
{
- case 0: /* generate */
+ switch (rb->do_menu(&menu, NULL, NULL, false))
+ {
+ case 0: /* generate */
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(true);
+ rb->cpu_boost(true);
#endif
- generate();
+ generate();
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(false);
+ rb->cpu_boost(false);
#endif
#ifdef HAVE_REMOTE_LCD
- rb->remote_backlight_on();
+ rb->remote_backlight_on();
#endif
- rb->backlight_on();
- break;
- case 1:
+ rb->backlight_on();
+ break;
+ case 1:
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(true);
+ rb->cpu_boost(true);
#endif
- if (edit_list() < 0)
- exit = true;
+ if (edit_list() < 0)
+ return PLUGIN_OK;
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(false);
+ rb->cpu_boost(false);
#endif
#ifdef HAVE_REMOTE_LCD
- rb->remote_backlight_on();
+ rb->remote_backlight_on();
#endif
- rb->backlight_on();
- break;
- case 2: /* export to textfile */
+ rb->backlight_on();
+ break;
+ case 2: /* export to textfile */
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(true);
+ rb->cpu_boost(true);
#endif
- export_list_to_file_text();
+ export_list_to_file_text();
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(false);
+ rb->cpu_boost(false);
#endif
#ifdef HAVE_REMOTE_LCD
- rb->remote_backlight_on();
+ rb->remote_backlight_on();
#endif
- rb->backlight_on();
- break;
- case 3: /* import from textfile */
+ rb->backlight_on();
+ break;
+ case 3: /* import from textfile */
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(true);
+ rb->cpu_boost(true);
#endif
- import_list_from_file_text();
+ import_list_from_file_text();
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
- rb->cpu_boost(false);
+ rb->cpu_boost(false);
#endif
#ifdef HAVE_REMOTE_LCD
- rb->remote_backlight_on();
+ rb->remote_backlight_on();
#endif
- rb->backlight_on();
- break;
- case 4:
- start_shuffled_play();
- exit=true;
- break;
- case 5:
- return 1;
+ rb->backlight_on();
+ break;
+ case 4:
+ if (!start_shuffled_play())
+ return PLUGIN_ERROR;
+ else
+ return PLUGIN_GOTO_WPS;
+ case 5:
+ return PLUGIN_OK;
+ }
}
- return exit?1:0;
}

enum plugin_status plugin_start(const void* parameter)
@@ -618,7 +619,5 @@ enum plugin_status plugin_start(const void* parameter)

abort = false;

- while (!main_menu())
- ;
- return PLUGIN_OK;
+ return main_menu();
}