Subversion Repositories Kolibri OS

Rev

Rev 4674 | Rev 4686 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //HTML Viewer in C--
  2. //Copyright 2007-2013 by Veliant & Leency
  3. //Asper, lev, Lrz, Barsuk, Nable...
  4. //home icon - rachel fu, GPL licence
  5.  
  6. #ifndef AUTOBUILD
  7.         #include "lang.h--"
  8. #endif
  9.  
  10. //libraries
  11. #define MEMSIZE 0x100000
  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"
  19. #include "..\lib\draw_buf.h"
  20. #include "..\lib\list_box.h"
  21. #include "..\lib\cursor.h"
  22.  
  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"
  27. #include "..\lib\lib.obj\http.h"
  28.  
  29. char homepage[] = FROM "html\homepage.htm";
  30.  
  31. #ifdef LANG_RUS
  32.         char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.0 Beta 1";
  33.         ?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
  34.         ?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
  35.         char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
  36.         char page_not_found[] = FROM "html\page_not_found_ru.htm";
  37.         char accept_language[]= "Accept-Language: ru\n";
  38. #else
  39.         char version[]=" Text-based Browser 1.0 Beta 1";
  40.         ?define IMAGES_CACHE_CLEARED "Images cache cleared"
  41.         ?define T_LAST_SLIDE "This slide is the last"
  42.         char loading[] = "Loading...<br>";
  43.         char page_not_found[] = FROM "html\page_not_found_en.htm";
  44.         char accept_language[]= "Accept-Language: en\n";       
  45. #endif
  46.  
  47. proc_info Form;
  48. #define WIN_W 640
  49. #define WIN_H 480
  50.  
  51. char search_path[]="http://nigma.ru/index.php?s=";
  52. char str_location[]="location\0";
  53. int redirected = 0;
  54.  
  55. char stak[4096];
  56. mouse m;
  57. int action_buf;
  58.  
  59. dword http_transfer = 0;
  60. dword http_buffer;
  61.  
  62. dword TAB_H = 19;
  63. dword TAB_W = 150;
  64. dword TOOLBAR_H = 50;
  65. dword STATUSBAR_H =18;
  66. dword col_bg = 0xE4DFE1;
  67. dword panel_color = 0xF1F1F1;
  68. dword border_color = 0x9F9F9F;
  69.  
  70. pb progress_bar = {0, 10, 83, 150, 13, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
  71.  
  72. #include "..\TWB\TWB.c"
  73. #include "menu_rmb.h"
  74. #include "history.h"
  75.  
  76. char editURL[sizeof(URL)];
  77. int     mouse_twb;
  78. edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
  79.  
  80. #define URL_SERVICE_HISTORY "WebView://history"
  81. #define URL_SERVICE_HOME "WebView://home"
  82.  
  83. enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
  84.  
  85. struct skin {
  86.         dword image, w, h;
  87. } skin;
  88.  
  89. int LoadSkin()
  90. {
  91.         skin.image = load_image(abspath("wv_skin.png"));
  92.         skin.w = DSWORD[skin.image+4];
  93.         skin.h = DSWORD[skin.image+8];
  94. }
  95.  
  96. void main()
  97. {
  98.         int key, btn;
  99.         int half_scroll_size;
  100.         int scroll_used=0, show_menu;
  101.        
  102.         mem_Init();
  103.         CursorPointer.Load(#CursorFile);
  104.         if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
  105.         if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
  106.         if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
  107.         if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
  108.         LoadSkin();
  109.        
  110.         Form.width=WIN_W;
  111.         Form.height=WIN_H;
  112.         SetElementSizes();
  113.         if (!URL) strcpy(#URL, URL_SERVICE_HOME);
  114.         OpenPage();
  115.  
  116.         SetEventMask(0xa7);
  117.         loop()
  118.         {
  119.                 WaitEventTimeout(2);
  120.                 switch(EAX & 0xFF)
  121.                 {
  122.                         CASE evMouse:
  123.                                 if (!CheckActiveProcess(Form.ID)) break;
  124.                                 //Edit URL
  125.                                 edit_box_mouse stdcall (#address_box);
  126.                                 m.get();
  127.                                 //Links hover
  128.                                 if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
  129.                                 //Menu
  130.                                 if (m.y>WB1.list.y) && (m.y<Form.height) && (bufsize)
  131.                                 {
  132.                                         if (m.pkm)
  133.                                         {
  134.                                                 show_menu = 1;
  135.                                         }
  136.                                         if (!m.pkm) && (show_menu)
  137.                                         {
  138.                                                 show_menu = 0;
  139.                                                 SwitchToAnotherThread();
  140.                                                 CreateThread(#menu_rmb,#stak+4092);
  141.                                                 break;
  142.                                         }
  143.                                 }
  144.                                 //Mouse scroll
  145.                                 if (m.vert)
  146.                                 {
  147.                                         if (WB1.list.MouseScroll(m.vert)) WB1.Parse();
  148.                                 }
  149.                                 //Drag scroller
  150.                                 scroll_wv.all_redraw = 0;
  151.                                 if (!m.lkm) scroll_used=0;
  152.                                 if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x)
  153.                                 && (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y)
  154.                                 && (WB1.list.count>WB1.list.visible) && (m.lkm)
  155.                                 {
  156.                                         scroll_used=1;
  157.                                 }                              
  158.                                 if (scroll_used)
  159.                                 {
  160.                                         half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
  161.                                         if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y;
  162.                                         btn=WB1.list.first;
  163.                                         WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
  164.                                         if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
  165.                                         if (btn<>WB1.list.first) WB1.Parse();
  166.                                 }
  167.                                 break;
  168.                         case evButton:
  169.                                 btn=GetButtonID();
  170.                                 if (btn==1)     ExitProcess();
  171.                                 Scan(btn);
  172.                                 break;
  173.                         case evKey:
  174.                                 key = GetKey();
  175.                                
  176.                                 if (address_box.flags & 0b10) SWITCH(key)
  177.                                         { CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
  178.  
  179.                                 Scan(key);
  180.                                
  181.                                 _EDIT_MARK:
  182.                                 if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
  183.                                 break;
  184.                         case evReDraw:
  185.                                 if (action_buf) Scan(action_buf);
  186.                                 Draw_Window();
  187.                                 break;
  188.                                
  189.                         case evNetwork:
  190.                                 if (http_transfer > 0) {
  191.                                         http_process stdcall (http_transfer);
  192.                                         $push EAX
  193.                                         ESI = http_transfer;
  194.                                         progress_bar.max = ESI.http_msg.content_length;
  195.                                         progress_bar.value = ESI.http_msg.content_received;
  196.                                         progressbar_draw stdcall(#progress_bar);
  197.                                         $pop EAX
  198.                                         if (EAX == 0) {
  199.                                                 ESI = http_transfer;
  200.                                                 // Handle redirects
  201.                                                 if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
  202.                                                 {
  203.                                                         redirected++;
  204.                                                         if (redirected<=5)
  205.                                                         {
  206.                                                                 http_find_header_field stdcall (http_transfer, #str_location);
  207.                                                                 if (EAX!=0) {
  208.                                                                         ESI = EAX;
  209.                                                                         EDI = #URL;
  210.                                                                         do {
  211.                                                                                 $lodsb;
  212.                                                                                 $stosb;
  213.                                                                         } while (AL != 0) && (AL != 13) && (AL != 10));
  214.                                                                         DSBYTE[EDI-1]='\0';
  215.                                                                 }
  216.                                                         }
  217.                                                         else
  218.                                                         {
  219.                                                         //TODO: display error (too many redirects)
  220.                                                         }
  221.                                                 }
  222.                                                 else
  223.                                                 {
  224.                                                         redirected = 0;
  225.                                                 }
  226.                                                 // Loading the page is complete, free resources
  227.                                                 if (redirected>0)
  228.                                                 {
  229.                                                         http_free stdcall (http_transfer);
  230.                                                         http_transfer=0;
  231.                                                         WB1.GetNewUrl();
  232.                                                         strcpy(#editURL, #URL);
  233.                                                         BrowserHistory.current--;
  234.                                                         OpenPage();
  235.                                                 }
  236.                                                 else
  237.                                                 {
  238.                                                         ESI = http_transfer;
  239.                                                         bufpointer = ESI.http_msg.content_ptr;
  240.                                                         bufsize = ESI.http_msg.content_received;
  241.                                                         http_free stdcall (http_transfer);
  242.                                                         http_transfer=0;
  243.                                                         SetPageDefaults();
  244.                                                         Draw_Window();          // stop button => refresh button
  245.                                                 }
  246.                                         }
  247.                                 }
  248.                 }
  249.         }
  250. }
  251.  
  252. void SetElementSizes()
  253. {
  254.         address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
  255.         address_box.width = Form.cwidth - address_box.left - 25 - 22;
  256.         WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 10);
  257.         WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
  258.         WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
  259.         WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
  260. }
  261.  
  262. void Draw_Window()
  263. {
  264.         int img_off;
  265.         DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0);
  266.         GetProcessInfo(#Form, SelfInfo);
  267.         if (Form.status_window>2) { DrawTitle(#header); return; }
  268.         if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
  269.         if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
  270.         // tab {
  271.         DrawBar(0, 0, TAB_W, TAB_H+1, panel_color);
  272.         WriteText(5, 7, 0x80, 0xfdfdFd, "Index.htm");
  273.         WriteText(4, 6, 0x80, 0, "Index.htm");
  274.         // }
  275.         DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg);
  276.         DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color);
  277.         DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-2, panel_color);
  278.         DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
  279.         img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0);
  280.  
  281.         SetElementSizes();
  282.         DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color);
  283.         DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color);
  284.         // < / >
  285.         DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, 300+BT_HIDE, 0);
  286.         DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, 301+BT_HIDE, 0);
  287.         img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0);
  288.         // refrash
  289.         DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0);
  290.         if (http_transfer > 0) img_off = 131; else img_off = 52;
  291.         img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0);
  292.         // config
  293.         DefineButton(Form.cwidth-23, address_box.top-2, 17, skin.h-1, 312+BT_HIDE, 0);
  294.         img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-2, 16, skin.h, 85, 0);    
  295.  
  296.         ShowPage();
  297.         DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
  298.         //status bar
  299.         DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
  300.         DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
  301.         progress_bar.top = Form.cheight - STATUSBAR_H + 4;
  302.         progressbar_draw stdcall(#progress_bar);
  303. }
  304.  
  305.  
  306. void ChangeCharset(byte new_charset)
  307. {
  308.         BufEncode(new_charset);
  309.         WB1.Parse();   
  310. }
  311.  
  312. void Scan(int id)
  313. {
  314.         action_buf=0;
  315.         if (id >= 400)
  316.         {
  317.                 ProcessLinks(id);
  318.                 return;
  319.         }
  320.         switch (id)
  321.         {
  322.                 case 011: //Ctrk+K
  323.                         ChangeCharset(_KOI);
  324.                         return;
  325.  
  326.                 case 021: //Ctrl+U
  327.                         ChangeCharset(_UTF);
  328.                         return;
  329.  
  330.                 case 004: //Ctrl+D
  331.                         ChangeCharset(_DOS);
  332.                         return;
  333.  
  334.                 case 005: //Win encoding
  335.                         ChangeCharset(_WIN);
  336.                         return;
  337.  
  338.                 case 009: //free img cache
  339.                         ImgCache.Free();
  340.                         notify(IMAGES_CACHE_CLEARED);
  341.                         WB1.Parse();
  342.                         return;
  343.  
  344.                 case 003: //history
  345.                         strcpy(#URL, URL_SERVICE_HISTORY);
  346.                         OpenPage();
  347.                         return;
  348.  
  349.                 case BACK:
  350.                         if (!BrowserHistory.GoBack()) return;
  351.                         OpenPage();
  352.                         return;
  353.                 case FORWARD:
  354.                         if (!BrowserHistory.GoForward()) return;
  355.                         OpenPage();
  356.                         return;
  357.                 case 052:  //F3
  358.                         if (strncmp(#URL,"http:",5)==0)
  359.                         {
  360.                                 WriteFile(bufsize, bufpointer, "/tmp0/1/webview.tmp");
  361.                                 if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/webview.tmp");
  362.                         }
  363.                         else
  364.                         {
  365.                                 RunProgram("/rd/1/tinypad", #URL);
  366.                         }
  367.                         return;
  368.                 case 054: //F5
  369.                         IF(address_box.flags & 0b10) WB1.Parse();
  370.                         return;
  371.  
  372.                 case REFRESH:
  373.                         if (http_transfer > 0)
  374.                         {
  375.                                 StopLoading();
  376.                                 Draw_Window();
  377.                         }
  378.                         else OpenPage();
  379.                         return;
  380.                 case 014:
  381.                 case 020:
  382.                 case NEWTAB:
  383.                         MoveSize(190,80,OLD,OLD);
  384.                         RunProgram(#program_path, #URL);
  385.                         return;
  386.                        
  387.                 case HOME:
  388.                         strcpy(#editURL, "http://kolibrios.org/");
  389.                 case GOTOURL:
  390.                 case 0x0D: //enter
  391.                         if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
  392.                         strcat(#URL, #editURL);
  393.                         OpenPage();
  394.                         return;
  395.                 case SEARCHWEB:
  396.                         strcpy(#URL, #search_path);
  397.                         strcat(#URL, #editURL);
  398.                         OpenPage();
  399.                         return;
  400.  
  401.                 case 183: //PgDown
  402.                         if (WB1.list.count < WB1.list.visible) return;
  403.                         IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
  404.                         WB1.list.first += WB1.list.visible + 2;
  405.                         IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
  406.                         WB1.Parse();
  407.                         return;
  408.  
  409.                 case 184: //PgUp
  410.                         if (WB1.list.count < WB1.list.visible) return;
  411.                         IF(WB1.list.first == 0) return;
  412.                         WB1.list.first -= WB1.list.visible - 2;
  413.                         IF(WB1.list.first < 0) WB1.list.first = 0;
  414.                         WB1.Parse();
  415.                         return;
  416.  
  417.                 case 178:
  418.                 case BTN_UP:
  419.                         if (WB1.list.first <= 0) return;
  420.                         WB1.list.first--;
  421.                         WB1.Parse();
  422.                         return;
  423.  
  424.                 case 177:
  425.                 case BTN_DOWN:
  426.                         if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
  427.                         WB1.list.first++;
  428.                         WB1.Parse();
  429.                         return;
  430.  
  431.                 case 180: //home
  432.                         if (WB1.list.KeyHome()) WB1.Parse();
  433.                         return;
  434.  
  435.                 case 181: //end
  436.                         if (WB1.list.count < WB1.list.visible) return;
  437.                         if (WB1.list.KeyEnd()) WB1.Parse();
  438.                         return;
  439.                 case 312:
  440.                         SwitchToAnotherThread();
  441.                         m.y = TOOLBAR_H-6;
  442.                         m.x = Form.cwidth - 167;
  443.                         CreateThread(#menu_rmb,#stak+4092);
  444.         }
  445. }
  446.  
  447.  
  448.  
  449. void ProcessLinks(int id)
  450. {
  451.         strcpy(#URL, PageLinks.GetURL(id-401));
  452.         //$1 - Condition Script
  453.         if (URL[0] == '$')
  454.         {
  455.                 if (URL[1]=='-') && (condition_href) condition_href--;
  456.                 if (URL[1]=='+')
  457.                 {
  458.                         if (condition_href<condition_max) condition_href++; else notify(T_LAST_SLIDE);
  459.                 }
  460.                 if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1);
  461.                 strcpy(#URL, BrowserHistory.CurrentUrl());
  462.                 ShowPage();
  463.                 return;
  464.         }
  465.         //#1
  466.         if (URL[0] == '#')
  467.         {
  468.                 strcpy(#anchor, #URL+strrchr(#URL, '#'));              
  469.                 strcpy(#URL, BrowserHistory.CurrentUrl());
  470.                 WB1.list.first=WB1.list.count-WB1.list.visible;
  471.                 ShowPage();
  472.                 return;
  473.         }
  474.         //liner.ru#1
  475.         if (strrchr(#URL, '#')!=-1)
  476.         {
  477.                 strcpy(#anchor, #URL+strrchr(#URL, '#'));
  478.                 URL[strrchr(#URL, '#')-1] = 0x00;
  479.         }
  480.        
  481.         WB1.GetNewUrl();
  482.        
  483.         if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
  484.         {
  485.                 //if (strstr(#URL,"http:"))
  486.                 RunProgram("/sys/media/kiv", #URL);
  487.                 strcpy(#editURL, BrowserHistory.CurrentUrl());
  488.                 strcpy(#URL, BrowserHistory.CurrentUrl());
  489.                 return;
  490.         }
  491.         if (!strcmpn(#URL,"mailto:", 7))
  492.         {
  493.                 notify(#URL);
  494.                 strcpy(#editURL, BrowserHistory.CurrentUrl());
  495.                 strcpy(#URL, BrowserHistory.CurrentUrl());
  496.                 return;
  497.         }
  498.         OpenPage();
  499.         return;
  500. }
  501.  
  502. void StopLoading()
  503. {
  504.         if (http_transfer<>0)
  505.         {
  506.                 EAX = http_transfer;
  507.                 EAX = EAX.http_msg.content_ptr;         // get pointer to data
  508.                 $push   EAX                                                     // save it on the stack
  509.                 http_free stdcall (http_transfer);      // abort connection
  510.                 $pop    EAX                                                    
  511.                 mem_Free(EAX);                                          // free data
  512.                 http_transfer=0;
  513.                 bufsize = 0;
  514.                 bufpointer = mem_Free(bufpointer);
  515.         }
  516.         progress_bar.value = 0;
  517.         img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0);
  518. }
  519.  
  520. void SetPageDefaults()
  521. {
  522.         strcpy(#header, #version);
  523.         pre_text = 0;
  524.         WB1.list.count = WB1.list.first = 0;
  525.         stroka = 0;
  526.         cur_encoding = _DEFAULT;
  527.         if (o_bufpointer) o_bufpointer = free(o_bufpointer);
  528.         anchor_line_num=WB1.list.first;
  529.         anchor[0]='|';
  530. }
  531.  
  532. void OpenPage()
  533. {
  534.         StopLoading();
  535.         strcpy(#editURL, #URL);
  536.         BrowserHistory.AddUrl();
  537.         if (strncmp(#URL,"WebView:",8)==0) return;
  538.         if (strncmp(#URL,"http:",5)==0)
  539.         {
  540.                 img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0);
  541.                 http_get stdcall (#URL, #accept_language);
  542.                 http_transfer = EAX;
  543.                 if (http_transfer == 0)
  544.                 {
  545.                         StopLoading();
  546.                         bufsize = 0;
  547.                         bufpointer = mem_Free(bufpointer);
  548.                         ShowPage();
  549.                         return;
  550.                 }
  551.         }
  552.         else
  553.         {
  554.                 file_size stdcall (#URL);
  555.                 bufsize = EBX;
  556.                 if (bufsize)
  557.                 {
  558.                         bufpointer = mem_Free(bufpointer);
  559.                         bufpointer = mem_Alloc(bufsize);
  560.                         SetPageDefaults();
  561.                         ReadFile(0, bufsize, bufpointer, #URL);                        
  562.                 }
  563.                 ShowPage();
  564.         }
  565. }
  566.  
  567. void ShowPage()
  568. {
  569.         address_box.size = address_box.pos = strlen(#editURL);
  570.         address_box.offset=0;
  571.         edit_box_draw stdcall(#address_box);
  572.  
  573.         if (strcmp(#URL, URL_SERVICE_HOME)==0) WB1.Prepare(#homepage, sizeof(homepage)); else
  574.         if (strcmp(#URL, URL_SERVICE_HISTORY)==0) ShowHistory(); else
  575.         if (!bufsize)
  576.         {
  577.                 PageLinks.Clear();
  578.                 if (http_transfer<>0)
  579.                 {
  580.                         WB1.Prepare(#loading, sizeof(loading));
  581.                 }
  582.                 else
  583.                         WB1.Prepare(#page_not_found, sizeof(page_not_found));
  584.         }
  585.         else
  586.                 WB1.Parse();
  587.  
  588.         if (!header) strcpy(#header, #version);
  589.         if (!strcmp(#version, #header)) DrawTitle(#header);
  590. }
  591.  
  592.  
  593.  
  594.  
  595. stop:
  596.