diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/gwps-common.c | 48 | ||||
-rw-r--r-- | apps/gui/gwps.h | 5 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 38 |
3 files changed, 90 insertions, 1 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index a0e09b8117..bcaebc502b 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include "system.h" | 27 | #include "system.h" |
28 | #include "settings.h" | 28 | #include "settings.h" |
29 | #include "settings_list.h" | ||
29 | #include "rbunicode.h" | 30 | #include "rbunicode.h" |
30 | #include "rtc.h" | 31 | #include "rtc.h" |
31 | #include "audio.h" | 32 | #include "audio.h" |
@@ -1402,6 +1403,53 @@ static const char *get_token_value(struct gui_wps *gwps, | |||
1402 | token->value.i * TIMEOUT_UNIT)) | 1403 | token->value.i * TIMEOUT_UNIT)) |
1403 | return "v"; | 1404 | return "v"; |
1404 | return NULL; | 1405 | return NULL; |
1406 | |||
1407 | case WPS_TOKEN_SETTING: | ||
1408 | { | ||
1409 | if (intval) | ||
1410 | { | ||
1411 | /* Handle contionals */ | ||
1412 | const struct settings_list *s = settings+token->value.i; | ||
1413 | switch (s->flags&F_T_MASK) | ||
1414 | { | ||
1415 | case F_T_INT: | ||
1416 | case F_T_UINT: | ||
1417 | if (s->flags&F_RGB) | ||
1418 | /* %?St|name|<#000000|#000001|...|#FFFFFF> */ | ||
1419 | /* shouldn't overflow since colors are stored | ||
1420 | * on 16 bits ... | ||
1421 | * but this is pretty useless anyway */ | ||
1422 | *intval = *(int*)s->setting + 1; | ||
1423 | else if (s->cfg_vals == NULL) | ||
1424 | /* %?St|name|<1st choice|2nd choice|...> */ | ||
1425 | *intval = (*(int*)s->setting-s->int_setting->min) | ||
1426 | /s->int_setting->step + 1; | ||
1427 | else | ||
1428 | /* %?St|name|<1st choice|2nd choice|...> */ | ||
1429 | /* Not sure about this one. cfg_name/vals are | ||
1430 | * indexed from 0 right? */ | ||
1431 | *intval = *(int*)s->setting + 1; | ||
1432 | break; | ||
1433 | case F_T_BOOL: | ||
1434 | /* %?St|name|<if true|if false> */ | ||
1435 | *intval = *(bool*)s->setting?1:2; | ||
1436 | break; | ||
1437 | case F_T_CHARPTR: | ||
1438 | /* %?St|name|<if non empty string|if empty> | ||
1439 | * The string's emptyness discards the setting's | ||
1440 | * prefix and suffix */ | ||
1441 | *intval = ((char*)s->setting)[0]?1:2; | ||
1442 | break; | ||
1443 | default: | ||
1444 | /* This shouldn't happen ... but you never know */ | ||
1445 | *intval = -1; | ||
1446 | break; | ||
1447 | } | ||
1448 | } | ||
1449 | cfg_to_string(token->value.i,buf,buf_size); | ||
1450 | return buf; | ||
1451 | } | ||
1452 | |||
1405 | default: | 1453 | default: |
1406 | return NULL; | 1454 | return NULL; |
1407 | } | 1455 | } |
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index ff402a73a9..4cffb0de2c 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h | |||
@@ -292,7 +292,10 @@ enum wps_token_type { | |||
292 | WPS_VIEWPORT_ENABLE, | 292 | WPS_VIEWPORT_ENABLE, |
293 | 293 | ||
294 | /* buttons */ | 294 | /* buttons */ |
295 | WPS_TOKEN_BUTTON_VOLUME | 295 | WPS_TOKEN_BUTTON_VOLUME, |
296 | |||
297 | /* Setting option */ | ||
298 | WPS_TOKEN_SETTING, | ||
296 | }; | 299 | }; |
297 | 300 | ||
298 | struct wps_token { | 301 | struct wps_token { |
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 88601fd9eb..22b161155e 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -56,6 +56,7 @@ | |||
56 | 56 | ||
57 | #include "gwps.h" | 57 | #include "gwps.h" |
58 | #include "settings.h" | 58 | #include "settings.h" |
59 | #include "settings_list.h" | ||
59 | 60 | ||
60 | #ifdef HAVE_LCD_BITMAP | 61 | #ifdef HAVE_LCD_BITMAP |
61 | #include "bmp.h" | 62 | #include "bmp.h" |
@@ -137,6 +138,8 @@ static int parse_progressbar(const char *wps_bufptr, | |||
137 | struct wps_token *token, struct wps_data *wps_data); | 138 | struct wps_token *token, struct wps_data *wps_data); |
138 | static int parse_dir_level(const char *wps_bufptr, | 139 | static int parse_dir_level(const char *wps_bufptr, |
139 | struct wps_token *token, struct wps_data *wps_data); | 140 | struct wps_token *token, struct wps_data *wps_data); |
141 | static int parse_setting(const char *wps_bufptr, | ||
142 | struct wps_token *token, struct wps_data *wps_data); | ||
140 | 143 | ||
141 | #ifdef HAVE_LCD_BITMAP | 144 | #ifdef HAVE_LCD_BITMAP |
142 | static int parse_viewport_display(const char *wps_bufptr, | 145 | static int parse_viewport_display(const char *wps_bufptr, |
@@ -342,6 +345,8 @@ static const struct wps_tag all_tags[] = { | |||
342 | #endif | 345 | #endif |
343 | #endif | 346 | #endif |
344 | 347 | ||
348 | { WPS_TOKEN_SETTING, "St", WPS_REFRESH_DYNAMIC, parse_setting }, | ||
349 | |||
345 | { WPS_TOKEN_UNKNOWN, "", 0, NULL } | 350 | { WPS_TOKEN_UNKNOWN, "", 0, NULL } |
346 | /* the array MUST end with an empty string (first char is \0) */ | 351 | /* the array MUST end with an empty string (first char is \0) */ |
347 | }; | 352 | }; |
@@ -726,6 +731,39 @@ static int parse_viewport(const char *wps_bufptr, | |||
726 | return skip_end_of_line(wps_bufptr); | 731 | return skip_end_of_line(wps_bufptr); |
727 | } | 732 | } |
728 | 733 | ||
734 | static int parse_setting(const char *wps_bufptr, | ||
735 | struct wps_token *token, | ||
736 | struct wps_data *wps_data) | ||
737 | { | ||
738 | (void)wps_data; | ||
739 | const char *ptr = wps_bufptr; | ||
740 | const char *end; | ||
741 | int i; | ||
742 | |||
743 | /* Find the setting's cfg_name */ | ||
744 | if (*ptr != '|') | ||
745 | return WPS_ERROR_INVALID_PARAM; | ||
746 | ptr++; | ||
747 | end = strchr(ptr,'|'); | ||
748 | if (!end) | ||
749 | return WPS_ERROR_INVALID_PARAM; | ||
750 | |||
751 | /* Find the setting */ | ||
752 | for (i=0; i<nb_settings; i++) | ||
753 | if (settings[i].cfg_name && | ||
754 | !strncmp(settings[i].cfg_name,ptr,end-ptr) && | ||
755 | /* prevent matches on cfg_name prefixes */ | ||
756 | strlen(settings[i].cfg_name)==end-ptr) break; | ||
757 | if (i == nb_settings) | ||
758 | return WPS_ERROR_INVALID_PARAM; | ||
759 | |||
760 | /* Store the setting number */ | ||
761 | token->value.i = i; | ||
762 | |||
763 | /* Skip the rest of the line */ | ||
764 | return end-ptr+2; | ||
765 | } | ||
766 | |||
729 | 767 | ||
730 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) | 768 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) |
731 | static int parse_image_special(const char *wps_bufptr, | 769 | static int parse_image_special(const char *wps_bufptr, |