Subversion Repositories Kolibri OS

Rev

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