|
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: DM OMA XDM Settings Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __XDMDMADAPTER_H__ |
|
23 #define __XDMDMADAPTER_H__ |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <smldmadapter.h> |
|
27 #include <XdmSettingsApi.h> |
|
28 |
|
29 |
|
30 // LITERALS |
|
31 _LIT8( KXdmDmNodeName, "OMA_XDM" ); |
|
32 _LIT8( KXdmDmAppId, "APPID" ); |
|
33 _LIT8( KXdmDmName, "NAME" ); |
|
34 _LIT8( KXdmDmProviderId, "PROVIDER-ID" ); |
|
35 _LIT8( KXdmDmToConRef, "ToConRef" ); |
|
36 _LIT8( KXdmDmConRef, "ConRef" ); |
|
37 _LIT8( KXdmDmSip, "SIP" ); |
|
38 _LIT8( KXdmDmToNapId, "TO-NAPID" ); |
|
39 _LIT8( KXdmDmAP, "AP" ); |
|
40 _LIT8( KXdmDmUri, "URI" ); |
|
41 _LIT8( KXdmDmAAuthName, "AAUTHNAME" ); |
|
42 _LIT8( KXdmDmAAuthSecret, "AAUTHSECRET" ); |
|
43 _LIT8( KXdmDmAAuthType, "AAUTHTYPE" ); |
|
44 |
|
45 _LIT8( KXdmDmNodeNameDescription, "The interior object holds all OMA XDM objects" ); |
|
46 _LIT8( KXdmDmAppIdDescription, "The identity of the application service" ); |
|
47 _LIT8( KXdmDmNameDescription, "Application name which is to be displayed in the user's equipment" ); |
|
48 _LIT8( KXdmDmProviderIdDescription, "Provides an identifier for the service provider" ); |
|
49 _LIT8( KXdmDmUriDescription, "Defines the root of all XDM resources" ); |
|
50 _LIT8( KXdmDmAAuthNameDescription, "Defines the user name for XDMC authentication using HTTP digest" ); |
|
51 _LIT8( KXdmDmAAuthSecretDescription, "Defines the password for XDMC authentication using HTTP digest" ); |
|
52 _LIT8( KXdmDmAAuthTypeDescription, "Defines the authentication type for XDMC authentication" ); |
|
53 _LIT8( KXdmDmDynamicDescription, "Placeholder for one or more connectivity parameters" ); |
|
54 _LIT8( KXdmDmToConRefDescription, "Refers to a collection of connectivity definitions" ); |
|
55 _LIT8( KXdmDmConRefDescription, "Indicates the linkage to connectivity parameters" ); |
|
56 _LIT8( KXdmDmSipDescription, "Reference to SIP DM Object" ); |
|
57 _LIT8( KXdmDmToNapIdDescription, "Reference to the connection used for the XCAP traffic" ); |
|
58 |
|
59 _LIT8( KXdmDDFVersion, "1.0" ); |
|
60 _LIT8( KXdmDmTextPlain, "text/plain" ); |
|
61 _LIT8( KXdmDmUriDotSlash, "./" ); |
|
62 _LIT8( KXdmDmSeparator, "/" ); |
|
63 _LIT8( KXdmDmSipLinkPrefix, "./SIP" ); |
|
64 _LIT( KXdmDefaultId, "-1" ); |
|
65 _LIT( KXdmDmStartBracket, "(" ); |
|
66 _LIT( KXdmDmCloseBracket, ")" ); |
|
67 |
|
68 _LIT( KXdmDmLogDir, "Xdm" ); |
|
69 _LIT( KXdmDmLogFile, "XdmDm.txt" ); |
|
70 |
|
71 // CONSTANTS |
|
72 const TInt KXdmDmLogBufferMaxSize = 2000; |
|
73 const TInt KXdmDefaultResultSize = 255; |
|
74 const TInt KXdmDmLevel = 2; |
|
75 const TInt KXdmDmIdTableSize = 16; |
|
76 const TInt KXdmDmHexLength = 8; |
|
77 const TInt KXdmDmMaxIntLength = 10; // max length of 32bit integer |
|
78 const TUint8 KXdmDmObjectSizeWidth = 4; |
|
79 const TUint8 KXdmDmSeparatorDef = 0x2f; // forward slash |
|
80 |
|
81 |
|
82 /** |
|
83 * The main class of the OMA XDM DM adapter. Handles |
|
84 * requests of fetching and updating settings sets and |
|
85 * settings items. |
|
86 */ |
|
87 class CXdmDMAdapter : public CSmlDmAdapter |
|
88 { |
|
89 public: |
|
90 // Adapter interface from CSmlDmAdapter |
|
91 static CXdmDMAdapter* NewL( MSmlDmCallback* aDmCallback ); |
|
92 |
|
93 ~CXdmDMAdapter(); |
|
94 |
|
95 void DDFVersionL( CBufBase& aDDFVersion ); |
|
96 |
|
97 void DDFStructureL( MSmlDmDDFObject& aDDF ); |
|
98 |
|
99 void UpdateLeafObjectL( const TDesC8& aUri, |
|
100 const TDesC8& aLUID, |
|
101 const TDesC8& aObject, |
|
102 const TDesC8& aType, |
|
103 TInt aStatusRef ); |
|
104 |
|
105 void DeleteObjectL( const TDesC8& aUri, |
|
106 const TDesC8& aLUID, |
|
107 const TInt aStatusRef ); |
|
108 |
|
109 void FetchLeafObjectL( const TDesC8& aUri, |
|
110 const TDesC8& aLUID, |
|
111 const TDesC8& aType, |
|
112 const TInt aResultsRef, |
|
113 const TInt aStatusRef ); |
|
114 |
|
115 void ChildURIListL( const TDesC8& aUri, |
|
116 const TDesC8& aLUID, |
|
117 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
118 const TInt aResultsRef, |
|
119 const TInt aStatusRef ); |
|
120 |
|
121 void AddNodeObjectL( const TDesC8& aUri, |
|
122 const TDesC8& aParentLUID, |
|
123 const TInt aStatusRef ); |
|
124 |
|
125 void UpdateLeafObjectL( const TDesC8& aUri, |
|
126 const TDesC8& aLUID, |
|
127 RWriteStream*& aStream, |
|
128 const TDesC8& aType, |
|
129 const TInt aStatusRef ); |
|
130 |
|
131 void FetchLeafObjectSizeL( const TDesC8& aUri, |
|
132 const TDesC8& aLUID, |
|
133 const TDesC8& aType, |
|
134 const TInt aResultsRef, |
|
135 const TInt aStatusRef ); |
|
136 |
|
137 void ExecuteCommandL( const TDesC8& aUri, |
|
138 const TDesC8& aLUID, |
|
139 const TDesC8& aArgument, |
|
140 const TDesC8& aType, |
|
141 const TInt aStatusRef ); |
|
142 |
|
143 void ExecuteCommandL( const TDesC8& aUri, |
|
144 const TDesC8& aLUID, |
|
145 RWriteStream*& aStream, |
|
146 const TDesC8& aType, |
|
147 const TInt aStatusRef ); |
|
148 |
|
149 void CopyCommandL( const TDesC8& aTargetURI, |
|
150 const TDesC8& aTargetLUID, |
|
151 const TDesC8& aSourceURI, |
|
152 const TDesC8& aSourceLUID, |
|
153 const TDesC8& aType, |
|
154 TInt aStatusRef ); |
|
155 |
|
156 void StartAtomicL(); |
|
157 void CommitAtomicL(); |
|
158 void RollbackAtomicL(); |
|
159 TBool StreamingSupport( TInt& aItemSize); |
|
160 void StreamCommittedL(); |
|
161 void CompleteOutstandingCmdsL(); |
|
162 |
|
163 /** |
|
164 * Log writing |
|
165 * DEBUG only |
|
166 */ |
|
167 #ifdef _DEBUG |
|
168 static void WriteToLog( TRefByValue<const TDesC8> aFmt,... ); |
|
169 #endif |
|
170 |
|
171 |
|
172 private: |
|
173 |
|
174 /** |
|
175 * Default constructor |
|
176 * @param aDmCallback Pointer to callback interface |
|
177 */ |
|
178 CXdmDMAdapter( MSmlDmCallback* aDmCallback ); |
|
179 |
|
180 |
|
181 /** |
|
182 * Fetches an object from the given uri |
|
183 * @param aUri Uri to the fetched object |
|
184 * @param aObject The result is inserted to this buffer |
|
185 * @return Error code |
|
186 */ |
|
187 CSmlDmAdapter::TError FetchObjectL( const TDesC8& aUri, |
|
188 CBufBase& aObject, |
|
189 TInt aSettingsId ); |
|
190 |
|
191 /** |
|
192 * Updates the parameters of given DDF node |
|
193 * @param aNode The node to update. |
|
194 * @param aAccTypes Access types of the node. |
|
195 * @param aOccurrence Occurrance of the node. |
|
196 * @param aScope Scope of the node. |
|
197 * @param aFormat Format of the node. |
|
198 * @param aDescription A description of the node. |
|
199 */ |
|
200 void FillNodeInfoL( MSmlDmDDFObject& aNode, |
|
201 TSmlDmAccessTypes aAccTypes, |
|
202 MSmlDmDDFObject::TOccurence aOccurrence, |
|
203 MSmlDmDDFObject::TScope aScope, |
|
204 MSmlDmDDFObject::TDFFormat aFormat, |
|
205 const TDesC8& aDescription); |
|
206 |
|
207 /** |
|
208 * Get property from settings storage |
|
209 * @param aSettingsId unique id of the settings set |
|
210 * @param aProperty type of asked property |
|
211 * @param aObject returns property value |
|
212 * @return CSmlDmAdapter::EOk if successfull |
|
213 */ |
|
214 CSmlDmAdapter::TError GetPropertyL( TInt aSettingsId, |
|
215 TXdmSettingsProperty aProperty, |
|
216 CBufBase& aObject ); |
|
217 |
|
218 /** |
|
219 * Create/update settings property |
|
220 * @param aSettingsId unique id of the settings set |
|
221 * @param aProperty type of property |
|
222 * @param aObject property value |
|
223 * @return CSmlDmAdapter::EOk if successfull |
|
224 */ |
|
225 CSmlDmAdapter::TError UpdatePropertyL( TInt aSettingsId, |
|
226 TXdmSettingsProperty aProperty, |
|
227 const TDesC8& aObject ); |
|
228 /** |
|
229 * Find IAP id based on uri |
|
230 * @param aUri uri of the wanted object |
|
231 * @return id or KErrNotFound |
|
232 */ |
|
233 TInt IapIdFromURIL( const TDesC8& aUri ); |
|
234 |
|
235 /** |
|
236 * Find uri based on IAP id |
|
237 * @param aId value stored to xdm settings |
|
238 * @return uri or NULL |
|
239 */ |
|
240 HBufC8* URIFromIapIdL( TInt aId ); |
|
241 |
|
242 /** |
|
243 * Find SIP id based on uri |
|
244 * @param aUri uri of the wanted object |
|
245 * @return id or KErrNotFound |
|
246 */ |
|
247 TInt GetSipIdL( const TDesC8& aUri ); |
|
248 |
|
249 /** |
|
250 * Finds uri based on SIP id, updates result |
|
251 * @param aSettingsId xdm settings id |
|
252 * @param aObject object to be updated |
|
253 * @return Ok or Error |
|
254 */ |
|
255 CXdmDMAdapter::TError FetchSipConRefL( TInt aSettingsId, |
|
256 CBufBase& aObject ); |
|
257 |
|
258 /** |
|
259 * Find settings id |
|
260 * @param aLUID luid of the wanted object |
|
261 * @param aUri uri of the wanted object |
|
262 * @return id or KErrNotFound |
|
263 */ |
|
264 TInt FindSettingsIdL( const TDesC8& aLUID, const TDesC8& aUri ); |
|
265 |
|
266 /** |
|
267 * Checks if the settings name is already in use, |
|
268 * creates a unique name if needed |
|
269 * @param aName name of the settings |
|
270 * @return unique name |
|
271 */ |
|
272 HBufC* CheckExistingNamesLC( const TDesC8& aName ); |
|
273 |
|
274 |
|
275 /** |
|
276 * Compares strings |
|
277 * @param aLeft first string |
|
278 * @param aRight second string |
|
279 * @return True if the strings are identical |
|
280 */ |
|
281 TBool Match( const TDesC8& aLeft, const TDesC8& aRight ); |
|
282 |
|
283 |
|
284 /** |
|
285 * Converts descriptor to int |
|
286 * @param aSource descriptor to be converted |
|
287 * @return TInt converted value |
|
288 */ |
|
289 TInt DesToInt( const TDesC& aSource ) const; |
|
290 |
|
291 /** |
|
292 * Converts descriptor to int |
|
293 * @param aSource descriptor to be converted |
|
294 * @return TInt converted value |
|
295 */ |
|
296 TInt DesToInt( const TDesC8& aSource ) const; |
|
297 |
|
298 /** |
|
299 * Converts int to descriptor |
|
300 * @param aSource int to be converted |
|
301 * @return HBufC8* converted value |
|
302 */ |
|
303 HBufC8* IntToDes8LC( const TInt aSource ); |
|
304 |
|
305 /** |
|
306 * Converts 16-bit descriptor to 8-bit |
|
307 * @param aSource descriptor to be converted |
|
308 * @return HBufC8* converted value |
|
309 */ |
|
310 HBufC8* ConvertLC( const TDesC& aSource ); |
|
311 |
|
312 /** |
|
313 * Converts 8-bit descriptor to 16-bit |
|
314 * @param aSource descriptor to be converted |
|
315 * @return HBufC* converted value |
|
316 */ |
|
317 HBufC* ConvertLC( const TDesC8& aSource ); |
|
318 |
|
319 |
|
320 |
|
321 private: // Data |
|
322 |
|
323 |
|
324 |
|
325 }; |
|
326 |
|
327 #endif // __XDMDMADAPTER_H__ |
|
328 |
|
329 // End of File |