Subversion Repositories Kolibri OS

Rev

Rev 7037 | Rev 7208 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3067 leency 1
//HTML Viewer in C--
6978 leency 2
//Copyright 2007-2017 by Veliant & Leency
3
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
3067 leency 4
 
4085 leency 5
#ifndef AUTOBUILD
6
	#include "lang.h--"
7
#endif
8
 
3107 leency 9
//libraries
6738 leency 10
#define MEMSIZE 4096 * 200
5499 leency 11
#include "..\lib\gui.h"
4508 leency 12
#include "..\lib\draw_buf.h"
13
#include "..\lib\list_box.h"
14
#include "..\lib\cursor.h"
5978 leency 15
#include "..\lib\collection.h"
6045 leency 16
#include "..\lib\menu.h"
6795 leency 17
#include "..\lib\random.h"
7037 leency 18
#include "..\lib\clipboard.h"
5981 leency 19
 
3107 leency 20
//*.obj libraries
5499 leency 21
#include "..\lib\obj\box_lib.h"
7049 leency 22
#include "..\lib\obj\libio.h"
23
#include "..\lib\obj\libimg.h"
5499 leency 24
#include "..\lib\obj\http.h"
5690 leency 25
#include "..\lib\obj\iconv.h"
5408 leency 26
//useful patterns
27
#include "..\lib\patterns\libimg_load_skin.h"
5978 leency 28
#include "..\lib\patterns\history.h"
6058 leency 29
#include "..\lib\patterns\http_downloader.h"
5408 leency 30
 
6698 leency 31
char homepage[] = FROM "html\\homepage.htm""\0";
4677 leency 32
 
4026 leency 33
#ifdef LANG_RUS
7037 leency 34
char version[]="Текстовый браузер 1.72";
6045 leency 35
?define IMAGES_CACHE_CLEARED "Кэш картинок очищен"
36
?define T_LAST_SLIDE "Это последний слайд"
37
char loading[] = "Загрузка страницы...
";
6698 leency 38
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
6045 leency 39
char accept_language[]= "Accept-Language: ru\n";
40
char rmb_menu[] =
41
"Посмотреть исходник
42
Редактировать исходник
43
История
44
Менеджер загрузок";
7037 leency 45
char link_menu[] =
46
"Копировать ссылку";
4026 leency 47
#else
7037 leency 48
char version[]="Text-based Browser 1.72";
6045 leency 49
?define IMAGES_CACHE_CLEARED "Images cache cleared"
50
?define T_LAST_SLIDE "This slide is the last"
51
char loading[] = "Loading...
";
6698 leency 52
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
6045 leency 53
char accept_language[]= "Accept-Language: en\n";
54
char rmb_menu[] =
55
"View source
56
Edit source
57
History
58
Download Manager";
7037 leency 59
char link_menu[] =
60
"Copy link";
4026 leency 61
#endif
62
 
6795 leency 63
 
5773 leency 64
#define URL_SERVICE_HISTORY "WebView://history"
65
#define URL_SERVICE_HOME "WebView://home"
66
#define URL_SERVICE_SOURCE "WebView://source:"
5631 pavelyakov 67
 
3067 leency 68
proc_info Form;
69
 
5772 leency 70
//char search_path[]="http://nigma.ru/index.php?s=";
4558 hidnplayr 71
int redirected = 0;
3067 leency 72
 
4074 leency 73
char stak[4096];
5640 pavelyakov 74
 
4026 leency 75
int action_buf;
76
 
4565 leency 77
dword http_transfer = 0;
4537 leency 78
dword http_buffer;
4534 leency 79
 
6731 leency 80
dword TOOLBAR_H = 40;
5519 leency 81
dword STATUSBAR_H = 15;
4718 leency 82
dword col_bg;
83
dword panel_color;
84
dword border_color;
4677 leency 85
 
5718 leency 86
progress_bar wv_progress_bar;
6931 leency 87
bool souce_mode = false;
88
bool open_in_a_new_window = false;
4677 leency 89
 
5718 leency 90
enum {
91
	BACK_BUTTON=1000,
92
	FORWARD_BUTTON,
93
	REFRESH_BUTTON,
94
	GOTOURL_BUTTON,
6795 leency 95
	SANDWICH_BUTTON,
5768 leency 96
	VIEW_SOURCE=1100,
5718 leency 97
	EDIT_SOURCE,
98
	VIEW_HISTORY,
7037 leency 99
	//FREE_IMG_CACHE,
6795 leency 100
	DOWNLOAD_MANAGER,
7037 leency 101
	COPY_LINK=1200
5718 leency 102
};
103
 
4411 leency 104
#include "..\TWB\TWB.c"
4636 leency 105
#include "history.h"
4718 leency 106
#include "show_src.h"
6001 leency 107
#include "download_manager.h"
3067 leency 108
 
4534 leency 109
char editURL[sizeof(URL)];
110
int	mouse_twb;
6731 leency 111
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL),#editURL,#mouse_twb,2,19,19};
4534 leency 112
 
113
 
3067 leency 114
void main()
115
{
4536 leency 116
	CursorPointer.Load(#CursorFile);
5626 leency 117
	load_dll(boxlib, #box_lib_init,0);
118
	load_dll(libio, #libio_init,1);
119
	load_dll(libimg, #libimg_init,1);
120
	load_dll(libHTTP, #http_lib_init,1);
5690 leency 121
	load_dll(iconv_lib, #iconv_open,0);
5408 leency 122
	Libimg_LoadImage(#skin, abspath("wv_skin.png"));
123
	SetSkinColors();
5772 leency 124
	CreateDir("/tmp0/1/downloads");
125
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
6045 leency 126
	WB1.list.SetFont(8, 14, 10011000b);
5779 leency 127
	WB1.list.no_selection = true;
6978 leency 128
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
129
	loop() switch(WaitEvent())
130
	{
131
		case evMouse:
132
			edit_box_mouse stdcall (#address_box);
133
			mouse.get();
134
			if (WB1.list.MouseOver(mouse.x, mouse.y))
135
			{
136
				if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
137
				&& (bufsize) && (mouse.pkm) && (mouse.up) {
138
					EventShowPageMenu(mouse.x, mouse.y);
5782 leency 139
					break;
3067 leency 140
				}
6978 leency 141
				if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
142
			}
143
			scrollbar_v_mouse (#scroll_wv);
144
			if (WB1.list.first != scroll_wv.position)
145
			{
146
				WB1.list.first = scroll_wv.position;
147
				WB1.DrawPage();
3067 leency 148
				break;
6978 leency 149
			}
150
			break;
5711 leency 151
 
6978 leency 152
		case evButton:
153
			ProcessEvent(GetButtonID());
154
			break;
5711 leency 155
 
6978 leency 156
		case evKey:
157
			GetKeys();
158
			if (address_box.flags & 0b10)
159
			{
160
				if (key_ascii == ASCII_KEY_ENTER) ProcessEvent(key_scancode); else {
161
					EAX = key_editbox;
162
					edit_box_key stdcall(#address_box);
5530 leency 163
				}
6978 leency 164
			}
165
			else
166
			{
167
				if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
168
				else ProcessEvent(key_scancode);
169
			}
170
			break;
171
 
172
		case evReDraw:
173
			if (menu.list.cur_y) {
174
				ProcessEvent(menu.list.cur_y);
175
				menu.list.cur_y = 0;
176
			}
177
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0);
178
			GetProcessInfo(#Form, SelfInfo);
179
			if (Form.status_window>2) { DrawTitle(#header); break; }
180
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
181
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
182
			Draw_Window();
183
			break;
184
 
185
		case evNetwork:
186
			if (http_transfer > 0) {
187
				http_receive stdcall (http_transfer);
188
				$push EAX
189
				ESI = http_transfer;
190
				wv_progress_bar.max = ESI.http_msg.content_length;
191
				if (wv_progress_bar.value != ESI.http_msg.content_received)
5711 leency 192
				{
6978 leency 193
					wv_progress_bar.value = ESI.http_msg.content_received;
194
					DrawProgress();
5711 leency 195
				}
6978 leency 196
				$pop EAX
197
				if (EAX == 0) {
4677 leency 198
					ESI = http_transfer;
6978 leency 199
					// Handle redirects
200
					if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
4686 leency 201
					{
6978 leency 202
						redirected++;
203
						if (redirected<=5)
4563 leency 204
						{
6978 leency 205
							http_find_header_field stdcall (http_transfer, "location\0");
206
							if (EAX!=0) {
207
								ESI = EAX;
208
								EDI = #URL;
209
								do {
210
									$lodsb;
211
									$stosb;
212
								} while (AL != 0) && (AL != 13) && (AL != 10);
213
								DSBYTE[EDI-1]='\0';
214
								if (!strncmp(#URL,"https://",8))
215
								{
6985 leency 216
									history.back();
217
									strcpy(#editURL, history.current());
218
									strcpy(#URL, history.current());
6978 leency 219
									ShowErrorMessageThatHttpsIsNotSupportedYet();
220
									StopLoading();
221
									break;
4558 hidnplayr 222
								}
4563 leency 223
							}
4558 hidnplayr 224
						}
4563 leency 225
						else
226
						{
6978 leency 227
							notify("Too many redirects");
228
							StopLoading();
229
							break;
4558 hidnplayr 230
						}
6978 leency 231
					}
232
					else
233
					{
234
						redirected = 0;
4536 leency 235
					}
6978 leency 236
					// Loading the page is complete, free resources
237
					if (redirected>0)
238
					{
239
						http_free stdcall (http_transfer);
240
						http_transfer=0;
241
						GetAbsoluteURL(#URL);
242
						history.back();
243
						strcpy(#editURL, #URL);
244
						DrawEditBoxWebView();
245
						OpenPage();
246
					}
247
					else
248
					{
249
						history.add(#URL);
250
						ESI = http_transfer;
251
						bufpointer = ESI.http_msg.content_ptr;
252
						bufsize = ESI.http_msg.content_received;
253
						http_free stdcall (http_transfer);
254
						http_transfer=0;
255
						SetPageDefaults();
256
						ShowPage();
257
					}
4536 leency 258
				}
6978 leency 259
			}
260
	}
3067 leency 261
}
262
 
263
void SetElementSizes()
264
{
6731 leency 265
	address_box.top = TOOLBAR_H/2-10;
6794 leency 266
	basic_line_h = calc(WB1.list.font_h * 130) / 100;
6731 leency 267
	address_box.width = Form.cwidth - address_box.left - 50;
6803 leency 268
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
6794 leency 269
		Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h);
270
	WB1.list.wheel_size = 7 * basic_line_h;
5710 leency 271
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
6794 leency 272
	WB1.list.visible = WB1.list.h;
6045 leency 273
	if (WB1.list.w!=WB1.DrawBuf.bufw) {
6803 leency 274
		WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700);
6698 leency 275
		ProcessEvent(REFRESH_BUTTON);
6045 leency 276
	}
3067 leency 277
}
278
 
5981 leency 279
 
5982 leency 280
 
3067 leency 281
void Draw_Window()
282
{
5772 leency 283
	DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
5718 leency 284
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
4677 leency 285
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
3067 leency 286
	SetElementSizes();
6731 leency 287
	DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 25,border_color);
288
	DefineButton(address_box.left-52, address_box.top-2, 24, skin.h-2, BACK_BUTTON+BT_HIDE, 0);
289
	DefineButton(address_box.left-27, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0);
290
	img_draw stdcall(skin.image, address_box.left-53, address_box.top-3, 51, skin.h, 3, 0);
5718 leency 291
	DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
6731 leency 292
	DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
293
	img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 87, 0);
4677 leency 294
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
295
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
6278 leency 296
	if (!header) OpenPage(); else { WB1.DrawPage(); DrawEditBoxWebView(); }
4692 leency 297
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
4693 leency 298
	DrawProgress();
3067 leency 299
}
300
 
301
 
6698 leency 302
void ProcessEvent(dword id__)
4413 leency 303
{
6698 leency 304
	switch (id__)
4413 leency 305
	{
6698 leency 306
		case 1:
307
			ExitProcess();
308
			return;
5711 leency 309
		case SCAN_CODE_BS:
5718 leency 310
		case BACK_BUTTON:
6021 leency 311
			if (history.back()) {
312
				strcpy(#URL, history.current());
5978 leency 313
				OpenPage();
314
			}
5711 leency 315
			return;
5718 leency 316
		case FORWARD_BUTTON:
6021 leency 317
			if (history.forward()) {
318
				strcpy(#URL, history.current());
5978 leency 319
				OpenPage();
320
			}
5711 leency 321
			return;
5718 leency 322
		case GOTOURL_BUTTON:
5772 leency 323
		case SCAN_CODE_ENTER:
6730 leency 324
			if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
325
			|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
5772 leency 326
			{
327
				strcpy(#URL, #editURL);
328
			}
5711 leency 329
			else
5772 leency 330
			{
5803 leency 331
				strlcpy(#URL,"http://",7);
5772 leency 332
				strcat(#URL, #editURL);
333
			}
5711 leency 334
			OpenPage();
335
			return;
5718 leency 336
		case 063: //F5
337
			IF(address_box.flags & 0b10) return;
338
		case REFRESH_BUTTON:
5713 leency 339
			if (http_transfer > 0)
340
			{
341
				StopLoading();
342
				Draw_Window();
343
			}
344
			else OpenPage();
345
			return;
5718 leency 346
		case SANDWICH_BUTTON:
6795 leency 347
			EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
4415 leency 348
			return;
5718 leency 349
		case VIEW_SOURCE:
350
			WB1.list.first = 0;
351
			ShowSource();
5773 leency 352
			WB1.LoadInternalPage(bufpointer, bufsize);
5718 leency 353
			break;
354
		case EDIT_SOURCE:
355
			if (!strncmp(#URL,"http:",5))
356
			{
357
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
358
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
359
			}
360
			else RunProgram("/rd/1/tinypad", #URL);
4415 leency 361
			return;
7037 leency 362
		// case FREE_IMG_CACHE:
363
		// 	ImgCache.Free();
364
		// 	notify(IMAGES_CACHE_CLEARED);
365
		// 	WB1.DrawPage();
366
		// 	return;
5718 leency 367
		case VIEW_HISTORY:
4677 leency 368
			strcpy(#URL, URL_SERVICE_HISTORY);
4544 leency 369
			OpenPage();
370
			return;
5718 leency 371
		case DOWNLOAD_MANAGER:
5519 leency 372
			if (!downloader_opened) {
6001 leency 373
				downloader_edit = NULL;
5519 leency 374
				CreateThread(#Downloader,#downloader_stak+4092);
375
			}
4413 leency 376
			return;
7037 leency 377
		case COPY_LINK:
378
			Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
379
			notify("'URL copied to clipboard'O");
380
			return;
4413 leency 381
	}
382
}
383
 
4636 leency 384
void StopLoading()
385
{
5631 pavelyakov 386
	if (http_transfer)
4647 leency 387
	{
388
		EAX = http_transfer;
389
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
390
		$push	EAX							// save it on the stack
391
		http_free stdcall (http_transfer);	// abort connection
392
		$pop	EAX
5631 pavelyakov 393
		free(EAX);						// free data
4647 leency 394
		http_transfer=0;
395
		bufsize = 0;
5631 pavelyakov 396
		bufpointer = free(bufpointer);
4647 leency 397
	}
5519 leency 398
	wv_progress_bar.value = 0;
6731 leency 399
	DrawEditBoxWebView();
4645 leency 400
}
401
 
402
void SetPageDefaults()
403
{
404
	strcpy(#header, #version);
405
	WB1.list.count = WB1.list.first = 0;
5704 leency 406
	cur_encoding = CH_NULL;
4645 leency 407
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
4636 leency 408
}
409
 
4416 leency 410
void OpenPage()
411
{
4636 leency 412
	StopLoading();
4718 leency 413
	souce_mode = false;
4416 leency 414
	strcpy(#editURL, #URL);
6021 leency 415
	history.add(#URL);
5631 pavelyakov 416
	if (!strncmp(#URL,"WebView:",8))
4692 leency 417
	{
418
		SetPageDefaults();
5747 leency 419
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
5631 pavelyakov 420
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
6278 leency 421
		DrawEditBoxWebView();
4692 leency 422
		return;
423
	}
5631 pavelyakov 424
	if (!strncmp(#URL,"http:",5))
4416 leency 425
	{
5718 leency 426
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
5534 hidnplayr 427
		http_get stdcall (#URL, 0, 0, #accept_language);
4636 leency 428
		http_transfer = EAX;
5631 pavelyakov 429
		if (!http_transfer)
4646 leency 430
		{
431
			StopLoading();
432
			bufsize = 0;
5631 pavelyakov 433
			bufpointer = free(bufpointer);
4646 leency 434
			ShowPage();
435
			return;
436
		}
4416 leency 437
	}
4636 leency 438
	else
439
	{
440
		file_size stdcall (#URL);
441
		bufsize = EBX;
4650 leency 442
		if (bufsize)
443
		{
5631 pavelyakov 444
			free(bufpointer);
445
			bufpointer = malloc(bufsize);
4650 leency 446
			SetPageDefaults();
4718 leency 447
			ReadFile(0, bufsize, bufpointer, #URL);
4650 leency 448
		}
4645 leency 449
		ShowPage();
4636 leency 450
	}
4416 leency 451
}
4415 leency 452
 
6278 leency 453
DrawEditBoxWebView()
4508 leency 454
{
6731 leency 455
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
456
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
4718 leency 457
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
458
	address_box.offset = 0;
4508 leency 459
	edit_box_draw stdcall(#address_box);
6731 leency 460
	if (http_transfer > 0) EAX = 131; else EAX = 54;
5772 leency 461
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0);
4718 leency 462
}
4415 leency 463
 
4718 leency 464
 
465
void ShowPage()
466
{
6278 leency 467
	DrawEditBoxWebView();
6783 leency 468
	debugval("bufsize", bufsize);
4540 leency 469
	if (!bufsize)
4508 leency 470
	{
5773 leency 471
		if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
472
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
4508 leency 473
	}
474
	else
5768 leency 475
	{
5766 leency 476
		WB1.Prepare();
5768 leency 477
	}
4508 leency 478
}
479
 
5493 leency 480
byte UrlExtIs(dword ext)
481
{
5631 pavelyakov 482
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
483
	return false;
5493 leency 484
}
4508 leency 485
 
5772 leency 486
int SetSkinColors()
487
{
488
	dword image_data;
489
	image_data = DSDWORD[skin.image+24];
490
	col_bg = DSDWORD[image_data];
491
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
492
	border_color = DSDWORD[skin.w*4*7 + image_data];
493
	wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
494
	$and col_bg, 0x00ffffff
495
	$and panel_color, 0x00ffffff
496
	$and border_color, 0x00ffffff
497
	$and wv_progress_bar.progress_color, 0x00ffffff
498
}
4544 leency 499
 
5772 leency 500
void DrawProgress()
501
{
502
	unsigned long btn;
503
	if (http_transfer == 0) return;
504
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
6731 leency 505
	DrawBar(address_box.left-2, address_box.top+20, btn, 2, wv_progress_bar.progress_color);
5772 leency 506
}
5746 leency 507
 
6931 leency 508
 
6803 leency 509
char anchor[256];
5774 leency 510
void ClickLink()
511
{
512
	if (http_transfer > 0)
513
	{
514
		StopLoading();
6021 leency 515
		history.back();
5774 leency 516
	}
5772 leency 517
 
5774 leency 518
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));
519
	//#1
520
	if (URL[0] == '#')
521
	{
6730 leency 522
		if (URL[1] == NULL) {
523
			WB1.list.first = 0;
524
			strcpy(#URL, history.current());
525
		}
526
		else {
527
			strlcpy(#anchor, #URL+strrchr(#URL, '#'), sizeof(anchor));
528
			strcpy(#URL, history.current());
529
		}
530
		ShowPage();
5774 leency 531
		return;
532
	}
533
	//liner.ru#1
6730 leency 534
	if (strrchr(#URL, '#')!=0)
5774 leency 535
	{
6803 leency 536
		strlcpy(#anchor, #URL+strrchr(#URL, '#'), sizeof(anchor));
5774 leency 537
		URL[strrchr(#URL, '#')-1] = 0x00;
538
	}
6730 leency 539
 
540
	if (!strncmp(#URL,"mailto:", 7))
541
	{
542
		notify(#URL);
543
		strcpy(#editURL, history.current());
544
		strcpy(#URL, history.current());
545
		return;
546
	}
547
 
6731 leency 548
	if (!strncmp(#URL,"https://",8))
6730 leency 549
	{
6794 leency 550
		ShowErrorMessageThatHttpsIsNotSupportedYet();
6985 leency 551
		strcpy(#editURL, history.current());
552
		strcpy(#URL, history.current());
553
		return;
6730 leency 554
	}
5774 leency 555
 
5990 leency 556
	GetAbsoluteURL(#URL);
6730 leency 557
 
558
	if (strncmp(#URL,"http://",7)!=0)
5774 leency 559
	{
6730 leency 560
		if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true)
561
		{
562
			RunProgram("/sys/@open", #URL);
563
			strcpy(#editURL, history.current());
564
			strcpy(#URL, history.current());
565
			return;
566
		}
567
	}
568
	else
569
	{
570
		if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true)
6794 leency 571
		|| (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true) || (UrlExtIs(".pdf")==true)
572
		|| (UrlExtIs(".7z")==true) {
6986 leency 573
			if (!downloader_opened) {
574
				strcpy(#downloader_edit, #URL);
575
				CreateThread(#Downloader,#downloader_stak+4092);
576
				strcpy(#editURL, history.current());
577
				strcpy(#URL, history.current());
578
			}
579
			else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
6730 leency 580
			return;
5774 leency 581
		}
582
	}
6931 leency 583
	if (open_in_a_new_window)
584
	{
585
		RunProgram(#program_path, #URL);
586
		strcpy(#editURL, history.current());
587
		strcpy(#URL, history.current());
588
	}
589
	else
590
	{
591
		OpenPage();
592
	}
593
	open_in_a_new_window = false;
5774 leency 594
}
595
 
6795 leency 596
void EventShowPageMenu(dword _left, _top)
6782 leency 597
{
598
	menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE);
599
}
600
 
6795 leency 601
void EventShowLinkMenu(dword _left, _top)
602
{
603
	menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 180, #link_menu, COPY_LINK);
604
}
605
 
606
 
6794 leency 607
void ShowErrorMessageThatHttpsIsNotSupportedYet()
608
{
609
	notify("'HTTPS protocol is not supported yet' -E");
610
}
611
 
6795 leency 612
DrawStatusBar(dword _status_text)
613
{
614
	status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
615
	status_text.start_y = Form.cheight - STATUSBAR_H + 3;
616
	status_text.area_size_x = Form.cwidth - status_text.start_x -3;
617
	DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
618
	status_text.text_pointer = _status_text;
619
	PathShow_prepare stdcall(#status_text);
620
	PathShow_draw stdcall(#status_text);
621
}
622
 
5631 pavelyakov 623
stop: