Subversion Repositories Kolibri OS

Rev

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

Rev 8320 Rev 8330
Line 20... Line 20...
20
#include "..\lib\obj\libio.h"
20
#include "..\lib\obj\libio.h"
21
#include "..\lib\obj\libimg.h"
21
#include "..\lib\obj\libimg.h"
22
#include "..\lib\obj\http.h"
22
#include "..\lib\obj\http.h"
23
#include "..\lib\obj\iconv.h"
23
#include "..\lib\obj\iconv.h"
24
#include "..\lib\obj\proc_lib.h"
24
#include "..\lib\obj\proc_lib.h"
-
 
25
#include "..\lib\obj\netcode.h"
Line 25... Line 26...
25
 
26
 
26
//useful patterns
27
//useful patterns
27
#include "..\lib\patterns\history.h"
28
#include "..\lib\patterns\history.h"
28
#include "..\lib\patterns\simple_open_dialog.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
29
#include "..\lib\patterns\toolbar_button.h"
30
#include "..\lib\patterns\toolbar_button.h"
Line 30... Line 31...
30
#include "..\lib\patterns\restart_process.h"
31
#include "..\lib\patterns\restart_process.h"
Line 31... Line 32...
31
 
32
 
Line 32... Line 33...
32
char editbox_icons[] = FROM "res/editbox_icons.raw";
33
char editbox_icons[] = FROM "res/editbox_icons.raw";
33
 
34
 
34
char version[]="WebView 2.7e";
35
char version[]="WebView 2.8 ALPHA PREVIEW";
Line 35... Line 36...
35
 
36
 
-
 
37
#include "texts.h"
Line 36... Line 38...
36
#include "texts.h"
38
#include "cache.h"
37
#include "cache.h"
39
#include "show_src.h"
38
#include "show_src.h"
40
 
39
 
41
bool debug_mode = false;
Line 66... Line 68...
66
 
68
 
Line 67... Line 69...
67
_history history;
69
_history history;
Line 68... Line 70...
68
 
70
 
Line 69... Line 71...
69
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
71
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
Line 70... Line 72...
70
 
72
 
Line 82... Line 84...
82
 
84
 
Line 83... Line 85...
83
_http http = 0;
85
_http http = 0;
Line 84... Line 86...
84
 
86
 
85
bool source_mode = false;
87
bool source_mode = false;
86
 
88
 
Line 87... Line 89...
87
progress_bar wv_progress_bar;
89
progress_bar prbar;
Line 108... Line 110...
108
	load_dll(boxlib,    #box_lib_init,0);
110
	load_dll(boxlib,      #box_lib_init,0);
109
	load_dll(libio,     #libio_init,1);
111
	load_dll(libio,       #libio_init,1);
110
	load_dll(libimg,    #libimg_init,1);
112
	load_dll(libimg,      #libimg_init,1);
111
	load_dll(libHTTP,   #http_lib_init,1);
113
	load_dll(libHTTP,     #http_lib_init,1);
112
	load_dll(iconv_lib, #iconv_open,0);
114
	load_dll(iconv_lib,   #iconv_open,0);
-
 
115
	load_dll(netcode_lib, #base64_encode,0);
113
	load_dll(Proc_lib,  #OpenDialog_init,0);
116
	load_dll(Proc_lib,    #OpenDialog_init,0);
114
	OpenDialog_init stdcall (#o_dialog);	
117
	OpenDialog_init stdcall (#o_dialog);	
115
}
118
}
Line 116... Line 119...
116
 
119
 
Line 154... Line 157...
154
			mouse.get();
157
			mouse.get();
Line 155... Line 158...
155
 
158
 
Line 156... Line 159...
156
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
159
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
157
 
160
 
158
			scrollbar_v_mouse (#scroll_wv);
161
			scrollbar_v_mouse (#scroll_wv);
159
			if (scroll_wv.delta) {
162
			if (scroll_wv.delta2) {
160
				WB1.list.first = scroll_wv.position;
163
				WB1.list.first = scroll_wv.position;
161
				WB1.DrawPage();
164
				WB1.DrawPage();
Line 162... Line 165...
162
				break;
165
				break;
163
			}
166
			}
164
 
167
 
165
			if (links.hover(WB1.list.y, WB1.list.first))
168
			if (links.hover(WB1.list.y, WB1.list.first))
166
			{
169
			{
167
				if (mouse.mkm) {
170
				if (mouse.key&MOUSE_MIDDLE) && (mouse.up) {
168
					if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
171
					if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
169
						EventClickLink(TARGET_NEW_WINDOW);
172
						EventClickLink(TARGET_NEW_WINDOW);
170
					} else {
173
					} else {
171
						EventClickLink(TARGET_NEW_TAB);
174
						EventClickLink(TARGET_NEW_TAB);
172
					}
175
					}
173
				}
176
				}
174
				if (mouse.lkm) { 
177
				if (mouse.key&MOUSE_LEFT) && (mouse.up) { 
175
					CursorPointer.Restore();
178
					CursorPointer.Restore();
176
					EventClickLink(TARGET_SAME_TAB);
179
					EventClickLink(TARGET_SAME_TAB);
177
				}
180
				}
178
				if (mouse.pkm) {
181
				if (mouse.key&MOUSE_RIGHT) && (mouse.up) {
179
					CursorPointer.Restore();
182
					CursorPointer.Restore();
180
					EventShowLinkMenu();
183
					EventShowLinkMenu();
181
				}
184
				}
182
			} else {
185
			} else {
183
				CursorPointer.Restore();
186
				CursorPointer.Restore();
184
				if (mouse.pkm) && (WB1.list.MouseOver(mouse.x, mouse.y)) {
187
				if (mouse.key&MOUSE_RIGHT) && (mouse.up) && (WB1.list.MouseOver(mouse.x, mouse.y)) {
185
					EventShowPageMenu();
188
					EventShowPageMenu();
Line 257... Line 260...
257
					cache.add(history.current(), http.content_pointer, http.content_received, PAGE);
260
					cache.add(history.current(), http.content_pointer, http.content_received, PAGE);
258
					LoadInternalPage(http.content_pointer, http.content_received);
261
					LoadInternalPage(http.content_pointer, http.content_received);
259
				}
262
				}
260
				else if (http_get_type==IMG) {
263
				else if (http_get_type==IMG) {
261
					cache.add(WB1.page_img.current_url(), http.content_pointer, http.content_received, IMG);
264
					cache.add(WB1.page_img.current_url(), http.content_pointer, http.content_received, IMG);
262
					WB1.page_img.set_size(http.content_pointer, http.content_received);
265
					WB1.page_img.set_size(WB1.page_img.getid, http.content_pointer, http.content_received);
263
					GetImg();
266
					GetImg();
264
				}
267
				}
265
			}
268
			}
266
			break;
269
			break;
267
		default:
270
		default:
Line 395... Line 398...
395
		case IN_NEW_WINDOW:    EventClickLink(TARGET_NEW_WINDOW); return;
398
		case IN_NEW_WINDOW:    EventClickLink(TARGET_NEW_WINDOW); return;
396
		case COPY_LINK_URL:    EventCopyLinkToClipboard(); return;
399
		case COPY_LINK_URL:    EventCopyLinkToClipboard(); return;
397
		case DOWNLOAD_LINK_CT: EventOpenDownloader( GetAbsoluteActiveURL() ); return;
400
		case DOWNLOAD_LINK_CT: EventOpenDownloader( GetAbsoluteActiveURL() ); return;
398
		case OPEN_FILE:        EventOpenDialog(); return;
401
		case OPEN_FILE:        EventOpenDialog(); return;
399
		case SCAN_CODE_F12:    EventToggleDebugMode(); return;
402
		case SCAN_CODE_F12:    EventToggleDebugMode(); return;
-
 
403
		case SCAN_CODE_F11:    show_images^=1; return;
400
	}
404
	}
401
}
405
}
Line 402... Line 406...
402
 
406
 
403
void EventToggleDebugMode()
407
void EventToggleDebugMode()
Line 418... Line 422...
418
}
422
}
Line 419... Line 423...
419
 
423
 
420
void EventEditSource()
424
void EventEditSource()
421
{
425
{
422
	if (check_is_the_adress_local(history.current())) {
426
	if (check_is_the_adress_local(history.current())) {
423
		RunProgram("/rd/1/tinypad", history.current());
427
		RunProgram("/rd/1/quark", history.current());
424
	} else {
428
	} else {
425
		CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm");
429
		CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm");
426
		if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
430
		if (!EAX) RunProgram("/rd/1/quark", "/tmp0/1/WebView_tmp.htm");
427
	}
431
	}
Line 428... Line 432...
428
}
432
}
429
 
433
 
Line 441... Line 445...
441
}
445
}
Line 442... Line 446...
442
 
446
 
443
void StopLoading()
447
void StopLoading()
444
{
448
{
445
	if (http.stop()) pause(10);
449
	if (http.stop()) pause(10);
446
	wv_progress_bar.value = 0;
450
	prbar.value = 0;
447
	DrawOmnibox();
451
	DrawOmnibox();
Line 448... Line 452...
448
}
452
}
449
 
453
 
Line 492... Line 496...
492
	}
496
	}
493
	free(data);
497
	free(data);
494
	return true;
498
	return true;
495
}
499
}
Line -... Line 500...
-
 
500
 
-
 
501
void GetUrl(dword _http_url)
-
 
502
{
-
 
503
	char new_url_full[URL_SIZE+1];
-
 
504
 
-
 
505
	if (!strncmp(_http_url,"http:",5)) {
-
 
506
		http.get(_http_url);
-
 
507
	} else if (!strncmp(_http_url,"https://",8)) {
-
 
508
		strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
-
 
509
		strncat(#new_url_full, _http_url, URL_SIZE);
-
 
510
		http.get(#new_url_full);
-
 
511
	}
-
 
512
}
496
 
513
 
497
void OpenPage(dword _open_URL)
514
void OpenPage(dword _open_URL)
498
{
515
{
499
	char new_url[URL_SIZE+1];
-
 
500
	char new_url_full[URL_SIZE+1];
516
	char new_url[URL_SIZE+1];
Line 501... Line 517...
501
	int unz_id;
517
	int unz_id;
Line 502... Line 518...
502
 
518
 
Line 540... Line 556...
540
		if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
556
		if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
541
			strcpy(#editURL, #new_url);
557
			strcpy(#editURL, #new_url);
542
		}
558
		}
Line 543... Line 559...
543
 
559
 
544
		http_get_type = PAGE;
-
 
545
		if (!strncmp(#new_url,"http:",5)) {
560
		http_get_type = PAGE;
546
			http.get(#new_url);
-
 
547
		} else if (!strncmp(#new_url,"https://",8)) {
-
 
548
			strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
-
 
549
			strncat(#new_url_full, #new_url, URL_SIZE);
-
 
550
			http.get(#new_url_full);
-
 
Line 551... Line 561...
551
		}
561
		GetUrl(#new_url);
Line 552... Line 562...
552
 
562
 
553
		DrawOmnibox();
563
		DrawOmnibox();
Line 701... Line 711...
701
			WB1.custom_encoding = CH_CP866;
711
			WB1.custom_encoding = CH_CP866;
702
			ShowSource(WB1.bufpointer, _in_bufsize);
712
			ShowSource(WB1.bufpointer, _in_bufsize);
703
		} else {
713
		} else {
704
			WB1.DrawPage();
714
			WB1.DrawPage();
705
		}
715
		}
706
		//GetImg();
716
		GetImg();
707
	}
717
	}
708
}
718
}
Line 709... Line 719...
709
 
719
 
710
bool UrlExtIs(dword base, ext)
720
bool UrlExtIs(dword base, ext)
Line 713... Line 723...
713
	return false;
723
	return false;
714
}
724
}
Line 715... Line 725...
715
 
725
 
716
void DrawProgress()
726
void DrawProgress()
717
{
727
{
718
	dword persent;
728
	dword pct;
719
	if (http.transfer == 0) return;
729
	if (!http.transfer) return;
720
	if (wv_progress_bar.max) {
730
	if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10;
721
		persent = wv_progress_bar.value*100/wv_progress_bar.max;
-
 
722
	} else {
-
 
723
		persent = 10;
-
 
724
	}
731
	if (http_get_type==IMG) pct = WB1.page_img.getid * 70 / WB1.page_img.url.count + 30;
725
	DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width+16/100, 2, 0x72B7EB);
732
	DrawBar(address_box.left-1, address_box.top+20, pct*address_box.width+16/100, 2, 0x72B7EB);
Line 726... Line 733...
726
}
733
}
727
 
734
 
728
void EventShowPageMenu()
735
void EventShowPageMenu()
Line 764... Line 771...
764
	}
771
	}
765
}
772
}
Line 766... Line 773...
766
 
773
 
767
void EventUpdateProgressBar()
774
void EventUpdateProgressBar()
768
{
775
{
769
	wv_progress_bar.max = http.content_length;
776
	prbar.max = http.content_length;
770
	if (wv_progress_bar.value != http.content_received)
777
	if (prbar.value != http.content_received)
771
	{
778
	{
772
		wv_progress_bar.value = http.content_received;	
779
		prbar.value = http.content_received;	
773
		DrawProgress();
780
		DrawProgress();
774
	}
781
	}
Line 775... Line 782...
775
}
782
}
Line 923... Line 930...
923
void HandleRedirect()
930
void HandleRedirect()
924
{
931
{
925
	char redirect_url[URL_SIZE];
932
	char redirect_url[URL_SIZE];
926
	http.header_field("location", #redirect_url, URL_SIZE);
933
	http.header_field("location", #redirect_url, URL_SIZE);
927
	get_absolute_url(#redirect_url, history.current());
934
	get_absolute_url(#redirect_url, history.current());
928
	history.back();
935
	if (http_get_type==PAGE) history.back();
929
	http.hfree();
936
	http.hfree();
930
	if (http_get_type==PAGE) OpenPage(#redirect_url);
937
	if (http_get_type==PAGE) OpenPage(#redirect_url);
931
	else if (http_get_type==IMG) http.get(#redirect_url);
938
	else if (http_get_type==IMG) GetUrl(#redirect_url);
932
}
939
}
Line 933... Line 940...
933
 
940
 
934
dword GetImg()
941
dword GetImg()
-
 
942
{
935
{
943
	if (!show_images) return;
-
 
944
	while (WB1.page_img.next_url()) {
936
	while (WB1.page_img.next_url()) {
945
		DrawProgress();
937
		if (cache.has(WB1.page_img.current_url())) continue;
946
		if (cache.has(WB1.page_img.current_url())) continue;
938
		http_get_type = IMG;
947
		http_get_type = IMG;
939
		http.get(WB1.page_img.current_url());
948
		GetUrl(WB1.page_img.current_url());
940
		return;
949
		return;
941
	}
950
	}
-
 
951
	DrawOmnibox();
942
	DrawOmnibox();
952
	WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize);
943
	WB1.DrawPage();
953
	WB1.DrawPage();
Line 944... Line 954...
944
}
954
}
945
 
955