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"
46 #define MAX_BOOKMARKS 10
47 #define MAX_BOOKMARK_SIZE 350
48 #define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark"
50 /* Used to buffer bookmarks while displaying the bookmark list. */
58 bool show_dont_resume
;
60 bool show_playlist_name
;
64 static bool add_bookmark(const char* bookmark_file_name
, const char* bookmark
,
66 static bool check_bookmark(const char* bookmark
);
67 static char* create_bookmark(void);
68 static bool delete_bookmark(const char* bookmark_file_name
, int bookmark_id
);
69 static void say_bookmark(const char* bookmark
,
71 static bool play_bookmark(const char* bookmark
);
72 static bool generate_bookmark_file_name(const char *in
);
73 static const char* skip_token(const char* s
);
74 static const char* int_token(const char* s
, int* dest
);
75 static const char* long_token(const char* s
, long* dest
);
76 static const char* bool_token(const char* s
, bool* dest
);
77 static bool parse_bookmark(const char *bookmark
,
81 int *resume_first_index
,
83 unsigned int resume_file_size
,
88 static int buffer_bookmarks(struct bookmark_list
* bookmarks
, int first_line
);
89 static char* get_bookmark_info(int list_index
,
93 static char* select_bookmark(const char* bookmark_file_name
, bool show_dont_resume
);
94 static bool system_check(void);
95 static bool write_bookmark(bool create_bookmark_file
);
96 static int get_bookmark_count(const char* bookmark_file_name
);
98 static char global_temp_buffer
[MAX_PATH
+1];
99 /* File name created by generate_bookmark_file_name */
100 static char global_bookmark_file_name
[MAX_PATH
];
101 static char global_read_buffer
[MAX_BOOKMARK_SIZE
];
102 /* Bookmark created by create_bookmark*/
103 static char global_bookmark
[MAX_BOOKMARK_SIZE
];
104 /* Filename from parsed bookmark (can be made local where needed) */
105 static char global_filename
[MAX_PATH
];
107 /* ----------------------------------------------------------------------- */
108 /* This is the interface function from the main menu. */
109 /* ----------------------------------------------------------------------- */
110 bool bookmark_create_menu(void)
112 write_bookmark(true);
116 /* ----------------------------------------------------------------------- */
117 /* This function acts as the load interface from the main menu */
118 /* This function determines the bookmark file name and then loads that file*/
119 /* for the user. The user can then select a bookmark to load. */
120 /* If no file/directory is currently playing, the menu item does not work. */
121 /* ----------------------------------------------------------------------- */
122 bool bookmark_load_menu(void)
126 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
127 sizeof(global_temp_buffer
));
128 if (generate_bookmark_file_name(name
))
130 char* bookmark
= select_bookmark(global_bookmark_file_name
, false);
132 if (bookmark
!= NULL
)
134 return play_bookmark(bookmark
);
142 /* ----------------------------------------------------------------------- */
143 /* Gives the user a list of the Most Recent Bookmarks. This is an */
144 /* interface function */
145 /* ----------------------------------------------------------------------- */
146 bool bookmark_mrb_load()
148 char* bookmark
= select_bookmark(RECENT_BOOKMARK_FILE
, false);
150 if (bookmark
!= NULL
)
152 return play_bookmark(bookmark
);
158 /* ----------------------------------------------------------------------- */
159 /* This function handles an autobookmark creation. This is an interface */
161 /* ----------------------------------------------------------------------- */
162 bool bookmark_autobookmark(void)
167 audio_pause(); /* first pause playback */
168 switch (global_settings
.autocreatebookmark
)
171 return write_bookmark(true);
176 case BOOKMARK_RECENT_ONLY_YES
:
177 return write_bookmark(false);
179 #ifdef HAVE_LCD_BITMAP
180 const char *lines
[]={ID2P(LANG_AUTO_BOOKMARK_QUERY
)};
181 const struct text_message message
={lines
, 1};
183 const char *lines
[]={ID2P(LANG_AUTO_BOOKMARK_QUERY
),
184 str(LANG_CONFIRM_WITH_BUTTON
)};
185 const struct text_message message
={lines
, 2};
188 show_main_backdrop(); /* switch to main backdrop as we may come from wps */
190 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
191 show_remote_main_backdrop();
193 gui_syncstatusbar_draw(&statusbars
, false);
194 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
196 if (global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
197 return write_bookmark(false);
199 return write_bookmark(true);
204 /* ----------------------------------------------------------------------- */
205 /* This function takes the current current resume information and writes */
206 /* that to the beginning of the bookmark file. */
207 /* This file will contain N number of bookmarks in the following format: */
208 /* resume_index*resume_offset*resume_seed*resume_first_index* */
209 /* resume_file*milliseconds*MP3 Title* */
210 /* ------------------------------------------------------------------------*/
211 static bool write_bookmark(bool create_bookmark_file
)
217 return false; /* something didn't happen correctly, do nothing */
219 bookmark
= create_bookmark();
221 return false; /* something didn't happen correctly, do nothing */
223 if (global_settings
.usemrb
)
224 success
= add_bookmark(RECENT_BOOKMARK_FILE
, bookmark
, true);
227 /* writing the bookmark */
228 if (create_bookmark_file
)
230 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
231 sizeof(global_temp_buffer
));
232 if (generate_bookmark_file_name(name
))
234 success
= add_bookmark(global_bookmark_file_name
, bookmark
, false);
238 gui_syncsplash(HZ
, success
? ID2P(LANG_BOOKMARK_CREATE_SUCCESS
)
239 : ID2P(LANG_BOOKMARK_CREATE_FAILURE
));
244 /* ----------------------------------------------------------------------- */
245 /* This function adds a bookmark to a file. */
246 /* ------------------------------------------------------------------------*/
247 static bool add_bookmark(const char* bookmark_file_name
, const char* bookmark
,
250 int temp_bookmark_file
= 0;
251 int bookmark_file
= 0;
252 int bookmark_count
= 0;
253 char* playlist
= NULL
;
259 /* Opening up a temp bookmark file */
260 snprintf(global_temp_buffer
, sizeof(global_temp_buffer
),
261 "%s.tmp", bookmark_file_name
);
262 temp_bookmark_file
= open(global_temp_buffer
,
263 O_WRONLY
| O_CREAT
| O_TRUNC
);
264 if (temp_bookmark_file
< 0)
265 return false; /* can't open the temp file */
267 if (most_recent
&& (global_settings
.usemrb
== BOOKMARK_UNIQUE_ONLY
))
269 playlist
= strchr(bookmark
,'/');
270 cp
= strrchr(bookmark
,';');
275 /* Writing the new bookmark to the begining of the temp file */
276 write(temp_bookmark_file
, bookmark
, strlen(bookmark
));
277 write(temp_bookmark_file
, "\n", 1);
280 /* Reading in the previous bookmarks and writing them to the temp file */
281 bookmark_file
= open(bookmark_file_name
, O_RDONLY
);
282 if (bookmark_file
>= 0)
284 while (read_line(bookmark_file
, global_read_buffer
,
285 sizeof(global_read_buffer
)) > 0)
287 /* The MRB has a max of MAX_BOOKMARKS in it */
288 /* This keeps it from getting too large */
289 if (most_recent
&& (bookmark_count
>= MAX_BOOKMARKS
))
292 cp
= strchr(global_read_buffer
,'/');
293 tmp
= strrchr(global_read_buffer
,';');
294 if (check_bookmark(global_read_buffer
) &&
295 (!unique
|| len
!= tmp
-cp
|| strncmp(playlist
,cp
,len
)))
298 write(temp_bookmark_file
, global_read_buffer
,
299 strlen(global_read_buffer
));
300 write(temp_bookmark_file
, "\n", 1);
303 close(bookmark_file
);
305 close(temp_bookmark_file
);
307 remove(bookmark_file_name
);
308 rename(global_temp_buffer
, bookmark_file_name
);
314 /* ----------------------------------------------------------------------- */
315 /* This function takes the system resume data and formats it into a valid */
317 /* ----------------------------------------------------------------------- */
318 static char* create_bookmark()
320 int resume_index
= 0;
323 /* grab the currently playing track */
324 struct mp3entry
*id3
= audio_current_track();
328 /* Get some basic resume information */
329 /* queue_resume and queue_resume_index are not used and can be ignored.*/
330 playlist_get_resume_info(&resume_index
);
332 /* Get the currently playing file minus the path */
333 /* This is used when displaying the available bookmarks */
334 file
= strrchr(id3
->path
,'/');
338 /* create the bookmark */
339 snprintf(global_bookmark
, sizeof(global_bookmark
),
340 "%d;%ld;%d;%d;%ld;%d;%d;%s;%s",
343 playlist_get_seed(NULL
),
346 global_settings
.repeat_mode
,
347 global_settings
.playlist_shuffle
,
348 playlist_get_name(NULL
, global_temp_buffer
,
349 sizeof(global_temp_buffer
)),
352 /* checking to see if the bookmark is valid */
353 if (check_bookmark(global_bookmark
))
354 return global_bookmark
;
359 static bool check_bookmark(const char* bookmark
)
361 return parse_bookmark(bookmark
,
362 NULL
,NULL
,NULL
, NULL
,
367 /* ----------------------------------------------------------------------- */
368 /* This function will determine if an autoload is necessary. This is an */
369 /* interface function. */
370 /* ------------------------------------------------------------------------*/
371 bool bookmark_autoload(const char* file
)
373 if(global_settings
.autoloadbookmark
== BOOKMARK_NO
)
376 /*Checking to see if a bookmark file exists.*/
377 if(!generate_bookmark_file_name(file
))
382 if(!file_exists(global_bookmark_file_name
))
385 if(global_settings
.autoloadbookmark
== BOOKMARK_YES
)
387 return bookmark_load(global_bookmark_file_name
, true);
391 char* bookmark
= select_bookmark(global_bookmark_file_name
, true);
393 if (bookmark
!= NULL
)
395 if (!play_bookmark(bookmark
))
397 /* Selected bookmark not found. */
398 gui_syncsplash(HZ
*2, ID2P(LANG_NOTHING_TO_RESUME
));
401 /* Act as if autoload was done even if it failed, since the
402 * user did make an active selection.
411 /* ----------------------------------------------------------------------- */
412 /* This function loads the bookmark information into the resume memory. */
413 /* This is an interface function. */
414 /* ------------------------------------------------------------------------*/
415 bool bookmark_load(const char* file
, bool autoload
)
418 char* bookmark
= NULL
;
422 fd
= open(file
, O_RDONLY
);
425 if(read_line(fd
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
426 bookmark
=global_read_buffer
;
432 /* This is not an auto-load, so list the bookmarks */
433 bookmark
= select_bookmark(file
, false);
436 if (bookmark
!= NULL
)
438 if (!play_bookmark(bookmark
))
440 /* Selected bookmark not found. */
443 gui_syncsplash(HZ
*2, ID2P(LANG_NOTHING_TO_RESUME
));
454 static int get_bookmark_count(const char* bookmark_file_name
)
457 int file
= open(bookmark_file_name
, O_RDONLY
);
462 while(read_line(file
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
471 static int buffer_bookmarks(struct bookmark_list
* bookmarks
, int first_line
)
473 char* dest
= ((char*) bookmarks
) + bookmarks
->buffer_size
- 1;
475 int file
= open(bookmarks
->filename
, O_RDONLY
);
482 if ((first_line
!= 0) && ((size_t) filesize(file
) < bookmarks
->buffer_size
483 - sizeof(*bookmarks
) - (sizeof(char*) * bookmarks
->total_count
)))
485 /* Entire file fits in buffer */
489 bookmarks
->start
= first_line
;
490 bookmarks
->count
= 0;
491 bookmarks
->reload
= false;
493 while(read_line(file
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
497 if (read_count
>= first_line
)
499 dest
-= strlen(global_read_buffer
) + 1;
501 if (dest
< ((char*) bookmarks
) + sizeof(*bookmarks
)
502 + (sizeof(char*) * (bookmarks
->count
+ 1)))
507 strcpy(dest
, global_read_buffer
);
508 bookmarks
->items
[bookmarks
->count
] = dest
;
514 return bookmarks
->start
+ bookmarks
->count
;
517 static char* get_bookmark_info(int list_index
,
522 struct bookmark_list
* bookmarks
= (struct bookmark_list
*) data
;
523 int index
= list_index
/ 2;
524 int resume_index
= 0;
525 long resume_time
= 0;
526 bool shuffle
= false;
528 if (bookmarks
->show_dont_resume
)
532 return list_index
% 2 == 0
533 ? (char*) str(LANG_BOOKMARK_DONT_RESUME
) : " ";
539 if (bookmarks
->reload
|| (index
>= bookmarks
->start
+ bookmarks
->count
)
540 || (index
< bookmarks
->start
))
542 int read_index
= index
;
544 /* Using count as a guide on how far to move could possibly fail
545 * sometimes. Use byte count if that is a problem?
550 /* Move count * 3 / 4 items in the direction the user is moving,
551 * but don't go too close to the end.
553 int offset
= bookmarks
->count
;
554 int max
= bookmarks
->total_count
- (bookmarks
->count
/ 2);
556 if (read_index
< bookmarks
->start
)
561 read_index
= index
- offset
/ 4;
563 if (read_index
> max
)
574 if (buffer_bookmarks(bookmarks
, read_index
) <= index
)
580 if (!parse_bookmark(bookmarks
->items
[index
- bookmarks
->start
],
581 &resume_index
, NULL
, NULL
, NULL
, global_temp_buffer
,
582 sizeof(global_temp_buffer
), &resume_time
, NULL
, &shuffle
,
585 return list_index
% 2 == 0 ? (char*) str(LANG_BOOKMARK_INVALID
) : " ";
588 if (list_index
% 2 == 0)
592 int len
= strlen(global_temp_buffer
);
594 if (bookmarks
->show_playlist_name
&& len
> 0)
596 name
= global_temp_buffer
;
599 if (name
[len
] != '/')
610 name
= strrsplt(name
, '/');
617 name
= global_filename
;
621 strrsplt(global_filename
, '.');
622 snprintf(buffer
, buffer_len
, format
, name
, global_filename
);
629 format_time(time_buf
, sizeof(time_buf
), resume_time
);
630 snprintf(buffer
, buffer_len
, "%s, %d%s", time_buf
, resume_index
+ 1,
631 shuffle
? (char*) str(LANG_BOOKMARK_SHUFFLE
) : "");
636 /* ----------------------------------------------------------------------- */
637 /* This displays a the bookmarks in a file and allows the user to */
638 /* select one to play. */
639 /* ------------------------------------------------------------------------*/
640 static char* select_bookmark(const char* bookmark_file_name
, bool show_dont_resume
)
642 struct bookmark_list
* bookmarks
;
643 struct gui_synclist list
;
651 bookmarks
= plugin_get_buffer(&size
);
652 bookmarks
->buffer_size
= size
;
653 bookmarks
->show_dont_resume
= show_dont_resume
;
654 bookmarks
->filename
= bookmark_file_name
;
655 bookmarks
->start
= 0;
656 bookmarks
->show_playlist_name
657 = strcmp(bookmark_file_name
, RECENT_BOOKMARK_FILE
) == 0;
658 gui_synclist_init(&list
, &get_bookmark_info
, (void*) bookmarks
, false, 2, NULL
);
659 gui_synclist_set_title(&list
, str(LANG_BOOKMARK_SELECT_BOOKMARK
),
661 gui_syncstatusbar_draw(&statusbars
, true);
665 gui_syncstatusbar_draw(&statusbars
, false);
669 int count
= get_bookmark_count(bookmark_file_name
);
670 bookmarks
->total_count
= count
;
672 if (bookmarks
->total_count
< 1)
674 /* No more bookmarks, delete file and exit */
675 gui_syncsplash(HZ
, ID2P(LANG_BOOKMARK_LOAD_EMPTY
));
676 remove(bookmark_file_name
);
680 if (bookmarks
->show_dont_resume
)
686 gui_synclist_set_nb_items(&list
, count
* 2);
690 /* Selected item has been deleted */
692 gui_synclist_select_item(&list
, item
* 2);
695 buffer_bookmarks(bookmarks
, bookmarks
->start
);
696 gui_synclist_draw(&list
);
700 action
= get_action(CONTEXT_BOOKMARKSCREEN
, HZ
/ 2);
701 gui_synclist_do_button(&list
, &action
, LIST_WRAP_UNLESS_HELD
);
702 item
= gui_synclist_get_sel_pos(&list
) / 2;
704 if (bookmarks
->show_dont_resume
)
709 if (item
!= last_item
&& global_settings
.talk_menu
)
715 talk_id(LANG_BOOKMARK_DONT_RESUME
, true);
719 say_bookmark(bookmarks
->items
[item
- bookmarks
->start
], item
);
723 if (action
== ACTION_STD_CONTEXT
)
725 MENUITEM_STRINGLIST(menu_items
, ID2P(LANG_BOOKMARK_CONTEXT_MENU
),
726 NULL
, ID2P(LANG_BOOKMARK_CONTEXT_RESUME
),
727 ID2P(LANG_BOOKMARK_CONTEXT_DELETE
));
728 static const int menu_actions
[] =
730 ACTION_STD_OK
, ACTION_BMS_DELETE
732 int selection
= do_menu(&menu_items
, NULL
, NULL
, false);
736 if (selection
>= 0 && selection
<=
737 (int) (sizeof(menu_actions
) / sizeof(menu_actions
[0])))
739 action
= menu_actions
[selection
];
748 return bookmarks
->items
[item
- bookmarks
->start
];
751 /* Else fall through */
753 case ACTION_TREE_WPS
:
754 case ACTION_STD_CANCEL
:
758 case ACTION_BMS_DELETE
:
761 delete_bookmark(bookmark_file_name
, item
);
762 bookmarks
->reload
= true;
769 if (default_event_handler(action
) == SYS_USB_CONNECTED
)
781 /* ----------------------------------------------------------------------- */
782 /* This function takes a location in a bookmark file and deletes that */
784 /* ------------------------------------------------------------------------*/
785 static bool delete_bookmark(const char* bookmark_file_name
, int bookmark_id
)
787 int temp_bookmark_file
= 0;
788 int bookmark_file
= 0;
789 int bookmark_count
= 0;
791 /* Opening up a temp bookmark file */
792 snprintf(global_temp_buffer
, sizeof(global_temp_buffer
),
793 "%s.tmp", bookmark_file_name
);
794 temp_bookmark_file
= open(global_temp_buffer
,
795 O_WRONLY
| O_CREAT
| O_TRUNC
);
797 if (temp_bookmark_file
< 0)
798 return false; /* can't open the temp file */
800 /* Reading in the previous bookmarks and writing them to the temp file */
801 bookmark_file
= open(bookmark_file_name
, O_RDONLY
);
802 if (bookmark_file
>= 0)
804 while (read_line(bookmark_file
, global_read_buffer
,
805 sizeof(global_read_buffer
)) > 0)
807 if (bookmark_id
!= bookmark_count
)
809 write(temp_bookmark_file
, global_read_buffer
,
810 strlen(global_read_buffer
));
811 write(temp_bookmark_file
, "\n", 1);
815 close(bookmark_file
);
817 close(temp_bookmark_file
);
819 remove(bookmark_file_name
);
820 rename(global_temp_buffer
, bookmark_file_name
);
825 /* ----------------------------------------------------------------------- */
826 /* This function parses a bookmark, says the voice UI part of it. */
827 /* ------------------------------------------------------------------------*/
828 static void say_bookmark(const char* bookmark
,
833 bool enqueue
= false; /* only the first voice is not queued */
835 if (!parse_bookmark(bookmark
, &resume_index
, NULL
, NULL
, NULL
,
836 global_temp_buffer
, sizeof(global_temp_buffer
), &ms
, NULL
, NULL
, NULL
))
838 talk_id(LANG_BOOKMARK_INVALID
, true);
842 /* disabled, because transition between talkbox and voice UI clip is not nice */
844 if (global_settings
.talk_dir
>= 3)
845 { /* "talkbox" enabled */
846 char* last
= strrchr(global_temp_buffer
, '/');
848 { /* compose filename for talkbox */
849 strncpy(last
+ 1, dir_thumbnail_name
,
850 sizeof(global_temp_buffer
) - (last
- global_temp_buffer
) - 1);
851 talk_file(global_temp_buffer
, enqueue
);
856 talk_id(VOICE_EXT_BMARK
, enqueue
);
857 talk_number(bookmark_id
+ 1, true);
858 talk_id(VOICE_BOOKMARK_SELECT_INDEX_TEXT
, true);
859 talk_number(resume_index
+ 1, true);
860 talk_id(LANG_TIME
, true);
862 talk_value(ms
/ 60000, UNIT_MIN
, true);
863 talk_value((ms
% 60000) / 1000, UNIT_SEC
, true);
866 /* ----------------------------------------------------------------------- */
867 /* This function parses a bookmark and then plays it. */
868 /* ------------------------------------------------------------------------*/
869 static bool play_bookmark(const char* bookmark
)
875 if (parse_bookmark(bookmark
,
881 sizeof(global_temp_buffer
),
883 &global_settings
.repeat_mode
,
884 &global_settings
.playlist_shuffle
,
887 return bookmark_play(global_temp_buffer
, index
, offset
, seed
,
894 static const char* skip_token(const char* s
)
896 while (*s
&& *s
!= ';')
909 static const char* int_token(const char* s
, int* dest
)
916 return skip_token(s
);
919 static const char* long_token(const char* s
, long* dest
)
923 *dest
= atoi(s
); /* Should be atol, but we don't have it. */
926 return skip_token(s
);
929 static const char* bool_token(const char* s
, bool* dest
)
933 *dest
= atoi(s
) != 0;
936 return skip_token(s
);
939 /* ----------------------------------------------------------------------- */
940 /* This function takes a bookmark and parses it. This function also */
941 /* validates the bookmark. Passing in NULL for an output variable */
942 /* indicates that value is not requested. */
943 /* ----------------------------------------------------------------------- */
944 static bool parse_bookmark(const char *bookmark
,
948 int *resume_first_index
,
950 unsigned int resume_file_size
,
952 int * repeat_mode
, bool *shuffle
,
955 const char* s
= bookmark
;
958 s
= int_token(s
, resume_index
);
959 s
= int_token(s
, resume_offset
);
960 s
= int_token(s
, resume_seed
);
961 s
= int_token(s
, resume_first_index
);
962 s
= long_token(s
, ms
);
963 s
= int_token(s
, repeat_mode
);
964 s
= bool_token(s
, shuffle
);
971 end
= strchr(s
, ';');
973 if (resume_file
!= NULL
)
975 size_t len
= (end
== NULL
) ? strlen(s
) : (size_t) (end
- s
);
977 len
= MIN(resume_file_size
- 1, len
);
978 strncpy(resume_file
, s
, len
);
979 resume_file
[len
] = 0;
982 if (end
!= NULL
&& file_name
!= NULL
)
985 strncpy(file_name
, end
, MAX_PATH
- 1);
986 file_name
[MAX_PATH
- 1] = 0;
992 /* ----------------------------------------------------------------------- */
993 /* This function is used by multiple functions and is used to generate a */
994 /* bookmark named based off of the input. */
995 /* Changing this function could result in how the bookmarks are stored. */
996 /* it would be here that the centralized/decentralized bookmark code */
997 /* could be placed. */
998 /* ----------------------------------------------------------------------- */
999 static bool generate_bookmark_file_name(const char *in
)
1001 int len
= strlen(in
);
1003 /* if this is a root dir MP3, rename the bookmark file root_dir.bmark */
1004 /* otherwise, name it based on the in variable */
1005 if (!strcmp("/", in
))
1006 strcpy(global_bookmark_file_name
, "/root_dir.bmark");
1009 strcpy(global_bookmark_file_name
, in
);
1010 if(global_bookmark_file_name
[len
-1] == '/')
1012 strcpy(&global_bookmark_file_name
[len
], ".bmark");
1018 /* ----------------------------------------------------------------------- */
1019 /* Returns true if a bookmark file exists for the current playlist */
1020 /* ----------------------------------------------------------------------- */
1021 bool bookmark_exist(void)
1027 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
1028 sizeof(global_temp_buffer
));
1029 if (generate_bookmark_file_name(name
))
1031 exist
= file_exists(global_bookmark_file_name
);
1038 /* ----------------------------------------------------------------------- */
1039 /* Checks the current state of the system and returns if it is in a */
1040 /* bookmarkable state. */
1041 /* ----------------------------------------------------------------------- */
1043 /* ----------------------------------------------------------------------- */
1045 /* return bool: Indicates if the system was in a bookmarkable state */
1046 /* ----------------------------------------------------------------------- */
1047 static bool system_check(void)
1049 int resume_index
= 0;
1051 if (!(audio_status() && audio_current_track()))
1053 /* no track playing */
1057 /* Checking to see if playing a queued track */
1058 if (playlist_get_resume_info(&resume_index
) == -1)
1060 /* something bad happened while getting the queue information */
1063 else if (playlist_modified(NULL
))
1065 /* can't bookmark while in the queue */