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