1 #define MEMSIZE 1024*50
3 #include "../lib/gui.h"
4 #include "../lib/copyf.h"
6 #include "../lib/obj/libini.h"
7 #include "../lib/obj/libimg.h"
8 #include "../lib/obj/http.h"
9 #include "../lib/obj/network.h"
11 #include "../lib/patterns/restart_process.h"
13 bool install_complete
= false;
22 #define T_WINDOW_TITLE "Ž« © ®¡®¢«¥¨¥ KolibriOS"
23 #define T_TITLE_H1 "Ž�‹€‰� Ž��Ž‚‹…�ˆ…"
24 #define T_INTRO "„ ®¥ ¯à¨«®¦¥¨¥ áª ç ¥â ¯®á«¥¤îî ¢¥àá¨î KolibriOS ¨ à ᯠªã¥â ¥¥ RAM-¤¨áª. �ਠí⮬ ï¤à® ¥ ¡ã¤¥â ¯¥à¥§ ¯ã饮, ¤«ï í⮣® ¥®¡å®¤¨¬® á®åà ¨âì ®¡à § ¨ ¯¥à¥§ £à㧨âáï. �®¦ «ã©áâ , § ªà®©â¥ ¢á¥ ®âªàëâë¥ ¯à¨«®¦¥¨ï ¯¥à¥¤ ç «®¬ ®¡®¢«¥¨ï.
25 ‚�ˆŒ€�ˆ…: ‚ᥠ¨§¬¥ë¥ ä ©«ë RAM-¤¨áª¥ ¡ã¤ãâ ¯¥à¥§ ¯¨á ë!";
26 #define T_INSTALL "Ž¡®¢¨âì"
27 #define T_COMPLETE "Ž¡®¢«¥¨¥ § ¢¥à襮"
28 #define T_EXIT "‚ë室"
29 #define IMG_URL "http://builds.kolibrios.org/rus/data/data/kolibri.img"
30 #define KS "‘®åà ¨âì áâனª¨"
31 #define checkbox_h 190
33 #define T_WINDOW_TITLE "KolibriOS Online Updater"
34 #define T_TITLE_H1 "ONLINE UPDATE"
35 #define T_INTRO "This app will download the latest KolibriOS dirsto and update your RAM-disk with it. Kernel won't be restarted.
36 Please close all opened apps before start.
37 Note that all changes on RAM-disk will be lost.";
38 #define T_INSTALL "Update"
39 #define T_COMPLETE "Update complete"
41 #define IMG_URL "http://builds.kolibrios.org/eng/data/data/kolibri.img"
42 #define KS "Keep settings folder"
43 #define checkbox_h 210
45 char accept_language
[]="en"; //not used, necessary for http.get()
46 void Operation_Draw_Progress(dword f
) {} //not used, necessary for copyf()
48 checkbox keep_settings
= { KS
, true };
54 load_dll(libimg
, #libimg_init,1);
55 load_dll(libHTTP
, #http_lib_init,1);
56 @
SetEventMask(EVM_REDRAW
+ EVM_KEY
+ EVM_BUTTON
+ EVM_STACK
);
57 loop() switch(@
WaitEventTimeout(300))
61 if (btn
<=2) ExitProcess();
62 if (btn
==9) goto _INSTALL
;
63 keep_settings
.click(btn
);
67 switch (@
GetKeyScancode()) {
68 case SCAN_CODE_ESC
: ExitProcess();
70 if (install_complete
) ExitProcess();
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
);
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
);
100 if (http
.transfer
<= 0) break;
102 if (http
.content_length
) {
103 progress
.draw_progress(http
.content_length
- http
.content_received
104 * progress
.w
/ http
.content_length
);
106 if (!http
.receive_result
) {
107 CreateFile(http
.content_received
,
108 http
.content_pointer
, "/tmp0/1/latest.img");
110 EventDownloadComplete();
115 dword
GetFreeSpaceOfRamdisk()
117 dword rdempty
= malloc(1440*1024);
118 CreateFile(0, 1440*1024, rdempty
, "/sys/rdempty");
120 rdempty
= get_file_size("/sys/rdempty");
121 DeleteFile("/sys/rdempty");
125 signed CheckFreeSpace(dword _latest
, _combined
)
127 dword cur_size
, new_size
, empty
;
130 dir_size
.get("/sys");
131 cur_size
= dir_size
.bytes
;
133 copyf("/sys", _combined
);
134 copyf(_latest
, _combined
);
135 dir_size
.get(_combined
);
136 new_size
= dir_size
.bytes
;
138 empty
= GetFreeSpaceOfRamdisk();
140 return cur_size
+ empty
- new_size
/ 1024;
143 void EventDownloadComplete()
145 dword unimg_id
, slot_n
;
153 char exract_param
[64];
154 char backup_settings
[64];
156 do { sprintf(#osupdate, "/tmp0/1/osupdate%d", i); i++;
157 } while (dir_exists(#osupdate));
158 CreateDir(#osupdate);
160 sprintf(#latest, "%s/latest", #osupdate);
161 sprintf(#backup, "%s/rdbackup", #osupdate);
162 sprintf(#combined, "%s/combined", #osupdate);
163 sprintf(#backup_settings, "%s/settings", #backup);
164 sprintf(#exract_param, "/tmp0/1/latest.img %s -e", #latest);
167 unimg_id
= RunProgram("/sys/unimg", #exract_param);
169 slot_n
= GetProcessSlot(unimg_id
);
173 space_delta
= CheckFreeSpace(#latest, #combined);
175 sprintf(#param, "'Not enought free space! You need %d Kb more.'E", -space_delta);
178 copyf("/sys", #backup);
179 copyf(#latest, "/sys");
180 if (keep_settings
.checked
) copyf(#backup_settings, "/sys/settings");
181 install_complete
= true;