83
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 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 <sysutil.h>
|
|
19 |
#include "hnxmlmodelprovider.h"
|
|
20 |
#include "hnxmlmodelcache.h"
|
|
21 |
#include "hnglobals.h"
|
|
22 |
#include "hnconvutils.h"
|
|
23 |
#include "menudebug.h"
|
|
24 |
#include "hnhelper.inl"
|
|
25 |
#include "hnmdmodel.h"
|
|
26 |
#include "hnmdmenuitem.h"
|
|
27 |
|
|
28 |
// ======== MEMBER FUNCTIONS ========
|
|
29 |
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
void CHnXmlModelProvider::ConstructL()
|
|
35 |
{
|
|
36 |
iDomImpl.OpenL();
|
|
37 |
User::LeaveIfError(iDomParser.Open(iDomImpl));
|
|
38 |
iCache = CHnXmlModelCache::NewL();
|
|
39 |
}
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
EXPORT_C CHnXmlModelProvider* CHnXmlModelProvider::NewL()
|
|
46 |
{
|
|
47 |
CHnXmlModelProvider* self = CHnXmlModelProvider::NewLC();
|
|
48 |
CleanupStack::Pop(self);
|
|
49 |
return self;
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
EXPORT_C CHnXmlModelProvider* CHnXmlModelProvider::NewLC()
|
|
57 |
{
|
|
58 |
CHnXmlModelProvider* self = new (ELeave) CHnXmlModelProvider;
|
|
59 |
CleanupStack::PushL(self);
|
|
60 |
self->ConstructL();
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
CHnXmlModelProvider::CHnXmlModelProvider(): iEventMap(&HBuf16Hash, &HBuf16Ident)
|
|
69 |
{
|
|
70 |
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
EXPORT_C CHnXmlModelProvider::~CHnXmlModelProvider()
|
|
78 |
{
|
|
79 |
delete iCache;
|
|
80 |
iDomParser.Close();
|
|
81 |
iDomImpl.Close();
|
|
82 |
|
|
83 |
// clean up eventmap
|
|
84 |
THashMapIter<HBufC*, TInt> iter(iEventMap);
|
|
85 |
while (HBufC* const * ptr = iter.NextKey())
|
|
86 |
{
|
|
87 |
delete *ptr;
|
|
88 |
}
|
|
89 |
iEventMap.Close();
|
|
90 |
}
|
|
91 |
|
|
92 |
#ifdef _DEBUG
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
void CHnXmlModelProvider::LogEventMapping(
|
|
98 |
const RHashMap<HBufC*, TInt>& aEventMap)
|
|
99 |
{
|
|
100 |
DEBUG(("\t_MM_: CHnXmlModelProvider::LogEventMapping IN"));
|
|
101 |
RFs fs;
|
|
102 |
if ( !fs.Connect() )
|
|
103 |
{
|
|
104 |
RFile logFile;
|
|
105 |
if ( !logFile.Replace( fs, KEventMapLogFile, EFileWrite ) )
|
|
106 |
{
|
|
107 |
// first line
|
|
108 |
TBuf8<256> buf1;
|
|
109 |
buf1.Append( _L8("EventName") );
|
|
110 |
buf1.Append( _L8("\t") );
|
|
111 |
buf1.Append( _L8("EventId") );
|
|
112 |
buf1.Append( _L8("\n") );
|
|
113 |
logFile.Write( 0, buf1 );
|
|
114 |
THashMapIter<HBufC*, TInt> iter( aEventMap );
|
|
115 |
while ( HBufC* const * ptr = iter.NextKey() )
|
|
116 |
{
|
|
117 |
TInt *v = iter.CurrentValue();
|
|
118 |
TBuf8<256> buf2;
|
|
119 |
buf2.Append( (*ptr)->Des() );
|
|
120 |
buf2.Append( _L8("\t") );
|
|
121 |
buf2.AppendNum( *v );
|
|
122 |
buf2.Append( _L8("\n") );
|
|
123 |
TInt size ( 0 );
|
|
124 |
logFile.Size( size );
|
|
125 |
logFile.Write( size, buf2 );
|
|
126 |
}
|
|
127 |
logFile.Close();
|
|
128 |
}
|
|
129 |
fs.Close();
|
|
130 |
}
|
|
131 |
DEBUG(("\t_MM_: CHnXmlModelProvider::LogEventMapping OUT"));
|
|
132 |
}
|
|
133 |
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CHnXmlModelProvider::LogSuiteModel( const TDesC& aName,
|
|
139 |
RXmlEngDocument& aDoc )
|
|
140 |
{
|
|
141 |
DEBUG(("\t_MM_: CHnXmlModelProvider::LogSuiteModel IN"));
|
|
142 |
TBuf8<256> buf1;
|
|
143 |
TFileName logFileName;
|
|
144 |
logFileName.Copy( KSuiteLoadingLogFile );
|
|
145 |
logFileName.Append( Kbackslash );
|
|
146 |
logFileName.Append( aName );
|
|
147 |
logFileName.Append( KXmlExt );
|
|
148 |
TRAP_IGNORE( aDoc.SaveL( logFileName, aDoc.DocumentElement() ) );
|
|
149 |
DEBUG(("\t_MM_: CHnXmlModelProvider::LogSuiteModel OUT"));
|
|
150 |
}
|
|
151 |
#endif
|
|
152 |
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
//
|
|
155 |
// ---------------------------------------------------------------------------
|
|
156 |
//
|
|
157 |
RXmlEngDocument CHnXmlModelProvider::ParseFileL( const TDesC& aPath )
|
|
158 |
{
|
|
159 |
RBuf8 doc( ReadFileLC( aPath ) );
|
|
160 |
CleanupClosePushL(doc);
|
|
161 |
|
|
162 |
RXmlEngDocument xmlDoc;
|
|
163 |
CleanupClosePushL( xmlDoc );
|
|
164 |
xmlDoc = ParseDocL(doc);
|
|
165 |
CleanupStack::Pop( &xmlDoc );
|
|
166 |
|
|
167 |
// clean up
|
|
168 |
CleanupStack::PopAndDestroy( &doc );
|
|
169 |
|
|
170 |
return xmlDoc;
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
RXmlEngDocument CHnXmlModelProvider::ParseDocL( const TDesC8& aDoc )
|
|
178 |
{
|
|
179 |
RXmlEngDocument doc;
|
|
180 |
CleanupClosePushL( doc );
|
|
181 |
doc = iDomParser.ParseL( aDoc );
|
|
182 |
CleanupStack::Pop( &doc );
|
|
183 |
return doc;
|
|
184 |
}
|
|
185 |
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
HBufC8* CHnXmlModelProvider::ReadFileLC(const TDesC& aPath)
|
|
191 |
{
|
|
192 |
RFile file;
|
|
193 |
User::LeaveIfError( file.Open( CEikonEnv::Static()->FsSession(),
|
|
194 |
aPath, EFileRead) );
|
|
195 |
CleanupClosePushL( file );
|
|
196 |
|
|
197 |
TInt fileSize(0);
|
|
198 |
User::LeaveIfError( file.Size( fileSize ) );
|
|
199 |
HBufC8* buf = HBufC8::NewLC( fileSize );
|
|
200 |
TPtr8 bufPtr( buf->Des() );
|
|
201 |
User::LeaveIfError( file.Read( bufPtr ) );
|
|
202 |
|
|
203 |
// clean up
|
|
204 |
CleanupStack::Pop(buf);
|
|
205 |
CleanupStack::PopAndDestroy(&file);
|
|
206 |
|
|
207 |
return buf;
|
|
208 |
}
|
|
209 |
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CHnXmlModelProvider::ChangeEventsToIdsInChildrenL(
|
|
215 |
TXmlEngElement & aElement)
|
|
216 |
{
|
|
217 |
RXmlEngNodeList<TXmlEngElement> children;
|
|
218 |
CleanupClosePushL(children);
|
|
219 |
aElement.GetChildElements(children);
|
|
220 |
TInt amount = children.Count();
|
|
221 |
for (TInt i(0); i < amount; i++)
|
|
222 |
{
|
|
223 |
TXmlEngElement child = children.Next();
|
|
224 |
TPtrC8 childName = child.Name();
|
|
225 |
|
|
226 |
if (!childName.Compare(KEventName8)
|
|
227 |
|| CHnMdMenuItem::IsMenuItemElementName( childName )
|
|
228 |
|| !child.Name().Compare(KMenuToolbar8))
|
|
229 |
{
|
|
230 |
ChangeEventNamesToIdsL(child);
|
|
231 |
}
|
|
232 |
else if (!childName.Compare(KEditModeItem8))
|
|
233 |
{
|
|
234 |
ChangeEventsToIdsInChildrenL(child);
|
|
235 |
}
|
|
236 |
}
|
|
237 |
|
|
238 |
CleanupStack::PopAndDestroy(&children);
|
|
239 |
}
|
|
240 |
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
//
|
|
245 |
TInt CHnXmlModelProvider::CollectSuiteL( RXmlEngDocument& aXmlDoc )
|
|
246 |
{
|
|
247 |
TInt err(KErrNotFound);
|
|
248 |
RXmlEngDocument suiteDoc;
|
|
249 |
CleanupClosePushL( suiteDoc );
|
|
250 |
//hardcoded path for suites as there is only foldersuite
|
|
251 |
suiteDoc = ParseFileL( KFolderSuitePath );
|
|
252 |
|
|
253 |
// one suite per file
|
|
254 |
RXmlEngNodeList<TXmlEngElement> elements;
|
|
255 |
suiteDoc.DocumentElement().GetChildElements( elements );
|
|
256 |
TXmlEngElement suiteElement;
|
|
257 |
while ( elements.HasNext() )
|
|
258 |
{
|
|
259 |
suiteElement = elements.Next();
|
|
260 |
TPtrC8 t = suiteElement.Name();
|
|
261 |
if ( !suiteElement.Name().Compare( KSuiteElementName8 ) )
|
|
262 |
{
|
|
263 |
ChangeEventsToIdsInChildrenL( suiteElement.AsElement() );
|
|
264 |
break;
|
|
265 |
}
|
|
266 |
}
|
|
267 |
|
|
268 |
aXmlDoc.OpenL( iDomImpl, suiteDoc.DocumentElement() );
|
|
269 |
err = KErrNone;
|
|
270 |
|
|
271 |
CleanupStack::PopAndDestroy( &suiteDoc );
|
|
272 |
return err;
|
|
273 |
}
|
|
274 |
|
|
275 |
// ---------------------------------------------------------------------------
|
|
276 |
//
|
|
277 |
// ---------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
void CHnXmlModelProvider::CollectItemsL( RXmlEngDocument& aXmlDoc )
|
|
280 |
{
|
|
281 |
RXmlEngDocument itemDoc;
|
|
282 |
CleanupClosePushL( itemDoc );
|
|
283 |
//hardcoded path for items as there is only foldersuite
|
|
284 |
TInt err( KErrNone );
|
|
285 |
TRAP( err , itemDoc = ParseFileL(KFolderItemsPath) );
|
|
286 |
if( !err )
|
|
287 |
{
|
|
288 |
RXmlEngNodeList< TXmlEngElement > children;
|
|
289 |
CleanupClosePushL(children);
|
|
290 |
itemDoc.DocumentElement().GetChildElements(children);
|
|
291 |
|
|
292 |
TPtrC8 itemGenre =
|
|
293 |
itemDoc.DocumentElement().AttributeNodeL(KGenreName8).Value();
|
|
294 |
|
|
295 |
TInt amount = children.Count();
|
|
296 |
for( TInt i(0); i<amount; i++ )
|
|
297 |
{
|
|
298 |
TXmlEngElement child = children.Next();
|
|
299 |
TPtrC8 tempChildName = child.Name();
|
|
300 |
// append localizations to root
|
|
301 |
if (!child.Name().Compare(KLocalizationName8))
|
|
302 |
{
|
|
303 |
aXmlDoc.DocumentElement().AsElement().AppendChildL(child);
|
|
304 |
child.ReconcileNamespacesL();
|
|
305 |
}
|
|
306 |
// append itmes to proper suite
|
|
307 |
else if (!child.Name().Compare(KItemName8) )
|
|
308 |
{
|
|
309 |
// go througs item's children to change event names to ids
|
|
310 |
ChangeEventsToIdsInChildrenL(child);
|
|
311 |
|
|
312 |
// edit_mode item
|
|
313 |
RXmlEngNodeList< TXmlEngElement > editModeItems;
|
|
314 |
CleanupClosePushL( editModeItems );
|
|
315 |
child.GetChildElements( editModeItems );
|
|
316 |
TInt count = editModeItems.Count();
|
|
317 |
for ( TInt ic( 0 ); ic < count; ic++ )
|
|
318 |
{
|
|
319 |
TXmlEngElement editModeItem = editModeItems.Next();
|
|
320 |
if ( !editModeItem.Name().Compare( KEditModeItem8 ))
|
|
321 |
{
|
|
322 |
editModeItem.AddNewAttributeL(KSuiteElementName8,
|
|
323 |
itemGenre);
|
|
324 |
}
|
|
325 |
}
|
|
326 |
CleanupStack::PopAndDestroy(&editModeItems);
|
|
327 |
// edit_mode items - end
|
|
328 |
|
|
329 |
RXmlEngNodeList<TXmlEngElement> suites;
|
|
330 |
CleanupClosePushL(suites);
|
|
331 |
aXmlDoc.DocumentElement().GetChildElements(suites);
|
|
332 |
TInt amountSuites = suites.Count();
|
|
333 |
for (TInt i(0); i < amountSuites; i++)
|
|
334 |
{
|
|
335 |
TXmlEngElement childSuite = suites.Next();
|
|
336 |
TPtrC8 tempName = child.Name();
|
|
337 |
//find suite
|
|
338 |
if (!childSuite.Name().Compare(KTitleName8))
|
|
339 |
{
|
|
340 |
TPtrC8 suiteGenre = childSuite.AttributeNodeL(
|
|
341 |
KGenreName8).Value();
|
|
342 |
|
|
343 |
//find proper suite to append item
|
|
344 |
if (!suiteGenre.Compare(itemGenre))
|
|
345 |
{
|
|
346 |
child.AddNewAttributeL(KSuiteElementName8,
|
|
347 |
itemGenre);
|
|
348 |
childSuite.AppendChildL(child);
|
|
349 |
}
|
|
350 |
}
|
|
351 |
}
|
|
352 |
aXmlDoc.DocumentElement().ReconcileNamespacesL();
|
|
353 |
CleanupStack::PopAndDestroy( &suites );
|
|
354 |
}
|
|
355 |
}
|
|
356 |
CleanupStack::PopAndDestroy( &children );
|
|
357 |
}
|
|
358 |
CleanupStack::PopAndDestroy( &itemDoc );
|
|
359 |
}
|
|
360 |
|
|
361 |
|
|
362 |
// ---------------------------------------------------------------------------
|
|
363 |
//
|
|
364 |
// ---------------------------------------------------------------------------
|
|
365 |
//
|
|
366 |
TInt CHnXmlModelProvider::GetNewEventId( HBufC* aEventName )
|
|
367 |
{
|
|
368 |
TInt res( KErrGeneral );
|
|
369 |
|
|
370 |
if ( !aEventName->Compare( KKeyEmpty ) )
|
|
371 |
{
|
|
372 |
res = KKeyIdEmpty;
|
|
373 |
}
|
|
374 |
else if ( !aEventName->Compare( KKeySelect ) )
|
|
375 |
{
|
|
376 |
res = KKeyIdSelect;
|
|
377 |
}
|
|
378 |
else if ( !aEventName->Compare( KKeySelect2 ) )
|
|
379 |
{
|
|
380 |
res = KKeyIdSelect2;
|
|
381 |
}
|
|
382 |
else if ( !aEventName->Compare( KKeySelect3 ) )
|
|
383 |
{
|
|
384 |
res = KKeyIdSelect3;
|
|
385 |
}
|
|
386 |
else if ( !aEventName->Compare( KKeyCall ) )
|
|
387 |
{
|
|
388 |
res = KKeyIdCall;
|
|
389 |
}
|
|
390 |
else if ( !aEventName->Compare( KKeyClear ) )
|
|
391 |
{
|
|
392 |
res = KKeyIdClear;
|
|
393 |
}
|
|
394 |
else if ( !aEventName->Compare( KKeyMove ) )
|
|
395 |
{
|
|
396 |
res = KKeyIdMove;
|
|
397 |
}
|
|
398 |
else if ( !aEventName->Compare( KKeyMoveInto ) )
|
|
399 |
{
|
|
400 |
res = KKeyIdMoveInto;
|
|
401 |
}
|
|
402 |
else if ( !aEventName->Compare( KOnSuiteLoad ) )
|
|
403 |
{
|
|
404 |
res = KIdSuiteLoad;
|
|
405 |
}
|
|
406 |
else if ( !aEventName->Compare( KOnSuiteUnLoad ) )
|
|
407 |
{
|
|
408 |
res = KIdSuiteUnLoad;
|
|
409 |
}
|
|
410 |
else if ( !aEventName->Compare( KOnFocusGain ) )
|
|
411 |
{
|
|
412 |
res = KIdFocusGain;
|
|
413 |
}
|
|
414 |
else if ( !aEventName->Compare( KOnFocusLost ) )
|
|
415 |
{
|
|
416 |
res = KIdFocusLost;
|
|
417 |
}
|
|
418 |
else
|
|
419 |
{
|
|
420 |
THashMapIter<HBufC*, TInt> iter( iEventMap );
|
|
421 |
res = KCustomKeyOffset;
|
|
422 |
|
|
423 |
while ( TInt const * v = iter.NextValue() )
|
|
424 |
{
|
|
425 |
if ( v != NULL && *v >= KCustomKeyOffset )
|
|
426 |
{
|
|
427 |
res++;
|
|
428 |
}
|
|
429 |
}
|
|
430 |
}
|
|
431 |
|
|
432 |
return res;
|
|
433 |
}
|
|
434 |
|
|
435 |
// ---------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
// ---------------------------------------------------------------------------
|
|
438 |
//
|
|
439 |
void CHnXmlModelProvider::ChangeEventNamesToIdsL( TXmlEngElement& aElement )
|
|
440 |
{
|
|
441 |
if ( aElement.HasChildNodes() && ( !aElement.Name().Compare( KMenuItemName8 )
|
|
442 |
|| !aElement.Name().Compare( KMenuToolbar8 ) ) )
|
|
443 |
{
|
|
444 |
|
|
445 |
RXmlEngNodeList< TXmlEngElement > children;
|
|
446 |
CleanupClosePushL(children);
|
|
447 |
aElement.GetChildElements(children);
|
|
448 |
TInt count( children.Count() );
|
|
449 |
for( TInt i( 0 ); i < count; i++ )
|
|
450 |
{
|
|
451 |
TXmlEngElement element = children.Next();
|
|
452 |
if ( CHnMdMenuItem::IsMenuItemElementName( element.Name() ) ||
|
|
453 |
!element.Name().Compare( KMenuButton8 ) )
|
|
454 |
{
|
|
455 |
ChangeEventNamesToIdsL( element );
|
|
456 |
}
|
|
457 |
}
|
|
458 |
CleanupStack::PopAndDestroy( &children );
|
|
459 |
}
|
|
460 |
else if( aElement.AttributeValueL( KEventAttrName8 ).Length() )
|
|
461 |
{
|
|
462 |
TBool bufferEmpty ( ETrue );
|
|
463 |
TBuf8<KMaxPath> newEventIds;
|
|
464 |
|
|
465 |
// loop through all event names
|
|
466 |
|
|
467 |
// parsing events
|
|
468 |
HBufC* events = HnConvUtils::Str8ToStrLC(
|
|
469 |
aElement.AttributeValueL( KEventName8 ) );
|
|
470 |
|
|
471 |
TLex lex( events->Ptr() );
|
|
472 |
TChar ch;
|
|
473 |
|
|
474 |
TInt length( events->Length() );
|
|
475 |
TInt cnt = 0;
|
|
476 |
while( ch = lex.Get() != 0 )
|
|
477 |
{
|
|
478 |
cnt++;
|
|
479 |
while ( ( ch = lex.Peek() ) != '|' && cnt < length)
|
|
480 |
{
|
|
481 |
lex.Inc();
|
|
482 |
cnt++;
|
|
483 |
}
|
|
484 |
|
|
485 |
// iEventMap takes ownership of "en"
|
|
486 |
HBufC* en = HBufC::NewL( lex.MarkedToken().Length() );
|
|
487 |
en->Des().Copy( lex.MarkedToken() );
|
|
488 |
|
|
489 |
TInt* resFind = iEventMap.Find( en );
|
|
490 |
TInt res = -1;
|
|
491 |
if ( resFind == NULL )
|
|
492 |
{
|
|
493 |
TInt newId( GetNewEventId( en ) );
|
|
494 |
iEventMap.Insert( en, newId );
|
|
495 |
res = newId;
|
|
496 |
}
|
|
497 |
else
|
|
498 |
{
|
|
499 |
res = *resFind;
|
|
500 |
delete en;
|
|
501 |
}
|
|
502 |
|
|
503 |
if ( bufferEmpty )
|
|
504 |
{
|
|
505 |
newEventIds.AppendNum( res );
|
|
506 |
bufferEmpty = EFalse;
|
|
507 |
}
|
|
508 |
else
|
|
509 |
{
|
|
510 |
newEventIds.Append(KPipe);
|
|
511 |
newEventIds.AppendNum(res);
|
|
512 |
}
|
|
513 |
|
|
514 |
lex.Inc();
|
|
515 |
cnt++;
|
|
516 |
lex.Mark();
|
|
517 |
if (cnt >= length)
|
|
518 |
break;
|
|
519 |
}
|
|
520 |
|
|
521 |
TXmlEngAttr att = aElement.AttributeNodeL( KEventName8 );
|
|
522 |
att.SetValueL( newEventIds );
|
|
523 |
aElement.SetAttributeNodeL( att );
|
|
524 |
|
|
525 |
CleanupStack::PopAndDestroy( events );
|
|
526 |
}
|
|
527 |
}
|
|
528 |
|
|
529 |
// ---------------------------------------------------------------------------
|
|
530 |
//
|
|
531 |
// ---------------------------------------------------------------------------
|
|
532 |
//
|
|
533 |
void CHnXmlModelProvider::CreateModelL( RXmlEngDocument& aXmlDoc )
|
|
534 |
{
|
|
535 |
MMPERF( ( "CHnXmlModelProvider::CreateModelL IN") );
|
|
536 |
MMPERF( ( " Suite name: %S", &aSuiteName ) );
|
|
537 |
|
|
538 |
TBool suiteCollected = EFalse;
|
|
539 |
suiteCollected = CollectSuiteL( aXmlDoc );
|
|
540 |
|
|
541 |
if ( !suiteCollected )
|
|
542 |
{
|
|
543 |
MMPERF(("CHnXmlModelProvider::CreateModelL - suite collected"));
|
|
544 |
CollectItemsL( aXmlDoc );
|
|
545 |
MMPERF(("CHnXmlModelProvider::CreateModelL - items collected"));
|
|
546 |
}
|
|
547 |
MMPERF( ( "CHnXmlModelProvider::CreateModelL OUT") );
|
|
548 |
}
|
|
549 |
|
|
550 |
|
|
551 |
// ---------------------------------------------------------------------------
|
|
552 |
//
|
|
553 |
// ---------------------------------------------------------------------------
|
|
554 |
//
|
|
555 |
EXPORT_C TInt CHnXmlModelProvider::GetModelL(
|
|
556 |
const TDesC& aSuiteName, RXmlEngDocument& aXmlDoc )
|
|
557 |
{
|
|
558 |
if ( !iCache->IsCachedL( aSuiteName ) )
|
|
559 |
{
|
|
560 |
RXmlEngDocument newXmlDoc;
|
|
561 |
CleanupClosePushL( newXmlDoc );
|
|
562 |
|
|
563 |
CreateModelL( newXmlDoc );
|
|
564 |
|
|
565 |
#ifdef _DEBUG
|
|
566 |
DEBUG(("_MM_:CHnXmlModelProvider::GetModelL _DEBUG IN"));
|
|
567 |
LogEventMapping( iEventMap );
|
|
568 |
LogSuiteModel( aSuiteName, newXmlDoc );
|
|
569 |
DEBUG(("_MM_:CHnXmlModelProvider::GetModelL _DEBUG OUT"));
|
|
570 |
#endif
|
|
571 |
|
|
572 |
// cache takes ownership of the suite name and the document
|
|
573 |
iCache->AddL( aSuiteName, newXmlDoc );
|
|
574 |
|
|
575 |
CleanupStack::Pop( &newXmlDoc );
|
|
576 |
}
|
|
577 |
|
|
578 |
iCache->GetL( aSuiteName, aXmlDoc );
|
|
579 |
|
|
580 |
return KErrNone;
|
|
581 |
}
|