From 8289b966b810eb21732ecb905433debf4e872857 Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Sun, 7 Dec 2008 16:20:35 +0000 Subject: Apply FS#9368 : add generic settings tag to WPS. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19357 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'apps/gui/gwps-common.c') 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 @@ #include #include "system.h" #include "settings.h" +#include "settings_list.h" #include "rbunicode.h" #include "rtc.h" #include "audio.h" @@ -1402,6 +1403,53 @@ static const char *get_token_value(struct gui_wps *gwps, token->value.i * TIMEOUT_UNIT)) return "v"; return NULL; + + case WPS_TOKEN_SETTING: + { + if (intval) + { + /* Handle contionals */ + const struct settings_list *s = settings+token->value.i; + switch (s->flags&F_T_MASK) + { + case F_T_INT: + case F_T_UINT: + if (s->flags&F_RGB) + /* %?St|name|<#000000|#000001|...|#FFFFFF> */ + /* shouldn't overflow since colors are stored + * on 16 bits ... + * but this is pretty useless anyway */ + *intval = *(int*)s->setting + 1; + else if (s->cfg_vals == NULL) + /* %?St|name|<1st choice|2nd choice|...> */ + *intval = (*(int*)s->setting-s->int_setting->min) + /s->int_setting->step + 1; + else + /* %?St|name|<1st choice|2nd choice|...> */ + /* Not sure about this one. cfg_name/vals are + * indexed from 0 right? */ + *intval = *(int*)s->setting + 1; + break; + case F_T_BOOL: + /* %?St|name| */ + *intval = *(bool*)s->setting?1:2; + break; + case F_T_CHARPTR: + /* %?St|name| + * The string's emptyness discards the setting's + * prefix and suffix */ + *intval = ((char*)s->setting)[0]?1:2; + break; + default: + /* This shouldn't happen ... but you never know */ + *intval = -1; + break; + } + } + cfg_to_string(token->value.i,buf,buf_size); + return buf; + } + default: return NULL; } -- cgit v1.2.3