Rev 7746 | Rev 7749 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7746 | Rev 7748 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | #include "..\lib\obj\box_lib.h" |
20 | #include "..\lib\obj\box_lib.h" |
21 | #include "..\lib\obj\libio.h" |
21 | #include "..\lib\obj\libio.h" |
22 | #include "..\lib\obj\libimg.h" |
22 | #include "..\lib\obj\libimg.h" |
23 | #include "..\lib\obj\http.h" |
23 | #include "..\lib\obj\http.h" |
24 | #include "..\lib\obj\iconv.h" |
24 | #include "..\lib\obj\iconv.h" |
- | 25 | #include "..\lib\obj\proc_lib.h" |
|
25 | //useful patterns |
26 | //useful patterns |
26 | #include "..\lib\patterns\history.h" |
27 | #include "..\lib\patterns\history.h" |
27 | #include "..\lib\patterns\http_downloader.h" |
28 | #include "..\lib\patterns\http_downloader.h" |
- | 29 | #include "..\lib\patterns\simple_open_dialog.h" |
|
Line 28... | Line 30... | ||
28 | 30 | ||
Line 29... | Line 31... | ||
29 | _http http = {0, 0, 0, 0, 0, 0, 0}; |
31 | _http http = {0, 0, 0, 0, 0, 0, 0}; |
30 | 32 | ||
31 | 33 | ||
32 | #ifdef LANG_RUS |
34 | #ifdef LANG_RUS |
33 | char version[]="¥ªáâ®¢ë© ¡à 㧥à 1.9"; |
- | |
34 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
35 | char version[]="¥ªáâ®¢ë© ¡à 㧥à 1.92"; |
35 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
36 | #define T_LOADING " £à㧪 áâà ¨æë..." |
36 | char loading[] = " £à㧪 áâà ¨æë... |
37 | #define T_RENDERING "¥¤¥à¨£..." |
37 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
38 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
38 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
39 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
Line 46... | Line 47... | ||
46 | char link_menu[] = |
47 | char link_menu[] = |
47 | "®¯¨à®¢ âì áá뫪ã |
48 | "®¯¨à®¢ âì áá뫪ã |
48 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
49 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
49 | #else |
50 | #else |
50 | char version[]="Text-based Browser 1.9"; |
51 | char version[]="Text-based Browser 1.9"; |
51 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
- | |
52 | ?define T_LAST_SLIDE "This slide is the last" |
52 | #define T_LOADING "Loading..." |
53 | char loading[] = "Loading... |
53 | #define T_RENDERING "Rendering..." |
54 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
54 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
55 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
55 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
56 | char help[] = FROM "html\\help_en.htm""\0"; |
56 | char help[] = FROM "html\\help_en.htm""\0"; |
57 | char accept_language[]= "Accept-Language: en\n"; |
57 | char accept_language[]= "Accept-Language: en\n"; |
58 | char rmb_menu[] = |
58 | char rmb_menu[] = |
Line 71... | Line 71... | ||
71 | #define URL_SERVICE_HELP "WebView://help" |
71 | #define URL_SERVICE_HELP "WebView://help" |
72 | #define URL_SERVICE_SOURCE "WebView://source:" |
72 | #define URL_SERVICE_SOURCE "WebView://source:" |
Line 73... | Line 73... | ||
73 | 73 | ||
Line 74... | Line -... | ||
74 | proc_info Form; |
- | |
75 | - | ||
76 | //char search_path[]="http://nigma.ru/index.php?s="; |
- | |
77 | int redirected = 0; |
74 | proc_info Form; |
Line 78... | Line 75... | ||
78 | 75 | ||
Line 79... | Line 76... | ||
79 | char stak[4096]; |
76 | char stak[4096]; |
Line 88... | Line 85... | ||
88 | dword border_color = 0x8C8C8C; |
85 | dword border_color = 0x8C8C8C; |
Line 89... | Line 86... | ||
89 | 86 | ||
Line 90... | Line 87... | ||
90 | bool debug_mode = false; |
87 | bool debug_mode = false; |
- | 88 | ||
91 | 89 | progress_bar wv_progress_bar; |
|
92 | progress_bar wv_progress_bar; |
90 | |
Line 93... | Line 91... | ||
93 | bool souce_mode = false; |
91 | bool souce_mode = false; |
94 | bool open_in_a_new_window = false; |
92 | bool open_in_a_new_window = false; |
Line 100... | Line 98... | ||
100 | GOTOURL_BUTTON, |
98 | GOTOURL_BUTTON, |
101 | SANDWICH_BUTTON, |
99 | SANDWICH_BUTTON, |
102 | VIEW_SOURCE=1100, |
100 | VIEW_SOURCE=1100, |
103 | EDIT_SOURCE, |
101 | EDIT_SOURCE, |
104 | VIEW_HISTORY, |
102 | VIEW_HISTORY, |
105 | //FREE_IMG_CACHE, |
- | |
106 | DOWNLOAD_MANAGER, |
103 | DOWNLOAD_MANAGER, |
107 | COPY_LINK_URL=1200, |
104 | COPY_LINK_URL=1200, |
108 | DOWNLOAD_LINK_CONTENTS, |
105 | DOWNLOAD_LINK_CONTENTS, |
109 | }; |
106 | }; |
Line 110... | Line 107... | ||
110 | 107 | ||
111 | #include "..\TWB\TWB.c" |
108 | #include "..\TWB\TWB.c" |
112 | #include "history.h" |
109 | #include "history.h" |
113 | #include "show_src.h" |
110 | #include "show_src.h" |
Line -... | Line 111... | ||
- | 111 | #include "download_manager.h" |
|
- | 112 | ||
- | 113 | char default_dir[] = "/rd/1"; |
|
114 | #include "download_manager.h" |
114 | od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; |
115 | 115 | ||
Line 116... | Line 116... | ||
116 | char editURL[sizeof(URL)]; |
116 | char editURL[sizeof(URL)]; |
Line 117... | Line 117... | ||
117 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL)-2,#editURL,0,NULL,19,19}; |
117 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL)-2,#editURL,0,NULL,19,19}; |
118 | 118 | ||
119 | #define SKIN_Y 24 |
- | |
120 | 119 | #define SKIN_Y 24 |
|
121 | void main() |
120 | |
122 | { |
121 | void LoadLibraries() |
123 | int i; |
122 | { |
124 | load_dll(boxlib, #box_lib_init,0); |
123 | load_dll(boxlib, #box_lib_init,0); |
125 | load_dll(libio, #libio_init,1); |
124 | load_dll(libio, #libio_init,1); |
126 | load_dll(libimg, #libimg_init,1); |
125 | load_dll(libimg, #libimg_init,1); |
- | 126 | load_dll(libHTTP, #http_lib_init,1); |
|
- | 127 | load_dll(iconv_lib, #iconv_open,0); |
|
127 | load_dll(libHTTP, #http_lib_init,1); |
128 | load_dll(Proc_lib, #OpenDialog_init,0); |
- | 129 | OpenDialog_init stdcall (#o_dialog); |
|
128 | load_dll(iconv_lib, #iconv_open,0); |
130 | } |
129 | Libimg_LoadImage(#skin, "/sys/toolbar.png"); |
131 | |
130 | skin.h = 26; |
132 | void HandleParam() |
131 | wv_progress_bar.progress_color = 0x72B7EB; |
133 | { |
132 | CreateDir("/tmp0/1/downloads"); |
134 | if (param) { |
- | 135 | if (param[0]=='-') && (param[1]=='d') { |
|
- | 136 | strcpy(#downloader_edit, #param+3); |
|
- | 137 | CreateThread(#Downloader,#downloader_stak+4092); |
|
- | 138 | ExitProcess(); |
|
- | 139 | } else { |
|
- | 140 | strcpy(#URL, #param); |
|
133 | if (param) && (param[0]=='-') && (param[1]=='d') { |
141 | } |
- | 142 | } else { |
|
- | 143 | strcpy(#URL, URL_SERVICE_HOMEPAGE); |
|
- | 144 | } |
|
- | 145 | } |
|
- | 146 | ||
- | 147 | void main() |
|
- | 148 | { |
|
134 | strcpy(#downloader_edit, #param+3); |
149 | int redirect_count = 0; |
- | 150 | int i; |
|
- | 151 | LoadLibraries(); |
|
135 | CreateThread(#Downloader,#downloader_stak+4092); |
152 | CreateDir("/tmp0/1/downloads"); |
136 | ExitProcess(); |
153 | Libimg_LoadImage(#skin, "/sys/toolbar.png"); |
137 | } |
154 | HandleParam(); |
138 | else if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOMEPAGE); |
155 | skin.h = 26; |
139 | WB1.list.SetFont(8, 14, 10011000b); |
156 | WB1.list.SetFont(8, 14, 10011000b); |
Line 164... | Line 181... | ||
164 | break; |
181 | break; |
Line 165... | Line 182... | ||
165 | 182 | ||
166 | case evKey: |
183 | case evKey: |
167 | GetKeys(); |
184 | GetKeys(); |
- | 185 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
|
168 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
186 | if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog(); |
169 | if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY); |
187 | if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY); |
170 | if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE); |
188 | if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE); |
171 | if (key_scancode == SCAN_CODE_KEY_T) |
189 | if (key_scancode == SCAN_CODE_KEY_T) |
172 | || (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL); |
190 | || (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL); |
Line 204... | Line 222... | ||
204 | case evReDraw: |
222 | case evReDraw: |
205 | if (menu.cur_y) { |
223 | if (menu.cur_y) { |
206 | ProcessEvent(menu.cur_y); |
224 | ProcessEvent(menu.cur_y); |
207 | menu.cur_y = 0; |
225 | menu.cur_y = 0; |
208 | } |
226 | } |
209 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0); |
227 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,0,0,0); |
210 | GetProcessInfo(#Form, SelfInfo); |
228 | GetProcessInfo(#Form, SelfInfo); |
- | 229 | system.color.get(); |
|
- | 230 | col_bg = system.color.work; |
|
211 | if (Form.status_window>2) { DrawTitle(#header); break; } |
231 | if (Form.status_window>2) { DrawTitle(#header); break; } |
212 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
232 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
213 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
233 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
214 | Draw_Window(); |
234 | draw_window(); |
215 | break; |
235 | break; |
Line 216... | Line 236... | ||
216 | 236 | ||
217 | case evNetwork: |
237 | case evNetwork: |
218 | if (http.transfer > 0) { |
238 | if (http.transfer > 0) { |
219 | http.receive(); |
239 | http.receive(); |
- | 240 | EventUpdateProgressBar(); |
|
220 | EventUpdateProgressBar(); |
241 | DrawStatusBar(T_LOADING); |
221 | if (http.receive_result == 0) { |
242 | if (http.receive_result == 0) { |
222 | // Handle redirects |
243 | // Handle redirects |
223 | if (http.status_code >= 300) && (http.status_code < 400) |
244 | if (http.status_code >= 300) && (http.status_code < 400) |
224 | { |
245 | { |
225 | redirected++; |
246 | redirect_count++; |
226 | if (redirected>5) |
247 | if (redirect_count>5) |
227 | { |
248 | { |
228 | notify("'Too many redirects.' -E"); |
249 | notify("'Too many redirects.' -E"); |
229 | StopLoading(); |
250 | StopLoading(); |
230 | } |
251 | } |
231 | else |
252 | else |
232 | { |
253 | { |
233 | http.handle_redirect(); |
254 | http.handle_redirect(); |
234 | http.free(); |
255 | http.free(); |
- | 256 | GetAbsoluteURL(#http.redirect_url); |
|
235 | GetAbsoluteURL(#http.redirect_url); |
257 | debug("Redirect: "); debugln(#http.redirect_url); |
- | 258 | history.back(); |
|
236 | history.back(); |
259 | strcpy(#URL, #http.redirect_url); |
237 | strcpy(#editURL, #URL); |
260 | strcpy(#editURL, #URL); |
238 | DrawOmnibox(); |
261 | DrawOmnibox(); |
239 | OpenPage(); |
262 | OpenPage(); |
240 | //ProcessLink(history.current()); |
263 | //ProcessLink(history.current()); |
241 | } |
264 | } |
242 | break; |
265 | break; |
243 | } |
266 | } |
244 | redirected = 0; |
267 | redirect_count = 0; |
245 | // Loading the page is complete, free resources |
268 | // Loading the page is complete, free resources |
246 | history.add(#URL); |
269 | history.add(#URL); |
247 | bufpointer = http.content_pointer; |
270 | bufpointer = http.content_pointer; |
248 | bufsize = http.content_received; |
271 | bufsize = http.content_received; |
249 | http.free(); |
272 | http.free(); |
- | 273 | SetPageDefaults(); |
|
250 | SetPageDefaults(); |
274 | DrawStatusBar(T_RENDERING); |
- | 275 | ShowPage(); |
|
251 | ShowPage(); |
276 | DrawStatusBar(NULL); |
252 | } |
277 | } |
253 | } |
278 | } |
254 | } |
279 | } |
Line 270... | Line 295... | ||
270 | } |
295 | } |
271 | } |
296 | } |
Line 272... | Line 297... | ||
272 | 297 | ||
273 | 298 | ||
274 | 299 | ||
275 | void Draw_Window() |
300 | void draw_window() |
276 | { |
301 | { |
277 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
302 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
Line 324... | Line 349... | ||
324 | return; |
349 | return; |
325 | case REFRESH_BUTTON: |
350 | case REFRESH_BUTTON: |
326 | if (http.transfer > 0) |
351 | if (http.transfer > 0) |
327 | { |
352 | { |
328 | StopLoading(); |
353 | StopLoading(); |
329 | Draw_Window(); |
354 | draw_window(); |
330 | } |
355 | } |
331 | else OpenPage(); |
356 | else OpenPage(); |
332 | return; |
357 | return; |
333 | case SANDWICH_BUTTON: |
358 | case SANDWICH_BUTTON: |
334 | EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6); |
359 | EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6); |
Line 344... | Line 369... | ||
344 | CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
369 | CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
345 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
370 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
346 | } |
371 | } |
347 | else RunProgram("/rd/1/tinypad", #URL); |
372 | else RunProgram("/rd/1/tinypad", #URL); |
348 | return; |
373 | return; |
349 | // case FREE_IMG_CACHE: |
- | |
350 | // ImgCache.Free(); |
- | |
351 | // notify(IMAGES_CACHE_CLEARED); |
- | |
352 | // WB1.DrawPage(); |
- | |
353 | // return; |
- | |
354 | case VIEW_HISTORY: |
374 | case VIEW_HISTORY: |
355 | strcpy(#URL, URL_SERVICE_HISTORY); |
375 | strcpy(#URL, URL_SERVICE_HISTORY); |
356 | OpenPage(); |
376 | OpenPage(); |
357 | return; |
377 | return; |
358 | case DOWNLOAD_MANAGER: |
378 | case DOWNLOAD_MANAGER: |
Line 618... | Line 638... | ||
618 | void ShowPage() |
638 | void ShowPage() |
619 | { |
639 | { |
620 | DrawOmnibox(); |
640 | DrawOmnibox(); |
621 | if (!bufsize) |
641 | if (!bufsize) |
622 | { |
642 | { |
623 | if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading)); |
- | |
624 | else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
643 | WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
625 | } |
644 | } |
626 | else |
645 | else |
627 | { |
646 | { |
628 | WB1.Prepare(); |
647 | WB1.Prepare(); |
629 | } |
648 | } |
Line 638... | Line 657... | ||
638 | void DrawProgress() |
657 | void DrawProgress() |
639 | { |
658 | { |
640 | dword persent; |
659 | dword persent; |
641 | if (http.transfer == 0) return; |
660 | if (http.transfer == 0) return; |
642 | if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10; |
661 | if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10; |
643 | DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color); |
662 | DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, 0x72B7EB); |
644 | } |
663 | } |
Line 645... | Line 664... | ||
645 | 664 | ||
646 | void EventShowPageMenu(dword _left, _top) |
665 | void EventShowPageMenu(dword _left, _top) |
647 | { |
666 | { |
Line 664... | Line 683... | ||
664 | } |
683 | } |
Line 665... | Line 684... | ||
665 | 684 | ||
666 | void EventSeachWeb() |
685 | void EventSeachWeb() |
667 | { |
686 | { |
- | 687 | sprintf(#URL, "https://www.google.com/search?q=%s", #editURL); |
|
668 | sprintf(#URL, "https://www.google.com/search?q=%s", #editURL); |
688 | replace_char(#URL, ' ', '_', sizeof(URL)); |
669 | ProcessLink(); |
689 | ProcessLink(); |
Line -... | Line 690... | ||
- | 690 | } |
|
- | 691 | ||
- | 692 | void EventOpenDialog() |
|
- | 693 | { |
|
- | 694 | OpenDialog_start stdcall (#o_dialog); |
|
- | 695 | if (o_dialog.status) { |
|
- | 696 | strcpy(#URL, #openfile_path); |
|
- | 697 | OpenPage(); |
|
- | 698 | } |
|
670 | } |
699 | } |
671 | 700 | ||
672 | void DrawStatusBar(dword _status_text) |
701 | void DrawStatusBar(dword _status_text) |
673 | { |
702 | { |
674 | status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10; |
703 | status_text.start_x = 10; |
675 | status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
704 | status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
676 | status_text.area_size_x = Form.cwidth - status_text.start_x -3; |
705 | status_text.area_size_x = Form.cwidth - status_text.start_x -3; |
677 | DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg); |
706 | DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg); |