diff options
| author | Peter D'Hoye <peter.dhoye@gmail.com> | 2007-03-30 21:54:48 +0000 |
|---|---|---|
| committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2007-03-30 21:54:48 +0000 |
| commit | d2b305571edbdf9d3f941ac22c03c96cd59e4da4 (patch) | |
| tree | 6bf2733d238be0cb8f984a03d0f6f4372d14c7cf /apps/misc.c | |
| parent | 11fa3a871cf59707fa91c1cedfbb0ee9795c1ac1 (diff) | |
| download | rockbox-d2b305571edbdf9d3f941ac22c03c96cd59e4da4.zip rockbox-d2b305571edbdf9d3f941ac22c03c96cd59e4da4.tar.gz rockbox-d2b305571edbdf9d3f941ac22c03c96cd59e4da4.tar.bz2 rockbox-d2b305571edbdf9d3f941ac22c03c96cd59e4da4.tar.xz | |
Check if a new version got installed after usb disconnect and ask if user wants to reboot. Causes disk spinup before showing the usb logo. Also fixes do_menu() not returning to root_menu after usb disconnect.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12972 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
| -rw-r--r-- | apps/misc.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/misc.c b/apps/misc.c index d4be4dd..fb83bde 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -61,6 +61,12 @@ #include "misc.h" +#ifdef BOOTFILE +#include "textarea.h" +#include "rolo.h" +#include "yesno.h" +#endif + /* Format a large-range value for output, using the appropriate unit so that * the displayed value is in the range 1 <= display < 1000 (1024 for "binary" * units) if possible, and 3 significant digits are shown. If a buffer is @@ -766,7 +772,13 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame { scrobbler_flush_cache(); system_flush(); +#ifdef BOOTFILE + check_bootfile(false); /* gets initial size */ +#endif usb_screen(); +#ifdef BOOTFILE + check_bootfile(true); +#endif system_restore(); } return SYS_USB_CONNECTED; @@ -857,3 +869,48 @@ int get_replaygain_mode(bool have_track_gain, bool have_album_gain) return type; } #endif + +#ifdef BOOTFILE +/* + memorize/compare details about the BOOTFILE + we don't use dircache because it may not be up to date after + USB disconnect (scanning in the background) +*/ +void check_bootfile(bool do_rolo) +{ + static int boot_size = 0; + static int boot_cluster = 0; + DIR* dir = NULL; + struct dirent* entry = NULL; + + /* 1. open ROCKBOX_DIR and find the BOOTFILE dir entry */ + dir = opendir(ROCKBOX_DIR); + + if(!dir) return; /* do we want an error splash? */ + + /* loop all files in ROCKBOX_DIR */ + while(0 != (entry = readdir(dir))) + { + if(!strcasecmp(entry->d_name, BOOTFILE)) + { + /* found the bootfile */ + if(boot_size && do_rolo) + { + if((entry->size != boot_size) || + (entry->startcluster != boot_cluster)) + { + char *lines[] = { str(LANG_BOOT_CHANGED), + str(LANG_REBOOT_NOW) }; + struct text_message message={ lines, 2 }; + button_clear_queue(); /* Empty the keyboard buffer */ + if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES) + rolo_load(ROCKBOX_DIR "/" BOOTFILE); + } + } + boot_size = entry->size; + boot_cluster = entry->startcluster; + } + } + closedir(dir); +} +#endif |