Separate Downloader from WebView into /sys/network/dl
+ Multi-threaded now! + Some small fixes git-svn-id: svn://kolibrios.org@8278 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -641,6 +641,7 @@ tup.append_table(img_files, {
|
||||
{"GAMES/MINE", PROGS .. "/games/mine/trunk/mine"},
|
||||
{"MEDIA/PIXIE", PROGS .. "/cmm/pixie2/pixie.com"},
|
||||
{"MEDIA/ICONEDIT", PROGS .. "/cmm/iconedit/iconedit.com"},
|
||||
{"NETWORK/DL", PROGS .. "/cmm/downloader/dl.com"},
|
||||
{"NETWORK/WEBVIEW", PROGS .. "/cmm/browser/WebView.com"},
|
||||
})
|
||||
tup.append_table(extra_files, {
|
||||
|
@@ -30,14 +30,15 @@
|
||||
#include "..\lib\patterns\toolbar_button.h"
|
||||
#include "..\lib\patterns\restart_process.h"
|
||||
|
||||
char editbox_icons[] = FROM "res/editbox_icons.raw";
|
||||
|
||||
#define URL_SIZE 4000
|
||||
|
||||
char version[]="WebView 2.65b";
|
||||
char version[]="WebView 2.66";
|
||||
|
||||
#include "texts.h"
|
||||
#include "cache.h"
|
||||
#include "show_src.h"
|
||||
#include "download_manager.h"
|
||||
|
||||
bool debug_mode = false;
|
||||
|
||||
@@ -101,8 +102,6 @@ char editURL[URL_SIZE+1];
|
||||
edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff,
|
||||
0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
|
||||
|
||||
char editbox_icons[] = FROM "editbox_icons.raw";
|
||||
|
||||
dword shared_url;
|
||||
|
||||
dword http_get_type;
|
||||
@@ -120,17 +119,10 @@ void LoadLibraries()
|
||||
|
||||
void HandleParam()
|
||||
{
|
||||
if (param) {
|
||||
if (!strncmp(#param, "-download_and_exit ", 19)) {
|
||||
download_and_exit = true;
|
||||
strcpy(#downloader_edit, #param+19);
|
||||
Downloader();
|
||||
ExitProcess();
|
||||
} else if (!strncmp(#param, "-download ", 10)) {
|
||||
strcpy(#downloader_edit, #param+10);
|
||||
Downloader();
|
||||
ExitProcess();
|
||||
} else if (!strncmp(#param, "-source ", 8)) {
|
||||
if (!param) {
|
||||
history.add(URL_SERVICE_HOMEPAGE);
|
||||
} else {
|
||||
if (!strncmp(#param, "-source ", 8)) {
|
||||
source_mode = true;
|
||||
history.add(#param + 8);
|
||||
} else if (!strncmp(#param, "-new ", 5)) {
|
||||
@@ -144,8 +136,6 @@ void HandleParam()
|
||||
ExitProcess();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
history.add(URL_SERVICE_HOMEPAGE);
|
||||
}
|
||||
shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE);
|
||||
ESDWORD[shared_url] = '\0';
|
||||
@@ -155,7 +145,6 @@ void main()
|
||||
{
|
||||
int i, redirect_count=0;
|
||||
LoadLibraries();
|
||||
CreateDir("/tmp0/1/Downloads");
|
||||
//CreateDir("/tmp0/1/WebView_Cache");
|
||||
HandleParam();
|
||||
WB1.list.SetFont(8, 14, 10011000b);
|
||||
@@ -438,10 +427,7 @@ void ProcessEvent(dword id__)
|
||||
OpenPage(URL_SERVICE_HISTORY);
|
||||
return;
|
||||
case DOWNLOAD_MANAGER:
|
||||
if (!downloader_opened) {
|
||||
downloader_edit = NULL;
|
||||
CreateThread(#Downloader,#downloader_stak+4092);
|
||||
}
|
||||
EventOpenDownloader("");
|
||||
return;
|
||||
case UPDATE_BROWSER:
|
||||
EventUpdateBrowser();
|
||||
@@ -462,11 +448,7 @@ void ProcessEvent(dword id__)
|
||||
notify("'URL copied to clipboard'O");
|
||||
return;
|
||||
case DOWNLOAD_LINK_CONTENTS:
|
||||
if (!downloader_opened) {
|
||||
id__ = GetAbsoluteActiveURL();
|
||||
strcpy(#downloader_edit, id__);
|
||||
CreateThread(#Downloader,#downloader_stak+4092);
|
||||
}
|
||||
EventOpenDownloader( GetAbsoluteActiveURL() );
|
||||
return;
|
||||
case OPEN_FILE:
|
||||
EventOpenDialog();
|
||||
@@ -594,10 +576,10 @@ void OpenPage(dword _open_URL)
|
||||
|
||||
} else if (!strncmp(#new_url,"WebView:",8)) {
|
||||
//INTERNAL PAGE
|
||||
if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buidin_page_home, sizeof(buidin_page_home));
|
||||
else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buidin_page_help, sizeof(buidin_page_help));
|
||||
if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home));
|
||||
else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buildin_page_help, sizeof(buildin_page_help));
|
||||
else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
|
||||
else LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
|
||||
else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
|
||||
|
||||
} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
|
||||
//WEB PAGE
|
||||
@@ -618,7 +600,7 @@ void OpenPage(dword _open_URL)
|
||||
|
||||
if (!http.transfer) {
|
||||
StopLoading();
|
||||
LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
|
||||
LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
|
||||
}
|
||||
} else {
|
||||
//LOCAL PAGE
|
||||
@@ -630,11 +612,16 @@ void OpenPage(dword _open_URL)
|
||||
strcpy(#new_url, "/tmp0/1/temp/word/document.xml");
|
||||
}
|
||||
if (!GetLocalFileData(#new_url)) {
|
||||
LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
|
||||
LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dword EventOpenDownloader(dword _url)
|
||||
{
|
||||
//char download_params[URL_SIZE+50];
|
||||
return RunProgram("/sys/network/dl", _url);
|
||||
}
|
||||
|
||||
bool EventClickAnchor()
|
||||
{
|
||||
@@ -720,11 +707,7 @@ void EventClickLink(dword _target)
|
||||
if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true)
|
||||
|| (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true)
|
||||
|| (UrlExtIs(#new_url,".7z")==true) {
|
||||
if (!downloader_opened) {
|
||||
strcpy(#downloader_edit, #new_url);
|
||||
CreateThread(#Downloader,#downloader_stak+4092);
|
||||
}
|
||||
else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
|
||||
EventOpenDownloader(#new_url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -747,7 +730,7 @@ void EventSubmitOmnibox()
|
||||
|
||||
void LoadInternalPage(dword _bufdata, _in_bufsize){
|
||||
if (!_bufdata) || (!_in_bufsize) {
|
||||
LoadInternalPage(#buidin_page_error, sizeof(buidin_page_error));
|
||||
LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
|
||||
} else {
|
||||
WB1.list.first = 0; //scroll page to the top
|
||||
DrawOmnibox();
|
||||
@@ -892,7 +875,7 @@ void EventUpdateBrowser()
|
||||
|
||||
draw_window();
|
||||
|
||||
downloader_id = RunProgram(#program_path, #update_param);
|
||||
downloader_id = EventOpenDownloader(#update_param);
|
||||
do {
|
||||
slot_n = GetProcessSlot(downloader_id);
|
||||
pause(10);
|
||||
|
Before Width: | Height: | Size: 998 B After Width: | Height: | Size: 998 B |
@@ -1,7 +1,7 @@
|
||||
#ifdef LANG_RUS
|
||||
char buidin_page_error[] = FROM "buidin_pages\\page_not_found_ru.htm""\0";
|
||||
char buidin_page_home[] = FROM "buidin_pages\\homepage_ru.htm""\0";
|
||||
char buidin_page_help[] = FROM "buidin_pages\\help_ru.htm""\0";
|
||||
char buildin_page_error[] = FROM "res/page_not_found_ru.htm""\0";
|
||||
char buildin_page_home[] = FROM "res/homepage_ru.htm""\0";
|
||||
char buildin_page_help[] = FROM "res/help_ru.htm""\0";
|
||||
char accept_language[]= "Accept-Language: ru\n";
|
||||
char rmb_menu[] =
|
||||
"<EFBFBD><EFBFBD>ᬮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>室<EFBFBD><E5AEA4><EFBFBD>|Ctrl+U
|
||||
@@ -22,16 +22,16 @@ char link_menu[] =
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᮤ<EFBFBD>ন<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>뫪<EFBFBD>";
|
||||
char loading_text[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㧪<EFBFBD>...";
|
||||
|
||||
char update_param[] = "-download_and_exit http://builds.kolibrios.org/rus/data/programs/cmm/browser/WebView.com";
|
||||
char update_param[] = "-exit http://builds.kolibrios.org/rus/data/programs/cmm/browser/WebView.com";
|
||||
char update_download_error[] = "'WebView\n<EFBFBD>訡<EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>祭<EFBFBD><E7A5AD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -tE";
|
||||
char update_ok[] = "'WebView\n<EFBFBD><EFBFBD><EFBFBD>㧥<EFBFBD> <20><><EFBFBD> <20>ᯥ譮 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -tO";
|
||||
char update_is_current[] = "'WebView\n<EFBFBD><EFBFBD> 㦥 <20>ᯮ<EFBFBD><E1AFAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.' -tI";
|
||||
char update_can_not_copy[] = "'WebView\n<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>६<EFBFBD><E0A5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> Downloads <20><> Ramdisk. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>筮 <20><><EFBFBD><EFBFBD><EFBFBD>.' -tE";
|
||||
char clear_cache_ok[] = "'WebView\n<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>饭.' -tI";
|
||||
#else
|
||||
char buidin_page_error[] = FROM "buidin_pages\\page_not_found_en.htm""\0";
|
||||
char buidin_page_home[] = FROM "buidin_pages\\homepage_en.htm""\0";
|
||||
char buidin_page_help[] = FROM "buidin_pages\\help_en.htm""\0";
|
||||
char buildin_page_error[] = FROM "res/page_not_found_en.htm""\0";
|
||||
char buildin_page_home[] = FROM "res/homepage_en.htm""\0";
|
||||
char buildin_page_help[] = FROM "res/help_en.htm""\0";
|
||||
char accept_language[]= "Accept-Language: en\n";
|
||||
char rmb_menu[] =
|
||||
"View source|Ctrl+U
|
||||
@@ -51,7 +51,7 @@ Open in new window
|
||||
Copy link
|
||||
Download link contents";
|
||||
char loading_text[] = "Loading...";
|
||||
char update_param[] = "-download_and_exit http://builds.kolibrios.org/eng/data/programs/cmm/browser/WebView.com";
|
||||
char update_param[] = "-exit http://builds.kolibrios.org/eng/data/programs/cmm/browser/WebView.com";
|
||||
char update_download_error[] = "'WebView\nError receiving an up to date information!' -tE";
|
||||
char update_ok[] = "'WebView\nThe browser has been updated!' -tO";
|
||||
char update_is_current[] = "'WebView\nThe browser is up to date.' -tI";
|
||||
|
38
programs/cmm/downloader/const.h
Normal file
38
programs/cmm/downloader/const.h
Normal file
@@ -0,0 +1,38 @@
|
||||
//Copyright 2020 by Leency
|
||||
|
||||
#ifndef AUTOBUILD
|
||||
#include "lang.h--"
|
||||
#endif
|
||||
|
||||
#ifdef LANG_RUS
|
||||
#define DL_WINDOW_HEADER "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧮<EFBFBD>"
|
||||
#define START_DOWNLOADING "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
||||
#define STOP_DOWNLOADING "<22>⬥<EFBFBD><E2ACA5>"
|
||||
#define SHOW_IN_FOLDER "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>"
|
||||
#define OPEN_FILE_TEXT "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><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_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><E0A0AD> <20><><EFBFBD>\n%s' -Et"
|
||||
#define KB_RECEIVED "<22><><EFBFBD><EFBFBD> ᪠稢<E1AAA0><E7A8A2><EFBFBD><EFBFBD>... %s <20><><EFBFBD><EFBFBD>祭<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<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><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"
|
||||
char accept_language[]= "Accept-Language: ru\n";
|
||||
#else
|
||||
#define DL_WINDOW_HEADER "Download Manager"
|
||||
#define START_DOWNLOADING "Start downloading"
|
||||
#define STOP_DOWNLOADING "Cancel"
|
||||
#define SHOW_IN_FOLDER "Show in folder"
|
||||
#define OPEN_FILE_TEXT "Open file"
|
||||
#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 KB_RECEIVED "Downloading... %s received"
|
||||
#define T_ERROR_STARTING_DOWNLOAD "'Error while starting download process.\nPlease, check entered path and Internet connection.' -E"
|
||||
char accept_language[]= "Accept-Language: en\n";
|
||||
#endif
|
||||
|
||||
#define GAPX 15
|
||||
#define WIN_W 580
|
||||
#define WIN_H 100
|
||||
|
||||
#define URL_SIZE 4000
|
||||
|
||||
char save_to[] = "/tmp0/1/Downloads";
|
||||
char dl_shared[] = "DL";
|
@@ -1,77 +1,70 @@
|
||||
//Copyright 2020 by Leency
|
||||
|
||||
#define MEMSIZE 1024 * 100
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/random.h"
|
||||
#include "../lib/obj/box_lib.h"
|
||||
#include "../lib/obj/http.h"
|
||||
#include "../lib/patterns/http_downloader.h"
|
||||
|
||||
#include "const.h"
|
||||
|
||||
DOWNLOADER downloader;
|
||||
|
||||
#ifdef LANG_RUS
|
||||
#define DL_WINDOW_HEADER "Œ¥¥¤¦¥à § £àã§®ª"
|
||||
#define START_DOWNLOADING "<22> ç âì § ª çªã"
|
||||
#define STOP_DOWNLOADING "Žáâ ®¢¨âì"
|
||||
#define SHOW_IN_FOLDER "<22>®ª § âì ¢ ¯ ¯ª¥"
|
||||
#define OPEN_FILE_TEXT "Žâªàëâì ä ©«"
|
||||
#define FILE_SAVED_AS "'Œ¥¥¤¦¥à § £àã§®ª\n” ©« á®åà ¥ ª ª "
|
||||
#define KB_RECEIVED "ˆ¤¥â ᪠稢 ¨¥... %s ¯®«ã祮"
|
||||
#else
|
||||
#define DL_WINDOW_HEADER "Download Manager"
|
||||
#define START_DOWNLOADING "Start downloading"
|
||||
#define STOP_DOWNLOADING "Stop downloading"
|
||||
#define SHOW_IN_FOLDER "Show in folder"
|
||||
#define OPEN_FILE_TEXT "Open file"
|
||||
#define FILE_SAVED_AS "'Download manager\nFile saved as "
|
||||
#define KB_RECEIVED "Downloading... %s received"
|
||||
#endif
|
||||
char save_to[4096] = "/tmp0/1/Downloads";
|
||||
|
||||
#define CONX 15
|
||||
|
||||
proc_info DL_Form;
|
||||
char downloader_edit[10000];
|
||||
char downloader_edit[4000];
|
||||
char filepath[4096];
|
||||
edit_box ed = {NULL,57,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit)-2,#downloader_edit,0,ed_focus,19,19};
|
||||
progress_bar pb = {0, CONX, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
|
||||
//progress_bar pb = {0, 180, 55, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
|
||||
edit_box ed = {WIN_W-GAPX-GAPX,GAPX,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,
|
||||
sizeof(downloader_edit)-2,#downloader_edit,0,ed_focus,19,19};
|
||||
progress_bar pb = {0, GAPX, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
|
||||
//progress_bar: value, left, top, width, height, style, min, max, back_color, progress_color, frame_color;
|
||||
|
||||
bool downloader_opened;
|
||||
char downloader_stak[4096];
|
||||
bool exit_when_done = false;
|
||||
|
||||
bool download_and_exit = false;
|
||||
|
||||
void Downloader()
|
||||
void main()
|
||||
{
|
||||
dword shared_url;
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
load_dll(libHTTP, #http_lib_init,1);
|
||||
|
||||
if (!dir_exists(#save_to)) CreateDir(#save_to);
|
||||
downloader_opened = true;
|
||||
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
||||
|
||||
sc.get();
|
||||
pb.frame_color = sc.work_dark;
|
||||
if (param) {
|
||||
if (!strncmp(#param, "-exit ", 6)) {
|
||||
exit_when_done = true;
|
||||
param += 6;
|
||||
}
|
||||
|
||||
filepath[0] = NULL;
|
||||
|
||||
downloader.Stop();
|
||||
if (!strncmp(#param, "-mem", 5)) {
|
||||
shared_url = memopen(#dl_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
|
||||
strcpy(#downloader_edit, shared_url);
|
||||
} else {
|
||||
strcpy(#downloader_edit, #param);
|
||||
}
|
||||
}
|
||||
if (downloader_edit[0]) StartDownloading(); else strcpy(#downloader_edit, "http://");
|
||||
ed.size = ed.pos = ed.shift = ed.shift_old = strlen(#downloader_edit);
|
||||
|
||||
loop() switch(WaitEvent())
|
||||
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
||||
@SetWindowLayerBehaviour(-1, ZPOS_ALWAYS_TOP);
|
||||
loop() switch(@WaitEvent())
|
||||
{
|
||||
case evMouse:
|
||||
edit_box_mouse stdcall (#ed);
|
||||
break;
|
||||
|
||||
case evButton:
|
||||
Key_Scan(GetButtonID());
|
||||
ProcessEvent(GetButtonID());
|
||||
break;
|
||||
|
||||
case evKey:
|
||||
GetKeys();
|
||||
edit_box_key stdcall(#ed);
|
||||
if (key_scancode==SCAN_CODE_ENTER) Key_Scan(301);
|
||||
if (key_scancode==SCAN_CODE_ENTER) ProcessEvent(301);
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
DefineAndDrawWindow(215, 100, 580, 130, 0x74, sc.work, DL_WINDOW_HEADER, 0);
|
||||
GetProcessInfo(#DL_Form, SelfInfo);
|
||||
if (DL_Form.status_window>2) break;
|
||||
if (DL_Form.height<120) MoveSize(OLD,OLD,OLD,120);
|
||||
if (DL_Form.width<280) MoveSize(OLD,OLD,280,OLD);
|
||||
DL_Draw_Window();
|
||||
DrawWindow();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -87,38 +80,38 @@ void Downloader()
|
||||
if (downloader.state == STATE_COMPLETED)
|
||||
{
|
||||
SaveDownloadedFile();
|
||||
if (download_and_exit) ExitProcess();
|
||||
if (exit_when_done) ExitProcess();
|
||||
StopDownloading();
|
||||
DL_Draw_Window();
|
||||
DrawWindow();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Key_Scan(int id)
|
||||
void ProcessEvent(int id)
|
||||
{
|
||||
if (id==001) { downloader_opened=false; StopDownloading(); ExitProcess(); }
|
||||
if (id==001) { StopDownloading(); ExitProcess(); }
|
||||
if (id==301) && (downloader.httpd.transfer <= 0) StartDownloading();
|
||||
if (id==302) StopDownloading();
|
||||
if (id==305) RunProgram("/sys/File managers/Eolite", #save_to);
|
||||
if (id==305) RunProgram("/sys/File managers/Eolite", #filepath);
|
||||
if (id==306) {
|
||||
SetCurDir(#save_to);
|
||||
RunProgram("/sys/@open", #filepath);
|
||||
}
|
||||
}
|
||||
|
||||
void DL_Draw_Window()
|
||||
void DrawWindow()
|
||||
{
|
||||
int but_x = 0;
|
||||
int but_y = 58;
|
||||
DrawBar(0,0, DL_Form.cwidth, DL_Form.cheight, sc.work);
|
||||
DeleteButton(301);
|
||||
DeleteButton(302);
|
||||
DeleteButton(305);
|
||||
DeleteButton(306);
|
||||
|
||||
sc.get();
|
||||
pb.frame_color = sc.work_dark;
|
||||
DefineAndDrawWindow(110 + random(300), 100 + random(300), WIN_W+9, WIN_H + 5 + skin_height, 0x34, sc.work, DL_WINDOW_HEADER, 0);
|
||||
|
||||
if (downloader.state == STATE_NOT_STARTED) || (downloader.state == STATE_COMPLETED)
|
||||
{
|
||||
but_x = CONX + DrawStandartCaptButton(CONX, but_y, 301, START_DOWNLOADING);
|
||||
but_x = GAPX + DrawStandartCaptButton(GAPX, but_y, 301, START_DOWNLOADING);
|
||||
if (filepath[0])
|
||||
{
|
||||
but_x += DrawStandartCaptButton(but_x, but_y, 305, SHOW_IN_FOLDER);
|
||||
@@ -127,11 +120,9 @@ void DL_Draw_Window()
|
||||
}
|
||||
if (downloader.state == STATE_IN_PROGRESS)
|
||||
{
|
||||
DrawStandartCaptButton(DL_Form.width - 190, but_y, 302, STOP_DOWNLOADING);
|
||||
DrawStandartCaptButton(WIN_W - 190, but_y, 302, STOP_DOWNLOADING);
|
||||
DrawDownloading();
|
||||
}
|
||||
WriteText(CONX, ed.top + 4, 0x90, sc.work_text, "URL:");
|
||||
ed.width = DL_Form.cwidth - ed.left - CONX - 3;
|
||||
ed.offset=0;
|
||||
DrawEditBox(#ed);
|
||||
}
|
||||
@@ -143,7 +134,7 @@ void StartDownloading()
|
||||
StopDownloading();
|
||||
if (!strncmp(#downloader_edit,"https://",7)) {
|
||||
notify("'HTTPS for download is not supported, trying to download the file via HTTP' -W");
|
||||
sprintf(#http_url, "http://%s", #downloader_edit+8);
|
||||
miniprintf(#http_url, "http://%s", #downloader_edit+8);
|
||||
if (!downloader.Start(#http_url)) {
|
||||
notify("'Download failed.' -E");
|
||||
StopDownloading();
|
||||
@@ -153,19 +144,19 @@ void StartDownloading()
|
||||
// notify("'Download failed.' -E");
|
||||
// StopDownloading();
|
||||
//}
|
||||
DL_Draw_Window();
|
||||
DrawWindow();
|
||||
return;
|
||||
}
|
||||
if (!downloader.Start(#downloader_edit)) {
|
||||
if (download_and_exit) ExitProcess();
|
||||
notify("'Error while starting download process.\nPlease, check entered path and internet connection.' -E");
|
||||
if (exit_when_done) ExitProcess();
|
||||
notify(T_ERROR_STARTING_DOWNLOAD);
|
||||
StopDownloading();
|
||||
return;
|
||||
}
|
||||
ed.blur_border_color = 0xCACACA;
|
||||
ed.flags = 100000000000b;
|
||||
pb.value = 0;
|
||||
DL_Draw_Window();
|
||||
DrawWindow();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -200,9 +191,8 @@ void CalculateSpeed()
|
||||
void DrawDownloading()
|
||||
{
|
||||
char bytes_received[70];
|
||||
sprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.httpd.content_received) );
|
||||
DrawBar(CONX, pb.top + 22, pb.width, 16, sc.work);
|
||||
WriteText(CONX, pb.top + 22, 0x90, sc.work_text, #bytes_received);
|
||||
miniprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.httpd.content_received) );
|
||||
WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, #bytes_received, sc.work);
|
||||
//CalculateSpeed();
|
||||
progressbar_draw stdcall(#pb);
|
||||
}
|
||||
@@ -212,7 +202,7 @@ void StopDownloading()
|
||||
downloader.Stop();
|
||||
ed.blur_border_color = 0xFFFfff;
|
||||
ed.flags = 10b;
|
||||
DL_Draw_Window();
|
||||
DrawWindow();
|
||||
}
|
||||
|
||||
void SaveDownloadedFile()
|
||||
@@ -226,15 +216,27 @@ void SaveDownloadedFile()
|
||||
while (aux[strlen(#aux)-1] == '/') {
|
||||
aux[strlen(#aux)-1] = 0;
|
||||
}
|
||||
sprintf(#filepath, "%s/%s", #save_to, #aux+strrchr(#aux, '/'));
|
||||
|
||||
//miniprintf(#filepath, "%s/", #save_to);
|
||||
strcpy(#filepath, #save_to);
|
||||
chrcat(#filepath, '/');
|
||||
strcat(#filepath, #aux+strrchr(#aux, '/'));
|
||||
|
||||
for (i=0; i<strlen(#filepath); i++) if(filepath[i]==':')||(filepath[i]=='?')filepath[i]='-';
|
||||
|
||||
if (CreateFile(downloader.httpd.content_received, downloader.bufpointer, #filepath)==0) {
|
||||
sprintf(#notify_message, "%s%s%s",FILE_SAVED_AS,#filepath,"' -Dt");
|
||||
miniprintf(#notify_message, FILE_SAVED_AS, #filepath);
|
||||
} else {
|
||||
sprintf(#notify_message, "%s%s%s","'Download manager\nError! Can\96t save file as ",#filepath,"' -Et");
|
||||
miniprintf(#notify_message, FILE_NOT_SAVED, #filepath);
|
||||
}
|
||||
|
||||
if (!download_and_exit) notify(#notify_message);
|
||||
/*
|
||||
if (CreateFile(downloader.httpd.content_received, downloader.bufpointer, #filepath)==0) {
|
||||
strcpy(#notify_message, "'Download complete' -Dt");
|
||||
} else {
|
||||
strcpy(#notify_message, "'Error saving downloaded file!' -Et");
|
||||
}
|
||||
*/
|
||||
|
||||
if (!exit_when_done) notify(#notify_message);
|
||||
}
|
@@ -37,6 +37,7 @@ char logo[] = "
|
||||
#endif
|
||||
|
||||
#define B_INSTALL 10
|
||||
#define B_EXIT 11
|
||||
|
||||
bool install_complete = false;
|
||||
|
||||
@@ -50,8 +51,8 @@ void main()
|
||||
{
|
||||
case evButton:
|
||||
btn = GetButtonID();
|
||||
if (btn == 1) ExitProcess();
|
||||
if (btn == B_INSTALL) EventInstall();
|
||||
if (btn == 1) || (B_EXIT == btn) ExitProcess();
|
||||
if (B_INSTALL == btn) EventInstall();
|
||||
break;
|
||||
|
||||
case evKey:
|
||||
@@ -96,7 +97,7 @@ 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, CLOSE_BTN,
|
||||
DrawCaptButton(WINW-110/2, WINH-70, 110, 28, B_EXIT,
|
||||
0x0092D8, 0xFFFfff, T_EXIT);
|
||||
}
|
||||
|
||||
|
@@ -842,6 +842,16 @@ inline signed csshexdec(dword text)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void miniprintf(dword dst, format, insert_line)
|
||||
{
|
||||
dword in_pos = strchr(format, '%');
|
||||
if (ESBYTE[in_pos+1] == 's') {
|
||||
strlcpy(dst, format, in_pos - format);
|
||||
strcat(dst, insert_line);
|
||||
strcat(dst, in_pos+2);
|
||||
}
|
||||
}
|
||||
|
||||
inline cdecl int sprintf(dword buf, format,...)
|
||||
{
|
||||
#define END_ARGS 0xFF00FF //ARGS FUNCTION
|
||||
|
Reference in New Issue
Block a user