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