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 ****************************************************************************/
24 #include "applimits.h"
56 #define MAX_BOOKMARKS 10
57 #define MAX_BOOKMARK_SIZE 350
58 #define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark"
60 /* Used to buffer bookmarks while displaying the bookmark list. */
68 bool show_dont_resume
;
70 bool show_playlist_name
;
74 static bool add_bookmark(const char* bookmark_file_name
, const char* bookmark
,
76 static bool check_bookmark(const char* bookmark
);
77 static char* create_bookmark(void);
78 static bool delete_bookmark(const char* bookmark_file_name
, int bookmark_id
);
79 static void say_bookmark(const char* bookmark
,
81 static bool play_bookmark(const char* bookmark
);
82 static bool generate_bookmark_file_name(const char *in
);
83 static const char* skip_token(const char* s
);
84 static const char* int_token(const char* s
, int* dest
);
85 static const char* long_token(const char* s
, long* dest
);
86 static const char* bool_token(const char* s
, bool* dest
);
87 static bool parse_bookmark(const char *bookmark
,
91 int *resume_first_index
,
93 unsigned int resume_file_size
,
98 static int buffer_bookmarks(struct bookmark_list
* bookmarks
, int first_line
);
99 static char* get_bookmark_info(int list_index
, void* data
, char *buffer
);
100 static char* select_bookmark(const char* bookmark_file_name
, bool show_dont_resume
);
101 static bool system_check(void);
102 static bool write_bookmark(bool create_bookmark_file
);
103 static int get_bookmark_count(const char* bookmark_file_name
);
105 static char global_temp_buffer
[MAX_PATH
+1];
106 /* File name created by generate_bookmark_file_name */
107 static char global_bookmark_file_name
[MAX_PATH
];
108 static char global_read_buffer
[MAX_BOOKMARK_SIZE
];
109 /* Bookmark created by create_bookmark*/
110 static char global_bookmark
[MAX_BOOKMARK_SIZE
];
111 /* Filename from parsed bookmark (can be made local where needed) */
112 static char global_filename
[MAX_PATH
];
114 /* ----------------------------------------------------------------------- */
115 /* This is the interface function from the main menu. */
116 /* ----------------------------------------------------------------------- */
117 bool bookmark_create_menu(void)
119 write_bookmark(true);
123 /* ----------------------------------------------------------------------- */
124 /* This function acts as the load interface from the main menu */
125 /* This function determines the bookmark file name and then loads that file*/
126 /* for the user. The user can then select a bookmark to load. */
127 /* If no file/directory is currently playing, the menu item does not work. */
128 /* ----------------------------------------------------------------------- */
129 bool bookmark_load_menu(void)
133 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
134 sizeof(global_temp_buffer
));
135 if (generate_bookmark_file_name(name
))
137 char* bookmark
= select_bookmark(global_bookmark_file_name
, false);
139 if (bookmark
!= NULL
)
141 return play_bookmark(bookmark
);
149 /* ----------------------------------------------------------------------- */
150 /* Gives the user a list of the Most Recent Bookmarks. This is an */
151 /* interface function */
152 /* ----------------------------------------------------------------------- */
153 bool bookmark_mrb_load()
155 char* bookmark
= select_bookmark(RECENT_BOOKMARK_FILE
, false);
157 if (bookmark
!= NULL
)
159 return play_bookmark(bookmark
);
165 /* ----------------------------------------------------------------------- */
166 /* This function handles an autobookmark creation. This is an interface */
168 /* ----------------------------------------------------------------------- */
169 bool bookmark_autobookmark(void)
174 audio_pause(); /* first pause playback */
175 switch (global_settings
.autocreatebookmark
)
178 return write_bookmark(true);
183 case BOOKMARK_RECENT_ONLY_YES
:
184 return write_bookmark(false);
186 #ifdef HAVE_LCD_BITMAP
187 unsigned char *lines
[]={ID2P(LANG_AUTO_BOOKMARK_QUERY
)};
188 struct text_message message
={(char **)lines
, 1};
190 unsigned char *lines
[]={ID2P(LANG_AUTO_BOOKMARK_QUERY
),
191 str(LANG_CONFIRM_WITH_BUTTON
)};
192 struct text_message message
={(char **)lines
, 2};
195 show_main_backdrop(); /* switch to main backdrop as we may come from wps */
197 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
198 show_remote_main_backdrop();
200 gui_syncstatusbar_draw(&statusbars
, false);
201 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
203 if (global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
204 return write_bookmark(false);
206 return write_bookmark(true);
211 /* ----------------------------------------------------------------------- */
212 /* This function takes the current current resume information and writes */
213 /* that to the beginning of the bookmark file. */
214 /* This file will contain N number of bookmarks in the following format: */
215 /* resume_index*resume_offset*resume_seed*resume_first_index* */
216 /* resume_file*milliseconds*MP3 Title* */
217 /* ------------------------------------------------------------------------*/
218 static bool write_bookmark(bool create_bookmark_file
)
224 return false; /* something didn't happen correctly, do nothing */
226 bookmark
= create_bookmark();
228 return false; /* something didn't happen correctly, do nothing */
230 if (global_settings
.usemrb
)
231 success
= add_bookmark(RECENT_BOOKMARK_FILE
, bookmark
, true);
234 /* writing the bookmark */
235 if (create_bookmark_file
)
237 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
238 sizeof(global_temp_buffer
));
239 if (generate_bookmark_file_name(name
))
241 success
= add_bookmark(global_bookmark_file_name
, bookmark
, false);
245 gui_syncsplash(HZ
, success
? ID2P(LANG_BOOKMARK_CREATE_SUCCESS
)
246 : ID2P(LANG_BOOKMARK_CREATE_FAILURE
));
251 /* ----------------------------------------------------------------------- */
252 /* This function adds a bookmark to a file. */
253 /* ------------------------------------------------------------------------*/
254 static bool add_bookmark(const char* bookmark_file_name
, const char* bookmark
,
257 int temp_bookmark_file
= 0;
258 int bookmark_file
= 0;
259 int bookmark_count
= 0;
260 char* playlist
= NULL
;
266 /* Opening up a temp bookmark file */
267 snprintf(global_temp_buffer
, sizeof(global_temp_buffer
),
268 "%s.tmp", bookmark_file_name
);
269 temp_bookmark_file
= open(global_temp_buffer
,
270 O_WRONLY
| O_CREAT
| O_TRUNC
);
271 if (temp_bookmark_file
< 0)
272 return false; /* can't open the temp file */
274 if (most_recent
&& (global_settings
.usemrb
== BOOKMARK_UNIQUE_ONLY
))
276 playlist
= strchr(bookmark
,'/');
277 cp
= strrchr(bookmark
,';');
282 /* Writing the new bookmark to the begining of the temp file */
283 write(temp_bookmark_file
, bookmark
, strlen(bookmark
));
284 write(temp_bookmark_file
, "\n", 1);
287 /* Reading in the previous bookmarks and writing them to the temp file */
288 bookmark_file
= open(bookmark_file_name
, O_RDONLY
);
289 if (bookmark_file
>= 0)
291 while (read_line(bookmark_file
, global_read_buffer
,
292 sizeof(global_read_buffer
)) > 0)
294 /* The MRB has a max of MAX_BOOKMARKS in it */
295 /* This keeps it from getting too large */
296 if (most_recent
&& (bookmark_count
>= MAX_BOOKMARKS
))
299 cp
= strchr(global_read_buffer
,'/');
300 tmp
= strrchr(global_read_buffer
,';');
301 if (check_bookmark(global_read_buffer
) &&
302 (!unique
|| len
!= tmp
-cp
|| strncmp(playlist
,cp
,len
)))
305 write(temp_bookmark_file
, global_read_buffer
,
306 strlen(global_read_buffer
));
307 write(temp_bookmark_file
, "\n", 1);
310 close(bookmark_file
);
312 close(temp_bookmark_file
);
314 remove(bookmark_file_name
);
315 rename(global_temp_buffer
, bookmark_file_name
);
321 /* ----------------------------------------------------------------------- */
322 /* This function takes the system resume data and formats it into a valid */
324 /* ----------------------------------------------------------------------- */
325 static char* create_bookmark()
327 int resume_index
= 0;
330 /* grab the currently playing track */
331 struct mp3entry
*id3
= audio_current_track();
335 /* Get some basic resume information */
336 /* queue_resume and queue_resume_index are not used and can be ignored.*/
337 playlist_get_resume_info(&resume_index
);
339 /* Get the currently playing file minus the path */
340 /* This is used when displaying the available bookmarks */
341 file
= strrchr(id3
->path
,'/');
345 /* create the bookmark */
346 snprintf(global_bookmark
, sizeof(global_bookmark
),
347 "%d;%ld;%d;%d;%ld;%d;%d;%s;%s",
350 playlist_get_seed(NULL
),
353 global_settings
.repeat_mode
,
354 global_settings
.playlist_shuffle
,
355 playlist_get_name(NULL
, global_temp_buffer
,
356 sizeof(global_temp_buffer
)),
359 /* checking to see if the bookmark is valid */
360 if (check_bookmark(global_bookmark
))
361 return global_bookmark
;
366 static bool check_bookmark(const char* bookmark
)
368 return parse_bookmark(bookmark
,
369 NULL
,NULL
,NULL
, NULL
,
374 /* ----------------------------------------------------------------------- */
375 /* This function will determine if an autoload is necessary. This is an */
376 /* interface function. */
377 /* ------------------------------------------------------------------------*/
378 bool bookmark_autoload(const char* file
)
382 if(global_settings
.autoloadbookmark
== BOOKMARK_NO
)
385 /*Checking to see if a bookmark file exists.*/
386 if(!generate_bookmark_file_name(file
))
390 fd
= open(global_bookmark_file_name
, O_RDONLY
);
394 if(global_settings
.autoloadbookmark
== BOOKMARK_YES
)
396 return bookmark_load(global_bookmark_file_name
, true);
400 char* bookmark
= select_bookmark(global_bookmark_file_name
, true);
402 if (bookmark
!= NULL
)
404 if (!play_bookmark(bookmark
))
406 /* Selected bookmark not found. */
407 gui_syncsplash(HZ
*2, ID2P(LANG_NOTHING_TO_RESUME
));
410 /* Act as if autoload was done even if it failed, since the
411 * user did make an active selection.
420 /* ----------------------------------------------------------------------- */
421 /* This function loads the bookmark information into the resume memory. */
422 /* This is an interface function. */
423 /* ------------------------------------------------------------------------*/
424 bool bookmark_load(const char* file
, bool autoload
)
427 char* bookmark
= NULL
;
431 fd
= open(file
, O_RDONLY
);
434 if(read_line(fd
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
435 bookmark
=global_read_buffer
;
441 /* This is not an auto-load, so list the bookmarks */
442 bookmark
= select_bookmark(file
, false);
445 if (bookmark
!= NULL
)
447 if (!play_bookmark(bookmark
))
449 /* Selected bookmark not found. */
452 gui_syncsplash(HZ
*2, ID2P(LANG_NOTHING_TO_RESUME
));
463 static int get_bookmark_count(const char* bookmark_file_name
)
466 int file
= open(bookmark_file_name
, O_RDONLY
);
471 while(read_line(file
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
480 static int buffer_bookmarks(struct bookmark_list
* bookmarks
, int first_line
)
482 char* dest
= ((char*) bookmarks
) + bookmarks
->buffer_size
- 1;
484 int file
= open(bookmarks
->filename
, O_RDONLY
);
491 if ((first_line
!= 0) && ((size_t) filesize(file
) < bookmarks
->buffer_size
492 - sizeof(*bookmarks
) - (sizeof(char*) * bookmarks
->total_count
)))
494 /* Entire file fits in buffer */
498 bookmarks
->start
= first_line
;
499 bookmarks
->count
= 0;
500 bookmarks
->reload
= false;
502 while(read_line(file
, global_read_buffer
, sizeof(global_read_buffer
)) > 0)
506 if (read_count
>= first_line
)
508 dest
-= strlen(global_read_buffer
) + 1;
510 if (dest
< ((char*) bookmarks
) + sizeof(*bookmarks
)
511 + (sizeof(char*) * (bookmarks
->count
+ 1)))
516 strcpy(dest
, global_read_buffer
);
517 bookmarks
->items
[bookmarks
->count
] = dest
;
523 return bookmarks
->start
+ bookmarks
->count
;
526 static char* get_bookmark_info(int list_index
, void* data
, char *buffer
)
528 struct bookmark_list
* bookmarks
= (struct bookmark_list
*) data
;
529 int index
= list_index
/ 2;
530 int resume_index
= 0;
531 long resume_time
= 0;
532 bool shuffle
= false;
534 if (bookmarks
->show_dont_resume
)
538 return list_index
% 2 == 0
539 ? (char*) str(LANG_BOOKMARK_DONT_RESUME
) : " ";
545 if (bookmarks
->reload
|| (index
>= bookmarks
->start
+ bookmarks
->count
)
546 || (index
< bookmarks
->start
))
548 int read_index
= index
;
550 /* Using count as a guide on how far to move could possibly fail
551 * sometimes. Use byte count if that is a problem?
556 /* Move count * 3 / 4 items in the direction the user is moving,
557 * but don't go too close to the end.
559 int offset
= bookmarks
->count
;
560 int max
= bookmarks
->total_count
- (bookmarks
->count
/ 2);
562 if (read_index
< bookmarks
->start
)
567 read_index
= index
- offset
/ 4;
569 if (read_index
> max
)
580 if (buffer_bookmarks(bookmarks
, read_index
) <= index
)
586 if (!parse_bookmark(bookmarks
->items
[index
- bookmarks
->start
],
587 &resume_index
, NULL
, NULL
, NULL
, global_temp_buffer
,
588 sizeof(global_temp_buffer
), &resume_time
, NULL
, &shuffle
,
591 return list_index
% 2 == 0 ? (char*) str(LANG_BOOKMARK_INVALID
) : " ";
594 if (list_index
% 2 == 0)
598 int len
= strlen(global_temp_buffer
);
600 if (bookmarks
->show_playlist_name
&& len
> 0)
602 name
= global_temp_buffer
;
605 if (name
[len
] != '/')
616 name
= strrsplt(name
, '/');
623 name
= global_filename
;
627 strrsplt(global_filename
, '.');
628 snprintf(buffer
, MAX_PATH
, format
, name
, global_filename
);
635 format_time(time_buf
, sizeof(time_buf
), resume_time
);
636 snprintf(buffer
, MAX_PATH
, "%s, %d%s", time_buf
, resume_index
+ 1,
637 shuffle
? (char*) str(LANG_BOOKMARK_SHUFFLE
) : "");
642 /* ----------------------------------------------------------------------- */
643 /* This displays a the bookmarks in a file and allows the user to */
644 /* select one to play. */
645 /* ------------------------------------------------------------------------*/
646 static char* select_bookmark(const char* bookmark_file_name
, bool show_dont_resume
)
648 struct bookmark_list
* bookmarks
;
649 struct gui_synclist list
;
657 bookmarks
= plugin_get_buffer(&size
);
658 bookmarks
->buffer_size
= size
;
659 bookmarks
->show_dont_resume
= show_dont_resume
;
660 bookmarks
->filename
= bookmark_file_name
;
661 bookmarks
->start
= 0;
662 bookmarks
->show_playlist_name
663 = strcmp(bookmark_file_name
, RECENT_BOOKMARK_FILE
) == 0;
664 gui_synclist_init(&list
, &get_bookmark_info
, (void*) bookmarks
, false, 2, NULL
);
665 gui_synclist_set_title(&list
, str(LANG_BOOKMARK_SELECT_BOOKMARK
),
667 gui_syncstatusbar_draw(&statusbars
, true);
671 gui_syncstatusbar_draw(&statusbars
, false);
675 int count
= get_bookmark_count(bookmark_file_name
);
676 bookmarks
->total_count
= count
;
678 if (bookmarks
->total_count
< 1)
680 /* No more bookmarks, delete file and exit */
681 gui_syncsplash(HZ
, ID2P(LANG_BOOKMARK_LOAD_EMPTY
));
682 remove(bookmark_file_name
);
686 if (bookmarks
->show_dont_resume
)
692 gui_synclist_set_nb_items(&list
, count
* 2);
696 /* Selected item has been deleted */
698 gui_synclist_select_item(&list
, item
* 2);
701 buffer_bookmarks(bookmarks
, bookmarks
->start
);
702 gui_synclist_draw(&list
);
706 action
= get_action(CONTEXT_BOOKMARKSCREEN
, HZ
/ 2);
707 gui_synclist_do_button(&list
, &action
, LIST_WRAP_UNLESS_HELD
);
708 item
= gui_synclist_get_sel_pos(&list
) / 2;
710 if (bookmarks
->show_dont_resume
)
715 if (item
!= last_item
&& global_settings
.talk_menu
)
721 talk_id(LANG_BOOKMARK_DONT_RESUME
, true);
725 say_bookmark(bookmarks
->items
[item
- bookmarks
->start
], item
);
729 if (action
== ACTION_STD_CONTEXT
)
731 MENUITEM_STRINGLIST(menu_items
, ID2P(LANG_BOOKMARK_CONTEXT_MENU
),
732 NULL
, ID2P(LANG_BOOKMARK_CONTEXT_RESUME
),
733 ID2P(LANG_BOOKMARK_CONTEXT_DELETE
));
734 static const int menu_actions
[] =
736 ACTION_STD_OK
, ACTION_BMS_DELETE
738 int selection
= do_menu(&menu_items
, NULL
, NULL
, false);
742 if (selection
>= 0 && selection
<=
743 (int) (sizeof(menu_actions
) / sizeof(menu_actions
[0])))
745 action
= menu_actions
[selection
];
754 return bookmarks
->items
[item
- bookmarks
->start
];
757 /* Else fall through */
759 case ACTION_TREE_WPS
:
760 case ACTION_STD_CANCEL
:
764 case ACTION_BMS_DELETE
:
767 delete_bookmark(bookmark_file_name
, item
);
768 bookmarks
->reload
= true;
775 if (default_event_handler(action
) == SYS_USB_CONNECTED
)
787 /* ----------------------------------------------------------------------- */
788 /* This function takes a location in a bookmark file and deletes that */
790 /* ------------------------------------------------------------------------*/
791 static bool delete_bookmark(const char* bookmark_file_name
, int bookmark_id
)
793 int temp_bookmark_file
= 0;
794 int bookmark_file
= 0;
795 int bookmark_count
= 0;
797 /* Opening up a temp bookmark file */
798 snprintf(global_temp_buffer
, sizeof(global_temp_buffer
),
799 "%s.tmp", bookmark_file_name
);
800 temp_bookmark_file
= open(global_temp_buffer
,
801 O_WRONLY
| O_CREAT
| O_TRUNC
);
803 if (temp_bookmark_file
< 0)
804 return false; /* can't open the temp file */
806 /* Reading in the previous bookmarks and writing them to the temp file */
807 bookmark_file
= open(bookmark_file_name
, O_RDONLY
);
808 if (bookmark_file
>= 0)
810 while (read_line(bookmark_file
, global_read_buffer
,
811 sizeof(global_read_buffer
)) > 0)
813 if (bookmark_id
!= bookmark_count
)
815 write(temp_bookmark_file
, global_read_buffer
,
816 strlen(global_read_buffer
));
817 write(temp_bookmark_file
, "\n", 1);
821 close(bookmark_file
);
823 close(temp_bookmark_file
);
825 remove(bookmark_file_name
);
826 rename(global_temp_buffer
, bookmark_file_name
);
831 /* ----------------------------------------------------------------------- */
832 /* This function parses a bookmark, says the voice UI part of it. */
833 /* ------------------------------------------------------------------------*/
834 static void say_bookmark(const char* bookmark
,
839 bool enqueue
= false; /* only the first voice is not queued */
841 if (!parse_bookmark(bookmark
, &resume_index
, NULL
, NULL
, NULL
,
842 global_temp_buffer
, sizeof(global_temp_buffer
), &ms
, NULL
, NULL
, NULL
))
844 talk_id(LANG_BOOKMARK_INVALID
, true);
848 /* disabled, because transition between talkbox and voice UI clip is not nice */
850 if (global_settings
.talk_dir
>= 3)
851 { /* "talkbox" enabled */
852 char* last
= strrchr(global_temp_buffer
, '/');
854 { /* compose filename for talkbox */
855 strncpy(last
+ 1, dir_thumbnail_name
,
856 sizeof(global_temp_buffer
) - (last
- global_temp_buffer
) - 1);
857 talk_file(global_temp_buffer
, enqueue
);
862 talk_id(VOICE_EXT_BMARK
, enqueue
);
863 talk_number(bookmark_id
+ 1, true);
864 talk_id(VOICE_BOOKMARK_SELECT_INDEX_TEXT
, true);
865 talk_number(resume_index
+ 1, true);
866 talk_id(LANG_TIME
, true);
868 talk_value(ms
/ 60000, UNIT_MIN
, true);
869 talk_value((ms
% 60000) / 1000, UNIT_SEC
, true);
872 /* ----------------------------------------------------------------------- */
873 /* This function parses a bookmark and then plays it. */
874 /* ------------------------------------------------------------------------*/
875 static bool play_bookmark(const char* bookmark
)
881 if (parse_bookmark(bookmark
,
887 sizeof(global_temp_buffer
),
889 &global_settings
.repeat_mode
,
890 &global_settings
.playlist_shuffle
,
893 return bookmark_play(global_temp_buffer
, index
, offset
, seed
,
900 static const char* skip_token(const char* s
)
902 while (*s
&& *s
!= ';')
915 static const char* int_token(const char* s
, int* dest
)
922 return skip_token(s
);
925 static const char* long_token(const char* s
, long* dest
)
929 *dest
= atoi(s
); /* Should be atol, but we don't have it. */
932 return skip_token(s
);
935 static const char* bool_token(const char* s
, bool* dest
)
939 *dest
= atoi(s
) != 0;
942 return skip_token(s
);
945 /* ----------------------------------------------------------------------- */
946 /* This function takes a bookmark and parses it. This function also */
947 /* validates the bookmark. Passing in NULL for an output variable */
948 /* indicates that value is not requested. */
949 /* ----------------------------------------------------------------------- */
950 static bool parse_bookmark(const char *bookmark
,
954 int *resume_first_index
,
956 unsigned int resume_file_size
,
958 int * repeat_mode
, bool *shuffle
,
961 const char* s
= bookmark
;
964 s
= int_token(s
, resume_index
);
965 s
= int_token(s
, resume_offset
);
966 s
= int_token(s
, resume_seed
);
967 s
= int_token(s
, resume_first_index
);
968 s
= long_token(s
, ms
);
969 s
= int_token(s
, repeat_mode
);
970 s
= bool_token(s
, shuffle
);
977 end
= strchr(s
, ';');
979 if (resume_file
!= NULL
)
981 size_t len
= (end
== NULL
) ? strlen(s
) : (size_t) (end
- s
);
983 len
= MIN(resume_file_size
- 1, len
);
984 strncpy(resume_file
, s
, len
);
985 resume_file
[len
] = 0;
988 if (end
!= NULL
&& file_name
!= NULL
)
991 strncpy(file_name
, end
, MAX_PATH
- 1);
992 file_name
[MAX_PATH
- 1] = 0;
998 /* ----------------------------------------------------------------------- */
999 /* This function is used by multiple functions and is used to generate a */
1000 /* bookmark named based off of the input. */
1001 /* Changing this function could result in how the bookmarks are stored. */
1002 /* it would be here that the centralized/decentralized bookmark code */
1003 /* could be placed. */
1004 /* ----------------------------------------------------------------------- */
1005 static bool generate_bookmark_file_name(const char *in
)
1007 int len
= strlen(in
);
1009 /* if this is a root dir MP3, rename the bookmark file root_dir.bmark */
1010 /* otherwise, name it based on the in variable */
1011 if (!strcmp("/", in
))
1012 strcpy(global_bookmark_file_name
, "/root_dir.bmark");
1015 strcpy(global_bookmark_file_name
, in
);
1016 if(global_bookmark_file_name
[len
-1] == '/')
1018 strcpy(&global_bookmark_file_name
[len
], ".bmark");
1024 /* ----------------------------------------------------------------------- */
1025 /* Returns true if a bookmark file exists for the current playlist */
1026 /* ----------------------------------------------------------------------- */
1027 bool bookmark_exist(void)
1033 char* name
= playlist_get_name(NULL
, global_temp_buffer
,
1034 sizeof(global_temp_buffer
));
1035 if (generate_bookmark_file_name(name
))
1037 int fd
=open(global_bookmark_file_name
, O_RDONLY
);
1049 /* ----------------------------------------------------------------------- */
1050 /* Checks the current state of the system and returns if it is in a */
1051 /* bookmarkable state. */
1052 /* ----------------------------------------------------------------------- */
1054 /* ----------------------------------------------------------------------- */
1056 /* return bool: Indicates if the system was in a bookmarkable state */
1057 /* ----------------------------------------------------------------------- */
1058 static bool system_check(void)
1060 int resume_index
= 0;
1062 if (!(audio_status() && audio_current_track()))
1064 /* no track playing */
1068 /* Checking to see if playing a queued track */
1069 if (playlist_get_resume_info(&resume_index
) == -1)
1071 /* something bad happened while getting the queue information */
1074 else if (playlist_modified(NULL
))
1076 /* can't bookmark while in the queue */