diff --git a/apps/settings.c b/apps/settings.c index a627cce65b..bc6f066e22 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -19,6 +19,12 @@ * KIND, either express or implied. * ****************************************************************************/ +/* Define LOGF_ENABLE to enable logf output in this file */ +/*#define LOGF_ENABLE*/ +/*Define DEBUG_AVAIL_SETTINGS to get a list of all available settings and flags */ +/*#define DEBUG_AVAIL_SETTINGS*/ /* Needs (LOGF_ENABLE) */ +#include "logf.h" + #include #include #include @@ -102,6 +108,12 @@ struct system_status global_status; #else /* creates temp files on save, renames next load, saves old file if desired */ #define CONFIGFILE_TEMP CONFIGFILE".new" #define NVRAM_FILE_TEMP NVRAM_FILE".new" + +#ifdef LOGF_ENABLE +static char *debug_get_flags(uint32_t flags); +#endif +static void debug_available_settings(void); + static void rename_temp_file(const char *tempfile, const char *file, const char *oldfile) @@ -228,6 +240,9 @@ static void write_nvram_data(void) */ void settings_load(int which) { + logf("\r\n%s()\r\n", __func__); + debug_available_settings(); + if (which & SETTINGS_RTC) read_nvram_data(); if (which & SETTINGS_HD) @@ -318,6 +333,7 @@ bool copy_filename_setting(char *buf, size_t buflen, const char *input, bool settings_load_config(const char* file, bool apply) { + logf("%s()\r\n", __func__); const struct settings_list *setting; int index; int fd; @@ -346,17 +362,22 @@ bool settings_load_config(const char* file, bool apply) { case F_T_CUSTOM: setting->custom_setting->load_from_cfg(setting->setting, value); + logf("Val: %s\r\n",value); break; case F_T_INT: case F_T_UINT: #ifdef HAVE_LCD_COLOR if (setting->flags & F_RGB) + { hex_to_rgb(value, (int*)setting->setting); + logf("Val: %s\r\n", value); + } else #endif if (setting->cfg_vals == NULL) { *(int*)setting->setting = atoi(value); + logf("Val: %s\r\n",value); } else { @@ -368,10 +389,17 @@ bool settings_load_config(const char* file, bool apply) *v = setting->table_setting->values[temp]; else *v = temp; + logf("Val: %d\r\n", *v); } else if (setting->flags & F_ALLOW_ARBITRARY_VALS) { *v = atoi(value); + logf("Val: %s\r\n",value); + } + else + { + logf("Error: %s: Not Found! [%s]\r\n", + setting->cfg_name, value); } } break; @@ -379,9 +407,14 @@ bool settings_load_config(const char* file, bool apply) { int temp; if (cfg_string_to_int(setting, &temp, value)) + { *(bool*)setting->setting = !!temp; + logf("Val: %s\r\n", value); + } if (setting->bool_setting->option_callback) + { setting->bool_setting->option_callback(!!temp); + } break; } /* these can be plain text, filenames, or dirnames */ @@ -391,6 +424,7 @@ bool settings_load_config(const char* file, bool apply) const struct filename_setting *fs = setting->filename_setting; copy_filename_setting((char*)setting->setting, fs->max_len, value, fs); + logf("Val: %s\r\n", value); break; } } @@ -544,6 +578,7 @@ static bool is_changed(const struct settings_list *setting) static bool settings_write_config(const char* filename, int options) { + logf("%s\r\n", __func__); int i; int fd; char value[MAX_PATH]; @@ -583,8 +618,9 @@ static bool settings_write_config(const char* filename, int options) continue; break; } - cfg_to_string(setting, value, MAX_PATH); + logf("Written: '%s: %s'\r\n",setting->cfg_name, value); + fdprintf(fd,"%s: %s\r\n",setting->cfg_name,value); } /* for(...) */ close(fd); @@ -631,6 +667,7 @@ void status_save(void) int settings_save(void) { + logf("%s", __func__); update_runtime(); register_storage_idle_func(flush_config_block_callback); return 0; @@ -772,6 +809,7 @@ void sound_settings_apply(void) void settings_apply(bool read_disk) { + logf("%s", __func__); int rc; CHART(">set_codepage"); set_codepage(global_settings.default_codepage); @@ -1114,18 +1152,22 @@ const struct settings_list* find_setting(const void* variable, int *id) } return NULL; } + const struct settings_list* find_setting_by_cfgname(const char* name, int *id) { int i; + logf("Searching for Setting: '%s'",name); for (i=0; i