2020-05-17 17:52:41 +02:00
|
|
|
|
#define MEMSIZE 1024*460
|
|
|
|
|
|
|
|
|
|
#include "../lib/io.h"
|
|
|
|
|
#include "../lib/gui.h"
|
|
|
|
|
#include "../lib/copyf.h"
|
|
|
|
|
|
|
|
|
|
#include "../lib/obj/libini.h"
|
|
|
|
|
#include "../lib/obj/libio.h"
|
|
|
|
|
#include "../lib/obj/libimg.h"
|
|
|
|
|
#include "../lib/obj/http.h"
|
|
|
|
|
#include "../lib/obj/network.h"
|
|
|
|
|
|
|
|
|
|
#include "../lib/patterns/restart_process.h"
|
|
|
|
|
#include "../lib/patterns/http_downloader.h"
|
|
|
|
|
|
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
_http http;
|
|
|
|
|
proc_info Form;
|
2020-05-17 20:05:05 +02:00
|
|
|
|
bool install_complete = false;
|
|
|
|
|
sensor progress;
|
2020-05-17 17:52:41 +02:00
|
|
|
|
|
2020-05-17 20:05:05 +02:00
|
|
|
|
#define WINW 460
|
2020-05-17 17:52:41 +02:00
|
|
|
|
|
2020-05-17 20:05:05 +02:00
|
|
|
|
//#define LANG_RUS 1
|
2020-05-17 17:52:41 +02:00
|
|
|
|
|
|
|
|
|
#ifdef LANG_RUS
|
2020-05-17 20:05:05 +02:00
|
|
|
|
#define WINH 345
|
|
|
|
|
#define T_WINDOW_TITLE "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> KolibriOS"
|
|
|
|
|
#define T_TITLE_H1 "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
#define T_INTRO "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ਫ<EFBFBD><E0A8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᪠砥<E1AAA0> <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> KolibriOS <20> <20><>ᯠ<EFBFBD><E1AFA0><EFBFBD><EFBFBD> <20><> <20><> RAM-<2D><><EFBFBD><EFBFBD>. <20><><EFBFBD> <20>⮬ <20><><EFBFBD><EFBFBD> <20><> <20>㤥<EFBFBD> <20><>१<EFBFBD><E0A5A7><EFBFBD>饭<EFBFBD>, <20><><EFBFBD> <20>⮣<EFBFBD> <20><><EFBFBD><EFBFBD>室<EFBFBD><E5AEA4><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><E0A0AD><EFBFBD> <20><>ࠧ <20> <20><>१<EFBFBD><E0A5A7><EFBFBD>㧨<EFBFBD><E3A7A8><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD>ன<EFBFBD><E0AEA9> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ਫ<EFBFBD><E0A8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>। <20><>砫<EFBFBD><E7A0AB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 䠩<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> RAM-<EFBFBD><EFBFBD>᪥ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>१<EFBFBD><EFBFBD><EFBFBD>ᠭ<EFBFBD>!";
|
|
|
|
|
#define T_INSTALL "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
#define T_COMPLETE "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>襭<EFBFBD>"
|
2020-05-17 17:52:41 +02:00
|
|
|
|
#define T_EXIT "<22><>室"
|
|
|
|
|
#define IMG_URL "http://builds.kolibrios.org/rus/data/data/kolibri.img"
|
|
|
|
|
#else
|
2020-05-17 20:05:05 +02:00
|
|
|
|
#define WINH 305
|
|
|
|
|
#define T_WINDOW_TITLE "KolibriOS Online Updater"
|
|
|
|
|
#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.
|
|
|
|
|
Please close all opened apps before start.
|
|
|
|
|
|
|
|
|
|
ALERT: All chages on RAM-disk will be lost!";
|
2020-05-17 17:52:41 +02:00
|
|
|
|
#define T_INSTALL "Update"
|
|
|
|
|
#define T_COMPLETE "Update complete"
|
|
|
|
|
#define T_EXIT "Exit"
|
|
|
|
|
#define IMG_URL "http://builds.kolibrios.org/eng/data/data/kolibri.img"
|
|
|
|
|
#endif
|
2020-05-17 20:05:05 +02:00
|
|
|
|
char accept_language[]="en"; //not used, necessary for http.get()
|
2020-05-17 17:52:41 +02:00
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
//load_dll(libini, #lib_init,1);
|
|
|
|
|
load_dll(libio, #libio_init,1);
|
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
|
|
|
|
load_dll(libHTTP, #http_lib_init,1);
|
|
|
|
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_STACK);
|
|
|
|
|
loop() switch(WaitEventTimeout(300) & 0xFF)
|
|
|
|
|
{
|
|
|
|
|
case evButton:
|
2020-05-17 20:05:05 +02:00
|
|
|
|
if (GetButtonID() == 1) ExitProcess(); else EventInstall();
|
2020-05-17 17:52:41 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evKey:
|
|
|
|
|
GetKeys();
|
|
|
|
|
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
|
|
|
|
|
if (key_scancode == SCAN_CODE_ENTER) {
|
|
|
|
|
if (install_complete) ExitProcess();
|
|
|
|
|
else EventInstall();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evReDraw:
|
|
|
|
|
draw_window();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evNetwork:
|
|
|
|
|
if (http.transfer <= 0) break;
|
|
|
|
|
http.receive();
|
2020-05-17 20:05:05 +02:00
|
|
|
|
if (http.content_length) {
|
|
|
|
|
progress.draw_progress(http.content_length - http.content_received * progress.w / http.content_length);
|
|
|
|
|
}
|
2020-05-17 17:52:41 +02:00
|
|
|
|
if (http.receive_result == 0) EventDownloadComplete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_window()
|
|
|
|
|
{
|
|
|
|
|
sc.get();
|
|
|
|
|
DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2,
|
2020-05-17 20:05:05 +02:00
|
|
|
|
WINW+9,WINH+skin_height,0x34,sc.work,T_WINDOW_TITLE,0);
|
2020-05-17 17:52:41 +02:00
|
|
|
|
GetProcessInfo(#Form, -1);
|
2020-05-17 20:05:05 +02:00
|
|
|
|
WriteText(30, 20, 0x81, 0xEC008C, T_TITLE_H1);
|
|
|
|
|
if (install_complete) {
|
|
|
|
|
DrawInstallComplete();
|
|
|
|
|
} else {
|
|
|
|
|
DrawIntro();
|
|
|
|
|
progress.set_size(30, WINH-130, WINW-60, 20);
|
|
|
|
|
}
|
2020-05-17 17:52:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawIntro()
|
|
|
|
|
{
|
|
|
|
|
DrawTextViewArea(30, 50, WINW-60, WINH-80,
|
|
|
|
|
T_INTRO, -1, sc.work_text);
|
|
|
|
|
DrawCaptButton(WINW-110/2, WINH-70, 110, 28, 9999,
|
|
|
|
|
0x0092D8, 0xFFFfff, T_INSTALL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawInstallComplete()
|
|
|
|
|
{
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
http.get(IMG_URL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventDownloadComplete()
|
|
|
|
|
{
|
|
|
|
|
dword unimg_id, slot_n;
|
|
|
|
|
|
2020-05-17 20:05:05 +02:00
|
|
|
|
CreateFile(http.content_received, http.content_pointer, "/tmp0/1/latest.img");
|
2020-05-17 17:52:41 +02:00
|
|
|
|
http.free();
|
|
|
|
|
|
2020-05-17 20:05:05 +02:00
|
|
|
|
unimg_id = RunProgram("/sys/unimg", "/tmp0/1/latest.img /tmp0/1/latest_img -e");
|
2020-05-17 17:52:41 +02:00
|
|
|
|
do {
|
|
|
|
|
slot_n = GetProcessSlot(unimg_id);
|
|
|
|
|
pause(10);
|
|
|
|
|
} while (slot_n!=0);
|
|
|
|
|
|
2020-05-17 20:05:05 +02:00
|
|
|
|
copyf("/rd/1/settings", "/tmp0/1/settings_backup");
|
|
|
|
|
copyf("/tmp0/1/latest_img", "/rd/1");
|
|
|
|
|
copyf("/tmp0/1/settings_backup", "/rd/1/settings");
|
2020-05-17 17:52:41 +02:00
|
|
|
|
|
|
|
|
|
RestartAllProcess();
|
|
|
|
|
install_complete = true;
|
|
|
|
|
draw_window();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RestartAllProcess() {
|
|
|
|
|
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); }
|