summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-09-14 09:07:05 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-09-14 09:07:05 +0000
commit74353a7fe46c5d6973bffb2488f7c8276e088e80 (patch)
tree807383a9bb7b21b9dcd4850307f2f1ff861a7bc8 /apps
parent7b86bade5963dc47d3368e9a6e4fc002db79159e (diff)
downloadrockbox-74353a7fe46c5d6973bffb2488f7c8276e088e80.tar.gz
rockbox-74353a7fe46c5d6973bffb2488f7c8276e088e80.zip
The database is now always synched when entering USB mode or shutting down, and not only in the tree browser
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7516 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/misc.c18
-rw-r--r--apps/tree.c30
-rw-r--r--apps/tree.h2
3 files changed, 36 insertions, 14 deletions
diff --git a/apps/misc.c b/apps/misc.c
index ddf8d06e7b..d1b5c2274f 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -46,6 +46,7 @@
#ifdef HAVE_MMC
#include "ata_mmc.h"
#endif
+#include "tree.h"
#ifdef HAVE_LCD_BITMAP
#include "bmp.h"
@@ -381,6 +382,16 @@ bool settings_parseline(char* line, char** name, char** value)
return true;
}
+static void system_flush(void)
+{
+ tree_flush();
+}
+
+static void system_restore(void)
+{
+ tree_restore();
+}
+
static bool clean_shutdown(void (*callback)(void *), void *parameter)
{
#ifdef SIMULATOR
@@ -396,6 +407,9 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
splash(0, true, str(LANG_SHUTTINGDOWN));
if (callback != NULL)
callback(parameter);
+
+ system_flush();
+
shutdown_hw();
}
#endif
@@ -467,7 +481,11 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
#ifdef HAVE_MMC
if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED))
#endif
+ {
+ system_flush();
usb_screen();
+ system_restore();
+ }
return SYS_USB_CONNECTED;
case SYS_POWEROFF:
if (!clean_shutdown(callback, parameter))
diff --git a/apps/tree.c b/apps/tree.c
index a88d58b165..e8bf46f1af 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -566,13 +566,6 @@ static bool check_changed_id3mode(bool currmode)
return currmode;
}
-static void tree_prepare_usb(void *parameter)
-{
- (void) parameter;
- rundb_shutdown();
- tagdb_shutdown();
-}
-
static bool dirbrowse(void)
{
int numentries=0;
@@ -764,13 +757,13 @@ static bool dirbrowse(void)
case TREE_OFF:
if (*tc.dirfilter < NUM_FILTER_MODES)
{
- /* Stop the music if it is playing, else show the shutdown
- screen */
+ /* Stop the music if it is playing, else power off */
if(audio_status())
audio_stop();
else {
if (!charger_inserted()) {
- shutdown_screen();
+ if(shutdown_screen())
+ reload_dir = true;
} else {
charging_splash();
}
@@ -1126,11 +1119,8 @@ static bool dirbrowse(void)
#endif
default:
- if (default_event_handler_ex(button, tree_prepare_usb, NULL)
- == SYS_USB_CONNECTED)
+ if (default_event_handler(button) == SYS_USB_CONNECTED)
{
- tagdb_init(); /* re-init database */
- rundb_init();
if(*tc.dirfilter > NUM_FILTER_MODES)
/* leave sub-browsers after usb, doing otherwise
might be confusing to the user */
@@ -1638,3 +1628,15 @@ void ft_play_filename(char *dir, char *file)
}
}
+/* These two functions are called by the USB and shutdown handlers */
+void tree_flush(void)
+{
+ rundb_shutdown();
+ tagdb_shutdown();
+}
+
+void tree_restore(void)
+{
+ tagdb_init();
+ rundb_init();
+}
diff --git a/apps/tree.h b/apps/tree.h
index 41ef0e527f..a6c41f2af5 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -193,5 +193,7 @@ char *getcwd(char *buf, int size);
void reload_directory(void);
bool check_rockboxdir(void);
struct tree_context* tree_get_context(void);
+void tree_flush(void);
+void tree_restore(void);
#endif