menufw/hierarchynavigator/hnmetadatamodel/src/hnxmlmodelprovider.cpp
branchRCL_3
changeset 26 1b758917cafc
parent 4 4d54b72983ae
equal deleted inserted replaced
25:137ebc85284b 26:1b758917cafc
    16 */
    16 */
    17 
    17 
    18 #include <sysutil.h> 
    18 #include <sysutil.h> 
    19 #include "hnxmlmodelprovider.h"
    19 #include "hnxmlmodelprovider.h"
    20 #include "hnxmlmodelcache.h"	
    20 #include "hnxmlmodelcache.h"	
    21 #include "hnxmlsuitefilesreg.h"
       
    22 #include "hnglobals.h"
    21 #include "hnglobals.h"
    23 #include "hnconvutils.h"
    22 #include "hnconvutils.h"
    24 #include "menudebug.h"
    23 #include "menudebug.h"
    25 #include "hnhelper.inl"
    24 #include "hnhelper.inl"
    26 #include "hnmdmodel.h"
    25 #include "hnmdmodel.h"
    34 //
    33 //
    35 void CHnXmlModelProvider::ConstructL()
    34 void CHnXmlModelProvider::ConstructL()
    36 	{
    35 	{
    37 	iDomImpl.OpenL();
    36 	iDomImpl.OpenL();
    38 	User::LeaveIfError(iDomParser.Open(iDomImpl));
    37 	User::LeaveIfError(iDomParser.Open(iDomImpl));
    39 	User::LeaveIfError(iFs.Connect());
       
    40 	iFileMan = CFileMan::NewL(iFs);
       
    41 
       
    42 	iPath.CreateL(KMaxPath);
       
    43 	User::LeaveIfError(iFs.PrivatePath(iPath));
       
    44 	iPath.Insert(0, KDrive);
       
    45 	iPath.Append(KEntriesSuffix);
       
    46 	iCache = CHnXmlModelCache::NewL();
    38 	iCache = CHnXmlModelCache::NewL();
    47 	
       
    48 	CActiveScheduler::Add( this);
       
    49 	}
    39 	}
    50 
    40 
    51 // ---------------------------------------------------------------------------
       
    52 // 
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void CHnXmlModelProvider::DoCancel()
       
    56 	{
       
    57 	
       
    58 	}
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // 
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void CHnXmlModelProvider::SynchronizationFinishedL()
       
    65 	{
       
    66 	ResetCache();
       
    67 	THnMdCommonPointers &cmnPtr = *THnMdCommonPointers::Static();
       
    68 	CHnMdModel* model = cmnPtr.iModel;
       
    69 	if ( iSuiteFilesUpdated )
       
    70 	    {
       
    71 	    model->ReloadStackSuitesL( cmnPtr.iContainer );
       
    72 	    }
       
    73 	}
       
    74 // ---------------------------------------------------------------------------
       
    75 // 
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CHnXmlModelProvider::RunL()
       
    79 	{
       
    80 	if ( !iSuiteSetIterator )
       
    81 		{
       
    82 		CheckDrivesL();
       
    83 	    iSuiteSetIterator = new ( ELeave ) THashSetIter<HBufC*>( iInstSuites );
       
    84 	    iSuiteSetIterator->Reset();
       
    85 	    iStatus = KRequestPending;
       
    86 	    SetActive();
       
    87 	    TRequestStatus* status = &iStatus;
       
    88 	    User::RequestComplete( status, KErrNone );
       
    89 		}
       
    90 	else if ( iSuiteSetIterator->Next() )
       
    91 		{
       
    92 		TBool filesUpdated = CHnXmlSuiteFilesReg::SynchronizeL(
       
    93                 iFs, **(iSuiteSetIterator->Current()) );
       
    94         iSuiteFilesUpdated = ( iSuiteFilesUpdated || filesUpdated ); 
       
    95 	    iStatus = KRequestPending;
       
    96 	    SetActive();
       
    97 	    TRequestStatus* status = &iStatus;
       
    98 	    User::RequestComplete( status, KErrNone );
       
    99 		}
       
   100 	else
       
   101 		{
       
   102 		delete iSuiteSetIterator;
       
   103 		iSuiteSetIterator = NULL;
       
   104 		SynchronizationFinishedL();
       
   105 		}
       
   106 	}
       
   107 	
       
   108 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
   109 // 
    42 // 
   110 // ---------------------------------------------------------------------------
    43 // ---------------------------------------------------------------------------
   111 //
    44 //
   112 EXPORT_C CHnXmlModelProvider* CHnXmlModelProvider::NewL()
    45 EXPORT_C CHnXmlModelProvider* CHnXmlModelProvider::NewL()
   130 
    63 
   131 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
   132 // 
    65 // 
   133 // ---------------------------------------------------------------------------
    66 // ---------------------------------------------------------------------------
   134 //
    67 //
   135 CHnXmlModelProvider::CHnXmlModelProvider() :
    68 CHnXmlModelProvider::CHnXmlModelProvider(): iEventMap(&HBuf16Hash, &HBuf16Ident)
   136 	CActive( EPriorityLow ),	
       
   137 	iInstSuites(&HBuf16Hash, &HBuf16Ident),
       
   138 	iEventMap(&HBuf16Hash, &HBuf16Ident), 
       
   139 	iSuiteSetIterator( NULL )
       
   140 	{
    69 	{
   141 	 
    70 	 
   142 	}
    71 	}
   143 
    72 
   144 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
   145 // 
    74 // 
   146 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
   147 //
    76 //
   148 EXPORT_C CHnXmlModelProvider::~CHnXmlModelProvider()
    77 EXPORT_C CHnXmlModelProvider::~CHnXmlModelProvider()
   149 	{
    78 	{
   150 	Cancel(); 
       
   151 	
       
   152 	delete iSuiteSetIterator;
       
   153 	delete iCache;
    79 	delete iCache;
   154 	iDomParser.Close();
    80 	iDomParser.Close();
   155 	iDomImpl.Close();
    81 	iDomImpl.Close();
   156 	delete iFileMan;
       
   157 	iFs.Close();
       
   158 	iPath.Close();
       
   159 
    82 
   160 	// clean up eventmap
    83 	// clean up eventmap
   161 	THashMapIter<HBufC*, TInt> iter(iEventMap);
    84 	THashMapIter<HBufC*, TInt> iter(iEventMap);
   162 	while (HBufC* const * ptr = iter.NextKey())
    85 	while (HBufC* const * ptr = iter.NextKey())
   163 		{
    86 		{
   164 		delete *ptr;
    87 		delete *ptr;
   165 		}
    88 		}
   166 	iEventMap.Close();
    89 	iEventMap.Close();
   167 
       
   168 	THashSetIter<HBufC*> iterSuites(iInstSuites);
       
   169 	while ( iterSuites.Next())
       
   170 		{
       
   171 		delete *iterSuites.Current();
       
   172 		}
       
   173 	iInstSuites.Close();
       
   174 
       
   175 	}
    90 	}
   176 
    91 
   177 #ifdef _DEBUG
    92 #ifdef _DEBUG
   178 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
   179 // 
    94 // 
   273 // ---------------------------------------------------------------------------
   188 // ---------------------------------------------------------------------------
   274 //
   189 //
   275 HBufC8* CHnXmlModelProvider::ReadFileLC(const TDesC& aPath)
   190 HBufC8* CHnXmlModelProvider::ReadFileLC(const TDesC& aPath)
   276     {
   191     {
   277     RFile file;
   192     RFile file;
   278     User::LeaveIfError( file.Open(iFs, aPath, EFileRead) );
   193     User::LeaveIfError( file.Open( CEikonEnv::Static()->FsSession(),
       
   194                                    aPath, EFileRead) );
   279     CleanupClosePushL( file );
   195     CleanupClosePushL( file );
   280     
   196     
   281     TInt fileSize(0);
   197     TInt fileSize(0);
   282     User::LeaveIfError( file.Size( fileSize ) );
   198     User::LeaveIfError( file.Size( fileSize ) );
   283     HBufC8* buf = HBufC8::NewLC( fileSize );
   199     HBufC8* buf = HBufC8::NewLC( fileSize );
   324 
   240 
   325 // ---------------------------------------------------------------------------
   241 // ---------------------------------------------------------------------------
   326 // 
   242 // 
   327 // ---------------------------------------------------------------------------
   243 // ---------------------------------------------------------------------------
   328 //
   244 //
   329 TInt CHnXmlModelProvider::CollectSuiteL(const TDesC& aSuiteName,
   245 TInt CHnXmlModelProvider::CollectSuiteL( RXmlEngDocument& aXmlDoc )
   330 		RXmlEngDocument& aXmlDoc)
   246 	{
   331 	{
   247     TInt err(KErrNotFound);
   332 	TInt err(KErrNotFound);
   248     RXmlEngDocument suiteDoc;
   333 	TBuf<KMaxPath> filePath;
   249 	CleanupClosePushL( suiteDoc );
   334 	TBuf<KMaxPath> KsuitePath;
   250 	//hardcoded path for suites as there is only foldersuite
   335 	KsuitePath.Zero();
   251 	suiteDoc = ParseFileL( KFolderSuitePath );
   336 	KsuitePath.Copy(iPath);
       
   337 	KsuitePath.Append(aSuiteName);
       
   338 	KsuitePath.Append(Kbackslash);
       
   339 
       
   340 	filePath.Zero();
       
   341 	filePath.Copy(KsuitePath);
       
   342 	filePath.Append(KSuiteDefFileName);
       
   343 
       
   344 	RXmlEngDocument suiteDoc;
       
   345 	CleanupClosePushL(suiteDoc);
       
   346 	
       
   347 	suiteDoc = ParseFileL(filePath);
       
   348     
   252     
   349     // one suite per file
   253     // one suite per file
   350     RXmlEngNodeList<TXmlEngElement> elements;
   254     RXmlEngNodeList<TXmlEngElement> elements;
   351     suiteDoc.DocumentElement().GetChildElements( elements );
   255     suiteDoc.DocumentElement().GetChildElements( elements );
   352     TXmlEngElement suiteElement;
   256     TXmlEngElement suiteElement;
   370 
   274 
   371 // ---------------------------------------------------------------------------
   275 // ---------------------------------------------------------------------------
   372 // 
   276 // 
   373 // ---------------------------------------------------------------------------
   277 // ---------------------------------------------------------------------------
   374 //
   278 //
   375 TBool CHnXmlModelProvider::SuiteExistsL( const TDesC& aSuite )
   279 void CHnXmlModelProvider::CollectItemsL( RXmlEngDocument& aXmlDoc )
   376     {
   280     {
   377     TBuf<KMaxPath> filePath;
   281     RXmlEngDocument itemDoc;
   378     TBuf<KMaxPath> KsuitePath;
   282     CleanupClosePushL( itemDoc );
   379     KsuitePath.Zero();
   283     //hardcoded path for items as there is only foldersuite
   380     KsuitePath.Copy( iPath );
   284     TInt err( KErrNone );
   381     KsuitePath.Append( aSuite );
   285     TRAP( err , itemDoc = ParseFileL(KFolderItemsPath) );
   382     KsuitePath.Append( Kbackslash );
   286     if( !err )
   383 
   287         {
   384     filePath.Zero();
   288         RXmlEngNodeList< TXmlEngElement > children;
   385     filePath.Copy( KsuitePath );
   289         CleanupClosePushL(children);
   386     filePath.Append( KSuiteDefFileName );
   290         itemDoc.DocumentElement().GetChildElements(children);
   387     
   291         
   388     return BaflUtils::FileExists( iFs, filePath );
   292         TPtrC8 itemGenre =
   389     }
   293             itemDoc.DocumentElement().AttributeNodeL(KGenreName8).Value();
   390 
       
   391 
       
   392 // ---------------------------------------------------------------------------
       
   393 // 
       
   394 // ---------------------------------------------------------------------------
       
   395 //
       
   396 void CHnXmlModelProvider::CollectItemsL( const TDesC& aSuiteName,
       
   397         RXmlEngDocument& aXmlDoc )
       
   398     {
       
   399     TBuf<KMaxPath> filePath;
       
   400     TBuf<KMaxPath> KsuitePath;
       
   401     KsuitePath.Zero();
       
   402     KsuitePath.Copy( iPath );
       
   403     KsuitePath.Append( aSuiteName ); 
       
   404     KsuitePath.Append( Kbackslash ); 
       
   405     CDir* fileList;                  
       
   406     iFs.GetDir( KsuitePath, KEntryAttMaskSupported, ESortByName, fileList);
       
   407     CleanupStack::PushL(fileList);
       
   408 
       
   409     //for each file with entries definitions         
       
   410     for( TInt i(0); i<fileList->Count(); i++ )  
       
   411         {            
       
   412         TPtrC fileName = (*fileList)[i].iName;   
       
   413         
       
   414         if(!fileName.Compare(KSuiteDefFileName))
       
   415             continue;
       
   416         
       
   417         filePath.Zero();
       
   418         filePath.Copy(KsuitePath);
       
   419         filePath.Append(fileName);  
       
   420             
   294             
   421         RXmlEngDocument itemDoc;
   295         TInt amount = children.Count();
   422         CleanupClosePushL( itemDoc );
   296         for( TInt i(0); i<amount; i++ )
   423         
       
   424         TInt err( KErrNone );
       
   425         TRAP( err , itemDoc = ParseFileL(filePath) );
       
   426         if( !err )
       
   427             {
   297             {
   428             RXmlEngNodeList< TXmlEngElement > children;
   298             TXmlEngElement child = children.Next();
   429             CleanupClosePushL(children);
   299             TPtrC8 tempChildName = child.Name();
   430             itemDoc.DocumentElement().GetChildElements(children);
   300             // append localizations to root
   431             
   301             if (!child.Name().Compare(KLocalizationName8))
   432             TPtrC8 itemGenre =
   302                 {
   433                 itemDoc.DocumentElement().AttributeNodeL(KGenreName8).Value();
   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);
   434                 
   311                 
   435             TInt amount = children.Count();
   312                 // edit_mode item
   436             for( TInt i(0); i<amount; i++ )
   313                 RXmlEngNodeList< TXmlEngElement > editModeItems;
   437                 {
   314                 CleanupClosePushL( editModeItems );
   438                 TXmlEngElement child = children.Next();
   315                 child.GetChildElements( editModeItems );
   439                 TPtrC8 tempChildName = child.Name();
   316                 TInt count = editModeItems.Count();
   440                 // append localizations to root
   317                 for ( TInt ic( 0 ); ic < count; ic++ )
   441                 if (!child.Name().Compare(KLocalizationName8)) 
   318                     {
   442                     {                
   319                     TXmlEngElement editModeItem = editModeItems.Next();
   443                     aXmlDoc.DocumentElement().AsElement().AppendChildL(child);
   320                     if ( !editModeItem.Name().Compare( KEditModeItem8 ))
   444                     child.ReconcileNamespacesL();
       
   445                     } 
       
   446                 // append itmes to proper suite 
       
   447                 else if (!child.Name().Compare(KItemName8) )
       
   448                     {                                    
       
   449                     // go througs item's children to change event names to ids
       
   450                     ChangeEventsToIdsInChildrenL(child);
       
   451                     
       
   452                     // edit_mode item
       
   453                     RXmlEngNodeList< TXmlEngElement > editModeItems;
       
   454                     CleanupClosePushL( editModeItems );
       
   455                     child.GetChildElements( editModeItems );
       
   456                     TInt count = editModeItems.Count();
       
   457                     for ( TInt ic( 0 ); ic < count; ic++ )
       
   458                         {
   321                         {
   459                         TXmlEngElement editModeItem = editModeItems.Next();
   322                         editModeItem.AddNewAttributeL(KSuiteElementName8,
   460                         if ( !editModeItem.Name().Compare( KEditModeItem8 ))
   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))
   461                             {
   345                             {
   462 							editModeItem.AddNewAttributeL(KSuiteElementName8,
   346                             child.AddNewAttributeL(KSuiteElementName8,
   463 									itemGenre);
   347                                     itemGenre);
   464 							}
   348                             childSuite.AppendChildL(child);
   465 						}
       
   466 					CleanupStack::PopAndDestroy(&editModeItems);
       
   467 					// edit_mode items - end
       
   468 
       
   469 					RXmlEngNodeList<TXmlEngElement> suites;
       
   470 					CleanupClosePushL(suites);
       
   471 					aXmlDoc.DocumentElement().GetChildElements(suites);
       
   472 					TInt amountSuites = suites.Count();
       
   473 					for (TInt i(0); i < amountSuites; i++)
       
   474 						{
       
   475 						TXmlEngElement childSuite = suites.Next();
       
   476 						TPtrC8 tempName = child.Name();
       
   477 						//find suite
       
   478 						if (!childSuite.Name().Compare(KTitleName8))
       
   479 							{
       
   480 							TPtrC8 suiteGenre = childSuite.AttributeNodeL(
       
   481 									KGenreName8).Value();
       
   482 
       
   483 							//find proper suite to append item
       
   484 							if (!suiteGenre.Compare(itemGenre))
       
   485 								{
       
   486 								child.AddNewAttributeL(KSuiteElementName8,
       
   487 										itemGenre);
       
   488 								childSuite.AppendChildL(child);
       
   489                                 }                        
       
   490                             }
   349                             }
   491                         }
   350                         }
   492 					aXmlDoc.DocumentElement().ReconcileNamespacesL();
   351                     }
   493                     CleanupStack::PopAndDestroy( &suites );                    
   352                 aXmlDoc.DocumentElement().ReconcileNamespacesL();
   494                     }                                
   353                 CleanupStack::PopAndDestroy( &suites );
   495                 }                   
   354                 }
   496             CleanupStack::PopAndDestroy( &children );
       
   497             }
   355             }
   498         CleanupStack::PopAndDestroy( &itemDoc );
   356         CleanupStack::PopAndDestroy( &children );
   499         } 
   357         }
   500     
   358     CleanupStack::PopAndDestroy( &itemDoc );
   501     CleanupStack::PopAndDestroy(fileList);
       
   502     }        
   359     }        
   503 
   360 
   504 
   361 
   505 // ---------------------------------------------------------------------------
   362 // ---------------------------------------------------------------------------
   506 // 
   363 // 
   670     }
   527     }
   671     
   528     
   672 // ---------------------------------------------------------------------------
   529 // ---------------------------------------------------------------------------
   673 // 
   530 // 
   674 // ---------------------------------------------------------------------------
   531 // ---------------------------------------------------------------------------
   675 //
   532 // 
   676 TBool CHnXmlModelProvider::SynchronizeSuitesL()
   533 void CHnXmlModelProvider::CreateModelL( RXmlEngDocument& aXmlDoc )
   677     {
       
   678     MMPERF(("CHnXmlModelProvider::SynchronizeSuitesL - START"));
       
   679     iSuiteFilesUpdated = EFalse;
       
   680     TBool refresh( EFalse );   
       
   681 
       
   682     if (IsActive())
       
   683     	{
       
   684     	Cancel();
       
   685     	}
       
   686     
       
   687     delete iSuiteSetIterator;
       
   688     iSuiteSetIterator = NULL;
       
   689     
       
   690     iStatus = KRequestPending;
       
   691     SetActive();
       
   692     TRequestStatus* status = &iStatus;
       
   693     User::RequestComplete( status, KErrNone );
       
   694    
       
   695     MMPERF(("CHnXmlModelProvider::SynchronizeSuitesL - DONE"));
       
   696     return refresh;
       
   697     }
       
   698  
       
   699 // ---------------------------------------------------------------------------
       
   700 // 
       
   701 // ---------------------------------------------------------------------------
       
   702 // 
       
   703 void CHnXmlModelProvider::ResetCache()
       
   704     {
       
   705     iCache->Reset();
       
   706     }
       
   707 
       
   708 // ---------------------------------------------------------------------------
       
   709 // 
       
   710 // ---------------------------------------------------------------------------
       
   711 //   
       
   712 void CHnXmlModelProvider::SetupSuitePathL()
       
   713 	{
       
   714 	iPath.Close();
       
   715 	iPath.CreateL(KMaxPath);
       
   716 	User::LeaveIfError(iFs.PrivatePath(iPath));
       
   717 	TChar drive;
       
   718 	TBuf<1> driveLetter;
       
   719 	
       
   720 	iFs.DriveToChar( EDriveC, drive );
       
   721 	iPath.Insert(0, KColon );
       
   722 	driveLetter.Append( drive );
       
   723 	iPath.Insert(0, driveLetter );
       
   724 	iPath.Append(KEntriesSuffix);
       
   725 	}
       
   726 
       
   727 // ---------------------------------------------------------------------------
       
   728 // 
       
   729 // ---------------------------------------------------------------------------
       
   730 //   
       
   731 void CHnXmlModelProvider::SetupFailSafeSuitePathL()
       
   732 	{
       
   733 	iPath.Close();
       
   734 	iPath.CreateL(KMaxPath);
       
   735 	User::LeaveIfError(iFs.PrivatePath(iPath));
       
   736 	TChar drive;
       
   737 	TBuf<1> driveLetter;
       
   738 	
       
   739 	iFs.DriveToChar( EDriveZ, drive );
       
   740 	iPath.Insert(0, KColon );
       
   741 	driveLetter.Append( drive );
       
   742 	iPath.Insert(0, driveLetter );
       
   743 	iPath.Append(KSuitesDir);
       
   744 	}
       
   745 
       
   746 
       
   747 // ---------------------------------------------------------------------------
       
   748 // 
       
   749 // ---------------------------------------------------------------------------
       
   750 // 
       
   751 EXPORT_C void CHnXmlModelProvider::ReloadModelL()
       
   752 	{
       
   753 	SynchronizeSuitesL();
       
   754 	}
       
   755 
       
   756 // ---------------------------------------------------------------------------
       
   757 // 
       
   758 // ---------------------------------------------------------------------------
       
   759 // 
       
   760 void CHnXmlModelProvider::CreateModelL(const TDesC& aSuiteName,
       
   761         RXmlEngDocument& aXmlDoc )
       
   762     {
   534     {
   763     MMPERF( ( "CHnXmlModelProvider::CreateModelL IN") );
   535     MMPERF( ( "CHnXmlModelProvider::CreateModelL IN") );
   764     MMPERF( ( "    Suite name: %S", &aSuiteName ) );
   536     MMPERF( ( "    Suite name: %S", &aSuiteName ) );
   765     
   537     
   766     TBool suiteCollected = EFalse;
   538     TBool suiteCollected = EFalse;
   767 	
   539     suiteCollected = CollectSuiteL( aXmlDoc );
   768     SetupSuitePathL();	
       
   769     TRAPD( failSafeErr, suiteCollected = CollectSuiteL( aSuiteName, aXmlDoc ));
       
   770     if (failSafeErr)
       
   771     	{
       
   772     	SetupFailSafeSuitePathL();
       
   773     	suiteCollected = CollectSuiteL( aSuiteName, aXmlDoc );
       
   774     	}
       
   775     
   540     
   776     if ( !suiteCollected )
   541     if ( !suiteCollected )
   777         {
   542         {
   778         MMPERF(("CHnXmlModelProvider::CreateModelL - suite collected"));
   543         MMPERF(("CHnXmlModelProvider::CreateModelL - suite collected"));
   779         CollectItemsL( aSuiteName, aXmlDoc );
   544         CollectItemsL( aXmlDoc );
   780         MMPERF(("CHnXmlModelProvider::CreateModelL - items collected"));
   545         MMPERF(("CHnXmlModelProvider::CreateModelL - items collected"));
   781         }
   546         }
   782     MMPERF( ( "CHnXmlModelProvider::CreateModelL OUT") );
   547     MMPERF( ( "CHnXmlModelProvider::CreateModelL OUT") );
   783     }
   548     }
   784 
   549 
   793     if ( !iCache->IsCachedL( aSuiteName ) )
   558     if ( !iCache->IsCachedL( aSuiteName ) )
   794         {
   559         {
   795         RXmlEngDocument newXmlDoc;
   560         RXmlEngDocument newXmlDoc;
   796         CleanupClosePushL( newXmlDoc );
   561         CleanupClosePushL( newXmlDoc );
   797         
   562         
   798         CreateModelL( aSuiteName, newXmlDoc );
   563         CreateModelL( newXmlDoc );
   799         
   564         
   800         #ifdef _DEBUG
   565         #ifdef _DEBUG
   801             DEBUG(("_MM_:CHnXmlModelProvider::GetModelL _DEBUG IN"));
   566             DEBUG(("_MM_:CHnXmlModelProvider::GetModelL _DEBUG IN"));
   802             LogEventMapping( iEventMap );
   567             LogEventMapping( iEventMap );
   803             LogSuiteModel( aSuiteName, newXmlDoc );
   568             LogSuiteModel( aSuiteName, newXmlDoc );
   812     
   577     
   813     iCache->GetL( aSuiteName, aXmlDoc );
   578     iCache->GetL( aSuiteName, aXmlDoc );
   814     
   579     
   815     return KErrNone;
   580     return KErrNone;
   816     }   
   581     }   
   817    
       
   818 
       
   819 // ---------------------------------------------------------------------------
       
   820 // 
       
   821 // ---------------------------------------------------------------------------
       
   822 //
       
   823 void CHnXmlModelProvider::SearchPathForSuitesL( const TDesC& aPath )
       
   824 	{
       
   825 	CDir* fileList = NULL;            
       
   826 	iFs.GetDir( aPath, KEntryAttMaskSupported, ESortByName, fileList );  
       
   827 	if ( fileList )                        
       
   828 		{                
       
   829 		CleanupStack::PushL( fileList );      
       
   830 		for( TInt i( 0 ); i < fileList->Count(); i++ ) 
       
   831 			{  
       
   832 			if ( (*fileList)[ i ].IsDir() )
       
   833 				{
       
   834 				HBufC* suiteName = (*fileList)[i].iName.AllocLC();
       
   835 				if ( !iInstSuites.Find(suiteName) )
       
   836 					{
       
   837 					iInstSuites.InsertL( suiteName );
       
   838 					CleanupStack::Pop(suiteName);
       
   839 					}
       
   840 				else
       
   841 					{
       
   842 					CleanupStack::PopAndDestroy(suiteName);
       
   843 					}
       
   844 				}
       
   845 			}
       
   846 			CleanupStack::PopAndDestroy( fileList );
       
   847 		}
       
   848     }
       
   849 // ---------------------------------------------------------------------------
       
   850 // 
       
   851 // ---------------------------------------------------------------------------
       
   852 //
       
   853 void CHnXmlModelProvider::CheckDrivesL()
       
   854     { 
       
   855     TDriveList driveList;
       
   856     User::LeaveIfError( iFs.DriveList( driveList ) );
       
   857     
       
   858     TFixedArray< TInt, KMaxDrives > driveSearchOrder( KDriveSearchOrder, KMaxDrives );
       
   859     for(TInt iterator(0); iterator < driveSearchOrder.Count(); iterator++ )
       
   860      	{        
       
   861         if ( driveList[ driveSearchOrder[ iterator ] ] )
       
   862             {
       
   863             TBuf<KMaxPath> filePath;
       
   864 
       
   865             TChar driveLetter;
       
   866             User::LeaveIfError( iFs.DriveToChar( driveSearchOrder[ iterator ], driveLetter ) );  
       
   867             
       
   868             TBuf< KSingleChar > driveLetterConst;
       
   869             driveLetterConst.Append( driveLetter );
       
   870             User::LeaveIfError( iFs.PrivatePath( filePath ) );
       
   871             filePath.Insert( 0, driveLetterConst );
       
   872             filePath.Insert( 1, KColon );
       
   873             filePath.Append( KSuitesDir );
       
   874                          
       
   875             SearchPathForSuitesL( filePath );           
       
   876             }
       
   877     	}
       
   878     
       
   879     SearchPathForSuitesL( iPath );
       
   880     }
       
   881