Subversion Repositories Kolibri OS

Rev

Rev 6001 | Rev 6045 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6001 Rev 6021
1
//HTML Viewer in C--
1
//HTML Viewer in C--
2
//Copyright 2007-2013 by Veliant & Leency
2
//Copyright 2007-2013 by Veliant & Leency
3
//Asper, lev, Lrz, Barsuk, Nable...
3
//Asper, lev, Lrz, Barsuk, Nable...
4
//home icon - rachel fu, GPL licence
4
//home icon - rachel fu, GPL licence
5
 
5
 
6
#ifndef AUTOBUILD
6
#ifndef AUTOBUILD
7
	#include "lang.h--"
7
	#include "lang.h--"
8
#endif
8
#endif
9
 
9
 
10
//libraries
10
//libraries
11
#define MEMSIZE 1060000
11
#define MEMSIZE 1060000
12
#include "..\lib\gui.h"
12
#include "..\lib\gui.h"
13
#include "..\lib\draw_buf.h"
13
#include "..\lib\draw_buf.h"
14
#include "..\lib\list_box.h"
14
#include "..\lib\list_box.h"
15
#include "..\lib\cursor.h"
15
#include "..\lib\cursor.h"
16
#include "..\lib\collection.h"
16
#include "..\lib\collection.h"
17
#include "..\lib\font.h"
17
#include "..\lib\font.h"
18
 
18
 
19
//*.obj libraries
19
//*.obj libraries
20
#include "..\lib\obj\box_lib.h"
20
#include "..\lib\obj\box_lib.h"
21
#include "..\lib\obj\libio_lib.h"
21
#include "..\lib\obj\libio_lib.h"
22
#include "..\lib\obj\libimg_lib.h"
22
#include "..\lib\obj\libimg_lib.h"
23
#include "..\lib\obj\http.h"
23
#include "..\lib\obj\http.h"
24
#include "..\lib\obj\iconv.h"
24
#include "..\lib\obj\iconv.h"
25
//useful patterns
25
//useful patterns
26
#include "..\lib\patterns\libimg_load_skin.h"
26
#include "..\lib\patterns\libimg_load_skin.h"
27
#include "..\lib\patterns\history.h"
27
#include "..\lib\patterns\history.h"
28
 
28
 
29
char homepage[] = FROM "html\\homepage.htm";
29
char homepage[] = FROM "html\\homepage.htm";
30
 
30
 
31
#ifdef LANG_RUS
31
#ifdef LANG_RUS
32
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.42";
32
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.42";
33
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
33
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
34
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
34
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
35
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
35
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
36
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
36
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
37
	char accept_language[]= "Accept-Language: ru\n";
37
	char accept_language[]= "Accept-Language: ru\n";
38
#else
38
#else
39
	char version[]=" Text-based Browser 1.42";
39
	char version[]=" Text-based Browser 1.42";
40
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
40
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
41
	?define T_LAST_SLIDE "This slide is the last"
41
	?define T_LAST_SLIDE "This slide is the last"
42
	char loading[] = "Loading...
";
42
	char loading[] = "Loading...
";
43
	char page_not_found[] = FROM "html\page_not_found_en.htm";
43
	char page_not_found[] = FROM "html\page_not_found_en.htm";
44
	char accept_language[]= "Accept-Language: en\n";	
44
	char accept_language[]= "Accept-Language: en\n";	
45
#endif
45
#endif
46
 
46
 
47
#define URL_SERVICE_HISTORY "WebView://history"
47
#define URL_SERVICE_HISTORY "WebView://history"
48
#define URL_SERVICE_HOME "WebView://home"
48
#define URL_SERVICE_HOME "WebView://home"
49
#define URL_SERVICE_SOURCE "WebView://source:"
49
#define URL_SERVICE_SOURCE "WebView://source:"
50
 
50
 
51
proc_info Form;
51
proc_info Form;
52
 
52
 
53
//char search_path[]="http://nigma.ru/index.php?s=";
53
//char search_path[]="http://nigma.ru/index.php?s=";
54
int redirected = 0;
54
int redirected = 0;
55
 
55
 
56
char stak[4096];
56
char stak[4096];
57
 
57
 
58
int action_buf;
58
int action_buf;
59
 
59
 
60
dword http_transfer = 0;
60
dword http_transfer = 0;
61
dword http_buffer;
61
dword http_buffer;
62
 
62
 
63
dword TOOLBAR_H = 33;
63
dword TOOLBAR_H = 33;
64
dword STATUSBAR_H = 15;
64
dword STATUSBAR_H = 15;
65
dword col_bg;
65
dword col_bg;
66
dword panel_color;
66
dword panel_color;
67
dword border_color;
67
dword border_color;
68
 
68
 
69
progress_bar wv_progress_bar;
69
progress_bar wv_progress_bar;
70
byte souce_mode = false;
70
byte souce_mode = false;
71
 
71
 
72
enum { 
72
enum { 
73
	BACK_BUTTON=1000, 
73
	BACK_BUTTON=1000, 
74
	FORWARD_BUTTON, 
74
	FORWARD_BUTTON, 
75
	REFRESH_BUTTON, 
75
	REFRESH_BUTTON, 
76
	GOTOURL_BUTTON, 
76
	GOTOURL_BUTTON, 
77
	SANDWICH_BUTTON
77
	SANDWICH_BUTTON
78
};
78
};
79
 
79
 
80
enum {
80
enum {
81
	VIEW_SOURCE=1100,
81
	VIEW_SOURCE=1100,
82
	EDIT_SOURCE,
82
	EDIT_SOURCE,
83
	VIEW_HISTORY,
83
	VIEW_HISTORY,
84
	FREE_IMG_CACHE,
84
	FREE_IMG_CACHE,
85
	DOWNLOAD_MANAGER
85
	DOWNLOAD_MANAGER
86
};
86
};
87
 
87
 
88
#include "..\TWB\TWB.c"
88
#include "..\TWB\TWB.c"
89
#include "menu.h"
89
#include "menu.h"
90
#include "history.h"
90
#include "history.h"
91
#include "show_src.h"
91
#include "show_src.h"
92
#include "http_downloader.h"
92
#include "http_downloader.h"
93
#include "download_manager.h"
93
#include "download_manager.h"
94
 
94
 
95
char editURL[sizeof(URL)];
95
char editURL[sizeof(URL)];
96
int	mouse_twb;
96
int	mouse_twb;
97
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
97
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
98
 
98
 
99
 
99
 
100
void main()
100
void main()
101
{
101
{
102
	dword btn;
102
	dword btn;
103
	int half_scroll_size;
103
	int half_scroll_size;
104
	int scroll_used=0, show_menu;
104
	int scroll_used=0, show_menu;
105
	CursorPointer.Load(#CursorFile);
105
	CursorPointer.Load(#CursorFile);
106
	load_dll(boxlib, #box_lib_init,0);
106
	load_dll(boxlib, #box_lib_init,0);
107
	load_dll(libio, #libio_init,1);
107
	load_dll(libio, #libio_init,1);
108
	load_dll(libimg, #libimg_init,1);
108
	load_dll(libimg, #libimg_init,1);
109
	load_dll(libHTTP, #http_lib_init,1);
109
	load_dll(libHTTP, #http_lib_init,1);
110
	load_dll(iconv_lib, #iconv_open,0);
110
	load_dll(iconv_lib, #iconv_open,0);
111
	//load_dll(kmenu, #akmenu_init,0);
111
	//load_dll(kmenu, #akmenu_init,0);
112
	Libimg_LoadImage(#skin, abspath("wv_skin.png"));
112
	Libimg_LoadImage(#skin, abspath("wv_skin.png"));
113
	SetSkinColors();
113
	SetSkinColors();
114
	CreateDir("/tmp0/1/downloads");
114
	CreateDir("/tmp0/1/downloads");
115
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
115
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
116
	WB1.DrawBuf.zoom = 1;
116
	WB1.DrawBuf.zoom = 1;
117
	WB1.list.SetFont(8, 14, 10111000b);
117
	WB1.list.SetFont(8, 14, 10111000b);
118
	WB1.list.no_selection = true;
118
	WB1.list.no_selection = true;
119
	label.init(DEFAULT_FONT);
119
	label.init(DEFAULT_FONT);
120
	SetEventMask(0xa7);
120
	SetEventMask(0xa7);
121
	BEGIN_LOOP_APPLICATION:
121
	BEGIN_LOOP_APPLICATION:
122
		WaitEventTimeout(2);
122
		WaitEventTimeout(2);
123
		switch(EAX & 0xFF)
123
		switch(EAX & 0xFF)
124
		{
124
		{
125
			CASE evMouse:
125
			CASE evMouse:
126
				if (!CheckActiveProcess(Form.ID)) break;
126
				if (!CheckActiveProcess(Form.ID)) break;
127
				edit_box_mouse stdcall (#address_box);
127
				edit_box_mouse stdcall (#address_box);
128
				mouse.get();
128
				mouse.get();
129
				if (WB1.list.MouseOver(mouse.x, mouse.y))
129
				if (WB1.list.MouseOver(mouse.x, mouse.y))
130
				{
130
				{
131
					PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.item_h + mouse.y, link_color_inactive, link_color_active, bg_color);
131
					PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.item_h + mouse.y, link_color_inactive, link_color_active, bg_color);
132
					if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; }
132
					if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; }
133
					if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
133
					if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
134
				}
134
				}
135
				scrollbar_v_mouse (#scroll_wv);
135
				scrollbar_v_mouse (#scroll_wv);
136
				if (WB1.list.first != scroll_wv.position)
136
				if (WB1.list.first != scroll_wv.position)
137
				{
137
				{
138
					WB1.list.first = scroll_wv.position;
138
					WB1.list.first = scroll_wv.position;
139
					WB1.DrawPage();
139
					WB1.DrawPage();
140
					break;
140
					break;
141
				}
141
				}
142
				break;
142
				break;
143
 
143
 
144
			case evButton:
144
			case evButton:
145
				btn=GetButtonID();
145
				btn=GetButtonID();
146
				if (btn==1)	ExitProcess();
146
				if (btn==1)	ExitProcess();
147
				Scan(btn);
147
				Scan(btn);
148
				break;
148
				break;
149
 
149
 
150
			case evKey:
150
			case evKey:
151
				GetKeys();
151
				GetKeys();
152
				if (address_box.flags & 0b10)  
152
				if (address_box.flags & 0b10)  
153
				{
153
				{
154
					if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else
154
					if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else
155
					if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);}
155
					if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);}
156
				}
156
				}
157
				else 
157
				else 
158
				{
158
				{
159
					Scan(key_scancode);
159
					Scan(key_scancode);
160
				}
160
				}
161
				break;
161
				break;
162
 
162
 
163
			case evReDraw:
163
			case evReDraw:
164
				if (action_buf) Scan(action_buf);
164
				if (action_buf) Scan(action_buf);
165
				DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0);
165
				DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0);
166
				GetProcessInfo(#Form, SelfInfo);
166
				GetProcessInfo(#Form, SelfInfo);
167
				if (Form.status_window>2) { DrawTitle(#header); break; }
167
				if (Form.status_window>2) { DrawTitle(#header); break; }
168
				if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
168
				if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
169
				if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
169
				if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
170
				Draw_Window();
170
				Draw_Window();
171
				break;
171
				break;
172
				
172
				
173
			case evNetwork:
173
			case evNetwork:
174
				if (http_transfer > 0) {
174
				if (http_transfer > 0) {
175
					http_receive stdcall (http_transfer);
175
					http_receive stdcall (http_transfer);
176
					$push EAX
176
					$push EAX
177
					ESI = http_transfer;
177
					ESI = http_transfer;
178
					wv_progress_bar.max = ESI.http_msg.content_length;
178
					wv_progress_bar.max = ESI.http_msg.content_length;
179
					if (wv_progress_bar.value != ESI.http_msg.content_received)
179
					if (wv_progress_bar.value != ESI.http_msg.content_received)
180
					{
180
					{
181
						wv_progress_bar.value = ESI.http_msg.content_received;	
181
						wv_progress_bar.value = ESI.http_msg.content_received;	
182
						DrawProgress();
182
						DrawProgress();
183
					}
183
					}
184
					$pop EAX
184
					$pop EAX
185
					if (EAX == 0) {
185
					if (EAX == 0) {
186
						ESI = http_transfer;
186
						ESI = http_transfer;
187
						// Handle redirects
187
						// Handle redirects
188
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
188
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
189
						{
189
						{
190
							redirected++;
190
							redirected++;
191
							if (redirected<=5)
191
							if (redirected<=5)
192
							{
192
							{
193
								http_find_header_field stdcall (http_transfer, "location\0");
193
								http_find_header_field stdcall (http_transfer, "location\0");
194
								if (EAX!=0) {
194
								if (EAX!=0) {
195
									ESI = EAX;
195
									ESI = EAX;
196
									EDI = #URL;
196
									EDI = #URL;
197
									do {
197
									do {
198
										$lodsb;
198
										$lodsb;
199
										$stosb;
199
										$stosb;
200
									} while (AL != 0) && (AL != 13) && (AL != 10));
200
									} while (AL != 0) && (AL != 13) && (AL != 10));
201
									DSBYTE[EDI-1]='\0';
201
									DSBYTE[EDI-1]='\0';
202
								}
202
								}
203
							}
203
							}
204
							else
204
							else
205
							{
205
							{
206
								notify("Too many redirects");
206
								notify("Too many redirects");
207
								StopLoading();
207
								StopLoading();
208
								break;
208
								break;
209
							}
209
							}
210
						} 
210
						} 
211
						else
211
						else
212
						{
212
						{
213
							redirected = 0;
213
							redirected = 0;
214
						}
214
						}
215
						// Loading the page is complete, free resources
215
						// Loading the page is complete, free resources
216
						if (redirected>0)
216
						if (redirected>0)
217
						{
217
						{
218
							http_free stdcall (http_transfer);
218
							http_free stdcall (http_transfer);
219
							http_transfer=0;
219
							http_transfer=0;
220
							GetAbsoluteURL(#URL);
220
							GetAbsoluteURL(#URL);
221
							History.back();
221
							history.back();
222
							strcpy(#editURL, #URL);
222
							strcpy(#editURL, #URL);
223
							DrawEditBox();
223
							DrawEditBox();
224
							OpenPage();
224
							OpenPage();
225
						}
225
						}
226
						else
226
						else
227
						{
227
						{
228
							History.add(#URL);
228
							history.add(#URL);
229
							ESI = http_transfer;
229
							ESI = http_transfer;
230
							bufpointer = ESI.http_msg.content_ptr;
230
							bufpointer = ESI.http_msg.content_ptr;
231
							bufsize = ESI.http_msg.content_received;
231
							bufsize = ESI.http_msg.content_received;
232
							http_free stdcall (http_transfer);
232
							http_free stdcall (http_transfer);
233
							http_transfer=0;
233
							http_transfer=0;
234
							SetPageDefaults();
234
							SetPageDefaults();
235
							ShowPage();
235
							ShowPage();
236
						}
236
						}
237
					}
237
					}
238
				}
238
				}
239
		}
239
		}
240
	goto BEGIN_LOOP_APPLICATION;
240
	goto BEGIN_LOOP_APPLICATION;
241
}
241
}
242
 
242
 
243
void SetElementSizes()
243
void SetElementSizes()
244
{
244
{
245
	address_box.top = TOOLBAR_H/2-7;
245
	address_box.top = TOOLBAR_H/2-7;
246
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
246
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
247
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, 
247
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, 
248
		Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom);
248
		Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom);
249
	WB1.list.wheel_size = 7;
249
	WB1.list.wheel_size = 7;
250
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
250
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
251
	WB1.list.visible = WB1.list.h - 5 / WB1.list.item_h;
251
	WB1.list.visible = WB1.list.h - 5 / WB1.list.item_h;
252
	if (WB1.list.w!=WB1.DrawBuf.bufw) WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 30);
252
	if (WB1.list.w!=WB1.DrawBuf.bufw) WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 30);
253
}
253
}
254
 
254
 
255
 
255
 
256
 
256
 
257
void Draw_Window()
257
void Draw_Window()
258
{
258
{
259
	int list__w, list__h;
259
	int list__w, list__h;
260
	DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
260
	DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
261
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
261
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
262
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
262
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
263
	SetElementSizes();
263
	SetElementSizes();
264
	DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 20,border_color);
264
	DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 20,border_color);
265
	DefineButton(address_box.left-50, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0);
265
	DefineButton(address_box.left-50, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0);
266
	DefineButton(address_box.left-26, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0);
266
	DefineButton(address_box.left-26, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0);
267
	img_draw stdcall(skin.image, address_box.left-51, address_box.top-3, 48, skin.h, 3, 0);
267
	img_draw stdcall(skin.image, address_box.left-51, address_box.top-3, 48, skin.h, 3, 0);
268
	DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
268
	DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
269
	DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
269
	DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
270
	img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0);
270
	img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0);
271
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
271
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
272
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
272
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
273
	if (!header) OpenPage(); else { WB1.DrawPage(); DrawEditBox(); }
273
	if (!header) OpenPage(); else { WB1.DrawPage(); DrawEditBox(); }
274
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
274
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
275
	DrawProgress();
275
	DrawProgress();
276
 
276
 
277
	/*
277
	/*
278
	list__w = 200;
278
	list__w = 200;
279
	list__h = 200;
279
	list__h = 200;
280
	label.raw_size = 0;
280
	label.raw_size = 0;
281
	label.write_buf(10,10, list__w, list__h, 0xFFFFFF, 0, 11, "Hello World!");
281
	label.write_buf(10,10, list__w, list__h, 0xFFFFFF, 0, 11, "Hello World!");
282
	label.write_buf(10,23, list__w, list__h, 0xFFFFFF, 0xFF00FF, 12, "How are you?");
282
	label.write_buf(10,23, list__w, list__h, 0xFFFFFF, 0xFF00FF, 12, "How are you?");
283
	label.write_buf(11,40, list__w, list__h, 0xFFFFFF, 0x2E74BB, 15, "Fine");
283
	label.write_buf(11,40, list__w, list__h, 0xFFFFFF, 0x2E74BB, 15, "Fine");
284
	label.apply_smooth();
284
	label.apply_smooth();
285
	label.show_buf(0,0);
285
	label.show_buf(0,0);
286
	*/
286
	*/
287
}
287
}
288
 
288
 
289
 
289
 
290
void Scan(dword id__)
290
void Scan(dword id__)
291
{
291
{
292
	action_buf=0;
292
	action_buf=0;
293
	if (WB1.list.ProcessKey(id__)) WB1.DrawPage();
293
	if (WB1.list.ProcessKey(id__)) WB1.DrawPage();
294
	else switch (id__)
294
	else switch (id__)
295
	{
295
	{
296
		case SCAN_CODE_BS:
296
		case SCAN_CODE_BS:
297
		case BACK_BUTTON:
297
		case BACK_BUTTON:
298
			if (History.back()) {
298
			if (history.back()) {
299
				strcpy(#URL, History.current());
299
				strcpy(#URL, history.current());
300
				OpenPage();
300
				OpenPage();
301
			}
301
			}
302
			return;
302
			return;
303
		case FORWARD_BUTTON:
303
		case FORWARD_BUTTON:
304
			if (History.forward()) {
304
			if (history.forward()) {
305
				strcpy(#URL, History.current());
305
				strcpy(#URL, history.current());
306
				OpenPage();
306
				OpenPage();
307
			}
307
			}
308
			return;
308
			return;
309
		case GOTOURL_BUTTON:
309
		case GOTOURL_BUTTON:
310
		case SCAN_CODE_ENTER:
310
		case SCAN_CODE_ENTER:
311
			if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') || (!strncmp(#editURL,"WebView:",9))
311
			if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') || (!strncmp(#editURL,"WebView:",9))
312
			{
312
			{
313
				strcpy(#URL, #editURL);
313
				strcpy(#URL, #editURL);
314
			}
314
			}
315
			else
315
			else
316
			{
316
			{
317
				strlcpy(#URL,"http://",7);
317
				strlcpy(#URL,"http://",7);
318
				strcat(#URL, #editURL);
318
				strcat(#URL, #editURL);
319
			}
319
			}
320
			OpenPage();
320
			OpenPage();
321
			return;
321
			return;
322
		case 063: //F5
322
		case 063: //F5
323
			IF(address_box.flags & 0b10) return;
323
			IF(address_box.flags & 0b10) return;
324
		case REFRESH_BUTTON:
324
		case REFRESH_BUTTON:
325
			if (http_transfer > 0) 
325
			if (http_transfer > 0) 
326
			{
326
			{
327
				StopLoading();
327
				StopLoading();
328
				Draw_Window();
328
				Draw_Window();
329
			}
329
			}
330
			else OpenPage();
330
			else OpenPage();
331
			return;
331
			return;
332
		case SANDWICH_BUTTON:
332
		case SANDWICH_BUTTON:
333
			mouse.y = TOOLBAR_H-6;
333
			mouse.y = TOOLBAR_H-6;
334
			mouse.x = Form.cwidth - 167;
334
			mouse.x = Form.cwidth - 167;
335
			CreateThread(#menu_rmb,#stak+4092);
335
			CreateThread(#menu_rmb,#stak+4092);
336
			return;
336
			return;
337
		case VIEW_SOURCE:
337
		case VIEW_SOURCE:
338
			WB1.list.first = 0;
338
			WB1.list.first = 0;
339
			ShowSource();
339
			ShowSource();
340
			WB1.LoadInternalPage(bufpointer, bufsize);
340
			WB1.LoadInternalPage(bufpointer, bufsize);
341
			break;
341
			break;
342
		case EDIT_SOURCE:
342
		case EDIT_SOURCE:
343
			if (!strncmp(#URL,"http:",5)) 
343
			if (!strncmp(#URL,"http:",5)) 
344
			{
344
			{
345
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
345
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
346
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
346
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
347
			}
347
			}
348
			else RunProgram("/rd/1/tinypad", #URL);
348
			else RunProgram("/rd/1/tinypad", #URL);
349
			return;
349
			return;
350
		case FREE_IMG_CACHE:
350
		case FREE_IMG_CACHE:
351
			ImgCache.Free();
351
			ImgCache.Free();
352
			notify(IMAGES_CACHE_CLEARED);
352
			notify(IMAGES_CACHE_CLEARED);
353
			WB1.DrawPage();
353
			WB1.DrawPage();
354
			return;
354
			return;
355
		case VIEW_HISTORY:
355
		case VIEW_HISTORY:
356
			strcpy(#URL, URL_SERVICE_HISTORY);
356
			strcpy(#URL, URL_SERVICE_HISTORY);
357
			OpenPage();
357
			OpenPage();
358
			return;
358
			return;
359
		case DOWNLOAD_MANAGER:
359
		case DOWNLOAD_MANAGER:
360
			if (!downloader_opened) {
360
			if (!downloader_opened) {
361
				downloader_edit = NULL;
361
				downloader_edit = NULL;
362
				CreateThread(#Downloader,#downloader_stak+4092);
362
				CreateThread(#Downloader,#downloader_stak+4092);
363
			}
363
			}
364
			return;
364
			return;
365
	}
365
	}
366
}
366
}
367
 
367
 
368
 
368
 
369
void StopLoading()
369
void StopLoading()
370
{
370
{
371
	if (http_transfer)
371
	if (http_transfer)
372
	{
372
	{
373
		EAX = http_transfer;
373
		EAX = http_transfer;
374
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
374
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
375
		$push	EAX							// save it on the stack
375
		$push	EAX							// save it on the stack
376
		http_free stdcall (http_transfer);	// abort connection
376
		http_free stdcall (http_transfer);	// abort connection
377
		$pop	EAX							
377
		$pop	EAX							
378
		free(EAX);						// free data
378
		free(EAX);						// free data
379
		http_transfer=0;
379
		http_transfer=0;
380
		bufsize = 0;
380
		bufsize = 0;
381
		bufpointer = free(bufpointer);
381
		bufpointer = free(bufpointer);
382
	}
382
	}
383
	wv_progress_bar.value = 0;
383
	wv_progress_bar.value = 0;
384
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0);
384
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0);
385
}
385
}
386
 
386
 
387
void SetPageDefaults()
387
void SetPageDefaults()
388
{
388
{
389
	strcpy(#header, #version);
389
	strcpy(#header, #version);
390
	WB1.list.count = WB1.list.first = 0;
390
	WB1.list.count = WB1.list.first = 0;
391
	stroka = 0;
391
	stroka = 0;
392
	cur_encoding = CH_NULL;
392
	cur_encoding = CH_NULL;
393
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
393
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
394
	anchor_line_num=WB1.list.first;
394
	anchor_line_num=WB1.list.first;
395
	anchor[0]='|';
395
	anchor[0]='|';
396
}
396
}
397
 
397
 
398
void OpenPage()
398
void OpenPage()
399
{
399
{
400
	StopLoading();
400
	StopLoading();
401
	souce_mode = false;
401
	souce_mode = false;
402
	strcpy(#editURL, #URL);
402
	strcpy(#editURL, #URL);
403
	History.add(#URL);
403
	history.add(#URL);
404
	if (!strncmp(#URL,"WebView:",8))
404
	if (!strncmp(#URL,"WebView:",8))
405
	{
405
	{
406
		SetPageDefaults();
406
		SetPageDefaults();
407
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
407
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
408
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
408
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
409
		DrawEditBox();
409
		DrawEditBox();
410
		return;
410
		return;
411
	}
411
	}
412
	if (!strncmp(#URL,"http:",5))
412
	if (!strncmp(#URL,"http:",5))
413
	{
413
	{
414
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
414
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
415
		http_get stdcall (#URL, 0, 0, #accept_language);
415
		http_get stdcall (#URL, 0, 0, #accept_language);
416
		http_transfer = EAX;
416
		http_transfer = EAX;
417
		if (!http_transfer)
417
		if (!http_transfer)
418
		{
418
		{
419
			StopLoading();
419
			StopLoading();
420
			bufsize = 0;
420
			bufsize = 0;
421
			bufpointer = free(bufpointer);
421
			bufpointer = free(bufpointer);
422
			ShowPage();
422
			ShowPage();
423
			return;
423
			return;
424
		}
424
		}
425
	}
425
	}
426
	else
426
	else
427
	{
427
	{
428
		file_size stdcall (#URL);
428
		file_size stdcall (#URL);
429
		bufsize = EBX;
429
		bufsize = EBX;
430
		if (bufsize)
430
		if (bufsize)
431
		{
431
		{
432
			free(bufpointer);
432
			free(bufpointer);
433
			bufpointer = malloc(bufsize);
433
			bufpointer = malloc(bufsize);
434
			SetPageDefaults();
434
			SetPageDefaults();
435
			ReadFile(0, bufsize, bufpointer, #URL);
435
			ReadFile(0, bufsize, bufpointer, #URL);
436
		}
436
		}
437
		ShowPage();
437
		ShowPage();
438
	}
438
	}
439
}
439
}
440
 
440
 
441
DrawEditBox()
441
DrawEditBox()
442
{
442
{
443
	DrawWideRectangle(address_box.left-2, address_box.top-2, address_box.width+3, 19, 2, address_box.color);
443
	DrawWideRectangle(address_box.left-2, address_box.top-2, address_box.width+3, 19, 2, address_box.color);
444
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
444
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
445
	address_box.offset = 0;
445
	address_box.offset = 0;
446
	edit_box_draw stdcall(#address_box);
446
	edit_box_draw stdcall(#address_box);
447
	if (http_transfer > 0) EAX = 131; else EAX = 52;
447
	if (http_transfer > 0) EAX = 131; else EAX = 52;
448
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0);
448
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0);
449
}
449
}
450
 
450
 
451
 
451
 
452
void ShowPage()
452
void ShowPage()
453
{
453
{
454
	DrawEditBox();
454
	DrawEditBox();
455
	if (!bufsize)
455
	if (!bufsize)
456
	{
456
	{
457
		if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
457
		if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
458
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
458
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
459
	}
459
	}
460
	else
460
	else
461
	{
461
	{
462
		WB1.Prepare();
462
		WB1.Prepare();
463
	}
463
	}
464
	//if (!header) strcpy(#header, #version);
464
	//if (!header) strcpy(#header, #version);
465
	if (!strcmp(#version, #header)) DrawTitle(#header);
465
	if (!strcmp(#version, #header)) DrawTitle(#header);
466
}
466
}
467
 
467
 
468
byte UrlExtIs(dword ext)
468
byte UrlExtIs(dword ext)
469
{
469
{
470
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
470
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
471
	return false;
471
	return false;
472
}
472
}
473
 
473
 
474
int SetSkinColors()
474
int SetSkinColors()
475
{
475
{
476
	dword image_data;
476
	dword image_data;
477
	image_data = DSDWORD[skin.image+24];
477
	image_data = DSDWORD[skin.image+24];
478
	col_bg = DSDWORD[image_data];
478
	col_bg = DSDWORD[image_data];
479
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
479
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
480
	border_color = DSDWORD[skin.w*4*7 + image_data];
480
	border_color = DSDWORD[skin.w*4*7 + image_data];
481
	wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
481
	wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
482
	$and col_bg, 0x00ffffff
482
	$and col_bg, 0x00ffffff
483
	$and panel_color, 0x00ffffff
483
	$and panel_color, 0x00ffffff
484
	$and border_color, 0x00ffffff
484
	$and border_color, 0x00ffffff
485
	$and wv_progress_bar.progress_color, 0x00ffffff
485
	$and wv_progress_bar.progress_color, 0x00ffffff
486
}
486
}
487
 
487
 
488
void DrawProgress()
488
void DrawProgress()
489
{
489
{
490
	unsigned long btn;
490
	unsigned long btn;
491
	if (http_transfer == 0) return;
491
	if (http_transfer == 0) return;
492
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
492
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
493
	DrawBar(address_box.left-2, address_box.top+15, btn, 2, wv_progress_bar.progress_color);
493
	DrawBar(address_box.left-2, address_box.top+15, btn, 2, wv_progress_bar.progress_color);
494
}
494
}
495
 
495
 
496
void ClickLink()
496
void ClickLink()
497
{
497
{
498
	if (http_transfer > 0) 
498
	if (http_transfer > 0) 
499
	{
499
	{
500
		StopLoading();
500
		StopLoading();
501
		History.back();
501
		history.back();
502
	}
502
	}
503
 
503
 
504
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));	
504
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));	
505
	//#1
505
	//#1
506
	if (URL[0] == '#')
506
	if (URL[0] == '#')
507
	{
507
	{
508
		strcpy(#anchor, #URL+strrchr(#URL, '#'));		
508
		strcpy(#anchor, #URL+strrchr(#URL, '#'));		
509
		strcpy(#URL, History.current());
509
		strcpy(#URL, history.current());
510
		WB1.list.first=WB1.list.count-WB1.list.visible;
510
		WB1.list.first=WB1.list.count-WB1.list.visible;
511
		ShowPage();
511
		ShowPage();
512
		return;
512
		return;
513
	}
513
	}
514
	//liner.ru#1
514
	//liner.ru#1
515
	if (strrchr(#URL, '#')!=-1)
515
	if (strrchr(#URL, '#')!=-1)
516
	{
516
	{
517
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
517
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
518
		URL[strrchr(#URL, '#')-1] = 0x00;
518
		URL[strrchr(#URL, '#')-1] = 0x00;
519
	}
519
	}
520
	
520
	
521
	GetAbsoluteURL(#URL);
521
	GetAbsoluteURL(#URL);
522
	
522
	
523
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
523
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
524
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) 
524
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) 
525
	{
525
	{
526
		//notify(#URL);
526
		//notify(#URL);
527
		if (!strncmp(#URL,"http://", 7))
527
		if (!strncmp(#URL,"http://", 7))
528
		{
528
		{
529
			strcpy(#downloader_edit, #URL);
529
			strcpy(#downloader_edit, #URL);
530
			CreateThread(#Downloader,#downloader_stak+4092);
530
			CreateThread(#Downloader,#downloader_stak+4092);
531
		}
531
		}
532
		else RunProgram("@open", #URL);
532
		else RunProgram("@open", #URL);
533
		strcpy(#editURL, History.current());
533
		strcpy(#editURL, history.current());
534
		strcpy(#URL, History.current());
534
		strcpy(#URL, history.current());
535
		return;
535
		return;
536
	}
536
	}
537
	if (!strncmp(#URL,"mailto:", 7))
537
	if (!strncmp(#URL,"mailto:", 7))
538
	{
538
	{
539
		notify(#URL);
539
		notify(#URL);
540
		strcpy(#editURL, History.current());
540
		strcpy(#editURL, history.current());
541
		strcpy(#URL, History.current());
541
		strcpy(#URL, history.current());
542
		return;
542
		return;
543
	}
543
	}
544
	OpenPage();
544
	OpenPage();
545
	return;
545
	return;
546
}
546
}
547
 
547
 
548
 
548
 
549
char downloader_stak[4096];
549
char downloader_stak[4096];
550
stop:
550
stop:
551
>

551
>