summaryrefslogtreecommitdiff
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 @@
46#ifdef HAVE_MMC 46#ifdef HAVE_MMC
47#include "ata_mmc.h" 47#include "ata_mmc.h"
48#endif 48#endif
49#include "tree.h"
49 50
50#ifdef HAVE_LCD_BITMAP 51#ifdef HAVE_LCD_BITMAP
51#include "bmp.h" 52#include "bmp.h"
@@ -381,6 +382,16 @@ bool settings_parseline(char* line, char** name, char** value)
381 return true; 382 return true;
382} 383}
383 384
385static void system_flush(void)
386{
387 tree_flush();
388}
389
390static void system_restore(void)
391{
392 tree_restore();
393}
394
384static bool clean_shutdown(void (*callback)(void *), void *parameter) 395static bool clean_shutdown(void (*callback)(void *), void *parameter)
385{ 396{
386#ifdef SIMULATOR 397#ifdef SIMULATOR
@@ -396,6 +407,9 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
396 splash(0, true, str(LANG_SHUTTINGDOWN)); 407 splash(0, true, str(LANG_SHUTTINGDOWN));
397 if (callback != NULL) 408 if (callback != NULL)
398 callback(parameter); 409 callback(parameter);
410
411 system_flush();
412
399 shutdown_hw(); 413 shutdown_hw();
400 } 414 }
401#endif 415#endif
@@ -467,7 +481,11 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
467#ifdef HAVE_MMC 481#ifdef HAVE_MMC
468 if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED)) 482 if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED))
469#endif 483#endif
484 {
485 system_flush();
470 usb_screen(); 486 usb_screen();
487 system_restore();
488 }
471 return SYS_USB_CONNECTED; 489 return SYS_USB_CONNECTED;
472 case SYS_POWEROFF: 490 case SYS_POWEROFF:
473 if (!clean_shutdown(callback, parameter)) 491 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)
566 return currmode; 566 return currmode;
567} 567}
568 568
569static void tree_prepare_usb(void *parameter)
570{
571 (void) parameter;
572 rundb_shutdown();
573 tagdb_shutdown();
574}
575
576static bool dirbrowse(void) 569static bool dirbrowse(void)
577{ 570{
578 int numentries=0; 571 int numentries=0;
@@ -764,13 +757,13 @@ static bool dirbrowse(void)
764 case TREE_OFF: 757 case TREE_OFF:
765 if (*tc.dirfilter < NUM_FILTER_MODES) 758 if (*tc.dirfilter < NUM_FILTER_MODES)
766 { 759 {
767 /* Stop the music if it is playing, else show the shutdown 760 /* Stop the music if it is playing, else power off */
768 screen */
769 if(audio_status()) 761 if(audio_status())
770 audio_stop(); 762 audio_stop();
771 else { 763 else {
772 if (!charger_inserted()) { 764 if (!charger_inserted()) {
773 shutdown_screen(); 765 if(shutdown_screen())
766 reload_dir = true;
774 } else { 767 } else {
775 charging_splash(); 768 charging_splash();
776 } 769 }
@@ -1126,11 +1119,8 @@ static bool dirbrowse(void)
1126#endif 1119#endif
1127 1120
1128 default: 1121 default:
1129 if (default_event_handler_ex(button, tree_prepare_usb, NULL) 1122 if (default_event_handler(button) == SYS_USB_CONNECTED)
1130 == SYS_USB_CONNECTED)
1131 { 1123 {
1132 tagdb_init(); /* re-init database */
1133 rundb_init();
1134 if(*tc.dirfilter > NUM_FILTER_MODES) 1124 if(*tc.dirfilter > NUM_FILTER_MODES)
1135 /* leave sub-browsers after usb, doing otherwise 1125 /* leave sub-browsers after usb, doing otherwise
1136 might be confusing to the user */ 1126 might be confusing to the user */
@@ -1638,3 +1628,15 @@ void ft_play_filename(char *dir, char *file)
1638 } 1628 }
1639} 1629}
1640 1630
1631/* These two functions are called by the USB and shutdown handlers */
1632void tree_flush(void)
1633{
1634 rundb_shutdown();
1635 tagdb_shutdown();
1636}
1637
1638void tree_restore(void)
1639{
1640 tagdb_init();
1641 rundb_init();
1642}
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);
193void reload_directory(void); 193void reload_directory(void);
194bool check_rockboxdir(void); 194bool check_rockboxdir(void);
195struct tree_context* tree_get_context(void); 195struct tree_context* tree_get_context(void);
196void tree_flush(void);
197void tree_restore(void);
196 198
197#endif 199#endif