Subversion Repositories Kolibri OS

Rev

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

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