summaryrefslogtreecommitdiff
path: root/apps/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tree.c')
-rw-r--r--apps/tree.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/apps/tree.c b/apps/tree.c
index bfb6412bfe..772e2351bb 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -61,7 +61,9 @@
61#include "recorder/recording.h" 61#include "recorder/recording.h"
62#include "rtc.h" 62#include "rtc.h"
63#include "dircache.h" 63#include "dircache.h"
64#ifdef HAVE_TAGCACHE
64#include "tagcache.h" 65#include "tagcache.h"
66#endif
65#include "yesno.h" 67#include "yesno.h"
66#include "gwps-common.h" 68#include "gwps-common.h"
67#include "eeprom_settings.h" 69#include "eeprom_settings.h"
@@ -177,6 +179,7 @@ char * tree_get_filename(int selected_item, void * data, char *buffer)
177 struct tree_context * local_tc=(struct tree_context *)data; 179 struct tree_context * local_tc=(struct tree_context *)data;
178 char *name; 180 char *name;
179 int attr=0; 181 int attr=0;
182#ifdef HAVE_TAGCACHE
180 bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB; 183 bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB;
181 184
182 if (id3db) 185 if (id3db)
@@ -184,6 +187,7 @@ char * tree_get_filename(int selected_item, void * data, char *buffer)
184 return tagtree_get_entry(&tc, selected_item)->name; 187 return tagtree_get_entry(&tc, selected_item)->name;
185 } 188 }
186 else 189 else
190#endif
187 { 191 {
188 struct entry* dc = local_tc->dircache; 192 struct entry* dc = local_tc->dircache;
189 struct entry* e = &dc[selected_item]; 193 struct entry* e = &dc[selected_item];
@@ -205,11 +209,14 @@ char * tree_get_filename(int selected_item, void * data, char *buffer)
205void tree_get_fileicon(int selected_item, void * data, ICON * icon) 209void tree_get_fileicon(int selected_item, void * data, ICON * icon)
206{ 210{
207 struct tree_context * local_tc=(struct tree_context *)data; 211 struct tree_context * local_tc=(struct tree_context *)data;
212#ifdef HAVE_TAGCACHE
208 bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB; 213 bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB;
209 if (id3db) { 214 if (id3db) {
210 *icon = (ICON)tagtree_get_icon(&tc); 215 *icon = (ICON)tagtree_get_icon(&tc);
211 } 216 }
212 else { 217 else
218#endif
219 {
213 struct entry* dc = local_tc->dircache; 220 struct entry* dc = local_tc->dircache;
214 struct entry* e = &dc[selected_item]; 221 struct entry* e = &dc[selected_item];
215 *icon = (ICON)filetype_get_icon(e->attr); 222 *icon = (ICON)filetype_get_icon(e->attr);
@@ -304,8 +311,9 @@ int tree_get_file_position(char * filename)
304 */ 311 */
305static int update_dir(void) 312static int update_dir(void)
306{ 313{
314 bool changed = false;
315#ifdef HAVE_TAGCACHE
307 bool id3db = *tc.dirfilter == SHOW_ID3DB; 316 bool id3db = *tc.dirfilter == SHOW_ID3DB;
308 bool changed = false;
309 /* Checks for changes */ 317 /* Checks for changes */
310 if (id3db) { 318 if (id3db) {
311 if (tc.currtable != lasttable || 319 if (tc.currtable != lasttable ||
@@ -322,7 +330,9 @@ static int update_dir(void)
322 changed = true; 330 changed = true;
323 } 331 }
324 } 332 }
325 else { 333 else
334#endif
335 {
326 /* if the tc.currdir has been changed, reload it ...*/ 336 /* if the tc.currdir has been changed, reload it ...*/
327 if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir) { 337 if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir) {
328 338
@@ -345,12 +355,17 @@ static int update_dir(void)
345 } 355 }
346 if (changed) 356 if (changed)
347 { 357 {
348 if(!id3db && (tc.dirfull || 358 if(
359#ifdef HAVE_TAGCACHE
360 !id3db &&
361#endif
362 (tc.dirfull ||
349 tc.filesindir == global_settings.max_files_in_dir) ) 363 tc.filesindir == global_settings.max_files_in_dir) )
350 { 364 {
351 gui_syncsplash(HZ, true, str(LANG_SHOWDIR_BUFFER_FULL)); 365 gui_syncsplash(HZ, true, str(LANG_SHOWDIR_BUFFER_FULL));
352 } 366 }
353 } 367 }
368#ifdef HAVE_TAGCACHE
354 if (id3db) 369 if (id3db)
355 { 370 {
356 if (global_settings.show_path_in_browser == SHOW_PATH_FULL 371 if (global_settings.show_path_in_browser == SHOW_PATH_FULL
@@ -366,6 +381,7 @@ static int update_dir(void)
366 } 381 }
367 } 382 }
368 else 383 else
384#endif
369 { 385 {
370 if (global_settings.show_path_in_browser == SHOW_PATH_FULL) 386 if (global_settings.show_path_in_browser == SHOW_PATH_FULL)
371 { 387 {
@@ -417,7 +433,9 @@ static int update_dir(void)
417/* load tracks from specified directory to resume play */ 433/* load tracks from specified directory to resume play */
418void resume_directory(const char *dir) 434void resume_directory(const char *dir)
419{ 435{
436#ifdef HAVE_TAGCACHE
420 bool id3db = *tc.dirfilter == SHOW_ID3DB; 437 bool id3db = *tc.dirfilter == SHOW_ID3DB;
438#endif
421 439
422 if (ft_load(&tc, dir) < 0) 440 if (ft_load(&tc, dir) < 0)
423 return; 441 return;
@@ -425,8 +443,10 @@ void resume_directory(const char *dir)
425 443
426 ft_build_playlist(&tc, 0); 444 ft_build_playlist(&tc, 0);
427 445
446#ifdef HAVE_TAGCACHE
428 if (id3db) 447 if (id3db)
429 tagtree_load(&tc); 448 tagtree_load(&tc);
449#endif
430} 450}
431 451
432/* Returns the current working directory and also writes cwd to buf if 452/* Returns the current working directory and also writes cwd to buf if
@@ -504,10 +524,12 @@ void set_current_file(char *path)
504 char *name; 524 char *name;
505 int i; 525 int i;
506 526
527#ifdef HAVE_TAGCACHE
507 /* in ID3DB mode it is a bad idea to call this function */ 528 /* in ID3DB mode it is a bad idea to call this function */
508 /* (only happens with `follow playlist') */ 529 /* (only happens with `follow playlist') */
509 if( *tc.dirfilter == SHOW_ID3DB ) 530 if( *tc.dirfilter == SHOW_ID3DB )
510 return; 531 return;
532#endif
511 533
512 /* separate directory from filename */ 534 /* separate directory from filename */
513 /* gets the directory's name and put it into tc.currdir */ 535 /* gets the directory's name and put it into tc.currdir */
@@ -552,6 +574,7 @@ void set_current_file(char *path)
552 } 574 }
553} 575}
554 576
577#ifdef HAVE_TAGCACHE
555static bool check_changed_id3mode(bool currmode) 578static bool check_changed_id3mode(bool currmode)
556{ 579{
557 if (currmode != (global_settings.dirfilter == SHOW_ID3DB)) { 580 if (currmode != (global_settings.dirfilter == SHOW_ID3DB)) {
@@ -571,6 +594,8 @@ static bool check_changed_id3mode(bool currmode)
571 } 594 }
572 return currmode; 595 return currmode;
573} 596}
597#endif
598
574/* main loop, handles key events */ 599/* main loop, handles key events */
575static bool dirbrowse(void) 600static bool dirbrowse(void)
576{ 601{
@@ -586,11 +611,13 @@ static bool dirbrowse(void)
586 long thumbnail_time = -1; /* for delaying a thumbnail */ 611 long thumbnail_time = -1; /* for delaying a thumbnail */
587 612
588 char* currdir = tc.currdir; /* just a shortcut */ 613 char* currdir = tc.currdir; /* just a shortcut */
614#ifdef HAVE_TAGCACHE
589 bool id3db = *tc.dirfilter == SHOW_ID3DB; 615 bool id3db = *tc.dirfilter == SHOW_ID3DB;
590 616
591 if (id3db) 617 if (id3db)
592 curr_context=CONTEXT_ID3DB; 618 curr_context=CONTEXT_ID3DB;
593 else 619 else
620#endif
594 curr_context=CONTEXT_TREE; 621 curr_context=CONTEXT_TREE;
595 tc.selected_item = 0; 622 tc.selected_item = 0;
596 tc.dirlevel=0; 623 tc.dirlevel=0;
@@ -659,7 +686,11 @@ static bool dirbrowse(void)
659 if ( numentries == 0 ) 686 if ( numentries == 0 )
660 break; 687 break;
661 688
689#ifdef HAVE_TAGCACHE
662 switch (id3db?tagtree_enter(&tc):ft_enter(&tc)) 690 switch (id3db?tagtree_enter(&tc):ft_enter(&tc))
691#else
692 switch (ft_enter(&tc))
693#endif
663 { 694 {
664 case 1: reload_dir = true; break; 695 case 1: reload_dir = true; break;
665 case 2: start_wps = true; break; 696 case 2: start_wps = true; break;
@@ -677,10 +708,12 @@ static bool dirbrowse(void)
677 /* if we are in /, nothing to do */ 708 /* if we are in /, nothing to do */
678 if (tc.dirlevel == 0 && !strcmp(currdir,"/")) 709 if (tc.dirlevel == 0 && !strcmp(currdir,"/"))
679 break; 710 break;
680 711
712#ifdef HAVE_TAGCACHE
681 if (id3db) 713 if (id3db)
682 tagtree_exit(&tc); 714 tagtree_exit(&tc);
683 else 715 else
716#endif
684 if (ft_exit(&tc) == 3) 717 if (ft_exit(&tc) == 3)
685 exit_func = true; 718 exit_func = true;
686 719
@@ -737,9 +770,11 @@ static bool dirbrowse(void)
737 reload_dir = true; 770 reload_dir = true;
738 restore = true; 771 restore = true;
739 772
773#ifdef HAVE_TAGCACHE
740 id3db = check_changed_id3mode(id3db); 774 id3db = check_changed_id3mode(id3db);
741 if(id3db) 775 if(id3db)
742 reload_dir = true; 776 reload_dir = true;
777#endif
743 } 778 }
744 else /* use it as a quick exit instead */ 779 else /* use it as a quick exit instead */
745 exit_func = true; 780 exit_func = true;
@@ -769,8 +804,10 @@ static bool dirbrowse(void)
769 reload_dir = true; 804 reload_dir = true;
770 restore = true; 805 restore = true;
771 806
807#ifdef HAVE_TAGCACHE
772 id3db = check_changed_id3mode(id3db); 808 id3db = check_changed_id3mode(id3db);
773 reload_dir = true; 809 reload_dir = true;
810#endif
774 } 811 }
775 break; 812 break;
776#endif 813#endif
@@ -794,6 +831,7 @@ static bool dirbrowse(void)
794 if(!numentries) 831 if(!numentries)
795 onplay_result = onplay(NULL, 0, curr_context); 832 onplay_result = onplay(NULL, 0, curr_context);
796 else { 833 else {
834#ifdef HAVE_TAGCACHE
797 if (id3db) 835 if (id3db)
798 { 836 {
799 if (tagtree_get_attr(&tc) == TREE_ATTR_MPA) 837 if (tagtree_get_attr(&tc) == TREE_ATTR_MPA)
@@ -805,6 +843,7 @@ static bool dirbrowse(void)
805 attr = ATTR_DIRECTORY; 843 attr = ATTR_DIRECTORY;
806 } 844 }
807 else 845 else
846#endif
808 { 847 {
809 attr = dircache[tc.selected_item].attr; 848 attr = dircache[tc.selected_item].attr;
810 849
@@ -843,12 +882,14 @@ static bool dirbrowse(void)
843 int attr; 882 int attr;
844 char* name; 883 char* name;
845 884
885#ifdef HAVE_TAGCACHE
846 if (id3db) 886 if (id3db)
847 { 887 {
848 attr = tagtree_get_attr(&tc); 888 attr = tagtree_get_attr(&tc);
849 name = tagtree_get_entry(&tc, lasti)->name; 889 name = tagtree_get_entry(&tc, lasti)->name;
850 } 890 }
851 else 891 else
892#endif
852 { 893 {
853 attr = dircache[lasti].attr; 894 attr = dircache[lasti].attr;
854 name = dircache[lasti].name; 895 name = dircache[lasti].name;
@@ -880,7 +921,9 @@ static bool dirbrowse(void)
880 921
881#ifdef HAVE_HOTSWAP 922#ifdef HAVE_HOTSWAP
882 case SYS_FS_CHANGED: 923 case SYS_FS_CHANGED:
924#ifdef HAVE_TAGCACHE
883 if (!id3db) 925 if (!id3db)
926#endif
884 reload_dir = true; 927 reload_dir = true;
885 /* The 'dir no longer valid' situation will be caught later 928 /* The 'dir no longer valid' situation will be caught later
886 * by checking the showdir() result. */ 929 * by checking the showdir() result. */
@@ -916,13 +959,17 @@ static bool dirbrowse(void)
916 reload_dir = true; 959 reload_dir = true;
917#ifdef HAVE_HOTSWAP 960#ifdef HAVE_HOTSWAP
918 else 961 else
962#ifdef HAVE_TAGCACHE
919 if (!id3db) /* Try reload to catch 'no longer valid' case. */ 963 if (!id3db) /* Try reload to catch 'no longer valid' case. */
964#endif
920 reload_dir = true; 965 reload_dir = true;
921#endif 966#endif
922#ifdef HAVE_LCD_COLOR 967#ifdef HAVE_LCD_COLOR
923 show_main_backdrop(); 968 show_main_backdrop();
924#endif 969#endif
970#ifdef HAVE_TAGCACHE
925 id3db = check_changed_id3mode(id3db); 971 id3db = check_changed_id3mode(id3db);
972#endif
926 restore = true; 973 restore = true;
927 start_wps=false; 974 start_wps=false;
928 } 975 }
@@ -985,12 +1032,14 @@ static bool dirbrowse(void)
985 thumbnail_time = -1; /* Cancel whatever we were 1032 thumbnail_time = -1; /* Cancel whatever we were
986 about to say */ 1033 about to say */
987 1034
1035#ifdef HAVE_TAGCACHE
988 if (id3db) 1036 if (id3db)
989 { 1037 {
990 attr = tagtree_get_attr(&tc); 1038 attr = tagtree_get_attr(&tc);
991 name = tagtree_get_entry(&tc, tc.selected_item)->name; 1039 name = tagtree_get_entry(&tc, tc.selected_item)->name;
992 } 1040 }
993 else 1041 else
1042#endif
994 { 1043 {
995 attr = dircache[tc.selected_item].attr; 1044 attr = dircache[tc.selected_item].attr;
996 name = dircache[tc.selected_item].name; 1045 name = dircache[tc.selected_item].name;
@@ -1380,7 +1429,9 @@ void ft_play_filename(char *dir, char *file)
1380void tree_flush(void) 1429void tree_flush(void)
1381{ 1430{
1382 scrobbler_shutdown(); 1431 scrobbler_shutdown();
1432#ifdef HAVE_TAGCACHE
1383 tagcache_shutdown(); 1433 tagcache_shutdown();
1434#endif
1384 playlist_shutdown(); 1435 playlist_shutdown();
1385 1436
1386#ifdef HAVE_TC_RAMCACHE 1437#ifdef HAVE_TC_RAMCACHE
@@ -1440,6 +1491,8 @@ void tree_restore(void)
1440 } 1491 }
1441 } 1492 }
1442#endif 1493#endif
1494#ifdef HAVE_TAGCACHE
1443 tagcache_start_scan(); 1495 tagcache_start_scan();
1496#endif
1444 scrobbler_init(); 1497 scrobbler_init();
1445} 1498}