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"), TUint( 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 if ( !CategoryObj ) |
|
360 { |
|
361 continue; |
|
362 } |
|
363 iIndexing->RuntimeGenerateIndexL( *CategoryObj, XMLParser->GetFeatureIds() ); |
|
364 if(CategoryObj && aDataBase->GetMainTopics()->InsertChild(CategoryObj,EFalse)) |
|
365 iHtmlTOC1List.Append(CategoryObj);//Keep a local copy*/ |
|
366 else |
|
367 { |
|
368 if(CategoryObj) |
|
369 iDuplicateHelpTopicList.Append(CategoryObj); |
|
370 } |
|
371 } |
|
372 } |
|
373 } |
|
374 } |
|
375 |
|
376 CleanupStack::PopAndDestroy(entryList); |
|
377 } |
|
378 |
|
379 void CCSXHHTMLContentParser::InsertHTMLToc1L( |
|
380 const TDesC &appUidName,const TDesC &appName, |
|
381 const TInt& aDrive , CCSXHHelpDataBase* aDataBase, const TDesC &FeatureIds) |
|
382 { |
|
383 if(CheckFeatureIDL(FeatureIds)) |
|
384 { |
|
385 if(!IsAppUIdPresentAlready(appUidName)) |
|
386 { |
|
387 CCSXHHtmlTOC1* CategoryObj = CCSXHHtmlTOC1::NewL(appName,appUidName,aDrive); |
|
388 if(CategoryObj && aDataBase->GetMainTopics()->InsertChild(CategoryObj,EFalse)) |
|
389 iHtmlTOC1List.Append(CategoryObj);//Keep a local copy*/ |
|
390 else |
|
391 { |
|
392 if(CategoryObj) |
|
393 iDuplicateHelpTopicList.Append(CategoryObj); |
|
394 } |
|
395 } |
|
396 } |
|
397 } |
|
398 |
|
399 HBufC8* CCSXHHTMLContentParser::GetContentsFromFileL(const TDesC& htmlFile,CCoeEnv* aCoeEnv, |
|
400 RFeatureControl& aFeatureControl) |
|
401 { |
|
402 RFs& fileSession = aCoeEnv->FsSession(); |
|
403 TInt SlashPosition = htmlFile.LocateReverse('\\'); |
|
404 TBuf<KMaxFileName>* CompressedFile = new (ELeave) TBuf<KMaxFileName>; |
|
405 CleanupStack::PushL(CompressedFile); //1 |
|
406 CompressedFile->Copy(htmlFile.Mid(0,SlashPosition+1)); |
|
407 CompressedFile->Append(KContentZipFile); |
|
408 |
|
409 HBufC8* CssContent = CreateBufferForCSSContentL(aFeatureControl); |
|
410 |
|
411 if(!BaflUtils::FileExists(fileSession,*CompressedFile)) |
|
412 { |
|
413 CleanupStack::PopAndDestroy(CompressedFile); |
|
414 |
|
415 HBufC8* buffer = GetContentsFromHTMLFileL(htmlFile,aCoeEnv); |
|
416 |
|
417 return MergeCssAndHTMLContentL(buffer,CssContent); |
|
418 } |
|
419 |
|
420 // Create an instance of CZipFile. |
|
421 CZipFile* zipFile = CZipFile::NewL(fileSession, *CompressedFile); |
|
422 CleanupStack::PushL(zipFile); //2 |
|
423 |
|
424 // Iterate and get the file name |
|
425 CZipFileMemberIterator* members = zipFile->GetMembersL(); |
|
426 CleanupStack::PushL(members);//3 |
|
427 CZipFileMember* member = members->NextL(); // Get the first file in zip |
|
428 |
|
429 TInt nCount=0; |
|
430 const TBuf<KMaxFileName>*Fname; |
|
431 TBuf<KMaxFileName> *HtmlFileName = new (ELeave) TBuf<KMaxFileName>; |
|
432 CleanupStack::PushL(HtmlFileName); //4 |
|
433 HtmlFileName->Copy(htmlFile.Mid(SlashPosition+1)); |
|
434 for(nCount=0;member!=NULL;nCount++) |
|
435 { |
|
436 Fname = member->Name(); |
|
437 if(Fname->Compare(*HtmlFileName)==0 ) |
|
438 { |
|
439 break; |
|
440 } |
|
441 delete member; |
|
442 member = members->NextL(); |
|
443 } |
|
444 |
|
445 if(NULL == member) |
|
446 { |
|
447 CleanupStack::PopAndDestroy(HtmlFileName); |
|
448 CleanupStack::PopAndDestroy(members); |
|
449 CleanupStack::PopAndDestroy(zipFile); |
|
450 CleanupStack::PopAndDestroy(CompressedFile); |
|
451 |
|
452 HBufC8* buffer = GetContentsFromHTMLFileL(htmlFile,aCoeEnv); |
|
453 return MergeCssAndHTMLContentL(buffer,CssContent); |
|
454 } |
|
455 |
|
456 CleanupStack::PushL(member);//5 |
|
457 RZipFileMemberReaderStream* stream; |
|
458 zipFile->GetInputStreamL(member, stream); |
|
459 CleanupStack::PushL(stream);//6 |
|
460 |
|
461 // Extracts aFileName to a buffer. |
|
462 // If the file is quite huge, then read the file in streaming mode. |
|
463 // For example, use 4KB buffer and read it in an active object. |
|
464 HBufC8* buffer = HBufC8::NewLC(member->UncompressedSize());//5 |
|
465 TPtr8 bufferPtr(buffer->Des()); |
|
466 User::LeaveIfError(stream->Read(bufferPtr, member->UncompressedSize())); |
|
467 |
|
468 // Release all the resources. |
|
469 CleanupStack::Pop(buffer); |
|
470 CleanupStack::PopAndDestroy(stream); |
|
471 CleanupStack::PopAndDestroy(member); |
|
472 CleanupStack::PopAndDestroy(HtmlFileName); |
|
473 CleanupStack::PopAndDestroy(members); |
|
474 CleanupStack::PopAndDestroy(zipFile); |
|
475 CleanupStack::PopAndDestroy(CompressedFile); |
|
476 |
|
477 return MergeCssAndHTMLContentL(buffer,CssContent); |
|
478 } |
|
479 |
|
480 TBool CCSXHHTMLContentParser::HandleMasterKeywordFileL(CCSXHHelpDataBase* aDataBase) |
|
481 { |
|
482 RFs& FileSession = iCoeEnv->FsSession(); |
|
483 CCSXHXMLParseHandler_MasterKywd* XMLParser_MasterKywd = CCSXHXMLParseHandler_MasterKywd::NewL(iCoeEnv); |
|
484 CleanupStack::PushL(XMLParser_MasterKywd); |
|
485 InitializeReaderL(XMLParser_MasterKywd); |
|
486 XMLParser_MasterKywd->SetHtmlContentParserPtr(this); |
|
487 XMLParser_MasterKywd->SetDataBasePtr(aDataBase); |
|
488 TBool bMasterKeywordFilePresent = EFalse; |
|
489 |
|
490 //Check for the availability of Master Keyword file |
|
491 TBuf<KMaxFileName>* Master_kywdPath = new(ELeave) TBuf<KMaxFileName>; |
|
492 CleanupStack::PushL(Master_kywdPath);//5 |
|
493 Master_kywdPath->Append(PathInfo::RomRootPath().Left(1)); |
|
494 GetHTMLContentPathForDriveL(Master_kywdPath,iCoeEnv); |
|
495 Master_kywdPath->Append(KMasterKywdFile); |
|
496 |
|
497 if(BaflUtils::FileExists(FileSession,*Master_kywdPath)) |
|
498 { |
|
499 TRAP_IGNORE(iXmlReader->ParseL(FileSession,*Master_kywdPath )); |
|
500 bMasterKeywordFilePresent = ETrue; |
|
501 } |
|
502 |
|
503 //KMasterKywdFile; |
|
504 CleanupStack::PopAndDestroy(Master_kywdPath); |
|
505 CleanupStack::PopAndDestroy(XMLParser_MasterKywd); |
|
506 ClearReader(); |
|
507 |
|
508 return bMasterKeywordFilePresent; |
|
509 } |
|
510 |
|
511 void CCSXHHTMLContentParser::GenerateKywdTOC1ListL(CCSXHHelpDataBase* aDataBase) |
|
512 { |
|
513 if(!iHtmlTOC1List.Count()) |
|
514 return; |
|
515 TBool bMasterKeywordFilePresent = HandleMasterKeywordFileL(aDataBase); |
|
516 |
|
517 CCSXHXMLParseHandler_Kywd* XMLParser = CCSXHXMLParseHandler_Kywd::NewL(iCoeEnv); |
|
518 CleanupStack::PushL(XMLParser); |
|
519 InitializeReaderL(XMLParser); |
|
520 |
|
521 XMLParser->SetDataBasePtr(aDataBase); |
|
522 XMLParser->SetIsTOC2(EFalse); |
|
523 XMLParser->SetHtmlContentParserPtr(this); |
|
524 |
|
525 //Parse keyword.xml file from Main Array list |
|
526 ParseKeywdFileAndCreatekywdTOC1ObjectsL(iHtmlTOC1List,XMLParser,bMasterKeywordFilePresent); |
|
527 |
|
528 //Parse keyword.xml file from duplicate Array list |
|
529 ParseKeywdFileAndCreatekywdTOC1ObjectsL(iDuplicateHelpTopicList,XMLParser,bMasterKeywordFilePresent); |
|
530 |
|
531 CleanupStack::PopAndDestroy(XMLParser); |
|
532 ClearReader(); |
|
533 } |
|
534 |
|
535 void CCSXHHTMLContentParser::GenerateTOC2ListForKeywordSearchL |
|
536 (CCSXHHelpDataBase* aDataBase,CCSXHKywdTOC1* aKywdTOC1Object) |
|
537 { |
|
538 RPointerArray<CCSXHHtmlTOC1>* TOC1HtmlList = aKywdTOC1Object->GetHtmlTOC1List(); |
|
539 if(!TOC1HtmlList) |
|
540 return; |
|
541 |
|
542 CCSXHXMLParseHandler_Kywd* XMLParser = CCSXHXMLParseHandler_Kywd::NewL(iCoeEnv); |
|
543 CleanupStack::PushL(XMLParser); |
|
544 InitializeReaderL(XMLParser); |
|
545 |
|
546 int toc1Count = TOC1HtmlList->Count(); |
|
547 CCSXHHtmlTOC1* toc1; |
|
548 |
|
549 RFs& FileSession = iCoeEnv->FsSession(); |
|
550 |
|
551 XMLParser->SetDataBasePtr(aDataBase); |
|
552 XMLParser->SetIsTOC2(ETrue); |
|
553 XMLParser->SetHtmlContentParserPtr(this); |
|
554 |
|
555 TBuf<KMaxFileName>* lookup = new(ELeave)TBuf<KMaxFileName>; |
|
556 CleanupStack::PushL(lookup);//3 |
|
557 XMLParser->SetTOC1Title(aKywdTOC1Object->GetName()); |
|
558 for(int i = 0; i < toc1Count ; ++i ) |
|
559 { |
|
560 toc1 = (*TOC1HtmlList)[i]; |
|
561 //Get Corresponding toc1 from Main array and set toc1 object |
|
562 XMLParser->SetCurrentHtmlToc1(GetCorrespondingTOC1FromMainArray(toc1->GetName())); |
|
563 //Clear the previous values |
|
564 lookup->Delete(0,lookup->Length()); |
|
565 toc1->GetHelpFileL(*lookup); |
|
566 XMLParser->SetPath(*lookup); |
|
567 lookup->Append(KKeywordsFile); |
|
568 TRAP_IGNORE(iXmlReader->ParseL (FileSession,*lookup )); |
|
569 aDataBase->IncrementKeywordSearchCount(); |
|
570 } |
|
571 CleanupStack::PopAndDestroy(lookup); |
|
572 CleanupStack::PopAndDestroy(XMLParser); |
|
573 ClearReader(); |
|
574 } |
|
575 |
|
576 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetContextTopic |
|
577 (const TUid& aUid, const TDesC& contextName) |
|
578 { |
|
579 int toc1Count = iHtmlTOC1List.Count(); |
|
580 CCSXHHtmlTOC1* toc1,*temptoc1; |
|
581 |
|
582 for(int i = 0; i < toc1Count; ++i) |
|
583 { |
|
584 toc1 = iHtmlTOC1List[i]; |
|
585 if(aUid == toc1->GetAppUid()) |
|
586 { |
|
587 return toc1->GetContextTopic(contextName); |
|
588 } |
|
589 } |
|
590 |
|
591 toc1Count = iDuplicateHelpTopicList.Count(); |
|
592 for(int i = 0; i < toc1Count; ++i) |
|
593 { |
|
594 toc1 = iDuplicateHelpTopicList[i]; |
|
595 if(aUid == toc1->GetAppUid()) |
|
596 { |
|
597 temptoc1 = GetCorrespondingTOC1FromMainArray(toc1->GetName()); |
|
598 return temptoc1->GetContextTopic(contextName); |
|
599 } |
|
600 } |
|
601 return NULL; |
|
602 } |
|
603 |
|
604 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetHtmlTopicForUrlL(const TDesC& aUrl) |
|
605 { |
|
606 CCSXHHelpContentBase* tocobj = GetObjectBasedonUrlL(iHtmlTOC1List,aUrl,ETrue); |
|
607 |
|
608 if(NULL == tocobj) |
|
609 tocobj = GetObjectBasedonUrlL(iDuplicateHelpTopicList,aUrl,EFalse); |
|
610 |
|
611 return tocobj; |
|
612 } |
|
613 |
|
614 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetObjectBasedonUrlL(RPointerArray<CCSXHHtmlTOC1>& aTOC1ObjectsArray, |
|
615 const TDesC& aUrl, TBool aMainArrayList) |
|
616 { |
|
617 /*For URLs of form |
|
618 file:://<Drive Name>:/system/xhtml/<Lang ID>/<App UID>/Html name |
|
619 We can have help topics for other cases, help topic objects not possible |
|
620 */ |
|
621 TBuf<KMaxFileName> aFileUrl; |
|
622 |
|
623 int toc1Count = aTOC1ObjectsArray.Count(); |
|
624 CCSXHHtmlTOC1* toc1,*temptoc1; |
|
625 for(int j = 0; j < toc1Count; ++j) |
|
626 { |
|
627 toc1 = aTOC1ObjectsArray[j]; |
|
628 TBuf<KMaxFileName> htmlFile; |
|
629 toc1->GetHelpFileL(htmlFile); |
|
630 |
|
631 //Convert fwd slashes to back slashes |
|
632 TInt i = htmlFile.Find(KFwdSlash) ; |
|
633 while (KErrNotFound != i) |
|
634 { |
|
635 htmlFile.Replace(i,1,KBackSlash); |
|
636 i = htmlFile.Find(KFwdSlash) ; |
|
637 } |
|
638 |
|
639 i = aUrl.FindC(htmlFile); |
|
640 if(i != KErrNotFound) |
|
641 { |
|
642 TFileName fileName; |
|
643 i = aUrl.LocateReverseF('/'); |
|
644 fileName = aUrl.Mid(i + 1); |
|
645 if(aMainArrayList) |
|
646 temptoc1 = toc1; |
|
647 else |
|
648 temptoc1 = GetCorrespondingTOC1FromMainArray(toc1->GetName()); |
|
649 |
|
650 return temptoc1->GetHtmlTopicForFile(fileName); |
|
651 } |
|
652 } |
|
653 return NULL; |
|
654 } |
|
655 |
|
656 void CCSXHHTMLContentParser::GetHtmlFileL(CCoeEnv* coeEnv,const short& aDir, |
|
657 const TAppUid& aUid,TBuf<KMaxFileName>& aFileName) |
|
658 { |
|
659 aFileName.Copy(KEmptyString); |
|
660 |
|
661 RFs& FileSession = coeEnv->FsSession(); |
|
662 TDriveList DirList; |
|
663 if( (FileSession.DriveList(DirList)<KErrNone) || |
|
664 (aDir >= DirList.Length())) |
|
665 return; |
|
666 |
|
667 TChar driveLetter = '?'; |
|
668 TDriveInfo info; |
|
669 TInt error = FileSession.Drive(info, aDir); |
|
670 if ((error == KErrNone) && |
|
671 (DirList[aDir] && info.iType != EMediaNotPresent)) |
|
672 { |
|
673 RFs::DriveToChar(aDir, driveLetter); |
|
674 |
|
675 aFileName.Append(driveLetter); |
|
676 GetHTMLContentPathForDriveL(&aFileName,coeEnv); |
|
677 aUid.AppendUid(aFileName); |
|
678 aFileName.Append(KFwdSlash); |
|
679 } |
|
680 } |
|
681 |
|
682 void CCSXHHTMLContentParser::InitializeReaderL(CCSXHXMLParseHandler* aXMLParser) |
|
683 { |
|
684 if(iXmlReader == NULL ) |
|
685 { |
|
686 iXmlReader = CSenXmlReader::NewL(); |
|
687 iXmlReader->SetContentHandler(*aXMLParser); |
|
688 } |
|
689 } |
|
690 void CCSXHHTMLContentParser::ClearReader() |
|
691 { |
|
692 delete iXmlReader; |
|
693 iXmlReader = NULL; |
|
694 } |
|
695 |
|
696 TBool CCSXHHTMLContentParser::IsUidCategoryPresent(const TUid& aUid) |
|
697 { |
|
698 int toc1Count = iHtmlTOC1List.Count(); |
|
699 CCSXHHtmlTOC1* toc1; |
|
700 for(int i = 0; i < toc1Count; ++i) |
|
701 { |
|
702 toc1 = iHtmlTOC1List[i]; |
|
703 if(aUid == toc1->GetAppUid()) |
|
704 return ETrue; |
|
705 } |
|
706 |
|
707 toc1Count = iDuplicateHelpTopicList.Count(); |
|
708 for(int i = 0; i < toc1Count; ++i) |
|
709 { |
|
710 toc1 = iDuplicateHelpTopicList[i]; |
|
711 if(aUid == toc1->GetAppUid()) |
|
712 return ETrue; |
|
713 } |
|
714 return EFalse; |
|
715 } |
|
716 |
|
717 TBool CCSXHHTMLContentParser::GetHTMLToc1(const TDesC& aUid,CCSXHXMLParseHandler* aParser) |
|
718 { |
|
719 TUint AppId; |
|
720 |
|
721 if(!aUid.Length()) |
|
722 return EFalse; |
|
723 |
|
724 TLex FolderUid(aUid.Mid(KOffset)); |
|
725 FolderUid.Val(AppId,EHex); |
|
726 TUid ApplicationUid = TUid::Uid((TInt)AppId); |
|
727 |
|
728 int toc1Count = iHtmlTOC1List.Count(); |
|
729 |
|
730 CCSXHHtmlTOC1* toc1; |
|
731 for(int i = 0; i < toc1Count; ++i) |
|
732 { |
|
733 toc1 = iHtmlTOC1List[i]; |
|
734 if(ApplicationUid == toc1->GetAppUid()) |
|
735 { |
|
736 STATIC_CAST(CCSXHXMLParseHandler_MasterKywd*,aParser)->SetCurrentHtmlToc1(toc1); |
|
737 return ETrue; |
|
738 } |
|
739 } |
|
740 |
|
741 toc1Count = iDuplicateHelpTopicList.Count(); |
|
742 for(int i = 0; i < toc1Count; ++i) |
|
743 { |
|
744 toc1 = iDuplicateHelpTopicList[i]; |
|
745 if(ApplicationUid == toc1->GetAppUid()) |
|
746 { |
|
747 STATIC_CAST(CCSXHXMLParseHandler_MasterKywd*,aParser)->SetCurrentHtmlToc1(toc1); |
|
748 return ETrue; |
|
749 } |
|
750 } |
|
751 |
|
752 return EFalse; |
|
753 } |
|
754 |
|
755 //To get Corresponding toc1 from main array. |
|
756 CCSXHHtmlTOC1* CCSXHHTMLContentParser::GetCorrespondingTOC1FromMainArray(const TDesC& aApplicationName) |
|
757 { |
|
758 TInt toc1Count = iHtmlTOC1List.Count(); |
|
759 CCSXHHtmlTOC1* toc1; |
|
760 for(int i=0;i<toc1Count;++i) |
|
761 { |
|
762 toc1 = iHtmlTOC1List[i]; |
|
763 if(toc1->GetName().CompareF(aApplicationName) == 0) |
|
764 return toc1; |
|
765 } |
|
766 |
|
767 return NULL; |
|
768 } |
|
769 |
|
770 //Check UId is already present in the list. |
|
771 TBool CCSXHHTMLContentParser::IsAppUIdPresentAlready(const TDesC& aUid) |
|
772 { |
|
773 TBool result = EFalse; |
|
774 TInt toc1Count = iHtmlTOC1List.Count(); |
|
775 CCSXHHtmlTOC1* toc1; |
|
776 |
|
777 TUint AppId; |
|
778 TLex FolderUid(aUid.Mid(KOffset)); |
|
779 FolderUid.Val(AppId,EHex); |
|
780 TUid ApplicationUid = TUid::Uid((TInt)AppId); |
|
781 |
|
782 for(int i=0;i<toc1Count;++i) |
|
783 { |
|
784 toc1 = iHtmlTOC1List[i]; |
|
785 if(ApplicationUid == toc1->GetAppUid()) |
|
786 { |
|
787 result = ETrue; |
|
788 break; |
|
789 } |
|
790 } |
|
791 |
|
792 toc1Count = iDuplicateHelpTopicList.Count(); |
|
793 for(int i=0;i<toc1Count;++i) |
|
794 { |
|
795 toc1 = iDuplicateHelpTopicList[i]; |
|
796 if(ApplicationUid == toc1->GetAppUid()) |
|
797 { |
|
798 result = ETrue; |
|
799 break; |
|
800 } |
|
801 } |
|
802 |
|
803 return result; |
|
804 |
|
805 } |
|
806 |
|
807 void CCSXHHTMLContentParser::ParseKeywdFileAndCreatekywdTOC1ObjectsL( |
|
808 RPointerArray<CCSXHHtmlTOC1>& aTOC1ObjectsArray, |
|
809 CCSXHXMLParseHandler_Kywd* XMLParser, TBool bMasterKeywordFilePresent) |
|
810 { |
|
811 int toc1Count = aTOC1ObjectsArray.Count(); |
|
812 CCSXHHtmlTOC1* toc1; |
|
813 |
|
814 TBuf<KMaxFileName>* lookup = new(ELeave)TBuf<KMaxFileName>; |
|
815 CleanupStack::PushL(lookup);//1 |
|
816 |
|
817 RFs& FileSession = iCoeEnv->FsSession(); |
|
818 |
|
819 for(int i = 0; i < toc1Count; ++i) |
|
820 { |
|
821 toc1 = aTOC1ObjectsArray[i]; |
|
822 |
|
823 if(bMasterKeywordFilePresent && toc1->IsROMDrive()) |
|
824 continue; |
|
825 |
|
826 //Clear the previous values |
|
827 lookup->Delete(0,lookup->Length()); |
|
828 |
|
829 toc1->GetHelpFileL(*lookup); |
|
830 lookup->Append(KKeywordsFile); |
|
831 |
|
832 //Check whether a file exists |
|
833 if(!BaflUtils::FileExists(FileSession,*lookup)) |
|
834 continue; |
|
835 |
|
836 XMLParser->SetCurrentHtmlToc1(toc1); |
|
837 TRAP_IGNORE(iXmlReader->ParseL(FileSession,*lookup )); |
|
838 } |
|
839 |
|
840 CleanupStack::PopAndDestroy(lookup); |
|
841 } |
|
842 |
|
843 //RUNTIME |
|
844 void CCSXHHTMLContentParser::GetSupportedFeatureListL() |
|
845 { |
|
846 RFeatureUidArray SupportedFeatures; |
|
847 TInt err = iFeatureControl.Connect(); |
|
848 if ( err == KErrNone ) |
|
849 { |
|
850 // ListSupportedFeatures() returns one of the Symbian error codes. |
|
851 err = iFeatureControl.ListSupportedFeatures( SupportedFeatures ); |
|
852 |
|
853 // Remember to call CloseL after using RFeatureControl. |
|
854 // It disconnects the Feature Manager server. |
|
855 iFeatureControl.Close(); |
|
856 } |
|
857 //As per new req. add true, flase to id and create an array. |
|
858 |
|
859 iFeatureManager_FeatureIds = new (ELeave) CDesCArrayFlat(2); |
|
860 |
|
861 TBuf<25>CurrFId; |
|
862 |
|
863 for(TInt i=0;i<SupportedFeatures.Count();i++) |
|
864 { |
|
865 CurrFId.Copy(KEmptyString); |
|
866 CurrFId.AppendNum(SupportedFeatures[i].iUid); |
|
867 iFeatureManager_FeatureIds->AppendL(CurrFId); |
|
868 |
|
869 CurrFId.Copy(KTrue_StringtoAppend); |
|
870 CurrFId.AppendNum(SupportedFeatures[i].iUid); |
|
871 iFeatureManager_FeatureIds->AppendL(CurrFId); |
|
872 |
|
873 CurrFId.Copy(KFalse_StringtoAppend); |
|
874 CurrFId.AppendNum(SupportedFeatures[i].iUid); |
|
875 iFeatureManager_FeatureIds->AppendL(CurrFId); |
|
876 } |
|
877 |
|
878 //Input Language variation changes |
|
879 //----------------------------------------- |
|
880 //Create an array with supported input language |
|
881 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
882 CleanupStack::PushL( ptiEngine ); |
|
883 |
|
884 CArrayFix<TInt>* languageCodeArray = new(ELeave)CArrayFixFlat<TInt>(2); |
|
885 |
|
886 ptiEngine->GetAvailableLanguagesL( languageCodeArray ); |
|
887 |
|
888 TInt nCount = languageCodeArray->Count(); |
|
889 |
|
890 iSupportedInputLanguages = new (ELeave) CDesCArrayFlat(2); |
|
891 |
|
892 //Codescanner gives error, if member variables are pushed. |
|
893 //CleanupStack::PushL( iSupportedInputLanguages ); |
|
894 |
|
895 for(TInt i=0; i<nCount;i++) |
|
896 { |
|
897 TInt languageCode = languageCodeArray->At(i); |
|
898 TBuf<25>Currlang(_L("LANGUAGE_")); |
|
899 if(languageCode < 10) |
|
900 Currlang.AppendNumFixedWidth(languageCode,EDecimal,2); |
|
901 else |
|
902 Currlang.AppendNum(languageCode); |
|
903 |
|
904 iSupportedInputLanguages->AppendL(Currlang); |
|
905 } |
|
906 |
|
907 //CleanupStack::Pop(iSupportedInputLanguages); |
|
908 CleanupStack::PopAndDestroy( ptiEngine ); |
|
909 |
|
910 delete languageCodeArray; |
|
911 //----------------------------------------- |
|
912 |
|
913 SupportedFeatures.Close(); |
|
914 } |
|
915 |
|
916 //RUNTIME |
|
917 TBool CCSXHHTMLContentParser::CheckFeatureIDL(const TDesC& aFeatureIds) |
|
918 { |
|
919 if(/*KHexPrefixLength == aFeatureIds.Length() &&*/ |
|
920 KErrNotFound != aFeatureIds.Find(KDefaultFeatureIdStringTemp)) |
|
921 { |
|
922 return ETrue; |
|
923 } |
|
924 |
|
925 HBufC* Ids = HBufC::NewLC(aFeatureIds.Length()); |
|
926 TPtr CurrentFeatureIds = Ids->Des(); |
|
927 CurrentFeatureIds.Copy(aFeatureIds); |
|
928 CleanupStack::Pop(Ids); |
|
929 |
|
930 CDesCArray* FeatureIdList = new (ELeave) CDesCArrayFlat(2); ; |
|
931 TInt EndPos = CurrentFeatureIds.Locate(' '); |
|
932 |
|
933 CleanupStack::PushL(FeatureIdList); |
|
934 |
|
935 while (KErrNotFound != EndPos) |
|
936 { |
|
937 FeatureIdList->AppendL(CurrentFeatureIds.Mid(0,EndPos));// FId_Val); |
|
938 CurrentFeatureIds = CurrentFeatureIds.Mid(EndPos+1); |
|
939 EndPos = CurrentFeatureIds.Locate(' ') ; |
|
940 } |
|
941 |
|
942 if(KErrNotFound == EndPos && 0!= CurrentFeatureIds.Length()) |
|
943 { |
|
944 FeatureIdList->AppendL(CurrentFeatureIds); |
|
945 } |
|
946 |
|
947 CleanupStack::Pop(FeatureIdList); |
|
948 |
|
949 TInt position; |
|
950 if(KErrNone == FeatureIdList->Find(KDefaultFeatureIdString,position) || |
|
951 KErrNone == FeatureIdList->Find(KDefaultFeatureIdStringTemp,position) ) |
|
952 { |
|
953 delete FeatureIdList; |
|
954 delete Ids; |
|
955 return ETrue; |
|
956 } |
|
957 |
|
958 TInt nCount = FeatureIdList->MdcaCount(); |
|
959 |
|
960 |
|
961 //FeatureManager list contains all enabled featureIds, appended with true, and false. |
|
962 //New Req. text associated with true_featureId, should be displayed, if Id is enabled. |
|
963 //else, if featureId is disabled, text associated with false_featureId should be displayed. |
|
964 // 1. if featureId string contains "false" and it is not in the list, return ETrue. |
|
965 // 2. if featureId string does not contain "false" and it is present in the list, return ETrue. |
|
966 // 3. if featureId is part of input language, return ETrue. |
|
967 for(TInt j=0;j < nCount;j++) |
|
968 { |
|
969 if( |
|
970 (KErrNotFound != FeatureIdList->MdcaPoint(j).Find(KFalseString) && |
|
971 KErrNone != iFeatureManager_FeatureIds->Find(FeatureIdList->MdcaPoint(j),position))|| |
|
972 |
|
973 (KErrNotFound == FeatureIdList->MdcaPoint(j).Find(KFalseString) && |
|
974 KErrNone == iFeatureManager_FeatureIds->Find(FeatureIdList->MdcaPoint(j),position)) || |
|
975 |
|
976 KErrNone == iSupportedInputLanguages->Find(FeatureIdList->MdcaPoint(j),position) |
|
977 ) |
|
978 { |
|
979 delete FeatureIdList; |
|
980 delete Ids; |
|
981 return ETrue; |
|
982 } |
|
983 } |
|
984 |
|
985 delete Ids; |
|
986 delete FeatureIdList; |
|
987 return EFalse; |
|
988 } |
|
989 |
|
990 HBufC8* CCSXHHTMLContentParser::CreateBufferForCSSContentL(RFeatureControl& aFeatureControl) |
|
991 { |
|
992 RFeatureUidArray SupportedFeatures; |
|
993 TInt err = aFeatureControl.Connect(); |
|
994 if ( err == KErrNone ) |
|
995 { |
|
996 // ListSupportedFeatures() returns one of the Symbian error codes. |
|
997 err = aFeatureControl.ListSupportedFeatures( SupportedFeatures ); |
|
998 |
|
999 // Remember to call CloseL after using RFeatureControl. |
|
1000 // It disconnects the Feature Manager server. |
|
1001 aFeatureControl.Close(); |
|
1002 } |
|
1003 |
|
1004 //Input Language variation changes |
|
1005 //----------------------------------------- |
|
1006 |
|
1007 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
1008 CleanupStack::PushL( ptiEngine ); |
|
1009 |
|
1010 CArrayFix<TInt>* languageCodeArray = new(ELeave)CArrayFixFlat<TInt>(2); |
|
1011 |
|
1012 ptiEngine->GetAvailableLanguagesL( languageCodeArray ); |
|
1013 |
|
1014 TInt nInputLangCount = languageCodeArray->Count(); |
|
1015 TInt nCount = SupportedFeatures.Count(); |
|
1016 |
|
1017 HBufC8* CssContent = HBufC8::NewLC(nCount * KMaxUnits * 6 + nInputLangCount * 3 + 400); |
|
1018 TPtr8 bufferPtr(CssContent->Des()); |
|
1019 |
|
1020 AppendStyleSheetContent_listitem(bufferPtr,nCount,SupportedFeatures,*languageCodeArray); |
|
1021 AppendStyleSheetContent_paragraph(bufferPtr,nCount,SupportedFeatures,*languageCodeArray); |
|
1022 AppendStyleSheetContent_ahref(bufferPtr,nCount,SupportedFeatures,*languageCodeArray); |
|
1023 AppendStyleSheetContent_none(bufferPtr,nCount,SupportedFeatures); |
|
1024 |
|
1025 SupportedFeatures.Close(); |
|
1026 |
|
1027 CleanupStack::Pop(CssContent); |
|
1028 |
|
1029 //Input Language variation changes |
|
1030 //----------------------------------------- |
|
1031 CleanupStack::PopAndDestroy( ptiEngine ); |
|
1032 |
|
1033 delete languageCodeArray; |
|
1034 //----------------------------------------- |
|
1035 |
|
1036 return CssContent; |
|
1037 } |
|
1038 |
|
1039 HBufC8* CCSXHHTMLContentParser::GetContentsFromHTMLFileL(const TDesC& htmlFile,CCoeEnv* aCoeEnv) |
|
1040 { |
|
1041 RFs& fsSession = aCoeEnv->FsSession(); |
|
1042 RFile file; |
|
1043 |
|
1044 TInt err = file.Open(fsSession,htmlFile,EFileRead|EFileShareReadersOrWriters); |
|
1045 if(KErrNone == err) |
|
1046 { |
|
1047 TInt FileSize; |
|
1048 HBufC8* htmlFileContent = NULL; |
|
1049 if(KErrNone == file.Size(FileSize)) |
|
1050 { |
|
1051 htmlFileContent = HBufC8::NewLC(FileSize); |
|
1052 TPtr8 PtrContent = htmlFileContent->Des(); |
|
1053 |
|
1054 file.Read(PtrContent); |
|
1055 CleanupStack::Pop(htmlFileContent); |
|
1056 } |
|
1057 file.Close(); |
|
1058 return htmlFileContent; |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 return NULL; |
|
1063 } |
|
1064 } |
|
1065 |
|
1066 HBufC8* CCSXHHTMLContentParser::MergeCssAndHTMLContentL(HBufC8* aHTMLBuffer, HBufC8* aCssContent) |
|
1067 { |
|
1068 TInt BufferLength=0; |
|
1069 if(aHTMLBuffer) |
|
1070 BufferLength = aHTMLBuffer->Size(); |
|
1071 |
|
1072 if(aCssContent) |
|
1073 BufferLength += aCssContent->Size(); |
|
1074 |
|
1075 HBufC8* Htmlbuffer = HBufC8::NewLC(BufferLength); |
|
1076 |
|
1077 TPtr8 HtmlbufferPtr(Htmlbuffer->Des()); |
|
1078 |
|
1079 if(aCssContent) |
|
1080 { |
|
1081 HtmlbufferPtr.Copy(aCssContent->Des()); |
|
1082 delete aCssContent; |
|
1083 } |
|
1084 |
|
1085 if(aHTMLBuffer) |
|
1086 { |
|
1087 HtmlbufferPtr.Append(aHTMLBuffer->Des()); |
|
1088 delete aHTMLBuffer; |
|
1089 } |
|
1090 |
|
1091 if(Htmlbuffer) |
|
1092 CleanupStack::Pop(Htmlbuffer); |
|
1093 |
|
1094 return Htmlbuffer; |
|
1095 } |
|
1096 |
|
1097 void CCSXHHTMLContentParser::AppendStyleSheetContent_listitem(TPtr8& abufferptr,TInt aFeatureIdCount, |
|
1098 RFeatureUidArray& aSupportedFeatures, |
|
1099 CArrayFix<TInt>& alanguageCodeArray) |
|
1100 { |
|
1101 //List Items |
|
1102 //--------------------------------------------------------- |
|
1103 abufferptr.Copy(KCsstext_First); |
|
1104 |
|
1105 for(TInt i=0;i<aFeatureIdCount;++i) |
|
1106 { |
|
1107 TBuf<KMaxFileName> FeatureId; |
|
1108 FeatureId.Format(KtextFormat_true_l,aSupportedFeatures[i].iUid); |
|
1109 //FeatureId.Append(KComma); |
|
1110 abufferptr.Append(FeatureId); |
|
1111 } |
|
1112 |
|
1113 for(TInt i=0;i<alanguageCodeArray.Count();++i) |
|
1114 { |
|
1115 TBuf<KMaxFileName> FeatureId; |
|
1116 if(alanguageCodeArray[i] < 10) |
|
1117 FeatureId.Format(KtextFormat_lang_0l,alanguageCodeArray[i]); |
|
1118 else |
|
1119 FeatureId.Format(KtextFormat_lang_l,alanguageCodeArray[i]); |
|
1120 |
|
1121 abufferptr.Append(FeatureId); |
|
1122 } |
|
1123 |
|
1124 abufferptr.Append(KDefaultFeatureId); |
|
1125 abufferptr.Append(KCsstext_displayp_li); |
|
1126 abufferptr.Append(KCsstext_Last); |
|
1127 //--------------------------------------------------------- |
|
1128 } |
|
1129 |
|
1130 void CCSXHHTMLContentParser::AppendStyleSheetContent_paragraph(TPtr8& abufferptr,TInt aFeatureIdCount, |
|
1131 RFeatureUidArray& aSupportedFeatures, |
|
1132 CArrayFix<TInt>& alanguageCodeArray) |
|
1133 { |
|
1134 //Paragraph |
|
1135 //--------------------------------------------------------- |
|
1136 abufferptr.Append(KCsstext_First); |
|
1137 for(TInt i=0;i<aFeatureIdCount;++i) |
|
1138 { |
|
1139 TBuf<KMaxFileName> FeatureId; |
|
1140 FeatureId.Format(KtextFormat_true_b,aSupportedFeatures[i].iUid); |
|
1141 //FeatureId.Append(KComma); |
|
1142 |
|
1143 abufferptr.Append(FeatureId); |
|
1144 } |
|
1145 |
|
1146 for(TInt i=0;i<alanguageCodeArray.Count();++i) |
|
1147 { |
|
1148 TBuf<KMaxFileName> FeatureId; |
|
1149 if(alanguageCodeArray[i] < 10) |
|
1150 FeatureId.Format(KtextFormat_lang_0b,alanguageCodeArray[i]); |
|
1151 else |
|
1152 FeatureId.Format(KtextFormat_lang_b,alanguageCodeArray[i]); |
|
1153 |
|
1154 abufferptr.Append(FeatureId); |
|
1155 } |
|
1156 |
|
1157 abufferptr.Append(KDefaultFeatureId); |
|
1158 abufferptr.Append(KCsstext_displayp_p); |
|
1159 abufferptr.Append(KCsstext_Last); |
|
1160 |
|
1161 //--------------------------------------------------------- |
|
1162 } |
|
1163 |
|
1164 void CCSXHHTMLContentParser::AppendStyleSheetContent_ahref(TPtr8& abufferptr,TInt aFeatureIdCount, |
|
1165 RFeatureUidArray& aSupportedFeatures, |
|
1166 CArrayFix<TInt>& alanguageCodeArray) |
|
1167 { |
|
1168 //A href |
|
1169 //--------------------------------------------------------- |
|
1170 abufferptr.Append(KCsstext_First); |
|
1171 for(TInt i=0;i<aFeatureIdCount;++i) |
|
1172 { |
|
1173 TBuf<KMaxFileName> FeatureId; |
|
1174 FeatureId.Format(KtextFormat_true_a,aSupportedFeatures[i].iUid); |
|
1175 abufferptr.Append(FeatureId); |
|
1176 } |
|
1177 |
|
1178 for(TInt i=0;i<alanguageCodeArray.Count();++i) |
|
1179 { |
|
1180 TBuf<KMaxFileName> FeatureId; |
|
1181 if(alanguageCodeArray[i] < 10) |
|
1182 FeatureId.Format(KtextFormat_lang_0a,alanguageCodeArray[i]); |
|
1183 else |
|
1184 FeatureId.Format(KtextFormat_lang_a,alanguageCodeArray[i]); |
|
1185 abufferptr.Append(FeatureId); |
|
1186 } |
|
1187 |
|
1188 abufferptr.Append(KDefaultFeatureId); |
|
1189 abufferptr.Append(KCsstext_displayp_a); |
|
1190 abufferptr.Append(KCsstext_Last); |
|
1191 |
|
1192 //--------------------------------------------------------- |
|
1193 } |
|
1194 |
|
1195 void CCSXHHTMLContentParser::AppendStyleSheetContent_none(TPtr8& abufferptr,TInt aFeatureIdCount, |
|
1196 RFeatureUidArray& aSupportedFeatures |
|
1197 ) |
|
1198 { |
|
1199 //False |
|
1200 //--------------------------------------------------------- |
|
1201 abufferptr.Append(KCsstext_First); |
|
1202 for(TInt i=0;i<aFeatureIdCount;++i) |
|
1203 { |
|
1204 TBuf<KMaxFileName> FeatureId; |
|
1205 FeatureId.Format(KtextFormat_false,aSupportedFeatures[i].iUid,aSupportedFeatures[i].iUid,aSupportedFeatures[i].iUid); |
|
1206 abufferptr.Append(FeatureId); |
|
1207 } |
|
1208 |
|
1209 abufferptr.Append(KDefaultFeatureId); |
|
1210 abufferptr.Append(KCsstext_displayp_n); |
|
1211 abufferptr.Append(KCsstext_Last); |
|
1212 |
|
1213 //--------------------------------------------------------- |
|
1214 } |
|