|
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 "MemSpyViewServerList.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 #include <memspysession.h> |
|
31 |
|
32 // User includes |
|
33 #include "MemSpyUiUtils.h" |
|
34 #include "MemSpyViewMainMenu.h" |
|
35 #include "MemSpyViewProcesses.h" |
|
36 #include "MemSpyContainerObserver.h" |
|
37 |
|
38 |
|
39 |
|
40 /* |
|
41 CMemSpyViewServerList::CMemSpyViewServerList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver ) |
|
42 : CMemSpyViewBase( aEngine, aObserver ) |
|
43 { |
|
44 } |
|
45 */ |
|
46 CMemSpyViewServerList::CMemSpyViewServerList( RMemSpySession& aSession, MMemSpyViewObserver& aObserver ) |
|
47 : CMemSpyViewBase( aSession, aObserver ) |
|
48 { |
|
49 } |
|
50 |
|
51 |
|
52 |
|
53 CMemSpyViewServerList::~CMemSpyViewServerList() |
|
54 { |
|
55 delete iList; |
|
56 } |
|
57 |
|
58 |
|
59 void CMemSpyViewServerList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
60 { |
|
61 iSort = ESortServByName; |
|
62 _LIT( KTitle, "Running Servers" ); |
|
63 SetTitleL( KTitle ); |
|
64 // |
|
65 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
66 } |
|
67 |
|
68 |
|
69 TBool CMemSpyViewServerList::HandleCommandL( TInt aCommand ) |
|
70 { |
|
71 TBool handled = ETrue; |
|
72 // |
|
73 switch ( aCommand ) |
|
74 { |
|
75 case EMemSpyCmdServerListSortByName: |
|
76 OnCmdServerListSortByNameL(); |
|
77 break; |
|
78 case EMemSpyCmdServerListSortBySessionCount: |
|
79 OnCmdServerListSortBySessionCountL(); |
|
80 break; |
|
81 case EMemSpyCmdServerListOutputListCSV: |
|
82 OnCmdServerListOutputSummaryL(); |
|
83 break; |
|
84 case EMemSpyCmdServerListOutputListDetailed: |
|
85 OnCmdServerListOutputDetailedL(); |
|
86 break; |
|
87 |
|
88 default: |
|
89 handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
90 break; |
|
91 } |
|
92 // |
|
93 return handled; |
|
94 } |
|
95 |
|
96 |
|
97 void CMemSpyViewServerList::RefreshL() |
|
98 { |
|
99 SetListBoxModelL(); |
|
100 CMemSpyViewBase::RefreshL(); |
|
101 } |
|
102 |
|
103 |
|
104 TMemSpyViewType CMemSpyViewServerList::ViewType() const |
|
105 { |
|
106 return EMemSpyViewTypeServerList; |
|
107 } |
|
108 |
|
109 |
|
110 CMemSpyViewBase* CMemSpyViewServerList::PrepareParentViewL() |
|
111 { |
|
112 CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iMemSpySession, iObserver ); |
|
113 CleanupStack::PushL( parent ); |
|
114 parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() ); |
|
115 CleanupStack::Pop( parent ); |
|
116 return parent; |
|
117 } |
|
118 |
|
119 |
|
120 CMemSpyViewBase* CMemSpyViewServerList::PrepareChildViewL() |
|
121 { |
|
122 CMemSpyViewBase* child = NULL; |
|
123 |
|
124 if ( iActionedItemIndex ) |
|
125 { |
|
126 child = new(ELeave) CMemSpyViewProcesses( iMemSpySession, iObserver, iServers[iActionedItemIndex]->Id() ); |
|
127 CleanupStack::PushL( child ); |
|
128 child->ConstructL( Rect(), *Parent() ); |
|
129 CleanupStack::Pop( child ); |
|
130 } |
|
131 // |
|
132 |
|
133 return child; |
|
134 } |
|
135 |
|
136 void CMemSpyViewServerList::SetListBoxModelL() |
|
137 { |
|
138 TInt err = KErrNone; |
|
139 iModel = NULL; |
|
140 |
|
141 TRAP( err, iMemSpySession.GetServersL( iServers, iSort ) ); |
|
142 |
|
143 if ( err == KErrNone ) |
|
144 { |
|
145 iModel = new (ELeave) CDesC16ArrayFlat( iServers.Count() ); //array for formated items |
|
146 _LIT(KSession, "session"); |
|
147 |
|
148 for( TInt i = 0; i < iServers.Count(); i++ ) |
|
149 { |
|
150 HBufC* combined = HBufC::NewLC( iServers[i]->Name().Length() + 128 ); |
|
151 |
|
152 TPtr pCombined( combined->Des() ); |
|
153 pCombined.Zero(); |
|
154 pCombined.Copy( _L("\t") ); |
|
155 |
|
156 if( iServers[i]->Name() != KNullDesC ) |
|
157 { |
|
158 pCombined.Append( iServers[i]->Name() ); |
|
159 } |
|
160 |
|
161 pCombined.Append( _L("\t\t") ); |
|
162 TBuf<16> count; |
|
163 _LIT( KCount, "%d session"); |
|
164 |
|
165 count.Format( KCount, iServers[i]->SessionCount() ); |
|
166 pCombined.Append( count ); |
|
167 |
|
168 if( iServers[i]->SessionCount() != 1 ) |
|
169 { |
|
170 _LIT( KS, "s" ); |
|
171 pCombined.Append( KS ); |
|
172 } |
|
173 |
|
174 iModel->AppendL( pCombined ); |
|
175 |
|
176 CleanupStack::PopAndDestroy(combined); |
|
177 } |
|
178 } |
|
179 |
|
180 // |
|
181 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
182 listbox->Model()->SetItemTextArray( iModel ); |
|
183 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
184 } |
|
185 |
|
186 |
|
187 void CMemSpyViewServerList::HandleListBoxItemActionedL( TInt aCurrentIndex ) |
|
188 { |
|
189 if ( aCurrentIndex >= 0 && aCurrentIndex < iServers.Count() ) |
|
190 { |
|
191 iActionedItemIndex = aCurrentIndex; |
|
192 } |
|
193 else |
|
194 { |
|
195 iActionedItem = NULL; |
|
196 } |
|
197 |
|
198 // Notify observer about an item being 'fired' |
|
199 ReportEventL( MMemSpyViewObserver::EEventItemActioned ); |
|
200 } |
|
201 |
|
202 |
|
203 void CMemSpyViewServerList::OnCmdServerListSortByNameL() |
|
204 { |
|
205 iSort = ESortServByName; |
|
206 RefreshL(); |
|
207 } |
|
208 |
|
209 |
|
210 void CMemSpyViewServerList::OnCmdServerListSortBySessionCountL() |
|
211 { |
|
212 iSort = ESortServBySessionCount; |
|
213 RefreshL(); |
|
214 } |
|
215 |
|
216 |
|
217 void CMemSpyViewServerList::OnCmdServerListOutputSummaryL() |
|
218 { |
|
219 OnCmdServerListOutputGenericL( EFalse ); |
|
220 } |
|
221 |
|
222 |
|
223 void CMemSpyViewServerList::OnCmdServerListOutputDetailedL() |
|
224 { |
|
225 OnCmdServerListOutputGenericL( ETrue ); |
|
226 } |
|
227 |
|
228 |
|
229 void CMemSpyViewServerList::OnCmdServerListOutputGenericL( TBool aDetailed ) |
|
230 { |
|
231 iMemSpySession.ServerListOutputGenericL( aDetailed ); |
|
232 } |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |