diff options
Diffstat (limited to 'utils/wpseditor/libwps/src/api.c')
-rw-r--r-- | utils/wpseditor/libwps/src/api.c | 289 |
1 files changed, 0 insertions, 289 deletions
diff --git a/utils/wpseditor/libwps/src/api.c b/utils/wpseditor/libwps/src/api.c deleted file mode 100644 index f926f8bd90..0000000000 --- a/utils/wpseditor/libwps/src/api.c +++ /dev/null | |||
@@ -1,289 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include "sound.h" | ||
25 | #include "api.h" | ||
26 | #include "proxy.h" | ||
27 | #include "dummies.h" | ||
28 | #include "scroll_engine.h" | ||
29 | #include "wpsstate.h" | ||
30 | #include <string.h> | ||
31 | |||
32 | struct proxy_api *xapi; | ||
33 | |||
34 | void get_current_vp(struct viewport_api *avp); | ||
35 | /************************************************************* | ||
36 | |||
37 | *************************************************************/ | ||
38 | #ifdef HAVE_LCD_BITMAP | ||
39 | void screen_clear_area(struct screen * display, int xstart, int ystart, | ||
40 | int width, int height) { | ||
41 | display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
42 | display->fillrect(xstart, ystart, width, height); | ||
43 | display->set_drawmode(DRMODE_SOLID); | ||
44 | } | ||
45 | #endif | ||
46 | |||
47 | bool load_wps_backdrop(char* filename) { | ||
48 | return xapi->load_wps_backdrop(filename); | ||
49 | } | ||
50 | |||
51 | bool load_remote_wps_backdrop(char* filename) { | ||
52 | return xapi->load_remote_wps_backdrop(filename); | ||
53 | } | ||
54 | |||
55 | int read_bmp_file(const char* filename,struct bitmap *bm, int maxsize,int format) { | ||
56 | if (!xapi->read_bmp_file) { | ||
57 | DEBUGF1("can't read bmp file! NULL api!\n"); | ||
58 | return -1; | ||
59 | } | ||
60 | bm->format = 3;//FORMAT_ANY? | ||
61 | bm->data = (unsigned char*)malloc(255); | ||
62 | memset(bm->data,0,255); | ||
63 | strcpy((char*)bm->data,filename); | ||
64 | //bm->data[strlen(filename)] = '\0'; | ||
65 | xapi->read_bmp_file(filename,&bm->width, &bm->height); | ||
66 | return 1; | ||
67 | } | ||
68 | |||
69 | bool load_wps_backdrop2(char* filename) { | ||
70 | DEBUGF1("load_wps_backdrop(char* filename='%s')",filename); | ||
71 | return true; | ||
72 | } | ||
73 | |||
74 | bool load_remote_wps_backdrop2(char* filename) { | ||
75 | DEBUGF1("load_remote_wps_backdrop2(char* filename='%s')",filename); | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | void stop_scroll() { | ||
80 | DEBUGF3("stop_scroll\n"); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | void puts_scroll(int x, int y, const unsigned char *string) { | ||
85 | DEBUGF2("puts_scroll(int x=%d, int y=%d, const unsigned char *string='%s'\n",x,y,string); | ||
86 | } | ||
87 | |||
88 | void putsxy(int x, int y, const unsigned char *str) { | ||
89 | DEBUGF2("putsxy(int =%d, int y=%d, const unsigned char *str='%s')\n",x,y,str); | ||
90 | } | ||
91 | |||
92 | void lcd_update() { | ||
93 | DEBUGF3("update\n"); | ||
94 | } | ||
95 | |||
96 | void clear_viewport(int x, int y, int w, int h, int color) { | ||
97 | DEBUGF3("clear_viewport(int x=%d, int y=%d, int w=%d, int h=%d, int color=%d)\n", x, y, w, h, color); | ||
98 | }; | ||
99 | |||
100 | int getstringsize(const unsigned char *str, int *w, int *h) { | ||
101 | //DEBUGF1("getstringsize(const unsigned char *str=\"%s\", int *w=%d, int *h=%d \n",str,*w,*h); | ||
102 | *w=strlen((char*)str)*sysfont.maxwidth; | ||
103 | *h=sysfont.height; | ||
104 | return 1; | ||
105 | } | ||
106 | |||
107 | void set_wpsstate(struct wpsstate state) { | ||
108 | sysfont.height = state.fontheight; | ||
109 | sysfont.maxwidth = state.fontwidth; | ||
110 | global_settings.volume = state.volume; | ||
111 | battery_percent = state.battery_level; | ||
112 | _audio_status = state.audio_status; | ||
113 | } | ||
114 | |||
115 | void set_trackstate(struct trackstate state) { | ||
116 | if (!(gui_wps[0].state) || | ||
117 | !(gui_wps[0].state->id3)) | ||
118 | return; | ||
119 | gui_wps[0].state->id3->title = state.title; | ||
120 | gui_wps[0].state->id3->artist = state.artist; | ||
121 | gui_wps[0].state->id3->album = state.album; | ||
122 | gui_wps[0].state->id3->elapsed = state.elapsed; | ||
123 | gui_wps[0].state->id3->length = state.length; | ||
124 | } | ||
125 | |||
126 | void set_next_trackstate(struct trackstate state) { | ||
127 | gui_wps[0].state->nid3->title = state.title; | ||
128 | gui_wps[0].state->nid3->artist = state.artist; | ||
129 | gui_wps[0].state->nid3->album = state.album; | ||
130 | gui_wps[0].state->nid3->elapsed = state.elapsed; | ||
131 | gui_wps[0].state->nid3->length = state.length; | ||
132 | } | ||
133 | |||
134 | enum api_playmode playmodes[PLAYMODES_NUM] = { | ||
135 | API_STATUS_PLAY, | ||
136 | API_STATUS_STOP, | ||
137 | API_STATUS_PAUSE, | ||
138 | API_STATUS_FASTFORWARD, | ||
139 | API_STATUS_FASTBACKWARD | ||
140 | }; | ||
141 | |||
142 | const char *playmodeNames[] = { | ||
143 | "Play", "Stop", "Pause", "FastForward", "FastBackward" | ||
144 | }; | ||
145 | |||
146 | |||
147 | void set_audio_status(int status) { | ||
148 | DEBUGF1("%s",playmodeNames[status]); | ||
149 | switch (status) { | ||
150 | case API_STATUS_PLAY: | ||
151 | _audio_status = AUDIO_STATUS_PLAY; | ||
152 | status_set_ffmode(STATUS_PLAY); | ||
153 | break; | ||
154 | case API_STATUS_STOP: | ||
155 | _audio_status = 0; | ||
156 | status_set_ffmode(STATUS_STOP); | ||
157 | break; | ||
158 | case API_STATUS_PAUSE: | ||
159 | _audio_status = AUDIO_STATUS_PAUSE; | ||
160 | status_set_ffmode(STATUS_PLAY); | ||
161 | break; | ||
162 | case API_STATUS_FASTFORWARD: | ||
163 | status_set_ffmode(STATUS_FASTFORWARD); | ||
164 | break; | ||
165 | case API_STATUS_FASTBACKWARD: | ||
166 | status_set_ffmode(STATUS_FASTBACKWARD); | ||
167 | break; | ||
168 | default: | ||
169 | DEBUGF1("ERR: Unknown status"); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | void test_api(struct proxy_api *api) { | ||
174 | if (!api->stop_scroll) | ||
175 | api->stop_scroll=stop_scroll; | ||
176 | if (!api->set_viewport) | ||
177 | api->set_viewport=lcd_set_viewport; | ||
178 | if (!api->clear_viewport) | ||
179 | api->clear_viewport=clear_viewport; | ||
180 | if (!api->getstringsize) | ||
181 | api->getstringsize=getstringsize; | ||
182 | if (!api->getwidth) | ||
183 | api->getwidth=lcd_getwidth; | ||
184 | if (!api->getheight) | ||
185 | api->getheight=lcd_getheight; | ||
186 | if (!api->set_drawmode) | ||
187 | api->set_drawmode=lcd_set_drawmode; | ||
188 | if (!api->puts_scroll) | ||
189 | api->puts_scroll=puts_scroll; | ||
190 | if (!api->update) | ||
191 | api->update=lcd_update; | ||
192 | if (!api->clear_display) | ||
193 | api->clear_display=lcd_clear_display; | ||
194 | if (!api->getfont) | ||
195 | api->getfont=lcd_getfont; | ||
196 | if (!api->putsxy) | ||
197 | api->putsxy=putsxy; | ||
198 | |||
199 | #if LCD_DEPTH > 1 | ||
200 | if (!api->get_foreground) | ||
201 | api->get_foreground=lcd_get_foreground; | ||
202 | if (!api->get_background) | ||
203 | api->get_background=lcd_get_background; | ||
204 | #endif | ||
205 | if (!api->load_remote_wps_backdrop) | ||
206 | api->load_remote_wps_backdrop = load_remote_wps_backdrop2; | ||
207 | if (!api->load_wps_backdrop) | ||
208 | api->load_wps_backdrop = load_wps_backdrop2; | ||
209 | //dbgf = printf; | ||
210 | } | ||
211 | |||
212 | /************************************************************** | ||
213 | |||
214 | **************************************************************/ | ||
215 | |||
216 | int set_api(struct proxy_api* api) { | ||
217 | if (api->debugf) | ||
218 | dbgf = api->debugf; | ||
219 | screens[0].screen_type=SCREEN_MAIN; | ||
220 | screens[0].lcdwidth=LCD_WIDTH; | ||
221 | screens[0].lcdheight=LCD_HEIGHT; | ||
222 | screens[0].depth=LCD_DEPTH; | ||
223 | #ifdef HAVE_LCD_COLOR | ||
224 | screens[0].is_color=true; | ||
225 | #else | ||
226 | screens[0].is_color=false; | ||
227 | #endif | ||
228 | if (api->stop_scroll) | ||
229 | screens[0].stop_scroll=api->stop_scroll; | ||
230 | screens[0].scroll_stop = lcd_scroll_stop; | ||
231 | if (api->set_viewport) | ||
232 | screens[0].set_viewport=api->set_viewport; | ||
233 | if (api->clear_viewport) | ||
234 | screens[0].clear_viewport=lcd_clear_viewport; | ||
235 | if (api->getstringsize) | ||
236 | screens[0].getstringsize=api->getstringsize; | ||
237 | if (api->getwidth) | ||
238 | screens[0].getwidth=api->getwidth; | ||
239 | if (api->getheight) | ||
240 | screens[0].getheight=api->getheight; | ||
241 | if (api->set_drawmode) | ||
242 | screens[0].set_drawmode=api->set_drawmode; | ||
243 | if (api->fillrect) | ||
244 | screens[0].fillrect=api->fillrect; | ||
245 | if (api->puts_scroll) | ||
246 | screens[0].puts_scroll=api->puts_scroll; | ||
247 | if (api->transparent_bitmap_part) | ||
248 | screens[0].transparent_bitmap_part=api->transparent_bitmap_part; | ||
249 | if (api->update) | ||
250 | screens[0].update=api->update; | ||
251 | if (api->clear_display) | ||
252 | screens[0].clear_display=api->clear_display; | ||
253 | if (api->getfont) | ||
254 | screens[0].getfont=api->getfont; | ||
255 | if (api->hline) | ||
256 | screens[0].hline=api->hline; | ||
257 | if (api->vline) | ||
258 | screens[0].vline=api->vline; | ||
259 | if (api->drawpixel) | ||
260 | screens[0].drawpixel=api->drawpixel; | ||
261 | if (api->putsxy) | ||
262 | screens[0].putsxy=api->putsxy; | ||
263 | #if LCD_DEPTH > 1 | ||
264 | if (api->get_foreground) | ||
265 | screens[0].get_foreground=api->get_foreground; | ||
266 | if (api->get_background) | ||
267 | screens[0].get_background=api->get_background; | ||
268 | #endif | ||
269 | |||
270 | screens[0].bitmap_part = api->bitmap_part; | ||
271 | /************************** | ||
272 | * OUT * | ||
273 | **************************/ | ||
274 | api->get_model_name = get_model_name; | ||
275 | api->get_current_vp = get_current_vp; | ||
276 | api->set_wpsstate = set_wpsstate; | ||
277 | api->set_trackstate = set_trackstate; | ||
278 | api->set_next_trackstate= set_next_trackstate; | ||
279 | api->set_audio_status= set_audio_status; | ||
280 | xapi = api; | ||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | |||
285 | |||
286 | |||
287 | |||
288 | |||
289 | |||