Subversion Repositories Kolibri OS

Rev

Rev 7506 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7506 Rev 7521
Line 17... Line 17...
17
	#define FILE_SAVED_AS "'Download manager\nFile saved as "
17
	#define FILE_SAVED_AS "'Download manager\nFile saved as "
18
	#define KB_RECEIVED "Downloading... %s received"
18
	#define KB_RECEIVED "Downloading... %s received"
19
#endif
19
#endif
20
char save_to[4096] = "/tmp0/1/Downloads";
20
char save_to[4096] = "/tmp0/1/Downloads";
Line -... Line 21...
-
 
21
 
-
 
22
#define CONX 15
21
 
23
 
22
proc_info DL_Form;
24
proc_info DL_Form;
23
char downloader_edit[10000];
25
char downloader_edit[10000];
24
char filepath[4096];
26
char filepath[4096];
25
edit_box ed = {NULL,57,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit)-2,#downloader_edit,0,2,19,19};
27
edit_box ed = {NULL,57,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit)-2,#downloader_edit,0,2,19,19};
26
progress_bar pb = {0, 20, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
28
progress_bar pb = {0, CONX, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
27
//progress_bar pb = {0, 180, 55, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
29
//progress_bar pb = {0, 180, 55, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
Line -... Line 30...
-
 
30
//progress_bar: value, left, top, width, height, style, min, max, back_color, progress_color, frame_color;
28
//progress_bar: value, left, top, width, height, style, min, max, back_color, progress_color, frame_color;
31
 
29
	
32
	
Line 104... Line 107...
104
	}
107
	}
105
}
108
}
Line 106... Line 109...
106
 
109
 
107
void DL_Draw_Window()
110
void DL_Draw_Window()
108
{  
-
 
109
	int cleft = 15;
111
{  
110
	int but_x = 0;
112
	int but_x = 0;
111
	int but_y = 58;
113
	int but_y = 58;
112
	DrawBar(0,0, DL_Form.cwidth, DL_Form.cheight, system.color.work);
114
	DrawBar(0,0, DL_Form.cwidth, DL_Form.cheight, system.color.work);
113
	DeleteButton(301);
115
	DeleteButton(301);
114
	DeleteButton(302);
116
	DeleteButton(302);
115
	DeleteButton(305);
117
	DeleteButton(305);
116
	DeleteButton(306);
118
	DeleteButton(306);
117
	if (downloader.state == STATE_NOT_STARTED) || (downloader.state == STATE_COMPLETED)
119
	if (downloader.state == STATE_NOT_STARTED) || (downloader.state == STATE_COMPLETED)
118
	{
120
	{
119
		but_x = cleft + DrawStandartCaptButton(cleft, but_y, 301, START_DOWNLOADING);   
121
		but_x = CONX + DrawStandartCaptButton(CONX, but_y, 301, START_DOWNLOADING);   
120
		if (filepath[0])
122
		if (filepath[0])
121
		{
123
		{
122
			but_x += DrawStandartCaptButton(but_x, but_y, 305, SHOW_IN_FOLDER);
124
			but_x += DrawStandartCaptButton(but_x, but_y, 305, SHOW_IN_FOLDER);
123
			DrawStandartCaptButton(but_x, but_y, 306, OPEN_FILE_TEXT);  
125
			DrawStandartCaptButton(but_x, but_y, 306, OPEN_FILE_TEXT);  
Line 126... Line 128...
126
	if (downloader.state == STATE_IN_PROGRESS)
128
	if (downloader.state == STATE_IN_PROGRESS)
127
	{
129
	{
128
		DrawStandartCaptButton(DL_Form.width - 190, but_y, 302, STOP_DOWNLOADING);
130
		DrawStandartCaptButton(DL_Form.width - 190, but_y, 302, STOP_DOWNLOADING);
129
		DrawDownloading();
131
		DrawDownloading();
130
	}
132
	}
131
	WriteText(cleft, ed.top + 4, 0x90, system.color.work_text, "URL:");
133
	WriteText(CONX, ed.top + 4, 0x90, system.color.work_text, "URL:");
132
    ed.width = DL_Form.cwidth - ed.left - cleft - 3;
134
    ed.width = DL_Form.cwidth - ed.left - CONX - 3;
133
	ed.offset=0;
135
	ed.offset=0;
134
	DrawEditBox(#ed);
136
	DrawEditBox(#ed);
135
}
137
}
Line 136... Line 138...
136
 
138
 
Line 150... Line 152...
150
	ed.flags = 100000000000b;
152
	ed.flags = 100000000000b;
151
	pb.value = 0;
153
	pb.value = 0;
152
	DL_Draw_Window();
154
	DL_Draw_Window();
153
}
155
}
Line -... Line 156...
-
 
156
 
-
 
157
struct TIME
-
 
158
{
-
 
159
	dword old;
-
 
160
	dword cur;
-
 
161
	dword gone;
-
 
162
} time = {0,0,0};
-
 
163
 
-
 
164
dword netdata_received;
-
 
165
dword speed;
-
 
166
 
-
 
167
void CalculateSpeed()
-
 
168
{
-
 
169
	time.cur = GetStartTime();
-
 
170
 
-
 
171
	if (time.old) {
-
 
172
		time.gone = time.cur - time.old;
-
 
173
		if (time.gone > 200) {
-
 
174
			speed = downloader.httpd.content_received - netdata_received / time.gone * 100;
-
 
175
			debugval("speed", speed);
-
 
176
			debugln(ConvertSizeToKb(speed) );
-
 
177
			time.old = time.cur;
-
 
178
			netdata_received = downloader.httpd.content_received;
-
 
179
		}
-
 
180
	}
-
 
181
	else time.old = time.cur;
-
 
182
}
154
 
183
 
155
void DrawDownloading()
184
void DrawDownloading()
156
{
185
{
157
	char bytes_received[70];
186
	char bytes_received[70];
158
	sprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.httpd.content_received) );
187
	sprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.httpd.content_received) );
159
	DrawBar(15, pb.top + 22, strlen(#bytes_received+4)*12, 16, system.color.work);
188
	DrawBar(CONX, pb.top + 22, pb.width, 16, system.color.work);
-
 
189
	WriteText(CONX, pb.top + 22, 0x90, system.color.work_text, #bytes_received);
160
	WriteText(15, pb.top + 22, 0x90, system.color.work_text, #bytes_received);
190
	//CalculateSpeed();
161
	progressbar_draw stdcall(#pb);
191
	progressbar_draw stdcall(#pb);
Line 162... Line 192...
162
}
192
}
163
 
193