osupdate: final
git-svn-id: svn://kolibrios.org@8013 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
5950bfe4cd
commit
f6ab28ae5b
@ -130,4 +130,4 @@ void EventInstall()
|
|||||||
draw_window();
|
draw_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Operation_Draw_Progress(dword filename) { debug("copying: "); debugln(filename); }
|
void Operation_Draw_Progress(dword filename) { }
|
@ -299,7 +299,6 @@ struct libimg_image
|
|||||||
bg = _bg;
|
bg = _bg;
|
||||||
i32.load("/sys/icons32.png");
|
i32.load("/sys/icons32.png");
|
||||||
i32.replace_color(0x00000000, bg);
|
i32.replace_color(0x00000000, bg);
|
||||||
debugln("wolo");
|
|
||||||
}
|
}
|
||||||
if (icon_n>=0) i32.draw(x, y, 32, 32, 0, icon_n*32);
|
if (icon_n>=0) i32.draw(x, y, 32, 32, 0, icon_n*32);
|
||||||
}
|
}
|
||||||
|
@ -53,5 +53,19 @@ enum {
|
|||||||
RunProgram(proc_name, "");
|
RunProgram(proc_name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:void RestartAllProcess() {
|
||||||
|
int i;
|
||||||
|
proc_info Process, Self;
|
||||||
|
GetProcessInfo(#Self, -1);
|
||||||
|
for (i=0; i<MAX_PROCESS_COUNT; i++;)
|
||||||
|
{
|
||||||
|
GetProcessInfo(#Process, i);
|
||||||
|
if (Process.name)
|
||||||
|
&& (!streq(#Process.name, "OS"))
|
||||||
|
&& (Process.ID != Self.ID)
|
||||||
|
KillProcess(Process.ID);
|
||||||
|
}
|
||||||
|
RunProgram("/sys/launcher", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,4 +1,4 @@
|
|||||||
#define MEMSIZE 1024*460
|
#define MEMSIZE 1024*50
|
||||||
|
|
||||||
#include "../lib/io.h"
|
#include "../lib/io.h"
|
||||||
#include "../lib/gui.h"
|
#include "../lib/gui.h"
|
||||||
@ -17,147 +17,183 @@
|
|||||||
#include "lang.h--"
|
#include "lang.h--"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_http http;
|
|
||||||
proc_info Form;
|
|
||||||
bool install_complete = false;
|
bool install_complete = false;
|
||||||
sensor progress;
|
_http http;
|
||||||
|
|
||||||
#define WINW 460
|
#define WINW 460
|
||||||
|
#define WINH 380
|
||||||
|
|
||||||
//#define LANG_RUS 1
|
//#define LANG_RUS 1
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
#define WINH 345
|
|
||||||
#define T_WINDOW_TITLE "Ž« © ®¡®¢«¥¨¥ KolibriOS"
|
#define T_WINDOW_TITLE "Ž« © ®¡®¢«¥¨¥ KolibriOS"
|
||||||
#define T_TITLE_H1 "Ž<>‹€‰<E282AC> Ž<><C5BD>Ž‚‹…<E280B9>ˆ…"
|
#define T_TITLE_H1 "Ž<>‹€‰<E282AC> Ž<><C5BD>Ž‚‹…<E280B9>ˆ…"
|
||||||
#define T_INTRO "„ ®¥ ¯à¨«®¦¥¨¥ áª ç ¥â ¯®á«¥¤îî ¢¥àá¨î KolibriOS ¨ à ᯠªã¥â ¥¥ RAM-¤¨áª. <20>ਠí⮬ ï¤à® ¥ ¡ã¤¥â ¯¥à¥§ ¯ã饮, ¤«ï í⮣® ¥®¡å®¤¨¬® á®åà ¨âì ®¡à § ¨ ¯¥à¥§ £à㧨âáï. <20>®¦ «ã©áâ , § ªà®©â¥ ¢á¥ ®âªàëâë¥ ¯à¨«®¦¥¨ï ¯¥à¥¤ ç «®¬ ®¡®¢«¥¨ï.
|
#define T_INTRO "„ ®¥ ¯à¨«®¦¥¨¥ áª ç ¥â ¯®á«¥¤îî ¢¥àá¨î KolibriOS ¨ à ᯠªã¥â ¥¥ RAM-¤¨áª. <20>ਠí⮬ ï¤à® ¥ ¡ã¤¥â ¯¥à¥§ ¯ã饮, ¤«ï í⮣® ¥®¡å®¤¨¬® á®åà ¨âì ®¡à § ¨ ¯¥à¥§ £à㧨âáï. <20>®¦ «ã©áâ , § ªà®©â¥ ¢á¥ ®âªàëâë¥ ¯à¨«®¦¥¨ï ¯¥à¥¤ ç «®¬ ®¡®¢«¥¨ï.
|
||||||
|
|
||||||
‚<EFBFBD>ˆŒ€<EFBFBD>ˆ…: ‚ᥠ¨§¬¥ë¥ ä ©«ë RAM-¤¨áª¥ ¡ã¤ãâ ¯¥à¥§ ¯¨á ë!";
|
‚<EFBFBD>ˆŒ€<EFBFBD>ˆ…: ‚ᥠ¨§¬¥ë¥ ä ©«ë RAM-¤¨áª¥ ¡ã¤ãâ ¯¥à¥§ ¯¨á ë!";
|
||||||
#define T_INSTALL "Ž¡®¢¨âì"
|
#define T_INSTALL "Ž¡®¢¨âì"
|
||||||
#define T_COMPLETE "Ž¡®¢«¥¨¥ § ¢¥à襮"
|
#define T_COMPLETE "Ž¡®¢«¥¨¥ § ¢¥à襮"
|
||||||
#define T_EXIT "‚ë室"
|
#define T_EXIT "‚ë室"
|
||||||
#define IMG_URL "http://builds.kolibrios.org/rus/data/data/kolibri.img"
|
#define IMG_URL "http://builds.kolibrios.org/rus/data/data/kolibri.img"
|
||||||
|
#define KS "‘®åà ¨âì áâனª¨"
|
||||||
|
#define RA "<22>¥à¥§ ¯ãáâ¨âì ¢á¥ ¯à®£à ¬¬ë"
|
||||||
#else
|
#else
|
||||||
#define WINH 305
|
|
||||||
#define T_WINDOW_TITLE "KolibriOS Online Updater"
|
#define T_WINDOW_TITLE "KolibriOS Online Updater"
|
||||||
#define T_TITLE_H1 "ONLINE UPDATE"
|
#define T_TITLE_H1 "ONLINE UPDATE"
|
||||||
#define T_INTRO "This app will download the latest KolibriOS dirsto and update your RAM-disk with it. Kernel won't be restarted.
|
#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.
|
Please close all opened apps before start.
|
||||||
|
Note that all changes on RAM-disk will be lost.";
|
||||||
ALERT: All chages on RAM-disk will be lost!";
|
|
||||||
#define T_INSTALL "Update"
|
#define T_INSTALL "Update"
|
||||||
#define T_COMPLETE "Update complete"
|
#define T_COMPLETE "Update complete"
|
||||||
#define T_EXIT "Exit"
|
#define T_EXIT "Exit"
|
||||||
#define IMG_URL "http://builds.kolibrios.org/eng/data/data/kolibri.img"
|
#define IMG_URL "http://builds.kolibrios.org/eng/data/data/kolibri.img"
|
||||||
|
#define KS "Keep settings folder"
|
||||||
|
#define RA "Restart all apps"
|
||||||
#endif
|
#endif
|
||||||
char accept_language[]="en"; //not used, necessary for http.get()
|
char accept_language[]="en"; //not used, necessary for http.get()
|
||||||
|
void Operation_Draw_Progress(dword f) {} //not used, necessary for copyf()
|
||||||
|
|
||||||
|
checkbox keep_settings = { KS, true };
|
||||||
|
checkbox restart_apps = { RA, true };
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
//load_dll(libini, #lib_init,1);
|
int btn;
|
||||||
|
sensor progress;
|
||||||
load_dll(libio, #libio_init,1);
|
load_dll(libio, #libio_init,1);
|
||||||
load_dll(libimg, #libimg_init,1);
|
load_dll(libimg, #libimg_init,1);
|
||||||
load_dll(libHTTP, #http_lib_init,1);
|
load_dll(libHTTP, #http_lib_init,1);
|
||||||
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_STACK);
|
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_STACK);
|
||||||
loop() switch(WaitEventTimeout(300) & 0xFF)
|
loop() switch(@WaitEventTimeout(300))
|
||||||
{
|
{
|
||||||
case evButton:
|
case evButton:
|
||||||
if (GetButtonID() == 1) ExitProcess(); else EventInstall();
|
btn = @GetButtonID();
|
||||||
|
if (btn<=2) ExitProcess();
|
||||||
|
if (btn==9) goto _INSTALL;
|
||||||
|
keep_settings.click(btn);
|
||||||
|
restart_apps.click(btn);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case evKey:
|
case evKey:
|
||||||
GetKeys();
|
switch (@GetKeyScancode()) {
|
||||||
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
|
case SCAN_CODE_ESC: ExitProcess();
|
||||||
if (key_scancode == SCAN_CODE_ENTER) {
|
case SCAN_CODE_ENTER:
|
||||||
if (install_complete) ExitProcess();
|
if (install_complete) ExitProcess();
|
||||||
else EventInstall();
|
else {
|
||||||
|
_INSTALL:
|
||||||
|
http.get(IMG_URL);
|
||||||
|
goto _DRAW_WINDOW;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case evReDraw:
|
case evReDraw:
|
||||||
draw_window();
|
_DRAW_WINDOW:
|
||||||
break;
|
sc.get();
|
||||||
|
DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2,
|
||||||
|
WINW+9,WINH+skin_height,0x34,sc.work,T_WINDOW_TITLE,0);
|
||||||
|
WriteText(30, 20, 0x81, 0xEC008C, T_TITLE_H1);
|
||||||
|
if (!install_complete) {
|
||||||
|
DrawTextViewArea(30, 50, WINW-60, WINH-80, T_INTRO, -1, sc.work_text);
|
||||||
|
progress.set_size(30, WINH-130, WINW-60, 20);
|
||||||
|
if (http.transfer<=0) {
|
||||||
|
DrawCaptButton(WINW-110/2, WINH-70, 110, 28, 9, 0x0092D8, 0xFFFfff, T_INSTALL);
|
||||||
|
keep_settings.draw(30, WINH - 210);
|
||||||
|
restart_apps.draw(30, WINH - 185);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DrawIcon32(WINW-32/2, 140, sc.work, 49);
|
||||||
|
WriteTextCenter(0,185, WINW, sc.work_text, T_COMPLETE);
|
||||||
|
DrawCaptButton(WINW-110/2, WINH-70, 110, 28, 2,
|
||||||
|
0x0092D8, 0xFFFfff, T_EXIT);
|
||||||
|
}
|
||||||
|
|
||||||
case evNetwork:
|
case evNetwork:
|
||||||
if (http.transfer <= 0) break;
|
if (http.transfer <= 0) break;
|
||||||
http.receive();
|
http.receive();
|
||||||
if (http.content_length) {
|
if (http.content_length) {
|
||||||
progress.draw_progress(http.content_length - http.content_received * progress.w / http.content_length);
|
progress.draw_progress(http.content_length - http.content_received
|
||||||
|
* progress.w / http.content_length);
|
||||||
|
}
|
||||||
|
if (!http.receive_result) {
|
||||||
|
CreateFile(http.content_received,
|
||||||
|
http.content_pointer, "/tmp0/1/latest.img");
|
||||||
|
http.free();
|
||||||
|
EventDownloadComplete();
|
||||||
}
|
}
|
||||||
if (http.receive_result == 0) EventDownloadComplete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_window()
|
dword GetFreeSpaceOfRamdisk()
|
||||||
{
|
{
|
||||||
sc.get();
|
dword rdempty = malloc(1440*1024);
|
||||||
DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2,
|
CreateFile(0, 1440*1024, rdempty, "/rd/1/rdempty");
|
||||||
WINW+9,WINH+skin_height,0x34,sc.work,T_WINDOW_TITLE,0);
|
free(rdempty);
|
||||||
GetProcessInfo(#Form, -1);
|
file_size stdcall ("/rd/1/rdempty");
|
||||||
WriteText(30, 20, 0x81, 0xEC008C, T_TITLE_H1);
|
rdempty = EBX;
|
||||||
if (install_complete) {
|
DeleteFile("/rd/1/rdempty");
|
||||||
DrawInstallComplete();
|
return rdempty;
|
||||||
} else {
|
|
||||||
DrawIntro();
|
|
||||||
progress.set_size(30, WINH-130, WINW-60, 20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawIntro()
|
signed CheckFreeSpace(dword _latest, _combined)
|
||||||
{
|
{
|
||||||
DrawTextViewArea(30, 50, WINW-60, WINH-80,
|
dword cur_size, new_size, empty;
|
||||||
T_INTRO, -1, sc.work_text);
|
DIR_SIZE dir_size;
|
||||||
DrawCaptButton(WINW-110/2, WINH-70, 110, 28, 9999,
|
|
||||||
0x0092D8, 0xFFFfff, T_INSTALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawInstallComplete()
|
dir_size.get("/sys");
|
||||||
{
|
cur_size = dir_size.bytes;
|
||||||
DrawIcon32(WINW-32/2, 140, sc.work, 49);
|
|
||||||
WriteTextCenter(0,185, WINW, sc.work_text, T_COMPLETE);
|
|
||||||
DrawCaptButton(WINW-110/2, WINH-70, 110, 28, 1,
|
|
||||||
0x0092D8, 0xFFFfff, T_EXIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventInstall()
|
copyf("/sys", _combined);
|
||||||
{
|
copyf(_latest, _combined);
|
||||||
http.get(IMG_URL);
|
dir_size.get(_combined);
|
||||||
|
new_size = dir_size.bytes;
|
||||||
|
|
||||||
|
empty = GetFreeSpaceOfRamdisk();
|
||||||
|
|
||||||
|
return cur_size + empty - new_size / 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDownloadComplete()
|
void EventDownloadComplete()
|
||||||
{
|
{
|
||||||
dword unimg_id, slot_n;
|
dword unimg_id, slot_n;
|
||||||
|
signed space_delta;
|
||||||
|
int i=0;
|
||||||
|
|
||||||
CreateFile(http.content_received, http.content_pointer, "/tmp0/1/latest.img");
|
char osupdate[32];
|
||||||
http.free();
|
char latest[40];
|
||||||
|
char backup[40];
|
||||||
|
char combined[40];
|
||||||
|
char exract_param[64];
|
||||||
|
char backup_settings[64];
|
||||||
|
|
||||||
unimg_id = RunProgram("/sys/unimg", "/tmp0/1/latest.img /tmp0/1/latest_img -e");
|
do { sprintf(#osupdate, "/tmp0/1/osupdate%d", i); i++;
|
||||||
|
} while (dir_exists(#osupdate));
|
||||||
|
CreateDir(#osupdate);
|
||||||
|
|
||||||
|
sprintf(#latest, "%s/latest", #osupdate);
|
||||||
|
sprintf(#backup, "%s/rdbackup", #osupdate);
|
||||||
|
sprintf(#combined, "%s/combined", #osupdate);
|
||||||
|
sprintf(#backup_settings, "%s/settings", #backup);
|
||||||
|
sprintf(#exract_param, "/tmp0/1/latest.img %s -e", #latest);
|
||||||
|
|
||||||
|
|
||||||
|
unimg_id = RunProgram("/sys/unimg", #exract_param);
|
||||||
do {
|
do {
|
||||||
slot_n = GetProcessSlot(unimg_id);
|
slot_n = GetProcessSlot(unimg_id);
|
||||||
pause(10);
|
pause(10);
|
||||||
} while (slot_n!=0);
|
} while (slot_n!=0);
|
||||||
|
|
||||||
copyf("/rd/1/settings", "/tmp0/1/settings_backup");
|
space_delta = CheckFreeSpace(#latest, #combined);
|
||||||
copyf("/tmp0/1/latest_img", "/rd/1");
|
if (space_delta<0) {
|
||||||
copyf("/tmp0/1/settings_backup", "/rd/1/settings");
|
sprintf(#param, "'Not enought free space! You need %d Kb more.'E", -space_delta);
|
||||||
|
notify(#param);
|
||||||
RestartAllProcess();
|
} else {
|
||||||
install_complete = true;
|
copyf("/sys", #backup);
|
||||||
draw_window();
|
copyf(#latest, "/sys");
|
||||||
}
|
if (keep_settings.checked) copyf(#backup_settings, "/rd/1/settings");
|
||||||
|
if (restart_apps.checked) RestartAllProcess();
|
||||||
void RestartAllProcess() {
|
install_complete = true;
|
||||||
int i;
|
|
||||||
proc_info Process;
|
|
||||||
for (i=0; i<MAX_PROCESS_COUNT; i++;)
|
|
||||||
{
|
|
||||||
GetProcessInfo(#Process, i);
|
|
||||||
if (Process.name)
|
|
||||||
&& (!streq(#Process.name, "OS"))
|
|
||||||
&& (Process.ID != Form.ID)
|
|
||||||
KillProcess(Process.ID);
|
|
||||||
}
|
}
|
||||||
RunProgram("/sys/launcher", NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Operation_Draw_Progress(dword filename) { debug("copying: "); debugln(filename); }
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user