diff --git a/programs/cmm/TWB/img.h b/programs/cmm/TWB/img.h index bcb093ffd4..0f86274c87 100644 --- a/programs/cmm/TWB/img.h +++ b/programs/cmm/TWB/img.h @@ -19,7 +19,7 @@ dword _img::add(dword _path, _x, _y) { char full_path[URL_SIZE]; strncpy(#full_path, _path, URL_SIZE); - GetAbsoluteURL(#full_path, history.current()); + get_absolute_url(#full_path, history.current()); url.add(#full_path); xywh.add(_x); @@ -93,7 +93,7 @@ void ImageCache::Images(dword left1, top1, width1) dword image; dword imgw=0, imgh=0, img_lines_first=0, cur_pic=0; - //GetAbsoluteURL(#img_path); + //getting abs url from (#img_path); //cur_pic = GetImage(#img_path); if (!pics[cur_pic].image) diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 0986d2bcb5..32a99bda7f 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -34,7 +34,7 @@ char editbox_icons[] = FROM "res/editbox_icons.raw"; #define URL_SIZE 4000 -char version[]="WebView 2.66"; +char version[]="WebView 2.7"; #include "texts.h" #include "cache.h" @@ -240,6 +240,12 @@ void main() if (http.transfer <= 0) break; http.receive(); EventUpdateProgressBar(); + if (http.check_content_type()) && (!strncmp(#http.content_type,"application",11)) { + EventOpenDownloader(history.current()); + StopLoading(); + history.back(); + EventRefreshPage(); + } if (http.receive_result != 0) break; if (http.status_code >= 300) && (http.status_code < 400) { @@ -247,8 +253,6 @@ void main() if (redirect_count<=5) { redirect_count++; http.handle_redirect(); - http.free(); - GetAbsoluteURL(#http.redirect_url, history.current()); history.back(); if (http_get_type==PAGE) OpenPage(#http.redirect_url); else if (http_get_type==IMG) http.get(#http.redirect_url); @@ -260,7 +264,7 @@ void main() } else { // Loading the page is complete, free resources redirect_count = 0; - http.free(); + http.hfree(); if (http_get_type==PAGE) { cache.add(history.current(), http.content_pointer, http.content_received, PAGE); LoadInternalPage(http.content_pointer, http.content_received); @@ -951,7 +955,7 @@ dword GetAbsoluteActiveURL() char abs_url[URL_SIZE]; if (links.active_url) { strncpy(#abs_url, links.active_url, URL_SIZE); - GetAbsoluteURL(#abs_url, history.current()); + get_absolute_url(#abs_url, history.current()); return #abs_url; } return 0; diff --git a/programs/cmm/downloader/dl.c b/programs/cmm/downloader/dl.c index a16bed38e2..1b7951e6cc 100644 --- a/programs/cmm/downloader/dl.c +++ b/programs/cmm/downloader/dl.c @@ -6,14 +6,13 @@ #include "../lib/obj/box_lib.h" #include "../lib/obj/http.h" -#include "../lib/obj/libini.h" #include "../lib/patterns/http_downloader.h" #include "const.h" DOWNLOADER downloader; -checkbox autoclose = { T_AUTOCLOSE, true }; +checkbox autoclose = { T_AUTOCLOSE, false }; char downloader_edit[4000]; char filepath[4096]; @@ -30,7 +29,6 @@ void main() dword shared_url; load_dll(boxlib, #box_lib_init,0); load_dll(libHTTP, #http_lib_init,1); - load_dll(libini, #lib_init,1); if (!dir_exists(#save_to)) CreateDir(#save_to); @@ -74,8 +72,8 @@ void main() default: if (!downloader.MonitorProgress()) break; - pb.max = downloader.httpd.content_length / 100; - EDI = downloader.httpd.content_received/100; + pb.max = downloader.content_length / 100; + EDI = downloader.content_received/100; if (pb.value != EDI) { pb.value = EDI; @@ -97,7 +95,7 @@ void ProcessEvent(int id) { autoclose.click(id); if (id==001) { StopDownloading(); ExitProcess(); } - if (id==301) && (downloader.httpd.transfer <= 0) StartDownloading(); + if (id==301) && (downloader.transfer <= 0) StartDownloading(); if (id==302) StopDownloading(); if (id==305) RunProgram("/sys/File managers/Eolite", #filepath); if (id==306) { @@ -141,17 +139,17 @@ void StartDownloading() char proxy_url[URL_SIZE]; StopDownloading(); if (!strncmp(#downloader_edit,"https://",7)) { - notify("'HTTPS for download is not supported, trying to download the file via HTTP' -W"); - miniprintf(#http_url, "http://%s", #downloader_edit+8); - if (!downloader.Start(#http_url)) { - notify("'Download failed.' -E"); - StopDownloading(); - } - //sprintf(#proxy_url, "http://gate.aspero.pro/?site=%s", #downloader_edit); - //if (!downloader.Start(#proxy_url)) { + //notify("'HTTPS for download is not supported, trying to download the file via HTTP' -W"); + //miniprintf(#http_url, "http://%s", #downloader_edit+8); + //if (!downloader.Start(#http_url)) { // notify("'Download failed.' -E"); // StopDownloading(); //} + miniprintf(#proxy_url, "http://gate.aspero.pro/?site=%s", #downloader_edit); + if (!downloader.Start(#proxy_url)) { + notify("'Download failed.' -E"); + StopDownloading(); + } DrawWindow(); return; } @@ -185,11 +183,11 @@ void CalculateSpeed() if (time.old) { time.gone = time.cur - time.old; if (time.gone > 200) { - speed = downloader.httpd.content_received - netdata_received / time.gone * 100; + speed = downloader.content_received - netdata_received / time.gone * 100; debugval("speed", speed); debugln(ConvertSizeToKb(speed) ); time.old = time.cur; - netdata_received = downloader.httpd.content_received; + netdata_received = downloader.content_received; } } else time.old = time.cur; @@ -199,7 +197,7 @@ void CalculateSpeed() void DrawDownloading() { char bytes_received[70]; - miniprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.httpd.content_received) ); + miniprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.content_received) ); WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, #bytes_received, sc.work); //CalculateSpeed(); progressbar_draw stdcall(#pb); @@ -232,14 +230,14 @@ void SaveDownloadedFile() for (i=0; i= 300) && (httpd.status_code < 400) + if (receive_result == 0) { + if (status_code >= 300) && (status_code < 400) { - httpd.handle_redirect(); - strcpy(url, httpd.url); - get_absolute_url(#httpd.finaladress, url, #httpd.redirect_url); + url = handle_redirect(); Stop(); - Start(#httpd.finaladress); - url = #httpd.finaladress; + Start(url); return false; } state = STATE_COMPLETED; - bufpointer = httpd.content_pointer; - bufsize = httpd.content_received; - httpd.free(); + bufpointer = content_pointer; + bufsize = content_received; + hfree(); } return true; } @@ -181,42 +196,7 @@ bool DOWNLOADER::MonitorProgress() return false; } -:void get_absolute_url(dword _rez, _base, _new) -{ - int i; - //case: ./valera.html - if (!strncmp(_new,"./", 2)) _new+=2; - //case: http://site.name - if (check_is_the_url_absolute(_new)) { - strcpy(_rez, _new); - goto _GET_ABSOLUTE_URL_END; - } - //case: /valera.html - if (ESBYTE[_new] == '/') //remove everything after site domain name - { - strcpy(_rez, _base); - i = strchr(_rez+8,'/'); - if (i<1) i=strlen(_rez)+_rez; - strcpy(i, _new); - goto _GET_ABSOLUTE_URL_END; - } - //case: ../../valera.html - strcpy(_rez, _base); - ESBYTE[ strrchr(_rez,'/') + _rez -1 ] = '\0'; //remove name - while (!strncmp(_new,"../",3)) - { - _new += 3; - ESBYTE[ strrchr(_rez,'/') + _rez -1 ] = '\0'; - } - //case: valera.html - chrcat(_rez, '/'); - strcat(_rez, _new); - _GET_ABSOLUTE_URL_END: - while (i=strstr(_rez, "&")) strcpy(i+1, i+5); -} - - -:dword GetAbsoluteURL(dword new_URL, base_URL) +:dword get_absolute_url(dword new_URL, base_URL) { int i; dword orig_URL = new_URL; diff --git a/programs/cmm/misc/osupdate.c b/programs/cmm/misc/osupdate.c index 2d49a20a2d..777a963301 100644 --- a/programs/cmm/misc/osupdate.c +++ b/programs/cmm/misc/osupdate.c @@ -117,7 +117,7 @@ void main() if (!http.receive_result) { CreateFile(http.content_received, http.content_pointer, "/tmp0/1/latest.img"); - http.free(); + http.hfree(); EventDownloadComplete(); } }