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