Subversion Repositories Kolibri OS

Rev

Rev 8915 | Rev 8946 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6653 leency 1
#define MEMSIZE 4096*20
2
 
6662 leency 3
#ifndef AUTOBUILD
4
#include "lang.h--"
5
#endif
6
 
6653 leency 7
//===================================================//
8
//                                                   //
9
//                       LIB                         //
10
//                                                   //
11
//===================================================//
12
 
6631 leency 13
#include "../lib/gui.h"
6653 leency 14
#include "../lib/list_box.h"
15
#include "../lib/obj/box_lib.h"
7793 leency 16
#include "../lib/obj/libimg.h"
6653 leency 17
#include "../lib/obj/libini.h"
6654 leency 18
#include "../lib/collection.h"
19
#include "../lib/io.h"
6653 leency 20
#include "../lib/patterns/select_list.h"
7793 leency 21
#include "../lib/patterns/restart_process.h"
6653 leency 22
 
23
//===================================================//
24
//                                                   //
25
//                       DATA                        //
26
//                                                   //
27
//===================================================//
28
 
6631 leency 29
proc_info Form;
30
 
6662 leency 31
#ifdef LANG_RUS
32
	#define WINDOW_TITLE "Установщик драйверов"
33
	#define T_CAUTION_TITLE "ПРЕДУПРЕЖДЕНИЕ"
34
	#define T_CAUTION_PARAGRAPH "Установка дополнительных драйверов может нанести вред стабильности операционной системы и потенциально привести к порче оборудования."
35
	#define T_ASSEPT_RISK "Я принимаю риск"
36
	#define T_README "Readme"
37
	#define T_INSTALL "Установить"
7793 leency 38
	#define T_DRIVER_INSTALLARION_STARTED "'Началась установка драйвера.\nЛог установки находится в приложении BOARD.'I"
7590 leency 39
	char description_name[] = "description_ru";
6662 leency 40
#else
41
	#define WINDOW_TITLE "Driver Installer"
42
	#define T_CAUTION_TITLE "CAUTION"
43
	#define T_CAUTION_PARAGRAPH "Installing additional drivers can be harmful to the stability of the operation system and potentionally can harm hardware."
44
	#define T_ASSEPT_RISK "I accept the risk"
45
	#define T_README "Readme"
46
	#define T_INSTALL "Install"
7793 leency 47
	#define T_DRIVER_INSTALLARION_STARTED "'Driver installation started.\nInstallation log can be found in BOARD app.'I"
7590 leency 48
	char description_name[] = "description_en";
6662 leency 49
#endif
6631 leency 50
 
51
#define BUTTON_ID_ASSEPT_RISK 10
6651 leency 52
#define BUTTON_ID_README 11
53
#define BUTTON_ID_INSTALL 12
6631 leency 54
 
6651 leency 55
//WINDOW STEPS
56
#define WINDOW_STEP_INTRO 1;
57
#define WINDOW_STEP_DRIVER_LIST 2;
58
char window_step = WINDOW_STEP_INTRO;
6631 leency 59
 
7972 leency 60
collection ini_sections=0;
6654 leency 61
 
6656 leency 62
char drvinf_path[4096] = "/kolibrios/drivers/drvinf.ini";
6654 leency 63
char cur_version[64];
8915 leency 64
int  cur_icon;
6654 leency 65
char cur_description[1024];
66
char cur_readme_path[4096];
67
char cur_install_path[4096];
68
 
6653 leency 69
//===================================================//
70
//                                                   //
71
//                       CODE                        //
72
//                                                   //
73
//===================================================//
74
 
75
void GetIniData()
76
{
6654 leency 77
	select_list.count = 0;
78
	ini_enum_sections stdcall (#drvinf_path, #process_sections);
6653 leency 79
}
80
 
81
byte process_sections(dword sec_name, f_name)
82
{
6654 leency 83
	select_list.count++;
84
	ini_sections.add(sec_name);
6653 leency 85
	return true;
86
}
87
 
6631 leency 88
void main()
89
{
6653 leency 90
	load_dll(libini, #lib_init,1);
91
	load_dll(boxlib, #box_lib_init,0);
7793 leency 92
	load_dll(libimg, #libimg_init,1);
6654 leency 93
	GetIniData();
7031 leency 94
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
6631 leency 95
	loop() switch(WaitEvent())
96
	{
6653 leency 97
		case evMouse:
98
			SelectList_ProcessMouse();
99
			break;
100
 
6631 leency 101
		case evButton:
7031 leency 102
			Event_ProcessButtonId(GetButtonID());
6631 leency 103
			break;
104
 
105
		case evKey:
106
			GetKeys();
7031 leency 107
			if (key_scancode == SCAN_CODE_ENTER) Event_ProcessButtonId(active_button_id);
108
			if (window_step == WINDOW_STEP_DRIVER_LIST)
109
			{
110
				if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
111
				if (key_scancode == SCAN_CODE_TAB)
112
				{
113
					ActiveButtonSwitch(11, 12);
114
					Draw_DriverListWindow();
115
				}
116
			}
6631 leency 117
			break;
118
 
119
		case evReDraw:
6653 leency 120
			Event_DrawWindow();
6631 leency 121
	}
122
}
123
 
124
 
7031 leency 125
void Draw_IntroWindow()
6631 leency 126
{
127
	incn y;
6651 leency 128
	y.n = Form.cheight/2 - 80;
7806 leency 129
	WriteTextB(30+2,y.n+2,0x81,MixColors(sc.work, 0xB92234,220),T_CAUTION_TITLE);
6631 leency 130
	WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE);
6651 leency 131
	y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140,
7806 leency 132
		T_CAUTION_PARAGRAPH, -1, sc.work_text);
7031 leency 133
	active_button_id = BUTTON_ID_ASSEPT_RISK;
6631 leency 134
	DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK);
135
}
136
 
137
 
7031 leency 138
void Draw_DriverListWindow()
6651 leency 139
{
8915 leency 140
	#define PADDING 12
6654 leency 141
	int right_frame_x = Form.cwidth*46/100;
142
	int readme_w = 0;
6651 leency 143
	//LEFT FRAME
8933 leency 144
	SelectList_Init(PADDING, PADDING,
6654 leency 145
		right_frame_x - PADDING - PADDING - 8 - scroll1.size_x,
8933 leency 146
		Form.cheight - PADDING - PADDING);
6653 leency 147
	SelectList_Draw();
6662 leency 148
	SelectList_DrawBorder();
6651 leency 149
	//RIGHT FRAME
6654 leency 150
	GetCurrentSectionData();
7806 leency 151
	DrawBar(right_frame_x, PADDING+3, Form.cwidth - right_frame_x - PADDING, 80, sc.work);
8915 leency 152
	DrawIcon32(right_frame_x, PADDING, sc.work, cur_icon);
7806 leency 153
	WriteTextB(right_frame_x+44, PADDING+3, 0x81, sc.work_text, ini_sections.get(select_list.cur_y));
154
	WriteText(right_frame_x+44, PADDING+23, 0x80, sc.work_text, #cur_version);
6654 leency 155
	if(cur_readme_path[0]) readme_w = DrawStandartCaptButton(right_frame_x, PADDING+45, BUTTON_ID_README, T_README);
156
	DrawStandartCaptButton(right_frame_x + readme_w, PADDING+45, BUTTON_ID_INSTALL, T_INSTALL);
157
	DrawTextViewArea(right_frame_x-2, PADDING+83, Form.cwidth - right_frame_x - PADDING, Form.cheight-PADDING-PADDING,
7806 leency 158
		#cur_description, sc.work, sc.work_text);
6651 leency 159
}
6653 leency 160
 
161
void SelectList_DrawLine(dword i)
162
{
163
	int yyy, list_last;
164
 
165
	yyy = i*select_list.item_h+select_list.y;
166
 
167
	if (select_list.cur_y-select_list.first==i)
168
	{
7806 leency 169
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, sc.button);
170
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,sc.button_text, ini_sections.get(i));
6653 leency 171
	}
172
	else
173
	{
174
		DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
6654 leency 175
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, ini_sections.get(i));
6653 leency 176
	}
177
}
178
 
179
void SelectList_LineChanged()
180
{
7031 leency 181
	Draw_DriverListWindow();
6653 leency 182
}
183
 
6662 leency 184
 
6654 leency 185
void GetCurrentSectionData()
186
{
6662 leency 187
	dword section_name = ini_sections.get(select_list.cur_y);
188
	ini_get_str stdcall (#drvinf_path, section_name, "ver", #cur_version, sizeof(cur_version), 0);
8915 leency 189
	ini_get_int stdcall (#drvinf_path, section_name, "icon", 38); cur_icon = EAX;
7590 leency 190
	ini_get_str stdcall (#drvinf_path, section_name, #description_name, #cur_description, sizeof(cur_description), 0);
6662 leency 191
	ini_get_str stdcall (#drvinf_path, section_name, "readme", #cur_readme_path, sizeof(cur_readme_path), 0);
192
	ini_get_str stdcall (#drvinf_path, section_name, "install", #cur_install_path, sizeof(cur_install_path), 0);
6654 leency 193
}
194
 
6653 leency 195
//===================================================//
196
//                                                   //
197
//                     EVENTS                        //
198
//                                                   //
199
//===================================================//
200
 
7031 leency 201
void Event_ProcessButtonId(int id)
202
{
203
	if (id==1) ExitProcess();
204
	if (id==BUTTON_ID_ASSEPT_RISK) Event_AsseptRisk();
205
	if (id==BUTTON_ID_README) Event_ShowReadme();
206
	if (id==BUTTON_ID_INSTALL) Event_RunInstall();
207
}
208
 
6653 leency 209
void Event_DrawWindow()
210
{
7806 leency 211
	sc.get();
212
	DefineAndDrawWindow(215, 100, 600, 400, 0x33, sc.work, WINDOW_TITLE,0);
6653 leency 213
	GetProcessInfo(#Form, SelfInfo);
6654 leency 214
	if (Form.status_window>2) return;
215
	if (Form.width  < 450) { MoveSize(OLD,OLD,450,OLD); return; }
216
	if (Form.height < 250) { MoveSize(OLD,OLD,OLD,250); return; }
7031 leency 217
	if (window_step == WINDOW_STEP_INTRO) Draw_IntroWindow();
218
	if (window_step == WINDOW_STEP_DRIVER_LIST) Draw_DriverListWindow();
6653 leency 219
	return;
220
}
221
 
222
void Event_AsseptRisk()
223
{
224
	window_step = WINDOW_STEP_DRIVER_LIST;
7031 leency 225
	active_button_id = BUTTON_ID_INSTALL;
6653 leency 226
	Event_DrawWindow();
227
}
228
 
229
void Event_ShowReadme()
230
{
7946 leency 231
	io.run("/sys/@open", #cur_readme_path);
6653 leency 232
}
233
 
234
void Event_RunInstall()
235
{
7031 leency 236
	int result;
237
	result = io.run(#cur_install_path, NULL);
7793 leency 238
	if (result) notify(T_DRIVER_INSTALLARION_STARTED);
239
	pause(300);
8915 leency 240
	if (cur_icon == 61) {
7793 leency 241
		RestartProcessByName("/sys/@taskbar", SINGLE);
242
		RestartProcessByName("/sys/@docky", SINGLE);
7795 leency 243
		RestartProcessByName("/sys/@icon", MULTIPLE);
7793 leency 244
	}
6653 leency 245
}