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