diff --git a/programs/cmm/TWB/absolute_url.h b/programs/cmm/TWB/absolute_url.h
index f29d0955e2..eba0212868 100644
--- a/programs/cmm/TWB/absolute_url.h
+++ b/programs/cmm/TWB/absolute_url.h
@@ -1,24 +1,4 @@
-int UrlIsAbsolute(dword in)
-{
- if(!strncmp(in,"http:",5)) return true;
- if(!strncmp(in,"https:",6)) return true;
- if(!strncmp(in,"file:",5)) return true;
- if(!strncmp(in,"mailto:",7)) return true;
- if(!strncmp(in,"ftp:",4)) return true;
- if(!strncmp(in,"WebView:",8)) return true;
- if(!strncmp(in,"/sys/",5)) return true;
- if(!strncmp(in,"/hd/",4)) return true;
- if(!strncmp(in,"/fd/",4)) return true;
- if(!strncmp(in,"/rd/",4)) return true;
- if(!strncmp(in,"/tmp/",5)) return true;
- if(!strncmp(in,"/cd/",4)) return true;
- if(!strncmp(in,"/bd/",4)) return true;
- if(!strncmp(in,"/usbhd/",7)) return true;
- if(!strncmp(in,"/kolibrios/",11)) return true;
- return false;
-}
-
void GetAbsoluteURL(dword in_URL)
{
int i;
@@ -30,7 +10,7 @@ void GetAbsoluteURL(dword in_URL)
strcpy(i+1, i+5);
}
- if (UrlIsAbsolute(in_URL)) return;
+ if (check_is_the_url_absolute(in_URL)) return;
IF (!strcmpn(in_URL,"//", 2))
{
diff --git a/programs/cmm/TWB/links.h b/programs/cmm/TWB/links.h
index 8ac01f958b..45cb0659de 100644
--- a/programs/cmm/TWB/links.h
+++ b/programs/cmm/TWB/links.h
@@ -88,6 +88,7 @@ bool LinksArray::HoverAndProceed(dword mx, my)
return false;
}
if (active==i) return false;
+ CursorPointer.Load(#CursorFile);
CursorPointer.Set();
if (links[active].underline) DrawBar(links[active].x, -WB1.list.first + links[active].y
+ links[active].h, links[active].w, links[active].underline_h, link_color_inactive);
diff --git a/programs/cmm/TWB/parce_tag.h b/programs/cmm/TWB/parce_tag.h
index a17931609a..4bdde29a2f 100644
--- a/programs/cmm/TWB/parce_tag.h
+++ b/programs/cmm/TWB/parce_tag.h
@@ -1,4 +1,81 @@
-unsigned int GetNextParam()
+bool GetNextParam() {
+ if (!old_tag_parser_mode)
+ return GetNextParam_NEW();
+ else
+ return GetNextParam_OLD();
+}
+
+bool GetNextParam_NEW()
+{
+ byte quotes = NULL;
+ int i;
+
+ if (!tagparam) return false;
+
+ if (debug_mode) {
+ debug("tagparam: "); debugln(#tagparam);
+ }
+
+ i = strlen(#tagparam) - 1;
+
+ if (tagparam[i] == '/') i--;
+
+ while (i>0) && (__isWhite(tagparam[i])) i--;
+
+ if (tagparam[i] == '"') || (tagparam[i] == '\'')
+ {
+ //find VAL end
+ quotes = tagparam[i];
+ tagparam[i] = '\0'; i--;
+
+ //find VAL start and copy
+ i = strrchr(#tagparam, quotes);
+ strlcpy(#val, #tagparam + i, sizeof(val));
+ tagparam[i] = '\0'; i--;
+
+ //find ATTR end
+ while (i > 0) && (tagparam[i] != '=') i--;
+ tagparam[i+1] = '\0';
+ }
+ else
+ {
+ //find VAL end
+ //already have
+
+ //find VAL start and copy
+ while (i > 0) && (tagparam[i] != '=') i--;
+ i++;
+ strlcpy(#val, #tagparam + i, sizeof(val));
+ tagparam[i] = '\0';
+
+ //find ATTR end
+ //already have
+ }
+
+ //find ATTR start and copy
+ while (i>0) && (!__isWhite(tagparam[i])) i--;
+ strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
+ tagparam[i] = '\0';
+
+ strlwr(#attr);
+
+ if (debug_mode) {
+ if (quotes) {
+ debug("quote: "); debugch(quotes); debugln(" ");
+ }
+ else {
+ debugln("unquoted text");
+ }
+ sprintf(#param, "val: %s\nattr: %s\n\n", #val, #attr);
+ debug(#param);
+ }
+
+ return true;
+}
+
+
+
+unsigned int GetNextParam_OLD()
{
byte kavichki=0;
int i = strlen(#tagparam) - 1;
@@ -30,7 +107,7 @@ unsigned int GetNextParam()
FOR ( ; ((tagparam[i] <>' ') && (i > 0); i--)
{
- IF (tagparam[i] == '=') //фхЁчър чруыє°ър
+ IF (tagparam[i] == '=') //dirty fix (kludge)
tagparam[i + 1] = 0x00;
}
strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
diff --git a/programs/cmm/TWB/unicode_tags.h b/programs/cmm/TWB/unicode_tags.h
index 36363484db..b6421f13db 100644
--- a/programs/cmm/TWB/unicode_tags.h
+++ b/programs/cmm/TWB/unicode_tags.h
@@ -58,7 +58,7 @@ char *unicode_tags[]={
"#1031", "\244",
"#8470", "N",
-"bull", "-", //тююс∙х чфхё№ Єюўър
+"bull", "\31", //тююс∙х чфхё№ Єюўър
"percnt","%",
0};
diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c
index c1d6902b76..376bcd3068 100644
--- a/programs/cmm/browser/WebView.c
+++ b/programs/cmm/browser/WebView.c
@@ -32,7 +32,7 @@ _http http = {0, 0, 0, 0, 0, 0, 0};
char homepage[] = FROM "html\\homepage.htm""\0";
#ifdef LANG_RUS
-char version[]="Текстовый браузер 1.74";
+char version[]="Текстовый браузер 1.8";
?define IMAGES_CACHE_CLEARED "Кэш картинок очищен"
?define T_LAST_SLIDE "Это последний слайд"
char loading[] = "Загрузка страницы...
";
@@ -47,7 +47,7 @@ char link_menu[] =
"Копировать ссылку
Скачать содержимое ссылки";
#else
-char version[]="Text-based Browser 1.74";
+char version[]="Text-based Browser 1.8";
?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...
";
@@ -83,6 +83,9 @@ dword col_bg;
dword panel_color;
dword border_color;
+bool debug_mode = false;
+bool old_tag_parser_mode = false;
+
progress_bar wv_progress_bar;
bool souce_mode = false;
bool open_in_a_new_window = false;
@@ -98,7 +101,7 @@ enum {
VIEW_HISTORY,
//FREE_IMG_CACHE,
DOWNLOAD_MANAGER,
- COPY_LINK=1200,
+ COPY_LINK_URL=1200,
DOWNLOAD_LINK_CONTENTS,
};
@@ -114,7 +117,6 @@ edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000
void main()
{
- CursorPointer.Load(#CursorFile);
load_dll(boxlib, #box_lib_init,0);
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1);
@@ -132,15 +134,12 @@ void main()
case evMouse:
edit_box_mouse stdcall (#address_box);
mouse.get();
- if (WB1.list.MouseOver(mouse.x, mouse.y))
- {
- if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
- && (bufsize) && (mouse.pkm) && (mouse.up) {
- EventShowPageMenu(mouse.x, mouse.y);
- break;
- }
- if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
+ if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
+ && (bufsize) && (mouse.pkm) && (mouse.up) {
+ if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y);
+ break;
}
+ if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
scrollbar_v_mouse (#scroll_wv);
if (WB1.list.first != scroll_wv.position)
{
@@ -192,51 +191,31 @@ void main()
if (http.status_code >= 300) && (http.status_code < 400)
{
redirected++;
- if (redirected<=5)
+ if (redirected>5)
{
- if (http.handle_redirect()) {
- if (!strncmp(#URL,"https://",8))
- {
- history.back();
- strcpy(#editURL, history.current());
- strcpy(#URL, history.current());
- ShowErrorMessageThatHttpsIsNotSupportedYet();
- StopLoading();
- break;
- }
- }
+ notify("'Too many redirects.' -E");
+ StopLoading();
}
else
{
- notify("Too many redirects");
- StopLoading();
- break;
+ http.handle_redirect();
+ http.free();
+ GetAbsoluteURL(#http.redirect_url);
+ history.back();
+ strcpy(#editURL, #URL);
+ DrawEditBoxWebView();
+ OpenPage();
}
+ break;
}
- else
- {
- redirected = 0;
- }
+ redirected = 0;
// Loading the page is complete, free resources
- if (redirected>0)
- {
- http.free();
- GetAbsoluteURL(#URL);
- history.back();
- strcpy(#editURL, #URL);
- DrawEditBoxWebView();
- OpenPage();
- }
- else
- {
- history.add(#URL);
- ESI = http.transfer;
- bufpointer = ESI.http_msg.content_ptr;
- bufsize = ESI.http_msg.content_received;
- http.free();
- SetPageDefaults();
- ShowPage();
- }
+ history.add(#URL);
+ bufpointer = http.content_pointer;
+ bufsize = http.content_received;
+ http.free();
+ SetPageDefaults();
+ ShowPage();
}
}
}
@@ -275,7 +254,12 @@ void Draw_Window()
img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 87, 0);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
- if (!header) OpenPage(); else { WB1.DrawPage(); DrawEditBoxWebView(); }
+ if (!header)
+ OpenPage();
+ else {
+ WB1.DrawPage();
+ DrawEditBoxWebView();
+ }
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
DrawProgress();
}
@@ -303,7 +287,10 @@ void ProcessEvent(dword id__)
return;
case GOTOURL_BUTTON:
case SCAN_CODE_ENTER:
- if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
+ if (!editURL[0]) {
+ strcpy(#URL, URL_SERVICE_HOME);
+ }
+ else if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
{
strcpy(#URL, #editURL);
@@ -334,7 +321,7 @@ void ProcessEvent(dword id__)
WB1.LoadInternalPage(bufpointer, bufsize);
break;
case EDIT_SOURCE:
- if (!strncmp(#URL,"http:",5))
+ if (!strncmp(#URL,"http",4))
{
CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
@@ -356,7 +343,7 @@ void ProcessEvent(dword id__)
CreateThread(#Downloader,#downloader_stak+4092);
}
return;
- case COPY_LINK:
+ case COPY_LINK_URL:
Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
notify("'URL copied to clipboard'O");
return;
@@ -366,6 +353,16 @@ void ProcessEvent(dword id__)
CreateThread(#Downloader,#downloader_stak+4092);
}
return;
+ case SCAN_CODE_F12:
+ debug_mode ^= 1;
+ if (debug_mode) notify("'Debug mode ON'-I");
+ else notify("'Debug mode OFF'-I");
+ return;
+ case SCAN_CODE_F11:
+ old_tag_parser_mode ^= 1;
+ if (old_tag_parser_mode) notify("'Old tag parser ON'-I");
+ else notify("'Old tag parser OFF'-I");
+ return;
}
}
@@ -397,6 +394,7 @@ void SetPageDefaults()
void OpenPage()
{
+ char getUrl[sizeof(URL)];
StopLoading();
souce_mode = false;
strcpy(#editURL, #URL);
@@ -409,10 +407,18 @@ void OpenPage()
DrawEditBoxWebView();
return;
}
- if (!strncmp(#URL,"http:",5))
+ if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8))
{
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
- http.get(#URL);
+
+ if (!strncmp(#URL,"http:",5)) {
+ http.get(#URL);
+ }
+ if (!strncmp(#URL,"https://",8)) {
+ sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL);
+ http.get(#getUrl);
+ }
+ //http.get(#URL);
if (!http.transfer)
{
StopLoading();
@@ -452,7 +458,6 @@ DrawEditBoxWebView()
void ShowPage()
{
DrawEditBoxWebView();
- debugval("bufsize", bufsize);
if (!bufsize)
{
if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
@@ -486,10 +491,10 @@ int SetSkinColors()
void DrawProgress()
{
- unsigned long btn;
+ dword persent;
if (http.transfer == 0) return;
- if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
- DrawBar(address_box.left-2, address_box.top+20, btn, 2, wv_progress_bar.progress_color);
+ if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10;
+ DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color);
}
@@ -501,8 +506,7 @@ void ClickLink()
StopLoading();
history.back();
}
-
- strcpy(#URL, PageLinks.GetURL(PageLinks.active));
+ strcpy(#URL, PageLinks.GetURL(PageLinks.active));
//#1
if (URL[0] == '#')
{
@@ -532,17 +536,9 @@ void ClickLink()
return;
}
- if (!strncmp(#URL,"https://",8))
- {
- ShowErrorMessageThatHttpsIsNotSupportedYet();
- strcpy(#editURL, history.current());
- strcpy(#URL, history.current());
- return;
- }
-
GetAbsoluteURL(#URL);
- if (strncmp(#URL,"http://",7)!=0)
+ if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0)
{
if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true)
{
@@ -587,7 +583,7 @@ void EventShowPageMenu(dword _left, _top)
void EventShowLinkMenu(dword _left, _top)
{
- menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK);
+ menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL);
}
void EventUpdateProgressBar()
@@ -600,12 +596,6 @@ void EventUpdateProgressBar()
}
}
-
-void ShowErrorMessageThatHttpsIsNotSupportedYet()
-{
- notify("'HTTPS protocol is not supported yet' -E");
-}
-
DrawStatusBar(dword _status_text)
{
status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
diff --git a/programs/cmm/browser/download_manager.h b/programs/cmm/browser/download_manager.h
index b83a060f8b..57643d1df1 100644
--- a/programs/cmm/browser/download_manager.h
+++ b/programs/cmm/browser/download_manager.h
@@ -73,10 +73,10 @@ void Downloader()
default:
if (!downloader.MonitorProgress()) break;
- pb.max = downloader.data_full_size;
- if (pb.value != downloader.data_downloaded_size)
+ pb.max = downloader.httpd.content_length;
+ if (pb.value != downloader.httpd.content_received)
{
- pb.value = downloader.data_downloaded_size;
+ pb.value = downloader.httpd.content_received;
progressbar_draw stdcall(#pb);
DrawDownloading();
}
@@ -153,7 +153,7 @@ void StartDownloading()
void DrawDownloading()
{
char bytes_received[70];
- sprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.data_downloaded_size) );
+ sprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.httpd.content_received) );
DrawBar(15, pb.top + 22, strlen(#bytes_received+4)*12, 16, system.color.work);
WriteText(15, pb.top + 22, 0x90, system.color.work_text, #bytes_received);
progressbar_draw stdcall(#pb);
@@ -182,7 +182,7 @@ void SaveDownloadedFile()
for (i=0; i= 300) && (httpd.status_code < 400)
{
httpd.handle_redirect();
strcpy(url, httpd.url);
- get_absolute_url(#finaladress, url, #redirect_url);
+ get_absolute_url(#httpd.finaladress, url, #httpd.redirect_url);
Stop();
- Start(#finaladress);
- url = #finaladress;
+ Start(#httpd.finaladress);
+ url = #httpd.finaladress;
return false;
}
- Completed();
+ state = STATE_COMPLETED;
+ bufpointer = httpd.content_pointer;
+ bufsize = httpd.content_received;
+ httpd.free();
}
return true;
}
@@ -191,8 +180,6 @@ int check_is_the_url_absolute(dword _in)
void get_absolute_url(dword _rez, _base, _new)
{
int i;
- debug("_base:");debugln(_base);
- debug("_new:");debugln(_new);
//case: ./valera.html
if (!strncmp(_new,"./", 2)) _new+=2;
//case: http://site.name
@@ -222,5 +209,4 @@ void get_absolute_url(dword _rez, _base, _new)
strcat(_rez, _new);
_GET_ABSOLUTE_URL_END:
while (i=strstr(_rez, "&")) strcpy(i+1, i+5);
- debug("_rez:");debugln(_rez);
}