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 | |
| 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
| -rw-r--r-- | apps/filetree.c | 20 | ||||
| -rw-r--r-- | apps/menu.c | 3 | ||||
| -rw-r--r-- | apps/misc.c | 57 | ||||
| -rw-r--r-- | apps/misc.h | 4 | ||||
| -rw-r--r-- | apps/root_menu.c | 16 |
5 files changed, 64 insertions, 36 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index 5660a9b..4c48710 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -50,17 +50,10 @@ #include "radio.h" #endif -#ifndef SIMULATOR -static int boot_size = 0; -static int boot_cluster; -#endif - #if LCD_DEPTH > 1 #include "backdrop.h" #endif -extern bool boot_changed; - int ft_build_playlist(struct tree_context* c, int start_index) { int i; @@ -266,19 +259,6 @@ int ft_load(struct tree_context* c, const char* tempdir) if ( !(dptr->attr & ATTR_DIRECTORY) ) dptr->attr |= filetype_get_attr((char *)entry->d_name); -#ifdef BOOTFILE - /* memorize/compare details about the boot file */ - if ((c->currdir[1] == 0) && !strcasecmp(entry->d_name, BOOTFILE)) { - if (boot_size) { - if ((entry->size != boot_size) || - (entry->startcluster != boot_cluster)) - boot_changed = true; - } - boot_size = entry->size; - boot_cluster = entry->startcluster; - } -#endif - /* filter out non-visible files */ if ((!(dptr->attr & ATTR_DIRECTORY) && ( (*c->dirfilter == SHOW_PLAYLIST && diff --git a/apps/menu.c b/apps/menu.c index 0ac0166..5722d1f 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -617,7 +617,10 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) #endif } else if(default_event_handler(action) == SYS_USB_CONNECTED) + { ret = MENU_ATTACHED_USB; + done = true; + } gui_syncstatusbar_draw(&statusbars, true); gui_synclist_draw(&lists); } 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 diff --git a/apps/misc.h b/apps/misc.h index 02a4bd8..20cb84b 100644 --- a/apps/misc.h +++ b/apps/misc.h @@ -99,4 +99,8 @@ extern int show_logo(void); int get_replaygain_mode(bool have_track_gain, bool have_album_gain); #endif +#ifdef BOOTFILE +void check_bootfile(bool do_rolo); +#endif + #endif /* MISC_H */ diff --git a/apps/root_menu.c b/apps/root_menu.c index 97115b4..1626e86 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -269,21 +269,6 @@ static const struct root_items items[] = { }; static const int nb_items = sizeof(items)/sizeof(*items); -#ifdef BOOTFILE -extern bool boot_changed; /* from tree.c */ -static void check_boot(void) -{ - if (boot_changed) { - char *lines[]={str(LANG_BOOT_CHANGED), str(LANG_REBOOT_NOW)}; - struct text_message message={lines, 2}; - if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) - rolo_load("/" BOOTFILE); - boot_changed = false; - } -} -#else -# define check_boot() -#endif int item_callback(int action, const struct menu_item_ex *this_item) ; MENUITEM_RETURNVALUE(file_browser, ID2P(LANG_DIR_BROWSER), GO_TO_FILEBROWSER, @@ -443,7 +428,6 @@ void root_menu(void) { case MENU_ATTACHED_USB: case MENU_SELECTED_EXIT: - check_boot(); /* fall through */ case GO_TO_ROOT: if (last_screen != GO_TO_ROOT) |