Subversion Repositories Kolibri OS

Rev

Rev 7750 | Rev 7754 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7750 Rev 7752
Line 27... Line 27...
27
#include "..\lib\patterns\history.h"
27
#include "..\lib\patterns\history.h"
28
#include "..\lib\patterns\http_downloader.h"
28
#include "..\lib\patterns\http_downloader.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
Line 30... Line 30...
30
 
30
 
31
#ifdef LANG_RUS
31
#ifdef LANG_RUS
32
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.94";
32
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 2.0 beta1";
33
#define T_LOADING "‡ £à㧪  áâà ­¨æë..."
33
#define T_LOADING "‡ £à㧪  áâà ­¨æë..."
34
#define T_RENDERING "¥­¤¥à¨­£..."
34
#define T_RENDERING "¥­¤¥à¨­£..."
35
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
35
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
36
char homepage[] = FROM "html\\homepage_ru.htm""\0";
36
char homepage[] = FROM "html\\homepage_ru.htm""\0";
Line 43... Line 43...
43
Œ¥­¥¤¦¥à § £à㧮ª";
43
Œ¥­¥¤¦¥à § £à㧮ª";
44
char link_menu[] =
44
char link_menu[] =
45
"Š®¯¨à®¢ âì áá뫪ã
45
"Š®¯¨à®¢ âì áá뫪ã
46
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
46
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
47
#else
47
#else
48
char version[]="Text-based Browser 1.94";
48
char version[]="Text-based Browser 2.0 beta1";
49
#define T_LOADING "Loading..."
49
#define T_LOADING "Loading..."
50
#define T_RENDERING "Rendering..."
50
#define T_RENDERING "Rendering..."
51
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
51
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
52
char homepage[] = FROM "html\\homepage_en.htm""\0";
52
char homepage[] = FROM "html\\homepage_en.htm""\0";
53
char help[] = FROM "html\\help_en.htm""\0";
53
char help[] = FROM "html\\help_en.htm""\0";
Line 60... Line 60...
60
char link_menu[] =
60
char link_menu[] =
61
"Copy link
61
"Copy link
62
Download link contents";
62
Download link contents";
63
#endif
63
#endif
Line -... Line 64...
-
 
64
 
-
 
65
#define URL_SIZE 4000;
64
 
66
 
65
dword col_bg = 0xE3E2E2;
67
dword col_bg = 0xE3E2E2;
66
dword panel_color  = 0xE3E2E2;
68
dword panel_color  = 0xE3E2E2;
Line 67... Line 69...
67
dword border_color = 0x8C8C8C;
69
dword border_color = 0x8C8C8C;
Line 106... Line 108...
106
};
108
};
Line 107... Line 109...
107
 
109
 
108
char default_dir[] = "/rd/1";
110
char default_dir[] = "/rd/1";
Line -... Line 111...
-
 
111
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
109
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
112
 
110
 
113
char URL[URL_SIZE];
Line 111... Line 114...
111
char editURL[sizeof(URL)];
114
char editURL[URL_SIZE];
Line 112... Line 115...
112
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL)-2,#editURL,0,NULL,19,19};
115
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,0,NULL,19,19};
113
 
116
 
Line 179... Line 182...
179
			break;
182
			break;
Line 180... Line 183...
180
 
183
 
181
		case evKey:
184
		case evKey:
182
			GetKeys();
185
			GetKeys();
183
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
186
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
184
				if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog();
187
				if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;}
185
				if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
188
				if (key_scancode == SCAN_CODE_KEY_H) {ProcessEvent(VIEW_HISTORY);break;}
186
				if (key_scancode == SCAN_CODE_KEY_U) EventViewSource();
189
				if (key_scancode == SCAN_CODE_KEY_U) {EventViewSource();break;}
187
				if (key_scancode == SCAN_CODE_KEY_T) 
190
				if (key_scancode == SCAN_CODE_KEY_T) 
188
				|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
-
 
189
				if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
191
				|| (key_scancode == SCAN_CODE_KEY_N) {RunProgram(#program_path, NULL);break;}
190
				if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER);
192
				if (key_scancode == SCAN_CODE_KEY_J) {ProcessEvent(DOWNLOAD_MANAGER);break;}
191
				if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON);
193
				if (key_scancode == SCAN_CODE_KEY_R) {ProcessEvent(REFRESH_BUTTON);break;}
192
				if (key_scancode == SCAN_CODE_ENTER) EventSeachWeb();
194
				if (key_scancode == SCAN_CODE_ENTER) {EventSeachWeb();break;}
193
				if (key_scancode == SCAN_CODE_LEFT)  ProcessEvent(BACK_BUTTON);
195
				if (key_scancode == SCAN_CODE_LEFT)  {ProcessEvent(BACK_BUTTON);break;}
-
 
196
				if (key_scancode == SCAN_CODE_RIGHT) {ProcessEvent(FORWARD_BUTTON);break;}
194
				if (key_scancode == SCAN_CODE_RIGHT) ProcessEvent(FORWARD_BUTTON);
197
				if (key_scancode == SCAN_CODE_KEY_W) {ExitProcess();break;}
Line 195... Line 198...
195
			}
198
			}
Line 196... Line 199...
196
			
199
			
Line 266... Line 269...
266
					// Loading the page is complete, free resources
269
					// Loading the page is complete, free resources
267
					history.add(#URL);
270
					history.add(#URL);
268
					bufpointer = http.content_pointer;
271
					bufpointer = http.content_pointer;
269
					bufsize = http.content_received;
272
					bufsize = http.content_received;
270
					http.free();
273
					http.free();
271
					SetPageDefaults();
-
 
272
					DrawStatusBar(T_RENDERING);
274
					DrawStatusBar(T_RENDERING);
273
					ShowPage();
275
					ShowPage();
274
					DrawStatusBar(NULL);
276
					DrawStatusBar(NULL);
275
				}
277
				}
276
			}
278
			}
Line 308... Line 310...
308
	DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
310
	DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
309
	DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
311
	DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
310
	img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y);
312
	img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y);
311
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
313
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
312
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
314
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
313
	if (!header) 
315
	if (!header) {
314
		OpenPage(); 
316
		OpenPage(); 
-
 
317
		WB1.DrawScroller();
-
 
318
	}
315
	else { 
319
	else { 
316
		WB1.DrawPage(); 
320
		WB1.DrawPage(); 
317
		DrawOmnibox(); 
321
		DrawOmnibox(); 
318
	}
322
	}
319
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
323
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
Line 412... Line 416...
412
	}
416
	}
413
	wv_progress_bar.value = 0;
417
	wv_progress_bar.value = 0;
414
	DrawOmnibox();
418
	DrawOmnibox();
415
}
419
}
Line 416... Line -...
416
 
-
 
417
void SetPageDefaults()
-
 
418
{
-
 
419
	strcpy(#header, #version);
-
 
420
	WB1.list.count = WB1.list.first = 0;
-
 
421
	cur_encoding = CH_NULL;
-
 
422
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
-
 
423
}
-
 
424
 
420
 
425
void ReplaceSpaceInUrl() {
421
void ReplaceSpaceInUrl() {
426
	int i;
422
	int i;
427
	strcpy(#editURL, #URL);
423
	strcpy(#editURL, #URL);
428
	while (i = strchr(#URL, ' '))
424
	while (i = strchr(#URL, ' '))
Line 442... Line 438...
442
	StopLoading();
438
	StopLoading();
443
	strcpy(#editURL, #URL);
439
	strcpy(#editURL, #URL);
444
	history.add(#URL);
440
	history.add(#URL);
445
	if (!strncmp(#URL,"WebView:",8))
441
	if (!strncmp(#URL,"WebView:",8))
446
	{
442
	{
447
		SetPageDefaults();
-
 
448
		if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)-1);
443
		if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage));
449
		else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)-1);
444
		else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help));
450
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
445
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
451
		else {bufsize=0; ShowPage();} //page not found
446
		else {bufsize=0; ShowPage();} //page not found
452
		DrawOmnibox();
447
		DrawOmnibox();
453
		return;
448
		return;
454
	}
449
	}
Line 457... Line 452...
457
		ReplaceSpaceInUrl();
452
		ReplaceSpaceInUrl();
458
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 68, SKIN_Y);
453
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 68, SKIN_Y);
Line 459... Line 454...
459
 
454
 
460
		if (!strncmp(#URL,"http:",5)) {
455
		if (!strncmp(#URL,"http:",5)) {
461
			http.get(#URL);
-
 
462
		}
456
			http.get(#URL);
463
		if (!strncmp(#URL,"https://",8)) {
457
		} else if (!strncmp(#URL,"https://",8)) {
464
			sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL);
458
			sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL);
465
			http.get(#getUrl);
459
			http.get(#getUrl);
466
		}
-
 
-
 
460
		}
467
		//http.get(#URL);
461
 
468
		if (!http.transfer)
462
		if (!http.transfer)
469
		{
463
		{
470
			StopLoading();
464
			StopLoading();
471
			bufsize = 0;
465
			bufsize = 0;
Line 475... Line 469...
475
		}
469
		}
476
	}
470
	}
477
	else
471
	else
478
	{
472
	{
479
		file_size stdcall (#URL);
473
		file_size stdcall (#URL);
480
		if (EBX)
474
		if (EBX) {
481
		{
-
 
482
			bufsize = EBX;
475
			bufsize = EBX;
483
			free(bufpointer);
476
			free(bufpointer);
484
			bufpointer = malloc(bufsize);
477
			bufpointer = malloc(bufsize);
485
			SetPageDefaults();
-
 
486
			ReadFile(0, bufsize, bufpointer, #URL);
478
			ReadFile(0, bufsize, bufpointer, #URL);
-
 
479
		} else {
-
 
480
			bufsize = bufpointer = 0;
487
		}
481
		}
488
		ShowPage();
482
		ShowPage();
489
	}
483
	}
490
}
484
}
Line 491... Line 485...
491
 
485
 
492
void ProcessAnchor()
486
void ProcessAnchor()
493
{
487
{
494
	char anchor[256];
488
	char anchor[256];
Line 495... Line 489...
495
	int anchor_pos;
489
	dword anchor_pos;
496
	
490
	
497
	anchor_pos = strrchr(#URL, '#')-1;
491
	anchor_pos = strrchr(#URL, '#')-1;
Line 498... Line -...
498
	strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)-1);
-
 
499
	URL[anchor_pos] = 0x00;
492
	strlcpy(#anchors.current_anchor_name, #URL+anchor_pos, sizeof(anchor)-1);
500
 
-
 
501
	//#1
493
	URL[anchor_pos] = 0x00;
502
	if (URL[0] == NULL)
-
 
503
	{
-
 
504
		if (anchor[1] == NULL) {
-
 
505
			WB1.list.first = 0;
494
 
506
		}
-
 
507
		else {
495
	if (URL[0] == NULL) {
508
			if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1);
-
 
509
		}
-
 
510
		strcpy(#URL, history.current());
496
		//case when URL consists of anchor only
511
	}
-
 
512
	//liner.ru#1
497
		if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1);
513
	else
498
		strcpy(#URL, history.current());
514
	{
499
	} else {
515
		GetAbsoluteURL(#URL);
500
		GetAbsoluteURL(#URL);
Line 516... Line 501...
516
		OpenPage();
501
		OpenPage();
517
		if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1);
502
		if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1);
518
	}
503
	}
Line 534... Line 519...
534
	else
519
	else
535
	{
520
	{
536
		strlcpy(#URL,"http://",7);
521
		strlcpy(#URL,"http://",7);
537
		strcat(#URL, #editURL);
522
		strcat(#URL, #editURL);
538
	}
523
	}
539
	ProcessLink();
524
	OpenPage();
540
}
525
}
Line 541... Line 526...
541
 
526
 
542
void EventClickLink()
527
void EventClickLink()
543
{
528
{
Line 626... Line 611...
626
	edit_box_draw stdcall(#address_box);
611
	edit_box_draw stdcall(#address_box);
627
	if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
612
	if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
628
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
613
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
629
}
614
}
Line 630... Line 615...
630
 
615
 
631
void LoadInternalPage(dword bufpos, in_filesize){
616
void LoadInternalPage(dword _bufpos, _in_filesize){
-
 
617
	bufsize = _in_filesize;
632
	bufsize = in_filesize;
618
	if (bufpointer!=_bufpos) free(bufpointer);
-
 
619
	bufpointer = malloc(bufsize);
633
	bufpointer = bufpos;
620
	memmov(bufpointer, _bufpos, bufsize);
634
	ShowPage();
621
	ShowPage();
Line 635... Line 622...
635
}
622
}
636
 
623
 
-
 
624
void ShowPage()
637
void ShowPage()
625
{
638
{
626
	WB1.list.first = 0; //scroll page to the top
639
	DrawOmnibox();
627
	DrawOmnibox();
640
	if (!bufsize) || (!bufpointer) {
628
	if (!bufsize) || (!bufpointer) {
641
		LoadInternalPage(#page_not_found, sizeof(page_not_found)-1);
629
		LoadInternalPage(#page_not_found, sizeof(page_not_found));
642
	}
630
	}
643
	WB1.Prepare();
631
	WB1.ParseHtml();
644
	if (source_mode) {
632
	if (source_mode) {
645
		source_mode = false;
633
		source_mode = false;
646
		ShowSource();
634
		ShowSource();