1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32svr.h> |
|
17 #include "ResourceHandler.h" |
|
18 |
|
19 // |
|
20 // Thread Dialog |
|
21 // |
|
22 |
|
23 CThreadNumberDialog::CThreadNumberDialog() |
|
24 { |
|
25 } |
|
26 |
|
27 void CThreadNumberDialog::PreLayoutDynInitL() |
|
28 { |
|
29 // to start use the thread ID of this thread |
|
30 iThreadID = RThread().Id(); |
|
31 UpdateDialogData(); |
|
32 } |
|
33 |
|
34 void CThreadNumberDialog::PostLayoutDynInitL() |
|
35 { |
|
36 |
|
37 } |
|
38 |
|
39 void CThreadNumberDialog::UpdateDialogData() |
|
40 { |
|
41 if (iThreadID > 0) UpdateDialogDataReal(); // Real thread |
|
42 else UpdateDialogDataAll(); // 0 for all unprotected threads |
|
43 } |
|
44 |
|
45 void CThreadNumberDialog::UpdateDialogDataAll() |
|
46 //update dialog - set for all threads |
|
47 { |
|
48 // match controls and set values |
|
49 CXIKNUMBEREDITOR *thisNumberEditor; |
|
50 thisNumberEditor = STATIC_CAST(CXIKNUMBEREDITOR*, Control(EThreadNumberCtl)); |
|
51 thisNumberEditor->SETNUMBERVALUEL(0); |
|
52 |
|
53 CEikCheckBox *sysCheckBox, *protCheckBox; |
|
54 sysCheckBox = STATIC_CAST(CEikCheckBox*,Control(EThreadSystemCtl)); |
|
55 protCheckBox = STATIC_CAST(CEikCheckBox*,Control(EThreadProtectedCtl)); |
|
56 |
|
57 CEikCommandButton *killBut, *okBut, *setBut; |
|
58 killBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EThreadKillButtonCtl)); |
|
59 okBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EEikBidOk)); |
|
60 setBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EThreadSetButtonCtl)); |
|
61 CEikLabel *priorityDialogPrompt, *priorityNumberLabel; |
|
62 priorityNumberLabel = STATIC_CAST(CEikLabel*, Control(EThreadPriorityText)); |
|
63 priorityDialogPrompt = STATIC_CAST(CEikLabel*, Control(EThreadPriorityPrompt)); |
|
64 |
|
65 priorityDialogPrompt->SetTextL(_L("Cannot set priority for all threads.")); |
|
66 |
|
67 #ifdef UIQ |
|
68 CEikLabel *theThreadLabel, *theProcessLabel; |
|
69 theThreadLabel = STATIC_CAST(CEikLabel*, Control(EThreadLabelThreadName)); |
|
70 theProcessLabel = STATIC_CAST(CEikLabel*, Control(EThreadLabelProcessName)); |
|
71 theProcessLabel->SetTextL(_L("Various")); |
|
72 theThreadLabel->SetTextL(_L("All unprotected")); |
|
73 #endif |
|
74 #ifdef TV |
|
75 CEikLabel *threadAndProcessLabel; |
|
76 threadAndProcessLabel = STATIC_CAST(CEikLabel*, Control(EThreadLabelThreadAndProcessName)); |
|
77 threadAndProcessLabel->SetTextL(_L("All threads/processes")); |
|
78 #endif |
|
79 CEikChoiceList *prioritySelector; |
|
80 prioritySelector = STATIC_CAST(CEikChoiceList*, Control(EThreadPriorityButtonCtl)); |
|
81 |
|
82 |
|
83 // Change the dimming on the component controls as appropriate for all threads |
|
84 protCheckBox->SetDimmed(ETrue); |
|
85 sysCheckBox->SetDimmed(EFalse); |
|
86 |
|
87 prioritySelector->MakeVisible(EFalse); |
|
88 |
|
89 priorityNumberLabel->MakeVisible(EFalse); |
|
90 |
|
91 killBut->SetDimmed(ETrue); |
|
92 okBut->SetDimmed(EFalse); |
|
93 setBut->SetDimmed(EFalse); |
|
94 DrawNow(); |
|
95 |
|
96 } |
|
97 |
|
98 //updates dialog depending on iThreadID |
|
99 void CThreadNumberDialog::UpdateDialogDataReal() |
|
100 { |
|
101 // match controls |
|
102 CXIKNUMBEREDITOR *thisNumberEditor; |
|
103 thisNumberEditor = STATIC_CAST(CXIKNUMBEREDITOR*, Control(EThreadNumberCtl)); |
|
104 thisNumberEditor->SETNUMBERVALUEL(0); |
|
105 |
|
106 CEikCheckBox *sysCheckBox, *protCheckBox; |
|
107 sysCheckBox = STATIC_CAST(CEikCheckBox*,Control(EThreadSystemCtl)); |
|
108 protCheckBox = STATIC_CAST(CEikCheckBox*,Control(EThreadProtectedCtl)); |
|
109 |
|
110 CEikCommandButton *killBut, *okBut, *setBut; |
|
111 okBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EEikBidOk)); |
|
112 setBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EThreadSetButtonCtl)); |
|
113 killBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EThreadKillButtonCtl)); |
|
114 |
|
115 #ifdef UIQ |
|
116 CEikLabel *theThreadLabel, *theProcessLabel; |
|
117 theThreadLabel = STATIC_CAST(CEikLabel*, Control(EThreadLabelThreadName)); |
|
118 theProcessLabel = STATIC_CAST(CEikLabel*, Control(EThreadLabelProcessName)); |
|
119 #endif |
|
120 #ifdef TV |
|
121 CEikLabel *threadAndProcessLabel; |
|
122 threadAndProcessLabel = STATIC_CAST(CEikLabel*, Control(EThreadLabelThreadAndProcessName)); |
|
123 #endif |
|
124 |
|
125 CEikChoiceList *priorityOpButs; |
|
126 priorityOpButs = STATIC_CAST(CEikChoiceList*, Control(EThreadPriorityButtonCtl)); |
|
127 |
|
128 // |
|
129 //Update dialog info with thread details |
|
130 // |
|
131 |
|
132 RThread thread; |
|
133 TInt err = KErrNone; |
|
134 |
|
135 err = thread.Open(iThreadID); |
|
136 |
|
137 if (err!=KErrNone) |
|
138 { |
|
139 thread.Close(); |
|
140 TBuf<70> errorMessage(_L("Cannot get thread number ")); |
|
141 errorMessage.AppendNum(iThreadID); |
|
142 errorMessage.Append(_L(". Thread::Open()")); |
|
143 DisplayError(errorMessage, err); |
|
144 thread.Open(RThread().Id()); // Get this thread |
|
145 } |
|
146 |
|
147 thisNumberEditor->SETNUMBERVALUEL(thread.Id()); |
|
148 |
|
149 #ifdef UIQ |
|
150 theThreadLabel->SetTextL(thread.Name()); |
|
151 #endif |
|
152 #ifdef TV |
|
153 TBuf<150> lProcessAndThread(thread.Name()); |
|
154 #endif |
|
155 |
|
156 RProcess process; |
|
157 thread.Process(process); |
|
158 #ifdef UIQ |
|
159 theProcessLabel->SetTextL(process.Name()); |
|
160 #endif |
|
161 #ifdef TV |
|
162 lProcessAndThread.Append(_L("/")); |
|
163 lProcessAndThread.Append(process.Name()); |
|
164 threadAndProcessLabel->SetTextL(lProcessAndThread); |
|
165 #endif |
|
166 process.Close(); |
|
167 |
|
168 CEikLabel *priorityDialogPrompt, *priorityNumberLabel; |
|
169 |
|
170 priorityDialogPrompt = STATIC_CAST(CEikLabel*, Control(EThreadPriorityPrompt)); |
|
171 if ( iThreadID == RThread().Id()) priorityDialogPrompt->SetTextL(_L("The priority of the current thread cannot be reset from within this application.")); |
|
172 else priorityDialogPrompt->SetTextL(_L("Set the priority.")); |
|
173 |
|
174 priorityNumberLabel = STATIC_CAST(CEikLabel*, Control(EThreadPriorityText)); |
|
175 TBuf<30> priorityText(_L("Priority Value: ")); |
|
176 TBuf<4> priorityNumber; |
|
177 |
|
178 priorityNumber.Format(KFormatDec,thread.Priority()); |
|
179 priorityText.Append(priorityNumber); |
|
180 priorityNumberLabel->SetTextL(priorityText); |
|
181 |
|
182 TThreadPriority lThreadPriority = thread.Priority(); |
|
183 TInt lThreadPrioritySetting; |
|
184 switch (lThreadPriority) |
|
185 { |
|
186 case(EPriorityAbsoluteHigh): lThreadPrioritySetting = EThreadP500_AbsoluteHigh; break; |
|
187 case(EPriorityAbsoluteForeground): lThreadPrioritySetting = EThreadP400_AbsoluteForeground; break; |
|
188 case(EPriorityAbsoluteBackground): lThreadPrioritySetting = EThreadP300_AbsoluteBackground; break; |
|
189 case(EPriorityAbsoluteLow): lThreadPrioritySetting = EThreadP200_AbsoluteLow; break; |
|
190 case(EPriorityAbsoluteVeryLow): lThreadPrioritySetting = EThreadP100_AbsoluteVeryLow; break; |
|
191 case(EPriorityRealTime): lThreadPrioritySetting = EThreadP30_RealTime; break; |
|
192 case(EPriorityMuchMore): lThreadPrioritySetting = EThreadP20_MuchMore; break; |
|
193 case(EPriorityMore): lThreadPrioritySetting = EThreadP10_More; break; |
|
194 case(EPriorityNormal): lThreadPrioritySetting = EThreadP0_Normal; break; |
|
195 case(EPriorityLess): lThreadPrioritySetting = EThreadPm10_Less; break; |
|
196 case(EPriorityMuchLess): lThreadPrioritySetting = EThreadPm20_MuchLess; break; |
|
197 case(EPriorityNull): lThreadPrioritySetting = EThreadPm30_Null; break; |
|
198 default: lThreadPrioritySetting = EThreadP_NotStandard; break; |
|
199 } |
|
200 |
|
201 priorityOpButs->SetCurrentItem(lThreadPrioritySetting); |
|
202 |
|
203 sysCheckBox->SetState(CEikButtonBase::EIndeterminate); |
|
204 protCheckBox->SetState(CEikButtonBase::EIndeterminate); |
|
205 |
|
206 // Change the dimming on the component controls depending on the thread |
|
207 sysCheckBox->SetDimmed(EFalse); |
|
208 |
|
209 if ( iThreadID == RThread().Id()) priorityOpButs->SetDimmed(ETrue); |
|
210 else priorityOpButs->SetDimmed(EFalse); |
|
211 |
|
212 killBut->SetDimmed(EFalse); |
|
213 okBut->SetDimmed(EFalse); |
|
214 setBut->SetDimmed(EFalse); |
|
215 |
|
216 if (iThreadID == RThread().Id()) |
|
217 { |
|
218 // can change the protection on this thread |
|
219 protCheckBox->SetDimmed(EFalse); |
|
220 } |
|
221 else |
|
222 { |
|
223 // cannot change protection |
|
224 protCheckBox->SetDimmed(ETrue); |
|
225 if (true) // If we are in secure then we ensure that the |
|
226 // user can not change anything. |
|
227 { |
|
228 // cannot change anything |
|
229 sysCheckBox->SetDimmed(ETrue); |
|
230 priorityOpButs->SetDimmed(ETrue); |
|
231 killBut->SetDimmed(ETrue); |
|
232 okBut->SetDimmed(ETrue); |
|
233 setBut->SetDimmed(ETrue); |
|
234 } |
|
235 |
|
236 } |
|
237 |
|
238 thread.Close(); |
|
239 DrawNow(); |
|
240 |
|
241 } |
|
242 |
|
243 void CThreadNumberDialog::UpdatePriorityText() |
|
244 //updates the priority number value to correspond to the priority option selected |
|
245 { |
|
246 |
|
247 } |
|
248 |
|
249 void CThreadNumberDialog::HandleControlStateChangeL(TInt aControlId) |
|
250 { |
|
251 if (aControlId == EThreadGetButtonCtl) |
|
252 { |
|
253 CXIKNUMBEREDITOR *thisNumberEditor; |
|
254 thisNumberEditor = STATIC_CAST(CXIKNUMBEREDITOR*, Control(EThreadNumberCtl)); |
|
255 iThreadID = (TThreadId)thisNumberEditor->NUMBERVALUE(); |
|
256 // re-evaluate everything |
|
257 UpdateDialogData(); |
|
258 |
|
259 // re-draw |
|
260 PageChangedL(EThreadPageGeneral); |
|
261 PageChangedL(EThreadPagePriority); |
|
262 PageChangedL(EThreadPageOther); |
|
263 DrawNow(); |
|
264 } |
|
265 } |
|
266 |
|
267 void CThreadNumberDialog::SetThread() |
|
268 { |
|
269 //change thread parameters |
|
270 if (iThreadID > 0) |
|
271 { |
|
272 // only get here if thread is not protected |
|
273 |
|
274 |
|
275 RThread thread; |
|
276 TInt err = thread.Open(iThreadID); |
|
277 |
|
278 if (err == KErrNone) |
|
279 { |
|
280 // This is the current thread |
|
281 if ( iThreadID == RThread().Id()) |
|
282 { |
|
283 } |
|
284 |
|
285 |
|
286 |
|
287 CEikChoiceList *opButs; |
|
288 opButs = STATIC_CAST(CEikChoiceList*, Control(EThreadPriorityButtonCtl)); |
|
289 |
|
290 TThreadPriority threadPrioritySet = EPriorityNull; |
|
291 TInt currentItem = opButs->CurrentItem(); |
|
292 |
|
293 switch (currentItem) |
|
294 { |
|
295 case (EThreadP500_AbsoluteHigh): threadPrioritySet=EPriorityAbsoluteHigh; break; |
|
296 case (EThreadP400_AbsoluteForeground): threadPrioritySet=EPriorityAbsoluteForeground; break; |
|
297 case (EThreadP300_AbsoluteBackground): threadPrioritySet=EPriorityAbsoluteBackground; break; |
|
298 case (EThreadP200_AbsoluteLow): threadPrioritySet=EPriorityAbsoluteLow; break; |
|
299 case (EThreadP100_AbsoluteVeryLow): threadPrioritySet=EPriorityAbsoluteVeryLow; break; |
|
300 case (EThreadP30_RealTime): threadPrioritySet=EPriorityRealTime; break; |
|
301 case (EThreadP20_MuchMore): threadPrioritySet=EPriorityMuchMore; break; |
|
302 case (EThreadP10_More): threadPrioritySet=EPriorityMore; break; |
|
303 case (EThreadP0_Normal): threadPrioritySet=EPriorityNormal; break; |
|
304 case (EThreadPm10_Less): threadPrioritySet=EPriorityLess; break; |
|
305 case (EThreadPm20_MuchLess): threadPrioritySet=EPriorityMuchLess; break; |
|
306 case (EThreadPm30_Null): threadPrioritySet=EPriorityNull; |
|
307 iEikonEnv->InfoWinL(_L("Error"), _L("Cannot change thread priority to Null")); |
|
308 break; |
|
309 default: iEikonEnv->InfoWinL(_L("Error"), _L("Invalid priority: cannot change thread priority to Not Standard")); |
|
310 |
|
311 }; |
|
312 |
|
313 if (threadPrioritySet != EPriorityNull) |
|
314 { |
|
315 thread.SetPriority(threadPrioritySet); |
|
316 |
|
317 TThreadPriority threadPriorityGot = thread.Priority(); |
|
318 if (threadPrioritySet!=threadPriorityGot) |
|
319 { |
|
320 iEikonEnv->InfoWinL(_L("Error"), _L("Thread priority not set: RThread::SetPriority() unsuccessful!")); |
|
321 } |
|
322 thread.Close(); |
|
323 } |
|
324 } |
|
325 } |
|
326 else //all threads selected - only changes system setting |
|
327 { |
|
328 |
|
329 TName prefix(KAsterisk); |
|
330 TFindThread findHb; |
|
331 findHb.Find(prefix); |
|
332 TFullName name; // this is a TBuf |
|
333 RThread thread; |
|
334 |
|
335 while (findHb.Next(name)==KErrNone) |
|
336 { |
|
337 TInt err = thread.Open(name); |
|
338 if (err != KErrNone) |
|
339 { |
|
340 TBuf<70> errorMessage(_L("Cannot get thread ")); |
|
341 errorMessage.Append(name); |
|
342 errorMessage.Append(_L(". RThread::Open()")); |
|
343 DisplayError(errorMessage, err); |
|
344 } |
|
345 |
|
346 if (err == KErrNone) |
|
347 { |
|
348 |
|
349 |
|
350 thread.Close(); |
|
351 } |
|
352 } |
|
353 } |
|
354 } |
|
355 |
|
356 TBool CThreadNumberDialog::OkToExitL(TInt aButtonId) |
|
357 { |
|
358 if (aButtonId == EEikBidCancel) |
|
359 { |
|
360 return ETrue; |
|
361 } |
|
362 else if (aButtonId == EThreadSetButtonCtl) |
|
363 { |
|
364 SetThread(); |
|
365 UpdateDialogData(); |
|
366 iEikonEnv->InfoMsg(_L("Attribute(s) set as displayed")); |
|
367 return EFalse; |
|
368 } |
|
369 else if (aButtonId == EEikBidOk) |
|
370 { |
|
371 SetThread(); |
|
372 return ETrue; |
|
373 } |
|
374 else if (aButtonId == EThreadKillButtonCtl) |
|
375 { |
|
376 RThread thread; |
|
377 TInt err = thread.Open(iThreadID); |
|
378 if (err == KErrNone) |
|
379 { |
|
380 thread.Kill(KErrNone); |
|
381 iEikonEnv->InfoMsg(_L("Thread Killed")); |
|
382 } |
|
383 else iEikonEnv->InfoWinL(_L("Error"), _L("Attempt to open thread for modification unsuccessful.")); |
|
384 thread.Close(); |
|
385 return EFalse; |
|
386 } |
|
387 return ETrue; |
|
388 } |
|
389 |
|
390 // |
|
391 // |
|
392 // Process Dialog |
|
393 // |
|
394 // |
|
395 |
|
396 CProcessNumberDialog::CProcessNumberDialog() |
|
397 { |
|
398 } |
|
399 |
|
400 void CProcessNumberDialog::PreLayoutDynInitL() |
|
401 { |
|
402 // to start use the thread ID of this Process |
|
403 iProcessID = RProcess().Id(); |
|
404 UpdateDialogData(); |
|
405 } |
|
406 |
|
407 void CProcessNumberDialog::PostLayoutDynInitL() |
|
408 { |
|
409 } |
|
410 |
|
411 void CProcessNumberDialog::UpdateDialogData() |
|
412 //Updates GUI data |
|
413 { |
|
414 // match the controls |
|
415 CXIKNUMBEREDITOR *thisNumberEditor; |
|
416 thisNumberEditor = STATIC_CAST(CXIKNUMBEREDITOR*, Control(EProcessNumberCtl)); |
|
417 CEikLabel *priorityTextLabel; |
|
418 priorityTextLabel = STATIC_CAST(CEikLabel*, Control(EProcessPriorityText)); |
|
419 |
|
420 CEikCheckBox *sysCheckBox, *protCheckBox; |
|
421 sysCheckBox = STATIC_CAST(CEikCheckBox*,Control(EProcessSystemCtl)); |
|
422 protCheckBox = STATIC_CAST(CEikCheckBox*,Control(EProcessProtectedCtl)); |
|
423 |
|
424 CEikCommandButton *killBut, *okBut, *setBut; |
|
425 killBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EProcessKillButtonCtl)); |
|
426 okBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EEikBidOk)); |
|
427 setBut = STATIC_CAST(CEikCommandButton*, ButtonGroupContainer().CommandButtonOrNull(EProcessSetButtonCtl)); |
|
428 |
|
429 CEikLabel *theProcessLabel; |
|
430 theProcessLabel = STATIC_CAST(CEikLabel*, Control(EProcessLabelProcessName)); |
|
431 |
|
432 CEikChoiceList *opButs; |
|
433 opButs = STATIC_CAST(CEikChoiceList*, Control(EProcessPriorityButtonCtl)); |
|
434 |
|
435 //open a process and update GUI data |
|
436 RProcess process; |
|
437 TInt err = KErrNone; |
|
438 |
|
439 err = process.Open(iProcessID); // Opens a handle to a process |
|
440 |
|
441 if (err!=KErrNone) |
|
442 { |
|
443 TBuf<70> errorMessage(_L("Cannot get process number ")); |
|
444 errorMessage.AppendNum(iProcessID); |
|
445 errorMessage.Append(_L(". System error number ")); |
|
446 errorMessage.AppendNum(err); |
|
447 |
|
448 iEikonEnv->InfoWinL(_L("Error"), errorMessage); |
|
449 iProcessID = RProcess().Id(); |
|
450 process.Open(iProcessID); // Opens a handle to this Process |
|
451 } |
|
452 |
|
453 thisNumberEditor->SETNUMBERVALUEL(process.Id()); |
|
454 theProcessLabel->SetTextL(process.Name()); |
|
455 |
|
456 TBuf<30> priorityText(_L("Priority Value: ")); |
|
457 TBuf<10> priorityNumber; |
|
458 priorityNumber.Format(KFormatDec,process.Priority()); |
|
459 priorityText.Append(priorityNumber); |
|
460 priorityTextLabel->SetTextL(priorityText); |
|
461 if (process.Priority()==EPriorityLow) opButs->SetCurrentItem(EProcessP150_PriorityLow); |
|
462 else if (process.Priority()==EPriorityBackground) opButs->SetCurrentItem(EProcessP250_PriorityBackground); |
|
463 else if (process.Priority()==EPriorityForeground) opButs->SetCurrentItem(EProcessP350_PriorityForeground); |
|
464 else if (process.Priority()==EPriorityHigh) opButs->SetCurrentItem(EProcessP450_PriorityHigh); |
|
465 else if (process.Priority()==EPriorityWindowServer) opButs->SetCurrentItem(EProcessP650_PriorityWindowServer); |
|
466 else if (process.Priority()==EPriorityFileServer) opButs->SetCurrentItem(EProcessP750_PriorityFileServer); |
|
467 else if (process.Priority()==EPriorityRealTimeServer) opButs->SetCurrentItem(EProcessP850_PriorityRealTimeServer); |
|
468 else if (process.Priority()==EPrioritySupervisor) opButs->SetCurrentItem(EProcessP950_PrioritySupervisor); |
|
469 else (opButs->SetCurrentItem(EProcessPriorityNotStandard)); |
|
470 |
|
471 |
|
472 sysCheckBox->SetState(CEikButtonBase::EIndeterminate); |
|
473 protCheckBox->SetState(CEikButtonBase::EIndeterminate); |
|
474 |
|
475 |
|
476 // Change the dimming on the component controls depending on the Process |
|
477 sysCheckBox->SetDimmed(EFalse); |
|
478 opButs->SetDimmed(EFalse); |
|
479 #ifdef WINS |
|
480 opButs->SetDimmed(ETrue); |
|
481 #endif |
|
482 |
|
483 killBut->SetDimmed(EFalse); |
|
484 okBut->SetDimmed(EFalse); |
|
485 setBut->SetDimmed(EFalse); |
|
486 if (iProcessID == RProcess().Id()) |
|
487 { |
|
488 // can change the protection on this Process |
|
489 protCheckBox->SetDimmed(EFalse); |
|
490 } |
|
491 else |
|
492 { |
|
493 // cannot change protection |
|
494 protCheckBox->SetDimmed(ETrue); |
|
495 if (true) // If we are in secure then we ensure that the |
|
496 // user can not change anything. |
|
497 { |
|
498 // cannot change anything |
|
499 sysCheckBox->SetDimmed(ETrue); |
|
500 opButs->SetDimmed(ETrue); |
|
501 killBut->SetDimmed(ETrue); |
|
502 okBut->SetDimmed(ETrue); |
|
503 setBut->SetDimmed(ETrue); |
|
504 } |
|
505 } |
|
506 process.Close(); // Closes the handle |
|
507 DrawNow(); |
|
508 |
|
509 } |
|
510 |
|
511 void CProcessNumberDialog::SetProcess() |
|
512 { |
|
513 // only get here if Process is not protected |
|
514 |
|
515 |
|
516 RProcess process; |
|
517 TInt err = process.Open(iProcessID); |
|
518 |
|
519 if (err == KErrNone) |
|
520 { |
|
521 // This is the current Process |
|
522 if ( iProcessID == RProcess().Id()) |
|
523 { |
|
524 } |
|
525 |
|
526 |
|
527 |
|
528 CEikChoiceList *opButs; |
|
529 TProcessPriority processPrioritySelected = EPriorityLow; |
|
530 |
|
531 opButs = STATIC_CAST(CEikChoiceList*, Control(EProcessPriorityButtonCtl)); |
|
532 |
|
533 TInt currentItem = opButs->CurrentItem(); |
|
534 TBool validPrioritySelected = ETrue; |
|
535 |
|
536 switch (currentItem) |
|
537 { |
|
538 case (EProcessP150_PriorityLow): processPrioritySelected=EPriorityLow; break; |
|
539 case (EProcessP250_PriorityBackground): processPrioritySelected=EPriorityBackground; break; |
|
540 case (EProcessP350_PriorityForeground): processPrioritySelected=EPriorityForeground; break; |
|
541 case (EProcessP450_PriorityHigh): processPrioritySelected=EPriorityHigh; break; |
|
542 case (EProcessP650_PriorityWindowServer): |
|
543 case (EProcessP750_PriorityFileServer): |
|
544 case (EProcessP850_PriorityRealTimeServer): |
|
545 case (EProcessP950_PrioritySupervisor): |
|
546 default: iEikonEnv->InfoWinL(_L("Error"), _L("This is an internal priority and cannot be explicitly set")); |
|
547 validPrioritySelected = EFalse; |
|
548 break; |
|
549 } |
|
550 if (validPrioritySelected == 1) process.SetPriority(processPrioritySelected); |
|
551 |
|
552 } |
|
553 process.Close(); |
|
554 } |
|
555 |
|
556 void CProcessNumberDialog::HandleControlStateChangeL(TInt aControlId) |
|
557 { |
|
558 if (aControlId == EProcessGetButtonCtl) |
|
559 { |
|
560 CXIKNUMBEREDITOR *thisNumberEditor; |
|
561 thisNumberEditor = STATIC_CAST(CXIKNUMBEREDITOR*, Control(EProcessNumberCtl)); |
|
562 iProcessID = (TProcessId)thisNumberEditor->NUMBERVALUE(); |
|
563 // re-evaluate everything |
|
564 UpdateDialogData(); |
|
565 |
|
566 // re-draw |
|
567 PageChangedL(EProcessPageGeneral); |
|
568 PageChangedL(EProcessPagePriority); |
|
569 PageChangedL(EProcessPageOther); |
|
570 DrawNow(); |
|
571 } |
|
572 } |
|
573 |
|
574 TBool CProcessNumberDialog::OkToExitL(TInt aButtonId) |
|
575 { |
|
576 if (aButtonId == EEikBidCancel) // do nothing |
|
577 { |
|
578 return ETrue; |
|
579 } |
|
580 else if (aButtonId == EProcessSetButtonCtl) |
|
581 { |
|
582 SetProcess(); |
|
583 UpdateDialogData(); |
|
584 iEikonEnv->InfoMsg(_L("Attribute(s) set as displayed")); |
|
585 return EFalse; |
|
586 } |
|
587 else if (aButtonId == EProcessKillButtonCtl) |
|
588 { |
|
589 RProcess Process; |
|
590 TInt err = Process.Open(iProcessID); |
|
591 if (err == KErrNone) |
|
592 { |
|
593 iEikonEnv->InfoMsg(_L("Killing Process")); |
|
594 Process.Kill(KErrNone); |
|
595 } |
|
596 Process.Close(); |
|
597 iEikonEnv->InfoMsg(_L("Process killed")); |
|
598 return EFalse; |
|
599 } |
|
600 |
|
601 else if (aButtonId == EEikBidOk) |
|
602 { |
|
603 SetProcess(); |
|
604 return ETrue; |
|
605 } |
|
606 else return ETrue; |
|
607 } |
|
608 |
|
609 |
|
610 // |
|
611 // |
|
612 // Debug Dialog |
|
613 // |
|
614 // |
|
615 |
|
616 CDebugDialog::CDebugDialog() |
|
617 { |
|
618 } |
|
619 |
|
620 void CDebugDialog::PreLayoutDynInitL() |
|
621 { |
|
622 GetPortNumber(); |
|
623 GetKernelOptions(); |
|
624 } |
|
625 |
|
626 void CDebugDialog::GetPortNumber() |
|
627 { |
|
628 //map the control |
|
629 CXIKNUMBEREDITOR *thisNumberEditor; |
|
630 thisNumberEditor = static_cast<CXIKNUMBEREDITOR*>(Control(EDebugPortCtl)); |
|
631 //set control value |
|
632 TInt debugPort, err; |
|
633 err = HAL::Get(HAL::EDebugPort, debugPort); |
|
634 if (err == KErrNone) |
|
635 { |
|
636 thisNumberEditor->SETNUMBERVALUEL(debugPort); |
|
637 iCurrentDebugPort = debugPort; |
|
638 } |
|
639 else |
|
640 { |
|
641 thisNumberEditor->SETNUMBERVALUEL(-1); |
|
642 iCurrentDebugPort = -1; |
|
643 } |
|
644 |
|
645 } |
|
646 |
|
647 void CDebugDialog::GetKernelOptions() |
|
648 { |
|
649 // Kernel debug mask |
|
650 |
|
651 TUint32 debugMask = UserSvr::DebugMask(); |
|
652 //map the controls (check boxes) and set the control values |
|
653 |
|
654 CEikCheckBox *aCheckBox; |
|
655 |
|
656 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKHARDWARE)); |
|
657 aCheckBox->SetState(debugMask & KHARDWARE ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
658 |
|
659 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKBOOT)); |
|
660 aCheckBox->SetState(debugMask & KBOOT ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
661 |
|
662 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKSERVER)); |
|
663 aCheckBox->SetState(debugMask & KSERVER ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
664 |
|
665 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKMMU)); |
|
666 aCheckBox->SetState(debugMask & KMMU ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
667 |
|
668 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKSEMAPHORE)); |
|
669 aCheckBox->SetState(debugMask & KSEMAPHORE ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
670 |
|
671 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKSCHED)); |
|
672 aCheckBox->SetState(debugMask & KSCHED ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
673 |
|
674 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPROC)); |
|
675 aCheckBox->SetState(debugMask & KPROC ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
676 |
|
677 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKEXEC)); |
|
678 aCheckBox->SetState(debugMask & KEXEC ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
679 |
|
680 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKEXECFAST)); |
|
681 aCheckBox->SetState(debugMask & KEXECFAST ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
682 |
|
683 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKTHREAD)); |
|
684 aCheckBox->SetState(debugMask & KTHREAD ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
685 |
|
686 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKDLL)); |
|
687 aCheckBox->SetState(debugMask & KDLL ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
688 |
|
689 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKLOGON)); |
|
690 aCheckBox->SetState(debugMask & KLOGON ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
691 |
|
692 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPBUS1)); |
|
693 aCheckBox->SetState(debugMask & KPBUS1 ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
694 |
|
695 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPBUS2)); |
|
696 aCheckBox->SetState(debugMask & KPBUS2 ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
697 |
|
698 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPBUSDRV)); |
|
699 aCheckBox->SetState(debugMask & KPBUSDRV ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
700 |
|
701 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPOWER)); |
|
702 aCheckBox->SetState(debugMask & KPOWER ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
703 |
|
704 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKTIMING)); |
|
705 aCheckBox->SetState(debugMask & KTIMING ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
706 |
|
707 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKEVENT)); |
|
708 aCheckBox->SetState(debugMask & KEVENT ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
709 |
|
710 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKMEMTRACE)); |
|
711 aCheckBox->SetState(debugMask & KMEMTRACE ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
712 |
|
713 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKIPC)); |
|
714 aCheckBox->SetState(debugMask & KIPC ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
715 |
|
716 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKDEBUGGER)); |
|
717 aCheckBox->SetState(debugMask & KDEBUGGER ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
718 |
|
719 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKVIDEO)); |
|
720 aCheckBox->SetState(debugMask & KVIDEO ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
721 |
|
722 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKUSB)); |
|
723 aCheckBox->SetState(debugMask & KUSB ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
724 |
|
725 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPANIC)); |
|
726 aCheckBox->SetState(debugMask & KPANIC ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
727 } |
|
728 |
|
729 void CDebugDialog::SetDebugOptions() |
|
730 { |
|
731 TBuf<800> errorMssg; //to show where updates unsuccessful |
|
732 //set new debug port |
|
733 CXIKNUMBEREDITOR *thisNumberEditor; |
|
734 thisNumberEditor = static_cast<CXIKNUMBEREDITOR*>(Control(EDebugPortCtl)); |
|
735 TInt newDebugPort = thisNumberEditor->NUMBERVALUE(); |
|
736 |
|
737 TInt err; |
|
738 if (newDebugPort!=-1) |
|
739 { |
|
740 err = HAL::Set(HAL::EDebugPort, newDebugPort); |
|
741 if (err==KErrNone) iCurrentDebugPort = newDebugPort; |
|
742 else |
|
743 { |
|
744 TBuf<3> errorCode; |
|
745 errorCode.Format(KFormatDec,err); |
|
746 errorMssg.Append(_L("Cannot set port: System error ")); |
|
747 errorMssg.Append(errorCode); |
|
748 errorMssg.Append('\n'); |
|
749 thisNumberEditor->SETNUMBERVALUEL(iCurrentDebugPort); |
|
750 } |
|
751 } |
|
752 //set new Kernel debug values |
|
753 CEikCheckBox *aCheckBox; |
|
754 TUint32 debugMask = 0; |
|
755 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKHARDWARE)); |
|
756 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KHARDWARE; |
|
757 |
|
758 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKBOOT)); |
|
759 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KBOOT; |
|
760 |
|
761 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKSERVER)); |
|
762 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KSERVER; |
|
763 |
|
764 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKMMU)); |
|
765 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KMMU; |
|
766 |
|
767 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKSEMAPHORE)); |
|
768 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KSEMAPHORE; |
|
769 |
|
770 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKSCHED)); |
|
771 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KSCHED; |
|
772 |
|
773 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPROC)); |
|
774 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KPROC; |
|
775 |
|
776 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKEXEC)); |
|
777 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KEXEC; |
|
778 |
|
779 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKEXECFAST)); |
|
780 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KEXECFAST; |
|
781 |
|
782 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKTHREAD)); |
|
783 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KTHREAD; |
|
784 |
|
785 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKDLL)); |
|
786 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KDLL; |
|
787 |
|
788 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKLOGON)); |
|
789 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KLOGON; |
|
790 |
|
791 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPBUS1)); |
|
792 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KPBUS1; |
|
793 |
|
794 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPBUS2)); |
|
795 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KPBUS2; |
|
796 |
|
797 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPBUSDRV)); |
|
798 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KPBUSDRV; |
|
799 |
|
800 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPOWER)); |
|
801 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KPOWER; |
|
802 |
|
803 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKTIMING)); |
|
804 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KTIMING; |
|
805 |
|
806 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKEVENT)); |
|
807 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KEVENT; |
|
808 |
|
809 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKMEMTRACE)); |
|
810 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KMEMTRACE; |
|
811 |
|
812 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKIPC)); |
|
813 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KIPC; |
|
814 |
|
815 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKDEBUGGER)); |
|
816 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KDEBUGGER; |
|
817 |
|
818 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKVIDEO)); |
|
819 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KVIDEO; |
|
820 |
|
821 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKUSB)); |
|
822 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KUSB; |
|
823 |
|
824 aCheckBox = static_cast<CEikCheckBox*>(Control(EDebugKernelKPANIC)); |
|
825 if (aCheckBox->State()==CEikButtonBase::ESet) debugMask|=KPANIC; |
|
826 |
|
827 User::SetDebugMask(debugMask); |
|
828 TUint32 updatedDebugMask = UserSvr::DebugMask(); |
|
829 if (debugMask != updatedDebugMask) |
|
830 { |
|
831 errorMssg.Append(_L("Unable to set kernel options selected. Note that KPanic must be selected if any other options are selected. View the \nupdated dialog to see which Kernel options are set")); |
|
832 GetKernelOptions(); |
|
833 } |
|
834 |
|
835 |
|
836 CEikCheckBox *thisCheckBox, *thisCheckBox2, *thisCheckBox3; |
|
837 thisCheckBox = static_cast<CEikCheckBox*>(Control(EDebugFileServerCtl)); |
|
838 thisCheckBox2 = static_cast<CEikCheckBox*>(Control(EDebugFATCtl)); |
|
839 thisCheckBox3 = static_cast<CEikCheckBox*>(Control(EDebugLoaderCtl)); |
|
840 |
|
841 TInt fsDebugMask = 0; |
|
842 if (thisCheckBox->State()==CEikButtonBase::ESet) fsDebugMask|=KFSERV; |
|
843 if (thisCheckBox2->State()==CEikButtonBase::ESet) fsDebugMask|=KFSYS; |
|
844 if (thisCheckBox3->State()==CEikButtonBase::ESet) fsDebugMask|=KFLDR; |
|
845 |
|
846 RFs aRFs; |
|
847 err = aRFs.Connect(); |
|
848 if (err == KErrNone) |
|
849 { |
|
850 err = aRFs.SetDebugRegister(fsDebugMask); |
|
851 if (err != KErrNone) |
|
852 errorMssg.Append(_L("Unable to set FS options: RFs::SetDebugRegister() fails with System error number ")); |
|
853 TBuf<3> errorCode; |
|
854 errorCode.Format(KFormatDec, err); |
|
855 errorMssg.Append(errorCode); |
|
856 } |
|
857 else |
|
858 { |
|
859 errorMssg.Append(_L("\nRFs::Connect() fails with System error number ")); |
|
860 TBuf<3> errorCode; |
|
861 errorCode.Format(KFormatDec, err); |
|
862 errorMssg.Append(errorCode); |
|
863 thisCheckBox->SetState(CEikButtonBase::EClear); |
|
864 thisCheckBox2->SetState(CEikButtonBase::EClear); |
|
865 thisCheckBox3->SetState(CEikButtonBase::EClear); |
|
866 } |
|
867 aRFs.Close(); |
|
868 |
|
869 if (errorMssg.Length() != 0) |
|
870 { |
|
871 _LIT(KDialogTitle, "Error"); |
|
872 iEikonEnv->InfoWinL(KDialogTitle, errorMssg); |
|
873 } |
|
874 } |
|
875 |
|
876 TBool CDebugDialog::OkToExitL(TInt aButtonId) |
|
877 { |
|
878 if (aButtonId == EDebugSetButtonCtl) |
|
879 { |
|
880 SetDebugOptions(); |
|
881 DrawNow(); |
|
882 return EFalse; |
|
883 } |
|
884 if (aButtonId == EEikBidOk) |
|
885 { |
|
886 SetDebugOptions(); |
|
887 } |
|
888 else if (aButtonId == EEikBidCancel) |
|
889 { |
|
890 // Do Nothing |
|
891 } |
|
892 return ETrue; |
|
893 } |
|
894 |
|
895 // |
|
896 // |
|
897 // Ram Dialog |
|
898 // |
|
899 // |
|
900 |
|
901 CRamDialog::CRamDialog() |
|
902 { |
|
903 noChunks = 0; |
|
904 } |
|
905 |
|
906 void CRamDialog::PreLayoutDynInitL() |
|
907 { |
|
908 UpdateDialogData(); |
|
909 } |
|
910 |
|
911 void CRamDialog::UpdateDialogData() |
|
912 { |
|
913 CEikLabel *theTotalLabel, *theFreeLabel; |
|
914 theTotalLabel = STATIC_CAST(CEikLabel*, Control(ERamTotal)); |
|
915 theFreeLabel = STATIC_CAST(CEikLabel*, Control(ERamFree)); |
|
916 |
|
917 TMemoryInfoV1Buf memorybuf; |
|
918 UserHal::MemoryInfo(memorybuf); |
|
919 TInt total=memorybuf().iTotalRamInBytes; |
|
920 TInt free=memorybuf().iFreeRamInBytes; |
|
921 |
|
922 TBuf<40> totalTxt; |
|
923 totalTxt.Format(_L("Total RAM (bytes) %d"),total); |
|
924 TBuf<40> freeTxt; |
|
925 freeTxt.Format(_L("Free RAM (bytes) %d"),free); |
|
926 |
|
927 theTotalLabel->SetTextL(totalTxt); |
|
928 theFreeLabel->SetTextL(freeTxt); |
|
929 |
|
930 CXIKOPTIONBUTTONLIST *fillSpaceOpButs; |
|
931 fillSpaceOpButs = STATIC_CAST(CXIKOPTIONBUTTONLIST*, Control(ERamToLeaveButtonCtl)); |
|
932 |
|
933 // All buttons invisible |
|
934 fillSpaceOpButs->ComponentControl(0)->MakeVisible(ETrue); |
|
935 fillSpaceOpButs->ComponentControl(1)->MakeVisible(ETrue); |
|
936 fillSpaceOpButs->ComponentControl(2)->MakeVisible(ETrue); |
|
937 fillSpaceOpButs->ComponentControl(3)->MakeVisible(ETrue); |
|
938 fillSpaceOpButs->ComponentControl(4)->MakeVisible(ETrue); |
|
939 |
|
940 if (free<K4k) |
|
941 { |
|
942 // All buttons visible |
|
943 fillSpaceOpButs->ComponentControl(0)->MakeVisible(EFalse); |
|
944 fillSpaceOpButs->ComponentControl(1)->MakeVisible(EFalse); |
|
945 fillSpaceOpButs->ComponentControl(2)->MakeVisible(EFalse); |
|
946 fillSpaceOpButs->ComponentControl(3)->MakeVisible(EFalse); |
|
947 fillSpaceOpButs->ComponentControl(4)->MakeVisible(EFalse); |
|
948 } |
|
949 else if (free>=K4k && free<K8k) |
|
950 { |
|
951 fillSpaceOpButs->ComponentControl(1)->MakeVisible(EFalse); |
|
952 fillSpaceOpButs->ComponentControl(2)->MakeVisible(EFalse); |
|
953 fillSpaceOpButs->ComponentControl(3)->MakeVisible(EFalse); |
|
954 fillSpaceOpButs->ComponentControl(4)->MakeVisible(EFalse); |
|
955 fillSpaceOpButs->SetButtonById(ERamLeave4K); |
|
956 } |
|
957 else if (free>=K8k && free<K16k) |
|
958 { |
|
959 fillSpaceOpButs->ComponentControl(2)->MakeVisible(EFalse); |
|
960 fillSpaceOpButs->ComponentControl(3)->MakeVisible(EFalse); |
|
961 fillSpaceOpButs->ComponentControl(4)->MakeVisible(EFalse); |
|
962 fillSpaceOpButs->SetButtonById(ERamLeave8K); |
|
963 } |
|
964 else if (free>=K16k && free<K64k) |
|
965 { |
|
966 fillSpaceOpButs->ComponentControl(3)->MakeVisible(EFalse); |
|
967 fillSpaceOpButs->ComponentControl(4)->MakeVisible(EFalse); |
|
968 fillSpaceOpButs->SetButtonById(ERamLeave16K); |
|
969 } |
|
970 else if (free>= K64k && free<K256k) |
|
971 { |
|
972 fillSpaceOpButs->ComponentControl(4)->MakeVisible(EFalse); |
|
973 fillSpaceOpButs->SetButtonById(ERamLeave64K); |
|
974 } |
|
975 else |
|
976 { |
|
977 fillSpaceOpButs->SetButtonById(ERamLeave256K); |
|
978 } |
|
979 } |
|
980 |
|
981 void CRamDialog::UndoFillRam() |
|
982 { |
|
983 if (noChunks == 0) iEikonEnv->InfoMsg(_L("Undo fill invalid")); |
|
984 else |
|
985 { |
|
986 while (noChunks>0) |
|
987 { |
|
988 chunks[--noChunks].Close(); |
|
989 } |
|
990 } |
|
991 } |
|
992 void CRamDialog::FillRam() |
|
993 { |
|
994 iEikonEnv->BusyMsgL(_L("Filling RAM")); |
|
995 |
|
996 CXIKOPTIONBUTTONLIST *opButs; |
|
997 opButs = STATIC_CAST(CXIKOPTIONBUTTONLIST*, Control(ERamToLeaveButtonCtl)); |
|
998 |
|
999 TUint ramToLeave=K4k; |
|
1000 if (opButs->LabeledButtonId()==ERamLeave4K) ramToLeave=K4k; |
|
1001 else if (opButs->LabeledButtonId()==ERamLeave8K) ramToLeave=K8k; |
|
1002 else if (opButs->LabeledButtonId()==ERamLeave16K) ramToLeave=K16k; |
|
1003 else if (opButs->LabeledButtonId()==ERamLeave64K) ramToLeave=K64k; |
|
1004 else if (opButs->LabeledButtonId()==ERamLeave256K) ramToLeave=K256k; |
|
1005 |
|
1006 |
|
1007 TUint chunkSize; |
|
1008 TInt err = KErrNone; |
|
1009 TBuf<20> aName; |
|
1010 TTime time; |
|
1011 |
|
1012 TMemoryInfoV1Buf memorybuf; |
|
1013 UserHal::MemoryInfo(memorybuf); |
|
1014 |
|
1015 // Fill the RAM up with various chunks |
|
1016 for (chunkSize = K8M; chunkSize>=ramToLeave; chunkSize>>=1) |
|
1017 { |
|
1018 TUint KMaxChunks = 10000; |
|
1019 for (err=KErrNone; err==KErrNone && noChunks<KMaxChunks;) |
|
1020 { |
|
1021 // create a unique chunk name |
|
1022 time.UniversalTime(); |
|
1023 aName.Format(_L("%S%02d-%08x"),&KFillName, noChunks,*(reinterpret_cast<const TInt32*>(&(time.Int64())))); |
|
1024 |
|
1025 err = chunks[noChunks].CreateGlobal(aName, chunkSize, chunkSize); |
|
1026 // ensure RAM is committed by filling it |
|
1027 if (err==KErrNone) |
|
1028 { |
|
1029 Mem::Fill(chunks[noChunks++].Base(),chunkSize,'A'); |
|
1030 } |
|
1031 User::CompressAllHeaps(); |
|
1032 } ; |
|
1033 } |
|
1034 iEikonEnv->BusyMsgCancel(); |
|
1035 if (err == KErrNone) iEikonEnv->InfoMsg(_L("Fill Complete")); |
|
1036 } |
|
1037 |
|
1038 TBool CRamDialog::OkToExitL(TInt aButtonId) |
|
1039 { |
|
1040 if (aButtonId == EEikBidCancel) |
|
1041 { |
|
1042 return ETrue; |
|
1043 } |
|
1044 else if (aButtonId == ERamSetButtonCtl) |
|
1045 { |
|
1046 FillRam(); |
|
1047 UpdateDialogData(); |
|
1048 DrawNow(); |
|
1049 return EFalse; |
|
1050 } |
|
1051 else if (aButtonId == ERamUndoFillButtonCtl) |
|
1052 { |
|
1053 UndoFillRam(); |
|
1054 UpdateDialogData(); |
|
1055 DrawNow(); |
|
1056 return EFalse; |
|
1057 } |
|
1058 return ETrue; |
|
1059 } |
|
1060 |
|
1061 // |
|
1062 // |
|
1063 // Drive Dialog |
|
1064 // |
|
1065 // |
|
1066 |
|
1067 CDriveDialog::CDriveDialog() : iDriveName(NULL), iDriveLetter(NULL) |
|
1068 { |
|
1069 } |
|
1070 |
|
1071 CDriveDialog::~CDriveDialog() |
|
1072 { |
|
1073 delete iDriveLetter; |
|
1074 delete iDriveName; |
|
1075 } |
|
1076 |
|
1077 void CDriveDialog::PreLayoutDynInitL() |
|
1078 { |
|
1079 iDriveName = new (ELeave) CDesCArrayFlat(KMaxLocalDrives); |
|
1080 iDriveLetter = new CArrayFixFlat<TInt>(KMaxLocalDrives); |
|
1081 |
|
1082 TBuf<40> string; // displayed in choice box |
|
1083 RFs rfs; |
|
1084 User::LeaveIfError(rfs.Connect()); |
|
1085 TDriveInfo driveInfo; |
|
1086 TVolumeInfo volumeInfo; |
|
1087 TDriveUnit driveUnit(EDriveA); |
|
1088 TInt err1,err2,drive=0,number=0; |
|
1089 |
|
1090 do { |
|
1091 |
|
1092 driveUnit = drive; |
|
1093 err1 = rfs.Volume(volumeInfo,driveUnit); |
|
1094 err2 = rfs.Drive(driveInfo, driveUnit); |
|
1095 if (err1==KErrNone && err2==KErrNone) |
|
1096 { |
|
1097 |
|
1098 // Only interested if not ROM and local |
|
1099 |
|
1100 if (volumeInfo.iDrive.iType != EMediaRom && |
|
1101 (volumeInfo.iDrive.iDriveAtt | KDriveAttLocal)) |
|
1102 { |
|
1103 number++; |
|
1104 |
|
1105 string.Delete(0,string.MaxLength()); |
|
1106 |
|
1107 string=driveUnit.Name(); |
|
1108 |
|
1109 string.Append(_L(" ")); |
|
1110 string.Append(volumeInfo.iName); |
|
1111 |
|
1112 iDriveName->AppendL(string); |
|
1113 iDriveLetter->AppendL(drive); |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 drive++; |
|
1118 |
|
1119 } while (drive <= EDriveZ && number < KMaxLocalDrives); |
|
1120 |
|
1121 rfs.Close(); |
|
1122 |
|
1123 CEikChoiceList *driveChoice; |
|
1124 driveChoice = STATIC_CAST(CEikChoiceList*, Control(EDriveChoiceList)); |
|
1125 driveChoice->SetArrayL(iDriveName); |
|
1126 driveChoice->SetArrayExternalOwnership(ETrue); |
|
1127 |
|
1128 |
|
1129 CXIKOPTIONBUTTONLIST *fillSpaceOpButs; |
|
1130 fillSpaceOpButs = STATIC_CAST(CXIKOPTIONBUTTONLIST*, Control(EDriveToLeaveButtonCtl)); |
|
1131 fillSpaceOpButs->SetButtonById(EDriveLeave256K); |
|
1132 } |
|
1133 |
|
1134 |
|
1135 void UpdateDialogLeaveSpace() |
|
1136 { |
|
1137 } |
|
1138 |
|
1139 TBool CDriveDialog::OkToExitL(TInt aButtonId) |
|
1140 { |
|
1141 if (aButtonId == EEikBidCancel) |
|
1142 { |
|
1143 delete iDriveName; |
|
1144 delete iDriveLetter; |
|
1145 return ETrue; |
|
1146 } |
|
1147 else |
|
1148 { |
|
1149 CEikChoiceList *driveChoice; |
|
1150 driveChoice = STATIC_CAST(CEikChoiceList*, Control(EDriveChoiceList)); |
|
1151 TInt choice = driveChoice->CurrentItem(); |
|
1152 TDriveUnit driveUnit; |
|
1153 driveUnit = (*iDriveLetter)[choice]; |
|
1154 |
|
1155 RFs aRfs; |
|
1156 User::LeaveIfError(aRfs.Connect()); |
|
1157 |
|
1158 CXIKOPTIONBUTTONLIST *fillSpaceOpButs; |
|
1159 fillSpaceOpButs = STATIC_CAST(CXIKOPTIONBUTTONLIST*, Control(EDriveToLeaveButtonCtl)); |
|
1160 |
|
1161 if (aButtonId==EDriveFillButtonCtl) |
|
1162 { |
|
1163 iEikonEnv->BusyMsgL(_L("Filling Drive")); |
|
1164 // need a unique file name |
|
1165 TInt i=0,err = KErrNone; |
|
1166 TFileName fileName; |
|
1167 TTime time; |
|
1168 |
|
1169 TInt fileSize; |
|
1170 |
|
1171 CXIKOPTIONBUTTONLIST *fillSpaceOpButs; |
|
1172 fillSpaceOpButs = STATIC_CAST(CXIKOPTIONBUTTONLIST*, Control(EDriveToLeaveButtonCtl)); |
|
1173 |
|
1174 TInt spaceToLeave=K4k; |
|
1175 if (fillSpaceOpButs->LabeledButtonId()==EDriveLeave4K) spaceToLeave=K4k; |
|
1176 else if (fillSpaceOpButs->LabeledButtonId()==EDriveLeave8K) spaceToLeave=K8k; |
|
1177 else if (fillSpaceOpButs->LabeledButtonId()==EDriveLeave16K) spaceToLeave=K16k; |
|
1178 else if (fillSpaceOpButs->LabeledButtonId()==EDriveLeave64K) spaceToLeave=K64k; |
|
1179 else if (fillSpaceOpButs->LabeledButtonId()==EDriveLeave256K) spaceToLeave=K256k; |
|
1180 |
|
1181 for (fileSize = K1M; fileSize>=spaceToLeave; fileSize>>=1) |
|
1182 { |
|
1183 |
|
1184 do { |
|
1185 time.UniversalTime(); |
|
1186 TDriveName driveName = driveUnit.Name(); |
|
1187 fileName.Format(_L("%S\\%S%06d-%08x"),&driveName,&KFillName,++i,*(reinterpret_cast<const TInt32*>(&(time.Int64())))); |
|
1188 |
|
1189 // create a file of this file size |
|
1190 RFile file; |
|
1191 err=file.Create(aRfs, fileName, EFileRead|EFileWrite); |
|
1192 if (err!=KErrNone) |
|
1193 { |
|
1194 TBuf<70> errorMessage(_L("Cannot complete fill. RFile::Create() failed with error no. ")); |
|
1195 errorMessage.AppendNum(err); |
|
1196 iEikonEnv->InfoWinL(_L("Error"), errorMessage); |
|
1197 } |
|
1198 |
|
1199 // fill file up to fileSize |
|
1200 if (err==KErrNone) |
|
1201 { |
|
1202 const TInt MaxBufSize=512; |
|
1203 TBuf8<MaxBufSize> buf; |
|
1204 buf.SetLength(MaxBufSize); |
|
1205 Mem::Fill((void*)buf.Ptr(),MaxBufSize,0xef); |
|
1206 TInt rem=fileSize; |
|
1207 while(rem) |
|
1208 { |
|
1209 TInt s=Min(MaxBufSize,rem); |
|
1210 err=file.Write(buf,s); |
|
1211 if (err!=KErrNone) break; |
|
1212 rem-=s; |
|
1213 } |
|
1214 } |
|
1215 |
|
1216 file.Close(); |
|
1217 if(err!=KErrNone) aRfs.Delete(fileName); |
|
1218 } while (err==KErrNone && i<100); |
|
1219 } |
|
1220 iEikonEnv->BusyMsgCancel(); |
|
1221 iEikonEnv->InfoMsg(_L("Drive filled")); |
|
1222 } |
|
1223 else if (aButtonId==EDriveUndoFillButtonCtl) |
|
1224 { |
|
1225 iEikonEnv->BusyMsgL(_L("Undo Drive Fill")); |
|
1226 TFindFile fileFinder(aRfs); |
|
1227 CDir* fileList; |
|
1228 |
|
1229 TBuf<10> name; |
|
1230 name=KFillName; |
|
1231 name.Append(KAsterisk); |
|
1232 |
|
1233 TBuf<3> driveName; |
|
1234 driveName=driveUnit.Name(); |
|
1235 driveName.Append(_L("\\")); |
|
1236 |
|
1237 TInt findErr = fileFinder.FindWildByPath(name,&driveName,fileList); |
|
1238 TInt deleteErr = KErrNone; |
|
1239 |
|
1240 if (findErr == KErrNone) |
|
1241 { |
|
1242 for (TInt i=0;i<fileList->Count();++i) |
|
1243 { |
|
1244 TBuf<100> filePath(driveName); |
|
1245 filePath.Append((*fileList)[i].iName); |
|
1246 |
|
1247 deleteErr = aRfs.Delete(filePath); |
|
1248 } |
|
1249 } |
|
1250 iEikonEnv->BusyMsgCancel(); |
|
1251 |
|
1252 if (deleteErr !=KErrNone) |
|
1253 { |
|
1254 TBufC<15> function(_L("RFs::Delete()")); |
|
1255 DisplayError(function, deleteErr); |
|
1256 } |
|
1257 if (findErr == KErrNone && deleteErr == KErrNone) |
|
1258 { |
|
1259 fillSpaceOpButs->ComponentControl(0)->MakeVisible(ETrue); |
|
1260 fillSpaceOpButs->ComponentControl(1)->MakeVisible(ETrue); |
|
1261 fillSpaceOpButs->ComponentControl(2)->MakeVisible(ETrue); |
|
1262 fillSpaceOpButs->ComponentControl(3)->MakeVisible(ETrue); |
|
1263 fillSpaceOpButs->ComponentControl(4)->MakeVisible(ETrue); |
|
1264 iEikonEnv->InfoMsg(_L("Undo Fill Complete")); |
|
1265 } |
|
1266 |
|
1267 else iEikonEnv->InfoMsg(_L("Undo Fill Invalid")); |
|
1268 delete fileList; |
|
1269 } |
|
1270 else if (aButtonId==EDriveFormatButtonCtl) |
|
1271 { |
|
1272 TInt count; |
|
1273 RFormat format; |
|
1274 TInt err=format.Open(aRfs,driveUnit.Name(),EHighDensity,count); |
|
1275 if (err==KErrNone) |
|
1276 { |
|
1277 iEikonEnv->BusyMsgL(_L("Formatting Drive")); |
|
1278 while (count && err==KErrNone) |
|
1279 { |
|
1280 err = format.Next(count); |
|
1281 if (err != KErrNone) |
|
1282 { |
|
1283 TBufC<15> function(_L("RFormat::Next()")); |
|
1284 DisplayError(function, err); |
|
1285 } |
|
1286 } |
|
1287 iEikonEnv->BusyMsgCancel(); |
|
1288 } |
|
1289 else |
|
1290 { |
|
1291 TBuf<70> errorMessage(_L("RFormat::Open() failed with system error no.")); |
|
1292 errorMessage.AppendNum(err); |
|
1293 iEikonEnv->InfoWinL(_L("Error"), errorMessage); |
|
1294 } |
|
1295 format.Close(); |
|
1296 } |
|
1297 |
|
1298 aRfs.Close(); |
|
1299 } |
|
1300 return EFalse; |
|
1301 } |
|
1302 |
|
1303 CDialogBase::CDialogBase() |
|
1304 { |
|
1305 } |
|
1306 |
|
1307 void CDialogBase::DisplayError(TDesC& aMessage, TInt aErrorNumber) |
|
1308 { |
|
1309 //could check doesn't go out of bounds |
|
1310 TBuf<250> errorMssge(aMessage); |
|
1311 errorMssge.Append(_L(" fails with system error no. ")); |
|
1312 TBuf<3> errorNum; |
|
1313 _LIT(KFormatDec, "%d"); |
|
1314 errorNum.Format(KFormatDec, aErrorNumber); |
|
1315 errorMssge.Append(errorNum); |
|
1316 iEikonEnv->InfoWinL(_L("Error"), errorMssge); |
|
1317 } |
|
1318 |
|
1319 void CDialogBase::DisplayError(TDesC& aMessage) |
|
1320 { |
|
1321 //could check don't go out of bounds |
|
1322 TBuf<250> errorMssge(aMessage); |
|
1323 iEikonEnv->InfoWinL(_L("Error"), errorMssge); |
|
1324 } |
|
1325 |
|