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