Subversion Repositories Kolibri OS

Rev

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

Rev 9301 Rev 9439
Line 1... Line 1...
1
#define MEMSIZE 1024*50
1
#define MEMSIZE 1024*50
Line 2... Line 2...
2
 
2
 
3
#include "../lib/gui.h"
3
#include "../lib/gui.h"
Line 4... Line -...
4
#include "../lib/copyf.h"
-
 
5
 
-
 
6
#include "../lib/obj/libini.h"
4
#include "../lib/copyf.h"
7
#include "../lib/obj/libimg.h"
5
 
Line 8... Line 6...
8
#include "../lib/obj/http.h"
6
#include "../lib/obj/http.h"
Line 9... Line 7...
9
#include "../lib/obj/network.h"
7
#include "../lib/obj/network.h"
10
 
8
 
-
 
9
#include "../lib/patterns/restart_process.h"
Line 11... Line 10...
11
#include "../lib/patterns/restart_process.h"
10
 
12
 
11
bool install_complete = false;
Line 13... Line 12...
13
bool install_complete = false;
12
_http http;
Line 14... Line 13...
14
_http http;
13
dword unimg_id;
15
 
14
 
16
#define WINW 460
15
#define WINW 460
17
#define WINH 380
16
#define WINH 330
18
 
17
 
19
//#define LANG_RUS 1
18
//#define LANG_RUS 1
-
 
19
 
-
 
20
#ifdef LANG_RUS
20
 
21
#define T_WINDOW_TITLE "Ž­« ©­ ®¡­®¢«¥­¨¥ KolibriOS"
21
#ifdef LANG_RUS
22
#define T_TITLE_H1 "Ž­« ©­ ®¡­®¢«¥­¨¥"
22
#define T_WINDOW_TITLE "Ž­« ©­ ®¡­®¢«¥­¨¥ KolibriOS"
23
#define T_INTRO "„ ­­®¥ ¯à¨«®¦¥­¨¥ ᪠砥⠯®á«¥¤­îî ¢¥àá¨î KolibriOS ¨ à á¯ ªã¥â ¥¥ ­  RAM-¤¨áª. à¨ í⮬ ï¤à® ­¥ ¡ã¤¥â ¯¥à¥§ ¯ã饭®, ¤«ï í⮣® ­¥®¡å®¤¨¬® á®åà ­¨âì ®¡à § ¨ ¯¥à¥§ £à㧨âáï. ®¦ «ã©áâ , § ªà®©â¥ ¢á¥ ®âªàëâë¥ ¯à¨«®¦¥­¨ï ¯¥à¥¤ ­ ç «®¬ ®¡­®¢«¥­¨ï.
23
#define T_TITLE_H1 "Ž‹€‰ ŽŽ‚‹…ˆ…"
24
‚ˆŒ€ˆ…: ‚ᥠ¨§¬¥­­ë¥ ä ©«ë ­  RAM-¤¨áª¥ ¡ã¤ãâ ¯¥à¥§ ¯¨á ­ë!"; 
24
#define T_INTRO "„ ­­®¥ ¯à¨«®¦¥­¨¥ ᪠砥⠯®á«¥¤­îî ¢¥àá¨î KolibriOS ¨ à á¯ ªã¥â ¥¥ ­  RAM-¤¨áª. à¨ í⮬ ï¤à® ­¥ ¡ã¤¥â ¯¥à¥§ ¯ã饭®, ¤«ï í⮣® ­¥®¡å®¤¨¬® á®åà ­¨âì ®¡à § ¨ ¯¥à¥§ £à㧨âáï. ®¦ «ã©áâ , § ªà®©â¥ ¢á¥ ®âªàëâë¥ ¯à¨«®¦¥­¨ï ¯¥à¥¤ ­ ç «®¬ ®¡­®¢«¥­¨ï.
-
 
25
‚ˆŒ€ˆ…: ‚ᥠ¨§¬¥­­ë¥ ä ©«ë ­  RAM-¤¨áª¥ ¡ã¤ãâ ¯¥à¥§ ¯¨á ­ë!"; 
25
#define T_INSTALL "Ž¡­®¢¨âì"
26
#define T_INSTALL "Ž¡­®¢¨âì"
26
#define T_DOWNLOADING "‘ª ç¨¢ î ᢥ¦¨© ®¡à § kolibri.img..."
27
#define T_COMPLETE "Ž¡­®¢«¥­¨¥ § ¢¥à襭®"
27
#define T_UNPACKING " á¯ ª®¢ë¢ î ¨ ª®¯¨àãî ä ©«ë..."
28
#define T_EXIT "‚ë室"
28
#define T_COMPLETE "Ž¡­®¢«¥­¨¥ ãᯥ譮 § ¢¥à襭®."
29
#define IMG_URL "http://builds.kolibrios.org/rus/data/data/kolibri.img"
29
#define T_EXIT "‚ë室"
30
#define KS "‘®åà ­¨âì ­ áâனª¨"
30
#define IMG_URL "http://builds.kolibrios.org/rus/data/data/kolibri.img"
31
#define checkbox_h 190
31
#define KS "‘®åà ­¨âì ­ áâனª¨"
-
 
32
#else
-
 
33
#define T_WINDOW_TITLE "KolibriOS Online Updater"
32
#else
34
#define T_TITLE_H1 "Online Updater"
33
#define T_WINDOW_TITLE "KolibriOS Online Updater"
35
#define T_INTRO "This app will download the latest KolibriOS dirsto and update your RAM-disk with it. Kernel won't be restarted. 
34
#define T_TITLE_H1 "ONLINE UPDATE"
36
Please close all opened apps before start.
35
#define T_INTRO "This app will download the latest KolibriOS dirsto and update your RAM-disk with it. Kernel won't be restarted. 
37
Note that all changes on RAM-disk will be lost."; 
36
Please close all opened apps before start.
-
 
37
Note that all changes on RAM-disk will be lost."; 
38
#define T_INSTALL "Update"
38
#define T_INSTALL "Update"
39
#define T_DOWNLOADING "Downloading the latest kolibri.img..."
39
#define T_COMPLETE "Update complete"
40
#define T_UNPACKING "Unpacking and copying files..."
Line 40... Line 41...
40
#define T_EXIT "Exit"
41
#define T_COMPLETE "Update complete successfully."
-
 
42
#define T_EXIT "Exit"
Line 41... Line 43...
41
#define IMG_URL "http://builds.kolibrios.org/eng/data/data/kolibri.img"
43
#define IMG_URL "http://builds.kolibrios.org/eng/data/data/kolibri.img"
42
#define KS "Keep settings folder"
44
#define KS "Keep settings folder"
43
#define checkbox_h 210
45
#endif
44
#endif
-
 
45
char accept_language[]="en"; //not used, necessary for http.get()
-
 
46
void Operation_Draw_Progress(dword f) {} //not used, necessary for copyf()
46
char accept_language[]="en"; //not used, necessary for http.get()
-
 
47
void Operation_Draw_Progress(dword f) {} //not used, necessary for copyf()
47
 
48
 
48
checkbox keep_settings = { KS, true };
49
checkbox keep_settings = { KS, true };
49
 
50
sensor progress = { 40, WINH-70, WINW-80, 20 };
50
void main()
51
 
51
{
52
void main()
Line 76... Line 77...
76
			}
77
			}
77
			break;
78
			break;
Line 78... Line 79...
78
 
79
 
79
		case evReDraw:
80
		case evReDraw:
80
			_DRAW_WINDOW:
81
			_DRAW_WINDOW:
81
			sc.get();
-
 
82
			DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2,
-
 
83
				WINW+9,WINH+skin_height,0x34,sc.work,T_WINDOW_TITLE,0);
-
 
84
			WriteText(30, 20, 0x81, 0xEC008C, T_TITLE_H1);
-
 
85
			if (!install_complete) {
-
 
86
					DrawTextViewArea(30, 50, WINW-60, WINH-80, T_INTRO, -1, sc.work_text);
-
 
87
					progress.set_size(30, WINH-130, WINW-60, 20);
-
 
88
					if (http.transfer<=0) {
-
 
89
						DrawCaptButton(WINW-110/2, WINH-70, 110, 28, 9, 0x0092D8, 0xFFFfff, T_INSTALL);
-
 
90
						keep_settings.draw(30, WINH - checkbox_h);
-
 
91
					}
-
 
92
			} else {
-
 
93
					DrawIcon32(WINW-32/2, 140, sc.work, 49);
-
 
94
					WriteTextCenter(0,185, WINW, sc.work_text, T_COMPLETE);
-
 
95
					DrawCaptButton(WINW-110/2, WINH-70, 110, 28, 2, 
-
 
96
						0x0092D8, 0xFFFfff, T_EXIT);
-
 
Line 97... Line 82...
97
			}
82
			draw_window();
98
 
83
 
99
		case evNetwork:
84
		case evNetwork:
100
			if (http.transfer <= 0) break;
85
			if (http.transfer <= 0) break;
Line 110... Line 95...
110
				EventDownloadComplete();
95
				EventDownloadComplete();
111
			}
96
			}
112
	}
97
	}
113
}
98
}
Line -... Line 99...
-
 
99
 
-
 
100
void draw_window()
-
 
101
{
-
 
102
	sc.get();
-
 
103
	DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2,
-
 
104
		WINW+9,WINH+skin_height,0x34,sc.work,T_WINDOW_TITLE,0);
-
 
105
	WriteText(30, 20, 0x91, 0xEC008C, T_TITLE_H1);
-
 
106
	if (!install_complete) {
-
 
107
			if (GetProcessSlot(unimg_id)) {
-
 
108
				//UNPACKING
-
 
109
				draw_icon_32(WINW-32/2, 140, sc.work, 89);
-
 
110
				WriteTextCenter(0, 185, WINW, sc.work_text, T_UNPACKING);
-
 
111
			} else if (http.transfer<=0) {
-
 
112
				//INTRO
-
 
113
				DrawTextViewArea(30, 65, WINW-60, WINH-80, T_INTRO, -1, sc.work_text);
-
 
114
				DrawCaptButton(WINW-160, WINH-70, 110, 28, 9, 0x0092D8, 0xFFFfff, T_INSTALL);
-
 
115
				keep_settings.draw(30, WINH-65);
-
 
116
			} else {
-
 
117
				//DOWNLOADING
-
 
118
				draw_icon_32(WINW-32/2, 140, sc.work, 51);
-
 
119
				WriteTextCenter(0, 185, WINW, sc.work_text, T_DOWNLOADING);
-
 
120
				progress.draw_wrapper();
-
 
121
			}
-
 
122
	} else {
-
 
123
				//COMPLETE
-
 
124
				draw_icon_32(WINW-32/2, 140, sc.work, 49);
-
 
125
				WriteTextCenter(0, 185, WINW, sc.work_text, T_COMPLETE);
-
 
126
				DrawCaptButton(WINW-110/2, WINH-70, 110, 28, 2, 
-
 
127
					0x0092D8, 0xFFFfff, T_EXIT);
-
 
128
	}
-
 
129
}
114
 
130
 
115
dword GetFreeSpaceOfRamdisk()
131
dword GetFreeSpaceOfRamdisk()
116
{
132
{
117
	dword rdempty = malloc(1440*1024);
133
	dword rdempty = malloc(1440*1024);
118
	CreateFile(0, 1440*1024, rdempty, "/sys/rdempty");
134
	CreateFile(0, 1440*1024, rdempty, "/sys/rdempty");
Line 140... Line 156...
140
	return cur_size + empty - new_size / 1024;
156
	return cur_size + empty - new_size / 1024;
141
}
157
}
Line 142... Line 158...
142
 
158
 
143
void EventDownloadComplete()
159
void EventDownloadComplete()
144
{
160
{
145
	dword unimg_id, slot_n;
161
	dword slot_n;
146
	signed space_delta;
162
	signed space_delta;
Line 147... Line 163...
147
	int i=0;
163
	int i=0;
148
 
164
 
149
	char osupdate[32];
165
	char osupdate[32];
150
	char latest[40];
166
	char latest[40];
151
	char backup[40];
167
	char backup[40];
152
	char combined[40];
168
	char combined[40];
Line 153... Line 169...
153
	char exract_param[64];
169
	char exract_param[64];
154
	char backup_settings[64];
170
	char backup_settings[64];
155
 
171
 
Line 156... Line 172...
156
	do  { sprintf(#osupdate, "/tmp0/1/osupdate%d", i); i++;
172
	do  { miniprintf(#osupdate, "/tmp0/1/osupdate%d", i); i++;
157
	} while (dir_exists(#osupdate));
173
	} while (dir_exists(#osupdate));
158
	CreateDir(#osupdate);
174
	CreateDir(#osupdate);
159
 
175
 
160
	sprintf(#latest, "%s/latest", #osupdate);
176
	miniprintf(#latest, "%s/latest", #osupdate);
161
	sprintf(#backup, "%s/rdbackup", #osupdate);
-
 
Line 162... Line 177...
162
	sprintf(#combined, "%s/combined", #osupdate);
177
	miniprintf(#backup, "%s/rdbackup", #osupdate);
-
 
178
	miniprintf(#combined, "%s/combined", #osupdate);
-
 
179
	miniprintf(#backup_settings, "%s/settings", #backup);
163
	sprintf(#backup_settings, "%s/settings", #backup);
180
	miniprintf(#exract_param, "/tmp0/1/latest.img %s -e", #latest);
164
	sprintf(#exract_param, "/tmp0/1/latest.img %s -e", #latest);
181
 
165
 
182
	unimg_id = RunProgram("/sys/unimg", #exract_param);
166
 
183
	draw_window();
Line 167... Line 184...
167
	unimg_id = RunProgram("/sys/unimg", #exract_param);
184
 
168
	do {
185
	do {
169
		slot_n = GetProcessSlot(unimg_id);
186
		slot_n = GetProcessSlot(unimg_id);
170
		pause(10);
187
		pause(10);
171
	} while (slot_n!=0);
188
	} while (slot_n!=0);
172
 
189
 
173
	space_delta = CheckFreeSpace(#latest, #combined);
190
	space_delta = CheckFreeSpace(#latest, #combined);
174
	if (space_delta<0) {
191
	if (space_delta<0) {