summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorSteve Bavin <pondlife@pondlife.me>2007-03-07 19:56:15 +0000
committerSteve Bavin <pondlife@pondlife.me>2007-03-07 19:56:15 +0000
commit8137489e2b967e40c15005c8a4c09903a8a24fc4 (patch)
tree752564abdbe09360dcc97da686d3e45f244578a2 /apps
parent99b2742cd0de7181677f3aa7222caa5dc358ee12 (diff)
downloadrockbox-8137489e2b967e40c15005c8a4c09903a8a24fc4.tar.gz
rockbox-8137489e2b967e40c15005c8a4c09903a8a24fc4.tar.bz2
rockbox-8137489e2b967e40c15005c8a4c09903a8a24fc4.zip
Lead user through database initialisation
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12678 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang22
-rw-r--r--apps/main.c6
-rw-r--r--apps/menus/settings_menu.c17
-rw-r--r--apps/root_menu.c56
-rw-r--r--apps/tagcache.c10
-rw-r--r--apps/tagcache.h2
6 files changed, 100 insertions, 13 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 55838f2b39..9cbcb70404 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -10701,3 +10701,25 @@
*: "Alarm Wake up Screen"
</voice>
</phrase>
+<phrase>
+ id: LANG_BUILDING_DATABASE
+ desc: splash database building progress
+ user:
+ <source>
+ *: "Building database... %d found (OFF for menu)"
+ h100,h120,h300: "Building database... %d found (STOP for menu)"
+ ipod*: "Building database... %d found (PLAY/PAUSE for menu)"
+ x5: "Building database... %d found (Long PLAY for menu)"
+ h10: "Building database... %d found (PREV for menu)"
+ </source>
+ <dest>
+ *: "Building database... %d found (OFF for menu)"
+ h100,h120,h300: "Building database... %d found (STOP for menu)"
+ ipod*: "Building database... %d found (PLAY/PAUSE for menu)"
+ x5: "Building database... %d found (Long PLAY for menu)"
+ h10: "Building database... %d found (PREV for menu)"
+ </dest>
+ <voice>
+ *: ""
+ </voice>
+</phrase>
diff --git a/apps/main.c b/apps/main.c
index a1ea75fdc3..fe397c737c 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -207,10 +207,12 @@ static void init_tagcache(void)
{
#ifdef HAVE_LCD_BITMAP
gui_syncsplash(0, true, "%s [%d/%d]",
- str(LANG_TAGCACHE_INIT), ret, 7);
+ str(LANG_TAGCACHE_INIT), ret,
+ tagcache_get_max_commit_step());
#else
lcd_double_height(false);
- snprintf(buf, sizeof(buf), " TC [%d/%d]", ret, 7);
+ snprintf(buf, sizeof(buf), " TC [%d/%d]", ret,
+ tagcache_get_max_commit_step());
lcd_puts(0, 1, buf);
#endif
clear = true;
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index a58792b308..dd9ad731bb 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -45,14 +45,27 @@
/***********************************/
/* TAGCACHE MENU */
#ifdef HAVE_TAGCACHE
+
+static void tagcache_rebuild_with_splash(void)
+{
+ tagcache_rebuild();
+ gui_syncsplash(HZ*2, true, str(LANG_TAGCACHE_FORCE_UPDATE_SPLASH));
+}
+
+static void tagcache_update_with_splash(void)
+{
+ tagcache_update();
+ gui_syncsplash(HZ*2, true, str(LANG_TAGCACHE_FORCE_UPDATE_SPLASH));
+}
+
#ifdef HAVE_TC_RAMCACHE
MENUITEM_SETTING(tagcache_ram, &global_settings.tagcache_ram, NULL);
#endif
MENUITEM_SETTING(tagcache_autoupdate, &global_settings.tagcache_autoupdate, NULL);
MENUITEM_FUNCTION(tc_init, ID2P(LANG_TAGCACHE_FORCE_UPDATE),
- (int(*)(void))tagcache_rebuild, NULL, Icon_NOICON);
+ (int(*)(void))tagcache_rebuild_with_splash, NULL, Icon_NOICON);
MENUITEM_FUNCTION(tc_update, ID2P(LANG_TAGCACHE_UPDATE),
- (int(*)(void))tagcache_update, NULL, Icon_NOICON);
+ (int(*)(void))tagcache_update_with_splash, NULL, Icon_NOICON);
MENUITEM_SETTING(runtimedb, &global_settings.runtimedb, NULL);
MENUITEM_FUNCTION(tc_export, ID2P(LANG_TAGCACHE_EXPORT),
(int(*)(void))tagtree_export, NULL, Icon_NOICON);
diff --git a/apps/root_menu.c b/apps/root_menu.c
index c234614bc6..0dbf179d9e 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -61,6 +61,9 @@
#ifdef HAVE_RTC_ALARM
#include "rtc.h"
#endif
+#ifdef HAVE_TAGCACHE
+#include "tagcache.h"
+#endif
struct root_items {
int (*function)(void* param);
@@ -99,11 +102,58 @@ static int browser(void* param)
break;
#ifdef HAVE_TAGCACHE
case GO_TO_DBBROWSER:
- if ((last_screen != GO_TO_ROOT) && !tagcache_is_usable())
+ if (!tagcache_is_usable())
{
- gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY));
- return GO_TO_PREVIOUS;
+ /* Re-init if required */
+ struct tagcache_stat *stat = tagcache_get_stat();
+ if (!stat->ready && !stat->commit_delayed && stat->processed_entries == 0)
+ {
+ /* Prompt the user */
+ char *lines[]={str(LANG_TAGCACHE_BUSY), str(LANG_TAGCACHE_FORCE_UPDATE)};
+ struct text_message message={lines, 2};
+ if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO)
+ return GO_TO_PREVIOUS;
+ int i;
+ FOR_NB_SCREENS(i)
+ screens[i].clear_display();
+
+ /* Start initialisation */
+ tagcache_rebuild();
+ }
+
+ /* Now display progress until it's ready or the user exits */
+ while(!tagcache_is_usable())
+ {
+ gui_syncstatusbar_draw(&statusbars, false);
+ stat = tagcache_get_stat();
+
+ /* Maybe just needs to reboot due to delayed commit */
+ if (stat->commit_delayed)
+ {
+ gui_syncsplash(HZ*2, true, str(LANG_PLEASE_REBOOT));
+ break;
+ }
+
+ /* Display building progress */
+ if (stat->commit_step > 0)
+ {
+ gui_syncsplash(0, true, "%s [%d/%d]",
+ str(LANG_TAGCACHE_INIT), stat->commit_step,
+ tagcache_get_max_commit_step());
+ }
+ else
+ {
+ gui_syncsplash(0, true, str(LANG_BUILDING_DATABASE),
+ stat->processed_entries);
+ }
+
+ /* Allow user to exit */
+ if (action_userabort(HZ/2))
+ break;
+ }
}
+ if (!tagcache_is_usable())
+ return GO_TO_PREVIOUS;
filter = SHOW_ID3DB;
tc->dirlevel = last_db_dirlevel;
break;
diff --git a/apps/tagcache.c b/apps/tagcache.c
index bcff803d18..a899ff91fd 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -3904,16 +3904,12 @@ bool tagcache_update(void)
return false;
queue_post(&tagcache_queue, Q_UPDATE, 0);
- gui_syncsplash(HZ*2, true, str(LANG_TAGCACHE_FORCE_UPDATE_SPLASH));
-
return false;
}
-bool tagcache_rebuild(void)
+bool tagcache_rebuild()
{
queue_post(&tagcache_queue, Q_REBUILD, 0);
- gui_syncsplash(HZ*2, true, str(LANG_TAGCACHE_FORCE_UPDATE_SPLASH));
-
return false;
}
@@ -3974,4 +3970,8 @@ int tagcache_get_commit_step(void)
{
return tc_stat.commit_step;
}
+int tagcache_get_max_commit_step(void)
+{
+ return 8; /* To be written, better hard-coded here than in the UI */
+}
diff --git a/apps/tagcache.h b/apps/tagcache.h
index 7e9a42dfa7..c8d52308ce 100644
--- a/apps/tagcache.h
+++ b/apps/tagcache.h
@@ -187,6 +187,6 @@ void tagcache_start_scan(void);
void tagcache_stop_scan(void);
bool tagcache_update(void);
bool tagcache_rebuild(void);
-
+int tagcache_get_max_commit_step(void);
#endif
#endif