Rev 5749 | Rev 5768 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5749 | Rev 5766 | ||
---|---|---|---|
1 | //HTML Viewer in C-- |
1 | //HTML Viewer in C-- |
2 | //Copyright 2007-2013 by Veliant & Leency |
2 | //Copyright 2007-2013 by Veliant & Leency |
3 | //Asper, lev, Lrz, Barsuk, Nable... |
3 | //Asper, lev, Lrz, Barsuk, Nable... |
4 | //home icon - rachel fu, GPL licence |
4 | //home icon - rachel fu, GPL licence |
5 | 5 | ||
6 | #ifndef AUTOBUILD |
6 | #ifndef AUTOBUILD |
7 | #include "lang.h--" |
7 | #include "lang.h--" |
8 | #endif |
8 | #endif |
9 | 9 | ||
10 | //libraries |
10 | //libraries |
11 | #define MEMSIZE 0x100000 |
11 | #define MEMSIZE 0x100000 |
12 | #include "..\lib\strings.h" |
12 | #include "..\lib\strings.h" |
13 | #include "..\lib\gui.h" |
13 | #include "..\lib\gui.h" |
14 | #include "..\lib\file_system.h" |
14 | #include "..\lib\file_system.h" |
15 | #include "..\lib\mem.h" |
15 | #include "..\lib\mem.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 | 19 | ||
20 | //*.obj libraries |
20 | //*.obj libraries |
21 | #include "..\lib\obj\box_lib.h" |
21 | #include "..\lib\obj\box_lib.h" |
22 | #include "..\lib\obj\libio_lib.h" |
22 | #include "..\lib\obj\libio_lib.h" |
23 | #include "..\lib\obj\libimg_lib.h" |
23 | #include "..\lib\obj\libimg_lib.h" |
24 | #include "..\lib\obj\http.h" |
24 | #include "..\lib\obj\http.h" |
25 | #include "..\lib\obj\iconv.h" |
25 | #include "..\lib\obj\iconv.h" |
26 | 26 | ||
27 | //useful patterns |
27 | //useful patterns |
28 | #include "..\lib\patterns\libimg_load_skin.h" |
28 | #include "..\lib\patterns\libimg_load_skin.h" |
29 | 29 | ||
30 | char homepage[] = FROM "html\\homepage.htm"; |
30 | char homepage[] = FROM "html\\homepage.htm"; |
31 | 31 | ||
32 | #ifdef LANG_RUS |
32 | #ifdef LANG_RUS |
33 | char version[]=" ¥ªáâ®¢ë© ¡à 㧥à 1.23"; |
33 | char version[]=" ¥ªáâ®¢ë© ¡à 㧥à 1.3 UNSTABLE"; |
34 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
34 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
35 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
35 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
36 | char loading[] = " £à㧪 áâà ¨æë... |
36 | char loading[] = " £à㧪 áâà ¨æë... |
37 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
37 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
38 | char accept_language[]= "Accept-Language: ru\n"; |
38 | char accept_language[]= "Accept-Language: ru\n"; |
39 | #else |
39 | #else |
40 | char version[]=" Text-based Browser 1.23"; |
40 | char version[]=" Text-based Browser 1.3 UNSTABLE"; |
41 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
41 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
42 | ?define T_LAST_SLIDE "This slide is the last" |
42 | ?define T_LAST_SLIDE "This slide is the last" |
43 | char loading[] = "Loading... |
43 | char loading[] = "Loading... |
44 | char page_not_found[] = FROM "html\page_not_found_en.htm"; |
44 | char page_not_found[] = FROM "html\page_not_found_en.htm"; |
45 | char accept_language[]= "Accept-Language: en\n"; |
45 | char accept_language[]= "Accept-Language: en\n"; |
46 | #endif |
46 | #endif |
47 | 47 | ||
48 | 48 | ||
49 | 49 | ||
50 | proc_info Form; |
50 | proc_info Form; |
51 | #define WIN_W 799 |
51 | #define WIN_W 799 |
52 | #define WIN_H 559 |
52 | #define WIN_H 559 |
53 | 53 | ||
54 | char search_path[]="http://nigma.ru/index.php?s="; |
54 | char search_path[]="http://nigma.ru/index.php?s="; |
55 | char str_location[]="location\0"; |
55 | char str_location[]="location\0"; |
56 | int redirected = 0; |
56 | int redirected = 0; |
57 | 57 | ||
58 | char stak[4096]; |
58 | char stak[4096]; |
59 | 59 | ||
60 | int action_buf; |
60 | int action_buf; |
61 | 61 | ||
62 | dword http_transfer = 0; |
62 | dword http_transfer = 0; |
63 | dword http_buffer; |
63 | dword http_buffer; |
64 | 64 | ||
65 | dword TAB_H = false; //19; |
65 | dword TAB_H = false; //19; |
66 | dword TAB_W = 150; |
66 | dword TAB_W = 150; |
67 | dword TOOLBAR_H = 31; //50; |
67 | dword TOOLBAR_H = 31; //50; |
68 | dword STATUSBAR_H = 15; |
68 | dword STATUSBAR_H = 15; |
69 | dword col_bg; |
69 | dword col_bg; |
70 | dword panel_color; |
70 | dword panel_color; |
71 | dword border_color; |
71 | dword border_color; |
72 | 72 | ||
73 | progress_bar wv_progress_bar; |
73 | progress_bar wv_progress_bar; |
74 | byte souce_mode = false; |
74 | byte souce_mode = false; |
75 | 75 | ||
76 | enum { |
76 | enum { |
77 | BACK_BUTTON=1000, |
77 | BACK_BUTTON=1000, |
78 | FORWARD_BUTTON, |
78 | FORWARD_BUTTON, |
79 | REFRESH_BUTTON, |
79 | REFRESH_BUTTON, |
80 | GOTOURL_BUTTON, |
80 | GOTOURL_BUTTON, |
81 | SEARCHWEB_BUTTON, |
81 | SEARCHWEB_BUTTON, |
82 | SANDWICH_BUTTON |
82 | SANDWICH_BUTTON |
83 | }; |
83 | }; |
84 | 84 | ||
85 | enum { |
85 | enum { |
86 | ZOOM2x=1100, |
86 | ZOOM2x=1100, |
87 | VIEW_SOURCE, |
87 | VIEW_SOURCE, |
88 | EDIT_SOURCE, |
88 | EDIT_SOURCE, |
89 | VIEW_HISTORY, |
89 | VIEW_HISTORY, |
90 | FREE_IMG_CACHE, |
90 | FREE_IMG_CACHE, |
91 | DOWNLOAD_MANAGER |
91 | DOWNLOAD_MANAGER |
92 | }; |
92 | }; |
93 | 93 | ||
94 | #include "..\TWB\TWB.c" |
94 | #include "..\TWB\TWB.c" |
95 | #include "menu_rmb.h" |
95 | #include "menu_rmb.h" |
96 | #include "history.h" |
96 | #include "history.h" |
97 | #include "show_src.h" |
97 | #include "show_src.h" |
98 | #include "network_get.h" |
98 | #include "network_get.h" |
99 | #include "downloader.h" |
99 | #include "downloader.h" |
100 | 100 | ||
101 | char editURL[sizeof(URL)]; |
101 | char editURL[sizeof(URL)]; |
102 | int mouse_twb; |
102 | int mouse_twb; |
103 | edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
103 | edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
104 | 104 | ||
105 | #define URL_SERVICE_HISTORY "WebView://history" |
105 | #define URL_SERVICE_HISTORY "WebView://history" |
106 | #define URL_SERVICE_HOME "WebView://home" |
106 | #define URL_SERVICE_HOME "WebView://home" |
107 | #define URL_SERVICE_SOURCE "WebView://source:" |
107 | #define URL_SERVICE_SOURCE "WebView://source:" |
108 | 108 | ||
109 | 109 | ||
110 | libimg_image skin; |
110 | libimg_image skin; |
111 | 111 | ||
112 | int SetSkinColors() |
112 | int SetSkinColors() |
113 | { |
113 | { |
114 | dword image_data; |
114 | dword image_data; |
115 | image_data = DSDWORD[skin.image+24]; |
115 | image_data = DSDWORD[skin.image+24]; |
116 | col_bg = DSDWORD[image_data]; |
116 | col_bg = DSDWORD[image_data]; |
117 | panel_color = DSDWORD[skin.w*4*4 + image_data]; |
117 | panel_color = DSDWORD[skin.w*4*4 + image_data]; |
118 | border_color = DSDWORD[skin.w*4*7 + image_data]; |
118 | border_color = DSDWORD[skin.w*4*7 + image_data]; |
119 | wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data]; |
119 | wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data]; |
120 | $and col_bg, 0x00ffffff |
120 | $and col_bg, 0x00ffffff |
121 | $and panel_color, 0x00ffffff |
121 | $and panel_color, 0x00ffffff |
122 | $and border_color, 0x00ffffff |
122 | $and border_color, 0x00ffffff |
123 | $and wv_progress_bar.progress_color, 0x00ffffff |
123 | $and wv_progress_bar.progress_color, 0x00ffffff |
124 | } |
124 | } |
125 | 125 | ||
126 | void DrawProgress() |
126 | void DrawProgress() |
127 | { |
127 | { |
128 | unsigned long btn; |
128 | unsigned long btn; |
129 | if (http_transfer == 0) return; |
129 | if (http_transfer == 0) return; |
130 | if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30; |
130 | if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30; |
131 | DrawBar(address_box.left-1, address_box.top+15, btn, 2, wv_progress_bar.progress_color); |
131 | DrawBar(address_box.left-1, address_box.top+15, btn, 2, wv_progress_bar.progress_color); |
132 | } |
132 | } |
133 | 133 | ||
134 | 134 | ||
135 | void main() |
135 | void main() |
136 | { |
136 | { |
137 | dword btn; |
137 | dword btn; |
138 | int half_scroll_size; |
138 | int half_scroll_size; |
139 | int scroll_used=0, show_menu; |
139 | int scroll_used=0, show_menu; |
140 | 140 | ||
141 | CursorPointer.Load(#CursorFile); |
141 | CursorPointer.Load(#CursorFile); |
142 | load_dll(boxlib, #box_lib_init,0); |
142 | load_dll(boxlib, #box_lib_init,0); |
143 | load_dll(libio, #libio_init,1); |
143 | load_dll(libio, #libio_init,1); |
144 | load_dll(libimg, #libimg_init,1); |
144 | load_dll(libimg, #libimg_init,1); |
145 | load_dll(libHTTP, #http_lib_init,1); |
145 | load_dll(libHTTP, #http_lib_init,1); |
146 | load_dll(iconv_lib, #iconv_open,0); |
146 | load_dll(iconv_lib, #iconv_open,0); |
147 | //load_dll(kmenu, #akmenu_init,0); |
147 | //load_dll(kmenu, #akmenu_init,0); |
148 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
148 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
149 | SetSkinColors(); |
149 | SetSkinColors(); |
150 | 150 | ||
151 | WB1.DrawBuf.zoom = 1; |
151 | WB1.DrawBuf.zoom = 1; |
152 | WB1.list.SetFont(8, 14, 10111000b); |
152 | WB1.list.SetFont(8, 14, 10111000b); |
153 | Form.width=WIN_W; |
153 | Form.width=WIN_W; |
154 | Form.height=WIN_H; |
154 | Form.height=WIN_H; |
155 | SetElementSizes(); |
155 | SetElementSizes(); |
156 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
156 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
157 | OpenPage(); |
157 | OpenPage(); |
158 | 158 | ||
159 | CreateDir("/tmp0/1/downloads"); |
159 | CreateDir("/tmp0/1/downloads"); |
160 | 160 | ||
161 | SetEventMask(0xa7); |
161 | SetEventMask(0xa7); |
162 | BEGIN_LOOP_APPLICATION: |
162 | BEGIN_LOOP_APPLICATION: |
163 | WaitEventTimeout(2); |
163 | WaitEventTimeout(2); |
164 | switch(EAX & 0xFF) |
164 | switch(EAX & 0xFF) |
165 | { |
165 | { |
166 | CASE evMouse: |
166 | CASE evMouse: |
167 | if (!CheckActiveProcess(Form.ID)) break; |
167 | if (!CheckActiveProcess(Form.ID)) break; |
168 | //Edit URL |
168 | //Edit URL |
169 | edit_box_mouse stdcall (#address_box); |
169 | edit_box_mouse stdcall (#address_box); |
170 | mouse.get(); |
170 | mouse.get(); |
171 | //Links hover |
171 | //Links hover |
172 | if (mouse.y>WB1.list.y) PageLinks.Hover(mouse.x, mouse.y, link_color_inactive, link_color_active, bg_color); |
172 | if (mouse.y>WB1.list.y) PageLinks.Hover(mouse.x, mouse.y, link_color_inactive, link_color_active, bg_color); |
173 | //Menu |
173 | //Menu |
174 | if (mouse.y>WB1.list.y) && (mouse.y |
174 | if (mouse.y>WB1.list.y) && (mouse.y |
175 | { |
175 | { |
176 | if (mouse.pkm) && (mouse.up) |
176 | if (mouse.pkm) && (mouse.up) |
177 | { |
177 | { |
178 | CreateThread(#menu_rmb,#stak+4092); |
178 | CreateThread(#menu_rmb,#stak+4092); |
179 | break; |
179 | break; |
180 | } |
180 | } |
181 | } |
181 | } |
182 | //Mouse scroll |
182 | //Mouse scroll |
183 | if (mouse.vert) |
183 | if (mouse.vert) |
184 | { |
184 | { |
185 | if (WB1.list.MouseScroll(mouse.vert)) WB1.Parse(); |
185 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
186 | } |
186 | } |
187 | //Drag scroller |
187 | //Drag scroller |
188 | scroll_wv.all_redraw = 0; |
188 | scroll_wv.all_redraw = 0; |
189 | if (!mouse.lkm) scroll_used=0; |
189 | if (!mouse.lkm) scroll_used=0; |
190 | if (mouse.x>=scroll_wv.start_x) && (mouse.x<=scroll_wv.start_x+scroll_wv.size_x) |
190 | if (mouse.x>=scroll_wv.start_x) && (mouse.x<=scroll_wv.start_x+scroll_wv.size_x) |
191 | && (mouse.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>mouse.y) |
191 | && (mouse.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>mouse.y) |
192 | && (WB1.list.count>WB1.list.visible) && (mouse.lkm) |
192 | && (WB1.list.count>WB1.list.visible) && (mouse.lkm) |
193 | { |
193 | { |
194 | scroll_used=1; |
194 | scroll_used=1; |
195 | } |
195 | } |
196 | if (scroll_used) |
196 | if (scroll_used) |
197 | { |
197 | { |
198 | mouse.y = mouse.y + 5; |
198 | mouse.y = mouse.y + 5; |
199 | half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2; |
199 | half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2; |
200 | if (half_scroll_size+WB1.list.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=half_scroll_size+WB1.list.y; |
200 | if (half_scroll_size+WB1.list.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=half_scroll_size+WB1.list.y; |
201 | btn=WB1.list.first; |
201 | btn=WB1.list.first; |
202 | WB1.list.first = mouse.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h; |
202 | WB1.list.first = mouse.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h; |
203 | if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible; |
203 | if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible; |
204 | if (btn!=WB1.list.first) WB1.Parse(); |
204 | if (btn!=WB1.list.first) WB1.DrawPage(); |
205 | } |
205 | } |
206 | break; |
206 | break; |
207 | 207 | ||
208 | case evButton: |
208 | case evButton: |
209 | btn=GetButtonID(); |
209 | btn=GetButtonID(); |
210 | if (btn==1) ExitProcess(); |
210 | if (btn==1) ExitProcess(); |
211 | Scan(btn); |
211 | Scan(btn); |
212 | break; |
212 | break; |
213 | 213 | ||
214 | case evKey: |
214 | case evKey: |
215 | GetKeys(); |
215 | GetKeys(); |
216 | if (address_box.flags & 0b10) |
216 | if (address_box.flags & 0b10) |
217 | { |
217 | { |
218 | if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else |
218 | if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else |
219 | if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);} |
219 | if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);} |
220 | } |
220 | } |
221 | else |
221 | else |
222 | { |
222 | { |
223 | Scan(key_scancode); |
223 | Scan(key_scancode); |
224 | } |
224 | } |
225 | break; |
225 | break; |
226 | 226 | ||
227 | case evReDraw: |
227 | case evReDraw: |
228 | if (action_buf) Scan(action_buf); |
228 | if (action_buf) Scan(action_buf); |
229 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0); |
229 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0); |
230 | GetProcessInfo(#Form, SelfInfo); |
230 | GetProcessInfo(#Form, SelfInfo); |
231 | if (Form.status_window>2) { DrawTitle(#header); break; } |
231 | if (Form.status_window>2) { DrawTitle(#header); break; } |
232 | if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
232 | if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
233 | if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
233 | if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
234 | Draw_Window(); |
234 | Draw_Window(); |
235 | break; |
235 | break; |
236 | 236 | ||
237 | case evNetwork: |
237 | case evNetwork: |
238 | if (http_transfer > 0) { |
238 | if (http_transfer > 0) { |
239 | http_receive stdcall (http_transfer); |
239 | http_receive stdcall (http_transfer); |
240 | $push EAX |
240 | $push EAX |
241 | ESI = http_transfer; |
241 | ESI = http_transfer; |
242 | wv_progress_bar.max = ESI.http_msg.content_length; |
242 | wv_progress_bar.max = ESI.http_msg.content_length; |
243 | if (wv_progress_bar.value != ESI.http_msg.content_received) |
243 | if (wv_progress_bar.value != ESI.http_msg.content_received) |
244 | { |
244 | { |
245 | wv_progress_bar.value = ESI.http_msg.content_received; |
245 | wv_progress_bar.value = ESI.http_msg.content_received; |
246 | DrawProgress(); |
246 | DrawProgress(); |
247 | } |
247 | } |
248 | $pop EAX |
248 | $pop EAX |
249 | if (EAX == 0) { |
249 | if (EAX == 0) { |
250 | ESI = http_transfer; |
250 | ESI = http_transfer; |
251 | // Handle redirects |
251 | // Handle redirects |
252 | if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) |
252 | if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) |
253 | { |
253 | { |
254 | redirected++; |
254 | redirected++; |
255 | if (redirected<=5) |
255 | if (redirected<=5) |
256 | { |
256 | { |
257 | http_find_header_field stdcall (http_transfer, #str_location); |
257 | http_find_header_field stdcall (http_transfer, #str_location); |
258 | if (EAX!=0) { |
258 | if (EAX!=0) { |
259 | ESI = EAX; |
259 | ESI = EAX; |
260 | EDI = #URL; |
260 | EDI = #URL; |
261 | do { |
261 | do { |
262 | $lodsb; |
262 | $lodsb; |
263 | $stosb; |
263 | $stosb; |
264 | } while (AL != 0) && (AL != 13) && (AL != 10)); |
264 | } while (AL != 0) && (AL != 13) && (AL != 10)); |
265 | DSBYTE[EDI-1]='\0'; |
265 | DSBYTE[EDI-1]='\0'; |
266 | } |
266 | } |
267 | } |
267 | } |
268 | else |
268 | else |
269 | { |
269 | { |
270 | //TODO: display error (too many redirects) |
270 | //TODO: display error (too many redirects) |
271 | } |
271 | } |
272 | } |
272 | } |
273 | else |
273 | else |
274 | { |
274 | { |
275 | redirected = 0; |
275 | redirected = 0; |
276 | } |
276 | } |
277 | // Loading the page is complete, free resources |
277 | // Loading the page is complete, free resources |
278 | if (redirected>0) |
278 | if (redirected>0) |
279 | { |
279 | { |
280 | http_free stdcall (http_transfer); |
280 | http_free stdcall (http_transfer); |
281 | http_transfer=0; |
281 | http_transfer=0; |
282 | PageLinks.GetAbsoluteURL(#URL); |
282 | PageLinks.GetAbsoluteURL(#URL); |
283 | BrowserHistory.current--; |
283 | BrowserHistory.current--; |
284 | strcpy(#editURL, #URL); |
284 | strcpy(#editURL, #URL); |
285 | DrawEditBox(); |
285 | DrawEditBox(); |
286 | OpenPage(); |
286 | OpenPage(); |
287 | } |
287 | } |
288 | else |
288 | else |
289 | { |
289 | { |
290 | BrowserHistory.AddUrl(); |
290 | BrowserHistory.AddUrl(); |
291 | ESI = http_transfer; |
291 | ESI = http_transfer; |
292 | bufpointer = ESI.http_msg.content_ptr; |
292 | bufpointer = ESI.http_msg.content_ptr; |
293 | bufsize = ESI.http_msg.content_received; |
293 | bufsize = ESI.http_msg.content_received; |
294 | http_free stdcall (http_transfer); |
294 | http_free stdcall (http_transfer); |
295 | http_transfer=0; |
295 | http_transfer=0; |
296 | SetPageDefaults(); |
296 | SetPageDefaults(); |
297 | Draw_Window(); // stop button => refresh button |
297 | Draw_Window(); // stop button => refresh button |
298 | } |
298 | } |
299 | } |
299 | } |
300 | } |
300 | } |
301 | } |
301 | } |
302 | goto BEGIN_LOOP_APPLICATION; |
302 | goto BEGIN_LOOP_APPLICATION; |
303 | } |
303 | } |
304 | 304 | ||
305 | void SetElementSizes() |
305 | void SetElementSizes() |
306 | { |
306 | { |
307 | address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H; |
307 | address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H; |
308 | address_box.width = Form.cwidth - address_box.left - 25 - 22; |
308 | address_box.width = Form.cwidth - address_box.left - 25 - 22; |
309 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, |
309 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, |
310 | Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom); |
310 | Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom); |
311 | WB1.list.wheel_size = 7; |
311 | WB1.list.wheel_size = 7; |
312 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
312 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
313 | WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h; |
313 | WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h; |
314 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h); |
314 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 20); |
315 | } |
315 | } |
316 | 316 | ||
317 | void Draw_Window() |
317 | void Draw_Window() |
318 | { |
318 | { |
319 | int img_off; |
319 | int img_off; |
320 | // tab { |
320 | // tab { |
321 | /* |
321 | /* |
322 | if (TAB_H) |
322 | if (TAB_H) |
323 | { |
323 | { |
324 | DrawBar(0, 0, TAB_W, TAB_H+1, panel_color); |
324 | DrawBar(0, 0, TAB_W, TAB_H+1, panel_color); |
325 | WriteText(5, 7, 0x80, 0xfdfdFd, "Index.htm"); |
325 | WriteText(5, 7, 0x80, 0xfdfdFd, "Index.htm"); |
326 | WriteText(4, 6, 0x80, 0, "Index.htm"); |
326 | WriteText(4, 6, 0x80, 0, "Index.htm"); |
327 | DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg); |
327 | DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg); |
328 | DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color); |
328 | DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color); |
329 | img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0); |
329 | img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0); |
330 | } |
330 | } |
331 | else */ DrawBar(0,0, Form.cwidth,1, col_bg); |
331 | else */ DrawBar(0,0, Form.cwidth,1, col_bg); |
332 | // } |
332 | // } |
333 | DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color); |
333 | DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color); |
334 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
334 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
335 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
335 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
336 | SetElementSizes(); |
336 | SetElementSizes(); |
337 | DrawRectangle(address_box.left-2, address_box.top-3, address_box.width+4, 20,border_color); |
337 | DrawRectangle(address_box.left-2, address_box.top-3, address_box.width+4, 20,border_color); |
338 | DrawRectangle(address_box.left-1, address_box.top-2, address_box.width+2, 18,address_box.color); |
338 | DrawRectangle(address_box.left-1, address_box.top-2, address_box.width+2, 18,address_box.color); |
339 | DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
339 | DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
340 | // < / > |
340 | // < / > |
341 | DefineButton(address_box.left-49, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0); |
341 | DefineButton(address_box.left-49, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0); |
342 | DefineButton(address_box.left-25, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); |
342 | DefineButton(address_box.left-25, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); |
343 | img_draw stdcall(skin.image, address_box.left-50, address_box.top-3, 48, skin.h, 3, 0); |
343 | img_draw stdcall(skin.image, address_box.left-50, address_box.top-3, 48, skin.h, 3, 0); |
344 | // refresh_BUTTON |
344 | // refresh_BUTTON |
345 | DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); |
345 | DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); |
346 | if (http_transfer > 0) img_off = 131; else img_off = 52; |
346 | if (http_transfer > 0) img_off = 131; else img_off = 52; |
347 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, img_off, 0); |
347 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, img_off, 0); |
348 | // config |
348 | // config |
349 | DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); |
349 | DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); |
350 | img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0); |
350 | img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0); |
351 | //status bar |
351 | //status bar |
352 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
352 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
353 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
353 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
354 | ShowPage(); |
354 | ShowPage(); |
355 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
355 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
356 | DrawProgress(); |
356 | DrawProgress(); |
357 | } |
357 | } |
358 | 358 | ||
359 | 359 | ||
360 | void Scan(dword id__) |
360 | void Scan(dword id__) |
361 | { |
361 | { |
362 | action_buf=0; |
362 | action_buf=0; |
363 | if (id__ >= 400) && (id__ < 1000) |
363 | if (id__ >= 400) && (id__ < 1000) |
364 | { |
364 | { |
365 | ProcessLinks(id__); |
365 | ProcessLinks(id__); |
366 | return; |
366 | return; |
367 | } |
367 | } |
368 | switch (id__) |
368 | switch (id__) |
369 | { |
369 | { |
370 | case SCAN_CODE_BS: |
370 | case SCAN_CODE_BS: |
371 | case BACK_BUTTON: |
371 | case BACK_BUTTON: |
372 | if (!BrowserHistory.GoBack()) return; |
372 | if (!BrowserHistory.GoBack()) return; |
373 | OpenPage(); |
373 | OpenPage(); |
374 | return; |
374 | return; |
375 | 375 | ||
376 | case FORWARD_BUTTON: |
376 | case FORWARD_BUTTON: |
377 | if (!BrowserHistory.GoForward()) return; |
377 | if (!BrowserHistory.GoForward()) return; |
378 | OpenPage(); |
378 | OpenPage(); |
379 | return; |
379 | return; |
380 | 380 | ||
381 | case SCAN_CODE_HOME: |
381 | case SCAN_CODE_HOME: |
382 | case SCAN_CODE_END: |
382 | case SCAN_CODE_END: |
383 | case SCAN_CODE_PGUP: |
383 | case SCAN_CODE_PGUP: |
384 | case SCAN_CODE_PGDN: |
384 | case SCAN_CODE_PGDN: |
385 | if (WB1.list.ProcessKey(key_scancode)) WB1.Parse(); |
385 | if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
386 | return; |
386 | return; |
387 | 387 | ||
388 | case SCAN_CODE_UP: |
388 | case SCAN_CODE_UP: |
389 | if (WB1.list.first <= 0) return; |
389 | if (WB1.list.first <= 0) return; |
390 | WB1.list.first--; |
390 | WB1.list.first--; |
391 | WB1.Parse(); |
391 | WB1.DrawPage(); |
392 | return; |
392 | return; |
393 | 393 | ||
394 | case SCAN_CODE_DOWN: |
394 | case SCAN_CODE_DOWN: |
395 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
395 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
396 | WB1.list.first++; |
396 | WB1.list.first++; |
397 | WB1.Parse(); |
397 | WB1.DrawPage(); |
398 | return; |
398 | return; |
399 | 399 | ||
400 | case GOTOURL_BUTTON: |
400 | case GOTOURL_BUTTON: |
401 | case SCAN_CODE_ENTER: //enter |
401 | case SCAN_CODE_ENTER: //enter |
402 | if (!editURL[0]) return; |
402 | if (!editURL[0]) return; |
403 | if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7); |
403 | if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7); |
404 | else |
404 | else |
405 | URL[0] = 0; |
405 | URL[0] = 0; |
406 | strcat(#URL, #editURL); |
406 | strcat(#URL, #editURL); |
407 | OpenPage(); |
407 | OpenPage(); |
408 | return; |
408 | return; |
409 | 409 | ||
410 | case 063: //F5 |
410 | case 063: //F5 |
411 | IF(address_box.flags & 0b10) return; |
411 | IF(address_box.flags & 0b10) return; |
412 | case REFRESH_BUTTON: |
412 | case REFRESH_BUTTON: |
413 | if (http_transfer > 0) |
413 | if (http_transfer > 0) |
414 | { |
414 | { |
415 | StopLoading(); |
415 | StopLoading(); |
416 | Draw_Window(); |
416 | Draw_Window(); |
417 | } |
417 | } |
418 | else OpenPage(); |
418 | else OpenPage(); |
419 | return; |
419 | return; |
420 | 420 | ||
421 | case SANDWICH_BUTTON: |
421 | case SANDWICH_BUTTON: |
422 | mouse.y = TOOLBAR_H-6; |
422 | mouse.y = TOOLBAR_H-6; |
423 | mouse.x = Form.cwidth - 167; |
423 | mouse.x = Form.cwidth - 167; |
424 | CreateThread(#menu_rmb,#stak+4092); |
424 | CreateThread(#menu_rmb,#stak+4092); |
425 | return; |
425 | return; |
426 | 426 | ||
427 | case ZOOM2x: |
427 | case ZOOM2x: |
428 | if (WB1.DrawBuf.zoom==2) |
428 | if (WB1.DrawBuf.zoom==2) |
429 | { |
429 | { |
430 | WB1.DrawBuf.zoom=1; |
430 | WB1.DrawBuf.zoom=1; |
431 | WB1.list.SetFont(8, 14, 10111000b); |
431 | WB1.list.SetFont(8, 14, 10111000b); |
432 | } |
432 | } |
433 | else |
433 | else |
434 | { |
434 | { |
435 | WB1.DrawBuf.zoom=2; |
435 | WB1.DrawBuf.zoom=2; |
436 | WB1.list.SetFont(8, 14, 10111001b); |
436 | WB1.list.SetFont(8, 14, 10111001b); |
437 | } |
437 | } |
438 | Draw_Window(); |
438 | Draw_Window(); |
439 | return; |
439 | return; |
440 | 440 | ||
441 | case VIEW_SOURCE: |
441 | case VIEW_SOURCE: |
442 | WB1.list.first = 0; |
442 | WB1.list.first = 0; |
443 | ShowSource(); |
443 | ShowSource(); |
444 | WB1.Parse(); |
444 | WB1.DrawPage(); |
445 | break; |
445 | break; |
446 | 446 | ||
447 | case EDIT_SOURCE: |
447 | case EDIT_SOURCE: |
448 | if (!strncmp(#URL,"http:",5)) |
448 | if (!strncmp(#URL,"http:",5)) |
449 | { |
449 | { |
450 | WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
450 | WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
451 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
451 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
452 | } |
452 | } |
453 | else RunProgram("/rd/1/tinypad", #URL); |
453 | else RunProgram("/rd/1/tinypad", #URL); |
454 | return; |
454 | return; |
455 | 455 | ||
456 | case FREE_IMG_CACHE: |
456 | case FREE_IMG_CACHE: |
457 | ImgCache.Free(); |
457 | ImgCache.Free(); |
458 | notify(IMAGES_CACHE_CLEARED); |
458 | notify(IMAGES_CACHE_CLEARED); |
459 | WB1.Parse(); |
459 | WB1.DrawPage(); |
460 | return; |
460 | return; |
461 | 461 | ||
462 | case VIEW_HISTORY: |
462 | case VIEW_HISTORY: |
463 | strcpy(#URL, URL_SERVICE_HISTORY); |
463 | strcpy(#URL, URL_SERVICE_HISTORY); |
464 | OpenPage(); |
464 | OpenPage(); |
465 | return; |
465 | return; |
466 | 466 | ||
467 | case DOWNLOAD_MANAGER: |
467 | case DOWNLOAD_MANAGER: |
468 | if (!downloader_opened) { |
468 | if (!downloader_opened) { |
469 | strncpy(#DL_URL, "http://",7); |
469 | strncpy(#DL_URL, "http://",7); |
470 | CreateThread(#Downloader,#downloader_stak+4092); |
470 | CreateThread(#Downloader,#downloader_stak+4092); |
471 | } |
471 | } |
472 | return; |
472 | return; |
473 | /* |
473 | /* |
474 | case 020: |
474 | case 020: |
475 | case NEWTAB: |
475 | case NEWTAB: |
476 | MoveSize(190,80,OLD,OLD); |
476 | MoveSize(190,80,OLD,OLD); |
477 | RunProgram(#program_path, #URL); |
477 | RunProgram(#program_path, #URL); |
478 | return; |
478 | return; |
479 | 479 | ||
480 | case SEARCHWEB_BUTTON: |
480 | case SEARCHWEB_BUTTON: |
481 | sprintf(#URL,"%s%s",#search_path,#editURL); |
481 | sprintf(#URL,"%s%s",#search_path,#editURL); |
482 | OpenPage(); |
482 | OpenPage(); |
483 | return; |
483 | return; |
484 | */ |
484 | */ |
485 | } |
485 | } |
486 | } |
486 | } |
487 | 487 | ||
488 | 488 | ||
489 | 489 | ||
490 | void ProcessLinks(int id) |
490 | void ProcessLinks(int id) |
491 | { |
491 | { |
492 | if (http_transfer > 0) |
492 | if (http_transfer > 0) |
493 | { |
493 | { |
494 | StopLoading(); |
494 | StopLoading(); |
495 | BrowserHistory.current--; |
495 | BrowserHistory.current--; |
496 | } |
496 | } |
497 | 497 | ||
498 | strcpy(#URL, PageLinks.GetURL(id-401)); |
498 | strcpy(#URL, PageLinks.GetURL(id-401)); |
499 | //#1 |
499 | //#1 |
500 | if (URL[0] == '#') |
500 | if (URL[0] == '#') |
501 | { |
501 | { |
502 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
502 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
503 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
503 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
504 | WB1.list.first=WB1.list.count-WB1.list.visible; |
504 | WB1.list.first=WB1.list.count-WB1.list.visible; |
505 | ShowPage(); |
505 | ShowPage(); |
506 | return; |
506 | return; |
507 | } |
507 | } |
508 | //liner.ru#1 |
508 | //liner.ru#1 |
509 | if (strrchr(#URL, '#')!=-1) |
509 | if (strrchr(#URL, '#')!=-1) |
510 | { |
510 | { |
511 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
511 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
512 | URL[strrchr(#URL, '#')-1] = 0x00; |
512 | URL[strrchr(#URL, '#')-1] = 0x00; |
513 | } |
513 | } |
514 | 514 | ||
515 | PageLinks.GetAbsoluteURL(#URL); |
515 | PageLinks.GetAbsoluteURL(#URL); |
516 | 516 | ||
517 | if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1) |
517 | if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1) |
518 | || (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) |
518 | || (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) |
519 | { |
519 | { |
520 | //notify(#URL); |
520 | //notify(#URL); |
521 | if (!strncmp(#URL,"http://", 7)) |
521 | if (!strncmp(#URL,"http://", 7)) |
522 | { |
522 | { |
523 | strcpy(#DL_URL, #URL); |
523 | strcpy(#DL_URL, #URL); |
524 | CreateThread(#Downloader,#downloader_stak+4092); |
524 | CreateThread(#Downloader,#downloader_stak+4092); |
525 | } |
525 | } |
526 | else RunProgram("@open", #URL); |
526 | else RunProgram("@open", #URL); |
527 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
527 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
528 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
528 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
529 | return; |
529 | return; |
530 | } |
530 | } |
531 | if (!strncmp(#URL,"mailto:", 7)) |
531 | if (!strncmp(#URL,"mailto:", 7)) |
532 | { |
532 | { |
533 | notify(#URL); |
533 | notify(#URL); |
534 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
534 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
535 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
535 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
536 | return; |
536 | return; |
537 | } |
537 | } |
538 | OpenPage(); |
538 | OpenPage(); |
539 | return; |
539 | return; |
540 | } |
540 | } |
541 | 541 | ||
542 | void StopLoading() |
542 | void StopLoading() |
543 | { |
543 | { |
544 | if (http_transfer) |
544 | if (http_transfer) |
545 | { |
545 | { |
546 | EAX = http_transfer; |
546 | EAX = http_transfer; |
547 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
547 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
548 | $push EAX // save it on the stack |
548 | $push EAX // save it on the stack |
549 | http_free stdcall (http_transfer); // abort connection |
549 | http_free stdcall (http_transfer); // abort connection |
550 | $pop EAX |
550 | $pop EAX |
551 | free(EAX); // free data |
551 | free(EAX); // free data |
552 | http_transfer=0; |
552 | http_transfer=0; |
553 | bufsize = 0; |
553 | bufsize = 0; |
554 | bufpointer = free(bufpointer); |
554 | bufpointer = free(bufpointer); |
555 | } |
555 | } |
556 | wv_progress_bar.value = 0; |
556 | wv_progress_bar.value = 0; |
557 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0); |
557 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0); |
558 | } |
558 | } |
559 | 559 | ||
560 | void SetPageDefaults() |
560 | void SetPageDefaults() |
561 | { |
561 | { |
562 | strcpy(#header, #version); |
562 | strcpy(#header, #version); |
563 | WB1.list.count = WB1.list.first = 0; |
563 | WB1.list.count = WB1.list.first = 0; |
564 | stroka = 0; |
564 | stroka = 0; |
565 | cur_encoding = CH_NULL; |
565 | cur_encoding = CH_NULL; |
566 | if (o_bufpointer) o_bufpointer = free(o_bufpointer); |
566 | if (o_bufpointer) o_bufpointer = free(o_bufpointer); |
567 | anchor_line_num=WB1.list.first; |
567 | anchor_line_num=WB1.list.first; |
568 | anchor[0]='|'; |
568 | anchor[0]='|'; |
569 | } |
569 | } |
570 | 570 | ||
571 | void OpenPage() |
571 | void OpenPage() |
572 | { |
572 | { |
573 | StopLoading(); |
573 | StopLoading(); |
574 | souce_mode = false; |
574 | souce_mode = false; |
575 | strcpy(#editURL, #URL); |
575 | strcpy(#editURL, #URL); |
576 | BrowserHistory.AddUrl(); |
576 | BrowserHistory.AddUrl(); |
577 | if (!strncmp(#URL,"WebView:",8)) |
577 | if (!strncmp(#URL,"WebView:",8)) |
578 | { |
578 | { |
579 | SetPageDefaults(); |
579 | SetPageDefaults(); |
580 | if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage)); |
580 | if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage)); |
581 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
581 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
582 | return; |
582 | return; |
583 | } |
583 | } |
584 | if (!strncmp(#URL,"http:",5)) |
584 | if (!strncmp(#URL,"http:",5)) |
585 | { |
585 | { |
586 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0); |
586 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0); |
587 | http_get stdcall (#URL, 0, 0, #accept_language); |
587 | http_get stdcall (#URL, 0, 0, #accept_language); |
588 | http_transfer = EAX; |
588 | http_transfer = EAX; |
589 | if (!http_transfer) |
589 | if (!http_transfer) |
590 | { |
590 | { |
591 | StopLoading(); |
591 | StopLoading(); |
592 | bufsize = 0; |
592 | bufsize = 0; |
593 | bufpointer = free(bufpointer); |
593 | bufpointer = free(bufpointer); |
594 | ShowPage(); |
594 | ShowPage(); |
595 | return; |
595 | return; |
596 | } |
596 | } |
597 | } |
597 | } |
598 | else |
598 | else |
599 | { |
599 | { |
600 | file_size stdcall (#URL); |
600 | file_size stdcall (#URL); |
601 | bufsize = EBX; |
601 | bufsize = EBX; |
602 | if (bufsize) |
602 | if (bufsize) |
603 | { |
603 | { |
604 | free(bufpointer); |
604 | free(bufpointer); |
605 | bufpointer = malloc(bufsize); |
605 | bufpointer = malloc(bufsize); |
606 | SetPageDefaults(); |
606 | SetPageDefaults(); |
607 | ReadFile(0, bufsize, bufpointer, #URL); |
607 | ReadFile(0, bufsize, bufpointer, #URL); |
608 | //ShowSource(); |
608 | //ShowSource(); |
609 | } |
609 | } |
610 | ShowPage(); |
610 | ShowPage(); |
611 | } |
611 | } |
612 | } |
612 | } |
613 | 613 | ||
614 | DrawEditBox() |
614 | DrawEditBox() |
615 | { |
615 | { |
616 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
616 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
617 | address_box.offset = 0; |
617 | address_box.offset = 0; |
618 | edit_box_draw stdcall(#address_box); |
618 | edit_box_draw stdcall(#address_box); |
619 | } |
619 | } |
620 | 620 | ||
621 | 621 | ||
622 | void ShowPage() |
622 | void ShowPage() |
623 | { |
623 | { |
624 | DrawEditBox(); |
624 | DrawEditBox(); |
625 | if (!bufsize) |
625 | if (!bufsize) |
626 | { |
626 | { |
627 | PageLinks.Clear(); |
627 | PageLinks.Clear(); |
628 | if (http_transfer) |
628 | if (http_transfer) |
629 | { |
629 | { |
630 | WB1.LoadInternalPage(#loading, sizeof(loading)); |
630 | WB1.LoadInternalPage(#loading, sizeof(loading)); |
631 | } |
631 | } |
632 | else |
632 | else |
633 | WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
633 | WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
634 | } |
634 | } |
635 | else |
635 | else |
636 | WB1.Parse(); |
636 | WB1.Prepare(); |
637 | 637 | ||
638 | if (!header) strcpy(#header, #version); |
638 | if (!header) strcpy(#header, #version); |
639 | if (!strcmp(#version, #header)) DrawTitle(#header); |
639 | if (!strcmp(#version, #header)) DrawTitle(#header); |
640 | } |
640 | } |
641 | 641 | ||
642 | byte UrlExtIs(dword ext) |
642 | byte UrlExtIs(dword ext) |
643 | { |
643 | { |
644 | if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; |
644 | if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; |
645 | return false; |
645 | return false; |
646 | } |
646 | } |
647 | 647 | ||
648 | 648 | ||
649 | 649 | ||
650 | char downloader_stak[4096]; |
650 | char downloader_stak[4096]; |
651 | stop:=>>>=5) |
651 | stop:=>>>=5) |
652 | >>280)>120)>><>0)>=scroll_wv.start_x+scroll_wv.size_x)> |
652 | >>280)>120)>><>0)>=scroll_wv.start_x+scroll_wv.size_x)> |