summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/wps_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/skin_engine/wps_debug.c')
-rw-r--r--apps/gui/skin_engine/wps_debug.c641
1 files changed, 641 insertions, 0 deletions
diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c
new file mode 100644
index 0000000000..a89f61af9d
--- /dev/null
+++ b/apps/gui/skin_engine/wps_debug.c
@@ -0,0 +1,641 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Nicolas Pennequin, Dan Everton, Matthias Mohr
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#if defined(DEBUG) || defined(SIMULATOR)
23
24#include <stdio.h>
25#include <string.h>
26#include "wps_internals.h"
27#ifdef __PCTOOL__
28#ifdef WPSEDITOR
29#include "proxy.h"
30#else
31#define DEBUGF printf
32#endif
33#else
34#include "debug.h"
35#endif
36
37#if defined(SIMULATOR) || defined(__PCTOOL__)
38extern bool debug_wps;
39extern int wps_verbose_level;
40#endif
41
42static char *next_str(bool next) {
43 return next ? "next " : "";
44}
45
46static char *get_token_desc(struct wps_token *token, struct wps_data *data,
47 char *buf, int bufsize)
48{
49 bool next = token->next;
50
51 switch(token->type)
52 {
53 case WPS_NO_TOKEN:
54 snprintf(buf, bufsize, "No token");
55 break;
56
57 case WPS_TOKEN_UNKNOWN:
58 snprintf(buf, bufsize, "Unknown token");
59 break;
60
61 case WPS_TOKEN_CHARACTER:
62 snprintf(buf, bufsize, "Character '%c'",
63 token->value.c);
64 break;
65
66 case WPS_TOKEN_STRING:
67 snprintf(buf, bufsize, "String '%s'",
68 data->strings[token->value.i]);
69 break;
70
71#ifdef HAVE_LCD_BITMAP
72 case WPS_TOKEN_ALIGN_LEFT:
73 snprintf(buf, bufsize, "align left");
74 break;
75
76 case WPS_TOKEN_ALIGN_CENTER:
77 snprintf(buf, bufsize, "align center");
78 break;
79
80 case WPS_TOKEN_ALIGN_RIGHT:
81 snprintf(buf, bufsize, "align right");
82 break;
83#endif
84
85 case WPS_TOKEN_SUBLINE_TIMEOUT:
86 snprintf(buf, bufsize, "subline timeout value: %d",
87 token->value.i);
88 break;
89
90 case WPS_TOKEN_CONDITIONAL:
91 snprintf(buf, bufsize, "conditional, %d options",
92 token->value.i);
93 break;
94
95 case WPS_TOKEN_CONDITIONAL_START:
96 snprintf(buf, bufsize, "conditional start, next cond: %d",
97 token->value.i);
98 break;
99
100 case WPS_TOKEN_CONDITIONAL_OPTION:
101 snprintf(buf, bufsize, "conditional option, next cond: %d",
102 token->value.i);
103 break;
104
105 case WPS_TOKEN_CONDITIONAL_END:
106 snprintf(buf, bufsize, "conditional end");
107 break;
108
109#ifdef HAVE_LCD_BITMAP
110 case WPS_TOKEN_IMAGE_PRELOAD:
111 snprintf(buf, bufsize, "preload image");
112 break;
113
114 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
115 snprintf(buf, bufsize, "display preloaded image %d",
116 token->value.i);
117 break;
118
119 case WPS_TOKEN_IMAGE_DISPLAY:
120 snprintf(buf, bufsize, "display image");
121 break;
122#endif
123
124#ifdef HAS_BUTTON_HOLD
125 case WPS_TOKEN_MAIN_HOLD:
126 snprintf(buf, bufsize, "mode hold");
127 break;
128#endif
129
130#ifdef HAS_REMOTE_BUTTON_HOLD
131 case WPS_TOKEN_REMOTE_HOLD:
132 snprintf(buf, bufsize, "mode remote hold");
133 break;
134#endif
135
136 case WPS_TOKEN_REPEAT_MODE:
137 snprintf(buf, bufsize, "mode repeat");
138 break;
139
140 case WPS_TOKEN_PLAYBACK_STATUS:
141 snprintf(buf, bufsize, "mode playback");
142 break;
143
144 case WPS_TOKEN_RTC_DAY_OF_MONTH:
145 snprintf(buf, bufsize, "rtc: day of month (01..31)");
146 break;
147 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED:
148 snprintf(buf, bufsize,
149 "rtc: day of month, blank padded ( 1..31)");
150 break;
151 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED:
152 snprintf(buf, bufsize, "rtc: hour (00..23)");
153 break;
154 case WPS_TOKEN_RTC_HOUR_24:
155 snprintf(buf, bufsize, "rtc: hour ( 0..23)");
156 break;
157 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED:
158 snprintf(buf, bufsize, "rtc: hour (01..12)");
159 break;
160 case WPS_TOKEN_RTC_HOUR_12:
161 snprintf(buf, bufsize, "rtc: hour ( 1..12)");
162 break;
163 case WPS_TOKEN_RTC_MONTH:
164 snprintf(buf, bufsize, "rtc: month (01..12)");
165 break;
166 case WPS_TOKEN_RTC_MINUTE:
167 snprintf(buf, bufsize, "rtc: minute (00..59)");
168 break;
169 case WPS_TOKEN_RTC_SECOND:
170 snprintf(buf, bufsize, "rtc: second (00..59)");
171 break;
172 case WPS_TOKEN_RTC_YEAR_2_DIGITS:
173 snprintf(buf, bufsize,
174 "rtc: last two digits of year (00..99)");
175 break;
176 case WPS_TOKEN_RTC_YEAR_4_DIGITS:
177 snprintf(buf, bufsize, "rtc: year (1970...)");
178 break;
179 case WPS_TOKEN_RTC_AM_PM_UPPER:
180 snprintf(buf, bufsize,
181 "rtc: upper case AM or PM indicator");
182 break;
183 case WPS_TOKEN_RTC_AM_PM_LOWER:
184 snprintf(buf, bufsize,
185 "rtc: lower case am or pm indicator");
186 break;
187 case WPS_TOKEN_RTC_WEEKDAY_NAME:
188 snprintf(buf, bufsize,
189 "rtc: abbreviated weekday name (Sun..Sat)");
190 break;
191 case WPS_TOKEN_RTC_MONTH_NAME:
192 snprintf(buf, bufsize,
193 "rtc: abbreviated month name (Jan..Dec)");
194 break;
195 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
196 snprintf(buf, bufsize,
197 "rtc: day of week (1..7); 1 is Monday");
198 break;
199 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN:
200 snprintf(buf, bufsize,
201 "rtc: day of week (0..6); 0 is Sunday");
202 break;
203
204#if (CONFIG_CODEC == SWCODEC)
205 case WPS_TOKEN_CROSSFADE:
206 snprintf(buf, bufsize, "crossfade");
207 break;
208
209 case WPS_TOKEN_REPLAYGAIN:
210 snprintf(buf, bufsize, "replaygain");
211 break;
212#endif
213
214#ifdef HAVE_ALBUMART
215 case WPS_TOKEN_ALBUMART_DISPLAY:
216 snprintf(buf, bufsize, "album art display");
217 break;
218
219 case WPS_TOKEN_ALBUMART_FOUND:
220 snprintf(buf, bufsize, "%strack album art conditional",
221 next_str(next));
222 break;
223#endif
224
225#ifdef HAVE_LCD_BITMAP
226 case WPS_TOKEN_IMAGE_BACKDROP:
227 snprintf(buf, bufsize, "backdrop image");
228 break;
229
230 case WPS_TOKEN_IMAGE_PROGRESS_BAR:
231 snprintf(buf, bufsize, "progressbar bitmap");
232 break;
233
234 case WPS_TOKEN_PEAKMETER:
235 snprintf(buf, bufsize, "peakmeter");
236 break;
237#endif
238
239 case WPS_TOKEN_PROGRESSBAR:
240 snprintf(buf, bufsize, "progressbar");
241 break;
242
243#ifdef HAVE_LCD_CHARCELLS
244 case WPS_TOKEN_PLAYER_PROGRESSBAR:
245 snprintf(buf, bufsize, "full line progressbar");
246 break;
247#endif
248
249 case WPS_TOKEN_TRACK_TIME_ELAPSED:
250 snprintf(buf, bufsize, "time elapsed in track");
251 break;
252
253 case WPS_TOKEN_TRACK_ELAPSED_PERCENT:
254 snprintf(buf, bufsize, "played percentage of track");
255 break;
256
257 case WPS_TOKEN_PLAYLIST_ENTRIES:
258 snprintf(buf, bufsize, "number of entries in playlist");
259 break;
260
261 case WPS_TOKEN_PLAYLIST_NAME:
262 snprintf(buf, bufsize, "playlist name");
263 break;
264
265 case WPS_TOKEN_PLAYLIST_POSITION:
266 snprintf(buf, bufsize, "position in playlist");
267 break;
268
269 case WPS_TOKEN_TRACK_TIME_REMAINING:
270 snprintf(buf, bufsize, "time remaining in track");
271 break;
272
273 case WPS_TOKEN_PLAYLIST_SHUFFLE:
274 snprintf(buf, bufsize, "playlist shuffle mode");
275 break;
276
277 case WPS_TOKEN_TRACK_LENGTH:
278 snprintf(buf, bufsize, "track length");
279 break;
280
281 case WPS_TOKEN_VOLUME:
282 snprintf(buf, bufsize, "volume");
283 break;
284
285 case WPS_TOKEN_METADATA_ARTIST:
286 snprintf(buf, bufsize, "%strack artist",
287 next_str(next));
288 break;
289
290 case WPS_TOKEN_METADATA_COMPOSER:
291 snprintf(buf, bufsize, "%strack composer",
292 next_str(next));
293 break;
294
295 case WPS_TOKEN_METADATA_ALBUM:
296 snprintf(buf, bufsize, "%strack album",
297 next_str(next));
298 break;
299
300 case WPS_TOKEN_METADATA_GROUPING:
301 snprintf(buf, bufsize, "%strack grouping",
302 next_str(next));
303 break;
304
305 case WPS_TOKEN_METADATA_GENRE:
306 snprintf(buf, bufsize, "%strack genre",
307 next_str(next));
308 break;
309
310 case WPS_TOKEN_METADATA_DISC_NUMBER:
311 snprintf(buf, bufsize, "%strack disc", next_str(next));
312 break;
313
314 case WPS_TOKEN_METADATA_TRACK_NUMBER:
315 snprintf(buf, bufsize, "%strack number",
316 next_str(next));
317 break;
318
319 case WPS_TOKEN_METADATA_TRACK_TITLE:
320 snprintf(buf, bufsize, "%strack title",
321 next_str(next));
322 break;
323
324 case WPS_TOKEN_METADATA_VERSION:
325 snprintf(buf, bufsize, "%strack ID3 version",
326 next_str(next));
327 break;
328
329 case WPS_TOKEN_METADATA_ALBUM_ARTIST:
330 snprintf(buf, bufsize, "%strack album artist",
331 next_str(next));
332 break;
333
334 case WPS_TOKEN_METADATA_COMMENT:
335 snprintf(buf, bufsize, "%strack comment",
336 next_str(next));
337 break;
338
339 case WPS_TOKEN_METADATA_YEAR:
340 snprintf(buf, bufsize, "%strack year", next_str(next));
341 break;
342
343#ifdef HAVE_TAGCACHE
344 case WPS_TOKEN_DATABASE_PLAYCOUNT:
345 snprintf(buf, bufsize, "track playcount (database)");
346 break;
347
348 case WPS_TOKEN_DATABASE_RATING:
349 snprintf(buf, bufsize, "track rating (database)");
350 break;
351
352 case WPS_TOKEN_DATABASE_AUTOSCORE:
353 snprintf(buf, bufsize, "track autoscore (database)");
354 break;
355#endif
356
357 case WPS_TOKEN_BATTERY_PERCENT:
358 snprintf(buf, bufsize, "battery percentage");
359 break;
360
361 case WPS_TOKEN_BATTERY_VOLTS:
362 snprintf(buf, bufsize, "battery voltage");
363 break;
364
365 case WPS_TOKEN_BATTERY_TIME:
366 snprintf(buf, bufsize, "battery time left");
367 break;
368
369 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED:
370 snprintf(buf, bufsize, "battery charger connected");
371 break;
372
373 case WPS_TOKEN_BATTERY_CHARGING:
374 snprintf(buf, bufsize, "battery charging");
375 break;
376
377 case WPS_TOKEN_BATTERY_SLEEPTIME:
378 snprintf(buf, bufsize, "sleep timer");
379 break;
380
381 case WPS_TOKEN_FILE_BITRATE:
382 snprintf(buf, bufsize, "%sfile bitrate", next_str(next));
383 break;
384
385 case WPS_TOKEN_FILE_CODEC:
386 snprintf(buf, bufsize, "%sfile codec", next_str(next));
387 break;
388
389 case WPS_TOKEN_FILE_FREQUENCY:
390 snprintf(buf, bufsize, "%sfile audio frequency in Hz",
391 next_str(next));
392 break;
393
394 case WPS_TOKEN_FILE_FREQUENCY_KHZ:
395 snprintf(buf, bufsize, "%sfile audio frequency in KHz",
396 next_str(next));
397 break;
398
399 case WPS_TOKEN_FILE_NAME:
400 snprintf(buf, bufsize, "%sfile name", next_str(next));
401 break;
402
403 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION:
404 snprintf(buf, bufsize, "%sfile name with extension",
405 next_str(next));
406 break;
407
408 case WPS_TOKEN_FILE_PATH:
409 snprintf(buf, bufsize, "%sfile path", next_str(next));
410 break;
411
412 case WPS_TOKEN_FILE_SIZE:
413 snprintf(buf, bufsize, "%sfile size", next_str(next));
414 break;
415
416 case WPS_TOKEN_FILE_VBR:
417 snprintf(buf, bufsize, "%sfile is vbr", next_str(next));
418 break;
419
420 case WPS_TOKEN_FILE_DIRECTORY:
421 snprintf(buf, bufsize, "%sfile directory, level: %d",
422 next_str(next), token->value.i);
423 break;
424
425#if (CONFIG_CODEC != MAS3507D)
426 case WPS_TOKEN_SOUND_PITCH:
427 snprintf(buf, bufsize, "pitch value");
428 break;
429#endif
430 case WPS_VIEWPORT_ENABLE:
431 snprintf(buf, bufsize, "enable VP:%d",
432 token->value.i);
433 break;
434 case WPS_TOKEN_BUTTON_VOLUME:
435 snprintf(buf, bufsize, "Volume button timeout:%d",
436 token->value.i);
437 break;
438 default:
439 snprintf(buf, bufsize, "FIXME (code: %d)",
440 token->type);
441 break;
442 }
443
444 return buf;
445}
446
447#if defined(SIMULATOR) || defined(__PCTOOL__)
448static void dump_wps_tokens(struct wps_data *data)
449{
450 struct wps_token *token;
451 int i, j;
452 int indent = 0;
453 char buf[64];
454 int num_string_tokens = 0;
455
456 /* Dump parsed WPS */
457 for (i = 0, token = data->tokens; i < data->num_tokens; i++, token++)
458 {
459 get_token_desc(token, data, buf, sizeof(buf));
460
461 switch(token->type)
462 {
463 case WPS_TOKEN_STRING:
464 num_string_tokens++;
465 break;
466
467 case WPS_TOKEN_CONDITIONAL_START:
468 indent++;
469 break;
470
471 case WPS_TOKEN_CONDITIONAL_END:
472 indent--;
473 break;
474
475 default:
476 break;
477 }
478
479 if (wps_verbose_level > 2)
480 {
481 for(j = 0; j < indent; j++) {
482 DEBUGF("\t");
483 }
484
485 DEBUGF("[%3d] = (%2d) %s\n", i, token->type, buf);
486 }
487 }
488
489 if (wps_verbose_level > 0)
490 {
491 DEBUGF("\n");
492 DEBUGF("Number of string tokens: %d\n", num_string_tokens);
493 DEBUGF("\n");
494 }
495}
496
497static void print_line_info(struct wps_data *data)
498{
499 int i, j, v;
500 struct wps_line *line;
501 struct wps_subline *subline;
502
503 if (wps_verbose_level > 0)
504 {
505 DEBUGF("Number of viewports : %d\n", data->num_viewports);
506 for (v = 0; v < data->num_viewports; v++)
507 {
508 DEBUGF("vp %d: First line: %d\n", v, data->viewports[v].first_line);
509 DEBUGF("vp %d: Last line: %d\n", v, data->viewports[v].last_line);
510 }
511 DEBUGF("Number of sublines : %d\n", data->num_sublines);
512 DEBUGF("Number of tokens : %d\n", data->num_tokens);
513 DEBUGF("\n");
514 }
515
516 if (wps_verbose_level > 1)
517 {
518 for (v = 0; v < data->num_viewports; v++)
519 {
520 DEBUGF("Viewport %d - +%d+%d (%dx%d)\n",v,data->viewports[v].vp.x,
521 data->viewports[v].vp.y,
522 data->viewports[v].vp.width,
523 data->viewports[v].vp.height);
524 for (i = data->viewports[v].first_line, line = &data->lines[data->viewports[v].first_line]; i <= data->viewports[v].last_line; i++,line++)
525 {
526 DEBUGF("Line %2d (num_sublines=%d, first_subline=%d)\n",
527 i, line->num_sublines, line->first_subline_idx);
528
529 for (j = 0, subline = data->sublines + line->first_subline_idx;
530 j < line->num_sublines; j++, subline++)
531 {
532 DEBUGF(" Subline %d: first_token=%3d, last_token=%3d",
533 j, subline->first_token_idx,
534 wps_last_token_index(data, i, j));
535
536 if (subline->line_type & WPS_REFRESH_SCROLL)
537 DEBUGF(", scrolled");
538 else if (subline->line_type & WPS_REFRESH_PLAYER_PROGRESS)
539 DEBUGF(", progressbar");
540 else if (subline->line_type & WPS_REFRESH_PEAK_METER)
541 DEBUGF(", peakmeter");
542
543 DEBUGF("\n");
544 }
545 }
546 }
547
548 DEBUGF("\n");
549 }
550}
551
552static void print_wps_strings(struct wps_data *data)
553{
554 int i, len, total_len = 0, buf_used = 0;
555
556 if (wps_verbose_level > 1) DEBUGF("Strings:\n");
557 for (i = 0; i < data->num_strings; i++)
558 {
559 len = strlen(data->strings[i]);
560 total_len += len;
561 buf_used += len + 1;
562 if (wps_verbose_level > 1)
563 DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]);
564 }
565 if (wps_verbose_level > 1) DEBUGF("\n");
566
567 if (wps_verbose_level > 0)
568 {
569 DEBUGF("Number of unique strings: %d (max: %d)\n",
570 data->num_strings, WPS_MAX_STRINGS);
571 DEBUGF("Total string length: %d\n", total_len);
572 DEBUGF("String buffer used: %d out of %d bytes\n",
573 buf_used, STRING_BUFFER_SIZE);
574 DEBUGF("\n");
575 }
576}
577#endif
578
579void print_debug_info(struct wps_data *data, enum wps_parse_error fail, int line)
580{
581#if defined(SIMULATOR) || defined(__PCTOOL__)
582 if (debug_wps && wps_verbose_level)
583 {
584 dump_wps_tokens(data);
585 print_wps_strings(data);
586 print_line_info(data);
587 }
588#endif /* SIMULATOR */
589
590 if (data->num_tokens >= WPS_MAX_TOKENS - 1) {
591 DEBUGF("Warning: Max number of tokens was reached (%d)\n",
592 WPS_MAX_TOKENS - 1);
593 }
594
595 if (fail != PARSE_OK)
596 {
597 char buf[64];
598
599 DEBUGF("ERR: Failed parsing on line %d : ", line);
600 switch (fail)
601 {
602 case PARSE_OK:
603 break;
604
605 case PARSE_FAIL_UNCLOSED_COND:
606 DEBUGF("ERR: Unclosed conditional");
607 break;
608
609 case PARSE_FAIL_INVALID_CHAR:
610 DEBUGF("ERR: Unexpected conditional char after token %d: \"%s\"",
611 data->num_tokens-1,
612 get_token_desc(&data->tokens[data->num_tokens-1], data,
613 buf, sizeof(buf))
614 );
615 break;
616
617 case PARSE_FAIL_COND_SYNTAX_ERROR:
618 DEBUGF("ERR: Conditional syntax error after token %d: \"%s\"",
619 data->num_tokens-1,
620 get_token_desc(&data->tokens[data->num_tokens-1], data,
621 buf, sizeof(buf))
622 );
623 break;
624
625 case PARSE_FAIL_COND_INVALID_PARAM:
626 DEBUGF("ERR: Invalid parameter list for token %d: \"%s\"",
627 data->num_tokens,
628 get_token_desc(&data->tokens[data->num_tokens], data,
629 buf, sizeof(buf))
630 );
631 break;
632
633 case PARSE_FAIL_LIMITS_EXCEEDED:
634 DEBUGF("ERR: Limits exceeded");
635 break;
636 }
637 DEBUGF("\n");
638 }
639}
640
641#endif /* DEBUG || SIMULATOR */