diff --git a/programs/cmm/aelia/aelia.c b/programs/cmm/aelia/aelia.c index 571266b625..7070c168a5 100644 --- a/programs/cmm/aelia/aelia.c +++ b/programs/cmm/aelia/aelia.c @@ -15,6 +15,7 @@ #include "../lib/patterns/simple_open_dialog.h" #include "../lib/patterns/history.h" #include "../lib/patterns/http_downloader.h" +#include "../browser/download_manager.h" char default_dir[] = "/rd/1"; od_filter filter2 = {0,0}; @@ -68,7 +69,7 @@ dword CursorFile = FROM "pointer.cur"; #include "prepare_page.h" //#include "special_symbols.h" -#define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nAbout" +#define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout" void InitDlls() { @@ -117,7 +118,8 @@ void main() if (menu.list.cur_y==0) EventPageRefresh(); if (menu.list.cur_y==1) EventRunEdit(); if (menu.list.cur_y==2) EventShowHistory(); - if (menu.list.cur_y==3) EventShowInfo(); + if (menu.list.cur_y==3) EventShowDownloader(); + if (menu.list.cur_y==4) EventShowInfo(); menu.list.cur_y = 0; } } @@ -391,6 +393,14 @@ void EventPageRefresh() EventOpenAddress(history.current()); } +void EventShowDownloader() +{ + if (!downloader_opened) { + downloader_edit = NULL; + CreateThread(#Downloader,#downloader_stak+4092); + } +} + /* ------------------------------------------- */ diff --git a/programs/cmm/aelia/buidin_pages/about.htm b/programs/cmm/aelia/buidin_pages/about.htm index 0dd4d3752d..67d8f7ada8 100644 Binary files a/programs/cmm/aelia/buidin_pages/about.htm and b/programs/cmm/aelia/buidin_pages/about.htm differ diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 8adddc72ac..a1ac7c0d4a 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -565,6 +565,4 @@ void ClickLink() return; } - -char downloader_stak[4096]; stop: \ No newline at end of file diff --git a/programs/cmm/browser/download_manager.h b/programs/cmm/browser/download_manager.h index 5520a52987..f383faf81a 100644 --- a/programs/cmm/browser/download_manager.h +++ b/programs/cmm/browser/download_manager.h @@ -3,7 +3,7 @@ #define START_DOWNLOADING "Начать закачку" #define STOP_DOWNLOADING "Остановить" #define SHOW_IN_FOLDER "Показать в папке" - #define OPEN_FILE "Открыть файл" + #define OPEN_FILE_TEXT "Открыть файл" #define FILE_SAVED_AS "'Менеджер загрузок\nФайл сохранен как " #define KB_RECEIVED " получено" #else @@ -11,11 +11,11 @@ #define START_DOWNLOADING "Start downloading" #define STOP_DOWNLOADING "Stop downloading" #define SHOW_IN_FOLDER "Show in folder" - #define OPEN_FILE "Open file" + #define OPEN_FILE_TEXT "Open file" #define FILE_SAVED_AS "'Download manager\nFile saved as " #define KB_RECEIVED " received" #endif -char save_to[4096] = "/tmp0/1/Downloads/"; +char save_to[4096] = "/tmp0/1/Downloads"; proc_info DL_Form; char downloader_edit[10000]; @@ -25,6 +25,7 @@ edit_box ed = {250,20,20,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(downloader progress_bar pb = {0, 170, 51, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F}; byte downloader_opened; +char downloader_stak[4096]; void Downloader() @@ -80,9 +81,11 @@ void Downloader() } if (downloader.state == STATE_COMPLETED) { + if (!dir_exists(#save_to)) CreateDir(#save_to); strcpy(#filepath, #save_to); - strcat(#filepath, #save_to+strrchr(#save_to, '/')); - if (WriteFile(downloader.bufsize, downloader.bufpointer, #filepath)==0) + chrcat(#filepath, '/'); + strcat(#filepath, #downloader_edit+strrchr(#downloader_edit, '/')); + if (WriteFile(downloader.data_downloaded_size, downloader.bufpointer, #filepath)==0) sprintf(#notify_message, "%s%s%s",FILE_SAVED_AS,#filepath,"' -Dt"); else sprintf(#notify_message, "%s%s%s","'Download manager\nError! Can\96t save file as ",#filepath,"' -Et"); @@ -122,7 +125,7 @@ void DL_Draw_Window() if (downloader.state == STATE_COMPLETED) { DrawCaptButton(cleft+140, 50, 110, 27, 305, system.color.work_button, system.color.work_button_text, SHOW_IN_FOLDER); - DrawCaptButton(cleft+260, 50, 120, 27, 306, system.color.work_button, system.color.work_button_text, OPEN_FILE); + DrawCaptButton(cleft+260, 50, 120, 27, 306, system.color.work_button, system.color.work_button_text, OPEN_FILE_TEXT); } WriteText(cleft, ed.top + 4, 0x80, system.color.work_text, "URL:"); ed.left = strlen("URL:")*6 + 10 + cleft; diff --git a/programs/cmm/browser/http_downloader.h b/programs/cmm/browser/http_downloader.h deleted file mode 100644 index 3b50549b09..0000000000 --- a/programs/cmm/browser/http_downloader.h +++ /dev/null @@ -1,66 +0,0 @@ - -enum { - STATE_NOT_STARTED, - STATE_IN_PROGRESS, - STATE_COMPLETED -}; - -struct DOWNLOADER { - int data_downloaded_size, data_full_size; - dword bufpointer, bufsize; - byte state; - dword http_transfer; - dword Start(); - void Stop(); - void Completed(); - int MonitorProgress(); -} downloader; - -dword DOWNLOADER::Start(dword _url) -{ - state = STATE_IN_PROGRESS; - http_get stdcall (_url, 0, 0, #accept_language); - http_transfer = EAX; - return http_transfer; -} - -void DOWNLOADER::Stop() -{ - state = STATE_NOT_STARTED; - if (http_transfer!=0) - { - EAX = http_transfer; - EAX = EAX.http_msg.content_ptr; // get pointer to data - $push EAX // save it on the stack - http_free stdcall (http_transfer); // abort connection - $pop EAX - mem_Free(EAX); // free data - http_transfer=0; - bufsize = 0; - bufpointer = mem_Free(bufpointer); - } - data_downloaded_size = data_full_size = 0; -} - -void DOWNLOADER::Completed() -{ - state = STATE_COMPLETED; - ESI = http_transfer; - bufpointer = ESI.http_msg.content_ptr; - bufsize = ESI.http_msg.content_received; - http_free stdcall (http_transfer); - http_transfer=0; -} - -int DOWNLOADER::MonitorProgress() -{ - dword receive_result; - if (http_transfer <= 0) return false; - http_receive stdcall (http_transfer); - receive_result = EAX; - EDI = http_transfer; - data_full_size = EDI.http_msg.content_length; - data_downloaded_size = EDI.http_msg.content_received; - if (receive_result == 0) Completed(); - return true; -}