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 "MemSpyViewThreadInfoItemGeneric.h" |
|
19 |
|
20 // System includes |
|
21 #include <AknWaitDialog.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 "MemSpyViewThreadInfoItemList.h" |
|
37 #include "MemSpyUiUtils.h" |
|
38 |
|
39 // Constants |
|
40 const TInt KMemSpyConstructionCheckerTimerPeriod = 500000; // 1/2 second |
|
41 |
|
42 CMemSpyViewThreadInfoItemGeneric::CMemSpyViewThreadInfoItemGeneric( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aProcessId, TThreadId aId, TMemSpyThreadInfoItemType aType ) |
|
43 : CMemSpyViewBase( aSession, aObserver )//, iThreadId( aId ), iType( aType ) //iContainer( aInfoContainer ) |
|
44 { |
|
45 iParentProcessId = aProcessId; |
|
46 iThreadId = aId; |
|
47 iType = aType; |
|
48 } |
|
49 |
|
50 |
|
51 CMemSpyViewThreadInfoItemGeneric::~CMemSpyViewThreadInfoItemGeneric() |
|
52 {/* TODO: |
|
53 if ( iInfoItem ) |
|
54 { |
|
55 iInfoItem->Close(); |
|
56 } |
|
57 DestroyWaitNote(); |
|
58 */ |
|
59 } |
|
60 |
|
61 |
|
62 void CMemSpyViewThreadInfoItemGeneric::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
63 { |
|
64 const TPtrC pTitle( MemSpyUiUtils::ThreadInfoItemNameByType( iType ) ); |
|
65 SetTitleL( pTitle ); |
|
66 |
|
67 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
68 } |
|
69 |
|
70 |
|
71 CMemSpyProcess& CMemSpyViewThreadInfoItemGeneric::Process() const |
|
72 { |
|
73 // return iContainer.Thread().Process(); |
|
74 } |
|
75 |
|
76 |
|
77 CMemSpyThread& CMemSpyViewThreadInfoItemGeneric::Thread() const |
|
78 { |
|
79 // return iContainer.Thread(); |
|
80 } |
|
81 |
|
82 |
|
83 CMemSpyThreadInfoContainer& CMemSpyViewThreadInfoItemGeneric::Container() const |
|
84 { |
|
85 // return iContainer; |
|
86 } |
|
87 |
|
88 |
|
89 CMemSpyThreadInfoItemBase& CMemSpyViewThreadInfoItemGeneric::InfoItem() const |
|
90 { |
|
91 // __ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() ); |
|
92 // return *iInfoItem; |
|
93 } |
|
94 |
|
95 |
|
96 void CMemSpyViewThreadInfoItemGeneric::RefreshL() |
|
97 { |
|
98 // iInfoItem->RebuildL(); //TODO |
|
99 SetListBoxModelL(); |
|
100 CMemSpyViewBase::RefreshL(); |
|
101 } |
|
102 |
|
103 |
|
104 TMemSpyViewType CMemSpyViewThreadInfoItemGeneric::ViewType() const |
|
105 { |
|
106 TMemSpyViewType type = EMemSpyViewTypeNone; |
|
107 // |
|
108 //switch( iInfoItem->Type() ) |
|
109 switch( iType ) |
|
110 { |
|
111 case EMemSpyThreadInfoItemTypeHeap: |
|
112 type = EMemSpyViewTypeThreadInfoItemHeap; |
|
113 break; |
|
114 case EMemSpyThreadInfoItemTypeStack: |
|
115 type = EMemSpyViewTypeThreadInfoItemStack; |
|
116 break; |
|
117 case EMemSpyThreadInfoItemTypeChunk: |
|
118 type = EMemSpyViewTypeThreadInfoItemChunk; |
|
119 break; |
|
120 case EMemSpyThreadInfoItemTypeCodeSeg: |
|
121 type = EMemSpyViewTypeThreadInfoItemCodeSeg; |
|
122 break; |
|
123 case EMemSpyThreadInfoItemTypeServer: |
|
124 type = EMemSpyViewTypeThreadInfoItemServer; |
|
125 break; |
|
126 case EMemSpyThreadInfoItemTypeSession: |
|
127 type = EMemSpyViewTypeThreadInfoItemSession; |
|
128 break; |
|
129 case EMemSpyThreadInfoItemTypeSemaphore: |
|
130 type = EMemSpyViewTypeThreadInfoItemSemaphore; |
|
131 break; |
|
132 case EMemSpyThreadInfoItemTypeMutex: |
|
133 type = EMemSpyViewTypeThreadInfoItemMutex; |
|
134 break; |
|
135 case EMemSpyThreadInfoItemTypeTimer: |
|
136 type = EMemSpyViewTypeThreadInfoItemTimer; |
|
137 break; |
|
138 case EMemSpyThreadInfoItemTypeLDD: |
|
139 type = EMemSpyViewTypeThreadInfoItemLDD; |
|
140 break; |
|
141 case EMemSpyThreadInfoItemTypePDD: |
|
142 type = EMemSpyViewTypeThreadInfoItemPDD; |
|
143 break; |
|
144 case EMemSpyThreadInfoItemTypeLogicalChannel: |
|
145 type = EMemSpyViewTypeThreadInfoItemLogicalChannel; |
|
146 break; |
|
147 case EMemSpyThreadInfoItemTypeChangeNotifier: |
|
148 type = EMemSpyViewTypeThreadInfoItemChangeNotifier; |
|
149 break; |
|
150 case EMemSpyThreadInfoItemTypeUndertaker: |
|
151 type = EMemSpyViewTypeThreadInfoItemUndertaker; |
|
152 break; |
|
153 case EMemSpyThreadInfoItemTypeMessageQueue: |
|
154 type = EMemSpyViewTypeThreadInfoItemMessageQueue; |
|
155 break; |
|
156 case EMemSpyThreadInfoItemTypeConditionalVariable: |
|
157 type = EMemSpyViewTypeThreadInfoItemConditionalVariable; |
|
158 break; |
|
159 case EMemSpyThreadInfoItemTypeOpenFiles: |
|
160 type = EMemSpyViewTypeThreadInfoItemOpenFiles; |
|
161 break; |
|
162 case EMemSpyThreadInfoItemTypeActiveObject: |
|
163 type = EMemSpyViewTypeThreadInfoItemActiveObject; |
|
164 break; |
|
165 case EMemSpyThreadInfoItemTypeGeneralInfo: |
|
166 type = EMemSpyViewTypeThreadInfoItemGeneralInfo; |
|
167 break; |
|
168 case EMemSpyThreadInfoItemTypeOtherThreads: |
|
169 type = EMemSpyViewTypeThreadInfoItemOtherThreads; |
|
170 break; |
|
171 case EMemSpyThreadInfoItemTypeOtherProcesses: |
|
172 type = EMemSpyViewTypeThreadInfoItemOtherProcesses; |
|
173 break; |
|
174 case EMemSpyThreadInfoItemTypeOwnedThreadHandles: |
|
175 type = EMemSpyViewTypeThreadInfoItemOwnedThreadHandles; |
|
176 break; |
|
177 case EMemSpyThreadInfoItemTypeOwnedProcessHandles: |
|
178 type = EMemSpyViewTypeThreadInfoItemOwnedProcessHandles; |
|
179 break; |
|
180 |
|
181 default: |
|
182 //__ASSERT_DEBUG( EFalse, User::Invariant() ); |
|
183 break; |
|
184 } |
|
185 // |
|
186 return type; |
|
187 } |
|
188 |
|
189 |
|
190 CMemSpyViewBase* CMemSpyViewThreadInfoItemGeneric::PrepareParentViewL() |
|
191 { |
|
192 CMemSpyViewThreadInfoItemList* parent = new(ELeave) CMemSpyViewThreadInfoItemList( iMemSpySession, iObserver, iParentProcessId, iThreadId ); |
|
193 CleanupStack::PushL( parent ); |
|
194 parent->ConstructL( Rect(), *Parent(), iType ); |
|
195 CleanupStack::Pop( parent ); |
|
196 return parent; |
|
197 } |
|
198 |
|
199 |
|
200 CMemSpyViewBase* CMemSpyViewThreadInfoItemGeneric::PrepareChildViewL() |
|
201 { |
|
202 //__ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() ); |
|
203 CMemSpyViewBase* child = NULL; |
|
204 // |
|
205 return child; |
|
206 } |
|
207 |
|
208 |
|
209 TBool CMemSpyViewThreadInfoItemGeneric::HandleCommandL( TInt aCommand ) |
|
210 { |
|
211 TBool handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
212 return handled; |
|
213 } |
|
214 |
|
215 |
|
216 void CMemSpyViewThreadInfoItemGeneric::SetListBoxModelL() |
|
217 { |
|
218 iMemSpySession.GetThreadInfoItems( iThreadInfoItems, iThreadId, iType ); |
|
219 |
|
220 iModel = new (ELeave) CDesC16ArrayFlat( iThreadInfoItems.Count() + 10 ); |
|
221 |
|
222 for( TInt i=0; i<iThreadInfoItems.Count(); i++) |
|
223 { |
|
224 HBufC* combined = HBufC::NewLC( iThreadInfoItems[i]->Caption().Length() + iThreadInfoItems[i]->Value().Length() + 30 ); |
|
225 /* |
|
226 else if ( combined->Des().MaxLength() < requiredLength ) |
|
227 { |
|
228 combined = combined->ReAllocL( requiredLength ); |
|
229 }*/ |
|
230 |
|
231 TPtr pCombined( combined->Des() ); |
|
232 pCombined.Zero(); |
|
233 pCombined.Copy( _L("\t") ); |
|
234 if( iThreadInfoItems[i]->Caption() != KNullDesC ) |
|
235 pCombined.Append( iThreadInfoItems[i]->Caption() ); |
|
236 if( iType != EMemSpyThreadInfoItemTypeChunk ) |
|
237 { |
|
238 pCombined.Append( _L("\t\t") ); |
|
239 pCombined.Append( iThreadInfoItems[i]->Value() ); |
|
240 } |
|
241 |
|
242 iModel->AppendL( pCombined ); |
|
243 } |
|
244 |
|
245 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
246 //listbox->Model()->SetItemTextArray( iInfoItem ); |
|
247 listbox->Model()->SetItemTextArray( iModel ); |
|
248 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
249 } |
|
250 |
|
251 |
|
252 void CMemSpyViewThreadInfoItemGeneric::HandleListBoxItemActionedL( TInt /*aIndex*/ ) |
|
253 { |
|
254 // Notify observer about an item being 'fired' |
|
255 ReportEventL( MMemSpyViewObserver::EEventItemActioned ); |
|
256 } |
|
257 |
|
258 |
|
259 void CMemSpyViewThreadInfoItemGeneric::HandleListBoxItemSelectedL( TInt /*aIndex*/ ) |
|
260 { |
|
261 // Notify observer about item selection |
|
262 ReportEventL( MMemSpyViewObserver::EEventItemSelected ); |
|
263 } |
|
264 |
|
265 |
|
266 |
|
267 void CMemSpyViewThreadInfoItemGeneric::ShowWaitNoteL() |
|
268 { |
|
269 // Ugly, but I'm not adding an observer mechanism just for this wait dialog. |
|
270 // __ASSERT_ALWAYS( iWaitConstructionChecker == NULL, User::Invariant() ); |
|
271 iWaitConstructionChecker = CPeriodic::NewL( CActive::EPriorityLow ); |
|
272 iWaitConstructionChecker->Start( KMemSpyConstructionCheckerTimerPeriod, |
|
273 KMemSpyConstructionCheckerTimerPeriod, |
|
274 TCallBack( CheckForItemConstructionComplete, this ) ); |
|
275 |
|
276 if ( !iWaitNote ) |
|
277 { |
|
278 iWaitNote = new ( ELeave ) CAknWaitDialog( reinterpret_cast<CEikDialog**> ( &iWaitNote ), ETrue ); |
|
279 iWaitNote->ExecuteDlgLD( CAknNoteDialog::ENoTone, R_MEMSPY_PREPARING_INFO_ITEM_CONTAINER_WAIT_NOTE ); |
|
280 } |
|
281 } |
|
282 |
|
283 |
|
284 void CMemSpyViewThreadInfoItemGeneric::DestroyWaitNote() |
|
285 { |
|
286 #ifdef _DEBUG |
|
287 RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::DestroyWaitNote() - START" ); |
|
288 #endif |
|
289 // |
|
290 delete iWaitConstructionChecker; |
|
291 iWaitConstructionChecker = NULL; |
|
292 // |
|
293 if ( iWaitNote ) |
|
294 { |
|
295 TRAP_IGNORE( iWaitNote->ProcessFinishedL() ); // deletes the dialog |
|
296 iWaitNote = NULL; |
|
297 } |
|
298 // |
|
299 #ifdef _DEBUG |
|
300 RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::DestroyWaitNote() - END" ); |
|
301 #endif |
|
302 } |
|
303 |
|
304 |
|
305 TInt CMemSpyViewThreadInfoItemGeneric::CheckForItemConstructionComplete( TAny* aSelf ) |
|
306 { |
|
307 /* |
|
308 CMemSpyViewThreadInfoItemGeneric& self = *reinterpret_cast< CMemSpyViewThreadInfoItemGeneric* >( aSelf ); |
|
309 */ |
|
310 // |
|
311 #ifdef _DEBUG |
|
312 /* RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::CheckForItemConstructionComplete() - ready status: %d, iType: %d", self.iInfoItem->IsReady(), self.iInfoItem->Type() );*/ |
|
313 #endif |
|
314 // |
|
315 /* |
|
316 TBool callAgain = ETrue; |
|
317 if ( self.iInfoItem->IsReady() ) |
|
318 { |
|
319 self.DestroyWaitNote(); |
|
320 callAgain = EFalse; |
|
321 } |
|
322 // |
|
323 return callAgain; |
|
324 */ |
|
325 } |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|