Subversion Repositories Kolibri OS

Rev

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