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 <memspy/engine/memspyenginehelperecom.h>
|
|
19 |
|
|
20 |
// System includes
|
|
21 |
#include <charconv.h>
|
|
22 |
|
|
23 |
// User includes
|
|
24 |
#include <memspy/engine/memspyengine.h>
|
|
25 |
#include <memspy/engine/memspyengineutils.h>
|
|
26 |
#include <memspy/engine/memspyenginehelperfilesystem.h>
|
|
27 |
|
|
28 |
// Literal constants
|
|
29 |
_LIT8( KMemSpyEComXmlFileMimeType, "text/xml" );
|
|
30 |
_LIT8( KMemSpyXmlSpec_MasterSection, "memspy_ecom_sections" );
|
|
31 |
_LIT8( KMemSpyXmlSpec_ChildSectionCategory, "category" );
|
|
32 |
_LIT8( KMemSpyXmlSpec_ChildSectionCategory_Attribute_Name, "name" );
|
|
33 |
_LIT8( KMemSpyXmlSpec_ChildSectionInterface, "interface" );
|
|
34 |
_LIT8( KMemSpyXmlSpec_ChildSectionInterface_Name, "name" );
|
|
35 |
_LIT8( KMemSpyXmlSpec_ChildSectionInterface_Uid, "uid" );
|
|
36 |
_LIT8( KMemSpyXmlSpec_HexPrefix, "0x" );
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
CMemSpyEngineHelperECom::CMemSpyEngineHelperECom( CMemSpyEngine& aEngine )
|
|
43 |
: iEngine( aEngine )
|
|
44 |
{
|
|
45 |
}
|
|
46 |
|
|
47 |
|
|
48 |
CMemSpyEngineHelperECom::~CMemSpyEngineHelperECom()
|
|
49 |
{
|
|
50 |
iCategories.ResetAndDestroy();
|
|
51 |
iCategories.Close();
|
|
52 |
//
|
|
53 |
delete iParser;
|
|
54 |
delete iConverter;
|
|
55 |
//
|
|
56 |
iEComSession.Close();
|
|
57 |
REComSession::FinalClose();
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
void CMemSpyEngineHelperECom::ConstructL()
|
|
62 |
{
|
|
63 |
TRAPD( err, ConstructInternalL() );
|
|
64 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructL() - error: %d", err );
|
|
65 |
err = err;
|
|
66 |
}
|
|
67 |
|
|
68 |
|
|
69 |
void CMemSpyEngineHelperECom::ConstructInternalL()
|
|
70 |
{
|
|
71 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructInternalL() - START" );
|
|
72 |
iEComSession = REComSession::OpenL();
|
|
73 |
|
|
74 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructInternalL() - creating parser..." );
|
|
75 |
iParser = CParser::NewL( KMemSpyEComXmlFileMimeType, *this );
|
|
76 |
|
|
77 |
// We only convert from UTF-8 to UTF-16
|
|
78 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructInternalL() - creating charconv object..." );
|
|
79 |
iConverter = CCnvCharacterSetConverter::NewL();
|
|
80 |
if ( iConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierUtf8, iEngine.FsSession() ) == CCnvCharacterSetConverter::ENotAvailable )
|
|
81 |
{
|
|
82 |
User::Leave(KErrNotFound);
|
|
83 |
}
|
|
84 |
|
|
85 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructInternalL() - reading xml..." );
|
|
86 |
ConstructFromFileL();
|
|
87 |
|
|
88 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructInternalL() - END" );
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
void CMemSpyEngineHelperECom::ConstructFromFileL()
|
|
93 |
{
|
|
94 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructFromFileL() - START" );
|
|
95 |
|
|
96 |
// Locate the source file
|
|
97 |
TRAPD( err,
|
|
98 |
HBufC* fileName = FindEComXmlFileNameLC();
|
|
99 |
ParseL( *fileName );
|
|
100 |
CleanupStack::PopAndDestroy( fileName );
|
|
101 |
);
|
|
102 |
err = err;
|
|
103 |
|
|
104 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructFromFileL() - parse error: %d", err );
|
|
105 |
|
|
106 |
delete iConverter;
|
|
107 |
iConverter = NULL;
|
|
108 |
|
|
109 |
// Build captions
|
|
110 |
const TInt categoryCount = iCategories.Count();
|
|
111 |
for( TInt i=0; i<categoryCount; i++ )
|
|
112 |
{
|
|
113 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructFromFileL() - building caption: %d", i );
|
|
114 |
|
|
115 |
CMemSpyEngineEComCategory* cat = iCategories[ i ];
|
|
116 |
cat->BuildCaptionL();
|
|
117 |
}
|
|
118 |
|
|
119 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ConstructFromFileL() - END" );
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
CMemSpyEngineHelperECom* CMemSpyEngineHelperECom::NewL( CMemSpyEngine& aEngine )
|
|
124 |
{
|
|
125 |
CMemSpyEngineHelperECom* self = new(ELeave) CMemSpyEngineHelperECom( aEngine );
|
|
126 |
CleanupStack::PushL( self );
|
|
127 |
self->ConstructL();
|
|
128 |
CleanupStack::Pop( self );
|
|
129 |
return self;
|
|
130 |
}
|
|
131 |
|
|
132 |
|
|
133 |
REComSession& CMemSpyEngineHelperECom::EComSession()
|
|
134 |
{
|
|
135 |
return iEComSession;
|
|
136 |
}
|
|
137 |
|
|
138 |
|
|
139 |
EXPORT_C CMemSpyEngineEComCategory& CMemSpyEngineHelperECom::At( TInt aIndex )
|
|
140 |
{
|
|
141 |
return *iCategories[ aIndex ];
|
|
142 |
}
|
|
143 |
|
|
144 |
|
|
145 |
EXPORT_C TInt CMemSpyEngineHelperECom::IndexOf( const CMemSpyEngineEComCategory& aEntry )
|
|
146 |
{
|
|
147 |
const TInt index = iCategories.Find( &aEntry );
|
|
148 |
return index;
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
EXPORT_C TInt CMemSpyEngineHelperECom::MdcaCount() const
|
|
153 |
{
|
|
154 |
return iCategories.Count();
|
|
155 |
}
|
|
156 |
|
|
157 |
|
|
158 |
EXPORT_C TPtrC CMemSpyEngineHelperECom::MdcaPoint( TInt aIndex ) const
|
|
159 |
{
|
|
160 |
CMemSpyEngineEComCategory* category = iCategories[ aIndex ];
|
|
161 |
return category->Caption();
|
|
162 |
}
|
|
163 |
|
|
164 |
|
|
165 |
HBufC* CMemSpyEngineHelperECom::FindEComXmlFileNameLC()
|
|
166 |
{
|
|
167 |
RFs& fsSession = iEngine.FsSession();
|
|
168 |
//
|
|
169 |
TFileName* fileName = new(ELeave) TFileName();
|
|
170 |
CleanupStack::PushL( fileName );
|
|
171 |
//
|
|
172 |
fsSession.PrivatePath( *fileName );
|
|
173 |
//
|
|
174 |
TFindFile findFile( fsSession );
|
|
175 |
User::LeaveIfError( findFile.FindByPath( KMemSpyEComInterfaceIdFileName, fileName ) );
|
|
176 |
//
|
|
177 |
HBufC* ret = findFile.File().AllocL();
|
|
178 |
CleanupStack::PopAndDestroy( fileName );
|
|
179 |
CleanupStack::PushL( ret );
|
|
180 |
return ret;
|
|
181 |
}
|
|
182 |
|
|
183 |
|
|
184 |
void CMemSpyEngineHelperECom::ConvertL( const TDesC8& aInput, TDes16& aOutput )
|
|
185 |
{
|
|
186 |
const TInt error = iConverter->ConvertToUnicode( aOutput, aInput, iCharconvConverterState );
|
|
187 |
User::LeaveIfError( error );
|
|
188 |
}
|
|
189 |
|
|
190 |
|
|
191 |
void CMemSpyEngineHelperECom::ParseL( const TDesC& aFileName )
|
|
192 |
{
|
|
193 |
Xml::ParseL( *iParser, iEngine.FsSession(), aFileName );
|
|
194 |
//
|
|
195 |
const TInt error = iParserErrorCode;
|
|
196 |
//RDebug::Printf( "CMemSpyEngineHelperECom::ParseL() - iParserErrorCode: %d", iParserErrorCode );
|
|
197 |
iParserErrorCode = KErrNone;
|
|
198 |
//
|
|
199 |
User::LeaveIfError( error );
|
|
200 |
}
|
|
201 |
|
|
202 |
|
|
203 |
void CMemSpyEngineHelperECom::OnChildSectionCategoryL( const RAttributeArray& aAttributes )
|
|
204 |
{
|
|
205 |
TBuf<128> name;
|
|
206 |
TBool gotName = EFalse;
|
|
207 |
//
|
|
208 |
const TInt count = aAttributes.Count();
|
|
209 |
for( TInt i=0; i<count; i++ )
|
|
210 |
{
|
|
211 |
const TPtrC8 attrib( aAttributes[ i ].Attribute().LocalName().DesC() );
|
|
212 |
const TPtrC8 value( aAttributes[ i ].Value().DesC() );
|
|
213 |
//
|
|
214 |
if ( attrib.CompareF( KMemSpyXmlSpec_ChildSectionCategory_Attribute_Name ) == 0 )
|
|
215 |
{
|
|
216 |
if ( gotName )
|
|
217 |
{
|
|
218 |
User::LeaveIfError( KErrCorrupt );
|
|
219 |
}
|
|
220 |
else
|
|
221 |
{
|
|
222 |
ConvertL( value, name );
|
|
223 |
gotName = ETrue;
|
|
224 |
}
|
|
225 |
}
|
|
226 |
}
|
|
227 |
//
|
|
228 |
if ( gotName )
|
|
229 |
{
|
|
230 |
// Make a new category
|
|
231 |
//RDebug::Print( _L("CMemSpyEngineHelperECom::OnChildSectionCategoryL() - creating category: %S"), &name );
|
|
232 |
|
|
233 |
CMemSpyEngineEComCategory* category = CMemSpyEngineEComCategory::NewLC( *this, name );
|
|
234 |
iCategories.AppendL( category );
|
|
235 |
CleanupStack::Pop( category );
|
|
236 |
|
|
237 |
//RDebug::Print( _L("CMemSpyEngineHelperECom::OnChildSectionCategoryL() - created category: %S"), &name );
|
|
238 |
}
|
|
239 |
else
|
|
240 |
{
|
|
241 |
User::Leave( KErrCorrupt );
|
|
242 |
}
|
|
243 |
}
|
|
244 |
|
|
245 |
|
|
246 |
void CMemSpyEngineHelperECom::OnChildSectionInterfaceL( const RAttributeArray& aAttributes )
|
|
247 |
{
|
|
248 |
TUid uid = KNullUid;
|
|
249 |
TBuf<128> name;
|
|
250 |
TBool gotName = EFalse;
|
|
251 |
TBool gotUid = EFalse;
|
|
252 |
//
|
|
253 |
const TInt count = aAttributes.Count();
|
|
254 |
for( TInt i=0; i<count; i++ )
|
|
255 |
{
|
|
256 |
const TPtrC8 attrib( aAttributes[ i ].Attribute().LocalName().DesC() );
|
|
257 |
const TPtrC8 value( aAttributes[ i ].Value().DesC() );
|
|
258 |
//
|
|
259 |
if ( attrib.CompareF( KMemSpyXmlSpec_ChildSectionInterface_Name ) == 0 )
|
|
260 |
{
|
|
261 |
if ( gotName )
|
|
262 |
{
|
|
263 |
User::LeaveIfError( KErrCorrupt );
|
|
264 |
}
|
|
265 |
else
|
|
266 |
{
|
|
267 |
ConvertL( value, name );
|
|
268 |
gotName = ETrue;
|
|
269 |
}
|
|
270 |
}
|
|
271 |
else if ( attrib.CompareF( KMemSpyXmlSpec_ChildSectionInterface_Uid ) == 0 )
|
|
272 |
{
|
|
273 |
if ( gotUid )
|
|
274 |
{
|
|
275 |
User::LeaveIfError( KErrCorrupt );
|
|
276 |
}
|
|
277 |
else
|
|
278 |
{
|
|
279 |
if ( value.Length() >= 8 )
|
|
280 |
{
|
|
281 |
TRadix radix = EDecimal;
|
|
282 |
TPtrC8 pValue( value );
|
|
283 |
//
|
|
284 |
if ( value.Length() == 10 && value.Left( 2 ) == KMemSpyXmlSpec_HexPrefix )
|
|
285 |
{
|
|
286 |
pValue.Set( value.Mid( 2 ) );
|
|
287 |
radix = EHex;
|
|
288 |
}
|
|
289 |
//
|
|
290 |
TUint32 uidVal = 0;
|
|
291 |
TLex8 lexer( pValue );
|
|
292 |
const TInt err = lexer.Val( uidVal, radix );
|
|
293 |
User::LeaveIfError( err );
|
|
294 |
uid.iUid = uidVal;
|
|
295 |
gotUid = ETrue;
|
|
296 |
}
|
|
297 |
}
|
|
298 |
}
|
|
299 |
}
|
|
300 |
//
|
|
301 |
const TInt catCount = iCategories.Count();
|
|
302 |
if ( gotName && gotUid && catCount > 0 )
|
|
303 |
{
|
|
304 |
//RDebug::Print( _L("CMemSpyEngineHelperECom::OnChildSectionInterfaceL() - creating interface for %S [0x%08x]"), &name, uid.iUid );
|
|
305 |
|
|
306 |
CMemSpyEngineEComCategory* category = iCategories[ catCount - 1 ];
|
|
307 |
TRAPD( err, category->CreateInterfaceL( name, uid ) );
|
|
308 |
err = err;
|
|
309 |
//RDebug::Print( _L("CMemSpyEngineHelperECom::OnChildSectionInterfaceL() - error: %d, for %S [0x%08x]"), err, &name, uid.iUid );
|
|
310 |
}
|
|
311 |
else
|
|
312 |
{
|
|
313 |
User::Leave( KErrCorrupt );
|
|
314 |
}
|
|
315 |
}
|
|
316 |
|
|
317 |
|
|
318 |
void CMemSpyEngineHelperECom::OnStartDocumentL( const RDocumentParameters& /*aDocParam*/, TInt aErrorCode )
|
|
319 |
{
|
|
320 |
User::LeaveIfError( aErrorCode );
|
|
321 |
}
|
|
322 |
|
|
323 |
|
|
324 |
void CMemSpyEngineHelperECom::OnEndDocumentL( TInt aErrorCode )
|
|
325 |
{
|
|
326 |
User::LeaveIfError( aErrorCode );
|
|
327 |
}
|
|
328 |
|
|
329 |
|
|
330 |
void CMemSpyEngineHelperECom::OnStartElementL( const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode )
|
|
331 |
{
|
|
332 |
User::LeaveIfError( aErrorCode );
|
|
333 |
//
|
|
334 |
TInt err = KErrNone;
|
|
335 |
const TPtrC8 name( aElement.LocalName().DesC() );
|
|
336 |
//
|
|
337 |
if ( name.CompareF( KMemSpyXmlSpec_MasterSection ) == 0 )
|
|
338 |
{
|
|
339 |
iSeenMasterSection = ETrue;
|
|
340 |
}
|
|
341 |
else if ( iSeenMasterSection )
|
|
342 |
{
|
|
343 |
if ( name.CompareF( KMemSpyXmlSpec_ChildSectionCategory ) == 0 )
|
|
344 |
{
|
|
345 |
OnChildSectionCategoryL( aAttributes );
|
|
346 |
}
|
|
347 |
else if ( name.CompareF( KMemSpyXmlSpec_ChildSectionInterface ) == 0 )
|
|
348 |
{
|
|
349 |
OnChildSectionInterfaceL( aAttributes );
|
|
350 |
}
|
|
351 |
}
|
|
352 |
//
|
|
353 |
User::LeaveIfError( err );
|
|
354 |
}
|
|
355 |
|
|
356 |
|
|
357 |
void CMemSpyEngineHelperECom::OnEndElementL( const RTagInfo& /*aElement*/, TInt aErrorCode )
|
|
358 |
{
|
|
359 |
User::LeaveIfError( aErrorCode );
|
|
360 |
}
|
|
361 |
|
|
362 |
|
|
363 |
void CMemSpyEngineHelperECom::OnContentL( const TDesC8& /*aBytes*/, TInt aErrorCode )
|
|
364 |
{
|
|
365 |
User::LeaveIfError( aErrorCode );
|
|
366 |
}
|
|
367 |
|
|
368 |
|
|
369 |
void CMemSpyEngineHelperECom::OnStartPrefixMappingL( const RString& /*aPrefix*/, const RString& /*aUri*/, TInt aErrorCode )
|
|
370 |
{
|
|
371 |
User::LeaveIfError( aErrorCode );
|
|
372 |
}
|
|
373 |
|
|
374 |
|
|
375 |
void CMemSpyEngineHelperECom::OnEndPrefixMappingL( const RString& /*aPrefix*/, TInt aErrorCode )
|
|
376 |
{
|
|
377 |
User::LeaveIfError( aErrorCode );
|
|
378 |
}
|
|
379 |
|
|
380 |
|
|
381 |
void CMemSpyEngineHelperECom::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, TInt aErrorCode )
|
|
382 |
{
|
|
383 |
User::LeaveIfError( aErrorCode );
|
|
384 |
}
|
|
385 |
|
|
386 |
|
|
387 |
void CMemSpyEngineHelperECom::OnSkippedEntityL( const RString& /*aName*/, TInt aErrorCode )
|
|
388 |
{
|
|
389 |
User::LeaveIfError( aErrorCode );
|
|
390 |
}
|
|
391 |
|
|
392 |
|
|
393 |
void CMemSpyEngineHelperECom::OnProcessingInstructionL( const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt aErrorCode )
|
|
394 |
{
|
|
395 |
User::LeaveIfError( aErrorCode );
|
|
396 |
}
|
|
397 |
|
|
398 |
|
|
399 |
void CMemSpyEngineHelperECom::OnError( TInt aErrorCode )
|
|
400 |
{
|
|
401 |
iParserErrorCode = aErrorCode;
|
|
402 |
}
|
|
403 |
|
|
404 |
|
|
405 |
TAny* CMemSpyEngineHelperECom::GetExtendedInterface( const TInt32 /*aUid*/ )
|
|
406 |
{
|
|
407 |
return NULL;
|
|
408 |
}
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
CMemSpyEngineEComCategory::CMemSpyEngineEComCategory( CMemSpyEngineHelperECom& aHelper )
|
|
447 |
: iHelper( aHelper )
|
|
448 |
{
|
|
449 |
}
|
|
450 |
|
|
451 |
|
|
452 |
CMemSpyEngineEComCategory::~CMemSpyEngineEComCategory()
|
|
453 |
{
|
|
454 |
delete iCaption;
|
|
455 |
delete iName;
|
|
456 |
iInterfaces.ResetAndDestroy();
|
|
457 |
iInterfaces.Close();
|
|
458 |
}
|
|
459 |
|
|
460 |
|
|
461 |
void CMemSpyEngineEComCategory::ConstructL( const TDesC& aName )
|
|
462 |
{
|
|
463 |
iName = aName.AllocL();
|
|
464 |
iCaption = aName.AllocL(); // Replace later on
|
|
465 |
}
|
|
466 |
|
|
467 |
|
|
468 |
CMemSpyEngineEComCategory* CMemSpyEngineEComCategory::NewLC( CMemSpyEngineHelperECom& aHelper, const TDesC& aName )
|
|
469 |
{
|
|
470 |
CMemSpyEngineEComCategory* self = new(ELeave) CMemSpyEngineEComCategory( aHelper );
|
|
471 |
CleanupStack::PushL( self );
|
|
472 |
self->ConstructL( aName );
|
|
473 |
return self;
|
|
474 |
}
|
|
475 |
|
|
476 |
|
|
477 |
EXPORT_C CMemSpyEngineEComInterface& CMemSpyEngineEComCategory::At( TInt aIndex )
|
|
478 |
{
|
|
479 |
return *iInterfaces[ aIndex ];
|
|
480 |
}
|
|
481 |
|
|
482 |
|
|
483 |
EXPORT_C TInt CMemSpyEngineEComCategory::IndexOf( const CMemSpyEngineEComInterface& aEntry )
|
|
484 |
{
|
|
485 |
const TInt index = iInterfaces.Find( &aEntry );
|
|
486 |
return index;
|
|
487 |
}
|
|
488 |
|
|
489 |
|
|
490 |
EXPORT_C TInt CMemSpyEngineEComCategory::MdcaCount() const
|
|
491 |
{
|
|
492 |
return iInterfaces.Count();
|
|
493 |
}
|
|
494 |
|
|
495 |
|
|
496 |
EXPORT_C TPtrC CMemSpyEngineEComCategory::MdcaPoint( TInt aIndex ) const
|
|
497 |
{
|
|
498 |
CMemSpyEngineEComInterface* iface = iInterfaces[ aIndex ];
|
|
499 |
return iface->Caption();
|
|
500 |
}
|
|
501 |
|
|
502 |
|
|
503 |
void CMemSpyEngineEComCategory::CreateInterfaceL( const TDesC& aName, TUid aUid )
|
|
504 |
{
|
|
505 |
CMemSpyEngineEComInterface* iface = CMemSpyEngineEComInterface::NewLC( *this, aName, aUid );
|
|
506 |
iInterfaces.AppendL( iface );
|
|
507 |
CleanupStack::Pop( iface );
|
|
508 |
}
|
|
509 |
|
|
510 |
|
|
511 |
void CMemSpyEngineEComCategory::BuildCaptionL()
|
|
512 |
{
|
|
513 |
delete iCaption;
|
|
514 |
iCaption = NULL;
|
|
515 |
|
|
516 |
_LIT( KCaptionFormat, "\t%S\t\t%d interface" );
|
|
517 |
iCaption = HBufC::NewL( 256 );
|
|
518 |
TPtr pCaption( iCaption->Des() );
|
|
519 |
pCaption.Format( KCaptionFormat, iName, iInterfaces.Count() );
|
|
520 |
if ( iInterfaces.Count() > 1 )
|
|
521 |
{
|
|
522 |
pCaption.Append( 's' );
|
|
523 |
}
|
|
524 |
}
|
|
525 |
|
|
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
|
536 |
|
|
537 |
CMemSpyEngineEComInterface::CMemSpyEngineEComInterface( CMemSpyEngineEComCategory& aCategory, TUid aUid )
|
|
538 |
: iUid( aUid ), iCategory( aCategory )
|
|
539 |
{
|
|
540 |
}
|
|
541 |
|
|
542 |
|
|
543 |
CMemSpyEngineEComInterface::~CMemSpyEngineEComInterface()
|
|
544 |
{
|
|
545 |
delete iCaption;
|
|
546 |
delete iName;
|
|
547 |
iImplementations.ResetAndDestroy();
|
|
548 |
iImplementations.Close();
|
|
549 |
}
|
|
550 |
|
|
551 |
|
|
552 |
void CMemSpyEngineEComInterface::ConstructL( const TDesC& aName )
|
|
553 |
{
|
|
554 |
iName = aName.AllocL();
|
|
555 |
|
|
556 |
// Get implementation information for this interface...
|
|
557 |
RImplInfoPtrArray infoArray;
|
|
558 |
CleanupResetAndDestroyPushL( infoArray );
|
|
559 |
REComSession::ListImplementationsL( iUid, infoArray );
|
|
560 |
|
|
561 |
// Make implementation objects for each impl that exists.
|
|
562 |
const TInt count = infoArray.Count();
|
|
563 |
for( TInt i=count-1; i>=0; i-- )
|
|
564 |
{
|
|
565 |
CImplementationInformation* info = infoArray[ i ];
|
|
566 |
|
|
567 |
// Get info
|
|
568 |
CMemSpyEngineEComImplementation* impl = CMemSpyEngineEComImplementation::NewLC( *this, info );
|
|
569 |
|
|
570 |
// Now owned by impl
|
|
571 |
infoArray.Remove( i );
|
|
572 |
|
|
573 |
// Add to container
|
|
574 |
iImplementations.AppendL( impl );
|
|
575 |
CleanupStack::Pop( impl );
|
|
576 |
}
|
|
577 |
|
|
578 |
// Tidy up
|
|
579 |
CleanupStack::PopAndDestroy( &infoArray );
|
|
580 |
|
|
581 |
// Build caption
|
|
582 |
_LIT( KCaptionFormat, "\t%S\t\t[0x%08x] [%d impl]" );
|
|
583 |
iCaption = HBufC::NewL( 256 );
|
|
584 |
TPtr pCaption( iCaption->Des() );
|
|
585 |
pCaption.Format( KCaptionFormat, iName, iUid.iUid, count );
|
|
586 |
}
|
|
587 |
|
|
588 |
|
|
589 |
CMemSpyEngineEComInterface* CMemSpyEngineEComInterface::NewLC( CMemSpyEngineEComCategory& aCategory, const TDesC& aName, TUid aUid )
|
|
590 |
{
|
|
591 |
CMemSpyEngineEComInterface* self = new(ELeave) CMemSpyEngineEComInterface( aCategory, aUid );
|
|
592 |
CleanupStack::PushL( self );
|
|
593 |
self->ConstructL( aName );
|
|
594 |
return self;
|
|
595 |
}
|
|
596 |
|
|
597 |
|
|
598 |
EXPORT_C CMemSpyEngineEComImplementation& CMemSpyEngineEComInterface::At( TInt aIndex )
|
|
599 |
{
|
|
600 |
return *iImplementations[ aIndex ];
|
|
601 |
}
|
|
602 |
|
|
603 |
|
|
604 |
EXPORT_C TInt CMemSpyEngineEComInterface::IndexOf( const CMemSpyEngineEComImplementation& aEntry )
|
|
605 |
{
|
|
606 |
const TInt index = iImplementations.Find( &aEntry );
|
|
607 |
return index;
|
|
608 |
}
|
|
609 |
|
|
610 |
|
|
611 |
EXPORT_C TInt CMemSpyEngineEComInterface::MdcaCount() const
|
|
612 |
{
|
|
613 |
return iImplementations.Count();
|
|
614 |
}
|
|
615 |
|
|
616 |
|
|
617 |
EXPORT_C TPtrC CMemSpyEngineEComInterface::MdcaPoint( TInt aIndex ) const
|
|
618 |
{
|
|
619 |
CMemSpyEngineEComImplementation* impl = iImplementations[ aIndex ];
|
|
620 |
return impl->Caption();
|
|
621 |
}
|
|
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
|
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
|
|
637 |
|
|
638 |
|
|
639 |
|
|
640 |
|
|
641 |
|
|
642 |
|
|
643 |
CMemSpyEngineEComImplementation::CMemSpyEngineEComImplementation( CMemSpyEngineEComInterface& aInterface )
|
|
644 |
: iInterface( aInterface )
|
|
645 |
{
|
|
646 |
}
|
|
647 |
|
|
648 |
|
|
649 |
CMemSpyEngineEComImplementation::~CMemSpyEngineEComImplementation()
|
|
650 |
{
|
|
651 |
delete iCaption;
|
|
652 |
delete iName;
|
|
653 |
delete iInfoText;
|
|
654 |
delete iInfo;
|
|
655 |
}
|
|
656 |
|
|
657 |
|
|
658 |
void CMemSpyEngineEComImplementation::ConstructL( CImplementationInformation* aInfo )
|
|
659 |
{
|
|
660 |
iInfoText = new(ELeave) CDesCArrayFlat( 10 );
|
|
661 |
TBuf< 256 > temp;
|
|
662 |
|
|
663 |
// Make items.
|
|
664 |
if ( aInfo->DisplayName().Length() )
|
|
665 |
{
|
|
666 |
_LIT( KNameFormat, "0x%08x - %S" );
|
|
667 |
temp.Format( KNameFormat, aInfo->ImplementationUid().iUid, &aInfo->DisplayName() );
|
|
668 |
}
|
|
669 |
else
|
|
670 |
{
|
|
671 |
_LIT( KNameFormat, "0x%08x" );
|
|
672 |
temp.Format( KNameFormat, aInfo->ImplementationUid().iUid );
|
|
673 |
}
|
|
674 |
iName = temp.AllocL();
|
|
675 |
|
|
676 |
_LIT( KItem1, "\tImpl. Uid\t\t0x%08x" );
|
|
677 |
temp.Format( KItem1, aInfo->ImplementationUid().iUid );
|
|
678 |
iInfoText->AppendL( temp );
|
|
679 |
|
|
680 |
if ( aInfo->DisplayName().Length() )
|
|
681 |
{
|
|
682 |
_LIT( KItem2, "\tDisplay Name\t\t%S" );
|
|
683 |
temp.Format( KItem2, &aInfo->DisplayName() );
|
|
684 |
}
|
|
685 |
else
|
|
686 |
{
|
|
687 |
_LIT( KItem2, "\tDisplay Name\t\t[Undefined]" );
|
|
688 |
temp.Copy( KItem2 );
|
|
689 |
}
|
|
690 |
iInfoText->AppendL( temp );
|
|
691 |
|
|
692 |
_LIT( KItem3, "\tVersion\t\t%d" );
|
|
693 |
temp.Format( KItem3, aInfo->Version() );
|
|
694 |
iInfoText->AppendL( temp );
|
|
695 |
|
|
696 |
HBufC* opaqueData = CopyAndCropLC( aInfo->OpaqueData() );
|
|
697 |
if ( opaqueData->Length() )
|
|
698 |
{
|
|
699 |
_LIT( KItem4, "\tOpaque Data\t\t%S" );
|
|
700 |
temp.Format( KItem4, opaqueData );
|
|
701 |
}
|
|
702 |
else
|
|
703 |
{
|
|
704 |
_LIT( KItem4, "\tOpaque Data\t\t[Undefined]" );
|
|
705 |
temp.Copy( KItem4 );
|
|
706 |
}
|
|
707 |
iInfoText->AppendL( temp );
|
|
708 |
CleanupStack::PopAndDestroy( opaqueData );
|
|
709 |
|
|
710 |
HBufC* dataType = CopyAndCropLC( aInfo->DataType() );
|
|
711 |
if ( opaqueData->Length() )
|
|
712 |
{
|
|
713 |
_LIT( KItem5, "\tData Type\t\t%S" );
|
|
714 |
temp.Format( KItem5, dataType );
|
|
715 |
}
|
|
716 |
else
|
|
717 |
{
|
|
718 |
_LIT( KItem5, "\tData Type\t\t[Undefined]" );
|
|
719 |
temp.Copy( KItem5 );
|
|
720 |
}
|
|
721 |
iInfoText->AppendL( temp );
|
|
722 |
CleanupStack::PopAndDestroy( dataType );
|
|
723 |
|
|
724 |
_LIT( KItem6, "\tDrive\t\t%S" );
|
|
725 |
TBuf< 10 > drive;
|
|
726 |
const TDriveNumber driveNumber = static_cast< TDriveNumber >( static_cast< TInt >( aInfo->Drive() ) );
|
|
727 |
CMemSpyEngineHelperFileSystem::GetDriveNumberText( driveNumber, drive );
|
|
728 |
temp.Format( KItem6, &drive );
|
|
729 |
iInfoText->AppendL( temp );
|
|
730 |
|
|
731 |
if ( aInfo->Disabled() )
|
|
732 |
{
|
|
733 |
iInfoText->AppendL( _L("\tIs Disabled\t\tYes") );
|
|
734 |
}
|
|
735 |
else
|
|
736 |
{
|
|
737 |
iInfoText->AppendL( _L("\tIs Disabled\t\tNo") );
|
|
738 |
}
|
|
739 |
|
|
740 |
if ( aInfo->RomOnly() )
|
|
741 |
{
|
|
742 |
iInfoText->AppendL( _L("\tROM-Only\t\tYes") );
|
|
743 |
}
|
|
744 |
else
|
|
745 |
{
|
|
746 |
iInfoText->AppendL( _L("\tROM-Only\t\tNo") );
|
|
747 |
}
|
|
748 |
|
|
749 |
if ( aInfo->RomBased() )
|
|
750 |
{
|
|
751 |
iInfoText->AppendL( _L("\tROM-Based\t\tYes") );
|
|
752 |
}
|
|
753 |
else
|
|
754 |
{
|
|
755 |
iInfoText->AppendL( _L("\tROM-Based\t\tNo") );
|
|
756 |
}
|
|
757 |
|
|
758 |
// Make caption
|
|
759 |
if ( aInfo->DisplayName().Length() )
|
|
760 |
{
|
|
761 |
_LIT( KCaptionFormat, "\t0x%08x\t\t%S" );
|
|
762 |
temp.Format( KCaptionFormat, aInfo->ImplementationUid().iUid, &aInfo->DisplayName() );
|
|
763 |
}
|
|
764 |
else
|
|
765 |
{
|
|
766 |
_LIT( KCaptionFormat, "\t0x%08x\t\t[Name Undefined]" );
|
|
767 |
temp.Format( KCaptionFormat, aInfo->ImplementationUid().iUid );
|
|
768 |
}
|
|
769 |
iCaption = temp.AllocL();
|
|
770 |
|
|
771 |
// Must do this last
|
|
772 |
iInfo = aInfo;
|
|
773 |
}
|
|
774 |
|
|
775 |
|
|
776 |
CMemSpyEngineEComImplementation* CMemSpyEngineEComImplementation::NewLC( CMemSpyEngineEComInterface& aInterface, CImplementationInformation* aInfo )
|
|
777 |
{
|
|
778 |
CMemSpyEngineEComImplementation* self = new(ELeave) CMemSpyEngineEComImplementation( aInterface );
|
|
779 |
CleanupStack::PushL( self );
|
|
780 |
self->ConstructL( aInfo );
|
|
781 |
return self;
|
|
782 |
}
|
|
783 |
|
|
784 |
|
|
785 |
HBufC* CMemSpyEngineEComImplementation::CopyAndCropLC( const TDesC8& aText )
|
|
786 |
{
|
|
787 |
const TInt KMaxEComDataLength = 200; // Any longer and we'll crop it...
|
|
788 |
//
|
|
789 |
HBufC* data = HBufC::NewLC( aText.Length() );
|
|
790 |
data->Des().Copy( aText );
|
|
791 |
//
|
|
792 |
if ( data->Length() > KMaxEComDataLength )
|
|
793 |
{
|
|
794 |
data->Des().SetLength( KMaxEComDataLength );
|
|
795 |
}
|
|
796 |
//
|
|
797 |
return data;
|
|
798 |
}
|
|
799 |
|
|
800 |
|
|
801 |
EXPORT_C TInt CMemSpyEngineEComImplementation::MdcaCount() const
|
|
802 |
{
|
|
803 |
return iInfoText->MdcaCount();
|
|
804 |
}
|
|
805 |
|
|
806 |
|
|
807 |
EXPORT_C TPtrC CMemSpyEngineEComImplementation::MdcaPoint( TInt aIndex ) const
|
|
808 |
{
|
|
809 |
return iInfoText->MdcaPoint( aIndex );
|
|
810 |
}
|
|
811 |
|
|
812 |
|
|
813 |
|