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