skin engine: New logical 'and' and 'or' tags to evaluate multiple tags in a single...
[maemo-rb.git] / lib / skin_parser / tag_table.h
blob35316b749e45e9069fc7878bfd60cc4216f81698
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 #ifndef TAG_TABLE_H
23 #define TAG_TABLE_H
25 #ifdef __cplusplus
26 extern "C"
28 #endif
30 #define MAX_TAG_LENGTH 4 /* includes the \0 */
31 #define MAX_TAG_PARAMS 12
33 #define NOBREAK 0x1 /* Flag to tell the renderer not to insert a line break */
34 #define FEATURE_TAG 0x2 /* Parse time conditional for feature checks (e.g HAVE_RTC) */
36 /* constants used in line_type and as refresh_mode for wps_refresh */
37 #define SKIN_REFRESH_SHIFT 16
38 #define SKIN_REFRESH_STATIC (1u<<SKIN_REFRESH_SHIFT) /* line doesn't change over time */
39 #define SKIN_REFRESH_DYNAMIC (1u<<(SKIN_REFRESH_SHIFT+1)) /* line may change (e.g. time flag) */
40 #define SKIN_REFRESH_SCROLL (1u<<(SKIN_REFRESH_SHIFT+2)) /* line scrolls */
41 #define SKIN_REFRESH_PLAYER_PROGRESS (1u<<(SKIN_REFRESH_SHIFT+3)) /* line contains a progress bar */
42 #define SKIN_REFRESH_PEAK_METER (1u<<(SKIN_REFRESH_SHIFT+4)) /* line contains a peak meter */
43 #define SKIN_REFRESH_STATUSBAR (1u<<(SKIN_REFRESH_SHIFT+5)) /* refresh statusbar */
44 #define SKIN_RTC_REFRESH (1u<<(SKIN_REFRESH_SHIFT+6)) /* refresh rtc, convert at parse time */
45 #define SKIN_REFRESH_ALL (0xffffu<<SKIN_REFRESH_SHIFT) /* to refresh all line types */
47 /* to refresh only those lines that change over time */
48 #define SKIN_REFRESH_NON_STATIC (SKIN_REFRESH_DYNAMIC| \
49 SKIN_REFRESH_PLAYER_PROGRESS| \
50 SKIN_REFRESH_PEAK_METER)
52 enum skin_token_type {
54 SKIN_TOKEN_NO_TOKEN,
55 SKIN_TOKEN_UNKNOWN,
57 /* Markers */
58 SKIN_TOKEN_CHARACTER,
59 SKIN_TOKEN_STRING,
60 SKIN_TOKEN_TRANSLATEDSTRING,
62 /* Alignment */
63 SKIN_TOKEN_ALIGN_LEFT,
64 SKIN_TOKEN_ALIGN_LEFT_RTL,
65 SKIN_TOKEN_ALIGN_CENTER,
66 SKIN_TOKEN_ALIGN_RIGHT,
67 SKIN_TOKEN_ALIGN_RIGHT_RTL,
68 SKIN_TOKEN_ALIGN_LANGDIRECTION,
71 /* Sublines */
72 SKIN_TOKEN_SUBLINE_TIMEOUT,
73 SKIN_TOKEN_SUBLINE_SCROLL,
75 /* Conditional */
76 SKIN_TOKEN_LOGICAL_IF,
77 SKIN_TOKEN_LOGICAL_AND,
78 SKIN_TOKEN_LOGICAL_OR,
79 SKIN_TOKEN_CONDITIONAL,
80 SKIN_TOKEN_CONDITIONAL_START,
81 SKIN_TOKEN_CONDITIONAL_OPTION,
82 SKIN_TOKEN_CONDITIONAL_END,
84 /* Viewport display */
85 SKIN_TOKEN_VIEWPORT_LOAD,
86 SKIN_TOKEN_VIEWPORT_CONDITIONAL,
87 SKIN_TOKEN_VIEWPORT_ENABLE,
88 SKIN_TOKEN_VIEWPORT_CUSTOMLIST,
89 SKIN_TOKEN_UIVIEWPORT_ENABLE,
90 SKIN_TOKEN_UIVIEWPORT_LOAD,
91 SKIN_TOKEN_VIEWPORT_FGCOLOUR,
92 SKIN_TOKEN_VIEWPORT_BGCOLOUR,
93 SKIN_TOKEN_VIEWPORT_TEXTSTYLE,
94 SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP,
96 /* Battery */
97 SKIN_TOKEN_BATTERY_PERCENT,
98 SKIN_TOKEN_BATTERY_PERCENTBAR,
99 SKIN_TOKEN_BATTERY_VOLTS,
100 SKIN_TOKEN_BATTERY_TIME,
101 SKIN_TOKEN_BATTERY_CHARGER_CONNECTED,
102 SKIN_TOKEN_BATTERY_CHARGING,
103 SKIN_TOKEN_BATTERY_SLEEPTIME,
104 SKIN_TOKEN_USB_POWERED,
106 /* Sound */
107 SKIN_TOKEN_SOUND_PITCH,
108 SKIN_TOKEN_SOUND_SPEED,
109 SKIN_TOKEN_REPLAYGAIN,
110 SKIN_TOKEN_CROSSFADE,
112 /* Time */
113 SKIN_TOKEN_RTC_PRESENT,
115 /* The begin/end values allow us to know if a token is an RTC one.
116 New RTC tokens should be added between the markers. */
118 SKIN_TOKENS_RTC_BEGIN, /* just the start marker, not an actual token */
120 SKIN_TOKEN_RTC_DAY_OF_MONTH,
121 SKIN_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED,
122 SKIN_TOKEN_RTC_12HOUR_CFG,
123 SKIN_TOKEN_RTC_HOUR_24_ZERO_PADDED,
124 SKIN_TOKEN_RTC_HOUR_24,
125 SKIN_TOKEN_RTC_HOUR_12_ZERO_PADDED,
126 SKIN_TOKEN_RTC_HOUR_12,
127 SKIN_TOKEN_RTC_MONTH,
128 SKIN_TOKEN_RTC_MINUTE,
129 SKIN_TOKEN_RTC_SECOND,
130 SKIN_TOKEN_RTC_YEAR_2_DIGITS,
131 SKIN_TOKEN_RTC_YEAR_4_DIGITS,
132 SKIN_TOKEN_RTC_AM_PM_UPPER,
133 SKIN_TOKEN_RTC_AM_PM_LOWER,
134 SKIN_TOKEN_RTC_WEEKDAY_NAME,
135 SKIN_TOKEN_RTC_MONTH_NAME,
136 SKIN_TOKEN_RTC_DAY_OF_WEEK_START_MON,
137 SKIN_TOKEN_RTC_DAY_OF_WEEK_START_SUN,
139 SKIN_TOKENS_RTC_END, /* just the end marker, not an actual token */
141 /* Database */
142 SKIN_TOKEN_DATABASE_PLAYCOUNT,
143 SKIN_TOKEN_DATABASE_RATING,
144 SKIN_TOKEN_DATABASE_AUTOSCORE,
146 /* File */
147 SKIN_TOKEN_FILE_BITRATE,
148 SKIN_TOKEN_FILE_CODEC,
149 SKIN_TOKEN_FILE_FREQUENCY,
150 SKIN_TOKEN_FILE_FREQUENCY_KHZ,
151 SKIN_TOKEN_FILE_NAME,
152 SKIN_TOKEN_FILE_NAME_WITH_EXTENSION,
153 SKIN_TOKEN_FILE_PATH,
154 SKIN_TOKEN_FILE_SIZE,
155 SKIN_TOKEN_FILE_VBR,
156 SKIN_TOKEN_FILE_DIRECTORY,
158 /* Image */
159 SKIN_TOKEN_IMAGE_BACKDROP,
160 SKIN_TOKEN_IMAGE_PROGRESS_BAR,
161 SKIN_TOKEN_IMAGE_PRELOAD,
162 SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY,
163 SKIN_TOKEN_IMAGE_DISPLAY,
164 SKIN_TOKEN_IMAGE_DISPLAY_LISTICON,
166 /* Albumart */
167 SKIN_TOKEN_ALBUMART_LOAD,
168 SKIN_TOKEN_ALBUMART_DISPLAY,
169 SKIN_TOKEN_ALBUMART_FOUND,
171 /* Metadata */
172 SKIN_TOKEN_METADATA_ARTIST,
173 SKIN_TOKEN_METADATA_COMPOSER,
174 SKIN_TOKEN_METADATA_ALBUM_ARTIST,
175 SKIN_TOKEN_METADATA_GROUPING,
176 SKIN_TOKEN_METADATA_ALBUM,
177 SKIN_TOKEN_METADATA_GENRE,
178 SKIN_TOKEN_METADATA_DISC_NUMBER,
179 SKIN_TOKEN_METADATA_TRACK_NUMBER,
180 SKIN_TOKEN_METADATA_TRACK_TITLE,
181 SKIN_TOKEN_METADATA_VERSION,
182 SKIN_TOKEN_METADATA_YEAR,
183 SKIN_TOKEN_METADATA_COMMENT,
185 /* Mode */
186 SKIN_TOKEN_REPEAT_MODE,
187 SKIN_TOKEN_PLAYBACK_STATUS,
188 /* Progressbar */
189 SKIN_TOKEN_PROGRESSBAR,
190 SKIN_TOKEN_PLAYER_PROGRESSBAR,
191 /* Peakmeter */
192 SKIN_TOKEN_PEAKMETER,
193 SKIN_TOKEN_PEAKMETER_LEFT,
194 SKIN_TOKEN_PEAKMETER_LEFTBAR,
195 SKIN_TOKEN_PEAKMETER_RIGHT,
196 SKIN_TOKEN_PEAKMETER_RIGHTBAR,
198 /* Current track */
199 SKIN_TOKEN_TRACK_ELAPSED_PERCENT,
200 SKIN_TOKEN_TRACK_TIME_ELAPSED,
201 SKIN_TOKEN_TRACK_TIME_REMAINING,
202 SKIN_TOKEN_TRACK_LENGTH,
203 SKIN_TOKEN_TRACK_STARTING,
204 SKIN_TOKEN_TRACK_ENDING,
206 /* Playlist */
207 SKIN_TOKEN_PLAYLIST_ENTRIES,
208 SKIN_TOKEN_PLAYLIST_NAME,
209 SKIN_TOKEN_PLAYLIST_POSITION,
210 SKIN_TOKEN_PLAYLIST_SHUFFLE,
213 SKIN_TOKEN_ENABLE_THEME,
214 SKIN_TOKEN_DISABLE_THEME,
215 SKIN_TOKEN_DRAW_INBUILTBAR,
216 SKIN_TOKEN_LIST_TITLE_TEXT,
217 SKIN_TOKEN_LIST_TITLE_ICON,
218 SKIN_TOKEN_LIST_ITEM_CFG,
219 SKIN_TOKEN_LIST_SELECTED_ITEM_CFG,
220 SKIN_TOKEN_LIST_ITEM_IS_SELECTED,
221 SKIN_TOKEN_LIST_ITEM_TEXT,
222 SKIN_TOKEN_LIST_ITEM_NUMBER,
223 SKIN_TOKEN_LIST_ITEM_ICON,
224 SKIN_TOKEN_LIST_NEEDS_SCROLLBAR,
225 SKIN_TOKEN_LIST_SCROLLBAR,
227 SKIN_TOKEN_LOAD_FONT,
229 /* buttons */
230 SKIN_TOKEN_BUTTON_VOLUME,
231 SKIN_TOKEN_LASTTOUCH,
232 SKIN_TOKEN_TOUCHREGION,
233 SKIN_TOKEN_HAVE_TOUCH,
235 /* Virtual LED */
236 SKIN_TOKEN_VLED_HDD,
237 /* Volume level */
238 SKIN_TOKEN_VOLUME,
239 SKIN_TOKEN_VOLUMEBAR,
240 /* hold */
241 SKIN_TOKEN_MAIN_HOLD,
242 SKIN_TOKEN_REMOTE_HOLD,
244 /* Setting option */
245 SKIN_TOKEN_SETTING,
246 SKIN_TOKEN_CURRENT_SCREEN,
247 SKIN_TOKEN_LANG_IS_RTL,
249 /* Recording Tokens */
250 SKIN_TOKEN_HAVE_RECORDING,
251 SKIN_TOKEN_IS_RECORDING,
252 SKIN_TOKEN_REC_FREQ,
253 SKIN_TOKEN_REC_ENCODER,
254 SKIN_TOKEN_REC_BITRATE, /* SWCODEC: MP3 bitrate, HWCODEC: MP3 "quality" */
255 SKIN_TOKEN_REC_MONO,
256 SKIN_TOKEN_REC_SECONDS,
257 SKIN_TOKEN_REC_MINUTES,
258 SKIN_TOKEN_REC_HOURS,
261 /* Radio Tokens */
262 SKIN_TOKEN_HAVE_TUNER,
263 SKIN_TOKEN_TUNER_TUNED,
264 SKIN_TOKEN_TUNER_SCANMODE,
265 SKIN_TOKEN_TUNER_STEREO,
266 SKIN_TOKEN_TUNER_MINFREQ, /* changes based on "region" */
267 SKIN_TOKEN_TUNER_MAXFREQ, /* changes based on "region" */
268 SKIN_TOKEN_TUNER_CURFREQ,
269 SKIN_TOKEN_TUNER_RSSI,
270 SKIN_TOKEN_TUNER_RSSI_MIN,
271 SKIN_TOKEN_TUNER_RSSI_MAX,
272 SKIN_TOKEN_TUNER_RSSI_BAR,
273 SKIN_TOKEN_PRESET_ID, /* "id" of this preset.. really the array element number */
274 SKIN_TOKEN_PRESET_NAME,
275 SKIN_TOKEN_PRESET_FREQ,
276 SKIN_TOKEN_PRESET_COUNT,
277 /* RDS tokens */
278 SKIN_TOKEN_HAVE_RDS,
279 SKIN_TOKEN_RDS_NAME,
280 SKIN_TOKEN_RDS_TEXT,
282 /* Skin variables */
283 SKIN_TOKEN_VAR_SET,
284 SKIN_TOKEN_VAR_GETVAL,
285 SKIN_TOKEN_VAR_TIMEOUT,
287 SKIN_TOKEN_SUBSTRING,
291 * Struct for tag parsing information
292 * name - The name of the tag, i.e. V for %V
293 * params - A string specifying all of the tags parameters, each
294 * character representing a single parameter. Valid
295 * characters for parameters are:
296 * I - Required integer
297 * i - Nullable integer
298 * D - Required decimal
299 * d - Nullable decimal
300 * Decimals are stored as (whole*10)+part
301 * S - Required string
302 * s - Nullable string
303 * F - Required file name
304 * f - Nullable file name
305 * C - Required skin code
306 * T - Required single skin tag
307 * * - Any amonut of the previous tag (or group if after a []
308 * \n - causes the parser to eat everything up to and including the \n
309 * MUST be the last character of the prams string
310 * Any nullable parameter may be replaced in the WPS file
311 * with a '-'. To specify that parameters may be left off
312 * altogether, place a '|' in the parameter string. For
313 * instance, with the parameter string...
314 * Ii|Ss
315 * one integer must be specified, one integer can be
316 * specified or set to default with '-', and the user can
317 * stop providing parameters at any time after that.
318 * To specify multiple instances of the same type, put a
319 * number before the character. For instance, the string...
320 * 2s
321 * will specify two strings. A ? at the beginning of the
322 * string will specify that you may choose to omit all arguments
324 * You may also group param types in [] which will tell the parser to
325 * accept any *one* of those types for that param. i.e [IT] will
326 * accept either an integer or tag type. [ITs] will also accept a string or -
329 struct tag_info
331 enum skin_token_type type;
332 char* name;
333 char* params;
334 int flags;
338 * Finds a tag by name and returns its parameter list, or an empty
339 * string if the tag is not found in the table
341 const struct tag_info* find_tag(const char* name);
344 * Determines whether a character is legal to escape or not. If
345 * lookup is not found in the legal escape characters string, returns
346 * false, otherwise returns true
348 int find_escape_character(char lookup);
350 #ifdef __cplusplus
352 #endif
354 #endif /* TAG_TABLE_H */