|
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 "MemSpyViewThreadInfoItemServer.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/memspyenginehelperprocess.h> |
|
28 #include <memspy/engine/memspyenginehelperheap.h> |
|
29 #include <memspy/engine/memspyenginehelperserver.h> |
|
30 |
|
31 // User includes |
|
32 #include "MemSpyContainerObserver.h" |
|
33 |
|
34 // Constants |
|
35 const TInt KMemSpyServerSessionsIndex = 2; |
|
36 |
|
37 |
|
38 |
|
39 CMemSpyViewThreadInfoItemServer::CMemSpyViewThreadInfoItemServer( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aProcId, TThreadId aId, TMemSpyThreadInfoItemType aType ) |
|
40 : CMemSpyViewThreadInfoItemGeneric( aSession, aObserver, aProcId, aId, EMemSpyThreadInfoItemTypeServer ) |
|
41 { |
|
42 } |
|
43 |
|
44 |
|
45 void CMemSpyViewThreadInfoItemServer::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
46 { |
|
47 // Causes list of server's to be prepared |
|
48 CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune ); |
|
49 |
|
50 _LIT( KTitle, "Server List" ); |
|
51 SetTitleL( KTitle ); |
|
52 |
|
53 #ifdef _DEBUG |
|
54 RDebug::Printf( "CMemSpyViewThreadInfoItemServer::ConstructL() - aSelectionRune: 0x%08x", aSelectionRune ); |
|
55 #endif |
|
56 /* TODO |
|
57 // Try to select the correct server |
|
58 CMemSpyThreadInfoHandleObjectBase* infoItem = static_cast< CMemSpyThreadInfoHandleObjectBase* >( iInfoItem ); |
|
59 */ |
|
60 TInt selectedIndex = 0; |
|
61 /*if ( aSelectionRune ) |
|
62 { |
|
63 // Treat the rune as a handle, and try to look it up |
|
64 selectedIndex = infoItem->DetailsIndexByHandle( aSelectionRune ); |
|
65 } |
|
66 |
|
67 // Select item |
|
68 if ( infoItem->DetailsCount() > 0 ) |
|
69 {*/ |
|
70 iListBox->SetCurrentItemIndex( selectedIndex ); |
|
71 HandleListBoxItemSelectedL( selectedIndex ); |
|
72 /*}*/ |
|
73 } |
|
74 |
|
75 |
|
76 TBool CMemSpyViewThreadInfoItemServer::HandleCommandL( TInt aCommand ) |
|
77 { |
|
78 TBool handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
79 return handled; |
|
80 } |
|
81 |
|
82 |
|
83 CMemSpyViewBase* CMemSpyViewThreadInfoItemServer::PrepareChildViewL() |
|
84 { |
|
85 /* |
|
86 CMemSpyViewThreadInfoItemServerDetails* child = new(ELeave) CMemSpyViewThreadInfoItemServerDetails( iEngine, iObserver, iContainer, iCurrentInfoItemDetails ); |
|
87 CleanupStack::PushL( child ); |
|
88 child->ConstructL( Rect(), *Parent() ); |
|
89 CleanupStack::Pop( child ); |
|
90 return child; |
|
91 */ |
|
92 } |
|
93 |
|
94 |
|
95 void CMemSpyViewThreadInfoItemServer::HandleListBoxItemSelectedL( TInt aIndex ) |
|
96 {/* TODO |
|
97 // Identify the type of item to display... |
|
98 CMemSpyThreadInfoHandleObjectBase* infoItem = static_cast< CMemSpyThreadInfoHandleObjectBase* >( iInfoItem ); |
|
99 iCurrentInfoItemDetails = infoItem->DetailsAt( aIndex ); |
|
100 |
|
101 #ifdef _DEBUG |
|
102 RDebug::Printf( "CMemSpyViewThreadInfoItemServer::HandleListBoxItemSelectedL() - iCurrentInfoItemDetails.iHandle: 0x%08x", iCurrentInfoItemDetails.iHandle ); |
|
103 #endif |
|
104 */ |
|
105 // Notify observer about item selection |
|
106 ReportEventL( MMemSpyViewObserver::EEventItemSelected ); |
|
107 } |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 /* |
|
134 CMemSpyViewThreadInfoItemServerDetails::CMemSpyViewThreadInfoItemServerDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, const TMemSpyDriverHandleInfoGeneric& aInfoItemDetails ) |
|
135 : CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeServer ), iInfoItemDetails( aInfoItemDetails ) |
|
136 { |
|
137 } |
|
138 |
|
139 |
|
140 void CMemSpyViewThreadInfoItemServerDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
141 { |
|
142 // Causes list of server's to be prepared |
|
143 CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune ); |
|
144 |
|
145 _LIT( KTitle, "Server Details" ); |
|
146 SetTitleL( KTitle ); |
|
147 |
|
148 // Try to select the correct server |
|
149 TInt selectedIndex = 0; |
|
150 if ( aSelectionRune ) |
|
151 { |
|
152 // Presence of non-null item means that we came from the "Server sessions" list |
|
153 selectedIndex = KMemSpyServerSessionsIndex; |
|
154 } |
|
155 |
|
156 // Select item |
|
157 iListBox->SetCurrentItemIndex( selectedIndex ); |
|
158 HandleListBoxItemSelectedL( selectedIndex ); |
|
159 } |
|
160 |
|
161 |
|
162 TBool CMemSpyViewThreadInfoItemServerDetails::HandleCommandL( TInt aCommand ) |
|
163 { |
|
164 TBool handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
165 return handled; |
|
166 } |
|
167 |
|
168 |
|
169 TMemSpyViewType CMemSpyViewThreadInfoItemServerDetails::ViewType() const |
|
170 { |
|
171 return EMemSpyViewTypeThreadInfoItemServerDetails; |
|
172 } |
|
173 |
|
174 |
|
175 CMemSpyViewBase* CMemSpyViewThreadInfoItemServerDetails::PrepareChildViewL() |
|
176 { |
|
177 CMemSpyViewBase* child = NULL; |
|
178 const TInt currentIndex = iListBox->CurrentItemIndex(); |
|
179 // |
|
180 if ( currentIndex == KMemSpyServerSessionsIndex ) |
|
181 { |
|
182 CMemSpyViewThreadInfoItemServerSessions* serverSessions = new(ELeave) CMemSpyViewThreadInfoItemServerSessions( iEngine, iObserver, iInfoItem->Container(), iInfoItemDetails ); |
|
183 CleanupStack::PushL( serverSessions ); |
|
184 serverSessions->ConstructL( Rect(), *Parent(), NULL ); |
|
185 CleanupStack::Pop( serverSessions ); |
|
186 child = serverSessions; |
|
187 } |
|
188 // |
|
189 return child; |
|
190 } |
|
191 |
|
192 |
|
193 CMemSpyViewBase* CMemSpyViewThreadInfoItemServerDetails::PrepareParentViewL() |
|
194 { |
|
195 CMemSpyViewThreadInfoItemServer* parent = new(ELeave) CMemSpyViewThreadInfoItemServer( iEngine, iObserver, iInfoItem->Container() ); |
|
196 CleanupStack::PushL( parent ); |
|
197 parent->ConstructL( Rect(), *Parent(), iInfoItemDetails.iHandle ); |
|
198 CleanupStack::Pop( parent ); |
|
199 return parent; |
|
200 } |
|
201 |
|
202 |
|
203 void CMemSpyViewThreadInfoItemServerDetails::SetListBoxModelL() |
|
204 { |
|
205 CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(4); |
|
206 CleanupStack::PushL( model ); |
|
207 |
|
208 TBuf<KMaxFullName + 1> item; |
|
209 |
|
210 // 1st item = session type |
|
211 const TPtrC pServerSessionType = CMemSpyThreadInfoServer::SessionType( iInfoItemDetails.iSessionType ); |
|
212 _LIT(KItem1Format, "\tServer Type\t\t%S"); |
|
213 item.Format( KItem1Format, &pServerSessionType ); |
|
214 model->AppendL( item ); |
|
215 |
|
216 // 2nd item = session count |
|
217 _LIT(KItem2Format, "\tConnected Sessions\t\t%d"); |
|
218 item.Format( KItem2Format, iInfoItemDetails.iCount ); |
|
219 model->AppendL( item ); |
|
220 |
|
221 // 3rd item = view sessions |
|
222 if ( iInfoItem->Container().MdcaCount() > 0 ) |
|
223 { |
|
224 _LIT(KItem3Format, "\tView Sessions"); |
|
225 model->AppendL( KItem3Format ); |
|
226 } |
|
227 |
|
228 // Set up list box |
|
229 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
230 listbox->Model()->SetItemTextArray( model ); |
|
231 listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
232 CleanupStack::Pop( model ); |
|
233 } |
|
234 |
|
235 */ |
|
236 /* |
|
237 void CMemSpyViewThreadInfoItemServerDetails::HandleListBoxItemActionedL( TInt /*aIndex*/ /*) |
|
238 */ |
|
239 /* |
|
240 { |
|
241 // Notify observer about an item being 'fired' |
|
242 ReportEventL( MMemSpyViewObserver::EEventItemActioned ); |
|
243 } |
|
244 |
|
245 |
|
246 void CMemSpyViewThreadInfoItemServerDetails::HandleListBoxItemSelectedL( TInt /*aIndex*/ /*) |
|
247 */ |
|
248 /* |
|
249 { |
|
250 // Notify observer about item selection |
|
251 ReportEventL( MMemSpyViewObserver::EEventItemSelected ); |
|
252 } |
|
253 */ |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 /* |
|
279 |
|
280 |
|
281 CMemSpyViewThreadInfoItemServerSessions::CMemSpyViewThreadInfoItemServerSessions( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, const TMemSpyDriverHandleInfoGeneric& aInfoItemDetails ) |
|
282 : CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeServer ), iInfoItemDetails( aInfoItemDetails ) |
|
283 { |
|
284 } |
|
285 |
|
286 |
|
287 void CMemSpyViewThreadInfoItemServerSessions::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
288 { |
|
289 CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune ); |
|
290 // |
|
291 _LIT( KTitle, "Connected Session List" ); |
|
292 SetTitleL( KTitle ); |
|
293 } |
|
294 |
|
295 |
|
296 TBool CMemSpyViewThreadInfoItemServerSessions::HandleCommandL( TInt aCommand ) |
|
297 { |
|
298 TBool handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
299 return handled; |
|
300 } |
|
301 |
|
302 |
|
303 TMemSpyViewType CMemSpyViewThreadInfoItemServerSessions::ViewType() const |
|
304 { |
|
305 return EMemSpyViewTypeThreadInfoItemServerSessions; |
|
306 } |
|
307 |
|
308 |
|
309 CMemSpyViewBase* CMemSpyViewThreadInfoItemServerSessions::PrepareParentViewL() |
|
310 { |
|
311 CMemSpyViewThreadInfoItemServerDetails* parent = new(ELeave) CMemSpyViewThreadInfoItemServerDetails( iEngine, iObserver, iInfoItem->Container(), iInfoItemDetails ); |
|
312 CleanupStack::PushL( parent ); |
|
313 parent->ConstructL( Rect(), *Parent(), this ); |
|
314 CleanupStack::Pop( parent ); |
|
315 return parent; |
|
316 } |
|
317 |
|
318 |
|
319 void CMemSpyViewThreadInfoItemServerSessions::SetListBoxModelL() |
|
320 { |
|
321 CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(4); |
|
322 CleanupStack::PushL( model ); |
|
323 |
|
324 // Get handles |
|
325 RArray<TMemSpyDriverServerSessionInfo> sessions; |
|
326 CleanupClosePushL( sessions ); |
|
327 iEngine.HelperServer().GetServerSessionsL( iInfoItemDetails, sessions ); |
|
328 |
|
329 // Prepare items |
|
330 TBuf<KMaxFullName + 1> item; |
|
331 const TInt count = sessions.Count(); |
|
332 for( TInt i=0; i<count; i++ ) |
|
333 { |
|
334 _LIT(KInsertTab, "\t"); |
|
335 |
|
336 const TMemSpyDriverServerSessionInfo& session = sessions[ i ]; |
|
337 item.Zero(); |
|
338 |
|
339 if ( session.iOwnerType == TMemSpyDriverServerSessionInfo::EOwnerThread ) |
|
340 { |
|
341 // Find the thread object |
|
342 CMemSpyThread* thread = NULL; |
|
343 CMemSpyProcess* process = NULL; |
|
344 // |
|
345 const TInt error = iEngine.Container().ProcessAndThreadByThreadId( session.iOwnerId, process, thread ); |
|
346 // |
|
347 if ( error == KErrNone ) |
|
348 { |
|
349 item.Append( process->Name() ); |
|
350 item.Append( KInsertTab ); |
|
351 item.Append( KInsertTab ); |
|
352 item.Append( thread->Name() ); |
|
353 } |
|
354 } |
|
355 else if ( session.iOwnerType == TMemSpyDriverServerSessionInfo::EOwnerProcess ) |
|
356 { |
|
357 // Find the process object |
|
358 CMemSpyProcess* process = NULL; |
|
359 TRAPD( error, process = &iEngine.Container().ProcessByIdL( session.iOwnerId ) ); |
|
360 if ( error == KErrNone ) |
|
361 { |
|
362 item.Append( process->Name() ); |
|
363 } |
|
364 } |
|
365 |
|
366 if ( !item.Length() ) |
|
367 { |
|
368 // Fall-back case |
|
369 item.Copy( session.iName ); |
|
370 } |
|
371 |
|
372 // Add item |
|
373 item.Insert( 0, KInsertTab ); |
|
374 model->AppendL( item ); |
|
375 } |
|
376 CleanupStack::PopAndDestroy( &sessions ); |
|
377 |
|
378 // Set up list box |
|
379 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
380 listbox->Model()->SetItemTextArray( model ); |
|
381 listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
382 CleanupStack::Pop( model ); |
|
383 } |
|
384 |
|
385 */ |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |