Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7280 → Rev 7281

/programs/cmm/browser/download_manager.h
20,25 → 20,21
proc_info DL_Form;
char downloader_edit[10000];
char filepath[4096];
int mouse_twbi;
edit_box ed = {250,20,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit),#downloader_edit,#mouse_twbi,2,19,19};
edit_box ed = {NULL,57,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit),#downloader_edit,0,2,19,19};
progress_bar pb = {0, 20, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
//progress_bar pb = {0, 180, 55, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
//progress_bar: value, left, top, width, height, style, min, max, back_color, progress_color, frame_color;
byte downloader_opened;
bool downloader_opened;
char downloader_stak[4096];
char str[2048];
char aux[2048];
void Downloader()
{
int key, i;
char notify_message[4296];
downloader_opened = 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);
 
system.color.get();
53,7 → 49,6
loop() switch(WaitEvent())
{
case evMouse:
if (!CheckActiveProcess(DL_Form.ID)) break;
edit_box_mouse stdcall (#ed);
break;
 
87,24 → 82,7
}
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<strlen(#filepath); i++) if(filepath[i]==':')||(filepath[i]=='?')filepath[i]='-';
if (CreateFile(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");
notify(#notify_message);
SaveDownloadedFile();
StopDownloading();
DL_Draw_Window();
break;
114,12 → 92,15
void Key_Scan(int id)
{
if (id==001) { downloader_opened=0; StopDownloading(); ExitProcess(); }
if (id==301) && (downloader.http_transfer <= 0) StartDownloading();
if (id==001) { downloader_opened=false; 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==306) RunProgram("/sys/@open", #filepath);
if (id==306) {
SetCurDir(#save_to);
RunProgram("/sys/@open", #filepath);
}
}
void DL_Draw_Window()
{
127,6 → 108,8
int but_x = 0;
int but_y = 58;
DrawBar(0,0, DL_Form.cwidth, DL_Form.cheight, system.color.work);
DeleteButton(301);
DeleteButton(302);
DeleteButton(305);
DeleteButton(306);
if (downloader.state == STATE_NOT_STARTED) || (downloader.state == STATE_COMPLETED)
140,11 → 123,10
}
if (downloader.state == STATE_IN_PROGRESS)
{
DrawCaptButton(DL_Form.width - 190, but_y, 167, 26, 302, system.color.work_button, system.color.work_button_text, STOP_DOWNLOADING);
DrawStandartCaptButton(DL_Form.width - 190, but_y, 302, STOP_DOWNLOADING);
DrawDownloading();
}
WriteText(cleft, ed.top + 4, 0x90, system.color.work_text, "URL:");
ed.left = strlen("URL:")*8 + 10 + cleft;
ed.width = DL_Form.cwidth - ed.left - cleft - 3;
ed.offset=0;
DrawEditBox(#ed);
183,4 → 165,27
ed.blur_border_color = 0xFFFfff;
ed.flags = 10b;
DL_Draw_Window();
}
 
void SaveDownloadedFile()
{
int i;
char aux[2048];
char notify_message[4296];
 
// Clean all slashes at the end
strcpy(#aux, #downloader_edit);
while (aux[strlen(#aux)-1] == '/') {
aux[strlen(#aux)-1] = 0;
}
sprintf(#filepath, "%s/%s", #save_to, #aux+strrchr(#aux, '/'));
for (i=0; i<strlen(#filepath); i++) if(filepath[i]==':')||(filepath[i]=='?')filepath[i]='-';
 
if (CreateFile(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");
notify(#notify_message);
}