|
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 "MemSpyViewThreadInfoItemActiveObject.h" |
|
19 |
|
20 // Engine includes |
|
21 #include <memspy/engine/memspyengine.h> |
|
22 #include <memspy/engine/memspyengineobjectprocess.h> |
|
23 #include <memspy/engine/memspyengineobjectthread.h> |
|
24 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
25 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h> |
|
26 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h> |
|
27 #include <memspy/engine/memspyenginehelperactiveobject.h> |
|
28 |
|
29 // User includes |
|
30 #include "MemSpyContainerObserver.h" |
|
31 |
|
32 |
|
33 |
|
34 CMemSpyViewThreadInfoItemActiveObjectBase::CMemSpyViewThreadInfoItemActiveObjectBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer ) |
|
35 : CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeActiveObject ) |
|
36 { |
|
37 } |
|
38 |
|
39 |
|
40 TBool CMemSpyViewThreadInfoItemActiveObjectBase::HandleCommandL( TInt aCommand ) |
|
41 { |
|
42 TBool handled = ETrue; |
|
43 // |
|
44 switch ( aCommand ) |
|
45 { |
|
46 case EMemSpyCmdActiveObjectListing: |
|
47 OnCmdWriteAOListingL(); |
|
48 break; |
|
49 default: |
|
50 handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
51 break; |
|
52 } |
|
53 // |
|
54 return handled; |
|
55 } |
|
56 |
|
57 |
|
58 void CMemSpyViewThreadInfoItemActiveObjectBase::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
59 { |
|
60 if ( aResourceId == R_MEMSPY_MENUPANE ) |
|
61 { |
|
62 aMenuPane->SetItemDimmed( EMemSpyCmdActiveObject, Thread().IsDead() ); |
|
63 } |
|
64 } |
|
65 |
|
66 |
|
67 CMemSpyEngineActiveObjectArray& CMemSpyViewThreadInfoItemActiveObjectBase::ActiveObjectArray() const |
|
68 { |
|
69 CMemSpyThreadInfoActiveObjects* activeObjectArray = static_cast< CMemSpyThreadInfoActiveObjects* >( iInfoItem ); |
|
70 return activeObjectArray->Array(); |
|
71 } |
|
72 |
|
73 |
|
74 void CMemSpyViewThreadInfoItemActiveObjectBase::OnCmdWriteAOListingL() |
|
75 { |
|
76 CMemSpyEngineActiveObjectArray& objects = ActiveObjectArray(); |
|
77 |
|
78 // Begin a new data stream |
|
79 _LIT( KMemSpyContext, "Active Object List - " ); |
|
80 _LIT( KMemSpyFolder, "Active Objects" ); |
|
81 iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder ); |
|
82 |
|
83 // Set prefix for overall listing |
|
84 iEngine.Sink().OutputPrefixSetLC( KMemSpyContext ); |
|
85 |
|
86 // Create header |
|
87 CMemSpyEngineActiveObjectArray::OutputDataColumnsL( iEngine ); |
|
88 |
|
89 // List items |
|
90 const TInt count = objects.Count(); |
|
91 for(TInt i=0; i<count; i++) |
|
92 { |
|
93 const CMemSpyEngineActiveObject& object = objects.At( i ); |
|
94 // |
|
95 object.OutputDataL( iEngine ); |
|
96 } |
|
97 |
|
98 // Tidy up |
|
99 CleanupStack::PopAndDestroy(); // prefix |
|
100 |
|
101 // End data stream |
|
102 iEngine.Sink().DataStreamEndL(); |
|
103 } |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 CMemSpyViewThreadInfoItemActiveObject::CMemSpyViewThreadInfoItemActiveObject( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer ) |
|
116 : CMemSpyViewThreadInfoItemActiveObjectBase( aEngine, aObserver, aContainer ) |
|
117 { |
|
118 } |
|
119 |
|
120 |
|
121 void CMemSpyViewThreadInfoItemActiveObject::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
122 { |
|
123 // Causes list of server's to be prepared |
|
124 CMemSpyViewThreadInfoItemActiveObjectBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
125 |
|
126 _LIT( KTitle, "Active Objects" ); |
|
127 SetTitleL( KTitle ); |
|
128 |
|
129 // Try to select the correct server |
|
130 CMemSpyThreadInfoHandleObjectBase* infoItem = static_cast< CMemSpyThreadInfoHandleObjectBase* >( iInfoItem ); |
|
131 TInt selectedIndex = 0; |
|
132 if ( aSelectionRune ) |
|
133 { |
|
134 CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray(); |
|
135 const TInt index = activeObjectArray.ObjectIndexByAddress( aSelectionRune ); |
|
136 if ( index >= 0 && index < activeObjectArray.Count() ) |
|
137 { |
|
138 selectedIndex = index + 1; |
|
139 } |
|
140 } |
|
141 |
|
142 // Select item |
|
143 if ( infoItem->DetailsCount() > 0 ) |
|
144 { |
|
145 iListBox->SetCurrentItemIndex( selectedIndex ); |
|
146 HandleListBoxItemSelectedL( selectedIndex ); |
|
147 } |
|
148 } |
|
149 |
|
150 |
|
151 TMemSpyViewType CMemSpyViewThreadInfoItemActiveObject::ViewType() const |
|
152 { |
|
153 return EMemSpyViewTypeThreadInfoItemActiveObject; |
|
154 } |
|
155 |
|
156 |
|
157 CMemSpyViewBase* CMemSpyViewThreadInfoItemActiveObject::PrepareChildViewL() |
|
158 { |
|
159 CMemSpyViewBase* child = NULL; |
|
160 |
|
161 // Get current entry address |
|
162 TInt index = iListBox->CurrentItemIndex(); |
|
163 if ( index > 0 ) |
|
164 { |
|
165 --index; |
|
166 CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray(); |
|
167 // |
|
168 if ( index >= 0 && index < activeObjectArray.MdcaCount() ) |
|
169 { |
|
170 CMemSpyEngineActiveObject& object = activeObjectArray.At( index ); |
|
171 TAny* aoAddress = object.Address(); |
|
172 // |
|
173 child = new(ELeave) CMemSpyViewThreadInfoItemActiveObjectDetails( iEngine, iObserver, iInfoItem->Container(), aoAddress ); |
|
174 CleanupStack::PushL( child ); |
|
175 child->ConstructL( Rect(), *Parent(), NULL ); |
|
176 CleanupStack::Pop( child ); |
|
177 } |
|
178 } |
|
179 // |
|
180 return child; |
|
181 } |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 CMemSpyViewThreadInfoItemActiveObjectDetails::CMemSpyViewThreadInfoItemActiveObjectDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, TAny* aObjectAddress ) |
|
194 : CMemSpyViewThreadInfoItemActiveObjectBase( aEngine, aObserver, aContainer ), iObjectAddress( aObjectAddress ) |
|
195 { |
|
196 } |
|
197 |
|
198 |
|
199 void CMemSpyViewThreadInfoItemActiveObjectDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
200 { |
|
201 CMemSpyViewThreadInfoItemActiveObjectBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
202 |
|
203 _LIT( KTitle, "Active Object Details" ); |
|
204 SetTitleL( KTitle ); |
|
205 } |
|
206 |
|
207 |
|
208 TMemSpyViewType CMemSpyViewThreadInfoItemActiveObjectDetails::ViewType() const |
|
209 { |
|
210 return EMemSpyViewTypeThreadInfoItemActiveObjectDetails; |
|
211 } |
|
212 |
|
213 |
|
214 CMemSpyViewBase* CMemSpyViewThreadInfoItemActiveObjectDetails::PrepareParentViewL() |
|
215 { |
|
216 CMemSpyViewThreadInfoItemActiveObject* parent = new(ELeave) CMemSpyViewThreadInfoItemActiveObject( iEngine, iObserver, iInfoItem->Container() ); |
|
217 CleanupStack::PushL( parent ); |
|
218 parent->ConstructL( Rect(), *Parent(), iObjectAddress ); |
|
219 CleanupStack::Pop( parent ); |
|
220 return parent; |
|
221 } |
|
222 |
|
223 |
|
224 void CMemSpyViewThreadInfoItemActiveObjectDetails::SetListBoxModelL() |
|
225 { |
|
226 // Try to find the right entry |
|
227 CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray(); |
|
228 const TInt index = activeObjectArray.ObjectIndexByAddress( iObjectAddress ); |
|
229 User::LeaveIfError( index ); |
|
230 CMemSpyEngineActiveObject& object = activeObjectArray.At( index ); |
|
231 // |
|
232 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
233 listbox->Model()->SetItemTextArray( &object ); |
|
234 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
235 } |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |