summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/plugin.c4
-rw-r--r--apps/plugin.h7
-rw-r--r--apps/plugins/pictureflow/pictureflow.c31
-rw-r--r--apps/root_menu.c40
4 files changed, 54 insertions, 28 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 28577ab251..2066d3a108 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -803,6 +803,10 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time
the API gets incompatible */
+
+#ifdef HAVE_TAGCACHE
+ tagcache_get_stat,
+#endif
};
static int plugin_buffer_handle;
diff --git a/apps/plugin.h b/apps/plugin.h
index ee21291192..2585d17205 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -154,7 +154,7 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 239
+#define PLUGIN_API_VERSION 240
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
@@ -930,6 +930,11 @@ struct plugin_api {
/* new stuff at the end, sort into place next time
the API gets incompatible */
+
+#ifdef HAVE_TAGCACHE
+ struct tagcache_stat* (*tagcache_get_stat)(void);
+#endif
+
};
/* plugin header */
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index ba3ae3018f..d1da10ee09 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -530,6 +530,26 @@ static void draw_progressbar(int step, int count, char *msg);
static void draw_splashscreen(unsigned char * buf_tmp, size_t buf_tmp_size);
static void free_all_slide_prio(int prio);
+static bool check_database(bool prompt)
+{
+ bool needwarn = true;
+ struct tagcache_stat *stat = rb->tagcache_get_stat();
+ while ( !(stat->initialized && stat->ready) )
+ {
+ if (needwarn)
+ rb->splash(0, ID2P(LANG_TAGCACHE_BUSY));
+ if (!prompt)
+ return false;
+ else if (rb->action_userabort(HZ/5))
+ return false;
+
+ needwarn = false;
+ stat = rb->tagcache_get_stat();
+ rb->yield();
+ }
+ return true;
+}
+
static bool confirm_quit(void)
{
const struct text_message prompt =
@@ -3821,6 +3841,17 @@ enum plugin_status plugin_start(const void *parameter)
void * buf;
size_t buf_size;
+ bool prompt = (parameter && ((char *) parameter)[0] == ACTIVITY_MAINMENU);
+
+ if (!check_database(prompt))
+ {
+ if (prompt)
+ return PLUGIN_OK;
+ else
+ error_wait("Please enable database");
+
+ return PLUGIN_ERROR;
+ }
atexit(cleanup);
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 9ff7325ce1..c59c39fe88 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -704,7 +704,7 @@ static int load_context_screen(int selection)
}
#ifdef HAVE_PICTUREFLOW_INTEGRATION
-static int load_plugin_screen(char *plug_path)
+static int load_plugin_screen(char *plug_path, void* plug_param)
{
int ret_val;
int old_previous = last_screen;
@@ -712,7 +712,7 @@ static int load_plugin_screen(char *plug_path)
global_status.last_screen = (char)next_screen;
status_save();
- switch (plugin_load(plug_path, NULL))
+ switch (plugin_load(plug_path, plug_param))
{
case PLUGIN_GOTO_WPS:
ret_val = GO_TO_WPS;
@@ -729,20 +729,6 @@ static int load_plugin_screen(char *plug_path)
last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous;
return ret_val;
}
-
-static bool check_database(void)
-{
- bool needwarn = true;
- while ( !tagcache_is_usable() )
- {
- if (needwarn)
- splash(0, ID2P(LANG_TAGCACHE_BUSY));
- if ( action_userabort(HZ/5) )
- return false;
- needwarn = false;
- }
- return true;
-}
#endif
void root_menu(void)
@@ -823,18 +809,18 @@ void root_menu(void)
break;
#ifdef HAVE_PICTUREFLOW_INTEGRATION
case GO_TO_PICTUREFLOW:
- if (check_database())
- {
- char pf_path[MAX_PATH];
- snprintf(pf_path, sizeof(pf_path),
- "%s/pictureflow.rock",
- PLUGIN_DEMOS_DIR);
- next_screen = load_plugin_screen(pf_path);
- previous_browser = (next_screen != GO_TO_WPS) ? GO_TO_FILEBROWSER : GO_TO_PICTUREFLOW;
- }
- else
- next_screen = GO_TO_PREVIOUS;
+ {
+ char pf_path[MAX_PATH];
+ char activity[6];/* big enough to display int */
+ snprintf(activity, sizeof(activity), "%d", get_current_activity());
+ snprintf(pf_path, sizeof(pf_path),
+ "%s/pictureflow.rock",
+ PLUGIN_DEMOS_DIR);
+
+ next_screen = load_plugin_screen(pf_path, &activity);
+ previous_browser = (next_screen != GO_TO_WPS) ? GO_TO_FILEBROWSER : GO_TO_PICTUREFLOW;
break;
+ }
#endif
default:
#ifdef HAVE_TAGCACHE