summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-07-28 10:58:34 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2020-08-16 10:35:57 -0400
commitd553bb1149800daf16dcb92bc0608fe6248e1dab (patch)
tree86cdcf361ef387a3d624485d1e6c6e062d7ce85b
parent94eb1df58b4ad4e25941782832d20e1c8d57f0c5 (diff)
downloadrockbox-d553bb1149800daf16dcb92bc0608fe6248e1dab.tar.gz
rockbox-d553bb1149800daf16dcb92bc0608fe6248e1dab.zip
root_menu move tag cache init check to pictureflow plugin
let pictureflow decide if the tag cache is ready instead of core Change-Id: I2ab9b375d773dbbc28ea41fbf7bb6fb361ace8fd
-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 = {
803 803
804 /* new stuff at the end, sort into place next time 804 /* new stuff at the end, sort into place next time
805 the API gets incompatible */ 805 the API gets incompatible */
806
807#ifdef HAVE_TAGCACHE
808 tagcache_get_stat,
809#endif
806}; 810};
807 811
808static int plugin_buffer_handle; 812static 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);
154#define PLUGIN_MAGIC 0x526F634B /* RocK */ 154#define PLUGIN_MAGIC 0x526F634B /* RocK */
155 155
156/* increase this every time the api struct changes */ 156/* increase this every time the api struct changes */
157#define PLUGIN_API_VERSION 239 157#define PLUGIN_API_VERSION 240
158 158
159/* update this to latest version if a change to the api struct breaks 159/* update this to latest version if a change to the api struct breaks
160 backwards compatibility (and please take the opportunity to sort in any 160 backwards compatibility (and please take the opportunity to sort in any
@@ -930,6 +930,11 @@ struct plugin_api {
930 930
931 /* new stuff at the end, sort into place next time 931 /* new stuff at the end, sort into place next time
932 the API gets incompatible */ 932 the API gets incompatible */
933
934#ifdef HAVE_TAGCACHE
935 struct tagcache_stat* (*tagcache_get_stat)(void);
936#endif
937
933}; 938};
934 939
935/* plugin header */ 940/* 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);
530static void draw_splashscreen(unsigned char * buf_tmp, size_t buf_tmp_size); 530static void draw_splashscreen(unsigned char * buf_tmp, size_t buf_tmp_size);
531static void free_all_slide_prio(int prio); 531static void free_all_slide_prio(int prio);
532 532
533static bool check_database(bool prompt)
534{
535 bool needwarn = true;
536 struct tagcache_stat *stat = rb->tagcache_get_stat();
537 while ( !(stat->initialized && stat->ready) )
538 {
539 if (needwarn)
540 rb->splash(0, ID2P(LANG_TAGCACHE_BUSY));
541 if (!prompt)
542 return false;
543 else if (rb->action_userabort(HZ/5))
544 return false;
545
546 needwarn = false;
547 stat = rb->tagcache_get_stat();
548 rb->yield();
549 }
550 return true;
551}
552
533static bool confirm_quit(void) 553static bool confirm_quit(void)
534{ 554{
535 const struct text_message prompt = 555 const struct text_message prompt =
@@ -3821,6 +3841,17 @@ enum plugin_status plugin_start(const void *parameter)
3821 3841
3822 void * buf; 3842 void * buf;
3823 size_t buf_size; 3843 size_t buf_size;
3844 bool prompt = (parameter && ((char *) parameter)[0] == ACTIVITY_MAINMENU);
3845
3846 if (!check_database(prompt))
3847 {
3848 if (prompt)
3849 return PLUGIN_OK;
3850 else
3851 error_wait("Please enable database");
3852
3853 return PLUGIN_ERROR;
3854 }
3824 3855
3825 atexit(cleanup); 3856 atexit(cleanup);
3826 3857
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)
704} 704}
705 705
706#ifdef HAVE_PICTUREFLOW_INTEGRATION 706#ifdef HAVE_PICTUREFLOW_INTEGRATION
707static int load_plugin_screen(char *plug_path) 707static int load_plugin_screen(char *plug_path, void* plug_param)
708{ 708{
709 int ret_val; 709 int ret_val;
710 int old_previous = last_screen; 710 int old_previous = last_screen;
@@ -712,7 +712,7 @@ static int load_plugin_screen(char *plug_path)
712 global_status.last_screen = (char)next_screen; 712 global_status.last_screen = (char)next_screen;
713 status_save(); 713 status_save();
714 714
715 switch (plugin_load(plug_path, NULL)) 715 switch (plugin_load(plug_path, plug_param))
716 { 716 {
717 case PLUGIN_GOTO_WPS: 717 case PLUGIN_GOTO_WPS:
718 ret_val = GO_TO_WPS; 718 ret_val = GO_TO_WPS;
@@ -729,20 +729,6 @@ static int load_plugin_screen(char *plug_path)
729 last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous; 729 last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous;
730 return ret_val; 730 return ret_val;
731} 731}
732
733static bool check_database(void)
734{
735 bool needwarn = true;
736 while ( !tagcache_is_usable() )
737 {
738 if (needwarn)
739 splash(0, ID2P(LANG_TAGCACHE_BUSY));
740 if ( action_userabort(HZ/5) )
741 return false;
742 needwarn = false;
743 }
744 return true;
745}
746#endif 732#endif
747 733
748void root_menu(void) 734void root_menu(void)
@@ -823,18 +809,18 @@ void root_menu(void)
823 break; 809 break;
824#ifdef HAVE_PICTUREFLOW_INTEGRATION 810#ifdef HAVE_PICTUREFLOW_INTEGRATION
825 case GO_TO_PICTUREFLOW: 811 case GO_TO_PICTUREFLOW:
826 if (check_database()) 812 {
827 { 813 char pf_path[MAX_PATH];
828 char pf_path[MAX_PATH]; 814 char activity[6];/* big enough to display int */
829 snprintf(pf_path, sizeof(pf_path), 815 snprintf(activity, sizeof(activity), "%d", get_current_activity());
830 "%s/pictureflow.rock", 816 snprintf(pf_path, sizeof(pf_path),
831 PLUGIN_DEMOS_DIR); 817 "%s/pictureflow.rock",
832 next_screen = load_plugin_screen(pf_path); 818 PLUGIN_DEMOS_DIR);
833 previous_browser = (next_screen != GO_TO_WPS) ? GO_TO_FILEBROWSER : GO_TO_PICTUREFLOW; 819
834 } 820 next_screen = load_plugin_screen(pf_path, &activity);
835 else 821 previous_browser = (next_screen != GO_TO_WPS) ? GO_TO_FILEBROWSER : GO_TO_PICTUREFLOW;
836 next_screen = GO_TO_PREVIOUS;
837 break; 822 break;
823 }
838#endif 824#endif
839 default: 825 default:
840#ifdef HAVE_TAGCACHE 826#ifdef HAVE_TAGCACHE