1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
Index: apps/plugins/random_folder_advance_config.c
===================================================================
--- apps/plugins/random_folder_advance_config.c  (Revision 21603)
+++ apps/plugins/random_folder_advance_config.c  (Arbeitskopie)
@@ -20,6 +20,7 @@
  ****************************************************************************/
 #include "plugin.h"
 #include "file.h"
+#include "lib/pluginlib_exit.h"

 PLUGIN_HEADER

@@ -287,7 +288,7 @@
 int edit_list(void)
 {
     struct gui_synclist lists;
-    bool exit = false;
+    bool quit = false;
     int button,i;
     int selection, ret = 0;

@@ -306,7 +307,7 @@
     rb->gui_synclist_limit_scroll(&lists,true);
     rb->gui_synclist_select_item(&lists, 0);

-    while (!exit)
+    while (!quit)
     {
         rb->gui_synclist_draw(&lists);
         button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
@@ -359,7 +360,7 @@
                     case 0:
                         save_list();
                     case 1:
-                        exit = true;
+                        quit = true;
                         ret = -2;
                 }
             }
@@ -537,7 +538,7 @@

 int main_menu(void)
 {
-    bool exit = false;
+    bool quit = false;

     MENUITEM_STRINGLIST(menu, "Main Menu", NULL,
                         "Generate Folder List",
@@ -567,7 +568,7 @@
             rb->cpu_boost(true);
 #endif
             if (edit_list() < 0)
-                exit = true;
+                quit = true;
 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
             rb->cpu_boost(false);
 #endif
@@ -603,21 +604,26 @@
             rb->backlight_on();
             break;
         case 4:
-            start_shuffled_play();
-            exit=true;
+        {
+            int ret = start_shuffled_play();
+            if (!ret)
+                exit(PLUGIN_ERROR);
+            else
+                exit(PLUGIN_GOTO_WPS);
             break;
+        }
         case 5:
             return 1;
     }
-    return exit?1:0;
+    return quit?1:0;
 }

 enum plugin_status plugin_start(const void* parameter)
 {
+    PLUGINLIB_EXIT_INIT;
     (void)parameter;

     abort = false;
-    
     while (!main_menu())
         ;
     return PLUGIN_OK;
Index: apps/plugins/lib/pluginlib_exit.h
===================================================================
--- apps/plugins/lib/pluginlib_exit.h  (Revision 21603)
+++ apps/plugins/lib/pluginlib_exit.h  (Arbeitskopie)
@@ -30,18 +30,21 @@
 #endif

 /* PLUGINLIB_EXIT_INIT needs to be placed as the first line in plugin_start */
-#define PLUGINLIB_EXIT_INIT switch(setjmp(__exit_env))   \
-                            {                            \
-                                case 1:                  \
-                                    return PLUGIN_OK;    \
-                                case 2:                  \
-                                    return PLUGIN_ERROR; \
-                                case 0:                  \
-                                default:                 \
-                                    break;               \
+#define PLUGINLIB_EXIT_INIT switch(setjmp(__exit_env))      \
+                            {                               \
+                                case -1:                    \
+                                    return PLUGIN_ERROR;    \
+                                case PLUGIN_OK+1:           \
+                                    return PLUGIN_OK;       \
+                                case PLUGIN_GOTO_WPS+1:     \
+                                    return PLUGIN_GOTO_WPS; \
+                                case PLUGIN_USB_CONNECTED+1:    \
+                                    return PLUGIN_USB_CONNECTED;\
+                                default:                    \
+                                    break;                  \
                             }

 extern jmp_buf __exit_env;
-#define exit(status) longjmp(__exit_env, status != 0 ? 2 : 1)
+#define exit(status) longjmp(__exit_env, (status < 0 || status >= PLUGIN_MAX_RETURNS) ? -1:status+1)

 #endif /*  __PLUGINLIB_EXIT_H__ */
Index: apps/plugins/properties.c
===================================================================
--- apps/plugins/properties.c  (Revision 21603)
+++ apps/plugins/properties.c  (Arbeitskopie)
@@ -276,6 +276,7 @@
     int button;
     bool quit = false;
     char file[MAX_PATH];
+    int ret = PLUGIN_OK;
     rb->strcpy(file, (const char *) parameter);

     /* determine if it's a file or a directory */
@@ -332,11 +333,13 @@
 
     while(!quit)
     {
-        button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
+        button = rb->get_action(CONTEXT_TREE,TIMEOUT_BLOCK);
         if (rb->gui_synclist_do_button(&properties_lists,&button,LIST_WRAP_ON))
             continue;
         switch(button)
         {
+            case ACTION_TREE_WPS:
+                return PLUGIN_GOTO_WPS;
             case ACTION_STD_CANCEL:
                 quit = true;
                 break;
@@ -346,5 +349,5 @@
         }
     }
 
-    return PLUGIN_OK;
+    return ret;
 }
Index: apps/plugins/pictureflow/pictureflow.c
===================================================================
--- apps/plugins/pictureflow/pictureflow.c  (Revision 21603)
+++ apps/plugins/pictureflow/pictureflow.c  (Arbeitskopie)
@@ -54,6 +54,12 @@
 #define PF_CONTEXT ACTION_STD_CONTEXT
 #define PF_BACK ACTION_STD_CANCEL
 #define PF_MENU ACTION_STD_MENU
+#define PF_WPS ACTION_TREE_WPS
+
+#if PF_PLAYBACK_CAPABLE
+#define PF_STOP ACTION_TREE_STOP
+#endif
+
 #define PF_QUIT (LAST_ACTION_PLACEHOLDER + 1)
 
 #if !defined(HAVE_SCROLLWHEEL)
@@ -122,8 +128,6 @@
     {PF_BACK,         BUTTON_POWER|BUTTON_REL,    BUTTON_POWER},
     {ACTION_NONE,     BUTTON_POWER,               BUTTON_NONE},
 #endif
-#elif CONFIG_KEYPAD == SANSA_E200_PAD
-    {PF_QUIT,         BUTTON_POWER,               BUTTON_NONE},
 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
     {PF_QUIT,         BUTTON_EQ,                  BUTTON_NONE},
 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
@@ -2008,6 +2012,10 @@
 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 +2144,7 @@
   Show the main menu
  */
 enum {
+    PF_GOTO_WPS,
 #if PF_PLAYBACK_CAPABLE
     PF_MENU_PLAYBACK_CONTROL,
 #endif
@@ -2154,12 +2163,15 @@
 #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 +2181,8 @@
                 result = settings_menu();
                 if ( result != 0 ) return result;
                 break;
-
             case PF_MENU_RETURN:
                 return 0;
-
             case PF_MENU_QUIT:
                 return -1;
 
@@ -2400,6 +2410,16 @@
     old_shuffle = shuffle;
 }
 #endif
+/*
+int tracklist_context(void)
+{
+    char* filename = get_track_filename(selected_track);
+    int attr = 0x300;
+    int context = CONTEXT_ID3DB;
+    return rb->onplay(filename, attr, context);
+}
+*/
+
 /**
    Draw the current album name
  */
@@ -2656,7 +2676,13 @@
         switch (button) {
         case PF_QUIT:
             return PLUGIN_OK;
-
+        case PF_WPS:
+            return PLUGIN_GOTO_WPS;
+#if PF_PLAYBACK_CAPABLE
+        case PF_STOP:
+            rb->audio_stop();
+            break;
+#endif
         case PF_BACK:
             if ( pf_state == pf_show_tracks )
             {
@@ -2668,12 +2694,12 @@
             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 +2734,12 @@
 #endif
             }
             break;
-
+        case PF_CONTEXT:
+/*
+            if ( pf_state == pf_show_tracks)
+                tracklist_context();
+*/
+            break;
         default:
             if (rb->default_event_handler_ex(button, cleanup, NULL)
                 == SYS_USB_CONNECTED)
@@ -2747,9 +2778,6 @@
 #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 +2787,6 @@
         }
     }
 
-    end_pf_thread();
     cleanup(NULL);
     return ret;
 }
Index: apps/onplay.c
===================================================================
--- apps/onplay.c  (Revision 21603)
+++ apps/onplay.c  (Arbeitskopie)
@@ -79,6 +79,7 @@
     static const struct menu_callback_with_desc name##__ = {callback,str,icon};\
     static const struct menu_item_ex name =                             \
         {MT_MENU|MENU_HAS_DESC|MENU_EXITAFTERTHISMENU|                  \
+        MENU_ALLOW_AUDIO_ACTIONS|                                       \
          MENU_ITEM_COUNT(sizeof( name##_)/sizeof(*name##_)),            \
             { (void*)name##_},{.callback_and_desc = & name##__}};
             
@@ -135,12 +136,18 @@
     return action;
 }
 
-static bool list_viewers(void)
+static int list_viewers(void)
 {
     int ret = filetype_list_viewers(selected_file);
-    if (ret == PLUGIN_USB_CONNECTED)
+    if (ret == PLUGIN_USB_CONNECTED
+        ||ret == SYS_USB_CONNECTED)
         onplay_result = ONPLAY_RELOAD_DIR;
-    return false;
+    else if (ret == ACTION_TREE_WPS)
+    {
+        onplay_result = ONPLAY_START_PLAY;
+        return GO_TO_WPS;
+    }
+    return 0;
 }
 
 static bool shuffle_playlist(void)
@@ -1017,7 +1024,7 @@
                   properties, NULL, clipboard_callback, Icon_NOICON);
 MENUITEM_FUNCTION(create_dir_item, 0, ID2P(LANG_CREATE_DIR),
                   create_dir, NULL, clipboard_callback, Icon_NOICON);
-MENUITEM_FUNCTION(list_viewers_item, 0, ID2P(LANG_ONPLAY_OPEN_WITH),
+MENUITEM_FUNCTION(list_viewers_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_ONPLAY_OPEN_WITH),
                   list_viewers, NULL, clipboard_callback, Icon_NOICON);
 #if LCD_DEPTH > 1
 MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP),
@@ -1155,18 +1162,16 @@
 #endif
            &add_to_faves_item,
          );
+
 static int onplaymenu_callback(int action,const struct menu_item_ex *this_item)
 {
     (void)this_item;
     switch (action)
     {
         case ACTION_TREE_STOP:
+            list_stop_handler();
             if (this_item == &wps_onplay_menu)
-            {
-                list_stop_handler();
                 return ACTION_STD_CANCEL;
-            }
-            break;
         case ACTION_EXIT_MENUITEM:
             return ACTION_EXIT_AFTER_THIS_MENUITEM;
             break;
@@ -1187,6 +1192,7 @@
     switch (do_menu(menu, NULL, NULL, false))
     {
         case GO_TO_WPS:
+        case GO_TO_PREVIOUS_MUSIC:
             return ONPLAY_START_PLAY;
         case GO_TO_ROOT:
         case GO_TO_MAINMENU:
Index: apps/gui/list.c
===================================================================
--- apps/gui/list.c  (Revision 21603)
+++ apps/gui/list.c  (Arbeitskopie)
@@ -838,8 +838,9 @@
     return simplelist_text[item];
 }
 
-bool simplelist_show_list(struct simplelist_info *info)
+int simplelist_show_list(struct simplelist_info *info)
 {
+    int retval = 0;
     struct gui_synclist lists;
     int action, old_line_count = simplelist_line_count;
     int oldbars = viewportmanager_set_statusbar(VP_SB_ALLSCREENS);
@@ -880,7 +881,7 @@
 
     while(1)
     {
-        list_do_action(CONTEXT_STD, info->timeout,
+        list_do_action(CONTEXT_TREE, info->timeout,
                        &lists, &action, wrap);
 
         /* We must yield in this case or no other thread can run */
@@ -897,7 +898,6 @@
                 info->selection = gui_synclist_get_sel_pos(&lists);
                 break;
             }
-                
             if (info->get_name == NULL)
                 gui_synclist_set_nb_items(&lists,
                         simplelist_line_count*info->selection_size);
@@ -919,11 +919,14 @@
             old_line_count = simplelist_line_count;
         }
         else if(default_event_handler(action) == SYS_USB_CONNECTED)
-            return true;
+            return SYS_USB_CONNECTED;
+        else if(action == ACTION_TREE_WPS ||
+                action == ACTION_TREE_STOP)
+            return action;
     }
     talk_shutup();
     viewportmanager_set_statusbar(oldbars);
-    return false;
+    return retval;
 }
 
 void simplelist_info_init(struct simplelist_info *info, char* title,
Index: apps/gui/list.h
===================================================================
--- apps/gui/list.h  (Revision 21603)
+++ apps/gui/list.h  (Arbeitskopie)
@@ -255,6 +255,6 @@
 /* show a list.
    if list->action_callback != NULL it is called with the action ACTION_REDRAW
     before the list is dislplayed for the first time */
-bool simplelist_show_list(struct simplelist_info *info);
+int simplelist_show_list(struct simplelist_info *info);
 
 #endif /* _GUI_LIST_H_ */
Index: apps/menu.c
===================================================================
--- apps/menu.c  (Revision 21603)
+++ apps/menu.c  (Arbeitskopie)
@@ -428,12 +428,14 @@
             done = true;
         }
 #endif
-        else if (action == ACTION_TREE_WPS)
+        else if (menu->flags & MENU_ALLOW_AUDIO_ACTIONS
+                && action == ACTION_TREE_WPS)
         {
             ret = GO_TO_PREVIOUS_MUSIC;
             done = true;
         }
-        else if (action == ACTION_TREE_STOP)
+        else if (menu->flags & MENU_ALLOW_AUDIO_ACTIONS
+                && action == ACTION_TREE_STOP)
         {
             redraw_lists = list_stop_handler();
         }
Index: apps/menus/main_menu.c
===================================================================
--- apps/menus/main_menu.c  (Revision 21603)
+++ apps/menus/main_menu.c  (Arbeitskopie)
@@ -394,10 +394,12 @@
     }
     return action;
 }
-static bool show_info(void)
+
+static int show_info(void* ignored)
 {
     struct info_data data = {.new_data = true };
     struct simplelist_info info;
+    (void)ignored;
     simplelist_info_init(&info, str(LANG_ROCKBOX_INFO), INFO_COUNT, (void*)&data);
     info.hide_selection = !global_settings.talk_menu;
     if (info.hide_selection)
@@ -409,7 +411,7 @@
     return simplelist_show_list(&info);
 }
 MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO),
-                   (menu_function)show_info, NULL, NULL, Icon_NOICON);
+                   show_info, NULL, NULL, Icon_NOICON);
 
 
 /* sleep Menu */
@@ -441,6 +443,18 @@
                    &sleep_timer_set, -5, 300, 0, sleep_timer_formatter);
 }
 
+static int debug_callback(int action, const struct menu_item_ex *this_item)
+{
+    switch(action)
+    {
+        case ACTION_TREE_WPS:
+            panicf("LOL");
+            return GO_TO_WPS;
+        default:
+            break;
+    }
+    return action;
+}
 
 #if CONFIG_RTC
 int time_screen(void* ignored);
@@ -456,10 +470,10 @@
                    (menu_function)show_credits, NULL, NULL, Icon_NOICON);
 MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME),
                    (menu_function)view_runtime, NULL, NULL, Icon_NOICON);
-MENUITEM_FUNCTION(debug_menu_item, 0, ID2P(LANG_DEBUG),
-                   (menu_function)debug_menu, NULL, NULL, Icon_NOICON);
+MENUITEM_FUNCTION(debug_menu_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_DEBUG),
+                   debug_menu, NULL, NULL, Icon_NOICON);
 
-MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_Questionmark,
+MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), debug_callback, Icon_Questionmark,
 #if CONFIG_RTC
           &timedate_item,
 #endif
Index: apps/menu.h
===================================================================
--- apps/menu.h  (Revision 21603)
+++ apps/menu.h  (Arbeitskopie)
@@ -61,6 +61,7 @@
 /* Flags for MT_FUNCTION_CALL */
 #define MENU_FUNC_USEPARAM 0x80
 #define MENU_FUNC_CHECK_RETVAL 0x100
+#define MENU_ALLOW_AUDIO_ACTIONS  0x200
 
 #define MENU_COUNT_MASK 0xFFF
 #define MENU_COUNT_SHIFT 12
Index: apps/filetree.c
===================================================================
--- apps/filetree.c  (Revision 21603)
+++ apps/filetree.c  (Arbeitskopie)
@@ -552,22 +552,31 @@
 
                 /* 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 @@
                 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;
             }
Index: apps/plugin.c
===================================================================
--- apps/plugin.c  (Revision 21603)
+++ apps/plugin.c  (Arbeitskopie)
@@ -658,6 +658,7 @@
     appsversion,
     /* new stuff at the end, sort into place next time
        the API gets incompatible */
+    onplay,
     playlist_insert_directory,
 };
 
@@ -804,8 +805,6 @@
 #endif /* LCD_DEPTH */
 #endif /* HAVE_LCD_BITMAP */
 
-    lcd_clear_display();
-    lcd_update();
 
 #ifdef HAVE_REMOTE_LCD
 #if LCD_REMOTE_DEPTH > 1
@@ -814,12 +813,16 @@
 #else
     lcd_remote_set_drawmode(DRMODE_SOLID);
 #endif
-    lcd_remote_clear_display();
 
+    if (rc != PLUGIN_GOTO_WPS)
+    {
+        lcd_clear_display();
+        lcd_update();
+        lcd_remote_clear_display();
+        lcd_remote_update();
+    }
 
-    lcd_remote_update();
 
-
 #endif
     viewportmanager_set_statusbar(oldbars);
     if (pfn_tsr_exit == NULL)
@@ -827,19 +830,10 @@
 
     sim_plugin_close(pd);
 
-    switch (rc) {
-        case PLUGIN_OK:
-            break;
+    if (rc == PLUGIN_ERROR)
+        splash(HZ*2, str(LANG_PLUGIN_ERROR));
 
-        case PLUGIN_USB_CONNECTED:
-            return PLUGIN_USB_CONNECTED;
-
-        default:
-            splash(HZ*2, str(LANG_PLUGIN_ERROR));
-            break;
-    }
-
-    return PLUGIN_OK;
+    return rc;
 }
 
 /* Returns a pointer to the portion of the plugin buffer that is not already
Index: apps/plugin.h
===================================================================
--- apps/plugin.h  (Revision 21603)
+++ apps/plugin.h  (Arbeitskopie)
@@ -93,6 +93,7 @@
 #include "ata_idle_notify.h"
 #include "settings_list.h"
 #include "timefuncs.h"
+#include "onplay.h"
 
 #ifdef HAVE_ALBUMART
 #include "albumart.h"
@@ -139,6 +140,8 @@
 enum plugin_status {
     PLUGIN_OK = 0,
     PLUGIN_USB_CONNECTED,
+    PLUGIN_GOTO_WPS,
+    PLUGIN_MAX_RETURNS,
     PLUGIN_ERROR = -1,
 };
 
@@ -351,7 +354,7 @@
                                         const struct text_message * no_message);
     void (*simplelist_info_init)(struct simplelist_info *info, char* title,
            int count, void* data);
-    bool (*simplelist_show_list)(struct simplelist_info *info);
+    int  (*simplelist_show_list)(struct simplelist_info *info);
 
     /* button */
     long (*button_get)(bool block);
@@ -821,6 +824,7 @@
     const char *appsversion;
     /* new stuff at the end, sort into place next time
        the API gets incompatible */
+    int (*onplay)(char* file, int attr, int from);
     int (*playlist_insert_directory)(struct playlist_info* playlist,
                               const char *dirname, int position, bool queue,
                               bool recurse);
Index: apps/root_menu.c
===================================================================
--- apps/root_menu.c  (Revision 21603)
+++ apps/root_menu.c  (Arbeitskopie)
@@ -414,6 +414,8 @@
 {
     switch (action)
     {
+        case ACTION_TREE_WPS:
+            return GO_TO_WPS;
         case ACTION_TREE_STOP:
             return ACTION_REDRAW;
         case ACTION_REQUEST_MENUITEM:
@@ -434,6 +436,7 @@
     }
     return action;
 }
+
 static int get_selection(int last_screen)
 {
     unsigned int i;
Index: apps/debug_menu.c
===================================================================
--- apps/debug_menu.c  (Revision 21603)
+++ apps/debug_menu.c  (Arbeitskopie)
@@ -2853,8 +2853,9 @@
     (void)data; (void)buffer; (void)buffer_len;
     return menuitems[item].desc;
 }
-bool debug_menu(void)
+int debug_menu(void* ignored)
 {
+    (void)ignored;
     struct simplelist_info info;
 
     simplelist_info_init(&info, "Debug Menu", ARRAYLEN(menuitems), NULL);
Index: apps/debug_menu.h
===================================================================
--- apps/debug_menu.h  (Revision 21603)
+++ apps/debug_menu.h  (Arbeitskopie)
@@ -21,7 +21,7 @@
 #ifndef _DEBUG_MENU_H
 #define _DEBUG_MENU_H
 
-bool debug_menu(void);
+int debug_menu(void* ignored);
 
 #ifndef SIMULATOR
 extern bool dbg_ports(void);
Index: apps/tagtree.c
===================================================================
--- apps/tagtree.c  (Revision 21603)
+++ apps/tagtree.c  (Arbeitskopie)
@@ -54,6 +54,11 @@
 #include "storage.h"
 #include "dir_uncached.h"
 
+#ifdef HAVE_LCD_BITMAP
+#include "plugin.h" /* to plugin_load() pictureflow */
+#endif
+
+
 #define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config"
 
 static int tagtree_play_folder(struct tree_context* c);
@@ -65,6 +70,9 @@
     NAVIBROWSE,
     ALLSUBENTRIES,
     PLAYTRACK,
+#ifdef HAVE_LCD_BITMAP
+    PICTUREFLOW,
+#endif
 };
 
 static const struct id3_to_search_mapping {
@@ -1166,6 +1174,16 @@
             dptr++;
             current_entry_count++;
         }
+#ifdef HAVE_LCD_BITMAP
+        if (offset <= 2 && tag == tag_album)
+        {
+            dptr->newtable = PICTUREFLOW;
+            dptr->name = "<By Covers>";
+            dptr++;
+            current_entry_count++;
+            special_entry_count++;
+        }
+#endif
         special_entry_count+=2;
     }
     
@@ -1366,7 +1384,9 @@
         case ROOT:
             count = load_root(c);
             break;
-
+#ifdef HAVE_LCD_BITMAP
+        case PICTUREFLOW:
+#endif
         case ALLSUBENTRIES:
         case NAVIBROWSE:
             logf("navibrowse...");
@@ -1416,6 +1436,23 @@
     }
     newextra = dptr->newtable;
 
+#ifdef HAVE_LCD_BITMAP
+    /* Start pictureflow, and return as we're leaving the db browser
+     * and also we still want to be in the album node after exiting
+     */
+    if (newextra == PICTUREFLOW)
+    {
+        int retval = plugin_load(PLUGIN_DEMOS_DIR "/pictureflow.rock", NULL);
+        switch(retval)
+        {
+            case PLUGIN_GOTO_WPS:
+                return 2;
+            default:
+                return 0;
+        }
+    }
+#endif
+
     if (c->dirlevel >= MAX_DIR_LEVELS)
         return 0;