Rev 4558 | Rev 4564 | 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 | |||
4563 | leency | 46 | byte native_http=1; |
4554 | leency | 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 |
||
4563 | leency | 190 | if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) |
191 | { |
||
4558 | hidnplayr | 192 | redirected++; |
4563 | leency | 193 | if (redirected<=5) |
194 | { |
||
4558 | hidnplayr | 195 | http_find_header_field stdcall (http_transfer, #str_location); |
196 | if (EAX!=0) { |
||
197 | ESI = EAX; |
||
198 | EDI = #URL; |
||
199 | do { |
||
200 | $lodsb; |
||
201 | $stosb; |
||
202 | } while (AL != 0) && (AL != 13) && (AL != 10)); |
||
203 | DSBYTE[EDI-1]='\0'; |
||
204 | } |
||
4563 | leency | 205 | } |
206 | else |
||
207 | { |
||
4558 | hidnplayr | 208 | //TODO: display error (too many redirects) |
209 | } |
||
4563 | leency | 210 | } |
211 | else |
||
212 | { |
||
4558 | hidnplayr | 213 | redirected = 0; |
214 | } |
||
4554 | leency | 215 | // Loading the page is complete, free resources |
4536 | leency | 216 | http_free stdcall (http_transfer); |
4554 | leency | 217 | http_transfer=0; |
4563 | leency | 218 | if (redirected>0) |
219 | { |
||
4558 | hidnplayr | 220 | WB1.GetNewUrl(); |
221 | strcpy(#editURL, #URL); |
||
4563 | leency | 222 | BrowserHistory.current--; |
4558 | hidnplayr | 223 | OpenPage(); |
4563 | leency | 224 | } |
225 | else |
||
226 | { |
||
4558 | hidnplayr | 227 | Draw_Window(); // stop button => refresh button |
228 | } |
||
4536 | leency | 229 | } |
230 | } |
||
3067 | leency | 231 | default: |
232 | if (downloader_id<>0) |
||
233 | { |
||
234 | if (GetProcessSlot(downloader_id)<>0) break; |
||
235 | downloader_id=0; |
||
4415 | leency | 236 | WB1.list.first = WB1.list.count = 0; |
3067 | leency | 237 | WB1.ReadHtml(_WIN); |
238 | Draw_Window(); |
||
239 | } |
||
240 | } |
||
241 | } |
||
242 | } |
||
243 | |||
244 | void SetElementSizes() |
||
245 | { |
||
4416 | leency | 246 | address_box.width = Form.width - 266; |
247 | WB1.list.SetSizes(0, 44, Form.width - 10 - scroll_wv.size_x, Form.cheight - 44, 0, 10); |
||
4415 | leency | 248 | WB1.list.column_max = WB1.list.w - 30 / 6; |
249 | WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2; |
||
4475 | leency | 250 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h, WB1.list.line_h); |
3067 | leency | 251 | } |
252 | |||
253 | |||
254 | void Draw_Window() |
||
255 | { |
||
256 | int j; |
||
3466 | leency | 257 | DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0xE4DFE1,0,0); |
3067 | leency | 258 | |
259 | GetProcessInfo(#Form, SelfInfo); |
||
3464 | leency | 260 | if (Form.status_window>2) |
3067 | leency | 261 | { |
262 | DrawTitle(#header); |
||
263 | return; |
||
264 | } |
||
265 | if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
||
266 | if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
||
267 | |||
268 | PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
||
4554 | leency | 269 | if (GetProcessSlot(downloader_id)<>0) || (http_transfer > 0) _PutImage(88,10, 24,24, #stop_btn); |
3067 | leency | 270 | |
3464 | leency | 271 | DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1); |
272 | DrawBar(0,42,Form.cwidth,1,0xE2DBDC); |
||
273 | DrawBar(0,43,Form.cwidth,1,0xD2CED0); |
||
3067 | leency | 274 | for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1); |
3464 | leency | 275 | _PutImage(Form.cwidth-48,14, 40,19, #URLgoto); |
276 | DefineButton(Form.cwidth-28,15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1); |
||
277 | DefineButton(Form.cwidth-47,15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1); |
||
278 | DrawRectangle(205,14,Form.cwidth-205-49,18,0x94AECE); //around adress bar |
||
279 | DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3); |
||
3067 | leency | 280 | |
281 | SetElementSizes(); |
||
4508 | leency | 282 | ShowPage(); |
3464 | leency | 283 | |
4416 | leency | 284 | DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1); |
285 | DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+scroll_wv.size_y-18, 16, 16, BTN_DOWN+BT_HIDE, 0xE4DFE1); |
||
3067 | leency | 286 | } |
287 | |||
288 | |||
4413 | leency | 289 | void Scan(int id) |
290 | { |
||
4415 | leency | 291 | if (id >= 400) ProcessLinks(id); |
4413 | leency | 292 | |
293 | switch (id) |
||
294 | { |
||
295 | case 011: //Ctrk+K |
||
296 | WB1.ReadHtml(_KOI); |
||
4550 | leency | 297 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 298 | return; |
299 | |||
4413 | leency | 300 | case 021: //Ctrl+U |
301 | WB1.ReadHtml(_UTF); |
||
4550 | leency | 302 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 303 | return; |
304 | |||
4413 | leency | 305 | case 004: //Ctrl+D |
306 | WB1.ReadHtml(_DOS); |
||
4550 | leency | 307 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 308 | return; |
309 | |||
4533 | leency | 310 | case 005: //Win encoding |
311 | WB1.ReadHtml(_WIN); |
||
4550 | leency | 312 | WB1.Parse(bufpointer, bufsize); |
4533 | leency | 313 | return; |
314 | |||
315 | case 009: //free img cache |
||
4491 | leency | 316 | ImgCache.Free(); |
4416 | leency | 317 | notify(IMAGES_CACHE_CLEARED); |
4550 | leency | 318 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 319 | return; |
320 | |||
4546 | leency | 321 | case 003: //history |
4544 | leency | 322 | strcpy(#URL, URL_HISTORY); |
323 | OpenPage(); |
||
324 | return; |
||
325 | |||
4413 | leency | 326 | case BACK: |
327 | if (!BrowserHistory.GoBack()) return; |
||
4416 | leency | 328 | OpenPage(); |
4413 | leency | 329 | return; |
330 | case FORWARD: |
||
331 | if (!BrowserHistory.GoForward()) return; |
||
4416 | leency | 332 | OpenPage(); |
4413 | leency | 333 | return; |
334 | case 052: //F3 |
||
4488 | leency | 335 | if (strncmp(#URL,"http:",5)<>0) RunProgram("/rd/1/tinypad", #URL); |
4415 | leency | 336 | else RunProgram("/rd/1/tinypad", #download_path); |
4413 | leency | 337 | return; |
338 | case 054: //F5 |
||
4550 | leency | 339 | IF(address_box.flags & 0b10) WB1.Parse(bufpointer, bufsize); |
4415 | leency | 340 | return; |
341 | |||
4413 | leency | 342 | case REFRESH: |
4554 | leency | 343 | if (http_transfer<>0) |
344 | { |
||
345 | EAX = http_transfer; |
||
346 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
||
347 | $push EAX // save it on the stack |
||
348 | http_free stdcall (http_transfer); // abort connection |
||
349 | $pop EAX |
||
350 | mem_Free(EAX); // free data |
||
351 | http_transfer=0; |
||
352 | bufsize = 0; |
||
353 | } |
||
4413 | leency | 354 | if (GetProcessSlot(downloader_id)<>0) |
355 | { |
||
356 | KillProcess(downloader_id); |
||
357 | pause(20); |
||
358 | Draw_Window(); |
||
359 | return; |
||
360 | } |
||
4415 | leency | 361 | anchor_line_num=WB1.list.first; |
4413 | leency | 362 | anchor[0]='|'; |
4416 | leency | 363 | OpenPage(); |
4413 | leency | 364 | return; |
4415 | leency | 365 | case 014: |
366 | case 020: |
||
4413 | leency | 367 | case NEWTAB: |
368 | MoveSize(190,80,OLD,OLD); |
||
369 | RunProgram(#program_path, #URL); |
||
370 | return; |
||
371 | |||
372 | case HOME: |
||
373 | strcpy(#editURL, "http://kolibrios.org/en/index.htm"); |
||
374 | case GOTOURL: |
||
375 | case 0x0D: //enter |
||
376 | if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0; |
||
377 | strcat(#URL, #editURL); |
||
4416 | leency | 378 | OpenPage(); |
4413 | leency | 379 | return; |
380 | case SEARCHWEB: |
||
381 | strcpy(#URL, #search_path); |
||
382 | strcat(#URL, #editURL); |
||
4416 | leency | 383 | OpenPage(); |
4413 | leency | 384 | return; |
385 | |||
386 | case 183: //PgDown |
||
4415 | leency | 387 | if (WB1.list.count < WB1.list.visible) return; |
388 | IF(WB1.list.first == WB1.list.count - WB1.list.visible) return; |
||
389 | WB1.list.first += WB1.list.visible + 2; |
||
390 | IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible; |
||
4550 | leency | 391 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 392 | return; |
393 | |||
4413 | leency | 394 | case 184: //PgUp |
4415 | leency | 395 | if (WB1.list.count < WB1.list.visible) return; |
396 | IF(WB1.list.first == 0) return; |
||
397 | WB1.list.first -= WB1.list.visible - 2; |
||
398 | IF(WB1.list.first < 0) WB1.list.first = 0; |
||
4550 | leency | 399 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 400 | return; |
401 | |||
402 | case 178: |
||
4544 | leency | 403 | case BTN_UP: |
4416 | leency | 404 | if (WB1.list.first <= 0) return; |
4415 | leency | 405 | WB1.list.first--; |
4550 | leency | 406 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 407 | return; |
408 | |||
409 | case 177: |
||
4544 | leency | 410 | case BTN_DOWN: |
4416 | leency | 411 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
4415 | leency | 412 | WB1.list.first++; |
4550 | leency | 413 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 414 | return; |
415 | |||
4413 | leency | 416 | case 180: //home |
4550 | leency | 417 | if (WB1.list.KeyHome()) WB1.Parse(bufpointer, bufsize); |
4415 | leency | 418 | return; |
419 | |||
4413 | leency | 420 | case 181: //end |
4415 | leency | 421 | if (WB1.list.count < WB1.list.visible) return; |
4550 | leency | 422 | if (WB1.list.KeyEnd()) WB1.Parse(bufpointer, bufsize); |
4413 | leency | 423 | return; |
424 | } |
||
425 | } |
||
426 | |||
427 | |||
428 | |||
4415 | leency | 429 | void ProcessLinks(int id) |
430 | { |
||
4544 | leency | 431 | strcpy(#URL, PageLinks.GetURL(id-401)); |
4417 | leency | 432 | //$1 - Condition Script |
433 | if (URL[0] == '$') |
||
434 | { |
||
435 | if (URL[1]=='-') && (condition_href) condition_href--; |
||
436 | if (URL[1]=='+') |
||
437 | { |
||
438 | if (condition_href |
||
439 | } |
||
440 | if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1); |
||
441 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
||
4508 | leency | 442 | ShowPage(); |
4417 | leency | 443 | return; |
444 | } |
||
4415 | leency | 445 | //#1 |
446 | if (URL[0] == '#') |
||
447 | { |
||
4417 | leency | 448 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
4415 | leency | 449 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
450 | WB1.list.first=WB1.list.count-WB1.list.visible; |
||
4508 | leency | 451 | ShowPage(); |
4415 | leency | 452 | return; |
453 | } |
||
454 | //liner.ru#1 |
||
4417 | leency | 455 | if (strrchr(#URL, '#')!=-1) |
4415 | leency | 456 | { |
457 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
||
4416 | leency | 458 | URL[strrchr(#URL, '#')-1] = 0x00; |
4415 | leency | 459 | } |
460 | |||
461 | WB1.GetNewUrl(); |
||
462 | |||
463 | if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg")) |
||
464 | { |
||
465 | //if (strstr(#URL,"http:")) |
||
466 | RunProgram("/sys/media/kiv", #URL); |
||
467 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
||
468 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
||
469 | return; |
||
470 | } |
||
471 | if (!strcmpn(#URL,"mailto:", 7)) |
||
472 | { |
||
473 | notify(#URL); |
||
474 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
||
475 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
||
476 | return; |
||
477 | } |
||
4413 | leency | 478 | |
4416 | leency | 479 | OpenPage(); |
4415 | leency | 480 | return; |
481 | } |
||
482 | |||
4416 | leency | 483 | void OpenPage() |
484 | { |
||
485 | if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
||
486 | KillProcess(downloader_id); |
||
487 | strcpy(#editURL, #URL); |
||
488 | BrowserHistory.AddUrl(); |
||
489 | strcpy(#header, #version); |
||
490 | pre_text =0; |
||
4488 | leency | 491 | if (!strncmp(#URL,"http:",5)) |
4416 | leency | 492 | { |
4554 | leency | 493 | if (native_http) |
494 | { |
||
495 | http_get stdcall (#URL, 0); |
||
496 | http_transfer = EAX; |
||
497 | IF (http_transfer < 0) notify("Error from HTTP lib"); |
||
498 | } |
||
499 | else |
||
500 | { |
||
501 | KillProcess(downloader_id); |
||
502 | DeleteFile(#download_path); |
||
503 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
||
504 | IF (downloader_id<0) notify("Error running Downloader. Internet unavilable."); |
||
505 | } |
||
4416 | leency | 506 | Draw_Window(); |
507 | return; |
||
508 | } |
||
509 | WB1.list.first = WB1.list.count =0; |
||
510 | WB1.ReadHtml(_WIN); |
||
4508 | leency | 511 | ShowPage(); |
4416 | leency | 512 | } |
4415 | leency | 513 | |
4508 | leency | 514 | void ShowPage() |
515 | { |
||
516 | address_box.size = address_box.pos = strlen(#editURL); |
||
517 | address_box.offset=0; |
||
518 | edit_box_draw stdcall(#address_box); |
||
4415 | leency | 519 | |
4544 | leency | 520 | if (strcmp(#URL, URL_HISTORY)==0) ShowHistory(); else |
4540 | leency | 521 | if (!bufsize) |
4508 | leency | 522 | { |
523 | PageLinks.Clear(); |
||
4550 | leency | 524 | if (GetProcessSlot(downloader_id)<>0) |
525 | WB1.Parse(#loading, sizeof(loading)); |
||
4508 | leency | 526 | else |
4550 | leency | 527 | WB1.Parse(#page_not_found, sizeof(page_not_found)); |
4508 | leency | 528 | } |
529 | else |
||
4550 | leency | 530 | WB1.Parse(bufpointer, bufsize); |
4415 | leency | 531 | |
4508 | leency | 532 | if (!header) strcpy(#header, #version); |
533 | if (!strcmp(#version, #header)) DrawTitle(#header); |
||
534 | } |
||
535 | |||
4544 | leency | 536 | ShowHistory() |
537 | { |
||
538 | int i; |
||
539 | static int history_pointer; |
||
540 | |||
541 | free(history_pointer); |
||
542 | history_pointer = malloc(64000); |
||
4550 | leency | 543 | strcat(history_pointer, " |
4544 | leency | 544 | strcat(history_pointer, " |
545 | for (i=1; i |
||
546 | { |
||
547 | strcat(history_pointer, ""); |
||
550 | strcat(history_pointer, BrowserHistory.GetUrl(i)); |
||
551 | strcat(history_pointer, " |
||
552 | } |
||
553 | strcat(history_pointer, " |
||
554 | for (i=1; i |
||
555 | { |
||
556 | strcat(history_pointer, " |
||
4550 | leency | 559 | strcat(history_pointer, #pics[i].path); |
4544 | leency | 560 | } |
561 | bufpointer = history_pointer; |
||
4550 | leency | 562 | WB1.Parse(history_pointer, strlen(history_pointer)); |
4544 | leency | 563 | } |
4508 | leency | 564 | |
4544 | leency | 565 | |
3067 | leency | 566 | stop:>0)>>>>=>>>>>>>5;>>280)>120)>>>=5) |