diff options
-rw-r--r-- | apps/tagcache.h | 7 | ||||
-rw-r--r-- | apps/tagnavi.config | 6 | ||||
-rw-r--r-- | apps/tagtree.c | 80 |
3 files changed, 45 insertions, 48 deletions
diff --git a/apps/tagcache.h b/apps/tagcache.h index a33e79b56d..39f0c61f7e 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -109,10 +109,9 @@ struct tagcache_stat { | |||
109 | // const char *uimessage; /* Pending error message. Implement soon. */ | 109 | // const char *uimessage; /* Pending error message. Implement soon. */ |
110 | }; | 110 | }; |
111 | 111 | ||
112 | enum source_type {source_constant, source_input, | 112 | enum source_type {source_constant, |
113 | source_current_path, /* has different handling to _id3 | 113 | source_runtime, |
114 | so it has to be seperate */ | 114 | source_current_path /* dont add items after this. |
115 | source_current_id3 /* dont add items after this. | ||
116 | it is used as an index | 115 | it is used as an index |
117 | into id3_to_search_mapping */ | 116 | into id3_to_search_mapping */ |
118 | }; | 117 | }; |
diff --git a/apps/tagnavi.config b/apps/tagnavi.config index 4facdd25b9..def3c12d61 100644 --- a/apps/tagnavi.config +++ b/apps/tagnavi.config | |||
@@ -141,9 +141,11 @@ | |||
141 | 141 | ||
142 | # Define the "same as current" sub menu | 142 | # Define the "same as current" sub menu |
143 | %menu_start "same" "Same as current" | 143 | %menu_start "same" "Same as current" |
144 | "Directory" -> title ? filename ^ "#directory#" | ||
145 | "Title" -> title = "fmt_title" ? title = "#title#" | ||
144 | "Artist" -> album ? artist = "#artist#" -> title = "fmt_title" | 146 | "Artist" -> album ? artist = "#artist#" -> title = "fmt_title" |
145 | "Album" -> title = "fmt_title" ? album = "#album#" | 147 | "Album" -> title = "fmt_title" ? album = "#album#" & albumartist = "#albumartist#" |
146 | "Directory" -> filename ? filename ~ "#directory#" | 148 | "Composer" -> title = "fmt_title" ? composer = "#composer#" |
147 | 149 | ||
148 | # Define the runtime sub menu | 150 | # Define the runtime sub menu |
149 | %menu_start "runtime" "Play history" | 151 | %menu_start "runtime" "Play history" |
diff --git a/apps/tagtree.c b/apps/tagtree.c index 94bf726caa..c0d9f0f425 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -51,12 +51,14 @@ | |||
51 | 51 | ||
52 | static int tagtree_play_folder(struct tree_context* c); | 52 | static int tagtree_play_folder(struct tree_context* c); |
53 | 53 | ||
54 | #define SEARCHSTR_SIZE 128 | 54 | #define SEARCHSTR_SIZE 256 |
55 | static char searchstring[SEARCHSTR_SIZE]; | 55 | |
56 | static const struct id3_to_search_mapping { | 56 | static const struct id3_to_search_mapping { |
57 | char *string; | 57 | char *string; |
58 | size_t id3_offset; | 58 | size_t id3_offset; |
59 | } id3_to_search_mapping[] = { | 59 | } id3_to_search_mapping[] = { |
60 | { "", 0 }, /* offset n/a */ | ||
61 | { "#directory#", 0 }, /* offset n/a */ | ||
60 | { "#title#", offsetof(struct mp3entry, title) }, | 62 | { "#title#", offsetof(struct mp3entry, title) }, |
61 | { "#artist#", offsetof(struct mp3entry, artist) }, | 63 | { "#artist#", offsetof(struct mp3entry, artist) }, |
62 | { "#album#", offsetof(struct mp3entry, album) }, | 64 | { "#album#", offsetof(struct mp3entry, album) }, |
@@ -288,7 +290,8 @@ static int get_clause(int *condition) | |||
288 | 290 | ||
289 | static bool read_clause(struct tagcache_search_clause *clause) | 291 | static bool read_clause(struct tagcache_search_clause *clause) |
290 | { | 292 | { |
291 | char buf[256]; | 293 | char buf[SEARCHSTR_SIZE]; |
294 | unsigned int i; | ||
292 | 295 | ||
293 | if (get_tag(&clause->tag) <= 0) | 296 | if (get_tag(&clause->tag) <= 0) |
294 | return false; | 297 | return false; |
@@ -298,33 +301,24 @@ static bool read_clause(struct tagcache_search_clause *clause) | |||
298 | 301 | ||
299 | if (get_token_str(buf, sizeof buf) < 0) | 302 | if (get_token_str(buf, sizeof buf) < 0) |
300 | return false; | 303 | return false; |
301 | 304 | ||
302 | clause->str = buffer_alloc(strlen(buf)+1); | 305 | for (i=0; i<ARRAYLEN(id3_to_search_mapping); i++) |
303 | strcpy(clause->str, buf); | ||
304 | |||
305 | logf("got clause: %d/%d [%s]", clause->tag, clause->type, clause->str); | ||
306 | |||
307 | if (*(clause->str) == '\0') | ||
308 | clause->source = source_input; | ||
309 | else if (!strcasecmp(clause->str, "#directory#")) | ||
310 | clause->source = source_current_path; | ||
311 | else | ||
312 | { | 306 | { |
313 | unsigned int i; | 307 | if (!strcasecmp(buf, id3_to_search_mapping[i].string)) |
314 | bool found = false; | 308 | break; |
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 | } | 309 | } |
310 | |||
311 | if (i<ARRAYLEN(id3_to_search_mapping)) /* runtime search operand found */ | ||
312 | { | ||
313 | clause->source = source_runtime+i; | ||
314 | clause->str = buffer_alloc(SEARCHSTR_SIZE); | ||
315 | } | ||
316 | else | ||
317 | { | ||
318 | clause->source = source_constant; | ||
319 | clause->str = buffer_alloc(strlen(buf)+1); | ||
320 | strcpy(clause->str, buf); | ||
321 | } | ||
328 | 322 | ||
329 | if (tagcache_is_numeric_tag(clause->tag)) | 323 | if (tagcache_is_numeric_tag(clause->tag)) |
330 | { | 324 | { |
@@ -333,6 +327,8 @@ static bool read_clause(struct tagcache_search_clause *clause) | |||
333 | } | 327 | } |
334 | else | 328 | else |
335 | clause->numeric = false; | 329 | clause->numeric = false; |
330 | |||
331 | logf("got clause: %d/%d [%s]", clause->tag, clause->type, clause->str); | ||
336 | 332 | ||
337 | return true; | 333 | return true; |
338 | } | 334 | } |
@@ -1419,14 +1415,17 @@ int tagtree_enter(struct tree_context* c) | |||
1419 | { | 1415 | { |
1420 | for (j = 0; j < csi->clause_count[i]; j++) | 1416 | for (j = 0; j < csi->clause_count[i]; j++) |
1421 | { | 1417 | { |
1422 | *searchstring='\0'; | 1418 | char* searchstring; |
1423 | source = csi->clause[i][j]->source; | 1419 | source = csi->clause[i][j]->source; |
1424 | 1420 | ||
1425 | if (source == source_constant) | 1421 | if (source == source_constant) |
1426 | continue; | 1422 | continue; |
1427 | 1423 | ||
1424 | searchstring=csi->clause[i][j]->str; | ||
1425 | *searchstring = '\0'; | ||
1426 | |||
1428 | id3 = audio_current_track(); | 1427 | id3 = audio_current_track(); |
1429 | 1428 | ||
1430 | if (source == source_current_path && id3) | 1429 | if (source == source_current_path && id3) |
1431 | { | 1430 | { |
1432 | char *e; | 1431 | char *e; |
@@ -1435,11 +1434,11 @@ int tagtree_enter(struct tree_context* c) | |||
1435 | if (e) | 1434 | if (e) |
1436 | *e = '\0'; | 1435 | *e = '\0'; |
1437 | } | 1436 | } |
1438 | 1437 | else if (source > source_runtime && id3) | |
1439 | if (source >= source_current_id3 && id3) | ||
1440 | { | 1438 | { |
1441 | int i = source-source_current_id3; | 1439 | |
1442 | int offset = id3_to_search_mapping[i].id3_offset; | 1440 | int k = source-source_runtime; |
1441 | int offset = id3_to_search_mapping[k].id3_offset; | ||
1443 | char **src = (char**)((char*)id3 + offset); | 1442 | char **src = (char**)((char*)id3 + offset); |
1444 | if (*src) | 1443 | if (*src) |
1445 | { | 1444 | { |
@@ -1447,8 +1446,7 @@ int tagtree_enter(struct tree_context* c) | |||
1447 | searchstring[SEARCHSTR_SIZE-1] = '\0'; | 1446 | searchstring[SEARCHSTR_SIZE-1] = '\0'; |
1448 | } | 1447 | } |
1449 | } | 1448 | } |
1450 | 1449 | else | |
1451 | if((source == source_input) || (*searchstring=='\0')) | ||
1452 | { | 1450 | { |
1453 | rc = kbd_input(searchstring, SEARCHSTR_SIZE); | 1451 | rc = kbd_input(searchstring, SEARCHSTR_SIZE); |
1454 | if (rc == -1 || !searchstring[0]) | 1452 | if (rc == -1 || !searchstring[0]) |
@@ -1456,18 +1454,16 @@ int tagtree_enter(struct tree_context* c) | |||
1456 | tagtree_exit(c); | 1454 | tagtree_exit(c); |
1457 | return 0; | 1455 | return 0; |
1458 | } | 1456 | } |
1457 | if (csi->clause[i][j]->numeric) | ||
1458 | csi->clause[i][j]->numeric_data = atoi(searchstring); | ||
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | if (csi->clause[i][j]->numeric) | ||
1462 | csi->clause[i][j]->numeric_data = atoi(searchstring); | ||
1463 | 1461 | ||
1464 | /* existing bug: only one dynamic string per clause! */ | ||
1465 | csi->clause[i][j]->str = searchstring; | ||
1466 | } | 1462 | } |
1467 | } | 1463 | } |
1468 | } | 1464 | } |
1469 | c->currtable = newextra; | 1465 | c->currtable = newextra; |
1470 | 1466 | ||
1471 | break; | 1467 | break; |
1472 | 1468 | ||
1473 | case navibrowse: | 1469 | case navibrowse: |