summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-10-29 14:10:24 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-10-29 14:10:24 +0000
commit75eff7af5e23bb86b376746c1216b553d1efbc35 (patch)
tree7fc38e65e85bf30996a131a6bec685e7756b6845
parentc98590308457f6d74b2539b978ce760c496a25cf (diff)
downloadrockbox-75eff7af5e23bb86b376746c1216b553d1efbc35.tar.gz
rockbox-75eff7af5e23bb86b376746c1216b553d1efbc35.zip
rework my previous commit (FS#8008) to be able to work for any of the strings in the id3 info struct, new ones need to be added to tagtree.c and tagnavi.config
*currently available tags are* #title# #artist# #album# #genre# #composer# #albumartist# and #directory# git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15358 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/tagcache.h10
-rw-r--r--apps/tagnavi.config1
-rw-r--r--apps/tagtree.c70
3 files changed, 57 insertions, 24 deletions
diff --git a/apps/tagcache.h b/apps/tagcache.h
index 16dac0b41f..a33e79b56d 100644
--- a/apps/tagcache.h
+++ b/apps/tagcache.h
@@ -110,10 +110,12 @@ struct tagcache_stat {
110}; 110};
111 111
112enum source_type {source_constant, source_input, 112enum source_type {source_constant, source_input,
113 source_current_artist, source_current_album}; 113 source_current_path, /* has different handling to _id3
114 114 so it has to be seperate */
115#define SOURCE_CURRENT_ARTIST "#artist#" 115 source_current_id3 /* dont add items after this.
116#define SOURCE_CURRENT_ALBUM "#album#" 116 it is used as an index
117 into id3_to_search_mapping */
118 };
117 119
118struct tagcache_search_clause 120struct tagcache_search_clause
119{ 121{
diff --git a/apps/tagnavi.config b/apps/tagnavi.config
index 30fd371b3e..4facdd25b9 100644
--- a/apps/tagnavi.config
+++ b/apps/tagnavi.config
@@ -143,6 +143,7 @@
143%menu_start "same" "Same as current" 143%menu_start "same" "Same as current"
144"Artist" -> album ? artist = "#artist#" -> title = "fmt_title" 144"Artist" -> album ? artist = "#artist#" -> title = "fmt_title"
145"Album" -> title = "fmt_title" ? album = "#album#" 145"Album" -> title = "fmt_title" ? album = "#album#"
146"Directory" -> filename ? filename ~ "#directory#"
146 147
147# Define the runtime sub menu 148# Define the runtime sub menu
148%menu_start "runtime" "Play history" 149%menu_start "runtime" "Play history"
diff --git a/apps/tagtree.c b/apps/tagtree.c
index bac74cf443..94bf726caa 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -53,7 +53,17 @@ static int tagtree_play_folder(struct tree_context* c);
53 53
54#define SEARCHSTR_SIZE 128 54#define SEARCHSTR_SIZE 128
55static char searchstring[SEARCHSTR_SIZE]; 55static char searchstring[SEARCHSTR_SIZE];
56 56static const struct id3_to_search_mapping {
57 char *string;
58 size_t id3_offset;
59} id3_to_search_mapping[] = {
60 { "#title#", offsetof(struct mp3entry, title) },
61 { "#artist#", offsetof(struct mp3entry, artist) },
62 { "#album#", offsetof(struct mp3entry, album) },
63 { "#genre#", offsetof(struct mp3entry, genre_string) },
64 { "#composer#", offsetof(struct mp3entry, composer) },
65 { "#albumartist#", offsetof(struct mp3entry, albumartist) },
66};
57enum variables { 67enum variables {
58 var_sorttype = 100, 68 var_sorttype = 100,
59 var_limit, 69 var_limit,
@@ -296,12 +306,25 @@ static bool read_clause(struct tagcache_search_clause *clause)
296 306
297 if (*(clause->str) == '\0') 307 if (*(clause->str) == '\0')
298 clause->source = source_input; 308 clause->source = source_input;
299 else if (!strcasecmp(clause->str, SOURCE_CURRENT_ALBUM)) 309 else if (!strcasecmp(clause->str, "#directory#"))
300 clause->source = source_current_album; 310 clause->source = source_current_path;
301 else if (!strcasecmp(clause->str, SOURCE_CURRENT_ARTIST)) 311 else
302 clause->source = source_current_artist; 312 {
303 else 313 unsigned int i;
304 clause->source = source_constant; 314 bool found = false;
315 for (i=0; !found && i<ARRAYLEN(id3_to_search_mapping); i++)
316 {
317 if (!strcasecmp(clause->str, id3_to_search_mapping[i].string))
318 {
319 found = true;
320 break;
321 }
322 }
323 if (found)
324 clause->source = source_current_id3+i;
325 else
326 clause->source = source_constant;
327 }
305 328
306 if (tagcache_is_numeric_tag(clause->tag)) 329 if (tagcache_is_numeric_tag(clause->tag))
307 { 330 {
@@ -1403,21 +1426,28 @@ int tagtree_enter(struct tree_context* c)
1403 continue; 1426 continue;
1404 1427
1405 id3 = audio_current_track(); 1428 id3 = audio_current_track();
1406 1429
1407 if ((source == source_current_artist) && 1430 if (source == source_current_path && id3)
1408 (id3) && (id3->artist))
1409 { 1431 {
1410 strncpy(searchstring, id3->artist, SEARCHSTR_SIZE); 1432 char *e;
1411 searchstring[SEARCHSTR_SIZE-1] = '\0'; 1433 strncpy(searchstring, id3->path, SEARCHSTR_SIZE);
1412 } 1434 e = strrchr(searchstring, '/');
1413 1435 if (e)
1414 if ((source == source_current_album) && 1436 *e = '\0';
1415 (id3) && (id3->album)) 1437 }
1438
1439 if (source >= source_current_id3 && id3)
1416 { 1440 {
1417 strncpy(searchstring, id3->album, SEARCHSTR_SIZE); 1441 int i = source-source_current_id3;
1418 searchstring[SEARCHSTR_SIZE-1] = '\0'; 1442 int offset = id3_to_search_mapping[i].id3_offset;
1419 } 1443 char **src = (char**)((char*)id3 + offset);
1420 1444 if (*src)
1445 {
1446 strncpy(searchstring, *src, SEARCHSTR_SIZE);
1447 searchstring[SEARCHSTR_SIZE-1] = '\0';
1448 }
1449 }
1450
1421 if((source == source_input) || (*searchstring=='\0')) 1451 if((source == source_input) || (*searchstring=='\0'))
1422 { 1452 {
1423 rc = kbd_input(searchstring, SEARCHSTR_SIZE); 1453 rc = kbd_input(searchstring, SEARCHSTR_SIZE);