Subversion Repositories Kolibri OS

Rev

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

Rev 8020 Rev 8278
Line 28... Line 28...
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"
30
#include "..\lib\patterns\toolbar_button.h"
30
#include "..\lib\patterns\toolbar_button.h"
31
#include "..\lib\patterns\restart_process.h"
31
#include "..\lib\patterns\restart_process.h"
Line -... Line 32...
-
 
32
 
-
 
33
char editbox_icons[] = FROM "res/editbox_icons.raw";
32
 
34
 
Line 33... Line 35...
33
#define URL_SIZE 4000
35
#define URL_SIZE 4000
Line 34... Line 36...
34
 
36
 
35
char version[]="WebView 2.65b";
37
char version[]="WebView 2.66";
36
 
38
 
37
#include "texts.h"
-
 
Line 38... Line 39...
38
#include "cache.h"
39
#include "texts.h"
Line 39... Line 40...
39
#include "show_src.h"
40
#include "cache.h"
40
#include "download_manager.h"
41
#include "show_src.h"
Line 99... Line 100...
99
 
100
 
100
char editURL[URL_SIZE+1];
101
char editURL[URL_SIZE+1];
101
edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff,
102
edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff,
Line 102... Line -...
102
	0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
-
 
103
 
-
 
104
char editbox_icons[] = FROM "editbox_icons.raw";
103
	0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
Line 105... Line 104...
105
 
104
 
Line 106... Line 105...
106
dword shared_url;
105
dword shared_url;
Line 118... Line 117...
118
	OpenDialog_init stdcall (#o_dialog);	
117
	OpenDialog_init stdcall (#o_dialog);	
119
}
118
}
Line 120... Line 119...
120
 
119
 
121
void HandleParam()
120
void HandleParam()
122
{
121
{
123
	if (param) {
-
 
124
		if (!strncmp(#param, "-download_and_exit ", 19)) {
-
 
125
			download_and_exit = true;
-
 
126
			strcpy(#downloader_edit, #param+19);
-
 
127
			Downloader();
-
 
128
			ExitProcess();
-
 
129
		} else if (!strncmp(#param, "-download ", 10)) {
122
	if (!param) {
130
			strcpy(#downloader_edit, #param+10);
123
		history.add(URL_SERVICE_HOMEPAGE);
131
			Downloader();
-
 
132
			ExitProcess();
124
	} else {
133
		} else if (!strncmp(#param, "-source ", 8)) {
125
		if (!strncmp(#param, "-source ", 8)) {
134
			source_mode = true;
126
			source_mode = true;
135
			history.add(#param + 8);
127
			history.add(#param + 8);
136
		} else if (!strncmp(#param, "-new ", 5)) {
128
		} else if (!strncmp(#param, "-new ", 5)) {
137
			history.add(#param + 5);
129
			history.add(#param + 5);
Line 142... Line 134...
142
				shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
134
				shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
143
				strncpy(shared_url, #param, URL_SIZE);
135
				strncpy(shared_url, #param, URL_SIZE);
144
				ExitProcess();
136
				ExitProcess();
145
			}
137
			}
146
		}
138
		}
147
	} else {
-
 
148
		history.add(URL_SERVICE_HOMEPAGE);
-
 
149
	}
139
	}
150
	shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE);
140
	shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE);
151
	ESDWORD[shared_url] = '\0';
141
	ESDWORD[shared_url] = '\0';
152
}
142
}
Line 153... Line 143...
153
 
143
 
154
void main()
144
void main()
155
{
145
{
156
	int i, redirect_count=0;
146
	int i, redirect_count=0;
157
	LoadLibraries();
-
 
158
	CreateDir("/tmp0/1/Downloads");
147
	LoadLibraries();
159
	//CreateDir("/tmp0/1/WebView_Cache");
148
	//CreateDir("/tmp0/1/WebView_Cache");
160
	HandleParam();
149
	HandleParam();
161
	WB1.list.SetFont(8, 14, 10011000b);
150
	WB1.list.SetFont(8, 14, 10011000b);
162
	WB1.list.no_selection = true;
151
	WB1.list.no_selection = true;
Line 436... Line 425...
436
			return;
425
			return;
437
		case VIEW_HISTORY:
426
		case VIEW_HISTORY:
438
			OpenPage(URL_SERVICE_HISTORY);
427
			OpenPage(URL_SERVICE_HISTORY);
439
			return;
428
			return;
440
		case DOWNLOAD_MANAGER:
429
		case DOWNLOAD_MANAGER:
441
			if (!downloader_opened) {
430
			EventOpenDownloader("");
442
				downloader_edit = NULL;
-
 
443
				CreateThread(#Downloader,#downloader_stak+4092);
-
 
444
			}
-
 
445
			return;
431
			return;
446
		case UPDATE_BROWSER:
432
		case UPDATE_BROWSER:
447
			EventUpdateBrowser();
433
			EventUpdateBrowser();
448
			return;
434
			return;
449
		case CLEAR_CACHE:
435
		case CLEAR_CACHE:
Line 460... Line 446...
460
		case COPY_LINK_URL:
446
		case COPY_LINK_URL:
461
			Clipboard__CopyText(GetAbsoluteActiveURL()); 
447
			Clipboard__CopyText(GetAbsoluteActiveURL()); 
462
			notify("'URL copied to clipboard'O");
448
			notify("'URL copied to clipboard'O");
463
			return;
449
			return;
464
		case DOWNLOAD_LINK_CONTENTS:
450
		case DOWNLOAD_LINK_CONTENTS:
465
			if (!downloader_opened) {
-
 
466
				id__ = GetAbsoluteActiveURL();
451
			EventOpenDownloader( GetAbsoluteActiveURL() );
467
				strcpy(#downloader_edit, id__);
-
 
468
				CreateThread(#Downloader,#downloader_stak+4092);
-
 
469
			}
-
 
470
			return;
452
			return;
471
		case OPEN_FILE:
453
		case OPEN_FILE:
472
			EventOpenDialog();
454
			EventOpenDialog();
473
			return;
455
			return;
474
		case SCAN_CODE_F12:
456
		case SCAN_CODE_F12:
Line 592... Line 574...
592
		//CACHED PAGE
574
		//CACHED PAGE
593
		LoadInternalPage(cache.current_buf, cache.current_size);
575
		LoadInternalPage(cache.current_buf, cache.current_size);
Line 594... Line 576...
594
 
576
 
595
	} else if (!strncmp(#new_url,"WebView:",8)) {
577
	} else if (!strncmp(#new_url,"WebView:",8)) {
596
		//INTERNAL PAGE
578
		//INTERNAL PAGE
597
		if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buidin_page_home, sizeof(buidin_page_home));
579
		if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home));
598
		else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buidin_page_help, sizeof(buidin_page_help));
580
		else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buildin_page_help, sizeof(buildin_page_help));
599
		else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
581
		else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
Line 600... Line 582...
600
		else LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
582
		else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
601
 
583
 
602
	} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
584
	} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
603
		//WEB PAGE
585
		//WEB PAGE
Line 616... Line 598...
616
 
598
 
Line 617... Line 599...
617
		DrawOmnibox();
599
		DrawOmnibox();
618
 
600
 
619
		if (!http.transfer) {
601
		if (!http.transfer) {
620
			StopLoading();
602
			StopLoading();
621
			LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
603
			LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
622
		}
604
		}
623
	} else {
605
	} else {
624
		//LOCAL PAGE
606
		//LOCAL PAGE
Line 628... Line 610...
628
			unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url));
610
			unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url));
629
			while (GetProcessSlot(unz_id)) pause(2);
611
			while (GetProcessSlot(unz_id)) pause(2);
630
			strcpy(#new_url, "/tmp0/1/temp/word/document.xml");
612
			strcpy(#new_url, "/tmp0/1/temp/word/document.xml");
631
		} 
613
		} 
632
		if (!GetLocalFileData(#new_url)) {
614
		if (!GetLocalFileData(#new_url)) {
633
			LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
615
			LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
634
		}
616
		}
635
	}
617
	}
636
}
618
}
Line -... Line 619...
-
 
619
 
-
 
620
dword EventOpenDownloader(dword _url)
-
 
621
{
-
 
622
	//char download_params[URL_SIZE+50];
-
 
623
	return RunProgram("/sys/network/dl", _url);
Line 637... Line 624...
637
 
624
}
638
 
625
 
639
bool EventClickAnchor()
626
bool EventClickAnchor()
Line 718... Line 705...
718
		}
705
		}
719
	} else {
706
	} else {
720
		if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) 
707
		if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) 
721
		|| (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true)
708
		|| (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true)
722
		|| (UrlExtIs(#new_url,".7z")==true) {
709
		|| (UrlExtIs(#new_url,".7z")==true) {
723
			if (!downloader_opened) {
-
 
724
				strcpy(#downloader_edit, #new_url);
710
			EventOpenDownloader(#new_url);
725
				CreateThread(#Downloader,#downloader_stak+4092);
-
 
726
			}
-
 
727
			else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
-
 
728
			return;
711
			return;
729
		}
712
		}
730
	}
713
	}
731
	OpenPage(#new_url);
714
	OpenPage(#new_url);
732
}
715
}
Line 745... Line 728...
745
	}
728
	}
746
}
729
}
Line 747... Line 730...
747
 
730
 
748
void LoadInternalPage(dword _bufdata, _in_bufsize){
731
void LoadInternalPage(dword _bufdata, _in_bufsize){
749
	if (!_bufdata) || (!_in_bufsize) {
732
	if (!_bufdata) || (!_in_bufsize) {
750
		LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
733
		LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
751
	} else {
734
	} else {
752
		WB1.list.first = 0; //scroll page to the top
735
		WB1.list.first = 0; //scroll page to the top
753
		DrawOmnibox();
736
		DrawOmnibox();
754
		if(!strrchr(#editURL, '#')) {
737
		if(!strrchr(#editURL, '#')) {
Line 890... Line 873...
890
	dword new_size;
873
	dword new_size;
891
	int error;
874
	int error;
Line 892... Line 875...
892
 
875
 
Line 893... Line 876...
893
	draw_window();
876
	draw_window();
894
 
877
 
895
	downloader_id = RunProgram(#program_path, #update_param);
878
	downloader_id = EventOpenDownloader(#update_param);
896
	do {
879
	do {
897
		slot_n = GetProcessSlot(downloader_id);
880
		slot_n = GetProcessSlot(downloader_id);