diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 631f027..d9ca14f 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -99,7 +99,7 @@ #include "pcf50605.h" #endif #include "appevents.h" -#include "debug-target.h" +//#include "debug-target.h" #if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \ || (CONFIG_CPU == AS3525 && defined(CONFIG_CHARGING)) \ diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 9034130..89c6faa 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -12647,3 +12647,31 @@ *: "Start File Browser at root" + + id: LANG_SET_AS_START_TAGCACHE + desc: used in the onplay menu to set tagcache start directory + user: core + + *: "Start Database Scan Here" + + + *: "Start Database Scan Here" + + + *: "Start Database Scan Here" + + + + id: LANG_RESET_START_TAGCACHE + desc: reset the tagcache start directory + user: core + + *: "Reset Database Root Directory" + + + *: "Reset Database Root Directory" + + + *: "Reset Database Root Directory" + + diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index 5de3a30..74ed764 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c @@ -80,12 +80,22 @@ MENUITEM_FUNCTION(tc_export, 0, ID2P(LANG_TAGCACHE_EXPORT), MENUITEM_FUNCTION(tc_import, 0, ID2P(LANG_TAGCACHE_IMPORT), (int(*)(void))tagtree_import, NULL, NULL, Icon_NOICON); +static int clear_start_tagcache(void) +{ + strcpy(global_settings.start_tagcache, DEFAULT_TAGCACHE_ROOT); + settings_save(); + splash(HZ, ID2P(LANG_RESET_DONE_CLEAR)); + return false; +} +MENUITEM_FUNCTION(clear_start_tagcache_item, 0, ID2P(LANG_RESET_START_TAGCACHE), + clear_start_tagcache, NULL, NULL, Icon_NOICON); MAKE_MENU(tagcache_menu, ID2P(LANG_TAGCACHE), 0, Icon_NOICON, #ifdef HAVE_TC_RAMCACHE &tagcache_ram, #endif &tagcache_autoupdate, &tc_init, &tc_update, &runtimedb, - &tc_export, &tc_import); + &tc_export, &tc_import, &clear_start_tagcache_item + ); #endif /* HAVE_TAGCACHE */ /* TAGCACHE MENU */ /***********************************/ diff --git a/apps/onplay.c b/apps/onplay.c index 1d59b34..54bfd40 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -1055,6 +1055,18 @@ static bool set_startdir(void) } MENUITEM_FUNCTION(set_startdir_item, 0, ID2P(LANG_SET_AS_START_DIR), set_startdir, NULL, clipboard_callback, Icon_file_view_menu); +#ifdef HAVE_TAGCACHE +static bool set_start_tagcache(void) +{ + snprintf(global_settings.start_tagcache, + sizeof(global_settings.start_tagcache), + "%s/", selected_file); + settings_save(); + return false; +} +MENUITEM_FUNCTION(set_start_tagcache_item, 0, ID2P(LANG_SET_AS_START_TAGCACHE), + set_start_tagcache, NULL, clipboard_callback, Icon_Audio); +#endif static int clipboard_callback(int action,const struct menu_item_ex *this_item) { @@ -1112,6 +1124,9 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item) #ifdef HAVE_RECORDING || this_item == &set_recdir_item #endif +#ifdef HAVE_TAGCACHE + || this_item == &set_start_tagcache_item +#endif ) return action; } @@ -1174,6 +1189,9 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), &set_recdir_item, #endif &set_startdir_item, &add_to_faves_item, +#ifdef HAVE_TAGCACHE + &set_start_tagcache_item, +#endif ); static int onplaymenu_callback(int action,const struct menu_item_ex *this_item) { diff --git a/apps/settings.h b/apps/settings.h index 20aee18..adfce0d 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -576,6 +576,7 @@ struct user_settings #endif bool tagcache_autoupdate; /* automatically keep tagcache in sync? */ bool runtimedb; /* runtime database active? */ + char start_tagcache[2*MAX_FILENAME+1]; #endif /* HAVE_TAGCACHE */ #if LCD_DEPTH > 1 diff --git a/apps/settings_list.c b/apps/settings_list.c index 2922bcd..79b84fa 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1259,6 +1259,8 @@ const struct settings_list settings[] = { #ifdef HAVE_TAGCACHE OFFON_SETTING(0, runtimedb, LANG_RUNTIMEDB_ACTIVE, false, "gather runtime data", NULL), + TEXT_SETTING(0, start_tagcache, "start tagcache", + DEFAULT_TAGCACHE_ROOT, NULL, NULL), #endif #if CONFIG_CODEC == SWCODEC diff --git a/apps/tagcache.c b/apps/tagcache.c index 39ed99f..fa4f159 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -83,6 +83,8 @@ #include "eeprom_settings.h" #endif +#define logf printf + #ifdef __PCTOOL__ #define yield() do { } while(0) #define sim_sleep(timeout) do { } while(0) @@ -4274,6 +4276,22 @@ void tagcache_screensync_enable(bool state) tc_stat.syncscreen = state; } +#if (CONFIG_PLATFORM&PLATFORM_SDL) +static char* tagcache_get_root() +{ + static char tagcache_root[MAX_PATH]; + char *from = global_settings.start_tagcache; + if (!strcmp(from, DEFAULT_TAGCACHE_ROOT)) + from = getenv("HOME"); + printf(">> %s\n\n", from); + snprintf(tagcache_root, sizeof(tagcache_root), "%s/", from); + return tagcache_root; +} +#else +#define tagcache_get_root() global_settings.start_tagcache +#endif + + void tagcache_build(const char *path) { struct tagcache_header header; @@ -4319,7 +4337,7 @@ void tagcache_build(const char *path) memset(&header, 0, sizeof(struct tagcache_header)); write(cachefd, &header, sizeof(struct tagcache_header)); - if (strcmp("/", path) != 0) + if (strcmp(tagcache_get_root(), path) != 0) strcpy(curpath, path); ret = check_dir(path, true); @@ -4462,11 +4480,11 @@ static void tagcache_thread(void) remove_files(); remove(get_user_file_path(TAGCACHE_FILE_TEMP, IS_FILE|NEED_WRITE, path, sizeof(path))); - tagcache_build("/"); + tagcache_build(tagcache_get_root()); break; case Q_UPDATE: - tagcache_build("/"); + tagcache_build(tagcache_get_root()); #ifdef HAVE_TC_RAMCACHE load_ramcache(); #endif @@ -4484,13 +4502,13 @@ static void tagcache_thread(void) { load_ramcache(); if (tc_stat.ramcache && global_settings.tagcache_autoupdate) - tagcache_build("/"); + tagcache_build(tagcache_get_root()); } else #endif if (global_settings.tagcache_autoupdate) { - tagcache_build("/"); + tagcache_build(tagcache_get_root()); /* This will be very slow unless dircache is enabled or target is flash based, but do it anyway for diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h index cd87888..f3635f8 100644 --- a/firmware/export/rbpaths.h +++ b/firmware/export/rbpaths.h @@ -119,6 +119,17 @@ extern const char* get_user_file_path(const char *path, #define RECPRESETS_DIR ROCKBOX_DIR "/recpresets" #define FMPRESET_PATH ROCKBOX_DIR "/fmpresets" +#ifdef APPLICATION + #if (CONFIG_PLATFORM & PLATFORM_ANDROID) + #define DEFAULT_TAGCACHE_ROOT "/sdcard" + #else + #define DEFAULT_TAGCACHE_ROOT "~/" + #endif +#else + #define DEFAULT_TAGCACHE_ROOT "/" +#endif + + #define DIRCACHE_FILE ROCKBOX_DIR "/dircache.dat" #define CODEPAGE_DIR ROCKBOX_DIR "/codepages"