summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-02-17 09:53:11 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-02-17 09:53:11 +0000
commitbda4ec10fcc5a02bf440cc5392f80c958cfd16bd (patch)
tree3751e54753283e004f09c9e54cc014df074a50d4
parent5eb63848781842b09963017a2cae34d3b8c0f00c (diff)
downloadrockbox-bda4ec10fcc5a02bf440cc5392f80c958cfd16bd.tar.gz
rockbox-bda4ec10fcc5a02bf440cc5392f80c958cfd16bd.tar.bz2
rockbox-bda4ec10fcc5a02bf440cc5392f80c958cfd16bd.zip
Fixed a number of .cfg loader bugs
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3280 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/settings.c101
-rw-r--r--apps/settings.h1
-rw-r--r--apps/tree.c36
-rw-r--r--docs/CUSTOM_CFG_FORMAT16
4 files changed, 92 insertions, 62 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 0a00fc71ad..40513bf4b3 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -762,6 +762,35 @@ static bool settings_parseline(char* line, char** name, char** value)
return true;
}
+void set_file(char* filename, char* setting, int maxlen)
+{
+ char* fptr = strrchr(filename,'/');
+ int len;
+ int extlen = 0;
+ char* ptr;
+
+ if (!fptr)
+ return;
+
+ *fptr = 0;
+ fptr++;
+
+ len = strlen(fptr);
+ ptr = fptr + len;
+ while (*ptr != '.') {
+ extlen++;
+ ptr--;
+ }
+
+ if (strcmp(ROCKBOX_DIR, filename) || (len-extlen > maxlen))
+ return;
+
+ strncpy(setting, fptr, len-extlen);
+ setting[len-extlen]=0;
+
+ settings_save();
+}
+
static void set_sound(char* value, int type, int* setting)
{
int num = atoi(value);
@@ -842,12 +871,20 @@ bool settings_load_config(char* file)
set_sound(value, SOUND_TREBLE, &global_settings.treble);
else if (!strcasecmp(name, "balance"))
set_sound(value, SOUND_BALANCE, &global_settings.balance);
- else if (!strcasecmp(name, "channels"))
- set_sound(value, SOUND_CHANNELS, &global_settings.channel_config);
- else if (!strcasecmp(name, "wps"))
- strncpy(global_settings.wps_file, value, MAX_FILENAME);
- else if (!strcasecmp(name, "lang"))
- strncpy(global_settings.lang_file, value, MAX_FILENAME);
+ else if (!strcasecmp(name, "channels")) {
+ static char* options[] = {
+ "stereo","mono","mono left","mono right"};
+ set_cfg_option(&global_settings.channel_config, value,
+ options, 4);
+ }
+ else if (!strcasecmp(name, "wps")) {
+ if (wps_load(value,true))
+ set_file(value, global_settings.wps_file, MAX_FILENAME);
+ }
+ else if (!strcasecmp(name, "lang")) {
+ if (!lang_load(value))
+ set_file(value, global_settings.lang_file, MAX_FILENAME);
+ }
#ifdef HAVE_LCD_BITMAP
else if (!strcasecmp(name, "font"))
strncpy(global_settings.font_file, value, MAX_FILENAME);
@@ -884,6 +921,20 @@ bool settings_load_config(char* file)
set_cfg_int(&global_settings.peak_meter_max, value, 0, 100);
else if (!strcasecmp(name, "peak meter busy"))
set_cfg_bool(&global_settings.peak_meter_performance, value);
+ else if (!strcasecmp(name, "volume display")) {
+ static char* options[] = {"graphic", "numeric"};
+ set_cfg_option(&global_settings.volume_type, value, options, 2);
+ }
+ else if (!strcasecmp(name, "battery display")) {
+ static char* options[] = {"graphic", "numeric"};
+ set_cfg_option(&global_settings.battery_type, value, options, 2);
+ }
+ else if (!strcasecmp(name, "time format")) {
+ static char* options[] = {"24hour", "12hour"};
+ set_cfg_option(&global_settings.timeformat, value, options, 2);
+ }
+ else if (!strcasecmp(name, "scrollbar"))
+ set_cfg_bool(&global_settings.scrollbar, value);
#endif
else if (!strcasecmp(name, "shuffle"))
set_cfg_bool(&global_settings.playlist_shuffle, value);
@@ -891,45 +942,34 @@ bool settings_load_config(char* file)
static char* options[] = {"off", "all", "one"};
set_cfg_option(&global_settings.repeat_mode, value, options, 3);
}
- else if (!strcasecmp(name, "resume"))
- set_cfg_int(&global_settings.resume, value, 0, 3);
+ else if (!strcasecmp(name, "resume")) {
+ static char* options[] = {"off", "ask", "ask once", "on"};
+ set_cfg_option(&global_settings.resume, value, options, 4);
+ }
else if (!strcasecmp(name, "sort case"))
set_cfg_bool(&global_settings.sort_case, value);
else if (!strcasecmp(name, "show files")) {
- static char* options[] = {"all", "supported","music"};
- set_cfg_option(&global_settings.dirfilter, value, options, 3);
+ static char* options[] = {"all", "supported","music", "playlists"};
+ set_cfg_option(&global_settings.dirfilter, value, options, 4);
}
else if (!strcasecmp(name, "follow playlist"))
set_cfg_bool(&global_settings.browse_current, value);
else if (!strcasecmp(name, "play selected"))
set_cfg_bool(&global_settings.play_selected, value);
- else if (!strcasecmp(name, "volume display")) {
- static char* options[] = {"graphic", "numeric"};
- set_cfg_option(&global_settings.volume_type, value, options, 2);
- }
- else if (!strcasecmp(name, "battery display")) {
- static char* options[] = {"graphic", "numeric"};
- set_cfg_option(&global_settings.battery_type, value, options, 2);
- }
- else if (!strcasecmp(name, "time format")) {
- static char* options[] = {"24hour", "12hour"};
- set_cfg_option(&global_settings.timeformat, value, options, 2);
- }
else if (!strcasecmp(name, "contrast"))
set_cfg_int(&global_settings.contrast, value,
0, MAX_CONTRAST_SETTING);
- else if (!strcasecmp(name, "scrollbar"))
- set_cfg_bool(&global_settings.scrollbar, value);
else if (!strcasecmp(name, "scroll speed"))
set_cfg_int(&global_settings.scroll_speed, value, 1, 10);
else if (!strcasecmp(name, "scan min step")) {
static char* options[] =
- {"1","2","3","4","5","6","8","10","15","20","25"};
+ {"1","2","3","4","5","6","8","10",
+ "15","20","25","30","45","60"};
set_cfg_option(&global_settings.ff_rewind_min_step, value,
- options, 11);
+ options, 14);
}
else if (!strcasecmp(name, "scan accel"))
- set_cfg_int(&global_settings.ff_rewind_min_step, value, 0, 15);
+ set_cfg_int(&global_settings.ff_rewind_accel, value, 0, 15);
else if (!strcasecmp(name, "scroll delay"))
set_cfg_int(&global_settings.scroll_delay, value, 0, 250);
else if (!strcasecmp(name, "backlight timeout")) {
@@ -977,8 +1017,11 @@ bool settings_load_config(char* file)
set_cfg_option(&global_settings.rec_channels, value, options, 2);
}
#endif
- else if (!strcasecmp(name, "poweroff"))
- set_cfg_int(&global_settings.poweroff, value, 0, 15);
+ else if (!strcasecmp(name, "idle poweroff")) {
+ static char* options[] = {"off","1","2","3","4","5","6","7","8",
+ "9","10","15","30","45","60"};
+ set_cfg_option(&global_settings.poweroff, value, options, 15);
+ }
else if (!strcasecmp(name, "battery capacity"))
set_cfg_int(&global_settings.battery_capacity, value,
1500, BATTERY_CAPACITY_MAX);
diff --git a/apps/settings.h b/apps/settings.h
index bfdf12b593..6f127e05dc 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -171,6 +171,7 @@ bool set_option(char* string, int* variable, char* options[],
bool set_int(char* string, char* unit, int* variable,
void (*function)(int), int step, int min, int max );
bool set_time(char* string, int timedate[]);
+void set_file(char* filename, char* setting, int maxlen);
/* global settings */
extern struct user_settings global_settings;
diff --git a/apps/tree.c b/apps/tree.c
index d39c279763..d8ecfb243e 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -947,26 +947,6 @@ static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)
return used;
}
-static void storefile(char* filename, char* setting, int maxlen)
-{
- int len = strlen(filename);
- int extlen = 0;
- char* ptr = filename + len;
-
- while (*ptr != '.') {
- extlen++;
- ptr--;
- }
-
- if (strcmp(ROCKBOX_DIR, currdir) || (len-extlen > maxlen))
- return;
-
- strncpy(setting, filename, len-extlen);
- setting[len-extlen]=0;
-
- settings_save();
-}
-
bool dirbrowse(char *root)
{
int numentries=0;
@@ -1117,8 +1097,8 @@ bool dirbrowse(char *root)
/* wps config file */
case TREE_ATTR_WPS:
wps_load(buf,true);
- storefile(file->name, global_settings.wps_file,
- MAX_FILENAME);
+ set_file(buf, global_settings.wps_file,
+ MAX_FILENAME);
restore = true;
break;
@@ -1152,10 +1132,10 @@ bool dirbrowse(char *root)
case TREE_ATTR_LNG:
if(!lang_load(buf)) {
- storefile(file->name,
- global_settings.lang_file,
- MAX_FILENAME);
-
+ set_file(file->name,
+ global_settings.lang_file,
+ MAX_FILENAME);
+
lcd_clear_display();
#ifdef HAVE_LCD_CHARCELLS
lcd_puts(0, 0, str(LANG_LANGUAGE_LOADED));
@@ -1179,8 +1159,8 @@ bool dirbrowse(char *root)
#ifdef HAVE_LCD_BITMAP
case TREE_ATTR_FONT:
font_load(buf);
- storefile(file->name, global_settings.font_file,
- MAX_FILENAME);
+ set_file(file->name, global_settings.font_file,
+ MAX_FILENAME);
lcd_getstringsize("A", &fw, &fh);
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
diff --git a/docs/CUSTOM_CFG_FORMAT b/docs/CUSTOM_CFG_FORMAT
index 3bb599f1e2..845a9df8c4 100644
--- a/docs/CUSTOM_CFG_FORMAT
+++ b/docs/CUSTOM_CFG_FORMAT
@@ -18,23 +18,24 @@ volume (0 - 100)
bass (-15 - 15)
treble (-15 - 15)
balance (-100 - 100)
+channels (stereo, mono, mono left, mono right)
shuffle (on, off)
repeat (off, all, one)
play selected (on, off)
-resume (off, ask, on)
-scan min step (1, 2, 3, 4, 5, 6, 8, 10, 15, 20, 25) [seconds]
+resume (off, ask, ask once, on)
+scan min step (1, 2, 3, 4, 5, 6, 8, 10, 15, 20, 25, 30, 45, 60) [seconds]
scan accel (0 - 15) [double scan speed every X seconds]
antiskip (0 - 7) [seconds]
volume fade (on, off)
sort case (on, off)
-show files (all, supported, music)
+show files (all, supported, music, playlists)
follow playlist (on, off)
scroll speed (1 - 10) [Hz]
start delay (0 - 250) [1/10s]
-scroll step (1 - 112) [pixel]
+scroll step (1 - 112) [pixels]
bidir limit (0 - 200) [% of screen width]
contrast (0 - 63)
backlight timeout (off, on, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
@@ -42,11 +43,13 @@ backlight timeout (off, on, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
backlight when plugged (on, off)
disk spindown (3 - 254) [seconds]
-disk poweroff (on, off)
battery capacity (1500 - 2400) [mAh]
idle poweroff (off, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 15, 30, 45, 60) [minutes]
+lang (/path/filename.lng)
+wps (/path/filename.wps)
+
Recorder-specific settings (allowed values) [unit]
---------------------------------------------------
loudness (0 - 17)
@@ -66,12 +69,15 @@ peak meter dbfs (on, off) (on = dbfs, off = linear)
peak meter min (0 - 89) [dB] or (0 - 100) [%]
peak meter max (0 - 89) [dB] or (0 - 100) [%]
+statusbar (on, off)
+scrollbar (on, off)
volume display (graphic, numeric)
battery display (graphic, numeric)
time format (12hour, 24hour)
deep discharge (on, off)
trickle charge (on, off)
+disk poweroff (on, off)
rec quality (0 - 7) (0=smallest size, 7=highest quality)
rec frequency (48, 44, 32, 24, 22, 16) [kHz]