Subversion Repositories Kolibri OS

Rev

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

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

539
>