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