Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8290 → Rev 8291

/programs/cmm/TWB/img.h
19,7 → 19,7
{
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
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)
/programs/cmm/browser/WebView.c
34,7 → 34,7
 
#define URL_SIZE 4000
 
char version[]="WebView 2.66";
char version[]="WebView 2.7";
 
#include "texts.h"
#include "cache.h"
240,6 → 240,12
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
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
} 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
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;
/programs/cmm/downloader/dl.c
6,7 → 6,6
 
#include "../lib/obj/box_lib.h"
#include "../lib/obj/http.h"
#include "../lib/obj/libini.h"
 
#include "../lib/patterns/http_downloader.h"
 
13,7 → 12,7
#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
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
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
{
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
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("'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();
}
//sprintf(#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
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 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,7 → 230,7
for (i=0; i<strlen(#filepath); i++) if(filepath[i]==':')||(filepath[i]=='?')filepath[i]='-';
 
if (CreateFile(downloader.httpd.content_received, downloader.bufpointer, #filepath)==0) {
if (CreateFile(downloader.content_received, downloader.bufpointer, #filepath)==0) {
miniprintf(#notify_message, FILE_SAVED_AS, #filepath);
} else {
miniprintf(#notify_message, FILE_NOT_SAVED, #filepath);
239,7 → 237,7
}
 
/*
if (CreateFile(downloader.httpd.content_received, downloader.bufpointer, #filepath)==0) {
if (CreateFile(downloader.content_received, downloader.bufpointer, #filepath)==0) {
strcpy(#notify_message, "'Download complete' -Dt");
} else {
strcpy(#notify_message, "'Error saving downloaded file!' -Et");
/programs/cmm/lib/patterns/http_downloader.h
6,7 → 6,7
 
struct _http
{
dword url;
dword cur_url;
dword transfer;
dword content_length;
dword content_received;
14,23 → 14,25
dword receive_result;
dword content_pointer;
char redirect_url[4096*3];
char finaladress[4096*3];
char content_type[64];
 
dword get();
void free();
void hfree();
void receive();
bool handle_redirect();
dword check_content_type();
};
 
dword _http::get(dword _url)
{
url = _url;
http_get stdcall (url, 0, 0, #accept_language);
cur_url = _url;
http_get stdcall (_url, 0, 0, #accept_language);
content_type[0] = '\0';
transfer = EAX;
return transfer;
}
 
void _http::free()
void _http::hfree()
{
http_free stdcall (transfer);
transfer=0;
53,7 → 55,6
 
:bool _http::handle_redirect()
{
dword redirect;
http_find_header_field stdcall (transfer, "location\0");
if (EAX!=0) {
ESI = EAX;
63,13 → 64,31
$stosb;
} while (AL != 0) && (AL != 13) && (AL != 10);
DSBYTE[EDI-1]='\0';
get_absolute_url(#finaladress, url, #redirect_url);
strcpy(url, #finaladress);
return true;
get_absolute_url(#redirect_url, cur_url);
hfree();
return #redirect_url;
}
return false;
return NULL;
}
 
:dword _http::check_content_type()
{
if (content_type[0]) return NULL;
http_find_header_field stdcall (transfer, "content-type\0");
if (EAX!=0) {
ESI = EAX;
EDI = #content_type;
do {
$lodsb;
$stosb;
} while (AL != 0) && (AL != 13) && (AL != 10);
DSBYTE[EDI-1]='\0';
debugln(#content_type);
return #content_type;
}
return NULL;
}
 
//===================================================//
// //
// DOWNLOADER //
83,8 → 102,7
STATE_COMPLETED
};
 
struct DOWNLOADER {
_http httpd;
struct DOWNLOADER : _http {
dword bufpointer, bufsize, url;
int state;
dword Start();
96,50 → 114,47
{
url = _url;
state = STATE_IN_PROGRESS;
httpd.get(url);
if (!httpd.transfer) Stop();
return httpd.transfer;
get(_url);
if (!transfer) Stop();
return transfer;
}
 
void DOWNLOADER::Stop()
{
state = STATE_NOT_STARTED;
if (httpd.transfer!=0)
if (transfer!=0)
{
EAX = httpd.transfer;
EAX = transfer;
EAX = EAX.http_msg.content_ptr; // get pointer to data
$push EAX // save it on the stack
http_free stdcall (httpd.transfer); // abort connection
http_free stdcall (transfer); // abort connection
$pop EAX
free(EAX); // free data
httpd.transfer=0;
transfer=0;
bufsize = 0;
bufpointer = free(bufpointer);
}
httpd.content_received = httpd.content_length = 0;
content_received = content_length = 0;
}
 
bool DOWNLOADER::MonitorProgress()
{
if (httpd.transfer <= 0) return false;
httpd.receive();
if (!httpd.content_length) httpd.content_length = httpd.content_received * 20;
if (transfer <= 0) return false;
receive();
if (!content_length) content_length = content_received * 20;
 
if (httpd.receive_result == 0) {
if (httpd.status_code >= 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,44 → 196,9
return false;
}
 
:void get_absolute_url(dword _rez, _base, _new)
:dword get_absolute_url(dword new_URL, base_URL)
{
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, "&amp;")) strcpy(i+1, i+5);
}
 
 
:dword GetAbsoluteURL(dword new_URL, base_URL)
{
int i;
dword orig_URL = new_URL;
char newurl[URL_SIZE+1];
strcpy(#newurl, base_URL);
/programs/cmm/misc/osupdate.c
117,7 → 117,7
if (!http.receive_result) {
CreateFile(http.content_received,
http.content_pointer, "/tmp0/1/latest.img");
http.free();
http.hfree();
EventDownloadComplete();
}
}