blob: 58c14b5e0b7df6b0f73f67d132cb057150bf4389 [file] [log] [blame]
Robert Bieberd5b24dd2010-05-25 15:19:52 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef TAG_TABLE_H
23#define TAG_TABLE_H
24
Robert Bieber0769fc52010-05-25 22:24:08 +000025#ifdef __cplusplus
26extern "C"
27{
Robert Bieber0769fc52010-05-25 22:24:08 +000028#endif
29
Jonathan Gordon2d31d772010-07-29 12:37:48 +000030#define MAX_TAG_PARAMS 12
31
Jonathan Gordon943de3c2010-10-28 11:00:36 +000032#define NOBREAK 0x1 /* Flag to tell the renderer not to insert a line break */
33#define FEATURE_TAG 0x2 /* Parse time conditional for feature checks (e.g HAVE_RTC) */
Robert Bieber32ff4e92010-07-04 01:39:57 +000034
Jonathan Gordon2d31d772010-07-29 12:37:48 +000035/* constants used in line_type and as refresh_mode for wps_refresh */
36#define SKIN_REFRESH_SHIFT 16
37#define SKIN_REFRESH_STATIC (1u<<SKIN_REFRESH_SHIFT) /* line doesn't change over time */
38#define SKIN_REFRESH_DYNAMIC (1u<<(SKIN_REFRESH_SHIFT+1)) /* line may change (e.g. time flag) */
39#define SKIN_REFRESH_SCROLL (1u<<(SKIN_REFRESH_SHIFT+2)) /* line scrolls */
40#define SKIN_REFRESH_PLAYER_PROGRESS (1u<<(SKIN_REFRESH_SHIFT+3)) /* line contains a progress bar */
41#define SKIN_REFRESH_PEAK_METER (1u<<(SKIN_REFRESH_SHIFT+4)) /* line contains a peak meter */
42#define SKIN_REFRESH_STATUSBAR (1u<<(SKIN_REFRESH_SHIFT+5)) /* refresh statusbar */
43#define SKIN_RTC_REFRESH (1u<<(SKIN_REFRESH_SHIFT+6)) /* refresh rtc, convert at parse time */
44#define SKIN_REFRESH_ALL (0xffffu<<SKIN_REFRESH_SHIFT) /* to refresh all line types */
45
46/* to refresh only those lines that change over time */
47#define SKIN_REFRESH_NON_STATIC (SKIN_REFRESH_DYNAMIC| \
48 SKIN_REFRESH_PLAYER_PROGRESS| \
49 SKIN_REFRESH_PEAK_METER)
Robert Bieber0769fc52010-05-25 22:24:08 +000050
Robert Bieber48198822010-05-30 05:51:50 +000051enum skin_token_type {
52
Jonathan Gordon2d31d772010-07-29 12:37:48 +000053 SKIN_TOKEN_NO_TOKEN,
Robert Bieber48198822010-05-30 05:51:50 +000054 SKIN_TOKEN_UNKNOWN,
55
56 /* Markers */
57 SKIN_TOKEN_CHARACTER,
58 SKIN_TOKEN_STRING,
59 SKIN_TOKEN_TRANSLATEDSTRING,
60
61 /* Alignment */
62 SKIN_TOKEN_ALIGN_LEFT,
63 SKIN_TOKEN_ALIGN_LEFT_RTL,
64 SKIN_TOKEN_ALIGN_CENTER,
65 SKIN_TOKEN_ALIGN_RIGHT,
66 SKIN_TOKEN_ALIGN_RIGHT_RTL,
67 SKIN_TOKEN_ALIGN_LANGDIRECTION,
68
69
70 /* Sublines */
71 SKIN_TOKEN_SUBLINE_TIMEOUT,
72 SKIN_TOKEN_SUBLINE_SCROLL,
73
74 /* Conditional */
Jonathan Gordon74ec0112010-08-19 13:49:32 +000075 SKIN_TOKEN_LOGICAL_IF,
Robert Bieber48198822010-05-30 05:51:50 +000076 SKIN_TOKEN_CONDITIONAL,
77 SKIN_TOKEN_CONDITIONAL_START,
78 SKIN_TOKEN_CONDITIONAL_OPTION,
79 SKIN_TOKEN_CONDITIONAL_END,
80
81 /* Viewport display */
82 SKIN_TOKEN_VIEWPORT_LOAD,
83 SKIN_TOKEN_VIEWPORT_CONDITIONAL,
84 SKIN_TOKEN_VIEWPORT_ENABLE,
85 SKIN_TOKEN_VIEWPORT_CUSTOMLIST,
86 SKIN_TOKEN_UIVIEWPORT_ENABLE,
87 SKIN_TOKEN_UIVIEWPORT_LOAD,
Jonathan Gordon9f2bd982010-06-07 10:45:15 +000088 SKIN_TOKEN_VIEWPORT_FGCOLOUR,
89 SKIN_TOKEN_VIEWPORT_BGCOLOUR,
Jonathan Gordon281f1a12011-08-14 13:50:07 +000090 SKIN_TOKEN_VIEWPORT_TEXTSTYLE,
91 SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP,
Robert Bieber48198822010-05-30 05:51:50 +000092
93 /* Battery */
Robert Bieber48198822010-05-30 05:51:50 +000094 SKIN_TOKEN_BATTERY_PERCENT,
95 SKIN_TOKEN_BATTERY_PERCENTBAR,
96 SKIN_TOKEN_BATTERY_VOLTS,
97 SKIN_TOKEN_BATTERY_TIME,
98 SKIN_TOKEN_BATTERY_CHARGER_CONNECTED,
99 SKIN_TOKEN_BATTERY_CHARGING,
100 SKIN_TOKEN_BATTERY_SLEEPTIME,
101 SKIN_TOKEN_USB_POWERED,
102
103 /* Sound */
Robert Bieber48198822010-05-30 05:51:50 +0000104 SKIN_TOKEN_SOUND_PITCH,
105 SKIN_TOKEN_SOUND_SPEED,
106 SKIN_TOKEN_REPLAYGAIN,
107 SKIN_TOKEN_CROSSFADE,
108
109 /* Time */
Robert Bieber48198822010-05-30 05:51:50 +0000110 SKIN_TOKEN_RTC_PRESENT,
111
112 /* The begin/end values allow us to know if a token is an RTC one.
113 New RTC tokens should be added between the markers. */
114
Jonathan Gordon2d31d772010-07-29 12:37:48 +0000115 SKIN_TOKENS_RTC_BEGIN, /* just the start marker, not an actual token */
Robert Bieber48198822010-05-30 05:51:50 +0000116
117 SKIN_TOKEN_RTC_DAY_OF_MONTH,
118 SKIN_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED,
119 SKIN_TOKEN_RTC_12HOUR_CFG,
120 SKIN_TOKEN_RTC_HOUR_24_ZERO_PADDED,
121 SKIN_TOKEN_RTC_HOUR_24,
122 SKIN_TOKEN_RTC_HOUR_12_ZERO_PADDED,
123 SKIN_TOKEN_RTC_HOUR_12,
124 SKIN_TOKEN_RTC_MONTH,
125 SKIN_TOKEN_RTC_MINUTE,
126 SKIN_TOKEN_RTC_SECOND,
127 SKIN_TOKEN_RTC_YEAR_2_DIGITS,
128 SKIN_TOKEN_RTC_YEAR_4_DIGITS,
129 SKIN_TOKEN_RTC_AM_PM_UPPER,
130 SKIN_TOKEN_RTC_AM_PM_LOWER,
131 SKIN_TOKEN_RTC_WEEKDAY_NAME,
132 SKIN_TOKEN_RTC_MONTH_NAME,
133 SKIN_TOKEN_RTC_DAY_OF_WEEK_START_MON,
134 SKIN_TOKEN_RTC_DAY_OF_WEEK_START_SUN,
135
136 SKIN_TOKENS_RTC_END, /* just the end marker, not an actual token */
137
138 /* Database */
Robert Bieber48198822010-05-30 05:51:50 +0000139 SKIN_TOKEN_DATABASE_PLAYCOUNT,
140 SKIN_TOKEN_DATABASE_RATING,
141 SKIN_TOKEN_DATABASE_AUTOSCORE,
142
143 /* File */
Robert Bieber48198822010-05-30 05:51:50 +0000144 SKIN_TOKEN_FILE_BITRATE,
145 SKIN_TOKEN_FILE_CODEC,
146 SKIN_TOKEN_FILE_FREQUENCY,
147 SKIN_TOKEN_FILE_FREQUENCY_KHZ,
148 SKIN_TOKEN_FILE_NAME,
149 SKIN_TOKEN_FILE_NAME_WITH_EXTENSION,
150 SKIN_TOKEN_FILE_PATH,
151 SKIN_TOKEN_FILE_SIZE,
152 SKIN_TOKEN_FILE_VBR,
153 SKIN_TOKEN_FILE_DIRECTORY,
154
155 /* Image */
Robert Bieber48198822010-05-30 05:51:50 +0000156 SKIN_TOKEN_IMAGE_BACKDROP,
157 SKIN_TOKEN_IMAGE_PROGRESS_BAR,
158 SKIN_TOKEN_IMAGE_PRELOAD,
159 SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY,
160 SKIN_TOKEN_IMAGE_DISPLAY,
Jonathan Gordon70ebe462010-08-12 13:27:10 +0000161 SKIN_TOKEN_IMAGE_DISPLAY_LISTICON,
Robert Bieber48198822010-05-30 05:51:50 +0000162
163 /* Albumart */
164 SKIN_TOKEN_ALBUMART_LOAD,
165 SKIN_TOKEN_ALBUMART_DISPLAY,
Jonathan Gordon20b90202010-06-09 14:51:52 +0000166 SKIN_TOKEN_ALBUMART_FOUND,
Robert Bieber48198822010-05-30 05:51:50 +0000167
168 /* Metadata */
Robert Bieber48198822010-05-30 05:51:50 +0000169 SKIN_TOKEN_METADATA_ARTIST,
170 SKIN_TOKEN_METADATA_COMPOSER,
171 SKIN_TOKEN_METADATA_ALBUM_ARTIST,
172 SKIN_TOKEN_METADATA_GROUPING,
173 SKIN_TOKEN_METADATA_ALBUM,
174 SKIN_TOKEN_METADATA_GENRE,
175 SKIN_TOKEN_METADATA_DISC_NUMBER,
176 SKIN_TOKEN_METADATA_TRACK_NUMBER,
177 SKIN_TOKEN_METADATA_TRACK_TITLE,
178 SKIN_TOKEN_METADATA_VERSION,
179 SKIN_TOKEN_METADATA_YEAR,
180 SKIN_TOKEN_METADATA_COMMENT,
181
Robert Bieber48198822010-05-30 05:51:50 +0000182 /* Mode */
183 SKIN_TOKEN_REPEAT_MODE,
184 SKIN_TOKEN_PLAYBACK_STATUS,
185 /* Progressbar */
186 SKIN_TOKEN_PROGRESSBAR,
187 SKIN_TOKEN_PLAYER_PROGRESSBAR,
188 /* Peakmeter */
189 SKIN_TOKEN_PEAKMETER,
Jonathan Gordon261c56b2011-01-13 06:48:39 +0000190 SKIN_TOKEN_PEAKMETER_LEFT,
191 SKIN_TOKEN_PEAKMETER_LEFTBAR,
192 SKIN_TOKEN_PEAKMETER_RIGHT,
193 SKIN_TOKEN_PEAKMETER_RIGHTBAR,
Robert Bieber48198822010-05-30 05:51:50 +0000194
195 /* Current track */
196 SKIN_TOKEN_TRACK_ELAPSED_PERCENT,
197 SKIN_TOKEN_TRACK_TIME_ELAPSED,
198 SKIN_TOKEN_TRACK_TIME_REMAINING,
199 SKIN_TOKEN_TRACK_LENGTH,
200 SKIN_TOKEN_TRACK_STARTING,
201 SKIN_TOKEN_TRACK_ENDING,
202
203 /* Playlist */
Robert Bieber48198822010-05-30 05:51:50 +0000204 SKIN_TOKEN_PLAYLIST_ENTRIES,
205 SKIN_TOKEN_PLAYLIST_NAME,
206 SKIN_TOKEN_PLAYLIST_POSITION,
207 SKIN_TOKEN_PLAYLIST_SHUFFLE,
208
209
Robert Bieber48198822010-05-30 05:51:50 +0000210 SKIN_TOKEN_ENABLE_THEME,
211 SKIN_TOKEN_DISABLE_THEME,
212 SKIN_TOKEN_DRAW_INBUILTBAR,
213 SKIN_TOKEN_LIST_TITLE_TEXT,
214 SKIN_TOKEN_LIST_TITLE_ICON,
215
216 SKIN_TOKEN_LOAD_FONT,
217
218 /* buttons */
219 SKIN_TOKEN_BUTTON_VOLUME,
220 SKIN_TOKEN_LASTTOUCH,
221 SKIN_TOKEN_TOUCHREGION,
Jonathan Gordon943de3c2010-10-28 11:00:36 +0000222 SKIN_TOKEN_HAVE_TOUCH,
223
Robert Bieber48198822010-05-30 05:51:50 +0000224 /* Virtual LED */
225 SKIN_TOKEN_VLED_HDD,
226 /* Volume level */
227 SKIN_TOKEN_VOLUME,
228 SKIN_TOKEN_VOLUMEBAR,
229 /* hold */
230 SKIN_TOKEN_MAIN_HOLD,
231 SKIN_TOKEN_REMOTE_HOLD,
232
233 /* Setting option */
234 SKIN_TOKEN_SETTING,
235 SKIN_TOKEN_CURRENT_SCREEN,
236 SKIN_TOKEN_LANG_IS_RTL,
237
238 /* Recording Tokens */
Robert Bieber48198822010-05-30 05:51:50 +0000239 SKIN_TOKEN_HAVE_RECORDING,
240 SKIN_TOKEN_IS_RECORDING,
241 SKIN_TOKEN_REC_FREQ,
242 SKIN_TOKEN_REC_ENCODER,
243 SKIN_TOKEN_REC_BITRATE, /* SWCODEC: MP3 bitrate, HWCODEC: MP3 "quality" */
244 SKIN_TOKEN_REC_MONO,
245 SKIN_TOKEN_REC_SECONDS,
246 SKIN_TOKEN_REC_MINUTES,
247 SKIN_TOKEN_REC_HOURS,
248
249
250 /* Radio Tokens */
Robert Bieber48198822010-05-30 05:51:50 +0000251 SKIN_TOKEN_HAVE_TUNER,
252 SKIN_TOKEN_TUNER_TUNED,
253 SKIN_TOKEN_TUNER_SCANMODE,
254 SKIN_TOKEN_TUNER_STEREO,
255 SKIN_TOKEN_TUNER_MINFREQ, /* changes based on "region" */
256 SKIN_TOKEN_TUNER_MAXFREQ, /* changes based on "region" */
257 SKIN_TOKEN_TUNER_CURFREQ,
Bertrik Sikkende870b32010-11-11 21:13:29 +0000258 SKIN_TOKEN_TUNER_RSSI,
259 SKIN_TOKEN_TUNER_RSSI_MIN,
260 SKIN_TOKEN_TUNER_RSSI_MAX,
Jonathan Gordon1ce7ba42010-11-18 11:47:42 +0000261 SKIN_TOKEN_TUNER_RSSI_BAR,
Robert Bieber48198822010-05-30 05:51:50 +0000262 SKIN_TOKEN_PRESET_ID, /* "id" of this preset.. really the array element number */
263 SKIN_TOKEN_PRESET_NAME,
264 SKIN_TOKEN_PRESET_FREQ,
265 SKIN_TOKEN_PRESET_COUNT,
266 /* RDS tokens */
267 SKIN_TOKEN_HAVE_RDS,
268 SKIN_TOKEN_RDS_NAME,
269 SKIN_TOKEN_RDS_TEXT,
Jonathan Gordon87aa86c2011-03-27 08:01:58 +0000270
271 /* Skin variables */
272 SKIN_TOKEN_VAR_SET,
273 SKIN_TOKEN_VAR_GETVAL,
274 SKIN_TOKEN_VAR_TIMEOUT,
Robert Bieber48198822010-05-30 05:51:50 +0000275};
276
Robert Bieberd5b24dd2010-05-25 15:19:52 +0000277/*
278 * Struct for tag parsing information
279 * name - The name of the tag, i.e. V for %V
280 * params - A string specifying all of the tags parameters, each
281 * character representing a single parameter. Valid
282 * characters for parameters are:
283 * I - Required integer
284 * i - Nullable integer
Robert Bieber15488a02010-07-15 06:24:11 +0000285 * D - Required decimal
286 * d - Nullable decimal
287 * Decimals are stored as (whole*10)+part
Robert Bieberd5b24dd2010-05-25 15:19:52 +0000288 * S - Required string
289 * s - Nullable string
290 * F - Required file name
291 * f - Nullable file name
Jonathan Gordon20b90202010-06-09 14:51:52 +0000292 * C - Required skin code
Jonathan Gordon145571d2010-08-05 11:28:35 +0000293 * T - Required single skin tag
Jonathan Gordon9ac4b442010-06-09 16:15:01 +0000294 * N - any amount of strings.. must be the last param in the list
Robert Bieber7dfd0c02010-07-01 08:45:49 +0000295 * \n - causes the parser to eat everything up to and including the \n
296 * MUST be the last character of the prams string
Robert Bieberd5b24dd2010-05-25 15:19:52 +0000297 * Any nullable parameter may be replaced in the WPS file
298 * with a '-'. To specify that parameters may be left off
299 * altogether, place a '|' in the parameter string. For
300 * instance, with the parameter string...
301 * Ii|Ss
302 * one integer must be specified, one integer can be
303 * specified or set to default with '-', and the user can
304 * stop providing parameters at any time after that.
305 * To specify multiple instances of the same type, put a
306 * number before the character. For instance, the string...
307 * 2s
Robert Bieber1937b1b2010-05-25 17:22:39 +0000308 * will specify two strings. An asterisk (*) at the beginning of the
Robert Bieberf02a2442010-06-02 05:27:37 +0000309 * string will specify that you may choose to omit all arguments
Jonathan Gordon863d2392010-08-14 11:17:49 +0000310 *
311 * You may also group param types in [] which will tell the parser to
312 * accept any *one* of those types for that param. i.e [IT] will
313 * accept either an integer or tag type. [ITs] will also accept a string or -
Robert Bieberd5b24dd2010-05-25 15:19:52 +0000314 *
315 */
316struct tag_info
317{
Robert Bieber48198822010-05-30 05:51:50 +0000318 enum skin_token_type type;
Robert Bieberd5b24dd2010-05-25 15:19:52 +0000319 char* name;
320 char* params;
Robert Bieber32ff4e92010-07-04 01:39:57 +0000321 int flags;
Robert Bieberd5b24dd2010-05-25 15:19:52 +0000322};
323
324/*
325 * Finds a tag by name and returns its parameter list, or an empty
326 * string if the tag is not found in the table
327 */
Nils Wallméniusc2529c32010-07-31 11:28:37 +0000328const struct tag_info* find_tag(const char* name);
Robert Bieberd5b24dd2010-05-25 15:19:52 +0000329
330/*
331 * Determines whether a character is legal to escape or not. If
332 * lookup is not found in the legal escape characters string, returns
333 * false, otherwise returns true
334 */
335int find_escape_character(char lookup);
336
Robert Bieberc5e14b52010-05-31 17:39:58 +0000337#ifdef __cplusplus
338}
339#endif
340
Robert Bieberd5b24dd2010-05-25 15:19:52 +0000341#endif /* TAG_TABLE_H */