Subversion Repositories Kolibri OS

Rev

Rev 7796 | Rev 7800 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7739 leency 1
//Copyright 2007-2020 by Veliant & Leency
6978 leency 2
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
3067 leency 3
 
4085 leency 4
#ifndef AUTOBUILD
5
	#include "lang.h--"
6
#endif
7
 
3107 leency 8
//libraries
7771 leency 9
#define MEMSIZE 1024 * 1000
5499 leency 10
#include "..\lib\gui.h"
4508 leency 11
#include "..\lib\draw_buf.h"
12
#include "..\lib\list_box.h"
13
#include "..\lib\cursor.h"
5978 leency 14
#include "..\lib\collection.h"
6795 leency 15
#include "..\lib\random.h"
7037 leency 16
#include "..\lib\clipboard.h"
5981 leency 17
 
7437 leency 18
// *.obj libraries
5499 leency 19
#include "..\lib\obj\box_lib.h"
7049 leency 20
#include "..\lib\obj\libio.h"
21
#include "..\lib\obj\libimg.h"
5499 leency 22
#include "..\lib\obj\http.h"
5690 leency 23
#include "..\lib\obj\iconv.h"
7748 leency 24
#include "..\lib\obj\proc_lib.h"
7757 leency 25
 
5408 leency 26
//useful patterns
5978 leency 27
#include "..\lib\patterns\history.h"
6058 leency 28
#include "..\lib\patterns\http_downloader.h"
7748 leency 29
#include "..\lib\patterns\simple_open_dialog.h"
7759 leency 30
#include "..\lib\patterns\toolbar_button.h"
5408 leency 31
 
7771 leency 32
#include "texts.h"
33
#include "cache.h"
7757 leency 34
#include "show_src.h"
35
#include "download_manager.h"
7771 leency 36
 
7757 leency 37
bool debug_mode = false;
7771 leency 38
 
7791 leency 39
enum {
40
	NEW_TAB=600,
41
	ENCODINGS=700,
42
	BACK_BUTTON=800,
43
	FORWARD_BUTTON,
44
	REFRESH_BUTTON,
45
	GOTOURL_BUTTON,
46
	CHANGE_ENCODING,
47
	SANDWICH_BUTTON,
48
	VIEW_SOURCE,
49
	EDIT_SOURCE,
50
	OPEN_FILE,
51
	NEW_WINDOW,
52
	VIEW_HISTORY,
53
	DOWNLOAD_MANAGER,
54
	CLEAR_CACHE,
55
	UPDATE_BROWSER,
56
	IN_NEW_TAB,
57
	IN_NEW_WINDOW,
58
	COPY_LINK_URL,
59
	DOWNLOAD_LINK_CONTENTS,
60
	TAB_ID,
61
	TAB_CLOSE_ID = 900
62
};
63
 
7759 leency 64
#include "..\TWB\TWB.c" //HTML Parser, a core component
7757 leency 65
 
7759 leency 66
TWebBrowser WB1;
7771 leency 67
_history history;
7758 leency 68
 
7771 leency 69
#include "history.h"
7752 leency 70
 
7758 leency 71
#define PADDING 9
72
#define TSZE 25
7771 leency 73
#define STATUSBAR_H 15
74
#define TAB_H 20
7758 leency 75
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
4677 leency 76
 
7771 leency 77
#define URL_SIZE 4000
78
 
7750 leency 79
int action_buf;
7425 leency 80
 
7759 leency 81
_http http = 0;
7758 leency 82
 
7750 leency 83
bool source_mode = false;
7282 leency 84
 
5718 leency 85
progress_bar wv_progress_bar;
7750 leency 86
char stak[4096];
87
proc_info Form;
7748 leency 88
 
7780 leency 89
int menu_id=NULL;
90
 
7771 leency 91
#include "tabs.h"
92
 
7748 leency 93
char default_dir[] = "/rd/1";
7788 leency 94
od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" };
7748 leency 95
 
7755 leency 96
char editURL[URL_SIZE+1];
7758 leency 97
edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff,
98
	0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
4534 leency 99
 
7784 leency 100
char editbox_icons[] = FROM "editbox_icons.raw";
4534 leency 101
 
7784 leency 102
 
7748 leency 103
void LoadLibraries()
104
{
105
	load_dll(boxlib,    #box_lib_init,0);
106
	load_dll(libio,     #libio_init,1);
107
	load_dll(libimg,    #libimg_init,1);
108
	load_dll(libHTTP,   #http_lib_init,1);
109
	load_dll(iconv_lib, #iconv_open,0);
110
	load_dll(Proc_lib,  #OpenDialog_init,0);
111
	OpenDialog_init stdcall (#o_dialog);
112
}
113
 
114
void HandleParam()
115
{
116
	if (param) {
7765 leency 117
		if (!strncmp(#param, "-download_and_exit ", 19)) {
118
			download_and_exit = true;
119
			strcpy(#downloader_edit, #param+19);
120
			Downloader();
7748 leency 121
			ExitProcess();
7765 leency 122
		} else if (!strncmp(#param, "-download ", 10)) {
123
			strcpy(#downloader_edit, #param+10);
124
			//CreateThread(#Downloader,#downloader_stak+4092);
125
			Downloader();
126
			ExitProcess();
127
		} else if (!strncmp(#param, "-source ", 8)) {
7750 leency 128
			source_mode = true;
7765 leency 129
			history.add(#param + 8);
7748 leency 130
		} else {
7755 leency 131
			history.add(#param);
7748 leency 132
		}
133
	} else {
7755 leency 134
		history.add(URL_SERVICE_HOMEPAGE);
7748 leency 135
	}
136
}
137
 
3067 leency 138
void main()
139
{
7758 leency 140
	int i, btn, redirect_count=0;
7748 leency 141
	LoadLibraries();
7762 leency 142
	CreateDir("/tmp0/1/Downloads");
7764 leency 143
	//CreateDir("/tmp0/1/WebView_Cache");
7748 leency 144
	HandleParam();
6045 leency 145
	WB1.list.SetFont(8, 14, 10011000b);
5779 leency 146
	WB1.list.no_selection = true;
7759 leency 147
	WB1.custom_encoding = -1;
6978 leency 148
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
149
	loop() switch(WaitEvent())
150
	{
151
		case evMouse:
152
			edit_box_mouse stdcall (#address_box);
153
			mouse.get();
7757 leency 154
			if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first))
7755 leency 155
			&& (mouse.pkm) && (mouse.up) {
7770 leency 156
				if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu();
7282 leency 157
				break;
6978 leency 158
			}
7282 leency 159
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
6978 leency 160
			scrollbar_v_mouse (#scroll_wv);
161
			if (WB1.list.first != scroll_wv.position)
162
			{
163
				WB1.list.first = scroll_wv.position;
164
				WB1.DrawPage();
3067 leency 165
				break;
6978 leency 166
			}
7758 leency 167
			if (mouse.up) && (! address_box.flags & ed_focus) && (address_box.flags & ed_shift_bac)
168
			{
169
				DrawOmnibox(); //reset text selection
170
			}
6978 leency 171
			break;
5711 leency 172
 
6978 leency 173
		case evButton:
7758 leency 174
			btn = GetButtonID();
175
			if (1==btn) ExitProcess(); else ProcessEvent(btn);
6978 leency 176
			break;
5711 leency 177
 
6978 leency 178
		case evKey:
179
			GetKeys();
7771 leency 180
			//if (key_scancode == SCAN_CODE_F1) {DebugTabs();break;}
181
 
182
			if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
183
				if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();break;}
184
			}
185
 
7772 leency 186
			if (ProcessCtrlKeyEvent()) break;
7743 leency 187
 
188
			if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
189
 
7506 leency 190
			if (address_box.flags & ed_focus)