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