Subversion Repositories Kolibri OS

Rev

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

Rev 7229 Rev 7281
Line 25... Line 25...
25
#include "..\lib\obj\iconv.h"
25
#include "..\lib\obj\iconv.h"
26
//useful patterns
26
//useful patterns
27
#include "..\lib\patterns\history.h"
27
#include "..\lib\patterns\history.h"
28
#include "..\lib\patterns\http_downloader.h"
28
#include "..\lib\patterns\http_downloader.h"
Line -... Line 29...
-
 
29
 
-
 
30
_http http = {0, 0, 0, 0, 0, 0, 0};
29
 
31
 
Line 30... Line 32...
30
char homepage[] = FROM "html\\homepage.htm""\0";
32
char homepage[] = FROM "html\\homepage.htm""\0";
31
 
33
 
32
#ifdef LANG_RUS
34
#ifdef LANG_RUS
33
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.73";
35
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.74";
34
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
36
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
35
?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
37
?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
36
char loading[] = "‡ £à㧪  áâà ­¨æë...
";
38
char loading[] = "‡ £à㧪  áâà ­¨æë...
";
Line 43... Line 45...
43
Œ¥­¥¤¦¥à § £à㧮ª";
45
Œ¥­¥¤¦¥à § £à㧮ª";
44
char link_menu[] =
46
char link_menu[] =
45
"Š®¯¨à®¢ âì áá뫪ã
47
"Š®¯¨à®¢ âì áá뫪ã
46
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
48
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
47
#else
49
#else
48
char version[]="Text-based Browser 1.73";
50
char version[]="Text-based Browser 1.74";
49
?define IMAGES_CACHE_CLEARED "Images cache cleared"
51
?define IMAGES_CACHE_CLEARED "Images cache cleared"
50
?define T_LAST_SLIDE "This slide is the last"
52
?define T_LAST_SLIDE "This slide is the last"
51
char loading[] = "Loading...
";
53
char loading[] = "Loading...
";
52
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
54
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
53
char accept_language[]= "Accept-Language: en\n";
55
char accept_language[]= "Accept-Language: en\n";
Line 73... Line 75...
73
 
75
 
Line 74... Line 76...
74
char stak[4096];
76
char stak[4096];
Line 75... Line -...
75
 
-
 
76
int action_buf;
-
 
77
 
-
 
78
dword http_transfer = 0;
77
 
79
dword http_buffer;
78
int action_buf;
80
 
79
 
81
dword TOOLBAR_H = 40;
80
dword TOOLBAR_H = 40;
82
dword STATUSBAR_H = 15;
81
dword STATUSBAR_H = 15;
Line 183... Line 182...
183
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
182
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
184
			Draw_Window();
183
			Draw_Window();
185
			break;
184
			break;
Line 186... Line 185...
186
			
185
			
187
		case evNetwork:
186
		case evNetwork:
188
			if (http_transfer > 0) {
-
 
189
				http_receive stdcall (http_transfer);
-
 
190
				$push EAX
187
			if (http.transfer > 0) {
191
				ESI = http_transfer;
-
 
192
				wv_progress_bar.max = ESI.http_msg.content_length;
-
 
193
				if (wv_progress_bar.value != ESI.http_msg.content_received)
-
 
194
				{
-
 
195
					wv_progress_bar.value = ESI.http_msg.content_received;	
188
				http.receive();
196
					DrawProgress();
-
 
197
				}
-
 
198
				$pop EAX
189
				EventUpdateProgressBar();
199
				if (EAX == 0) {
-
 
200
					ESI = http_transfer;
190
				if (http.receive_result == 0) {
201
					// Handle redirects
191
					// Handle redirects
202
					if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
192
					if (http.status_code >= 300) && (http.status_code < 400)
203
					{
193
					{
204
						redirected++;
194
						redirected++;
205
						if (redirected<=5)
195
						if (redirected<=5)
206
						{
-
 
207
							http_find_header_field stdcall (http_transfer, "location\0");
196
						{
208
							if (EAX!=0) {
-
 
209
								ESI = EAX;
-
 
210
								EDI = #URL;
-
 
211
								do {
-
 
212
									$lodsb;
-
 
213
									$stosb;
-
 
214
								} while (AL != 0) && (AL != 13) && (AL != 10);
-
 
215
								DSBYTE[EDI-1]='\0';
197
							if (http.handle_redirect()) {
216
								if (!strncmp(#URL,"https://",8))
198
								if (!strncmp(#URL,"https://",8))
217
								{
199
								{
218
									history.back();
200
									history.back();
219
									strcpy(#editURL, history.current());
201
									strcpy(#editURL, history.current());
Line 236... Line 218...
236
						redirected = 0;
218
						redirected = 0;
237
					}
219
					}
238
					// Loading the page is complete, free resources
220
					// Loading the page is complete, free resources
239
					if (redirected>0)
221
					if (redirected>0)
240
					{
222
					{
241
						http_free stdcall (http_transfer);
-
 
242
						http_transfer=0;
223
						http.free();
243
						GetAbsoluteURL(#URL);
224
						GetAbsoluteURL(#URL);
244
						history.back();
225
						history.back();
245
						strcpy(#editURL, #URL);
226
						strcpy(#editURL, #URL);
246
						DrawEditBoxWebView();
227
						DrawEditBoxWebView();
247
						OpenPage();
228
						OpenPage();
248
					}
229
					}
249
					else
230
					else
250
					{
231
					{
251
						history.add(#URL);
232
						history.add(#URL);
252
						ESI = http_transfer;
233
						ESI = http.transfer;
253
						bufpointer = ESI.http_msg.content_ptr;
234
						bufpointer = ESI.http_msg.content_ptr;
254
						bufsize = ESI.http_msg.content_received;
235
						bufsize = ESI.http_msg.content_received;
255
						http_free stdcall (http_transfer);
-
 
256
						http_transfer=0;
236
						http.free();
257
						SetPageDefaults();
237
						SetPageDefaults();
258
						ShowPage();
238
						ShowPage();
259
					}
239
					}
260
				}
240
				}
261
			}
241
			}
Line 336... Line 316...
336
			OpenPage();
316
			OpenPage();
337
			return;
317
			return;
338
		case 063: //F5
318
		case 063: //F5
339
			IF(address_box.flags & 0b10) return;
319
			IF(address_box.flags & 0b10) return;
340
		case REFRESH_BUTTON:
320
		case REFRESH_BUTTON:
341
			if (http_transfer > 0) 
321
			if (http.transfer > 0) 
342
			{
322
			{
343
				StopLoading();
323
				StopLoading();
344
				Draw_Window();
324
				Draw_Window();
345
			}
325
			}
346
			else OpenPage();
326
			else OpenPage();
Line 389... Line 369...
389
	}
369
	}
390
}
370
}
Line 391... Line 371...
391
 
371
 
392
void StopLoading()
372
void StopLoading()
393
{
373
{
394
	if (http_transfer)
374
	if (http.transfer)
395
	{
375
	{
396
		EAX = http_transfer;
376
		EAX = http.transfer;
397
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
377
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
398
		$push	EAX							// save it on the stack
378
		$push	EAX							// save it on the stack
399
		http_free stdcall (http_transfer);	// abort connection
379
		http_free stdcall (http.transfer);	// abort connection
400
		$pop	EAX							
380
		$pop	EAX							
401
		free(EAX);						// free data
381
		free(EAX);						// free data
402
		http_transfer=0;
382
		http.transfer=0;
403
		bufsize = 0;
383
		bufsize = 0;
404
		bufpointer = free(bufpointer);
384
		bufpointer = free(bufpointer);
405
	}
385
	}
406
	wv_progress_bar.value = 0;
386
	wv_progress_bar.value = 0;
Line 430... Line 410...
430
		return;
410
		return;
431
	}
411
	}
432
	if (!strncmp(#URL,"http:",5))
412
	if (!strncmp(#URL,"http:",5))
433
	{
413
	{
434
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
414
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
435
		http_get stdcall (#URL, 0, 0, #accept_language);
-
 
436
		http_transfer = EAX;
415
		http.get(#URL);
437
		if (!http_transfer)
416
		if (!http.transfer)
438
		{
417
		{
439
			StopLoading();
418
			StopLoading();
440
			bufsize = 0;
419
			bufsize = 0;
441
			bufpointer = free(bufpointer);
420
			bufpointer = free(bufpointer);
442
			ShowPage();
421
			ShowPage();
Line 463... Line 442...
463
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
442
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
464
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
443
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
465
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
444
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
466
	address_box.offset = 0;
445
	address_box.offset = 0;
467
	edit_box_draw stdcall(#address_box);
446
	edit_box_draw stdcall(#address_box);
468
	if (http_transfer > 0) EAX = 131; else EAX = 54;
447
	if (http.transfer > 0) EAX = 131; else EAX = 54;
469
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0);
448
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0);
470
}
449
}
Line 471... Line 450...
471
 
450
 
472
 
451
 
473
void ShowPage()
452
void ShowPage()
474
{
453
{
475
	DrawEditBoxWebView();
454
	DrawEditBoxWebView();
476
	debugval("bufsize", bufsize);
455
	debugval("bufsize", bufsize);
477
	if (!bufsize)
456
	if (!bufsize)
478
	{
457
	{
479
		if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
458
		if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
480
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
459
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
481
	}
460
	}
482
	else
461
	else
Line 506... Line 485...
506
}
485
}
Line 507... Line 486...
507
 
486
 
508
void DrawProgress()
487
void DrawProgress()
509
{
488
{
510
	unsigned long btn;
489
	unsigned long btn;
511
	if (http_transfer == 0) return;
490
	if (http.transfer == 0) return;
512
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
491
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
513
	DrawBar(address_box.left-2, address_box.top+20, btn, 2, wv_progress_bar.progress_color);
492
	DrawBar(address_box.left-2, address_box.top+20, btn, 2, wv_progress_bar.progress_color);
Line 514... Line 493...
514
}
493
}
515
 
494
 
516
 
495
 
517
char anchor[256];
496
char anchor[256];
518
void ClickLink()
497
void ClickLink()
519
{
498
{
520
	if (http_transfer > 0) 
499
	if (http.transfer > 0) 
521
	{
500
	{
Line 609... Line 588...
609
void EventShowLinkMenu(dword _left, _top)
588
void EventShowLinkMenu(dword _left, _top)
610
{
589
{
611
	menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK);
590
	menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK);
612
}
591
}
Line -... Line 592...
-
 
592
 
-
 
593
void EventUpdateProgressBar()
-
 
594
{
-
 
595
	wv_progress_bar.max = http.content_length;
-
 
596
	if (wv_progress_bar.value != http.content_received)
-
 
597
	{
-
 
598
		wv_progress_bar.value = http.content_received;	
-
 
599
		DrawProgress();
-
 
600
	}
-
 
601
}
Line 613... Line 602...
613
 
602
 
614
 
603
 
615
void ShowErrorMessageThatHttpsIsNotSupportedYet()
604
void ShowErrorMessageThatHttpsIsNotSupportedYet()
616
{
605
{