Subversion Repositories Kolibri OS

Rev

Rev 6654 | Rev 6662 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6654 Rev 6656
1
#define MEMSIZE 4096*20
1
#define MEMSIZE 4096*20
2
 
2
 
3
//===================================================//
3
//===================================================//
4
//                                                   //
4
//                                                   //
5
//                       LIB                         //
5
//                       LIB                         //
6
//                                                   //
6
//                                                   //
7
//===================================================//
7
//===================================================//
8
 
8
 
9
#include "../lib/gui.h"
9
#include "../lib/gui.h"
10
#include "../lib/list_box.h"
10
#include "../lib/list_box.h"
11
#include "../lib/obj/box_lib.h"
11
#include "../lib/obj/box_lib.h"
12
#include "../lib/obj/libio_lib.h"
12
#include "../lib/obj/libio_lib.h"
13
#include "../lib/obj/libini.h"
13
#include "../lib/obj/libini.h"
14
#include "../lib/collection.h"
14
#include "../lib/collection.h"
15
#include "../lib/io.h"
15
#include "../lib/io.h"
16
#include "../lib/patterns/select_list.h"
16
#include "../lib/patterns/select_list.h"
17
 
17
 
18
//===================================================//
18
//===================================================//
19
//                                                   //
19
//                                                   //
20
//                       DATA                        //
20
//                       DATA                        //
21
//                                                   //
21
//                                                   //
22
//===================================================//
22
//===================================================//
23
 
23
 
24
proc_info Form;
24
proc_info Form;
25
 
25
 
26
#define WINDOW_TITLE "Driver Installer"
26
#define WINDOW_TITLE "Driver Installer"
27
#define T_CAUTION_TITLE "CAUTION"
27
#define T_CAUTION_TITLE "CAUTION"
28
#define T_CAUTION_PARAGRAPH "Installing additional drivers can be harmful to the stability of the operation system and potentionally can harm hardware."
28
#define T_CAUTION_PARAGRAPH "Installing additional drivers can be harmful to the stability of the operation system and potentionally can harm hardware."
29
#define T_ASSEPT_RISK "I assept the risk"
29
#define T_ASSEPT_RISK "I assept the risk"
30
#define T_README "Readme"
30
#define T_README "Readme"
31
#define T_INSTALL "Install"
31
#define T_INSTALL "Install"
32
 
32
 
33
#define BUTTON_ID_ASSEPT_RISK 10
33
#define BUTTON_ID_ASSEPT_RISK 10
34
#define BUTTON_ID_README 11
34
#define BUTTON_ID_README 11
35
#define BUTTON_ID_INSTALL 12
35
#define BUTTON_ID_INSTALL 12
36
 
36
 
37
//WINDOW STEPS
37
//WINDOW STEPS
38
#define WINDOW_STEP_INTRO 1;
38
#define WINDOW_STEP_INTRO 1;
39
#define WINDOW_STEP_DRIVER_LIST 2;
39
#define WINDOW_STEP_DRIVER_LIST 2;
40
char window_step = WINDOW_STEP_INTRO;
40
char window_step = WINDOW_STEP_INTRO;
41
 
41
 
42
collection ini_sections;
42
collection ini_sections;
43
 
43
 
44
char drvinf_path[4096] = "/sys/drvinf.ini";
44
char drvinf_path[4096] = "/kolibrios/drivers/drvinf.ini";
45
char cur_version[64];
45
char cur_version[64];
46
char cur_description[1024];
46
char cur_description[1024];
47
char cur_readme_path[4096];
47
char cur_readme_path[4096];
48
char cur_install_path[4096];
48
char cur_install_path[4096];
49
 
49
 
50
//===================================================//
50
//===================================================//
51
//                                                   //
51
//                                                   //
52
//                       CODE                        //
52
//                       CODE                        //
53
//                                                   //
53
//                                                   //
54
//===================================================//
54
//===================================================//
55
 
55
 
56
void GetIniData()
56
void GetIniData()
57
{
57
{
58
	select_list.count = 0;
58
	select_list.count = 0;
59
	ini_enum_sections stdcall (#drvinf_path, #process_sections);
59
	ini_enum_sections stdcall (#drvinf_path, #process_sections);
60
}
60
}
61
 
61
 
62
byte process_sections(dword sec_name, f_name)
62
byte process_sections(dword sec_name, f_name)
63
{
63
{
64
	select_list.count++;
64
	select_list.count++;
65
	ini_sections.add(sec_name);
65
	ini_sections.add(sec_name);
66
	return true;
66
	return true;
67
}
67
}
68
 
68
 
69
void main()
69
void main()
70
{
70
{
71
	int id;
71
	int id;
72
	load_dll(libio,  #libio_init,1);
72
	load_dll(libio,  #libio_init,1);
73
	load_dll(libini, #lib_init,1);
73
	load_dll(libini, #lib_init,1);
74
	load_dll(boxlib, #box_lib_init,0);
74
	load_dll(boxlib, #box_lib_init,0);
75
	GetIniData();
75
	GetIniData();
76
	SetEventMask(0x27);
76
	SetEventMask(0x27);
77
	loop() switch(WaitEvent())
77
	loop() switch(WaitEvent())
78
	{
78
	{
79
		case evMouse:
79
		case evMouse:
80
			if (!CheckActiveProcess(Form.ID)) break;
80
			if (!CheckActiveProcess(Form.ID)) break;
81
			SelectList_ProcessMouse();
81
			SelectList_ProcessMouse();
82
			break;
82
			break;
83
 
83
 
84
		case evButton:
84
		case evButton:
85
			id=GetButtonID();               
85
			id=GetButtonID();               
86
			if (id==1) ExitProcess();
86
			if (id==1) ExitProcess();
87
			if (id==BUTTON_ID_ASSEPT_RISK) Event_AsseptRisk();
87
			if (id==BUTTON_ID_ASSEPT_RISK) Event_AsseptRisk();
88
			if (id==BUTTON_ID_README) Event_ShowReadme();
88
			if (id==BUTTON_ID_README) Event_ShowReadme();
89
			if (id==BUTTON_ID_INSTALL) Event_RunInstall();
89
			if (id==BUTTON_ID_INSTALL) Event_RunInstall();
90
			break;
90
			break;
91
	  
91
	  
92
		case evKey:
92
		case evKey:
93
			GetKeys();
93
			GetKeys();
94
			if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
94
			if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
95
			break;
95
			break;
96
		 
96
		 
97
		case evReDraw:
97
		case evReDraw:
98
			Event_DrawWindow();
98
			Event_DrawWindow();
99
	}
99
	}
100
} 
100
} 
101
 
101
 
102
 
102
 
103
void draw_intro_window()
103
void draw_intro_window()
104
{
104
{
105
	incn y;
105
	incn y;
106
	y.n = Form.cheight/2 - 80;
106
	y.n = Form.cheight/2 - 80;
107
	WriteTextB(30+2,y.n+2,0x81,MixColors(system.color.work, 0xB92234,220),T_CAUTION_TITLE);
107
	WriteTextB(30+2,y.n+2,0x81,MixColors(system.color.work, 0xB92234,220),T_CAUTION_TITLE);
108
	WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE);
108
	WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE);
109
	y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140, 
109
	y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140, 
110
		T_CAUTION_PARAGRAPH, -1, system.color.work_text);
110
		T_CAUTION_PARAGRAPH, -1, system.color.work_text);
111
	DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK);
111
	DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK);
112
}
112
}
113
 
113
 
114
 
114
 
115
void draw_driver_list_window()
115
void draw_driver_list_window()
116
{
116
{
117
	int PADDING = 12;
117
	int PADDING = 12;
118
	int right_frame_x = Form.cwidth*46/100;
118
	int right_frame_x = Form.cwidth*46/100;
119
	int readme_w = 0;
119
	int readme_w = 0;
120
	//LEFT FRAME
120
	//LEFT FRAME
121
	SelectList_Init(PADDING, 
121
	SelectList_Init(PADDING, 
122
		PADDING, 
122
		PADDING, 
123
		right_frame_x - PADDING - PADDING - 8 - scroll1.size_x, 
123
		right_frame_x - PADDING - PADDING - 8 - scroll1.size_x, 
124
		Form.cheight - PADDING - PADDING, 
124
		Form.cheight - PADDING - PADDING, 
125
		false);
125
		false);
126
	SelectList_Draw();
126
	SelectList_Draw();
127
	//RIGHT FRAME
127
	//RIGHT FRAME
128
	GetCurrentSectionData();
128
	GetCurrentSectionData();
129
	DrawBar(right_frame_x, PADDING+3, Form.cwidth - right_frame_x - PADDING, 80, system.color.work);
129
	DrawBar(right_frame_x, PADDING+3, Form.cwidth - right_frame_x - PADDING, 80, system.color.work);
130
	WriteTextB(right_frame_x, PADDING+3, 0x81, system.color.work_text, ini_sections.get(select_list.cur_y));
130
	WriteTextB(right_frame_x, PADDING+3, 0x81, system.color.work_text, ini_sections.get(select_list.cur_y));
131
	WriteText(right_frame_x, PADDING+23, 0x80, system.color.work_text, #cur_version);
131
	WriteText(right_frame_x, PADDING+23, 0x80, system.color.work_text, #cur_version);
132
	if(cur_readme_path[0]) readme_w = DrawStandartCaptButton(right_frame_x, PADDING+45, BUTTON_ID_README, T_README);
132
	if(cur_readme_path[0]) readme_w = DrawStandartCaptButton(right_frame_x, PADDING+45, BUTTON_ID_README, T_README);
133
	DrawStandartCaptButton(right_frame_x + readme_w, PADDING+45, BUTTON_ID_INSTALL, T_INSTALL);
133
	DrawStandartCaptButton(right_frame_x + readme_w, PADDING+45, BUTTON_ID_INSTALL, T_INSTALL);
134
	DrawTextViewArea(right_frame_x-2, PADDING+83, Form.cwidth - right_frame_x - PADDING, Form.cheight-PADDING-PADDING, 
134
	DrawTextViewArea(right_frame_x-2, PADDING+83, Form.cwidth - right_frame_x - PADDING, Form.cheight-PADDING-PADDING, 
135
		#cur_description, system.color.work, system.color.work_text);
135
		#cur_description, system.color.work, system.color.work_text);
136
}
136
}
137
 
137
 
138
void SelectList_DrawLine(dword i)
138
void SelectList_DrawLine(dword i)
139
{
139
{
140
	int yyy, list_last;
140
	int yyy, list_last;
141
 
141
 
142
	yyy = i*select_list.item_h+select_list.y;
142
	yyy = i*select_list.item_h+select_list.y;
143
	
143
	
144
	if (select_list.cur_y-select_list.first==i)
144
	if (select_list.cur_y-select_list.first==i)
145
	{
145
	{
146
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
146
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
147
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, ini_sections.get(i));
147
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, ini_sections.get(i));
148
	}
148
	}
149
	else
149
	else
150
	{
150
	{
151
		DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
151
		DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
152
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, ini_sections.get(i));
152
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, ini_sections.get(i));
153
	}
153
	}
154
}
154
}
155
 
155
 
156
void SelectList_LineChanged()
156
void SelectList_LineChanged()
157
{
157
{
158
	draw_driver_list_window();
158
	draw_driver_list_window();
159
}
159
}
160
 
160
 
161
void GetCurrentSectionData()
161
void GetCurrentSectionData()
162
{
162
{
163
	dword cur_section_name = ini_sections.get(select_list.cur_y);
163
	dword cur_section_name = ini_sections.get(select_list.cur_y);
164
	ini_get_str stdcall (#drvinf_path, cur_section_name, "ver", #cur_version, sizeof(cur_version), 0);
164
	ini_get_str stdcall (#drvinf_path, cur_section_name, "ver", #cur_version, sizeof(cur_version), 0);
165
	ini_get_str stdcall (#drvinf_path, cur_section_name, "description", #cur_description, sizeof(cur_description), 0);
165
	ini_get_str stdcall (#drvinf_path, cur_section_name, "description", #cur_description, sizeof(cur_description), 0);
166
	ini_get_str stdcall (#drvinf_path, cur_section_name, "readme", #cur_readme_path, sizeof(cur_readme_path), 0);
166
	ini_get_str stdcall (#drvinf_path, cur_section_name, "readme", #cur_readme_path, sizeof(cur_readme_path), 0);
167
	ini_get_str stdcall (#drvinf_path, cur_section_name, "install", #cur_install_path, sizeof(cur_install_path), 0);
167
	ini_get_str stdcall (#drvinf_path, cur_section_name, "install", #cur_install_path, sizeof(cur_install_path), 0);
168
}
168
}
169
 
169
 
170
//===================================================//
170
//===================================================//
171
//                                                   //
171
//                                                   //
172
//                     EVENTS                        //
172
//                     EVENTS                        //
173
//                                                   //
173
//                                                   //
174
//===================================================//
174
//===================================================//
175
 
175
 
176
void Event_DrawWindow() 
176
void Event_DrawWindow() 
177
{
177
{
178
	system.color.get();
178
	system.color.get();
179
	DefineAndDrawWindow(215, 100, 600, 400, 0x33, system.color.work, WINDOW_TITLE);
179
	DefineAndDrawWindow(215, 100, 600, 400, 0x33, system.color.work, WINDOW_TITLE);
180
	GetProcessInfo(#Form, SelfInfo);
180
	GetProcessInfo(#Form, SelfInfo);
181
	if (Form.status_window>2) return;
181
	if (Form.status_window>2) return;
182
	if (Form.width  < 450) { MoveSize(OLD,OLD,450,OLD); return; }
182
	if (Form.width  < 450) { MoveSize(OLD,OLD,450,OLD); return; }
183
	if (Form.height < 250) { MoveSize(OLD,OLD,OLD,250); return; }
183
	if (Form.height < 250) { MoveSize(OLD,OLD,OLD,250); return; }
184
	if (window_step == WINDOW_STEP_INTRO) draw_intro_window();
184
	if (window_step == WINDOW_STEP_INTRO) draw_intro_window();
185
	if (window_step == WINDOW_STEP_DRIVER_LIST) draw_driver_list_window();
185
	if (window_step == WINDOW_STEP_DRIVER_LIST) draw_driver_list_window();
186
	return;
186
	return;
187
}
187
}
188
 
188
 
189
void Event_AsseptRisk()
189
void Event_AsseptRisk()
190
{
190
{
191
	window_step = WINDOW_STEP_DRIVER_LIST;
191
	window_step = WINDOW_STEP_DRIVER_LIST;
192
	Event_DrawWindow();
192
	Event_DrawWindow();
193
}
193
}
194
 
194
 
195
void Event_ShowReadme()
195
void Event_ShowReadme()
196
{
196
{
197
	io.run("/sys/textreader", #cur_readme_path);
197
	io.run("/sys/textreader", #cur_readme_path);
198
}
198
}
199
 
199
 
200
void Event_RunInstall()
200
void Event_RunInstall()
201
{
201
{
202
	io.run(#cur_install_path, NULL);
202
	io.run(#cur_install_path, NULL);
203
}
203
}