1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Robert Bieber
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "tag_table.h"
25 #define BAR_PARAMS "*|iiiiN"
26 /* The tag definition table */
27 struct tag_info legal_tags
[] =
29 { SKIN_TOKEN_ALIGN_CENTER
, "ac", "" },
30 { SKIN_TOKEN_ALIGN_LEFT
, "al", "" },
31 { SKIN_TOKEN_ALIGN_LEFT_RTL
, "aL", "" },
32 { SKIN_TOKEN_ALIGN_RIGHT
, "ar", "" },
33 { SKIN_TOKEN_ALIGN_RIGHT_RTL
, "aR", "" },
34 { SKIN_TOKEN_ALIGN_LANGDIRECTION
, "ax", "" },
36 { SKIN_TOKEN_BATTERY_PERCENT
, "bl" , BAR_PARAMS
},
37 { SKIN_TOKEN_BATTERY_VOLTS
, "bv", "" },
38 { SKIN_TOKEN_BATTERY_TIME
, "bt", "" },
39 { SKIN_TOKEN_BATTERY_SLEEPTIME
, "bs", "" },
40 { SKIN_TOKEN_BATTERY_CHARGING
, "bc", "" },
41 { SKIN_TOKEN_BATTERY_CHARGER_CONNECTED
, "bp", "" },
42 { SKIN_TOKEN_USB_POWERED
, "bu", "" },
45 { SKIN_TOKEN_RTC_PRESENT
, "cc", "" },
46 { SKIN_TOKEN_RTC_DAY_OF_MONTH
, "cd", "" },
47 { SKIN_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
, "ce", "" },
48 { SKIN_TOKEN_RTC_12HOUR_CFG
, "cf", "" },
49 { SKIN_TOKEN_RTC_HOUR_24_ZERO_PADDED
, "cH", "" },
50 { SKIN_TOKEN_RTC_HOUR_24
, "ck", "" },
51 { SKIN_TOKEN_RTC_HOUR_12_ZERO_PADDED
, "cI", "" },
52 { SKIN_TOKEN_RTC_HOUR_12
, "cl", "" },
53 { SKIN_TOKEN_RTC_MONTH
, "cm", "" },
54 { SKIN_TOKEN_RTC_MINUTE
, "cM", "" },
55 { SKIN_TOKEN_RTC_SECOND
, "cS", "" },
56 { SKIN_TOKEN_RTC_YEAR_2_DIGITS
, "cy", "" },
57 { SKIN_TOKEN_RTC_YEAR_4_DIGITS
, "cY", "" },
58 { SKIN_TOKEN_RTC_AM_PM_UPPER
, "cP", "" },
59 { SKIN_TOKEN_RTC_AM_PM_LOWER
, "cp", "" },
60 { SKIN_TOKEN_RTC_WEEKDAY_NAME
, "ca", "" },
61 { SKIN_TOKEN_RTC_MONTH_NAME
, "cb", "" },
62 { SKIN_TOKEN_RTC_DAY_OF_WEEK_START_MON
, "cu", "" },
63 { SKIN_TOKEN_RTC_DAY_OF_WEEK_START_SUN
, "cw", "" },
65 { SKIN_TOKEN_FILE_BITRATE
, "fb", "" },
66 { SKIN_TOKEN_FILE_CODEC
, "fc", "" },
67 { SKIN_TOKEN_FILE_FREQUENCY
, "ff", "" },
68 { SKIN_TOKEN_FILE_FREQUENCY_KHZ
, "fk", "" },
69 { SKIN_TOKEN_FILE_NAME_WITH_EXTENSION
, "fm", "" },
70 { SKIN_TOKEN_FILE_NAME
, "fn", "" },
71 { SKIN_TOKEN_FILE_PATH
, "fp", "" },
72 { SKIN_TOKEN_FILE_SIZE
, "fs", "" },
73 { SKIN_TOKEN_FILE_VBR
, "fv", "" },
74 { SKIN_TOKEN_FILE_DIRECTORY
, "d" , "I" },
76 { SKIN_TOKEN_FILE_BITRATE
, "Fb", "" },
77 { SKIN_TOKEN_FILE_CODEC
, "Fc", "" },
78 { SKIN_TOKEN_FILE_FREQUENCY
, "Ff", "" },
79 { SKIN_TOKEN_FILE_FREQUENCY_KHZ
, "Fk", "" },
80 { SKIN_TOKEN_FILE_NAME_WITH_EXTENSION
, "Fm", "" },
81 { SKIN_TOKEN_FILE_NAME
, "Fn", "" },
82 { SKIN_TOKEN_FILE_PATH
, "Fp", "" },
83 { SKIN_TOKEN_FILE_SIZE
, "Fs", "" },
84 { SKIN_TOKEN_FILE_VBR
, "Fv", "" },
85 { SKIN_TOKEN_FILE_DIRECTORY
, "D" , "I" },
88 { SKIN_TOKEN_METADATA_ARTIST
, "ia", "" },
89 { SKIN_TOKEN_METADATA_COMPOSER
, "ic", "" },
90 { SKIN_TOKEN_METADATA_ALBUM
, "id", "" },
91 { SKIN_TOKEN_METADATA_ALBUM_ARTIST
, "iA", "" },
92 { SKIN_TOKEN_METADATA_GROUPING
, "iG", "" },
93 { SKIN_TOKEN_METADATA_GENRE
, "ig", "" },
94 { SKIN_TOKEN_METADATA_DISC_NUMBER
, "ik", "" },
95 { SKIN_TOKEN_METADATA_TRACK_NUMBER
, "in", "" },
96 { SKIN_TOKEN_METADATA_TRACK_TITLE
, "it", "" },
97 { SKIN_TOKEN_METADATA_VERSION
, "iv", "" },
98 { SKIN_TOKEN_METADATA_YEAR
, "iy", "" },
99 { SKIN_TOKEN_METADATA_COMMENT
, "iC", "" },
101 { SKIN_TOKEN_METADATA_ARTIST
, "Ia", "" },
102 { SKIN_TOKEN_METADATA_COMPOSER
, "Ic", "" },
103 { SKIN_TOKEN_METADATA_ALBUM
, "Id", "" },
104 { SKIN_TOKEN_METADATA_ALBUM_ARTIST
, "IA", "" },
105 { SKIN_TOKEN_METADATA_GROUPING
, "IG", "" },
106 { SKIN_TOKEN_METADATA_GENRE
, "Ig", "" },
107 { SKIN_TOKEN_METADATA_DISC_NUMBER
, "Ik", "" },
108 { SKIN_TOKEN_METADATA_TRACK_NUMBER
, "In", "" },
109 { SKIN_TOKEN_METADATA_TRACK_TITLE
, "It", "" },
110 { SKIN_TOKEN_METADATA_VERSION
, "Iv", "" },
111 { SKIN_TOKEN_METADATA_YEAR
, "Iy", "" },
112 { SKIN_TOKEN_METADATA_COMMENT
, "IC", "" },
114 { SKIN_TOKEN_SOUND_PITCH
, "Sp", "" },
115 { SKIN_TOKEN_SOUND_SPEED
, "Ss", "" },
117 { SKIN_TOKEN_VLED_HDD
, "lh", "" },
119 { SKIN_TOKEN_MAIN_HOLD
, "mh", "" },
120 { SKIN_TOKEN_REMOTE_HOLD
, "mr", "" },
121 { SKIN_TOKEN_REPEAT_MODE
, "mm", "" },
122 { SKIN_TOKEN_PLAYBACK_STATUS
, "mp", "" },
123 { SKIN_TOKEN_BUTTON_VOLUME
, "mv", "|S" },
125 { SKIN_TOKEN_PEAKMETER
, "pm", "" },
126 { SKIN_TOKEN_PLAYER_PROGRESSBAR
, "pf", "" },
127 { SKIN_TOKEN_PROGRESSBAR
, "pb" , BAR_PARAMS
},
128 { SKIN_TOKEN_VOLUME
, "pv" , BAR_PARAMS
},
130 { SKIN_TOKEN_TRACK_ELAPSED_PERCENT
, "px", "" },
131 { SKIN_TOKEN_TRACK_TIME_ELAPSED
, "pc", "" },
132 { SKIN_TOKEN_TRACK_TIME_REMAINING
, "pr", "" },
133 { SKIN_TOKEN_TRACK_LENGTH
, "pt", "" },
134 { SKIN_TOKEN_TRACK_STARTING
, "pS" , "|S"},
135 { SKIN_TOKEN_TRACK_ENDING
, "pE" , "|S"},
136 { SKIN_TOKEN_PLAYLIST_POSITION
, "pp", "" },
137 { SKIN_TOKEN_PLAYLIST_ENTRIES
, "pe", "" },
138 { SKIN_TOKEN_PLAYLIST_NAME
, "pn", "" },
139 { SKIN_TOKEN_PLAYLIST_SHUFFLE
, "ps", "" },
141 { SKIN_TOKEN_DATABASE_PLAYCOUNT
, "rp", "" },
142 { SKIN_TOKEN_DATABASE_RATING
, "rr", "" },
143 { SKIN_TOKEN_DATABASE_AUTOSCORE
, "ra", "" },
145 { SKIN_TOKEN_REPLAYGAIN
, "rg", "" },
146 { SKIN_TOKEN_CROSSFADE
, "xf", "" },
148 { SKIN_TOKEN_HAVE_TUNER
, "tp", "" },
149 { SKIN_TOKEN_TUNER_TUNED
, "tt", "" },
150 { SKIN_TOKEN_TUNER_SCANMODE
, "tm", "" },
151 { SKIN_TOKEN_TUNER_STEREO
, "ts", "" },
152 { SKIN_TOKEN_TUNER_MINFREQ
, "ta", "" },
153 { SKIN_TOKEN_TUNER_MAXFREQ
, "tb", "" },
154 { SKIN_TOKEN_TUNER_CURFREQ
, "tf", "" },
155 { SKIN_TOKEN_PRESET_ID
, "Ti", "" },
156 { SKIN_TOKEN_PRESET_NAME
, "Tn", "" },
157 { SKIN_TOKEN_PRESET_FREQ
, "Tf", "" },
158 { SKIN_TOKEN_PRESET_COUNT
, "Tc", "" },
159 { SKIN_TOKEN_HAVE_RDS
, "tx", "" },
160 { SKIN_TOKEN_RDS_NAME
, "ty", "" },
161 { SKIN_TOKEN_RDS_TEXT
, "tz", "" },
163 { SKIN_TOKEN_SUBLINE_SCROLL
, "s", "" },
164 { SKIN_TOKEN_SUBLINE_TIMEOUT
, "t" , "S" },
166 { SKIN_TOKEN_ENABLE_THEME
, "we", "\n" },
167 { SKIN_TOKEN_DISABLE_THEME
, "wd", "\n" },
168 { SKIN_TOKEN_DRAW_INBUILTBAR
, "wi", "\n" },
170 { SKIN_TOKEN_IMAGE_PRELOAD
, "xl", "SFII|I\n" },
171 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY
, "xd", "S" },
172 { SKIN_TOKEN_IMAGE_PRELOAD
, "x", "SFII\n" },
174 { SKIN_TOKEN_LOAD_FONT
, "Fl" , "IF\n"},
175 { SKIN_TOKEN_ALBUMART_LOAD
, "Cl" , "IIII|ss\n"},
176 { SKIN_TOKEN_ALBUMART_DISPLAY
, "Cd" , ""},
177 { SKIN_TOKEN_ALBUMART_FOUND
, "C" , ""},
179 { SKIN_TOKEN_VIEWPORT_ENABLE
, "Vd" , "S"},
180 { SKIN_TOKEN_UIVIEWPORT_ENABLE
, "VI" , "S"},
182 { SKIN_TOKEN_VIEWPORT_CUSTOMLIST
, "Vp" , "ICC\n"},
183 { SKIN_TOKEN_LIST_TITLE_TEXT
, "Lt" , ""},
184 { SKIN_TOKEN_LIST_TITLE_ICON
, "Li" , ""},
186 { SKIN_TOKEN_VIEWPORT_FGCOLOUR
, "Vf" , "S"},
187 { SKIN_TOKEN_VIEWPORT_BGCOLOUR
, "Vb" , "S"},
189 { SKIN_TOKEN_VIEWPORT_CONDITIONAL
, "Vl" , "SIIiii"},
190 { SKIN_TOKEN_UIVIEWPORT_LOAD
, "Vi" , "sIIiii"},
191 { SKIN_TOKEN_VIEWPORT_LOAD
, "V" , "IIiii"},
193 { SKIN_TOKEN_IMAGE_BACKDROP
, "X" , "f\n"},
195 { SKIN_TOKEN_SETTING
, "St" , "S"},
196 { SKIN_TOKEN_TRANSLATEDSTRING
, "Sx" , "S"},
197 { SKIN_TOKEN_LANG_IS_RTL
, "Sr" , ""},
199 { SKIN_TOKEN_LASTTOUCH
, "Tl" , "|S"},
200 { SKIN_TOKEN_CURRENT_SCREEN
, "cs", "" },
201 { SKIN_TOKEN_TOUCHREGION
, "T" , "IIiiS\n"},
203 { SKIN_TOKEN_HAVE_RECORDING
, "Rp" , ""},
204 { SKIN_TOKEN_IS_RECORDING
, "Rr" , ""},
205 { SKIN_TOKEN_REC_FREQ
, "Rf" , ""},
206 { SKIN_TOKEN_REC_ENCODER
, "Re" , ""},
207 { SKIN_TOKEN_REC_BITRATE
, "Rb" , ""},
208 { SKIN_TOKEN_REC_MONO
, "Rm" , ""},
209 { SKIN_TOKEN_REC_SECONDS
, "Rs" , ""},
210 { SKIN_TOKEN_REC_MINUTES
, "Rn" , ""},
211 { SKIN_TOKEN_REC_HOURS
, "Rh" , ""},
213 { SKIN_TOKEN_UNKNOWN
, "" , ""}
214 /* Keep this here to mark the end of the table */
217 /* A table of legal escapable characters */
218 char legal_escape_characters
[] = "%(,);#<|>";
221 * Just does a straight search through the tag table to find one by
224 struct tag_info
* find_tag(char* name
)
227 struct tag_info
* current
= legal_tags
;
230 * Continue searching so long as we have a non-empty name string
231 * and the name of the current element doesn't match the name
232 * we're searching for
235 while(strcmp(current
->name
, name
) && current
->name
[0] != '\0')
238 if(current
->name
[0] == '\0')
245 /* Searches through the legal escape characters string */
246 int find_escape_character(char lookup
)
248 char* current
= legal_escape_characters
;
249 while(*current
!= lookup
&& *current
!= '\0')
252 if(*current
== lookup
&& *current
)