Subversion Repositories Kolibri OS

Rev

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

Rev 7987 Rev 8016
Line 1... Line 1...
1
//Copyright 2007-2020 by Veliant & Leency
1
//Copyright 2007-2020 by Veliant & Leency
2
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
2
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
Line 3... Line -...
3
 
-
 
4
//Licence restriction: compiling this app for WIN32 is forbidden.
-
 
5
 
3
 
6
#ifndef AUTOBUILD
4
#ifndef AUTOBUILD
7
	#include "lang.h--"
5
	#include "lang.h--"
Line 8... Line 6...
8
#endif
6
#endif
Line 30... Line 28...
30
#include "..\lib\patterns\http_downloader.h"
28
#include "..\lib\patterns\http_downloader.h"
31
#include "..\lib\patterns\simple_open_dialog.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
32
#include "..\lib\patterns\toolbar_button.h"
30
#include "..\lib\patterns\toolbar_button.h"
33
#include "..\lib\patterns\restart_process.h"
31
#include "..\lib\patterns\restart_process.h"
Line -... Line 32...
-
 
32
 
-
 
33
#define URL_SIZE 4000
-
 
34
 
-
 
35
char version[]="WebView 2.65";
34
 
36
 
35
#include "texts.h"
37
#include "texts.h"
36
#include "cache.h"
38
#include "cache.h"
37
#include "show_src.h"
39
#include "show_src.h"
Line 62... Line 64...
62
	DOWNLOAD_LINK_CONTENTS,
64
	DOWNLOAD_LINK_CONTENTS,
63
	TAB_ID,
65
	TAB_ID,
64
	TAB_CLOSE_ID = 900
66
	TAB_CLOSE_ID = 900
65
};
67
};
Line -... Line 68...
-
 
68
 
-
 
69
_history history;
66
 
70
 
Line 67... Line 71...
67
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
71
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
Line 68... Line 72...
68
 
72
 
69
#include "..\TWB\TWB.c" //HTML Parser, a core component
-
 
Line 70... Line 73...
70
 
73
#include "..\TWB\TWB.c" //HTML Parser, a core component
Line 71... Line 74...
71
TWebBrowser WB1;
74
 
72
_history history;
75
TWebBrowser WB1;
73
 
76
 
74
#include "history.h"
77
#include "history.h"
75
 
78
 
Line 76... Line -...
76
#define PADDING 9
-
 
77
#define TSZE 25
-
 
78
#define STATUSBAR_H 15
-
 
79
#define TAB_H 20
-
 
80
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
79
#define PADDING 9
Line 81... Line 80...
81
 
80
#define TSZE 25
Line 82... Line 81...
82
#define URL_SIZE 4000
81
#define STATUSBAR_H 15
Line 104... Line 103...
104
 
103
 
Line 105... Line 104...
105
char editbox_icons[] = FROM "editbox_icons.raw";
104
char editbox_icons[] = FROM "editbox_icons.raw";
Line -... Line 105...
-
 
105
 
-
 
106
dword shared_url;
106
 
107
 
107
dword shared_url;
108
dword http_get_type;
108
 
109
 
109
void LoadLibraries()
110
void LoadLibraries()
110
{
111
{
Line 200... Line 201...
200
				}
201
				}
201
			}
202
			}
202
			break;
203
			break;
Line 203... Line 204...
203
 
204
 
204
		case evButton:
205
		case evButton:
205
			ProcessEvent( GetButtonID() );
206
			ProcessEvent( @GetButtonID() );
Line 206... Line 207...
206
			break;
207
			break;
207
 
208
 
Line 258... Line 259...
258
					redirect_count++;
259
					redirect_count++;
259
					http.handle_redirect();
260
					http.handle_redirect();
260
					http.free();
261
					http.free();
261
					GetAbsoluteURL(#http.redirect_url, history.current());
262
					GetAbsoluteURL(#http.redirect_url, history.current());
262
					history.back();
263
					history.back();
263
					OpenPage(#http.redirect_url);
264
					if (http_get_type==PAGE) OpenPage(#http.redirect_url);
-
 
265
					else if (http_get_type==IMG) http.get(#http.redirect_url);
264
				} else {
266
				} else {
265
					notify("'Too many redirects.' -E");
267
					notify("'Too many redirects.' -E");
266
					StopLoading();
268
					StopLoading();
267
					redirect_count = 0;
269
					redirect_count = 0;
268
				}
270
				}
269
			} else {
271
			} else {
270
				// Loading the page is complete, free resources
272
				// Loading the page is complete, free resources
271
				redirect_count = 0;
273
				redirect_count = 0;
272
				http.free();
274
				http.free();
-
 
275
				if (http_get_type==PAGE) {
273
				pages_cache.add(history.current(), http.content_pointer, http.content_received);
276
					cache.add(history.current(), http.content_pointer, http.content_received, PAGE);
274
				LoadInternalPage(http.content_pointer, http.content_received);
277
					LoadInternalPage(http.content_pointer, http.content_received);
275
			}
278
				}
-
 
279
				else if (http_get_type==IMG) {
-
 
280
					cache.add(WB1.page_img.current_url(), http.content_pointer, http.content_received, IMG);
-
 
281
					WB1.page_img.set_data(cache.data.get_last(), http.content_received);
-
 
282
					GetImg();
-
 
283
				}
-
 
284
			}
276
			break;
285
			break;
277
		default:
286
		default:
278
			if (ESDWORD[shared_url] != '\0') {
287
			if (ESDWORD[shared_url] != '\0') {
279
				EventOpenNewTab(shared_url);
288
				EventOpenNewTab(shared_url);
280
				ESDWORD[shared_url] = '\0';
289
				ESDWORD[shared_url] = '\0';
Line 285... Line 294...
285
 
294
 
286
bool ProcessCtrlKeyEvent()
295
bool ProcessCtrlKeyEvent()
287
{
296
{
288
	if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode) 
297
	if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode) 
289
	{
298
	{
290
		case SCAN_CODE_KEY_O:
-
 
291
			EventOpenDialog();
-
 
292
			return true;
-
 
293
		case SCAN_CODE_KEY_H:
299
		case SCAN_CODE_KEY_O: EventOpenDialog(); return true;
294
			ProcessEvent(VIEW_HISTORY);
-
 
295
			return true;
300
		case SCAN_CODE_KEY_H: ProcessEvent(VIEW_HISTORY); return true;
296
		case SCAN_CODE_KEY_U:
-
 
297
			EventViewSource();
-
 
298
			return true;
-
 
299
		case SCAN_CODE_KEY_T:
301
		case SCAN_CODE_KEY_U: EventViewSource(); return true;
300
			EventOpenNewTab(URL_SERVICE_HOMEPAGE); 
-
 
301
			return true;
-
 
302
		case SCAN_CODE_KEY_N:
302
		case SCAN_CODE_KEY_T: EventOpenNewTab(URL_SERVICE_HOMEPAGE); return true;
303
			RunProgram(#program_path, NULL);
-
 
304
			return true;
-
 
305
		case SCAN_CODE_KEY_J:
303
		case SCAN_CODE_KEY_N: RunProgram(#program_path, NULL); return true;
306
			ProcessEvent(DOWNLOAD_MANAGER);
-
 
307
			return true;
-
 
308
		case SCAN_CODE_KEY_R:
304
		case SCAN_CODE_KEY_J: ProcessEvent(DOWNLOAD_MANAGER); return true;
309
			ProcessEvent(REFRESH_BUTTON);
-
 
310
			return true;
305
		case SCAN_CODE_KEY_R: ProcessEvent(REFRESH_BUTTON); return true;
311
		case SCAN_CODE_ENTER:
-
 
312
			EventSeachWeb();
-
 
313
			return true;
-
 
314
		case SCAN_CODE_LEFT:
306
		case SCAN_CODE_ENTER: EventSeachWeb(); return true;
315
			 ProcessEvent(BACK_BUTTON);
-
 
316
			 return true;
-
 
317
		case SCAN_CODE_RIGHT:
307
		case SCAN_CODE_LEFT:  ProcessEvent(BACK_BUTTON); return true;
318
			ProcessEvent(FORWARD_BUTTON);
-
 
319
			return true;
-
 
320
		case SCAN_CODE_KEY_W:
308
		case SCAN_CODE_RIGHT: ProcessEvent(FORWARD_BUTTON); return true;
321
			EventCloseActiveTab();
-
 
322
			return true;
-
 
323
		case SCAN_CODE_TAB:
309
		case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true;
324
			EventActivateNextTab();
310
		case SCAN_CODE_TAB:   EventActivateNextTab(); return true;
325
			return true;
311
		default: return false;
326
	}
-
 
327
	return false;
312
	}
Line 328... Line 313...
328
}
313
}
329
 
314
 
330
void SetElementSizes()
315
void SetElementSizes()
Line 460... Line 445...
460
			return;
445
			return;
461
		case UPDATE_BROWSER:
446
		case UPDATE_BROWSER:
462
			EventUpdateBrowser();
447
			EventUpdateBrowser();
463
			return;
448
			return;
464
		case CLEAR_CACHE:
449
		case CLEAR_CACHE:
465
			pages_cache.clear();
450
			cache.clear();
466
			notify(#clear_cache_ok);
451
			notify(#clear_cache_ok);
467
			EventRefreshPage();
452
			EventRefreshPage();
468
			return;
453
			return;
469
		case IN_NEW_TAB:
454
		case IN_NEW_TAB:
470
			EventClickLink(TARGET_NEW_TAB);
455
			EventClickLink(TARGET_NEW_TAB);
Line 601... Line 586...
601
	- local file
586
	- local file
602
	So we need to detect what incoming address is
587
	So we need to detect what incoming address is
603
	and then halndle it in the propper way.
588
	and then halndle it in the propper way.
604
	*/
589
	*/
Line 605... Line 590...
605
 
590
 
606
	if (pages_cache.has(#new_url)) {
591
	if (cache.has(#new_url)) {
607
		//CACHED PAGE
592
		//CACHED PAGE
Line 608... Line 593...
608
		LoadInternalPage(pages_cache.current_page_buf, pages_cache.current_page_size);
593
		LoadInternalPage(cache.current_buf, cache.current_size);
609
 
594
 
610
	} else if (!strncmp(#new_url,"WebView:",8)) {
595
	} else if (!strncmp(#new_url,"WebView:",8)) {
611
		//INTERNAL PAGE
596
		//INTERNAL PAGE
Line 618... Line 603...
618
		//WEB PAGE
603
		//WEB PAGE
619
		if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
604
		if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
620
			strcpy(#editURL, #new_url);
605
			strcpy(#editURL, #new_url);
621
		}
606
		}
Line -... Line 607...
-
 
607
 
622
 
608
		http_get_type = PAGE;
623
		if (!strncmp(#new_url,"http:",5)) {
609
		if (!strncmp(#new_url,"http:",5)) {
624
			http.get(#new_url);
610
			http.get(#new_url);
625
		} else if (!strncmp(#new_url,"https://",8)) {
611
		} else if (!strncmp(#new_url,"https://",8)) {
626
			strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
612
			strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
Line 777... Line 763...
777
			WB1.custom_encoding = CH_CP866;
763
			WB1.custom_encoding = CH_CP866;
778
			ShowSource(WB1.bufpointer, _in_bufsize);
764
			ShowSource(WB1.bufpointer, _in_bufsize);
779
		} else {
765
		} else {
780
			WB1.DrawPage();			
766
			WB1.DrawPage();
781
		}
767
		}
-
 
768
		//GetImg();
782
	}
769
	}
783
}
770
}
Line 784... Line 771...
784
 
771
 
785
bool UrlExtIs(dword base, ext)
772
bool UrlExtIs(dword base, ext)
Line 939... Line 926...
939
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
926
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
940
	if (links.active_url) {
927
	if (links.active_url) {
941
		ESI = math.min(status_w/6, strlen(links.active_url));
928
		ESI = math.min(status_w/6, strlen(links.active_url));
942
		WriteText(10, status_y, 0, sc.work_text, links.active_url);
929
		WriteText(10, status_y, 0, sc.work_text, links.active_url);
943
	}
930
	}
-
 
931
	if (http.transfer>0) && (http_get_type==IMG) {
-
 
932
		//
-
 
933
	}
944
	DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
934
	DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
945
	WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
935
	WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
946
}
936
}
Line 947... Line 937...
947
 
937
 
Line 981... Line 971...
981
		return #abs_url;
971
		return #abs_url;
982
	}
972
	}
983
	return 0;
973
	return 0;
984
}
974
}
Line -... Line 975...
-
 
975
 
-
 
976
dword GetImg()
-
 
977
{
-
 
978
	while (WB1.page_img.next_url()) {
-
 
979
		if (cache.has(WB1.page_img.current_url())) continue;
-
 
980
		http_get_type = IMG;
-
 
981
		http.get(WB1.page_img.current_url());
-
 
982
		return;
-
 
983
	}
-
 
984
	DrawOmnibox();
-
 
985
	WB1.DrawPage();
-
 
986
}
985
 
987
 
986
stop:
988
stop: