Rev 9439 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9439 | Rev 9887 | ||
---|---|---|---|
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/libimg.h" |
12 | #include "../lib/obj/libimg.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 | #include "../lib/patterns/restart_process.h" |
17 | #include "../lib/patterns/restart_process.h" |
18 | 18 | ||
19 | //===================================================// |
19 | //===================================================// |
20 | // // |
20 | // // |
21 | // DATA // |
21 | // DATA // |
22 | // // |
22 | // // |
23 | //===================================================// |
23 | //===================================================// |
24 | 24 | ||
25 | proc_info Form; |
25 | proc_info Form; |
26 | 26 | ||
27 | #ifdef LANG_RUS |
27 | #ifdef LANG_RUS |
28 | #define WINDOW_TITLE "áâ ®¢é¨ª ¤à ©¢¥à®¢" |
28 | #define WINDOW_TITLE "áâ ®¢é¨ª ¤à ©¢¥à®¢" |
29 | #define T_CAUTION_TITLE " " |
29 | #define T_CAUTION_TITLE " " |
30 | #define T_CAUTION_PARAGRAPH "áâ ®¢ª ¤®¯®«¨â¥«ìëå ¤à ©¢¥à®¢ ¬®¦¥â ¥á⨠¢à¥¤ áâ ¡¨«ì®á⨠®¯¥à 樮®© á¨áâ¥¬ë ¨ ¯®â¥æ¨ «ì® ¯à¨¢¥á⨠ª ¯®àç¥ ®¡®à㤮¢ ¨ï." |
30 | #define T_CAUTION_PARAGRAPH "áâ ®¢ª ¤®¯®«¨â¥«ìëå ¤à ©¢¥à®¢ ¬®¦¥â ¥á⨠¢à¥¤ áâ ¡¨«ì®á⨠®¯¥à 樮®© á¨áâ¥¬ë ¨ ¯®â¥æ¨ «ì® ¯à¨¢¥á⨠ª ¯®àç¥ ®¡®à㤮¢ ¨ï." |
31 | #define T_ASSEPT_RISK " ¯à¨¨¬ î à¨áª" |
31 | #define T_ASSEPT_RISK " ¯à¨¨¬ î à¨áª" |
32 | #define T_README "Readme" |
32 | #define T_README "Readme" |
33 | #define T_INSTALL "áâ ®¢¨âì" |
33 | #define T_INSTALL "áâ ®¢¨âì" |
34 | #define T_DRIVER_INSTALLARION_STARTED "' ç « áì ãáâ ®¢ª ¤à ©¢¥à .\n®£ ãáâ ®¢ª¨ 室¨âáï ¢ ¯à¨«®¦¥¨¨ BOARD.'I" |
34 | #define T_DRIVER_INSTALLARION_STARTED "' ç « áì ãáâ ®¢ª ¤à ©¢¥à .\n®£ ãáâ ®¢ª¨ 室¨âáï ¢ ¯à¨«®¦¥¨¨ BOARD.'I" |
35 | char description_name[] = "description_ru"; |
35 | char description_name[] = "description_ru"; |
36 | #else |
36 | #else |
37 | #define WINDOW_TITLE "Driver Installer" |
37 | #define WINDOW_TITLE "Driver Installer" |
38 | #define T_CAUTION_TITLE "CAUTION" |
38 | #define T_CAUTION_TITLE "CAUTION" |
39 | #define T_CAUTION_PARAGRAPH "Installing additional drivers can be harmful to the stability of the operation system and potentionally can harm hardware." |
39 | #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_ASSEPT_RISK "I accept the risk" |
40 | #define T_ASSEPT_RISK "I accept the risk" |
41 | #define T_README "Readme" |
41 | #define T_README "Readme" |
42 | #define T_INSTALL "Install" |
42 | #define T_INSTALL "Install" |
43 | #define T_DRIVER_INSTALLARION_STARTED "'Driver installation started.\nInstallation log can be found in BOARD app.'I" |
43 | #define T_DRIVER_INSTALLARION_STARTED "'Driver installation started.\nInstallation log can be found in BOARD app.'I" |
44 | char description_name[] = "description_en"; |
44 | char description_name[] = "description_en"; |
45 | #endif |
45 | #endif |
46 | 46 | ||
47 | #define BUTTON_ID_ASSEPT_RISK 10 |
47 | #define BUTTON_ID_ASSEPT_RISK 10 |
48 | #define BUTTON_ID_README 11 |
48 | #define BUTTON_ID_README 11 |
49 | #define BUTTON_ID_INSTALL 12 |
49 | #define BUTTON_ID_INSTALL 12 |
50 | 50 | ||
51 | //WINDOW STEPS |
51 | //WINDOW STEPS |
52 | #define WINDOW_STEP_INTRO 1; |
52 | #define WINDOW_STEP_INTRO 1; |
53 | #define WINDOW_STEP_DRIVER_LIST 2; |
53 | #define WINDOW_STEP_DRIVER_LIST 2; |
54 | char window_step = WINDOW_STEP_INTRO; |
54 | char window_step = WINDOW_STEP_INTRO; |
55 | 55 | ||
56 | collection ini_sections=0; |
56 | collection ini_sections=0; |
57 | 57 | ||
58 | char drvinf_path[4096] = "/kolibrios/drivers/drvinf.ini"; |
58 | char drvinf_path[4096] = "/kolibrios/drivers/drvinf.ini"; |
59 | char cur_version[64]; |
59 | char cur_version[64]; |
60 | int cur_icon; |
60 | int cur_icon; |
61 | char cur_description[1024]; |
61 | char cur_description[1024]; |
62 | char cur_readme_path[4096]; |
62 | char cur_readme_path[4096]; |
63 | char cur_install_path[4096]; |
63 | char cur_install_path[4096]; |
64 | 64 | ||
65 | //===================================================// |
65 | //===================================================// |
66 | // // |
66 | // // |
67 | // CODE // |
67 | // CODE // |
68 | // // |
68 | // // |
69 | //===================================================// |
69 | //===================================================// |
70 | 70 | ||
71 | void GetIniData() |
71 | void GetIniData() |
72 | { |
72 | { |
73 | select_list.count = 0; |
73 | select_list.count = 0; |
74 | ini_enum_sections stdcall (#drvinf_path, #process_sections); |
74 | ini_enum_sections stdcall (#drvinf_path, #process_sections); |
75 | } |
75 | } |
76 | 76 | ||
77 | byte process_sections(dword sec_name, f_name) |
77 | byte process_sections(dword sec_name, f_name) |
78 | { |
78 | { |
79 | select_list.count++; |
79 | select_list.count++; |
80 | ini_sections.add(sec_name); |
80 | ini_sections.add(sec_name); |
81 | return true; |
81 | return true; |
82 | } |
82 | } |
83 | 83 | ||
84 | void main() |
84 | void main() |
85 | { |
85 | { |
86 | load_dll(libini, #lib_init,1); |
86 | load_dll(libini, #lib_init,1); |
87 | load_dll(boxlib, #box_lib_init,0); |
87 | load_dll(boxlib, #box_lib_init,0); |
88 | load_dll(libimg, #libimg_init,1); |
88 | load_dll(libimg, #libimg_init,1); |
89 | GetIniData(); |
89 | GetIniData(); |
90 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
90 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
91 | loop() switch(WaitEvent()) |
91 | loop() switch(WaitEvent()) |
92 | { |
92 | { |
93 | case evMouse: |
93 | case evMouse: |
94 | SelectList_ProcessMouse(); |
94 | SelectList_ProcessMouse(); |
95 | break; |
95 | break; |
96 | 96 | ||
97 | case evButton: |
97 | case evButton: |
98 | Event_ProcessButtonId(GetButtonID()); |
98 | Event_ProcessButtonId(GetButtonID()); |
99 | break; |
99 | break; |
100 | 100 | ||
101 | case evKey: |
101 | case evKey: |
102 | GetKeys(); |
102 | GetKeys(); |
103 | if (key_scancode == SCAN_CODE_ENTER) Event_ProcessButtonId(active_button_id); |
103 | if (key_scancode == SCAN_CODE_ENTER) Event_ProcessButtonId(active_button_id); |
104 | if (window_step == WINDOW_STEP_DRIVER_LIST) |
104 | if (window_step == WINDOW_STEP_DRIVER_LIST) |
105 | { |
105 | { |
106 | if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); |
106 | if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); |
107 | if (key_scancode == SCAN_CODE_TAB) |
107 | if (key_scancode == SCAN_CODE_TAB) |
108 | { |
108 | { |
109 | ActiveButtonSwitch(11, 12); |
109 | ActiveButtonSwitch(11, 12); |
110 | Draw_DriverListWindow(); |
110 | Draw_DriverListWindow(); |
111 | } |
111 | } |
112 | } |
112 | } |
113 | break; |
113 | break; |
114 | 114 | ||
115 | case evReDraw: |
115 | case evReDraw: |
116 | Event_DrawWindow(); |
116 | Event_DrawWindow(); |
117 | } |
117 | } |
118 | } |
118 | } |
119 | 119 | ||
120 | 120 | ||
121 | void Draw_IntroWindow() |
121 | void Draw_IntroWindow() |
122 | { |
122 | { |
123 | incn y; |
123 | incn y; |
124 | y.n = Form.cheight/2 - 80; |
124 | y.n = Form.cheight/2 - 80; |
125 | WriteTextB(30+2,y.n+2,0x81,MixColors(sc.work, 0xB92234,220),T_CAUTION_TITLE); |
125 | WriteTextB(30+2,y.n+2,0x81,MixColors(sc.work, 0xB92234,220),T_CAUTION_TITLE); |
126 | WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE); |
126 | WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE); |
127 | y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140, |
127 | y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140, |
128 | T_CAUTION_PARAGRAPH, -1, sc.work_text); |
128 | T_CAUTION_PARAGRAPH, -1, sc.work_text); |
129 | active_button_id = BUTTON_ID_ASSEPT_RISK; |
129 | active_button_id = BUTTON_ID_ASSEPT_RISK; |
130 | DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK); |
130 | DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK); |
131 | } |
131 | } |
132 | 132 | ||
133 | 133 | ||
134 | void Draw_DriverListWindow() |
134 | void Draw_DriverListWindow() |
135 | { |
135 | { |
136 | #define PADDING 12 |
136 | #define PADDING 12 |
137 | int right_frame_x = Form.cwidth*46/100; |
137 | int right_frame_x = Form.cwidth*46/100; |
138 | int readme_w = 0; |
138 | int readme_w = 0; |
139 | //LEFT FRAME |
139 | //LEFT FRAME |
140 | SelectList_Init(PADDING, PADDING, |
140 | SelectList_Init(PADDING, PADDING, |
141 | right_frame_x - PADDING - PADDING - 8 - scroll1.size_x, |
141 | right_frame_x - PADDING - PADDING - 8 - scroll1.size_x, |
142 | Form.cheight - PADDING - PADDING); |
142 | Form.cheight - PADDING - PADDING); |
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, sc.work); |
147 | DrawBar(right_frame_x, PADDING+3, Form.cwidth - right_frame_x - PADDING, 80, sc.work); |
148 | draw_icon_32(right_frame_x, PADDING, sc.work, cur_icon); |
148 | draw_icon_32(right_frame_x, PADDING, sc.work, cur_icon); |
149 | WriteTextB(right_frame_x+44, PADDING+3, 0x81, sc.work_text, ini_sections.get(select_list.cur_y)); |
149 | WriteTextB(right_frame_x+44, PADDING+3, 0x81, sc.work_text, ini_sections.get(select_list.cur_y)); |
150 | WriteText(right_frame_x+44, PADDING+23, 0x80, sc.work_text, #cur_version); |
150 | WriteText(right_frame_x+44, PADDING+23, 0x80, sc.work_text, #cur_version); |
151 | if(cur_readme_path[0]) readme_w = DrawStandartCaptButton(right_frame_x, PADDING+45, BUTTON_ID_README, T_README); |
151 | if(cur_readme_path[0]) readme_w = DrawStandartCaptButton(right_frame_x, PADDING+45, BUTTON_ID_README, T_README); |
152 | DrawStandartCaptButton(right_frame_x + readme_w, PADDING+45, BUTTON_ID_INSTALL, T_INSTALL); |
152 | DrawStandartCaptButton(right_frame_x + readme_w, PADDING+45, BUTTON_ID_INSTALL, T_INSTALL); |
153 | DrawTextViewArea(right_frame_x-2, PADDING+83, Form.cwidth - right_frame_x - PADDING, Form.cheight-PADDING-PADDING, |
153 | DrawTextViewArea(right_frame_x-2, PADDING+83, Form.cwidth - right_frame_x - PADDING, Form.cheight-PADDING-PADDING, |
154 | #cur_description, sc.work, sc.work_text); |
154 | #cur_description, sc.work, sc.work_text); |
155 | } |
155 | } |
156 | 156 | ||
157 | void SelectList_DrawLine(dword i) |
157 | void SelectList_DrawLine(dword i) |
158 | { |
158 | { |
159 | int yyy, list_last; |
159 | int yyy, list_last; |
160 | 160 | ||
161 | yyy = i*select_list.item_h+select_list.y; |
161 | yyy = i*select_list.item_h+select_list.y; |
162 | 162 | ||
163 | if (select_list.cur_y-select_list.first==i) |
163 | if (select_list.cur_y-select_list.first==i) |
164 | { |
164 | { |
165 | DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, sc.button); |
165 | DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, sc.button); |
166 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,sc.button_text, ini_sections.get(i)); |
166 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,sc.button_text, ini_sections.get(i+select_list.first)); |
167 | } |
167 | } |
168 | else |
168 | else |
169 | { |
169 | { |
170 | DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff); |
170 | DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff); |
171 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, ini_sections.get(i)); |
171 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, ini_sections.get(i+select_list.first)); |
172 | } |
172 | } |
173 | } |
173 | } |
174 | 174 | ||
175 | void SelectList_LineChanged() |
175 | void SelectList_LineChanged() |
176 | { |
176 | { |
177 | Draw_DriverListWindow(); |
177 | Draw_DriverListWindow(); |
178 | } |
178 | } |
179 | 179 | ||
180 | 180 | ||
181 | void GetCurrentSectionData() |
181 | void GetCurrentSectionData() |
182 | { |
182 | { |
183 | dword section_name = ini_sections.get(select_list.cur_y); |
183 | dword section_name = ini_sections.get(select_list.cur_y); |
184 | ini_get_str stdcall (#drvinf_path, section_name, "ver", #cur_version, sizeof(cur_version), 0); |
184 | ini_get_str stdcall (#drvinf_path, section_name, "ver", #cur_version, sizeof(cur_version), 0); |
185 | ini_get_int stdcall (#drvinf_path, section_name, "icon", 38); cur_icon = EAX; |
185 | ini_get_int stdcall (#drvinf_path, section_name, "icon", 38); cur_icon = EAX; |
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 | sc.get(); |
207 | sc.get(); |
208 | DefineAndDrawWindow(215, 100, 600, 400, 0x33, sc.work, WINDOW_TITLE,0); |
208 | DefineAndDrawWindow(215, 100, 600, 400, 0x33, sc.work, WINDOW_TITLE,0); |
209 | GetProcessInfo(#Form, SelfInfo); |
209 | GetProcessInfo(#Form, SelfInfo); |
210 | if (Form.status_window&ROLLED_UP) return; |
210 | if (Form.status_window&ROLLED_UP) 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/@open", #cur_readme_path); |
227 | io.run("/sys/@open", #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(T_DRIVER_INSTALLARION_STARTED); |
234 | if (result) notify(T_DRIVER_INSTALLARION_STARTED); |
235 | pause(300); |
235 | pause(300); |
236 | if (cur_icon == 61) { |
236 | if (cur_icon == 61) { |
237 | RestartProcessByName("/sys/@taskbar", SINGLE); |
237 | RestartProcessByName("/sys/@taskbar", SINGLE); |
238 | RestartProcessByName("/sys/@docky", SINGLE); |
238 | RestartProcessByName("/sys/@docky", SINGLE); |
239 | RestartProcessByName("/sys/@icon", MULTIPLE); |
239 | RestartProcessByName("/sys/@icon", MULTIPLE); |
240 | } |
240 | } |
241 | }>> |
241 | }>> |