Rev 8365 | Rev 8396 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7739 | leency | 1 | //Copyright 2007-2020 by Veliant & Leency |
6978 | leency | 2 | //Asper, lev, Lrz, Barsuk, Nable, hidnplayr... |
3067 | leency | 3 | |
4085 | leency | 4 | #ifndef AUTOBUILD |
5 | #include "lang.h--" |
||
6 | #endif |
||
7 | |||
8332 | leency | 8 | //===================================================// |
9 | // // |
||
10 | // LIB // |
||
11 | // // |
||
12 | //===================================================// |
||
13 | |||
7771 | leency | 14 | #define MEMSIZE 1024 * 1000 |
5499 | leency | 15 | #include "..\lib\gui.h" |
4508 | leency | 16 | #include "..\lib\draw_buf.h" |
17 | #include "..\lib\list_box.h" |
||
18 | #include "..\lib\cursor.h" |
||
5978 | leency | 19 | #include "..\lib\collection.h" |
6795 | leency | 20 | #include "..\lib\random.h" |
7037 | leency | 21 | #include "..\lib\clipboard.h" |
5981 | leency | 22 | |
5499 | leency | 23 | #include "..\lib\obj\box_lib.h" |
7049 | leency | 24 | #include "..\lib\obj\libimg.h" |
5499 | leency | 25 | #include "..\lib\obj\http.h" |
5690 | leency | 26 | #include "..\lib\obj\iconv.h" |
7748 | leency | 27 | #include "..\lib\obj\proc_lib.h" |
8330 | leency | 28 | #include "..\lib\obj\netcode.h" |
7757 | leency | 29 | |
5978 | leency | 30 | #include "..\lib\patterns\history.h" |
7748 | leency | 31 | #include "..\lib\patterns\simple_open_dialog.h" |
7759 | leency | 32 | #include "..\lib\patterns\toolbar_button.h" |
7914 | leency | 33 | #include "..\lib\patterns\restart_process.h" |
5408 | leency | 34 | |
8336 | leency | 35 | #include "const.h" |
36 | #include "cache.h" |
||
37 | #include "show_src.h" |
||
38 | |||
8332 | leency | 39 | //===================================================// |
40 | // // |
||
41 | // DATA // |
||
42 | // // |
||
43 | //===================================================// |
||
8363 | leency | 44 | char version[]="WebView 2.8 BETA 5"; |
8278 | leency | 45 | |
8336 | leency | 46 | #define DEFAULT_URL URL_SERVICE_HOMEPAGE |
8016 | leency | 47 | |
7757 | leency | 48 | bool debug_mode = false; |
8330 | leency | 49 | bool show_images = false; |
7771 | leency | 50 | |
8016 | leency | 51 | _history history; |
52 | |||
7970 | leency | 53 | enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB }; |
54 | |||
8330 | leency | 55 | #include "TWB\TWB.c" //HTML Parser, a core component |
7757 | leency | 56 | |
7759 | leency | 57 | TWebBrowser WB1; |
7758 | leency | 58 | |
7771 | leency | 59 | #include "history.h" |
7752 | leency | 60 | |
7758 | leency | 61 | #define PADDING 9 |
62 | #define TSZE 25 |
||
7771 | leency | 63 | #define STATUSBAR_H 15 |
64 | #define TAB_H 20 |
||
7758 | leency | 65 | dword TOOLBAR_H = PADDING+TSZE+PADDING+2; |
4677 | leency | 66 | |
7759 | leency | 67 | _http http = 0; |
7758 | leency | 68 | |
7750 | leency | 69 | bool source_mode = false; |
7282 | leency | 70 | |
8330 | leency | 71 | progress_bar prbar; |
7750 | leency | 72 | char stak[4096]; |
73 | proc_info Form; |
||
7748 | leency | 74 | |
8336 | leency | 75 | #include "tabs.h" |
76 | |||
77 | dword cur_img_url; |
||
78 | dword shared_url; |
||
79 | dword http_get_type; |
||
8365 | leency | 80 | dword render_start_time; |
7780 | leency | 81 | int menu_id=NULL; |
82 | |||
7748 | leency | 83 | char default_dir[] = "/rd/1"; |
7788 | leency | 84 | od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" }; |
7748 | leency | 85 | |
7755 | leency | 86 | char editURL[URL_SIZE+1]; |
8332 | leency | 87 | edit_box omnibox_edit = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff, |
7758 | leency | 88 | 0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19}; |
4534 | leency | 89 | |
8332 | leency | 90 | //===================================================// |
91 | // // |
||
92 | // CODE // |
||
93 | // // |
||
94 | //===================================================// |
||
95 | |||
7748 | leency | 96 | void LoadLibraries() |
97 | { |
||
8330 | leency | 98 | load_dll(boxlib, #box_lib_init,0); |
99 | load_dll(libimg, #libimg_init,1); |
||
100 | load_dll(libHTTP, #http_lib_init,1); |
||
101 | load_dll(iconv_lib, #iconv_open,0); |
||
102 | load_dll(netcode_lib, #base64_encode,0); |
||
103 | load_dll(Proc_lib, #OpenDialog_init,0); |
||
7748 | leency | 104 | OpenDialog_init stdcall (#o_dialog); |
105 | } |
||
106 | |||
107 | void HandleParam() |
||
108 | { |
||
8278 | leency | 109 | if (!param) { |
8336 | leency | 110 | history.add(DEFAULT_URL); |
8278 | leency | 111 | } else { |
112 | if (!strncmp(#param, "-source ", 8)) { |
||
7750 | leency | 113 | source_mode = true; |
7765 | leency | 114 | history.add(#param + 8); |
7936 | leency | 115 | } else if (!strncmp(#param, "-new ", 5)) { |
116 | history.add(#param + 5); |
||
7748 | leency | 117 | } else { |
7914 | leency | 118 | if (GetProcessesCount("WEBVIEW") == 1) { |
119 | history.add(#param); |
||
120 | } else { |
||
121 | shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE); |
||
122 | strncpy(shared_url, #param, URL_SIZE); |
||
123 | ExitProcess(); |
||
124 | } |
||
7748 | leency | 125 | } |
126 | } |
||
7914 | leency | 127 | shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE); |
7920 | leency | 128 | ESDWORD[shared_url] = '\0'; |
7748 | leency | 129 | } |
130 | |||
3067 | leency | 131 | void main() |
132 | { |
||
8332 | leency | 133 | int redirect_count=0; |
7748 | leency | 134 | LoadLibraries(); |
135 | HandleParam(); |
||
6045 | leency | 136 | WB1.list.SetFont(8, 14, 10011000b); |
5779 | leency | 137 | WB1.list.no_selection = true; |
7759 | leency | 138 | WB1.custom_encoding = -1; |
8332 | leency | 139 | @SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
7914 | leency | 140 | loop() switch(@WaitEventTimeout(30)) |
6978 | leency | 141 | { |
142 | case evMouse: |
||
8332 | leency | 143 | edit_box_mouse stdcall (#omnibox_edit); |
6978 | leency | 144 | mouse.get(); |
7970 | leency | 145 | |
7282 | leency | 146 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
7970 | leency | 147 | |
6978 | leency | 148 | scrollbar_v_mouse (#scroll_wv); |
8330 | leency | 149 | if (scroll_wv.delta2) { |
6978 | leency | 150 | WB1.list.first = scroll_wv.position; |
151 | WB1.DrawPage(); |
||
3067 | leency | 152 | break; |
6978 | leency | 153 | } |
7970 | leency | 154 | |
155 | if (links.hover(WB1.list.y, WB1.list.first)) |
||
7758 | leency | 156 | { |
8330 | leency | 157 | if (mouse.key&MOUSE_MIDDLE) && (mouse.up) { |
7970 | leency | 158 | if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) { |
159 | EventClickLink(TARGET_NEW_WINDOW); |
||
160 | } else { |
||
161 | EventClickLink(TARGET_NEW_TAB); |
||
162 | } |
||
163 | } |
||
8330 | leency | 164 | if (mouse.key&MOUSE_LEFT) && (mouse.up) { |
7970 | leency | 165 | CursorPointer.Restore(); |
166 | EventClickLink(TARGET_SAME_TAB); |
||
167 | } |
||
8330 | leency | 168 | if (mouse.key&MOUSE_RIGHT) && (mouse.up) { |
7970 | leency | 169 | CursorPointer.Restore(); |
170 | EventShowLinkMenu(); |
||
171 | } |
||
172 | } else { |
||
173 | CursorPointer.Restore(); |
||
8330 | leency | 174 | if (mouse.key&MOUSE_RIGHT) && (mouse.up) && (WB1.list.MouseOver(mouse.x, mouse.y)) { |
7970 | leency | 175 | EventShowPageMenu(); |
176 | } |
||
7758 | leency | 177 | } |
6978 | leency | 178 | break; |
5711 | leency | 179 | |
6978 | leency | 180 | case evButton: |
8332 | leency | 181 | ProcessButtonClick( @GetButtonID() ); |
6978 | leency | 182 | break; |
5711 | leency | 183 | |
6978 | leency | 184 | case evKey: |
8332 | leency | 185 | @GetKeys(); |
186 | edit_box_key stdcall(#omnibox_edit); |
||
187 | ProcessKeyEvent(); |
||
6978 | leency | 188 | break; |
189 | |||
190 | case evReDraw: |
||
8332 | leency | 191 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), |
7755 | leency | 192 | GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); |
6978 | leency | 193 | GetProcessInfo(#Form, SelfInfo); |
7780 | leency | 194 | ProcessMenuClick(); |
7806 | leency | 195 | sc.get(); |
7759 | leency | 196 | if (Form.status_window>2) break; |
6978 | leency | 197 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
198 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
||
7748 | leency | 199 | draw_window(); |
6978 | leency | 200 | break; |
201 | |||
202 | case evNetwork: |
||
7758 | leency | 203 | if (http.transfer <= 0) break; |
204 | http.receive(); |
||
8336 | leency | 205 | |
206 | if (http_get_type==PAGE) { |
||
207 | CheckContentType(); |
||
208 | prbar.max = http.content_length; |
||
209 | if (prbar.value != http.content_received) { |
||
210 | prbar.value = http.content_received; |
||
211 | DrawProgress(); |
||
212 | } |
||
213 | } |
||
214 | |||
7758 | leency | 215 | if (http.receive_result != 0) break; |
216 | if (http.status_code >= 300) && (http.status_code < 400) |
||
217 | { |
||
218 | // Handle redirects |
||
219 | if (redirect_count<=5) { |
||
220 | redirect_count++; |
||
8305 | leency | 221 | HandleRedirect(); |
7758 | leency | 222 | } else { |
223 | notify("'Too many redirects.' -E"); |
||
224 | StopLoading(); |
||
7791 | leency | 225 | redirect_count = 0; |
4536 | leency | 226 | } |
7758 | leency | 227 | } else { |
228 | // Loading the page is complete, free resources |
||
229 | redirect_count = 0; |
||
8291 | leency | 230 | http.hfree(); |
8016 | leency | 231 | if (http_get_type==PAGE) { |
232 | cache.add(history.current(), http.content_pointer, http.content_received, PAGE); |
||
233 | LoadInternalPage(http.content_pointer, http.content_received); |
||
234 | } |
||
235 | else if (http_get_type==IMG) { |
||
8336 | leency | 236 | cache.add(cur_img_url, http.content_pointer, http.content_received, IMG); |
237 | GetImg(false); |
||
8016 | leency | 238 | } |
6978 | leency | 239 | } |
7914 | leency | 240 | break; |
241 | default: |
||
242 | if (ESDWORD[shared_url] != '\0') { |
||
243 | EventOpenNewTab(shared_url); |
||
244 | ESDWORD[shared_url] = '\0'; |
||
245 | ActivateWindow(GetProcessSlot(Form.ID)); |
||
246 | } |
||
6978 | leency | 247 | } |
3067 | leency | 248 | } |
249 | |||
8332 | leency | 250 | |
251 | //===================================================// |
||
252 | // // |
||
253 | // EVENTS // |
||
254 | // // |
||
255 | //===================================================// |
||
256 | |||
257 | void ProcessButtonClick(dword id__) |
||
7772 | leency | 258 | { |
8332 | leency | 259 | switch (id__) |
260 | { |
||
261 | case 1: ExitProcess(); |
||
262 | case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX: EventTabClose(id__ - TAB_CLOSE_ID); return; |
||
263 | case TAB_ID...TAB_ID+TABS_MAX: EventAllTabsClick(id__ - TAB_ID); return; |
||
264 | case ENCODINGS...ENCODINGS+6: EventChangeEncodingAndLoadPage(id__-ENCODINGS); return; |
||
265 | case NEW_WINDOW: RunProgram(#program_path, NULL); return; |
||
266 | case NEW_TAB: if (!http.transfer) EventOpenNewTab(URL_SERVICE_HOMEPAGE); return; |
||
267 | case SCAN_CODE_BS: |
||
268 | case BACK_BUTTON: if (history.back()) OpenPage(history.current()); return; |
||
269 | case FORWARD_BUTTON: if (history.forward()) OpenPage(history.current()); return; |
||
270 | case GOTOURL_BUTTON: EventSubmitOmnibox(); return; |
||
271 | case REFRESH_BUTTON: EventRefreshPage(); return; |
||
272 | case CHANGE_ENCODING: EventShowEncodingsList(); return; |
||
273 | case SANDWICH_BUTTON: EventShowMainMenu(); return; |
||
274 | case VIEW_SOURCE: EventViewSource(); return; |
||
275 | case EDIT_SOURCE: EventEditSource(); return; |
||
276 | case VIEW_HISTORY: OpenPage(URL_SERVICE_HISTORY); return; |
||
277 | case DOWNLOAD_MANAGER: EventOpenDownloader(""); return; |
||
278 | case UPDATE_BROWSER: EventUpdateBrowser(); return; |
||
279 | case CLEAR_CACHE: EventClearCache(); return; |
||
280 | case IN_NEW_TAB: EventClickLink(TARGET_NEW_TAB); return; |
||
281 | case IN_NEW_WINDOW: EventClickLink(TARGET_NEW_WINDOW); return; |
||
282 | case COPY_LINK_URL: EventCopyLinkToClipboard(); return; |
||
283 | case DOWNLOAD_LINK_CT: EventOpenDownloader( GetAbsoluteActiveURL() ); return; |
||
284 | case OPEN_FILE: EventOpenDialog(); return; |
||
285 | } |
||
286 | } |
||
287 | |||
288 | bool ProcessKeyEvent() |
||
289 | { |
||
290 | if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) |
||
291 | { |
||
292 | if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();return;} |
||
293 | } |
||
294 | |||
7772 | leency | 295 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode) |
296 | { |
||
8016 | leency | 297 | case SCAN_CODE_KEY_O: EventOpenDialog(); return true; |
8332 | leency | 298 | case SCAN_CODE_KEY_H: ProcessButtonClick(VIEW_HISTORY); return true; |
8016 | leency | 299 | case SCAN_CODE_KEY_U: EventViewSource(); return true; |
300 | case SCAN_CODE_KEY_T: EventOpenNewTab(URL_SERVICE_HOMEPAGE); return true; |
||
301 | case SCAN_CODE_KEY_N: RunProgram(#program_path, NULL); return true; |
||
8332 | leency | 302 | case SCAN_CODE_KEY_J: ProcessButtonClick(DOWNLOAD_MANAGER); return true; |
303 | case SCAN_CODE_KEY_R: ProcessButtonClick(REFRESH_BUTTON); return true; |
||
8016 | leency | 304 | case SCAN_CODE_ENTER: EventSeachWeb(); return true; |
8332 | leency | 305 | case SCAN_CODE_LEFT: ProcessButtonClick(BACK_BUTTON); return true; |
306 | case SCAN_CODE_RIGHT: ProcessButtonClick(FORWARD_BUTTON); return true; |
||
8016 | leency | 307 | case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true; |
308 | case SCAN_CODE_TAB: EventActivateNextTab(); return true; |
||
8336 | leency | 309 | case SCAN_CODE_F5: EventClearCache(); return; |
8016 | leency | 310 | default: return false; |
7772 | leency | 311 | } |
8332 | leency | 312 | |
313 | switch(key_scancode) |
||
314 | { |
||
315 | case SCAN_CODE_UP: EventScrollUpAndDown(SCAN_CODE_UP); return; |
||
316 | case SCAN_CODE_DOWN: EventScrollUpAndDown(SCAN_CODE_DOWN); return; |
||
317 | case SCAN_CODE_F6: {omnibox_edit.flags=ed_focus; DrawOmnibox();} return; |
||
318 | case SCAN_CODE_F5: EventRefreshPage(); return; |
||
319 | case SCAN_CODE_ENTER: if (omnibox_edit.flags & ed_focus) EventSubmitOmnibox(); return; |
||
320 | case SCAN_CODE_F12: EventToggleDebugMode(); return; |
||
321 | case SCAN_CODE_F11: show_images^=1; EventClearCache(); return; |
||
322 | default: if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); return; |
||
323 | } |
||
7772 | leency | 324 | } |
325 | |||
3067 | leency | 326 | void SetElementSizes() |
327 | { |
||
8332 | leency | 328 | omnibox_edit.width = Form.cwidth - omnibox_edit.left - 52 - 16; |
7771 | leency | 329 | WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x, |
330 | Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H); |
||
7759 | leency | 331 | WB1.list.wheel_size = 7 * BASIC_LINE_H; |
7746 | leency | 332 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
6794 | leency | 333 | WB1.list.visible = WB1.list.h; |
3067 | leency | 334 | } |
335 | |||
5981 | leency | 336 | |
7748 | leency | 337 | void draw_window() |
3067 | leency | 338 | { |
7910 | leency | 339 | bool burger_active = false; |
340 | if (menu_id == OPEN_FILE) burger_active = true; |
||
341 | |||
3067 | leency | 342 | SetElementSizes(); |
7758 | leency | 343 | |
7806 | leency | 344 | DrawBar(0,0, Form.cwidth,PADDING, sc.work); |
345 | DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work); |
||
346 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.work_dark, sc.work, 180)); |
||
347 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph); |
||
8332 | leency | 348 | DrawBar(0, PADDING, omnibox_edit.left-2, TSZE+1, sc.work); |
349 | DrawBar(omnibox_edit.left+omnibox_edit.width+18, PADDING, Form.cwidth-omnibox_edit.left-omnibox_edit.width-18, TSZE+1, sc.work); |
||
7758 | leency | 350 | |
7910 | leency | 351 | DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false); |
352 | DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false); |
||
353 | DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1, burger_active); //burger menu |
||
7758 | leency | 354 | |
7806 | leency | 355 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph); |
7758 | leency | 356 | |
357 | DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, |
||
358 | WB1.list.h-1, scroll_wv.bckg_col); |
||
359 | |||
7771 | leency | 360 | if (!BrowserWidthChanged()) { |
361 | WB1.DrawPage(); |
||
362 | DrawOmnibox(); |
||
363 | } |
||
364 | DrawProgress(); |
||
7970 | leency | 365 | DrawStatusBar(); |
7771 | leency | 366 | DrawTabsBar(); |
367 | } |
||
368 | |||
369 | bool BrowserWidthChanged() |
||
370 | { |
||
371 | dword source_mode_holder; |
||
372 | if (WB1.list.w!=DrawBuf.bufw) { |
||
373 | DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20); |
||
7758 | leency | 374 | if (!strncmp(history.current(),"http",4)) { |
7759 | leency | 375 | //nihuya ne izyashnoe reshenie, no pust' poka butet tak |
7771 | leency | 376 | source_mode_holder = source_mode; |
7758 | leency | 377 | LoadInternalPage(#loading_text, sizeof(loading_text)); |
7771 | leency | 378 | source_mode = source_mode_holder; |
7758 | leency | 379 | } |
380 | OpenPage(history.current()); |
||
7771 | leency | 381 | return true; |
7282 | leency | 382 | } |
7771 | leency | 383 | return false; |
3067 | leency | 384 | } |
385 | |||
7771 | leency | 386 | |
7759 | leency | 387 | void EventChangeEncodingAndLoadPage(int _new_encoding) |
388 | { |
||
389 | dword newbuf, newsize; |
||
390 | WB1.custom_encoding = _new_encoding; |
||
391 | newsize = strlen(WB1.o_bufpointer); |
||
392 | newbuf = malloc(newsize); |
||
393 | memmov(newbuf, WB1.o_bufpointer, newsize); |
||
394 | LoadInternalPage(newbuf, newsize); |
||
395 | free(newbuf); |
||
396 | } |
||
3067 | leency | 397 | |
7759 | leency | 398 | |
8332 | leency | 399 | void EventScrollUpAndDown(int _direction) |
4413 | leency | 400 | { |
8332 | leency | 401 | int i; |
402 | for (i=0;i |
||
403 | if (_direction == SCAN_CODE_UP) WB1.list.KeyUp(); |
||
404 | if (_direction == SCAN_CODE_DOWN) WB1.list.KeyDown(); |
||
405 | } |
||
406 | WB1.DrawPage(); |
||
4413 | leency | 407 | } |
408 | |||
8305 | leency | 409 | void EventToggleDebugMode() |
410 | { |
||
411 | debug_mode ^= 1; |
||
412 | if (debug_mode) notify("'Debug mode ON'-I"); |
||
413 | else notify("'Debug mode OFF'-I"); |
||
414 | } |
||
415 | |||
416 | void EventAllTabsClick(dword _n) |
||
417 | { |
||
418 | if (http.transfer) return; |
||
419 | if (mouse.mkm) { |
||
420 | EventTabClose(_n); |
||
421 | } else { |
||
422 | EventTabClick(_n); |
||
8355 | leency | 423 | } |
8305 | leency | 424 | } |
425 | |||
426 | void EventEditSource() |
||
427 | { |
||
428 | if (check_is_the_adress_local(history.current())) { |
||
8330 | leency | 429 | RunProgram("/rd/1/quark", history.current()); |
8305 | leency | 430 | } else { |
431 | CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm"); |
||
8330 | leency | 432 | if (!EAX) RunProgram("/rd/1/quark", "/tmp0/1/WebView_tmp.htm"); |
8305 | leency | 433 | } |
434 | } |
||
435 | |||
436 | void EventClearCache() |
||
437 | { |
||
438 | cache.clear(); |
||
439 | notify(#clear_cache_ok); |
||
440 | EventRefreshPage(); |
||
441 | } |
||
442 | |||
443 | void EventCopyLinkToClipboard() |
||
444 | { |
||
445 | Clipboard__CopyText(GetAbsoluteActiveURL()); |
||
446 | notify("'URL copied to clipboard'O"); |
||
447 | } |
||
448 | |||
4636 | leency | 449 | void StopLoading() |
450 | { |
||
8305 | leency | 451 | if (http.stop()) pause(10); |
8330 | leency | 452 | prbar.value = 0; |
4645 | leency | 453 | } |
454 | |||
7756 | leency | 455 | //rewrite into |
7757 | leency | 456 | //bool strrpl(dword dst, from, into, dst_len); |
457 | bool ReplaceSpaceInUrl(dword url, size) { |
||
7756 | leency | 458 | unsigned int i, j; |
7757 | leency | 459 | bool was_changed=false; |
460 | for (i=url+size-3; i>url; i--) |
||
7720 | leency | 461 | { |
7756 | leency | 462 | if (ESBYTE[i]!=' ') continue; |
7757 | leency | 463 | for (j=url+size-3; j>=i; j--) { |
464 | ESBYTE[j+3]=ESBYTE[j+2]; |
||
7756 | leency | 465 | ESBYTE[j+2]=ESBYTE[j+1]; |
466 | ESBYTE[j+1]=ESBYTE[j]; |
||
467 | } |
||
468 | ESBYTE[i] = '%'; |
||
469 | ESBYTE[i+1] = '2'; |
||
470 | ESBYTE[i+2] = '0'; |
||
7757 | leency | 471 | was_changed = true; |
7720 | leency | 472 | } |
7757 | leency | 473 | return was_changed; |
7720 | leency | 474 | } |
475 | |||
7801 | leency | 476 | bool HandleUrlFiles(dword _path, _data) |
477 | { |
||
478 | dword url_from_file; |
||
479 | if (!UrlExtIs(_path, "url")) return false; |
||
7945 | leency | 480 | if (! url_from_file = strstri(_data, "URL=")) return false; |
7801 | leency | 481 | replace_char(url_from_file, '\n', '\0', strlen(url_from_file)); |
7945 | leency | 482 | OpenPage(url_from_file); |
483 | return true; |
||
7801 | leency | 484 | } |
485 | |||
7755 | leency | 486 | bool GetLocalFileData(dword _path) |
4416 | leency | 487 | { |
7801 | leency | 488 | dword data, size; |
8392 | leency | 489 | read_file(_path, #data, #size); |
7801 | leency | 490 | if (!HandleUrlFiles(_path, data)) { |
491 | LoadInternalPage(data, size); |
||
4692 | leency | 492 | } |
7801 | leency | 493 | free(data); |
494 | return true; |
||
7755 | leency | 495 | } |
7282 | leency | 496 | |
8336 | leency | 497 | bool GetUrl(dword _http_url) |
8330 | leency | 498 | { |
499 | char new_url_full[URL_SIZE+1]; |
||
500 | |||
501 | if (!strncmp(_http_url,"http:",5)) { |
||
502 | http.get(_http_url); |
||
8336 | leency | 503 | return true; |
8330 | leency | 504 | } else if (!strncmp(_http_url,"https://",8)) { |
505 | strcpy(#new_url_full, "http://gate.aspero.pro/?site="); |
||
506 | strncat(#new_url_full, _http_url, URL_SIZE); |
||
507 | http.get(#new_url_full); |
||
8336 | leency | 508 | return true; |
8330 | leency | 509 | } |
8336 | leency | 510 | return false; |
8330 | leency | 511 | } |
512 | |||
7755 | leency | 513 | void OpenPage(dword _open_URL) |
514 | { |
||
515 | char new_url[URL_SIZE+1]; |
||
7788 | leency | 516 | int unz_id; |
7755 | leency | 517 | |
518 | StopLoading(); |
||
519 | |||
7771 | leency | 520 | SetOmniboxText(_open_URL); |
521 | |||
7755 | leency | 522 | strncpy(#new_url, _open_URL, URL_SIZE); |
523 | |||
524 | //Exclude # from the URL to the load page |
||
525 | //We will bring it back when we get the buffer |
||
7970 | leency | 526 | if (strrchr(#new_url, '#')) { |
527 | anchors.take_anchor_from(#new_url); |
||
528 | } |
||
7755 | leency | 529 | |
530 | history.add(#new_url); |
||
531 | |||
7976 | leency | 532 | /* |
533 | There could be several possible types of addresses: |
||
534 | - cached page (only http/https) |
||
535 | - internal page |
||
536 | - web page |
||
537 | - local file |
||
538 | So we need to detect what incoming address is |
||
539 | and then halndle it in the propper way. |
||
540 | */ |
||
541 | |||
8016 | leency | 542 | if (cache.has(#new_url)) { |
7764 | leency | 543 | //CACHED PAGE |
8336 | leency | 544 | if (cache.current_type==PAGE) LoadInternalPage(cache.current_buf, cache.current_size); |
545 | else {EventOpenDownloader(#new_url);return;} |
||
7764 | leency | 546 | |
547 | } else if (!strncmp(#new_url,"WebView:",8)) { |
||
7755 | leency | 548 | //INTERNAL PAGE |
8278 | leency | 549 | if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home)); |
550 | else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buildin_page_help, sizeof(buildin_page_help)); |
||
7976 | leency | 551 | else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory(); |
8278 | leency | 552 | else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); |
7800 | leency | 553 | |
7755 | leency | 554 | } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { |
555 | //WEB PAGE |
||
7757 | leency | 556 | if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) { |
557 | strcpy(#editURL, #new_url); |
||
558 | } |
||
559 | |||
8016 | leency | 560 | http_get_type = PAGE; |
8330 | leency | 561 | GetUrl(#new_url); |
7758 | leency | 562 | |
563 | DrawOmnibox(); |
||
564 | |||
7755 | leency | 565 | if (!http.transfer) { |
4646 | leency | 566 | StopLoading(); |
8278 | leency | 567 | LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); |
4646 | leency | 568 | } |
7755 | leency | 569 | } else { |
570 | //LOCAL PAGE |
||
7788 | leency | 571 | if (UrlExtIs(#new_url,".docx")) { |
572 | DeleteFile("/tmp0/1/temp/word/document.xml"); |
||
573 | CreateDir("/tmp0/1/temp"); |
||
574 | unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url)); |
||
575 | while (GetProcessSlot(unz_id)) pause(2); |
||
576 | strcpy(#new_url, "/tmp0/1/temp/word/document.xml"); |
||
577 | } |
||
7755 | leency | 578 | if (!GetLocalFileData(#new_url)) { |
8278 | leency | 579 | LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); |
4650 | leency | 580 | } |
4636 | leency | 581 | } |
4416 | leency | 582 | } |
4415 | leency | 583 | |
8278 | leency | 584 | dword EventOpenDownloader(dword _url) |
585 | { |
||
586 | //char download_params[URL_SIZE+50]; |
||
587 | return RunProgram("/sys/network/dl", _url); |
||
588 | } |
||
7970 | leency | 589 | |
590 | bool EventClickAnchor() |
||
4508 | leency | 591 | { |
7970 | leency | 592 | dword aURL = links.active_url; |
593 | |||
594 | if (anchors.get_pos_by_name(aURL+1)!=-1) { |
||
595 | WB1.list.first = anchors.get_pos_by_name(aURL+1); |
||
596 | //WB1.list.CheckDoesValuesOkey(); |
||
597 | strcpy(#editURL, history.current()); |
||
598 | strcat(#editURL, aURL); |
||
599 | DrawOmnibox(); |
||
600 | WB1.DrawPage(); |
||
601 | return true; |
||
602 | } |
||
603 | return false; |
||
604 | } |
||
605 | |||
606 | void EventClickLink(dword _target) |
||
607 | { |
||
7756 | leency | 608 | char new_url[URL_SIZE+1]; |
7936 | leency | 609 | char new_url_full[URL_SIZE+1]; |
7970 | leency | 610 | dword aURL = GetAbsoluteActiveURL(); |
611 | if (!aURL) return; |
||
4415 | leency | 612 | |
7970 | leency | 613 | strcpy(#new_url, aURL); |
614 | |||
615 | if (ESBYTE[aURL]=='#') { |
||
616 | if (_target == TARGET_SAME_TAB) { |
||
617 | EventClickAnchor(); |
||
618 | return; |
||
619 | } else { |
||
620 | strcpy(#new_url, history.current()); |
||
621 | strcat(#new_url, aURL); |
||
622 | } |
||
623 | } |
||
624 | |||
625 | if (_target == TARGET_NEW_TAB) { |
||
626 | EventOpenNewTab(#new_url); |
||
7758 | leency | 627 | return; |
628 | } |
||
629 | |||
7970 | leency | 630 | if (_target == TARGET_NEW_WINDOW) { |
631 | strcpy(#new_url_full, "-new "); |
||
632 | strncat(#new_url_full, #new_url, URL_SIZE); |
||
633 | RunProgram(#program_path, #new_url_full); |
||
7755 | leency | 634 | return; |
5768 | leency | 635 | } |
7742 | leency | 636 | |
7970 | leency | 637 | if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) { |
638 | notify(#new_url); |
||
7755 | leency | 639 | return; |
7742 | leency | 640 | } |
4508 | leency | 641 | |
7771 | leency | 642 | if (http.transfer) { |
5774 | leency | 643 | StopLoading(); |
6021 | leency | 644 | history.back(); |
5774 | leency | 645 | } |
6730 | leency | 646 | |
7755 | leency | 647 | if (strrchr(#new_url, '#')!=0) { |
648 | anchors.take_anchor_from(#new_url); |
||
649 | OpenPage(#new_url); |
||
6730 | leency | 650 | return; |
651 | } |
||
652 | |||
7755 | leency | 653 | if (!strncmp(#new_url,"WebView:",8)) { |
654 | OpenPage(#new_url); |
||
7742 | leency | 655 | return; |
656 | } |
||
6730 | leency | 657 | |
7755 | leency | 658 | if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0) |
5774 | leency | 659 | { |
7755 | leency | 660 | if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true) |
6730 | leency | 661 | { |
7755 | leency | 662 | if (strchr(#new_url, '|')) { |
663 | ESBYTE[strchr(#new_url, '|')] = NULL; |
||
664 | RunProgram(#new_url, strlen(#new_url)+1+#new_url); |
||
665 | } else { |
||
666 | RunProgram("/sys/@open", #new_url); |
||
7422 | leency | 667 | } |
6730 | leency | 668 | return; |
669 | } |
||
5774 | leency | 670 | } |
7755 | leency | 671 | OpenPage(#new_url); |
672 | } |
||
673 | |||
674 | void EventSubmitOmnibox() |
||
675 | { |
||
676 | char new_url[URL_SIZE+1]; |
||
677 | if (!editURL[0]) return; |
||
678 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
||
679 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) { |
||
680 | OpenPage(#editURL); |
||
681 | } else { |
||
682 | strcpy(#new_url, "http://"); |
||
7970 | leency | 683 | strncat(#new_url, #editURL, URL_SIZE-1); |
7755 | leency | 684 | OpenPage(#new_url); |
6931 | leency | 685 | } |
5774 | leency | 686 | } |
687 | |||
7755 | leency | 688 | void LoadInternalPage(dword _bufdata, _in_bufsize){ |
689 | if (!_bufdata) || (!_in_bufsize) { |
||
8278 | leency | 690 | LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); |
7755 | leency | 691 | } else { |
692 | WB1.list.first = 0; //scroll page to the top |
||
693 | DrawOmnibox(); |
||
694 | if(!strrchr(#editURL, '#')) { |
||
695 | strcat(#editURL, #anchors.current); |
||
696 | DrawOmnibox(); |
||
697 | } |
||
8365 | leency | 698 | render_start_time = GetStartTime(); |
7759 | leency | 699 | WB1.ParseHtml(_bufdata, _in_bufsize); |
8302 | leency | 700 | // REJECTED. Reason: infinite redirect at Google Results. |
701 | /* |
||
702 | if (WB1.redirect) { // |
||
703 | get_absolute_url(#WB1.redirect, history.current()); |
||
704 | history.back(); |
||
705 | OpenPage(#WB1.redirect); |
||
706 | } |
||
707 | */ |
||
7970 | leency | 708 | DrawStatusBar(); |
7771 | leency | 709 | DrawActiveTab(); |
7756 | leency | 710 | if (source_mode) { |
711 | source_mode = false; |
||
7799 | leency | 712 | WB1.custom_encoding = CH_CP866; |
7759 | leency | 713 | ShowSource(WB1.bufpointer, _in_bufsize); |
7757 | leency | 714 | } else { |
8016 | leency | 715 | WB1.DrawPage(); |
7756 | leency | 716 | } |
8336 | leency | 717 | GetImg(true); |
7742 | leency | 718 | } |
719 | } |
||
720 | |||
7799 | leency | 721 | bool UrlExtIs(dword base, ext) |
7742 | leency | 722 | { |
7755 | leency | 723 | if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true; |
7742 | leency | 724 | return false; |
725 | } |
||
726 | |||
727 | void DrawProgress() |
||
728 | { |
||
8330 | leency | 729 | dword pct; |
730 | if (!http.transfer) return; |
||
731 | if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10; |
||
8336 | leency | 732 | if (http_get_type==IMG) pct = prbar.value * 70 / prbar.max + 30; |
8332 | leency | 733 | DrawBar(omnibox_edit.left-1, omnibox_edit.top+20, pct*omnibox_edit.width+16/100, 2, 0x72B7EB); |
7742 | leency | 734 | } |
735 | |||
7770 | leency | 736 | void EventShowPageMenu() |
6782 | leency | 737 | { |
8020 | leency | 738 | open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu); |
7780 | leency | 739 | menu_id = VIEW_SOURCE; |
6782 | leency | 740 | } |
741 | |||
7770 | leency | 742 | void EventShowLinkMenu() |
7759 | leency | 743 | { |
8020 | leency | 744 | open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #link_menu); |
7789 | simsanutiy | 745 | menu_id = IN_NEW_TAB; |
7759 | leency | 746 | } |
747 | |||
7780 | leency | 748 | void EventShowMainMenu() |
749 | { |
||
8020 | leency | 750 | open_lmenu(Form.cwidth - PADDING -4, PADDING + TSZE + 3, |
751 | MENU_TOP_RIGHT, NULL, #main_menu); |
||
7780 | leency | 752 | menu_id = OPEN_FILE; |
753 | } |
||
754 | |||
7770 | leency | 755 | void EventShowEncodingsList() |
7758 | leency | 756 | { |
8020 | leency | 757 | open_lmenu(Form.cwidth-4, Form.cheight - STATUSBAR_H + 12, |
758 | MENU_BOT_RIGHT, WB1.cur_encoding + 1, |
||
759 | "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); |
||
7780 | leency | 760 | menu_id = ENCODINGS; |
7758 | leency | 761 | } |
762 | |||
7780 | leency | 763 | void ProcessMenuClick() |
6795 | leency | 764 | { |
7780 | leency | 765 | int click_id; |
7910 | leency | 766 | if (menu_id) { |
767 | if (click_id = get_menu_click()) { |
||
768 | click_id += menu_id - 1; |
||
8332 | leency | 769 | ProcessButtonClick(click_id); |
7910 | leency | 770 | } |
771 | if (!menu_process_id) menu_id = NULL; |
||
7780 | leency | 772 | } |
6795 | leency | 773 | } |
774 | |||
7743 | leency | 775 | void EventSeachWeb() |
776 | { |
||
7755 | leency | 777 | char new_url[URL_SIZE+1]; |
778 | replace_char(#editURL, ' ', '_', URL_SIZE); |
||
779 | strcpy(#new_url, "https://www.google.com/search?q="); |
||
780 | strncat(#new_url, #editURL, URL_SIZE); |
||
781 | OpenPage(#new_url); |
||
7743 | leency | 782 | } |
783 | |||
7748 | leency | 784 | void EventOpenDialog() |
785 | { |
||
786 | OpenDialog_start stdcall (#o_dialog); |
||
787 | if (o_dialog.status) { |
||
7755 | leency | 788 | OpenPage(#openfile_path); |
7748 | leency | 789 | } |
790 | } |
||
791 | |||
7750 | leency | 792 | void EventViewSource() |
793 | { |
||
7771 | leency | 794 | source_mode = true; |
795 | EventOpenNewTab(history.current()); |
||
7750 | leency | 796 | } |
797 | |||
7893 | leency | 798 | void EventRefreshPage() |
799 | { |
||
800 | if (http.transfer) { |
||
801 | StopLoading(); |
||
802 | draw_window(); |
||
803 | } else { |
||
804 | OpenPage(history.current()); |
||
805 | } |
||
806 | } |
||
807 | |||
7765 | leency | 808 | void EventUpdateBrowser() |
809 | { |
||
810 | dword downloader_id, slot_n; |
||
811 | dword current_size; |
||
812 | dword new_size; |
||
813 | |||
814 | draw_window(); |
||
815 | |||
8278 | leency | 816 | downloader_id = EventOpenDownloader(#update_param); |
7765 | leency | 817 | do { |
818 | slot_n = GetProcessSlot(downloader_id); |
||
819 | pause(10); |
||
820 | } while (slot_n!=0); |
||
821 | |||
8392 | leency | 822 | current_size = get_file_size(#program_path); |
823 | new_size = get_file_size("/tmp0/1/Downloads/WebView.com"); |
||
7765 | leency | 824 | |
825 | if (!new_size) || (new_size<5000) { |
||
826 | notify(#update_download_error); |
||
827 | return; |
||
828 | } |
||
829 | |||
830 | if (current_size == new_size) { |
||
831 | notify(#update_is_current); |
||
832 | return; |
||
833 | } |
||
834 | |||
8332 | leency | 835 | if (CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) { |
7765 | leency | 836 | notify(#update_can_not_copy); |
837 | } else { |
||
838 | notify(#update_ok); |
||
839 | RunProgram(#program_path, history.current()); |
||
840 | ExitProcess(); |
||
841 | } |
||
842 | } |
||
843 | |||
7970 | leency | 844 | void DrawStatusBar() |
6795 | leency | 845 | { |
7970 | leency | 846 | dword status_y = Form.cheight - STATUSBAR_H + 4; |
847 | dword status_w = Form.cwidth - 90; |
||
7806 | leency | 848 | DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work); |
7970 | leency | 849 | if (links.active_url) { |
850 | ESI = math.min(status_w/6, strlen(links.active_url)); |
||
851 | WriteText(10, status_y, 0, sc.work_text, links.active_url); |
||
7758 | leency | 852 | } |
8016 | leency | 853 | if (http.transfer>0) && (http_get_type==IMG) { |
854 | // |
||
855 | } |
||
7970 | leency | 856 | DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING); |
857 | WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets); |
||
7758 | leency | 858 | } |
859 | |||
860 | void DrawOmnibox() |
||
861 | { |
||
7784 | leency | 862 | int imgxoff; |
7758 | leency | 863 | |
8332 | leency | 864 | DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.work_graph, |
7806 | leency | 865 | sc.work_graph, sc.work_graph, sc.work_dark); |
8332 | leency | 866 | DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8); |
867 | DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+18, 1, omnibox_edit.color); |
||
868 | DrawBar(omnibox_edit.left-1, omnibox_edit.top, 1, 22, omnibox_edit.color); |
||
7758 | leency | 869 | |
8332 | leency | 870 | if (omnibox_edit.flags & ed_focus) omnibox_edit.flags = ed_focus; else omnibox_edit.flags = 0; |
871 | EditBox_UpdateText(#omnibox_edit, omnibox_edit.flags); |
||
872 | edit_box_draw stdcall(#omnibox_edit); |
||
7784 | leency | 873 | if (http.transfer) imgxoff = 16*23*3; else imgxoff = 0; |
8332 | leency | 874 | _PutImage(omnibox_edit.left+omnibox_edit.width+1, omnibox_edit.top-1, 16, 23, imgxoff + #editbox_icons); |
875 | DefineHiddenButton(omnibox_edit.left+omnibox_edit.width-1, omnibox_edit.top-2, 17, 23, REFRESH_BUTTON); |
||
7758 | leency | 876 | |
877 | DrawProgress(); |
||
878 | } |
||
879 | |||
7771 | leency | 880 | void SetOmniboxText(dword _text) |
881 | { |
||
8336 | leency | 882 | edit_box_set_text stdcall (#omnibox_edit, _text); |
8355 | leency | 883 | omnibox_edit.pos = omnibox_edit.flags = 0; |
884 | DrawOmnibox(); |
||
7771 | leency | 885 | } |
7758 | leency | 886 | |
7970 | leency | 887 | dword GetAbsoluteActiveURL() |
888 | { |
||
889 | char abs_url[URL_SIZE]; |
||
890 | if (links.active_url) { |
||
891 | strncpy(#abs_url, links.active_url, URL_SIZE); |
||
8291 | leency | 892 | get_absolute_url(#abs_url, history.current()); |
7970 | leency | 893 | return #abs_url; |
894 | } |
||
895 | return 0; |
||
896 | } |
||
7771 | leency | 897 | |
8305 | leency | 898 | void CheckContentType() |
899 | { |
||
900 | char content_type[64]; |
||
8319 | leency | 901 | if (http.header_field("content-type", #content_type, sizeof(content_type))) // application || image |
8305 | leency | 902 | if (content_type[0] == 'a') || (content_type[0] == 'i') { |
903 | EventOpenDownloader(history.current()); |
||
904 | StopLoading(); |
||
905 | history.back(); |
||
906 | EventRefreshPage(); |
||
907 | } |
||
908 | } |
||
909 | |||
910 | void HandleRedirect() |
||
911 | { |
||
912 | char redirect_url[URL_SIZE]; |
||
8319 | leency | 913 | http.header_field("location", #redirect_url, URL_SIZE); |
8305 | leency | 914 | get_absolute_url(#redirect_url, history.current()); |
8330 | leency | 915 | if (http_get_type==PAGE) history.back(); |
8305 | leency | 916 | http.hfree(); |
917 | if (http_get_type==PAGE) OpenPage(#redirect_url); |
||
8330 | leency | 918 | else if (http_get_type==IMG) GetUrl(#redirect_url); |
8305 | leency | 919 | } |
920 | |||
8336 | leency | 921 | dword GetImg(bool _new) |
8016 | leency | 922 | { |
8336 | leency | 923 | int i; |
8330 | leency | 924 | if (!show_images) return; |
8336 | leency | 925 | http_get_type = IMG; |
926 | |||
927 | for (i = 0; i < WB1.img.url.count; i++) |
||
928 | { |
||
929 | cur_img_url = WB1.img.url.get(i); |
||
930 | if (cache.has(cur_img_url)==false) { |
||
931 | prbar.max = WB1.img.url.count; |
||
932 | prbar.value = i; |
||
933 | if (GetUrl(cur_img_url)) {DrawProgress(); return;} |
||
934 | } |
||
8016 | leency | 935 | } |
8336 | leency | 936 | if (_new) return; |
8016 | leency | 937 | DrawOmnibox(); |
8330 | leency | 938 | WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize); |
8016 | leency | 939 | WB1.DrawPage(); |
8365 | leency | 940 | debugln(sprintf(#param, "WebView: page rendered in %i sec", GetStartTime()-render_start_time/100)); |
8016 | leency | 941 | } |
942 | |||
5631 | pavelyakov | 943 | stop:>5000)>=5)>>=>280)>120)> |