Rearrange these files so they are more managable. No real code changes. Some functions/variables in these are possibly out of place and
should be considered for moving. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12142 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bc60af1daf
commit
41bd24e7dc
2 changed files with 320 additions and 312 deletions
398
apps/settings.c
398
apps/settings.c
|
@ -22,36 +22,23 @@
|
|||
#include <limits.h>
|
||||
#include "inttypes.h"
|
||||
#include "config.h"
|
||||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "action.h"
|
||||
#include "crc32.h"
|
||||
#include "settings.h"
|
||||
#include "disk.h"
|
||||
#include "panic.h"
|
||||
#include "debug.h"
|
||||
#include "usb.h"
|
||||
#include "backlight.h"
|
||||
#include "lcd.h"
|
||||
#include "audio.h"
|
||||
#include "mp3_playback.h"
|
||||
#include "mpeg.h"
|
||||
#include "talk.h"
|
||||
#include "string.h"
|
||||
#include "ata.h"
|
||||
#include "ata_idle_notify.h"
|
||||
#include "fat.h"
|
||||
#include "power.h"
|
||||
#include "powermgmt.h"
|
||||
#include "status.h"
|
||||
#include "atoi.h"
|
||||
#include "screens.h"
|
||||
#include "ctype.h"
|
||||
#include "file.h"
|
||||
#include "errno.h"
|
||||
#include "system.h"
|
||||
#include "misc.h"
|
||||
#include "timefuncs.h"
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
#include "font.h"
|
||||
|
@ -62,11 +49,9 @@
|
|||
#include "language.h"
|
||||
#include "gwps.h"
|
||||
#include "powermgmt.h"
|
||||
#include "bookmark.h"
|
||||
#include "sprintf.h"
|
||||
#include "keyboard.h"
|
||||
#include "version.h"
|
||||
#include "rtc.h"
|
||||
#include "sound.h"
|
||||
#include "rbunicode.h"
|
||||
#include "dircache.h"
|
||||
|
@ -117,7 +102,7 @@ const char rec_base_directory[] = REC_BASE_DIR;
|
|||
|
||||
long lasttime = 0;
|
||||
|
||||
/* NVRAM stuff, if the target doesnt have NVRAM it is saved in ROCKBOX_DIR /nvram.bin */
|
||||
/** NVRAM stuff, if the target doesnt have NVRAM it is saved in ROCKBOX_DIR /nvram.bin **/
|
||||
/* NVRAM is set out as
|
||||
[0] 'R'
|
||||
[1] 'b'
|
||||
|
@ -227,6 +212,139 @@ static bool write_nvram_data(char* buf, int max_len)
|
|||
return true;
|
||||
}
|
||||
|
||||
/** Reading from a config file **/
|
||||
/*
|
||||
* load settings from disk or RTC RAM
|
||||
*/
|
||||
void settings_load(int which)
|
||||
{
|
||||
DEBUGF( "reload_all_settings()\n" );
|
||||
if (which&SETTINGS_RTC)
|
||||
read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
||||
if (which&SETTINGS_HD)
|
||||
{
|
||||
settings_load_config(CONFIGFILE,false);
|
||||
settings_load_config(FIXEDSETTINGSFILE,false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool cfg_string_to_int(int setting_id, int* out, char* str)
|
||||
{
|
||||
const char* start = settings[setting_id].cfg_vals;
|
||||
char* end = NULL;
|
||||
char temp[MAX_PATH];
|
||||
int count = 0;
|
||||
while (1)
|
||||
{
|
||||
end = strchr(start, ',');
|
||||
if (!end)
|
||||
{
|
||||
if (!strcmp(str, start))
|
||||
{
|
||||
*out = count;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
strncpy(temp, start, end-start);
|
||||
temp[end-start] = '\0';
|
||||
if (!strcmp(str, temp))
|
||||
{
|
||||
*out = count;
|
||||
return true;
|
||||
}
|
||||
start = end +1;
|
||||
count++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool settings_load_config(const char* file, bool apply)
|
||||
{
|
||||
int fd;
|
||||
char line[128];
|
||||
char* name;
|
||||
char* value;
|
||||
int i;
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return false;
|
||||
|
||||
while (read_line(fd, line, sizeof line) > 0)
|
||||
{
|
||||
if (!settings_parseline(line, &name, &value))
|
||||
continue;
|
||||
for(i=0; i<nb_settings; i++)
|
||||
{
|
||||
if (settings[i].cfg_name == NULL)
|
||||
continue;
|
||||
if (!strcasecmp(name,settings[i].cfg_name))
|
||||
{
|
||||
switch (settings[i].flags&F_T_MASK)
|
||||
{
|
||||
case F_T_INT:
|
||||
case F_T_UINT:
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
if (settings[i].flags&F_RGB)
|
||||
*(int*)settings[i].setting = hex_to_rgb(value);
|
||||
else
|
||||
#endif
|
||||
if (settings[i].cfg_vals == NULL)
|
||||
{
|
||||
*(int*)settings[i].setting = atoi(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg_string_to_int(i,(int*)settings[i].setting,value);
|
||||
}
|
||||
break;
|
||||
case F_T_BOOL:
|
||||
{
|
||||
int temp;
|
||||
if (cfg_string_to_int(i,&temp,value))
|
||||
*(bool*)settings[i].setting = (temp==0?false:true);
|
||||
break;
|
||||
}
|
||||
case F_T_CHARPTR:
|
||||
case F_T_UCHARPTR:
|
||||
{
|
||||
char storage[MAX_PATH];
|
||||
if (settings[i].filename_setting->prefix)
|
||||
{
|
||||
int len = strlen(settings[i].filename_setting->prefix);
|
||||
if (!strncmp(value,settings[i].filename_setting->prefix,len))
|
||||
{
|
||||
strncpy(storage,&value[len],MAX_PATH);
|
||||
}
|
||||
else strncpy(storage,value,MAX_PATH);
|
||||
}
|
||||
else strncpy(storage,value,MAX_PATH);
|
||||
if (settings[i].filename_setting->suffix)
|
||||
{
|
||||
char *s = strcasestr(storage,settings[i].filename_setting->suffix);
|
||||
if (s) *s = '\0';
|
||||
}
|
||||
strncpy((char*)settings[i].setting,storage,
|
||||
settings[i].filename_setting->max_len);
|
||||
((char*)settings[i].setting)
|
||||
[settings[i].filename_setting->max_len-1] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} /* if (!strcmp(name,settings[i].cfg_name)) */
|
||||
} /* for(...) */
|
||||
} /* while(...) */
|
||||
|
||||
close(fd);
|
||||
settings_save();
|
||||
if (apply)
|
||||
settings_apply();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Writing to a config file and saving settings **/
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
/*
|
||||
* Helper function to convert a string of 6 hex digits to a native colour
|
||||
|
@ -258,7 +376,7 @@ static int hex_to_rgb(const char* hex)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_LCD_COLOR */
|
||||
static bool cfg_int_to_string(int setting_id, int val, char* buf)
|
||||
{
|
||||
const char* start = settings[setting_id].cfg_vals;
|
||||
|
@ -416,9 +534,35 @@ int settings_save( void )
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
bool settings_save_config(void)
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
|
||||
create_numbered_filename(filename, ROCKBOX_DIR, "config", ".cfg", 2
|
||||
IF_CNFN_NUM_(, NULL));
|
||||
|
||||
/* allow user to modify filename */
|
||||
while (true) {
|
||||
if (!kbd_input(filename, sizeof filename)) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
gui_syncsplash(HZ, true, str(LANG_MENU_SETTING_CANCEL));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (settings_write_config(filename))
|
||||
gui_syncsplash(HZ, true, str(LANG_SETTINGS_SAVED));
|
||||
else gui_syncsplash(HZ, true, str(LANG_FAILED));
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Apply and Reset settings **/
|
||||
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
/**
|
||||
/*
|
||||
* Applies the range infos stored in global_settings to
|
||||
* the peak meter.
|
||||
*/
|
||||
|
@ -671,189 +815,6 @@ void settings_apply(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* load settings from disk or RTC RAM
|
||||
*/
|
||||
void settings_load(int which)
|
||||
{
|
||||
DEBUGF( "reload_all_settings()\n" );
|
||||
if (which&SETTINGS_RTC)
|
||||
read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
||||
if (which&SETTINGS_HD)
|
||||
{
|
||||
settings_load_config(CONFIGFILE,false);
|
||||
settings_load_config(FIXEDSETTINGSFILE,false);
|
||||
}
|
||||
}
|
||||
|
||||
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 != '.') && (ptr != fptr)) {
|
||||
extlen++;
|
||||
ptr--;
|
||||
}
|
||||
if(ptr == fptr) extlen = 0;
|
||||
|
||||
if (strncasecmp(ROCKBOX_DIR, filename ,strlen(ROCKBOX_DIR)) ||
|
||||
(len-extlen > maxlen))
|
||||
return;
|
||||
|
||||
strncpy(setting, fptr, len-extlen);
|
||||
setting[len-extlen]=0;
|
||||
|
||||
settings_save();
|
||||
}
|
||||
static bool cfg_string_to_int(int setting_id, int* out, char* str)
|
||||
{
|
||||
const char* start = settings[setting_id].cfg_vals;
|
||||
char* end = NULL;
|
||||
char temp[MAX_PATH];
|
||||
int count = 0;
|
||||
while (1)
|
||||
{
|
||||
end = strchr(start, ',');
|
||||
if (!end)
|
||||
{
|
||||
if (!strcmp(str, start))
|
||||
{
|
||||
*out = count;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
strncpy(temp, start, end-start);
|
||||
temp[end-start] = '\0';
|
||||
if (!strcmp(str, temp))
|
||||
{
|
||||
*out = count;
|
||||
return true;
|
||||
}
|
||||
start = end +1;
|
||||
count++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool settings_load_config(const char* file, bool apply)
|
||||
{
|
||||
int fd;
|
||||
char line[128];
|
||||
char* name;
|
||||
char* value;
|
||||
int i;
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return false;
|
||||
|
||||
while (read_line(fd, line, sizeof line) > 0)
|
||||
{
|
||||
if (!settings_parseline(line, &name, &value))
|
||||
continue;
|
||||
for(i=0; i<nb_settings; i++)
|
||||
{
|
||||
if (settings[i].cfg_name == NULL)
|
||||
continue;
|
||||
if (!strcasecmp(name,settings[i].cfg_name))
|
||||
{
|
||||
switch (settings[i].flags&F_T_MASK)
|
||||
{
|
||||
case F_T_INT:
|
||||
case F_T_UINT:
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
if (settings[i].flags&F_RGB)
|
||||
*(int*)settings[i].setting = hex_to_rgb(value);
|
||||
else
|
||||
#endif
|
||||
if (settings[i].cfg_vals == NULL)
|
||||
{
|
||||
*(int*)settings[i].setting = atoi(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg_string_to_int(i,(int*)settings[i].setting,value);
|
||||
}
|
||||
break;
|
||||
case F_T_BOOL:
|
||||
{
|
||||
int temp;
|
||||
if (cfg_string_to_int(i,&temp,value))
|
||||
*(bool*)settings[i].setting = (temp==0?false:true);
|
||||
break;
|
||||
}
|
||||
case F_T_CHARPTR:
|
||||
case F_T_UCHARPTR:
|
||||
{
|
||||
char storage[MAX_PATH];
|
||||
if (settings[i].filename_setting->prefix)
|
||||
{
|
||||
int len = strlen(settings[i].filename_setting->prefix);
|
||||
if (!strncmp(value,settings[i].filename_setting->prefix,len))
|
||||
{
|
||||
strncpy(storage,&value[len],MAX_PATH);
|
||||
}
|
||||
else strncpy(storage,value,MAX_PATH);
|
||||
}
|
||||
else strncpy(storage,value,MAX_PATH);
|
||||
if (settings[i].filename_setting->suffix)
|
||||
{
|
||||
char *s = strcasestr(storage,settings[i].filename_setting->suffix);
|
||||
if (s) *s = '\0';
|
||||
}
|
||||
strncpy((char*)settings[i].setting,storage,
|
||||
settings[i].filename_setting->max_len);
|
||||
((char*)settings[i].setting)
|
||||
[settings[i].filename_setting->max_len-1] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} /* if (!strcmp(name,settings[i].cfg_name)) */
|
||||
} /* for(...) */
|
||||
} /* while(...) */
|
||||
|
||||
close(fd);
|
||||
settings_save();
|
||||
if (apply)
|
||||
settings_apply();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool settings_save_config(void)
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
|
||||
create_numbered_filename(filename, ROCKBOX_DIR, "config", ".cfg", 2
|
||||
IF_CNFN_NUM_(, NULL));
|
||||
|
||||
/* allow user to modify filename */
|
||||
while (true) {
|
||||
if (!kbd_input(filename, sizeof filename)) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
gui_syncsplash(HZ, true, str(LANG_MENU_SETTING_CANCEL));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (settings_write_config(filename))
|
||||
gui_syncsplash(HZ, true, str(LANG_SETTINGS_SAVED));
|
||||
else gui_syncsplash(HZ, true, str(LANG_FAILED));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -893,6 +854,8 @@ void settings_reset(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
/** Changing setting values **/
|
||||
|
||||
bool set_bool(const char* string, bool* variable )
|
||||
{
|
||||
return set_bool_options(string, variable,
|
||||
|
@ -1114,6 +1077,39 @@ bool set_option(const char* string, void* variable, enum optiontype type,
|
|||
selected, &data,function);
|
||||
}
|
||||
|
||||
/** extra stuff which is probably misplaced **/
|
||||
|
||||
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 != '.') && (ptr != fptr)) {
|
||||
extlen++;
|
||||
ptr--;
|
||||
}
|
||||
if(ptr == fptr) extlen = 0;
|
||||
|
||||
if (strncasecmp(ROCKBOX_DIR, filename ,strlen(ROCKBOX_DIR)) ||
|
||||
(len-extlen > maxlen))
|
||||
return;
|
||||
|
||||
strncpy(setting, fptr, len-extlen);
|
||||
setting[len-extlen]=0;
|
||||
|
||||
settings_save();
|
||||
}
|
||||
|
||||
#ifdef HAVE_RECORDING
|
||||
/* This array holds the record timer interval lengths, in seconds */
|
||||
static const unsigned long rec_timer_seconds[] =
|
||||
|
|
234
apps/settings.h
234
apps/settings.h
|
@ -37,6 +37,10 @@
|
|||
#include "backlight.h" /* for [MIN|MAX]_BRIGHTNESS_SETTING */
|
||||
#endif
|
||||
|
||||
/** Setting values defines **/
|
||||
|
||||
/* name of directory where configuration, fonts and other data
|
||||
* files are stored */
|
||||
#ifdef __PCTOOL__
|
||||
#define ROCKBOX_DIR "."
|
||||
#define ROCKBOX_DIR_LEN 1
|
||||
|
@ -61,7 +65,6 @@
|
|||
|
||||
#define MAX_FILENAME 20
|
||||
|
||||
/* data structures */
|
||||
|
||||
#define BOOKMARK_NO 0
|
||||
#define BOOKMARK_YES 1
|
||||
|
@ -100,6 +103,69 @@ extern const char * const trig_durations[TRIG_DURATION_COUNT];
|
|||
#define FOLDER_ADVANCE_NEXT 1
|
||||
#define FOLDER_ADVANCE_RANDOM 2
|
||||
|
||||
/* system defines */
|
||||
#ifndef TARGET_TREE
|
||||
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
#define DEFAULT_CONTRAST_SETTING 40
|
||||
#endif
|
||||
|
||||
#if defined HAVE_LCD_CHARCELLS
|
||||
#define MIN_CONTRAST_SETTING 5
|
||||
#define MAX_CONTRAST_SETTING 31
|
||||
#else
|
||||
#define MIN_CONTRAST_SETTING 5
|
||||
#define MAX_CONTRAST_SETTING 63
|
||||
#endif
|
||||
|
||||
/* As it was */
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
#ifndef DEFAULT_REMOTE_CONTRAST_SETTING
|
||||
/* May be defined in config file if driver code needs the value */
|
||||
#define DEFAULT_REMOTE_CONTRAST_SETTING 42
|
||||
#endif
|
||||
#define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING
|
||||
#define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING
|
||||
#endif
|
||||
|
||||
#endif /* !TARGET_TREE */
|
||||
|
||||
#if !defined(HAVE_LCD_COLOR)
|
||||
#define HAVE_LCD_CONTRAST
|
||||
#endif
|
||||
|
||||
/* repeat mode options */
|
||||
enum
|
||||
{
|
||||
REPEAT_OFF,
|
||||
REPEAT_ALL,
|
||||
REPEAT_ONE,
|
||||
REPEAT_SHUFFLE,
|
||||
#if (AB_REPEAT_ENABLE == 1)
|
||||
REPEAT_AB,
|
||||
#endif
|
||||
NUM_REPEAT_MODES
|
||||
};
|
||||
|
||||
/* dir filter options */
|
||||
/* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
|
||||
* Any new rockbox browse filter modes (accessible through the menu)
|
||||
* must be added after NUM_FILTER_MODES. */
|
||||
enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, SHOW_ID3DB,
|
||||
NUM_FILTER_MODES,
|
||||
SHOW_WPS, SHOW_RWPS, SHOW_FMR, SHOW_CFG, SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS};
|
||||
|
||||
/* recursive dir insert options */
|
||||
enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };
|
||||
|
||||
/* replaygain types */
|
||||
enum { REPLAYGAIN_TRACK = 0, REPLAYGAIN_ALBUM, REPLAYGAIN_SHUFFLE };
|
||||
|
||||
/* show path types */
|
||||
enum { SHOW_PATH_OFF = 0, SHOW_PATH_CURRENT, SHOW_PATH_FULL };
|
||||
|
||||
|
||||
/** virtual pointer stuff.. move to another .h maybe? **/
|
||||
/* These define "virtual pointers", which could either be a literal string,
|
||||
or a mean a string ID if the pointer is in a certain range.
|
||||
This helps to save space for menus and options. */
|
||||
|
@ -126,9 +192,58 @@ extern unsigned char vp_dummy[VIRT_SIZE];
|
|||
/* !defined(HAVE_LCD_COLOR) implies HAVE_LCD_CONTRAST with default 40.
|
||||
Explicitly define HAVE_LCD_CONTRAST in config file for newer ports for
|
||||
simplicity. */
|
||||
#if !defined(HAVE_LCD_COLOR)
|
||||
#define HAVE_LCD_CONTRAST
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/** function prototypes **/
|
||||
|
||||
/* argument bits for settings_load() */
|
||||
#define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
|
||||
#define SETTINGS_HD 2 /* only the settings from the disk sector */
|
||||
#define SETTINGS_ALL 3 /* both */
|
||||
void settings_load(int which);
|
||||
bool settings_load_config(const char* file, bool apply);
|
||||
|
||||
void status_save( void );
|
||||
int settings_save(void);
|
||||
bool settings_save_config(void);
|
||||
|
||||
void settings_reset(void);
|
||||
void sound_settings_apply(void);
|
||||
void settings_apply(void);
|
||||
void settings_apply_pm_range(void);
|
||||
void settings_display(void);
|
||||
|
||||
enum optiontype { INT, BOOL };
|
||||
|
||||
struct opt_items {
|
||||
unsigned const char* string;
|
||||
long voice_id;
|
||||
};
|
||||
bool set_bool_options(const char* string, bool* variable,
|
||||
const char* yes_str, int yes_voice,
|
||||
const char* no_str, int no_voice,
|
||||
void (*function)(bool));
|
||||
|
||||
bool set_bool(const char* string, bool* variable );
|
||||
bool set_option(const char* string, void* variable, enum optiontype type,
|
||||
const struct opt_items* options, int numoptions, void (*function)(int));
|
||||
bool set_int(const unsigned char* string, const char* unit, int voice_unit,
|
||||
int* variable,
|
||||
void (*function)(int), int step, int min, int max,
|
||||
void (*formatter)(char*, int, int, const char*) );
|
||||
|
||||
/* the following are either not in setting.c or shouldnt be */
|
||||
bool set_time_screen(const char* string, struct tm *tm);
|
||||
int read_line(int fd, char* buffer, int buffer_size);
|
||||
void set_file(char* filename, char* setting, int maxlen);
|
||||
unsigned int rec_timesplit_seconds(void);
|
||||
unsigned long rec_sizesplit_bytes(void);
|
||||
void settings_apply_trigger(void);
|
||||
|
||||
|
||||
/** global_settings and global_status struct definitions **/
|
||||
|
||||
struct system_status
|
||||
{
|
||||
int resume_index; /* index in playlist (-1 for no active resume) */
|
||||
|
@ -547,116 +662,13 @@ struct user_settings
|
|||
#endif /* CONFIG_CODEC == SWCODEC */
|
||||
};
|
||||
|
||||
enum optiontype { INT, BOOL };
|
||||
|
||||
struct opt_items {
|
||||
unsigned const char* string;
|
||||
long voice_id;
|
||||
};
|
||||
|
||||
/* prototypes */
|
||||
void status_save( void );
|
||||
int settings_save(void);
|
||||
void settings_load(int which);
|
||||
void settings_reset(void);
|
||||
void sound_settings_apply(void);
|
||||
void settings_apply(void);
|
||||
void settings_apply_pm_range(void);
|
||||
void settings_display(void);
|
||||
|
||||
bool settings_load_config(const char* file, bool apply);
|
||||
bool settings_save_config(void);
|
||||
bool set_bool_options(const char* string, bool* variable,
|
||||
const char* yes_str, int yes_voice,
|
||||
const char* no_str, int no_voice,
|
||||
void (*function)(bool));
|
||||
|
||||
bool set_bool(const char* string, bool* variable );
|
||||
bool set_option(const char* string, void* variable, enum optiontype type,
|
||||
const struct opt_items* options, int numoptions, void (*function)(int));
|
||||
bool set_int(const unsigned char* string, const char* unit, int voice_unit,
|
||||
int* variable,
|
||||
void (*function)(int), int step, int min, int max,
|
||||
void (*formatter)(char*, int, int, const char*) );
|
||||
bool set_time_screen(const char* string, struct tm *tm);
|
||||
int read_line(int fd, char* buffer, int buffer_size);
|
||||
void set_file(char* filename, char* setting, int maxlen);
|
||||
|
||||
unsigned int rec_timesplit_seconds(void);
|
||||
unsigned long rec_sizesplit_bytes(void);
|
||||
void settings_apply_trigger(void);
|
||||
|
||||
/** global variables **/
|
||||
extern long lasttime;
|
||||
/* Recording base directory */
|
||||
extern const char rec_base_directory[];
|
||||
/* global settings */
|
||||
extern struct user_settings global_settings;
|
||||
/* global status */
|
||||
extern struct system_status global_status;
|
||||
/* name of directory where configuration, fonts and other data
|
||||
* files are stored */
|
||||
extern long lasttime;
|
||||
|
||||
/* Recording base directory */
|
||||
extern const char rec_base_directory[];
|
||||
|
||||
/* system defines */
|
||||
#ifndef TARGET_TREE
|
||||
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
#define DEFAULT_CONTRAST_SETTING 40
|
||||
#endif
|
||||
|
||||
#if defined HAVE_LCD_CHARCELLS
|
||||
#define MIN_CONTRAST_SETTING 5
|
||||
#define MAX_CONTRAST_SETTING 31
|
||||
#else
|
||||
#define MIN_CONTRAST_SETTING 5
|
||||
#define MAX_CONTRAST_SETTING 63
|
||||
#endif
|
||||
|
||||
/* As it was */
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
#ifndef DEFAULT_REMOTE_CONTRAST_SETTING
|
||||
/* May be defined in config file if driver code needs the value */
|
||||
#define DEFAULT_REMOTE_CONTRAST_SETTING 42
|
||||
#endif
|
||||
#define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING
|
||||
#define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING
|
||||
#endif
|
||||
|
||||
#endif /* !TARGET_TREE */
|
||||
|
||||
/* argument bits for settings_load() */
|
||||
#define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
|
||||
#define SETTINGS_HD 2 /* only the settings from the disk sector */
|
||||
#define SETTINGS_ALL 3 /* both */
|
||||
|
||||
/* repeat mode options */
|
||||
enum
|
||||
{
|
||||
REPEAT_OFF,
|
||||
REPEAT_ALL,
|
||||
REPEAT_ONE,
|
||||
REPEAT_SHUFFLE,
|
||||
#if (AB_REPEAT_ENABLE == 1)
|
||||
REPEAT_AB,
|
||||
#endif
|
||||
NUM_REPEAT_MODES
|
||||
};
|
||||
|
||||
/* dir filter options */
|
||||
/* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
|
||||
* Any new rockbox browse filter modes (accessible through the menu)
|
||||
* must be added after NUM_FILTER_MODES. */
|
||||
enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, SHOW_ID3DB,
|
||||
NUM_FILTER_MODES,
|
||||
SHOW_WPS, SHOW_RWPS, SHOW_FMR, SHOW_CFG, SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS};
|
||||
|
||||
/* recursive dir insert options */
|
||||
enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };
|
||||
|
||||
/* replaygain types */
|
||||
enum { REPLAYGAIN_TRACK = 0, REPLAYGAIN_ALBUM, REPLAYGAIN_SHUFFLE };
|
||||
|
||||
/* show path types */
|
||||
enum { SHOW_PATH_OFF = 0, SHOW_PATH_CURRENT, SHOW_PATH_FULL };
|
||||
|
||||
#endif /* __SETTINGS_H__ */
|
||||
|
|
Loading…
Reference in a new issue