Subversion Repositories Kolibri OS

Rev

Rev 7970 | Rev 7987 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7970 Rev 7976
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...
3
 
3
 
4
//Licence restriction: compiling this app for WIN32 is forbidden.
4
//Licence restriction: compiling this app for WIN32 is forbidden.
5
 
5
 
6
#ifndef AUTOBUILD
6
#ifndef AUTOBUILD
7
	#include "lang.h--"
7
	#include "lang.h--"
8
#endif
8
#endif
9
 
9
 
10
//libraries
10
//libraries
11
#define MEMSIZE 1024 * 1000
11
#define MEMSIZE 1024 * 1000
12
#include "..\lib\gui.h"
12
#include "..\lib\gui.h"
13
#include "..\lib\draw_buf.h"
13
#include "..\lib\draw_buf.h"
14
#include "..\lib\list_box.h"
14
#include "..\lib\list_box.h"
15
#include "..\lib\cursor.h"
15
#include "..\lib\cursor.h"
16
#include "..\lib\collection.h"
16
#include "..\lib\collection.h"
17
#include "..\lib\random.h"
17
#include "..\lib\random.h"
18
#include "..\lib\clipboard.h"
18
#include "..\lib\clipboard.h"
19
 
19
 
20
// *.obj libraries
20
// *.obj libraries
21
#include "..\lib\obj\box_lib.h"
21
#include "..\lib\obj\box_lib.h"
22
#include "..\lib\obj\libio.h"
22
#include "..\lib\obj\libio.h"
23
#include "..\lib\obj\libimg.h"
23
#include "..\lib\obj\libimg.h"
24
#include "..\lib\obj\http.h"
24
#include "..\lib\obj\http.h"
25
#include "..\lib\obj\iconv.h"
25
#include "..\lib\obj\iconv.h"
26
#include "..\lib\obj\proc_lib.h"
26
#include "..\lib\obj\proc_lib.h"
27
 
27
 
28
//useful patterns
28
//useful patterns
29
#include "..\lib\patterns\history.h"
29
#include "..\lib\patterns\history.h"
30
#include "..\lib\patterns\http_downloader.h"
30
#include "..\lib\patterns\http_downloader.h"
31
#include "..\lib\patterns\simple_open_dialog.h"
31
#include "..\lib\patterns\simple_open_dialog.h"
32
#include "..\lib\patterns\toolbar_button.h"
32
#include "..\lib\patterns\toolbar_button.h"
33
#include "..\lib\patterns\restart_process.h"
33
#include "..\lib\patterns\restart_process.h"
34
 
34
 
35
#include "texts.h"
35
#include "texts.h"
36
#include "cache.h"
36
#include "cache.h"
37
#include "show_src.h"
37
#include "show_src.h"
38
#include "download_manager.h"
38
#include "download_manager.h"
39
 
39
 
40
bool debug_mode = false;
40
bool debug_mode = false;
41
 
41
 
42
enum { 
42
enum { 
43
	NEW_TAB=600,
43
	NEW_TAB=600,
44
	ENCODINGS=700,
44
	ENCODINGS=700,
45
	BACK_BUTTON=800, 
45
	BACK_BUTTON=800, 
46
	FORWARD_BUTTON, 
46
	FORWARD_BUTTON, 
47
	REFRESH_BUTTON, 
47
	REFRESH_BUTTON, 
48
	GOTOURL_BUTTON, 
48
	GOTOURL_BUTTON, 
49
	CHANGE_ENCODING,
49
	CHANGE_ENCODING,
50
	SANDWICH_BUTTON,
50
	SANDWICH_BUTTON,
51
	VIEW_SOURCE,
51
	VIEW_SOURCE,
52
	EDIT_SOURCE,
52
	EDIT_SOURCE,
53
	OPEN_FILE,
53
	OPEN_FILE,
54
	NEW_WINDOW,
54
	NEW_WINDOW,
55
	VIEW_HISTORY,
55
	VIEW_HISTORY,
56
	DOWNLOAD_MANAGER,
56
	DOWNLOAD_MANAGER,
57
	CLEAR_CACHE,
57
	CLEAR_CACHE,
58
	UPDATE_BROWSER,
58
	UPDATE_BROWSER,
59
	IN_NEW_TAB,
59
	IN_NEW_TAB,
60
	IN_NEW_WINDOW,
60
	IN_NEW_WINDOW,
61
	COPY_LINK_URL,
61
	COPY_LINK_URL,
62
	DOWNLOAD_LINK_CONTENTS,
62
	DOWNLOAD_LINK_CONTENTS,
63
	TAB_ID,
63
	TAB_ID,
64
	TAB_CLOSE_ID = 900
64
	TAB_CLOSE_ID = 900
65
};
65
};
66
 
66
 
67
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
67
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
68
 
68
 
69
#include "..\TWB\TWB.c" //HTML Parser, a core component
69
#include "..\TWB\TWB.c" //HTML Parser, a core component
70
 
70
 
71
TWebBrowser WB1;
71
TWebBrowser WB1;
72
_history history;
72
_history history;
73
 
73
 
74
#include "history.h"
74
#include "history.h"
75
 
75
 
76
#define PADDING 9
76
#define PADDING 9
77
#define TSZE 25
77
#define TSZE 25
78
#define STATUSBAR_H 15
78
#define STATUSBAR_H 15
79
#define TAB_H 20
79
#define TAB_H 20
80
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
80
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
81
 
81
 
82
#define URL_SIZE 4000
82
#define URL_SIZE 4000
83
 
83
 
84
int action_buf;
84
int action_buf;
85
 
85
 
86
_http http = 0;
86
_http http = 0;
87
 
87
 
88
bool source_mode = false;
88
bool source_mode = false;
89
 
89
 
90
progress_bar wv_progress_bar;
90
progress_bar wv_progress_bar;
91
char stak[4096];
91
char stak[4096];
92
proc_info Form;
92
proc_info Form;
93
 
93
 
94
int menu_id=NULL;
94
int menu_id=NULL;
95
 
95
 
96
#include "tabs.h"
96
#include "tabs.h"
97
 
97
 
98
char default_dir[] = "/rd/1";
98
char default_dir[] = "/rd/1";
99
od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" };
99
od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" };
100
 
100
 
101
char editURL[URL_SIZE+1];
101
char editURL[URL_SIZE+1];
102
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,
103
	0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
103
	0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
104
 
104
 
105
char editbox_icons[] = FROM "editbox_icons.raw";
105
char editbox_icons[] = FROM "editbox_icons.raw";
106
 
106
 
107
dword shared_url;
107
dword shared_url;
108
 
108
 
109
void LoadLibraries()
109
void LoadLibraries()
110
{
110
{
111
	load_dll(boxlib,    #box_lib_init,0);
111
	load_dll(boxlib,    #box_lib_init,0);
112
	load_dll(libio,     #libio_init,1);
112
	load_dll(libio,     #libio_init,1);
113
	load_dll(libimg,    #libimg_init,1);
113
	load_dll(libimg,    #libimg_init,1);
114
	load_dll(libHTTP,   #http_lib_init,1);
114
	load_dll(libHTTP,   #http_lib_init,1);
115
	load_dll(iconv_lib, #iconv_open,0);
115
	load_dll(iconv_lib, #iconv_open,0);
116
	load_dll(Proc_lib,  #OpenDialog_init,0);
116
	load_dll(Proc_lib,  #OpenDialog_init,0);
117
	OpenDialog_init stdcall (#o_dialog);	
117
	OpenDialog_init stdcall (#o_dialog);	
118
}
118
}
119
 
119
 
120
void HandleParam()
120
void HandleParam()
121
{
121
{
122
	if (param) {
122
	if (param) {
123
		if (!strncmp(#param, "-download_and_exit ", 19)) {
123
		if (!strncmp(#param, "-download_and_exit ", 19)) {
124
			download_and_exit = true;
124
			download_and_exit = true;
125
			strcpy(#downloader_edit, #param+19);
125
			strcpy(#downloader_edit, #param+19);
126
			Downloader();
126
			Downloader();
127
			ExitProcess();
127
			ExitProcess();
128
		} else if (!strncmp(#param, "-download ", 10)) {
128
		} else if (!strncmp(#param, "-download ", 10)) {
129
			strcpy(#downloader_edit, #param+10);
129
			strcpy(#downloader_edit, #param+10);
130
			Downloader();
130
			Downloader();
131
			ExitProcess();
131
			ExitProcess();
132
		} else if (!strncmp(#param, "-source ", 8)) {
132
		} else if (!strncmp(#param, "-source ", 8)) {
133
			source_mode = true;
133
			source_mode = true;
134
			history.add(#param + 8);
134
			history.add(#param + 8);
135
		} else if (!strncmp(#param, "-new ", 5)) {
135
		} else if (!strncmp(#param, "-new ", 5)) {
136
			history.add(#param + 5);
136
			history.add(#param + 5);
137
		} else {
137
		} else {
138
			if (GetProcessesCount("WEBVIEW") == 1) {
138
			if (GetProcessesCount("WEBVIEW") == 1) {
139
				history.add(#param);
139
				history.add(#param);
140
			} else {
140
			} else {
141
				shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
141
				shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
142
				strncpy(shared_url, #param, URL_SIZE);
142
				strncpy(shared_url, #param, URL_SIZE);
143
				ExitProcess();
143
				ExitProcess();
144
			}
144
			}
145
		}
145
		}
146
	} else {
146
	} else {
147
		history.add(URL_SERVICE_HOMEPAGE);
147
		history.add(URL_SERVICE_HOMEPAGE);
148
	}
148
	}
149
	shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE);
149
	shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE);
150
	ESDWORD[shared_url] = '\0';
150
	ESDWORD[shared_url] = '\0';
151
}
151
}
152
 
152
 
153
void main()
153
void main()
154
{
154
{
155
	int i, redirect_count=0;
155
	int i, redirect_count=0;
156
	LoadLibraries();
156
	LoadLibraries();
157
	CreateDir("/tmp0/1/Downloads");
157
	CreateDir("/tmp0/1/Downloads");
158
	//CreateDir("/tmp0/1/WebView_Cache");
158
	//CreateDir("/tmp0/1/WebView_Cache");
159
	HandleParam();
159
	HandleParam();
160
	WB1.list.SetFont(8, 14, 10011000b);
160
	WB1.list.SetFont(8, 14, 10011000b);
161
	WB1.list.no_selection = true;
161
	WB1.list.no_selection = true;
162
	WB1.custom_encoding = -1;
162
	WB1.custom_encoding = -1;
163
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
163
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
164
	loop() switch(@WaitEventTimeout(30))
164
	loop() switch(@WaitEventTimeout(30))
165
	{
165
	{
166
		case evMouse:
166
		case evMouse:
167
			edit_box_mouse stdcall (#address_box);
167
			edit_box_mouse stdcall (#address_box);
168
			mouse.get();
168
			mouse.get();
169
 
169
 
170
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
170
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
171
 
171
 
172
			scrollbar_v_mouse (#scroll_wv);
172
			scrollbar_v_mouse (#scroll_wv);
173
			if (scroll_wv.delta) {
173
			if (scroll_wv.delta) {
174
				WB1.list.first = scroll_wv.position;
174
				WB1.list.first = scroll_wv.position;
175
				WB1.DrawPage();
175
				WB1.DrawPage();
176
				break;
176
				break;
177
			}
177
			}
178
 
178
 
179
			if (links.hover(WB1.list.y, WB1.list.first))
179
			if (links.hover(WB1.list.y, WB1.list.first))
180
			{
180
			{
181
				if (mouse.mkm) {
181
				if (mouse.mkm) {
182
					if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
182
					if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
183
						EventClickLink(TARGET_NEW_WINDOW);
183
						EventClickLink(TARGET_NEW_WINDOW);
184
					} else {
184
					} else {
185
						EventClickLink(TARGET_NEW_TAB);
185
						EventClickLink(TARGET_NEW_TAB);
186
					}
186
					}
187
				}
187
				}
188
				if (mouse.lkm) { 
188
				if (mouse.lkm) { 
189
					CursorPointer.Restore();
189
					CursorPointer.Restore();
190
					EventClickLink(TARGET_SAME_TAB);
190
					EventClickLink(TARGET_SAME_TAB);
191
				}
191
				}
192
				if (mouse.pkm) {
192
				if (mouse.pkm) {
193
					CursorPointer.Restore();
193
					CursorPointer.Restore();
194
					EventShowLinkMenu();
194
					EventShowLinkMenu();
195
				}
195
				}
196
			} else {
196
			} else {
197
				CursorPointer.Restore();
197
				CursorPointer.Restore();
198
				if (mouse.pkm) && (WB1.list.MouseOver(mouse.x, mouse.y)) {
198
				if (mouse.pkm) && (WB1.list.MouseOver(mouse.x, mouse.y)) {
199
					EventShowPageMenu();
199
					EventShowPageMenu();
200
				}
200
				}
201
			}
201
			}
202
			break;
202
			break;
203
 
203
 
204
		case evButton:
204
		case evButton:
205
			ProcessEvent( GetButtonID() );
205
			ProcessEvent( GetButtonID() );
206
			break;
206
			break;
207
 
207
 
208
		case evKey:
208
		case evKey:
209
			GetKeys();
209
			GetKeys();
210
 
210
 
211
			if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
211
			if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
212
				if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();break;}
212
				if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();break;}
213
			}
213
			}
214
 
214
 
215
			if (ProcessCtrlKeyEvent()) break;
215
			if (ProcessCtrlKeyEvent()) break;
216
			
216
			
217
			if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
217
			if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
218
			
218
			
219
			if (address_box.flags & ed_focus)  
219
			if (address_box.flags & ed_focus)  
220
			{
220
			{
221
				if (key_scancode == SCAN_CODE_ENTER) {
221
				if (key_scancode == SCAN_CODE_ENTER) {
222
					ProcessEvent(key_scancode); 
222
					ProcessEvent(key_scancode); 
223
				} else {
223
				} else {
224
					EAX = key_editbox; 
224
					EAX = key_editbox; 
225
					edit_box_key stdcall(#address_box);
225
					edit_box_key stdcall(#address_box);
226
				}
226
				}
227
			} else {
227
			} else {
228
				#define KEY_SCROLL_N 11
228
				#define KEY_SCROLL_N 11
229
				if (SCAN_CODE_UP   == key_scancode) for (i=0;i
229
				if (SCAN_CODE_UP   == key_scancode) for (i=0;i
230
				if (SCAN_CODE_DOWN == key_scancode) for (i=0;i
230
				if (SCAN_CODE_DOWN == key_scancode) for (i=0;i
231
				if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();}
231
				if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();}
232
				if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
232
				if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
233
				else ProcessEvent(key_scancode);
233
				else ProcessEvent(key_scancode);
234
			}
234
			}
235
			break;
235
			break;
236
 
236
 
237
		case evReDraw:
237
		case evReDraw:
238
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), //40
238
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), //40
239
				GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
239
				GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
240
			GetProcessInfo(#Form, SelfInfo);
240
			GetProcessInfo(#Form, SelfInfo);
241
			ProcessMenuClick();
241
			ProcessMenuClick();
242
			sc.get();
242
			sc.get();
243
			if (Form.status_window>2) break;
243
			if (Form.status_window>2) break;
244
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
244
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
245
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
245
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
246
			draw_window();
246
			draw_window();
247
			break;
247
			break;
248
			
248
			
249
		case evNetwork:
249
		case evNetwork:
250
			if (http.transfer <= 0) break;
250
			if (http.transfer <= 0) break;
251
			http.receive();
251
			http.receive();
252
			EventUpdateProgressBar();
252
			EventUpdateProgressBar();
253
			if (http.receive_result != 0) break;
253
			if (http.receive_result != 0) break;
254
			if (http.status_code >= 300) && (http.status_code < 400)
254
			if (http.status_code >= 300) && (http.status_code < 400)
255
			{
255
			{
256
				// Handle redirects
256
				// Handle redirects
257
				if (redirect_count<=5) {
257
				if (redirect_count<=5) {
258
					redirect_count++;
258
					redirect_count++;
259
					http.handle_redirect();
259
					http.handle_redirect();
260
					http.free();
260
					http.free();
261
					GetAbsoluteURL(#http.redirect_url, history.current());
261
					GetAbsoluteURL(#http.redirect_url, history.current());
262
					history.back();
262
					history.back();
263
					OpenPage(#http.redirect_url);
263
					OpenPage(#http.redirect_url);
264
				} else {
264
				} else {
265
					notify("'Too many redirects.' -E");
265
					notify("'Too many redirects.' -E");
266
					StopLoading();
266
					StopLoading();
267
					redirect_count = 0;
267
					redirect_count = 0;
268
				}
268
				}
269
			} else {
269
			} else {
270
				// Loading the page is complete, free resources
270
				// Loading the page is complete, free resources
271
				redirect_count = 0;
271
				redirect_count = 0;
272
				http.free();
272
				http.free();
273
				pages_cache.add(history.current(), http.content_pointer, http.content_received);
273
				pages_cache.add(history.current(), http.content_pointer, http.content_received);
274
				LoadInternalPage(http.content_pointer, http.content_received);
274
				LoadInternalPage(http.content_pointer, http.content_received);
275
			}
275
			}
276
			break;
276
			break;
277
		default:
277
		default:
278
			if (ESDWORD[shared_url] != '\0') {
278
			if (ESDWORD[shared_url] != '\0') {
279
				EventOpenNewTab(shared_url);
279
				EventOpenNewTab(shared_url);
280
				ESDWORD[shared_url] = '\0';
280
				ESDWORD[shared_url] = '\0';
281
				ActivateWindow(GetProcessSlot(Form.ID));
281
				ActivateWindow(GetProcessSlot(Form.ID));
282
			}
282
			}
283
	}
283
	}
284
}
284
}
285
 
285
 
286
bool ProcessCtrlKeyEvent()
286
bool ProcessCtrlKeyEvent()
287
{
287
{
288
	if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode) 
288
	if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode) 
289
	{
289
	{
290
		case SCAN_CODE_KEY_O:
290
		case SCAN_CODE_KEY_O:
291
			EventOpenDialog();
291
			EventOpenDialog();
292
			return true;
292
			return true;
293
		case SCAN_CODE_KEY_H:
293
		case SCAN_CODE_KEY_H:
294
			ProcessEvent(VIEW_HISTORY);
294
			ProcessEvent(VIEW_HISTORY);
295
			return true;
295
			return true;
296
		case SCAN_CODE_KEY_U:
296
		case SCAN_CODE_KEY_U:
297
			EventViewSource();
297
			EventViewSource();
298
			return true;
298
			return true;
299
		case SCAN_CODE_KEY_T:
299
		case SCAN_CODE_KEY_T:
300
			EventOpenNewTab(URL_SERVICE_HOMEPAGE); 
300
			EventOpenNewTab(URL_SERVICE_HOMEPAGE); 
301
			return true;
301
			return true;
302
		case SCAN_CODE_KEY_N:
302
		case SCAN_CODE_KEY_N:
303
			RunProgram(#program_path, NULL);
303
			RunProgram(#program_path, NULL);
304
			return true;
304
			return true;
305
		case SCAN_CODE_KEY_J:
305
		case SCAN_CODE_KEY_J:
306
			ProcessEvent(DOWNLOAD_MANAGER);
306
			ProcessEvent(DOWNLOAD_MANAGER);
307
			return true;
307
			return true;
308
		case SCAN_CODE_KEY_R:
308
		case SCAN_CODE_KEY_R:
309
			ProcessEvent(REFRESH_BUTTON);
309
			ProcessEvent(REFRESH_BUTTON);
310
			return true;
310
			return true;
311
		case SCAN_CODE_ENTER:
311
		case SCAN_CODE_ENTER:
312
			EventSeachWeb();
312
			EventSeachWeb();
313
			return true;
313
			return true;
314
		case SCAN_CODE_LEFT:
314
		case SCAN_CODE_LEFT:
315
			 ProcessEvent(BACK_BUTTON);
315
			 ProcessEvent(BACK_BUTTON);
316
			 return true;
316
			 return true;
317
		case SCAN_CODE_RIGHT:
317
		case SCAN_CODE_RIGHT:
318
			ProcessEvent(FORWARD_BUTTON);
318
			ProcessEvent(FORWARD_BUTTON);
319
			return true;
319
			return true;
320
		case SCAN_CODE_KEY_W:
320
		case SCAN_CODE_KEY_W:
321
			EventCloseActiveTab();
321
			EventCloseActiveTab();
322
			return true;
322
			return true;
323
		case SCAN_CODE_TAB:
323
		case SCAN_CODE_TAB:
324
			EventActivateNextTab();
324
			EventActivateNextTab();
325
			return true;
325
			return true;
326
	}
326
	}
327
	return false;
327
	return false;
328
}
328
}
329
 
329
 
330
void SetElementSizes()
330
void SetElementSizes()
331
{
331
{
332
	address_box.width = Form.cwidth - address_box.left - 52 - 16;
332
	address_box.width = Form.cwidth - address_box.left - 52 - 16;
333
	WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x, 
333
	WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x, 
334
		Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H);
334
		Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H);
335
	WB1.list.wheel_size = 7 * BASIC_LINE_H;
335
	WB1.list.wheel_size = 7 * BASIC_LINE_H;
336
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
336
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
337
	WB1.list.visible = WB1.list.h;
337
	WB1.list.visible = WB1.list.h;
338
}
338
}
339
 
339
 
340
 
340
 
341
void draw_window()
341
void draw_window()
342
{
342
{
343
	int i;
343
	int i;
344
	bool burger_active = false;
344
	bool burger_active = false;
345
	if (menu_id == OPEN_FILE) burger_active = true;
345
	if (menu_id == OPEN_FILE) burger_active = true;
346
 
346
 
347
	SetElementSizes();
347
	SetElementSizes();
348
 
348
 
349
	DrawBar(0,0, Form.cwidth,PADDING, sc.work);
349
	DrawBar(0,0, Form.cwidth,PADDING, sc.work);
350
	DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work);
350
	DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work);
351
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.work_dark, sc.work, 180));
351
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.work_dark, sc.work, 180));
352
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph);
352
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph);
353
	DrawBar(0, PADDING, address_box.left-2, TSZE+1, sc.work);
353
	DrawBar(0, PADDING, address_box.left-2, TSZE+1, sc.work);
354
	DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, sc.work);
354
	DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, sc.work);
355
 
355
 
356
	DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false);
356
	DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false);
357
	DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false);
357
	DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false);
358
	DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1, burger_active); //burger menu
358
	DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1, burger_active); //burger menu
359
 
359
 
360
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
360
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
361
 
361
 
362
	DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, 
362
	DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, 
363
		WB1.list.h-1, scroll_wv.bckg_col);
363
		WB1.list.h-1, scroll_wv.bckg_col);
364
 
364
 
365
	if (!BrowserWidthChanged()) { 
365
	if (!BrowserWidthChanged()) { 
366
		WB1.DrawPage(); 
366
		WB1.DrawPage(); 
367
		DrawOmnibox(); 
367
		DrawOmnibox(); 
368
	}
368
	}
369
	DrawProgress();
369
	DrawProgress();
370
	DrawStatusBar();
370
	DrawStatusBar();
371
	DrawTabsBar();
371
	DrawTabsBar();
372
}
372
}
373
 
373
 
374
bool BrowserWidthChanged()
374
bool BrowserWidthChanged()
375
{
375
{
376
	dword source_mode_holder;
376
	dword source_mode_holder;
377
	if (WB1.list.w!=DrawBuf.bufw) {
377
	if (WB1.list.w!=DrawBuf.bufw) {
378
		DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
378
		DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
379
		if (!strncmp(history.current(),"http",4)) {
379
		if (!strncmp(history.current(),"http",4)) {
380
			//nihuya ne izyashnoe reshenie, no pust' poka butet tak
380
			//nihuya ne izyashnoe reshenie, no pust' poka butet tak
381
			source_mode_holder = source_mode;
381
			source_mode_holder = source_mode;
382
			LoadInternalPage(#loading_text, sizeof(loading_text));
382
			LoadInternalPage(#loading_text, sizeof(loading_text));
383
			source_mode = source_mode_holder;
383
			source_mode = source_mode_holder;
384
		}
384
		}
385
		OpenPage(history.current());
385
		OpenPage(history.current());
386
		return true;
386
		return true;
387
	}
387
	}
388
	return false;
388
	return false;
389
}
389
}
390
 
390
 
391
 
391
 
392
void EventChangeEncodingAndLoadPage(int _new_encoding)
392
void EventChangeEncodingAndLoadPage(int _new_encoding)
393
{
393
{
394
	dword newbuf, newsize;
394
	dword newbuf, newsize;
395
	WB1.custom_encoding = _new_encoding;
395
	WB1.custom_encoding = _new_encoding;
396
	newsize = strlen(WB1.o_bufpointer);
396
	newsize = strlen(WB1.o_bufpointer);
397
	newbuf = malloc(newsize);
397
	newbuf = malloc(newsize);
398
	memmov(newbuf, WB1.o_bufpointer, newsize);
398
	memmov(newbuf, WB1.o_bufpointer, newsize);
399
	LoadInternalPage(newbuf, newsize);
399
	LoadInternalPage(newbuf, newsize);
400
	free(newbuf);
400
	free(newbuf);
401
}
401
}
402
 
402
 
403
 
403
 
404
void ProcessEvent(dword id__)
404
void ProcessEvent(dword id__)
405
{
405
{
406
	switch (id__)
406
	switch (id__)
407
	{
407
	{
408
		case 1:
408
		case 1:
409
			ExitProcess();
409
			ExitProcess();
410
			break;
410
			break;
411
		case ENCODINGS...ENCODINGS+6:
411
		case ENCODINGS...ENCODINGS+6:
412
			EventChangeEncodingAndLoadPage(id__-ENCODINGS);
412
			EventChangeEncodingAndLoadPage(id__-ENCODINGS);
413
			return;
413
			return;
414
		case NEW_WINDOW:
414
		case NEW_WINDOW:
415
			RunProgram(#program_path, NULL);
415
			RunProgram(#program_path, NULL);
416
			return;
416
			return;
417
		case SCAN_CODE_BS:
417
		case SCAN_CODE_BS:
418
		case BACK_BUTTON:
418
		case BACK_BUTTON:
419
			if (history.back()) {
419
			if (history.back()) {
420
				OpenPage(history.current());
420
				OpenPage(history.current());
421
			}
421
			}
422
			return;
422
			return;
423
		case FORWARD_BUTTON:
423
		case FORWARD_BUTTON:
424
			if (history.forward()) {
424
			if (history.forward()) {
425
				OpenPage(history.current());
425
				OpenPage(history.current());
426
			}
426
			}
427
			return;
427
			return;
428
		case GOTOURL_BUTTON:
428
		case GOTOURL_BUTTON:
429
		case SCAN_CODE_ENTER:
429
		case SCAN_CODE_ENTER:
430
			EventSubmitOmnibox();
430
			EventSubmitOmnibox();
431
			return;
431
			return;
432
		case REFRESH_BUTTON:
432
		case REFRESH_BUTTON:
433
			EventRefreshPage();
433
			EventRefreshPage();
434
			return;
434
			return;
435
		case CHANGE_ENCODING:
435
		case CHANGE_ENCODING:
436
			EventShowEncodingsList();
436
			EventShowEncodingsList();
437
			return;
437
			return;
438
		case SANDWICH_BUTTON:
438
		case SANDWICH_BUTTON:
439
			EventShowMainMenu();
439
			EventShowMainMenu();
440
			return;
440
			return;
441
		case VIEW_SOURCE:
441
		case VIEW_SOURCE:
442
			EventViewSource();
442
			EventViewSource();
443
			break;
443
			break;
444
		case EDIT_SOURCE:
444
		case EDIT_SOURCE:
445
			if (check_is_the_adress_local(history.current())) {
445
			if (check_is_the_adress_local(history.current())) {
446
				RunProgram("/rd/1/tinypad", history.current());
446
				RunProgram("/rd/1/tinypad", history.current());
447
			} else {
447
			} else {
448
				CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm");
448
				CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm");
449
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
449
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
450
			}
450
			}
451
			return;
451
			return;
452
		case VIEW_HISTORY:
452
		case VIEW_HISTORY:
453
			OpenPage(URL_SERVICE_HISTORY);
453
			OpenPage(URL_SERVICE_HISTORY);
454
			return;
454
			return;
455
		case DOWNLOAD_MANAGER:
455
		case DOWNLOAD_MANAGER:
456
			if (!downloader_opened) {
456
			if (!downloader_opened) {
457
				downloader_edit = NULL;
457
				downloader_edit = NULL;
458
				CreateThread(#Downloader,#downloader_stak+4092);
458
				CreateThread(#Downloader,#downloader_stak+4092);
459
			}
459
			}
460
			return;
460
			return;
461
		case UPDATE_BROWSER:
461
		case UPDATE_BROWSER:
462
			EventUpdateBrowser();
462
			EventUpdateBrowser();
463
			return;
463
			return;
464
		case CLEAR_CACHE:
464
		case CLEAR_CACHE:
465
			pages_cache.clear();
465
			pages_cache.clear();
466
			notify(#clear_cache_ok);
466
			notify(#clear_cache_ok);
467
			EventRefreshPage();
467
			EventRefreshPage();
468
			return;
468
			return;
469
		case IN_NEW_TAB:
469
		case IN_NEW_TAB:
470
			EventClickLink(TARGET_NEW_TAB);
470
			EventClickLink(TARGET_NEW_TAB);
471
			return;
471
			return;
472
		case IN_NEW_WINDOW:
472
		case IN_NEW_WINDOW:
473
			EventClickLink(TARGET_NEW_WINDOW);
473
			EventClickLink(TARGET_NEW_WINDOW);
474
			return;
474
			return;
475
		case COPY_LINK_URL:
475
		case COPY_LINK_URL:
476
			Clipboard__CopyText(GetAbsoluteActiveURL()); 
476
			Clipboard__CopyText(GetAbsoluteActiveURL()); 
477
			notify("'URL copied to clipboard'O");
477
			notify("'URL copied to clipboard'O");
478
			return;
478
			return;
479
		case DOWNLOAD_LINK_CONTENTS:
479
		case DOWNLOAD_LINK_CONTENTS:
480
			if (!downloader_opened) {
480
			if (!downloader_opened) {
481
				strcpy(#downloader_edit, GetAbsoluteActiveURL());
481
				strcpy(#downloader_edit, GetAbsoluteActiveURL());
482
				CreateThread(#Downloader,#downloader_stak+4092);
482
				CreateThread(#Downloader,#downloader_stak+4092);
483
			}
483
			}
484
			return;
484
			return;
485
		case OPEN_FILE:
485
		case OPEN_FILE:
486
			EventOpenDialog();
486
			EventOpenDialog();
487
			return;
487
			return;
488
		case SCAN_CODE_F12:
488
		case SCAN_CODE_F12:
489
			debug_mode ^= 1;
489
			debug_mode ^= 1;
490
			if (debug_mode) notify("'Debug mode ON'-I");
490
			if (debug_mode) notify("'Debug mode ON'-I");
491
			else notify("'Debug mode OFF'-I");
491
			else notify("'Debug mode OFF'-I");
492
			return;
492
			return;
493
		case NEW_TAB:
493
		case NEW_TAB:
494
			if (http.transfer) break;
494
			if (http.transfer) break;
495
			EventOpenNewTab(URL_SERVICE_HOMEPAGE);
495
			EventOpenNewTab(URL_SERVICE_HOMEPAGE);
496
			return;
496
			return;
497
		case TAB_ID...TAB_ID+TABS_MAX:
497
		case TAB_ID...TAB_ID+TABS_MAX:
498
			if (http.transfer) break;
498
			if (http.transfer) break;
499
			if (mouse.mkm) {
499
			if (mouse.mkm) {
500
				EventTabClose(id__ - TAB_ID);
500
				EventTabClose(id__ - TAB_ID);
501
			} else {
501
			} else {
502
				EventTabClick(id__ - TAB_ID);
502
				EventTabClick(id__ - TAB_ID);
503
			}
503
			}
504
			return;
504
			return;
505
		case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX:
505
		case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX:
506
			EventTabClose(id__ - TAB_CLOSE_ID);
506
			EventTabClose(id__ - TAB_CLOSE_ID);
507
			return;
507
			return;
508
	}
508
	}
509
}
509
}
510
 
510
 
511
void StopLoading()
511
void StopLoading()
512
{
512
{
513
	if (http.transfer)
513
	if (http.transfer)
514
	{
514
	{
515
		EAX = http.transfer;
515
		EAX = http.transfer;
516
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
516
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
517
		$push	EAX							// save it on the stack
517
		$push	EAX							// save it on the stack
518
		http_free stdcall (http.transfer);	// abort connection
518
		http_free stdcall (http.transfer);	// abort connection
519
		$pop	EAX							
519
		$pop	EAX							
520
		free(EAX);						// free data
520
		free(EAX);						// free data
521
		http.transfer=0;
521
		http.transfer=0;
522
		pause(10);
522
		pause(10);
523
	}
523
	}
524
	wv_progress_bar.value = 0;
524
	wv_progress_bar.value = 0;
525
	DrawOmnibox();
525
	DrawOmnibox();
526
}
526
}
527
 
527
 
528
//rewrite into 
528
//rewrite into 
529
//bool strrpl(dword dst, from, into, dst_len);
529
//bool strrpl(dword dst, from, into, dst_len);
530
bool ReplaceSpaceInUrl(dword url, size) {
530
bool ReplaceSpaceInUrl(dword url, size) {
531
	unsigned int i, j;
531
	unsigned int i, j;
532
	bool was_changed=false;
532
	bool was_changed=false;
533
	for (i=url+size-3; i>url; i--)
533
	for (i=url+size-3; i>url; i--)
534
	{
534
	{
535
		if (ESBYTE[i]!=' ') continue;
535
		if (ESBYTE[i]!=' ') continue;
536
		for (j=url+size-3; j>=i; j--) {
536
		for (j=url+size-3; j>=i; j--) {
537
			ESBYTE[j+3]=ESBYTE[j+2];
537
			ESBYTE[j+3]=ESBYTE[j+2];
538
			ESBYTE[j+2]=ESBYTE[j+1];
538
			ESBYTE[j+2]=ESBYTE[j+1];
539
			ESBYTE[j+1]=ESBYTE[j];
539
			ESBYTE[j+1]=ESBYTE[j];
540
		}
540
		}
541
		ESBYTE[i] = '%';
541
		ESBYTE[i] = '%';
542
		ESBYTE[i+1] = '2';
542
		ESBYTE[i+1] = '2';
543
		ESBYTE[i+2] = '0';
543
		ESBYTE[i+2] = '0';
544
		was_changed = true;
544
		was_changed = true;
545
	}
545
	}
546
	return was_changed;
546
	return was_changed;
547
}
547
}
548
 
548
 
549
bool HandleUrlFiles(dword _path, _data)
549
bool HandleUrlFiles(dword _path, _data)
550
{
550
{
551
	dword url_from_file;
551
	dword url_from_file;
552
	if (!UrlExtIs(_path, "url")) return false;
552
	if (!UrlExtIs(_path, "url")) return false;
553
	if (! url_from_file = strstri(_data, "URL=")) return false;
553
	if (! url_from_file = strstri(_data, "URL=")) return false;
554
	replace_char(url_from_file, '\n', '\0', strlen(url_from_file));
554
	replace_char(url_from_file, '\n', '\0', strlen(url_from_file));
555
	OpenPage(url_from_file); 	
555
	OpenPage(url_from_file); 	
556
	return true;	
556
	return true;	
557
}
557
}
558
 
558
 
559
bool GetLocalFileData(dword _path)
559
bool GetLocalFileData(dword _path)
560
{
560
{
561
	dword data, size;
561
	dword data, size;
562
	file_size stdcall (_path);
562
	file_size stdcall (_path);
563
	if (!EBX) return false;
563
	if (!EBX) return false;
564
 
564
 
565
	size = EBX;
565
	size = EBX;
566
	data = malloc(size);
566
	data = malloc(size);
567
	ReadFile(0, size, data, _path);
567
	ReadFile(0, size, data, _path);
568
	if (!HandleUrlFiles(_path, data)) {
568
	if (!HandleUrlFiles(_path, data)) {
569
		LoadInternalPage(data, size);
569
		LoadInternalPage(data, size);
570
	}
570
	}
571
	free(data);
571
	free(data);
572
	return true;
572
	return true;
573
}
573
}
574
 
574
 
575
void OpenPage(dword _open_URL)
575
void OpenPage(dword _open_URL)
576
{
576
{
577
	char new_url[URL_SIZE+1];
577
	char new_url[URL_SIZE+1];
578
	char new_url_full[URL_SIZE+1];
578
	char new_url_full[URL_SIZE+1];
579
	int unz_id;
579
	int unz_id;
580
 
580
 
581
	StopLoading();
581
	StopLoading();
582
 
582
 
583
	SetOmniboxText(_open_URL);
583
	SetOmniboxText(_open_URL);
584
 
584
 
585
	strncpy(#new_url, _open_URL, URL_SIZE);
585
	strncpy(#new_url, _open_URL, URL_SIZE);
586
 
586
 
587
	//Exclude # from the URL to the load page
587
	//Exclude # from the URL to the load page
588
	//We will bring it back when we get the buffer
588
	//We will bring it back when we get the buffer
589
	if (strrchr(#new_url, '#')) {
589
	if (strrchr(#new_url, '#')) {
590
		anchors.take_anchor_from(#new_url);
590
		anchors.take_anchor_from(#new_url);
591
	}
591
	}
592
 
592
 
593
	history.add(#new_url);
593
	history.add(#new_url);
-
 
594
 
-
 
595
	/*
-
 
596
	There could be several possible types of addresses:
-
 
597
	- cached page (only http/https)
-
 
598
	- internal page
-
 
599
	- web page
-
 
600
	- local file
-
 
601
	So we need to detect what incoming address is
-
 
602
	and then halndle it in the propper way.
-
 
603
	*/
594
 
604
 
595
	if (pages_cache.has(#new_url)) {
605
	if (pages_cache.has(#new_url)) {
596
		//CACHED PAGE
606
		//CACHED PAGE
597
		LoadInternalPage(pages_cache.current_page_buf, pages_cache.current_page_size);
607
		LoadInternalPage(pages_cache.current_page_buf, pages_cache.current_page_size);
598
 
608
 
599
	} else if (!strncmp(#new_url,"WebView:",8)) {
609
	} else if (!strncmp(#new_url,"WebView:",8)) {
600
		//INTERNAL PAGE
610
		//INTERNAL PAGE
601
		if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage));
611
		if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buidin_page_home, sizeof(buidin_page_home));
602
		else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help));
612
		else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buidin_page_help, sizeof(buidin_page_help));
603
		else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
613
		else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
604
		else LoadInternalPage(#page_not_found, sizeof(page_not_found));
614
		else LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
605
 
615
 
606
	} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
616
	} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
607
		//WEB PAGE
617
		//WEB PAGE
608
		if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
618
		if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
609
			strcpy(#editURL, #new_url);
619
			strcpy(#editURL, #new_url);
610
		}
620
		}
611
 
621
 
612
		if (!strncmp(#new_url,"http:",5)) {
622
		if (!strncmp(#new_url,"http:",5)) {
613
			http.get(#new_url);
623
			http.get(#new_url);
614
		} else if (!strncmp(#new_url,"https://",8)) {
624
		} else if (!strncmp(#new_url,"https://",8)) {
615
			strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
625
			strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
616
			strncat(#new_url_full, #new_url, URL_SIZE);
626
			strncat(#new_url_full, #new_url, URL_SIZE);
617
			http.get(#new_url_full);
627
			http.get(#new_url_full);
618
		}
628
		}
619
 
629
 
620
		DrawOmnibox();
630
		DrawOmnibox();
621
 
631
 
622
		if (!http.transfer) {
632
		if (!http.transfer) {
623
			StopLoading();
633
			StopLoading();
624
			LoadInternalPage(#page_not_found, sizeof(page_not_found));
634
			LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
625
		}
635
		}
626
	} else {
636
	} else {
627
		//LOCAL PAGE
637
		//LOCAL PAGE
628
		if (UrlExtIs(#new_url,".docx")) {
638
		if (UrlExtIs(#new_url,".docx")) {
629
			DeleteFile("/tmp0/1/temp/word/document.xml");
639
			DeleteFile("/tmp0/1/temp/word/document.xml");
630
			CreateDir("/tmp0/1/temp");
640
			CreateDir("/tmp0/1/temp");
631
			unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url));
641
			unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url));
632
			while (GetProcessSlot(unz_id)) pause(2);
642
			while (GetProcessSlot(unz_id)) pause(2);
633
			strcpy(#new_url, "/tmp0/1/temp/word/document.xml");
643
			strcpy(#new_url, "/tmp0/1/temp/word/document.xml");
634
		} 
644
		} 
635
		if (!GetLocalFileData(#new_url)) {
645
		if (!GetLocalFileData(#new_url)) {
636
			LoadInternalPage(#page_not_found, sizeof(page_not_found));
646
			LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
637
		}
647
		}
638
	}
648
	}
639
}
649
}
640
 
650
 
641
 
651
 
642
bool EventClickAnchor()
652
bool EventClickAnchor()
643
{
653
{
644
	dword aURL = links.active_url;
654
	dword aURL = links.active_url;
645
 
655
 
646
	if (anchors.get_pos_by_name(aURL+1)!=-1) {
656
	if (anchors.get_pos_by_name(aURL+1)!=-1) {
647
		WB1.list.first = anchors.get_pos_by_name(aURL+1);
657
		WB1.list.first = anchors.get_pos_by_name(aURL+1);
648
		//WB1.list.CheckDoesValuesOkey();
658
		//WB1.list.CheckDoesValuesOkey();
649
		strcpy(#editURL, history.current());
659
		strcpy(#editURL, history.current());
650
		strcat(#editURL, aURL);
660
		strcat(#editURL, aURL);
651
		DrawOmnibox();
661
		DrawOmnibox();
652
		WB1.DrawPage();
662
		WB1.DrawPage();
653
		return true;
663
		return true;
654
	}
664
	}
655
	return false;
665
	return false;
656
}
666
}
657
 
667
 
658
void EventClickLink(dword _target)
668
void EventClickLink(dword _target)
659
{
669
{
660
	char new_url[URL_SIZE+1];
670
	char new_url[URL_SIZE+1];
661
	char new_url_full[URL_SIZE+1];
671
	char new_url_full[URL_SIZE+1];
662
	dword aURL = GetAbsoluteActiveURL();
672
	dword aURL = GetAbsoluteActiveURL();
663
	if (!aURL) return;
673
	if (!aURL) return;
664
 
674
 
665
	strcpy(#new_url, aURL);
675
	strcpy(#new_url, aURL);
666
 
676
 
667
	if (ESBYTE[aURL]=='#') {
677
	if (ESBYTE[aURL]=='#') {
668
		if (_target == TARGET_SAME_TAB) {
678
		if (_target == TARGET_SAME_TAB) {
669
			EventClickAnchor(); 
679
			EventClickAnchor(); 
670
			return;
680
			return;
671
		} else {
681
		} else {
672
			strcpy(#new_url, history.current());
682
			strcpy(#new_url, history.current());
673
			strcat(#new_url, aURL);
683
			strcat(#new_url, aURL);
674
		}
684
		}
675
	}
685
	}
676
 
686
 
677
	if (_target == TARGET_NEW_TAB) {
687
	if (_target == TARGET_NEW_TAB) {
678
		EventOpenNewTab(#new_url);
688
		EventOpenNewTab(#new_url);
679
		return;
689
		return;
680
	}
690
	}
681
 
691
 
682
	if (_target == TARGET_NEW_WINDOW) {
692
	if (_target == TARGET_NEW_WINDOW) {
683
		strcpy(#new_url_full, "-new ");
693
		strcpy(#new_url_full, "-new ");
684
		strncat(#new_url_full, #new_url, URL_SIZE);
694
		strncat(#new_url_full, #new_url, URL_SIZE);
685
		RunProgram(#program_path, #new_url_full);
695
		RunProgram(#program_path, #new_url_full);
686
		return;
696
		return;
687
	}
697
	}
688
 
698
 
689
	if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) {
699
	if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) {
690
		notify(#new_url);
700
		notify(#new_url);
691
		return;
701
		return;
692
	}
702
	}
693
 
703
 
694
	if (http.transfer) {
704
	if (http.transfer) {
695
		StopLoading();
705
		StopLoading();
696
		history.back();
706
		history.back();
697
	}
707
	}
698
 
708
 
699
	if (strrchr(#new_url, '#')!=0) {
709
	if (strrchr(#new_url, '#')!=0) {
700
		anchors.take_anchor_from(#new_url);
710
		anchors.take_anchor_from(#new_url);
701
		OpenPage(#new_url);
711
		OpenPage(#new_url);
702
		return;
712
		return;
703
	}
713
	}
704
 
714
 
705
	if (!strncmp(#new_url,"WebView:",8)) {
715
	if (!strncmp(#new_url,"WebView:",8)) {
706
		OpenPage(#new_url);
716
		OpenPage(#new_url);
707
		return;
717
		return;
708
	}
718
	}
709
 
719
 
710
	if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0)
720
	if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0)
711
	{
721
	{
712
		if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true)
722
		if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true)
713
		{	
723
		{	
714
			if (strchr(#new_url, '|')) {
724
			if (strchr(#new_url, '|')) {
715
				ESBYTE[strchr(#new_url, '|')] = NULL;
725
				ESBYTE[strchr(#new_url, '|')] = NULL;
716
				RunProgram(#new_url, strlen(#new_url)+1+#new_url);
726
				RunProgram(#new_url, strlen(#new_url)+1+#new_url);
717
			} else {
727
			} else {
718
				RunProgram("/sys/@open", #new_url);
728
				RunProgram("/sys/@open", #new_url);
719
			}
729
			}
720
			return;
730
			return;
721
		}
731
		}
722
	} else {
732
	} else {
723
		if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) 
733
		if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) 
724
		|| (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true)
734
		|| (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true)
725
		|| (UrlExtIs(#new_url,".7z")==true) {
735
		|| (UrlExtIs(#new_url,".7z")==true) {
726
			if (!downloader_opened) {
736
			if (!downloader_opened) {
727
				strcpy(#downloader_edit, #new_url);
737
				strcpy(#downloader_edit, #new_url);
728
				CreateThread(#Downloader,#downloader_stak+4092);
738
				CreateThread(#Downloader,#downloader_stak+4092);
729
			}
739
			}
730
			else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
740
			else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
731
			return;
741
			return;
732
		}
742
		}
733
	}
743
	}
734
	OpenPage(#new_url);
744
	OpenPage(#new_url);
735
}
745
}
736
 
746
 
737
void EventSubmitOmnibox()
747
void EventSubmitOmnibox()
738
{
748
{
739
	char new_url[URL_SIZE+1];
749
	char new_url[URL_SIZE+1];
740
	if (!editURL[0]) return;
750
	if (!editURL[0]) return;
741
	if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') 
751
	if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') 
742
	|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) {
752
	|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) {
743
		OpenPage(#editURL);
753
		OpenPage(#editURL);
744
	} else {
754
	} else {
745
		strcpy(#new_url, "http://");
755
		strcpy(#new_url, "http://");
746
		strncat(#new_url, #editURL, URL_SIZE-1);
756
		strncat(#new_url, #editURL, URL_SIZE-1);
747
		OpenPage(#new_url);
757
		OpenPage(#new_url);
748
	}
758
	}
749
}
759
}
750
 
760
 
751
void LoadInternalPage(dword _bufdata, _in_bufsize){
761
void LoadInternalPage(dword _bufdata, _in_bufsize){
752
	if (!_bufdata) || (!_in_bufsize) {
762
	if (!_bufdata) || (!_in_bufsize) {
753
		LoadInternalPage(#page_not_found, sizeof(page_not_found));
763
		LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
754
	} else {
764
	} else {
755
		WB1.list.first = 0; //scroll page to the top
765
		WB1.list.first = 0; //scroll page to the top
756
		DrawOmnibox();
766
		DrawOmnibox();
757
		if(!strrchr(#editURL, '#')) {
767
		if(!strrchr(#editURL, '#')) {
758
			strcat(#editURL, #anchors.current);
768
			strcat(#editURL, #anchors.current);
759
			DrawOmnibox();
769
			DrawOmnibox();
760
		}
770
		}
761
		WB1.ParseHtml(_bufdata, _in_bufsize);
771
		WB1.ParseHtml(_bufdata, _in_bufsize);
762
		DrawStatusBar();
772
		DrawStatusBar();
763
		DrawActiveTab();
773
		DrawActiveTab();
764
		if (source_mode) {
774
		if (source_mode) {
765
			source_mode = false;
775
			source_mode = false;
766
			WB1.custom_encoding = CH_CP866;
776
			WB1.custom_encoding = CH_CP866;
767
			ShowSource(WB1.bufpointer, _in_bufsize);
777
			ShowSource(WB1.bufpointer, _in_bufsize);
768
		} else {
778
		} else {
769
			WB1.DrawPage();			
779
			WB1.DrawPage();			
770
		}
780
		}
771
	}
781
	}
772
}
782
}
773
 
783
 
774
bool UrlExtIs(dword base, ext)
784
bool UrlExtIs(dword base, ext)
775
{
785
{
776
	if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true;
786
	if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true;
777
	return false;
787
	return false;
778
}
788
}
779
 
789
 
780
void DrawProgress()
790
void DrawProgress()
781
{
791
{
782
	dword persent;
792
	dword persent;
783
	if (http.transfer == 0) return;
793
	if (http.transfer == 0) return;
784
	if (wv_progress_bar.max) {
794
	if (wv_progress_bar.max) {
785
		persent = wv_progress_bar.value*100/wv_progress_bar.max;
795
		persent = wv_progress_bar.value*100/wv_progress_bar.max;
786
	} else {
796
	} else {
787
		persent = 10;
797
		persent = 10;
788
	}
798
	}
789
	DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width+16/100, 2, 0x72B7EB);
799
	DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width+16/100, 2, 0x72B7EB);
790
}
800
}
791
 
801
 
792
void EventShowPageMenu()
802
void EventShowPageMenu()
793
{
803
{
794
	open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, MENU_ALIGN_TOP_LEFT, NULL, #rmb_menu);
804
	open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, MENU_ALIGN_TOP_LEFT, NULL, #rmb_menu);
795
	menu_id = VIEW_SOURCE;
805
	menu_id = VIEW_SOURCE;
796
}
806
}
797
 
807
 
798
void EventShowLinkMenu()
808
void EventShowLinkMenu()
799
{
809
{
800
	open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, MENU_ALIGN_TOP_LEFT, NULL, #link_menu);
810
	open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, MENU_ALIGN_TOP_LEFT, NULL, #link_menu);
801
	menu_id = IN_NEW_TAB;
811
	menu_id = IN_NEW_TAB;
802
}
812
}
803
 
813
 
804
void EventShowMainMenu()
814
void EventShowMainMenu()
805
{
815
{
806
	open_lmenu(Form.left + Form.cwidth - PADDING, Form.top + skin_height + PADDING + TSZE + 3, 
816
	open_lmenu(Form.left + Form.cwidth - PADDING, Form.top + skin_height + PADDING + TSZE + 3, 
807
		MENU_ALIGN_TOP_RIGHT, NULL, #main_menu);
817
		MENU_ALIGN_TOP_RIGHT, NULL, #main_menu);
808
	menu_id = OPEN_FILE;
818
	menu_id = OPEN_FILE;
809
}
819
}
810
 
820
 
811
void EventShowEncodingsList()
821
void EventShowEncodingsList()
812
{
822
{
813
	open_lmenu(Form.left + Form.cwidth, Form.top + skin_height + Form.cheight - STATUSBAR_H + 12, 
823
	open_lmenu(Form.left + Form.cwidth, Form.top + skin_height + Form.cheight - STATUSBAR_H + 12, 
814
		MENU_ALIGN_BOT_RIGHT, WB1.cur_encoding + 1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
824
		MENU_ALIGN_BOT_RIGHT, WB1.cur_encoding + 1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
815
	menu_id = ENCODINGS;
825
	menu_id = ENCODINGS;
816
}
826
}
817
 
827
 
818
void ProcessMenuClick()
828
void ProcessMenuClick()
819
{
829
{
820
	int click_id;
830
	int click_id;
821
	if (menu_id) {
831
	if (menu_id) {
822
		if (click_id = get_menu_click()) {
832
		if (click_id = get_menu_click()) {
823
			click_id += menu_id - 1;
833
			click_id += menu_id - 1;
824
			ProcessEvent(click_id);
834
			ProcessEvent(click_id);
825
		}
835
		}
826
		if (!menu_process_id) menu_id = NULL;
836
		if (!menu_process_id) menu_id = NULL;
827
	}
837
	}
828
}
838
}
829
 
839
 
830
void EventUpdateProgressBar()
840
void EventUpdateProgressBar()
831
{
841
{
832
	wv_progress_bar.max = http.content_length;
842
	wv_progress_bar.max = http.content_length;
833
	if (wv_progress_bar.value != http.content_received)
843
	if (wv_progress_bar.value != http.content_received)
834
	{
844
	{
835
		wv_progress_bar.value = http.content_received;	
845
		wv_progress_bar.value = http.content_received;	
836
		DrawProgress();
846
		DrawProgress();
837
	}
847
	}
838
}
848
}
839
 
849
 
840
void EventSeachWeb()
850
void EventSeachWeb()
841
{
851
{
842
	char new_url[URL_SIZE+1];
852
	char new_url[URL_SIZE+1];
843
	replace_char(#editURL, ' ', '_', URL_SIZE);
853
	replace_char(#editURL, ' ', '_', URL_SIZE);
844
	strcpy(#new_url, "https://www.google.com/search?q=");
854
	strcpy(#new_url, "https://www.google.com/search?q=");
845
	strncat(#new_url, #editURL, URL_SIZE);
855
	strncat(#new_url, #editURL, URL_SIZE);
846
	OpenPage(#new_url);
856
	OpenPage(#new_url);
847
}
857
}
848
 
858
 
849
void EventOpenDialog()
859
void EventOpenDialog()
850
{
860
{
851
	OpenDialog_start stdcall (#o_dialog);
861
	OpenDialog_start stdcall (#o_dialog);
852
	if (o_dialog.status) {
862
	if (o_dialog.status) {
853
		OpenPage(#openfile_path);
863
		OpenPage(#openfile_path);
854
	}
864
	}
855
}
865
}
856
 
866
 
857
void EventViewSource()
867
void EventViewSource()
858
{
868
{
859
	char source_view_param[URL_SIZE+1];
869
	char source_view_param[URL_SIZE+1];
860
	//strcpy(#source_view_param, "-source ");
870
	//strcpy(#source_view_param, "-source ");
861
	//strncat(#source_view_param, history.current(), URL_SIZE);
871
	//strncat(#source_view_param, history.current(), URL_SIZE);
862
	//RunProgram(#program_path, #source_view_param);
872
	//RunProgram(#program_path, #source_view_param);
863
	source_mode = true;
873
	source_mode = true;
864
	EventOpenNewTab(history.current());
874
	EventOpenNewTab(history.current());
865
}
875
}
866
 
876
 
867
void EventRefreshPage()
877
void EventRefreshPage()
868
{
878
{
869
	if (http.transfer) {
879
	if (http.transfer) {
870
		StopLoading();
880
		StopLoading();
871
		draw_window();
881
		draw_window();
872
	} else {
882
	} else {
873
		OpenPage(history.current());
883
		OpenPage(history.current());
874
	}
884
	}
875
}
885
}
876
 
886
 
877
dword GetFileSize(dword _path)
887
dword GetFileSize(dword _path)
878
{
888
{
879
	BDVK bdvk;
889
	BDVK bdvk;
880
	if (GetFileInfo(_path, #bdvk)!=0) {
890
	if (GetFileInfo(_path, #bdvk)!=0) {
881
		return 0;
891
		return 0;
882
	} else {
892
	} else {
883
		return bdvk.sizelo;
893
		return bdvk.sizelo;
884
	}
894
	}
885
}
895
}
886
 
896
 
887
void EventUpdateBrowser()
897
void EventUpdateBrowser()
888
{
898
{
889
	dword downloader_id, slot_n;
899
	dword downloader_id, slot_n;
890
	dword current_size;
900
	dword current_size;
891
	dword new_size;
901
	dword new_size;
892
	int error;
902
	int error;
893
 
903
 
894
	draw_window();
904
	draw_window();
895
 
905
 
896
	downloader_id = RunProgram(#program_path, #update_param);
906
	downloader_id = RunProgram(#program_path, #update_param);
897
	do {
907
	do {
898
		slot_n = GetProcessSlot(downloader_id);
908
		slot_n = GetProcessSlot(downloader_id);
899
		pause(10);
909
		pause(10);
900
	} while (slot_n!=0);
910
	} while (slot_n!=0);
901
 
911
 
902
	current_size = GetFileSize(#program_path);
912
	current_size = GetFileSize(#program_path);
903
	new_size = GetFileSize("/tmp0/1/Downloads/WebView.com");
913
	new_size = GetFileSize("/tmp0/1/Downloads/WebView.com");
904
 
914
 
905
	if (!new_size) || (new_size<5000) {
915
	if (!new_size) || (new_size<5000) {
906
		notify(#update_download_error);
916
		notify(#update_download_error);
907
		return;
917
		return;
908
	}
918
	}
909
 
919
 
910
	if (current_size == new_size) {
920
	if (current_size == new_size) {
911
		notify(#update_is_current);
921
		notify(#update_is_current);
912
		return;
922
		return;
913
	}
923
	}
914
 
924
 
915
	if (error = CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) {
925
	if (error = CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) {
916
		notify(#update_can_not_copy);
926
		notify(#update_can_not_copy);
917
	} else {
927
	} else {
918
		notify(#update_ok);
928
		notify(#update_ok);
919
		RunProgram(#program_path, history.current());
929
		RunProgram(#program_path, history.current());
920
		ExitProcess();
930
		ExitProcess();
921
	}
931
	}
922
}
932
}
923
 
933
 
924
void DrawStatusBar()
934
void DrawStatusBar()
925
{
935
{
926
	dword status_y = Form.cheight - STATUSBAR_H + 4;
936
	dword status_y = Form.cheight - STATUSBAR_H + 4;
927
	dword status_w = Form.cwidth - 90;
937
	dword status_w = Form.cwidth - 90;
928
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
938
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
929
	if (links.active_url) {
939
	if (links.active_url) {
930
		ESI = math.min(status_w/6, strlen(links.active_url));
940
		ESI = math.min(status_w/6, strlen(links.active_url));
931
		WriteText(10, status_y, 0, sc.work_text, links.active_url);
941
		WriteText(10, status_y, 0, sc.work_text, links.active_url);
932
	}
942
	}
933
	DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
943
	DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
934
	WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
944
	WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
935
}
945
}
936
 
946
 
937
void DrawOmnibox()
947
void DrawOmnibox()
938
{
948
{
939
	int imgxoff;
949
	int imgxoff;
940
	
950
	
941
	DrawOvalBorder(address_box.left-2, address_box.top-3, address_box.width+18, 24, sc.work_graph, 
951
	DrawOvalBorder(address_box.left-2, address_box.top-3, address_box.width+18, 24, sc.work_graph, 
942
		sc.work_graph, sc.work_graph, sc.work_dark);
952
		sc.work_graph, sc.work_graph, sc.work_dark);
943
	DrawBar(address_box.left-1, address_box.top-2, address_box.width+18, 1, 0xD8DCD8);
953
	DrawBar(address_box.left-1, address_box.top-2, address_box.width+18, 1, 0xD8DCD8);
944
	DrawBar(address_box.left-1, address_box.top-1, address_box.width+18, 1, address_box.color);
954
	DrawBar(address_box.left-1, address_box.top-1, address_box.width+18, 1, address_box.color);
945
	DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color);
955
	DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color);
946
 
956
 
947
	if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0;
957
	if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0;
948
	EditBox_UpdateText(#address_box, address_box.flags);
958
	EditBox_UpdateText(#address_box, address_box.flags);
949
	edit_box_draw stdcall(#address_box);
959
	edit_box_draw stdcall(#address_box);
950
	if (http.transfer) imgxoff = 16*23*3; else imgxoff = 0;
960
	if (http.transfer) imgxoff = 16*23*3; else imgxoff = 0;
951
	_PutImage(address_box.left+address_box.width+1, address_box.top-1, 16, 23, imgxoff + #editbox_icons);
961
	_PutImage(address_box.left+address_box.width+1, address_box.top-1, 16, 23, imgxoff + #editbox_icons);
952
	DefineHiddenButton(address_box.left+address_box.width-1, address_box.top-2, 17, 23, REFRESH_BUTTON);
962
	DefineHiddenButton(address_box.left+address_box.width-1, address_box.top-2, 17, 23, REFRESH_BUTTON);
953
 
963
 
954
	DrawProgress();
964
	DrawProgress();
955
}
965
}
956
 
966
 
957
void SetOmniboxText(dword _text)
967
void SetOmniboxText(dword _text)
958
{
968
{
959
	strcpy(#editURL, _text);
969
	strcpy(#editURL, _text);
960
	address_box.flags=0;
970
	address_box.flags=0;
961
	DrawOmnibox();
971
	DrawOmnibox();
962
}
972
}
963
 
973
 
964
dword GetAbsoluteActiveURL()
974
dword GetAbsoluteActiveURL()
965
{
975
{
966
	char abs_url[URL_SIZE];
976
	char abs_url[URL_SIZE];
967
	if (links.active_url) {
977
	if (links.active_url) {
968
		strncpy(#abs_url, links.active_url, URL_SIZE);
978
		strncpy(#abs_url, links.active_url, URL_SIZE);
969
		GetAbsoluteURL(#abs_url, history.current());		
979
		GetAbsoluteURL(#abs_url, history.current());		
970
		return #abs_url;
980
		return #abs_url;
971
	}
981
	}
972
	return 0;
982
	return 0;
973
}
983
}
974
 
984
 
975
stop:
985
stop: