|
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 class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_NSMLDMVCCADAPTER_H |
|
21 #define C_NSMLDMVCCADAPTER_H |
|
22 |
|
23 |
|
24 #include <smldmadapter.h> |
|
25 #include <msvapi.h> |
|
26 |
|
27 #include "vccunittesting.h" |
|
28 |
|
29 class CVccSPSettings; |
|
30 |
|
31 /** |
|
32 * The main class of the OMA PoC DM adapter. |
|
33 * Handles requests of fetching and updating settings sets and settings items. |
|
34 * |
|
35 * @lib nsmldmvccadapter.dll |
|
36 * @since S60 ?S60_version |
|
37 */ |
|
38 class CNSmlDmVCCAdapter : public CSmlDmAdapter |
|
39 { |
|
40 public: |
|
41 |
|
42 /** |
|
43 * Two-phased constructor. |
|
44 * |
|
45 * @since S60 3.2 |
|
46 * @param aDmCallback The pointer to callback to return results and |
|
47 * status to codes for completed commands to the |
|
48 * DM framework. The interface also has |
|
49 * functionality for mapping LUIDs and fetching |
|
50 * from other parts of the DM Tree. |
|
51 * @return A pointer to the newly created object. |
|
52 */ |
|
53 static CNSmlDmVCCAdapter* NewL( MSmlDmCallback* aDmCallback ); |
|
54 |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * |
|
58 * @since S60 3.2 |
|
59 * @param aDmCallback The pointer to callback to return results and |
|
60 * status to codes for completed commands to the |
|
61 * DM framework. The interface also has |
|
62 * functionality for mapping LUIDs and fetching |
|
63 * from other parts of the DM Tree. |
|
64 * @return A pointer to the newly created object. |
|
65 */ |
|
66 static CNSmlDmVCCAdapter* NewLC( MSmlDmCallback* aDmCallback ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 virtual ~CNSmlDmVCCAdapter(); |
|
72 |
|
73 //from base class MSmlDmAdapter |
|
74 |
|
75 /** |
|
76 * From MSmlDmAdapter. |
|
77 * Returns current version of the DDF. |
|
78 * This function is always called after DDFStructureL. |
|
79 * |
|
80 * @since S60 3.2 |
|
81 * @param aVersion DDF version of the adapter. |
|
82 */ |
|
83 void DDFVersionL( CBufBase& aVersion ); |
|
84 |
|
85 /** |
|
86 * From MSmlDmAdapter. |
|
87 * Fills the DDF structure of the adapter. The adapter starts to |
|
88 * fill the data structure by calling AddChildObjectL to the root |
|
89 * object and so describes the DDF of the adapter. |
|
90 * |
|
91 * @since S60 3.2 |
|
92 * @param aDDFObject Reference to the root object. |
|
93 */ |
|
94 void DDFStructureL( MSmlDmDDFObject& aDDF ); |
|
95 |
|
96 /** |
|
97 * From MSmlDmAdapter. |
|
98 * Creates new leaf objects, or replaces data in existing |
|
99 * leaf objects. The information about the success of the command |
|
100 * should be returned by calling SetStatusL function of MSmlDmCallback |
|
101 * callback interface. This makes it possible to buffer the commands. |
|
102 * However, all the status codes for buffered commands must be returned |
|
103 * at the latest when the adapter's CompleteOutstandingCmdsL() is |
|
104 * called. |
|
105 * |
|
106 * @since S60 3.2 |
|
107 * @param aURI URI of the object |
|
108 * @param aLUID LUID of the object (if the adapter has earlier |
|
109 * returned a LUID to the DM Module). For new |
|
110 * objects, this is the LUID inherited through the |
|
111 * parent node. |
|
112 * @param aObject Data of the object. |
|
113 * @param aType MIME type of the object |
|
114 * @param aStatusRef Reference to correct command, i.e. this reference |
|
115 * must be used when calling the SetStatusL of this |
|
116 * command |
|
117 */ |
|
118 void UpdateLeafObjectL( const TDesC8& aURI, |
|
119 const TDesC8& aLUID, |
|
120 const TDesC8& aObject, |
|
121 const TDesC8& aType, |
|
122 TInt aStatusRef ); |
|
123 |
|
124 /** |
|
125 * From MSmlDmAdapter. |
|
126 * The function creates new leaf objects, or replaces data in existing |
|
127 * leaf objects, in the case where data is large enough to be streamed. |
|
128 * SetStatusL function of MSmlDmCallback callback interface should be |
|
129 * called to inform about the success of the command. This makes it |
|
130 * possible to buffer the commands. All the status codes for buffered |
|
131 * commands must be returned at the latest |
|
132 * when the CompleteOutstandingCmdsL() of adapter is called. |
|
133 * |
|
134 * @since S60 3.2 |
|
135 * @param aURI URI of the object |
|
136 * @param aLUID LUID of the object (if the adapter has earlier |
|
137 * returned a LUID to the DM Module). |
|
138 * For new objects, this is the LUID inherited |
|
139 * through the parent node. |
|
140 * @param aStream Data of the object. Adapter should create write |
|
141 * stream and return, when data is written to stream |
|
142 * by DM agent, StreamCommittedL() is called by DM |
|
143 * engine |
|
144 * @param aType MIME type of the object |
|
145 * @param aStatusRef Reference to correct command, i.e. this reference |
|
146 * must be used when calling the SetStatusL of this |
|
147 * command. |
|
148 */ |
|
149 void UpdateLeafObjectL( const TDesC8& aURI, |
|
150 const TDesC8& aLUID, |
|
151 RWriteStream*& aStream, |
|
152 const TDesC8& aType, |
|
153 TInt aStatusRef ); |
|
154 |
|
155 /** |
|
156 * From MSmlDmAdapter. |
|
157 * Deletes an object and its child objects. The information about the |
|
158 * success of the command should be returned by calling SetStatusL |
|
159 * function of MSmlDmCallback callback interface. |
|
160 * This makes it possible to buffer the commands. All the |
|
161 * status codes for buffered commands must be returned at the latest |
|
162 * when the CompleteOutstandingCmdsL() of adapter is called. |
|
163 * |
|
164 * @since S60 3.2 |
|
165 * @param aURI URI of the object |
|
166 * @param aLUID LUID of the object (if the adapter have earlier |
|
167 * returned LUID to the DM Module). |
|
168 * @param aStatusRef Reference to correct command, i.e. this reference |
|
169 * must be used when calling the SetStatusL of this |
|
170 * command. |
|
171 */ |
|
172 void DeleteObjectL( const TDesC8& aURI, |
|
173 const TDesC8& aLUID, |
|
174 TInt aStatusRef ); |
|
175 |
|
176 /** |
|
177 * From MSmlDmAdapter. |
|
178 * Fetches the data of a leaf object. The SetStatusL should be used as |
|
179 * described in UpdateLeafObjectL(). The data is returned by using the |
|
180 * SetResultsL function of MSmlCallback callback interface, and may be |
|
181 * streamed. |
|
182 * |
|
183 * @since S60 3.2 |
|
184 * @param aURI URI of the object |
|
185 * @param aLUID LUID of the object (if the adapter have |
|
186 * earlier returned LUID to the DM Module). |
|
187 * @param aType MIME type of the object |
|
188 * @param aResultsRef Reference to correct results, i.e. this |
|
189 * reference must be used when returning the |
|
190 * result by calling the SetResultsL. |
|
191 * @param aStatusRef Reference to correct command, i.e. this |
|
192 * reference must be used when calling the |
|
193 * SetStatusL of this command. |
|
194 */ |
|
195 void FetchLeafObjectL( const TDesC8& aURI, |
|
196 const TDesC8& aLUID, |
|
197 const TDesC8& aType, |
|
198 TInt aResultsRef, |
|
199 TInt aStatusRef ); |
|
200 |
|
201 /** |
|
202 * From MSmlDmAdapter. |
|
203 * The function fetches the size of the data of a leaf object. The size |
|
204 * is in bytes, and must reflect the number of bytes that will be |
|
205 * transferred when the framework calls FetchLeafObjectL. The |
|
206 * SetStatusL should be used as described in FetchLeafObjectL(). The |
|
207 * size value is returned by using the SetResultsL function of |
|
208 * MSmlCallback callback interface, and must be a decimal integer |
|
209 * expressed as a string, eg. "1234". Results from this call MUST NOT |
|
210 * be streamed. |
|
211 * |
|
212 * @since S60 3.2 |
|
213 * @param aURI URI of the object |
|
214 * @param aLUID LUID of the object (if the adapter have |
|
215 * earlier returned LUID to the DM Module). |
|
216 * @param aType MIME type of the object |
|
217 * @param aResultsRef Reference to correct results, i.e. this |
|
218 * reference must be used when returning the |
|
219 * result by calling the SetResultsL. |
|
220 * @param aStatusRef Reference to correct command, i.e. this |
|
221 * reference must be used when calling the |
|
222 * SetStatusL of this command. |
|
223 */ |
|
224 void FetchLeafObjectSizeL( const TDesC8& aURI, |
|
225 const TDesC8& aLUID, |
|
226 const TDesC8& aType, |
|
227 TInt aResultsRef, |
|
228 TInt aStatusRef ); |
|
229 /** |
|
230 * From MSmlDmAdapter. |
|
231 * Fetches URI list. The adapter returns the list of URI segments under |
|
232 * the given URI be separated by slash ("/"). The URI segment names for |
|
233 * new objects must be given by the adapter. The list is returned by |
|
234 * calling the SetResultsL function of MSmlCallback callback interface. |
|
235 * Results from this call MUST NOT be streamed. |
|
236 * |
|
237 * @since S60 3.2 |
|
238 * @param aParentURI URI of the parent object |
|
239 * @param aParentLUID LUID of the parent object (if the |
|
240 * adapter have earlier returned LUID |
|
241 * to the DM Module). |
|
242 * @param aPreviousURISegmentList URI list with mapping LUID |
|
243 * information, which is known by DM |
|
244 * engine. An adapter can use this |
|
245 * information when verifying if old |
|
246 * objects still exists. An adapter also |
|
247 * knows what objects are new to DM |
|
248 * engine and can provide LUID mapping |
|
249 * for them. aPreviousURISegmentList |
|
250 * parameter (see above) helps to |
|
251 * recognise new objects. |
|
252 * @param aResultsRef Reference to correct results, i.e. |
|
253 * this reference must be used when |
|
254 * returning the result by calling the |
|
255 * SetResultsL. |
|
256 * @param aStatusRef Reference to correct command, i.e. |
|
257 * this reference must be used when |
|
258 * calling the SetStatusL of this |
|
259 * command. |
|
260 */ |
|
261 void ChildURIListL( const TDesC8& aURI, |
|
262 const TDesC8& aLUID, |
|
263 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
264 TInt aResultsRef, |
|
265 TInt aStatusRef ); |
|
266 |
|
267 /** |
|
268 * From MSmlDmAdapter. |
|
269 * The function adds node object. In some cases an implementation of |
|
270 * the function may be empty function, if the node object does not need |
|
271 * concrete database update. Still this function may be helpful to an |
|
272 * adapter, i.e. in passing mapping LUID of the node to DM Module. The |
|
273 * SetStatusL should be used as described in UpdateLeafObjectL(). |
|
274 * |
|
275 * @since S60 3.2 |
|
276 * @param aURI URI of the object |
|
277 * @param aParentLUID LUID of the parent object (if the adapter have |
|
278 * earlier returned LUID to the DM Module). |
|
279 * @param aStatusRef Reference to correct command, i.e. this |
|
280 * reference must be used when calling the |
|
281 * SetStatusL of this command. |
|
282 */ |
|
283 void AddNodeObjectL( const TDesC8& aURI, |
|
284 const TDesC8& aParentLUID, |
|
285 TInt aStatusRef ); |
|
286 |
|
287 /** |
|
288 * From MSmlDmAdapter. |
|
289 * The function implements execute command. The information about the |
|
290 * success of the command should be returned by calling SetStatusL |
|
291 * function of MSmlDmCallback callback interface. This makes it |
|
292 * possible to buffer the commands. However, all the status codes for |
|
293 * buffered commands must be returned at the latest when the |
|
294 * CompleteOutstandingCmdsL() of adapter is called. |
|
295 * |
|
296 * @since S60 3.2 |
|
297 * @param aURI URI of the command |
|
298 * @param aLUID LUID of the object (if the adapter have |
|
299 * earlier returned LUID to the DM Module). |
|
300 * @param aArgument Argument for the command |
|
301 * @param aType MIME type of the object |
|
302 * @param aStatusRef Reference to correct command, i.e. this |
|
303 * reference must be used when calling the |
|
304 * SetStatusL of this command. |
|
305 */ |
|
306 void ExecuteCommandL( const TDesC8& aURI, |
|
307 const TDesC8& aLUID, |
|
308 const TDesC8& aArgument, |
|
309 const TDesC8& aType, |
|
310 TInt aStatusRef ); |
|
311 |
|
312 /** |
|
313 * From MSmlDmAdapter. |
|
314 * The function implements execute command. The information about the |
|
315 * success of the command should be returned by calling SetStatusL |
|
316 * function of MSmlDmCallback callback interface. This makes it |
|
317 * possible to buffer the commands. |
|
318 * However, all the status codes for buffered commands must be returned |
|
319 * at the latest when the CompleteOutstandingCmdsL() of adapter is |
|
320 * called. |
|
321 * |
|
322 * @since S60 3.2 |
|
323 * @param aURI URI of the command |
|
324 * @param aLUID LUID of the object (if the adapter have |
|
325 * earlier returned LUID to the DM Module). |
|
326 * @param aStream Argument for the command. Adapter should |
|
327 * create write stream and return, when data is |
|
328 * written to stream by DM agent,StreamCommittedL |
|
329 * is called by DM engine |
|
330 * @param aType MIME type of the object |
|
331 * @param aStatusRef Reference to correct command, i.e. this |
|
332 * reference must be used when calling the |
|
333 * SetStatusL of this command. |
|
334 */ |
|
335 void ExecuteCommandL( const TDesC8& aURI, |
|
336 const TDesC8& aLUID, |
|
337 RWriteStream*& aStream, |
|
338 const TDesC8& aType, |
|
339 TInt aStatusRef ); |
|
340 |
|
341 /** |
|
342 * From MSmlDmAdapter. |
|
343 * The function implements copy command. The information about the |
|
344 * success of the command should be returned by calling SetStatusL |
|
345 * function of MSmlDmCallback callback interface. This makes it |
|
346 * possible to buffer the commands. |
|
347 * However, all the status codes for buffered commands must be returned |
|
348 * at the latest when the CompleteOutstandingCmdsL() of adapter is |
|
349 * called. |
|
350 * |
|
351 * @since S60 3.2 |
|
352 * @param aTargetURI Target URI for the command |
|
353 * @param aSourceLUID LUID of the target object (if one exists, and |
|
354 * if the adapter has earlier returned a LUID to |
|
355 * the DM Module). |
|
356 * @param aSourceURI Source URI for the command |
|
357 * @param aSourceLUID LUID of the source object (if the adapter has |
|
358 * earlier returned a LUID to the DM Module). |
|
359 * @param aType MIME type of the objects |
|
360 * @param aStatusRef Reference to correct command, i.e. this |
|
361 * reference must be used when calling the |
|
362 * SetStatusL of this command. |
|
363 */ |
|
364 void CopyCommandL( const TDesC8& aTargetURI, |
|
365 const TDesC8& aTargetLUID, |
|
366 const TDesC8& aSourceURI, |
|
367 const TDesC8& aSourceLUID, |
|
368 const TDesC8& aType, |
|
369 TInt aStatusRef ); |
|
370 |
|
371 /** |
|
372 * From MSmlDmAdapter. |
|
373 * The function indicates start of Atomic command. |
|
374 * |
|
375 * @since S60 3.2 |
|
376 */ |
|
377 void StartAtomicL(); |
|
378 |
|
379 /** |
|
380 * From MSmlDmAdapter. |
|
381 * The function indicates successful end of Atomic command. The adapter |
|
382 * should commit all changes issued between StartAtomicL and |
|
383 * CommitAtomicL |
|
384 * |
|
385 * @since S60 3.2 |
|
386 */ |
|
387 void CommitAtomicL(); |
|
388 |
|
389 /** |
|
390 * From MSmlDmAdapter. |
|
391 * The function indicates unsuccessful end of Atomic command. The |
|
392 * adapter should rollback all changes issued between StartAtomicL() |
|
393 * and RollbackAtomicL(). If rollback fails for a command, adapter |
|
394 * should use SetStatusL() to indicate it. |
|
395 * |
|
396 * @since S60 3.2 |
|
397 */ |
|
398 void RollbackAtomicL(); |
|
399 |
|
400 /** |
|
401 * From MSmlDmAdapter. |
|
402 * Returns ETrue if adapter supports streaming otherwise EFalse. |
|
403 * |
|
404 * @since S60 3.2 |
|
405 * @param aItemSize size limit for stream usage |
|
406 * @return TBool ETrue for streaming support |
|
407 */ |
|
408 TBool StreamingSupport( TInt& aItemSize ); |
|
409 |
|
410 /** |
|
411 * From MSmlDmAdapter. |
|
412 * Called when stream returned from UpdateLeafObjectL or |
|
413 * ExecuteCommandL has been written to and committed. Not called when |
|
414 * fetching item. |
|
415 * |
|
416 * @since S60 3.2 |
|
417 */ |
|
418 void StreamCommittedL(); |
|
419 |
|
420 /** |
|
421 * From MSmlDmAdapter. |
|
422 * The function tells the adapter that all the commands of the message |
|
423 * that can be passed to the adapter have now been passed. This |
|
424 * indciates that the adapter must supply status codes and results to |
|
425 * any buffered commands. This must be done at latest by the time this |
|
426 * function returns. This function is used at the end of SyncML |
|
427 * messages, and during processing of Atomic. In the case of Atomic |
|
428 * processing, the function will be followed by a call to CommitAtomicL |
|
429 * or RollbackAtomicL. |
|
430 * |
|
431 * @since S60 3.2 |
|
432 */ |
|
433 void CompleteOutstandingCmdsL(); |
|
434 |
|
435 /** |
|
436 * Implementation for cleanup item. |
|
437 * Resets and destroys array of the RCSE |
|
438 * entries. |
|
439 * @param anArray RPointerArray pointer. |
|
440 */ |
|
441 static void ResetAndDestroyEntries( TAny* anArray ); |
|
442 |
|
443 protected: |
|
444 |
|
445 private: |
|
446 |
|
447 /** |
|
448 * Constructor. |
|
449 * |
|
450 * @param aEcomArguments |
|
451 */ |
|
452 CNSmlDmVCCAdapter( TAny* aEcomArguments ); |
|
453 |
|
454 /** |
|
455 * Second-phase constructor. |
|
456 */ |
|
457 void ConstructL(); |
|
458 |
|
459 /** |
|
460 * Gets last uri segment. |
|
461 * |
|
462 * @since S60 3.2 |
|
463 * @param aURI Descriptor to handle |
|
464 * @return integer |
|
465 */ |
|
466 const TPtrC8 LastURISeg( const TDesC8& aURI ); |
|
467 |
|
468 /** |
|
469 * Gets last uri segment. |
|
470 * |
|
471 * @since S60 3.2 |
|
472 * @param aURI Descriptor to handle |
|
473 * @param aResult Object data. |
|
474 * @return Error status enumeration |
|
475 */ |
|
476 CSmlDmAdapter::TError FetchObjectL( const TDesC8& aURI, |
|
477 CBufBase& aResult ); |
|
478 |
|
479 /** |
|
480 * Converts Utf8 to Unicode. |
|
481 * |
|
482 * @since S60 3.2 |
|
483 * @param aSource Descriptor to handle containing UTF8 data |
|
484 * @return Handle to Unicode data |
|
485 */ |
|
486 HBufC* ConvertToUnicodeL( const TDesC8& aSource ); |
|
487 |
|
488 /** |
|
489 * Fetches Voip profile reference |
|
490 * @param aUri Uri of the wanted object |
|
491 * @param aObject The result is inserted to this buffer |
|
492 * @return Error code |
|
493 */ |
|
494 CSmlDmAdapter::TError FetchVoipConRefL( const TDesC8& aUri, |
|
495 CBufBase& aObject ); |
|
496 |
|
497 /** |
|
498 * Updates Voip profile reference (ServiceId) |
|
499 * @param aUri Uri of the wanted object |
|
500 * @param aObject The result is inserted to this buffer |
|
501 * @return Error code |
|
502 */ |
|
503 CSmlDmAdapter::TError UpdateVoipConRefL( const TDesC8& aUri, |
|
504 const TDesC8& aObject); |
|
505 |
|
506 /** |
|
507 * Removes separator from the end of URI. |
|
508 * @param aURI Reference to the URI. |
|
509 */ |
|
510 static void RemoveLastSeparator( TPtr8& aURI ); |
|
511 |
|
512 private: // data |
|
513 |
|
514 VCC_UNITTEST( T_CNSmlDmVCCAdapter ) |
|
515 |
|
516 /** |
|
517 * VCC SP Settings object |
|
518 * own |
|
519 * @see VccUtils |
|
520 */ |
|
521 CVccSPSettings* iVCCSettings; |
|
522 |
|
523 /** |
|
524 * Temporary object for converting Utf8 string to Unicode |
|
525 * own |
|
526 */ |
|
527 HBufC* iTempBuf; |
|
528 }; |
|
529 |
|
530 #endif // C_NSMLDMVCCADAPTER_H |