Fixed some WebView and Downloader issues #108

Merged
mxlgv merged 4 commits from webview-update into main 2025-03-02 12:10:11 +01:00
12 changed files with 92 additions and 116 deletions

View File

@@ -112,6 +112,7 @@ dword _tag::get_next_param(dword ps, pe)
// "pe" - param end
// "q" - quote char
char q = NULL;
dword initial_pe = pe;
dword fixeq;
dword val;
dword attr;
@@ -145,6 +146,14 @@ dword _tag::get_next_param(dword ps, pe)
//already have ATTR end
}
if (pe > ps) pe--;
//Fix case: "src ="
while (pe>ps) && (__isWhite(ESBYTE[pe])) {
ESBYTE[pe] = '\0';
pe--;
}
//find ATTR start and copy
while (pe>ps) && (!__isWhite(ESBYTE[pe])) pe--;
attr = pe + 1;
@@ -161,6 +170,8 @@ dword _tag::get_next_param(dword ps, pe)
}
strlwr(attr);
strrtrim(val);
//Fix case: " img.png"
while(__isWhite(ESBYTE[val])) && (val<initial_pe) val++;
attributes.add(attr);
values.add(val);

View File

@@ -10,11 +10,9 @@ void TWebBrowser::RenderLine(dword _line)
if (style.title)
{
strncpy(#header, _line, sizeof(TWebBrowser.header)-1);
if (!application_mode) {
strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
strncat(#header, #version, sizeof(TWebBrowser.header)-1);
}
}
else if (t_html) && (!t_body) {
//
}

View File

@@ -56,10 +56,6 @@ void TWebBrowser::SetStyle()
if (tag.is("tr")) { tag_table(); return; }
if (tag.is("th")) { tag_table(); return; }
if (tag.is("td")) { tag_table(); return; }
if (application_mode) {
if (tag.is("exit")) { ExitProcess(); return; }
}
}
void TWebBrowser::tag_p()
@@ -148,22 +144,6 @@ void TWebBrowser::tag_meta_xml()
if (streq(tag.get_value_of("http-equiv"), "refresh")) && (tag.get_value_of("content")) {
if (tag.value = strstri(tag.value, "url")) strcpy(#redirect, tag.value);
}
if (streq(tag.get_value_of("name"), "application")) {
if (application_mode) {
if (tag.get_number_of("left")) {
MoveSize(tag.number,-1,-1,-1);
}
if (tag.get_number_of("top")) {
MoveSize(-1,tag.number,-1,-1);
}
if (tag.get_number_of("width")) {
MoveSize(-1,-1,tag.number,-1);
}
if (tag.get_number_of("height")) {
MoveSize(-1,-1,-1,tag.number);
}
}
}
}
signed int get_encoding_type_by_name(dword name)
@@ -456,7 +436,7 @@ void TWebBrowser::tag_table()
}
} */
tallest_cell_in_row = math.max(draw_y+style.cur_line_h-list.item_h, tallest_cell_in_row);
tallest_cell_in_row = math.max(draw_y+style.cur_line_h-list.item_h+1, tallest_cell_in_row);
style.cur_line_h = list.item_h;
if (tag.opened) {

View File

@@ -65,6 +65,8 @@ char *unicode_symbols[]={
"times", "x",
"lowast","*",
"#128154","<3",
0};

View File

@@ -45,7 +45,6 @@
bool debug_mode = false;
bool show_images = true;
bool source_mode = false;
bool application_mode = false;
_history history;
@@ -110,9 +109,6 @@ void HandleParam()
history.add(#param + 8);
} else if (!strncmp(#param, "-new ", 5)) {
history.add(#param + 5);
} else if (!strncmp(#param, "-app ", 5)) {
history.add(#param + 5);
application_mode = true;
} else {
if (GetProcessesCount("WEBVIEW") == 1) {
history.add(#param);
@@ -136,14 +132,6 @@ void main()
LoadLibraries();
HandleParam();
if (application_mode) {
TOOLBAR_H = 0;
PADDING = 0;
TSZE = 0;
STATUSBAR_H = 0;
TAB_H = 0;
}
omnibox_edit.left = PADDING+TSZE*2+PADDING+6;
omnibox_edit.top = PADDING+3;
@@ -221,15 +209,6 @@ void main()
if (http.transfer <= 0) break;
http.receive();
if (http_get_type==PAGE) {
CheckContentType();
prbar.max = http.content_length;
if (prbar.value != http.content_received) {
prbar.value = http.content_received;
DrawProgress();
}
}
if (http.receive_result != 0) break;
if (debug_mode) {
EAX = http.transfer;
@@ -248,6 +227,15 @@ void main()
notify("'Too many redirects.' -E");
}
} else {
if (http_get_type==PAGE) {
CheckContentType();
prbar.max = http.content_length;
if (prbar.value != http.content_received) {
prbar.value = http.content_received;
DrawProgress();
}
}
// Loading the page is complete, free resources
redirect_count = 0;
if (http_get_type==PAGE) {
@@ -324,7 +312,7 @@ void ProcessKeyEvent()
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT)
{
if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();return;}
if (key_scancode == SCAN_CODE_KEY_T) {EventOpenNewTab(URL_SERVICE_TEST);return;}
if (key_scancode == SCAN_CODE_BS) {EventOpenNewTab(URL_SERVICE_TEST);return;}
}
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode)
@@ -382,7 +370,6 @@ void draw_window()
SetElementSizes();
if (!application_mode) {
DrawBar(0,0, Form.cwidth,PADDING, sc.work);
DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work);
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.dark, sc.work, 180));
@@ -398,7 +385,6 @@ void draw_window()
DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x,
WB1.list.h-1, scroll_wv.bckg_col);
}
if (!canvas.bufw) {
EventOpenFirstPage();
@@ -406,14 +392,11 @@ void draw_window()
WB1.DrawPage();
DrawOmnibox();
}
if (!application_mode) {
DrawProgress();
DrawStatusBar(NULL);
DrawTabsBar();
}
}
void EventOpenFirstPage()
{
OpenPage(history.current());
@@ -770,7 +753,6 @@ bool UrlExtIs(dword base, ext)
void DrawProgress()
{
dword pct;
if (application_mode) return;
if (!http.transfer) return;
if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10;
if (http_get_type==IMG) pct = prbar.value * 70 / prbar.max + 30;
@@ -779,21 +761,18 @@ void DrawProgress()
void EventShowPageMenu()
{
if (application_mode) return;
open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu);
menu_id = VIEW_SOURCE;
}
void EventShowLinkMenu()
{
if (application_mode) return;
open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #link_menu);
menu_id = IN_NEW_TAB;
}
void EventShowMainMenu()
{
if (application_mode) return;
open_lmenu(Form.cwidth - PADDING -4, PADDING + TSZE + 3,
MENU_TOP_RIGHT, NULL, #main_menu);
menu_id = OPEN_FILE;
@@ -801,7 +780,6 @@ void EventShowMainMenu()
void EventShowEncodingsList()
{
if (application_mode) return;
open_lmenu(Form.cwidth-4, Form.cheight - STATUSBAR_H + 12,
MENU_BOT_RIGHT, WB1.cur_encoding + 1,
"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
@@ -824,7 +802,8 @@ void EventSeachWeb()
{
char new_url[URL_SIZE+1];
replace_char(#editURL, ' ', '+', URL_SIZE);
strcpy(#new_url, "https://www.google.com/search?q=");
//strcpy(#new_url, "https://html.duckduckgo.com/html/?q=");
strcpy(#new_url, "http://bing.com/search?q=");
strncat(#new_url, #editURL, URL_SIZE);
OpenPage(#new_url);
}
@@ -886,7 +865,6 @@ void DrawStatusBar(dword _msg)
{
dword status_y = Form.cheight - STATUSBAR_H + 4;
dword status_w = Form.cwidth - 90;
if (application_mode) return;
if (Form.status_window>2) return;
DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
if (_msg) {
@@ -900,7 +878,6 @@ void DrawStatusBar(dword _msg)
void DrawOmnibox()
{
int imgxoff;
if (application_mode) return;
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.line,
sc.line, sc.line, sc.dark);
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8);
@@ -919,7 +896,6 @@ void DrawOmnibox()
void SetOmniboxText(dword _text)
{
if (application_mode) return;
edit_box_set_text stdcall (#omnibox_edit, _text);
omnibox_edit.pos = omnibox_edit.flags = 0;
DrawOmnibox();

View File

@@ -27,7 +27,7 @@ char link_menu[] =
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>";
char loading_text[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...";
char update_param[] = "-e http://builds.kolibrios.org/rus/data/programs/cmm/browser/WebView.com";
char update_param[] = "-e http://builds.kolibrios.org/ru_RU/data/programs/cmm/browser/WebView.com";
char update_download_error[] = "'WebView\n<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E7A5AD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -tE";
char update_ok[] = "'WebView\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20>ᯥ譮 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -tO";
char update_is_current[] = "'WebView\n<EFBFBD><EFBFBD><20><EFBFBD><E1AFAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.' -tI";
@@ -63,7 +63,7 @@ Open in new window
Copy link
Download link contents";
char loading_text[] = "Loading...";
char update_param[] = "-e http://builds.kolibrios.org/eng/data/programs/cmm/browser/WebView.com";
char update_param[] = "-e http://builds.kolibrios.org/en_US/data/programs/cmm/browser/WebView.com";
char update_download_error[] = "'WebView\nError receiving an up to date information!' -tE";
char update_ok[] = "'WebView\nThe browser has been updated!' -tO";
char update_is_current[] = "'WebView\nThe browser is up to date.' -tI";
@@ -107,4 +107,4 @@ char editbox_icons[] = FROM "res/editbox_icons.raw";
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
char version[]="WebView 3.66-3";
char version[]="WebView 3.7";

View File

@@ -2,23 +2,22 @@
<title>TEST</title>
<style>a {display:block;font-size:130%;margin:5px 40px 5px 0;}</style>
<body>
<pre>
<a href=//kolibrios.org>KolibriOS</a>
<a href=//kolibri-n.org>KolibriN10</a>
<a href=//store.kolibri-n.org>Kolibri Store</a>
<pre><a href=//wiby.org>wiby.org</a>
<a href=//www.xlr8yourmac.com/OSX/os_x_network_cards.html>OSX network cards</a>
<a href=//macintoshgarden.org/>Macintosh Garden</a>
<table><tr><td>Simplest:
<a href=//nostalgy.net.ru/>nostalgy.net.ru</a>
<a href=//pci-ids.ucw.cz>pci.ids</a>
<a href=//dgmag.in>dgmag.in</a>
<a href=//bash.im>bash.im</a>
<a href=//opennet.ru>opennet</a>
<a href=//web.archive.org/web/https://bash.im>bash.im</a>
<a href=//web.archive.org/web/https://opennet.ru>opennet</a>
<a href=//linux.org.ru>LOR</a>
<a href=//baravy.by/me/b.html>baravy.by/me/b.html</a>
<a href=//samlib.ru/b>samlib.ru/b</a>
<a href=//mirrors.pdp-11.ru>mirrors.pdp-11.ru</a>
<a href=//web.archive.org/web/https://samlib.ru/b>samlib.ru/b</a>
<a href=//web.archive.org/web/https://mirrors.pdp-11.ru>mirrors.pdp-11.ru</a>
<a href=//web.archive.org/web/http://gona.mactar.hu/ATI_Mac/>ATI drivers for Mac</a>
<td>Simple:
<a href=//lionovsky.us>lionovsky.us</a>
<a href=//web.archive.org/web/http://lionovsky.us>lionovsky.us</a>
<a href=//os-menuet.narod.ru>os-menuet.narod.ru</a>
<a href=//mestack.narod.ru/index.html>mestack.narod.ru</a>
<a href=//coolthemes.narod.ru/indexold.html>coolthemes.narod.ru</a>
@@ -34,8 +33,7 @@ Moderate:
<a href=//www.weitek.com/textual/support/driver.html>weitek</a>
<a href=//www.abandonwarering.com/?Page=Listing>abandonware</a>
<td>Complex:
<a href=//artcon.ru>artcon.ru</a>
<a href=//web.archive.org/web/https://artcon.ru>artcon.ru</a>
<a href=//nubo.ru>nubo.ru</a>
<a href=//salinc.ru>salinc.ru</a>
<a href=//electromyne.de>electromyne.de</a>
<a href=//www.thg.ru/graphic/25year_ati_history>tom's hardware</a>
<a href=//web.archive.org/web/20190403215447//www.thg.ru/>thg</a>

View File

@@ -17,8 +17,10 @@
#define T_STATUS_DL_P2 " M<> <20><><EFBFBD><EFBFBD><EFBFBD> ("
#define T_STATUS_DL_P3 " K<>/<EFBFBD>) "
#define FILE_SAVED_AS "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> %s' -Dt"
#define FILE_NOT_SAVED "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><EFBFBD><E8A8A1>! <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0A0AD> <20><><EFBFBD>\n%s' -Et"
#define T_ERROR_TOO_MANY_REDIRECTS "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>४⮢ (HTTP 3XX)' -Et"
#define T_FILE_SAVED_AS "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0A0AD> <20><><EFBFBD> %s' -Dt"
#define T_FILE_NOT_SAVED "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><EFBFBD><E8A8A1>! <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0A0AD> <20><><EFBFBD>\n%s' -Et"
#define T_ERROR_STARTING_DOWNLOAD "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᪠稢<E1AAA0><E7A8A2><EFBFBD><EFBFBD>.\n<><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><E1AEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>୥⮬.' -E"
char accept_language[]= "Accept-Language: ru\n";
#else
@@ -38,8 +40,10 @@
#define T_STATUS_DL_P2 " MB received ("
#define T_STATUS_DL_P3 " KB/s) "
#define FILE_SAVED_AS "'Download manager\nFile saved as %s' -Dt"
#define FILE_NOT_SAVED "'Download manager\nError! Can\96t save file as %s' -Et"
#define T_ERROR_TOO_MANY_REDIRECTS "'Download manager\nToo many redirects' -Et"
#define T_FILE_SAVED_AS "'Download manager\nFile saved as %s' -Dt"
#define T_FILE_NOT_SAVED "'Download manager\nError! Can\96t save file as %s' -Et"
#define T_ERROR_STARTING_DOWNLOAD "'Error while starting download process.\nCheck entered path and Internet connection.' -E"
char accept_language[]= "Accept-Language: en\n";
#endif

View File

@@ -11,6 +11,8 @@ bool open_file = false;
dword speed;
int redirect_count;
_http http;
checkbox autoclose = { T_AUTOCLOSE, false };
@@ -228,6 +230,7 @@ void InitDownload()
pb.progress_color = PB_COL_PROGRESS;
filepath = '\0';
active_status = T_STATUS_READY;
redirect_count = 0;
}
void MonitorProgress()
@@ -241,6 +244,13 @@ void MonitorProgress()
DrawDownloadingProgress();
} else {
if (http.status_code >= 300) && (http.status_code < 400) {
redirect_count++;
if (redirect_count >= 5) {
notify(T_ERROR_TOO_MANY_REDIRECTS);
ProcessButtonClick(BTN_STOP);
EditBox_UpdateText(#ed, ed_focus + ed_always_focus);
return;
}
http.header_field("location", #redirect_url, URL_SIZE);
get_absolute_url(#redirect_url, #uEdit);
edit_box_set_text stdcall (#ed, #redirect_url);
@@ -307,9 +317,9 @@ void SaveFile(int attempt)
}
if (CreateFile(http.content_received, http.content_pointer, #filepath)==0) {
miniprintf(#notify_message, FILE_SAVED_AS, #filepath);
miniprintf(#notify_message, T_FILE_SAVED_AS, #filepath);
} else {
miniprintf(#notify_message, FILE_NOT_SAVED, #filepath);
miniprintf(#notify_message, T_FILE_NOT_SAVED, #filepath);
}
if (!autoclose.checked) notify(#notify_message);

View File

@@ -202,7 +202,7 @@ struct proc_info
byte reserved[1024-71];
};
:void GetProcessInfo(dword _process_struct_pointer, _process_id)
:int GetProcessInfo(dword _process_struct_pointer, _process_id)
{
EAX = 9;
EBX = _process_struct_pointer;

View File

@@ -70,17 +70,17 @@ char aURIunescape[] = "unescape";
#define FLAG_TRANSFER_FAILED 1 << 20
struct http_msg{
dword socket;
dword flags;
dword write_ptr;
dword buffer_length;
dword chunk_ptr;
dword timestamp;
dword status;
dword header_length;
dword content_ptr;
dword content_length;
dword content_received;
dword socket; //socket on which the actual transfer happens
dword flags; //flags, reflects status of the transfer using bitflags
dword write_ptr; //internal use only (where to write new data in buffer)
dword buffer_length; //internal use only (number of available bytes in buffer)
dword chunk_ptr; //internal use only (where the next chunk begins)
dword timestamp; //internal use only (when last data was received)
dword status; //HTTP status
dword header_length; //length of HTTP header
dword content_ptr; //ptr to content
dword content_length; //total length of HTTP content
dword content_received; //number of currently received content bytes
char http_header;
};

View File

@@ -30,8 +30,7 @@ enum {
proc_info Process;
for (i=0; i<MAX_PROCESS_COUNT; i++)
{
GetProcessInfo(#Process, i);
if (EAX+1 >= i) break;
if (i > GetProcessInfo(#Process, i)) break;
if (Process.status_slot != TSTATE_FREE)
&& (strcmpi(#Process.name, proc_name)==0)
{
@@ -46,8 +45,7 @@ enum {
proc_info Process;
for (i=0; i<MAX_PROCESS_COUNT; i++)
{
GetProcessInfo(#Process, i);
if (EAX+1 >= i) break;
if (i > GetProcessInfo(#Process, i)) break;
if (Process.status_slot != TSTATE_FREE)
&& (strcmpi(#Process.name, proc_name)==0)
count++;
@@ -66,8 +64,7 @@ enum {
GetProcessInfo(#Self, -1);
for (i=0; i<MAX_PROCESS_COUNT; i++)
{
GetProcessInfo(#Process, i);
if (EAX+1 >= i) break;
if (i > GetProcessInfo(#Process, i)) break;
if (Process.name)
&& (Process.ID != Self.ID)
KillProcess(Process.ID);