forked from KolibriOS/kolibrios
WebView 1.8:
1. possibility to open HTTPS sites via gate.aspero.pro (invisible for user), not working for files 2. rewrite parse tag function to fix broken URLs on page in some cases ("/user" instead of "/user/") 3. fix hand cursor appearance, fix progress bar on page load 4. load homepage on submitting empty url in adressbox 5. F12 - debug on, F11 - old tag parser on 6. unify page/file downloading code git-svn-id: svn://kolibrios.org@7282 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
e59b0f053b
commit
873fc290d5
@ -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)
|
void GetAbsoluteURL(dword in_URL)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -30,7 +10,7 @@ void GetAbsoluteURL(dword in_URL)
|
|||||||
strcpy(i+1, i+5);
|
strcpy(i+1, i+5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UrlIsAbsolute(in_URL)) return;
|
if (check_is_the_url_absolute(in_URL)) return;
|
||||||
|
|
||||||
IF (!strcmpn(in_URL,"//", 2))
|
IF (!strcmpn(in_URL,"//", 2))
|
||||||
{
|
{
|
||||||
|
@ -88,6 +88,7 @@ bool LinksArray::HoverAndProceed(dword mx, my)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (active==i) return false;
|
if (active==i) return false;
|
||||||
|
CursorPointer.Load(#CursorFile);
|
||||||
CursorPointer.Set();
|
CursorPointer.Set();
|
||||||
if (links[active].underline) DrawBar(links[active].x, -WB1.list.first + links[active].y
|
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);
|
+ links[active].h, links[active].w, links[active].underline_h, link_color_inactive);
|
||||||
|
@ -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;
|
byte kavichki=0;
|
||||||
int i = strlen(#tagparam) - 1;
|
int i = strlen(#tagparam) - 1;
|
||||||
@ -30,7 +107,7 @@ unsigned int GetNextParam()
|
|||||||
|
|
||||||
FOR ( ; ((tagparam[i] <>' ') && (i > 0); i--)
|
FOR ( ; ((tagparam[i] <>' ') && (i > 0); i--)
|
||||||
{
|
{
|
||||||
IF (tagparam[i] == '=') //äåðçêàÿ çàãëóøêà
|
IF (tagparam[i] == '=') //dirty fix (kludge)
|
||||||
tagparam[i + 1] = 0x00;
|
tagparam[i + 1] = 0x00;
|
||||||
}
|
}
|
||||||
strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
|
strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
|
||||||
|
@ -58,7 +58,7 @@ char *unicode_tags[]={
|
|||||||
"#1031", "\244",
|
"#1031", "\244",
|
||||||
|
|
||||||
"#8470", "N",
|
"#8470", "N",
|
||||||
"bull", "-", //вообще здесь точка
|
"bull", "\31", //вообще здесь точка
|
||||||
"percnt","%",
|
"percnt","%",
|
||||||
|
|
||||||
0};
|
0};
|
||||||
|
@ -32,7 +32,7 @@ _http http = {0, 0, 0, 0, 0, 0, 0};
|
|||||||
char homepage[] = FROM "html\\homepage.htm""\0";
|
char homepage[] = FROM "html\\homepage.htm""\0";
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
char version[]="’¥ªáâ®¢ë© ¡à 㧥à 1.74";
|
char version[]="’¥ªáâ®¢ë© ¡à 㧥à 1.8";
|
||||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||||
@ -47,7 +47,7 @@ char link_menu[] =
|
|||||||
"Š®¯¨à®¢ âì áá뫪ã
|
"Š®¯¨à®¢ âì áá뫪ã
|
||||||
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
|
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
|
||||||
#else
|
#else
|
||||||
char version[]="Text-based Browser 1.74";
|
char version[]="Text-based Browser 1.8";
|
||||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||||
?define T_LAST_SLIDE "This slide is the last"
|
?define T_LAST_SLIDE "This slide is the last"
|
||||||
char loading[] = "Loading...<br>";
|
char loading[] = "Loading...<br>";
|
||||||
@ -83,6 +83,9 @@ dword col_bg;
|
|||||||
dword panel_color;
|
dword panel_color;
|
||||||
dword border_color;
|
dword border_color;
|
||||||
|
|
||||||
|
bool debug_mode = false;
|
||||||
|
bool old_tag_parser_mode = false;
|
||||||
|
|
||||||
progress_bar wv_progress_bar;
|
progress_bar wv_progress_bar;
|
||||||
bool souce_mode = false;
|
bool souce_mode = false;
|
||||||
bool open_in_a_new_window = false;
|
bool open_in_a_new_window = false;
|
||||||
@ -98,7 +101,7 @@ enum {
|
|||||||
VIEW_HISTORY,
|
VIEW_HISTORY,
|
||||||
//FREE_IMG_CACHE,
|
//FREE_IMG_CACHE,
|
||||||
DOWNLOAD_MANAGER,
|
DOWNLOAD_MANAGER,
|
||||||
COPY_LINK=1200,
|
COPY_LINK_URL=1200,
|
||||||
DOWNLOAD_LINK_CONTENTS,
|
DOWNLOAD_LINK_CONTENTS,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,7 +117,6 @@ edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
CursorPointer.Load(#CursorFile);
|
|
||||||
load_dll(boxlib, #box_lib_init,0);
|
load_dll(boxlib, #box_lib_init,0);
|
||||||
load_dll(libio, #libio_init,1);
|
load_dll(libio, #libio_init,1);
|
||||||
load_dll(libimg, #libimg_init,1);
|
load_dll(libimg, #libimg_init,1);
|
||||||
@ -132,15 +134,12 @@ void main()
|
|||||||
case evMouse:
|
case evMouse:
|
||||||
edit_box_mouse stdcall (#address_box);
|
edit_box_mouse stdcall (#address_box);
|
||||||
mouse.get();
|
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) {
|
||||||
if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
|
if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y);
|
||||||
&& (bufsize) && (mouse.pkm) && (mouse.up) {
|
break;
|
||||||
EventShowPageMenu(mouse.x, mouse.y);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
|
||||||
}
|
}
|
||||||
|
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
||||||
scrollbar_v_mouse (#scroll_wv);
|
scrollbar_v_mouse (#scroll_wv);
|
||||||
if (WB1.list.first != scroll_wv.position)
|
if (WB1.list.first != scroll_wv.position)
|
||||||
{
|
{
|
||||||
@ -192,51 +191,31 @@ void main()
|
|||||||
if (http.status_code >= 300) && (http.status_code < 400)
|
if (http.status_code >= 300) && (http.status_code < 400)
|
||||||
{
|
{
|
||||||
redirected++;
|
redirected++;
|
||||||
if (redirected<=5)
|
if (redirected>5)
|
||||||
{
|
{
|
||||||
if (http.handle_redirect()) {
|
notify("'Too many redirects.' -E");
|
||||||
if (!strncmp(#URL,"https://",8))
|
StopLoading();
|
||||||
{
|
|
||||||
history.back();
|
|
||||||
strcpy(#editURL, history.current());
|
|
||||||
strcpy(#URL, history.current());
|
|
||||||
ShowErrorMessageThatHttpsIsNotSupportedYet();
|
|
||||||
StopLoading();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
notify("Too many redirects");
|
http.handle_redirect();
|
||||||
StopLoading();
|
http.free();
|
||||||
break;
|
GetAbsoluteURL(#http.redirect_url);
|
||||||
|
history.back();
|
||||||
|
strcpy(#editURL, #URL);
|
||||||
|
DrawEditBoxWebView();
|
||||||
|
OpenPage();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
redirected = 0;
|
||||||
{
|
|
||||||
redirected = 0;
|
|
||||||
}
|
|
||||||
// Loading the page is complete, free resources
|
// Loading the page is complete, free resources
|
||||||
if (redirected>0)
|
history.add(#URL);
|
||||||
{
|
bufpointer = http.content_pointer;
|
||||||
http.free();
|
bufsize = http.content_received;
|
||||||
GetAbsoluteURL(#URL);
|
http.free();
|
||||||
history.back();
|
SetPageDefaults();
|
||||||
strcpy(#editURL, #URL);
|
ShowPage();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,7 +254,12 @@ void Draw_Window()
|
|||||||
img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 87, 0);
|
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,STATUSBAR_H, col_bg);
|
||||||
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
|
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);
|
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
|
||||||
DrawProgress();
|
DrawProgress();
|
||||||
}
|
}
|
||||||
@ -303,7 +287,10 @@ void ProcessEvent(dword id__)
|
|||||||
return;
|
return;
|
||||||
case GOTOURL_BUTTON:
|
case GOTOURL_BUTTON:
|
||||||
case SCAN_CODE_ENTER:
|
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))
|
|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
|
||||||
{
|
{
|
||||||
strcpy(#URL, #editURL);
|
strcpy(#URL, #editURL);
|
||||||
@ -334,7 +321,7 @@ void ProcessEvent(dword id__)
|
|||||||
WB1.LoadInternalPage(bufpointer, bufsize);
|
WB1.LoadInternalPage(bufpointer, bufsize);
|
||||||
break;
|
break;
|
||||||
case EDIT_SOURCE:
|
case EDIT_SOURCE:
|
||||||
if (!strncmp(#URL,"http:",5))
|
if (!strncmp(#URL,"http",4))
|
||||||
{
|
{
|
||||||
CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
|
CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
|
||||||
if (!EAX) RunProgram("/rd/1/tinypad", "/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);
|
CreateThread(#Downloader,#downloader_stak+4092);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case COPY_LINK:
|
case COPY_LINK_URL:
|
||||||
Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
|
Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
|
||||||
notify("'URL copied to clipboard'O");
|
notify("'URL copied to clipboard'O");
|
||||||
return;
|
return;
|
||||||
@ -366,6 +353,16 @@ void ProcessEvent(dword id__)
|
|||||||
CreateThread(#Downloader,#downloader_stak+4092);
|
CreateThread(#Downloader,#downloader_stak+4092);
|
||||||
}
|
}
|
||||||
return;
|
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()
|
void OpenPage()
|
||||||
{
|
{
|
||||||
|
char getUrl[sizeof(URL)];
|
||||||
StopLoading();
|
StopLoading();
|
||||||
souce_mode = false;
|
souce_mode = false;
|
||||||
strcpy(#editURL, #URL);
|
strcpy(#editURL, #URL);
|
||||||
@ -409,10 +407,18 @@ void OpenPage()
|
|||||||
DrawEditBoxWebView();
|
DrawEditBoxWebView();
|
||||||
return;
|
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);
|
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)
|
if (!http.transfer)
|
||||||
{
|
{
|
||||||
StopLoading();
|
StopLoading();
|
||||||
@ -452,7 +458,6 @@ DrawEditBoxWebView()
|
|||||||
void ShowPage()
|
void ShowPage()
|
||||||
{
|
{
|
||||||
DrawEditBoxWebView();
|
DrawEditBoxWebView();
|
||||||
debugval("bufsize", bufsize);
|
|
||||||
if (!bufsize)
|
if (!bufsize)
|
||||||
{
|
{
|
||||||
if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
|
if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
|
||||||
@ -486,10 +491,10 @@ int SetSkinColors()
|
|||||||
|
|
||||||
void DrawProgress()
|
void DrawProgress()
|
||||||
{
|
{
|
||||||
unsigned long btn;
|
dword persent;
|
||||||
if (http.transfer == 0) return;
|
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;
|
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, btn, 2, wv_progress_bar.progress_color);
|
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();
|
StopLoading();
|
||||||
history.back();
|
history.back();
|
||||||
}
|
}
|
||||||
|
strcpy(#URL, PageLinks.GetURL(PageLinks.active));
|
||||||
strcpy(#URL, PageLinks.GetURL(PageLinks.active));
|
|
||||||
//#1
|
//#1
|
||||||
if (URL[0] == '#')
|
if (URL[0] == '#')
|
||||||
{
|
{
|
||||||
@ -532,17 +536,9 @@ void ClickLink()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncmp(#URL,"https://",8))
|
|
||||||
{
|
|
||||||
ShowErrorMessageThatHttpsIsNotSupportedYet();
|
|
||||||
strcpy(#editURL, history.current());
|
|
||||||
strcpy(#URL, history.current());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetAbsoluteURL(#URL);
|
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)
|
if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true)
|
||||||
{
|
{
|
||||||
@ -587,7 +583,7 @@ void EventShowPageMenu(dword _left, _top)
|
|||||||
|
|
||||||
void EventShowLinkMenu(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()
|
void EventUpdateProgressBar()
|
||||||
@ -600,12 +596,6 @@ void EventUpdateProgressBar()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ShowErrorMessageThatHttpsIsNotSupportedYet()
|
|
||||||
{
|
|
||||||
notify("'HTTPS protocol is not supported yet' -E");
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawStatusBar(dword _status_text)
|
DrawStatusBar(dword _status_text)
|
||||||
{
|
{
|
||||||
status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
|
status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
|
||||||
|
@ -73,10 +73,10 @@ void Downloader()
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (!downloader.MonitorProgress()) break;
|
if (!downloader.MonitorProgress()) break;
|
||||||
pb.max = downloader.data_full_size;
|
pb.max = downloader.httpd.content_length;
|
||||||
if (pb.value != downloader.data_downloaded_size)
|
if (pb.value != downloader.httpd.content_received)
|
||||||
{
|
{
|
||||||
pb.value = downloader.data_downloaded_size;
|
pb.value = downloader.httpd.content_received;
|
||||||
progressbar_draw stdcall(#pb);
|
progressbar_draw stdcall(#pb);
|
||||||
DrawDownloading();
|
DrawDownloading();
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ void StartDownloading()
|
|||||||
void DrawDownloading()
|
void DrawDownloading()
|
||||||
{
|
{
|
||||||
char bytes_received[70];
|
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);
|
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);
|
WriteText(15, pb.top + 22, 0x90, system.color.work_text, #bytes_received);
|
||||||
progressbar_draw stdcall(#pb);
|
progressbar_draw stdcall(#pb);
|
||||||
@ -182,7 +182,7 @@ void SaveDownloadedFile()
|
|||||||
|
|
||||||
for (i=0; i<strlen(#filepath); i++) if(filepath[i]==':')||(filepath[i]=='?')filepath[i]='-';
|
for (i=0; i<strlen(#filepath); i++) if(filepath[i]==':')||(filepath[i]=='?')filepath[i]='-';
|
||||||
|
|
||||||
if (CreateFile(downloader.data_downloaded_size, downloader.bufpointer, #filepath)==0)
|
if (CreateFile(downloader.httpd.content_received, downloader.bufpointer, #filepath)==0)
|
||||||
sprintf(#notify_message, "%s%s%s",FILE_SAVED_AS,#filepath,"' -Dt");
|
sprintf(#notify_message, "%s%s%s",FILE_SAVED_AS,#filepath,"' -Dt");
|
||||||
else
|
else
|
||||||
sprintf(#notify_message, "%s%s%s","'Download manager\nError! Can\96t save file as ",#filepath,"' -Et");
|
sprintf(#notify_message, "%s%s%s","'Download manager\nError! Can\96t save file as ",#filepath,"' -Et");
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
#define SCAN_CODE_PLUS 013
|
#define SCAN_CODE_PLUS 013
|
||||||
|
|
||||||
#define SCAN_CODE_F1 059
|
#define SCAN_CODE_F1 059
|
||||||
|
#define SCAN_CODE_F11 087
|
||||||
|
#define SCAN_CODE_F12 088
|
||||||
|
|
||||||
#define SCAN_CODE_KEY_B 048
|
#define SCAN_CODE_KEY_B 048
|
||||||
#define SCAN_CODE_KEY_C 046
|
#define SCAN_CODE_KEY_C 046
|
||||||
|
@ -13,6 +13,8 @@ struct _http
|
|||||||
dword status_code;
|
dword status_code;
|
||||||
dword receive_result;
|
dword receive_result;
|
||||||
dword content_pointer;
|
dword content_pointer;
|
||||||
|
char redirect_url[4096*3];
|
||||||
|
char finaladress[4096*3];
|
||||||
|
|
||||||
dword get();
|
dword get();
|
||||||
void free();
|
void free();
|
||||||
@ -39,17 +41,19 @@ void _http::receive()
|
|||||||
http_receive stdcall (transfer);
|
http_receive stdcall (transfer);
|
||||||
receive_result = EAX;
|
receive_result = EAX;
|
||||||
|
|
||||||
ESI = transfer;
|
EDI = transfer;
|
||||||
if (!EAX) status_code = ESI.http_msg.status;
|
if (!EAX) {
|
||||||
content_length = ESI.http_msg.content_length;
|
status_code = EDI.http_msg.status;
|
||||||
content_received = ESI.http_msg.content_received;
|
content_pointer = EDI.http_msg.content_ptr;
|
||||||
|
}
|
||||||
|
content_length = EDI.http_msg.content_length;
|
||||||
|
content_received = EDI.http_msg.content_received;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _http::handle_redirect()
|
bool _http::handle_redirect()
|
||||||
{
|
{
|
||||||
dword redirect, i;
|
dword redirect;
|
||||||
char redirect_url[4096*3], finaladress[4096*3];
|
|
||||||
http_find_header_field stdcall (transfer, "location\0");
|
http_find_header_field stdcall (transfer, "location\0");
|
||||||
if (EAX!=0) {
|
if (EAX!=0) {
|
||||||
ESI = EAX;
|
ESI = EAX;
|
||||||
@ -81,13 +85,11 @@ enum {
|
|||||||
|
|
||||||
struct DOWNLOADER {
|
struct DOWNLOADER {
|
||||||
_http httpd;
|
_http httpd;
|
||||||
unsigned data_downloaded_size, data_full_size;
|
|
||||||
dword bufpointer, bufsize, url;
|
dword bufpointer, bufsize, url;
|
||||||
int state;
|
int state;
|
||||||
dword Start();
|
dword Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
void Completed();
|
bool MonitorProgress();
|
||||||
int MonitorProgress();
|
|
||||||
} downloader;
|
} downloader;
|
||||||
|
|
||||||
dword DOWNLOADER::Start(dword _url)
|
dword DOWNLOADER::Start(dword _url)
|
||||||
@ -113,43 +115,30 @@ void DOWNLOADER::Stop()
|
|||||||
bufsize = 0;
|
bufsize = 0;
|
||||||
bufpointer = free(bufpointer);
|
bufpointer = free(bufpointer);
|
||||||
}
|
}
|
||||||
data_downloaded_size = data_full_size = 0;
|
httpd.content_received = httpd.content_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DOWNLOADER::Completed()
|
bool DOWNLOADER::MonitorProgress()
|
||||||
{
|
{
|
||||||
state = STATE_COMPLETED;
|
|
||||||
ESI = httpd.transfer;
|
|
||||||
bufpointer = ESI.http_msg.content_ptr;
|
|
||||||
bufsize = ESI.http_msg.content_received;
|
|
||||||
httpd.free();
|
|
||||||
}
|
|
||||||
|
|
||||||
int DOWNLOADER::MonitorProgress()
|
|
||||||
{
|
|
||||||
dword receive_result;
|
|
||||||
char redirect_url[4096*3], finaladress[4096*3];
|
|
||||||
if (httpd.transfer <= 0) return false;
|
if (httpd.transfer <= 0) return false;
|
||||||
http_receive stdcall (httpd.transfer);
|
httpd.receive();
|
||||||
receive_result = EAX;
|
if (!httpd.content_length) httpd.content_length = httpd.content_received * 20;
|
||||||
EDI = httpd.transfer;
|
|
||||||
httpd.status_code = EDI.http_msg.status;
|
|
||||||
data_full_size = EDI.http_msg.content_length;
|
|
||||||
data_downloaded_size = EDI.http_msg.content_received;
|
|
||||||
if (!data_full_size) data_full_size = data_downloaded_size * 6 + 1;
|
|
||||||
|
|
||||||
if (receive_result == 0) {
|
if (httpd.receive_result == 0) {
|
||||||
if (httpd.status_code >= 300) && (httpd.status_code < 400)
|
if (httpd.status_code >= 300) && (httpd.status_code < 400)
|
||||||
{
|
{
|
||||||
httpd.handle_redirect();
|
httpd.handle_redirect();
|
||||||
strcpy(url, httpd.url);
|
strcpy(url, httpd.url);
|
||||||
get_absolute_url(#finaladress, url, #redirect_url);
|
get_absolute_url(#httpd.finaladress, url, #httpd.redirect_url);
|
||||||
Stop();
|
Stop();
|
||||||
Start(#finaladress);
|
Start(#httpd.finaladress);
|
||||||
url = #finaladress;
|
url = #httpd.finaladress;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Completed();
|
state = STATE_COMPLETED;
|
||||||
|
bufpointer = httpd.content_pointer;
|
||||||
|
bufsize = httpd.content_received;
|
||||||
|
httpd.free();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -191,8 +180,6 @@ int check_is_the_url_absolute(dword _in)
|
|||||||
void get_absolute_url(dword _rez, _base, _new)
|
void get_absolute_url(dword _rez, _base, _new)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
debug("_base:");debugln(_base);
|
|
||||||
debug("_new:");debugln(_new);
|
|
||||||
//case: ./valera.html
|
//case: ./valera.html
|
||||||
if (!strncmp(_new,"./", 2)) _new+=2;
|
if (!strncmp(_new,"./", 2)) _new+=2;
|
||||||
//case: http://site.name
|
//case: http://site.name
|
||||||
@ -222,5 +209,4 @@ void get_absolute_url(dword _rez, _base, _new)
|
|||||||
strcat(_rez, _new);
|
strcat(_rez, _new);
|
||||||
_GET_ABSOLUTE_URL_END:
|
_GET_ABSOLUTE_URL_END:
|
||||||
while (i=strstr(_rez, "&")) strcpy(i+1, i+5);
|
while (i=strstr(_rez, "&")) strcpy(i+1, i+5);
|
||||||
debug("_rez:");debugln(_rez);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user