csxhelp/HelpEngine/src/CSXHHelpDataBase.cpp
branchRCL_3
changeset 5 d06b1526f62c
parent 0 1f04cf54edd8
equal deleted inserted replaced
1:27f5851bd5a5 5:d06b1526f62c
    36 
    36 
    37 
    37 
    38 #include <AknProgressDialog.h>
    38 #include <AknProgressDialog.h>
    39 
    39 
    40 EXPORT_C CCSXHHelpDataBase* CCSXHHelpDataBase::NewL(CCoeEnv* aCoeEnv,
    40 EXPORT_C CCSXHHelpDataBase* CCSXHHelpDataBase::NewL(CCoeEnv* aCoeEnv,
    41 	const TApaAppCaption& aAppCaption)
    41 	const TApaAppCaption& aAppCaption, const TApaAppCaption& aAppHelpTopic)
    42     {
    42     {
    43     CCSXHHelpDataBase* self = CCSXHHelpDataBase::NewLC(aCoeEnv,aAppCaption);
    43     CCSXHHelpDataBase* self = CCSXHHelpDataBase::NewLC(aCoeEnv,aAppCaption, aAppHelpTopic);
    44     CleanupStack::Pop(self);
    44     CleanupStack::Pop(self);
    45     return self;    
    45     return self;    
    46     }
    46     }
    47 
    47 
    48 CCSXHHelpDataBase* CCSXHHelpDataBase::NewLC(CCoeEnv* aCoeEnv,const TApaAppCaption& aAppCaption)
    48 CCSXHHelpDataBase* CCSXHHelpDataBase::NewLC(CCoeEnv* aCoeEnv, const TApaAppCaption& aAppCaption, const TApaAppCaption& aAppHelpTopic)
    49     {
    49     {
       
    50     CCSXHHelpDataBase *self = NULL;
    50     //Add stuff into TLS
    51     //Add stuff into TLS
    51     if(Dll::Tls() == NULL )
    52     if(Dll::Tls() == NULL )
    52         {
    53         {
    53         // TLS is still null, which means that no Singleton has
    54         // TLS is still null, which means that no Singleton has
    54         // been instantiated yet. Do so now, and return that
    55         // been instantiated yet. Do so now, and return that
    55         // instance:
    56         // instance:
    56         // Store a pointer to the new instance in thread local storage:
    57         // Store a pointer to the new instance in thread local storage:
    57         CCSXHHelpDataBase* self = new(ELeave) CCSXHHelpDataBase(aCoeEnv,aAppCaption);
    58         self = new(ELeave) CCSXHHelpDataBase(aCoeEnv,aAppCaption, aAppHelpTopic);
    58         CleanupStack::PushL(self);
    59         CleanupStack::PushL(self);
    59         self->ConstructL();
    60         self->ConstructL();
    60      
    61      
    61         TInt err = Dll::SetTls(self);
    62         TInt err = Dll::SetTls(self);
    62         if(err == KErrNone )
    63         if (err != KErrNone)
    63             {
    64             {
    64             return self;
    65             CleanupStack::Pop(self);            
       
    66             delete self;
       
    67             self = NULL;
       
    68             User::Leave(err);
    65             }
    69             }
    66         else
       
    67             {
       
    68             delete self;
       
    69             User::Leave( err );
       
    70             return NULL;
       
    71             }
       
    72         }
    70         }
    73      else
    71      else
    74         {
    72         {
    75             return GetInstance();
    73         self = GetInstance();
    76         }   
    74         }
       
    75 
       
    76     return self;
    77     }
    77     }
    78     
    78     
    79 CCSXHHelpDataBase* CCSXHHelpDataBase::GetInstance()
    79 CCSXHHelpDataBase* CCSXHHelpDataBase::GetInstance()
    80     {
    80     {
    81     // Singleton has been instantiated once already, so return
    81     // Singleton has been instantiated once already, so return
    82     // that instance:
    82     // that instance:
    83     return static_cast<CCSXHHelpDataBase*>(Dll::Tls());
    83     return static_cast<CCSXHHelpDataBase*>(Dll::Tls());
    84     }
    84     }
    85 
    85 
    86 CCSXHHelpDataBase::CCSXHHelpDataBase(CCoeEnv* aCoeEnv,const TApaAppCaption& aAppCaption)
    86 CCSXHHelpDataBase::CCSXHHelpDataBase(CCoeEnv* aCoeEnv, const TApaAppCaption& aAppCaption, const TApaAppCaption& aAppHelpTopic)
    87              : iCoeEnv(aCoeEnv),iAppCaption(aAppCaption),iKeywordSearchCount(0)
    87              : iCoeEnv(aCoeEnv), iAppCaption(aAppCaption), iAppHelpTopic(aAppHelpTopic), iKeywordSearchCount(0)
    88              
    88              
    89     {
    89     {
    90     }
    90     }
    91 
    91 
    92 CCSXHHelpDataBase::~CCSXHHelpDataBase()
    92 CCSXHHelpDataBase::~CCSXHHelpDataBase()
   104     iHTMLContentParser = CCSXHHTMLContentParser::NewL(iCoeEnv);
   104     iHTMLContentParser = CCSXHHTMLContentParser::NewL(iCoeEnv);
   105     iLegacyContentParser = CCSXHLegacyContentParser::NewL(this);
   105     iLegacyContentParser = CCSXHLegacyContentParser::NewL(this);
   106     
   106     
   107     iMainTOC1 = CCSXHMainTopics::NewL(KCSXHToc1ViewID,iAppCaption);
   107     iMainTOC1 = CCSXHMainTopics::NewL(KCSXHToc1ViewID,iAppCaption);
   108     iKywdTOC1 = CCSXHKywdTopics::NewL(iAppCaption);
   108     iKywdTOC1 = CCSXHKywdTopics::NewL(iAppCaption);
       
   109     
       
   110     //No need to delete iAppHelpsToc in destruct,
       
   111     //because it will be deleted when deleting iMainTOC1.
       
   112     //All third-party helps will be put to this topic
       
   113     TInt appHelpPriority = 20001;
       
   114     iAppHelpsToc = CCSXHMainTopics::NewL( KCSXHToc1AppHelpsViewID, iAppHelpTopic, appHelpPriority );
   109         
   115         
   110     //Build the TOC1 list here
   116     //Build the TOC1 list here
       
   117     iMainTOC1->InsertChildWithPriority(iAppHelpsToc, EFalse);
   111     iHTMLContentParser->GenerateTOC1ListL(this);
   118     iHTMLContentParser->GenerateTOC1ListL(this);
   112     iLegacyContentParser->GenerateTOC1ListL(this);
   119     iLegacyContentParser->GenerateTOC1ListL(this);
   113     }
   120     }
   114     
   121     
   115 CCoeEnv* CCSXHHelpDataBase::GetCoeEnv()
   122 CCoeEnv* CCSXHHelpDataBase::GetCoeEnv()
   122     return iMainTOC1;   
   129     return iMainTOC1;   
   123     }
   130     }
   124 EXPORT_C CCSXHGenericTOC1* CCSXHHelpDataBase::GetKywdTopics()
   131 EXPORT_C CCSXHGenericTOC1* CCSXHHelpDataBase::GetKywdTopics()
   125     {
   132     {
   126     return iKywdTOC1;
   133     return iKywdTOC1;
       
   134     }
       
   135 
       
   136 EXPORT_C CCSXHGenericTOC1* CCSXHHelpDataBase::GetAppHelpsTopics()
       
   137     {
       
   138     return iAppHelpsToc;   
   127     }
   139     }
   128 
   140 
   129 EXPORT_C CCSXHHelpContentBase* CCSXHHelpDataBase::GetContextTopic(const TDesC8& aContextMessage)
   141 EXPORT_C CCSXHHelpContentBase* CCSXHHelpDataBase::GetContextTopic(const TDesC8& aContextMessage)
   130     {
   142     {
   131     TRAP_IGNORE(GetContextTopicL(aContextMessage));
   143     TRAP_IGNORE(GetContextTopicL(aContextMessage));
   156     TCoeHelpContext* context;
   168     TCoeHelpContext* context;
   157     for (TInt i(0); i < numberOfContextList; i++)
   169     for (TInt i(0); i < numberOfContextList; i++)
   158         {
   170         {
   159         context = &(contextList->At(i));
   171         context = &(contextList->At(i));
   160         
   172         
   161         contextTopic = iHTMLContentParser->GetContextTopic(context->iMajor,context->iContext);
   173         contextTopic = iHTMLContentParser->GetContextTopicL(this, context->iMajor,context->iContext);
   162         if(contextTopic)
   174         if(contextTopic)
   163             {
   175             {
   164             CleanupStack::PopAndDestroy(contextList);
   176             CleanupStack::PopAndDestroy(contextList);
   165             iLastContextTopic = CCSXHContextTopic::NewL(contextTopic);
   177             iLastContextTopic = CCSXHContextTopic::NewL(contextTopic);
   166             return iLastContextTopic;
   178             return iLastContextTopic;