settings: Remove setting ID return from find_setting()
Now that all users have replaced setting IDs with direct pointers, find_setting() and friends don't need to return an ID value. Change-Id: I8c5c31bb68d3bca5350d43538335265a55fd5517
This commit is contained in:
parent
767ddef550
commit
701e262d3d
15 changed files with 56 additions and 67 deletions
|
@ -823,7 +823,7 @@ static int parse_setting_and_lang(struct skin_element *element,
|
|||
else
|
||||
{
|
||||
#ifndef __PCTOOL__
|
||||
const struct settings_list *setting = find_setting_by_cfgname(temp, NULL);
|
||||
const struct settings_list *setting = find_setting_by_cfgname(temp);
|
||||
if (!setting)
|
||||
return WPS_ERROR_INVALID_PARAM;
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ static int parse_progressbar_tag(struct skin_element* element,
|
|||
param++;
|
||||
text = SKINOFFSETTOPTR(skin_buffer, param->data.text);
|
||||
#ifndef __PCTOOL__
|
||||
pb->setting = find_setting_by_cfgname(text, NULL);
|
||||
pb->setting = find_setting_by_cfgname(text);
|
||||
if (!pb->setting)
|
||||
return WPS_ERROR_INVALID_PARAM;
|
||||
#endif
|
||||
|
@ -1548,7 +1548,7 @@ static int touchregion_setup_setting(struct skin_element *element, int param_no,
|
|||
#ifndef __PCTOOL__
|
||||
int p = param_no;
|
||||
char *name = get_param_text(element, p++);
|
||||
const struct settings_list *setting = find_setting_by_cfgname(name, NULL);
|
||||
const struct settings_list *setting = find_setting_by_cfgname(name);
|
||||
if (!setting)
|
||||
return WPS_ERROR_INVALID_PARAM;
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
|
|||
case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */
|
||||
{
|
||||
const struct settings_list *rep_setting =
|
||||
find_setting(&global_settings.repeat_mode, NULL);
|
||||
find_setting(&global_settings.repeat_mode);
|
||||
option_select_next_val(rep_setting, false, true);
|
||||
audio_flush_and_reload_tracks();
|
||||
returncode = ACTION_REDRAW;
|
||||
|
|
|
@ -147,7 +147,7 @@ static const char* get_menu_item_name(int selected_item,
|
|||
type = (menu->flags&MENU_TYPE_MASK);
|
||||
if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT))
|
||||
{
|
||||
const struct settings_list *v = find_setting(menu->variable, NULL);
|
||||
const struct settings_list *v = find_setting(menu->variable);
|
||||
if (v)
|
||||
return str(v->lang_id);
|
||||
else return "Not Done yet!";
|
||||
|
@ -356,14 +356,12 @@ void do_setting_from_menu(const struct menu_item_ex *temp,
|
|||
struct viewport parent[NB_SCREENS])
|
||||
{
|
||||
char *title;
|
||||
int setting_id;
|
||||
if (!temp)
|
||||
{
|
||||
panicf("do_setting_from_menu, NULL pointer");
|
||||
return;
|
||||
}
|
||||
const struct settings_list *setting =
|
||||
find_setting(temp->variable, &setting_id);
|
||||
const struct settings_list *setting = find_setting(temp->variable);
|
||||
|
||||
if ((temp->flags&MENU_TYPE_MASK) == MT_SETTING_W_TEXT)
|
||||
title = temp->callback_and_desc->desc;
|
||||
|
@ -523,7 +521,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
|||
ID2P(LANG_RESET_SETTING));
|
||||
const struct menu_item_ex *context_menu;
|
||||
const struct settings_list *setting =
|
||||
find_setting(temp->variable, NULL);
|
||||
find_setting(temp->variable);
|
||||
#ifdef HAVE_QUICKSCREEN
|
||||
if (is_setting_quickscreenable(setting))
|
||||
context_menu = &quickscreen_able_option;
|
||||
|
|
|
@ -462,30 +462,30 @@ int rectrigger(void)
|
|||
/* TODO: what to do if there is < 4 lines on the screen? */
|
||||
|
||||
settings[TRIGGER_MODE] =
|
||||
find_setting(&global_settings.rec_trigger_mode, NULL);
|
||||
find_setting(&global_settings.rec_trigger_mode);
|
||||
settings[TRIGGER_TYPE] =
|
||||
find_setting(&global_settings.rec_trigger_type, NULL);
|
||||
find_setting(&global_settings.rec_trigger_type);
|
||||
settings[PRERECORD_TIME] =
|
||||
find_setting(&global_settings.rec_prerecord_time, NULL);
|
||||
find_setting(&global_settings.rec_prerecord_time);
|
||||
settings[START_DURATION] =
|
||||
find_setting(&global_settings.rec_start_duration, NULL);
|
||||
find_setting(&global_settings.rec_start_duration);
|
||||
settings[STOP_POSTREC] =
|
||||
find_setting(&global_settings.rec_stop_postrec, NULL);
|
||||
find_setting(&global_settings.rec_stop_postrec);
|
||||
settings[STOP_GAP] =
|
||||
find_setting(&global_settings.rec_stop_gap, NULL);
|
||||
find_setting(&global_settings.rec_stop_gap);
|
||||
if (global_settings.peak_meter_dbfs) /* show the dB settings */
|
||||
{
|
||||
settings[START_THRESHOLD] =
|
||||
find_setting(&global_settings.rec_start_thres_db, NULL);
|
||||
find_setting(&global_settings.rec_start_thres_db);
|
||||
settings[STOP_THRESHOLD] =
|
||||
find_setting(&global_settings.rec_stop_thres_db, NULL);
|
||||
find_setting(&global_settings.rec_stop_thres_db);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings[START_THRESHOLD] =
|
||||
find_setting(&global_settings.rec_start_thres_linear, NULL);
|
||||
find_setting(&global_settings.rec_start_thres_linear);
|
||||
settings[STOP_THRESHOLD] =
|
||||
find_setting(&global_settings.rec_stop_thres_linear, NULL);
|
||||
find_setting(&global_settings.rec_stop_thres_linear);
|
||||
}
|
||||
gui_synclist_init(&lists, trigger_get_name, settings, false, 2, vp);
|
||||
gui_synclist_set_nb_items(&lists, TRIG_OPTION_COUNT*2);
|
||||
|
|
|
@ -669,10 +669,13 @@ static const struct plugin_api rockbox_api = {
|
|||
tagcache_retrieve,
|
||||
tagcache_search_finish,
|
||||
tagcache_get_numeric,
|
||||
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
|
||||
tagcache_get_stat,
|
||||
#if defined(HAVE_TC_RAMCACHE)
|
||||
tagcache_is_in_ram,
|
||||
#if defined(HAVE_DIRCACHE)
|
||||
tagcache_fill_tags,
|
||||
#endif
|
||||
tagcache_get_stat,
|
||||
#endif
|
||||
#endif /* HAVE_TAGCACHE */
|
||||
|
||||
#ifdef HAVE_ALBUMART
|
||||
|
@ -820,11 +823,6 @@ static const struct plugin_api rockbox_api = {
|
|||
|
||||
/* new stuff at the end, sort into place next time
|
||||
the API gets incompatible */
|
||||
#ifdef HAVE_TAGCACHE
|
||||
#ifdef HAVE_TC_RAMCACHE
|
||||
tagcache_is_in_ram,
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
static int plugin_buffer_handle;
|
||||
|
|
|
@ -157,12 +157,12 @@ int plugin_open(const char *plugin, const char *parameter);
|
|||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 256
|
||||
#define PLUGIN_API_VERSION 257
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
new function which are "waiting" at the end of the function table) */
|
||||
#define PLUGIN_MIN_API_VERSION 255
|
||||
#define PLUGIN_MIN_API_VERSION 257
|
||||
|
||||
/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
|
||||
|
||||
|
@ -766,10 +766,13 @@ struct plugin_api {
|
|||
int tag, char *buf, long size);
|
||||
void (*tagcache_search_finish)(struct tagcache_search *tcs);
|
||||
long (*tagcache_get_numeric)(const struct tagcache_search *tcs, int tag);
|
||||
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
|
||||
struct tagcache_stat* (*tagcache_get_stat)(void);
|
||||
#if defined(HAVE_TC_RAMCACHE)
|
||||
bool (*tagcache_is_in_ram)(void);
|
||||
#if defined(HAVE_DIRCACHE)
|
||||
bool (*tagcache_fill_tags)(struct mp3entry *id3, const char *filename);
|
||||
#endif
|
||||
struct tagcache_stat* (*tagcache_get_stat)(void);
|
||||
#endif
|
||||
#endif /* HAVE_TAGCACHE */
|
||||
|
||||
#ifdef HAVE_ALBUMART
|
||||
|
@ -824,7 +827,7 @@ struct plugin_api {
|
|||
|
||||
/* options */
|
||||
const struct settings_list* (*get_settings_list)(int*count);
|
||||
const struct settings_list* (*find_setting)(const void* variable, int *id);
|
||||
const struct settings_list* (*find_setting)(const void* variable);
|
||||
int (*settings_save)(void);
|
||||
bool (*option_screen)(const struct settings_list *setting,
|
||||
struct viewport parent[NB_SCREENS],
|
||||
|
@ -946,11 +949,6 @@ struct plugin_api {
|
|||
#endif
|
||||
/* new stuff at the end, sort into place next time
|
||||
the API gets incompatible */
|
||||
#ifdef HAVE_TAGCACHE
|
||||
#ifdef HAVE_TC_RAMCACHE
|
||||
bool (*tagcache_is_in_ram)(void);
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
/* plugin header */
|
||||
|
|
|
@ -65,21 +65,21 @@ static bool nexttrack(void)
|
|||
static bool volume(void)
|
||||
{
|
||||
const struct settings_list* vol =
|
||||
rb->find_setting(&rb->global_settings->volume, NULL);
|
||||
rb->find_setting(&rb->global_settings->volume);
|
||||
return rb->option_screen((struct settings_list*)vol, parentvp, false, "Volume");
|
||||
}
|
||||
|
||||
static bool shuffle(void)
|
||||
{
|
||||
const struct settings_list* shuffle =
|
||||
rb->find_setting(&rb->global_settings->playlist_shuffle, NULL);
|
||||
rb->find_setting(&rb->global_settings->playlist_shuffle);
|
||||
return rb->option_screen((struct settings_list*)shuffle, parentvp, false, "Shuffle");
|
||||
}
|
||||
|
||||
static bool repeat_mode(void)
|
||||
{
|
||||
const struct settings_list* repeat =
|
||||
rb->find_setting(&rb->global_settings->repeat_mode, NULL);
|
||||
rb->find_setting(&rb->global_settings->repeat_mode);
|
||||
int old_repeat = rb->global_settings->repeat_mode;
|
||||
|
||||
rb->option_screen((struct settings_list*)repeat, parentvp, false, "Repeat");
|
||||
|
|
|
@ -428,7 +428,7 @@ static void do_opt_menu(void)
|
|||
options.dirty=1; /* Assume that the settings have been changed */
|
||||
|
||||
struct viewport *parentvp = NULL;
|
||||
const struct settings_list* vol = rb->find_setting(&rb->global_settings->volume, NULL);
|
||||
const struct settings_list* vol = rb->find_setting(&rb->global_settings->volume);
|
||||
|
||||
while(!done)
|
||||
{
|
||||
|
|
|
@ -286,7 +286,7 @@ static void do_sound_settings(struct System* sys)
|
|||
case 2:
|
||||
{
|
||||
const struct settings_list* vol =
|
||||
rb->find_setting(&rb->global_settings->volume, NULL);
|
||||
rb->find_setting(&rb->global_settings->volume);
|
||||
rb->option_screen((struct settings_list*)vol, NULL, false, "Volume");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -335,7 +335,6 @@ bool settings_load_config(const char* file, bool apply)
|
|||
{
|
||||
logf("%s()\r\n", __func__);
|
||||
const struct settings_list *setting;
|
||||
int index;
|
||||
int fd;
|
||||
char line[128];
|
||||
char* name;
|
||||
|
@ -351,7 +350,7 @@ bool settings_load_config(const char* file, bool apply)
|
|||
if (!settings_parseline(line, &name, &value))
|
||||
continue;
|
||||
|
||||
setting = find_setting_by_cfgname(name, &index);
|
||||
setting = find_setting_by_cfgname(name);
|
||||
if (!setting)
|
||||
continue;
|
||||
|
||||
|
@ -1158,36 +1157,32 @@ void settings_reset(void)
|
|||
}
|
||||
|
||||
/** Changing setting values **/
|
||||
const struct settings_list* find_setting(const void* variable, int *id)
|
||||
const struct settings_list* find_setting(const void* variable)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<nb_settings;i++)
|
||||
for(int i = 0; i < nb_settings; i++)
|
||||
{
|
||||
if (settings[i].setting == variable)
|
||||
{
|
||||
if (id)
|
||||
*id = i;
|
||||
return &settings[i];
|
||||
}
|
||||
const struct settings_list *setting = &settings[i];
|
||||
if (setting->setting == variable)
|
||||
return setting;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const struct settings_list* find_setting_by_cfgname(const char* name, int *id)
|
||||
const struct settings_list* find_setting_by_cfgname(const char* name)
|
||||
{
|
||||
int i;
|
||||
logf("Searching for Setting: '%s'",name);
|
||||
for (i=0; i<nb_settings; i++)
|
||||
for(int i = 0; i < nb_settings; i++)
|
||||
{
|
||||
if (settings[i].cfg_name &&
|
||||
!strcasecmp(settings[i].cfg_name, name))
|
||||
const struct settings_list *setting = &settings[i];
|
||||
if (setting->cfg_name && !strcasecmp(setting->cfg_name, name))
|
||||
{
|
||||
logf("Found, flags: %s", debug_get_flags(settings[i].flags));
|
||||
if (id) *id = i;
|
||||
return &settings[i];
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
logf("Setting: '%s' Not Found!",name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -263,8 +263,8 @@ void settings_display(void);
|
|||
|
||||
enum optiontype { INT, BOOL };
|
||||
|
||||
const struct settings_list* find_setting(const void* variable, int *id);
|
||||
const struct settings_list* find_setting_by_cfgname(const char* name, int *id);
|
||||
const struct settings_list* find_setting(const void* variable);
|
||||
const struct settings_list* find_setting_by_cfgname(const char* name);
|
||||
bool cfg_int_to_string(const struct settings_list *setting, int val, char* buf, int buf_len);
|
||||
bool cfg_string_to_int(const struct settings_list *setting, int* out, const char* str);
|
||||
void cfg_to_string(const struct settings_list *setting, char* buf, int buf_len);
|
||||
|
|
|
@ -600,7 +600,7 @@ static void qs_load_from_cfg(void *var, char *value)
|
|||
if (*value == '-')
|
||||
*item = NULL;
|
||||
else
|
||||
*item = find_setting_by_cfgname(value, NULL);
|
||||
*item = find_setting_by_cfgname(value);
|
||||
}
|
||||
|
||||
static char* qs_write_to_cfg(void *var, char *buf, int buf_len)
|
||||
|
@ -613,14 +613,14 @@ static char* qs_write_to_cfg(void *var, char *buf, int buf_len)
|
|||
|
||||
static bool qs_is_changed(void* var, void* defaultval)
|
||||
{
|
||||
const struct settings_list *defaultsetting = find_setting(defaultval, NULL);
|
||||
const struct settings_list *defaultsetting = find_setting(defaultval);
|
||||
|
||||
return var != defaultsetting;
|
||||
}
|
||||
|
||||
static void qs_set_default(void* var, void* defaultval)
|
||||
{
|
||||
*(const struct settings_list **)var = find_setting(defaultval, NULL);
|
||||
*(const struct settings_list **)var = find_setting(defaultval);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_TOUCHSCREEN
|
||||
|
|
|
@ -342,7 +342,7 @@ static int readline_cb(int n, char *buf, void *parameters)
|
|||
strmemccpy(sc->u.path, value, MAX_PATH);
|
||||
break;
|
||||
case SHORTCUT_SETTING:
|
||||
sc->u.setting = find_setting_by_cfgname(value, NULL);
|
||||
sc->u.setting = find_setting_by_cfgname(value);
|
||||
break;
|
||||
case SHORTCUT_TIME:
|
||||
#if CONFIG_RTC
|
||||
|
|
|
@ -1488,7 +1488,7 @@ void talk_setting(const void *global_settings_variable)
|
|||
const struct settings_list *setting;
|
||||
if (!global_settings.talk_menu)
|
||||
return;
|
||||
setting = find_setting(global_settings_variable, NULL);
|
||||
setting = find_setting(global_settings_variable);
|
||||
if (setting == NULL)
|
||||
return;
|
||||
if (setting->lang_id)
|
||||
|
|
|
@ -1759,7 +1759,7 @@ void semaphore_wait(struct semaphore *s)
|
|||
\param s
|
||||
\description
|
||||
|
||||
const struct settings_list* find_setting(const void* variable, int *id)
|
||||
const struct settings_list* find_setting(const void* variable)
|
||||
\group options
|
||||
\param variable
|
||||
\param id
|
||||
|
|
Loading…
Reference in a new issue