csxhelp/HelpEngine/src/CSXHHTMLContentParser.cpp
changeset 0 1f04cf54edd8
child 1 27f5851bd5a5
equal deleted inserted replaced
-1:000000000000 0:1f04cf54edd8
       
     1 /*
       
     2 * Copyright (c) 2006 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:  CCSXHHTMLContentParser class definition
       
    15 *
       
    16 */
       
    17 
       
    18 #include "CSXHHTMLContentParser.h"
       
    19 #include "CSXHXMLParseHandler.h"
       
    20 #include "CSXHHtmlTOC1.h"
       
    21 #include "CSXHKywdTOC1.h"
       
    22 #include "CSXHHtmlTOC2.h"
       
    23 #include "CSXHHelpDataBase.h"
       
    24 #include "csxhconstants.h"
       
    25 #include "CSXHRuntimeIndexing.h"
       
    26 
       
    27 #include <eikenv.h> 
       
    28 #include <utf.h>
       
    29 #include <data_caging_path_literals.hrh>
       
    30 #include <zipfile.h>
       
    31 #include <bautils.h>
       
    32 #include <SenXmlReader.h> 
       
    33 #include <f32file.h>
       
    34 #include <pathinfo.h> 
       
    35 
       
    36 //Input Language variation changes
       
    37 #include <PtiEngine.h>
       
    38 
       
    39 const TInt KOffset = 2;
       
    40         
       
    41 CCSXHHTMLContentParser* CCSXHHTMLContentParser::NewL(CCoeEnv* aCoeEnv)
       
    42     {
       
    43     CCSXHHTMLContentParser* self = CCSXHHTMLContentParser::NewLC(aCoeEnv);
       
    44     CleanupStack::Pop(self);
       
    45     return self;
       
    46     }
       
    47     
       
    48 CCSXHHTMLContentParser* CCSXHHTMLContentParser::NewLC(CCoeEnv* aCoeEnv)
       
    49     {
       
    50     CCSXHHTMLContentParser* self = new (ELeave) CCSXHHTMLContentParser(aCoeEnv);
       
    51     CleanupStack::PushL(self);
       
    52     self->ConstructL();
       
    53     return self;
       
    54     }
       
    55     
       
    56 void CCSXHHTMLContentParser::ConstructL()
       
    57     {
       
    58     //RUNTIME
       
    59     GetSupportedFeatureListL();
       
    60     }
       
    61     
       
    62 CCSXHHTMLContentParser::CCSXHHTMLContentParser(CCoeEnv* aCoeEnv) : iCoeEnv(aCoeEnv)
       
    63     {
       
    64     }
       
    65     
       
    66 CCSXHHTMLContentParser::~CCSXHHTMLContentParser()
       
    67     {
       
    68     delete iXmlReader;
       
    69     
       
    70     //No need to delete the entries here, it will be done by the database
       
    71     iHtmlTOC1List.Close();
       
    72     
       
    73     //Delete all contents from the array.
       
    74     TInt count =    iDuplicateHelpTopicList.Count();
       
    75     CCSXHHtmlTOC1* toc1;
       
    76     for(TInt i=0;i<count;++i )
       
    77         {
       
    78         toc1 = iDuplicateHelpTopicList[i];
       
    79         delete toc1;
       
    80         }
       
    81     iDuplicateHelpTopicList.Reset();    
       
    82 	iDuplicateHelpTopicList.Close();
       
    83 	
       
    84     // Closes the array and frees all memory allocated to the array.
       
    85    // iSupportedFeatures.Close();
       
    86     
       
    87     delete iSupportedInputLanguages;
       
    88     delete iFeatureManager_FeatureIds;
       
    89     delete iIndexing;
       
    90     }
       
    91     
       
    92 void CCSXHHTMLContentParser::GenerateTOC1ListL(CCSXHHelpDataBase* aDataBase)
       
    93     {       
       
    94     RFs& FileSession = iCoeEnv->FsSession();
       
    95 
       
    96     TDriveList DirList; 
       
    97     if(FileSession.DriveList(DirList) != KErrNone)
       
    98         return; 
       
    99     CCSXHXMLParseHandler_MetaFile* XMLParser = CCSXHXMLParseHandler_MetaFile::NewL(iCoeEnv); 
       
   100     CleanupStack::PushL(XMLParser);   
       
   101     InitializeReaderL(XMLParser);
       
   102     
       
   103       
       
   104     TBuf<KMaxFileName>* rootDir = new(ELeave) TBuf<KMaxFileName>;
       
   105     CleanupStack::PushL(rootDir);//5
       
   106 
       
   107     // begin runtime index XML generating
       
   108     //   
       
   109     iIndexing = CCSXHRuntimeIndexing::NewL();
       
   110     TInt driveListSize = DirList.Length();
       
   111     TBool dirExists = iIndexing->IndexFileExists();
       
   112     CDirScan* scanner=CDirScan::NewLC(FileSession);
       
   113 #ifdef _DEBUG
       
   114     RDebug::Print(_L("runtime indexing object successfully build"));
       
   115 #endif
       
   116     for(TInt dir(0); dir < driveListSize; dir++)
       
   117         {
       
   118         TInt error;
       
   119         TDriveInfo info;
       
   120         TChar driveLetter = '?';
       
   121         error = FileSession.Drive(info, dir);
       
   122             
       
   123         if  ( ( error == KErrNone ) && 
       
   124                 (DirList[dir] && info.iType != EMediaNotPresent))
       
   125             {
       
   126             RFs::DriveToChar( dir, driveLetter );
       
   127             TInt dirChanged = iIndexing->CheckDirChange( driveLetter );
       
   128             rootDir->Delete( 0, rootDir->Length() );//Clear the previous contents                  
       
   129             rootDir->Append( driveLetter );
       
   130 
       
   131             if  ( dirExists 
       
   132                     && ( dirChanged == KNoChange
       
   133                         || dirChanged == KNoDirExist) )
       
   134                 {
       
   135                 // xml exist and no install/uninstall happened
       
   136                 // while Z needs special process once its index file exists
       
   137 #ifdef _DEBUG
       
   138                 RDebug::Print(_L("Used to launch, scan drive number:  %d"), dir);
       
   139 #endif
       
   140                 if ( dirChanged == KNoChange )
       
   141                     {
       
   142                     // no modify helps, so just parse index.xml
       
   143                     //
       
   144                     HandleMasterMetaFileL( aDataBase, driveLetter, XMLParser );
       
   145                     }
       
   146                 else // KNoDirExist
       
   147                     {
       
   148                     // help content folder removed due to some reason (uninstall/crash?)
       
   149                     // delete index file in case it exist
       
   150 #ifdef _DEBUG
       
   151                     RDebug::Print( _L("no resource folder, delete index.xml if exists") );
       
   152 #endif
       
   153                     iIndexing->DeleteIndexFile( driveLetter );
       
   154                     }
       
   155                 }
       
   156             else
       
   157                 {
       
   158                 // xml not exist or install/uninstall not happend
       
   159                 //
       
   160                 if( GetHTMLContentPathForDriveL( rootDir,iCoeEnv ) )
       
   161                     {
       
   162 #ifdef _DEBUG
       
   163                     RDebug::Print( _L("No index, scan folder for parsing, drive letter: %d"), dir );
       
   164 #endif
       
   165                     iIndexing->BeginIndexFile( driveLetter );
       
   166                     scanner->SetScanDataL(*rootDir
       
   167                                     ,KEntryAttDir|KEntryAttMatchExclusive,
       
   168                                     ESortByName|EAscending, CDirScan::EScanDownTree);
       
   169                     ScanAndParseXMLfileToCreateTOC1ObjectL(FileSession,scanner,aDataBase,
       
   170                                                         dir,XMLParser);  
       
   171                                                         
       
   172                     iIndexing->FinishAndCloseIndexFileL();
       
   173                     
       
   174                     }
       
   175                 
       
   176                 }
       
   177 
       
   178             }
       
   179         }
       
   180     CleanupStack::PopAndDestroy( scanner );
       
   181     CleanupStack::PopAndDestroy(rootDir);
       
   182     CleanupStack::PopAndDestroy(XMLParser);
       
   183     
       
   184     ClearReader();
       
   185     }
       
   186 
       
   187 TBool CCSXHHTMLContentParser::GetHTMLContentPathForDriveL(TBuf<KMaxFileName>* aContentDrive,CCoeEnv *aCoeEnv)
       
   188 	{
       
   189     // get the path to language level
       
   190     // Input: aContentDrive == C or E or Z
       
   191     // Output: aContentDrive == C:\\resource\\xhtml\\01\\ (or Z:\\resource\\xhtml\\31\\)
       
   192     //
       
   193 	aContentDrive->Append(KXhtmlFolder);
       
   194 	TInt len = aContentDrive->Length();
       
   195 	RFs& FileSession = aCoeEnv->FsSession();
       
   196 	RArray<TLanguage> langs;
       
   197    	BaflUtils::GetDowngradePathL(FileSession,User::Language(),langs);
       
   198     		
       
   199     for(int i = 0; i < langs.Count(); ++i)
       
   200     	{
       
   201     	TLanguage lang = langs[i];
       
   202     	//TSW Error: UKAL-6YL72P
       
   203     	//Tool chain uses full symbian language id in 
       
   204     	//the directory name, which is not detected by help application.
       
   205     	//
       
   206     	if(lang < 10)
       
   207             {
       
   208             aContentDrive->AppendNumFixedWidth(lang,EDecimal,2);
       
   209             }
       
   210         else
       
   211             {
       
   212             aContentDrive->AppendNum(lang);
       
   213             }
       
   214     	
       
   215     	aContentDrive->Append(KFwdSlash);
       
   216     	if(BaflUtils::PathExists(FileSession,*aContentDrive))
       
   217     		{
       
   218     		langs.Reset();
       
   219     		return ETrue;
       
   220     		}
       
   221     	else
       
   222     		{
       
   223     		aContentDrive->Delete((len-1),aContentDrive->Length()-len);
       
   224     		}	
       
   225     	}
       
   226     	langs.Reset();
       
   227     	return EFalse;
       
   228 	}
       
   229     
       
   230 TBool CCSXHHTMLContentParser::HandleMasterMetaFileL(CCSXHHelpDataBase* aDataBase, 
       
   231                         TChar& aDrive, MSenContentHandlerClient *aPrevHandler)											   
       
   232     {
       
   233     RFs& FileSession = iCoeEnv->FsSession();
       
   234     TBuf<KMaxFileName> masterFile;
       
   235 
       
   236     iIndexing->GetPrivatePath( masterFile );
       
   237     masterFile.Append( aDrive );
       
   238     masterFile.Append( KFwdSlash );
       
   239     iIndexing->AppendLocale( masterFile );
       
   240     masterFile.Append( KMasterMetaFile );
       
   241     if(BaflUtils::FileExists( FileSession,masterFile ) )
       
   242         {
       
   243 #ifdef _DEBUG
       
   244         RDebug::Print(_L("index exist begin to parse!    %c"), aDrive );
       
   245 #endif
       
   246         CCSXHXMLParseHandler_MasterMetaFile* masterMetaHandler = 
       
   247         CCSXHXMLParseHandler_MasterMetaFile::NewL(iCoeEnv);
       
   248         masterMetaHandler->SetDataBasePtr(aDataBase);
       
   249         masterMetaHandler->SetHtmlContentParserPtr(this);
       
   250         CleanupStack::PushL(masterMetaHandler);      
       
   251     
       
   252         iXmlReader->SetContentHandler(*masterMetaHandler);
       
   253         // ParseL is not in async
       
   254         iXmlReader->ParseL(FileSession,masterFile);
       
   255         iXmlReader->SetContentHandler(*aPrevHandler);
       
   256         CleanupStack::PopAndDestroy(masterMetaHandler);
       
   257         }
       
   258 
       
   259     return ETrue;
       
   260     }
       
   261     
       
   262 void CCSXHHTMLContentParser::GenerateTOC2ListL(CCSXHGenericTOC1& 
       
   263 aGenericTOC1Object, RPointerArray<CCSXHHelpContentBase>* GenericTOC2List)
       
   264     {
       
   265     CCSXHXMLParseHandler_IndexFile* XMLParser = CCSXHXMLParseHandler_IndexFile::NewL(iCoeEnv);
       
   266     CleanupStack::PushL(XMLParser);      
       
   267     InitializeReaderL(XMLParser);
       
   268         
       
   269     XMLParser->SetArray(GenericTOC2List);
       
   270     XMLParser->SetGenericTOC1Object(aGenericTOC1Object);
       
   271     XMLParser->SetHtmlContentParserPtr(this);
       
   272     RFs& FileSession = iCoeEnv->FsSession();
       
   273     CCSXHHtmlTOC1* toc1 = STATIC_CAST(CCSXHHtmlTOC1*,&aGenericTOC1Object);
       
   274     TBuf<KMaxFileName> lookupindexfile;
       
   275     toc1->GetHelpFileL(lookupindexfile);
       
   276     XMLParser->SetPath(lookupindexfile);
       
   277     lookupindexfile.Append(KIndexFile);              
       
   278  
       
   279     if(BaflUtils::FileExists(FileSession,lookupindexfile))
       
   280         iXmlReader->ParseL (FileSession,lookupindexfile);
       
   281 	
       
   282 	TBuf<KMaxFileName>HelpContentName(toc1->GetName());
       
   283 	int toc1Count = iDuplicateHelpTopicList.Count();
       
   284 	
       
   285  	for(int i=0;i < toc1Count;i++)
       
   286 	    {    
       
   287 	    CCSXHHtmlTOC1* temptoc1 = iDuplicateHelpTopicList[i];
       
   288 	        
       
   289 	    if(temptoc1->GetName().CompareF(HelpContentName) == 0)
       
   290 		    {    
       
   291 		    TBuf<KMaxFileName> lookup;
       
   292 		    temptoc1->GetHelpFileL(lookup);
       
   293 		    XMLParser->SetPath(lookup);
       
   294 		    lookup.Append(KIndexFile);              
       
   295 		 
       
   296 		    if(BaflUtils::FileExists(FileSession,lookup))
       
   297 		        iXmlReader->ParseL (FileSession,lookup);
       
   298 		    }
       
   299 	    }
       
   300     
       
   301     CleanupStack::PopAndDestroy(XMLParser);
       
   302     ClearReader();
       
   303     }       
       
   304         
       
   305 TAny* CCSXHHTMLContentParser::GetTopicContentL(CCSXHGenericTOC2* aTopic)
       
   306     {
       
   307     CCSXHHtmlTOC2* topic = STATIC_CAST(CCSXHHtmlTOC2*,aTopic);
       
   308     TBuf<KMaxFileName> htmlFile;
       
   309 	topic->GetHtmlFileName(htmlFile);
       
   310     return GetContentsFromFileL(htmlFile,iCoeEnv,iFeatureControl);
       
   311     }
       
   312     
       
   313 
       
   314 void CCSXHHTMLContentParser::ScanAndParseXMLfileToCreateTOC1ObjectL(RFs& FileSession,
       
   315                                                                  CDirScan* scanner,
       
   316                                                                  CCSXHHelpDataBase* aDataBase,
       
   317                                                                  const TInt& aDrive,
       
   318                                                                  CCSXHXMLParseHandler* XMLParser
       
   319                                                                   )
       
   320     {
       
   321      CDir* entryList = NULL;
       
   322     scanner->NextL(entryList);
       
   323     if(!entryList)
       
   324         return;
       
   325  
       
   326     CleanupStack::PushL(entryList);
       
   327     TInt entryCount = entryList->Count();           
       
   328      
       
   329     TLinearOrder<CCSXHHelpContentBase> anOrder(Orderer<CCSXHHelpContentBase>); 
       
   330     
       
   331     TBuf<KMaxFileName> lookup;
       
   332     
       
   333 
       
   334     while(entryCount--)
       
   335         {
       
   336         TEntry entry=(*entryList)[entryCount];
       
   337         
       
   338         //Clear the previous values
       
   339         lookup.Delete(0,lookup.Length());
       
   340         
       
   341         lookup.Append(scanner->FullPath());
       
   342         lookup.Append(entry.iName); 
       
   343         lookup.Append(KFwdSlash);
       
   344         lookup.Append(KMetaFile);
       
   345         
       
   346         //Check whether a file exists        
       
   347         if(!BaflUtils::FileExists(FileSession,lookup))
       
   348             continue;
       
   349         
       
   350         TRAPD(parserResult,iXmlReader->ParseL (FileSession,lookup ));
       
   351         if(parserResult == KErrNone)
       
   352             {
       
   353 			if(CheckFeatureIDL(XMLParser->GetFeatureIds()))
       
   354             	{            
       
   355             	if(!IsAppUIdPresentAlready(entry.iName))
       
   356 					{
       
   357 		            CCSXHHtmlTOC1* CategoryObj = CCSXHHtmlTOC1::NewL(
       
   358 		                                        XMLParser->GetApplicationName(),entry.iName,aDrive);
       
   359 		            iIndexing->RuntimeGenerateIndexL( *CategoryObj, XMLParser->GetFeatureIds() );
       
   360 		            if(CategoryObj && aDataBase->GetMainTopics()->InsertChild(CategoryObj,EFalse))
       
   361 		            	iHtmlTOC1List.Append(CategoryObj);//Keep a local copy*/ 
       
   362 					else
       
   363 						{
       
   364 						if(CategoryObj)  
       
   365 		            		iDuplicateHelpTopicList.Append(CategoryObj);	
       
   366 						}			            	
       
   367 					}
       
   368             	}         
       
   369             }
       
   370         }       
       
   371 
       
   372     CleanupStack::PopAndDestroy(entryList);
       
   373     }
       
   374     
       
   375 void CCSXHHTMLContentParser::InsertHTMLToc1L(
       
   376             const TDesC &appUidName,const TDesC &appName, 
       
   377             const TInt& aDrive , CCSXHHelpDataBase* aDataBase, const TDesC &FeatureIds)
       
   378     {
       
   379 	if(CheckFeatureIDL(FeatureIds))
       
   380 	    {
       
   381 	    if(!IsAppUIdPresentAlready(appUidName)) 
       
   382 		    {    
       
   383 			CCSXHHtmlTOC1* CategoryObj = CCSXHHtmlTOC1::NewL(appName,appUidName,aDrive);
       
   384 		    if(CategoryObj && aDataBase->GetMainTopics()->InsertChild(CategoryObj,EFalse))
       
   385 		    	iHtmlTOC1List.Append(CategoryObj);//Keep a local copy*/ 
       
   386 		    else
       
   387 		    	{
       
   388 		    	if(CategoryObj)  
       
   389 	           		iDuplicateHelpTopicList.Append(CategoryObj);			    	
       
   390 		    	}
       
   391 		    }
       
   392 	    }	
       
   393     }
       
   394     
       
   395 HBufC8* CCSXHHTMLContentParser::GetContentsFromFileL(const TDesC& htmlFile,CCoeEnv* aCoeEnv,
       
   396 			RFeatureControl& aFeatureControl) 
       
   397     {
       
   398     RFs& fileSession = aCoeEnv->FsSession();        
       
   399     TInt SlashPosition = htmlFile.LocateReverse('\\');    
       
   400     TBuf<KMaxFileName>* CompressedFile = new (ELeave) TBuf<KMaxFileName>; 
       
   401     CleanupStack::PushL(CompressedFile); //1
       
   402     CompressedFile->Copy(htmlFile.Mid(0,SlashPosition+1));
       
   403     CompressedFile->Append(KContentZipFile);    
       
   404     
       
   405     HBufC8* CssContent = CreateBufferForCSSContentL(aFeatureControl);
       
   406        
       
   407     if(!BaflUtils::FileExists(fileSession,*CompressedFile))
       
   408         {
       
   409         CleanupStack::PopAndDestroy(CompressedFile);
       
   410         
       
   411         HBufC8* buffer = GetContentsFromHTMLFileL(htmlFile,aCoeEnv);
       
   412         
       
   413         return MergeCssAndHTMLContentL(buffer,CssContent);
       
   414         }
       
   415         
       
   416     // Create an instance of CZipFile.
       
   417     CZipFile* zipFile = CZipFile::NewL(fileSession, *CompressedFile);    
       
   418     CleanupStack::PushL(zipFile); //2
       
   419         
       
   420     // Iterate and get the file name
       
   421     CZipFileMemberIterator* members = zipFile->GetMembersL();
       
   422     CleanupStack::PushL(members);//3
       
   423     CZipFileMember* member = members->NextL(); // Get the first file in zip
       
   424     
       
   425     TInt nCount=0;    
       
   426     const TBuf<KMaxFileName>*Fname;
       
   427     TBuf<KMaxFileName> *HtmlFileName = new (ELeave) TBuf<KMaxFileName>;
       
   428     CleanupStack::PushL(HtmlFileName); //4
       
   429     HtmlFileName->Copy(htmlFile.Mid(SlashPosition+1));
       
   430     for(nCount=0;member!=NULL;nCount++)
       
   431     	{    	 
       
   432     	 Fname = member->Name();    
       
   433 	     if(Fname->Compare(*HtmlFileName)==0 )
       
   434 	    	{
       
   435 	    	break;
       
   436 	    	}	    
       
   437 	    delete member;	
       
   438     	member = members->NextL();    	
       
   439     	}
       
   440 
       
   441 	if(NULL == member)
       
   442 		{
       
   443 		CleanupStack::PopAndDestroy(HtmlFileName);
       
   444 		CleanupStack::PopAndDestroy(members);
       
   445 	    CleanupStack::PopAndDestroy(zipFile);
       
   446 	    CleanupStack::PopAndDestroy(CompressedFile);
       
   447 	    
       
   448 	    HBufC8* buffer = GetContentsFromHTMLFileL(htmlFile,aCoeEnv);
       
   449 	    return MergeCssAndHTMLContentL(buffer,CssContent);
       
   450 	    }
       
   451 		
       
   452     CleanupStack::PushL(member);//5
       
   453     RZipFileMemberReaderStream* stream;
       
   454     zipFile->GetInputStreamL(member, stream);
       
   455     CleanupStack::PushL(stream);//6
       
   456         
       
   457     // Extracts aFileName to a buffer.
       
   458     // If the file is quite huge, then read the file in streaming mode.
       
   459     // For example, use 4KB buffer and read it in an active object.
       
   460     HBufC8* buffer = HBufC8::NewLC(member->UncompressedSize());//5
       
   461     TPtr8 bufferPtr(buffer->Des());
       
   462     User::LeaveIfError(stream->Read(bufferPtr, member->UncompressedSize()));
       
   463 
       
   464     // Release all the resources.   
       
   465     CleanupStack::Pop(buffer);
       
   466     CleanupStack::PopAndDestroy(stream); 
       
   467     CleanupStack::PopAndDestroy(member);
       
   468     CleanupStack::PopAndDestroy(HtmlFileName);
       
   469     CleanupStack::PopAndDestroy(members);
       
   470     CleanupStack::PopAndDestroy(zipFile);
       
   471     CleanupStack::PopAndDestroy(CompressedFile);
       
   472     
       
   473     return MergeCssAndHTMLContentL(buffer,CssContent);
       
   474     }
       
   475 
       
   476 TBool CCSXHHTMLContentParser::HandleMasterKeywordFileL(CCSXHHelpDataBase* aDataBase)
       
   477     {
       
   478     RFs& FileSession = iCoeEnv->FsSession();
       
   479     CCSXHXMLParseHandler_MasterKywd* XMLParser_MasterKywd = CCSXHXMLParseHandler_MasterKywd::NewL(iCoeEnv);  
       
   480     CleanupStack::PushL(XMLParser_MasterKywd);  
       
   481     InitializeReaderL(XMLParser_MasterKywd);
       
   482     XMLParser_MasterKywd->SetHtmlContentParserPtr(this);
       
   483     XMLParser_MasterKywd->SetDataBasePtr(aDataBase);
       
   484     TBool bMasterKeywordFilePresent = EFalse;
       
   485     
       
   486     //Check for the availability of Master Keyword file
       
   487     TBuf<KMaxFileName>* Master_kywdPath = new(ELeave) TBuf<KMaxFileName>;
       
   488     CleanupStack::PushL(Master_kywdPath);//5
       
   489     Master_kywdPath->Append(PathInfo::RomRootPath().Left(1));
       
   490     GetHTMLContentPathForDriveL(Master_kywdPath,iCoeEnv);
       
   491     Master_kywdPath->Append(KMasterKywdFile);
       
   492     
       
   493     if(BaflUtils::FileExists(FileSession,*Master_kywdPath))
       
   494     	{    	
       
   495         TRAP_IGNORE(iXmlReader->ParseL(FileSession,*Master_kywdPath ));
       
   496         bMasterKeywordFilePresent = ETrue;
       
   497     	}    
       
   498     
       
   499     //KMasterKywdFile;
       
   500     CleanupStack::PopAndDestroy(Master_kywdPath);
       
   501     CleanupStack::PopAndDestroy(XMLParser_MasterKywd);
       
   502     ClearReader();	
       
   503     
       
   504     return bMasterKeywordFilePresent;
       
   505     }
       
   506     
       
   507 void CCSXHHTMLContentParser::GenerateKywdTOC1ListL(CCSXHHelpDataBase* aDataBase)
       
   508     {
       
   509     if(!iHtmlTOC1List.Count())
       
   510         return;
       
   511     TBool bMasterKeywordFilePresent = HandleMasterKeywordFileL(aDataBase);
       
   512     
       
   513     CCSXHXMLParseHandler_Kywd* XMLParser = CCSXHXMLParseHandler_Kywd::NewL(iCoeEnv);  
       
   514     CleanupStack::PushL(XMLParser);  
       
   515     InitializeReaderL(XMLParser);
       
   516     
       
   517     XMLParser->SetDataBasePtr(aDataBase);
       
   518     XMLParser->SetIsTOC2(EFalse);
       
   519     XMLParser->SetHtmlContentParserPtr(this);
       
   520     
       
   521     //Parse keyword.xml file from Main Array list
       
   522     ParseKeywdFileAndCreatekywdTOC1ObjectsL(iHtmlTOC1List,XMLParser,bMasterKeywordFilePresent);
       
   523     
       
   524     //Parse keyword.xml file from duplicate Array list
       
   525     ParseKeywdFileAndCreatekywdTOC1ObjectsL(iDuplicateHelpTopicList,XMLParser,bMasterKeywordFilePresent);
       
   526     
       
   527     CleanupStack::PopAndDestroy(XMLParser);
       
   528     ClearReader();
       
   529     }
       
   530     
       
   531 void CCSXHHTMLContentParser::GenerateTOC2ListForKeywordSearchL
       
   532 (CCSXHHelpDataBase* aDataBase,CCSXHKywdTOC1* aKywdTOC1Object)
       
   533     {
       
   534     RPointerArray<CCSXHHtmlTOC1>* TOC1HtmlList = aKywdTOC1Object->GetHtmlTOC1List();
       
   535     if(!TOC1HtmlList)
       
   536         return;
       
   537     
       
   538     CCSXHXMLParseHandler_Kywd* XMLParser = CCSXHXMLParseHandler_Kywd::NewL(iCoeEnv);
       
   539     CleanupStack::PushL(XMLParser);      
       
   540     InitializeReaderL(XMLParser);
       
   541 	
       
   542     int toc1Count = TOC1HtmlList->Count();
       
   543     CCSXHHtmlTOC1* toc1;
       
   544 
       
   545     RFs& FileSession = iCoeEnv->FsSession();
       
   546     
       
   547     XMLParser->SetDataBasePtr(aDataBase);
       
   548     XMLParser->SetIsTOC2(ETrue);
       
   549     XMLParser->SetHtmlContentParserPtr(this);
       
   550     
       
   551     TBuf<KMaxFileName>* lookup = new(ELeave)TBuf<KMaxFileName>;
       
   552     CleanupStack::PushL(lookup);//3
       
   553     XMLParser->SetTOC1Title(aKywdTOC1Object->GetName());
       
   554     for(int i = 0; i < toc1Count ; ++i )
       
   555         {
       
   556         toc1 = (*TOC1HtmlList)[i];
       
   557         //Get Corresponding toc1 from Main array and set toc1 object
       
   558         XMLParser->SetCurrentHtmlToc1(GetCorrespondingTOC1FromMainArray(toc1->GetName()));
       
   559         //Clear the previous values
       
   560         lookup->Delete(0,lookup->Length());
       
   561         toc1->GetHelpFileL(*lookup);
       
   562         XMLParser->SetPath(*lookup);
       
   563         lookup->Append(KKeywordsFile);
       
   564         TRAP_IGNORE(iXmlReader->ParseL (FileSession,*lookup ));
       
   565         aDataBase->IncrementKeywordSearchCount();
       
   566         }   
       
   567     CleanupStack::PopAndDestroy(lookup);
       
   568     CleanupStack::PopAndDestroy(XMLParser);  
       
   569     ClearReader();
       
   570     }
       
   571     
       
   572 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetContextTopic
       
   573 (const TUid& aUid, const TDesC& contextName)
       
   574     {
       
   575     int toc1Count = iHtmlTOC1List.Count();
       
   576     CCSXHHtmlTOC1* toc1,*temptoc1;
       
   577     
       
   578     for(int i = 0; i < toc1Count; ++i)
       
   579         {
       
   580         toc1 = iHtmlTOC1List[i];
       
   581         if(aUid == toc1->GetAppUid())
       
   582             {
       
   583             return toc1->GetContextTopic(contextName);      
       
   584             }
       
   585         }
       
   586         
       
   587     toc1Count = iDuplicateHelpTopicList.Count();
       
   588 	for(int i = 0; i < toc1Count; ++i)
       
   589 		{
       
   590 		toc1 = iDuplicateHelpTopicList[i];
       
   591         if(aUid == toc1->GetAppUid())
       
   592         	{
       
   593     		temptoc1 = GetCorrespondingTOC1FromMainArray(toc1->GetName());        		
       
   594     		return temptoc1->GetContextTopic(contextName);
       
   595         	}
       
   596 		}    
       
   597     return NULL;
       
   598     }
       
   599     
       
   600 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetHtmlTopicForUrlL(const TDesC& aUrl)
       
   601     {
       
   602     CCSXHHelpContentBase* tocobj = GetObjectBasedonUrlL(iHtmlTOC1List,aUrl,ETrue);
       
   603     
       
   604     if(NULL == tocobj)
       
   605     	tocobj = GetObjectBasedonUrlL(iDuplicateHelpTopicList,aUrl,EFalse);
       
   606     
       
   607 	return tocobj;    	
       
   608     }
       
   609 
       
   610 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetObjectBasedonUrlL(RPointerArray<CCSXHHtmlTOC1>& aTOC1ObjectsArray,
       
   611 		const TDesC& aUrl, TBool aMainArrayList)    
       
   612     {
       
   613         /*For URLs of form 
       
   614         file:://<Drive Name>:/system/xhtml/<Lang ID>/<App UID>/Html name
       
   615       We can have help topics for other cases, help topic objects not possible   
       
   616     */
       
   617     TBuf<KMaxFileName> aFileUrl;
       
   618     
       
   619     int toc1Count = aTOC1ObjectsArray.Count();
       
   620     CCSXHHtmlTOC1* toc1,*temptoc1;
       
   621     for(int j = 0; j < toc1Count; ++j)
       
   622         {
       
   623         toc1 = aTOC1ObjectsArray[j];
       
   624         TBuf<KMaxFileName> htmlFile;
       
   625         toc1->GetHelpFileL(htmlFile);
       
   626         
       
   627         //Convert fwd slashes to back slashes
       
   628         TInt i = htmlFile.Find(KFwdSlash) ;
       
   629         while (KErrNotFound != i)
       
   630             {
       
   631             htmlFile.Replace(i,1,KBackSlash);
       
   632             i = htmlFile.Find(KFwdSlash) ;
       
   633             }
       
   634         
       
   635         i = aUrl.FindC(htmlFile);
       
   636         if(i != KErrNotFound)
       
   637             {
       
   638             TFileName fileName;
       
   639             i = aUrl.LocateReverseF('/');
       
   640             fileName = aUrl.Mid(i + 1);
       
   641             if(aMainArrayList)
       
   642             	temptoc1 = toc1;
       
   643             else
       
   644             	temptoc1 = GetCorrespondingTOC1FromMainArray(toc1->GetName());	
       
   645             
       
   646             return temptoc1->GetHtmlTopicForFile(fileName);
       
   647             }
       
   648         }
       
   649     return NULL;	
       
   650     }
       
   651 
       
   652 void CCSXHHTMLContentParser::GetHtmlFileL(CCoeEnv* coeEnv,const short& aDir,
       
   653                                             const TAppUid& aUid,TBuf<KMaxFileName>& aFileName)
       
   654     {
       
   655     aFileName.Copy(KEmptyString);
       
   656     
       
   657     RFs& FileSession = coeEnv->FsSession();
       
   658     TDriveList DirList; 
       
   659     if( (FileSession.DriveList(DirList)<KErrNone) ||
       
   660         (aDir >= DirList.Length()))
       
   661         return; 
       
   662     
       
   663     TChar driveLetter = '?';
       
   664     TDriveInfo info;
       
   665     TInt error = FileSession.Drive(info, aDir);
       
   666     if  ((error == KErrNone) && 
       
   667         (DirList[aDir] && info.iType != EMediaNotPresent))
       
   668         {
       
   669         RFs::DriveToChar(aDir, driveLetter);
       
   670 
       
   671         aFileName.Append(driveLetter);
       
   672         GetHTMLContentPathForDriveL(&aFileName,coeEnv);
       
   673         aUid.AppendUid(aFileName);
       
   674         aFileName.Append(KFwdSlash);
       
   675         }
       
   676     }
       
   677 
       
   678 void CCSXHHTMLContentParser::InitializeReaderL(CCSXHXMLParseHandler* aXMLParser)
       
   679     {
       
   680     if(iXmlReader == NULL )
       
   681         {       
       
   682         iXmlReader = CSenXmlReader::NewL();
       
   683         iXmlReader->SetContentHandler(*aXMLParser);
       
   684         }
       
   685     }
       
   686 void CCSXHHTMLContentParser::ClearReader()
       
   687     {
       
   688     delete iXmlReader;
       
   689     iXmlReader = NULL;
       
   690     }
       
   691     
       
   692 TBool CCSXHHTMLContentParser::IsUidCategoryPresent(const TUid& aUid)
       
   693     {
       
   694     int toc1Count = iHtmlTOC1List.Count();
       
   695     CCSXHHtmlTOC1* toc1;    
       
   696     for(int i = 0; i < toc1Count; ++i)
       
   697         {
       
   698         toc1 = iHtmlTOC1List[i];
       
   699         if(aUid == toc1->GetAppUid())
       
   700             return ETrue;
       
   701         }
       
   702     
       
   703     toc1Count = iDuplicateHelpTopicList.Count();
       
   704     for(int i = 0; i < toc1Count; ++i)
       
   705         {
       
   706         toc1 = iDuplicateHelpTopicList[i];
       
   707         if(aUid == toc1->GetAppUid())
       
   708             return ETrue;
       
   709         }    
       
   710     return EFalse;  
       
   711     }
       
   712 
       
   713 TBool CCSXHHTMLContentParser::GetHTMLToc1(const TDesC& aUid,CCSXHXMLParseHandler* aParser)
       
   714 	{
       
   715 	TUint AppId;
       
   716 	
       
   717 	if(!aUid.Length())
       
   718 		return EFalse;
       
   719 
       
   720     TLex FolderUid(aUid.Mid(KOffset));
       
   721     FolderUid.Val(AppId,EHex);
       
   722     TUid ApplicationUid = TUid::Uid((TInt)AppId);
       
   723 	
       
   724 	int toc1Count = iHtmlTOC1List.Count();
       
   725 	
       
   726     CCSXHHtmlTOC1* toc1;    
       
   727     for(int i = 0; i < toc1Count; ++i)
       
   728         {
       
   729         toc1 = iHtmlTOC1List[i];
       
   730         if(ApplicationUid == toc1->GetAppUid())
       
   731         	{
       
   732         	STATIC_CAST(CCSXHXMLParseHandler_MasterKywd*,aParser)->SetCurrentHtmlToc1(toc1); 
       
   733         	return ETrue;
       
   734         	}            
       
   735         }
       
   736 	
       
   737 	toc1Count = iDuplicateHelpTopicList.Count();	        
       
   738 	for(int i = 0; i < toc1Count; ++i)
       
   739         {
       
   740         toc1 = iDuplicateHelpTopicList[i];
       
   741         if(ApplicationUid == toc1->GetAppUid())
       
   742         	{
       
   743         	STATIC_CAST(CCSXHXMLParseHandler_MasterKywd*,aParser)->SetCurrentHtmlToc1(toc1); 
       
   744         	return ETrue;
       
   745         	}            
       
   746         }
       
   747                 
       
   748     return EFalse;  
       
   749 	}
       
   750 
       
   751 //To get Corresponding toc1 from main array.
       
   752 CCSXHHtmlTOC1* CCSXHHTMLContentParser::GetCorrespondingTOC1FromMainArray(const TDesC& aApplicationName)
       
   753 	{
       
   754 	TInt toc1Count = iHtmlTOC1List.Count();
       
   755 	CCSXHHtmlTOC1* toc1;
       
   756 	for(int i=0;i<toc1Count;++i)
       
   757 		{
       
   758 		toc1 = iHtmlTOC1List[i];
       
   759 		if(toc1->GetName().CompareF(aApplicationName) == 0)
       
   760 			return toc1;
       
   761 		}
       
   762 	
       
   763     return NULL;
       
   764 	}
       
   765 
       
   766 //Check UId is already present in the list.	
       
   767 TBool CCSXHHTMLContentParser::IsAppUIdPresentAlready(const TDesC& aUid)
       
   768 	{
       
   769 	TBool result = EFalse;
       
   770 	TInt toc1Count = iHtmlTOC1List.Count();
       
   771 	CCSXHHtmlTOC1* toc1;
       
   772 	
       
   773 	TUint AppId;
       
   774     TLex FolderUid(aUid.Mid(KOffset));
       
   775     FolderUid.Val(AppId,EHex);
       
   776     TUid ApplicationUid = TUid::Uid((TInt)AppId);
       
   777 	
       
   778 	for(int i=0;i<toc1Count;++i)
       
   779 		{
       
   780 		toc1 = iHtmlTOC1List[i];
       
   781 		if(ApplicationUid == toc1->GetAppUid())
       
   782 			{
       
   783 			result = ETrue;
       
   784 			break;
       
   785 			}			
       
   786 		}
       
   787 		
       
   788 	toc1Count =    iDuplicateHelpTopicList.Count();	
       
   789 	for(int i=0;i<toc1Count;++i)
       
   790 		{
       
   791 		toc1 = iDuplicateHelpTopicList[i];
       
   792 		if(ApplicationUid == toc1->GetAppUid())
       
   793 			{
       
   794 			result = ETrue;
       
   795 			break;
       
   796 			}
       
   797 		}		
       
   798 		
       
   799 	return result;	
       
   800 
       
   801 	}
       
   802 	
       
   803 void CCSXHHTMLContentParser::ParseKeywdFileAndCreatekywdTOC1ObjectsL(
       
   804 		RPointerArray<CCSXHHtmlTOC1>& aTOC1ObjectsArray,
       
   805 		CCSXHXMLParseHandler_Kywd* XMLParser, TBool bMasterKeywordFilePresent)
       
   806 	{
       
   807 	int toc1Count = aTOC1ObjectsArray.Count();
       
   808     CCSXHHtmlTOC1* toc1;
       
   809      
       
   810     TBuf<KMaxFileName>* lookup = new(ELeave)TBuf<KMaxFileName>;
       
   811     CleanupStack::PushL(lookup);//1
       
   812     
       
   813     RFs& FileSession = iCoeEnv->FsSession();
       
   814 	
       
   815 	    for(int i = 0; i < toc1Count; ++i)
       
   816         {
       
   817         toc1 = aTOC1ObjectsArray[i];
       
   818         
       
   819         if(bMasterKeywordFilePresent && toc1->IsROMDrive())
       
   820         	continue;
       
   821         
       
   822         //Clear the previous values
       
   823         lookup->Delete(0,lookup->Length());
       
   824         
       
   825         toc1->GetHelpFileL(*lookup);
       
   826         lookup->Append(KKeywordsFile);
       
   827         
       
   828           //Check whether a file exists        
       
   829         if(!BaflUtils::FileExists(FileSession,*lookup))
       
   830             continue;
       
   831         
       
   832         XMLParser->SetCurrentHtmlToc1(toc1);
       
   833         TRAP_IGNORE(iXmlReader->ParseL(FileSession,*lookup ));
       
   834         }
       
   835 
       
   836     CleanupStack::PopAndDestroy(lookup);  
       
   837 	}
       
   838 
       
   839 //RUNTIME
       
   840 void CCSXHHTMLContentParser::GetSupportedFeatureListL()
       
   841 	{
       
   842 	RFeatureUidArray SupportedFeatures;	
       
   843 	TInt err = iFeatureControl.Connect();
       
   844 	if ( err == KErrNone )
       
   845 		{
       
   846          // ListSupportedFeatures() returns one of the Symbian error codes.
       
   847          err = iFeatureControl.ListSupportedFeatures( SupportedFeatures );
       
   848 		 	
       
   849          // Remember to call CloseL after using RFeatureControl.
       
   850          // It disconnects the Feature Manager server.
       
   851          iFeatureControl.Close();  
       
   852 		}
       
   853 	//As per new req. add true, flase to id and create an array.
       
   854 	
       
   855 	iFeatureManager_FeatureIds = new (ELeave) CDesCArrayFlat(2); 
       
   856 	
       
   857 	TBuf<25>CurrFId;
       
   858 	
       
   859 	for(TInt i=0;i<SupportedFeatures.Count();i++)
       
   860 		{
       
   861 		CurrFId.Copy(KEmptyString);	
       
   862 		CurrFId.AppendNum(SupportedFeatures[i].iUid);
       
   863 		iFeatureManager_FeatureIds->AppendL(CurrFId);
       
   864 		
       
   865 		CurrFId.Copy(KTrue_StringtoAppend);	
       
   866 		CurrFId.AppendNum(SupportedFeatures[i].iUid);
       
   867 		iFeatureManager_FeatureIds->AppendL(CurrFId);
       
   868 		
       
   869 		CurrFId.Copy(KFalse_StringtoAppend);	
       
   870 		CurrFId.AppendNum(SupportedFeatures[i].iUid);
       
   871 		iFeatureManager_FeatureIds->AppendL(CurrFId);		
       
   872 		}
       
   873 		
       
   874 	//Input Language variation changes
       
   875 	//-----------------------------------------
       
   876 	//Create an array with supported input language		
       
   877 	CPtiEngine* ptiEngine = CPtiEngine::NewL();
       
   878     CleanupStack::PushL( ptiEngine );
       
   879     
       
   880     CArrayFix<TInt>* languageCodeArray = new(ELeave)CArrayFixFlat<TInt>(2);
       
   881     
       
   882     ptiEngine->GetAvailableLanguagesL( languageCodeArray );
       
   883 	
       
   884 	TInt nCount = languageCodeArray->Count();
       
   885 	
       
   886 	iSupportedInputLanguages = new (ELeave) CDesCArrayFlat(2); 
       
   887 	
       
   888 	//Codescanner gives error, if member variables are pushed.
       
   889 	//CleanupStack::PushL( iSupportedInputLanguages );
       
   890     
       
   891     for(TInt i=0; i<nCount;i++)
       
   892     	{
       
   893     	TInt languageCode = languageCodeArray->At(i);
       
   894     	TBuf<25>Currlang(_L("LANGUAGE_"));
       
   895 		if(languageCode < 10)
       
   896 			Currlang.AppendNumFixedWidth(languageCode,EDecimal,2);
       
   897 		else
       
   898 			Currlang.AppendNum(languageCode);
       
   899 		
       
   900 		iSupportedInputLanguages->AppendL(Currlang);
       
   901     	}
       
   902     
       
   903     //CleanupStack::Pop(iSupportedInputLanguages);	
       
   904     CleanupStack::PopAndDestroy( ptiEngine );
       
   905     
       
   906     delete languageCodeArray;	
       
   907     //-----------------------------------------
       
   908     
       
   909     SupportedFeatures.Close();
       
   910 	}
       
   911 	
       
   912 //RUNTIME
       
   913 TBool CCSXHHTMLContentParser::CheckFeatureIDL(const TDesC& aFeatureIds)
       
   914 	{
       
   915 	if(/*KHexPrefixLength == aFeatureIds.Length() &&*/ 
       
   916 		KErrNotFound != aFeatureIds.Find(KDefaultFeatureIdStringTemp))
       
   917 		{
       
   918 		return ETrue;
       
   919 		}
       
   920 			
       
   921 	HBufC* Ids = HBufC::NewLC(aFeatureIds.Length());	
       
   922 	TPtr CurrentFeatureIds = Ids->Des();	
       
   923 	CurrentFeatureIds.Copy(aFeatureIds);
       
   924 	CleanupStack::Pop(Ids);
       
   925 		
       
   926 	CDesCArray* FeatureIdList = new (ELeave) CDesCArrayFlat(2); ;
       
   927 	TInt EndPos = CurrentFeatureIds.Locate(' ');
       
   928 	
       
   929 	CleanupStack::PushL(FeatureIdList);
       
   930 				
       
   931     while (KErrNotFound != EndPos)
       
   932         {
       
   933 				FeatureIdList->AppendL(CurrentFeatureIds.Mid(0,EndPos));// FId_Val);	        
       
   934         CurrentFeatureIds = CurrentFeatureIds.Mid(EndPos+1);
       
   935         EndPos = CurrentFeatureIds.Locate(' ') ;
       
   936         }
       
   937 
       
   938 	if(KErrNotFound == EndPos && 0!= CurrentFeatureIds.Length())
       
   939 		{
       
   940 		FeatureIdList->AppendL(CurrentFeatureIds);
       
   941 		}    
       
   942 	
       
   943 	CleanupStack::Pop(FeatureIdList); 
       
   944 	 
       
   945 	TInt position;		
       
   946 	if(KErrNone == FeatureIdList->Find(KDefaultFeatureIdString,position) || 
       
   947 	   KErrNone == FeatureIdList->Find(KDefaultFeatureIdStringTemp,position) )
       
   948 		{
       
   949 		delete FeatureIdList;
       
   950 		delete Ids;
       
   951 		return ETrue;
       
   952 		}
       
   953 		
       
   954 	TInt nCount = FeatureIdList->MdcaCount();
       
   955 	
       
   956 	
       
   957 	//FeatureManager list contains all enabled featureIds, appended with true, and false.
       
   958 	//New Req. text associated with true_featureId, should be displayed, if Id is enabled.
       
   959 	//else, if featureId is disabled, text associated with false_featureId should be displayed. 
       
   960 	// 1. if featureId string contains "false" and it is not in the list, return ETrue.
       
   961 	// 2. if featureId string does not contain "false" and it is present in the list, return ETrue.
       
   962 	// 3. if featureId is part of input language, return ETrue.
       
   963 	for(TInt j=0;j < nCount;j++)
       
   964 		{
       
   965 		if(
       
   966 			(KErrNotFound != FeatureIdList->MdcaPoint(j).Find(KFalseString) &&
       
   967 			KErrNone != iFeatureManager_FeatureIds->Find(FeatureIdList->MdcaPoint(j),position))||
       
   968 		
       
   969 			(KErrNotFound == FeatureIdList->MdcaPoint(j).Find(KFalseString) &&
       
   970 			KErrNone == iFeatureManager_FeatureIds->Find(FeatureIdList->MdcaPoint(j),position)) ||
       
   971 		
       
   972 			KErrNone == iSupportedInputLanguages->Find(FeatureIdList->MdcaPoint(j),position)
       
   973 		)						
       
   974 			{
       
   975 			delete FeatureIdList;
       
   976 			delete Ids;
       
   977 			return ETrue;
       
   978 			}		
       
   979 		}
       
   980 				
       
   981 	delete Ids;		
       
   982 	delete FeatureIdList;	
       
   983 	return EFalse;		
       
   984 	}	
       
   985 	
       
   986 HBufC8* CCSXHHTMLContentParser::CreateBufferForCSSContentL(RFeatureControl& aFeatureControl)
       
   987 	{	
       
   988 	RFeatureUidArray SupportedFeatures;
       
   989 	TInt err = aFeatureControl.Connect();
       
   990 	if ( err == KErrNone )
       
   991 		{
       
   992          // ListSupportedFeatures() returns one of the Symbian error codes.
       
   993          err = aFeatureControl.ListSupportedFeatures( SupportedFeatures );
       
   994 		 	
       
   995          // Remember to call CloseL after using RFeatureControl.
       
   996          // It disconnects the Feature Manager server.
       
   997          aFeatureControl.Close();                    
       
   998 		}
       
   999 	
       
  1000 		//Input Language variation changes
       
  1001 	//-----------------------------------------
       
  1002 
       
  1003 	CPtiEngine* ptiEngine = CPtiEngine::NewL();
       
  1004     CleanupStack::PushL( ptiEngine );
       
  1005 
       
  1006     CArrayFix<TInt>* languageCodeArray = new(ELeave)CArrayFixFlat<TInt>(2);
       
  1007 
       
  1008     ptiEngine->GetAvailableLanguagesL( languageCodeArray );
       
  1009     
       
  1010 	TInt nInputLangCount = languageCodeArray->Count();
       
  1011 	TInt nCount = SupportedFeatures.Count();	
       
  1012 
       
  1013 	HBufC8* CssContent = HBufC8::NewLC(nCount * KMaxUnits * 6 + nInputLangCount * 3 + 400);
       
  1014 	TPtr8 bufferPtr(CssContent->Des());
       
  1015 	
       
  1016 	AppendStyleSheetContent_listitem(bufferPtr,nCount,SupportedFeatures,*languageCodeArray);
       
  1017 	AppendStyleSheetContent_paragraph(bufferPtr,nCount,SupportedFeatures,*languageCodeArray);
       
  1018 	AppendStyleSheetContent_ahref(bufferPtr,nCount,SupportedFeatures,*languageCodeArray);
       
  1019 	AppendStyleSheetContent_none(bufferPtr,nCount,SupportedFeatures);	
       
  1020 		
       
  1021 	SupportedFeatures.Close();				
       
  1022 	
       
  1023 	CleanupStack::Pop(CssContent);	
       
  1024 	
       
  1025 	//Input Language variation changes
       
  1026 	//-----------------------------------------
       
  1027 	CleanupStack::PopAndDestroy( ptiEngine );	
       
  1028 
       
  1029 	delete languageCodeArray;
       
  1030 	//-----------------------------------------
       
  1031 
       
  1032 	return CssContent;
       
  1033 	}
       
  1034 	
       
  1035 HBufC8* CCSXHHTMLContentParser::GetContentsFromHTMLFileL(const TDesC& htmlFile,CCoeEnv* aCoeEnv)
       
  1036 	{
       
  1037 	RFs& fsSession = aCoeEnv->FsSession();             
       
  1038 	RFile file; 
       
  1039         
       
  1040 	TInt err = file.Open(fsSession,htmlFile,EFileRead|EFileShareReadersOrWriters);
       
  1041     if(KErrNone == err)
       
  1042 	    {
       
  1043 	    TInt FileSize;
       
  1044 	    HBufC8* htmlFileContent = NULL;
       
  1045 	    if(KErrNone == file.Size(FileSize))
       
  1046 		    {
       
  1047 		    htmlFileContent = HBufC8::NewLC(FileSize);
       
  1048 			TPtr8 PtrContent = htmlFileContent->Des();
       
  1049 	        
       
  1050 		    file.Read(PtrContent);	
       
  1051 		    CleanupStack::Pop(htmlFileContent);			    
       
  1052 		    }		
       
  1053 	    file.Close();
       
  1054 		return htmlFileContent;
       
  1055 		}
       
  1056 	else
       
  1057 		{		
       
  1058 		return NULL;
       
  1059 		}
       
  1060 	}
       
  1061 	
       
  1062 HBufC8* CCSXHHTMLContentParser::MergeCssAndHTMLContentL(HBufC8* aHTMLBuffer, HBufC8* aCssContent)
       
  1063 	{
       
  1064     TInt BufferLength=0;
       
  1065     if(aHTMLBuffer)
       
  1066     	BufferLength = aHTMLBuffer->Size();
       
  1067     
       
  1068     if(aCssContent)
       
  1069     	BufferLength += aCssContent->Size();
       
  1070     
       
  1071     HBufC8* Htmlbuffer = HBufC8::NewLC(BufferLength);
       
  1072     
       
  1073     TPtr8 HtmlbufferPtr(Htmlbuffer->Des());
       
  1074     
       
  1075     if(aCssContent)
       
  1076     	{
       
  1077     	HtmlbufferPtr.Copy(aCssContent->Des());
       
  1078     	delete aCssContent;
       
  1079     	}
       
  1080     	
       
  1081     if(aHTMLBuffer)
       
  1082 	    {
       
  1083 	    HtmlbufferPtr.Append(aHTMLBuffer->Des());
       
  1084 	    delete aHTMLBuffer;	
       
  1085 	    }
       
  1086     
       
  1087     if(Htmlbuffer)
       
  1088     	CleanupStack::Pop(Htmlbuffer);
       
  1089     
       
  1090     return Htmlbuffer;	
       
  1091 	}
       
  1092 
       
  1093 void CCSXHHTMLContentParser::AppendStyleSheetContent_listitem(TPtr8& abufferptr,TInt aFeatureIdCount,
       
  1094 													RFeatureUidArray& aSupportedFeatures,
       
  1095 													CArrayFix<TInt>& alanguageCodeArray)
       
  1096 	{
       
  1097 	//List Items
       
  1098 	//---------------------------------------------------------
       
  1099 	abufferptr.Copy(KCsstext_First);
       
  1100 	
       
  1101 	for(TInt i=0;i<aFeatureIdCount;++i)
       
  1102 		{
       
  1103 		TBuf<KMaxFileName> FeatureId;
       
  1104 		FeatureId.Format(KtextFormat_true_l,aSupportedFeatures[i].iUid);
       
  1105 		//FeatureId.Append(KComma);
       
  1106 		abufferptr.Append(FeatureId);		
       
  1107 		}
       
  1108 		
       
  1109 	for(TInt i=0;i<alanguageCodeArray.Count();++i)
       
  1110 		{
       
  1111 		TBuf<KMaxFileName> FeatureId;
       
  1112 		if(alanguageCodeArray[i] < 10)
       
  1113 			FeatureId.Format(KtextFormat_lang_0l,alanguageCodeArray[i]);
       
  1114 		else
       
  1115 			FeatureId.Format(KtextFormat_lang_l,alanguageCodeArray[i]);
       
  1116 		
       
  1117 		abufferptr.Append(FeatureId);		
       
  1118 		}
       
  1119 		
       
  1120 	abufferptr.Append(KDefaultFeatureId);		
       
  1121 	abufferptr.Append(KCsstext_displayp_li);		
       
  1122 	abufferptr.Append(KCsstext_Last);
       
  1123 	//---------------------------------------------------------
       
  1124 	}
       
  1125 
       
  1126 void CCSXHHTMLContentParser::AppendStyleSheetContent_paragraph(TPtr8& abufferptr,TInt aFeatureIdCount,
       
  1127 													RFeatureUidArray& aSupportedFeatures,
       
  1128 													CArrayFix<TInt>& alanguageCodeArray)
       
  1129 	{
       
  1130 	//Paragraph
       
  1131 	//---------------------------------------------------------
       
  1132 	abufferptr.Append(KCsstext_First);
       
  1133 	for(TInt i=0;i<aFeatureIdCount;++i)
       
  1134 		{
       
  1135 		TBuf<KMaxFileName> FeatureId;
       
  1136 		FeatureId.Format(KtextFormat_true_b,aSupportedFeatures[i].iUid);
       
  1137 		//FeatureId.Append(KComma);
       
  1138 		
       
  1139 		abufferptr.Append(FeatureId);		
       
  1140 		}
       
  1141 		
       
  1142 	for(TInt i=0;i<alanguageCodeArray.Count();++i)
       
  1143 		{
       
  1144 		TBuf<KMaxFileName> FeatureId;
       
  1145 		if(alanguageCodeArray[i] < 10)
       
  1146 			FeatureId.Format(KtextFormat_lang_0b,alanguageCodeArray[i]);
       
  1147 		else
       
  1148 			FeatureId.Format(KtextFormat_lang_b,alanguageCodeArray[i]);
       
  1149 		
       
  1150 		abufferptr.Append(FeatureId);		
       
  1151 		}
       
  1152 		
       
  1153 	abufferptr.Append(KDefaultFeatureId);
       
  1154 	abufferptr.Append(KCsstext_displayp_p);		
       
  1155 	abufferptr.Append(KCsstext_Last);
       
  1156 	
       
  1157 	//---------------------------------------------------------
       
  1158 	}
       
  1159 
       
  1160 void CCSXHHTMLContentParser::AppendStyleSheetContent_ahref(TPtr8& abufferptr,TInt aFeatureIdCount,
       
  1161 												RFeatureUidArray& aSupportedFeatures,
       
  1162 												CArrayFix<TInt>& alanguageCodeArray)
       
  1163 	{
       
  1164 	//A href
       
  1165 	//---------------------------------------------------------
       
  1166 	abufferptr.Append(KCsstext_First);
       
  1167 	for(TInt i=0;i<aFeatureIdCount;++i)
       
  1168 		{
       
  1169 		TBuf<KMaxFileName> FeatureId;
       
  1170 		FeatureId.Format(KtextFormat_true_a,aSupportedFeatures[i].iUid);		
       
  1171 		abufferptr.Append(FeatureId);		
       
  1172 		}
       
  1173 	
       
  1174 	for(TInt i=0;i<alanguageCodeArray.Count();++i)
       
  1175 		{
       
  1176 		TBuf<KMaxFileName> FeatureId;
       
  1177 		if(alanguageCodeArray[i] < 10)
       
  1178 			FeatureId.Format(KtextFormat_lang_0a,alanguageCodeArray[i]);
       
  1179 		else
       
  1180 			FeatureId.Format(KtextFormat_lang_a,alanguageCodeArray[i]);
       
  1181 		abufferptr.Append(FeatureId);		
       
  1182 		}
       
  1183 		
       
  1184 	abufferptr.Append(KDefaultFeatureId);
       
  1185 	abufferptr.Append(KCsstext_displayp_a);		
       
  1186 	abufferptr.Append(KCsstext_Last);
       
  1187 	
       
  1188 	//---------------------------------------------------------
       
  1189 	}
       
  1190 
       
  1191 void CCSXHHTMLContentParser::AppendStyleSheetContent_none(TPtr8& abufferptr,TInt aFeatureIdCount,
       
  1192 													RFeatureUidArray& aSupportedFeatures
       
  1193 													)
       
  1194 	{
       
  1195 	//False
       
  1196 	//---------------------------------------------------------
       
  1197 	abufferptr.Append(KCsstext_First);
       
  1198 	for(TInt i=0;i<aFeatureIdCount;++i)
       
  1199 		{
       
  1200 		TBuf<KMaxFileName> FeatureId;
       
  1201 		FeatureId.Format(KtextFormat_false,aSupportedFeatures[i].iUid,aSupportedFeatures[i].iUid,aSupportedFeatures[i].iUid);
       
  1202 		abufferptr.Append(FeatureId);		
       
  1203 		}
       
  1204 		
       
  1205 	abufferptr.Append(KDefaultFeatureId);
       
  1206 	abufferptr.Append(KCsstext_displayp_n);		
       
  1207 	abufferptr.Append(KCsstext_Last);
       
  1208 	
       
  1209 	//---------------------------------------------------------
       
  1210 	}