45
|
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: CCSXHHtmlTOC1 class definition
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "CSXHHtmlTOC1.h"
|
|
19 |
#include "CSXHHtmlTOC2.h"
|
|
20 |
#include "CSXHViewIDs.h"
|
|
21 |
#include "CSXHHTMLContentParser.h"
|
|
22 |
#include "CSXHHelpDataBase.h"
|
|
23 |
#include "csxhconstants.h"
|
|
24 |
|
|
25 |
#include <eikenv.h>
|
|
26 |
#include <utf.h>
|
|
27 |
#include <data_caging_path_literals.hrh>
|
|
28 |
#include <zipfile.h>
|
|
29 |
#include <bautils.h>
|
|
30 |
#include <SenXmlReader.h>
|
|
31 |
#include <f32file.h>
|
|
32 |
#include <pathinfo.h>
|
|
33 |
|
|
34 |
const TInt KBufSize = 35;
|
|
35 |
|
|
36 |
// ---------------------------------------------------------
|
|
37 |
// Items commented in header.
|
|
38 |
// ---------------------------------------------------------
|
|
39 |
CCSXHHtmlTOC1* CCSXHHtmlTOC1::NewL(const TDesC& aName, const TDesC& aFolder,const TInt& aDrive, TUid aViewId, TInt32 aPriority)
|
|
40 |
{
|
|
41 |
CCSXHHtmlTOC1* self = new (ELeave) CCSXHHtmlTOC1(aName, aFolder, aDrive, aViewId, aPriority);
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------
|
|
46 |
// Items commented in header.
|
|
47 |
// ---------------------------------------------------------
|
|
48 |
CCSXHHtmlTOC1::CCSXHHtmlTOC1(const TDesC& aName, const TDesC& aFolder,const TInt& aDrive, TUid aViewId, TInt32 aPriority):
|
|
49 |
CCSXHGenericTOC1(aName, aPriority), iAppUid(aFolder), iDrive(aDrive), iViewId(aViewId)
|
|
50 |
{//No implementation required
|
|
51 |
}
|
|
52 |
|
|
53 |
// ---------------------------------------------------------
|
|
54 |
// Items commented in header.
|
|
55 |
// ---------------------------------------------------------
|
|
56 |
CCSXHHtmlTOC1::~CCSXHHtmlTOC1()
|
|
57 |
{//No implementation required
|
|
58 |
}
|
|
59 |
|
|
60 |
// ---------------------------------------------------------
|
|
61 |
// Items commented in header.
|
|
62 |
// ---------------------------------------------------------
|
|
63 |
TUid CCSXHHtmlTOC1::GetViewID() const
|
|
64 |
{
|
|
65 |
return iViewId;
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------
|
|
69 |
// Items commented in header.
|
|
70 |
// ---------------------------------------------------------
|
|
71 |
void CCSXHHtmlTOC1::GetHelpFileL(TBuf<KMaxFileName>& aFileName ) const
|
|
72 |
{
|
|
73 |
//return iHelpFile;
|
|
74 |
return CCSXHHTMLContentParser::GetHtmlFileL(
|
|
75 |
CCSXHHelpDataBase::GetInstance()->GetCoeEnv(),iDrive,iAppUid,aFileName);
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------
|
|
79 |
// Items commented in header.
|
|
80 |
// ---------------------------------------------------------
|
|
81 |
const TUid& CCSXHHtmlTOC1::GetAppUid() const
|
|
82 |
{
|
|
83 |
return iAppUid.GetUid();
|
|
84 |
}
|
|
85 |
|
|
86 |
// ---------------------------------------------------------
|
|
87 |
// Items commented in header.
|
|
88 |
// ---------------------------------------------------------
|
|
89 |
TBool CCSXHHtmlTOC1::IsROMDrive()
|
|
90 |
{
|
|
91 |
TInt ROMDrive;
|
|
92 |
RFs::CharToDrive( PathInfo::RomRootPath()[0], ROMDrive );
|
|
93 |
if(ROMDrive == iDrive)
|
|
94 |
return ETrue;
|
|
95 |
else
|
|
96 |
return EFalse;
|
|
97 |
}
|
|
98 |
|
|
99 |
// ---------------------------------------------------------
|
|
100 |
// Items commented in header.
|
|
101 |
// ---------------------------------------------------------
|
|
102 |
CCSXHHelpContentBase* CCSXHHtmlTOC1::GetContextTopic(const TDesC& contextName)
|
|
103 |
{
|
|
104 |
TBool resetChildList = EFalse;
|
|
105 |
if(iChildList == NULL)
|
|
106 |
{
|
|
107 |
InitChildList();//Generates child list
|
|
108 |
resetChildList = ETrue;
|
|
109 |
}
|
|
110 |
|
|
111 |
TInt count = iChildList->Count();
|
|
112 |
CCSXHHtmlTOC2* toc2 = NULL;
|
|
113 |
for(TInt i=0;i<count;++i )
|
|
114 |
{
|
|
115 |
toc2 = STATIC_CAST(CCSXHHtmlTOC2*, (*iChildList)[i]);
|
|
116 |
TBuf<KBufSize> contextFile = contextName;
|
|
117 |
contextFile.Append(KHtmlFileExtn);
|
|
118 |
if(contextFile.Compare(toc2->GetFileName()) == 0)
|
|
119 |
return toc2;//Child list should not be reset
|
|
120 |
}
|
|
121 |
if(resetChildList)
|
|
122 |
ResetChildList();
|
|
123 |
return NULL;
|
|
124 |
}
|
|
125 |
|
|
126 |
// ---------------------------------------------------------
|
|
127 |
// Items commented in header.
|
|
128 |
// ---------------------------------------------------------
|
|
129 |
CCSXHHelpContentBase* CCSXHHtmlTOC1::GetHtmlTopicForFile(const TDesC& aFile)
|
|
130 |
{
|
|
131 |
TBool resetChildList = EFalse;
|
|
132 |
if(iChildList ==NULL)
|
|
133 |
{
|
|
134 |
InitChildList();//Generates child list if required.
|
|
135 |
resetChildList = ETrue;
|
|
136 |
}
|
|
137 |
|
|
138 |
TInt count = iChildList->Count();
|
|
139 |
CCSXHHtmlTOC2* toc2 = NULL;
|
|
140 |
for(TInt i=0;i<count;++i )
|
|
141 |
{
|
|
142 |
toc2 = STATIC_CAST(CCSXHHtmlTOC2*, (*iChildList)[i]);
|
|
143 |
if(toc2->GetFileName().Compare(aFile) == 0)
|
|
144 |
return toc2;//Child list should not be reset
|
|
145 |
}
|
|
146 |
if(resetChildList)
|
|
147 |
ResetChildList();
|
|
148 |
return NULL;
|
|
149 |
}
|
|
150 |
|
|
151 |
// ---------------------------------------------------------
|
|
152 |
// Items commented in header.
|
|
153 |
// ---------------------------------------------------------
|
|
154 |
void CCSXHHtmlTOC1::InitChildList()
|
|
155 |
{
|
|
156 |
if(iChildList != NULL)
|
|
157 |
return;
|
|
158 |
ConstructChildList();
|
|
159 |
TRAP_IGNORE(CCSXHHelpDataBase::GetInstance()->GetHtmlParser()->
|
|
160 |
GenerateTOC2ListL(*this,iChildList));
|
|
161 |
}
|
|
162 |
TBool CCSXHHtmlTOC1::IsValid() const
|
|
163 |
{
|
|
164 |
return iAppUid.IsValid();
|
|
165 |
}
|
|
166 |
|
|
167 |
|
|
168 |
TAppUid::TAppUid(const TDesC& aFolder)
|
|
169 |
{
|
|
170 |
TLex lex(aFolder.Mid(KHexPrefixLength));
|
|
171 |
TUint appId = 0;
|
|
172 |
lex.Val(appId,EHex);
|
|
173 |
|
|
174 |
if(appId)
|
|
175 |
{
|
|
176 |
iUid = TUid::Uid((TInt)appId);
|
|
177 |
iLength = aFolder.Length();
|
|
178 |
}
|
|
179 |
else
|
|
180 |
{
|
|
181 |
iLength = 0;
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
const TUid& TAppUid::GetUid() const
|
|
186 |
{
|
|
187 |
return iUid;
|
|
188 |
}
|
|
189 |
|
|
190 |
TBool TAppUid::IsValid() const
|
|
191 |
{
|
|
192 |
return iLength ? ETrue : EFalse;
|
|
193 |
}
|
|
194 |
void TAppUid::AppendUid(TBuf<KMaxFileName>& aStr) const
|
|
195 |
{
|
|
196 |
TInt initialLen = aStr.Length();
|
|
197 |
aStr.Append(KHexPrefix);
|
|
198 |
aStr.AppendNum(iUid.iUid,EHex);
|
|
199 |
TInt finalLen = aStr.Length();
|
|
200 |
|
|
201 |
while(iLength > (finalLen - initialLen))
|
|
202 |
{
|
|
203 |
aStr.Insert(initialLen+KHexPrefixLength,KZero);
|
|
204 |
++finalLen;
|
|
205 |
}
|
|
206 |
|
|
207 |
}
|
|
208 |
|