|
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: DM adapter for handling always-on settings. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NSMLDMALWAYSONADAPTER_H |
|
20 #define NSMLDMALWAYSONADAPTER_H |
|
21 |
|
22 #include <smldmadapter.h> |
|
23 |
|
24 #include "nsmldmalwaysonsettingstore.h" |
|
25 |
|
26 class CSmlDmAOCommandElement; |
|
27 class CNSmlDmAOSettingStore; |
|
28 |
|
29 // The DDF version must be changed if any changes in DDF structure |
|
30 // ( built in DDFStructureL() function ) |
|
31 _LIT8( KNSmlDmAOAdapterDDFVersion, "1.0" ); |
|
32 _LIT8( KNSmlDmAOAdapterTextPlain, "text/plain" ); |
|
33 |
|
34 // Names of the nodes |
|
35 // When updating KNSmlDmAOAdapterAOURI also update |
|
36 // KNSmlDmAOAdapterURIMaxLength! */ |
|
37 _LIT8(KNSmlDmAOAdapterAOURI, "./VENDORCONFIG"); |
|
38 _LIT8(KNSmlDmAOAdapterAO, "VENDORCONFIG"); |
|
39 _LIT8(KNSmlDmAOAdapterName, "NAME"); |
|
40 _LIT8(KNSmlDmAOAdapterAwonPdpc, "AWON-PDPC"); |
|
41 _LIT8(KNSmlDmAOAdapterTRetry, "T-RETRY"); |
|
42 |
|
43 |
|
44 // Descriptions of the nodes |
|
45 _LIT8( KNSmlDmAOAdapterAODescription, |
|
46 "Always-on provides management of connections"); |
|
47 _LIT8( KNSmlDmAOAdapterNameDescription, |
|
48 "Name of the VENDORCONFIG"); |
|
49 _LIT8( KNSmlDmAOAdapterAwonPdpcDescription, |
|
50 "Always-on setting in home and visited network"); |
|
51 _LIT8( KNSmlDmAOAdapterTRetryDescription, |
|
52 "T-Retry timer interval"); |
|
53 |
|
54 // Leaf nodes of VENDORCONFIG node |
|
55 _LIT8( KNSmlDmAOAllLeafNodes, |
|
56 "NAME/AWON-PDPC/T-RETRY"); |
|
57 |
|
58 // URI segment separator |
|
59 // When updating this literal also update |
|
60 // KNSmlDmAOAdapterAPURIMaxLength and KNSmlDmAOAdapterURIMaxLength! |
|
61 _LIT8( KNSmlDmAOSeparator, "/" ); |
|
62 |
|
63 // URI segment separator |
|
64 // When updating KNSmlDmAOAdapterAOURI also update |
|
65 // KNSmlDmAOAdapterAPURIMaxLength and KNSmlDmAOAdapterURIMaxLength! |
|
66 _LIT8( KNSmlDmAOUriListSeparator, "," ); |
|
67 |
|
68 // Prefix in URIs (removed for LUID mapping) |
|
69 _LIT8( KNSmlDmAOAdapterURIPrefix, "./" ); |
|
70 |
|
71 // Name prefix for unnamed VENDORCONFIG nodes |
|
72 _LIT8( KNSmlDmAONamePrefix, "VENDORCONFIG" ); |
|
73 |
|
74 const TInt KNSmlDmAOGranularity = 4; |
|
75 const TInt KNSmlDmAOInvalidRef = -1; |
|
76 |
|
77 // Maximum length of VENDORCONFIG URI including a separator |
|
78 // character in URI List. Node is not calculated here. |
|
79 // KNSmlDmAOAdapterAOURI + KNSmlDmAOSeparator + KNSmlDmAOUriListSeparator |
|
80 const TInt KNSmlDmAOAdapterURIMaxLength = 16; |
|
81 |
|
82 /** |
|
83 * Always-on device management adapter |
|
84 * |
|
85 * Always-on device management adapter manages settings |
|
86 * related to VENDORCONFIG. |
|
87 * |
|
88 * @lib nsmldmalwaysonadapter |
|
89 * @since S60 v3.2 |
|
90 */ |
|
91 class CNSmlDmAOAdapter : public CSmlDmAdapter |
|
92 { |
|
93 |
|
94 public: |
|
95 |
|
96 /** Possible command types */ |
|
97 enum TCommandType |
|
98 { |
|
99 EAddCmd, |
|
100 EGetCmd, |
|
101 EGetSizeCmd, |
|
102 EDeleteCmd |
|
103 }; |
|
104 |
|
105 |
|
106 static CNSmlDmAOAdapter* NewL( MSmlDmCallback* aDmCallback ); |
|
107 |
|
108 virtual ~CNSmlDmAOAdapter(); |
|
109 |
|
110 |
|
111 // from base class CSmlDmAdapter |
|
112 |
|
113 /** |
|
114 * The function returns current version of the DDF. |
|
115 * |
|
116 * @since S60 v3.2 |
|
117 * @param aVersion DDF version of the |
|
118 * adapter. (filled by the adapter) |
|
119 */ |
|
120 void DDFVersionL( CBufBase& aDDFVersion ); |
|
121 |
|
122 /** |
|
123 * The function for filling the DDF structure of the adapter |
|
124 * |
|
125 * @since S60 v3.2 |
|
126 * @param aDDFObject Reference to root object. |
|
127 */ |
|
128 void DDFStructureL( MSmlDmDDFObject& aDDF ); |
|
129 |
|
130 /** |
|
131 * The function creates new leaf objects, or replaces data in existing |
|
132 * leaf objects. The information about the success of the command is |
|
133 * returned by calling SetStatusL function of MSmlDmCallback callback |
|
134 * interface. |
|
135 * |
|
136 * @since S60 v3.2 |
|
137 * @param aURI URI of the object |
|
138 * @param aLUID LUID of the object |
|
139 * @param aObject Data of the object. |
|
140 * @param aType MIME type of the object |
|
141 * @param aStatusRef Reference to correct command, i.e. this reference |
|
142 * must be used when calling the SetStatusL of this |
|
143 * command |
|
144 */ |
|
145 void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, |
|
146 const TDesC8& aObject, const TDesC8& aType, |
|
147 TInt aStatusRef ); |
|
148 /** |
|
149 * The function deletes an object and its child objects. |
|
150 * |
|
151 * @since S60 v3.2 |
|
152 * @param aURI URI of the object |
|
153 * @param aLUID LUID of the object (if the adapter have earlier |
|
154 * returned LUID to the DM Module). |
|
155 * @param aStatusRef Reference to correct command, i.e. this reference |
|
156 * must be used when calling the SetStatusL of this |
|
157 * command. |
|
158 */ |
|
159 void DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID, |
|
160 TInt aStatusRef ); |
|
161 |
|
162 /** |
|
163 * The function fetches data of a leaf object. The SetStatusL is used |
|
164 * as described in UpdateLeafObjectL(). The data is returned by using the |
|
165 * SetResultsL function of MSmlCallback callback interface. |
|
166 * |
|
167 * @since S60 v3.2 |
|
168 * @param aURI URI of the object |
|
169 * @param aLUID LUID of the object (if the adapter have |
|
170 * earlier returned LUID to the DM Module). |
|
171 * @param aType MIME type of the object |
|
172 * @param aResultsRef Reference to correct results, i.e. this |
|
173 * reference must be used when returning the |
|
174 * result by calling the SetResultsL. |
|
175 * @param aStatusRef Reference to correct command, i.e. this |
|
176 * reference must be used when calling the |
|
177 * SetStatusL of this command. |
|
178 */ |
|
179 void FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, |
|
180 const TDesC8& aType, TInt aResultsRef, |
|
181 TInt aStatusRef ); |
|
182 |
|
183 /** |
|
184 * The function fetches the size of the data of a leaf object. The size |
|
185 * is in bytes, and must reflect the number of bytes that will be |
|
186 * transferred when the framework calls FetchLeafObjectL. |
|
187 * |
|
188 * @since S60 v3.2 |
|
189 * @param aURI URI of the object |
|
190 * @param aLUID LUID of the object (if the adapter have |
|
191 * earlier returned LUID to the DM Module). |
|
192 * @param aType MIME type of the object |
|
193 * @param aResultsRef Reference to correct results, i.e. this |
|
194 * reference must be used when returning the |
|
195 * result by calling the SetResultsL. |
|
196 * @param aStatusRef Reference to correct command, i.e. this |
|
197 * reference must be used when calling the |
|
198 * SetStatusL of this command. |
|
199 */ |
|
200 void FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, |
|
201 const TDesC8& aType, TInt aResultsRef, |
|
202 TInt aStatusRef ); |
|
203 |
|
204 /** |
|
205 * The function fetches URI list. An adapter returns the list of URI |
|
206 * segments under the given URI be separated by slash ("/"). The URI |
|
207 * segment names for new objects must be given by the adapter. |
|
208 * The list is returned by calling the SetResultsL function of |
|
209 * MSmlCallback callback interface. |
|
210 * |
|
211 * @since S60 v3.2 |
|
212 * @param aParentURI URI of the parent object |
|
213 * @param aParentLUID LUID of the parent object (if the |
|
214 * adapter have earlier returned LUID to |
|
215 * the DM Module). |
|
216 * @param aPreviousURISegmentList URI list with mapping LUID |
|
217 * information, which is known by DM |
|
218 * engine. |
|
219 * @param aResultsRef Reference to correct results, i.e. |
|
220 * this reference must be used when |
|
221 * returning the result by calling the |
|
222 * SetResultsL. |
|
223 * @param aStatusRef Reference to correct command, i.e. |
|
224 * this reference must be used when |
|
225 * calling the SetStatusL of this |
|
226 * command. |
|
227 */ |
|
228 void ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID, |
|
229 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
230 TInt aResultsRef, TInt aStatusRef ); |
|
231 |
|
232 /** |
|
233 * The function adds node object. |
|
234 * |
|
235 * @since S60 v3.2 |
|
236 * @param aURI URI of the object |
|
237 * @param aParentLUID LUID of the parent object (if the adapter have |
|
238 * earlier returned LUID to the DM Module). |
|
239 * @param aStatusRef Reference to correct command, i.e. this |
|
240 * reference must be used when calling the |
|
241 * SetStatusL of this command. |
|
242 */ |
|
243 void AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID, |
|
244 TInt aStatusRef ); |
|
245 /** |
|
246 * The adapter does not support streaming and no implementation is |
|
247 * provided for this function. |
|
248 * |
|
249 * @since S60 v3.2 |
|
250 * @param aURI URI of the object |
|
251 * @param aLUID LUID of the object |
|
252 * @param aStream Data of the object. |
|
253 * @param aType MIME type of the object |
|
254 * @param aStatusRef Reference to correct command, i.e. this reference |
|
255 * must be used when calling the SetStatusL of this |
|
256 * command. |
|
257 */ |
|
258 void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, |
|
259 RWriteStream*& aStream, const TDesC8& aType, |
|
260 TInt aStatusRef ); |
|
261 /** |
|
262 * The adapter does not support execute command and does not |
|
263 * provide implementation for this function. |
|
264 * |
|
265 * @since S60 v3.2 |
|
266 * @param aURI URI of the command |
|
267 * @param aLUID LUID of the object |
|
268 * @param aArgument Argument for the command |
|
269 * @param aType MIME type of the object |
|
270 * @param aStatusRef Reference to correct command, i.e. this |
|
271 * reference must be used when calling the |
|
272 * SetStatusL of this command. |
|
273 */ |
|
274 void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, |
|
275 const TDesC8& aArgument, const TDesC8& aType, |
|
276 TInt aStatusRef ); |
|
277 /** |
|
278 * The adapter does not support execute command and does not |
|
279 * provide implementation for this function. |
|
280 * |
|
281 * @since S60 v3.2 |
|
282 * @param aURI URI of the command |
|
283 * @param aLUID LUID of the object |
|
284 * @param aStream Argument for the command. |
|
285 * @param aType MIME type of the object |
|
286 * @param aStatusRef Reference to correct command, i.e. this |
|
287 * reference must be used when calling the |
|
288 * SetStatusL of this command. |
|
289 */ |
|
290 void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, |
|
291 RWriteStream*& aStream, const TDesC8& aType, |
|
292 TInt aStatusRef ); |
|
293 /** |
|
294 * The adapter does not support copy command and does not |
|
295 * provide implementation for this function. |
|
296 * |
|
297 * @since S60 v3.2 |
|
298 * @param aTargetURI Target URI for the command |
|
299 * @param aSourceLUID LUID of the target object |
|
300 * @param aSourceURI Source URI for the command |
|
301 * @param aSourceLUID LUID of the source object |
|
302 * @param aType MIME type of the objects |
|
303 * @param aStatusRef Reference to correct command, i.e. this |
|
304 * reference must be used when calling the |
|
305 * SetStatusL of this command. |
|
306 */ |
|
307 void CopyCommandL( const TDesC8& aTargetURI, const TDesC8& aTargetLUID, |
|
308 const TDesC8& aSourceURI, const TDesC8& aSourceLUID, |
|
309 const TDesC8& aType, TInt aStatusRef ); |
|
310 /** |
|
311 * Not supported |
|
312 * @since S60 v3.2 |
|
313 */ |
|
314 void StartAtomicL(); |
|
315 /** |
|
316 * Not Supported |
|
317 * @since S60 v3.2 |
|
318 * |
|
319 */ |
|
320 void CommitAtomicL(); |
|
321 /** |
|
322 * Not supported. |
|
323 * @since S60 v3.2 |
|
324 */ |
|
325 void RollbackAtomicL(); |
|
326 /** |
|
327 * Returns EFalse as the adapter does not support streaming |
|
328 * |
|
329 * @since S60 v3.2 |
|
330 * @param aItemSize size limit for stream usage |
|
331 * @return TBool EFalse as streaming is not supported |
|
332 */ |
|
333 TBool StreamingSupport( TInt& aItemSize ); |
|
334 /** |
|
335 * Not supported |
|
336 * |
|
337 * @since S60 v3.2 |
|
338 */ |
|
339 void StreamCommittedL(); |
|
340 /** |
|
341 * The function tells the adapter that all the commands of the message |
|
342 * that can be passed to the adapter have now been passed. This |
|
343 * indciates that the adapter must supply status codes and results to |
|
344 * any buffered commands. This must be done at latest by the time this |
|
345 * function returns. This function is used at the end of SyncML messages, |
|
346 * and during processing of Atomic. |
|
347 * |
|
348 * @since S60 v3.2 |
|
349 */ |
|
350 void CompleteOutstandingCmdsL(); |
|
351 |
|
352 /** |
|
353 * Converts integer to 8bit descriptor |
|
354 * |
|
355 * @since S60 v3.2 |
|
356 * @param aLuid The integer to be converted |
|
357 * @return The Integer as a descriptor |
|
358 */ |
|
359 HBufC8* IntToDes8L( TInt aLuid) const; |
|
360 |
|
361 /** |
|
362 * Converts 8bit descriptor to integer |
|
363 * |
|
364 * @since S60 v3.2 |
|
365 * @param aLuid The descriptor to be converted |
|
366 * @return Integer value of the descriptor |
|
367 */ |
|
368 TUint DesToIntL(const TDesC8& aLuid) const; |
|
369 |
|
370 |
|
371 private: |
|
372 |
|
373 /** |
|
374 * Constructor |
|
375 */ |
|
376 CNSmlDmAOAdapter(); |
|
377 |
|
378 /** |
|
379 * Constructor |
|
380 * @param aDmCallback Callback object to the framework |
|
381 */ |
|
382 CNSmlDmAOAdapter( MSmlDmCallback* aDmCallback ); |
|
383 |
|
384 /** |
|
385 * Second phase constructor |
|
386 */ |
|
387 void ConstructL(); |
|
388 |
|
389 /** |
|
390 * Parses the last URI segment from URI |
|
391 * @param aURI The whole URI |
|
392 * @return The last URI segment |
|
393 */ |
|
394 TPtrC8 LastURISeg(const TDesC8& aURI) const; |
|
395 |
|
396 |
|
397 private: //data |
|
398 |
|
399 /** |
|
400 * Setting store object, which is called for managing settings |
|
401 * in CommsDat. Own. |
|
402 */ |
|
403 CNSmlDmAOSettingStore * iSettingStore; |
|
404 |
|
405 }; |
|
406 |
|
407 |
|
408 /** |
|
409 * CSmlDmAOCommandElement |
|
410 * |
|
411 * Helper class, which stores a single command for a VENDORCONFIG. |
|
412 * @lib nsmldmalwaysonadapter |
|
413 * @since S60 v3.2 |
|
414 */ |
|
415 |
|
416 class CSmlDmAOCommandElement : public CBase |
|
417 { |
|
418 |
|
419 public: |
|
420 |
|
421 static CSmlDmAOCommandElement* NewLC( TBool aLeaf, |
|
422 TInt aStatusRef, |
|
423 TInt aResultRef, |
|
424 CNSmlDmAOAdapter::TCommandType aCmdType, |
|
425 const TDesC8& aLastUriSeg, |
|
426 const TDesC8& aData ); |
|
427 |
|
428 ~CSmlDmAOCommandElement(); |
|
429 |
|
430 /** |
|
431 * Returns the iExecuted member value of the object |
|
432 * |
|
433 * @since S60 v3.2 |
|
434 * @return The iExecuted member value of the object |
|
435 */ |
|
436 inline TBool Executed(); |
|
437 |
|
438 /** |
|
439 * Sets the iExecuted member value of the object |
|
440 * |
|
441 * @since S60 v3.2 |
|
442 * @param aExecuted Executed value for the object. |
|
443 */ |
|
444 inline void SetExecuted( TBool aExecuted ); |
|
445 |
|
446 /** |
|
447 * Returns the iStatus member value of the object |
|
448 * |
|
449 * @since S60 v3.2 |
|
450 * @return The iStatus value of the object |
|
451 */ |
|
452 inline CSmlDmAdapter::TError Status(); |
|
453 |
|
454 /** |
|
455 * Sets the iStatus member value of the object |
|
456 * |
|
457 * @since S60 v3.2 |
|
458 * @param aStatus Status value for the object. |
|
459 */ |
|
460 inline void SetStatus( CSmlDmAdapter::TError aStatus ); |
|
461 |
|
462 /** |
|
463 * Returns the iLeaf member value of the object |
|
464 * |
|
465 * @since S60 v3.2 |
|
466 * @return The iLeaf member value of the object |
|
467 */ |
|
468 inline TBool Leaf(); |
|
469 |
|
470 /** |
|
471 * Returns the iStatusRef member value of the object |
|
472 * |
|
473 * @since S60 v3.2 |
|
474 * @return The iStatusRef member value of the object |
|
475 */ |
|
476 inline TInt StatusRef(); |
|
477 |
|
478 /** |
|
479 * Returns the iResultRef member value of the object |
|
480 * |
|
481 * @since S60 v3.2 |
|
482 * @return The iResultRef member value of the object |
|
483 */ |
|
484 inline TInt ResultRef(); |
|
485 |
|
486 /** |
|
487 * Returns the iCmdType member value of the object |
|
488 * |
|
489 * @since S60 v3.2 |
|
490 * @return The iCmdType member value of the object |
|
491 */ |
|
492 inline CNSmlDmAOAdapter::TCommandType CmdType(); |
|
493 |
|
494 /** |
|
495 * Returns the iData member value of the object |
|
496 * |
|
497 * @since S60 v3.2 |
|
498 * @return The iData member value of the object |
|
499 */ |
|
500 inline const HBufC8* Data(); |
|
501 |
|
502 /** |
|
503 * Returns the iLastUriSeg member value of the object |
|
504 * |
|
505 * @since S60 v3.2 |
|
506 * @return The iLastUriSeg member value of the object |
|
507 */ |
|
508 inline const HBufC8* LastUriSeg(); |
|
509 |
|
510 /** |
|
511 * Sets the iData member value of the object |
|
512 * |
|
513 * @since S60 v3.2 |
|
514 * @param aData Data set to the object. The data will be owned by |
|
515 * the command object. |
|
516 */ |
|
517 inline void SetData( HBufC8* aData ); |
|
518 |
|
519 private: |
|
520 |
|
521 CSmlDmAOCommandElement( TBool aLeaf, |
|
522 TInt aStatusRef, |
|
523 TInt aResultRef, |
|
524 CNSmlDmAOAdapter::TCommandType aCmdType ); |
|
525 |
|
526 void ConstructL( const TDesC8& aLastUriSeg, const TDesC8& aData ); |
|
527 |
|
528 |
|
529 private: //data |
|
530 |
|
531 /** |
|
532 * Has command been executed. |
|
533 * Set to ETrue when command is executed. |
|
534 */ |
|
535 TBool iExecuted; |
|
536 |
|
537 /** |
|
538 * The execution status of an exeuted command. |
|
539 * Filled in when command is executed. |
|
540 */ |
|
541 CSmlDmAdapter::TError iStatus; |
|
542 |
|
543 |
|
544 /** |
|
545 * True if commend is for a leaf node, False if it is for a NAPDEF node. |
|
546 */ |
|
547 const TBool iLeaf; |
|
548 |
|
549 /** |
|
550 * Reference for returning the status to DM framework. |
|
551 */ |
|
552 const TInt iStatusRef; |
|
553 |
|
554 /** |
|
555 * Reference for returning result of Get command to the DM framework. |
|
556 */ |
|
557 const TInt iResultRef; |
|
558 |
|
559 /** |
|
560 * Type of command. |
|
561 */ |
|
562 const CNSmlDmAOAdapter::TCommandType iCmdType; |
|
563 |
|
564 |
|
565 /** |
|
566 * Data which is either ment to be stored to setting store |
|
567 * or which has been fetched from there. |
|
568 */ |
|
569 HBufC8* iData; |
|
570 |
|
571 /** |
|
572 * Last segment in the command URI, which indicates the leaf node |
|
573 * in question. For non leaf command empty string. |
|
574 */ |
|
575 HBufC8* iLastUriSeg; |
|
576 |
|
577 }; |
|
578 |
|
579 #include "nsmldmalwaysonadapter.inl" |
|
580 |
|
581 #endif // NSMLDMALWAYSONADAPTER_H |