160 if( GetHTMLContentPathForDriveL( rootDir,iCoeEnv ) ) |
161 if( GetHTMLContentPathForDriveL( rootDir,iCoeEnv ) ) |
161 { |
162 { |
162 #ifdef _DEBUG |
163 #ifdef _DEBUG |
163 RDebug::Print( _L("No index, scan folder for parsing, drive letter: %d"), dir ); |
164 RDebug::Print( _L("No index, scan folder for parsing, drive letter: %d"), dir ); |
164 #endif |
165 #endif |
165 iIndexing->BeginIndexFile( driveLetter ); |
166 iIndexing->BeginIndexFileL( driveLetter ); |
166 scanner->SetScanDataL(*rootDir |
167 scanner->SetScanDataL(*rootDir |
167 ,KEntryAttDir|KEntryAttMatchExclusive, |
168 ,KEntryAttDir|KEntryAttMatchExclusive, |
168 ESortByName|EAscending, CDirScan::EScanDownTree); |
169 ESortByName|EAscending, CDirScan::EScanDownTree); |
169 ScanAndParseXMLfileToCreateTOC1ObjectL(FileSession,scanner,aDataBase, |
170 ScanAndParseXMLfileToCreateTOC1ObjectL(FileSession,scanner,aDataBase, |
170 dir,XMLParser); |
171 dir,XMLParser); |
255 iXmlReader->SetContentHandler(*aPrevHandler); |
256 iXmlReader->SetContentHandler(*aPrevHandler); |
256 CleanupStack::PopAndDestroy(masterMetaHandler); |
257 CleanupStack::PopAndDestroy(masterMetaHandler); |
257 } |
258 } |
258 |
259 |
259 return ETrue; |
260 return ETrue; |
|
261 } |
|
262 |
|
263 TBool CCSXHHTMLContentParser::IsRedirectedL(CCSXHHelpDataBase *aDataBase, |
|
264 const TDesC &aPath, TUid &aUid, TCoeContextName &aContextName) |
|
265 { |
|
266 RFs& FileSession = iCoeEnv->FsSession(); |
|
267 TBuf<KMaxFileName> redirectFile( aPath ); |
|
268 redirectFile.Append( KRedirectFile ); |
|
269 TBool result = EFalse; |
|
270 |
|
271 if ( BaflUtils::FileExists( FileSession, redirectFile ) ) |
|
272 { |
|
273 CCSXHXMLParseHandler_RedirectFile* XMLParser = |
|
274 CCSXHXMLParseHandler_RedirectFile::NewL(iCoeEnv, aUid, aContextName); |
|
275 XMLParser->SetDataBasePtr( aDataBase ); |
|
276 |
|
277 CleanupStack::PushL( XMLParser ); |
|
278 InitializeReaderL( XMLParser ); |
|
279 // ParseL is not in async |
|
280 iXmlReader->ParseL( FileSession, redirectFile ); |
|
281 if ( XMLParser->IsTargetPathFound() ) |
|
282 { |
|
283 TBuf<KMaxFileName>& targetContextName = XMLParser->TargetContextName(); |
|
284 if ( targetContextName.Length() <= aContextName.MaxLength() ) |
|
285 { |
|
286 aUid = XMLParser->TargetUid(); |
|
287 aContextName = targetContextName; |
|
288 result = ETrue; |
|
289 } |
|
290 } |
|
291 CleanupStack::PopAndDestroy( XMLParser ); |
|
292 ClearReader(); |
|
293 } |
|
294 |
|
295 return result; |
260 } |
296 } |
261 |
297 |
262 void CCSXHHTMLContentParser::GenerateTOC2ListL(CCSXHGenericTOC1& |
298 void CCSXHHTMLContentParser::GenerateTOC2ListL(CCSXHGenericTOC1& |
263 aGenericTOC1Object, RPointerArray<CCSXHHelpContentBase>* GenericTOC2List) |
299 aGenericTOC1Object, RPointerArray<CCSXHHelpContentBase>* GenericTOC2List) |
264 { |
300 { |
352 { |
389 { |
353 if(CheckFeatureIDL(XMLParser->GetFeatureIds())) |
390 if(CheckFeatureIDL(XMLParser->GetFeatureIds())) |
354 { |
391 { |
355 if(!IsAppUIdPresentAlready(entry.iName)) |
392 if(!IsAppUIdPresentAlready(entry.iName)) |
356 { |
393 { |
357 CCSXHHtmlTOC1* CategoryObj = CCSXHHtmlTOC1::NewL( |
394 CCSXHHtmlTOC1* CategoryObj = NULL; |
358 XMLParser->GetApplicationName(),entry.iName,aDrive); |
395 TBool duplicateToc = EFalse; |
359 if ( !CategoryObj ) |
396 |
|
397 TInt32 priority = XMLParser->Priority(); |
|
398 // Now we take a walk if it's application helps (priority == 0) |
|
399 |
|
400 if ( (priority != 0) |
|
401 && ( ( aDrive == ROMDrive ) || IsRomBasedContentL( FileSession, entry.iName ) ) ) |
360 { |
402 { |
361 continue; |
403 if ( priority < KHighestPriority ) |
|
404 { |
|
405 priority = KHighestPriority; |
|
406 } |
|
407 else if ( priority > KLowestPriority ) |
|
408 { |
|
409 priority = KLowestPriority; |
|
410 } |
|
411 |
|
412 CategoryObj = CCSXHHtmlTOC1::NewL( |
|
413 XMLParser->GetApplicationName(),entry.iName,aDrive, |
|
414 KCSXHToc2ViewID, priority); |
|
415 if(CategoryObj && aDataBase->GetMainTopics()->InsertChildWithPriority(CategoryObj,EFalse)) |
|
416 iHtmlTOC1List.Append(CategoryObj);//Keep a local copy |
|
417 else |
|
418 duplicateToc = ETrue; |
362 } |
419 } |
363 iIndexing->RuntimeGenerateIndexL( *CategoryObj, XMLParser->GetFeatureIds() ); |
420 else |
364 if(CategoryObj && aDataBase->GetMainTopics()->InsertChild(CategoryObj,EFalse)) |
421 { |
365 iHtmlTOC1List.Append(CategoryObj);//Keep a local copy*/ |
422 CategoryObj = CCSXHHtmlTOC1::NewL( |
366 else |
423 XMLParser->GetApplicationName(),entry.iName, aDrive, |
367 { |
424 KCSXHToc2AppHelpsViewID, 0); |
368 if(CategoryObj) |
425 |
369 iDuplicateHelpTopicList.Append(CategoryObj); |
426 if(CategoryObj && aDataBase->GetAppHelpsTopics()->InsertChild(CategoryObj,EFalse)) |
370 } |
427 iHtmlTOC1List.Append(CategoryObj);//Keep a local copy |
371 } |
428 else |
|
429 duplicateToc = ETrue; |
|
430 } |
|
431 if ( CategoryObj ) |
|
432 { |
|
433 iIndexing->RuntimeGenerateIndexL( *CategoryObj, XMLParser->GetFeatureIds() ); |
|
434 |
|
435 if( duplicateToc ) |
|
436 { |
|
437 iDuplicateHelpTopicList.Append(CategoryObj); |
|
438 } |
|
439 } |
|
440 } |
372 } |
441 } |
373 } |
442 } |
374 } |
443 } |
375 |
444 |
376 CleanupStack::PopAndDestroy(entryList); |
445 CleanupStack::PopAndDestroy(entryList); |
377 } |
446 } |
|
447 TBool CCSXHHTMLContentParser::IsRomBasedContentL( RFs& FileSession, const TDesC &aUid ) |
|
448 { |
|
449 #ifdef __WINSCW__ |
|
450 return ETrue; |
|
451 #endif |
|
452 |
|
453 TBool result = EFalse; |
|
454 CDirScan* scanner=CDirScan::NewLC(FileSession); |
|
455 TBuf<KMaxFileName> rootDir; |
|
456 rootDir.Append( 'z' ); |
|
457 |
|
458 if( GetHTMLContentPathForDriveL( &rootDir,iCoeEnv ) ) |
|
459 { |
|
460 scanner->SetScanDataL(rootDir,KEntryAttDir|KEntryAttMatchExclusive, |
|
461 ESortByName|EAscending, CDirScan::EScanDownTree); |
|
462 CDir* entryList = NULL; |
|
463 scanner->NextL(entryList); |
|
464 |
|
465 if ( !entryList ) |
|
466 { |
|
467 CleanupStack::PopAndDestroy( scanner ); |
|
468 return EFalse; |
|
469 } |
|
470 |
|
471 TInt entryCount = entryList->Count(); |
|
472 |
|
473 while ( entryCount-- ) |
|
474 { |
|
475 TEntry entry=(*entryList)[entryCount]; |
|
476 if ( ( entry.iName ).CompareC(aUid) == 0 ) |
|
477 { |
|
478 result = ETrue; |
|
479 break; |
|
480 } |
|
481 } |
|
482 delete entryList; |
|
483 } |
|
484 |
|
485 CleanupStack::PopAndDestroy( scanner ); |
|
486 |
|
487 return result; |
|
488 } |
378 |
489 |
379 void CCSXHHTMLContentParser::InsertHTMLToc1L( |
490 void CCSXHHTMLContentParser::InsertHTMLToc1L( |
380 const TDesC &appUidName,const TDesC &appName, |
491 const TDesC &appUidName,const TDesC &appName, |
381 const TInt& aDrive , CCSXHHelpDataBase* aDataBase, const TDesC &FeatureIds) |
492 const TInt& aDrive , CCSXHHelpDataBase* aDataBase, |
|
493 const TDesC &FeatureIds, TInt32 aPriority ) |
382 { |
494 { |
383 if(CheckFeatureIDL(FeatureIds)) |
495 if(CheckFeatureIDL(FeatureIds)) |
384 { |
496 { |
385 if(!IsAppUIdPresentAlready(appUidName)) |
497 if(!IsAppUIdPresentAlready(appUidName)) |
386 { |
498 { |
387 CCSXHHtmlTOC1* CategoryObj = CCSXHHtmlTOC1::NewL(appName,appUidName,aDrive); |
499 CCSXHHtmlTOC1* CategoryObj = NULL; |
388 if(CategoryObj && aDataBase->GetMainTopics()->InsertChild(CategoryObj,EFalse)) |
500 TBool duplicateToc = EFalse; |
389 iHtmlTOC1List.Append(CategoryObj);//Keep a local copy*/ |
501 // Now we take a walk if it's application helps (priority == 0) |
390 else |
502 if ( aPriority == 0 ) |
391 { |
503 { |
392 if(CategoryObj) |
504 CategoryObj = CCSXHHtmlTOC1::NewL(appName,appUidName,aDrive, |
393 iDuplicateHelpTopicList.Append(CategoryObj); |
505 KCSXHToc2AppHelpsViewID,aPriority); |
394 } |
506 // Hardcode EDriveZ as ROM drive, need to be runtime check? |
|
507 if(CategoryObj && aDataBase->GetAppHelpsTopics()->InsertChild(CategoryObj,EFalse)) |
|
508 iHtmlTOC1List.Append(CategoryObj);//Keep a local copy |
|
509 else |
|
510 duplicateToc = ETrue; |
|
511 } |
|
512 else |
|
513 { |
|
514 CategoryObj = CCSXHHtmlTOC1::NewL(appName,appUidName,aDrive, |
|
515 KCSXHToc2ViewID,aPriority); |
|
516 if(CategoryObj && aDataBase->GetMainTopics()->InsertChildWithPriority(CategoryObj,EFalse)) |
|
517 iHtmlTOC1List.Append(CategoryObj);//Keep a local copy*/ |
|
518 else |
|
519 duplicateToc = ETrue; |
|
520 } |
|
521 |
|
522 if( CategoryObj && duplicateToc ) |
|
523 iDuplicateHelpTopicList.Append(CategoryObj); |
395 } |
524 } |
396 } |
525 } |
397 } |
526 } |
398 |
527 |
399 HBufC8* CCSXHHTMLContentParser::GetContentsFromFileL(const TDesC& htmlFile,CCoeEnv* aCoeEnv, |
528 HBufC8* CCSXHHTMLContentParser::GetContentsFromFileL(const TDesC& htmlFile,CCoeEnv* aCoeEnv, |
571 CleanupStack::PopAndDestroy(lookup); |
700 CleanupStack::PopAndDestroy(lookup); |
572 CleanupStack::PopAndDestroy(XMLParser); |
701 CleanupStack::PopAndDestroy(XMLParser); |
573 ClearReader(); |
702 ClearReader(); |
574 } |
703 } |
575 |
704 |
576 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetContextTopic |
705 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetContextTopicL( |
577 (const TUid& aUid, const TDesC& contextName) |
706 CCSXHHelpDataBase *aDataBase, |
578 { |
707 TUid &aUid, |
579 int toc1Count = iHtmlTOC1List.Count(); |
708 TCoeContextName &aContextName |
580 CCSXHHtmlTOC1* toc1,*temptoc1; |
709 ) |
581 |
710 { |
582 for(int i = 0; i < toc1Count; ++i) |
711 TBuf<KMaxFileName> path; |
|
712 TInt32 toc1Count = iHtmlTOC1List.Count(); |
|
713 TInt32 dupToc1Count = iDuplicateHelpTopicList.Count(); |
|
714 CCSXHHtmlTOC1 *toc1 = NULL; |
|
715 CCSXHHtmlTOC1 *temptoc1 = NULL; |
|
716 TBool redirected = EFalse; |
|
717 |
|
718 for ( TInt32 i = 0; i < toc1Count; ++i ) |
583 { |
719 { |
584 toc1 = iHtmlTOC1List[i]; |
720 toc1 = iHtmlTOC1List[i]; |
585 if(aUid == toc1->GetAppUid()) |
721 if ( aUid == toc1->GetAppUid() ) |
586 { |
722 { |
587 return toc1->GetContextTopic(contextName); |
723 toc1->GetHelpFileL( path ); |
|
724 if ( IsRedirectedL( aDataBase, path, aUid, aContextName ) ) |
|
725 { |
|
726 redirected = ETrue; |
|
727 } |
|
728 else |
|
729 { |
|
730 return toc1->GetContextTopic( aContextName ); |
|
731 } |
|
732 break; |
588 } |
733 } |
589 } |
734 } |
590 |
735 |
591 toc1Count = iDuplicateHelpTopicList.Count(); |
736 if ( !redirected ) |
592 for(int i = 0; i < toc1Count; ++i) |
737 { |
593 { |
738 for ( TInt32 i = 0; i < dupToc1Count; ++i ) |
594 toc1 = iDuplicateHelpTopicList[i]; |
739 { |
595 if(aUid == toc1->GetAppUid()) |
740 toc1 = iDuplicateHelpTopicList[i]; |
596 { |
741 if ( aUid == toc1->GetAppUid() ) |
597 temptoc1 = GetCorrespondingTOC1FromMainArray(toc1->GetName()); |
742 { |
598 return temptoc1->GetContextTopic(contextName); |
743 toc1->GetHelpFileL( path ); |
599 } |
744 if ( IsRedirectedL( aDataBase, path, aUid, aContextName ) ) |
600 } |
745 { |
|
746 redirected = ETrue; |
|
747 } |
|
748 else |
|
749 { |
|
750 temptoc1 = GetCorrespondingTOC1FromMainArray(toc1->GetName()); |
|
751 return temptoc1->GetContextTopic( aContextName ); |
|
752 } |
|
753 } |
|
754 } |
|
755 } |
|
756 |
|
757 if ( redirected ) |
|
758 { |
|
759 for ( TInt32 i = 0; i < toc1Count; ++i ) |
|
760 { |
|
761 toc1 = iHtmlTOC1List[i]; |
|
762 if ( aUid == toc1->GetAppUid() ) |
|
763 { |
|
764 return toc1->GetContextTopic( aContextName ); |
|
765 } |
|
766 } |
|
767 |
|
768 for ( TInt32 i = 0; i < dupToc1Count; ++i ) |
|
769 { |
|
770 toc1 = iDuplicateHelpTopicList[i]; |
|
771 if ( aUid == toc1->GetAppUid() ) |
|
772 { |
|
773 temptoc1 = GetCorrespondingTOC1FromMainArray( toc1->GetName() ); |
|
774 return temptoc1->GetContextTopic( aContextName ); |
|
775 } |
|
776 } |
|
777 } |
|
778 |
601 return NULL; |
779 return NULL; |
602 } |
780 } |
603 |
781 |
604 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetHtmlTopicForUrlL(const TDesC& aUrl) |
782 CCSXHHelpContentBase* CCSXHHTMLContentParser::GetHtmlTopicForUrlL(const TDesC& aUrl) |
605 { |
783 { |