Rev 8332 | Rev 8339 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8332 | Rev 8336 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | #include "..\lib\patterns\history.h" |
31 | #include "..\lib\patterns\history.h" |
32 | #include "..\lib\patterns\simple_open_dialog.h" |
32 | #include "..\lib\patterns\simple_open_dialog.h" |
33 | #include "..\lib\patterns\toolbar_button.h" |
33 | #include "..\lib\patterns\toolbar_button.h" |
34 | #include "..\lib\patterns\restart_process.h" |
34 | #include "..\lib\patterns\restart_process.h" |
Line -... | Line 35... | ||
- | 35 | ||
- | 36 | #include "const.h" |
|
- | 37 | #include "cache.h" |
|
- | 38 | #include "show_src.h" |
|
35 | 39 | ||
36 | //===================================================// |
40 | //===================================================// |
37 | // // |
41 | // // |
38 | // DATA // |
42 | // DATA // |
39 | // // |
43 | // // |
- | 44 | //===================================================// |
|
Line 40... | Line 45... | ||
40 | //===================================================// |
45 | char version[]="WebView 2.8 BETA"; |
41 | - | ||
42 | char version[]="WebView 2.8 ALPHA PREVIEW"; |
- | |
43 | - | ||
44 | #include "const.h" |
- | |
Line 45... | Line 46... | ||
45 | #include "cache.h" |
46 | |
46 | #include "show_src.h" |
47 | #define DEFAULT_URL URL_SERVICE_HOMEPAGE |
Line 47... | Line 48... | ||
47 | 48 | ||
Line 70... | Line 71... | ||
70 | 71 | ||
71 | progress_bar prbar; |
72 | progress_bar prbar; |
72 | char stak[4096]; |
73 | char stak[4096]; |
Line 73... | Line -... | ||
73 | proc_info Form; |
- | |
74 | - | ||
75 | int menu_id=NULL; |
74 | proc_info Form; |
Line -... | Line 75... | ||
- | 75 | ||
- | 76 | #include "tabs.h" |
|
- | 77 | ||
- | 78 | dword cur_img_url; |
|
- | 79 | dword shared_url; |
|
76 | 80 | dword http_get_type; |
|
77 | #include "tabs.h" |
81 | int menu_id=NULL; |
Line 78... | Line 82... | ||
78 | 82 | ||
79 | char default_dir[] = "/rd/1"; |
83 | char default_dir[] = "/rd/1"; |
80 | od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" }; |
84 | od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" }; |
Line 81... | Line -... | ||
81 | - | ||
82 | char editURL[URL_SIZE+1]; |
- | |
83 | edit_box omnibox_edit = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff, |
- | |
84 | 0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19}; |
- | |
85 | 85 | ||
86 | dword shared_url; |
86 | char editURL[URL_SIZE+1]; |
87 | 87 | edit_box omnibox_edit = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff, |
|
88 | dword http_get_type; |
88 | 0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19}; |
89 | 89 | ||
Line 106... | Line 106... | ||
106 | } |
106 | } |
Line 107... | Line 107... | ||
107 | 107 | ||
108 | void HandleParam() |
108 | void HandleParam() |
109 | { |
109 | { |
110 | if (!param) { |
110 | if (!param) { |
111 | history.add(URL_SERVICE_HOMEPAGE); |
111 | history.add(DEFAULT_URL); |
112 | } else { |
112 | } else { |
113 | if (!strncmp(#param, "-source ", 8)) { |
113 | if (!strncmp(#param, "-source ", 8)) { |
114 | source_mode = true; |
114 | source_mode = true; |
115 | history.add(#param + 8); |
115 | history.add(#param + 8); |
Line 201... | Line 201... | ||
201 | break; |
201 | break; |
Line 202... | Line 202... | ||
202 | 202 | ||
203 | case evNetwork: |
203 | case evNetwork: |
204 | if (http.transfer <= 0) break; |
204 | if (http.transfer <= 0) break; |
- | 205 | http.receive(); |
|
205 | http.receive(); |
206 | |
- | 207 | if (http_get_type==PAGE) { |
|
- | 208 | CheckContentType(); |
|
- | 209 | prbar.max = http.content_length; |
|
- | 210 | if (prbar.value != http.content_received) { |
|
206 | if (http_get_type==PAGE) CheckContentType(); |
211 | prbar.value = http.content_received; |
- | 212 | DrawProgress(); |
|
- | 213 | } |
|
- | 214 | } |
|
207 | EventUpdateProgressBar(); |
215 | |
208 | if (http.receive_result != 0) break; |
216 | if (http.receive_result != 0) break; |
209 | if (http.status_code >= 300) && (http.status_code < 400) |
217 | if (http.status_code >= 300) && (http.status_code < 400) |
210 | { |
218 | { |
211 | // Handle redirects |
219 | // Handle redirects |
Line 224... | Line 232... | ||
224 | if (http_get_type==PAGE) { |
232 | if (http_get_type==PAGE) { |
225 | cache.add(history.current(), http.content_pointer, http.content_received, PAGE); |
233 | cache.add(history.current(), http.content_pointer, http.content_received, PAGE); |
226 | LoadInternalPage(http.content_pointer, http.content_received); |
234 | LoadInternalPage(http.content_pointer, http.content_received); |
227 | } |
235 | } |
228 | else if (http_get_type==IMG) { |
236 | else if (http_get_type==IMG) { |
229 | cache.add(WB1.page_img.current_url(), http.content_pointer, http.content_received, IMG); |
237 | cache.add(cur_img_url, http.content_pointer, http.content_received, IMG); |
230 | WB1.page_img.set_size(WB1.page_img.getid, http.content_pointer, http.content_received); |
- | |
231 | GetImg(); |
238 | GetImg(false); |
232 | } |
239 | } |
233 | } |
240 | } |
234 | break; |
241 | break; |
235 | default: |
242 | default: |
236 | if (ESDWORD[shared_url] != '\0') { |
243 | if (ESDWORD[shared_url] != '\0') { |
Line 298... | Line 305... | ||
298 | case SCAN_CODE_ENTER: EventSeachWeb(); return true; |
305 | case SCAN_CODE_ENTER: EventSeachWeb(); return true; |
299 | case SCAN_CODE_LEFT: ProcessButtonClick(BACK_BUTTON); return true; |
306 | case SCAN_CODE_LEFT: ProcessButtonClick(BACK_BUTTON); return true; |
300 | case SCAN_CODE_RIGHT: ProcessButtonClick(FORWARD_BUTTON); return true; |
307 | case SCAN_CODE_RIGHT: ProcessButtonClick(FORWARD_BUTTON); return true; |
301 | case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true; |
308 | case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true; |
302 | case SCAN_CODE_TAB: EventActivateNextTab(); return true; |
309 | case SCAN_CODE_TAB: EventActivateNextTab(); return true; |
- | 310 | case SCAN_CODE_F5: EventClearCache(); return; |
|
303 | default: return false; |
311 | default: return false; |
304 | } |
312 | } |
Line 305... | Line 313... | ||
305 | 313 | ||
306 | switch(key_scancode) |
314 | switch(key_scancode) |
Line 491... | Line 499... | ||
491 | } |
499 | } |
492 | free(data); |
500 | free(data); |
493 | return true; |
501 | return true; |
494 | } |
502 | } |
Line 495... | Line 503... | ||
495 | 503 | ||
496 | void GetUrl(dword _http_url) |
504 | bool GetUrl(dword _http_url) |
497 | { |
505 | { |
Line 498... | Line 506... | ||
498 | char new_url_full[URL_SIZE+1]; |
506 | char new_url_full[URL_SIZE+1]; |
499 | 507 | ||
- | 508 | if (!strncmp(_http_url,"http:",5)) { |
|
500 | if (!strncmp(_http_url,"http:",5)) { |
509 | http.get(_http_url); |
501 | http.get(_http_url); |
510 | return true; |
502 | } else if (!strncmp(_http_url,"https://",8)) { |
511 | } else if (!strncmp(_http_url,"https://",8)) { |
503 | strcpy(#new_url_full, "http://gate.aspero.pro/?site="); |
512 | strcpy(#new_url_full, "http://gate.aspero.pro/?site="); |
- | 513 | strncat(#new_url_full, _http_url, URL_SIZE); |
|
504 | strncat(#new_url_full, _http_url, URL_SIZE); |
514 | http.get(#new_url_full); |
- | 515 | return true; |
|
505 | http.get(#new_url_full); |
516 | } |
Line 506... | Line 517... | ||
506 | } |
517 | return false; |
507 | } |
518 | } |
508 | 519 | ||
Line 535... | Line 546... | ||
535 | and then halndle it in the propper way. |
546 | and then halndle it in the propper way. |
536 | */ |
547 | */ |
Line 537... | Line 548... | ||
537 | 548 | ||
538 | if (cache.has(#new_url)) { |
549 | if (cache.has(#new_url)) { |
539 | //CACHED PAGE |
550 | //CACHED PAGE |
- | 551 | if (cache.current_type==PAGE) LoadInternalPage(cache.current_buf, cache.current_size); |
|
Line 540... | Line 552... | ||
540 | LoadInternalPage(cache.current_buf, cache.current_size); |
552 | else {EventOpenDownloader(#new_url);return;} |
541 | 553 | ||
542 | } else if (!strncmp(#new_url,"WebView:",8)) { |
554 | } else if (!strncmp(#new_url,"WebView:",8)) { |
543 | //INTERNAL PAGE |
555 | //INTERNAL PAGE |
Line 706... | Line 718... | ||
706 | WB1.custom_encoding = CH_CP866; |
718 | WB1.custom_encoding = CH_CP866; |
707 | ShowSource(WB1.bufpointer, _in_bufsize); |
719 | ShowSource(WB1.bufpointer, _in_bufsize); |
708 | } else { |
720 | } else { |
709 | WB1.DrawPage(); |
721 | WB1.DrawPage(); |
710 | } |
722 | } |
711 | GetImg(); |
723 | GetImg(true); |
712 | } |
724 | } |
713 | } |
725 | } |
Line 714... | Line 726... | ||
714 | 726 | ||
715 | bool UrlExtIs(dword base, ext) |
727 | bool UrlExtIs(dword base, ext) |
Line 721... | Line 733... | ||
721 | void DrawProgress() |
733 | void DrawProgress() |
722 | { |
734 | { |
723 | dword pct; |
735 | dword pct; |
724 | if (!http.transfer) return; |
736 | if (!http.transfer) return; |
725 | if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10; |
737 | if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10; |
726 | if (http_get_type==IMG) pct = WB1.page_img.getid * 70 / WB1.page_img.url.count + 30; |
738 | if (http_get_type==IMG) pct = prbar.value * 70 / prbar.max + 30; |
727 | DrawBar(omnibox_edit.left-1, omnibox_edit.top+20, pct*omnibox_edit.width+16/100, 2, 0x72B7EB); |
739 | DrawBar(omnibox_edit.left-1, omnibox_edit.top+20, pct*omnibox_edit.width+16/100, 2, 0x72B7EB); |
728 | } |
740 | } |
Line 729... | Line 741... | ||
729 | 741 | ||
730 | void EventShowPageMenu() |
742 | void EventShowPageMenu() |
Line 764... | Line 776... | ||
764 | } |
776 | } |
765 | if (!menu_process_id) menu_id = NULL; |
777 | if (!menu_process_id) menu_id = NULL; |
766 | } |
778 | } |
767 | } |
779 | } |
Line 768... | Line -... | ||
768 | - | ||
769 | void EventUpdateProgressBar() |
- | |
770 | { |
- | |
771 | prbar.max = http.content_length; |
- | |
772 | if (prbar.value != http.content_received) |
- | |
773 | { |
- | |
774 | prbar.value = http.content_received; |
- | |
775 | DrawProgress(); |
- | |
776 | } |
- | |
777 | } |
- | |
778 | 780 | ||
779 | void EventSeachWeb() |
781 | void EventSeachWeb() |
780 | { |
782 | { |
781 | char new_url[URL_SIZE+1]; |
783 | char new_url[URL_SIZE+1]; |
782 | replace_char(#editURL, ' ', '_', URL_SIZE); |
784 | replace_char(#editURL, ' ', '_', URL_SIZE); |
Line 888... | Line 890... | ||
888 | DrawProgress(); |
890 | DrawProgress(); |
889 | } |
891 | } |
Line 890... | Line 892... | ||
890 | 892 | ||
891 | void SetOmniboxText(dword _text) |
893 | void SetOmniboxText(dword _text) |
892 | { |
894 | { |
893 | strcpy(#editURL, _text); |
- | |
894 | omnibox_edit.flags=0; |
- | |
895 | DrawOmnibox(); |
895 | edit_box_set_text stdcall (#omnibox_edit, _text); |
Line 896... | Line 896... | ||
896 | } |
896 | } |
897 | 897 | ||
898 | dword GetAbsoluteActiveURL() |
898 | dword GetAbsoluteActiveURL() |
Line 927... | Line 927... | ||
927 | http.hfree(); |
927 | http.hfree(); |
928 | if (http_get_type==PAGE) OpenPage(#redirect_url); |
928 | if (http_get_type==PAGE) OpenPage(#redirect_url); |
929 | else if (http_get_type==IMG) GetUrl(#redirect_url); |
929 | else if (http_get_type==IMG) GetUrl(#redirect_url); |
930 | } |
930 | } |
Line 931... | Line 931... | ||
931 | 931 | ||
932 | dword GetImg() |
932 | dword GetImg(bool _new) |
- | 933 | { |
|
933 | { |
934 | int i; |
934 | if (!show_images) return; |
- | |
935 | while (WB1.page_img.next_url()) { |
- | |
936 | DrawProgress(); |
- | |
937 | if (cache.has(WB1.page_img.current_url())) continue; |
935 | if (!show_images) return; |
- | 936 | http_get_type = IMG; |
|
- | 937 | ||
- | 938 | for (i = 0; i < WB1.img.url.count; i++) |
|
938 | http_get_type = IMG; |
939 | { |
- | 940 | cur_img_url = WB1.img.url.get(i); |
|
- | 941 | if (cache.has(cur_img_url)==false) { |
|
- | 942 | prbar.max = WB1.img.url.count; |
|
- | 943 | prbar.value = i; |
|
939 | GetUrl(WB1.page_img.current_url()); |
944 | if (GetUrl(cur_img_url)) {DrawProgress(); return;} |
940 | return; |
945 | } |
- | 946 | } |
|
941 | } |
947 | if (_new) return; |
942 | DrawOmnibox(); |
948 | DrawOmnibox(); |
943 | WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize); |
949 | WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize); |
944 | WB1.DrawPage(); |
950 | WB1.DrawPage(); |