Subversion Repositories Kolibri OS

Rev

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

Rev 4662 Rev 4666
Line 1... Line 1...
1
#define MEMSIZE 0x100000
1
#define MEMSIZE 0x100000
2
//libraries
2
//libraries
3
#include "..\lib\kolibri.h"
3
#include "..\lib\kolibri.h"
4
#include "..\lib\strings.h"
4
#include "..\lib\strings.h"
5
#include "..\lib\figures.h"
5
#include "..\lib\figures.h"
-
 
6
#include "..\lib\encoding.h"
-
 
7
#include "..\lib\draw_buf.h"
6
#include "..\lib\file_system.h"
8
#include "..\lib\file_system.h"
7
#include "..\lib\mem.h"
9
#include "..\lib\mem.h"
8
#include "..\lib\dll.h"
10
#include "..\lib\dll.h"
9
#include "..\lib\list_box.h"
11
#include "..\lib\list_box.h"
10
//*.obj libraries
12
//*.obj libraries
11
#include "..\lib\lib.obj\box_lib.h"
13
#include "..\lib\lib.obj\box_lib.h"
12
#include "..\lib\lib.obj\libio_lib.h"
14
#include "..\lib\lib.obj\libio_lib.h"
13
#include "..\lib\lib.obj\http.h"
15
#include "..\lib\lib.obj\http.h"
Line 14... Line 16...
14
 
16
 
Line 15... Line 17...
15
char header[]="New Downloader v0.4";
17
char header[]="New Downloader v0.5";
16
 
18
 
17
#ifdef LANG_RUS
19
#ifdef LANG_RUS
18
	char accept_language[]= "Accept-Language: ru\n";
20
	char accept_language[]= "Accept-Language: ru\n";
19
#else
21
#else
Line 20... Line 22...
20
	char accept_language[]= "Accept-Language: en\n";	
22
	char accept_language[]= "Accept-Language: en\n";	
21
#endif
23
#endif
22
 
24
 
23
proc_info Form;
25
proc_info Form;
24
#define WIN_W 400
26
#define WIN_W 400
Line 25... Line 27...
25
#define WIN_H 240
27
#define WIN_H 220
26
system_colors sc;
28
system_colors sc;
Line 35... Line 37...
35
dword bufsize;
37
dword bufsize;
Line 36... Line 38...
36
 
38
 
37
dword http_transfer = 0;
39
dword http_transfer = 0;
Line 38... Line 40...
38
dword http_buffer;
40
dword http_buffer;
39
 
-
 
40
struct diagram {
-
 
Line 41... Line 41...
41
	int x,y,w,h;
41
 
42
} diagram;
42
DrawBufer diagram;
43
 
43
 
44
void main()
44
void main()
Line 53... Line 53...
53
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
53
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
54
	if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");	
54
	if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");	
55
	if (!URL) strcpy(#URL, "http://builds.kolibrios.org/eng/latest-iso.7z");
55
	if (!URL) strcpy(#URL, "http://builds.kolibrios.org/eng/latest-iso.7z");
56
	address_box.size = address_box.pos = strlen(#URL);
56
	address_box.size = address_box.pos = strlen(#URL);
Line 57... Line 57...
57
 
57
 
58
	SetEventMask(0xa7);
58
	SetEventMask(0x27); //a7
59
	loop()
59
	loop()
60
	{
60
	{
61
		WaitEventTimeout(40);
61
		WaitEventTimeout(40);
62
		switch(EAX & 0xFF)
62
		switch(EAX & 0xFF)
Line 87... Line 87...
87
				DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,sc.work,#header,0);
87
				DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,sc.work,#header,0);
88
				GetProcessInfo(#Form, SelfInfo);
88
				GetProcessInfo(#Form, SelfInfo);
89
				if (Form.status_window>2) return;
89
				if (Form.status_window>2) return;
90
				if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
90
				if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
91
				if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
91
				if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
92
				diagram.x = 20;
-
 
93
				diagram.y = 87;
-
 
94
				diagram.w = Form.cwidth - diagram.x - diagram.x;
92
				diagram.Init(20, 87, Form.cwidth - 40, Form.cheight - 87 - 28);
95
				diagram.h = Form.cheight - diagram.y - 28;
-
 
96
				Draw_Window();
93
				Draw_Window();
97
				break;
94
				break;
Line 98... Line 95...
98
				
95
				
99
			default:
96
			default:
Line 130... Line 127...
130
}
127
}
Line 131... Line 128...
131
 
128
 
132
void DrawSpeed()
129
void DrawSpeed()
133
{
130
{
134
	int i;
131
	int i;
135
	int speed_in_position;
132
	int speed_in_position, speed_string;
136
	int max_speed, start_from;
133
	int max_speed, start_from;
Line 137... Line 134...
137
	char bytes_received[70];
134
	char bytes_received[70];
138
 
135
 
139
	DrawBar(diagram.x, diagram.y, diagram.w, diagram.h+1, 0xFCF8F7);
136
	diagram.Fill(0xFCF8F7);
140
	max_speed = speed[speed_position];
137
	max_speed = speed[speed_position];
141
	if (speed_position < diagram.w) start_from = 0; else start_from = speed_position - diagram.w;
138
	if (speed_position < diagram.bufw) start_from = 0; else start_from = speed_position - diagram.bufw + 1;
142
	for (i = 0; i <= speed_position-start_from; i++)
139
	for (i = 0; i <= speed_position-start_from; i++)
143
	{
140
	{
144
		if (max_speed>0)
141
		if (max_speed>0)
145
		{
142
		{
146
			speed_in_position = diagram.h - 2 * speed[i+start_from] / max_speed;
-
 
147
			PutPixel(diagram.x+i, diagram.h - speed_in_position + diagram.y, 0x00A3CB);
-
 
148
			ECX++;
143
			speed_in_position = diagram.bufh - 1 * speed[i+start_from] / max_speed;
149
			$int 64;
144
			diagram.DrawBar(i, diagram.bufh - speed_in_position, 1, speed_in_position, 0x00A3CB);
-
 
145
		}
150
		}
146
	}
151
	}
147
	diagram.Show();
152
	if (speed_position==0) return;
148
	if (speed_position==0) return;
153
	if (http_transfer > 0)
149
	if (http_transfer > 0)
154
	{
150
	{
155
		strcpy(#bytes_received, "Downloading... ");	
151
		strcpy(#bytes_received, "Downloading... ");	
156
	} 
152
	} 
157
	else
153
	else
158
	{
154
	{
-
 
155
		strcpy(#bytes_received, "Downloading competle. ");	
159
		strcpy(#bytes_received, "Downloading competle. ");	
156
	}
160
	}
157
	speed_string = ConvertSize(speed[speed_position-1]);
161
	strcat(#bytes_received, itoa(speed[speed_position-1]));
158
	strcat(#bytes_received, speed_string);
162
	strcat(#bytes_received, " bytes received.");
159
	strcat(#bytes_received, " received.");
163
	DrawBar(diagram.x, diagram.y + diagram.h + 10, diagram.w, 9, sc.work);
160
	DrawBar(diagram.bufx, diagram.bufy + diagram.bufh + 10, diagram.bufw, 9, sc.work);
Line 164... Line 161...
164
	WriteText(diagram.x, diagram.y + diagram.h + 10, 0x80, sc.work_text, #bytes_received);
161
	WriteText(diagram.bufx, diagram.bufy + diagram.bufh + 10, 0x80, sc.work_text, #bytes_received);
165
}
162
}
166
 
163
 
-
 
164
void Draw_Window()
-
 
165
{	
167
void Draw_Window()
166
	DrawBar(0,0,Form.cwidth,Form.cheight,sc.work); //bg
-
 
167
	if (http_transfer <= 0)
-
 
168
	{
-
 
169
		DrawCaptButton(diagram.bufx, 50, 120, 20, 301, sc.work_button, sc.work_button_text, "Start downloading");	
-
 
170
	}
-
 
171
	else
168
{	
172
	{
169
	DrawBar(0,0,Form.cwidth,Form.cheight,sc.work); //bg
173
		DrawCaptButton(diagram.bufx, 50, 120, 20, 302, sc.work_button, sc.work_button_text, "Stop downloading");
170
	DrawCaptButton(diagram.x, 50, 120, 20, 301, sc.work_button, sc.work_button_text, "Start downloading");
174
	}
171
	if (http_transfer <= 0) && (speed_position>0)
175
	if (http_transfer <= 0) && (speed_position>0)
172
	{
176
	{
173
		DrawCaptButton(diagram.x+130, 50, 120, 20, 305, sc.work_button, sc.work_button_text, "Show in folder");	
177
		DrawCaptButton(diagram.bufx+130, 50, 120, 20, 305, sc.work_button, sc.work_button_text, "Show in folder");	
174
	} 
178
	} 
175
	WriteText(diagram.x, address_box.top + 4, 0x80, sc.work_text, "URL:");
179
	WriteText(diagram.bufx, address_box.top + 4, 0x80, sc.work_text, "URL:");
176
	address_box.left = strlen("URL:")*6 + 10 + diagram.x;
180
	address_box.left = strlen("URL:")*6 + 10 + diagram.bufx;
177
	address_box.width = Form.cwidth - address_box.left - diagram.x - 3;
181
	address_box.width = Form.cwidth - address_box.left - diagram.bufx - 3;
178
	address_box.offset=0;
182
	address_box.offset=0;
Line 179... Line 183...
179
	edit_box_draw stdcall(#address_box);
183
	edit_box_draw stdcall(#address_box);
180
	DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color);
184
	DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color);
181
	DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,sc.work_graph);
185
	DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,sc.work_graph);
Line 182... Line 186...
182
 
186
 
183
	DrawRectangle(diagram.x-2, diagram.y-2, diagram.w+2, diagram.h+3, sc.work_graph);
187
	DrawRectangle(diagram.bufx-2, diagram.bufy-2, diagram.bufw+2, diagram.bufh+2, sc.work_graph);