#ifdef LANG_RUS #define DL_WINDOW_HEADER "Менеджер загрузок" #define START_DOWNLOADING "Начать закачку" #define STOP_DOWNLOADING "Остановить" #define SHOW_IN_FOLDER "Показать в папке" #define OPEN_FILE_TEXT "Открыть файл" #define FILE_SAVED_AS "'Менеджер загрузок\nФайл сохранен как " #define KB_RECEIVED " получено" #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 " received" #endif char save_to[4096] = "/tmp0/1/Downloads"; proc_info DL_Form; char downloader_edit[10000]; char filepath[4096]; int mouse_twbi; edit_box ed = {250,20,20,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(downloader_edit),#downloader_edit,#mouse_twbi,2,19,19}; progress_bar pb = {0, 170, 51, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F}; byte downloader_opened; char downloader_stak[4096]; char str[2048]; char aux[2048]; void Downloader() { int key, i; char notify_message[4296]; downloader_opened = 1; SetEventMask(0x27); downloader.Stop(); if (downloader_edit[0]) StartDownloading(); else strcpy(#downloader_edit, "http://"); ed.size = ed.pos = ed.shift = ed.shift_old = strlen(#downloader_edit); loop() { WaitEventTimeout(30); switch(EAX & 0xFF) { CASE evMouse: if (!CheckActiveProcess(DL_Form.ID)) break; edit_box_mouse stdcall (#ed); break; case evButton: Key_Scan(GetButtonID()); break; case evKey: GetKeys(); EAX = key_ascii << 8; edit_box_key stdcall(#ed); if (key_scancode==SCAN_CODE_ENTER) Key_Scan(301); break; case evReDraw: system.color.get(); DefineAndDrawWindow(215, 100, 420, 120, 0x74, system.color.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(); break; default: if (!downloader.MonitorProgress()) break; pb.max = downloader.data_full_size; if (pb.value != downloader.data_downloaded_size) { pb.value = downloader.data_downloaded_size; progressbar_draw stdcall(#pb); DrawDownloading(); } if (downloader.state == STATE_COMPLETED) { if (!dir_exists(#save_to)) CreateDir(#save_to); strcpy(#filepath, #save_to); chrcat(#filepath, '/'); // Clean all slashes at the end strcpy(#aux, #downloader_edit); while (aux[strlen(#aux)-1] == '/') { aux[strlen(#aux)-1] = 0; } strcat(#filepath, #aux+strrchr(#aux, '/')); for (i=0; i