|
1 /* |
|
2 * Copyright (c) 2007 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: XML file handler for DM-settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __DMPROFILECONTENTHANDLER_H |
|
20 #define __DMPROFILECONTENTHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <f32file.h> |
|
25 #include "MXMLAttributes.h" |
|
26 #include "MXMLContentHandler.h" |
|
27 #include "NSmlDMResourceProfile.h" |
|
28 |
|
29 const TInt KNSmlDmFileNameLength=255; |
|
30 const TInt KNSmlDmProfileNameMaxLength = 100; |
|
31 const TInt KNSmlDmSettingsSuccess = 1; |
|
32 const TInt KNSmlDmSettingsFail = 0; |
|
33 const TInt KNSmlDmInternetType = 0x101F99F0; |
|
34 const TInt KNSmlDmBluetoothType = 0x101F99F1; |
|
35 const TInt KNSmlDmMaxPortLength = 5; |
|
36 const TUint8 KNSmlDMColon = ':'; |
|
37 const TUint8 KNSmlDMUriSeparator = '/'; |
|
38 |
|
39 _LIT( KNSmlDMXmlFactorySettings, "DMFactorySettings" ); |
|
40 _LIT( KNSmlDMXmlServerId, "ServerID" ); |
|
41 _LIT( KNSmlDMXmlProfileName, "ProfileName" ); |
|
42 _LIT( KNSmlDMXmlProfileAP, "AccessPoint" ); |
|
43 _LIT( KNSmlDMXmlProfileTransportId, "TransportID" ); |
|
44 _LIT( KNSmlDMXmlProfileUsername, "UserName" ); |
|
45 _LIT( KNSmlDMXmlProfileServerPassword, "ServerPassword" ); |
|
46 _LIT( KNSmlDMXmlProfileClientPassword, "ClientPassword" ); |
|
47 _LIT( KNSmlDMXmlProfileServerUrl, "ServerURL" ); |
|
48 _LIT( KNSmlDMXmlProfileServerAlertedAction, "ServerAlertedAction" ); |
|
49 _LIT( KNSmlDMXmlProfileAuthentication, "Authentication" ); |
|
50 _LIT( KNSmlDMXmlProfileDeleteAllowed, "DeleteAllowed" ); |
|
51 _LIT( KNSmlDMXmlProfileView, "ProfileView" ); |
|
52 _LIT( KNSmlDMXmlProfileNetworkAuthentication, "NetworkAuthentication" ); |
|
53 _LIT( KNSmlDMXmlProfileHttpAuthUsername, "HTTPUserName" ); |
|
54 _LIT( KNSmlDMXmlProfileHttpAuthPassword, "HTTPPassword" ); |
|
55 _LIT( KNSmlDMInternetTypeString, "0x101F99F0" ); |
|
56 _LIT( KNSmlDMBluetoothTypeString, "0x101F99F1" ); |
|
57 _LIT( KNSmlDMDefaultProfile, "Unnamed server" ); |
|
58 _LIT( KNSmlDMXmlProfileLock, "ProfileLock" ); |
|
59 |
|
60 _LIT( KNSmlDMSettingsHTTP, "http://" ); |
|
61 _LIT( KNSmlDMSettingsHTTPS, "https://" ); |
|
62 |
|
63 enum TDMparameterState |
|
64 { |
|
65 //Management operations |
|
66 EStateHandled = 0, |
|
67 EProfileName, |
|
68 EServerID, |
|
69 EServerPassword, |
|
70 EUserName, |
|
71 EUserPwd, |
|
72 EClientPwd, |
|
73 EServerURL, |
|
74 ETransportID, |
|
75 EAccessPoint, |
|
76 EServerAlertedAction, |
|
77 EAuthentication, |
|
78 EDeleteAllowed, |
|
79 EProfileView, |
|
80 ENetworkAuthentication, |
|
81 EHTTPUserName, |
|
82 EHTTPPwd, |
|
83 EProfileLock |
|
84 }; |
|
85 |
|
86 // CLASS DECLARATION |
|
87 |
|
88 // FORWARD DECLARATIONS |
|
89 class CNSmlDMSettings; |
|
90 |
|
91 /** |
|
92 * Interface for SAX Parser Callback events. |
|
93 * If an application (client) needs to be informed of basic parsing events, |
|
94 * it implements this interface and registers an instance with the SAX parser using the SetContentHandler() method. |
|
95 * The parser uses the instance to report basic document-related events like the start and end of elements. |
|
96 * |
|
97 * @lib ?library |
|
98 * @since ?Series60_version |
|
99 */ |
|
100 class CDMProfileContentHandler: public CBase, public MXMLContentHandler |
|
101 { |
|
102 public: |
|
103 |
|
104 |
|
105 /** |
|
106 * Two-phased constructor. |
|
107 */ |
|
108 static CDMProfileContentHandler* NewL(CNSmlDMSettings* aSettings); |
|
109 |
|
110 static CDMProfileContentHandler* NewLC(); |
|
111 |
|
112 /** |
|
113 * Destructor. |
|
114 */ |
|
115 virtual ~CDMProfileContentHandler(); |
|
116 |
|
117 /** |
|
118 * Appends the new profile |
|
119 * @param - |
|
120 * @return - |
|
121 */ |
|
122 void AddProfileL(); |
|
123 |
|
124 /** |
|
125 * Assign the profile element value |
|
126 * @param - |
|
127 * @return - |
|
128 */ |
|
129 void AddProfileElementL(TDesC& aBuf); |
|
130 |
|
131 /** |
|
132 * Removes duplicate profiles from array |
|
133 * @param - |
|
134 * @return - |
|
135 */ |
|
136 void RemoveDuplicateEntry(); |
|
137 |
|
138 /** |
|
139 * Removes RSC duplicate profiles from array |
|
140 * @param - |
|
141 * @return - |
|
142 */ |
|
143 void RemoveRSCEntryL(); |
|
144 |
|
145 /** |
|
146 * Returns true value for other than numerical character. |
|
147 * @param - aChar |
|
148 * @return - true if aChar is other than numerical character. |
|
149 */ |
|
150 TBool IsChar( const TUint8 aChar ); |
|
151 |
|
152 /** |
|
153 * Gets IAP id from the db |
|
154 * @param - TInt count, TInt &iapId |
|
155 * @return - TBool - ETrue if server id was found |
|
156 */ |
|
157 TBool GetAccessPointIdL(TInt count, TInt &iapId); |
|
158 |
|
159 /** |
|
160 * Save profiles to db |
|
161 * @param - |
|
162 * @return - |
|
163 */ |
|
164 void SaveProfilesL(); |
|
165 |
|
166 /** |
|
167 * Receive notification of the beginning of a document. |
|
168 * @param none |
|
169 * @return none |
|
170 */ |
|
171 TInt StartDocument(); |
|
172 |
|
173 /** |
|
174 * Receive notification of the end of a document. |
|
175 * @param none |
|
176 * @return none |
|
177 */ |
|
178 TInt EndDocument(); |
|
179 |
|
180 /** |
|
181 * Receive notification of the beginning of an element. |
|
182 * @param aURI: The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace |
|
183 * processing is not being performed. |
|
184 * @param aLocalName: The local name (without prefix), or the empty string if Namespace processing is not being |
|
185 * performed. |
|
186 * @param aName: The qualified name, or the empty string if qualified names are not available. |
|
187 * @param aAttributeList: The attributes attached to the element. If there are no attributes, it shall be an |
|
188 * empty Attributes object. |
|
189 * |
|
190 * @return none |
|
191 */ |
|
192 TInt StartElement(TDesC& aURI, TDesC& aLocalName, TDesC& aName, MXMLAttributes *aAttributeList); |
|
193 |
|
194 /** |
|
195 * Receive notification of the end of an element. |
|
196 * @param aURI: The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace |
|
197 * processing is not being performed. |
|
198 * @param aLocalName: The local name (without prefix), or the empty string if Namespace processing is not being |
|
199 * performed. |
|
200 * @param aName: The qualified name, or the empty string if qualified names are not available. |
|
201 * @return none |
|
202 */ |
|
203 TInt EndElement(TDesC& aURI, TDesC& aLocalName, TDesC& aName); |
|
204 |
|
205 /** |
|
206 * Receive notification of the start of a CDATA section. |
|
207 * The contents of the CDATA section will be reported through the Characters() event. |
|
208 * @param none. |
|
209 * @return none. |
|
210 */ |
|
211 TInt StartCDATA(); |
|
212 |
|
213 /** |
|
214 * Receive notification of the end of a CDATA section. |
|
215 * @param none. |
|
216 * @return none. |
|
217 */ |
|
218 TInt EndCDATA(); |
|
219 |
|
220 /** |
|
221 * Receive notification of character data inside an element. |
|
222 * @param aBuff: The characters. |
|
223 * @param aStart: The start position in the character buffer. |
|
224 * @param aLength: The number of characters to use from the character buffer. |
|
225 * @return none |
|
226 */ |
|
227 TInt Charecters(TDesC& aBuf, TInt aStart, TInt aLength); |
|
228 |
|
229 /** |
|
230 * Receive notification of XML comment. |
|
231 * @param aComment: Buffer containing the comment. |
|
232 * @return none |
|
233 */ |
|
234 TInt Comment(TDesC& aComment); // JIM might need start and end index as params. |
|
235 |
|
236 /** |
|
237 * Receive notification of a processing instruction |
|
238 * @param aTarget: The processing instruction target. |
|
239 * @param aData: The processing instruction data, or null if none is supplied. |
|
240 * @return none |
|
241 */ |
|
242 TInt ProcessingInstructions(TDesC& aTarget, TDesC& aData); |
|
243 |
|
244 /** |
|
245 * Receive notification of ignorable whitespace in element content. |
|
246 * @param aString: The whitespace characters. |
|
247 * @return none |
|
248 */ |
|
249 TInt IgnoreWhiteSpace(TDesC& aString); // JIM might need start and end index as params. |
|
250 |
|
251 /** |
|
252 * Receive notification of beginning of some internal and external XML entities. |
|
253 * @param aName: The name of the entity. |
|
254 * @return none |
|
255 */ |
|
256 TInt StartEntity(TDesC& aName); |
|
257 |
|
258 /** |
|
259 * Receive notification of end of XML entities. |
|
260 * @param aName: The name of the entity. |
|
261 * @return none |
|
262 */ |
|
263 TInt EndEntity(TDesC& aName); |
|
264 |
|
265 /** |
|
266 * Receive notification of a skipped entity. |
|
267 * @param aName: The name of the skipped entity. |
|
268 * @return none |
|
269 */ |
|
270 TInt SkippedEntity(TDesC& aName); |
|
271 |
|
272 /** |
|
273 * Receive notification of error situation during parsing. |
|
274 * @param aErrorCode: Error status code. |
|
275 * @param aSeverity: Error Severity. |
|
276 * @return none. |
|
277 */ |
|
278 TInt Error(TInt aErrorCode, TInt aSeverity); |
|
279 |
|
280 protected: |
|
281 CDMProfileContentHandler(); |
|
282 |
|
283 |
|
284 private: |
|
285 void ConstructL(CNSmlDMSettings* aSettings); |
|
286 |
|
287 /** |
|
288 * Assign the profile element value |
|
289 * @param aBuf : element value |
|
290 * @return - |
|
291 */ |
|
292 void AddRemainingElementsL(TDesC& aBuf); |
|
293 |
|
294 private: |
|
295 |
|
296 // List of attributes |
|
297 RFile iFile; |
|
298 RFs iSession; |
|
299 TBuf<KNSmlDmFileNameLength> iFilename; |
|
300 |
|
301 TDMparameterState iState; |
|
302 TInt iCounter; |
|
303 TBool iDMAccountInProgress; |
|
304 CArrayPtrFlat<CNSmlDMResourceProfile>* iProfileArray; |
|
305 CNSmlDMSettings* iSettings; |
|
306 }; |
|
307 |
|
308 #endif // End of File |