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
This commit is contained in:
Peter D'Hoye 2007-03-30 21:54:48 +00:00
parent 11fa3a871c
commit d2b305571e
5 changed files with 64 additions and 36 deletions

View file

@ -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 &&

View file

@ -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);
}

View file

@ -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

View file

@ -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 */

View file

@ -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)