1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C)2003 by Benjamin Metzler
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
43 #include "statusbar.h"
45 #define MAX_BOOKMARKS 10
46 #define MAX_BOOKMARK_SIZE 350
47 #define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark"
49 /* Used to buffer bookmarks while displaying the bookmark list. */
57 bool show_dont_resume
;
59 bool show_playlist_name
;
63 static bool add_bookmark(const char* bookmark_file_name
, const char* bookmark
,
65 static bool check_bookmark(const char* bookmark
);
66 static char* create_bookmark(void);
67 static bool delete_bookmark(const char* bookmark_file_name
, int bookmark_id
);
68 static void say_bookmark(const char* bookmark
,
70 static bool play_bookmark(const char* bookmark
);
71 static bool generate_bookmark_file_name(const char *in
);
72 static const char* skip_token(const char* s
);
73 static const char* int_token(const char* s
, int* dest
);
74 static const char* long_token(const char* s
, long* dest
);
75 static const char* bool_token(const char* s
, bool* dest
);
76 static bool parse_bookmark(const char *bookmark
,
80 int *resume_first_index
,
82 unsigned int resume_file_size
,
87 static int buffer_bookmarks(struct bookmark_list
* bookmarks
, int first_line
);
88 static char* get_bookmark_info(int list_index
,
92 static char* select_bookmark(const char* bookmark_file_name
, bool show_dont_resume
);
93 static bool system_check(void);
94 static bool write_bookmark(bool create_bookmark_file
);
95 static int get_bookmark_count(const char* bookmark_file_name
);
97 static char global_temp_buffer
[MAX_PATH
+1];
98 /* File name created by generate_bookmark_file_name */
99 static char global_bookmark_file_name
[MAX_PATH
];
100 static char global_read_buffer
[MAX_BOOKMARK_SIZE
];
101 /* Bookmark created by create_bookmark*/
102 static char global_bookmark
[MAX_BOOKMARK_SIZE
];
103 /* Filename from parsed bookmark (can be made local where needed) */
104 static char global_filename
[MAX_PATH
];
106 /* ----------------------------------------------------------------------- */
107 /* This is the interface function from the main menu. */
108 /* ----------------------------------------------------------------------- */
109 bool bookmark_create_menu(void)
111 write_bookmark(true);
115 /* ----------------------------------------------------------------------- */
116 /* This function acts as the load interface from the main menu */
117 /* This function determines the bookmark file name and then loads that file*/
118 /* for the user. The user can then select a bookmark to load. */
119 /* If no file/directory is currently playing, the menu item does not work. */
120 /* ----------------------------------------------------------------------- */
121 bool bookmark_load_menu(void)
125 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
126 sizeof(global_temp_buffer
));
127 if (generate_bookmark_file_name(name
))
129 char* bookmark
= select_bookmark(global_bookmark_file_name
, false);
131 if (bookmark
!= NULL
)
133 return play_bookmark(bookmark
);
141 /* ----------------------------------------------------------------------- */
142 /* Gives the user a list of the Most Recent Bookmarks. This is an */
143 /* interface function */
144 /* ----------------------------------------------------------------------- */
145 bool bookmark_mrb_load()
147 char* bookmark
= select_bookmark(RECENT_BOOKMARK_FILE
, false);
149 if (bookmark
!= NULL
)
151 return play_bookmark(bookmark
);
157 /* ----------------------------------------------------------------------- */
158 /* This function handles an autobookmark creation. This is an interface */
160 /* ----------------------------------------------------------------------- */
161 bool bookmark_autobookmark(void)
166 audio_pause(); /* first pause playback */
167 switch (global_settings
.autocreatebookmark
)
170 return write_bookmark(true);
175 case BOOKMARK_RECENT_ONLY_YES
:
176 return write_bookmark(false);
178 #ifdef HAVE_LCD_BITMAP
179 const char *lines
[]={ID2P(LANG_AUTO_BOOKMARK_QUERY
)};
180 const struct text_message message
={lines
, 1};
182 const char *lines
[]={ID2P(LANG_AUTO_BOOKMARK_QUERY
),
183 str(LANG_CONFIRM_WITH_BUTTON
)};
184 const struct text_message message
={lines
, 2};
187 show_main_backdrop(); /* switch to main backdrop as we may come from wps */
189 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
190 show_remote_main_backdrop();
192 gui_syncstatusbar_draw(&statusbars
, false);
193 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
195 if (global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
196 return write_bookmark(false);
198 return write_bookmark(true);
203 /* ----------------------------------------------------------------------- */
204 /* This function takes the current current resume information and writes */
205 /* that to the beginning of the bookmark file. */
206 /* This file will contain N number of bookmarks in the following format: */
207 /* resume_index*resume_offset*resume_seed*resume_first_index* */
208 /* resume_file*milliseconds*MP3 Title* */
209 /* ------------------------------------------------------------------------*/
210 static bool write_bookmark(bool create_bookmark_file
)
216 return false; /* something didn't happen correctly, do nothing */
218 bookmark
= create_bookmark();
220 return false; /* something didn't happen correctly, do nothing */
222 if (global_settings
.usemrb
)
223 success
= add_bookmark(RECENT_BOOKMARK_FILE
, bookmark
, true);
226 /* writing the bookmark */
227 if (create_bookmark_file
)
229 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
230 sizeof(global_temp_buffer
));
231 if (generate_bookmark_file_name(name
))
233 success
= add_bookmark(global_bookmark_file_name
, bookmark
, false);
237 gui_syncsplash(HZ
, success
? ID2P(LANG_BOOKMARK_CREATE_SUCCESS
)
238 : ID2P(LANG_BOOKMARK_CREATE_FAILURE
));
243 /* ----------------------------------------------------------------------- */
244 /* This function adds a bookmark to a file. */
245 /* ------------------------------------------------------------------------*/
246 static bool add_bookmark(const char* bookmark_file_name
, const char* bookmark
,
249 int temp_bookmark_file
= 0;
250 int bookmark_file
= 0;
251 int bookmark_count
= 0;
252 char* playlist
= NULL
;
258 /* Opening up a temp bookmark file */
259 snprintf(global_temp_buffer
, sizeof(global_temp_buffer
),
260 "%s.tmp", bookmark_file_name
);
261 temp_bookmark_file
= open(global_temp_buffer
,
262 O_WRONLY
| O_CREAT
| O_TRUNC
);
263 if (temp_bookmark_file
< 0)
264 return false; /* can't open the temp file */
266 if (most_recent
&& (global_settings
.usemrb
== BOOKMARK_UNIQUE_ONLY
))
268 playlist
= strchr(bookmark
,'/');
269 cp
= strrchr(bookmark
,';');
274 /* Writing the new bookmark to the begining of the temp file */
275 write(temp_bookmark_file
, bookmark
, strlen(bookmark
));
276 write(temp_bookmark_file
, "\n", 1);
279 /* Reading in the previous bookmarks and writing them to the temp file */
280 bookmark_file
= open(bookmark_file_name
, O_RDONLY
);
281 if (bookmark_file
>= 0)
283 while (read_line(bookmark_file
, global_read_buffer
,
284 sizeof(global_read_buffer
)) > 0)
286 /* The MRB has a max of MAX_BOOKMARKS in it */
287 /* This keeps it from getting too large */
288 if (most_recent
&& (bookmark_count
>= MAX_BOOKMARKS
))
291 cp
= strchr(global_read_buffer
,'/');
292 tmp
= strrchr(global_read_buffer
,';');
293 if (check_bookmark(global_read_buffer
) &&
294 (!unique
|| len
!= tmp
-cp
|| strncmp(playlist
,cp
,len
)))
297 write(temp_bookmark_file
, global_read_buffer
,
298 strlen(global_read_buffer
));
299 write(temp_bookmark_file
, "\n", 1);
302 close(bookmark_file
);
304 close(temp_bookmark_file
);
306 remove(bookmark_file_name
);
307 rename(global_temp_buffer
, bookmark_file_name
);
313 /* ----------------------------------------------------------------------- */
314 /* This function takes the system resume data and formats it into a valid */
316 /* ----------------------------------------------------------------------- */
317 static char* create_bookmark()
319 int resume_index
= 0;
322 /* grab the currently playing track */
323 struct mp3entry
*id3
= audio_current_track();
327 /* Get some basic resume information */
328 /* queue_resume and queue_resume_index are not used and can be ignored.*/
329 playlist_get_resume_info(&resume_index
);
331 /* Get the currently playing file minus the path */
332 /* This is used when displaying the available bookmarks */
333 file
= strrchr(id3
->path
,'/');
337 /* create the bookmark */
338 snprintf(global_bookmark
, sizeof(global_bookmark
),
339 "%d;%ld;%d;%d;%ld;%d;%d;%s;%s",
342 playlist_get_seed(NULL
),
345 global_settings
.repeat_mode
,
346 global_settings
.playlist_shuffle
,
347 playlist_get_name(NULL
, global_temp_buffer
,
348 sizeof(global_temp_buffer
)),
351 /* checking to see if the bookmark is valid */
352 if (check_bookmark(global_bookmark
))
353 return global_bookmark
;
358 static bool check_bookmark(const char* bookmark
)
360 return parse_bookmark(bookmark
,
361 NULL
,NULL
,NULL
, NULL
,
366 /* ----------------------------------------------------------------------- */
367 /* This function will determine if an autoload is necessary. This is an */
368 /* interface function. */
369 /* ------------------------------------------------------------------------*/
370 bool bookmark_autoload(const char* file
)
372 if(global_settings
.autoloadbookmark
== BOOKMARK_NO
)
375 /*Checking to see if a bookmark file exists.*/
376 if(!generate_bookmark_file_name(file
))
381 if(!file_exists(global_bookmark_file_name
))
384 if(global_settings
.autoloadbookmark
== BOOKMARK_YES
)
386 return bookmark_load(global_bookmark_file_name
, true);
390 char* bookmark
= select_bookmark(global_bookmark_file_name
, true);
392 if (bookmark
!= NULL
)
394 if (!play_bookmark(bookmark
))
396 /* Selected bookmark not found. */
397 gui_syncsplash(HZ
*2, ID2P(LANG_NOTHING_TO_RESUME
));
400 /* Act as if autoload was done even if it failed, since the
401 * user did make an active selection.
410 /* ----------------------------------------------------------------------- */
411 /* This function loads the bookmark information into the resume memory. */
412 /* This is an interface function. */
413 /* ------------------------------------------------------------------------*/
414 bool bookmark_load(const char* file
, bool autoload
)
417 char* bookmark
= NULL
;
421 fd
= open(file
, O_RDONLY
);
424 if(read_line(fd
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
425 bookmark
=global_read_buffer
;
431 /* This is not an auto-load, so list the bookmarks */
432 bookmark
= select_bookmark(file
, false);
435 if (bookmark
!= NULL
)
437 if (!play_bookmark(bookmark
))
439 /* Selected bookmark not found. */
442 gui_syncsplash(HZ
*2, ID2P(LANG_NOTHING_TO_RESUME
));
453 static int get_bookmark_count(const char* bookmark_file_name
)
456 int file
= open(bookmark_file_name
, O_RDONLY
);
461 while(read_line(file
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
470 static int buffer_bookmarks(struct bookmark_list
* bookmarks
, int first_line
)
472 char* dest
= ((char*) bookmarks
) + bookmarks
->buffer_size
- 1;
474 int file
= open(bookmarks
->filename
, O_RDONLY
);
481 if ((first_line
!= 0) && ((size_t) filesize(file
) < bookmarks
->buffer_size
482 - sizeof(*bookmarks
) - (sizeof(char*) * bookmarks
->total_count
)))
484 /* Entire file fits in buffer */
488 bookmarks
->start
= first_line
;
489 bookmarks
->count
= 0;
490 bookmarks
->reload
= false;
492 while(read_line(file
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
496 if (read_count
>= first_line
)
498 dest
-= strlen(global_read_buffer
) + 1;
500 if (dest
< ((char*) bookmarks
) + sizeof(*bookmarks
)
501 + (sizeof(char*) * (bookmarks
->count
+ 1)))
506 strcpy(dest
, global_read_buffer
);
507 bookmarks
->items
[bookmarks
->count
] = dest
;
513 return bookmarks
->start
+ bookmarks
->count
;
516 static char* get_bookmark_info(int list_index
,
521 struct bookmark_list
* bookmarks
= (struct bookmark_list
*) data
;
522 int index
= list_index
/ 2;
523 int resume_index
= 0;
524 long resume_time
= 0;
525 bool shuffle
= false;
527 if (bookmarks
->show_dont_resume
)
531 return list_index
% 2 == 0
532 ? (char*) str(LANG_BOOKMARK_DONT_RESUME
) : " ";
538 if (bookmarks
->reload
|| (index
>= bookmarks
->start
+ bookmarks
->count
)
539 || (index
< bookmarks
->start
))
541 int read_index
= index
;
543 /* Using count as a guide on how far to move could possibly fail
544 * sometimes. Use byte count if that is a problem?
549 /* Move count * 3 / 4 items in the direction the user is moving,
550 * but don't go too close to the end.
552 int offset
= bookmarks
->count
;
553 int max
= bookmarks
->total_count
- (bookmarks
->count
/ 2);
555 if (read_index
< bookmarks
->start
)
560 read_index
= index
- offset
/ 4;
562 if (read_index
> max
)
573 if (buffer_bookmarks(bookmarks
, read_index
) <= index
)
579 if (!parse_bookmark(bookmarks
->items
[index
- bookmarks
->start
],
580 &resume_index
, NULL
, NULL
, NULL
, global_temp_buffer
,
581 sizeof(global_temp_buffer
), &resume_time
, NULL
, &shuffle
,
584 return list_index
% 2 == 0 ? (char*) str(LANG_BOOKMARK_INVALID
) : " ";
587 if (list_index
% 2 == 0)
591 int len
= strlen(global_temp_buffer
);
593 if (bookmarks
->show_playlist_name
&& len
> 0)
595 name
= global_temp_buffer
;
598 if (name
[len
] != '/')
609 name
= strrsplt(name
, '/');
616 name
= global_filename
;
620 strrsplt(global_filename
, '.');
621 snprintf(buffer
, buffer_len
, format
, name
, global_filename
);
628 format_time(time_buf
, sizeof(time_buf
), resume_time
);
629 snprintf(buffer
, buffer_len
, "%s, %d%s", time_buf
, resume_index
+ 1,
630 shuffle
? (char*) str(LANG_BOOKMARK_SHUFFLE
) : "");
635 /* ----------------------------------------------------------------------- */
636 /* This displays a the bookmarks in a file and allows the user to */
637 /* select one to play. */
638 /* ------------------------------------------------------------------------*/
639 static char* select_bookmark(const char* bookmark_file_name
, bool show_dont_resume
)
641 struct bookmark_list
* bookmarks
;
642 struct gui_synclist list
;
650 bookmarks
= plugin_get_buffer(&size
);
651 bookmarks
->buffer_size
= size
;
652 bookmarks
->show_dont_resume
= show_dont_resume
;
653 bookmarks
->filename
= bookmark_file_name
;
654 bookmarks
->start
= 0;
655 bookmarks
->show_playlist_name
656 = strcmp(bookmark_file_name
, RECENT_BOOKMARK_FILE
) == 0;
657 gui_synclist_init(&list
, &get_bookmark_info
, (void*) bookmarks
, false, 2, NULL
);
658 gui_synclist_set_title(&list
, str(LANG_BOOKMARK_SELECT_BOOKMARK
),
660 gui_syncstatusbar_draw(&statusbars
, true);
664 gui_syncstatusbar_draw(&statusbars
, false);
668 int count
= get_bookmark_count(bookmark_file_name
);
669 bookmarks
->total_count
= count
;
671 if (bookmarks
->total_count
< 1)
673 /* No more bookmarks, delete file and exit */
674 gui_syncsplash(HZ
, ID2P(LANG_BOOKMARK_LOAD_EMPTY
));
675 remove(bookmark_file_name
);
679 if (bookmarks
->show_dont_resume
)
685 gui_synclist_set_nb_items(&list
, count
* 2);
689 /* Selected item has been deleted */
691 gui_synclist_select_item(&list
, item
* 2);
694 buffer_bookmarks(bookmarks
, bookmarks
->start
);
695 gui_synclist_draw(&list
);
699 action
= get_action(CONTEXT_BOOKMARKSCREEN
, HZ
/ 2);
700 gui_synclist_do_button(&list
, &action
, LIST_WRAP_UNLESS_HELD
);
701 item
= gui_synclist_get_sel_pos(&list
) / 2;
703 if (bookmarks
->show_dont_resume
)
708 if (item
!= last_item
&& global_settings
.talk_menu
)
714 talk_id(LANG_BOOKMARK_DONT_RESUME
, true);
718 say_bookmark(bookmarks
->items
[item
- bookmarks
->start
], item
);
722 if (action
== ACTION_STD_CONTEXT
)
724 MENUITEM_STRINGLIST(menu_items
, ID2P(LANG_BOOKMARK_CONTEXT_MENU
),
725 NULL
, ID2P(LANG_BOOKMARK_CONTEXT_RESUME
),
726 ID2P(LANG_BOOKMARK_CONTEXT_DELETE
));
727 static const int menu_actions
[] =
729 ACTION_STD_OK
, ACTION_BMS_DELETE
731 int selection
= do_menu(&menu_items
, NULL
, NULL
, false);
735 if (selection
>= 0 && selection
<=
736 (int) (sizeof(menu_actions
) / sizeof(menu_actions
[0])))
738 action
= menu_actions
[selection
];
747 return bookmarks
->items
[item
- bookmarks
->start
];
750 /* Else fall through */
752 case ACTION_TREE_WPS
:
753 case ACTION_STD_CANCEL
:
757 case ACTION_BMS_DELETE
:
760 delete_bookmark(bookmark_file_name
, item
);
761 bookmarks
->reload
= true;
768 if (default_event_handler(action
) == SYS_USB_CONNECTED
)
780 /* ----------------------------------------------------------------------- */
781 /* This function takes a location in a bookmark file and deletes that */
783 /* ------------------------------------------------------------------------*/
784 static bool delete_bookmark(const char* bookmark_file_name
, int bookmark_id
)
786 int temp_bookmark_file
= 0;
787 int bookmark_file
= 0;
788 int bookmark_count
= 0;
790 /* Opening up a temp bookmark file */
791 snprintf(global_temp_buffer
, sizeof(global_temp_buffer
),
792 "%s.tmp", bookmark_file_name
);
793 temp_bookmark_file
= open(global_temp_buffer
,
794 O_WRONLY
| O_CREAT
| O_TRUNC
);
796 if (temp_bookmark_file
< 0)
797 return false; /* can't open the temp file */
799 /* Reading in the previous bookmarks and writing them to the temp file */
800 bookmark_file
= open(bookmark_file_name
, O_RDONLY
);
801 if (bookmark_file
>= 0)
803 while (read_line(bookmark_file
, global_read_buffer
,
804 sizeof(global_read_buffer
)) > 0)
806 if (bookmark_id
!= bookmark_count
)
808 write(temp_bookmark_file
, global_read_buffer
,
809 strlen(global_read_buffer
));
810 write(temp_bookmark_file
, "\n", 1);
814 close(bookmark_file
);
816 close(temp_bookmark_file
);
818 remove(bookmark_file_name
);
819 rename(global_temp_buffer
, bookmark_file_name
);
824 /* ----------------------------------------------------------------------- */
825 /* This function parses a bookmark, says the voice UI part of it. */
826 /* ------------------------------------------------------------------------*/
827 static void say_bookmark(const char* bookmark
,
832 bool enqueue
= false; /* only the first voice is not queued */
834 if (!parse_bookmark(bookmark
, &resume_index
, NULL
, NULL
, NULL
,
835 global_temp_buffer
, sizeof(global_temp_buffer
), &ms
, NULL
, NULL
, NULL
))
837 talk_id(LANG_BOOKMARK_INVALID
, true);
841 /* disabled, because transition between talkbox and voice UI clip is not nice */
843 if (global_settings
.talk_dir
>= 3)
844 { /* "talkbox" enabled */
845 char* last
= strrchr(global_temp_buffer
, '/');
847 { /* compose filename for talkbox */
848 strncpy(last
+ 1, dir_thumbnail_name
,
849 sizeof(global_temp_buffer
) - (last
- global_temp_buffer
) - 1);
850 talk_file(global_temp_buffer
, enqueue
);
855 talk_id(VOICE_EXT_BMARK
, enqueue
);
856 talk_number(bookmark_id
+ 1, true);
857 talk_id(VOICE_BOOKMARK_SELECT_INDEX_TEXT
, true);
858 talk_number(resume_index
+ 1, true);
859 talk_id(LANG_TIME
, true);
861 talk_value(ms
/ 60000, UNIT_MIN
, true);
862 talk_value((ms
% 60000) / 1000, UNIT_SEC
, true);
865 /* ----------------------------------------------------------------------- */
866 /* This function parses a bookmark and then plays it. */
867 /* ------------------------------------------------------------------------*/
868 static bool play_bookmark(const char* bookmark
)
874 if (parse_bookmark(bookmark
,
880 sizeof(global_temp_buffer
),
882 &global_settings
.repeat_mode
,
883 &global_settings
.playlist_shuffle
,
886 return bookmark_play(global_temp_buffer
, index
, offset
, seed
,
893 static const char* skip_token(const char* s
)
895 while (*s
&& *s
!= ';')
908 static const char* int_token(const char* s
, int* dest
)
915 return skip_token(s
);
918 static const char* long_token(const char* s
, long* dest
)
922 *dest
= atoi(s
); /* Should be atol, but we don't have it. */
925 return skip_token(s
);
928 static const char* bool_token(const char* s
, bool* dest
)
932 *dest
= atoi(s
) != 0;
935 return skip_token(s
);
938 /* ----------------------------------------------------------------------- */
939 /* This function takes a bookmark and parses it. This function also */
940 /* validates the bookmark. Passing in NULL for an output variable */
941 /* indicates that value is not requested. */
942 /* ----------------------------------------------------------------------- */
943 static bool parse_bookmark(const char *bookmark
,
947 int *resume_first_index
,
949 unsigned int resume_file_size
,
951 int * repeat_mode
, bool *shuffle
,
954 const char* s
= bookmark
;
957 s
= int_token(s
, resume_index
);
958 s
= int_token(s
, resume_offset
);
959 s
= int_token(s
, resume_seed
);
960 s
= int_token(s
, resume_first_index
);
961 s
= long_token(s
, ms
);
962 s
= int_token(s
, repeat_mode
);
963 s
= bool_token(s
, shuffle
);
970 end
= strchr(s
, ';');
972 if (resume_file
!= NULL
)
974 size_t len
= (end
== NULL
) ? strlen(s
) : (size_t) (end
- s
);
976 len
= MIN(resume_file_size
- 1, len
);
977 strncpy(resume_file
, s
, len
);
978 resume_file
[len
] = 0;
981 if (end
!= NULL
&& file_name
!= NULL
)
984 strncpy(file_name
, end
, MAX_PATH
- 1);
985 file_name
[MAX_PATH
- 1] = 0;
991 /* ----------------------------------------------------------------------- */
992 /* This function is used by multiple functions and is used to generate a */
993 /* bookmark named based off of the input. */
994 /* Changing this function could result in how the bookmarks are stored. */
995 /* it would be here that the centralized/decentralized bookmark code */
996 /* could be placed. */
997 /* ----------------------------------------------------------------------- */
998 static bool generate_bookmark_file_name(const char *in
)
1000 int len
= strlen(in
);
1002 /* if this is a root dir MP3, rename the bookmark file root_dir.bmark */
1003 /* otherwise, name it based on the in variable */
1004 if (!strcmp("/", in
))
1005 strcpy(global_bookmark_file_name
, "/root_dir.bmark");
1008 strcpy(global_bookmark_file_name
, in
);
1009 if(global_bookmark_file_name
[len
-1] == '/')
1011 strcpy(&global_bookmark_file_name
[len
], ".bmark");
1017 /* ----------------------------------------------------------------------- */
1018 /* Returns true if a bookmark file exists for the current playlist */
1019 /* ----------------------------------------------------------------------- */
1020 bool bookmark_exist(void)
1026 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
1027 sizeof(global_temp_buffer
));
1028 if (generate_bookmark_file_name(name
))
1030 exist
= file_exists(global_bookmark_file_name
);
1037 /* ----------------------------------------------------------------------- */
1038 /* Checks the current state of the system and returns if it is in a */
1039 /* bookmarkable state. */
1040 /* ----------------------------------------------------------------------- */
1042 /* ----------------------------------------------------------------------- */
1044 /* return bool: Indicates if the system was in a bookmarkable state */
1045 /* ----------------------------------------------------------------------- */
1046 static bool system_check(void)
1048 int resume_index
= 0;
1050 if (!(audio_status() && audio_current_track()))
1052 /* no track playing */
1056 /* Checking to see if playing a queued track */
1057 if (playlist_get_resume_info(&resume_index
) == -1)
1059 /* something bad happened while getting the queue information */
1062 else if (playlist_modified(NULL
))
1064 /* can't bookmark while in the queue */