Subversion Repositories Kolibri OS

Rev

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

Rev 7764 Rev 7765
Line 28... Line 28...
28
#include "..\lib\patterns\http_downloader.h"
28
#include "..\lib\patterns\http_downloader.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
30
#include "..\lib\patterns\toolbar_button.h"
30
#include "..\lib\patterns\toolbar_button.h"
Line 31... Line 31...
31
 
31
 
-
 
32
#include "show_src.h"
32
#include "show_src.h"
33
bool download_and_exit = false;
33
#include "download_manager.h"
34
#include "download_manager.h"
34
_history history;
35
_history history;
35
#include "history.h"
36
#include "history.h"
36
bool debug_mode = false;
37
bool debug_mode = false;
Line 70... Line 71...
70
	EDIT_SOURCE,
71
	EDIT_SOURCE,
71
	OPEN_FILE,
72
	OPEN_FILE,
72
	NEW_WINDOW,
73
	NEW_WINDOW,
73
	VIEW_HISTORY,
74
	VIEW_HISTORY,
74
	DOWNLOAD_MANAGER,
75
	DOWNLOAD_MANAGER,
-
 
76
	UPDATE_BROWSER,
75
	COPY_LINK_URL,
77
	COPY_LINK_URL,
76
	DOWNLOAD_LINK_CONTENTS,
78
	DOWNLOAD_LINK_CONTENTS,
77
};
79
};
Line 78... Line 80...
78
 
80
 
Line 96... Line 98...
96
}
98
}
Line 97... Line 99...
97
 
99
 
98
void HandleParam()
100
void HandleParam()
99
{
101
{
-
 
102
	if (param) {
-
 
103
		if (!strncmp(#param, "-download_and_exit ", 19)) {
-
 
104
			download_and_exit = true;
-
 
105
			strcpy(#downloader_edit, #param+19);
-
 
106
			Downloader();
100
	if (param) {
107
			ExitProcess();
101
		if (!strncmp(#param, "-d ", 3)) {
108
		} else if (!strncmp(#param, "-download ", 10)) {
102
			strcpy(#downloader_edit, #param+3);
109
			strcpy(#downloader_edit, #param+10);
-
 
110
			//CreateThread(#Downloader,#downloader_stak+4092);
103
			CreateThread(#Downloader,#downloader_stak+4092);
111
			Downloader();
104
			ExitProcess();
112
			ExitProcess();
105
		} else if (!strncmp(#param, "-s ", 3)) {
113
		} else if (!strncmp(#param, "-source ", 8)) {
106
			source_mode = true;
114
			source_mode = true;
107
			history.add(#param + 3);
115
			history.add(#param + 8);
108
		} else {
116
		} else {
109
			history.add(#param);
117
			history.add(#param);
110
		}
118
		}
111
	} else {
119
	} else {
Line 357... Line 365...
357
			if (!downloader_opened) {
365
			if (!downloader_opened) {
358
				downloader_edit = NULL;
366
				downloader_edit = NULL;
359
				CreateThread(#Downloader,#downloader_stak+4092);
367
				CreateThread(#Downloader,#downloader_stak+4092);
360
			}
368
			}
361
			return;
369
			return;
-
 
370
		case UPDATE_BROWSER:
-
 
371
			EventUpdateBrowser();
-
 
372
			return;
362
		case COPY_LINK_URL:
373
		case COPY_LINK_URL:
363
			Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
374
			Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
364
			notify("'URL copied to clipboard'O");
375
			notify("'URL copied to clipboard'O");
365
			return;
376
			return;
366
		case DOWNLOAD_LINK_CONTENTS:
377
		case DOWNLOAD_LINK_CONTENTS:
Line 671... Line 682...
671
}
682
}
Line 672... Line 683...
672
 
683
 
673
void EventViewSource()
684
void EventViewSource()
674
{
685
{
675
	char source_view_param[URL_SIZE+1];
686
	char source_view_param[URL_SIZE+1];
676
	strcpy(#source_view_param, "-s ");
687
	strcpy(#source_view_param, "-source ");
677
	strncat(#source_view_param, history.current(), URL_SIZE);
688
	strncat(#source_view_param, history.current(), URL_SIZE);
678
	RunProgram(#program_path, #source_view_param);
689
	RunProgram(#program_path, #source_view_param);
Line -... Line 690...
-
 
690
}
-
 
691
 
-
 
692
dword GetFileSize(dword _path)
-
 
693
{
-
 
694
	BDVK bdvk;
-
 
695
	if (GetFileInfo(_path, #bdvk)!=0) {
-
 
696
		return 0;
-
 
697
	} else {
-
 
698
		return bdvk.sizelo;
-
 
699
	}
-
 
700
}
-
 
701
 
-
 
702
void EventUpdateBrowser()
-
 
703
{
-
 
704
	dword downloader_id, slot_n;
-
 
705
	dword current_size;
-
 
706
	dword new_size;
-
 
707
	int error;
-
 
708
 
-
 
709
	draw_window();
-
 
710
 
-
 
711
	downloader_id = RunProgram(#program_path, #update_param);
-
 
712
	do {
-
 
713
		slot_n = GetProcessSlot(downloader_id);
-
 
714
		pause(10);
-
 
715
	} while (slot_n!=0);
-
 
716
 
-
 
717
	current_size = GetFileSize(#program_path);
-
 
718
	new_size = GetFileSize("/tmp0/1/Downloads/WebView.com");
-
 
719
 
-
 
720
	if (!new_size) || (new_size<5000) {
-
 
721
		notify(#update_download_error);
-
 
722
		return;
-
 
723
	}
-
 
724
 
-
 
725
	if (current_size == new_size) {
-
 
726
		notify(#update_is_current);
-
 
727
		return;
-
 
728
	}
-
 
729
 
-
 
730
	if (error = CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) {
-
 
731
		notify(#update_can_not_copy);
-
 
732
	} else {
-
 
733
		notify(#update_ok);
-
 
734
		RunProgram(#program_path, history.current());
-
 
735
		ExitProcess();
-
 
736
	}
679
}
737
}
680
 
738
 
681
void DrawStatusBar(dword _status_text)
739
void DrawStatusBar(dword _status_text)
682
{
740
{
683
	status_text.font_color = system.color.work_text;
741
	status_text.font_color = system.color.work_text;