1
0
Fork 0
forked from len0rd/rockbox

Const police raid, making a lot of pointers to lang strings const and removing some ugly casting

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17251 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2008-04-26 09:30:24 +00:00
parent e1bc2d5b71
commit 33c44461e1
15 changed files with 58 additions and 56 deletions

View file

@ -187,12 +187,12 @@ bool bookmark_autobookmark(void)
return write_bookmark(false); return write_bookmark(false);
} }
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
unsigned char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY)}; const char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY)};
struct text_message message={(char **)lines, 1}; const struct text_message message={lines, 1};
#else #else
unsigned char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY), const char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY),
str(LANG_CONFIRM_WITH_BUTTON)}; str(LANG_CONFIRM_WITH_BUTTON)};
struct text_message message={(char **)lines, 2}; const struct text_message message={lines, 2};
#endif #endif
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
show_main_backdrop(); /* switch to main backdrop as we may come from wps */ show_main_backdrop(); /* switch to main backdrop as we may come from wps */

View file

@ -104,7 +104,7 @@ bool ft_play_playlist(char* pathname, char* dirname, char* filename)
if (global_settings.warnon_erase_dynplaylist && if (global_settings.warnon_erase_dynplaylist &&
playlist_modified(NULL)) playlist_modified(NULL))
{ {
char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)}; const char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
struct text_message message = {lines, 1}; struct text_message message = {lines, 1};
if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES) if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
@ -408,8 +408,8 @@ int ft_enter(struct tree_context* c)
!global_settings.party_mode && !global_settings.party_mode &&
playlist_modified(NULL)) playlist_modified(NULL))
{ {
char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)}; static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
struct text_message message={lines, 1}; static const struct text_message message={lines, 1};
if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES) if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
break; break;

View file

@ -47,7 +47,7 @@ void gui_textarea_update(struct screen * display)
} }
int gui_textarea_put_message(struct screen * display, int gui_textarea_put_message(struct screen * display,
struct text_message * message, const struct text_message * message,
int ystart) int ystart)
{ {
int i; int i;
@ -78,7 +78,7 @@ void gui_textarea_update_nblines(struct screen * display)
display->nb_lines = height / display->char_height; display->nb_lines = height / display->char_height;
} }
void talk_text_message(struct text_message * message, bool enqueue) void talk_text_message(const struct text_message * message, bool enqueue)
{ {
int line; int line;
if(message) if(message)

View file

@ -25,7 +25,7 @@
struct text_message struct text_message
{ {
char **message_lines; const char **message_lines;
int nb_lines; int nb_lines;
}; };
@ -50,7 +50,7 @@ extern void gui_textarea_update(struct screen * display);
* returns : the number of lines effectively displayed * returns : the number of lines effectively displayed
*/ */
extern int gui_textarea_put_message(struct screen * display, extern int gui_textarea_put_message(struct screen * display,
struct text_message * message, const struct text_message * message,
int ystart); int ystart);
/* /*
* Compute the number of text lines the display can draw with the current font * Compute the number of text lines the display can draw with the current font
@ -63,7 +63,7 @@ extern void gui_textarea_update_nblines(struct screen * display);
* Speak a text_message. The message's lines may be virtual pointers * Speak a text_message. The message's lines may be virtual pointers
* representing language / voicefont IDs (see settings.h). * representing language / voicefont IDs (see settings.h).
*/ */
extern void talk_text_message(struct text_message * message, bool enqueue); extern void talk_text_message(const struct text_message * message, bool enqueue);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* /*

View file

@ -33,9 +33,9 @@
* - no_message : message displayed if answer is 'no' * - no_message : message displayed if answer is 'no'
*/ */
static void gui_yesno_init(struct gui_yesno * yn, static void gui_yesno_init(struct gui_yesno * yn,
struct text_message * main_message, const struct text_message * main_message,
struct text_message * yes_message, const struct text_message * yes_message,
struct text_message * no_message) const struct text_message * no_message)
{ {
yn->main_message=main_message; yn->main_message=main_message;
yn->result_message[YESNO_YES]=yes_message; yn->result_message[YESNO_YES]=yes_message;
@ -92,7 +92,7 @@ static void gui_yesno_draw(struct gui_yesno * yn)
*/ */
static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result) static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
{ {
struct text_message * message=yn->result_message[result]; const struct text_message * message=yn->result_message[result];
if(message==NULL) if(message==NULL)
return false; return false;
gui_textarea_put_message(yn->display, message, 0); gui_textarea_put_message(yn->display, message, 0);
@ -101,9 +101,9 @@ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
#include "debug.h" #include "debug.h"
enum yesno_res gui_syncyesno_run(struct text_message * main_message, enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
struct text_message * yes_message, const struct text_message * yes_message,
struct text_message * no_message) const struct text_message * no_message)
{ {
int i; int i;
unsigned button; unsigned button;

View file

@ -32,8 +32,8 @@ enum yesno_res
struct gui_yesno struct gui_yesno
{ {
struct text_message * main_message; const struct text_message * main_message;
struct text_message * result_message[2]; const struct text_message * result_message[2];
struct screen * display; struct screen * display;
}; };
@ -47,7 +47,7 @@ struct gui_yesno
* - no_message : message displayed if answer is 'no' * - no_message : message displayed if answer is 'no'
*/ */
extern enum yesno_res gui_syncyesno_run( extern enum yesno_res gui_syncyesno_run(
struct text_message * main_message, const struct text_message * main_message,
struct text_message * yes_message, const struct text_message * yes_message,
struct text_message * no_message); const struct text_message * no_message);
#endif /* _GUI_YESNO_H_ */ #endif /* _GUI_YESNO_H_ */

View file

@ -55,15 +55,18 @@ static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG};
static int reset_settings(void) static int reset_settings(void)
{ {
const unsigned char *lines[]={ID2P(LANG_RESET_ASK)}; static const char *lines[]={ID2P(LANG_RESET_ASK)};
const unsigned char *yes_lines[]={ static const char *yes_lines[]={
str(LANG_SETTINGS), ID2P(LANG_SETTINGS),
ID2P(LANG_RESET_DONE_CLEAR) ID2P(LANG_RESET_DONE_CLEAR)
}; };
const unsigned char *no_lines[]={yes_lines[0], ID2P(LANG_CANCEL)}; static const char *no_lines[]={
struct text_message message={(char **)lines, 1}; ID2P(LANG_SETTINGS),
struct text_message yes_message={(char **)yes_lines, 2}; ID2P(LANG_CANCEL)
struct text_message no_message={(char **)no_lines, 2}; };
static const struct text_message message={lines, 1};
static const struct text_message yes_message={yes_lines, 2};
static const struct text_message no_message={no_lines, 2};
switch(gui_syncyesno_run(&message, &yes_message, &no_message)) switch(gui_syncyesno_run(&message, &yes_message, &no_message))
{ {

View file

@ -1050,9 +1050,9 @@ void check_bootfile(bool do_rolo)
if((entry->wrtdate != wrtdate) || if((entry->wrtdate != wrtdate) ||
(entry->wrttime != wrttime)) (entry->wrttime != wrttime))
{ {
char *lines[] = { ID2P(LANG_BOOT_CHANGED), static const char *lines[] = { ID2P(LANG_BOOT_CHANGED),
ID2P(LANG_REBOOT_NOW) }; ID2P(LANG_REBOOT_NOW) };
struct text_message message={ lines, 2 }; static const struct text_message message={ lines, 2 };
button_clear_queue(); /* Empty the keyboard buffer */ button_clear_queue(); /* Empty the keyboard buffer */
if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES) if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES)
rolo_load(BOOTDIR "/" BOOTFILE); rolo_load(BOOTDIR "/" BOOTFILE);

View file

@ -160,11 +160,11 @@ static bool save_playlist(void)
static bool add_to_playlist(int position, bool queue) static bool add_to_playlist(int position, bool queue)
{ {
bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY); bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY);
char *lines[] = { const char *lines[] = {
ID2P(LANG_RECURSE_DIRECTORY_QUESTION), ID2P(LANG_RECURSE_DIRECTORY_QUESTION),
selected_file selected_file
}; };
struct text_message message={lines, 2}; const struct text_message message={lines, 2};
gui_syncsplash(0, ID2P(LANG_WAIT)); gui_syncsplash(0, ID2P(LANG_WAIT));
@ -523,11 +523,11 @@ static int remove_dir(char* dirname, int len)
/* share code for file and directory deletion, saves space */ /* share code for file and directory deletion, saves space */
static bool delete_handler(bool is_dir) static bool delete_handler(bool is_dir)
{ {
char *lines[]={ const char *lines[]={
ID2P(LANG_REALLY_DELETE), ID2P(LANG_REALLY_DELETE),
selected_file selected_file
}; };
char *yes_lines[]={ const char *yes_lines[]={
ID2P(LANG_DELETED), ID2P(LANG_DELETED),
selected_file selected_file
}; };
@ -867,8 +867,8 @@ static bool clipboard_paste(void)
char *cwd, *nameptr; char *cwd, *nameptr;
bool success; bool success;
unsigned char *lines[]={ID2P(LANG_REALLY_OVERWRITE)}; static const char *lines[]={ID2P(LANG_REALLY_OVERWRITE)};
struct text_message message={(char **)lines, 1}; static const struct text_message message={lines, 1};
/* Get the name of the current directory */ /* Get the name of the current directory */
cwd = getcwd(NULL, 0); cwd = getcwd(NULL, 0);

View file

@ -378,11 +378,9 @@ static int add_to_playlist(const char* playlist, char* sel, int sel_attr)
{ {
/* search directory for tracks and append to playlist */ /* search directory for tracks and append to playlist */
bool recurse = false; bool recurse = false;
char *lines[] = { const char *lines[] = {
(char *)str(LANG_RECURSE_DIRECTORY_QUESTION), str(LANG_RECURSE_DIRECTORY_QUESTION), sel};
sel const struct text_message message={lines, 2};
};
struct text_message message={lines, 2};
struct add_track_context context; struct add_track_context context;
if (global_settings.recursive_dir_insert != RECURSE_ASK) if (global_settings.recursive_dir_insert != RECURSE_ASK)

View file

@ -136,11 +136,11 @@ static int scan_presets(void);
/* Function to manipulate all yesno dialogues. /* Function to manipulate all yesno dialogues.
This function needs the output text as an argument. */ This function needs the output text as an argument. */
static bool yesno_pop(char* text) static bool yesno_pop(const char* text)
{ {
int i; int i;
char *lines[]={text}; const char *lines[]={text};
struct text_message message={lines, 1}; const struct text_message message={lines, 1};
bool ret = (gui_syncyesno_run(&message,NULL,NULL)== YESNO_YES); bool ret = (gui_syncyesno_run(&message,NULL,NULL)== YESNO_YES);
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
gui_textarea_clear(&screens[i]); gui_textarea_clear(&screens[i]);

View file

@ -143,8 +143,9 @@ static int browser(void* param)
{ {
/* Prompt the user */ /* Prompt the user */
reinit_attempted = true; reinit_attempted = true;
char *lines[]={ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)}; static const char *lines[]={
struct text_message message={lines, 2}; ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)};
static const struct text_message message={lines, 2};
if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO) if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO)
break; break;
int i; int i;

View file

@ -1270,8 +1270,8 @@ static int runtime_speak_data(int selected_item, void* data)
bool view_runtime(void) bool view_runtime(void)
{ {
unsigned char *lines[]={ID2P(LANG_CLEAR_TIME)}; static const char *lines[]={ID2P(LANG_CLEAR_TIME)};
struct text_message message={(char **)lines, 1}; static const struct text_message message={lines, 1};
struct gui_synclist lists; struct gui_synclist lists;
int action; int action;

View file

@ -1501,8 +1501,8 @@ int tagtree_enter(struct tree_context* c)
!global_settings.party_mode && !global_settings.party_mode &&
playlist_modified(NULL)) playlist_modified(NULL))
{ {
char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)}; static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
struct text_message message={lines, 1}; static const struct text_message message={lines, 1};
if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES) if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
break; break;

View file

@ -645,8 +645,8 @@ static int dirbrowse()
tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */ tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
#ifdef BOOTFILE #ifdef BOOTFILE
if (boot_changed) { if (boot_changed) {
char *lines[]={ID2P(LANG_BOOT_CHANGED), ID2P(LANG_REBOOT_NOW)}; static const char *lines[]={ID2P(LANG_BOOT_CHANGED), ID2P(LANG_REBOOT_NOW)};
struct text_message message={lines, 2}; static const struct text_message message={lines, 2};
if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES)
rolo_load("/" BOOTFILE); rolo_load("/" BOOTFILE);
restore = true; restore = true;