|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include <e32hashtab.h> |
|
22 #include "CIniFile.h" |
|
23 #include "CXMLFile.h" |
|
24 |
|
25 #ifndef INPUT_H |
|
26 #define INPUT_H |
|
27 |
|
28 class LinkByTagResolver; |
|
29 class CFileDump; |
|
30 |
|
31 class CfgFile : public CBase |
|
32 /** |
|
33 @internalComponent |
|
34 */ |
|
35 { |
|
36 friend class LinkByTagResolver; |
|
37 public: |
|
38 CfgFile():file(NULL){} |
|
39 ~CfgFile() {CloseConfigFile();} |
|
40 |
|
41 TInt OpenConfigFile(TDesC &fIn); |
|
42 void CloseConfigFile(); |
|
43 |
|
44 TInt OpenSetBlock(const TDesC &aSection) |
|
45 { return file->OpenSetBlock(aSection); } |
|
46 TInt OpenTemplateBlock(const TDesC &aSection) |
|
47 { return file->OpenTemplateBlock(aSection); } |
|
48 TInt OpenAddBlock(const TDesC &aSection) |
|
49 { return file->OpenAddBlock(aSection); } |
|
50 TInt GetSetting(const TDesC &aValue, TPtrC &aSetting) |
|
51 { return file->GetSetting(aValue, aSetting); } |
|
52 TInt StepToNextBlock() |
|
53 { return file->StepToNextBlock(); } |
|
54 private: |
|
55 CIniData* file; |
|
56 }; |
|
57 |
|
58 |
|
59 NONSHARABLE_CLASS(LinkByTagResolver) : public CBase |
|
60 { |
|
61 public: |
|
62 static LinkByTagResolver* NewL(CfgFile* aIniData, CFileDump* aLogger); |
|
63 static LinkByTagResolver* NewLC(CfgFile* aIniData, CFileDump* aLogger); |
|
64 virtual ~LinkByTagResolver(); |
|
65 |
|
66 /** |
|
67 returns the recordId for the given Link.Table.Id format. |
|
68 param: aTableName - the given linking by tag |
|
69 return value: -1 if the linking cannot be found |
|
70 ther record number if the linking is found |
|
71 */ |
|
72 const HBufC* ResolvedIdForTagLink(const TPtrC& aLinkingString/*, TDesC& aTheResolvedPair*/); |
|
73 |
|
74 |
|
75 protected: |
|
76 LinkByTagResolver(CfgFile* aIniData, CFileDump* aLogger); |
|
77 void ConstructL(); |
|
78 |
|
79 private: |
|
80 /** |
|
81 Called from ConstructL to fillup the hashmap from the config file |
|
82 */ |
|
83 void FillUpHashMapL(); |
|
84 void ExemineFieldsL(const TInt aTableIndex); |
|
85 TInt SearchForLink(const TPtrC& aSetting); |
|
86 |
|
87 //this function tries to resolve the linking by tag type linking. |
|
88 //If it cannot resolve the link it leaves!!!! |
|
89 void ResolveLinkToRecIdL(const TPtrC& aSetting, TBuf<MAX_BUFFER_LEN>& aResolvedLink); |
|
90 |
|
91 //The class owns this pointer so this has to be deleted!! |
|
92 RPtrHashMap<HBufC, HBufC >* iLinkByTagRecIdPairs; |
|
93 |
|
94 /** |
|
95 This class USES this pointer and doesn't have the right to modify it... |
|
96 As the ownership is not here we don't have to take care about deleting it. |
|
97 |
|
98 Unfortunetaly these cannot be const pointers because the iConfigFile will be changed - |
|
99 the pointers inside the object... |
|
100 And the iLogger doesn't have any const function... |
|
101 */ |
|
102 CfgFile* iConfigFile; |
|
103 CFileDump* iLogger; |
|
104 }; |
|
105 |
|
106 |
|
107 inline TInt CfgFile::OpenConfigFile(TDesC &fIn) |
|
108 { |
|
109 TRAPD(ret, file = CIniData::NewL(fIn)); |
|
110 if (ret == KErrNone) |
|
111 { |
|
112 if (file) |
|
113 { |
|
114 return ETrue; |
|
115 } |
|
116 |
|
117 } |
|
118 return EFalse; |
|
119 } |
|
120 |
|
121 inline void CfgFile::CloseConfigFile() |
|
122 { |
|
123 if (file) |
|
124 { |
|
125 delete file; |
|
126 file = NULL; |
|
127 } |
|
128 } |
|
129 |
|
130 class CXMLDatabase; |
|
131 |
|
132 |
|
133 class XMLFile : public CBase |
|
134 /** |
|
135 @internalComponent |
|
136 */ |
|
137 { |
|
138 public: |
|
139 XMLFile():file(NULL){} |
|
140 ~XMLFile() {CloseConfigFile(); } |
|
141 |
|
142 TInt OpenConfigFile(RFs& aFs, TDesC &fIn, CXMLDatabase* aXmlDb, |
|
143 TBool aForceXMLProcessing, |
|
144 TBool aAppendMode); |
|
145 void CloseConfigFile(); |
|
146 TInt GetSetting(const TInt aEntryIndex, const TDesC& aParamName, TPtrC &aParamValue) |
|
147 { return file->GetSetting(aEntryIndex, aParamName, aParamValue); } |
|
148 TInt GetStartingIndex(const TDesC& aTableName) |
|
149 { return file->GetStartingIndex(aTableName); } |
|
150 TInt GetLastIndex(const TDesC& aTableName) |
|
151 { return file->GetLastIndex(aTableName); } |
|
152 TInt GetEntryNumberParameters(const TInt aEntryIndex) |
|
153 { return file->GetEntryNumberParameters(aEntryIndex); } |
|
154 const TBuf<MAX_BUFFER_LEN>& GetOperation(const TInt aEntryIndex) |
|
155 { return file->GetOperation(aEntryIndex); } |
|
156 TInt GetElementRecordID(const TInt aEntryIndex) const |
|
157 { return file->GetElementRecordID(aEntryIndex); } |
|
158 |
|
159 private: |
|
160 CXMLData* file; |
|
161 }; |
|
162 |
|
163 |
|
164 inline TInt XMLFile::OpenConfigFile(RFs& aFs, TDesC &fIn, CXMLDatabase* aXmlDb, |
|
165 TBool aForceXMLProcessing, |
|
166 TBool aAppendMode) |
|
167 { |
|
168 TRAPD(ret, file = CXMLData::NewL(aFs,fIn,aXmlDb,aForceXMLProcessing, aAppendMode)); |
|
169 if (ret == KErrNone) |
|
170 { |
|
171 if (file) |
|
172 { |
|
173 return ETrue; |
|
174 } |
|
175 } |
|
176 return EFalse; |
|
177 } |
|
178 |
|
179 inline void XMLFile::CloseConfigFile() |
|
180 { |
|
181 if (file) |
|
182 { |
|
183 delete file; |
|
184 file = NULL; |
|
185 } |
|
186 } |
|
187 |
|
188 |
|
189 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
190 |
|
191 class CFileDump; |
|
192 |
|
193 /** |
|
194 @internalComponent |
|
195 */ |
|
196 class CInputFileParser : public CBase |
|
197 { |
|
198 public: |
|
199 virtual ~CInputFileParser() {} |
|
200 |
|
201 static CInputFileParser* FactoryLC(TBool aIsXML, TDesC& aFile, CFileDump* aLog); |
|
202 |
|
203 TBool IsMeshCompatibleL(); |
|
204 |
|
205 virtual void InitialiseL() = 0; |
|
206 virtual TBool CheckMeshTemplateL(TDesC &aTable) = 0; |
|
207 virtual TBool CheckMeshInsertsL(TDesC &aTable) = 0; |
|
208 |
|
209 protected: |
|
210 CInputFileParser(TDesC& aFile, CFileDump* aLog); |
|
211 void Exit(TInt aErr); |
|
212 |
|
213 TDesC& iFile; |
|
214 CFileDump* iLog; |
|
215 const TText** iTable; |
|
216 }; |
|
217 |
|
218 |
|
219 /** |
|
220 @internalComponent |
|
221 */ |
|
222 class CCfgFileParser : public CInputFileParser |
|
223 { |
|
224 friend class CInputFileParser; |
|
225 public: |
|
226 virtual ~CCfgFileParser(); |
|
227 |
|
228 virtual void InitialiseL(); |
|
229 virtual TBool CheckMeshTemplateL(TDesC &aTable); |
|
230 virtual TBool CheckMeshInsertsL(TDesC &aTable); |
|
231 |
|
232 protected: |
|
233 CCfgFileParser(TDesC& aFile, CFileDump* aLog); |
|
234 |
|
235 private: |
|
236 CfgFile iCfg; |
|
237 }; |
|
238 |
|
239 /** |
|
240 Lightweight XML file parser, read a file in, search it as text content... |
|
241 |
|
242 This class shamelessly copies from 'CIniData'. |
|
243 |
|
244 @internalComponent |
|
245 */ |
|
246 class CXMLFileParser : public CInputFileParser |
|
247 { |
|
248 friend class CInputFileParser; |
|
249 public: |
|
250 virtual ~CXMLFileParser(); |
|
251 |
|
252 virtual void InitialiseL(); |
|
253 virtual TBool CheckMeshTemplateL(TDesC &aTable); |
|
254 virtual TBool CheckMeshInsertsL(TDesC &aTable); |
|
255 |
|
256 protected: |
|
257 CXMLFileParser(TDesC& aFile, CFileDump* aLog); |
|
258 |
|
259 private: |
|
260 TBool SearchXMLFile(const TDesC& aOpType, const TDesC& aTable); |
|
261 |
|
262 void OpenXMLFileL(); |
|
263 |
|
264 TPtr iPtr; |
|
265 }; |
|
266 |
|
267 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
268 |
|
269 #endif |