diff --git a/apps/filetree.c b/apps/filetree.c index 4c48710797..088d68ac1e 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -63,7 +63,7 @@ int ft_build_playlist(struct tree_context* c, int start_index) for(i = 0;i < c->filesindir;i++) { - if((dircache[i].attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) + if((dircache[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) { DEBUGF("Adding %s\n", dircache[i].name); if (playlist_add(dircache[i].name) < 0) @@ -101,11 +101,11 @@ static void check_file_thumbnails(struct tree_context* c) &dircache[i].name[strlen(dircache[i].name) - strlen(file_thumbnail_ext)])) { /* no .talk file */ - dircache[i].attr &= ~TREE_ATTR_THUMBNAIL; /* clear */ + dircache[i].attr &= ~FILE_ATTR_THUMBNAIL; /* clear */ } else { /* .talk file, we later let them speak themselves */ - dircache[i].attr |= TREE_ATTR_THUMBNAIL; /* set */ + dircache[i].attr |= FILE_ATTR_THUMBNAIL; /* set */ } } @@ -130,7 +130,7 @@ static void check_file_thumbnails(struct tree_context* c) { if (!strcasecmp(dircache[i].name, (char *)entry->d_name)) { /* match */ - dircache[i].attr |= TREE_ATTR_THUMBNAIL; /* set the flag */ + dircache[i].attr |= FILE_ATTR_THUMBNAIL; /* set the flag */ break; /* exit search loop, because we found it */ } } @@ -171,8 +171,8 @@ static int compare(const void* p1, const void* p2) { case 3: /* sort type */ { - int t1 = e1->attr & TREE_ATTR_MASK; - int t2 = e2->attr & TREE_ATTR_MASK; + int t1 = e1->attr & FILE_ATTR_MASK; + int t2 = e2->attr & FILE_ATTR_MASK; if (!t1) /* unknown type */ t1 = INT_MAX; /* gets a high number, to sort after known */ @@ -262,23 +262,23 @@ int ft_load(struct tree_context* c, const char* tempdir) /* filter out non-visible files */ if ((!(dptr->attr & ATTR_DIRECTORY) && ( (*c->dirfilter == SHOW_PLAYLIST && - (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_M3U) || + (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) || ((*c->dirfilter == SHOW_MUSIC && - (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_MPA) && - (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_M3U) || + (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) && + (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) || (*c->dirfilter == SHOW_SUPPORTED && !filetype_supported(dptr->attr)))) || - (*c->dirfilter == SHOW_WPS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_WPS) || + (*c->dirfilter == SHOW_WPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_WPS) || #ifdef HAVE_REMOTE_LCD - (*c->dirfilter == SHOW_RWPS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_RWPS) || + (*c->dirfilter == SHOW_RWPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RWPS) || #endif #if CONFIG_TUNER - (*c->dirfilter == SHOW_FMR && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_FMR) || + (*c->dirfilter == SHOW_FMR && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMR) || #endif - (*c->dirfilter == SHOW_CFG && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_CFG) || - (*c->dirfilter == SHOW_LNG && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_LNG) || - (*c->dirfilter == SHOW_MOD && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_MOD) || - (*c->dirfilter == SHOW_FONT && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_FONT) || - (*c->dirfilter == SHOW_PLUGINS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_ROCK)) + (*c->dirfilter == SHOW_CFG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_CFG) || + (*c->dirfilter == SHOW_LNG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LNG) || + (*c->dirfilter == SHOW_MOD && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_MOD) || + (*c->dirfilter == SHOW_FONT && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FONT) || + (*c->dirfilter == SHOW_PLUGINS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_ROCK)) { i--; continue; @@ -340,8 +340,8 @@ int ft_enter(struct tree_context* c) bool play = false; int start_index=0; - switch ( file->attr & TREE_ATTR_MASK ) { - case TREE_ATTR_M3U: + switch ( file->attr & FILE_ATTR_MASK ) { + case FILE_ATTR_M3U: if (global_settings.party_mode) { gui_syncsplash(HZ, str(LANG_PARTY_MODE)); break; @@ -374,7 +374,7 @@ int ft_enter(struct tree_context* c) } break; - case TREE_ATTR_MPA: + case FILE_ATTR_AUDIO: if (bookmark_autoload(c->currdir)) break; @@ -420,7 +420,7 @@ int ft_enter(struct tree_context* c) #if CONFIG_TUNER /* fmr preset file */ - case TREE_ATTR_FMR: + case FILE_ATTR_FMR: gui_syncsplash(0, str(LANG_WAIT)); @@ -448,7 +448,7 @@ int ft_enter(struct tree_context* c) /* wps config file */ - case TREE_ATTR_WPS: + case FILE_ATTR_WPS: gui_syncsplash(0, str(LANG_WAIT)); #if LCD_DEPTH > 1 unload_wps_backdrop(); @@ -460,7 +460,7 @@ int ft_enter(struct tree_context* c) #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) /* remote-wps config file */ - case TREE_ATTR_RWPS: + case FILE_ATTR_RWPS: gui_syncsplash(0, str(LANG_WAIT)); wps_data_load(gui_wps[1].data, buf, true); set_file(buf, (char *)global_settings.rwps_file, @@ -468,20 +468,20 @@ int ft_enter(struct tree_context* c) break; #endif - case TREE_ATTR_CFG: + case FILE_ATTR_CFG: gui_syncsplash(0, str(LANG_WAIT)); if (!settings_load_config(buf,true)) break; gui_syncsplash(HZ, str(LANG_SETTINGS_LOADED)); break; - case TREE_ATTR_BMARK: + case FILE_ATTR_BMARK: gui_syncsplash(0, str(LANG_WAIT)); bookmark_load(buf, false); reload_dir = true; break; - case TREE_ATTR_LNG: + case FILE_ATTR_LNG: gui_syncsplash(0, str(LANG_WAIT)); if(!lang_load(buf)) { set_file(buf, (char *)global_settings.lang_file, @@ -492,13 +492,13 @@ int ft_enter(struct tree_context* c) break; #ifdef HAVE_LCD_BITMAP - case TREE_ATTR_FONT: + case FILE_ATTR_FONT: gui_syncsplash(0, str(LANG_WAIT)); font_load(buf); set_file(buf, (char *)global_settings.font_file, MAX_FILENAME); break; - case TREE_ATTR_KBD: + case FILE_ATTR_KBD: gui_syncsplash(0, str(LANG_WAIT)); if (!load_kbd(buf)) gui_syncsplash(HZ, str(LANG_KEYBOARD_LOADED)); @@ -508,14 +508,14 @@ int ft_enter(struct tree_context* c) #ifndef SIMULATOR /* firmware file */ - case TREE_ATTR_MOD: + case FILE_ATTR_MOD: gui_syncsplash(0, str(LANG_WAIT)); rolo_load(buf); break; #endif /* plugin file */ - case TREE_ATTR_ROCK: + case FILE_ATTR_ROCK: if (global_settings.party_mode) { gui_syncsplash(HZ, str(LANG_PARTY_MODE)); break; @@ -534,7 +534,7 @@ int ft_enter(struct tree_context* c) } break; - case TREE_ATTR_CUE: + case FILE_ATTR_CUE: display_cuesheet_content(buf); break; diff --git a/apps/filetypes.c b/apps/filetypes.c index a4eac70374..0daae1b617 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -48,8 +48,66 @@ #define MAX_FILETYPES 48 #endif -/* number of bytes for the binary icon */ -#define ICON_LENGTH 6 +/* a table for the know file types */ +const struct filetype inbuilt_filetypes[] = { + { "mp3", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "mp2", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "mpa", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, +#if CONFIG_CODEC == SWCODEC + /* Temporary hack to allow playlist creation */ + { "mp1", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "ogg", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "wma", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "wav", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "flac",FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "ac3", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "a52", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "mpc", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "wv", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "m4a", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "m4b", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "mp4", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "shn", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "aif", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "aiff",FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "spx" ,FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "sid", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "adx", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "nsf", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "nsfe",FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "spc", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, +#endif + { "m3u", FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, + { "m3u8",FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, + { "cfg", FILE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG }, + { "wps", FILE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS }, +#ifdef HAVE_REMOTE_LCD + { "rwps",FILE_ATTR_RWPS, Icon_Wps, VOICE_EXT_RWPS }, +#endif +#if LCD_DEPTH > 1 + { "bmp", FILE_ATTR_BMP, Icon_Wps, VOICE_EXT_WPS }, +#endif +#if CONFIG_TUNER + { "fmr", FILE_ATTR_FMR, Icon_Preset, LANG_FMR }, +#endif + { "lng", FILE_ATTR_LNG, Icon_Language, LANG_LANGUAGE }, + { "rock",FILE_ATTR_ROCK,Icon_Plugin, VOICE_EXT_ROCK }, +#ifdef HAVE_LCD_BITMAP + { "fnt", FILE_ATTR_FONT,Icon_Font, VOICE_EXT_FONT }, + { "kbd", FILE_ATTR_KBD, Icon_Keyboard, VOICE_EXT_KBD }, +#endif + { "bmark",FILE_ATTR_BMARK, Icon_Bookmark, VOICE_EXT_BMARK }, + { "cue", FILE_ATTR_CUE, Icon_Bookmark, LANG_CUESHEET }, +#ifdef BOOTFILE_EXT + { BOOTFILE_EXT, FILE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ }, +#endif /* #ifndef SIMULATOR */ +}; + +void tree_get_filetypes(const struct filetype** types, int* count) +{ + *types = inbuilt_filetypes; + *count = sizeof(inbuilt_filetypes) / sizeof(*inbuilt_filetypes); +} /* mask for dynamic filetype info in attribute */ #define FILETYPES_MASK 0xFF00 @@ -155,17 +213,15 @@ static void rm_whitespaces(char* str) static void read_builtin_types(void) { - const struct filetype *types; - int count, i; - tree_get_filetypes(&types, &count); + int count = sizeof(inbuilt_filetypes)/sizeof(*inbuilt_filetypes), i; for(i=0; i>8; + filetypes[filetype_count].attr = inbuilt_filetypes[i].tree_attr>>8; if (filetypes[filetype_count].attr > heighest_attr) heighest_attr = filetypes[filetype_count].attr; - filetypes[filetype_count].icon = types[i].icon; + filetypes[filetype_count].icon = inbuilt_filetypes[i].icon; filetype_count++; } } @@ -247,7 +303,7 @@ int filetype_get_attr(const char* file) { if (filetypes[i].extension && !strcasecmp(extension, filetypes[i].extension)) - return (filetypes[i].attr<<8)&TREE_ATTR_MASK; + return (filetypes[i].attr<<8)&FILE_ATTR_MASK; } return 0; } diff --git a/apps/filetypes.h b/apps/filetypes.h index 182cb0da4e..a38b4bc000 100644 --- a/apps/filetypes.h +++ b/apps/filetypes.h @@ -21,13 +21,40 @@ #include #include -#include + +/* using attribute bits not used by FAT (FAT uses lower 7) */ +#define FILE_ATTR_THUMBNAIL 0x0080 /* corresponding .talk file exists */ +/* (this also reflects the sort order if by type) */ +#define FILE_ATTR_BMARK 0x0100 /* book mark file */ +#define FILE_ATTR_M3U 0x0200 /* playlist */ +#define FILE_ATTR_AUDIO 0x0300 /* audio file */ +#define FILE_ATTR_CFG 0x0400 /* config file */ +#define FILE_ATTR_WPS 0x0500 /* wps config file */ +#define FILE_ATTR_FONT 0x0600 /* font file */ +#define FILE_ATTR_LNG 0x0700 /* binary lang file */ +#define FILE_ATTR_ROCK 0x0800 /* binary rockbox plugin */ +#define FILE_ATTR_MOD 0x0900 /* firmware file */ +#define FILE_ATTR_RWPS 0x0A00 /* remote-wps config file */ +#define FILE_ATTR_BMP 0x0B00 /* backdrop bmp file */ +#define FILE_ATTR_KBD 0x0C00 /* keyboard file */ +#define FILE_ATTR_FMR 0x0D00 /* preset file */ +#define FILE_ATTR_CUE 0x0E00 /* cuesheet file */ +#define FILE_ATTR_MASK 0xFF00 /* which bits tree.c uses for file types */ + +struct filetype { + char* extension; + int tree_attr; + int icon; + int voiceclip; +}; +void tree_get_filetypes(const struct filetype**, int*); + /* init the filetypes structs. uses audio buffer for storage, so call early in init... */ void filetype_init(void); void read_viewer_theme_file(void); -/* Return the attribute (TREE_ATTR_*) of the file */ +/* Return the attribute (FILE_ATTR_*) of the file */ int filetype_get_attr(const char* file); int filetype_get_icon(int attr); /* return the plugin filename associated with the file */ diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 6bf584fc6a..0819d122f5 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -28,7 +28,7 @@ #include "backlight.h" #include "action.h" #include "kernel.h" -#include "tree.h" +#include "filetypes.h" #include "debug.h" #include "sprintf.h" #include "settings.h" @@ -236,7 +236,7 @@ long gui_wps_show(void) show_main_backdrop(); #endif action_signalscreenchange(); - if (onplay(wps_state.id3->path, TREE_ATTR_MPA, CONTEXT_WPS) + if (onplay(wps_state.id3->path, FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU) return GO_TO_ROOT; #if LCD_DEPTH > 1 diff --git a/apps/onplay.c b/apps/onplay.c index a92736385c..6aaa6e734f 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -171,7 +171,7 @@ static bool add_to_playlist(int position, bool queue) else #endif { - if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) + if ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) playlist_insert_track(NULL, selected_file, position, queue, true); else if (selected_file_attr & ATTR_DIRECTORY) { @@ -188,7 +188,7 @@ static bool add_to_playlist(int position, bool queue) playlist_insert_directory(NULL, selected_file, position, queue, recurse); } - else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U) + else if ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U) playlist_insert_playlist(NULL, selected_file, position, queue); } @@ -273,7 +273,7 @@ static bool playlist_options(void) int m, i=0, pstart=0, result; bool ret = false; - if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U && + if ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U && context == CONTEXT_TREE) { items[i].desc = ID2P(LANG_VIEW); @@ -355,7 +355,7 @@ static bool playlist_options(void) args[i].queue = false; i++; } - else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || + else if (((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) || (selected_file_attr & ATTR_DIRECTORY)) { items[i].desc = ID2P(LANG_INSERT); diff --git a/apps/playlist.c b/apps/playlist.c index 9d88e210f8..ba98648c2e 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -91,6 +91,7 @@ #include "dircache.h" #include "thread.h" #include "usb.h" +#include "filetypes.h" #ifdef HAVE_LCD_BITMAP #include "icons.h" #endif @@ -1536,7 +1537,7 @@ static int check_subdir_for_music(char *dir, char *subdir) { if (files[i].attr & ATTR_DIRECTORY) has_subdir = true; - else if ((files[i].attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) + else if ((files[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) { has_music = true; break; @@ -3568,7 +3569,7 @@ int playlist_directory_tracksearch(const char* dirname, bool recurse, else continue; } - else if ((files[i].attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) + else if ((files[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) { snprintf(buf, sizeof(buf), "%s/%s", dirname, files[i].name); diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 1e3d523181..5ff2bddaab 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c @@ -37,6 +37,7 @@ #include "sprintf.h" #include "tree.h" #include "yesno.h" +#include "filetypes.h" #define PLAYLIST_CATALOG_CFG ROCKBOX_DIR "/playlist_catalog.config" #define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists" @@ -167,7 +168,7 @@ static int create_playlist_list(char** playlists, int num_items, for (i=0; i 0) result = 0; } - else if ((sel_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U) + else if ((sel_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U) { /* append playlist */ int f, fs, i; diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index b5f72cbfe5..eaca81e190 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -32,7 +32,7 @@ #include "menu.h" #include "plugin.h" #include "keyboard.h" -#include "tree.h" +#include "filetypes.h" #include "onplay.h" #include "talk.h" #include "misc.h" @@ -487,7 +487,7 @@ static int onplay_menu(int index) case 2: /* add to catalog */ case 3: /* add to a new one */ catalog_add_to_a_playlist(current_track->name, - TREE_ATTR_MPA, + FILE_ATTR_AUDIO, result==3 ); ret = 0; break; diff --git a/apps/tagtree.c b/apps/tagtree.c index 41db17b31a..405274c6bd 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -24,6 +24,7 @@ #include #include #include +#include "config.h" #include "system.h" #include "kernel.h" #include "splash.h" @@ -43,6 +44,7 @@ #include "playback.h" #include "yesno.h" #include "misc.h" +#include "filetypes.h" #define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" @@ -1669,13 +1671,13 @@ int tagtree_get_attr(struct tree_context* c) { case navibrowse: if (csi->tagorder[c->currextra] == tag_title) - attr = TREE_ATTR_MPA; + attr = FILE_ATTR_AUDIO; else attr = ATTR_DIRECTORY; break; case allsubentries: - attr = TREE_ATTR_MPA; + attr = FILE_ATTR_AUDIO; break; default: @@ -1690,7 +1692,7 @@ int tagtree_get_icon(struct tree_context* c) { int icon = Icon_Folder; - if (tagtree_get_attr(c) == TREE_ATTR_MPA) + if (tagtree_get_attr(c) == FILE_ATTR_AUDIO) icon = Icon_Audio; return icon; diff --git a/apps/tree.c b/apps/tree.c index 944f76840f..b847a7f112 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -85,60 +85,8 @@ #include "backdrop.h" #endif -/* a table for the know file types */ -const struct filetype filetypes[] = { - { "mp3", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "mp2", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "mpa", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, -#if CONFIG_CODEC == SWCODEC - /* Temporary hack to allow playlist creation */ - { "mp1", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "ogg", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "wma", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "wav", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "flac",TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "ac3", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "a52", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "mpc", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "wv", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "m4a", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "m4b", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "mp4", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "shn", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "aif", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "aiff",TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "spx" ,TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "sid", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "adx", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "nsf", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "nsfe", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, - { "spc", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, -#endif - { "m3u", TREE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, - { "m3u8", TREE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, - { "cfg", TREE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG }, - { "wps", TREE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS }, -#ifdef HAVE_REMOTE_LCD - { "rwps", TREE_ATTR_RWPS, Icon_Wps, VOICE_EXT_RWPS }, -#endif -#if LCD_DEPTH > 1 - { "bmp", TREE_ATTR_BMP, Icon_Wps, VOICE_EXT_WPS }, -#endif -#if CONFIG_TUNER - { "fmr", TREE_ATTR_FMR, Icon_Preset, LANG_FMR }, -#endif - { "lng", TREE_ATTR_LNG, Icon_Language, LANG_LANGUAGE }, - { "rock",TREE_ATTR_ROCK,Icon_Plugin, VOICE_EXT_ROCK }, -#ifdef HAVE_LCD_BITMAP - { "fnt", TREE_ATTR_FONT,Icon_Font, VOICE_EXT_FONT }, - { "kbd", TREE_ATTR_KBD, Icon_Keyboard, VOICE_EXT_KBD }, -#endif - { "bmark",TREE_ATTR_BMARK, Icon_Bookmark, VOICE_EXT_BMARK }, - { "cue", TREE_ATTR_CUE, Icon_Bookmark, LANG_CUESHEET }, -#ifdef BOOTFILE_EXT - { BOOTFILE_EXT, TREE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ }, -#endif /* #ifndef SIMULATOR */ -}; +static const struct filetype *filetypes; +static int filetypes_count; struct gui_synclist tree_lists; @@ -279,11 +227,7 @@ void browse_root(void) root_menu(); } -void tree_get_filetypes(const struct filetype** types, int* count) -{ - *types = filetypes; - *count = sizeof(filetypes) / sizeof(*filetypes); -} + struct tree_context* tree_get_context(void) { @@ -710,9 +654,9 @@ static int dirbrowse() #ifdef HAVE_TAGCACHE if (id3db) { - if (tagtree_get_attr(&tc) == TREE_ATTR_MPA) + if (tagtree_get_attr(&tc) == FILE_ATTR_AUDIO) { - attr = TREE_ATTR_MPA; + attr = FILE_ATTR_AUDIO; tagtree_get_filename(&tc, buf, sizeof(buf)); } else @@ -931,7 +875,7 @@ static int dirbrowse() case 1: /* files as numbers */ ft_play_filenumber( tc.selected_item-tc.dirsindir+1, - attr & TREE_ATTR_MASK); + attr & FILE_ATTR_MASK); break; case 2: /* files spelled */ @@ -941,7 +885,7 @@ static int dirbrowse() case 3: /* thumbnail clip */ /* "schedule" a thumbnail, to have a little delay */ - if (attr & TREE_ATTR_THUMBNAIL) + if (attr & FILE_ATTR_THUMBNAIL) thumbnail_time = current_tick + HOVER_DELAY; else /* spell the number as fallback */ @@ -1003,15 +947,15 @@ static bool add_dir(char* dirname, int len, int fd) } else { int x = strlen((char *)entry->d_name); - unsigned int i; + int i; char *cp = strrchr((char *)entry->d_name,'.'); if (cp) { cp++; /* add all supported audio files to playlists */ - for (i=0; i < sizeof(filetypes)/sizeof(struct filetype); i++) { - if (filetypes[i].tree_attr == TREE_ATTR_MPA) { + for (i=0; i < filetypes_count; i++) { + if (filetypes[i].tree_attr == FILE_ATTR_AUDIO) { if (!strcasecmp(cp, filetypes[i].extension)) { char buf[8]; int i; @@ -1147,6 +1091,7 @@ void tree_init(void) tc.dircache_size = max_files * sizeof(struct entry); tc.dircache = buffer_alloc(tc.dircache_size); + tree_get_filetypes(&filetypes, &filetypes_count); } void bookmark_play(char *resume_file, int index, int offset, int seed, @@ -1230,9 +1175,9 @@ void bookmark_play(char *resume_file, int index, int offset, int seed, static int ft_play_filenumber(int pos, int attr) { /* try to find a voice ID for the extension, if known */ - unsigned int j; + int j; int ext_id = -1; /* default to none */ - for (j=0; j