Subversion Repositories Kolibri OS

Rev

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

Rev 7938 Rev 7939
Line 17... Line 17...
17
#include "lang.h--"
17
#include "lang.h--"
18
#endif
18
#endif
Line 19... Line 19...
19
 
19
 
20
_http http;
20
_http http;
-
 
21
proc_info Form;
-
 
22
bool install_complete = false;
Line 21... Line 23...
21
proc_info Form;
23
sensor progress;
22
 
-
 
Line 23... Line 24...
23
#define WINW 400
24
 
Line 24... Line 25...
24
#define WINH 300
25
#define WINW 460
-
 
26
 
-
 
27
//#define LANG_RUS 1
-
 
28
 
25
 
29
#ifdef LANG_RUS
-
 
30
#define WINH 345
-
 
31
#define T_WINDOW_TITLE "Ž­« ©­ ®¡­®¢«¥­¨¥ KolibriOS"
26
char accept_language[]="en"; //not used, necessary for http.get()
32
#define T_TITLE_H1 "Ž‹€‰ ŽŽ‚‹…ˆ…"
27
 
33
#define T_INTRO "„ ­­®¥ ¯à¨«®¦¥­¨¥ ᪠砥⠯®á«¥¤­îî ¢¥àá¨î KolibriOS ¨ à á¯ ªã¥â ¥¥ ­  RAM-¤¨áª. à¨ í⮬ ï¤à® ­¥ ¡ã¤¥â ¯¥à¥§ ¯ã饭®, ¤«ï í⮣® ­¥®¡å®¤¨¬® á®åà ­¨âì ®¡à § ¨ ¯¥à¥§ £à㧨âáï. ®¦ «ã©áâ , § ªà®©â¥ ¢á¥ ®âªàëâë¥ ¯à¨«®¦¥­¨ï ¯¥à¥¤ ­ ç «®¬ ®¡­®¢«¥­¨ï.
28
#ifdef LANG_RUS
34
 
29
#define T_INTRO "®¯à®¡ã©â¥ ­®¢®¥ ¢¨§ã «ì­®¥ ®ä®à¬«¥­¨¥ Š®«¨¡à¨, ª®â®à®¥ à ­ìè¥ ¡ë«® ¤®áâ㯭® ⮫쪮 ¢ KolibriNext."; 
35
‚ˆŒ€ˆ…: ‚ᥠ¨§¬¥­­ë¥ ä ©«ë ­  RAM-¤¨áª¥ ¡ã¤ãâ ¯¥à¥§ ¯¨á ­ë!"; 
30
#define T_INSTALL "“áâ ­®¢¨âì"
36
#define T_INSTALL "Ž¡­®¢¨âì"
-
 
37
#define T_COMPLETE "Ž¡­®¢«¥­¨¥ § ¢¥à襭®"
-
 
38
#define T_EXIT "‚ë室"
-
 
39
#define IMG_URL "http://builds.kolibrios.org/rus/data/data/kolibri.img"
31
#define T_COMPLETE "“áâ ­®¢ª  § ¢¥à襭 "
40
#else
-
 
41
#define WINH 305
-
 
42
#define T_WINDOW_TITLE "KolibriOS Online Updater"
-
 
43
#define T_TITLE_H1 "ONLINE UPDATE"
32
#define T_EXIT "‚ë室"
44
#define T_INTRO "This app will download the latest KolibriOS dirsto and update your RAM-disk with it. Kernel won't be restarted. 
33
#define IMG_URL "http://builds.kolibrios.org/rus/data/data/kolibri.img"
45
Please close all opened apps before start.
34
#else
46
 
35
#define T_INTRO "This app will download the latest KolibriOS dirsto and update your RAM-disk with it. Kernel won't be restarted. Please close all opened apps before start."; 
47
ALERT: All chages on RAM-disk will be lost!"; 
36
#define T_INSTALL "Update"
48
#define T_INSTALL "Update"
37
#define T_COMPLETE "Update complete"
-
 
38
#define T_EXIT "Exit"
-
 
39
#define IMG_URL "http://builds.kolibrios.org/eng/data/data/kolibri.img"
49
#define T_COMPLETE "Update complete"
Line 40... Line 50...
40
#endif
50
#define T_EXIT "Exit"
41
 
51
#define IMG_URL "http://builds.kolibrios.org/eng/data/data/kolibri.img"
42
 
-
 
43
bool install_complete = false;
52
#endif
44
 
53
char accept_language[]="en"; //not used, necessary for http.get()
45
void main()
54
 
46
{
55
void main()
47
	word btn;
56
{
48
	//load_dll(libini, #lib_init,1);
57
	//load_dll(libini, #lib_init,1);
49
	load_dll(libio, #libio_init,1);
58
	load_dll(libio, #libio_init,1);
50
	load_dll(libimg, #libimg_init,1);
59
	load_dll(libimg, #libimg_init,1);
51
	load_dll(libHTTP,   #http_lib_init,1);
-
 
52
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_STACK);
60
	load_dll(libHTTP,   #http_lib_init,1);
53
	loop() switch(WaitEventTimeout(300) & 0xFF)
-
 
54
	{
61
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_STACK);
Line 55... Line 62...
55
		case evButton:
62
	loop() switch(WaitEventTimeout(300) & 0xFF)
56
			btn = GetButtonID();               
63
	{
57
			if (btn == 1) ExitProcess();
64
		case evButton:
Line 72... Line 79...
72
			break;
79
			break;
Line 73... Line 80...
73
 
80
 
74
		case evNetwork:
81
		case evNetwork:
75
			if (http.transfer <= 0) break;
82
			if (http.transfer <= 0) break;
76
			http.receive();
83
			http.receive();
77
			if (http.content_length) DrawProgressBar(30, WINH-140, WINW-60, 20, sc.work, 0xC3C3C3, 
84
			if (http.content_length) {
-
 
85
				progress.draw_progress(http.content_length - http.content_received * progress.w / http.content_length);
78
				0x54B1D6, sc.work_text, 100 * http.content_received / http.content_length);
86
			}
79
			if (http.receive_result == 0) EventDownloadComplete();
87
			if (http.receive_result == 0) EventDownloadComplete();
80
	}
88
	}
Line 81... Line 89...
81
}
89
}
82
 
90
 
83
void draw_window()
91
void draw_window()
84
{
92
{
85
	sc.get();
93
	sc.get();
86
	DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2,
94
	DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2,
87
		WINW+9,WINH+skin_height,0x34,sc.work,"KolibriOS Online Updater",0);
95
		WINW+9,WINH+skin_height,0x34,sc.work,T_WINDOW_TITLE,0);
88
	GetProcessInfo(#Form, -1);
96
	GetProcessInfo(#Form, -1);
-
 
97
	WriteText(30, 20, 0x81, 0xEC008C, T_TITLE_H1);
-
 
98
	if (install_complete) {
-
 
99
		DrawInstallComplete(); 
-
 
100
	} else {
-
 
101
		DrawIntro();
89
	WriteText(30, 20, 0x81, 0xEC008C, "ONLINE UPDATE");
102
		progress.set_size(30, WINH-130, WINW-60, 20);
Line 90... Line 103...
90
	if (install_complete) DrawInstallComplete(); else DrawIntro();
103
	}
91
}
104
}
92
 
105
 
Line 113... Line 126...
113
 
126
 
114
void EventDownloadComplete()
127
void EventDownloadComplete()
115
{
128
{
Line 116... Line 129...
116
	dword unimg_id, slot_n;
129
	dword unimg_id, slot_n;
117
 
130
 
Line 118... Line 131...
118
	CreateFile(http.content_received, http.content_pointer, "/tmp0/1/last.img");
131
	CreateFile(http.content_received, http.content_pointer, "/tmp0/1/latest.img");
119
	http.free();
132
	http.free();
120
 
133
 
121
	unimg_id = RunProgram("/tmp0/1/unimg", "/tmp0/1/last.img -e");
134
	unimg_id = RunProgram("/sys/unimg", "/tmp0/1/latest.img /tmp0/1/latest_img -e");
122
	do {
135
	do {
Line -... Line 136...
-
 
136
		slot_n = GetProcessSlot(unimg_id);
123
		slot_n = GetProcessSlot(unimg_id);
137
		pause(10);
-
 
138
	} while (slot_n!=0);
Line 124... Line 139...
124
		pause(10);
139
 
125
	} while (slot_n!=0);
140
	copyf("/rd/1/settings", "/tmp0/1/settings_backup");
126
 
141
	copyf("/tmp0/1/latest_img", "/rd/1");
127
	copyf("/tmp0/1/KOLIBRI.IMG", "/rd/1");
142
	copyf("/tmp0/1/settings_backup", "/rd/1/settings");