|
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 #include "MemSpyViewProcesses.h" |
|
19 |
|
20 // System includes |
|
21 #include <aknsfld.h> |
|
22 #include <AknQueryDialog.h> |
|
23 #include <memspyui.rsg> |
|
24 |
|
25 // Engine includes |
|
26 #include <memspy/engine/memspyengine.h> |
|
27 #include <memspy/engine/memspyengineobjectprocess.h> |
|
28 #include <memspy/engine/memspyengineobjectthread.h> |
|
29 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
30 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h> |
|
31 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h> |
|
32 #include <memspy/engine/memspyenginehelperprocess.h> |
|
33 #include <memspysession.h> |
|
34 #include <memspy/engine/memspyengineutils.h> |
|
35 |
|
36 // User includes |
|
37 #include "MemSpyViewThreads.h" |
|
38 #include "MemSpyViewMainMenu.h" |
|
39 #include "MemSpyContainerObserver.h" |
|
40 |
|
41 // Constants |
|
42 const TInt KMemSpyMaxSearchTextLength = 30; |
|
43 const TInt KMemSpyMaxSearchTextLengthWithWildcards = KMemSpyMaxSearchTextLength + 4; |
|
44 |
|
45 |
|
46 /* |
|
47 CMemSpyViewProcesses::CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver ) |
|
48 : CMemSpyViewBase( aEngine, aObserver ) |
|
49 { |
|
50 } |
|
51 |
|
52 |
|
53 CMemSpyViewProcesses::CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess ) |
|
54 : CMemSpyViewBase( aEngine, aObserver ), iCurrentProcess( &aProcess ) |
|
55 { |
|
56 iCurrentProcess->Open(); |
|
57 } |
|
58 */ |
|
59 |
|
60 CMemSpyViewProcesses::CMemSpyViewProcesses( RMemSpySession& aSession, MMemSpyViewObserver& aObserver ) |
|
61 : CMemSpyViewBase( aSession, aObserver ) |
|
62 { |
|
63 } |
|
64 |
|
65 /* |
|
66 CMemSpyViewProcesses::CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess ) |
|
67 : CMemSpyViewBase( aEngine, aObserver ), iCurrentProcess( &aProcess ) |
|
68 { |
|
69 iCurrentProcess->Open(); |
|
70 } |
|
71 */ |
|
72 |
|
73 CMemSpyViewProcesses::CMemSpyViewProcesses( RMemSpySession& aEngine, MMemSpyViewObserver& aObserver, TProcessId aId ) |
|
74 : CMemSpyViewBase( aEngine, aObserver ), iCurrentProcessId( aId ) |
|
75 { |
|
76 } |
|
77 |
|
78 CMemSpyViewProcesses::~CMemSpyViewProcesses() |
|
79 { |
|
80 iProcesses.Close(); |
|
81 delete iSearchField; |
|
82 delete iMatcherBuffer; |
|
83 } |
|
84 |
|
85 |
|
86 //void CMemSpyViewProcesses::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
87 void CMemSpyViewProcesses::ConstructL( const TRect& aRect, CCoeControl& aContainer, TProcessId aSelectionRune ) |
|
88 { |
|
89 iMemSpySession.GetProcessesL(iProcesses); // get processes array; |
|
90 |
|
91 _LIT( KTitle, "Processes\n& Threads" ); |
|
92 SetTitleL( KTitle ); |
|
93 // |
|
94 //CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
95 CMemSpyViewBase::ConstructL( aRect, aContainer ); |
|
96 // |
|
97 iMatcherBuffer = HBufC::NewL( KMemSpyMaxSearchTextLengthWithWildcards ); |
|
98 // |
|
99 iSearchField = CAknSearchField::NewL( *this, CAknSearchField::ESearch, NULL, KMemSpyMaxSearchTextLength ); |
|
100 iSearchField->SetObserver( this ); |
|
101 iSearchField->SetFocus( ETrue ); |
|
102 iSearchField->SetComponentsToInheritVisibility( ETrue ); |
|
103 // |
|
104 if ( aSelectionRune ) |
|
105 { |
|
106 TInt index = 0; |
|
107 TProcessId selectedItem = aSelectionRune; //static_cast< TProcessId >( *aSelectionRune ); |
|
108 for( TInt i=0; i<iProcesses.Count();i++) |
|
109 { |
|
110 if( iProcesses[i]->Id() == selectedItem ) |
|
111 { |
|
112 index = i; |
|
113 } |
|
114 } |
|
115 |
|
116 if ( index >= 0 && index < iListBox->Model()->NumberOfItems() ) |
|
117 { |
|
118 iListBox->SetCurrentItemIndex( index ); |
|
119 HandleListBoxItemSelectedL( index ); |
|
120 } |
|
121 } |
|
122 else if ( iProcesses.Count() > 0 ) //TODO: to solve item selection when come back from previous view |
|
123 { |
|
124 iListBox->SetCurrentItemIndex( 0 ); |
|
125 HandleListBoxItemSelectedL( 0 ); |
|
126 } |
|
127 // |
|
128 SizeChanged(); |
|
129 ActivateL(); |
|
130 } |
|
131 |
|
132 |
|
133 CMemSpyProcess& CMemSpyViewProcesses::CurrentProcess() const |
|
134 { |
|
135 /* |
|
136 __ASSERT_ALWAYS( iCurrentProcess != NULL, User::Invariant() ); |
|
137 return *iCurrentProcess; |
|
138 */ |
|
139 } |
|
140 |
|
141 |
|
142 void CMemSpyViewProcesses::RefreshL() |
|
143 { |
|
144 SetListBoxModelL(); |
|
145 CMemSpyViewBase::RefreshL(); |
|
146 } |
|
147 |
|
148 |
|
149 TMemSpyViewType CMemSpyViewProcesses::ViewType() const |
|
150 { |
|
151 return EMemSpyViewTypeProcesses; |
|
152 } |
|
153 |
|
154 |
|
155 CMemSpyViewBase* CMemSpyViewProcesses::PrepareParentViewL() |
|
156 { |
|
157 CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iMemSpySession, iObserver ); |
|
158 CleanupStack::PushL( parent ); |
|
159 parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() ); |
|
160 CleanupStack::Pop( parent ); |
|
161 return parent; |
|
162 } |
|
163 |
|
164 |
|
165 CMemSpyViewBase* CMemSpyViewProcesses::PrepareChildViewL() |
|
166 { |
|
167 CMemSpyViewThreads* child = new(ELeave) CMemSpyViewThreads( iMemSpySession, iObserver, iProcesses[iListBox->CurrentItemIndex()]->Id() ); |
|
168 CleanupStack::PushL( child ); |
|
169 child->ConstructL( Rect(), *Parent() ); |
|
170 CleanupStack::Pop( child ); |
|
171 return child; |
|
172 |
|
173 return 0; |
|
174 } |
|
175 |
|
176 |
|
177 void CMemSpyViewProcesses::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
178 { |
|
179 if ( aResourceId == MenuCascadeResourceId() ) |
|
180 { |
|
181 CMemSpyProcess& process = CurrentProcess(); |
|
182 //const TBool hide = ( iEngine.Container().Count() == 0 ) || process.IsDead(); //TODO |
|
183 // |
|
184 const TBool hide = EFalse; //to replace |
|
185 |
|
186 aMenuPane->SetItemDimmed( EMemSpyCmdProcessInfo, hide ); |
|
187 aMenuPane->SetItemDimmed( EMemSpyCmdProcessEnd, hide ); |
|
188 } |
|
189 } |
|
190 |
|
191 |
|
192 TBool CMemSpyViewProcesses::HandleCommandL( TInt aCommand ) |
|
193 { |
|
194 TBool handled = ETrue; |
|
195 // |
|
196 switch ( aCommand ) |
|
197 { |
|
198 // Sorting |
|
199 case EMemSpyCmdProcessSortById: |
|
200 OnCmdSortByIdL(); |
|
201 break; |
|
202 case EMemSpyCmdProcessSortByName: |
|
203 OnCmdSortByNameL(); |
|
204 break; |
|
205 case EMemSpyCmdProcessSortByThreadCount: |
|
206 OnCmdSortByThreadCountL(); |
|
207 break; |
|
208 case EMemSpyCmdProcessSortByCodeSegs: |
|
209 OnCmdSortByCodeSegsL(); |
|
210 break; |
|
211 case EMemSpyCmdProcessSortByHeapUsage: |
|
212 OnCmdSortByHeapUsageL(); |
|
213 break; |
|
214 case EMemSpyCmdProcessSortByStackUsage: |
|
215 OnCmdSortByStackUsageL(); |
|
216 break; |
|
217 // End |
|
218 case EMemSpyCmdProcessEndTerminate: |
|
219 OnCmdEndTerminateL(); |
|
220 break; |
|
221 case EMemSpyCmdProcessEndKill: |
|
222 OnCmdEndKillL(); |
|
223 break; |
|
224 case EMemSpyCmdProcessEndPanic: |
|
225 OnCmdEndPanicL(); |
|
226 break; |
|
227 // Info |
|
228 case EMemSpyCmdProcessInfoSummary: |
|
229 OnCmdInfoSummaryL(); |
|
230 break; |
|
231 case EMemSpyCmdProcessInfoHandles: |
|
232 OnCmdInfoHandlesL(); |
|
233 break; |
|
234 |
|
235 default: |
|
236 handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
237 break; |
|
238 } |
|
239 // |
|
240 return handled; |
|
241 } |
|
242 |
|
243 |
|
244 void CMemSpyViewProcesses::OnCmdSortByIdL() |
|
245 { |
|
246 //iEngine.Container().SortById(); |
|
247 RefreshL(); |
|
248 } |
|
249 |
|
250 |
|
251 void CMemSpyViewProcesses::OnCmdSortByNameL() |
|
252 { |
|
253 //iEngine.Container().SortByName(); |
|
254 RefreshL(); |
|
255 } |
|
256 |
|
257 |
|
258 void CMemSpyViewProcesses::OnCmdSortByThreadCountL() |
|
259 { |
|
260 //iEngine.Container().SortByThreadCount(); |
|
261 RefreshL(); |
|
262 } |
|
263 |
|
264 |
|
265 void CMemSpyViewProcesses::OnCmdSortByCodeSegsL() |
|
266 { |
|
267 //iEngine.Container().SortByCodeSegs(); |
|
268 RefreshL(); |
|
269 } |
|
270 |
|
271 |
|
272 void CMemSpyViewProcesses::OnCmdSortByHeapUsageL() |
|
273 { |
|
274 //iEngine.Container().SortByHeapUsage(); |
|
275 RefreshL(); |
|
276 } |
|
277 |
|
278 |
|
279 void CMemSpyViewProcesses::OnCmdSortByStackUsageL() |
|
280 { |
|
281 // iEngine.Container().SortByStackUsage(); |
|
282 RefreshL(); |
|
283 } |
|
284 |
|
285 |
|
286 void CMemSpyViewProcesses::OnCmdInfoSummaryL() |
|
287 { |
|
288 //CMemSpyProcess& process = CurrentProcess(); |
|
289 //iEngine.HelperProcess().OutputProcessInfoL( process ); |
|
290 } |
|
291 |
|
292 |
|
293 void CMemSpyViewProcesses::OnCmdInfoHandlesL() |
|
294 { |
|
295 /* |
|
296 CMemSpyProcess& process = CurrentProcess(); |
|
297 // |
|
298 const TInt threadCount = process.Count(); |
|
299 for( TInt i=0; i<threadCount; i++ ) |
|
300 { |
|
301 CMemSpyThread& thread = process.At( i ); |
|
302 thread.InfoContainerForceSyncronousConstructionL().PrintL(); |
|
303 } |
|
304 */ |
|
305 } |
|
306 |
|
307 |
|
308 void CMemSpyViewProcesses::OnCmdEndTerminateL() |
|
309 { |
|
310 /* |
|
311 TBool doTerminate = ETrue; |
|
312 CMemSpyProcess& process = CurrentProcess(); |
|
313 // |
|
314 if ( process.IsSystemPermanent() || process.IsSystemCritical() ) |
|
315 { |
|
316 CAknQueryDialog* importDialog = CAknQueryDialog::NewL(); |
|
317 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) ); |
|
318 } |
|
319 // |
|
320 if ( doTerminate ) |
|
321 { |
|
322 process.TerminateL(); |
|
323 RefreshL(); |
|
324 } |
|
325 */ |
|
326 } |
|
327 |
|
328 |
|
329 void CMemSpyViewProcesses::OnCmdEndPanicL() |
|
330 {/* |
|
331 TBool doTerminate = ETrue; |
|
332 CMemSpyProcess& process = CurrentProcess(); |
|
333 // |
|
334 if ( process.IsSystemPermanent() || process.IsSystemCritical() ) |
|
335 { |
|
336 CAknQueryDialog* importDialog = CAknQueryDialog::NewL(); |
|
337 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) ); |
|
338 } |
|
339 // |
|
340 if ( doTerminate ) |
|
341 { |
|
342 process.PanicL(); |
|
343 RefreshL(); |
|
344 } |
|
345 */ |
|
346 } |
|
347 |
|
348 |
|
349 void CMemSpyViewProcesses::OnCmdEndKillL() |
|
350 {/* |
|
351 TBool doTerminate = ETrue; |
|
352 CMemSpyProcess& process = CurrentProcess(); |
|
353 // |
|
354 if ( process.IsSystemPermanent() || process.IsSystemCritical() ) |
|
355 { |
|
356 CAknQueryDialog* importDialog = CAknQueryDialog::NewL(); |
|
357 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) ); |
|
358 } |
|
359 // |
|
360 if ( doTerminate ) |
|
361 { |
|
362 process.KillL(); |
|
363 RefreshL(); |
|
364 } |
|
365 */ |
|
366 } |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 void CMemSpyViewProcesses::SetListBoxModelL() |
|
372 { |
|
373 if( iProcesses.Count() > 0 ) |
|
374 { |
|
375 iProcesses.Close(); |
|
376 } |
|
377 |
|
378 iMemSpySession.GetProcessesL(iProcesses); // get processes array; |
|
379 iModel = new (ELeave) CDesC16ArrayFlat( iProcesses.Count() + 1); //array for formated items |
|
380 |
|
381 _LIT( KTab, "\t" ); |
|
382 //iModel = FormatModel( iProcesses ); //TODO Format model method with advanced formatting |
|
383 |
|
384 |
|
385 for( TInt i=0; i < iProcesses.Count(); i++ ) |
|
386 { |
|
387 HBufC* tempName = HBufC::NewL( iProcesses[i]->Name().Length() + 16 ); |
|
388 CleanupStack::PushL( tempName ); |
|
389 TPtr tempNamePtr( tempName->Des() ); |
|
390 tempNamePtr.Copy( KTab ); |
|
391 tempNamePtr.Append( iProcesses[i]->Name() ); |
|
392 iModel->AppendL( tempNamePtr ); |
|
393 |
|
394 CleanupStack::PopAndDestroy( tempName ); |
|
395 } |
|
396 |
|
397 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
398 //listbox->Model()->SetItemTextArray( &iEngine.Container() ); |
|
399 listbox->Model()->SetItemTextArray( iModel ); |
|
400 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
401 } |
|
402 |
|
403 |
|
404 void CMemSpyViewProcesses::HandleListBoxItemActionedL( TInt /*aIndex*/ ) |
|
405 { |
|
406 // Notify observer about an item being 'fired' |
|
407 ReportEventL( MMemSpyViewObserver::EEventItemActioned ); |
|
408 } |
|
409 |
|
410 |
|
411 void CMemSpyViewProcesses::HandleListBoxItemSelectedL( TInt aIndex ) |
|
412 {/* |
|
413 if ( iCurrentProcess ) |
|
414 { |
|
415 iCurrentProcess->Close(); |
|
416 } |
|
417 |
|
418 // Obtain the process that corresponds to the selected item |
|
419 CMemSpyEngineObjectContainer& container = iEngine.Container(); |
|
420 CMemSpyProcess& process = container.At( aIndex ); |
|
421 iCurrentProcess = &process; |
|
422 iCurrentProcess->Open(); |
|
423 |
|
424 // Notify observer about item selection |
|
425 ReportEventL( MMemSpyViewObserver::EEventItemSelected );*/ |
|
426 } |
|
427 |
|
428 |
|
429 void CMemSpyViewProcesses::SizeChanged() |
|
430 { |
|
431 const TRect rect( Rect() ); |
|
432 |
|
433 if ( iListBox && iSearchField ) |
|
434 { |
|
435 const TInt lafIndex_H = 1; |
|
436 AknLayoutUtils::LayoutControl( iListBox, rect, AknLayout::list_gen_pane( lafIndex_H ) ); |
|
437 AknLayoutUtils::LayoutControl( iSearchField, rect, AknLayout::find_pane() ); |
|
438 } |
|
439 else |
|
440 { |
|
441 CMemSpyViewBase::SizeChanged(); |
|
442 } |
|
443 |
|
444 /* |
|
445 // Search field |
|
446 TSize searchFieldSize( iSearchField->MinimumSize() ); // BALLS: search field doesn't implement minimum size correctly?!?!? |
|
447 searchFieldSize.SetWidth( rect.Width() ); |
|
448 const TRect searchFieldRect( TPoint( rect.iTl.iX, rect.iBr.iY ), searchFieldSize ); |
|
449 iSearchField->SetRect( searchFieldRect ); |
|
450 |
|
451 // Listbox |
|
452 TSize listBoxSize( rect.Size() - TSize( 0, searchFieldSize.iHeight ) ); |
|
453 iListBox->SetRect( rect.iTl, listBoxSize ); |
|
454 */ |
|
455 } |
|
456 |
|
457 |
|
458 TInt CMemSpyViewProcesses::CountComponentControls() const |
|
459 { |
|
460 TInt count = 0; |
|
461 // |
|
462 if ( iListBox != NULL ) |
|
463 { |
|
464 ++count; |
|
465 } |
|
466 if ( iSearchField != NULL ) |
|
467 { |
|
468 ++count; |
|
469 } |
|
470 // |
|
471 return count; |
|
472 } |
|
473 |
|
474 |
|
475 CCoeControl* CMemSpyViewProcesses::ComponentControl( TInt aIndex ) const |
|
476 { |
|
477 CCoeControl* ret = iListBox; |
|
478 // |
|
479 if ( aIndex == 1 ) |
|
480 { |
|
481 ret = iSearchField; |
|
482 } |
|
483 // |
|
484 return ret; |
|
485 } |
|
486 |
|
487 |
|
488 TKeyResponse CMemSpyViewProcesses::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
489 { |
|
490 TKeyResponse resp = EKeyWasNotConsumed; |
|
491 // |
|
492 if ( aType == EEventKey ) |
|
493 { |
|
494 switch( aKeyEvent.iCode ) |
|
495 { |
|
496 case EKeyUpArrow: |
|
497 case EKeyDownArrow: |
|
498 case EKeyEnter: |
|
499 case EKeyOK: |
|
500 if ( iListBox ) |
|
501 { |
|
502 resp = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
503 } |
|
504 break; |
|
505 default: |
|
506 break; |
|
507 } |
|
508 // |
|
509 if ( resp == EKeyWasNotConsumed ) |
|
510 { |
|
511 // Do we need to show the find field? |
|
512 resp = iSearchField->OfferKeyEventL( aKeyEvent, aType ); |
|
513 } |
|
514 } |
|
515 // |
|
516 return resp; |
|
517 } |
|
518 |
|
519 |
|
520 void CMemSpyViewProcesses::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ) |
|
521 { |
|
522 CMemSpyViewBase::HandleControlEventL( aControl, aEventType ); |
|
523 // |
|
524 if ( aEventType == MCoeControlObserver::EEventStateChanged ) |
|
525 { |
|
526 if ( aControl == iSearchField ) |
|
527 { |
|
528 SelectListBoxItemByFindTextL(); |
|
529 } |
|
530 } |
|
531 } |
|
532 |
|
533 |
|
534 void CMemSpyViewProcesses::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
535 { |
|
536 if ( iListBox ) |
|
537 { |
|
538 iListBox->SetFocus( IsFocused() ); |
|
539 } |
|
540 if ( iSearchField ) |
|
541 { |
|
542 iSearchField->SetFocus( IsFocused() ); |
|
543 } |
|
544 } |
|
545 |
|
546 |
|
547 void CMemSpyViewProcesses::SelectListBoxItemByFindTextL() |
|
548 { |
|
549 /* |
|
550 _LIT( KMemSpyWildcardCharacter, "*" ); |
|
551 |
|
552 TPtr pBuffer( iMatcherBuffer->Des() ); |
|
553 iSearchField->GetSearchText( pBuffer ); |
|
554 //pBuffer.Insert( 0, KMemSpyWildcardCharacter ); |
|
555 pBuffer.Append( KMemSpyWildcardCharacter ); |
|
556 |
|
557 CMemSpyEngineObjectContainer& container = iEngine.Container(); |
|
558 const TInt count = container.Count(); |
|
559 // |
|
560 TInt index = 0; |
|
561 while( index < count ) |
|
562 { |
|
563 CMemSpyProcess& process = container.At( index ); |
|
564 const TPtrC processName( process.Name() ); |
|
565 // |
|
566 if ( processName.MatchF( pBuffer ) >= 0 ) |
|
567 { |
|
568 HandleListBoxItemSelectedL( index ); |
|
569 iListBox->ScrollToMakeItemVisible( index ); |
|
570 iListBox->SetCurrentItemIndexAndDraw( index ); |
|
571 return; |
|
572 } |
|
573 |
|
574 ++index; |
|
575 } |
|
576 */ |
|
577 } |
|
578 |
|
579 //Model formating methods |
|
580 //TODO: to be debbuged |
|
581 /* |
|
582 CDesCArrayFlat* CMemSpyViewProcesses::FormatModel( RArray<CMemSpyApiProcess*> aProcesses ) |
|
583 { |
|
584 model = new (ELeave) CDesC16ArrayFlat( iProcesses.Count() + 16 ); //array for formated items |
|
585 _LIT( KMemSpyProcessNameFormatSpecBasicName, " \t%S\t\t%8x, " ); |
|
586 |
|
587 for( TInt i=0; i < aProcesses.Count(); i++ ) |
|
588 { |
|
589 HBufC* tempName = HBufC::NewL( KMaxFullName ); //aProcesses[i]->Name().Length() + 16 |
|
590 CleanupStack::PushL( tempName ); |
|
591 TPtr tempNamePtr( tempName->Des() ); |
|
592 tempNamePtr.Copy( aProcesses[i]->Name() ); |
|
593 |
|
594 TBuf<10> priority; |
|
595 AppendPriority( priority, aProcesses[i]->Priority() ); |
|
596 |
|
597 // Convert the full name to the format we want in the UI |
|
598 TBuf<KMaxFullName + 60> name; |
|
599 TMemSpyTruncateOverflow overflow; //included from EngineUtils TODO: to consider if this is needed to be removed or left there |
|
600 |
|
601 name.AppendFormat( KMemSpyProcessNameFormatSpecBasicName, &overflow, tempNamePtr, aProcesses[i]->SID() ); |
|
602 |
|
603 if( aProcesses[i]->ExitType() != EExitPending ) // instead of IsDead() method |
|
604 { |
|
605 AppendExitInfo( name, aProcesses[i]->ExitType(), aProcesses[i]->ExitReason(), aProcesses[i]->ExitCategory() ); |
|
606 } |
|
607 else |
|
608 { |
|
609 _LIT( KMemSpyProcessNameFormatSpecAlive, "%2d thr, %S" ); |
|
610 name.AppendFormat( KMemSpyProcessNameFormatSpecAlive, &overflow, aProcesses[i]->ThreadCount(), &priority ); |
|
611 } |
|
612 |
|
613 model->AppendL( name ); |
|
614 |
|
615 CleanupStack::PopAndDestroy( tempName ); |
|
616 } |
|
617 |
|
618 return model; |
|
619 } |
|
620 |
|
621 void CMemSpyViewProcesses::AppendPriority( TDes& aDes, TProcessPriority aPriority ) |
|
622 { |
|
623 switch( aPriority ) |
|
624 { |
|
625 case EPriorityLow: |
|
626 aDes += _L("[L]"); |
|
627 break; |
|
628 case EPriorityBackground: |
|
629 aDes += _L("[B]"); |
|
630 break; |
|
631 case EPriorityForeground: |
|
632 aDes += _L("[F]"); |
|
633 break; |
|
634 case EPriorityHigh: |
|
635 aDes += _L("[H]"); |
|
636 break; |
|
637 case EPriorityWindowServer: |
|
638 aDes += _L("[WS]"); |
|
639 break; |
|
640 case EPriorityFileServer: |
|
641 aDes += _L("[FS]"); |
|
642 break; |
|
643 case EPriorityRealTimeServer: |
|
644 aDes += _L("[RTS]"); |
|
645 break; |
|
646 case EPrioritySupervisor: |
|
647 aDes += _L("[SUP]"); |
|
648 break; |
|
649 default: |
|
650 aDes += _L("[?]"); |
|
651 break; |
|
652 } |
|
653 } |
|
654 |
|
655 void CMemSpyViewProcesses::AppendExitInfo( TDes& aDes, TExitType aType, TInt aExitReason, const TDesC& aExitCategory ) |
|
656 { |
|
657 aDes.Append( '[' ); |
|
658 const TInt length = aDes.Length(); |
|
659 AppendExitType( aDes, aType ); |
|
660 aDes.SetLength( length + 1 ); // Remove all but the first letter |
|
661 aDes.Append( ']' ); |
|
662 |
|
663 if ( aType == EExitKill || aType == EExitPending ) |
|
664 { |
|
665 // Kill implies "clean" exit. Pending implies not yet dead. |
|
666 } |
|
667 else |
|
668 { |
|
669 TMemSpyTruncateOverflow overflow; |
|
670 |
|
671 // Terminate or Panic implies abnormal exit condition, so |
|
672 // show full exit info. |
|
673 _LIT( KAbnormalFormatSpec, " %S-%d" ); |
|
674 aDes.AppendFormat( KAbnormalFormatSpec, &overflow, &aExitCategory, aExitReason ); |
|
675 } |
|
676 } |
|
677 |
|
678 void CMemSpyViewProcesses::AppendExitType( TDes& aDes, TExitType aType ) |
|
679 { |
|
680 _LIT( KExitTypeKilled, "Killed" ); |
|
681 _LIT( KExitTypeTerminated, "Terminated" ); |
|
682 _LIT( KExitTypePanicked, "Panicked" ); |
|
683 _LIT( KExitTypePending, "Pending" ); |
|
684 |
|
685 // Panic and Terminate are exceptional exit conditions. |
|
686 // Kill, is ironically, not an exceptional condition. |
|
687 switch( aType ) |
|
688 { |
|
689 case EExitKill: |
|
690 aDes += KExitTypeKilled; |
|
691 break; |
|
692 case EExitTerminate: |
|
693 aDes += KExitTypeTerminated; |
|
694 break; |
|
695 case EExitPanic: |
|
696 aDes += KExitTypePanicked; |
|
697 break; |
|
698 default: |
|
699 case EExitPending: |
|
700 aDes += KExitTypePending; |
|
701 break; |
|
702 } |
|
703 } |
|
704 */ |