Rev 4554 | Rev 4563 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3067 | leency | 1 | //HTML Viewer in C-- |
3987 | leency | 2 | //Copyright 2007-2013 by Veliant & Leency |
3107 | leency | 3 | //Asper, lev, Lrz, Barsuk, Nable... |
3067 | leency | 4 | //home icon - rachel fu, GPL licence |
5 | |||
4085 | leency | 6 | #ifndef AUTOBUILD |
7 | #include "lang.h--" |
||
8 | #endif |
||
9 | |||
3107 | leency | 10 | //libraries |
3363 | leency | 11 | #define MEMSIZE 0x100000 |
3067 | leency | 12 | #include "..\lib\kolibri.h" |
13 | #include "..\lib\strings.h" |
||
14 | #include "..\lib\figures.h" |
||
15 | #include "..\lib\encoding.h" |
||
16 | #include "..\lib\file_system.h" |
||
17 | #include "..\lib\mem.h" |
||
18 | #include "..\lib\dll.h" |
||
4508 | leency | 19 | #include "..\lib\draw_buf.h" |
20 | #include "..\lib\list_box.h" |
||
21 | #include "..\lib\cursor.h" |
||
22 | |||
3107 | leency | 23 | //*.obj libraries |
24 | #include "..\lib\lib.obj\box_lib.h" |
||
25 | #include "..\lib\lib.obj\libio_lib.h" |
||
26 | #include "..\lib\lib.obj\libimg_lib.h" |
||
4536 | leency | 27 | #include "..\lib\lib.obj\http.h" |
3107 | leency | 28 | //images |
3067 | leency | 29 | #include "img\toolbar_icons.c" |
30 | #include "img\URLgoto.txt"; |
||
31 | |||
4026 | leency | 32 | #ifdef LANG_RUS |
4550 | leency | 33 | char version[]=" Текстовый браузер 0.99.67"; |
4416 | leency | 34 | ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" |
4417 | leency | 35 | ?define T_LAST_SLIDE "Это последний слайд" |
4550 | leency | 36 | char loading[] = "Загрузка страницы... |
4544 | leency | 37 | unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
4026 | leency | 38 | #else |
4550 | leency | 39 | char version[]=" Text-based Browser 0.99.67"; |
4026 | leency | 40 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
4417 | leency | 41 | ?define T_LAST_SLIDE "This slide is the last" |
4550 | leency | 42 | char loading[] = "Loading... |
4544 | leency | 43 | unsigned char page_not_found[] = FROM "html\page_not_found_en.htm"; |
4026 | leency | 44 | #endif |
45 | |||
4554 | leency | 46 | byte native_http=0; |
47 | |||
3067 | leency | 48 | proc_info Form; |
49 | #define WIN_W 640 |
||
50 | #define WIN_H 480 |
||
51 | |||
4416 | leency | 52 | char search_path[]="http://nigma.ru/index.php?s="; |
4558 | hidnplayr | 53 | char str_location[]="location\0"; |
54 | int redirected = 0; |
||
3067 | leency | 55 | |
4074 | leency | 56 | char stak[4096]; |
3067 | leency | 57 | mouse m; |
4026 | leency | 58 | int action_buf; |
59 | |||
4537 | leency | 60 | dword http_transfer = 0; |
61 | dword http_buffer; |
||
4534 | leency | 62 | |
4540 | leency | 63 | int downloader_id; |
64 | |||
4411 | leency | 65 | #include "..\TWB\TWB.c" |
66 | #include "menu_rmb.h" |
||
3067 | leency | 67 | |
4534 | leency | 68 | char editURL[sizeof(URL)]; |
69 | int mouse_twb; |
||
70 | edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
||
71 | |||
4544 | leency | 72 | #define URL_HISTORY "WebView://history" |
4534 | leency | 73 | |
4488 | leency | 74 | enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN }; |
3067 | leency | 75 | |
4488 | leency | 76 | |
3067 | leency | 77 | void main() |
78 | { |
||
4081 | leency | 79 | int key, btn; |
3067 | leency | 80 | int half_scroll_size; |
4026 | leency | 81 | int scroll_used=0, show_menu; |
3067 | leency | 82 | |
83 | mem_Init(); |
||
4536 | leency | 84 | CursorPointer.Load(#CursorFile); |
3107 | leency | 85 | if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();} |
4536 | leency | 86 | if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); |
87 | if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); |
||
4540 | leency | 88 | if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http"); |
3067 | leency | 89 | |
4536 | leency | 90 | if (!URL) strcpy(#URL, "/sys/index.htm"); |
3067 | leency | 91 | Form.width=WIN_W; |
92 | Form.height=WIN_H; |
||
93 | SetElementSizes(); |
||
4416 | leency | 94 | OpenPage(); |
3067 | leency | 95 | |
4536 | leency | 96 | SetEventMask(0xa7); |
3067 | leency | 97 | loop() |
98 | { |
||
99 | WaitEventTimeout(2); |
||
100 | switch(EAX & 0xFF) |
||
101 | { |
||
102 | CASE evMouse: |
||
4081 | leency | 103 | if (!CheckActiveProcess(Form.ID)) break; |
3067 | leency | 104 | |
3466 | leency | 105 | edit_box_mouse stdcall (#address_box); |
3067 | leency | 106 | |
107 | m.get(); |
||
4550 | leency | 108 | if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color); |
3067 | leency | 109 | |
4540 | leency | 110 | if (m.y>WB1.list.y) && (m.y |
3067 | leency | 111 | { |
4026 | leency | 112 | if (m.pkm) |
113 | { |
||
114 | show_menu = 1; |
||
115 | } |
||
116 | if (!m.pkm) && (show_menu) |
||
117 | { |
||
118 | show_menu = 0; |
||
119 | SwitchToAnotherThread(); |
||
4074 | leency | 120 | CreateThread(#menu_rmb,#stak+4092); |
4026 | leency | 121 | break; |
122 | } |
||
3067 | leency | 123 | } |
124 | |||
4415 | leency | 125 | if (m.vert) |
3067 | leency | 126 | { |
4550 | leency | 127 | if (WB1.list.MouseScroll(m.vert)) WB1.Parse(bufpointer, bufsize); |
3067 | leency | 128 | } |
129 | |||
130 | if (!m.lkm) scroll_used=0; |
||
4416 | leency | 131 | if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x) |
132 | && (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y) |
||
4415 | leency | 133 | && (WB1.list.count>WB1.list.visible) && (m.lkm) |
4026 | leency | 134 | { |
135 | scroll_used=1; |
||
136 | } |
||
3067 | leency | 137 | |
138 | if (scroll_used) |
||
139 | { |
||
4415 | leency | 140 | half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2; |
4416 | leency | 141 | if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y; |
142 | btn=WB1.list.first; |
||
4415 | leency | 143 | WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h; |
144 | if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible; |
||
4550 | leency | 145 | if (btn<>WB1.list.first) WB1.Parse(bufpointer, bufsize); |
3067 | leency | 146 | } |
147 | |||
148 | break; |
||
149 | case evButton: |
||
150 | btn=GetButtonID(); |
||
3464 | leency | 151 | if (btn==1) |
3067 | leency | 152 | { |
153 | KillProcess(downloader_id); |
||
154 | ExitProcess(); |
||
155 | } |
||
156 | ELSE |
||
157 | { |
||
4413 | leency | 158 | Scan(btn); |
3067 | leency | 159 | } |
160 | break; |
||
161 | case evKey: |
||
162 | key = GetKey(); |
||
163 | |||
4416 | leency | 164 | if (address_box.flags & 0b10) SWITCH(key) |
3067 | leency | 165 | { CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; } |
166 | |||
4413 | leency | 167 | Scan(key); |
3067 | leency | 168 | |
169 | _EDIT_MARK: |
||
4416 | leency | 170 | if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} |
3067 | leency | 171 | break; |
172 | case evReDraw: |
||
4413 | leency | 173 | if (action_buf) { Scan(action_buf); action_buf=0;} |
3067 | leency | 174 | Draw_Window(); |
175 | break; |
||
4540 | leency | 176 | |
4536 | leency | 177 | case evNetwork: |
4540 | leency | 178 | if (http_transfer > 0) { |
4536 | leency | 179 | http_process stdcall (http_transfer); |
180 | $push EAX |
||
181 | ESI = http_transfer; |
||
4540 | leency | 182 | bufpointer = ESI.http_msg.content_ptr; |
4554 | leency | 183 | bufsize = ESI.http_msg.content_received; |
4550 | leency | 184 | WB1.Parse(bufpointer, bufsize); |
4554 | leency | 185 | |
4536 | leency | 186 | $pop EAX |
4554 | leency | 187 | if (EAX == 0) { |
4558 | hidnplayr | 188 | ESI = http_transfer; |
189 | // Handle redirects |
||
190 | if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) { |
||
191 | redirected++; |
||
192 | if (redirected<=5) { |
||
193 | http_find_header_field stdcall (http_transfer, #str_location); |
||
194 | if (EAX!=0) { |
||
195 | ESI = EAX; |
||
196 | EDI = #URL; |
||
197 | do { |
||
198 | $lodsb; |
||
199 | $stosb; |
||
200 | } while (AL != 0) && (AL != 13) && (AL != 10)); |
||
201 | DSBYTE[EDI-1]='\0'; |
||
202 | } |
||
203 | } else { |
||
204 | //TODO: display error (too many redirects) |
||
205 | } |
||
206 | } else { |
||
207 | redirected = 0; |
||
208 | } |
||
4554 | leency | 209 | // Loading the page is complete, free resources |
4536 | leency | 210 | http_free stdcall (http_transfer); |
4554 | leency | 211 | http_transfer=0; |
4558 | hidnplayr | 212 | if (redirected>0) { |
213 | WB1.GetNewUrl(); |
||
214 | strcpy(#editURL, #URL); |
||
215 | OpenPage(); |
||
216 | } else { |
||
217 | Draw_Window(); // stop button => refresh button |
||
218 | } |
||
4536 | leency | 219 | } |
220 | } |
||
3067 | leency | 221 | default: |
222 | if (downloader_id<>0) |
||
223 | { |
||
224 | if (GetProcessSlot(downloader_id)<>0) break; |
||
225 | downloader_id=0; |
||
4415 | leency | 226 | WB1.list.first = WB1.list.count = 0; |
3067 | leency | 227 | WB1.ReadHtml(_WIN); |
228 | Draw_Window(); |
||
229 | } |
||
230 | } |
||
231 | } |
||
232 | } |
||
233 | |||
234 | void SetElementSizes() |
||
235 | { |
||
4416 | leency | 236 | address_box.width = Form.width - 266; |
237 | WB1.list.SetSizes(0, 44, Form.width - 10 - scroll_wv.size_x, Form.cheight - 44, 0, 10); |
||
4415 | leency | 238 | WB1.list.column_max = WB1.list.w - 30 / 6; |
239 | WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2; |
||
4475 | leency | 240 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h, WB1.list.line_h); |
3067 | leency | 241 | } |
242 | |||
243 | |||
244 | void Draw_Window() |
||
245 | { |
||
246 | int j; |
||
3466 | leency | 247 | DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0xE4DFE1,0,0); |
3067 | leency | 248 | |
249 | GetProcessInfo(#Form, SelfInfo); |
||
3464 | leency | 250 | if (Form.status_window>2) |
3067 | leency | 251 | { |
252 | DrawTitle(#header); |
||
253 | return; |
||
254 | } |
||
255 | if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
||
256 | if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
||
257 | |||
258 | PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
||
4554 | leency | 259 | if (GetProcessSlot(downloader_id)<>0) || (http_transfer > 0) _PutImage(88,10, 24,24, #stop_btn); |
3067 | leency | 260 | |
3464 | leency | 261 | DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1); |
262 | DrawBar(0,42,Form.cwidth,1,0xE2DBDC); |
||
263 | DrawBar(0,43,Form.cwidth,1,0xD2CED0); |
||
3067 | leency | 264 | for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1); |
3464 | leency | 265 | _PutImage(Form.cwidth-48,14, 40,19, #URLgoto); |
266 | DefineButton(Form.cwidth-28,15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1); |
||
267 | DefineButton(Form.cwidth-47,15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1); |
||
268 | DrawRectangle(205,14,Form.cwidth-205-49,18,0x94AECE); //around adress bar |
||
269 | DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3); |
||
3067 | leency | 270 | |
271 | SetElementSizes(); |
||
4508 | leency | 272 | ShowPage(); |
3464 | leency | 273 | |
4416 | leency | 274 | DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1); |
275 | DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+scroll_wv.size_y-18, 16, 16, BTN_DOWN+BT_HIDE, 0xE4DFE1); |
||
3067 | leency | 276 | } |
277 | |||
278 | |||
4413 | leency | 279 | void Scan(int id) |
280 | { |
||
4415 | leency | 281 | if (id >= 400) ProcessLinks(id); |
4413 | leency | 282 | |
283 | switch (id) |
||
284 | { |
||
285 | case 011: //Ctrk+K |
||
286 | WB1.ReadHtml(_KOI); |
||
4550 | leency | 287 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 288 | return; |
289 | |||
4413 | leency | 290 | case 021: //Ctrl+U |
291 | WB1.ReadHtml(_UTF); |
||
4550 | leency | 292 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 293 | return; |
294 | |||
4413 | leency | 295 | case 004: //Ctrl+D |
296 | WB1.ReadHtml(_DOS); |
||
4550 | leency | 297 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 298 | return; |
299 | |||
4533 | leency | 300 | case 005: //Win encoding |
301 | WB1.ReadHtml(_WIN); |
||
4550 | leency | 302 | WB1.Parse(bufpointer, bufsize); |
4533 | leency | 303 | return; |
304 | |||
305 | case 009: //free img cache |
||
4491 | leency | 306 | ImgCache.Free(); |
4416 | leency | 307 | notify(IMAGES_CACHE_CLEARED); |
4550 | leency | 308 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 309 | return; |
310 | |||
4546 | leency | 311 | case 003: //history |
4544 | leency | 312 | strcpy(#URL, URL_HISTORY); |
313 | OpenPage(); |
||
314 | return; |
||
315 | |||
4413 | leency | 316 | case BACK: |
317 | if (!BrowserHistory.GoBack()) return; |
||
4416 | leency | 318 | OpenPage(); |
4413 | leency | 319 | return; |
320 | case FORWARD: |
||
321 | if (!BrowserHistory.GoForward()) return; |
||
4416 | leency | 322 | OpenPage(); |
4413 | leency | 323 | return; |
324 | case 052: //F3 |
||
4488 | leency | 325 | if (strncmp(#URL,"http:",5)<>0) RunProgram("/rd/1/tinypad", #URL); |
4415 | leency | 326 | else RunProgram("/rd/1/tinypad", #download_path); |
4413 | leency | 327 | return; |
328 | case 054: //F5 |
||
4550 | leency | 329 | IF(address_box.flags & 0b10) WB1.Parse(bufpointer, bufsize); |
4415 | leency | 330 | return; |
331 | |||
4413 | leency | 332 | case REFRESH: |
4554 | leency | 333 | if (http_transfer<>0) |
334 | { |
||
335 | EAX = http_transfer; |
||
336 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
||
337 | $push EAX // save it on the stack |
||
338 | http_free stdcall (http_transfer); // abort connection |
||
339 | $pop EAX |
||
340 | mem_Free(EAX); // free data |
||
341 | http_transfer=0; |
||
342 | bufsize = 0; |
||
343 | } |
||
4413 | leency | 344 | if (GetProcessSlot(downloader_id)<>0) |
345 | { |
||
346 | KillProcess(downloader_id); |
||
347 | pause(20); |
||
348 | Draw_Window(); |
||
349 | return; |
||
350 | } |
||
4415 | leency | 351 | anchor_line_num=WB1.list.first; |
4413 | leency | 352 | anchor[0]='|'; |
4416 | leency | 353 | OpenPage(); |
4413 | leency | 354 | return; |
4415 | leency | 355 | case 014: |
356 | case 020: |
||
4413 | leency | 357 | case NEWTAB: |
358 | MoveSize(190,80,OLD,OLD); |
||
359 | RunProgram(#program_path, #URL); |
||
360 | return; |
||
361 | |||
362 | case HOME: |
||
363 | strcpy(#editURL, "http://kolibrios.org/en/index.htm"); |
||
364 | case GOTOURL: |
||
365 | case 0x0D: //enter |
||
366 | if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0; |
||
367 | strcat(#URL, #editURL); |
||
4416 | leency | 368 | OpenPage(); |
4413 | leency | 369 | return; |
370 | case SEARCHWEB: |
||
371 | strcpy(#URL, #search_path); |
||
372 | strcat(#URL, #editURL); |
||
4416 | leency | 373 | OpenPage(); |
4413 | leency | 374 | return; |
375 | |||
376 | case 183: //PgDown |
||
4415 | leency | 377 | if (WB1.list.count < WB1.list.visible) return; |
378 | IF(WB1.list.first == WB1.list.count - WB1.list.visible) return; |
||
379 | WB1.list.first += WB1.list.visible + 2; |
||
380 | IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible; |
||
4550 | leency | 381 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 382 | return; |
383 | |||
4413 | leency | 384 | case 184: //PgUp |
4415 | leency | 385 | if (WB1.list.count < WB1.list.visible) return; |
386 | IF(WB1.list.first == 0) return; |
||
387 | WB1.list.first -= WB1.list.visible - 2; |
||
388 | IF(WB1.list.first < 0) WB1.list.first = 0; |
||
4550 | leency | 389 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 390 | return; |
391 | |||
392 | case 178: |
||
4544 | leency | 393 | case BTN_UP: |
4416 | leency | 394 | if (WB1.list.first <= 0) return; |
4415 | leency | 395 | WB1.list.first--; |
4550 | leency | 396 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 397 | return; |
398 | |||
399 | case 177: |
||
4544 | leency | 400 | case BTN_DOWN: |
4416 | leency | 401 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
4415 | leency | 402 | WB1.list.first++; |
4550 | leency | 403 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 404 | return; |
405 | |||
4413 | leency | 406 | case 180: //home |
4550 | leency | 407 | if (WB1.list.KeyHome()) WB1.Parse(bufpointer, bufsize); |
4415 | leency | 408 | return; |
409 | |||
4413 | leency | 410 | case 181: //end |
4415 | leency | 411 | if (WB1.list.count < WB1.list.visible) return; |
4550 | leency | 412 | if (WB1.list.KeyEnd()) WB1.Parse(bufpointer, bufsize); |
4413 | leency | 413 | return; |
414 | } |
||
415 | } |
||
416 | |||
417 | |||
418 | |||
4415 | leency | 419 | void ProcessLinks(int id) |
420 | { |
||
4544 | leency | 421 | strcpy(#URL, PageLinks.GetURL(id-401)); |
4417 | leency | 422 | //$1 - Condition Script |
423 | if (URL[0] == '$') |
||
424 | { |
||
425 | if (URL[1]=='-') && (condition_href) condition_href--; |
||
426 | if (URL[1]=='+') |
||
427 | { |
||
428 | if (condition_href |
||
429 | } |
||
430 | if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1); |
||
431 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
||
4508 | leency | 432 | ShowPage(); |
4417 | leency | 433 | return; |
434 | } |
||
4415 | leency | 435 | //#1 |
436 | if (URL[0] == '#') |
||
437 | { |
||
4417 | leency | 438 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
4415 | leency | 439 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
440 | WB1.list.first=WB1.list.count-WB1.list.visible; |
||
4508 | leency | 441 | ShowPage(); |
4415 | leency | 442 | return; |
443 | } |
||
444 | //liner.ru#1 |
||
4417 | leency | 445 | if (strrchr(#URL, '#')!=-1) |
4415 | leency | 446 | { |
447 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
||
4416 | leency | 448 | URL[strrchr(#URL, '#')-1] = 0x00; |
4415 | leency | 449 | } |
450 | |||
451 | WB1.GetNewUrl(); |
||
452 | |||
453 | if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg")) |
||
454 | { |
||
455 | //if (strstr(#URL,"http:")) |
||
456 | RunProgram("/sys/media/kiv", #URL); |
||
457 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
||
458 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
||
459 | return; |
||
460 | } |
||
461 | if (!strcmpn(#URL,"mailto:", 7)) |
||
462 | { |
||
463 | notify(#URL); |
||
464 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
||
465 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
||
466 | return; |
||
467 | } |
||
4413 | leency | 468 | |
4416 | leency | 469 | OpenPage(); |
4415 | leency | 470 | return; |
471 | } |
||
472 | |||
4416 | leency | 473 | void OpenPage() |
474 | { |
||
475 | if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
||
476 | KillProcess(downloader_id); |
||
477 | strcpy(#editURL, #URL); |
||
478 | BrowserHistory.AddUrl(); |
||
479 | strcpy(#header, #version); |
||
480 | pre_text =0; |
||
4488 | leency | 481 | if (!strncmp(#URL,"http:",5)) |
4416 | leency | 482 | { |
4554 | leency | 483 | if (native_http) |
484 | { |
||
485 | http_get stdcall (#URL, 0); |
||
486 | http_transfer = EAX; |
||
487 | IF (http_transfer < 0) notify("Error from HTTP lib"); |
||
488 | } |
||
489 | else |
||
490 | { |
||
491 | KillProcess(downloader_id); |
||
492 | DeleteFile(#download_path); |
||
493 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
||
494 | IF (downloader_id<0) notify("Error running Downloader. Internet unavilable."); |
||
495 | } |
||
4416 | leency | 496 | Draw_Window(); |
497 | return; |
||
498 | } |
||
499 | WB1.list.first = WB1.list.count =0; |
||
500 | WB1.ReadHtml(_WIN); |
||
4508 | leency | 501 | ShowPage(); |
4416 | leency | 502 | } |
4415 | leency | 503 | |
4508 | leency | 504 | void ShowPage() |
505 | { |
||
506 | address_box.size = address_box.pos = strlen(#editURL); |
||
507 | address_box.offset=0; |
||
508 | edit_box_draw stdcall(#address_box); |
||
4415 | leency | 509 | |
4544 | leency | 510 | if (strcmp(#URL, URL_HISTORY)==0) ShowHistory(); else |
4540 | leency | 511 | if (!bufsize) |
4508 | leency | 512 | { |
513 | PageLinks.Clear(); |
||
4550 | leency | 514 | if (GetProcessSlot(downloader_id)<>0) |
515 | WB1.Parse(#loading, sizeof(loading)); |
||
4508 | leency | 516 | else |
4550 | leency | 517 | WB1.Parse(#page_not_found, sizeof(page_not_found)); |
4508 | leency | 518 | } |
519 | else |
||
4550 | leency | 520 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 521 | |
4508 | leency | 522 | if (!header) strcpy(#header, #version); |
523 | if (!strcmp(#version, #header)) DrawTitle(#header); |
||
524 | } |
||
525 | |||
4544 | leency | 526 | ShowHistory() |
527 | { |
||
528 | int i; |
||
529 | static int history_pointer; |
||
530 | |||
531 | free(history_pointer); |
||
532 | history_pointer = malloc(64000); |
||
4550 | leency | 533 | strcat(history_pointer, " |
4544 | leency | 534 | strcat(history_pointer, " |
535 | for (i=1; i |
||
536 | { |
||
537 | strcat(history_pointer, ""); |
||
540 | strcat(history_pointer, BrowserHistory.GetUrl(i)); |
||
541 | strcat(history_pointer, " |
||
542 | } |
||
543 | strcat(history_pointer, " |
||
544 | for (i=1; i |
||
545 | { |
||
546 | strcat(history_pointer, " |
||
4550 | leency | 549 | strcat(history_pointer, #pics[i].path); |
4544 | leency | 550 | } |
551 | bufpointer = history_pointer; |
||
4550 | leency | 552 | WB1.Parse(history_pointer, strlen(history_pointer)); |
4544 | leency | 553 | } |
4508 | leency | 554 | |
4544 | leency | 555 | |
3067 | leency | 556 | stop:>0)>>>>=>>>>>>>5;>>280)>120)>>>=5)>>8;><8;>>>>>0)>=scroll_wv.start_x+scroll_wv.size_x)> |