1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <e32cons.h> |
|
23 #include <e32svr.h> |
|
24 #include <f32file.h> |
|
25 |
|
26 #include "atconsoleui.h" |
|
27 #include "atconsoleviews.h" |
|
28 |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KNameTxt, "AT CONSOLE UI" ); |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 LOCAL_C void MainL(); |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CConsoleMain::NewL() |
|
38 // Construct the console main class. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CConsoleMain* CConsoleMain::NewL( ) |
|
42 { |
|
43 CConsoleMain* self = new ( ELeave ) CConsoleMain(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CConsoleMain::ConstructL() |
|
52 // Second level constructor. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CConsoleMain::ConstructL( ) |
|
56 { |
|
57 // Construct the console |
|
58 iConsole = Console::NewL( KNameTxt, |
|
59 TSize( KConsFullScreen, KConsFullScreen ) ); |
|
60 |
|
61 iStorageServerOpen = EFalse; |
|
62 |
|
63 iConsole->Printf(_L("\nAnalyzeTool console starting\n")); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CConsoleMain::CConsoleMain() |
|
68 // C++ default constructor. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CConsoleMain::CConsoleMain() |
|
72 { |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CConsoleMain::~CConsoleMain() |
|
77 // Destructor. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CConsoleMain::~CConsoleMain() |
|
81 { |
|
82 // Close storage server |
|
83 iStorageServer.Close(); |
|
84 |
|
85 delete iReader; |
|
86 iReader = NULL; |
|
87 |
|
88 delete iScroller; |
|
89 iScroller = NULL; |
|
90 |
|
91 delete iConsole; |
|
92 iConsole = NULL; |
|
93 |
|
94 delete iMainView; |
|
95 iMainView = NULL; |
|
96 |
|
97 iSubTestProcesses.Close(); |
|
98 |
|
99 iProcesses.Close(); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CConsoleMain::StartL() |
|
104 // Construct menu objects and start the menu handling. |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 TInt CConsoleMain::StartL() |
|
108 { |
|
109 // Construct keystroke reader |
|
110 iReader = CConsoleReader::NewL( this, iConsole ); |
|
111 // Construct the main menu |
|
112 iMainView = CMainView::NewL( this, NULL, _L( "Processes view" ) ); |
|
113 // Connect to the storage server |
|
114 TInt error = iStorageServer.Connect(); |
|
115 if( error != KErrNone ) |
|
116 { |
|
117 // Notify if error occurs |
|
118 } |
|
119 else |
|
120 { |
|
121 iStorageServerOpen = ETrue; |
|
122 iStorageServer.GetProcessesL( iProcesses ); |
|
123 } |
|
124 |
|
125 // TEST |
|
126 /*TATProcessInfo pr1; |
|
127 pr1.iProcessId = 1; |
|
128 TBuf8<KMaxProcessName> pr1Name; |
|
129 pr1Name.Copy( _L("MemoryLeaker.exe") ); |
|
130 pr1.iProcessName.Copy( pr1Name ); |
|
131 pr1.iStartTime = 1234556789; |
|
132 iProcesses.Append( pr1 ); |
|
133 |
|
134 TATProcessInfo pr2; |
|
135 pr2.iProcessId = 2; |
|
136 TBuf8<KMaxProcessName> pr2Name; |
|
137 pr2Name.Copy( _L("ConsoleApplication.exe") ); |
|
138 pr2.iProcessName.Copy( pr2Name ); |
|
139 pr2.iStartTime = 12345567559; |
|
140 iProcesses.Append( pr2 ); |
|
141 |
|
142 TATProcessInfo pr3; |
|
143 pr3.iProcessId = 3; |
|
144 TBuf8<KMaxProcessName> pr3Name; |
|
145 pr3Name.Copy( _L("Player.exe") ); |
|
146 pr3.iProcessName.Copy( pr3Name ); |
|
147 pr3.iStartTime = 1234577789; |
|
148 iProcesses.Append( pr3 );*/ |
|
149 // TEST END |
|
150 |
|
151 if ( iProcesses.Count() > KErrNone ) |
|
152 { |
|
153 CView* processMenu = NULL; |
|
154 for ( TInt count = 0 ; count < iProcesses.Count() ; count++ ) |
|
155 { |
|
156 TBuf<KMaxProcessName> processName; |
|
157 processName.Copy( iProcesses[ count ].iProcessName ); |
|
158 TInt64 processId = iProcesses[ count ].iProcessId; |
|
159 // Create and add menu |
|
160 processMenu = CProcessInfoView::NewL( this, iMainView, processName, processId ); |
|
161 iMainView->AddItemL( processMenu ); |
|
162 } |
|
163 } |
|
164 |
|
165 iScroller = CScrollerTimer::NewL ( this ); |
|
166 iScroller->StartL(); |
|
167 // Print the main menu |
|
168 iCurrentView = iMainView; |
|
169 iCurrentView->PrintViewL( CView::EViewPrint ); |
|
170 // Start to process keyboard events |
|
171 iReader->StartL(); |
|
172 |
|
173 return KErrNone; |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CConsoleMain::Processes() |
|
178 // Returns processes. |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 RArray<TATProcessInfo> CConsoleMain::Processes() |
|
182 { |
|
183 return iProcesses; |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CConsoleMain::KeyPressedL() |
|
188 // Process keyboard events. Print new menu. |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CConsoleMain::KeyPressedL() |
|
192 { |
|
193 TBool cont = ETrue; |
|
194 // Read the key |
|
195 TKeyCode key = iConsole->KeyCode(); |
|
196 CView* tmp = iCurrentView; |
|
197 // Update the screen |
|
198 TimerUpdate(); |
|
199 |
|
200 // Let the menu handle the key press |
|
201 TRAPD( err, |
|
202 iCurrentView = iCurrentView->SelectL( key, cont ); |
|
203 ); |
|
204 |
|
205 if( err != KErrNone ) |
|
206 { |
|
207 User::InfoPrint( |
|
208 _L( "Processing keystroke failed" ) ); |
|
209 } |
|
210 |
|
211 if ( iCurrentView == NULL ) |
|
212 { |
|
213 iCurrentView = tmp; |
|
214 } |
|
215 |
|
216 // If "not-exit" key pressed, continue |
|
217 if ( cont ) |
|
218 { |
|
219 // Either only update old menu or new menu. |
|
220 if ( tmp == iCurrentView ) |
|
221 { |
|
222 TRAP( err, iCurrentView->PrintViewL( CView::EViewRefresh ); ); |
|
223 } |
|
224 else |
|
225 { |
|
226 TRAP( err, iCurrentView->PrintViewL( CView::EViewPrint ); ) |
|
227 } |
|
228 if( err != KErrNone ) |
|
229 { |
|
230 User::InfoPrint( |
|
231 _L( "Printing view failed" ) ); |
|
232 } |
|
233 // Enable keystrokes |
|
234 iReader->StartL(); |
|
235 } |
|
236 else |
|
237 { |
|
238 // Stop all subtests before closing handles |
|
239 StopAllSubtestsL(); |
|
240 // "Exit", stop scheduler and exit |
|
241 CActiveScheduler::Stop(); |
|
242 } |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------------------------- |
|
246 // CConsoleMain::StopAllSubtestsL() |
|
247 // Stops all subtests which are running |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 void CConsoleMain::StopAllSubtestsL() |
|
251 { |
|
252 TInt index( KErrNone ); |
|
253 RArray<TATProcessInfo> processes; |
|
254 iStorageServer.GetProcessesL( processes ); |
|
255 while ( index < processes.Count() ) |
|
256 { |
|
257 TUint processId = processes[ index ].iProcessId; |
|
258 _LIT8( KSubTestId, "ATConsoleUiSubTest" ); |
|
259 TInt stopErr = iStorageServer.StopSubTest( processId, KSubTestId ); |
|
260 TInt find = iSubTestProcesses.Find( processId ); |
|
261 |
|
262 if ( find > KErrNotFound ) |
|
263 { |
|
264 iSubTestProcesses.Remove( find ); |
|
265 if ( iSubTestProcesses.Count() == KErrNone ) |
|
266 { |
|
267 iSubTestProcesses.Reset(); |
|
268 } |
|
269 } |
|
270 |
|
271 index++; |
|
272 } |
|
273 processes.Close(); |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CConsoleMain::Close() |
|
278 // Close instance. |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CConsoleMain::Close( TInt aHandle ) |
|
282 { |
|
283 if( aHandle < 0 ) |
|
284 { |
|
285 return; |
|
286 } |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // CConsoleMain::GetConsole() |
|
291 // Returns the console. |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 CConsoleBase* CConsoleMain::GetConsole() |
|
295 { |
|
296 return iConsole; |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CConsoleMain::TimerUpdate() |
|
301 // Updates current menu from timer. |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void CConsoleMain::TimerUpdate() |
|
305 { |
|
306 // Update processes |
|
307 if ( iCurrentView->Name().Compare( _L( "Processes view" ) ) == KErrNone ) |
|
308 { |
|
309 UpdateProcessesL(); |
|
310 iCurrentView->ResetItems(); |
|
311 if ( iProcesses.Count() > KErrNone ) |
|
312 { |
|
313 CView* processMenu = NULL; |
|
314 for ( TInt count = 0 ; count < iProcesses.Count() ; count++ ) |
|
315 { |
|
316 TBuf<KMaxProcessName> processName; |
|
317 processName.Copy( iProcesses[ count ].iProcessName ); |
|
318 TInt64 processId = iProcesses[ count ].iProcessId; |
|
319 // Create and add menu |
|
320 processMenu = CProcessInfoView::NewL( this, iMainView, processName, processId ); |
|
321 iMainView->AddItemL( processMenu ); |
|
322 } |
|
323 } |
|
324 } |
|
325 iCurrentView->TimerUpdate(); |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CConsoleMain::UpdateProcessesL() |
|
330 // Updates processes. |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 void CConsoleMain::UpdateProcessesL() |
|
334 { |
|
335 if ( iStorageServerOpen ) |
|
336 { |
|
337 iStorageServer.GetProcessesL( iProcesses ); |
|
338 } |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CConsoleMain::SetProcessSubTestStart() |
|
343 // Starts subtest for a process. |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CConsoleMain::SetProcessSubTestStart( TUint aProcessId ) |
|
347 { |
|
348 // load the kernel side device driver |
|
349 TInt loadErr = User::LoadLogicalDevice( KAnalyzeToolLddName ); |
|
350 TBool driverLoaded( EFalse ); |
|
351 |
|
352 if ( loadErr == KErrNone || loadErr == KErrAlreadyExists ) |
|
353 { |
|
354 driverLoaded = ETrue; |
|
355 } |
|
356 |
|
357 RAnalyzeTool analyzeTool; |
|
358 |
|
359 TInt driverOpen = analyzeTool.Open(); |
|
360 TInt handleCount( KErrNone ); |
|
361 |
|
362 if ( driverOpen == KErrNone ) |
|
363 { |
|
364 TATProcessHandlesBuf params; |
|
365 params().iProcessId = aProcessId; |
|
366 |
|
367 analyzeTool.GetCurrentHandleCount( params ); |
|
368 handleCount = params().iCurrentHandleCount; |
|
369 } |
|
370 |
|
371 _LIT8( KSubTestId, "ATConsoleUiSubTest" ); |
|
372 TInt startErr = iStorageServer.StartSubTest( aProcessId, KSubTestId, handleCount ); |
|
373 if ( KErrNone == startErr ) |
|
374 { |
|
375 iSubTestProcesses.Append( aProcessId ); |
|
376 } |
|
377 |
|
378 // The count of device driver users |
|
379 TClientCountBuf count; |
|
380 |
|
381 // Check the flag |
|
382 if ( driverOpen == KErrNone ) |
|
383 { |
|
384 analyzeTool.ClientCount( count ); |
|
385 analyzeTool.Close(); |
|
386 } |
|
387 // Check the flag |
|
388 if ( driverLoaded ) |
|
389 { |
|
390 // Check if there is another user for device driver |
|
391 if ( count().iClientCount <= 1 ) |
|
392 { |
|
393 // There was no other users -> unload the device driver |
|
394 User::FreeLogicalDevice( KAnalyzeToolLddName ); |
|
395 } |
|
396 } |
|
397 } |
|
398 |
|
399 // ----------------------------------------------------------------------------- |
|
400 // CConsoleMain::SetProcessSubTestStop() |
|
401 // Stops subtest for a process. |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 void CConsoleMain::SetProcessSubTestStop( TUint aProcessId ) |
|
405 { |
|
406 // Load the kernel side device driver |
|
407 TInt loadErr = User::LoadLogicalDevice( KAnalyzeToolLddName ); |
|
408 TBool driverLoaded( EFalse ); |
|
409 |
|
410 if ( loadErr == KErrNone || loadErr == KErrAlreadyExists ) |
|
411 { |
|
412 driverLoaded = ETrue; |
|
413 } |
|
414 |
|
415 RAnalyzeTool analyzeTool; |
|
416 |
|
417 TInt driverOpen = analyzeTool.Open(); |
|
418 TInt handleCount( KErrNone ); |
|
419 |
|
420 if ( driverOpen == KErrNone ) |
|
421 { |
|
422 TATProcessHandlesBuf params; |
|
423 params().iProcessId = aProcessId; |
|
424 |
|
425 analyzeTool.GetCurrentHandleCount( params ); |
|
426 handleCount = params().iCurrentHandleCount; |
|
427 } |
|
428 |
|
429 _LIT8( KSubTestId, "ATConsoleUiSubTest" ); |
|
430 TInt stopErr = iStorageServer.StopSubTest( aProcessId, KSubTestId, handleCount ); |
|
431 if ( KErrNone == stopErr ) |
|
432 { |
|
433 TInt index = iSubTestProcesses.Find( aProcessId ); |
|
434 if ( index > KErrNotFound ) |
|
435 { |
|
436 iSubTestProcesses.Remove( index ); |
|
437 if ( iSubTestProcesses.Count() == KErrNone ) |
|
438 iSubTestProcesses.Reset(); |
|
439 } |
|
440 } |
|
441 |
|
442 // The count of device driver users |
|
443 TClientCountBuf count; |
|
444 |
|
445 // Check the flag |
|
446 if ( driverOpen == KErrNone ) |
|
447 { |
|
448 analyzeTool.ClientCount( count ); |
|
449 analyzeTool.Close(); |
|
450 } |
|
451 |
|
452 // Check the flag |
|
453 if ( driverLoaded ) |
|
454 { |
|
455 // Check if there is another user for device driver |
|
456 if ( count().iClientCount <= 1 ) |
|
457 { |
|
458 // There was no other users -> unload the device driver |
|
459 User::FreeLogicalDevice( KAnalyzeToolLddName ); |
|
460 } |
|
461 } |
|
462 } |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // CConsoleMain::IsSubTestRunning() |
|
466 // Returns ETrue if subtest is running for a process. |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 TInt CConsoleMain::IsSubTestRunning( TUint aProcessId ) |
|
470 { |
|
471 return iSubTestProcesses.Find( aProcessId ); |
|
472 } |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // CScrollerTimer::NewL() |
|
476 // Construct a new CScrollerTimer object. |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 CScrollerTimer* CScrollerTimer::NewL( CConsoleMain* aMain ) |
|
480 { |
|
481 CScrollerTimer* self = new ( ELeave ) CScrollerTimer(); |
|
482 CleanupStack::PushL( self ); |
|
483 self->ConstructL( aMain ); |
|
484 CleanupStack::Pop( self ); |
|
485 return self; |
|
486 } |
|
487 |
|
488 // ----------------------------------------------------------------------------- |
|
489 // CScrollerTimer::ConstructL() |
|
490 // Second level constructor. |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 void CScrollerTimer::ConstructL( CConsoleMain* aMain ) |
|
494 { |
|
495 // Store module information |
|
496 iMain = aMain; |
|
497 iTimer.CreateLocal(); |
|
498 |
|
499 CActiveScheduler::Add ( this ); |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CScrollerTimer::CScrollerTimer() |
|
504 // Constructor. |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 CScrollerTimer::CScrollerTimer() : CActive (CActive::EPriorityStandard) |
|
508 { |
|
509 } |
|
510 |
|
511 // ----------------------------------------------------------------------------- |
|
512 // CScrollerTimer::~CScrollerTimer() |
|
513 // Destructor. |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 CScrollerTimer::~CScrollerTimer( ) |
|
517 { |
|
518 Cancel(); |
|
519 iTimer.Close(); |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // CScrollerTimer::StartL() |
|
524 // Start timer. |
|
525 // ----------------------------------------------------------------------------- |
|
526 // |
|
527 void CScrollerTimer::StartL( ) |
|
528 { |
|
529 SetActive(); |
|
530 iTimer.After ( iStatus, KScrollPeriod ); |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // CScrollerTimer::RunL() |
|
535 // RunL. |
|
536 // ----------------------------------------------------------------------------- |
|
537 // |
|
538 void CScrollerTimer::RunL( ) |
|
539 { |
|
540 iMain->TimerUpdate(); |
|
541 |
|
542 // Restart request |
|
543 SetActive(); |
|
544 iTimer.After ( iStatus, KScrollPeriod ); |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // CScrollerTimer::DoCancel() |
|
549 // Cancels timer. |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CScrollerTimer::DoCancel( ) |
|
553 { |
|
554 iTimer.Cancel(); |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // CScrollerTimer::RunError() |
|
559 // Returns error. |
|
560 // ----------------------------------------------------------------------------- |
|
561 // |
|
562 TInt CScrollerTimer::RunError( TInt aError) |
|
563 { |
|
564 return aError; |
|
565 } |
|
566 |
|
567 // ----------------------------------------------------------------------------- |
|
568 // CConsoleReader::NewL() |
|
569 // First phase constructor. |
|
570 // ----------------------------------------------------------------------------- |
|
571 // |
|
572 CConsoleReader* CConsoleReader::NewL( CConsoleMain* aMain, |
|
573 CConsoleBase* aConsole ) |
|
574 { |
|
575 CConsoleReader* self = |
|
576 new ( ELeave ) CConsoleReader( aMain, aConsole ); |
|
577 CleanupStack::PushL( self ); |
|
578 self->ConstructL(); |
|
579 CleanupStack::Pop( self ); |
|
580 return self; |
|
581 } |
|
582 |
|
583 // ----------------------------------------------------------------------------- |
|
584 // CConsoleReader::ConstructL() |
|
585 // Second phase constructor. |
|
586 // ----------------------------------------------------------------------------- |
|
587 // |
|
588 void CConsoleReader::ConstructL( ) |
|
589 { |
|
590 } |
|
591 |
|
592 // ----------------------------------------------------------------------------- |
|
593 // CConsoleReader::CConsoleReader() |
|
594 // C++ default constructor. |
|
595 // ----------------------------------------------------------------------------- |
|
596 // |
|
597 CConsoleReader::CConsoleReader( CConsoleMain* aMain, |
|
598 CConsoleBase* aConsole ): |
|
599 CActive( EPriorityStandard ) |
|
600 { |
|
601 iMain = aMain; |
|
602 iConsole = aConsole; |
|
603 |
|
604 CActiveScheduler::Add( this ); |
|
605 } |
|
606 |
|
607 // ----------------------------------------------------------------------------- |
|
608 // CConsoleReader::~CConsoleReader() |
|
609 // Destructor. |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 CConsoleReader::~CConsoleReader( ) |
|
613 { |
|
614 Cancel(); |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CConsoleReader::StartL() |
|
619 // Starts console reader. |
|
620 // ----------------------------------------------------------------------------- |
|
621 // |
|
622 void CConsoleReader::StartL( ) |
|
623 { |
|
624 // Start to process keyboard events |
|
625 SetActive(); |
|
626 iConsole->Read(iStatus); |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CConsoleReader::RunError() |
|
631 // Returns error. |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 TInt CConsoleReader::RunError( TInt aError ) |
|
635 { |
|
636 return aError; |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CConsoleReader::RunL() |
|
641 // Handles key pressings. |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 void CConsoleReader::RunL() |
|
645 { |
|
646 iMain->KeyPressedL(); |
|
647 } |
|
648 |
|
649 // ----------------------------------------------------------------------------- |
|
650 // CConsoleReader::DoCancel() |
|
651 // Cancel request. |
|
652 // ----------------------------------------------------------------------------- |
|
653 // |
|
654 void CConsoleReader::DoCancel() |
|
655 { |
|
656 iConsole->ReadCancel(); |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // MainL() |
|
661 // The main function that can leave. |
|
662 // Create the CMainConsole object and create, initialise and |
|
663 // start active scheduler. |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 LOCAL_C void MainL() |
|
667 { |
|
668 // Construct and install active scheduler |
|
669 CActiveScheduler* scheduler=new ( ELeave ) CActiveScheduler; |
|
670 CleanupStack::PushL( scheduler ); |
|
671 CActiveScheduler::Install( scheduler ); |
|
672 |
|
673 // Construct the console |
|
674 CConsoleMain* mainConsole = CConsoleMain::NewL(); |
|
675 CleanupStack::PushL( mainConsole ); |
|
676 |
|
677 // Start the console |
|
678 mainConsole->StartL(); |
|
679 |
|
680 // Start handling requests |
|
681 CActiveScheduler::Start(); |
|
682 // Execution continues from here after CActiveScheduler::Stop() |
|
683 |
|
684 // Clean-up |
|
685 CleanupStack::PopAndDestroy( mainConsole ); |
|
686 CleanupStack::PopAndDestroy( scheduler ); |
|
687 } |
|
688 |
|
689 // ----------------------------------------------------------------------------- |
|
690 // E32Main() |
|
691 // The main function. Execution starts from here. |
|
692 // Create clean-up stack and trap the MainL function which does the |
|
693 // real work. |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 GLDEF_C TInt E32Main() |
|
697 { |
|
698 __UHEAP_MARK; |
|
699 |
|
700 // Get clean-up stack |
|
701 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
702 |
|
703 // Call the main function |
|
704 TRAPD( error, MainL() ); |
|
705 |
|
706 // Clean-up |
|
707 delete cleanup; |
|
708 cleanup = NULL; |
|
709 |
|
710 __UHEAP_MARKEND; |
|
711 |
|
712 return error; |
|
713 } |
|
714 |
|
715 #if defined(__WINS__) |
|
716 // ----------------------------------------------------------------------------- |
|
717 // WinsMain() |
|
718 // ----------------------------------------------------------------------------- |
|
719 // |
|
720 EXPORT_C TInt WinsMain() |
|
721 { |
|
722 E32Main(); |
|
723 return KErrNone; |
|
724 } |
|
725 |
|
726 #endif // __WINS__ |
|
727 |
|
728 // End of File |
|