Subversion Repositories Kolibri OS

Rev

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