Subversion Repositories Kolibri OS

Rev

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

Rev 7031 Rev 7049
1
#define MEMSIZE 4096*20
1
#define MEMSIZE 4096*20
2
 
2
 
3
#ifndef AUTOBUILD
3
#ifndef AUTOBUILD
4
#include "lang.h--"
4
#include "lang.h--"
5
#endif
5
#endif
6
 
6
 
7
//===================================================//
7
//===================================================//
8
//                                                   //
8
//                                                   //
9
//                       LIB                         //
9
//                       LIB                         //
10
//                                                   //
10
//                                                   //
11
//===================================================//
11
//===================================================//
12
 
12
 
13
#include "../lib/gui.h"
13
#include "../lib/gui.h"
14
#include "../lib/list_box.h"
14
#include "../lib/list_box.h"
15
#include "../lib/obj/box_lib.h"
15
#include "../lib/obj/box_lib.h"
16
#include "../lib/obj/libio_lib.h"
16
#include "../lib/obj/libio.h"
17
#include "../lib/obj/libini.h"
17
#include "../lib/obj/libini.h"
18
#include "../lib/collection.h"
18
#include "../lib/collection.h"
19
#include "../lib/io.h"
19
#include "../lib/io.h"
20
#include "../lib/patterns/select_list.h"
20
#include "../lib/patterns/select_list.h"
21
 
21
 
22
//===================================================//
22
//===================================================//
23
//                                                   //
23
//                                                   //
24
//                       DATA                        //
24
//                       DATA                        //
25
//                                                   //
25
//                                                   //
26
//===================================================//
26
//===================================================//
27
 
27
 
28
proc_info Form;
28
proc_info Form;
29
 
29
 
30
#ifdef LANG_RUS
30
#ifdef LANG_RUS
31
	#define WINDOW_TITLE "“áâ ­®¢é¨ª ¤à ©¢¥à®¢"
31
	#define WINDOW_TITLE "“áâ ­®¢é¨ª ¤à ©¢¥à®¢"
32
	#define T_CAUTION_TITLE "…„“…†„…ˆ…"
32
	#define T_CAUTION_TITLE "…„“…†„…ˆ…"
33
	#define T_CAUTION_PARAGRAPH "“áâ ­®¢ª  ¤®¯®«­¨â¥«ì­ëå ¤à ©¢¥à®¢ ¬®¦¥â ­ ­¥á⨠¢à¥¤ áâ ¡¨«ì­®á⨠®¯¥à æ¨®­­®© á¨áâ¥¬ë ¨ ¯®â¥­æ¨ «ì­® ¯à¨¢¥á⨠ª ¯®àç¥ ®¡®à㤮¢ ­¨ï."
33
	#define T_CAUTION_PARAGRAPH "“áâ ­®¢ª  ¤®¯®«­¨â¥«ì­ëå ¤à ©¢¥à®¢ ¬®¦¥â ­ ­¥á⨠¢à¥¤ áâ ¡¨«ì­®á⨠®¯¥à æ¨®­­®© á¨áâ¥¬ë ¨ ¯®â¥­æ¨ «ì­® ¯à¨¢¥á⨠ª ¯®àç¥ ®¡®à㤮¢ ­¨ï."
34
	#define T_ASSEPT_RISK "Ÿ ¯à¨­¨¬ î à¨áª"
34
	#define T_ASSEPT_RISK "Ÿ ¯à¨­¨¬ î à¨áª"
35
	#define T_README "Readme"
35
	#define T_README "Readme"
36
	#define T_INSTALL "“áâ ­®¢¨âì"
36
	#define T_INSTALL "“áâ ­®¢¨âì"
37
#else
37
#else
38
	#define WINDOW_TITLE "Driver Installer"
38
	#define WINDOW_TITLE "Driver Installer"
39
	#define T_CAUTION_TITLE "CAUTION"
39
	#define T_CAUTION_TITLE "CAUTION"
40
	#define T_CAUTION_PARAGRAPH "Installing additional drivers can be harmful to the stability of the operation system and potentionally can harm hardware."
40
	#define T_CAUTION_PARAGRAPH "Installing additional drivers can be harmful to the stability of the operation system and potentionally can harm hardware."
41
	#define T_ASSEPT_RISK "I accept the risk"
41
	#define T_ASSEPT_RISK "I accept the risk"
42
	#define T_README "Readme"
42
	#define T_README "Readme"
43
	#define T_INSTALL "Install"
43
	#define T_INSTALL "Install"
44
#endif
44
#endif
45
 
45
 
46
#define BUTTON_ID_ASSEPT_RISK 10
46
#define BUTTON_ID_ASSEPT_RISK 10
47
#define BUTTON_ID_README 11
47
#define BUTTON_ID_README 11
48
#define BUTTON_ID_INSTALL 12
48
#define BUTTON_ID_INSTALL 12
49
 
49
 
50
//WINDOW STEPS
50
//WINDOW STEPS
51
#define WINDOW_STEP_INTRO 1;
51
#define WINDOW_STEP_INTRO 1;
52
#define WINDOW_STEP_DRIVER_LIST 2;
52
#define WINDOW_STEP_DRIVER_LIST 2;
53
char window_step = WINDOW_STEP_INTRO;
53
char window_step = WINDOW_STEP_INTRO;
54
 
54
 
55
collection ini_sections;
55
collection ini_sections;
56
 
56
 
57
char drvinf_path[4096] = "/kolibrios/drivers/drvinf.ini";
57
char drvinf_path[4096] = "/kolibrios/drivers/drvinf.ini";
58
char cur_version[64];
58
char cur_version[64];
59
char cur_description[1024];
59
char cur_description[1024];
60
char cur_readme_path[4096];
60
char cur_readme_path[4096];
61
char cur_install_path[4096];
61
char cur_install_path[4096];
62
 
62
 
63
//===================================================//
63
//===================================================//
64
//                                                   //
64
//                                                   //
65
//                       CODE                        //
65
//                       CODE                        //
66
//                                                   //
66
//                                                   //
67
//===================================================//
67
//===================================================//
68
 
68
 
69
void GetIniData()
69
void GetIniData()
70
{
70
{
71
	select_list.count = 0;
71
	select_list.count = 0;
72
	ini_enum_sections stdcall (#drvinf_path, #process_sections);
72
	ini_enum_sections stdcall (#drvinf_path, #process_sections);
73
}
73
}
74
 
74
 
75
byte process_sections(dword sec_name, f_name)
75
byte process_sections(dword sec_name, f_name)
76
{
76
{
77
	select_list.count++;
77
	select_list.count++;
78
	ini_sections.add(sec_name);
78
	ini_sections.add(sec_name);
79
	return true;
79
	return true;
80
}
80
}
81
 
81
 
82
void main()
82
void main()
83
{
83
{
84
	load_dll(libio,  #libio_init,1);
84
	load_dll(libio,  #libio_init,1);
85
	load_dll(libini, #lib_init,1);
85
	load_dll(libini, #lib_init,1);
86
	load_dll(boxlib, #box_lib_init,0);
86
	load_dll(boxlib, #box_lib_init,0);
87
	GetIniData();
87
	GetIniData();
88
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
88
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
89
	loop() switch(WaitEvent())
89
	loop() switch(WaitEvent())
90
	{
90
	{
91
		case evMouse:
91
		case evMouse:
92
			SelectList_ProcessMouse();
92
			SelectList_ProcessMouse();
93
			break;
93
			break;
94
 
94
 
95
		case evButton:
95
		case evButton:
96
			Event_ProcessButtonId(GetButtonID());
96
			Event_ProcessButtonId(GetButtonID());
97
			break;
97
			break;
98
	  
98
	  
99
		case evKey:
99
		case evKey:
100
			GetKeys();
100
			GetKeys();
101
			if (key_scancode == SCAN_CODE_ENTER) Event_ProcessButtonId(active_button_id);
101
			if (key_scancode == SCAN_CODE_ENTER) Event_ProcessButtonId(active_button_id);
102
			if (window_step == WINDOW_STEP_DRIVER_LIST) 
102
			if (window_step == WINDOW_STEP_DRIVER_LIST) 
103
			{
103
			{
104
				if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
104
				if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
105
				if (key_scancode == SCAN_CODE_TAB) 
105
				if (key_scancode == SCAN_CODE_TAB) 
106
				{
106
				{
107
					ActiveButtonSwitch(11, 12);
107
					ActiveButtonSwitch(11, 12);
108
					Draw_DriverListWindow();
108
					Draw_DriverListWindow();
109
				}
109
				}
110
			} 
110
			} 
111
			break;
111
			break;
112
		 
112
		 
113
		case evReDraw:
113
		case evReDraw:
114
			Event_DrawWindow();
114
			Event_DrawWindow();
115
	}
115
	}
116
} 
116
} 
117
 
117
 
118
 
118
 
119
void Draw_IntroWindow()
119
void Draw_IntroWindow()
120
{
120
{
121
	incn y;
121
	incn y;
122
	y.n = Form.cheight/2 - 80;
122
	y.n = Form.cheight/2 - 80;
123
	WriteTextB(30+2,y.n+2,0x81,MixColors(system.color.work, 0xB92234,220),T_CAUTION_TITLE);
123
	WriteTextB(30+2,y.n+2,0x81,MixColors(system.color.work, 0xB92234,220),T_CAUTION_TITLE);
124
	WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE);
124
	WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE);
125
	y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140, 
125
	y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140, 
126
		T_CAUTION_PARAGRAPH, -1, system.color.work_text);
126
		T_CAUTION_PARAGRAPH, -1, system.color.work_text);
127
	active_button_id = BUTTON_ID_ASSEPT_RISK;
127
	active_button_id = BUTTON_ID_ASSEPT_RISK;
128
	DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK);
128
	DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK);
129
}
129
}
130
 
130
 
131
 
131
 
132
void Draw_DriverListWindow()
132
void Draw_DriverListWindow()
133
{
133
{
134
	int PADDING = 12;
134
	int PADDING = 12;
135
	int right_frame_x = Form.cwidth*46/100;
135
	int right_frame_x = Form.cwidth*46/100;
136
	int readme_w = 0;
136
	int readme_w = 0;
137
	//LEFT FRAME
137
	//LEFT FRAME
138
	SelectList_Init(PADDING, 
138
	SelectList_Init(PADDING, 
139
		PADDING, 
139
		PADDING, 
140
		right_frame_x - PADDING - PADDING - 8 - scroll1.size_x, 
140
		right_frame_x - PADDING - PADDING - 8 - scroll1.size_x, 
141
		Form.cheight - PADDING - PADDING, 
141
		Form.cheight - PADDING - PADDING, 
142
		false);
142
		false);
143
	SelectList_Draw();
143
	SelectList_Draw();
144
	SelectList_DrawBorder();
144
	SelectList_DrawBorder();
145
	//RIGHT FRAME
145
	//RIGHT FRAME
146
	GetCurrentSectionData();
146
	GetCurrentSectionData();
147
	DrawBar(right_frame_x, PADDING+3, Form.cwidth - right_frame_x - PADDING, 80, system.color.work);
147
	DrawBar(right_frame_x, PADDING+3, Form.cwidth - right_frame_x - PADDING, 80, system.color.work);
148
	WriteTextB(right_frame_x, PADDING+3, 0x81, system.color.work_text, ini_sections.get(select_list.cur_y));
148
	WriteTextB(right_frame_x, PADDING+3, 0x81, system.color.work_text, ini_sections.get(select_list.cur_y));
149
	WriteText(right_frame_x, PADDING+23, 0x80, system.color.work_text, #cur_version);
149
	WriteText(right_frame_x, PADDING+23, 0x80, system.color.work_text, #cur_version);
150
	if(cur_readme_path[0]) readme_w = DrawStandartCaptButton(right_frame_x, PADDING+45, BUTTON_ID_README, T_README);
150
	if(cur_readme_path[0]) readme_w = DrawStandartCaptButton(right_frame_x, PADDING+45, BUTTON_ID_README, T_README);
151
	DrawStandartCaptButton(right_frame_x + readme_w, PADDING+45, BUTTON_ID_INSTALL, T_INSTALL);
151
	DrawStandartCaptButton(right_frame_x + readme_w, PADDING+45, BUTTON_ID_INSTALL, T_INSTALL);
152
	DrawTextViewArea(right_frame_x-2, PADDING+83, Form.cwidth - right_frame_x - PADDING, Form.cheight-PADDING-PADDING, 
152
	DrawTextViewArea(right_frame_x-2, PADDING+83, Form.cwidth - right_frame_x - PADDING, Form.cheight-PADDING-PADDING, 
153
		#cur_description, system.color.work, system.color.work_text);
153
		#cur_description, system.color.work, system.color.work_text);
154
}
154
}
155
 
155
 
156
void SelectList_DrawLine(dword i)
156
void SelectList_DrawLine(dword i)
157
{
157
{
158
	int yyy, list_last;
158
	int yyy, list_last;
159
 
159
 
160
	yyy = i*select_list.item_h+select_list.y;
160
	yyy = i*select_list.item_h+select_list.y;
161
	
161
	
162
	if (select_list.cur_y-select_list.first==i)
162
	if (select_list.cur_y-select_list.first==i)
163
	{
163
	{
164
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
164
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
165
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, ini_sections.get(i));
165
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, ini_sections.get(i));
166
	}
166
	}
167
	else
167
	else
168
	{
168
	{
169
		DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
169
		DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
170
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, ini_sections.get(i));
170
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, ini_sections.get(i));
171
	}
171
	}
172
}
172
}
173
 
173
 
174
void SelectList_LineChanged()
174
void SelectList_LineChanged()
175
{
175
{
176
	Draw_DriverListWindow();
176
	Draw_DriverListWindow();
177
}
177
}
178
 
178
 
179
 
179
 
180
void GetCurrentSectionData()
180
void GetCurrentSectionData()
181
{
181
{
182
	dword section_name = ini_sections.get(select_list.cur_y);
182
	dword section_name = ini_sections.get(select_list.cur_y);
183
	dword description_name;
183
	dword description_name;
184
	if (GetSystemLanguage() == SYS_LANG_RUS) description_name = "description_ru"; else description_name = "description_en";
184
	if (GetSystemLanguage() == SYS_LANG_RUS) description_name = "description_ru"; else description_name = "description_en";
185
	ini_get_str stdcall (#drvinf_path, section_name, "ver", #cur_version, sizeof(cur_version), 0);
185
	ini_get_str stdcall (#drvinf_path, section_name, "ver", #cur_version, sizeof(cur_version), 0);
186
	ini_get_str stdcall (#drvinf_path, section_name, description_name, #cur_description, sizeof(cur_description), 0);
186
	ini_get_str stdcall (#drvinf_path, section_name, description_name, #cur_description, sizeof(cur_description), 0);
187
	ini_get_str stdcall (#drvinf_path, section_name, "readme", #cur_readme_path, sizeof(cur_readme_path), 0);
187
	ini_get_str stdcall (#drvinf_path, section_name, "readme", #cur_readme_path, sizeof(cur_readme_path), 0);
188
	ini_get_str stdcall (#drvinf_path, section_name, "install", #cur_install_path, sizeof(cur_install_path), 0);
188
	ini_get_str stdcall (#drvinf_path, section_name, "install", #cur_install_path, sizeof(cur_install_path), 0);
189
}
189
}
190
 
190
 
191
//===================================================//
191
//===================================================//
192
//                                                   //
192
//                                                   //
193
//                     EVENTS                        //
193
//                     EVENTS                        //
194
//                                                   //
194
//                                                   //
195
//===================================================//
195
//===================================================//
196
 
196
 
197
void Event_ProcessButtonId(int id)
197
void Event_ProcessButtonId(int id)
198
{
198
{
199
	if (id==1) ExitProcess();
199
	if (id==1) ExitProcess();
200
	if (id==BUTTON_ID_ASSEPT_RISK) Event_AsseptRisk();
200
	if (id==BUTTON_ID_ASSEPT_RISK) Event_AsseptRisk();
201
	if (id==BUTTON_ID_README) Event_ShowReadme();
201
	if (id==BUTTON_ID_README) Event_ShowReadme();
202
	if (id==BUTTON_ID_INSTALL) Event_RunInstall();
202
	if (id==BUTTON_ID_INSTALL) Event_RunInstall();
203
}
203
}
204
 
204
 
205
void Event_DrawWindow() 
205
void Event_DrawWindow() 
206
{
206
{
207
	system.color.get();
207
	system.color.get();
208
	DefineAndDrawWindow(215, 100, 600, 400, 0x33, system.color.work, WINDOW_TITLE,0);
208
	DefineAndDrawWindow(215, 100, 600, 400, 0x33, system.color.work, WINDOW_TITLE,0);
209
	GetProcessInfo(#Form, SelfInfo);
209
	GetProcessInfo(#Form, SelfInfo);
210
	if (Form.status_window>2) return;
210
	if (Form.status_window>2) return;
211
	if (Form.width  < 450) { MoveSize(OLD,OLD,450,OLD); return; }
211
	if (Form.width  < 450) { MoveSize(OLD,OLD,450,OLD); return; }
212
	if (Form.height < 250) { MoveSize(OLD,OLD,OLD,250); return; }
212
	if (Form.height < 250) { MoveSize(OLD,OLD,OLD,250); return; }
213
	if (window_step == WINDOW_STEP_INTRO) Draw_IntroWindow();
213
	if (window_step == WINDOW_STEP_INTRO) Draw_IntroWindow();
214
	if (window_step == WINDOW_STEP_DRIVER_LIST) Draw_DriverListWindow();
214
	if (window_step == WINDOW_STEP_DRIVER_LIST) Draw_DriverListWindow();
215
	return;
215
	return;
216
}
216
}
217
 
217
 
218
void Event_AsseptRisk()
218
void Event_AsseptRisk()
219
{
219
{
220
	window_step = WINDOW_STEP_DRIVER_LIST;
220
	window_step = WINDOW_STEP_DRIVER_LIST;
221
	active_button_id = BUTTON_ID_INSTALL;
221
	active_button_id = BUTTON_ID_INSTALL;
222
	Event_DrawWindow();
222
	Event_DrawWindow();
223
}
223
}
224
 
224
 
225
void Event_ShowReadme()
225
void Event_ShowReadme()
226
{
226
{
227
	io.run("/sys/txtread", #cur_readme_path);
227
	io.run("/sys/txtread", #cur_readme_path);
228
}
228
}
229
 
229
 
230
void Event_RunInstall()
230
void Event_RunInstall()
231
{
231
{
232
	int result;
232
	int result;
233
	result = io.run(#cur_install_path, NULL);
233
	result = io.run(#cur_install_path, NULL);
234
	if (result) notify("'Driver installation started.\nPlease, open BOARD to check status.'I");
234
	if (result) notify("'Driver installation started.\nPlease, open BOARD to check status.'I");
235
}
235
}