Rev 7754 | Rev 7756 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7754 | Rev 7755 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | #ifndef AUTOBUILD |
5 | #ifndef AUTOBUILD |
6 | #include "lang.h--" |
6 | #include "lang.h--" |
7 | #endif |
7 | #endif |
Line 8... | Line 8... | ||
8 | 8 | ||
9 | //libraries |
9 | //libraries |
10 | #define MEMSIZE 1024 * 800 |
10 | #define MEMSIZE 1024 * 850 |
11 | #include "..\lib\gui.h" |
11 | #include "..\lib\gui.h" |
12 | #include "..\lib\draw_buf.h" |
12 | #include "..\lib\draw_buf.h" |
13 | #include "..\lib\list_box.h" |
13 | #include "..\lib\list_box.h" |
14 | #include "..\lib\cursor.h" |
14 | #include "..\lib\cursor.h" |
Line 27... | Line 27... | ||
27 | #include "..\lib\patterns\history.h" |
27 | #include "..\lib\patterns\history.h" |
28 | #include "..\lib\patterns\http_downloader.h" |
28 | #include "..\lib\patterns\http_downloader.h" |
29 | #include "..\lib\patterns\simple_open_dialog.h" |
29 | #include "..\lib\patterns\simple_open_dialog.h" |
Line 30... | Line 30... | ||
30 | 30 | ||
31 | #ifdef LANG_RUS |
31 | #ifdef LANG_RUS |
32 | char version[]="¥ªáâ®¢ë© ¡à 㧥à 2.0 beta1"; |
- | |
33 | #define T_LOADING " £à㧪 áâà ¨æë..." |
- | |
34 | #define T_RENDERING "¥¤¥à¨£..." |
32 | char version[]="¥ªáâ®¢ë© ¡à 㧥à 2.0 beta2"; |
35 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
33 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
36 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
34 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
37 | char help[] = FROM "html\\help_ru.htm""\0"; |
35 | char help[] = FROM "html\\help_ru.htm""\0"; |
38 | char accept_language[]= "Accept-Language: ru\n"; |
36 | char accept_language[]= "Accept-Language: ru\n"; |
Line 43... | Line 41... | ||
43 | ¥¥¤¦¥à § £à㧮ª"; |
41 | ¥¥¤¦¥à § £à㧮ª"; |
44 | char link_menu[] = |
42 | char link_menu[] = |
45 | "®¯¨à®¢ âì áá뫪ã |
43 | "®¯¨à®¢ âì áá뫪ã |
46 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
44 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
47 | #else |
45 | #else |
48 | char version[]="Text-based Browser 2.0 beta1"; |
46 | char version[]="Text-based Browser 2.0 beta2"; |
49 | #define T_LOADING "Loading..." |
- | |
50 | #define T_RENDERING "Rendering..." |
- | |
51 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
47 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
52 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
48 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
53 | char help[] = FROM "html\\help_en.htm""\0"; |
49 | char help[] = FROM "html\\help_en.htm""\0"; |
54 | char accept_language[]= "Accept-Language: en\n"; |
50 | char accept_language[]= "Accept-Language: en\n"; |
55 | char rmb_menu[] = |
51 | char rmb_menu[] = |
Line 64... | Line 60... | ||
64 | 60 | ||
Line 65... | Line 61... | ||
65 | #define URL_SIZE 4000; |
61 | #define URL_SIZE 4000; |
66 | 62 | ||
67 | dword col_bg = 0xE3E2E2; |
63 | dword col_bg = 0xE3E2E2; |
Line 68... | Line 64... | ||
68 | dword panel_color = 0xE3E2E2; |
64 | dword panel_color = 0xE3E2E2; |
69 | dword border_color = 0x8C8C8C; |
- | |
Line 70... | Line 65... | ||
70 | 65 | dword border_color = 0x787878; |
|
Line 71... | Line 66... | ||
71 | bool debug_mode = false; |
66 | |
72 | bool open_in_a_new_window = false; |
67 | bool debug_mode = false; |
Line 80... | Line 75... | ||
80 | 75 | ||
81 | #define URL_SERVICE_HISTORY "WebView:history" |
76 | #define URL_SERVICE_HISTORY "WebView:history" |
82 | #define URL_SERVICE_HOMEPAGE "WebView:home" |
77 | #define URL_SERVICE_HOMEPAGE "WebView:home" |
Line -... | Line 78... | ||
- | 78 | #define URL_SERVICE_HELP "WebView:help" |
|
83 | #define URL_SERVICE_HELP "WebView:help" |
79 | |
84 | 80 | #define TOOLBAR_GAPS 10 |
|
Line 85... | Line 81... | ||
85 | dword TOOLBAR_H = 40; |
81 | dword TOOLBAR_H = 40; |
Line 108... | Line 104... | ||
108 | }; |
104 | }; |
Line 109... | Line 105... | ||
109 | 105 | ||
110 | char default_dir[] = "/rd/1"; |
106 | char default_dir[] = "/rd/1"; |
Line 111... | Line 107... | ||
111 | od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; |
107 | od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; |
112 | 108 | ||
113 | char URL[URL_SIZE]; |
109 | char editURL[URL_SIZE+1]; |
Line 114... | Line 110... | ||
114 | char editURL[URL_SIZE]; |
110 | edit_box address_box = {NULL,TOOLBAR_GAPS+TOOLBAR_GAPS+51,10,0xffffff,0x94AECE,0xffffff, |
Line 115... | Line 111... | ||
115 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,0,NULL,19,19}; |
111 | 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,NULL,19,19}; |
116 | 112 | ||
Line 134... | Line 130... | ||
134 | strcpy(#downloader_edit, #param+3); |
130 | strcpy(#downloader_edit, #param+3); |
135 | CreateThread(#Downloader,#downloader_stak+4092); |
131 | CreateThread(#Downloader,#downloader_stak+4092); |
136 | ExitProcess(); |
132 | ExitProcess(); |
137 | } else if (!strncmp(#param, "-s ", 3)) { |
133 | } else if (!strncmp(#param, "-s ", 3)) { |
138 | source_mode = true; |
134 | source_mode = true; |
139 | strcpy(#URL, #param + 3); |
135 | history.add(#param + 3); |
140 | } else { |
136 | } else { |
141 | strcpy(#URL, #param); |
137 | history.add(#param); |
142 | } |
138 | } |
143 | } else { |
139 | } else { |
144 | strcpy(#URL, URL_SERVICE_HOMEPAGE); |
140 | history.add(URL_SERVICE_HOMEPAGE); |
145 | } |
141 | } |
146 | } |
142 | } |
Line 147... | Line 143... | ||
147 | 143 | ||
148 | void main() |
144 | void main() |
Line 161... | Line 157... | ||
161 | { |
157 | { |
162 | case evMouse: |
158 | case evMouse: |
163 | edit_box_mouse stdcall (#address_box); |
159 | edit_box_mouse stdcall (#address_box); |
164 | mouse.get(); |
160 | mouse.get(); |
165 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y)) |
161 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y)) |
166 | && (bufsize) && (mouse.pkm) && (mouse.up) { |
162 | && (mouse.pkm) && (mouse.up) { |
167 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
163 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
168 | break; |
164 | break; |
169 | } |
165 | } |
170 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
166 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
171 | scrollbar_v_mouse (#scroll_wv); |
167 | scrollbar_v_mouse (#scroll_wv); |
Line 223... | Line 219... | ||
223 | case evReDraw: |
219 | case evReDraw: |
224 | if (menu.cur_y) { |
220 | if (menu.cur_y) { |
225 | ProcessEvent(menu.cur_y); |
221 | ProcessEvent(menu.cur_y); |
226 | menu.cur_y = 0; |
222 | menu.cur_y = 0; |
227 | } |
223 | } |
- | 224 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), |
|
228 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); |
225 | GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); |
229 | GetProcessInfo(#Form, SelfInfo); |
226 | GetProcessInfo(#Form, SelfInfo); |
230 | system.color.get(); |
227 | system.color.get(); |
231 | col_bg = system.color.work; |
228 | col_bg = system.color.work; |
232 | if (Form.status_window>2) { DrawTitle(#header); break; } |
229 | if (Form.status_window>2) { DrawTitle(#header); break; } |
233 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
230 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
Line 237... | Line 234... | ||
237 | 234 | ||
238 | case evNetwork: |
235 | case evNetwork: |
239 | if (http.transfer > 0) { |
236 | if (http.transfer > 0) { |
240 | http.receive(); |
237 | http.receive(); |
241 | EventUpdateProgressBar(); |
- | |
242 | DrawStatusBar(T_LOADING); |
238 | EventUpdateProgressBar(); |
243 | if (http.receive_result == 0) { |
239 | if (http.receive_result == 0) { |
244 | // Handle redirects |
240 | // Handle redirects |
245 | if (http.status_code >= 300) && (http.status_code < 400) |
241 | if (http.status_code >= 300) && (http.status_code < 400) |
246 | { |
242 | { |
Line 255... | Line 251... | ||
255 | http.handle_redirect(); |
251 | http.handle_redirect(); |
256 | http.free(); |
252 | http.free(); |
257 | GetAbsoluteURL(#http.redirect_url); |
253 | GetAbsoluteURL(#http.redirect_url); |
258 | debug("Redirect: "); debugln(#http.redirect_url); |
254 | debug("Redirect: "); debugln(#http.redirect_url); |
259 | history.back(); |
255 | history.back(); |
260 | strcpy(#URL, #http.redirect_url); |
256 | OpenPage(#http.redirect_url); |
261 | strcpy(#editURL, #URL); |
- | |
262 | DrawOmnibox(); |
- | |
263 | OpenPage(); |
- | |
264 | //ProcessLink(history.current()); |
- | |
265 | } |
257 | } |
266 | break; |
258 | break; |
267 | } |
259 | } |
268 | redirect_count = 0; |
260 | redirect_count = 0; |
269 | // Loading the page is complete, free resources |
261 | // Loading the page is complete, free resources |
270 | history.add(#URL); |
- | |
271 | bufpointer = http.content_pointer; |
- | |
272 | bufsize = http.content_received; |
- | |
273 | http.free(); |
262 | http.free(); |
274 | DrawStatusBar(T_RENDERING); |
263 | LoadInternalPage(http.content_pointer, http.content_received); |
275 | ShowPage(); |
- | |
276 | DrawStatusBar(NULL); |
- | |
277 | } |
264 | } |
278 | } |
265 | } |
279 | } |
266 | } |
280 | } |
267 | } |
Line 281... | Line 268... | ||
281 | 268 | ||
282 | void SetElementSizes() |
269 | void SetElementSizes() |
283 | { |
270 | { |
284 | address_box.top = TOOLBAR_H/2-10; |
271 | address_box.top = TOOLBAR_H/2-10; |
285 | basic_line_h = calc(WB1.list.font_h * 130) / 100; |
272 | basic_line_h = calc(WB1.list.font_h * 130) / 100; |
286 | address_box.width = Form.cwidth - address_box.left - 50; |
273 | address_box.width = Form.cwidth - address_box.left - 55; |
287 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
274 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
288 | Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
275 | Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
289 | WB1.list.wheel_size = 7 * basic_line_h; |
276 | WB1.list.wheel_size = 7 * basic_line_h; |
290 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
277 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
291 | WB1.list.visible = WB1.list.h; |
278 | WB1.list.visible = WB1.list.h; |
292 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
279 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
293 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20); |
280 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20); |
294 | ProcessEvent(REFRESH_BUTTON); |
281 | OpenPage(history.current()); |
295 | } |
282 | } |
Line 301... | Line 288... | ||
301 | { |
288 | { |
302 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
289 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
303 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
290 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
304 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
291 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
305 | SetElementSizes(); |
292 | SetElementSizes(); |
306 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 25,border_color); |
- | |
307 | DefineButton(address_box.left-52, address_box.top-2, 24, skin.h-2, BACK_BUTTON+BT_HIDE, 0); |
293 | DefineHiddenButton(TOOLBAR_GAPS, address_box.top-2, 24, skin.h-2, BACK_BUTTON); |
308 | DefineButton(address_box.left-27, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); |
294 | DefineHiddenButton(TOOLBAR_GAPS+25, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON); |
309 | img_draw stdcall(skin.image, address_box.left-53, address_box.top-3, 51, skin.h, 0, SKIN_Y); |
295 | img_draw stdcall(skin.image, TOOLBAR_GAPS-1, address_box.top-3, 51, skin.h, 0, SKIN_Y); |
310 | DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); |
296 | DefineHiddenButton(address_box.left+address_box.width-4, address_box.top-2, 20, skin.h-3, REFRESH_BUTTON); |
311 | DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); |
297 | DefineHiddenButton(Form.cwidth-31, address_box.top-3, 24, skin.h-1, SANDWICH_BUTTON); |
312 | img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y); |
298 | img_draw stdcall(skin.image, Form.cwidth-27, address_box.top+1, 17, 18, 51, SKIN_Y); |
313 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
299 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
314 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
300 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
315 | if (!header) { |
301 | if (!header) { |
316 | OpenPage(); |
302 | OpenPage(history.current()); |
317 | WB1.DrawScroller(); |
303 | WB1.DrawScroller(); |
318 | } |
304 | } |
319 | else { |
305 | else { |
320 | WB1.DrawPage(); |
306 | WB1.DrawPage(); |
321 | DrawOmnibox(); |
307 | DrawOmnibox(); |
322 | } |
308 | } |
323 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
309 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, |
- | 310 | scroll_wv.size_y-1, scroll_wv.bckg_col); |
|
324 | DrawProgress(); |
311 | DrawProgress(); |
325 | } |
312 | } |
Line 326... | Line 313... | ||
326 | 313 | ||
Line 333... | Line 320... | ||
333 | ExitProcess(); |
320 | ExitProcess(); |
334 | return; |
321 | return; |
335 | case SCAN_CODE_BS: |
322 | case SCAN_CODE_BS: |
336 | case BACK_BUTTON: |
323 | case BACK_BUTTON: |
337 | if (history.back()) { |
324 | if (history.back()) { |
338 | strcpy(#URL, history.current()); |
325 | OpenPage(history.current()); |
339 | OpenPage(); |
- | |
340 | } |
326 | } |
341 | return; |
327 | return; |
342 | case FORWARD_BUTTON: |
328 | case FORWARD_BUTTON: |
343 | if (history.forward()) { |
329 | if (history.forward()) { |
344 | strcpy(#URL, history.current()); |
330 | OpenPage(history.current()); |
345 | OpenPage(); |
- | |
346 | } |
331 | } |
347 | return; |
332 | return; |
348 | case GOTOURL_BUTTON: |
333 | case GOTOURL_BUTTON: |
349 | case SCAN_CODE_ENTER: |
334 | case SCAN_CODE_ENTER: |
350 | EventSubmitOmnibox(); |
335 | EventSubmitOmnibox(); |
351 | return; |
336 | return; |
352 | case REFRESH_BUTTON: |
337 | case REFRESH_BUTTON: |
353 | if (http.transfer > 0) |
338 | if (http.transfer > 0) { |
354 | { |
- | |
355 | StopLoading(); |
339 | StopLoading(); |
356 | draw_window(); |
340 | draw_window(); |
- | 341 | } else { |
|
- | 342 | OpenPage(history.current()); |
|
357 | } |
343 | } |
358 | else OpenPage(); |
- | |
359 | return; |
344 | return; |
360 | case SANDWICH_BUTTON: |
345 | case SANDWICH_BUTTON: |
361 | EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6); |
346 | EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6); |
362 | return; |
347 | return; |
363 | case VIEW_SOURCE: |
348 | case VIEW_SOURCE: |
364 | EventViewSource(); |
349 | EventViewSource(); |
365 | break; |
350 | break; |
366 | case EDIT_SOURCE: |
351 | case EDIT_SOURCE: |
367 | if (check_is_the_adress_local(#URL)) { |
352 | if (check_is_the_adress_local(history.current())) { |
368 | RunProgram("/rd/1/tinypad", #URL); |
353 | RunProgram("/rd/1/tinypad", history.current()); |
369 | } else { |
354 | } else { |
370 | CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
355 | CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
371 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
356 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
372 | } |
357 | } |
373 | return; |
358 | return; |
374 | case VIEW_HISTORY: |
359 | case VIEW_HISTORY: |
375 | strcpy(#URL, URL_SERVICE_HISTORY); |
360 | OpenPage(URL_SERVICE_HISTORY); |
376 | OpenPage(); |
- | |
377 | return; |
361 | return; |
378 | case DOWNLOAD_MANAGER: |
362 | case DOWNLOAD_MANAGER: |
379 | if (!downloader_opened) { |
363 | if (!downloader_opened) { |
380 | downloader_edit = NULL; |
364 | downloader_edit = NULL; |
381 | CreateThread(#Downloader,#downloader_stak+4092); |
365 | CreateThread(#Downloader,#downloader_stak+4092); |
Line 408... | Line 392... | ||
408 | $push EAX // save it on the stack |
392 | $push EAX // save it on the stack |
409 | http_free stdcall (http.transfer); // abort connection |
393 | http_free stdcall (http.transfer); // abort connection |
410 | $pop EAX |
394 | $pop EAX |
411 | free(EAX); // free data |
395 | free(EAX); // free data |
412 | http.transfer=0; |
396 | http.transfer=0; |
413 | bufsize = 0; |
- | |
414 | bufpointer = free(bufpointer); |
- | |
415 | pause(10); |
397 | pause(10); |
416 | } |
398 | } |
417 | wv_progress_bar.value = 0; |
399 | wv_progress_bar.value = 0; |
418 | DrawOmnibox(); |
400 | DrawOmnibox(); |
419 | } |
401 | } |
Line -... | Line 402... | ||
- | 402 | ||
420 | 403 | /* |
|
421 | void ReplaceSpaceInUrl() { |
404 | void ReplaceSpaceInUrl() { |
- | 405 | int i; |
|
422 | int i; |
406 | char new_url[URL_SIZE]; |
423 | strcpy(#editURL, #URL); |
407 | strcpy(#new_url, history.current()); |
424 | while (i = strchr(#URL, ' ')) |
408 | while (i = strchr(#new_url, ' ')) |
425 | { |
409 | { |
426 | i -= #URL; |
410 | i -= #new_url; |
427 | strlcpy(#URL+i+3, #editURL+i+1, sizeof(URL)-i-4); |
411 | strlcpy(#new_url+i+3, #new_url+i+1, URL_SIZE); |
428 | URL[i] = '%'; |
412 | URL[i] = '%'; |
429 | URL[i+1] = '2'; |
413 | URL[i+1] = '2'; |
430 | URL[i+2] = '0'; |
414 | URL[i+2] = '0'; |
431 | } |
415 | } |
432 | strcpy(#editURL, #URL); |
416 | strcpy(#editURL, #new_url); |
Line -... | Line 417... | ||
- | 417 | } |
|
- | 418 | ||
- | 419 | //bool strrpl(dword dst, from, to, dst_len); !!!!!!!! |
|
- | 420 | ||
433 | } |
421 | */ |
434 | 422 | ||
435 | void OpenPage() |
423 | bool GetLocalFileData(dword _path) |
436 | { |
- | |
437 | char getUrl[sizeof(URL)]; |
424 | { |
438 | StopLoading(); |
425 | dword data, size; |
439 | strcpy(#editURL, #URL); |
426 | file_size stdcall (_path); |
440 | history.add(#URL); |
427 | if (!EBX) { |
441 | if (!strncmp(#URL,"WebView:",8)) |
428 | return false; |
442 | { |
429 | } else { |
443 | if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)); |
430 | size = EBX; |
444 | else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)); |
431 | data = malloc(size); |
445 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
432 | ReadFile(0, size, data, _path); |
446 | else {bufsize=0; ShowPage();} //page not found |
433 | LoadInternalPage(data, size); |
447 | DrawOmnibox(); |
434 | free(data); |
448 | return; |
- | |
449 | } |
- | |
450 | if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8)) |
- | |
451 | { |
- | |
452 | ReplaceSpaceInUrl(); |
- | |
453 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 68, SKIN_Y); |
- | |
454 | - | ||
455 | if (!strncmp(#URL,"http:",5)) { |
- | |
456 | http.get(#URL); |
- | |
457 | } else if (!strncmp(#URL,"https://",8)) { |
- | |
458 | sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL); |
435 | return true; |
Line 459... | Line 436... | ||
459 | http.get(#getUrl); |
436 | } |
460 | } |
437 | } |
- | 438 | ||
- | 439 | void OpenPage(dword _open_URL) |
|
461 | 440 | { |
|
- | 441 | char new_url[URL_SIZE+1]; |
|
- | 442 | ||
462 | if (!http.transfer) |
443 | StopLoading(); |
- | 444 | ||
463 | { |
445 | strcpy(#editURL, _open_URL); |
- | 446 | DrawOmnibox(); |
|
- | 447 | ||
- | 448 | strncpy(#new_url, _open_URL, URL_SIZE); |
|
- | 449 | ||
- | 450 | //Exclude # from the URL to the load page |
|
- | 451 | //We will bring it back when we get the buffer |
|
- | 452 | if (strrchr(#new_url, '#')) anchors.take_anchor_from(#new_url); |
|
- | 453 | ||
- | 454 | history.add(#new_url); |
|
- | 455 | ||
- | 456 | if (!strncmp(#new_url,"WebView:",8)) { |
|
- | 457 | //INTERNAL PAGE |
|
- | 458 | if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)); |
|
- | 459 | else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)); |
|
- | 460 | else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory(); |
|
- | 461 | else LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
|
- | 462 | } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { |
|
- | 463 | //WEB PAGE |
|
- | 464 | //ReplaceSpaceInUrl(); !!!!!!!! |
|
- | 465 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, |
|
464 | StopLoading(); |
466 | address_box.top-3, 17, skin.h, 85, SKIN_Y); |
- | 467 | ||
- | 468 | if (!strncmp(#new_url,"http:",5)) { |
|
- | 469 | http.get(#new_url); |
|
465 | bufsize = 0; |
470 | } else if (!strncmp(#new_url,"https://",8)) { |
466 | bufpointer = free(bufpointer); |
471 | strcpy(#new_url, "http://gate.aspero.pro/?site="); |
- | 472 | strncat(#new_url, _open_URL, URL_SIZE); |
|
- | 473 | http.get(#new_url); |
|
- | 474 | } |
|
467 | ShowPage(); |
475 | if (!http.transfer) { |
468 | return; |
- | |
469 | } |
- | |
470 | } |
- | |
471 | else |
- | |
472 | { |
- | |
473 | file_size stdcall (#URL); |
- | |
474 | if (EBX) { |
- | |
475 | bufsize = EBX; |
- | |
476 | free(bufpointer); |
476 | StopLoading(); |
- | 477 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
|
477 | bufpointer = malloc(bufsize); |
478 | } |
- | 479 | } else { |
|
478 | ReadFile(0, bufsize, bufpointer, #URL); |
480 | //LOCAL PAGE |
479 | } else { |
- | |
480 | bufsize = bufpointer = 0; |
481 | if (!GetLocalFileData(#new_url)) { |
481 | } |
482 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
Line 482... | Line 483... | ||
482 | ShowPage(); |
483 | } |
483 | } |
484 | } |
484 | } |
485 | } |
485 | - | ||
486 | void ProcessAnchor() |
- | |
487 | { |
- | |
488 | char anchor[256]; |
- | |
489 | dword anchor_pos; |
- | |
Line 490... | Line 486... | ||
490 | 486 | ||
491 | anchor_pos = strrchr(#URL, '#')-1; |
487 | void EventClickLink(dword _click_URL) |
492 | strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)-1); |
488 | { |
493 | URL[anchor_pos] = 0x00; |
489 | char new_url[URL_SIZE]; |
494 | - | ||
495 | if (URL[0] == NULL) { |
- | |
496 | //case when URL consists of anchor only |
- | |
497 | if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1); |
- | |
498 | strcpy(#URL, history.current()); |
490 | |
499 | } else { |
- | |
500 | GetAbsoluteURL(#URL); |
- | |
501 | OpenPage(); |
491 | if (ESBYTE[_click_URL]=='#') { |
502 | if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1); |
492 | if (anchors.get_pos_by_name(_click_URL+1)!=-1) { |
503 | } |
493 | WB1.list.first = anchors.get_pos_by_name(_click_URL+1); |
- | 494 | WB1.list.CheckDoesValuesOkey(); |
|
- | 495 | } |
|
504 | 496 | strcpy(#editURL, history.current()); |
|
Line 505... | Line -... | ||
505 | WB1.DrawPage(); |
- | |
506 | strcpy(#editURL, #URL); |
- | |
507 | strcat(#editURL, #anchor); |
- | |
508 | DrawOmnibox(); |
- | |
509 | } |
497 | strcat(#editURL, _click_URL); |
510 | - | ||
511 | void EventSubmitOmnibox() |
498 | DrawOmnibox(); |
512 | { |
- | |
513 | if (!editURL[0]) return; |
- | |
514 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
- | |
515 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) |
- | |
516 | { |
- | |
517 | strcpy(#URL, #editURL); |
- | |
518 | } |
- | |
519 | else |
- | |
520 | { |
- | |
521 | strlcpy(#URL,"http://",7); |
- | |
522 | strcat(#URL, #editURL); |
- | |
523 | } |
- | |
524 | OpenPage(); |
- | |
525 | } |
499 | WB1.DrawPage(); |
526 | 500 | return; |
|
Line 527... | Line -... | ||
527 | void EventClickLink() |
- | |
528 | { |
- | |
529 | strcpy(#URL, PageLinks.GetURL(PageLinks.active)); |
501 | } |
530 | GetAbsoluteURL(#URL); |
- | |
531 | ProcessLink(); |
502 | |
532 | } |
503 | if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) { |
533 | 504 | notify(_click_URL); |
|
Line 534... | Line 505... | ||
534 | void ProcessLink() |
505 | return; |
535 | { |
506 | } |
536 | if (http.transfer > 0) |
- | |
537 | { |
- | |
Line 538... | Line 507... | ||
538 | StopLoading(); |
507 | |
539 | history.back(); |
- | |
540 | } |
- | |
541 | 508 | if (http.transfer > 0) { |
|
542 | if (strrchr(#URL, '#')!=0) { |
509 | StopLoading(); |
543 | ProcessAnchor(); |
510 | history.back(); |
544 | return; |
511 | } |
Line 545... | Line 512... | ||
545 | } |
512 | |
546 | 513 | strcpy(#new_url, _click_URL); |
|
547 | if (!strncmp(#URL,"mailto:", 7)) || (!strncmp(#URL,"tel:", 4)) |
514 | GetAbsoluteURL(#new_url); |
548 | { |
515 | |
Line 549... | Line 516... | ||
549 | notify(#URL); |
516 | if (strrchr(#new_url, '#')!=0) { |
550 | strcpy(#editURL, history.current()); |
517 | anchors.take_anchor_from(#new_url); |
551 | strcpy(#URL, history.current()); |
518 | OpenPage(#new_url); |
552 | return; |
519 | return; |
553 | } |
520 | } |
554 | 521 | ||
555 | if (!strncmp(#URL,"WebView:",8)) { |
522 | if (!strncmp(#new_url,"WebView:",8)) { |
556 | OpenPage(); |
- | |
557 | return; |
523 | OpenPage(#new_url); |
558 | } |
524 | return; |
559 | 525 | } |
|
560 | if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0) |
- | |
561 | { |
- | |
562 | if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true) |
526 | |
563 | { |
527 | if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0) |
564 | if (strchr(#URL, '|')) { |
- | |
565 | ESBYTE[strchr(#URL, '|')] = NULL; |
528 | { |
566 | RunProgram(#URL, strlen(#URL)+1+#URL); |
- | |
567 | } |
529 | if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true) |
568 | else { |
530 | { |
569 | RunProgram("/sys/@open", #URL); |
531 | if (strchr(#new_url, '|')) { |
570 | } |
532 | ESBYTE[strchr(#new_url, '|')] = NULL; |
571 | strcpy(#editURL, history.current()); |
533 | RunProgram(#new_url, strlen(#new_url)+1+#new_url); |
572 | strcpy(#URL, history.current()); |
534 | } else { |
573 | return; |
- | |
574 | } |
- | |
575 | } |
535 | RunProgram("/sys/@open", #new_url); |
576 | else |
536 | } |
577 | { |
537 | return; |
578 | if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true) |
538 | } |
579 | || (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true) || (UrlExtIs(".pdf")==true) |
539 | } else { |
580 | || (UrlExtIs(".7z")==true) { |
540 | if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) |
581 | if (!downloader_opened) { |
- | |
582 | strcpy(#downloader_edit, #URL); |
- | |
583 | CreateThread(#Downloader,#downloader_stak+4092); |
- | |
584 | strcpy(#editURL, history.current()); |
- | |
585 | strcpy(#URL, history.current()); |
541 | || (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true) |
586 | } |
542 | || (UrlExtIs(#new_url,".7z")==true) { |
- | 543 | if (!downloader_opened) { |
|
587 | else notify("'WebView\nPlease, start a new download only when previous ended.'Et"); |
544 | strcpy(#downloader_edit, #new_url); |
- | 545 | CreateThread(#Downloader,#downloader_stak+4092); |
|
- | 546 | } |
|
- | 547 | else notify("'WebView\nPlease, start a new download only when previous ended.'Et"); |
|
- | 548 | return; |
|
588 | return; |
549 | } |
- | 550 | } |
|
- | 551 | OpenPage(#new_url); |
|
- | 552 | } |
|
- | 553 | ||
589 | } |
554 | void EventSubmitOmnibox() |
590 | } |
- | |
591 | if (open_in_a_new_window) |
555 | { |
Line 592... | Line 556... | ||
592 | { |
556 | char new_url[URL_SIZE+1]; |
593 | RunProgram(#program_path, #URL); |
557 | if (!editURL[0]) return; |
594 | strcpy(#editURL, history.current()); |
558 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
- | 559 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) { |
|
- | 560 | OpenPage(#editURL); |
|
- | 561 | } else { |
|
595 | strcpy(#URL, history.current()); |
562 | strcpy(#new_url, "http://"); |
596 | } |
563 | strncat(#new_url, #editURL, sizeof(new_url)-1); |
- | 564 | OpenPage(#new_url); |
|
597 | else |
565 | } |
598 | { |
566 | } |
599 | OpenPage(); |
567 | |
600 | } |
568 | void DrawOmnibox() |
601 | open_in_a_new_window = false; |
569 | { |
- | 570 | int skin_x_offset; |
|
602 | } |
571 | |
Line 603... | Line 572... | ||
603 | 572 | DrawRectangle(address_box.left-2, address_box.top-3, address_box.width+5, 25,border_color); |
|
- | 573 | ||
- | 574 | DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 1,0xD8DCD8); |
|
- | 575 | DrawBar(address_box.left-2, address_box.top-1, address_box.width+3, 1, address_box.color); |
|
- | 576 | img_draw stdcall(skin.image, address_box.left-2, address_box.top-3, 2, skin.h, 102, SKIN_Y); |
|
- | 577 | if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0; |
|
- | 578 | EditBox_UpdateText(#address_box, address_box.flags); |
|
- | 579 | edit_box_draw stdcall(#address_box); |
|
604 | void DrawOmnibox() |
580 | if (http.transfer > 0) skin_x_offset = 85; else skin_x_offset = 68; |
605 | { |
581 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, |
606 | int skin_x_offset; |
582 | address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
607 | DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
583 | } |
608 | DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
- | |
609 | if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0; |
- | |
610 | EditBox_UpdateText(#address_box, address_box.flags); |
- | |
611 | edit_box_draw stdcall(#address_box); |
- | |
612 | if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51; |
- | |
613 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
584 | |
614 | } |
585 | void LoadInternalPage(dword _bufdata, _in_bufsize){ |
615 | 586 | if (!_bufdata) || (!_in_bufsize) { |
|
616 | void LoadInternalPage(dword _bufpos, _in_filesize){ |
587 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
- | 588 | } else if (source_mode) { |
|
617 | bufsize = _in_filesize; |
589 | source_mode = false; |
618 | if (bufpointer!=_bufpos) free(bufpointer); |
590 | //WB1.ParseHtml(); |
619 | bufpointer = malloc(bufsize); |
- | |
620 | memmov(bufpointer, _bufpos, bufsize); |
- | |
621 | ShowPage(); |
591 | ShowSource(_bufdata, _in_bufsize); |
622 | } |
- | |
623 | 592 | } else { |
|
624 | void ShowPage() |
593 | bufsize = _in_bufsize; |
Line 625... | Line 594... | ||
625 | { |
594 | if (bufpointer!=_bufdata) free(bufpointer); |
626 | WB1.list.first = 0; //scroll page to the top |
595 | bufpointer = malloc(bufsize); |
627 | DrawOmnibox(); |
596 | memmov(bufpointer, _bufdata, bufsize); |
628 | if (!bufsize) || (!bufpointer) { |
597 | WB1.list.first = 0; //scroll page to the top |
629 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
598 | DrawOmnibox(); |
Line 630... | Line 599... | ||
630 | } |
599 | if(!strrchr(#editURL, '#')) { |
631 | WB1.ParseHtml(); |
600 | strcat(#editURL, #anchors.current); |
632 | if (source_mode) { |
601 | DrawOmnibox(); |
633 | source_mode = false; |
602 | } |
- | 603 | WB1.ParseHtml(); |
|
634 | ShowSource(); |
604 | WB1.DrawPage(); |
- | 605 | } |
|
- | 606 | } |
|
- | 607 | ||
635 | LoadInternalPage(bufpointer, bufsize); |
608 | byte UrlExtIs(dword base, ext) |
636 | } |
609 | { |
Line 637... | Line 610... | ||
637 | } |
610 | if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true; |
638 | 611 | return false; |
|
639 | byte UrlExtIs(dword ext) |
612 | } |
Line 670... | Line 643... | ||
670 | } |
643 | } |
671 | } |
644 | } |
Line 672... | Line 645... | ||
672 | 645 | ||
673 | void EventSeachWeb() |
646 | void EventSeachWeb() |
- | 647 | { |
|
- | 648 | char new_url[URL_SIZE+1]; |
|
674 | { |
649 | replace_char(#editURL, ' ', '_', URL_SIZE); |
675 | sprintf(#URL, "https://www.google.com/search?q=%s", #editURL); |
650 | strcpy(#new_url, "https://www.google.com/search?q="); |
676 | replace_char(#URL, ' ', '_', sizeof(URL)); |
651 | strncat(#new_url, #editURL, URL_SIZE); |
677 | ProcessLink(); |
652 | OpenPage(#new_url); |
Line 678... | Line 653... | ||
678 | } |
653 | } |
679 | 654 | ||
680 | void EventOpenDialog() |
655 | void EventOpenDialog() |
681 | { |
656 | { |
682 | OpenDialog_start stdcall (#o_dialog); |
657 | OpenDialog_start stdcall (#o_dialog); |
683 | if (o_dialog.status) { |
- | |
684 | strcpy(#URL, #openfile_path); |
658 | if (o_dialog.status) { |
685 | OpenPage(); |
659 | OpenPage(#openfile_path); |
Line 686... | Line 660... | ||
686 | } |
660 | } |
687 | } |
661 | } |
688 | 662 | ||
689 | void EventViewSource() |
663 | void EventViewSource() |
690 | { |
664 | { |
691 | char source_view_param[sizeof(URL)+4]; |
665 | char source_view_param[URL_SIZE+1]; |
692 | strcpy(#source_view_param, "-s "); |
666 | strcpy(#source_view_param, "-s "); |
Line 693... | Line 667... | ||
693 | strcat(#source_view_param, #URL); |
667 | strncat(#source_view_param, history.current(), URL_SIZE); |
694 | RunProgram(#program_path, #source_view_param); |
668 | RunProgram(#program_path, #source_view_param); |