From 9e2807fc666a58aa90c0ff627efff3a97419dda3 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 26 Oct 2008 11:44:21 +0000 Subject: [PATCH] Add a simple plugin (apps/settings_dumper.rock) which dumps the valid values of all the config settings to /settings_dumper.txt. If you notice any settings its not dumping please let me know. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18882 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugin.c | 2 +- apps/plugin.h | 2 + apps/plugins/CATEGORIES | 1 + apps/plugins/SOURCES | 1 + apps/plugins/settings_dumper.c | 151 +++++++++++++++++++++++++++++++++ apps/settings_list.c | 6 ++ apps/settings_list.h | 2 +- 7 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 apps/plugins/settings_dumper.c diff --git a/apps/plugin.c b/apps/plugin.c index a9c9a6c3f8..13c829805f 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -618,7 +618,7 @@ static const struct plugin_api rockbox_api = { appsversion, /* new stuff at the end, sort into place next time the API gets incompatible */ - + get_settings_list, }; int plugin_load(const char* plugin, const void* parameter) diff --git a/apps/plugin.h b/apps/plugin.h index 9544b3851c..1b452bd270 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -89,6 +89,7 @@ void* plugin_get_buffer(size_t *buffer_size); #include "tagcache.h" #include "viewport.h" #include "ata_idle_notify.h" +#include "settings_list.h" #ifdef HAVE_ALBUMART #include "albumart.h" @@ -774,6 +775,7 @@ struct plugin_api { const char *appsversion; /* new stuff at the end, sort into place next time the API gets incompatible */ + const struct settings_list* (*get_settings_list)(int*count); }; diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES index 1cf530b5af..9b18bc3722 100644 --- a/apps/plugins/CATEGORIES +++ b/apps/plugins/CATEGORIES @@ -68,6 +68,7 @@ rocklife,games rockpaint,apps search,viewers searchengine,viewers +settings_dumper,apps shortcuts_append,viewers shortcuts_view,viewers sliding_puzzle,games diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index fe00ebc948..0c27a5b1de 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -14,6 +14,7 @@ random_folder_advance_config.c rockblox.c rockbox_flash.c search.c +settings_dumper.c snow.c sort.c stats.c diff --git a/apps/plugins/settings_dumper.c b/apps/plugins/settings_dumper.c new file mode 100644 index 0000000000..cdf973498b --- /dev/null +++ b/apps/plugins/settings_dumper.c @@ -0,0 +1,151 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: helloworld.c 17847 2008-06-28 18:10:04Z bagder $ + * + * Copyright (C) 2002 Björn Stenberg + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "plugin.h" + +PLUGIN_HEADER + +static const struct plugin_api* rb; +#define FILENAME "/settings_dumper.txt" +static int setting_count = 0; + +static void write_setting(const struct settings_list *setting, int fd, unsigned int group) +{ + char text[1024]; + if (setting->cfg_name == NULL) + return; + if (group && (setting->flags&group) == 0) /* not in the group we are dumping */ + return; + else if (!group && (setting->flags&(F_THEMESETTING|F_RECSETTING|F_EQSETTING|F_SOUNDSETTING))) + return; + setting_count++; + if (setting_count%10 == 0) + rb->fdprintf(fd, "\r\n"); + switch (setting->flags&F_T_MASK) + { + case F_T_INT: + case F_T_UINT: + if (setting->flags&F_RGB) + rb->strcpy(text, "RGB colour value in the form RRGGBB (in hexadecimal)"); + else if (setting->flags&F_T_SOUND) + rb->snprintf(text, sizeof(text), "Min: %d, Max %d", + rb->sound_min(setting->sound_setting->setting), + rb->sound_max(setting->sound_setting->setting)); + else if (setting->flags&F_TABLE_SETTING) + { + char temp[8]; + int i; + rb->snprintf(text, sizeof(text), "Setting allows the following values%s: ", + setting->flags&F_ALLOW_ARBITRARY_VALS? " (And any value between)":""); + for(i=0;itable_setting->count;i++) + { + rb->snprintf(temp, 8, "%d, ", setting->table_setting->values[i]); + rb->strcat(text, temp); + } + } + else if (setting->flags&F_INT_SETTING) + { + int min = setting->int_setting->min, + max = setting->int_setting->max, + step = setting->int_setting->step; + rb->snprintf(text, sizeof(text), "Min: %d, Max: %d, Step size: %d", + min, max, step); + } + else if (setting->flags&F_CHOICE_SETTING && (setting->cfg_vals == NULL)) + { + char temp[64]; + int i; + temp[0] = '\0'; + for(i=0;ichoice_setting->count;i++) + { + rb->snprintf(temp, 64, "%s, ", setting->choice_setting->desc[i]); + rb->strcat(text, temp); + } + } + else if (setting->cfg_vals != NULL) + { + rb->snprintf(text, sizeof(text), "%s", setting->cfg_vals); + } + break; /* F_T_*INT */ + case F_T_BOOL: + rb->snprintf(text, sizeof(text), "on, off"); + break; + case F_T_CHARPTR: + case F_T_UCHARPTR: + if (setting->flags&F_FILENAME) + { + rb->snprintf(text, sizeof(text), "Up to %d characters.", setting->filename_setting->max_len-1); + if (setting->filename_setting->prefix && setting->filename_setting->suffix) + { + rb->strcat(text, "Should start with:\""); + rb->strcat(text, setting->filename_setting->prefix); + rb->strcat(text, "\" And end with:\""); + rb->strcat(text, setting->filename_setting->suffix); + rb->strcat(text, "\""); + } + } + break; + } + rb->fdprintf(fd, "%s: %s\r\n", setting->cfg_name, text); +} + + + +/* this is the plugin entry point */ +enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) +{ + const struct settings_list *list; + int setting_count, i; + int fd; + (void)parameter; + rb = api; + + fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY); + if (fd < 0) + return PLUGIN_ERROR; + list = rb->get_settings_list(&setting_count); + rb->fdprintf(fd, "# .cfg file created by rockbox %s - " + "http://www.rockbox.org\r\n\r\n", rb->appsversion); + + rb->fdprintf(fd, "# -- Sound settings -- #\r\n"); + for(i=0;ifdprintf(fd, "\r\n\r\n# -- Theme settings -- #\r\n"); + for(i=0;ifdprintf(fd, "\r\n\r\n# -- Recording settings -- #\r\n"); + for(i=0;ifdprintf(fd, "\r\n\r\n# -- EQ settings -- #\r\n"); + for(i=0;ifdprintf(fd, "\r\n\r\n# -- Other settings -- #\r\n"); + for(i=0;ifdprintf(fd, "\r\n\r\n# Total settings count: %d\r\n", setting_count); + rb->close(fd); + rb->splash(HZ, "Done!"); + return PLUGIN_OK; +} diff --git a/apps/settings_list.c b/apps/settings_list.c index 6d604574f1..7f870b442e 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1367,3 +1367,9 @@ const struct settings_list settings[] = { }; const int nb_settings = sizeof(settings)/sizeof(*settings); + +const struct settings_list* get_settings_list(int*count) +{ + *count = nb_settings; + return settings; +} diff --git a/apps/settings_list.h b/apps/settings_list.h index c3a8cbaf3e..326effdc40 100644 --- a/apps/settings_list.h +++ b/apps/settings_list.h @@ -139,7 +139,7 @@ struct settings_list { const struct table_setting *table_setting; /* F_TABLE_SETTING */ }; }; - +const struct settings_list* get_settings_list(int*count); #ifndef PLUGIN /* not needed for plugins and just causes compile error, possibly fix proberly later */