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