summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/bookmark.c61
-rw-r--r--apps/lang/english.lang36
-rw-r--r--apps/settings.h25
-rw-r--r--apps/settings_list.c5
4 files changed, 100 insertions, 27 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index 567f98ac29..f783c83992 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -271,6 +271,19 @@ static bool write_bookmark(bool create_bookmark_file, const char *bookmark)
271 return ret; 271 return ret;
272} 272}
273 273
274/* Get the name of the playlist and the name of the track from a bookmark. */
275/* Returns true iff both were extracted. */
276static bool get_playlist_and_track(const char *bookmark, char **pl_start,
277 char **pl_end, char **track)
278{
279 *pl_start = strchr(bookmark,'/');
280 if (!(*pl_start))
281 return false;
282 *pl_end = strrchr(bookmark,';');
283 *track = *pl_end + 1;
284 return true;
285}
286
274/* ----------------------------------------------------------------------- */ 287/* ----------------------------------------------------------------------- */
275/* This function adds a bookmark to a file. */ 288/* This function adds a bookmark to a file. */
276/* Returns true on successful bookmark add. */ 289/* Returns true on successful bookmark add. */
@@ -281,11 +294,13 @@ static bool add_bookmark(const char* bookmark_file_name, const char* bookmark,
281 int temp_bookmark_file = 0; 294 int temp_bookmark_file = 0;
282 int bookmark_file = 0; 295 int bookmark_file = 0;
283 int bookmark_count = 0; 296 int bookmark_count = 0;
284 char* playlist = NULL; 297 char *pl_start = NULL, *bm_pl_start;
285 char* cp; 298 char *pl_end = NULL, *bm_pl_end;
286 char* tmp; 299 int pl_len = 0, bm_pl_len;
287 int len = 0; 300 char *track = NULL, *bm_track;
288 bool unique = false; 301 bool comp_playlist = false;
302 bool comp_track = false;
303 bool equal;
289 304
290 /* Opening up a temp bookmark file */ 305 /* Opening up a temp bookmark file */
291 snprintf(global_temp_buffer, sizeof(global_temp_buffer), 306 snprintf(global_temp_buffer, sizeof(global_temp_buffer),
@@ -295,12 +310,16 @@ static bool add_bookmark(const char* bookmark_file_name, const char* bookmark,
295 if (temp_bookmark_file < 0) 310 if (temp_bookmark_file < 0)
296 return false; /* can't open the temp file */ 311 return false; /* can't open the temp file */
297 312
298 if (most_recent && (global_settings.usemrb == BOOKMARK_UNIQUE_ONLY)) 313 if (most_recent && ((global_settings.usemrb == BOOKMARK_ONE_PER_PLAYLIST)
314 || (global_settings.usemrb == BOOKMARK_ONE_PER_TRACK)))
299 { 315 {
300 playlist = strchr(bookmark,'/'); 316 if (get_playlist_and_track(bookmark, &pl_start, &pl_end, &track))
301 cp = strrchr(bookmark,';'); 317 {
302 len = cp - playlist; 318 comp_playlist = true;
303 unique = true; 319 pl_len = pl_end - pl_start;
320 if (global_settings.usemrb == BOOKMARK_ONE_PER_TRACK)
321 comp_track = true;
322 }
304 } 323 }
305 324
306 /* Writing the new bookmark to the begining of the temp file */ 325 /* Writing the new bookmark to the begining of the temp file */
@@ -319,11 +338,23 @@ static bool add_bookmark(const char* bookmark_file_name, const char* bookmark,
319 /* This keeps it from getting too large */ 338 /* This keeps it from getting too large */
320 if (most_recent && (bookmark_count >= MAX_BOOKMARKS)) 339 if (most_recent && (bookmark_count >= MAX_BOOKMARKS))
321 break; 340 break;
322 341
323 cp = strchr(global_read_buffer,'/'); 342 if (!parse_bookmark(global_read_buffer, false))
324 tmp = strrchr(global_read_buffer,';'); 343 break;
325 if (parse_bookmark(global_read_buffer, false) && 344
326 (!unique || len != tmp -cp || strncmp(playlist,cp,len))) 345 equal = false;
346 if (comp_playlist)
347 {
348 if (get_playlist_and_track(global_read_buffer, &bm_pl_start,
349 &bm_pl_end, &bm_track))
350 {
351 bm_pl_len = bm_pl_end - bm_pl_start;
352 equal = (pl_len == bm_pl_len) && !strncmp(pl_start, bm_pl_start, pl_len);
353 if (equal && comp_track)
354 equal = !strcmp(track, bm_track);
355 }
356 }
357 if (!equal)
327 { 358 {
328 bookmark_count++; 359 bookmark_count++;
329 write(temp_bookmark_file, global_read_buffer, 360 write(temp_bookmark_file, global_read_buffer,
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index f4f1b12032..02482d08af 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -4737,16 +4737,16 @@
4737</phrase> 4737</phrase>
4738<phrase> 4738<phrase>
4739 id: LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY 4739 id: LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY
4740 desc: Save only on bookmark for each playlist in recent bookmarks 4740 desc: deprecated
4741 user: core 4741 user: core
4742 <source> 4742 <source>
4743 *: "Unique only" 4743 *: ""
4744 </source> 4744 </source>
4745 <dest> 4745 <dest>
4746 *: "Unique only" 4746 *: ""
4747 </dest> 4747 </dest>
4748 <voice> 4748 <voice>
4749 *: "Unique only" 4749 *: ""
4750 </voice> 4750 </voice>
4751</phrase> 4751</phrase>
4752<phrase> 4752<phrase>
@@ -13689,3 +13689,31 @@
13689 *: "gibibyte" 13689 *: "gibibyte"
13690 </voice> 13690 </voice>
13691</phrase> 13691</phrase>
13692<phrase>
13693 id: LANG_BOOKMARK_SETTINGS_ONE_PER_PLAYLIST
13694 desc: Save only one bookmark for a playlist in recent bookmarks
13695 user: core
13696 <source>
13697 *: "One per playlist"
13698 </source>
13699 <dest>
13700 *: "One per playlist"
13701 </dest>
13702 <voice>
13703 *: "One per playlist"
13704 </voice>
13705</phrase>
13706<phrase>
13707 id: LANG_BOOKMARK_SETTINGS_ONE_PER_TRACK
13708 desc: Save only one bookmark for a combination (playlist,track) in recent bookmarks
13709 user: core
13710 <source>
13711 *: "One per track"
13712 </source>
13713 <dest>
13714 *: "One per track"
13715 </dest>
13716 <voice>
13717 *: "One per track"
13718 </voice>
13719</phrase>
diff --git a/apps/settings.h b/apps/settings.h
index cbe12d70b7..db16e717e6 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -45,14 +45,26 @@ struct opt_items {
45#define MAX_FILENAME 32 45#define MAX_FILENAME 32
46#define MAX_PATHNAME 80 46#define MAX_PATHNAME 80
47 47
48/* The values are assigned to the enums so that they correspond to */
49/* setting values in settings_list.c */
48 50
51/* Shared by all bookmark parameters */
49enum { 52enum {
50 BOOKMARK_NO = 0, 53 BOOKMARK_NO = 0,
51 BOOKMARK_YES, 54 BOOKMARK_YES = 1,
52 BOOKMARK_ASK, 55};
53 BOOKMARK_UNIQUE_ONLY = 2, 56
54 BOOKMARK_RECENT_ONLY_YES, 57/* Auto create bookmark */
55 BOOKMARK_RECENT_ONLY_ASK, 58enum {
59 BOOKMARK_ASK = 2,
60 BOOKMARK_RECENT_ONLY_YES = 3,
61 BOOKMARK_RECENT_ONLY_ASK = 4,
62};
63
64/* Most recent bookmark */
65enum {
66 BOOKMARK_ONE_PER_PLAYLIST = 2,
67 BOOKMARK_ONE_PER_TRACK = 3,
56}; 68};
57 69
58enum 70enum
@@ -557,7 +569,8 @@ struct user_settings
557 int autoloadbookmark; /* auto load option: 0=off, 1=ask, 2=on */ 569 int autoloadbookmark; /* auto load option: 0=off, 1=ask, 2=on */
558 int autocreatebookmark; /* auto create option: 0=off, 1=ask, 2=on */ 570 int autocreatebookmark; /* auto create option: 0=off, 1=ask, 2=on */
559 bool autoupdatebookmark;/* auto update option */ 571 bool autoupdatebookmark;/* auto update option */
560 int usemrb; /* use MRB list: 0=No, 1=Yes, 2=One per playlist */ 572 int usemrb; /* use MRB list: 0=No, 1=Yes, 2=One per playlist,
573 3=One per playlist and track */
561 574
562#ifdef HAVE_DIRCACHE 575#ifdef HAVE_DIRCACHE
563 bool dircache; /* enable directory cache */ 576 bool dircache; /* enable directory cache */
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 57763d345a..d4ad6f64dc 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1246,9 +1246,10 @@ const struct settings_list settings[] = {
1246 ID2P(LANG_ASK)), 1246 ID2P(LANG_ASK)),
1247 CHOICE_SETTING(0, usemrb, LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS, 1247 CHOICE_SETTING(0, usemrb, LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS,
1248 BOOKMARK_NO, "use most-recent-bookmarks", 1248 BOOKMARK_NO, "use most-recent-bookmarks",
1249 "off,on,unique only", NULL, 3, ID2P(LANG_SET_BOOL_NO), 1249 "off,on,unique only,one per track", NULL, 4, ID2P(LANG_SET_BOOL_NO),
1250 ID2P(LANG_SET_BOOL_YES), 1250 ID2P(LANG_SET_BOOL_YES),
1251 ID2P(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY)), 1251 ID2P(LANG_BOOKMARK_SETTINGS_ONE_PER_PLAYLIST),
1252 ID2P(LANG_BOOKMARK_SETTINGS_ONE_PER_TRACK)),
1252#ifdef HAVE_LCD_BITMAP 1253#ifdef HAVE_LCD_BITMAP
1253 /* peak meter */ 1254 /* peak meter */
1254 STRINGCHOICE_SETTING(0, peak_meter_clip_hold, LANG_PM_CLIP_HOLD, 16, 1255 STRINGCHOICE_SETTING(0, peak_meter_clip_hold, LANG_PM_CLIP_HOLD, 16,