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
This commit is contained in:
Yoshihisa Uchida 2010-07-02 12:16:47 +00:00
parent 0fef85e9db
commit 2cdf332f01
5 changed files with 83 additions and 25 deletions

View file

@ -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;
}

View file

@ -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;
/* initialize bookmarks and window modules */
return tv_init_bookmark(buf, size) && tv_init_window(buf, size);
}
/* get the plugin buffer */
unsigned char *buf = rb->plugin_get_buffer(&size);
static void tv_finalize_action(void)
{
/* save preference and bookmarks */
if (!tv_save_settings())
rb->splash(HZ, "Can't save preferences and bookmarks");
tv_init_bookmark();
/* finalize bookmark modules */
tv_finalize_bookmark();
/* initialize modules */
if (!tv_init_window(&buf, &size))
return false;
/* load the preferences and bookmark */
if (!tv_load_settings(file))
return false;
/* 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)

View file

@ -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);

View file

@ -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)

View file

@ -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