|
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 "MemSpyViewThreads.h" |
|
19 |
|
20 // System includes |
|
21 #include <AknQueryDialog.h> |
|
22 #include <memspyui.rsg> |
|
23 |
|
24 // Engine includes |
|
25 #include <memspy/engine/memspyengine.h> |
|
26 #include <memspy/engine/memspyengineobjectprocess.h> |
|
27 #include <memspy/engine/memspyengineobjectthread.h> |
|
28 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
29 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h> |
|
30 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h> |
|
31 #include <memspy/engine/memspyenginehelperprocess.h> |
|
32 #include <memspysession.h> |
|
33 |
|
34 // User includes |
|
35 #include "MemSpyContainerObserver.h" |
|
36 #include "MemSpyViewProcesses.h" |
|
37 #include "MemSpyViewThreadInfoItemList.h" |
|
38 |
|
39 |
|
40 |
|
41 /* |
|
42 CMemSpyViewThreads::CMemSpyViewThreads( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess ) |
|
43 : CMemSpyViewBase( aEngine, aObserver ), iParentProcess( aProcess ) |
|
44 { |
|
45 iParentProcess.Open(); |
|
46 } |
|
47 */ |
|
48 CMemSpyViewThreads::CMemSpyViewThreads( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aId ) |
|
49 : CMemSpyViewBase( aSession, aObserver ), iParentProcessId( aId ) |
|
50 { |
|
51 } |
|
52 |
|
53 |
|
54 CMemSpyViewThreads::~CMemSpyViewThreads() |
|
55 { |
|
56 } |
|
57 |
|
58 |
|
59 void CMemSpyViewThreads::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
60 { |
|
61 _LIT( KTitle, "Threads" ); |
|
62 SetTitleL( KTitle ); |
|
63 // |
|
64 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
65 // |
|
66 if ( aSelectionRune ) |
|
67 { |
|
68 iListBox->SetCurrentItemIndex( 0 ); //for now |
|
69 HandleListBoxItemSelectedL( 0 ); |
|
70 /* TODO: |
|
71 CMemSpyThread* selectedItem = reinterpret_cast< CMemSpyThread* >( aSelectionRune ); |
|
72 const TInt index = iParentProcess.ThreadIndexById( selectedItem->Id() ); |
|
73 if ( index >= 0 && index < iListBox->Model()->NumberOfItems() ) |
|
74 { |
|
75 iListBox->SetCurrentItemIndex( index ); |
|
76 HandleListBoxItemSelectedL( index ); |
|
77 } |
|
78 */ |
|
79 } |
|
80 //else if ( iParentProcess.Count() > 0 ) |
|
81 // { |
|
82 iListBox->SetCurrentItemIndex( 0 ); |
|
83 HandleListBoxItemSelectedL( 0 ); |
|
84 // } |
|
85 } |
|
86 |
|
87 |
|
88 TProcessId CMemSpyViewThreads::Process() const |
|
89 { |
|
90 return iParentProcessId; |
|
91 } |
|
92 |
|
93 |
|
94 TThreadId CMemSpyViewThreads::CurrentThread() |
|
95 { |
|
96 return iCurrentThreadId; |
|
97 } |
|
98 |
|
99 |
|
100 void CMemSpyViewThreads::RefreshL() |
|
101 { |
|
102 SetListBoxModelL(); |
|
103 CMemSpyViewBase::RefreshL(); |
|
104 } |
|
105 |
|
106 |
|
107 TMemSpyViewType CMemSpyViewThreads::ViewType() const |
|
108 { |
|
109 return EMemSpyViewTypeThreads; |
|
110 } |
|
111 |
|
112 |
|
113 CMemSpyViewBase* CMemSpyViewThreads::PrepareParentViewL() |
|
114 { |
|
115 CMemSpyViewProcesses* parent = new(ELeave) CMemSpyViewProcesses( iMemSpySession, iObserver, iParentProcessId ); |
|
116 CleanupStack::PushL( parent ); |
|
117 //parent->ConstructL( Rect(), *Parent(), &iParentProcessId ); |
|
118 parent->ConstructL( Rect(), *Parent() ); |
|
119 CleanupStack::Pop( parent ); |
|
120 return parent; |
|
121 } |
|
122 |
|
123 |
|
124 CMemSpyViewBase* CMemSpyViewThreads::PrepareChildViewL() |
|
125 { |
|
126 /* |
|
127 CMemSpyViewThreadInfoItemList* child = new(ELeave) CMemSpyViewThreadInfoItemList( iEngine, iObserver, *iCurrentThread ); |
|
128 CleanupStack::PushL( child ); |
|
129 child->ConstructL( Rect(), *Parent() ); |
|
130 CleanupStack::Pop( child ); |
|
131 return child; |
|
132 */ |
|
133 } |
|
134 |
|
135 |
|
136 void CMemSpyViewThreads::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
137 { |
|
138 if ( aResourceId == R_MEMSPY_MENUPANE ) |
|
139 { |
|
140 /* |
|
141 CMemSpyThread& thread = CurrentThread(); |
|
142 aMenuPane->SetItemDimmed( EMemSpyCmdThread, thread.IsDead() ); |
|
143 */ |
|
144 aMenuPane->SetItemDimmed( EMemSpyCmdThread, (iThreads[iListBox->CurrentItemIndex()]->ExitType() != EExitPending )); |
|
145 } |
|
146 } |
|
147 |
|
148 |
|
149 TBool CMemSpyViewThreads::HandleCommandL( TInt aCommand ) |
|
150 { |
|
151 TBool handled = ETrue; |
|
152 // |
|
153 switch ( aCommand ) |
|
154 { |
|
155 case EMemSpyCmdThreadEndKill: |
|
156 OnCmdEndKillL(); |
|
157 break; |
|
158 case EMemSpyCmdThreadEndTerminate: |
|
159 OnCmdEndTerminateL(); |
|
160 break; |
|
161 case EMemSpyCmdThreadEndPanic: |
|
162 OnCmdEndPanicL(); |
|
163 break; |
|
164 case EMemSpyCmdThreadSetPriorityAbsoluteVeryLow: |
|
165 case EMemSpyCmdThreadSetPriorityAbsoluteLowNormal: |
|
166 case EMemSpyCmdThreadSetPriorityAbsoluteLow: |
|
167 case EMemSpyCmdThreadSetPriorityAbsoluteBackgroundNormal: |
|
168 case EMemSpyCmdThreadSetPriorityAbsoluteBackground: |
|
169 case EMemSpyCmdThreadSetPriorityAbsoluteForegroundNormal: |
|
170 case EMemSpyCmdThreadSetPriorityAbsoluteForeground: |
|
171 case EMemSpyCmdThreadSetPriorityAbsoluteHighNormal: |
|
172 case EMemSpyCmdThreadSetPriorityAbsoluteHigh: |
|
173 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime1: |
|
174 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime2: |
|
175 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime3: |
|
176 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime4: |
|
177 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime5: |
|
178 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime6: |
|
179 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime7: |
|
180 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime8: |
|
181 OnCmdSetPriorityL( aCommand ); |
|
182 break; |
|
183 |
|
184 case EMemSpyCmdThreadInfoHandles: |
|
185 OnCmdInfoHandlesL(); |
|
186 break; |
|
187 |
|
188 default: |
|
189 handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
190 break; |
|
191 } |
|
192 // |
|
193 return handled; |
|
194 } |
|
195 |
|
196 |
|
197 void CMemSpyViewThreads::OnCmdEndKillL() |
|
198 { |
|
199 /* |
|
200 TBool doTerminate = ETrue; |
|
201 CMemSpyThread& thread = CurrentThread(); |
|
202 // |
|
203 if ( thread.IsSystemPermanent() ) |
|
204 { |
|
205 CAknQueryDialog* importDialog = CAknQueryDialog::NewL(); |
|
206 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) ); |
|
207 } |
|
208 // |
|
209 if ( doTerminate ) |
|
210 { |
|
211 thread.KillL(); |
|
212 RefreshL(); |
|
213 } |
|
214 */ |
|
215 } |
|
216 |
|
217 |
|
218 void CMemSpyViewThreads::OnCmdEndTerminateL() |
|
219 { |
|
220 /* |
|
221 TBool doTerminate = ETrue; |
|
222 CMemSpyThread& thread = CurrentThread(); |
|
223 // |
|
224 if ( thread.IsSystemPermanent() || thread.IsSystemCritical() ) |
|
225 { |
|
226 CAknQueryDialog* importDialog = CAknQueryDialog::NewL(); |
|
227 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) ); |
|
228 } |
|
229 // |
|
230 if ( doTerminate ) |
|
231 { |
|
232 thread.TerminateL(); |
|
233 RefreshL(); |
|
234 } |
|
235 */ |
|
236 } |
|
237 |
|
238 |
|
239 void CMemSpyViewThreads::OnCmdEndPanicL() |
|
240 { |
|
241 /* |
|
242 TBool doTerminate = ETrue; |
|
243 CMemSpyThread& thread = CurrentThread(); |
|
244 // |
|
245 if ( thread.IsSystemPermanent() || thread.IsSystemCritical() ) |
|
246 { |
|
247 CAknQueryDialog* importDialog = CAknQueryDialog::NewL(); |
|
248 doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) ); |
|
249 } |
|
250 // |
|
251 if ( doTerminate ) |
|
252 { |
|
253 thread.PanicL(); |
|
254 RefreshL(); |
|
255 } |
|
256 */ |
|
257 } |
|
258 |
|
259 |
|
260 void CMemSpyViewThreads::OnCmdSetPriorityL( TInt aCommand ) |
|
261 { |
|
262 /* |
|
263 TThreadPriority pri = EPriorityAbsoluteBackground; |
|
264 switch( aCommand ) |
|
265 { |
|
266 case EMemSpyCmdThreadSetPriorityAbsoluteVeryLow: |
|
267 pri = EPriorityAbsoluteVeryLow; |
|
268 break; |
|
269 case EMemSpyCmdThreadSetPriorityAbsoluteLowNormal: |
|
270 pri = EPriorityAbsoluteLowNormal; |
|
271 break; |
|
272 case EMemSpyCmdThreadSetPriorityAbsoluteLow: |
|
273 pri = EPriorityAbsoluteLow; |
|
274 break; |
|
275 case EMemSpyCmdThreadSetPriorityAbsoluteBackgroundNormal: |
|
276 pri = EPriorityAbsoluteBackgroundNormal; |
|
277 break; |
|
278 case EMemSpyCmdThreadSetPriorityAbsoluteBackground: |
|
279 pri = EPriorityAbsoluteBackground; |
|
280 break; |
|
281 case EMemSpyCmdThreadSetPriorityAbsoluteForegroundNormal: |
|
282 pri = EPriorityAbsoluteForegroundNormal; |
|
283 break; |
|
284 case EMemSpyCmdThreadSetPriorityAbsoluteForeground: |
|
285 pri = EPriorityAbsoluteForeground; |
|
286 break; |
|
287 case EMemSpyCmdThreadSetPriorityAbsoluteHighNormal: |
|
288 pri = EPriorityAbsoluteHighNormal; |
|
289 break; |
|
290 case EMemSpyCmdThreadSetPriorityAbsoluteHigh: |
|
291 pri = EPriorityAbsoluteHigh; |
|
292 break; |
|
293 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime1: |
|
294 pri = EPriorityAbsoluteRealTime1; |
|
295 break; |
|
296 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime2: |
|
297 pri = EPriorityAbsoluteRealTime2; |
|
298 break; |
|
299 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime3: |
|
300 pri = EPriorityAbsoluteRealTime3; |
|
301 break; |
|
302 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime4: |
|
303 pri = EPriorityAbsoluteRealTime4; |
|
304 break; |
|
305 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime5: |
|
306 pri = EPriorityAbsoluteRealTime5; |
|
307 break; |
|
308 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime6: |
|
309 pri = EPriorityAbsoluteRealTime6; |
|
310 break; |
|
311 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime7: |
|
312 pri = EPriorityAbsoluteRealTime7; |
|
313 break; |
|
314 case EMemSpyCmdThreadSetPriorityAbsoluteRealTime8: |
|
315 pri = EPriorityAbsoluteRealTime8; |
|
316 break; |
|
317 } |
|
318 |
|
319 #ifdef _DEBUG |
|
320 RDebug::Printf( "CMemSpyViewThreads::OnCmdSetPriorityL() - pri: %d", pri ); |
|
321 #endif |
|
322 |
|
323 CMemSpyThread& thread = CurrentThread(); |
|
324 thread.SetPriorityL( pri ); |
|
325 RefreshL(); |
|
326 |
|
327 #ifdef _DEBUG |
|
328 RDebug::Printf( "CMemSpyViewThreads::OnCmdSetPriorityL() - END" ); |
|
329 #endif |
|
330 */ |
|
331 } |
|
332 |
|
333 |
|
334 void CMemSpyViewThreads::OnCmdInfoHandlesL() |
|
335 { |
|
336 /* |
|
337 CMemSpyThread& thread = CurrentThread(); |
|
338 thread.InfoContainerForceSyncronousConstructionL().PrintL(); |
|
339 */ |
|
340 } |
|
341 |
|
342 |
|
343 void CMemSpyViewThreads::SetListBoxModelL() |
|
344 { |
|
345 iMemSpySession.GetThreadsL( iParentProcessId, iThreads ); |
|
346 |
|
347 iModel = new (ELeave) CDesC16ArrayFlat( iThreads.Count() ); //array for formated items |
|
348 |
|
349 _LIT( KTab, "\t" ); |
|
350 |
|
351 |
|
352 for( TInt i=0; i < iThreads.Count(); i++ ) |
|
353 { |
|
354 HBufC* tempName = HBufC::NewL( iThreads[i]->Name().Length() + 16 ); |
|
355 CleanupStack::PushL( tempName ); |
|
356 TPtr tempNamePtr( tempName->Des() ); |
|
357 tempNamePtr.Copy( KTab ); |
|
358 tempNamePtr.Append( iThreads[i]->Name() ); |
|
359 iModel->AppendL( tempNamePtr ); |
|
360 |
|
361 CleanupStack::PopAndDestroy( tempName ); |
|
362 } |
|
363 |
|
364 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
365 //listbox->Model()->SetItemTextArray( &iParentProcess ); |
|
366 listbox->Model()->SetItemTextArray( iModel ); |
|
367 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
368 } |
|
369 |
|
370 |
|
371 void CMemSpyViewThreads::HandleListBoxItemActionedL( TInt /*aIndex*/ ) |
|
372 { |
|
373 // Notify observer about an item being 'fired' |
|
374 ReportEventL( MMemSpyViewObserver::EEventItemActioned ); |
|
375 } |
|
376 |
|
377 |
|
378 void CMemSpyViewThreads::HandleListBoxItemSelectedL( TInt aIndex ) |
|
379 { |
|
380 iCurrentThreadId = iThreads[ aIndex ]->Id(); |
|
381 |
|
382 // Notify observer about item selection |
|
383 ReportEventL( MMemSpyViewObserver::EEventItemSelected ); |
|
384 } |
|
385 |
|
386 |
|
387 |