Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6053 → Rev 6058

/programs/cmm/aelia/parse_address.h
File deleted
\ No newline at end of file
/programs/cmm/aelia/aelia.c
1,4 → 1,4
#define MEMSIZE 4096*30
#define MEMSIZE 4096*60
 
#include "../lib/font.h"
#include "../lib/io.h"
13,10 → 13,8
#include "../lib/patterns/libimg_load_skin.h"
#include "../lib/patterns/simple_open_dialog.h"
#include "../lib/patterns/history.h"
#include "../lib/patterns/http_downloader.h"
 
#include "../browser/http_downloader.h"
#include "parse_address.h"
 
char default_dir[] = "/rd/1";
od_filter filter2 = {0,0};
 
48,9 → 46,9
MAGNIFY_PLUS,
CHANGE_ENCODING,
RUN_EDIT,
SHOW_INFO,
GO_BACK,
GO_FORWARD,
SANDWICH
};
 
char address[UML]="http://";
60,8 → 58,12
#include "ini.h"
#include "gui.h"
#include "label.h"
#include "link.h"
#include "prepare_page.h"
//#include "special_symbols.h"
 
#define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nAbout"
 
void InitDlls()
{
load_dll(boxlib, #box_lib_init, 0);
98,15 → 100,22
break;
case evReDraw:
draw_window();
if (menu.list.cur_y) {
if (menu.list.cur_y>=10) && (menu.list.cur_y<20) {
encoding = menu.list.cur_y - 10;
debugln("evReDraw: charset changed");
EventOpenAddress(history.current());
EventPageRefresh();
menu.list.cur_y = 0;
}
if (menu.list.cur_y>=20) {
menu.list.cur_y-=20;
if (menu.list.cur_y==0) EventPageRefresh();
if (menu.list.cur_y==1) EventRunEdit();
if (menu.list.cur_y==2) EventShowHistory();
if (menu.list.cur_y==3) EventShowInfo();
menu.list.cur_y = 0;
}
}
}
}
 
 
void HandleButtonEvent()
139,8 → 148,8
case RUN_EDIT:
EventRunEdit();
break;
case SHOW_INFO:
EventShowInfo();
case SANDWICH:
EventShowSandwichMenu();
break;
}
}
205,6 → 214,7
edit_box_mouse stdcall (#address_box);
mouse.get();
list.wheel_size = 7;
link.hover();
if (list.MouseScroll(mouse.vert)) {
DrawPage();
return;
279,6 → 289,8
else
DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2);
}
strcpy(#address,downloader.url);
DrawAddressBox();
io.buffer_data = downloader.bufpointer;
}
}
356,6 → 368,17
if (history.forward()) EventOpenAddress(history.current());
}
 
void EventShowSandwichMenu()
{
menu.selected = 0;
menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20);
}
 
void EventPageRefresh()
{
EventOpenAddress(history.current());
}
 
/* ------------------------------------------- */
 
 
375,11 → 398,10
DrawToolbarButton(GO_BACK, 8);
DrawToolbarButton(GO_FORWARD, 33);
DrawToolbarButton(OPEN_FILE, 68);
DrawToolbarButton(MAGNIFY_PLUS, Form.cwidth - 161);
DrawToolbarButton(MAGNIFY_MINUS, Form.cwidth - 136);
DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 102);
DrawToolbarButton(RUN_EDIT, Form.cwidth - 68);
DrawToolbarButton(SHOW_INFO, Form.cwidth - 34);
DrawToolbarButton(MAGNIFY_PLUS, Form.cwidth - 125);
DrawToolbarButton(MAGNIFY_MINUS, Form.cwidth - 100);
DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64);
DrawToolbarButton(SANDWICH, Form.cwidth - 31);
 
DrawAddressBox();
 
413,7 → 435,7
{
address_box.left = 97;
address_box.top = 11;
address_box.width = Form.cwidth - address_box.left - 172;
address_box.width = Form.cwidth - address_box.left - 138;
DrawRectangle(address_box.left-4, address_box.top-5, address_box.width+6, 23, 0x8C8C8C);
DrawWideRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 21, 4, address_box.color);
address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address);
/programs/cmm/aelia/buidin_pages/about.htm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/cmm/aelia/link.h
0,0 → 1,55
struct _link
{
int count;
int x[4096], y[4096], w[4096], h[4096];
collection text;
collection url;
void clear();
void add();
int hover();
int active;
} link;
 
void _link::clear()
{
text.drop();
url.drop();
count = 0;
}
 
void _link::add(int _xx, _yy, _ww, _hh, dword _textt, _urll )
{
if (count==4095) return;
x[count] = _xx;
y[count] = _yy;
w[count] = _ww;
h[count] = _hh;
text.add(_textt);
url.add(_urll);
count++;
}
 
int _link::hover()
{
//char tempp[4096];
dword color;
int i;
active = 0;
mouse.x = mouse.x - list.x;
mouse.y = mouse.y - list.y;
for (i=0; i<link.count; i++) {
if(link.y[i]>list.first*list.item_h) && (link.y[i]<list.first*list.item_h+list.h) {
// sprintf(#tempp, "mx:%i my:%i x[i]:%i y[i]:%i", mx, my, x[i], y[i]);
// sprintf(#tempp);
if (mouse.x>link.x[i])
&& (-list.first*list.item_h+link.y[i]<mouse.y)
&& (mouse.x<link.x[i]+link.w[i])
&& (-list.first*list.item_h+link.y[i]+link.h[i]>mouse.y)
color = 0xFF0000;
else
color = 0xCCCccc;
DrawRectangle(link.x[i]+list.x+1, -list.first*list.item_h+link.y[i]+list.y, link.w[i], link.h[i], color);
}
}
return false;
}
/programs/cmm/aelia/prepare_page.h
6,6 → 6,7
//get font chars width, need to increase performance
get_label_symbols_size();
ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
link.clear();
if (strstri(io.buffer_data, "<html")==-1) {
debugln("no <html> found");
DrawProgress(STEP_2_COUNT_PAGE_HEIGHT); ParceTxt(false); //get page height to calculate buffer size
82,8 → 83,19
bool pre;
bool ignore;
dword color;
void clear();
} style;
 
void _style::clear()
{
b=u=i=s=0;
h1=h2=h3=h4=h5=h6=0;
a=0;
pre=0;
ignore=0;
color=0;
}
 
struct _text {
dword start;
int x, y;
96,6 → 108,7
dword value[10];
void parce();
int nameis();
void clear();
};
 
void _tag::parce()
108,10 → 121,15
 
int _tag::nameis(dword _in_tag_name)
{
if (strcmp(_in_tag_name, name)==0) return true;
if (name) && (strcmp(_in_tag_name, name)==0) return true;
return false;
}
 
void _tag::clear()
{
start=name=0;
}
 
#define HTML_PADDING_X 8;
#define HTML_PADDING_Y 5;
 
127,6 → 145,8
_tag tag;
dword DOM_pos;
 
tag.clear();
style.clear();
/* Create DOM */
debugln("creating DOM");
DOM.len = strlen(io.buffer_data);
133,15 → 153,16
DOM.start = malloc(DOM.len);
DOM.end = DOM.start + DOM.len;
strlcpy(DOM.start, io.buffer_data, DOM.len);
//RemoveSpecialSymbols(DOM.start, DOM.len);
//DOM.len = strlen(DOM.start);
 
/* Parce DOM */
debugln("starting DOM parce...");
text.start = DOM_pos;
text.start = DOM.start;
for (DOM_pos=DOM.start; DOM_pos<DOM.end; DOM_pos++)
{
if (ESBYTE[DOM_pos]==0x0D) || (ESBYTE[DOM_pos]==0x0A) ESBYTE[DOM_pos]=' ';
ch = ESBYTE[DOM_pos];
//debugch(ch);
if (ch=='<') {
ESBYTE[DOM_pos] = '\0';
tag.start = DOM_pos + 1;
152,7 → 173,6
}
while (get_label_len(text.start) + stroka_x + 30 > list.w)
{
//debugln("long line cut");
zeroch = 0;
for (line_break=tag.start-1; line_break>text.start; line_break--;)
{
161,7 → 181,10
ESBYTE[line_break] >< zeroch; //restore line
}
if (draw==true) {
if (style.a) label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
if (style.a) {
link.add(stroka_x,stroka_y,get_label_len(text.start),list.item_h,text.start," ");
label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
}
WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
}
ESBYTE[line_break] >< zeroch; //restore line
170,7 → 193,10
stroka_y += list.item_h;
}
if (draw==true) {
if (style.a) label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
if (style.a) {
link.add(stroka_x,stroka_y,get_label_len(text.start),list.item_h,text.start," ");
label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
}
WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
}
stroka_x += get_label_len(text.start);
/programs/cmm/aelia/toolbar.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/cmm/browser/WebView.c
26,6 → 26,7
//useful patterns
#include "..\lib\patterns\libimg_load_skin.h"
#include "..\lib\patterns\history.h"
#include "..\lib\patterns\http_downloader.h"
 
char homepage[] = FROM "html\\homepage.htm";
 
101,7 → 102,6
#include "..\TWB\TWB.c"
#include "history.h"
#include "show_src.h"
#include "http_downloader.h"
#include "download_manager.h"
 
char editURL[sizeof(URL)];
/programs/cmm/examples/compile.bat
1,18 → 1,15
c-- window.c
c-- collections.c
c-- menu.c
c-- mixcolors.c
 
@echo off
@del _window
@del _collections
@del _menu
@del _mixcolors
 
@rename window.com _window
@rename collections.com _collections
@rename menu.com _menu
@rename mixcolors.com _mixcolors
 
@del warning.txt
@echo on
/programs/cmm/lib/debug.h
0,0 → 1,68
#ifndef INCLUDE_DEBUG_H
#define INCLUDE_DEBUG_H
#print "[include <debug.h>]\n"
 
#ifndef INCLUDE_STRING_H
#include "../lib/strings.h"
#endif
 
inline fastcall void debugch( ECX)
{
$push eax
$push ebx
$mov eax,63
$mov ebx,1
$int 0x40
$pop ebx
$pop eax
}
 
inline fastcall void debug( EDX)
{
$push eax
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
NEXT_CHAR:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz DONE
$int 0x40
$inc edx
$jmp NEXT_CHAR
DONE:
$pop ecx
$pop ebx
$pop eax
}
 
inline fastcall void debugln( EDX)
{
debug( EDX);
debugch('\n');
}
 
inline void debugi(dword d_int)
{
char tmpch[12];
itoa_(#tmpch, d_int);
debugln(#tmpch);
}
 
:void assert(dword _type, _actual, _expected)
{
char r[4096];
if (_type=='s') {
if (streq(_actual, _expected)) return;
sprintf(#r, "==========nok{\nactual: %s\nexpected: %s", _actual, _expected);
debugln(#r);
}
if (_type=='i') {
if (_actual == _expected)) return;
sprintf(#r, "==========nok{\nactual: %i\nexpected: %i", _actual, _expected);
debugln(#r);
}
}
 
#endif
/programs/cmm/lib/kolibri.h
437,61 → 437,6
$int 0x40
}
 
inline fastcall void debugln( EDX)
{
$push eax
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
NEXT_CHAR:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz DONE
$int 0x40
$inc edx
$jmp NEXT_CHAR
DONE:
$mov cl, 13
$int 0x40
$mov cl, 10
$int 0x40
$pop ecx
$pop ebx
$pop eax
}
 
inline fastcall void debug( EDX)
{
$push eax
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
NEXT_CHAR:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz DONE
$int 0x40
$inc edx
$jmp NEXT_CHAR
DONE:
$pop ecx
$pop ebx
$pop eax
}
 
 
inline fastcall void debugch( ECX)
{
$push eax
$push ebx
$mov eax,63
$mov ebx,1
$int 0x40
$pop ebx
$pop eax
}
//------------------------------------------------------------------------------
 
void DefineAndDrawWindow(dword x, y, size_w, size_h, byte WindowType,dword WindowAreaColor, EDI, ESI)
812,3 → 757,7
#ifndef INCLUDE_MEM_H
#include "../lib/mem.h"
#endif
 
#ifndef INCLUDE_DEBUG_H
#include "../lib/debug.h"
#endif
/programs/cmm/lib/obj/iconv.h
7,10 → 7,6
#include "../lib/kolibri.h"
#endif
 
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
 
dword iconv_lib = #a_iconv_lib;
char a_iconv_lib[19]="/sys/lib/iconv.obj\0";
 
/programs/cmm/lib/patterns/http_downloader.h
0,0 → 1,163
 
enum {
STATE_NOT_STARTED,
STATE_IN_PROGRESS,
STATE_COMPLETED
};
 
struct DOWNLOADER {
unsigned data_downloaded_size, data_full_size;
dword bufpointer, bufsize, url;
byte state;
dword http_transfer;
int http_status_code;
dword Start();
void Stop();
void Completed();
int MonitorProgress();
} downloader;
 
dword DOWNLOADER::Start(dword _url)
{
url = _url;
state = STATE_IN_PROGRESS;
http_get stdcall (url, 0, 0, #accept_language);
http_transfer = EAX;
return http_transfer;
}
 
void DOWNLOADER::Stop()
{
state = STATE_NOT_STARTED;
if (http_transfer!=0)
{
EAX = http_transfer;
EAX = EAX.http_msg.content_ptr; // get pointer to data
$push EAX // save it on the stack
http_free stdcall (http_transfer); // abort connection
$pop EAX
mem_Free(EAX); // free data
http_transfer=0;
bufsize = 0;
bufpointer = mem_Free(bufpointer);
}
data_downloaded_size = data_full_size = 0;
}
 
void DOWNLOADER::Completed()
{
state = STATE_COMPLETED;
ESI = http_transfer;
bufpointer = ESI.http_msg.content_ptr;
bufsize = ESI.http_msg.content_received;
http_free stdcall (http_transfer);
http_transfer=0;
}
 
int DOWNLOADER::MonitorProgress()
{
dword receive_result;
char redirect_url[4096*3], finaladress[4096*3];
if (http_transfer <= 0) return false;
http_receive stdcall (http_transfer);
receive_result = EAX;
EDI = http_transfer;
http_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 (http_status_code >= 300) && (http_status_code < 400)
{
http_find_header_field stdcall (http_transfer, "location\0");
if (EAX!=0) {
ESI = EAX;
EDI = #redirect_url;
do {
$lodsb;
$stosb;
} while (AL != 0) && (AL != 13) && (AL != 10));
DSBYTE[EDI-1]='\0';
}
get_absolute_url(#finaladress, url, #redirect_url);
Stop();
Start(#finaladress);
url = #finaladress;
return false;
}
Completed();
}
return true;
}
 
 
/*=====================================
== ==
== CHECK URL TYPE ==
== ==
=====================================*/
 
 
int check_is_the_adress_local(dword _in)
{
if (ESBYTE[_in]!='/') return false;
_in++;
if(!strncmp(_in,"rd/",3)) return true;
if(!strncmp(_in,"fd/",3)) return true;
if(!strncmp(_in,"hd/",3)) return true;
if(!strncmp(_in,"bd/",3)) return true;
if(!strncmp(_in,"cd/",3)) return true;
if(!strncmp(_in,"sys/",4)) return true;
if(!strncmp(_in,"tmp/",4)) return true;
if(!strncmp(_in,"usbhd",6)) return true;
if(!strncmp(_in,"kolibrios",10)) return true;
return false;
}
 
int check_is_the_url_absolute(dword _in)
{
if(!strncmp(_in,"ftp:",4)) return true;
if(!strncmp(_in,"http:",5)) return true;
if(!strncmp(_in,"https:",6)) return true;
if(!strncmp(_in,"mailto:",7)) return true;
if(check_is_the_adress_local(_in)) return true;
return false;
}
 
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
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);
debug("_rez:");debugln(_rez);
}
/programs/cmm/lib/strings.h
181,6 → 181,10
return 0;
}
 
inline signed int streq(dword text1, text2) {
if (!strcmp(text1,text2)) return true; else return false;
}
 
/*
signed int strncmp(dword s1, s2, signed n)
unsigned char _s1,_s2;
385,18 → 389,6
ESBYTE[ESI+EDI+1] = 0;
}
 
 
inline fastcall signed int old_strchr( ESI,BL)
{
int jj=0;
do{
jj++;
$lodsb
IF(AL==BL) return jj;
} while(AL!=0);
return 0;
}
 
inline dword strchr(dword shb;char s)
{
char ss;
897,14 → 889,6
return 0;
}
 
inline void debugi(dword d_int)
{
char tmpch[12];
itoa_(#tmpch, d_int);
debugln(#tmpch);
}
 
 
#define strnmov strmovn
#define stricmp strcmpi
#define strcmpn strncmp