summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/plugins/CATEGORIES1
-rw-r--r--apps/plugins/SOURCES1
-rw-r--r--apps/plugins/settings_dumper.c151
-rw-r--r--apps/settings_list.c6
-rw-r--r--apps/settings_list.h2
7 files changed, 163 insertions, 2 deletions
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 = {
618 appsversion, 618 appsversion,
619 /* new stuff at the end, sort into place next time 619 /* new stuff at the end, sort into place next time
620 the API gets incompatible */ 620 the API gets incompatible */
621 621 get_settings_list,
622}; 622};
623 623
624int plugin_load(const char* plugin, const void* parameter) 624int 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);
89#include "tagcache.h" 89#include "tagcache.h"
90#include "viewport.h" 90#include "viewport.h"
91#include "ata_idle_notify.h" 91#include "ata_idle_notify.h"
92#include "settings_list.h"
92 93
93#ifdef HAVE_ALBUMART 94#ifdef HAVE_ALBUMART
94#include "albumart.h" 95#include "albumart.h"
@@ -774,6 +775,7 @@ struct plugin_api {
774 const char *appsversion; 775 const char *appsversion;
775 /* new stuff at the end, sort into place next time 776 /* new stuff at the end, sort into place next time
776 the API gets incompatible */ 777 the API gets incompatible */
778 const struct settings_list* (*get_settings_list)(int*count);
777 779
778}; 780};
779 781
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
68rockpaint,apps 68rockpaint,apps
69search,viewers 69search,viewers
70searchengine,viewers 70searchengine,viewers
71settings_dumper,apps
71shortcuts_append,viewers 72shortcuts_append,viewers
72shortcuts_view,viewers 73shortcuts_view,viewers
73sliding_puzzle,games 74sliding_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
14rockblox.c 14rockblox.c
15rockbox_flash.c 15rockbox_flash.c
16search.c 16search.c
17settings_dumper.c
17snow.c 18snow.c
18sort.c 19sort.c
19stats.c 20stats.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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: helloworld.c 17847 2008-06-28 18:10:04Z bagder $
9 *
10 * Copyright (C) 2002 Björn Stenberg
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "plugin.h"
22
23PLUGIN_HEADER
24
25static const struct plugin_api* rb;
26#define FILENAME "/settings_dumper.txt"
27static int setting_count = 0;
28
29static void write_setting(const struct settings_list *setting, int fd, unsigned int group)
30{
31 char text[1024];
32 if (setting->cfg_name == NULL)
33 return;
34 if (group && (setting->flags&group) == 0) /* not in the group we are dumping */
35 return;
36 else if (!group && (setting->flags&(F_THEMESETTING|F_RECSETTING|F_EQSETTING|F_SOUNDSETTING)))
37 return;
38 setting_count++;
39 if (setting_count%10 == 0)
40 rb->fdprintf(fd, "\r\n");
41 switch (setting->flags&F_T_MASK)
42 {
43 case F_T_INT:
44 case F_T_UINT:
45 if (setting->flags&F_RGB)
46 rb->strcpy(text, "RGB colour value in the form RRGGBB (in hexadecimal)");
47 else if (setting->flags&F_T_SOUND)
48 rb->snprintf(text, sizeof(text), "Min: %d, Max %d",
49 rb->sound_min(setting->sound_setting->setting),
50 rb->sound_max(setting->sound_setting->setting));
51 else if (setting->flags&F_TABLE_SETTING)
52 {
53 char temp[8];
54 int i;
55 rb->snprintf(text, sizeof(text), "Setting allows the following values%s: ",
56 setting->flags&F_ALLOW_ARBITRARY_VALS? " (And any value between)":"");
57 for(i=0;i<setting->table_setting->count;i++)
58 {
59 rb->snprintf(temp, 8, "%d, ", setting->table_setting->values[i]);
60 rb->strcat(text, temp);
61 }
62 }
63 else if (setting->flags&F_INT_SETTING)
64 {
65 int min = setting->int_setting->min,
66 max = setting->int_setting->max,
67 step = setting->int_setting->step;
68 rb->snprintf(text, sizeof(text), "Min: %d, Max: %d, Step size: %d",
69 min, max, step);
70 }
71 else if (setting->flags&F_CHOICE_SETTING && (setting->cfg_vals == NULL))
72 {
73 char temp[64];
74 int i;
75 temp[0] = '\0';
76 for(i=0;i<setting->choice_setting->count;i++)
77 {
78 rb->snprintf(temp, 64, "%s, ", setting->choice_setting->desc[i]);
79 rb->strcat(text, temp);
80 }
81 }
82 else if (setting->cfg_vals != NULL)
83 {
84 rb->snprintf(text, sizeof(text), "%s", setting->cfg_vals);
85 }
86 break; /* F_T_*INT */
87 case F_T_BOOL:
88 rb->snprintf(text, sizeof(text), "on, off");
89 break;
90 case F_T_CHARPTR:
91 case F_T_UCHARPTR:
92 if (setting->flags&F_FILENAME)
93 {
94 rb->snprintf(text, sizeof(text), "Up to %d characters.", setting->filename_setting->max_len-1);
95 if (setting->filename_setting->prefix && setting->filename_setting->suffix)
96 {
97 rb->strcat(text, "Should start with:\"");
98 rb->strcat(text, setting->filename_setting->prefix);
99 rb->strcat(text, "\" And end with:\"");
100 rb->strcat(text, setting->filename_setting->suffix);
101 rb->strcat(text, "\"");
102 }
103 }
104 break;
105 }
106 rb->fdprintf(fd, "%s: %s\r\n", setting->cfg_name, text);
107}
108
109
110
111/* this is the plugin entry point */
112enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
113{
114 const struct settings_list *list;
115 int setting_count, i;
116 int fd;
117 (void)parameter;
118 rb = api;
119
120 fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY);
121 if (fd < 0)
122 return PLUGIN_ERROR;
123 list = rb->get_settings_list(&setting_count);
124 rb->fdprintf(fd, "# .cfg file created by rockbox %s - "
125 "http://www.rockbox.org\r\n\r\n", rb->appsversion);
126
127 rb->fdprintf(fd, "# -- Sound settings -- #\r\n");
128 for(i=0;i<setting_count;i++)
129 write_setting(&list[i], fd, F_SOUNDSETTING);
130
131 rb->fdprintf(fd, "\r\n\r\n# -- Theme settings -- #\r\n");
132 for(i=0;i<setting_count;i++)
133 write_setting(&list[i], fd, F_THEMESETTING);
134#ifdef HAVE_RECORDING
135 rb->fdprintf(fd, "\r\n\r\n# -- Recording settings -- #\r\n");
136 for(i=0;i<setting_count;i++)
137 write_setting(&list[i], fd, F_RECSETTING);
138#endif
139 rb->fdprintf(fd, "\r\n\r\n# -- EQ settings -- #\r\n");
140 for(i=0;i<setting_count;i++)
141 write_setting(&list[i], fd, F_EQSETTING);
142
143 rb->fdprintf(fd, "\r\n\r\n# -- Other settings -- #\r\n");
144 for(i=0;i<setting_count;i++)
145 write_setting(&list[i], fd, 0);
146
147 rb->fdprintf(fd, "\r\n\r\n# Total settings count: %d\r\n", setting_count);
148 rb->close(fd);
149 rb->splash(HZ, "Done!");
150 return PLUGIN_OK;
151}
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[] = {
1367}; 1367};
1368 1368
1369const int nb_settings = sizeof(settings)/sizeof(*settings); 1369const int nb_settings = sizeof(settings)/sizeof(*settings);
1370
1371const struct settings_list* get_settings_list(int*count)
1372{
1373 *count = nb_settings;
1374 return settings;
1375}
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 {
139 const struct table_setting *table_setting; /* F_TABLE_SETTING */ 139 const struct table_setting *table_setting; /* F_TABLE_SETTING */
140 }; 140 };
141}; 141};
142 142const struct settings_list* get_settings_list(int*count);
143#ifndef PLUGIN 143#ifndef PLUGIN
144/* not needed for plugins and just causes compile error, 144/* not needed for plugins and just causes compile error,
145 possibly fix proberly later */ 145 possibly fix proberly later */