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