51
|
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 "MemSpyViewWindowGroups.h"
|
|
19 |
|
|
20 |
// System includes
|
|
21 |
#include <eikclbd.h>
|
|
22 |
#include <aknmessagequerydialog.h>
|
|
23 |
#include <aknnotewrappers.h>
|
|
24 |
|
|
25 |
// Engine includes
|
|
26 |
#include <memspy/engine/memspyengine.h>
|
|
27 |
#include <memspy/engine/memspyengineobjectcontainer.h>
|
|
28 |
#include <memspy/engine/memspyengineobjectthread.h>
|
|
29 |
|
|
30 |
// User includes
|
|
31 |
#include "MemSpyUiUtils.h"
|
|
32 |
#include "MemSpyViewMainMenu.h"
|
|
33 |
#include "MemSpyContainerObserver.h"
|
|
34 |
|
|
35 |
// Literal constants
|
|
36 |
const TInt KMaxInfoLength = 128;
|
|
37 |
|
|
38 |
|
|
39 |
CMemSpyViewWindowGroups::CMemSpyViewWindowGroups( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
|
|
40 |
: CMemSpyViewBase( aEngine, aObserver )
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
|
|
45 |
CMemSpyViewWindowGroups::~CMemSpyViewWindowGroups()
|
|
46 |
{
|
|
47 |
delete iWindowGroupList;
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
void CMemSpyViewWindowGroups::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
|
|
52 |
{
|
|
53 |
_LIT( KTitle, "Window Groups" );
|
|
54 |
SetTitleL( KTitle );
|
|
55 |
//
|
|
56 |
CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
|
|
57 |
}
|
|
58 |
|
|
59 |
|
|
60 |
CEikListBox* CMemSpyViewWindowGroups::ConstructListBoxL()
|
|
61 |
{
|
|
62 |
delete iListBox;
|
|
63 |
iListBox = NULL;
|
|
64 |
CAknSingleNumberStyleListBox* listbox = new (ELeave) CAknSingleNumberStyleListBox();
|
|
65 |
iListBox = listbox;
|
|
66 |
listbox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxLoopScrolling );
|
|
67 |
listbox->SetContainerWindowL( *this );
|
|
68 |
listbox->CreateScrollBarFrameL( ETrue );
|
|
69 |
SetListBoxModelL();
|
|
70 |
listbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
71 |
listbox->SetListBoxObserver( this );
|
|
72 |
listbox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
|
|
73 |
listbox->SetObserver( this );
|
|
74 |
return listbox;
|
|
75 |
}
|
|
76 |
|
|
77 |
void CMemSpyViewWindowGroups::RefreshL()
|
|
78 |
{
|
|
79 |
SetListBoxModelL();
|
|
80 |
CMemSpyViewBase::RefreshL();
|
|
81 |
}
|
|
82 |
|
|
83 |
|
|
84 |
TMemSpyViewType CMemSpyViewWindowGroups::ViewType() const
|
|
85 |
{
|
|
86 |
return EMemSpyViewTypeWindowGroups;
|
|
87 |
}
|
|
88 |
|
|
89 |
|
|
90 |
CMemSpyViewBase* CMemSpyViewWindowGroups::PrepareParentViewL()
|
|
91 |
{
|
|
92 |
CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
|
|
93 |
CleanupStack::PushL( parent );
|
|
94 |
parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
|
|
95 |
CleanupStack::Pop( parent );
|
|
96 |
return parent;
|
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
CMemSpyViewBase* CMemSpyViewWindowGroups::PrepareChildViewL()
|
|
101 |
{
|
|
102 |
CMemSpyViewBase* child = NULL;
|
|
103 |
if ( iListBox &&
|
|
104 |
iListBox->Model()->NumberOfItems() &&
|
|
105 |
iListBox->CurrentItemIndex() > KErrNotFound )
|
|
106 |
{
|
|
107 |
DetailsL();
|
|
108 |
}
|
|
109 |
return child;
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
void CMemSpyViewWindowGroups::SetListBoxModelL()
|
|
114 |
{
|
|
115 |
// Take ownership of new model
|
|
116 |
MMemSpyEngineHelperWindowServer& windowServerManager = iEngine.HelperWindowServer();
|
|
117 |
MMemSpyEngineWindowGroupList* windowGroupList = windowServerManager.WindowGroupListL();
|
|
118 |
delete iWindowGroupList;
|
|
119 |
iWindowGroupList = windowGroupList;
|
|
120 |
|
|
121 |
// Set up list box
|
|
122 |
CAknSingleNumberStyleListBox* listbox = static_cast< CAknSingleNumberStyleListBox* >( iListBox );
|
|
123 |
listbox->Model()->SetItemTextArray( iWindowGroupList );
|
|
124 |
listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
125 |
}
|
|
126 |
|
|
127 |
|
|
128 |
TBool CMemSpyViewWindowGroups::HandleCommandL( TInt aCommand )
|
|
129 |
{
|
|
130 |
TBool handled = ETrue;
|
|
131 |
//
|
|
132 |
switch ( aCommand )
|
|
133 |
{
|
|
134 |
case EMemSpyCmdWindowGroupTerminate:
|
|
135 |
{
|
|
136 |
TRAPD( err, OnCmdEndL( aCommand ) );
|
|
137 |
CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
|
|
138 |
if ( err )
|
|
139 |
{
|
|
140 |
note->ExecuteLD( _L("Cannot terminate task") );
|
|
141 |
}
|
|
142 |
else
|
|
143 |
{
|
|
144 |
note->ExecuteLD( _L("Task terminated") );
|
|
145 |
}
|
|
146 |
break;
|
|
147 |
}
|
|
148 |
case EMemSpyCmdWindowGroupSwitchTo:
|
|
149 |
{
|
|
150 |
TRAPD( err, OnCmdSwitchToL() );
|
|
151 |
if ( err )
|
|
152 |
{
|
|
153 |
CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
|
|
154 |
note->ExecuteLD( _L("Cannot bring to foreground") );
|
|
155 |
}
|
|
156 |
break;
|
|
157 |
}
|
|
158 |
case EMemSpyCmdWindowGroupEnd:
|
|
159 |
{
|
|
160 |
TRAPD( err, OnCmdEndL( aCommand ) );
|
|
161 |
CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
|
|
162 |
if ( err )
|
|
163 |
{
|
|
164 |
note->ExecuteLD( _L("Cannot end task") );
|
|
165 |
}
|
|
166 |
else
|
|
167 |
{
|
|
168 |
note->ExecuteLD( _L("Task exited") );
|
|
169 |
}
|
|
170 |
break;
|
|
171 |
}
|
|
172 |
case EMemSpyCmdWindowGroupPanic:
|
|
173 |
{
|
|
174 |
TRAPD( err, OnCmdEndL( aCommand ) );
|
|
175 |
CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
|
|
176 |
if ( err )
|
|
177 |
{
|
|
178 |
note->ExecuteLD( _L("Cannot panic task") );
|
|
179 |
}
|
|
180 |
else
|
|
181 |
{
|
|
182 |
note->ExecuteLD( _L("Task panic'ed") );
|
|
183 |
}
|
|
184 |
break;
|
|
185 |
}
|
|
186 |
default:
|
|
187 |
{
|
|
188 |
handled = CMemSpyViewBase::HandleCommandL( aCommand );
|
|
189 |
break;
|
|
190 |
}
|
|
191 |
}
|
|
192 |
//
|
|
193 |
return handled;
|
|
194 |
}
|
|
195 |
|
|
196 |
|
|
197 |
void CMemSpyViewWindowGroups::OnCmdSwitchToL()
|
|
198 |
{
|
|
199 |
MMemSpyEngineHelperWindowServer& windowServerManager = iEngine.HelperWindowServer();
|
|
200 |
TInt id = iWindowGroupList->At( iListBox->CurrentItemIndex() ).iId;
|
|
201 |
windowServerManager.SwitchToL( id );
|
|
202 |
}
|
|
203 |
|
|
204 |
|
|
205 |
void CMemSpyViewWindowGroups::OnCmdEndL( TInt aCommand )
|
|
206 |
{
|
|
207 |
/*
|
|
208 |
TBool doTerminate = ETrue;
|
|
209 |
|
|
210 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
211 |
TThreadId id = iWindowGroupList->At( iListBox->CurrentItemIndex() ).iThreadId;
|
|
212 |
|
|
213 |
// Try to find the thread in question...
|
|
214 |
CMemSpyProcess* process = NULL;
|
|
215 |
CMemSpyThread* thread = NULL;
|
|
216 |
User::LeaveIfError( container.ProcessAndThreadByThreadId( id, process, thread ) );
|
|
217 |
|
|
218 |
if ( thread )
|
|
219 |
{
|
|
220 |
//
|
|
221 |
if ( thread->IsSystemPermanent() || thread->IsSystemCritical() )
|
|
222 |
{
|
|
223 |
CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
|
|
224 |
doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
|
|
225 |
}
|
|
226 |
//
|
|
227 |
if ( doTerminate )
|
|
228 |
{
|
|
229 |
switch ( aCommand )
|
|
230 |
{
|
|
231 |
case EMemSpyCmdWindowGroupTerminate:
|
|
232 |
{
|
|
233 |
thread->TerminateL();
|
|
234 |
break;
|
|
235 |
}
|
|
236 |
case EMemSpyCmdWindowGroupEnd:
|
|
237 |
{
|
|
238 |
thread->KillL();
|
|
239 |
break;
|
|
240 |
}
|
|
241 |
case EMemSpyCmdWindowGroupPanic:
|
|
242 |
{
|
|
243 |
thread->PanicL();
|
|
244 |
break;
|
|
245 |
}
|
|
246 |
default:
|
|
247 |
{
|
|
248 |
// Programming error
|
|
249 |
__ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
|
|
250 |
}
|
|
251 |
}
|
|
252 |
}
|
|
253 |
}
|
|
254 |
RefreshL();
|
|
255 |
*/
|
|
256 |
}
|
|
257 |
|
|
258 |
|
|
259 |
void CMemSpyViewWindowGroups::DetailsL()
|
|
260 |
{
|
|
261 |
HBufC* messageBuf = HBufC::NewLC( 4096 );
|
|
262 |
TPtr messagePtr = messageBuf->Des();
|
|
263 |
|
|
264 |
// Fetch data from helper
|
|
265 |
TMemSpyEngineWindowGroupDetails selectedObject;
|
|
266 |
MMemSpyEngineHelperWindowServer& windowServerManager = iEngine.HelperWindowServer();
|
|
267 |
TInt id = iWindowGroupList->At( iListBox->CurrentItemIndex() ).iId;
|
|
268 |
windowServerManager.GetWindowGroupDetailsL( id, selectedObject );
|
|
269 |
|
|
270 |
// Append info to string buffer
|
|
271 |
AppendFormatString( messagePtr, _L("WG ID: %d\n"), selectedObject.iId );
|
|
272 |
AppendFormatString( messagePtr, _L("Client ThreadId: %Lu\n"), selectedObject.iThreadId.Id() );
|
|
273 |
TFullName name;
|
|
274 |
name.Copy( selectedObject.iFullName );
|
|
275 |
AppendFormatString( messagePtr, _L("Thr: %S\n"), &name );
|
|
276 |
name.Zero();
|
|
277 |
AppendFormatString( messagePtr, _L("Priority: %d\n"), selectedObject.iPriority );
|
|
278 |
AppendFormatString( messagePtr, _L("Handle: 0x%08X\n"), selectedObject.iWindowGroupHandle );
|
|
279 |
name.Copy( selectedObject.iName );
|
|
280 |
AppendFormatString( messagePtr, _L("Name: %S\n"), &name );
|
|
281 |
name.Zero();
|
|
282 |
AppendFormatString( messagePtr, _L("UID: 0x%08X\n"), selectedObject.iUID );
|
|
283 |
AppendFormatString( messagePtr, _L("IsBusy: %d\n"), selectedObject.iIsBusy );
|
|
284 |
AppendFormatString( messagePtr, _L("IsSystem: %d\n"), selectedObject.iIsSystem );
|
|
285 |
AppendFormatString( messagePtr, _L("IsHidden: %d\n"), selectedObject.iIsHidden );
|
|
286 |
name.Copy( selectedObject.iCaption );
|
|
287 |
AppendFormatString( messagePtr, _L("Caption: %S\n"), &name );
|
|
288 |
name.Zero();
|
|
289 |
name.Copy( selectedObject.iDocName );
|
|
290 |
AppendFormatString( messagePtr, _L("Docname: %S"), &name );
|
|
291 |
name.Zero();
|
|
292 |
|
|
293 |
// Display the buffer on a dialog
|
|
294 |
CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog( CAknQueryDialog::ENoTone );
|
|
295 |
dialog->PrepareLC( R_MEMSPY_KERNEL_OBJECT_DETAILS_DIALOG );
|
|
296 |
TFileName headerText;
|
|
297 |
headerText.Copy( selectedObject.iFullName );
|
|
298 |
dialog->SetHeaderTextL( headerText );
|
|
299 |
dialog->SetMessageTextL( messagePtr );
|
|
300 |
dialog->RunLD();
|
|
301 |
|
|
302 |
CleanupStack::PopAndDestroy( messageBuf );
|
|
303 |
}
|
|
304 |
|
|
305 |
|
|
306 |
void CMemSpyViewWindowGroups::AppendFormatString( TPtr& aPtr, TRefByValue<const TDesC> aFmt, ... )
|
|
307 |
{
|
|
308 |
TBuf<KMaxInfoLength> infoString;
|
|
309 |
VA_LIST list;
|
|
310 |
VA_START ( list, aFmt );
|
|
311 |
infoString.FormatList( aFmt, list );
|
|
312 |
aPtr.Append( infoString );
|
|
313 |
}
|
|
314 |
|
|
315 |
|