Merge branch 'main' of https://git.kolibrios.org/KolibriOS/kolibrios into webview-update

This commit is contained in:
2025-02-28 01:24:59 +02:00
7 changed files with 182 additions and 93 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -94,11 +94,11 @@ lua=$CodeEdit
ob07=$CodeEdit ob07=$CodeEdit
json=$CodeEdit json=$CodeEdit
asm=$TinyPad asm=$CodeEdit
inc=$TinyPad inc=$CodeEdit
mac=$TinyPad mac=$CodeEdit
inf=$TinyPad inf=$CodeEdit
conf=$TinyPad conf=$CodeEdit
ini=$TextEditor ini=$TextEditor

View File

@@ -49,7 +49,7 @@
11 Fplay Video * |/kolibrios/media/fplay 11 Fplay Video * |/kolibrios/media/fplay
#5 **** DEV #5 **** DEV
54 Flat Assembler |develop/fasm 54 Flat Assembler |develop/fasm
27 Example.asm |example.asm 27 Example.asm |/sys/example.asm
49 Debugger mtdbg |develop/mtdbg 49 Debugger mtdbg |develop/mtdbg
49 Debugger koldbg * |/kolibrios/develop/koldbg 49 Debugger koldbg * |/kolibrios/develop/koldbg
13 Debug Board |develop/board 13 Debug Board |develop/board

View File

@@ -4,7 +4,7 @@
00 3D Demos > |@2 00 3D Demos > |@2
00 Gr<47>ficos > |@3 00 Gr<47>ficos > |@3
00 Multimedia > |@4 00 Multimedia > |@4
00 Emulators > |@18 00 Emulators > |@6
00 Desarrollo > |@5 00 Desarrollo > |@5
00 Sistema > |@7 00 Sistema > |@7
00 Proceso de datos > |@11 00 Proceso de datos > |@11
@@ -45,12 +45,12 @@
#4 **** MULTIMEDIA #4 **** MULTIMEDIA
16 Pixie Audioplayer |media/pixie 16 Pixie Audioplayer |media/pixie
16 AC97SND Audioplayer |media/ac97snd 16 AC97SND Audioplayer |media/ac97snd
16 Fplay - video |/kolibrios/media/fplay 16 Fplay - video * |/kolibrios/media/fplay
16 MidAMP |media/midamp 16 MidAMP |media/midamp
#5 **** DESARROLLO #5 **** DESARROLLO
00 Ejemplos > |@6 27 Example.asm |/sys/example.asm
16 Archiver KPack |kpack
16 Flat Assembler |develop/fasm 16 Flat Assembler |develop/fasm
16 Archiver KPack |kpack
16 Diff Tool |develop/diff 16 Diff Tool |develop/diff
16 Debug Board |develop/board 16 Debug Board |develop/board
49 Debugger mtdbg |develop/mtdbg 49 Debugger mtdbg |develop/mtdbg
@@ -59,12 +59,14 @@
16 Tabla de caracteres |ASCIIVju 16 Tabla de caracteres |ASCIIVju
16 C<>digos ASCII |develop/keyascii 16 C<>digos ASCII |develop/keyascii
16 C<>digos SCAN |develop/scancode 16 C<>digos SCAN |develop/scancode
#6 **** EJEMPLOS #6 **** EMULATORS
16 Threads |develop/thread 24 DOSBox * |/kolibrios/emul/DosBox/dosbox
16 Selector de color |demos/cslide 16 e80 (ZX Spectrum) * |/kolibrios/emul/e80/e80
16 Ejemplo de consola 1 |develop/testcon2 23 FCE Ultra (NES) * |/kolibrios/emul/fceu/fceu
16 Ejemplo de consola 2 |develop/test_gets 23 DGEN (Sega) * |/kolibrios/emul/dgen/dgen
16 Ejemplo de Messages |demos/use_mb 23 Gameboy Color * |/kolibrios/emul/gameboy
23 ZSNES * |/kolibrios/emul/zsnes/zsnes
16 ScummVM * |/kolibrios/emul/scummvm
#7 **** SISTEMA #7 **** SISTEMA
00 Archivos > |@10 00 Archivos > |@10
00 Accesibilidad > |@17 00 Accesibilidad > |@17
@@ -132,12 +134,4 @@
#17 **** ACCESIBILIDAD #17 **** ACCESIBILIDAD
16 Ampliaci<63>n de pantalla|magnify 16 Ampliaci<63>n de pantalla|magnify
16 Teclado en pantalla |zkey 16 Teclado en pantalla |zkey
#18 **** EMULATORS
24 DOSBox * |/kolibrios/emul/DosBox/dosbox
16 e80 (ZX Spectrum) * |/kolibrios/emul/e80/e80
23 FCE Ultra (NES) * |/kolibrios/emul/fceu/fceu
23 DGEN (Sega) * |/kolibrios/emul/dgen/dgen
23 Gameboy Color * |/kolibrios/emul/gameboy
23 ZSNES * |/kolibrios/emul/zsnes/zsnes
16 ScummVM * |/kolibrios/emul/scummvm
## ##

View File

@@ -49,7 +49,7 @@
11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Fplay * |/kolibrios/media/fplay 11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Fplay * |/kolibrios/media/fplay
#5 **** <20><><EFBFBD><EFBFBD> #5 **** <20><><EFBFBD><EFBFBD>
54 Flat Assembler |develop/fasm 54 Flat Assembler |develop/fasm
27 Example.asm |example.asm 27 Example.asm |/sys/example.asm
09 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>騪 KPack |kpack 09 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>騪 KPack |kpack
49 <20><EFBFBD>稪 mtdbg |develop/mtdbg 49 <20><EFBFBD>稪 mtdbg |develop/mtdbg
49 <20><EFBFBD>稪 koldbg * |/kolibrios/develop/koldbg 49 <20><EFBFBD>稪 koldbg * |/kolibrios/develop/koldbg

View File

@@ -6,12 +6,20 @@
#define T_CANCEL "<22><EFBFBD><E2ACA5>" #define T_CANCEL "<22><EFBFBD><E2ACA5>"
#define T_OPEN_DIR "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>" #define T_OPEN_DIR "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>"
#define T_RUN "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>" #define T_RUN "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>"
#define T_SPEED_TEST "<22><><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" #define T_NEW "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>"
#define T_SAVE_TO "<22><><EFBFBD><EFBFBD><E0A0AD><EFBFBD> <20>:"
#define T_AUTOCLOSE "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8A5AD> <20><><EFBFBD><EFBFBD><EFBFBD>"
#define T_STATUS_READY "<22><><20> <20><><EFBFBD><EFBFBD><EFBFBD> ^_^ "
#define T_STATUS_DOWNLOADING "<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>... %i.%i M<> <20><><EFBFBD><EFBFBD><EFBFBD> (%i K<>/<EFBFBD>) "
#define T_STATUS_COMPLETE "<22><><EFBFBD><EFBFBD><EFBFBD> <20>ᯥ譮 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. "
#define T_STATUS_DL_P1 "<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>... "
#define T_STATUS_DL_P2 " M<> <20><><EFBFBD><EFBFBD><EFBFBD> ("
#define T_STATUS_DL_P3 " K<>/<EFBFBD>) "
#define FILE_SAVED_AS "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0A0AD> <20><><EFBFBD> %s' -Dt" #define FILE_SAVED_AS "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0A0AD> <20><><EFBFBD> %s' -Dt"
#define FILE_NOT_SAVED "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><EFBFBD><E8A8A1>! <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0A0AD> <20><><EFBFBD>\n%s' -Et" #define FILE_NOT_SAVED "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\n<><EFBFBD><E8A8A1>! <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0A0AD> <20><><EFBFBD>\n%s' -Et"
#define KB_RECEIVED "<22><><EFBFBD><EFBFBD> ᪠稢<E1AAA0><E7A8A2><EFBFBD><EFBFBD>: %i.%i M<> <20><><EFBFBD><EFBFBD><EFBFBD> (%i K<>/<EFBFBD>) "
#define T_ERROR_STARTING_DOWNLOAD "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᪠稢<E1AAA0><E7A8A2><EFBFBD><EFBFBD>.\n<><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><E1AEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>୥⮬.' -E" #define T_ERROR_STARTING_DOWNLOAD "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᪠稢<E1AAA0><E7A8A2><EFBFBD><EFBFBD>.\n<><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><E1AEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>୥⮬.' -E"
#define T_AUTOCLOSE "<22><><EFBFBD><E2AEA7><EFBFBD><EFBFBD>⨥"
char accept_language[]= "Accept-Language: ru\n"; char accept_language[]= "Accept-Language: ru\n";
#else #else
#define DL_WINDOW_HEADER "Download Manager" #define DL_WINDOW_HEADER "Download Manager"
@@ -19,20 +27,31 @@
#define T_CANCEL "Cancel" #define T_CANCEL "Cancel"
#define T_OPEN_DIR " Show in folder " #define T_OPEN_DIR " Show in folder "
#define T_RUN "Open file" #define T_RUN "Open file"
#define T_SPEED_TEST "Speed test" #define T_NEW "New download"
#define T_SAVE_TO "Download to:"
#define T_AUTOCLOSE "Close this window when download completes"
#define T_STATUS_READY "Ready to download ^_^ "
#define T_STATUS_DOWNLOADING "Downloading... %i.%i MB received (%i KB/s) "
#define T_STATUS_COMPLETE "Download completed succesfully. "
#define T_STATUS_DL_P1 "Downloading... "
#define T_STATUS_DL_P2 " MB received ("
#define T_STATUS_DL_P3 " KB/s) "
#define FILE_SAVED_AS "'Download manager\nFile saved as %s' -Dt" #define FILE_SAVED_AS "'Download manager\nFile saved as %s' -Dt"
#define FILE_NOT_SAVED "'Download manager\nError! Can\96t save file as %s' -Et" #define FILE_NOT_SAVED "'Download manager\nError! Can\96t save file as %s' -Et"
#define KB_RECEIVED "Downloading: %i.%i MB received (%i KB/s) "
#define T_ERROR_STARTING_DOWNLOAD "'Error while starting download process.\nCheck entered path and Internet connection.' -E" #define T_ERROR_STARTING_DOWNLOAD "'Error while starting download process.\nCheck entered path and Internet connection.' -E"
#define T_AUTOCLOSE "Autoclose"
char accept_language[]= "Accept-Language: en\n"; char accept_language[]= "Accept-Language: en\n";
#endif #endif
#define GAPX 15 #define WIN_W 526
#define WIN_W 540 #define WIN_H 195
#define WIN_H 100
#define GAPX 15
#define BUT_W 148
#define DEFAULT_SAVE_DIR "/tmp0/1/Downloads"
char save_dir[] = "/tmp0/1/Downloads";
char dl_shared[] = "DL"; char dl_shared[] = "DL";
#define URL_SPEED_TEST "http://speedtest.tele2.net/100MB.zip" #define URL_SPEED_TEST "http://speedtest.tele2.net/100MB.zip"
@@ -43,4 +62,9 @@ enum {
BTN_STOP, BTN_STOP,
BTN_DIR, BTN_DIR,
BTN_RUN, BTN_RUN,
BTN_NEW
}; };
#define PB_COL_ERROR 0xF55353
#define PB_COL_PROGRESS 0x297FFD
#define PB_COL_COMPLETE 0x74DA00

View File

@@ -7,7 +7,6 @@
#include "const.h" #include "const.h"
bool exit_param = false;
bool open_file = false; bool open_file = false;
dword speed; dword speed;
@@ -17,11 +16,15 @@ _http http;
checkbox autoclose = { T_AUTOCLOSE, false }; checkbox autoclose = { T_AUTOCLOSE, false };
char uEdit[URL_SIZE]; char uEdit[URL_SIZE];
char filepath[URL_SIZE+96]; char filepath[4096];
char save_dir[4096];
char* active_status;
progress_bar pb = {0, GAPX, 58, 380, 17, 0, NULL, NULL, 0xFFFfff, 0x74DA00, NULL};
edit_box ed = {WIN_W-GAPX-GAPX,GAPX,20,0xffffff,0x94AECE,0xffffff,0xffffff, edit_box ed = {WIN_W-GAPX-GAPX,GAPX,20,0xffffff,0x94AECE,0xffffff,0xffffff,
0x10000000, sizeof(uEdit)-2,#uEdit,0,ed_focus,19,19}; 0x10000000, sizeof(uEdit)-2, #uEdit, 0, ed_focus + ed_always_focus, 19, 19};
progress_bar pb = {0, GAPX, 52, WIN_W - GAPX - GAPX, 17, 0, NULL, NULL,
0xFFFfff, 0, NULL};
void main() void main()
@@ -30,16 +33,19 @@ void main()
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);
load_dll(libHTTP, #http_lib_init,1); load_dll(libHTTP, #http_lib_init,1);
strcpy(#save_dir, DEFAULT_SAVE_DIR);
if (!dir_exists(#save_dir)) CreateDir(#save_dir); if (!dir_exists(#save_dir)) CreateDir(#save_dir);
SetCurDir(#save_dir); SetCurDir(#save_dir);
sc.get();
InitDownload();
if (param) { if (param) {
if (streqrp(#param, "-e ")) { if (streqrp(#param, "-e ")) {
exit_param = true; autoclose.checked = true;
param += 3; param += 3;
} }
if (streqrp(#param, "-eo ")) { if (streqrp(#param, "-eo ")) {
exit_param = true; autoclose.checked = true;
open_file = true; open_file = true;
param += 4; param += 4;
} }
@@ -65,7 +71,7 @@ void main()
case evMouse: edit_box_mouse stdcall (#ed); break; case evMouse: edit_box_mouse stdcall (#ed); break;
case evButton: ProcessButtonClick(@GetButtonID()); break; case evButton: ProcessButtonClick(@GetButtonID()); break;
case evKey: ProcessKeyPress(); break; case evKey: ProcessKeyPress(); break;
case evReDraw: DrawWindow(); break; case evReDraw: DefineWindow(); break;
default: MonitorProgress(); default: MonitorProgress();
} }
} }
@@ -73,11 +79,30 @@ void main()
void ProcessButtonClick(int id) void ProcessButtonClick(int id)
{ {
autoclose.click(id); autoclose.click(id);
if (id==BTN_EXIT) { StopDownloading(); ExitProcess(); } switch (id) {
if (id==BTN_START) StartDownloading(); case BTN_EXIT:
if (id==BTN_STOP) StopDownloading(); StopDownloading();
if (id==BTN_DIR) { RunProgram("/sys/File managers/Eolite", #filepath); ExitProcess(); } ExitProcess();
if (id==BTN_RUN) { RunProgram("/sys/@open", #filepath); ExitProcess(); } case BTN_START:
StartDownloading();
break;
case BTN_STOP:
StopDownloading();
InitDownload();
DrawWindow();
break;
case BTN_NEW:
InitDownload();
EditBox_UpdateText(#ed, ed_focus + ed_always_focus);
DrawWindow();
break;
case BTN_DIR:
RunProgram("/sys/File managers/Eolite", #filepath);
break;
case BTN_RUN:
RunProgram("/sys/@open", #filepath);
break;
}
} }
void ProcessKeyPress() void ProcessKeyPress()
@@ -85,33 +110,53 @@ void ProcessKeyPress()
@GetKey(); @GetKey();
edit_box_key stdcall(#ed); edit_box_key stdcall(#ed);
EAX >>= 16; EAX >>= 16;
if (AL == SCAN_CODE_ENTER) StartDownloading(); if (AL == SCAN_CODE_ENTER) ProcessButtonClick(BTN_START);
if (AL == SCAN_CODE_ESC) StopDownloading(); if (AL == SCAN_CODE_ESC) ProcessButtonClick(BTN_STOP);
}
void DrawDlButton(int x, id, t)
{
DrawCaptButton(x, 102, BUT_W, 24, id, sc.button, sc.button_text, t);
}
void DefineWindow()
{
sc.get();
pb.frame_color = ed.border_color = ed.focus_border_color = sc.line;
DefineAndDrawWindow(110 + random(300), 100 + random(300), WIN_W+9,
WIN_H + 5 + skin_h, 0x34, sc.work, DL_WINDOW_HEADER, 0);
DrawWindow();
} }
void DrawWindow() void DrawWindow()
{ {
sc.get();
pb.frame_color = sc.dark;
DefineAndDrawWindow(110 + random(300), 100 + random(300), WIN_W+9,
WIN_H + 5 + skin_h, 0x34, sc.work, DL_WINDOW_HEADER, 0);
#define BUT_Y 58; #define BUT_Y 58;
//autoclose.draw(WIN_W-135, BUT_Y+6); if (!http.transfer) && (!filepath) {
if (!http.transfer) DrawBar(GAPX, 102, WIN_W - GAPX - GAPX+1, 24+1, sc.work);
{ DeleteButton(BTN_DIR);
DrawStandartCaptButton(GAPX, BUT_Y, BTN_START, T_DOWNLOAD); DeleteButton(BTN_NEW);
if (filepath) DrawDlButton(WIN_W-BUT_W/2, BTN_START, T_DOWNLOAD);
{ autoclose.disabled = false;
DrawStandartCaptButton(GAPX+102, BUT_Y, BTN_DIR, T_OPEN_DIR); } else if (http.transfer) {
DrawStandartCaptButton(GAPX+276, BUT_Y, BTN_RUN, T_RUN); DrawDlButton(WIN_W-BUT_W/2, BTN_STOP, T_CANCEL);
}
} else {
DrawStandartCaptButton(WIN_W - 120, BUT_Y, BTN_STOP, T_CANCEL);
DrawDownloadingProgress(); DrawDownloadingProgress();
} else if (!http.transfer) && (filepath) {
autoclose.disabled = true;
DrawDlButton(GAPX, BTN_RUN, T_RUN);
DrawDlButton(WIN_W-BUT_W/2, BTN_DIR, T_OPEN_DIR);
DrawDlButton(WIN_W-BUT_W-GAPX, BTN_NEW, T_NEW);
} }
//ed.offset=0; //DEL?
DrawEditBox(#ed); WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, active_status, sc.work);
DrawBar(GAPX, WIN_H - 58, WIN_W - GAPX - GAPX, 1, sc.light);
DrawBar(GAPX, WIN_H - 58 + 1, WIN_W - GAPX - GAPX, 1, sc.dark);
WriteText(GAPX, WIN_H - 48, 0x90, sc.work_text, T_SAVE_TO);
WriteTextWithBg(GAPX + 108, WIN_H - 48, 0xD0, sc.work_text, #save_dir, sc.light);
edit_box_draw stdcall (#ed);
progressbar_draw stdcall(#pb);
autoclose.draw(GAPX, WIN_H - 24);
} }
void StartDownloading() void StartDownloading()
@@ -119,34 +164,31 @@ void StartDownloading()
char get_url[URL_SIZE+33]; char get_url[URL_SIZE+33];
if (http.transfer > 0) return; if (http.transfer > 0) return;
ResetDownloadSpeed(); ResetDownloadSpeed();
filepath = '\0'; pb.back_color = 0xFFFfff;
if (!strncmp(#uEdit,"https:",6)) { if (!strncmp(#uEdit,"https:",6)) {
miniprintf(#get_url, "http://gate.aspero.pro/?site=%s", #uEdit); //miniprintf(#get_url, "http://gate.aspero.pro/?site=%s", #uEdit);
//notify("'HTTPS for download is not supported, trying to download the file via HTTP' -W"); notify("'HTTPS for download temporary is not supported,\ntrying to download the file via HTTP' -W");
//miniprintf(#http_url, "http://%s", #uEdit+8); miniprintf(#uEdit, "http://%s", #uEdit+8);
//if (!downloader.Start(#http_url)) {
// notify("'Download failed.' -E");
// StopDownloading();
//}
} else {
strcpy(#get_url, #uEdit);
} }
strcpy(#get_url, #uEdit);
if (http.get(#get_url)) { if (http.get(#get_url)) {
ed.border_color = 0xCACACA;
EditBox_UpdateText(#ed, ed_disabled);
pb.value = 0; pb.value = 0;
pb.progress_color = PB_COL_PROGRESS;
EditBox_UpdateText(#ed, ed_disabled);
DrawWindow(); DrawWindow();
} else { } else {
pb.progress_color = PB_COL_ERROR;
notify(T_ERROR_STARTING_DOWNLOAD); notify(T_ERROR_STARTING_DOWNLOAD);
StopDownloading(); StopDownloading();
if (exit_param) ExitProcess(); EditBox_UpdateText(#ed, ed_focus + ed_always_focus);
DrawWindow();
} }
} }
void DrawDownloadingProgress() void DrawDownloadingProgress()
{ {
char bytes_received[70]; char received_status[70];
dword gotkb = http.content_received/1024; dword gotkb = http.content_received/1024;
EDI = http.content_received / 100; EDI = http.content_received / 100;
@@ -156,8 +198,20 @@ void DrawDownloadingProgress()
pb.max = http.content_length / 100; pb.max = http.content_length / 100;
progressbar_draw stdcall(#pb); progressbar_draw stdcall(#pb);
CalculateDownloadSpeed(); CalculateDownloadSpeed();
sprintf(#bytes_received, KB_RECEIVED, gotkb/1024, gotkb%1024/103, speed);
WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, #bytes_received, sc.work); //sprintf gets too much space
//sprintf(#received_status, T_STATUS_DOWNLOADING, gotkb/1024, gotkb%1024/103, speed);
strcpy(#received_status, T_STATUS_DL_P1);
strcat(#received_status, itoa(gotkb/1024));
strcat(#received_status, ".");
strcat(#received_status, itoa(gotkb%1024/103));
strcat(#received_status, T_STATUS_DL_P2);
strcat(#received_status, itoa(speed));
strcat(#received_status, T_STATUS_DL_P3);
active_status = #received_status;
WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, active_status, sc.work);
} }
void StopDownloading() void StopDownloading()
@@ -165,10 +219,15 @@ void StopDownloading()
http.stop(); http.stop();
if (http.content_pointer) http.content_pointer = free(http.content_pointer); if (http.content_pointer) http.content_pointer = free(http.content_pointer);
http.content_received = http.content_length = 0; http.content_received = http.content_length = 0;
}
ed.border_color = 0xFFFfff; void InitDownload()
EditBox_UpdateText(#ed, ed_focus); {
DrawWindow(); pb.value = 0;
pb.back_color = sc.light;
pb.progress_color = PB_COL_PROGRESS;
filepath = '\0';
active_status = T_STATUS_READY;
} }
void MonitorProgress() void MonitorProgress()
@@ -188,12 +247,21 @@ void MonitorProgress()
StopDownloading(); StopDownloading();
StartDownloading(); StartDownloading();
return; return;
} else {
CompleteDownload();
} }
}
}
void CompleteDownload()
{
SaveFile(0); SaveFile(0);
if (exit_param) ExitProcess(); if (autoclose.checked) ExitProcess();
pb.value = pb.max;
pb.progress_color = PB_COL_COMPLETE;
StopDownloading(); StopDownloading();
active_status = T_STATUS_COMPLETE;
DrawWindow(); DrawWindow();
}
} }
void SaveFile(int attempt) void SaveFile(int attempt)
@@ -202,8 +270,9 @@ void SaveFile(int attempt)
char notify_message[4296]; char notify_message[4296];
char file_name[URL_SIZE+96]; char file_name[URL_SIZE+96];
strcpy(#filepath, #save_dir); strcpy(#filepath, #save_dir);
chrcat(#filepath, '/'); chrcat(#filepath, '/'); ///need to check the last symbol
if (attempt > 9) { if (attempt > 9) {
notify("'Too many saving attempts' -E"); notify("'Too many saving attempts' -E");
@@ -243,7 +312,8 @@ void SaveFile(int attempt)
miniprintf(#notify_message, FILE_NOT_SAVED, #filepath); miniprintf(#notify_message, FILE_NOT_SAVED, #filepath);
} }
if (!exit_param) notify(#notify_message); if (!autoclose.checked) notify(#notify_message);
if (!strcmpi(#filepath+strlen(#filepath)-4, ".zip")) if (!strcmpi(#filepath+strlen(#filepath)-4, ".zip"))
|| (!strcmpi(#filepath+strlen(#filepath)-3, ".7z")) { || (!strcmpi(#filepath+strlen(#filepath)-3, ".7z")) {
@@ -257,11 +327,12 @@ void SaveFile(int attempt)
void Unarchive(dword _arc) void Unarchive(dword _arc)
{ {
char folder_name[4096]; char folder_name[4096];
strcpy(#folder_name, "/tmp0/1/Downloads/"); strcpy(#folder_name, #save_dir);
strcpy(#folder_name, #filepath+strrchr(#filepath, '/')); strcpy(#folder_name, #filepath+strrchr(#filepath, '/'));
folder_name[strlen(#folder_name)-4] = '\0'; folder_name[strlen(#folder_name)-4] = '\0';
CreateDir(#folder_name); CreateDir(#folder_name);
//miniprintf2(#param, "-o \"%s\" -h \"%s", #folder_name, #filepath);
strcpy(#param, "-o \""); strcpy(#param, "-o \"");
strcat(#param, #folder_name); strcat(#param, #folder_name);
strcat(#param, "\" -h \""); strcat(#param, "\" -h \"");