diff options
Diffstat (limited to 'apps/filetypes.c')
-rw-r--r-- | apps/filetypes.c | 113 |
1 files changed, 42 insertions, 71 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c index 3ce3200e3c..d690b554fd 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -148,74 +148,42 @@ static const struct filetype inbuilt_filetypes[] = { | |||
148 | #endif | 148 | #endif |
149 | }; | 149 | }; |
150 | 150 | ||
151 | /* a table for the known file types voice clips */ | 151 | struct fileattr_icon_voice { |
152 | static const struct fileattr_voice inbuilt_attrvoices[] = { | 152 | int tree_attr; |
153 | { FILE_ATTR_AUDIO, VOICE_EXT_MPA }, | ||
154 | { FILE_ATTR_M3U, LANG_PLAYLIST }, | ||
155 | { FILE_ATTR_CFG, VOICE_EXT_CFG }, | ||
156 | { FILE_ATTR_WPS, VOICE_EXT_WPS }, | ||
157 | #ifdef HAVE_REMOTE_LCD | ||
158 | { FILE_ATTR_RWPS, VOICE_EXT_RWPS }, | ||
159 | #endif | ||
160 | #if CONFIG_TUNER | ||
161 | { FILE_ATTR_FMR, LANG_FMR }, | ||
162 | { FILE_ATTR_FMS, VOICE_EXT_FMS }, | ||
163 | #endif | ||
164 | { FILE_ATTR_LNG, LANG_LANGUAGE }, | ||
165 | { FILE_ATTR_ROCK, VOICE_EXT_ROCK }, | ||
166 | { FILE_ATTR_LUA, VOICE_EXT_ROCK }, | ||
167 | { FILE_ATTR_OPX, VOICE_EXT_ROCK }, | ||
168 | { FILE_ATTR_FONT, VOICE_EXT_FONT }, | ||
169 | { FILE_ATTR_KBD, VOICE_EXT_KBD }, | ||
170 | { FILE_ATTR_BMARK, VOICE_EXT_BMARK }, | ||
171 | { FILE_ATTR_CUE, VOICE_EXT_CUESHEET }, | ||
172 | { FILE_ATTR_SBS, VOICE_EXT_SBS }, | ||
173 | #ifdef HAVE_REMOTE_LCD | ||
174 | { FILE_ATTR_RSBS, VOICE_EXT_RSBS }, | ||
175 | #if CONFIG_TUNER | ||
176 | { FILE_ATTR_RFMS, VOICE_EXT_RFMS }, | ||
177 | #endif | ||
178 | #endif | ||
179 | #if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2) | ||
180 | { FILE_ATTR_MOD, VOICE_EXT_AJZ }, | ||
181 | #endif | ||
182 | }; | ||
183 | |||
184 | struct attr_icon { | ||
185 | uint16_t tree_attr; | ||
186 | uint16_t icon; | 153 | uint16_t icon; |
154 | uint16_t voiceclip; | ||
187 | }; | 155 | }; |
188 | 156 | ||
189 | /* a table for the known file type icons */ | 157 | /* a table for the known file types icons & voice clips */ |
190 | static const struct attr_icon inbuilt_attricons[] = { | 158 | static const struct fileattr_icon_voice inbuilt_attr_icons_voices[] = { |
191 | { FILE_ATTR_AUDIO, Icon_Audio}, | 159 | { FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, |
192 | { FILE_ATTR_M3U, Icon_Playlist}, | 160 | { FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, |
193 | { FILE_ATTR_CFG, Icon_Config}, | 161 | { FILE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG }, |
194 | { FILE_ATTR_WPS, Icon_Wps}, | 162 | { FILE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS }, |
195 | #ifdef HAVE_REMOTE_LCD | 163 | #ifdef HAVE_REMOTE_LCD |
196 | { FILE_ATTR_RWPS, Icon_Wps}, | 164 | {FILE_ATTR_RWPS, Icon_Wps, VOICE_EXT_RWPS }, |
197 | #endif | 165 | #endif |
198 | #if CONFIG_TUNER | 166 | #if CONFIG_TUNER |
199 | { FILE_ATTR_FMR, Icon_Preset}, | 167 | { FILE_ATTR_FMR, Icon_Preset, LANG_FMR }, |
200 | { FILE_ATTR_FMS, Icon_Wps}, | 168 | { FILE_ATTR_FMS, Icon_Wps, VOICE_EXT_FMS }, |
201 | #endif | 169 | #endif |
202 | { FILE_ATTR_LNG, Icon_Language}, | 170 | { FILE_ATTR_LNG, Icon_Language, LANG_LANGUAGE }, |
203 | { FILE_ATTR_ROCK, Icon_Plugin}, | 171 | { FILE_ATTR_ROCK, Icon_Plugin, VOICE_EXT_ROCK }, |
204 | { FILE_ATTR_LUA, Icon_Plugin}, | 172 | { FILE_ATTR_LUA, Icon_Plugin, VOICE_EXT_ROCK }, |
205 | { FILE_ATTR_OPX, Icon_Plugin}, | 173 | { FILE_ATTR_OPX, Icon_Plugin, VOICE_EXT_ROCK }, |
206 | { FILE_ATTR_FONT, Icon_Font}, | 174 | { FILE_ATTR_FONT, Icon_Font, VOICE_EXT_FONT }, |
207 | { FILE_ATTR_KBD, Icon_Keyboard}, | 175 | { FILE_ATTR_KBD, Icon_Keyboard, VOICE_EXT_KBD }, |
208 | { FILE_ATTR_BMARK, Icon_Bookmark}, | 176 | { FILE_ATTR_BMARK, Icon_Bookmark, VOICE_EXT_BMARK }, |
209 | { FILE_ATTR_CUE, Icon_Bookmark}, | 177 | { FILE_ATTR_CUE, Icon_Bookmark, VOICE_EXT_CUESHEET }, |
210 | { FILE_ATTR_SBS, Icon_Wps}, | 178 | { FILE_ATTR_SBS, Icon_Wps, VOICE_EXT_SBS }, |
211 | #ifdef HAVE_REMOTE_LCD | 179 | #ifdef HAVE_REMOTE_LCD |
212 | { FILE_ATTR_RSBS, Icon_Wps}, | 180 | { FILE_ATTR_RSBS, Icon_Wps, VOICE_EXT_RSBS }, |
213 | #if CONFIG_TUNER | 181 | #if CONFIG_TUNER |
214 | { FILE_ATTR_RFMS, Icon_Wps}, | 182 | { FILE_ATTR_RFMS, Icon_Wps, VOICE_EXT_RFMS }, |
215 | #endif | 183 | #endif |
216 | #endif | 184 | #endif |
217 | #if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2) | 185 | #if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2) |
218 | { FILE_ATTR_MOD, Icon_Firmware}, | 186 | { FILE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ }, |
219 | #endif | 187 | #endif |
220 | }; | 188 | }; |
221 | 189 | ||
@@ -225,22 +193,25 @@ void tree_get_filetypes(const struct filetype** types, int* count) | |||
225 | *count = sizeof(inbuilt_filetypes) / sizeof(*inbuilt_filetypes); | 193 | *count = sizeof(inbuilt_filetypes) / sizeof(*inbuilt_filetypes); |
226 | } | 194 | } |
227 | 195 | ||
228 | long tree_filetype_voiceclip(int attr) | 196 | long tree_get_filetype_voiceclip(int attr) |
229 | { | 197 | { |
230 | logf("%s attr %d", __func__, attr); | ||
231 | int j; | ||
232 | if (global_settings.talk_filetype) | 198 | if (global_settings.talk_filetype) |
233 | { | 199 | { |
234 | int count = sizeof(inbuilt_attrvoices)/sizeof(*inbuilt_attrvoices); | 200 | size_t count = ARRAY_SIZE(inbuilt_attr_icons_voices); |
235 | /* try to find a voice ID for the extension, if known */ | 201 | /* try to find a voice ID for the extension, if known */ |
236 | attr &= FILE_ATTR_MASK; /* file type */ | 202 | attr &= FILE_ATTR_MASK; /* file type */ |
237 | for (j=0; j<count; j++) | 203 | |
238 | if (attr == inbuilt_attrvoices[j].tree_attr) | 204 | for (size_t i = count - 1; i < count; i--) |
205 | { | ||
206 | if (attr == inbuilt_attr_icons_voices[i].tree_attr) | ||
239 | { | 207 | { |
240 | logf("%s attr %d id %d", __func__, attr, inbuilt_attrvoices[j].voiceclip); | 208 | logf("%s found attr %d id %d", __func__, attr, |
241 | return inbuilt_attrvoices[j].voiceclip; | 209 | inbuilt_attr_icons_voices[i].voiceclip); |
210 | return inbuilt_attr_icons_voices[i].voiceclip; | ||
242 | } | 211 | } |
212 | } | ||
243 | } | 213 | } |
214 | logf("%s not found attr %d", __func__, attr); | ||
244 | return -1; | 215 | return -1; |
245 | } | 216 | } |
246 | 217 | ||
@@ -489,10 +460,10 @@ static void rm_whitespaces(char* str) | |||
489 | 460 | ||
490 | static void read_builtin_types(void) | 461 | static void read_builtin_types(void) |
491 | { | 462 | { |
492 | int i,j, tree_attr; | 463 | int tree_attr; |
493 | int count = sizeof(inbuilt_filetypes)/sizeof(*inbuilt_filetypes); | 464 | size_t count = ARRAY_SIZE(inbuilt_filetypes); |
494 | int icon_count = sizeof(inbuilt_attricons)/sizeof(*inbuilt_attricons); | 465 | size_t icon_count = ARRAY_SIZE(inbuilt_attr_icons_voices); |
495 | for(i=0; i<count && (filetype_count < MAX_FILETYPES); i++) | 466 | for(size_t i = 0; (i < count) && (filetype_count < MAX_FILETYPES); i++) |
496 | { | 467 | { |
497 | filetypes[filetype_count].extension = inbuilt_filetypes[i].extension; | 468 | filetypes[filetype_count].extension = inbuilt_filetypes[i].extension; |
498 | filetypes[filetype_count].plugin = NULL; | 469 | filetypes[filetype_count].plugin = NULL; |
@@ -503,11 +474,11 @@ static void read_builtin_types(void) | |||
503 | highest_attr = filetypes[filetype_count].attr; | 474 | highest_attr = filetypes[filetype_count].attr; |
504 | 475 | ||
505 | filetypes[filetype_count].icon = unknown_file.icon; | 476 | filetypes[filetype_count].icon = unknown_file.icon; |
506 | for (j = 0; j < icon_count; j++) | 477 | for (size_t j = icon_count - 1; j < icon_count; j--) |
507 | { | 478 | { |
508 | if (tree_attr == inbuilt_attricons[j].tree_attr) | 479 | if (tree_attr == inbuilt_attr_icons_voices[j].tree_attr) |
509 | { | 480 | { |
510 | filetypes[filetype_count].icon = inbuilt_attricons[j].icon; | 481 | filetypes[filetype_count].icon = inbuilt_attr_icons_voices[j].icon; |
511 | break; | 482 | break; |
512 | } | 483 | } |
513 | } | 484 | } |