Subversion Repositories Kolibri OS

Rev

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

Rev 5626 Rev 5631
Line 7... Line 7...
7
	#include "lang.h--"
7
	#include "lang.h--"
8
#endif
8
#endif
Line 9... Line 9...
9
 
9
 
10
//libraries
10
//libraries
11
#define MEMSIZE 0x100000
-
 
12
#include "..\lib\kolibri.h"
11
#define MEMSIZE 0x100000
13
#include "..\lib\strings.h"
12
#include "..\lib\strings.h"
14
#include "..\lib\gui.h"
13
#include "..\lib\gui.h"
15
#include "..\lib\encoding.h"
14
#include "..\lib\encoding.h"
16
#include "..\lib\file_system.h"
15
#include "..\lib\file_system.h"
17
#include "..\lib\mem.h"
-
 
18
#include "..\lib\dll.h"
16
#include "..\lib\mem.h"
19
#include "..\lib\draw_buf.h"
17
#include "..\lib\draw_buf.h"
20
#include "..\lib\list_box.h"
18
#include "..\lib\list_box.h"
Line 21... Line 19...
21
#include "..\lib\cursor.h"
19
#include "..\lib\cursor.h"
Line 45... Line 43...
45
	char loading[] = "Loading...
";
43
	char loading[] = "Loading...
";
46
	char page_not_found[] = FROM "html\page_not_found_en.htm";
44
	char page_not_found[] = FROM "html\page_not_found_en.htm";
47
	char accept_language[]= "Accept-Language: en\n";	
45
	char accept_language[]= "Accept-Language: en\n";	
48
#endif
46
#endif
Line -... Line 47...
-
 
47
 
-
 
48
 
49
 
49
 
50
proc_info Form;
50
proc_info Form;
51
#define WIN_W 799
51
#define WIN_W 799
Line 52... Line 52...
52
#define WIN_H 559
52
#define WIN_H 559
Line 139... Line 139...
139
	OpenPage();
139
	OpenPage();
Line 140... Line 140...
140
 
140
 
Line 141... Line 141...
141
	CreateDir("/tmp0/1/downloads");
141
	CreateDir("/tmp0/1/downloads");
142
 
142
 
143
	SetEventMask(0xa7);
-
 
144
	loop()
143
	SetEventMask(0xa7);
145
	{
144
	BEGIN_LOOP_APPLICATION:
146
		WaitEventTimeout(2);
145
		WaitEventTimeout(2);
147
		switch(EAX & 0xFF)
146
		switch(EAX & 0xFF)
148
		{
147
		{
Line 154... Line 153...
154
				//Links hover
153
				//Links hover
155
				if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
154
				if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
156
				//Menu
155
				//Menu
157
				if (m.y>WB1.list.y) && (m.y
156
				if (m.y>WB1.list.y) && (m.y
158
				{
157
				{
159
					if (m.pkm)
158
					if (m.pkm) && (m.up)
160
					{
159
					{
161
						show_menu = 1;
-
 
162
					}
-
 
163
					if (!m.pkm) && (show_menu)
-
 
164
					{
-
 
165
						show_menu = 0;
-
 
166
						SwitchToAnotherThread();
160
						SwitchToAnotherThread();
167
						CreateThread(#menu_rmb,#stak+4092);
161
						CreateThread(#menu_rmb,#stak+4092);
168
						break; 
162
						break; 
169
					}
163
					}
170
				}
164
				}
Line 188... Line 182...
188
					half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
182
					half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
189
					if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y;
183
					if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y;
190
					btn=WB1.list.first;
184
					btn=WB1.list.first;
191
					WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
185
					WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
192
					if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
186
					if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
193
					if (btn<>WB1.list.first) WB1.Parse();
187
					if (btn!=WB1.list.first) WB1.Parse();
194
				}
188
				}
195
				break;
189
				break;
196
			case evButton:
190
			case evButton:
197
				btn=GetButtonID();
191
				btn=GetButtonID();
198
				if (btn==1)	ExitProcess();
192
				if (btn==1)	ExitProcess();
Line 201... Line 195...
201
			case evKey:
195
			case evKey:
202
				key = GetKey();		
196
				key = GetKey();		
203
				if (address_box.flags & 0b10)  
197
				if (address_box.flags & 0b10)  
204
				{
198
				{
205
					if (key==ASCII_KEY_ENTER) Scan(key); else
199
					if (key==ASCII_KEY_ENTER) Scan(key); else
206
					if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
200
					if (key!=0x0d) && (key!=183) && (key!=184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
207
				}
201
				}
208
				else Scan(key);
202
				else Scan(key);
209
				break;
203
				break;
Line 210... Line 204...
210
 
204
 
Line 280... Line 274...
280
							Draw_Window();		// stop button => refresh button
274
							Draw_Window();		// stop button => refresh button
281
						}
275
						}
282
					}
276
					}
283
				}
277
				}
284
		}
278
		}
285
	}
-
 
-
 
279
	goto BEGIN_LOOP_APPLICATION;
286
}
280
}
Line 287... Line 281...
287
 
281
 
288
void SetElementSizes()
282
void SetElementSizes()
289
{
283
{
Line 380... Line 374...
380
			OpenPage();
374
			OpenPage();
381
			return;
375
			return;
Line 382... Line 376...
382
 
376
 
383
		case 006: //download manager
377
		case 006: //download manager
384
			if (!downloader_opened) {
378
			if (!downloader_opened) {
385
				strcpy(#DL_URL, "http://");
379
				strncpy(#DL_URL, "http://",7);
386
				CreateThread(#Downloader,#downloader_stak+4092);
380
				CreateThread(#Downloader,#downloader_stak+4092);
387
			}
381
			}
Line 388... Line 382...
388
			return;
382
			return;
Line 400... Line 394...
400
			WB1.list.first = 0;
394
			WB1.list.first = 0;
401
			ShowSource();
395
			ShowSource();
402
			WB1.Parse();
396
			WB1.Parse();
403
			break;
397
			break;
404
		case 053: //F4
398
		case 053: //F4
405
			if (strncmp(#URL,"http:",5)==0) 
399
			if (!strncmp(#URL,"http:",5)) 
406
			{
400
			{
407
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
401
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
408
				if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
402
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
409
			}
-
 
410
			else
-
 
411
			{
-
 
412
				RunProgram("/rd/1/tinypad", #URL);
-
 
413
			}
403
			}
-
 
404
			else RunProgram("/rd/1/tinypad", #URL);
414
			return;
405
			return;
415
		case 054: //F5
406
		case 054: //F5
416
			IF(address_box.flags & 0b10) return;
407
			IF(address_box.flags & 0b10) return;
417
		case REFRESH:
408
		case REFRESH:
418
			if (http_transfer > 0) 
409
			if (http_transfer > 0) 
Line 429... Line 420...
429
			RunProgram(#program_path, #URL);
420
			RunProgram(#program_path, #URL);
430
			return;
421
			return;
431
		case GOTOURL:
422
		case GOTOURL:
432
		case 0x0D: //enter
423
		case 0x0D: //enter
433
			if (!editURL[0]) return;
424
			if (!editURL[0]) return;
434
			if ((strncmp(#editURL,"http:",5)!=0) && (editURL[0]!='/') && ((strncmp(#editURL,"WebView:",8)!=0))
425
			if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7);
435
			{
-
 
436
				strcpy(#URL,"http://");
-
 
437
			} 
-
 
438
			else
426
			else
439
				URL[0] = 0;
427
				URL[0] = 0;
440
			strcat(#URL, #editURL);
428
			strcat(#URL, #editURL);
441
			OpenPage();
429
			OpenPage();
442
			return;
430
			return;
443
		case SEARCHWEB:
431
		case SEARCHWEB:
444
			strcpy(#URL, #search_path);
432
			sprintf(#URL,"%s%s",#search_path,#editURL);
445
			strcat(#URL, #editURL);
-
 
446
			OpenPage();
433
			OpenPage();
447
			return;
434
			return;
Line 448... Line 435...
448
 
435
 
449
		case 183: //PgDown
436
		case 183: //PgDown
Line 509... Line 496...
509
	strcpy(#URL, PageLinks.GetURL(id-401));	
496
	strcpy(#URL, PageLinks.GetURL(id-401));	
510
	//$1 - Condition Script
497
	//$1 - Condition Script
511
	if (URL[0] == '$')
498
	if (URL[0] == '$')
512
	{
499
	{
513
		if (URL[1]=='-') && (condition_href) condition_href--;
500
		if (URL[1]=='-') && (condition_href) condition_href--;
514
		if (URL[1]=='+') 
501
		else if (URL[1]=='+') 
515
		{
502
		{
516
			if (condition_href
503
			if (condition_href
517
		}
504
		}
518
		if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1);
505
		else condition_href = atoi(#URL+1);
519
		strcpy(#URL, BrowserHistory.CurrentUrl());
506
		strcpy(#URL, BrowserHistory.CurrentUrl());
520
		ShowPage();
507
		ShowPage();
521
		return;
508
		return;
522
	}
509
	}
523
	//#1
510
	//#1
Line 540... Line 527...
540
	
527
	
541
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
528
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
542
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) 
529
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) 
543
	{
530
	{
544
		//notify(#URL);
531
		//notify(#URL);
545
		if (strcmpn(#URL,"http://", 7)==0)
532
		if (!strncmp(#URL,"http://", 7))
546
		{
533
		{
547
			strcpy(#DL_URL, #URL);
534
			strcpy(#DL_URL, #URL);
548
			CreateThread(#Downloader,#downloader_stak+4092);
535
			CreateThread(#Downloader,#downloader_stak+4092);
549
		}
-
 
550
		else
-
 
551
		{
536
		}
552
			RunProgram("@open", #URL);
-
 
553
		}
537
		else RunProgram("@open", #URL);
554
		strcpy(#editURL, BrowserHistory.CurrentUrl());
538
		strcpy(#editURL, BrowserHistory.CurrentUrl());
555
		strcpy(#URL, BrowserHistory.CurrentUrl());
539
		strcpy(#URL, BrowserHistory.CurrentUrl());
556
		return;
540
		return;
557
	}
541
	}
558
	if (!strcmpn(#URL,"mailto:", 7))
542
	if (!strncmp(#URL,"mailto:", 7))
559
	{
543
	{
560
		notify(#URL);
544
		notify(#URL);
561
		strcpy(#editURL, BrowserHistory.CurrentUrl());
545
		strcpy(#editURL, BrowserHistory.CurrentUrl());
562
		strcpy(#URL, BrowserHistory.CurrentUrl());
546
		strcpy(#URL, BrowserHistory.CurrentUrl());
Line 566... Line 550...
566
	return;
550
	return;
567
}
551
}
Line 568... Line 552...
568
 
552
 
569
void StopLoading()
553
void StopLoading()
570
{
554
{
571
	if (http_transfer<>0)
555
	if (http_transfer)
572
	{
556
	{
573
		EAX = http_transfer;
557
		EAX = http_transfer;
574
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
558
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
575
		$push	EAX							// save it on the stack
559
		$push	EAX							// save it on the stack
576
		http_free stdcall (http_transfer);	// abort connection
560
		http_free stdcall (http_transfer);	// abort connection
577
		$pop	EAX							
561
		$pop	EAX							
578
		mem_Free(EAX);						// free data
562
		free(EAX);						// free data
579
		http_transfer=0;
563
		http_transfer=0;
580
		bufsize = 0;
564
		bufsize = 0;
581
		bufpointer = mem_Free(bufpointer);
565
		bufpointer = free(bufpointer);
582
	}
566
	}
583
	wv_progress_bar.value = 0;
567
	wv_progress_bar.value = 0;
584
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0);
568
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0);
Line 600... Line 584...
600
{
584
{
601
	StopLoading();
585
	StopLoading();
602
	souce_mode = false;
586
	souce_mode = false;
603
	strcpy(#editURL, #URL);
587
	strcpy(#editURL, #URL);
604
	BrowserHistory.AddUrl();
588
	BrowserHistory.AddUrl();
605
	if (strncmp(#URL,"WebView:",8)==0)
589
	if (!strncmp(#URL,"WebView:",8))
606
	{
590
	{
607
		SetPageDefaults();
591
		SetPageDefaults();
608
		if (strcmp(#URL, URL_SERVICE_HOME)==0) 
-
 
609
		{
-
 
610
			WB1.Prepare(#homepage, sizeof(homepage));
592
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.Prepare(#homepage, sizeof(homepage));
611
		}
-
 
612
		if (strcmp(#URL, URL_SERVICE_HISTORY)==0)
593
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
613
		{
-
 
614
			ShowHistory();
-
 
615
		}
-
 
616
		return;
594
		return;
617
	}
595
	}
618
	if (strncmp(#URL,"http:",5)==0)
596
	if (!strncmp(#URL,"http:",5))
619
	{
597
	{
620
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0);
598
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0);
621
		http_get stdcall (#URL, 0, 0, #accept_language);
599
		http_get stdcall (#URL, 0, 0, #accept_language);
622
		http_transfer = EAX;
600
		http_transfer = EAX;
623
		if (http_transfer == 0)
601
		if (!http_transfer)
624
		{
602
		{
625
			StopLoading();
603
			StopLoading();
626
			bufsize = 0;
604
			bufsize = 0;
627
			bufpointer = mem_Free(bufpointer);
605
			bufpointer = free(bufpointer);
628
			ShowPage();
606
			ShowPage();
629
			return;
607
			return;
630
		}
608
		}
631
	}
609
	}
632
	else
610
	else
633
	{
611
	{
634
		file_size stdcall (#URL);
612
		file_size stdcall (#URL);
635
		bufsize = EBX;
613
		bufsize = EBX;
636
		if (bufsize)
614
		if (bufsize)
637
		{
615
		{
638
			mem_Free(bufpointer);
616
			free(bufpointer);
639
			bufpointer = mem_Alloc(bufsize);
617
			bufpointer = malloc(bufsize);
640
			SetPageDefaults();
618
			SetPageDefaults();
641
			ReadFile(0, bufsize, bufpointer, #URL);
619
			ReadFile(0, bufsize, bufpointer, #URL);
642
			//ShowSource();
620
			//ShowSource();
643
		}
621
		}
644
		ShowPage();
622
		ShowPage();
Line 657... Line 635...
657
{
635
{
658
	DrawEditBox();
636
	DrawEditBox();
659
	if (!bufsize)
637
	if (!bufsize)
660
	{
638
	{
661
		PageLinks.Clear();
639
		PageLinks.Clear();
662
		if (http_transfer<>0)
640
		if (http_transfer)
663
		{
641
		{
664
			WB1.Prepare(#loading, sizeof(loading));
642
			WB1.Prepare(#loading, sizeof(loading));
665
		}
643
		}
666
		else
644
		else
667
			WB1.Prepare(#page_not_found, sizeof(page_not_found));
645
			WB1.Prepare(#page_not_found, sizeof(page_not_found));
Line 673... Line 651...
673
	if (!strcmp(#version, #header)) DrawTitle(#header);
651
	if (!strcmp(#version, #header)) DrawTitle(#header);
674
}
652
}
Line 675... Line 653...
675
 
653
 
676
byte UrlExtIs(dword ext)
654
byte UrlExtIs(dword ext)
677
{
655
{
-
 
656
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
678
	if (strcmpi(#URL + strlen(#URL) - strlen(ext), ext)==0) return 1; else return 0;
657
	return false;
Line 679... Line -...
679
}
-
 
680
 
-
 
681
 
-
 
682
 
-
 
683
 
658
}
-
 
659
 
684
stop:
660