|
1 /* |
|
2 * Copyright (c) 2009 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: DCMO DM Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __DCMODMADAPTER_H |
|
19 #define __DCMODMADAPTER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <smldmadapter.h> |
|
24 #include <centralrepository.h> |
|
25 #include "dcmoclient.h" |
|
26 #include "dcmoconst.h" |
|
27 |
|
28 const TUid KCRUidDCMOServer={0x2001FE47}; |
|
29 const TInt KDCMOKeyMaxNumber = 16; |
|
30 const TInt KDCMOPropertyNumber = 1; |
|
31 |
|
32 _LIT8( KMimeType, "text/plain" ); |
|
33 _LIT8( KNSmlDCMOAdapterTitle, "DCMO DM Adapter" ); |
|
34 _LIT8( KNSmlTrue, "True" ); |
|
35 _LIT8( KNSmlFalse, "False" ); |
|
36 |
|
37 _LIT8( KNSmlHardware, "Hardware" ); |
|
38 _LIT8( KNSmlIO, "IO" ); |
|
39 _LIT8( KNSmlConnectivity, "Connectivity" ); |
|
40 _LIT8( KNSmlSoftware, "Software" ); |
|
41 _LIT8( KNSmlService, "Service" ); |
|
42 |
|
43 //DDF accepted DM-fieldnames |
|
44 _LIT8( KNSmlDdfProperty, "Property" ); |
|
45 _LIT8( KNSmlDdfGroup, "Group" ); |
|
46 _LIT8( KNSmlDdfDescription, "Description" ); |
|
47 _LIT8( KNSmlDdfAttached, "Attached" ); |
|
48 _LIT8( KNSmlDdfEnabled, "Enabled" ); |
|
49 _LIT8( KNSmlDdfDCMOConfig, "DCMOConfig" ); |
|
50 _LIT8( KNSmlDdfDenyUserEnable, "DenyUserEnable" ); |
|
51 _LIT8( KNSmlDdfNotifyUser, "NotifyUser" ); |
|
52 _LIT8( KNSmlDdfOperations, "Operations" ); |
|
53 _LIT8( KNSmlDdfEnable, "Enable" ); |
|
54 _LIT8( KNSmlDdfDisable, "Disable" ); |
|
55 _LIT8( KNSmlDdfOpExt, "Ext" ); |
|
56 _LIT8( KNSmlDdfExt, "Ext" ); |
|
57 _LIT8( KNSmlDdfOpExtSemiEnable, "SemiEnable" ); |
|
58 |
|
59 //DDF DM-field descriptions |
|
60 _LIT8( KDCMOCapabilityDescription, "DCMO capability node"); |
|
61 _LIT8( KNSmlDdfPropertyDescription, "Property of DCMO" ); |
|
62 _LIT8( KNSmlDdfGroupDescription, "Group of DCMO" ); |
|
63 _LIT8( KNSmlDdfDescDescription, "The Description node" ); |
|
64 _LIT8( KNSmlDdfAttachedDescription, "Attached" ); |
|
65 _LIT8( KNSmlDdfEnabledDescription, "Enabled" ); |
|
66 _LIT8( KNSmlDdfDCMOConfigDescription, "The DCMO Configuration node" ); |
|
67 _LIT8( KNSmlDdfDenyUserEnableDescription, "DenyUserEnable" ); |
|
68 _LIT8( KNSmlDdfNotifyUserDescription, "NotifyUser" ); |
|
69 _LIT8( KNSmlDdfOperationsDescription , "Operations node " ); |
|
70 _LIT8( KNSmlDdfEnableDescription , "Enable Operation " ); |
|
71 _LIT8( KNSmlDdfDisableDescription , "Disable Operation " ); |
|
72 _LIT8( KNSmlDdfOpExtDescription , "Extra Operations " ); |
|
73 _LIT8( KNSmlDdfExtDescription, "Extra" ); |
|
74 _LIT8( KNSmlDdfOpExtSemiEnableDescription, "Semi Enable Operation" ); |
|
75 |
|
76 _LIT8( KDcmoMatch, "DCMO" ); |
|
77 _LIT8( KDcmoMatch2, "DCMO/*" ); |
|
78 _LIT8( KDcmoMatch3, "DCMO/*/*" ); |
|
79 _LIT8( KDcmoConfigMatch, "DCMO/*/DCMOConfig"); |
|
80 _LIT8( KSegmDcmo, "Property/Group/Description/Attached/Enabled/DCMOConfig/Operations/Ext"); |
|
81 _LIT8( KSegmDcmoConfig, "DenyUserEnable/NotifyUser"); |
|
82 _LIT8( KSegmDcmoOperations, "Enable/Disable/Ext"); |
|
83 _LIT8( KDcmoConfigDenyUserEnableMatch, "DCMO/*/DCMOConfig/DenyUserEnable"); |
|
84 _LIT8( KDcmoConfigNotifyUserMatch, "DCMO/*/DCMOConfig/NotifyUser"); |
|
85 _LIT8( KDcmoOperationsMatch, "DCMO/*/Operations"); |
|
86 _LIT8( KDcmoOperationsExtMatch, "DCMO/*/Operations/Ext"); |
|
87 |
|
88 |
|
89 _LIT8( KNSmlBluetooth, "Bluetooth" ); |
|
90 |
|
91 // CLASS DECLARATION |
|
92 |
|
93 /** |
|
94 * Adapter class |
|
95 * Provides DM adapter interface |
|
96 */ |
|
97 class CDcmoDMAdapter : public CSmlDmAdapter |
|
98 { |
|
99 |
|
100 public: // Constructors, destructor |
|
101 /** |
|
102 * Create instance of CDcmoDMAdapter |
|
103 * @param aDmCallBack |
|
104 * @return Instance of CDcmoDMAdapter |
|
105 */ |
|
106 static CDcmoDMAdapter* NewL( MSmlDmCallback* aDmCallback ); |
|
107 |
|
108 /** |
|
109 * Create instance of CDcmoDMAdapter |
|
110 * @param aDmCallBack |
|
111 * @return Instance of CDcmoDMAdapter |
|
112 */ |
|
113 static CDcmoDMAdapter* NewLC( MSmlDmCallback* aDmCallback ); |
|
114 |
|
115 /** |
|
116 * C++ Destructor |
|
117 */ |
|
118 virtual ~CDcmoDMAdapter(); |
|
119 |
|
120 public: |
|
121 /** |
|
122 * The function returns current version of the DDF. |
|
123 * By asking current DDF versions from adapters DM Module can control |
|
124 * possible changes in the data structure and send the changed DDF |
|
125 * description to a management server. |
|
126 * This function is always called after DDFStructureL. |
|
127 * @param aVersion DDF version of the adapter. (filled by the adapter) |
|
128 * @publishedPartner |
|
129 * @prototype |
|
130 */ |
|
131 void DDFVersionL( CBufBase& aVersion ); |
|
132 |
|
133 /** |
|
134 * The function for filling the DDF structure of the adapter |
|
135 * This function is only called once, immediately after the adapter is created. |
|
136 * @param aDDFObject Reference to root object. A DM adapter starts filling |
|
137 the data structure by calling AddChildObjectL to the root object and |
|
138 so describes the DDF of the adapter. |
|
139 * @publishedPartner |
|
140 * @prototype |
|
141 */ |
|
142 void DDFStructureL( MSmlDmDDFObject& aDDF ); |
|
143 |
|
144 /** |
|
145 * The function creates new leaf objects, or replaces data in existing leaf |
|
146 * objects. The information about the success of the command should be |
|
147 * returned by calling SetStatusL function of MSmlDmCallback callback |
|
148 * interface. This makes it possible to buffer the commands. However, all |
|
149 * the status codes for buffered commands must be returned at the latest when |
|
150 * the adapter's CompleteOutstandingCmdsL() is called. |
|
151 * @param aURI URI of the object |
|
152 * @param aLUID LUID of the object (if the adapter has earlier returned a |
|
153 LUID to the DM Module). For new objects, this is the LUID |
|
154 inherited through the parent node. |
|
155 * @param aObject Data of the object. |
|
156 * @param aType MIME type of the object |
|
157 * @param aStatusRef Reference to correct command, i.e. this reference |
|
158 must be used when calling the SetStatusL of this command |
|
159 * @publishedPartner |
|
160 * @prototype |
|
161 */ |
|
162 void UpdateLeafObjectL( const TDesC8& aURI, |
|
163 const TDesC8& aLUID, |
|
164 const TDesC8& aObject, |
|
165 const TDesC8& aType, |
|
166 TInt aStatusRef |
|
167 ); |
|
168 |
|
169 /** |
|
170 * The function creates new leaf objects, or replaces data in existing leaf |
|
171 * objects, in the case where data is large enough to be streamed. The |
|
172 * information about the success of the command should be returned by calling |
|
173 * SetStatusL function of MSmlDmCallback callback interface. This makes it |
|
174 * possible to buffer the commands. However, all the status codes for buffered |
|
175 * commands must be returned at the latest when the CompleteOutstandingCmdsL() |
|
176 * of adapter is called. |
|
177 * @param aURI URI of the object |
|
178 * @param aLUID LUID of the object (if the adapter has earlier returned a |
|
179 LUID to the DM Module). For new objects, this is the LUID |
|
180 inherited through the parent node. |
|
181 * @param aStream Data of the object. Adapter should create write stream |
|
182 and return, when data is written to stream by DM agent, |
|
183 StreamCommittedL() is called by DM engine |
|
184 * @param aType MIME type of the object |
|
185 * @param aStatusRef Reference to correct command, i.e. this reference |
|
186 must be used when calling the SetStatusL of this |
|
187 command. |
|
188 * @publishedPartner |
|
189 * @prototype |
|
190 */ |
|
191 void UpdateLeafObjectL( const TDesC8& aURI, |
|
192 const TDesC8& aLUID, |
|
193 RWriteStream*& aStream, |
|
194 const TDesC8& aType, |
|
195 TInt aStatusRef |
|
196 ); |
|
197 |
|
198 /** |
|
199 * The function deletes an object and its child objects. The SetStatusL |
|
200 * should be used as described in UpdateLeafObjectL() |
|
201 * @param aURI URI of the object |
|
202 * @param aLUID LUID of the object (if the adapter have earlier returned |
|
203 LUID to the DM Module). |
|
204 * @param aStatusRef Reference to correct command, i.e. this reference must |
|
205 be used when calling the SetStatusL of this command. |
|
206 * @publishedPartner |
|
207 * @prototype |
|
208 */ |
|
209 void DeleteObjectL( const TDesC8& aURI, |
|
210 const TDesC8& aLUID, |
|
211 TInt aStatusRef |
|
212 ); |
|
213 |
|
214 /** |
|
215 * The function fetches data of a leaf object. The SetStatusL should be used |
|
216 * as described in UpdateLeafObjectL(). The data is returned by using the |
|
217 * SetResultsL function of MSmlCallback callback interface, and may be streamed. |
|
218 * @param aURI URI of the object |
|
219 * @param aLUID LUID of the object (if the adapter have earlier |
|
220 returned LUID to the DM Module). |
|
221 * @param aType MIME type of the object |
|
222 * @param aResultsRef Reference to correct results, i.e. this reference |
|
223 must be used when returning the result by calling |
|
224 the SetResultsL. |
|
225 * @param aStatusRef Reference to correct command, i.e. this reference |
|
226 must be used when calling the SetStatusL of this |
|
227 command. |
|
228 * @publishedPartner |
|
229 * @prototype |
|
230 */ |
|
231 void FetchLeafObjectL( const TDesC8& aURI, |
|
232 const TDesC8& aLUID, |
|
233 const TDesC8& aType, |
|
234 TInt aResultsRef, |
|
235 TInt aStatusRef |
|
236 ); |
|
237 |
|
238 /** |
|
239 * The function fetches the size of the data of a leaf object. The size is |
|
240 * in bytes, and must reflect the number of bytes that will be transferred |
|
241 * when the framework calls FetchLeafObjectL. The SetStatusL should be used |
|
242 * as described in FetchLeafObjectL(). The size value is returned by using |
|
243 * the SetResultsL function of MSmlCallback callback interface, and must be |
|
244 * a decimal integer expressed as a string, eg. "1234". |
|
245 * Results from this call MUST NOT be streamed. |
|
246 * @param aURI URI of the object |
|
247 * @param aLUID LUID of the object (if the adapter have earlier |
|
248 returned LUID to the DM Module). |
|
249 * @param aType MIME type of the object |
|
250 * @param aResultsRef Reference to correct results, i.e. this reference |
|
251 must be used when returning the result by calling |
|
252 the SetResultsL. |
|
253 * @param aStatusRef Reference to correct command, i.e. this reference |
|
254 must be used when calling the SetStatusL of this |
|
255 command. |
|
256 * @publishedPartner |
|
257 * @prototype |
|
258 */ |
|
259 void FetchLeafObjectSizeL( const TDesC8& aURI, |
|
260 const TDesC8& aLUID, |
|
261 const TDesC8& aType, |
|
262 TInt aResultsRef, |
|
263 TInt aStatusRef |
|
264 ); |
|
265 /** |
|
266 * The function fetches URI list. An adapter returns the list of URI segments |
|
267 * under the given URI be separated by slash ("/"). The URI segment names for |
|
268 * new objects must be given by the adapter. |
|
269 * The list is returned by calling the SetResultsL function of MSmlCallback |
|
270 * callback interface. Results from this call MUST NOT be streamed. |
|
271 * @param aParentURI URI of the parent object |
|
272 * @param aParentLUID LUID of the parent object (if the |
|
273 adapter have earlier returned LUID to |
|
274 the DM Module). |
|
275 * @param aPreviousURISegmentList URI list with mapping LUID information, |
|
276 which is known by DM engine. An adapter |
|
277 can use this information when verifying |
|
278 if old objects still exists. An adapter |
|
279 also knows what objects are new to DM |
|
280 engine and can provide LUID mapping for |
|
281 them. aPreviousURISegmentList parameter |
|
282 (see above) helps to recognise new |
|
283 objects. |
|
284 * @param aResultsRef Reference to correct results, i.e. this |
|
285 reference must be used when returning |
|
286 the result by calling the SetResultsL. |
|
287 * @param aStatusRef Reference to correct command, i.e. this |
|
288 reference must be used when calling the |
|
289 SetStatusL of this command. |
|
290 * @publishedPartner |
|
291 * @prototype |
|
292 */ |
|
293 void ChildURIListL( const TDesC8& aURI, |
|
294 const TDesC8& aLUID, |
|
295 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
296 TInt aResultsRef, |
|
297 TInt aStatusRef |
|
298 ); |
|
299 |
|
300 /** |
|
301 * The function adds node object. In some cases an implementation of the |
|
302 * function may be empty function, if the node object does not need concrete |
|
303 * database update. Still this function may be helpful to an adapter, i.e. in |
|
304 * passing mapping LUID of the node to DM Module. The SetStatusL should be |
|
305 * used as described in UpdateLeafObjectL() |
|
306 * @param aURI URI of the object |
|
307 * @param aParentLUID LUID of the parent object (if the adapter have |
|
308 earlier returned LUID to the DM Module). |
|
309 * @param aStatusRef Reference to correct command, i.e. this reference |
|
310 must be used when calling the SetStatusL of this |
|
311 command. |
|
312 * @publishedPartner |
|
313 * @prototype |
|
314 */ |
|
315 void AddNodeObjectL( const TDesC8& aURI, |
|
316 const TDesC8& aParentLUID, |
|
317 TInt aStatusRef |
|
318 ); |
|
319 |
|
320 /** |
|
321 * The function implements execute command. The information about the success |
|
322 * of the command should be returned by calling SetStatusL function of |
|
323 * MSmlDmCallback callback interface. This makes it possible to buffer the |
|
324 * commands. |
|
325 * However, all the status codes for buffered commands must be returned at |
|
326 * the latest when the CompleteOutstandingCmdsL() of adapter is called. |
|
327 * @param aURI URI of the command |
|
328 * @param aLUID LUID of the object (if the adapter have earlier |
|
329 returned LUID to the DM Module). |
|
330 * @param aArgument Argument for the command |
|
331 * @param aType MIME type of the object |
|
332 * @param aStatusRef Reference to correct command, i.e. this reference |
|
333 must be used when calling the SetStatusL of this |
|
334 command. |
|
335 * @publishedPartner |
|
336 * @prototype |
|
337 */ |
|
338 void ExecuteCommandL( const TDesC8& aURI, |
|
339 const TDesC8& aLUID, |
|
340 const TDesC8& aArgument, |
|
341 const TDesC8& aType, |
|
342 TInt aStatusRef |
|
343 ); |
|
344 |
|
345 /** |
|
346 * The function implements execute command. The information about the |
|
347 * success of the command should be returned by calling SetStatusL function |
|
348 * of MSmlDmCallback callback interface. This makes it possible to buffer the |
|
349 * commands. |
|
350 * However, all the status codes for buffered commands must be returned at |
|
351 * the latest when the CompleteOutstandingCmdsL() of adapter is called. |
|
352 * @param aURI URI of the command |
|
353 * @param aLUID LUID of the object (if the adapter have earlier |
|
354 returned LUID to the DM Module). |
|
355 * @param aStream Argument for the command. Adapter should create |
|
356 write stream and return, when data is written to |
|
357 stream by DM agent, StreamCommittedL() is called by |
|
358 DM engine |
|
359 * @param aType MIME type of the object |
|
360 * @param aStatusRef Reference to correct command, i.e. this reference |
|
361 must be used when calling the SetStatusL of this |
|
362 command. |
|
363 * @publishedPartner |
|
364 * @prototype |
|
365 */ |
|
366 void ExecuteCommandL( const TDesC8& aURI, |
|
367 const TDesC8& aLUID, |
|
368 RWriteStream*& aStream, |
|
369 const TDesC8& aType, |
|
370 TInt aStatusRef |
|
371 ); |
|
372 |
|
373 /** |
|
374 * The function implements copy command. The information about the success of |
|
375 * the command should be returned by calling SetStatusL function of |
|
376 * MSmlDmCallback callback interface. This makes it possible to buffer the |
|
377 * commands. |
|
378 * However, all the status codes for buffered commands must be returned at |
|
379 * the latest when the CompleteOutstandingCmdsL() of adapter is called. |
|
380 * @param aTargetURI Target URI for the command |
|
381 * @param aSourceLUID LUID of the target object (if one exists, and if the adapter |
|
382 has earlier returned a LUID to the DM Module). |
|
383 * @param aSourceURI Source URI for the command |
|
384 * @param aSourceLUID LUID of the source object (if the adapter has |
|
385 earlier returned a LUID to the DM Module). |
|
386 * @param aType MIME type of the objects |
|
387 * @param aStatusRef Reference to correct command, i.e. this reference |
|
388 must be used when calling the SetStatusL of this |
|
389 command. |
|
390 * @publishedPartner |
|
391 * @prototype |
|
392 */ |
|
393 void CopyCommandL( const TDesC8& aTargetURI, |
|
394 const TDesC8& aTargetLUID, |
|
395 const TDesC8& aSourceURI, |
|
396 const TDesC8& aSourceLUID, |
|
397 const TDesC8& aType, |
|
398 TInt aStatusRef |
|
399 ); |
|
400 |
|
401 /** |
|
402 * The function indicates start of Atomic command. |
|
403 * @publishedPartner |
|
404 * @prototype |
|
405 */ |
|
406 void StartAtomicL(); |
|
407 |
|
408 /** |
|
409 * The function indicates successful end of Atomic command. The adapter |
|
410 * should commit all changes issued between StartAtomicL() and |
|
411 * CommitAtomicL() |
|
412 * @publishedPartner |
|
413 * @prototype |
|
414 */ |
|
415 void CommitAtomicL(); |
|
416 |
|
417 /** |
|
418 * The function indicates unsuccessful end of Atomic command. The adapter |
|
419 * should rollback all changes issued between StartAtomicL() and |
|
420 * RollbackAtomicL(). If rollback fails for a command, adapter should use |
|
421 * SetStatusL() to indicate it. |
|
422 * @publishedPartner |
|
423 * @prototype |
|
424 */ |
|
425 void RollbackAtomicL(); |
|
426 |
|
427 /** |
|
428 * Returns ETrue if adapter supports streaming otherwise EFalse. |
|
429 * @param aItemSize size limit for stream usage |
|
430 * @return TBool ETrue for streaming support |
|
431 * @publishedPartner |
|
432 * @prototype |
|
433 */ |
|
434 TBool StreamingSupport( TInt& aItemSize ); |
|
435 |
|
436 /** |
|
437 * Called when stream returned from UpdateLeafObjectL or ExecuteCommandL has |
|
438 * been written to and committed. Not called when fetching item. |
|
439 * @publishedPartner |
|
440 * @prototype |
|
441 */ |
|
442 void StreamCommittedL(); |
|
443 |
|
444 /** |
|
445 * The function tells the adapter that all the commands of the message that |
|
446 * can be passed to the adapter have now been passed. This indicates that |
|
447 * the adapter must supply status codes and results to any buffered commands. |
|
448 * This must be done at latest by the time this function returns. |
|
449 * This function is used at the end of SyncML messages, and during processing |
|
450 * of Atomic. In the case of Atomic processing, the function will be |
|
451 * followed by a call to CommitAtomicL or RollbackAtomicL. |
|
452 * @publishedPartner |
|
453 * @prototype |
|
454 */ |
|
455 void CompleteOutstandingCmdsL(); |
|
456 |
|
457 private: // New methods |
|
458 |
|
459 /** |
|
460 * The function fills the adapter node with the details |
|
461 * @publishedPartner |
|
462 * @prototype |
|
463 */ |
|
464 void FillNodeInfoL( MSmlDmDDFObject& aDDFObject, |
|
465 TSmlDmAccessTypes& aAccessTypes, |
|
466 MSmlDmDDFObject::TScope aScope, |
|
467 MSmlDmDDFObject::TDFFormat aFormat, |
|
468 MSmlDmDDFObject::TOccurence aOccurence, |
|
469 const TDesC8& aDescription, |
|
470 const TDesC8& aMIMEType ); |
|
471 |
|
472 /** |
|
473 * This function loads all the DCMO plug-in adapters |
|
474 * @publishedPartner |
|
475 * @prototype |
|
476 */ |
|
477 void DDFDCMOAdaptersL(MSmlDmDDFObject& rootdcmo); |
|
478 |
|
479 /** |
|
480 * This function constructs the DDFnode with the details |
|
481 * @publishedPartner |
|
482 * @prototype |
|
483 */ |
|
484 void FillDCMODDFL(MSmlDmDDFObject& aDDF); |
|
485 |
|
486 |
|
487 /** |
|
488 * This function returns the Category of the plug-in |
|
489 * adapter from the aURI. |
|
490 * @param aURI |
|
491 * @return TPtrC8 category |
|
492 */ |
|
493 |
|
494 TPtrC8 GetCategoryFromUriL(const TDesC8& aURI ) ; |
|
495 |
|
496 /** |
|
497 * Maps a system wide error code to a TError. |
|
498 * @param aError A system wide error code. |
|
499 * @return A TError value depending on aError. |
|
500 */ |
|
501 CSmlDmAdapter::TError MapErrorToStatus( TInt aError ) const; |
|
502 |
|
503 /** |
|
504 * This function returns the dcmo enforcement |
|
505 * @param None |
|
506 * @return TBool true if dcmo enforcement or false |
|
507 */ |
|
508 TBool CheckEnforcementL(); |
|
509 |
|
510 private: // Constructor |
|
511 /** |
|
512 * Symbian 2nd phase constructor |
|
513 */ |
|
514 void ConstructL(); |
|
515 |
|
516 /** |
|
517 * C++ Constructor |
|
518 */ |
|
519 CDcmoDMAdapter( TAny* aEcomArguments ); |
|
520 |
|
521 private: // Data |
|
522 RDCMOClient* idcmoClient; |
|
523 TBool iExtOpNode; |
|
524 }; |
|
525 |
|
526 #endif // __DCMODMADAPTER_H |
|
527 |
|
528 // End Of File |