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