From af8dd86a4a64cd0c29702ba132d1a981924681c5 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 27 Jan 2014 02:16:25 +0000 Subject: [PATCH] Liza: integration TWB part #2 git-svn-id: svn://kolibrios.org@4534 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 29 +++++++++---------- programs/cmm/browser/HTMLv.c | 35 +++++++++++++++++++---- programs/cmm/liza/mail_box.c | 5 ++-- programs/cmm/liza/parselist.c | 54 ----------------------------------- 4 files changed, 44 insertions(+), 79 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index b5d1091abd..051124af4b 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -1,19 +1,16 @@ #include "..\TWB\links.h" -int downloader_id; dword buf; dword filesize; #define URL param -int mouse_twb; -edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; -char editURL[sizeof(URL)]; char header[2048]; +int downloader_id; char download_path[]="/rd/1/.download"; @@ -105,9 +102,9 @@ void TWebBrowser::DrawPage() char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0}; -//dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){ void TWebBrowser::GetNewUrl(){ int i, len; + char newurl[4096]; for (i=0; ABSOLUTE_LINKS[i]; i++) { @@ -115,34 +112,34 @@ void TWebBrowser::GetNewUrl(){ if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return; } - IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //шуэюЁшь :) - strcpy(#editURL, BrowserHistory.CurrentUrl()); //фюёЄр╕ь рфЁхё Єхъє∙хщ ёЄЁрэшЎ√ + IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); + strcpy(#newurl, BrowserHistory.CurrentUrl()); if (URL[0] == '/') { - i = strchr(#editURL+8, '/'); - editURL[i+7]=0; + i = strchr(#newurl+8, '/'); + newurl[i+7]=0; strcpy(#URL, #URL+1); } _CUT_ST_LEVEL_MARK: - if (editURL[strrchr(#editURL, '/')-2]<>'/') // хёыш эх http:// + if (newurl[strrchr(#newurl, '/')-2]<>'/') { - editURL[strrchr(#editURL, '/')] = 0x00; //юсЁхчрхь х╕ єЁы фю яюёыхфэхую / + newurl[strrchr(#newurl, '/')] = 0x00; } - IF (!strncmp(#URL,"../",3)) //эр єЁютхэ№ ттхЁї + IF (!strncmp(#URL,"../",3)) { strcpy(#URL,#URL+3); - editURL[strrchr(#editURL, '/')-1] = 0x00; //юсЁхчрхь х╕ єЁы фю яюёыхфэхую / + newurl[strrchr(#newurl, '/')-1] = 0x00; goto _CUT_ST_LEVEL_MARK; } - if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/"); + if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/"); - strcat(#editURL, #URL); //ъыхшь эют√щ рфЁхё - strcpy(#URL, #editURL); + strcat(#newurl, #URL); + strcpy(#URL, #newurl); } diff --git a/programs/cmm/browser/HTMLv.c b/programs/cmm/browser/HTMLv.c index a49de4dc04..433cef6ccc 100644 --- a/programs/cmm/browser/HTMLv.c +++ b/programs/cmm/browser/HTMLv.c @@ -29,13 +29,19 @@ #include "img\URLgoto.txt"; #ifdef LANG_RUS - char version[]=" Текстовый браузер 0.99.64"; + char version[]=" Текстовый браузер 0.99.65"; ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" ?define T_LAST_SLIDE "Это последний слайд" + char loading[] = "Loading..."; + char page_not_found[] = "Страница не найдена. Воможно, URL содержит ошибку."; + char page_not_found_no_internet[] = "Страница не найдена. Воможно, URL содержит ошибку.
Или нет доступа в Интернеты."; #else - char version[]=" Text-based Browser 0.99.64"; + char version[]=" Text-based Browser 0.99.65"; ?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define T_LAST_SLIDE "This slide is the last" + char loading[] = "Loading..."; + char page_not_found[] = "Page not found. Maybe, URL contains some errors."; + char page_not_found_no_internet[] = "Page not found. Maybe, URL contains some errors.
Or Internet unavailable for your configuration."; #endif proc_info Form; @@ -48,9 +54,15 @@ char stak[4096]; mouse m; int action_buf; + #include "..\TWB\TWB.c" #include "menu_rmb.h" +char editURL[sizeof(URL)]; +int mouse_twb; +edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; + + enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN }; @@ -421,12 +433,23 @@ void ShowPage() if (!filesize) { PageLinks.Clear(); - DrawBar(WB1.list.x, WB1.list.y, WB1.list.w+scroll_wv.size_x+1, WB1.list.h, 0xFFFFFF); //fill all - if (GetProcessSlot(downloader_id)<>0) WriteText(WB1.list.x + 10, WB1.list.y + 18, 0x80, 0, "Loading..."); + if (GetProcessSlot(downloader_id)<>0) + { + filesize = sizeof(loading); + WB1.ParseHTML(#loading); + } else { - WriteText(WB1.list.x + 10, WB1.list.y + 18, 0x80, 0, "Page not found. May be, URL contains some errors."); - if (!strncmp(#URL,"http:",5)) WriteText(WB1.list.x + 10, WB1.list.y + 32, 0x80, 0, "Or Internet unavilable for your configuration."); + if (strncmp(#URL,"http:",5)==0) + { + filesize = sizeof(page_not_found_no_internet); + WB1.ParseHTML(#page_not_found_no_internet); + } + else + { + filesize = sizeof(page_not_found); + WB1.ParseHTML(#page_not_found); + } } //return; } diff --git a/programs/cmm/liza/mail_box.c b/programs/cmm/liza/mail_box.c index 31148f6b5a..191ef8d52b 100644 --- a/programs/cmm/liza/mail_box.c +++ b/programs/cmm/liza/mail_box.c @@ -349,15 +349,14 @@ void InitTWB() { WB1.list.visible = WB1.list.h / WB1.list.line_h; WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h, WB1.list.line_h); - strcpy(#URL, "/sys/yavu.htm"); strcpy(#header, #version); pre_text = 0; WB1.list.first = WB1.list.count = 0; - WB1.ReadHtml(_WIN); } void DrawLetter() { - WB1.ParseHTML(buf); + filesize = strlen(mdata); + if (filesize) WB1.ParseHTML(mdata); } diff --git a/programs/cmm/liza/parselist.c b/programs/cmm/liza/parselist.c index 44e6bde444..33be8779da 100644 --- a/programs/cmm/liza/parselist.c +++ b/programs/cmm/liza/parselist.c @@ -43,16 +43,6 @@ void ParseMail() mdata = strstr(mailstart, "\x0a\x0d") + 3; debug("ConvertToDOS"); ConvertToDOS(mdata, mailstart); - debug("FromHTMLtoTXT"); - FromHTMLtoTXT(); - letter_view.first = letter_view.count = 0; - - line_off = mdata; - while (line_off>1) - { - line_off = GetNextLine(line_off); - letter_view.count++; - } debug("SetAtrFromCurr"); atr.SetAtrFromCurr(mail_list.current+1); DrawMailBox(); @@ -85,50 +75,6 @@ void ConvertToDOS(dword inbuf, searchin) } -void FromHTMLtoTXT() -{ - dword cur_chr, txt_buf_srt, txt_buf_end, is_tag=0; - int i; - if (strstri(mdata, "")==0) && (strstri(mailstart, "text/html")==0) {debug("no html tags found"); return;} - debug ("Mail got code"); - cur_chr = mdata; - txt_buf_srt = malloc(mailend - mailstart); - txt_buf_end = txt_buf_srt; - - while (cur_chr < mailend) - { - if (DSBYTE[cur_chr]=='<') is_tag = 1; - if (!is_tag) - { - DSBYTE[txt_buf_end] = DSBYTE[cur_chr]; - txt_buf_end++; - _END: - } - if (DSBYTE[cur_chr]=='>') is_tag = NULL; - cur_chr++; - } - DSBYTE[txt_buf_end] = '\0'; - strcpy(mdata, txt_buf_srt); - mailend = strlen(mailstart) + mailstart; - free(txt_buf_srt); -} - - -dword GetNextLine(dword start_offset) -{ - dword off_n = strstr(start_offset, "\n") + 1, //╤А╨░╨╖╤А╤Л╨▓ ╤Б╤В╤А╨╛╨║╨╕ - off_w = letter_view.w / 6 - 2 + start_offset, //max ╨┤╨╗╨╕╨╜╨╜╨░ ╤Б╨║╤А╨╛╨║╨╕ - off_m; - off_m = off_w; - if (off_n < off_w) return off_n; - while (off_m > start_offset) //╨┐╨╡╤А╨╡╨╜╨╛╤Б ╨┐╨╛ ╤Б╨╗╨╛╨▓╨░╨╝ - { - if (DSBYTE[off_m]==' ') || (DSBYTE[off_m]=='\9') || (DSBYTE[off_m]=='-') return off_m; - off_m--; - } - return off_w; -} - dword CopyBetweenOffsets(dword start, end) //do not forget to free(line) after use { dword line, new_line;