diff options
author | Yoshihisa Uchida <uchida@rockbox.org> | 2010-07-02 12:16:47 +0000 |
---|---|---|
committer | Yoshihisa Uchida <uchida@rockbox.org> | 2010-07-02 12:16:47 +0000 |
commit | 2cdf332f01bf3a9904f8322596bb81740ea3fe6b (patch) | |
tree | 25f1f2826798ed0812000a86256a8c35a9782355 | |
parent | 0fef85e9dbdc31c593ffda7b3d4f8062eec503f2 (diff) | |
download | rockbox-2cdf332f01bf3a9904f8322596bb81740ea3fe6b.tar.gz rockbox-2cdf332f01bf3a9904f8322596bb81740ea3fe6b.zip |
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.c | 12 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_action.c | 43 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_action.h | 23 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_bookmark.c | 11 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_bookmark.h | 19 |
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 e5f3160bb6..ca5cf70d36 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) | |||
35 | long old_tick; | 35 | long old_tick; |
36 | bool done = false; | 36 | bool done = false; |
37 | bool display_update = true; | 37 | bool display_update = true; |
38 | size_t size; | ||
39 | unsigned char *plugin_buf; | ||
38 | 40 | ||
39 | old_tick = *rb->current_tick; | 41 | old_tick = *rb->current_tick; |
40 | 42 | ||
41 | if (!file) | 43 | if (!file) |
42 | return PLUGIN_ERROR; | 44 | return PLUGIN_ERROR; |
43 | 45 | ||
44 | if (!tv_init(file)) { | 46 | /* get the plugin buffer */ |
47 | plugin_buf = rb->plugin_get_buffer(&size); | ||
48 | |||
49 | if (!tv_init_action(&plugin_buf, &size)) { | ||
50 | rb->splash(HZ, "Error initialize"); | ||
51 | return PLUGIN_ERROR; | ||
52 | } | ||
53 | |||
54 | if (!tv_load_file(file)) { | ||
45 | rb->splash(HZ, "Error opening file"); | 55 | rb->splash(HZ, "Error opening file"); |
46 | return PLUGIN_ERROR; | 56 | return PLUGIN_ERROR; |
47 | } | 57 | } |
diff --git a/apps/plugins/text_viewer/tv_action.c b/apps/plugins/text_viewer/tv_action.c index b8542daafe..c95ece0649 100644 --- a/apps/plugins/text_viewer/tv_action.c +++ b/apps/plugins/text_viewer/tv_action.c | |||
@@ -28,26 +28,23 @@ | |||
28 | #include "tv_settings.h" | 28 | #include "tv_settings.h" |
29 | #include "tv_window.h" | 29 | #include "tv_window.h" |
30 | 30 | ||
31 | bool tv_init(const unsigned char *file) | 31 | bool tv_init_action(unsigned char **buf, size_t *size) |
32 | { | 32 | { |
33 | size_t size; | 33 | /* initialize bookmarks and window modules */ |
34 | 34 | return tv_init_bookmark(buf, size) && tv_init_window(buf, size); | |
35 | /* get the plugin buffer */ | 35 | } |
36 | unsigned char *buf = rb->plugin_get_buffer(&size); | ||
37 | |||
38 | tv_init_bookmark(); | ||
39 | 36 | ||
40 | /* initialize modules */ | 37 | static void tv_finalize_action(void) |
41 | if (!tv_init_window(&buf, &size)) | 38 | { |
42 | return false; | 39 | /* save preference and bookmarks */ |
40 | if (!tv_save_settings()) | ||
41 | rb->splash(HZ, "Can't save preferences and bookmarks"); | ||
43 | 42 | ||
44 | /* load the preferences and bookmark */ | 43 | /* finalize bookmark modules */ |
45 | if (!tv_load_settings(file)) | 44 | tv_finalize_bookmark(); |
46 | return false; | ||
47 | 45 | ||
48 | /* select to read the page */ | 46 | /* finalize window modules */ |
49 | tv_select_bookmark(); | 47 | tv_finalize_window(); |
50 | return true; | ||
51 | } | 48 | } |
52 | 49 | ||
53 | void tv_exit(void *parameter) | 50 | void tv_exit(void *parameter) |
@@ -59,7 +56,19 @@ void tv_exit(void *parameter) | |||
59 | rb->splash(HZ, "Can't save preferences and bookmarks"); | 56 | rb->splash(HZ, "Can't save preferences and bookmarks"); |
60 | 57 | ||
61 | /* finalize modules */ | 58 | /* finalize modules */ |
62 | tv_finalize_window(); | 59 | tv_finalize_action(); |
60 | } | ||
61 | |||
62 | bool tv_load_file(const unsigned char *file) | ||
63 | { | ||
64 | /* load the preferences and bookmark */ | ||
65 | if (!tv_load_settings(file)) | ||
66 | return false; | ||
67 | |||
68 | /* select to read the page */ | ||
69 | tv_select_bookmark(); | ||
70 | |||
71 | return true; | ||
63 | } | 72 | } |
64 | 73 | ||
65 | void tv_draw(void) | 74 | void tv_draw(void) |
diff --git a/apps/plugins/text_viewer/tv_action.h b/apps/plugins/text_viewer/tv_action.h index f774f07422..fba008dbe9 100644 --- a/apps/plugins/text_viewer/tv_action.h +++ b/apps/plugins/text_viewer/tv_action.h | |||
@@ -42,16 +42,19 @@ enum | |||
42 | }; | 42 | }; |
43 | 43 | ||
44 | /* | 44 | /* |
45 | * initialize modules | 45 | * initialize the action module |
46 | * | 46 | * |
47 | * [In] file | 47 | * [In/Out] buf |
48 | * read file name | 48 | * the start pointer of the buffer |
49 | * | ||
50 | * [In/Out] size | ||
51 | * buffer size | ||
49 | * | 52 | * |
50 | * return | 53 | * return |
51 | * true initialize success | 54 | * true initialize success |
52 | * false initialize failure | 55 | * false initialize failure |
53 | */ | 56 | */ |
54 | bool tv_init(const unsigned char *file); | 57 | bool tv_init_action(unsigned char **buf, size_t *bufsize); |
55 | 58 | ||
56 | /* | 59 | /* |
57 | * finalize modules | 60 | * finalize modules |
@@ -61,6 +64,18 @@ bool tv_init(const unsigned char *file); | |||
61 | */ | 64 | */ |
62 | void tv_exit(void *parameter); | 65 | void tv_exit(void *parameter); |
63 | 66 | ||
67 | /* | ||
68 | * load the file | ||
69 | * | ||
70 | * [In] file | ||
71 | * read file name | ||
72 | * | ||
73 | * return | ||
74 | * true load success | ||
75 | * false load failure | ||
76 | */ | ||
77 | bool tv_load_file(const unsigned char *file); | ||
78 | |||
64 | /* draw the current page */ | 79 | /* draw the current page */ |
65 | void tv_draw(void); | 80 | void tv_draw(void); |
66 | 81 | ||
diff --git a/apps/plugins/text_viewer/tv_bookmark.c b/apps/plugins/text_viewer/tv_bookmark.c index 7e38d766ec..c6574dbb6f 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) | |||
110 | return TV_CALLBACK_OK; | 110 | return TV_CALLBACK_OK; |
111 | } | 111 | } |
112 | 112 | ||
113 | void tv_init_bookmark(void) | 113 | bool tv_init_bookmark(unsigned char **buf, size_t *size) |
114 | { | 114 | { |
115 | (void)buf; | ||
116 | (void)size; | ||
117 | |||
115 | tv_add_preferences_change_listner(tv_change_preferences); | 118 | tv_add_preferences_change_listner(tv_change_preferences); |
119 | return true; | ||
120 | } | ||
121 | |||
122 | void tv_finalize_bookmark(void) | ||
123 | { | ||
124 | /* no-operation function */ | ||
116 | } | 125 | } |
117 | 126 | ||
118 | int tv_get_bookmark_positions(struct tv_screen_pos *pos_array) | 127 | 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 d61af41620..b0b91077d4 100644 --- a/apps/plugins/text_viewer/tv_bookmark.h +++ b/apps/plugins/text_viewer/tv_bookmark.h | |||
@@ -30,8 +30,23 @@ | |||
30 | /* Maximum amount of register possible bookmarks */ | 30 | /* Maximum amount of register possible bookmarks */ |
31 | #define TV_MAX_BOOKMARKS 16 | 31 | #define TV_MAX_BOOKMARKS 16 |
32 | 32 | ||
33 | /* initialize the bookmark module */ | 33 | /* |
34 | void tv_init_bookmark(void); | 34 | * initialize the bookmark module |
35 | * | ||
36 | * [In/Out] buf | ||
37 | * the start pointer of the buffer | ||
38 | * | ||
39 | * [In/Out] size | ||
40 | * buffer size | ||
41 | * | ||
42 | * return | ||
43 | * true initialize success | ||
44 | * false initialize failure | ||
45 | */ | ||
46 | bool tv_init_bookmark(unsigned char **buf, size_t *size); | ||
47 | |||
48 | /* finalize the bookmark module */ | ||
49 | void tv_finalize_bookmark(void); | ||
35 | 50 | ||
36 | /* | 51 | /* |
37 | * get the positions which registered bookmarks | 52 | * get the positions which registered bookmarks |