diff options
Diffstat (limited to 'apps/root_menu.c')
-rw-r--r-- | apps/root_menu.c | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/apps/root_menu.c b/apps/root_menu.c index 15d03a7cda..ed6bdfdcca 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c | |||
@@ -634,6 +634,7 @@ static int item_callback(int action, | |||
634 | } | 634 | } |
635 | return action; | 635 | return action; |
636 | } | 636 | } |
637 | |||
637 | static int get_selection(int last_screen) | 638 | static int get_selection(int last_screen) |
638 | { | 639 | { |
639 | int i; | 640 | int i; |
@@ -683,6 +684,7 @@ static inline int load_screen(int screen) | |||
683 | last_screen = old_previous; | 684 | last_screen = old_previous; |
684 | return ret_val; | 685 | return ret_val; |
685 | } | 686 | } |
687 | |||
686 | static int load_context_screen(int selection) | 688 | static int load_context_screen(int selection) |
687 | { | 689 | { |
688 | const struct menu_item_ex *context_menu = NULL; | 690 | const struct menu_item_ex *context_menu = NULL; |
@@ -709,13 +711,12 @@ static int load_plugin_screen(char *key) | |||
709 | { | 711 | { |
710 | int ret_val; | 712 | int ret_val; |
711 | int old_previous = last_screen; | 713 | int old_previous = last_screen; |
714 | int old_global = global_status.last_screen; | ||
712 | last_screen = next_screen; | 715 | last_screen = next_screen; |
713 | global_status.last_screen = (char)next_screen; | 716 | global_status.last_screen = (char)next_screen; |
714 | status_save(); | 717 | status_save(); |
715 | 718 | ||
716 | |||
717 | int opret = open_plugin_get_entry(key, &open_plugin_entry); | 719 | int opret = open_plugin_get_entry(key, &open_plugin_entry); |
718 | bool flush = (opret == OPEN_PLUGIN_NEEDS_FLUSHED); | ||
719 | char *path = open_plugin_entry.path; | 720 | char *path = open_plugin_entry.path; |
720 | char *param = open_plugin_entry.param; | 721 | char *param = open_plugin_entry.param; |
721 | if (param[0] == '\0') | 722 | if (param[0] == '\0') |
@@ -723,6 +724,9 @@ static int load_plugin_screen(char *key) | |||
723 | 724 | ||
724 | switch (plugin_load(path, param)) | 725 | switch (plugin_load(path, param)) |
725 | { | 726 | { |
727 | case PLUGIN_USB_CONNECTED: | ||
728 | ret_val = GO_TO_ROOT; | ||
729 | break; | ||
726 | case PLUGIN_GOTO_WPS: | 730 | case PLUGIN_GOTO_WPS: |
727 | ret_val = GO_TO_WPS; | 731 | ret_val = GO_TO_WPS; |
728 | break; | 732 | break; |
@@ -730,18 +734,30 @@ static int load_plugin_screen(char *key) | |||
730 | ret_val = GO_TO_PLUGIN; | 734 | ret_val = GO_TO_PLUGIN; |
731 | break; | 735 | break; |
732 | case PLUGIN_OK: | 736 | case PLUGIN_OK: |
733 | ret_val = audio_status() ? GO_TO_PREVIOUS : GO_TO_ROOT; | 737 | /* Prevents infinite loop with WPS & Plugins*/ |
734 | break; | 738 | if (old_global == GO_TO_WPS && !audio_status()) |
739 | { | ||
740 | ret_val = GO_TO_ROOT; | ||
741 | break; | ||
742 | } | ||
743 | /*fallthrough*/ | ||
735 | default: | 744 | default: |
736 | ret_val = GO_TO_PREVIOUS; | 745 | ret_val = GO_TO_PREVIOUS; |
746 | last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous; | ||
737 | break; | 747 | break; |
738 | } | ||
739 | 748 | ||
740 | if (!flush && ret_val != GO_TO_PLUGIN) | 749 | } |
741 | open_plugin_add_path(NULL, NULL, NULL); | ||
742 | 750 | ||
743 | if (ret_val == GO_TO_PREVIOUS) | 751 | if (ret_val != GO_TO_PLUGIN) |
744 | last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous; | 752 | { |
753 | if (opret != OPEN_PLUGIN_NEEDS_FLUSHED || last_screen != GO_TO_WPS) | ||
754 | { | ||
755 | /* Keep the entry in case of GO_TO_PREVIOUS */ | ||
756 | open_plugin_entry.hash = 0; /*remove hash -- prevents flush to disk */ | ||
757 | open_plugin_entry.lang_id = LANG_PREVIOUS_SCREEN; | ||
758 | /*open_plugin_add_path(NULL, NULL, NULL);// clear entry */ | ||
759 | } | ||
760 | } | ||
745 | return ret_val; | 761 | return ret_val; |
746 | } | 762 | } |
747 | 763 | ||
@@ -858,8 +874,12 @@ void root_menu(void) | |||
858 | #endif /* With !CONFIG_TUNER previous_music is always GO_TO_WPS */ | 874 | #endif /* With !CONFIG_TUNER previous_music is always GO_TO_WPS */ |
859 | 875 | ||
860 | case GO_TO_PREVIOUS: | 876 | case GO_TO_PREVIOUS: |
877 | { | ||
861 | next_screen = last_screen; | 878 | next_screen = last_screen; |
879 | if (last_screen == GO_TO_PLUGIN)/* for WPS */ | ||
880 | last_screen = GO_TO_PREVIOUS; | ||
862 | break; | 881 | break; |
882 | } | ||
863 | 883 | ||
864 | case GO_TO_PREVIOUS_BROWSER: | 884 | case GO_TO_PREVIOUS_BROWSER: |
865 | next_screen = previous_browser; | 885 | next_screen = previous_browser; |
@@ -874,7 +894,8 @@ void root_menu(void) | |||
874 | case GO_TO_PLUGIN: | 894 | case GO_TO_PLUGIN: |
875 | { | 895 | { |
876 | char *key; | 896 | char *key; |
877 | if (global_status.last_screen == GO_TO_SHORTCUTMENU) | 897 | if (global_status.last_screen == GO_TO_SHORTCUTMENU && |
898 | last_screen != GO_TO_ROOT) | ||
878 | { | 899 | { |
879 | shortcut_origin = last_screen; | 900 | shortcut_origin = last_screen; |
880 | key = ID2P(LANG_SHORTCUTS); | 901 | key = ID2P(LANG_SHORTCUTS); |
@@ -892,6 +913,9 @@ void root_menu(void) | |||
892 | case GO_TO_SHORTCUTMENU: | 913 | case GO_TO_SHORTCUTMENU: |
893 | key = ID2P(LANG_SHORTCUTS); | 914 | key = ID2P(LANG_SHORTCUTS); |
894 | break; | 915 | break; |
916 | case GO_TO_PREVIOUS: | ||
917 | key = ID2P(LANG_PREVIOUS_SCREEN); | ||
918 | break; | ||
895 | default: | 919 | default: |
896 | key = ID2P(LANG_OPEN_PLUGIN); | 920 | key = ID2P(LANG_OPEN_PLUGIN); |
897 | break; | 921 | break; |
@@ -900,15 +924,23 @@ void root_menu(void) | |||
900 | 924 | ||
901 | next_screen = load_plugin_screen(key); | 925 | next_screen = load_plugin_screen(key); |
902 | 926 | ||
903 | /* shortcuts may take several trips through the GO_TO_PLUGIN case | 927 | if (next_screen == GO_TO_PREVIOUS) |
904 | make sure we preserve and restore the origin */ | ||
905 | if (next_screen == GO_TO_PREVIOUS && shortcut_origin != GO_TO_ROOT) | ||
906 | { | 928 | { |
907 | if (shortcut_origin != GO_TO_WPS) | 929 | /* shortcuts may take several trips through the GO_TO_PLUGIN |
908 | next_screen = shortcut_origin; | 930 | case make sure we preserve and restore the origin */ |
909 | shortcut_origin = GO_TO_ROOT; | 931 | if (shortcut_origin != GO_TO_ROOT) |
932 | { | ||
933 | if (shortcut_origin != GO_TO_WPS) | ||
934 | next_screen = shortcut_origin; | ||
935 | shortcut_origin = GO_TO_ROOT; | ||
936 | } | ||
937 | /* skip GO_TO_PREVIOUS */ | ||
938 | if (last_screen == GO_TO_BROWSEPLUGINS) | ||
939 | { | ||
940 | next_screen = last_screen; | ||
941 | last_screen = GO_TO_PLUGIN; | ||
942 | } | ||
910 | } | 943 | } |
911 | |||
912 | previous_browser = (next_screen != GO_TO_WPS) ? GO_TO_FILEBROWSER : GO_TO_PLUGIN; | 944 | previous_browser = (next_screen != GO_TO_WPS) ? GO_TO_FILEBROWSER : GO_TO_PLUGIN; |
913 | break; | 945 | break; |
914 | } | 946 | } |