summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoshihisa Uchida <uchida@rockbox.org>2010-07-02 12:16:47 +0000
committerYoshihisa Uchida <uchida@rockbox.org>2010-07-02 12:16:47 +0000
commit2cdf332f01bf3a9904f8322596bb81740ea3fe6b (patch)
tree25f1f2826798ed0812000a86256a8c35a9782355
parent0fef85e9dbdc31c593ffda7b3d4f8062eec503f2 (diff)
downloadrockbox-2cdf332f01bf3a9904f8322596bb81740ea3fe6b.zip
rockbox-2cdf332f01bf3a9904f8322596bb81740ea3fe6b.tar.gz
rockbox-2cdf332f01bf3a9904f8322596bb81740ea3fe6b.tar.bz2
rockbox-2cdf332f01bf3a9904f8322596bb81740ea3fe6b.tar.xz
text viewer: for tv_action and tv_bookmark, the prototype of the initializer is the same arguments as other modules.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27243 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/text_viewer/text_viewer.c12
-rw-r--r--apps/plugins/text_viewer/tv_action.c43
-rw-r--r--apps/plugins/text_viewer/tv_action.h23
-rw-r--r--apps/plugins/text_viewer/tv_bookmark.c11
-rw-r--r--apps/plugins/text_viewer/tv_bookmark.h19
5 files changed, 83 insertions, 25 deletions
diff --git a/apps/plugins/text_viewer/text_viewer.c b/apps/plugins/text_viewer/text_viewer.c
index e5f3160..ca5cf70 100644
--- a/apps/plugins/text_viewer/text_viewer.c
+++ b/apps/plugins/text_viewer/text_viewer.c
@@ -35,13 +35,23 @@ enum plugin_status plugin_start(const void* file)
long old_tick;
bool done = false;
bool display_update = true;
+ size_t size;
+ unsigned char *plugin_buf;
old_tick = *rb->current_tick;
if (!file)
return PLUGIN_ERROR;
- if (!tv_init(file)) {
+ /* get the plugin buffer */
+ plugin_buf = rb->plugin_get_buffer(&size);
+
+ if (!tv_init_action(&plugin_buf, &size)) {
+ rb->splash(HZ, "Error initialize");
+ return PLUGIN_ERROR;
+ }
+
+ if (!tv_load_file(file)) {
rb->splash(HZ, "Error opening file");
return PLUGIN_ERROR;
}
diff --git a/apps/plugins/text_viewer/tv_action.c b/apps/plugins/text_viewer/tv_action.c
index b8542da..c95ece0 100644
--- a/apps/plugins/text_viewer/tv_action.c
+++ b/apps/plugins/text_viewer/tv_action.c
@@ -28,26 +28,23 @@
#include "tv_settings.h"
#include "tv_window.h"
-bool tv_init(const unsigned char *file)
+bool tv_init_action(unsigned char **buf, size_t *size)
{
- size_t size;
-
- /* get the plugin buffer */
- unsigned char *buf = rb->plugin_get_buffer(&size);
-
- tv_init_bookmark();
+ /* initialize bookmarks and window modules */
+ return tv_init_bookmark(buf, size) && tv_init_window(buf, size);
+}
- /* initialize modules */
- if (!tv_init_window(&buf, &size))
- return false;
+static void tv_finalize_action(void)
+{
+ /* save preference and bookmarks */
+ if (!tv_save_settings())
+ rb->splash(HZ, "Can't save preferences and bookmarks");
- /* load the preferences and bookmark */
- if (!tv_load_settings(file))
- return false;
+ /* finalize bookmark modules */
+ tv_finalize_bookmark();
- /* select to read the page */
- tv_select_bookmark();
- return true;
+ /* finalize window modules */
+ tv_finalize_window();
}
void tv_exit(void *parameter)
@@ -59,7 +56,19 @@ void tv_exit(void *parameter)
rb->splash(HZ, "Can't save preferences and bookmarks");
/* finalize modules */
- tv_finalize_window();
+ tv_finalize_action();
+}
+
+bool tv_load_file(const unsigned char *file)
+{
+ /* load the preferences and bookmark */
+ if (!tv_load_settings(file))
+ return false;
+
+ /* select to read the page */
+ tv_select_bookmark();
+
+ return true;
}
void tv_draw(void)
diff --git a/apps/plugins/text_viewer/tv_action.h b/apps/plugins/text_viewer/tv_action.h
index f774f07..fba008d 100644
--- a/apps/plugins/text_viewer/tv_action.h
+++ b/apps/plugins/text_viewer/tv_action.h
@@ -42,16 +42,19 @@ enum
};
/*
- * initialize modules
+ * initialize the action module
*
- * [In] file
- * read file name
+ * [In/Out] buf
+ * the start pointer of the buffer
+ *
+ * [In/Out] size
+ * buffer size
*
* return
* true initialize success
* false initialize failure
*/
-bool tv_init(const unsigned char *file);
+bool tv_init_action(unsigned char **buf, size_t *bufsize);
/*
* finalize modules
@@ -61,6 +64,18 @@ bool tv_init(const unsigned char *file);
*/
void tv_exit(void *parameter);
+/*
+ * load the file
+ *
+ * [In] file
+ * read file name
+ *
+ * return
+ * true load success
+ * false load failure
+ */
+bool tv_load_file(const unsigned char *file);
+
/* draw the current page */
void tv_draw(void);
diff --git a/apps/plugins/text_viewer/tv_bookmark.c b/apps/plugins/text_viewer/tv_bookmark.c
index 7e38d76..c6574db 100644
--- a/apps/plugins/text_viewer/tv_bookmark.c
+++ b/apps/plugins/text_viewer/tv_bookmark.c
@@ -110,9 +110,18 @@ static int tv_change_preferences(const struct tv_preferences *oldp)
return TV_CALLBACK_OK;
}
-void tv_init_bookmark(void)
+bool tv_init_bookmark(unsigned char **buf, size_t *size)
{
+ (void)buf;
+ (void)size;
+
tv_add_preferences_change_listner(tv_change_preferences);
+ return true;
+}
+
+void tv_finalize_bookmark(void)
+{
+ /* no-operation function */
}
int tv_get_bookmark_positions(struct tv_screen_pos *pos_array)
diff --git a/apps/plugins/text_viewer/tv_bookmark.h b/apps/plugins/text_viewer/tv_bookmark.h
index d61af41..b0b9107 100644
--- a/apps/plugins/text_viewer/tv_bookmark.h
+++ b/apps/plugins/text_viewer/tv_bookmark.h
@@ -30,8 +30,23 @@
/* Maximum amount of register possible bookmarks */
#define TV_MAX_BOOKMARKS 16
-/* initialize the bookmark module */
-void tv_init_bookmark(void);
+/*
+ * initialize the bookmark module
+ *
+ * [In/Out] buf
+ * the start pointer of the buffer
+ *
+ * [In/Out] size
+ * buffer size
+ *
+ * return
+ * true initialize success
+ * false initialize failure
+ */
+bool tv_init_bookmark(unsigned char **buf, size_t *size);
+
+/* finalize the bookmark module */
+void tv_finalize_bookmark(void);
/*
* get the positions which registered bookmarks