diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/bookmark.c | 141 | ||||
-rw-r--r-- | apps/bookmark.h | 9 | ||||
-rw-r--r-- | apps/onplay.c | 16 |
3 files changed, 107 insertions, 59 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c index cce8ef88bf..e0325b38d4 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -93,8 +93,7 @@ static const char* get_bookmark_info(int list_index, | |||
93 | void* data, | 93 | void* data, |
94 | char *buffer, | 94 | char *buffer, |
95 | size_t buffer_len); | 95 | size_t buffer_len); |
96 | static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resume); | 96 | static int select_bookmark(const char* bookmark_file_name, bool show_dont_resume, char** selected_bookmark); |
97 | static bool is_bookmarkable_state(void); | ||
98 | static bool write_bookmark(bool create_bookmark_file, const char *bookmark); | 97 | static bool write_bookmark(bool create_bookmark_file, const char *bookmark); |
99 | static int get_bookmark_count(const char* bookmark_file_name); | 98 | static int get_bookmark_count(const char* bookmark_file_name); |
100 | 99 | ||
@@ -109,37 +108,38 @@ static char global_bookmark[MAX_BOOKMARK_SIZE]; | |||
109 | static char global_filename[MAX_PATH]; | 108 | static char global_filename[MAX_PATH]; |
110 | 109 | ||
111 | /* ----------------------------------------------------------------------- */ | 110 | /* ----------------------------------------------------------------------- */ |
112 | /* This is the interface function from the main menu. */ | 111 | /* This is an interface function from the context menu. */ |
112 | /* Returns true on successful bookmark creation. */ | ||
113 | /* ----------------------------------------------------------------------- */ | 113 | /* ----------------------------------------------------------------------- */ |
114 | bool bookmark_create_menu(void) | 114 | bool bookmark_create_menu(void) |
115 | { | 115 | { |
116 | write_bookmark(true, create_bookmark()); | 116 | return write_bookmark(true, create_bookmark()); |
117 | return false; | ||
118 | } | 117 | } |
119 | 118 | ||
120 | /* ----------------------------------------------------------------------- */ | 119 | /* ----------------------------------------------------------------------- */ |
121 | /* This function acts as the load interface from the main menu */ | 120 | /* This function acts as the load interface from the context menu. */ |
122 | /* This function determines the bookmark file name and then loads that file*/ | 121 | /* This function determines the bookmark file name and then loads that file*/ |
123 | /* for the user. The user can then select a bookmark to load. */ | 122 | /* for the user. The user can then select or delete previous bookmarks. */ |
124 | /* If no file/directory is currently playing, the menu item does not work. */ | 123 | /* This function returns BOOKMARK_SUCCESS on the selection of a track to */ |
124 | /* resume, BOOKMARK_FAIL if the menu is exited without a selection and */ | ||
125 | /* BOOKMARK_USB_CONNECTED if the menu is forced to exit due to a USB */ | ||
126 | /* connection. */ | ||
125 | /* ----------------------------------------------------------------------- */ | 127 | /* ----------------------------------------------------------------------- */ |
126 | bool bookmark_load_menu(void) | 128 | int bookmark_load_menu(void) |
127 | { | 129 | { |
128 | bool ret = false; | 130 | char* bookmark; |
131 | int ret = BOOKMARK_FAIL; | ||
129 | 132 | ||
130 | push_current_activity(ACTIVITY_BOOKMARKSLIST); | 133 | push_current_activity(ACTIVITY_BOOKMARKSLIST); |
131 | if (is_bookmarkable_state()) | 134 | |
132 | { | 135 | char* name = playlist_get_name(NULL, global_temp_buffer, |
133 | char* name = playlist_get_name(NULL, global_temp_buffer, | ||
134 | sizeof(global_temp_buffer)); | 136 | sizeof(global_temp_buffer)); |
135 | if (generate_bookmark_file_name(name)) | 137 | if (generate_bookmark_file_name(name)) |
138 | { | ||
139 | ret = select_bookmark(global_bookmark_file_name, false, &bookmark); | ||
140 | if (bookmark != NULL) | ||
136 | { | 141 | { |
137 | char* bookmark = select_bookmark(global_bookmark_file_name, false); | 142 | ret = play_bookmark(bookmark) ? BOOKMARK_SUCCESS : BOOKMARK_FAIL; |
138 | |||
139 | if (bookmark != NULL) | ||
140 | { | ||
141 | ret = play_bookmark(bookmark); | ||
142 | } | ||
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
@@ -150,6 +150,7 @@ bool bookmark_load_menu(void) | |||
150 | /* ----------------------------------------------------------------------- */ | 150 | /* ----------------------------------------------------------------------- */ |
151 | /* Gives the user a list of the Most Recent Bookmarks. This is an */ | 151 | /* Gives the user a list of the Most Recent Bookmarks. This is an */ |
152 | /* interface function */ | 152 | /* interface function */ |
153 | /* Returns true on the successful selection of a recent bookmark. */ | ||
153 | /* ----------------------------------------------------------------------- */ | 154 | /* ----------------------------------------------------------------------- */ |
154 | bool bookmark_mrb_load() | 155 | bool bookmark_mrb_load() |
155 | { | 156 | { |
@@ -157,7 +158,7 @@ bool bookmark_mrb_load() | |||
157 | bool ret = false; | 158 | bool ret = false; |
158 | 159 | ||
159 | push_current_activity(ACTIVITY_BOOKMARKSLIST); | 160 | push_current_activity(ACTIVITY_BOOKMARKSLIST); |
160 | bookmark = select_bookmark(RECENT_BOOKMARK_FILE, false); | 161 | select_bookmark(RECENT_BOOKMARK_FILE, false, &bookmark); |
161 | if (bookmark != NULL) | 162 | if (bookmark != NULL) |
162 | { | 163 | { |
163 | ret = play_bookmark(bookmark); | 164 | ret = play_bookmark(bookmark); |
@@ -170,13 +171,14 @@ bool bookmark_mrb_load() | |||
170 | /* ----------------------------------------------------------------------- */ | 171 | /* ----------------------------------------------------------------------- */ |
171 | /* This function handles an autobookmark creation. This is an interface */ | 172 | /* This function handles an autobookmark creation. This is an interface */ |
172 | /* function. */ | 173 | /* function. */ |
174 | /* Returns true on successful bookmark creation. */ | ||
173 | /* ----------------------------------------------------------------------- */ | 175 | /* ----------------------------------------------------------------------- */ |
174 | bool bookmark_autobookmark(bool prompt_ok) | 176 | bool bookmark_autobookmark(bool prompt_ok) |
175 | { | 177 | { |
176 | char* bookmark; | 178 | char* bookmark; |
177 | bool update; | 179 | bool update; |
178 | 180 | ||
179 | if (!is_bookmarkable_state()) | 181 | if (!bookmark_is_bookmarkable_state()) |
180 | return false; | 182 | return false; |
181 | 183 | ||
182 | audio_pause(); /* first pause playback */ | 184 | audio_pause(); /* first pause playback */ |
@@ -229,36 +231,50 @@ bool bookmark_autobookmark(bool prompt_ok) | |||
229 | /* This file will contain N number of bookmarks in the following format: */ | 231 | /* This file will contain N number of bookmarks in the following format: */ |
230 | /* resume_index*resume_offset*resume_seed*resume_first_index* */ | 232 | /* resume_index*resume_offset*resume_seed*resume_first_index* */ |
231 | /* resume_file*milliseconds*MP3 Title* */ | 233 | /* resume_file*milliseconds*MP3 Title* */ |
234 | /* Returns true on successful bookmark write. */ | ||
235 | /* Returns false if any part of the bookmarking process fails. It is */ | ||
236 | /* possible that a bookmark is successfully added to the most recent */ | ||
237 | /* bookmark list but fails to be added to the bookmark file or vice versa. */ | ||
232 | /* ------------------------------------------------------------------------*/ | 238 | /* ------------------------------------------------------------------------*/ |
233 | static bool write_bookmark(bool create_bookmark_file, const char *bookmark) | 239 | static bool write_bookmark(bool create_bookmark_file, const char *bookmark) |
234 | { | 240 | { |
235 | bool success=false; | 241 | bool ret=true; |
236 | if (!bookmark) | ||
237 | return false; /* something didn't happen correctly, do nothing */ | ||
238 | 242 | ||
239 | if (global_settings.usemrb) | 243 | if (!bookmark) |
240 | success = add_bookmark(RECENT_BOOKMARK_FILE, bookmark, true); | 244 | { |
245 | ret = false; /* something didn't happen correctly, do nothing */ | ||
246 | } | ||
247 | else | ||
248 | { | ||
249 | if (global_settings.usemrb) | ||
250 | ret = add_bookmark(RECENT_BOOKMARK_FILE, bookmark, true); | ||
241 | 251 | ||
242 | 252 | ||
243 | /* writing the bookmark */ | 253 | /* writing the bookmark */ |
244 | if (create_bookmark_file) | 254 | if (create_bookmark_file) |
245 | { | ||
246 | char* name = playlist_get_name(NULL, global_temp_buffer, | ||
247 | sizeof(global_temp_buffer)); | ||
248 | if (generate_bookmark_file_name(name)) | ||
249 | { | 255 | { |
250 | success = add_bookmark(global_bookmark_file_name, bookmark, false); | 256 | char* name = playlist_get_name(NULL, global_temp_buffer, |
257 | sizeof(global_temp_buffer)); | ||
258 | if (generate_bookmark_file_name(name)) | ||
259 | { | ||
260 | ret = ret & add_bookmark(global_bookmark_file_name, bookmark, false); | ||
261 | } | ||
262 | else | ||
263 | { | ||
264 | ret = false; /* generating bookmark file failed */ | ||
265 | } | ||
251 | } | 266 | } |
252 | } | 267 | } |
253 | 268 | ||
254 | splash(HZ, success ? ID2P(LANG_BOOKMARK_CREATE_SUCCESS) | 269 | splash(HZ, ret ? ID2P(LANG_BOOKMARK_CREATE_SUCCESS) |
255 | : ID2P(LANG_BOOKMARK_CREATE_FAILURE)); | 270 | : ID2P(LANG_BOOKMARK_CREATE_FAILURE)); |
256 | 271 | ||
257 | return true; | 272 | return ret; |
258 | } | 273 | } |
259 | 274 | ||
260 | /* ----------------------------------------------------------------------- */ | 275 | /* ----------------------------------------------------------------------- */ |
261 | /* This function adds a bookmark to a file. */ | 276 | /* This function adds a bookmark to a file. */ |
277 | /* Returns true on successful bookmark add. */ | ||
262 | /* ------------------------------------------------------------------------*/ | 278 | /* ------------------------------------------------------------------------*/ |
263 | static bool add_bookmark(const char* bookmark_file_name, const char* bookmark, | 279 | static bool add_bookmark(const char* bookmark_file_name, const char* bookmark, |
264 | bool most_recent) | 280 | bool most_recent) |
@@ -330,13 +346,14 @@ static bool add_bookmark(const char* bookmark_file_name, const char* bookmark, | |||
330 | /* ----------------------------------------------------------------------- */ | 346 | /* ----------------------------------------------------------------------- */ |
331 | /* This function takes the system resume data and formats it into a valid */ | 347 | /* This function takes the system resume data and formats it into a valid */ |
332 | /* bookmark. */ | 348 | /* bookmark. */ |
349 | /* Returns not NULL on successful bookmark format. */ | ||
333 | /* ----------------------------------------------------------------------- */ | 350 | /* ----------------------------------------------------------------------- */ |
334 | static char* create_bookmark() | 351 | static char* create_bookmark() |
335 | { | 352 | { |
336 | int resume_index = 0; | 353 | int resume_index = 0; |
337 | char *file; | 354 | char *file; |
338 | 355 | ||
339 | if (!is_bookmarkable_state()) | 356 | if (!bookmark_is_bookmarkable_state()) |
340 | return NULL; /* something didn't happen correctly, do nothing */ | 357 | return NULL; /* something didn't happen correctly, do nothing */ |
341 | 358 | ||
342 | /* grab the currently playing track */ | 359 | /* grab the currently playing track */ |
@@ -395,9 +412,12 @@ static char* create_bookmark() | |||
395 | /* ----------------------------------------------------------------------- */ | 412 | /* ----------------------------------------------------------------------- */ |
396 | /* This function will determine if an autoload is necessary. This is an */ | 413 | /* This function will determine if an autoload is necessary. This is an */ |
397 | /* interface function. */ | 414 | /* interface function. */ |
415 | /* Returns true on bookmark load or bookmark selection. */ | ||
398 | /* ------------------------------------------------------------------------*/ | 416 | /* ------------------------------------------------------------------------*/ |
399 | bool bookmark_autoload(const char* file) | 417 | bool bookmark_autoload(const char* file) |
400 | { | 418 | { |
419 | char* bookmark; | ||
420 | |||
401 | if(global_settings.autoloadbookmark == BOOKMARK_NO) | 421 | if(global_settings.autoloadbookmark == BOOKMARK_NO) |
402 | return false; | 422 | return false; |
403 | 423 | ||
@@ -416,7 +436,7 @@ bool bookmark_autoload(const char* file) | |||
416 | } | 436 | } |
417 | else | 437 | else |
418 | { | 438 | { |
419 | char* bookmark = select_bookmark(global_bookmark_file_name, true); | 439 | select_bookmark(global_bookmark_file_name, true, &bookmark); |
420 | 440 | ||
421 | if (bookmark != NULL) | 441 | if (bookmark != NULL) |
422 | { | 442 | { |
@@ -439,6 +459,7 @@ bool bookmark_autoload(const char* file) | |||
439 | /* ----------------------------------------------------------------------- */ | 459 | /* ----------------------------------------------------------------------- */ |
440 | /* This function loads the bookmark information into the resume memory. */ | 460 | /* This function loads the bookmark information into the resume memory. */ |
441 | /* This is an interface function. */ | 461 | /* This is an interface function. */ |
462 | /* Returns true on successful bookmark load. */ | ||
442 | /* ------------------------------------------------------------------------*/ | 463 | /* ------------------------------------------------------------------------*/ |
443 | bool bookmark_load(const char* file, bool autoload) | 464 | bool bookmark_load(const char* file, bool autoload) |
444 | { | 465 | { |
@@ -458,7 +479,7 @@ bool bookmark_load(const char* file, bool autoload) | |||
458 | else | 479 | else |
459 | { | 480 | { |
460 | /* This is not an auto-load, so list the bookmarks */ | 481 | /* This is not an auto-load, so list the bookmarks */ |
461 | bookmark = select_bookmark(file, false); | 482 | select_bookmark(file, false, &bookmark); |
462 | } | 483 | } |
463 | 484 | ||
464 | if (bookmark != NULL) | 485 | if (bookmark != NULL) |
@@ -672,10 +693,15 @@ static int bookmark_list_voice_cb(int list_index, void* data) | |||
672 | } | 693 | } |
673 | 694 | ||
674 | /* ----------------------------------------------------------------------- */ | 695 | /* ----------------------------------------------------------------------- */ |
675 | /* This displays a the bookmarks in a file and allows the user to */ | 696 | /* This displays the bookmarks in a file and allows the user to */ |
676 | /* select one to play. */ | 697 | /* select one to play. */ |
698 | /* *selected_bookmark contains a non NULL value on successful bookmark */ | ||
699 | /* selection. */ | ||
700 | /* Returns BOOKMARK_SUCCESS on successful bookmark selection, BOOKMARK_FAIL*/ | ||
701 | /* if no selection was made and BOOKMARK_USB_CONNECTED if the selection */ | ||
702 | /* menu is forced to exit due to a USB connection. */ | ||
677 | /* ------------------------------------------------------------------------*/ | 703 | /* ------------------------------------------------------------------------*/ |
678 | static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resume) | 704 | static int select_bookmark(const char* bookmark_file_name, bool show_dont_resume, char** selected_bookmark) |
679 | { | 705 | { |
680 | struct bookmark_list* bookmarks; | 706 | struct bookmark_list* bookmarks; |
681 | struct gui_synclist list; | 707 | struct gui_synclist list; |
@@ -684,6 +710,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
684 | size_t size; | 710 | size_t size; |
685 | bool exit = false; | 711 | bool exit = false; |
686 | bool refresh = true; | 712 | bool refresh = true; |
713 | int ret = BOOKMARK_FAIL; | ||
687 | 714 | ||
688 | bookmarks = plugin_get_buffer(&size); | 715 | bookmarks = plugin_get_buffer(&size); |
689 | bookmarks->buffer_size = size; | 716 | bookmarks->buffer_size = size; |
@@ -711,7 +738,8 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
711 | /* No more bookmarks, delete file and exit */ | 738 | /* No more bookmarks, delete file and exit */ |
712 | splash(HZ, ID2P(LANG_BOOKMARK_LOAD_EMPTY)); | 739 | splash(HZ, ID2P(LANG_BOOKMARK_LOAD_EMPTY)); |
713 | remove(bookmark_file_name); | 740 | remove(bookmark_file_name); |
714 | return NULL; | 741 | *selected_bookmark = NULL; |
742 | return BOOKMARK_FAIL; | ||
715 | } | 743 | } |
716 | 744 | ||
717 | if (bookmarks->show_dont_resume) | 745 | if (bookmarks->show_dont_resume) |
@@ -771,7 +799,8 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
771 | if (item >= 0) | 799 | if (item >= 0) |
772 | { | 800 | { |
773 | talk_shutup(); | 801 | talk_shutup(); |
774 | return bookmarks->items[item - bookmarks->start]; | 802 | *selected_bookmark = bookmarks->items[item - bookmarks->start]; |
803 | return BOOKMARK_SUCCESS; | ||
775 | } | 804 | } |
776 | 805 | ||
777 | /* Else fall through */ | 806 | /* Else fall through */ |
@@ -806,6 +835,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
806 | default: | 835 | default: |
807 | if (default_event_handler(action) == SYS_USB_CONNECTED) | 836 | if (default_event_handler(action) == SYS_USB_CONNECTED) |
808 | { | 837 | { |
838 | ret = BOOKMARK_USB_CONNECTED; | ||
809 | exit = true; | 839 | exit = true; |
810 | } | 840 | } |
811 | 841 | ||
@@ -814,12 +844,14 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
814 | } | 844 | } |
815 | 845 | ||
816 | talk_shutup(); | 846 | talk_shutup(); |
817 | return NULL; | 847 | *selected_bookmark = NULL; |
848 | return ret; | ||
818 | } | 849 | } |
819 | 850 | ||
820 | /* ----------------------------------------------------------------------- */ | 851 | /* ----------------------------------------------------------------------- */ |
821 | /* This function takes a location in a bookmark file and deletes that */ | 852 | /* This function takes a location in a bookmark file and deletes that */ |
822 | /* bookmark. */ | 853 | /* bookmark. */ |
854 | /* Returns true on successful bookmark deletion. */ | ||
823 | /* ------------------------------------------------------------------------*/ | 855 | /* ------------------------------------------------------------------------*/ |
824 | static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id) | 856 | static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id) |
825 | { | 857 | { |
@@ -919,6 +951,7 @@ static void say_bookmark(const char* bookmark, | |||
919 | 951 | ||
920 | /* ----------------------------------------------------------------------- */ | 952 | /* ----------------------------------------------------------------------- */ |
921 | /* This function parses a bookmark and then plays it. */ | 953 | /* This function parses a bookmark and then plays it. */ |
954 | /* Returns true on successful bookmark play. */ | ||
922 | /* ------------------------------------------------------------------------*/ | 955 | /* ------------------------------------------------------------------------*/ |
923 | static bool play_bookmark(const char* bookmark) | 956 | static bool play_bookmark(const char* bookmark) |
924 | { | 957 | { |
@@ -976,6 +1009,7 @@ static const char* long_token(const char* s, long* dest) | |||
976 | /* This function takes a bookmark and parses it. This function also */ | 1009 | /* This function takes a bookmark and parses it. This function also */ |
977 | /* validates the bookmark. The parse_filenames flag indicates whether */ | 1010 | /* validates the bookmark. The parse_filenames flag indicates whether */ |
978 | /* the filename tokens are to be extracted. */ | 1011 | /* the filename tokens are to be extracted. */ |
1012 | /* Returns true on successful bookmark parse. */ | ||
979 | /* ----------------------------------------------------------------------- */ | 1013 | /* ----------------------------------------------------------------------- */ |
980 | static bool parse_bookmark(const char *bookmark, const bool parse_filenames) | 1014 | static bool parse_bookmark(const char *bookmark, const bool parse_filenames) |
981 | { | 1015 | { |
@@ -1042,6 +1076,7 @@ static bool parse_bookmark(const char *bookmark, const bool parse_filenames) | |||
1042 | /* Changing this function could result in how the bookmarks are stored. */ | 1076 | /* Changing this function could result in how the bookmarks are stored. */ |
1043 | /* it would be here that the centralized/decentralized bookmark code */ | 1077 | /* it would be here that the centralized/decentralized bookmark code */ |
1044 | /* could be placed. */ | 1078 | /* could be placed. */ |
1079 | /* Always returns true */ | ||
1045 | /* ----------------------------------------------------------------------- */ | 1080 | /* ----------------------------------------------------------------------- */ |
1046 | static bool generate_bookmark_file_name(const char *in) | 1081 | static bool generate_bookmark_file_name(const char *in) |
1047 | { | 1082 | { |
@@ -1074,30 +1109,28 @@ static bool generate_bookmark_file_name(const char *in) | |||
1074 | } | 1109 | } |
1075 | 1110 | ||
1076 | /* ----------------------------------------------------------------------- */ | 1111 | /* ----------------------------------------------------------------------- */ |
1077 | /* Returns true if a bookmark file exists for the current playlist */ | 1112 | /* Returns true if a bookmark file exists for the current playlist. */ |
1113 | /* This is an interface function. */ | ||
1078 | /* ----------------------------------------------------------------------- */ | 1114 | /* ----------------------------------------------------------------------- */ |
1079 | bool bookmark_exists(void) | 1115 | bool bookmark_exists(void) |
1080 | { | 1116 | { |
1081 | bool exist=false; | 1117 | bool exist=false; |
1082 | 1118 | ||
1083 | if(is_bookmarkable_state()) | 1119 | char* name = playlist_get_name(NULL, global_temp_buffer, |
1120 | sizeof(global_temp_buffer)); | ||
1121 | if (generate_bookmark_file_name(name)) | ||
1084 | { | 1122 | { |
1085 | char* name = playlist_get_name(NULL, global_temp_buffer, | 1123 | exist = file_exists(global_bookmark_file_name); |
1086 | sizeof(global_temp_buffer)); | ||
1087 | if (generate_bookmark_file_name(name)) | ||
1088 | { | ||
1089 | exist = file_exists(global_bookmark_file_name); | ||
1090 | } | ||
1091 | } | 1124 | } |
1092 | |||
1093 | return exist; | 1125 | return exist; |
1094 | } | 1126 | } |
1095 | 1127 | ||
1096 | /* ----------------------------------------------------------------------- */ | 1128 | /* ----------------------------------------------------------------------- */ |
1097 | /* Checks the current state of the system and returns true if it is in a */ | 1129 | /* Checks the current state of the system and returns true if it is in a */ |
1098 | /* bookmarkable state. */ | 1130 | /* bookmarkable state. */ |
1131 | /* This is an interface funtion. */ | ||
1099 | /* ----------------------------------------------------------------------- */ | 1132 | /* ----------------------------------------------------------------------- */ |
1100 | static bool is_bookmarkable_state(void) | 1133 | bool bookmark_is_bookmarkable_state(void) |
1101 | { | 1134 | { |
1102 | int resume_index = 0; | 1135 | int resume_index = 0; |
1103 | 1136 | ||
diff --git a/apps/bookmark.h b/apps/bookmark.h index 4b61edba9b..ff7b87c1bf 100644 --- a/apps/bookmark.h +++ b/apps/bookmark.h | |||
@@ -23,13 +23,20 @@ | |||
23 | 23 | ||
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | 25 | ||
26 | bool bookmark_load_menu(void); | 26 | enum { |
27 | BOOKMARK_FAIL = -1, | ||
28 | BOOKMARK_SUCCESS = 0, | ||
29 | BOOKMARK_USB_CONNECTED = 1 | ||
30 | }; | ||
31 | |||
32 | int bookmark_load_menu(void); | ||
27 | bool bookmark_autobookmark(bool prompt_ok); | 33 | bool bookmark_autobookmark(bool prompt_ok); |
28 | bool bookmark_create_menu(void); | 34 | bool bookmark_create_menu(void); |
29 | bool bookmark_mrb_load(void); | 35 | bool bookmark_mrb_load(void); |
30 | bool bookmark_autoload(const char* file); | 36 | bool bookmark_autoload(const char* file); |
31 | bool bookmark_load(const char* file, bool autoload); | 37 | bool bookmark_load(const char* file, bool autoload); |
32 | bool bookmark_exists(void); | 38 | bool bookmark_exists(void); |
39 | bool bookmark_is_bookmarkable_state(void); | ||
33 | 40 | ||
34 | #endif /* __BOOKMARK_H__ */ | 41 | #endif /* __BOOKMARK_H__ */ |
35 | 42 | ||
diff --git a/apps/onplay.c b/apps/onplay.c index 143745d366..11fffb9312 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -91,7 +91,8 @@ static int bookmark_menu_callback(int action, | |||
91 | const struct menu_item_ex *this_item); | 91 | const struct menu_item_ex *this_item); |
92 | MENUITEM_FUNCTION(bookmark_create_menu_item, 0, | 92 | MENUITEM_FUNCTION(bookmark_create_menu_item, 0, |
93 | ID2P(LANG_BOOKMARK_MENU_CREATE), | 93 | ID2P(LANG_BOOKMARK_MENU_CREATE), |
94 | bookmark_create_menu, NULL, NULL, Icon_Bookmark); | 94 | bookmark_create_menu, NULL, |
95 | bookmark_menu_callback, Icon_Bookmark); | ||
95 | MENUITEM_FUNCTION(bookmark_load_menu_item, 0, | 96 | MENUITEM_FUNCTION(bookmark_load_menu_item, 0, |
96 | ID2P(LANG_BOOKMARK_MENU_LIST), | 97 | ID2P(LANG_BOOKMARK_MENU_LIST), |
97 | bookmark_load_menu, NULL, | 98 | bookmark_load_menu, NULL, |
@@ -105,13 +106,20 @@ static int bookmark_menu_callback(int action, | |||
105 | switch (action) | 106 | switch (action) |
106 | { | 107 | { |
107 | case ACTION_REQUEST_MENUITEM: | 108 | case ACTION_REQUEST_MENUITEM: |
108 | if (this_item == &bookmark_load_menu_item) | 109 | /* hide create bookmark option if bookmarking isn't currently possible (no track playing, queued tracks...) */ |
110 | if (this_item == &bookmark_create_menu_item) | ||
111 | { | ||
112 | if (!bookmark_is_bookmarkable_state()) | ||
113 | return ACTION_EXIT_MENUITEM; | ||
114 | } | ||
115 | /* hide loading bookmarks menu if no bookmarks exist */ | ||
116 | else if (this_item == &bookmark_load_menu_item) | ||
109 | { | 117 | { |
110 | if (!bookmark_exists()) | 118 | if (!bookmark_exists()) |
111 | return ACTION_EXIT_MENUITEM; | 119 | return ACTION_EXIT_MENUITEM; |
112 | } | 120 | } |
113 | /* hide the bookmark menu if there is no playback */ | 121 | /* hide the bookmark menu if bookmarks can't be loaded or created */ |
114 | else if ((audio_status() & AUDIO_STATUS_PLAY) == 0) | 122 | else if (!bookmark_is_bookmarkable_state() && !bookmark_exists()) |
115 | return ACTION_EXIT_MENUITEM; | 123 | return ACTION_EXIT_MENUITEM; |
116 | break; | 124 | break; |
117 | #ifdef HAVE_LCD_CHARCELLS | 125 | #ifdef HAVE_LCD_CHARCELLS |