|
1 /* |
|
2 * Copyright (c) 2005 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 tree etc. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __NSMLDMDDF_H |
|
21 #define __NSMLDMDDF_H |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <ecom.h> |
|
26 #include <smldmadapter.h> |
|
27 |
|
28 #include <nsmldmmodule.h> |
|
29 #include <nsmldmtreedbclient.h> |
|
30 #include "nsmldmtreedtd.h" |
|
31 #include "nsmldmhostclient.h" |
|
32 |
|
33 class CNSmlDmModule; |
|
34 |
|
35 _LIT8(KNSmlDmFormatB64, "b64"); |
|
36 _LIT8(KNSmlDmFormatBool, "bool"); |
|
37 _LIT8(KNSmlDmFormatChr, "chr"); |
|
38 _LIT8(KNSmlDmFormatInt, "int"); |
|
39 _LIT8(KNSmlDmFormatNode, "node"); |
|
40 _LIT8(KNSmlDmFormatNull, "null"); |
|
41 _LIT8(KNSmlDmFormatXml, "xml"); |
|
42 _LIT8(KNSmlDmFormatBin, "bin"); |
|
43 |
|
44 _LIT8( KNSmlDmLitSeparator8, "/" ); |
|
45 _LIT ( KNSmlTxtPanicDmModule,"NSmlDmModule"); |
|
46 |
|
47 // Constant holding the value of number of slashes in a DM adapter aURI to get |
|
48 // the first dynamic node.Currently DM adapter will have maximum 4 slashes |
|
49 // eg: ./SCM/Inventory/Delivered/<x*>/z ; z is a leaf or internal node, |
|
50 // Before z four slashes present |
|
51 const TInt KMaximumNoOfSlashes = 4; |
|
52 |
|
53 // =========================================================================== |
|
54 // CNSmlCallbackElement |
|
55 // =========================================================================== |
|
56 /** |
|
57 * Container class for a DM callbacks |
|
58 * |
|
59 * @since |
|
60 */ |
|
61 class CNSmlCallbackElement : public CBase |
|
62 { |
|
63 public: |
|
64 ~CNSmlCallbackElement(); |
|
65 HBufC8* iUri; |
|
66 TInt iRef; |
|
67 TBool iNode; |
|
68 }; |
|
69 |
|
70 |
|
71 |
|
72 // =========================================================================== |
|
73 // CNSmlDmDDF |
|
74 // =========================================================================== |
|
75 |
|
76 /** |
|
77 * DM DDF Handler |
|
78 * |
|
79 * @since |
|
80 */ |
|
81 class CNSmlDmDDF : public CBase |
|
82 { |
|
83 public: |
|
84 |
|
85 enum TAccess |
|
86 { |
|
87 EOk, |
|
88 ENotAccess, |
|
89 ENotExist |
|
90 }; |
|
91 |
|
92 |
|
93 /** |
|
94 * Destructor |
|
95 */ |
|
96 virtual ~CNSmlDmDDF(); |
|
97 |
|
98 /** |
|
99 * Two-phased constructor. |
|
100 * @param aDmModule Reference to dmModule class |
|
101 * @return Pointer to newly created module instance |
|
102 */ |
|
103 static CNSmlDmDDF* NewL(CNSmlDmModule& aDmModule); |
|
104 |
|
105 /** |
|
106 * Generates xml of ddf structure |
|
107 * @param aObject Referencet to buffer where to generata |
|
108 * ddf xml |
|
109 */ |
|
110 void GenerateDDFL(CBufBase& aObject); |
|
111 |
|
112 /** |
|
113 * Sets the server identifier |
|
114 * @param aServer The server id of current session |
|
115 */ |
|
116 void SetServerL(const TDesC8& aServerId); |
|
117 |
|
118 /** |
|
119 * Creates sessions to Host Servers, asks ddf:s and calculates checksum of |
|
120 * all the ddf versions of plug-in adapters |
|
121 * @return Checksum of ddf's of plug-in adapters |
|
122 */ |
|
123 TInt IsDDFChangedL(); |
|
124 |
|
125 /** |
|
126 * Add operation in DM protocoll |
|
127 * @param aURI Target URI in command |
|
128 * @param aObject Data |
|
129 * @param aType Mime type |
|
130 * @param aStatusRef Reference to status element |
|
131 * @param aLargeItem Indicates if object comes in multiple messages |
|
132 * or not |
|
133 */ |
|
134 void AddObjectL(const TDesC8& aURI, const TDesC8& aObject, |
|
135 const TDesC8& aType,const TInt aStatusRef, TBool aLargeItem=EFalse); |
|
136 |
|
137 /** |
|
138 * Replace operation in DM protocoll |
|
139 * @param aURI Target URI in command |
|
140 * @param aObject Data |
|
141 * @param aType Mime type |
|
142 * @param aStatusRef Reference to status element |
|
143 * @param aLargeItem Indicates if object comes in multiple messages |
|
144 * or not |
|
145 */ |
|
146 void UpdateObjectL(const TDesC8& aURI, const TDesC8& aObject, |
|
147 const TDesC8& aType,const TInt aStatusRef, TBool aLargeItem=EFalse, |
|
148 // FOTA |
|
149 TInt aTotSizeOfLarge=0 |
|
150 // FOTA end |
|
151 ); |
|
152 |
|
153 /** |
|
154 * Get operation in DM protocoll |
|
155 * @param aURI Target URI in command |
|
156 * @param aType Mime type |
|
157 * @param aResultsRef Reference to result element |
|
158 * @param aStatusRef Reference to status element |
|
159 * @param aAclPass Passes acl checking if true |
|
160 */ |
|
161 void FetchObjectL( const TDesC8& aURI, const TDesC8& aType, |
|
162 const TInt aResultsRef,const TInt aStatusRef, TBool aAclPass=EFalse); |
|
163 |
|
164 /** |
|
165 * Get size property operation in DM protocoll |
|
166 * @param aURI Target URI in command |
|
167 * @param aType Mime type |
|
168 * @param aResultsRef Reference to result element |
|
169 * @param aStatusRef Reference to status element |
|
170 */ |
|
171 void FetchObjectSizeL( const TDesC8& aURI, const TDesC8& aType, |
|
172 const TInt aResultsRef,const TInt aStatusRef); |
|
173 |
|
174 /** |
|
175 * Delete operation in DM protocoll |
|
176 * @param aURI Target URI in command |
|
177 * @param aStatusRef Reference to status element |
|
178 */ |
|
179 void DeleteObjectL( const TDesC8& aURI, const TInt aStatusRef); |
|
180 |
|
181 /** |
|
182 * Execute operation in DM protocoll |
|
183 * @param aURI Target URI in command |
|
184 * @param aObject Data |
|
185 * @param aType Mime type |
|
186 * @param aStatusRef Reference to status element |
|
187 * @param aLargeItem Indicates if object comes in multiple messages |
|
188 * or not |
|
189 */ |
|
190 void ExecuteObjectL( const TDesC8& aURI, const TDesC8& aObject, |
|
191 const TDesC8& aType, TInt aStatusRef, |
|
192 // FOTA |
|
193 const TDesC8& aCorrelator, |
|
194 // FOTA end |
|
195 TBool aLargeItem=EFalse); |
|
196 |
|
197 /** |
|
198 * Copy operation in DM protocoll. |
|
199 * @param aTargetURI Target URI in command |
|
200 * @param aSourceURI Source URI in command |
|
201 * @param aType Mime type |
|
202 * @param aStatusRef Reference to status element |
|
203 */ |
|
204 void CopyObjectL( const TDesC8& aTargetURI,const TDesC8& aSourceURI, |
|
205 const TDesC8& aType, TInt aStatusRef); |
|
206 |
|
207 /** |
|
208 * Check ACL rights. |
|
209 * @param aURI Target URI in command |
|
210 * @param aCmdType Command type |
|
211 * or not |
|
212 * @return True if command is allowed by acls |
|
213 */ |
|
214 TBool CheckAclL(const TDesC8& aURI, TNSmlDmCmdType aCmdType); |
|
215 |
|
216 /** |
|
217 * Indicates message ending |
|
218 */ |
|
219 void EndMessageL(); |
|
220 |
|
221 /** |
|
222 * Gets and allocates format in DDF |
|
223 * @param aURI Target URI in command |
|
224 * @return pointer to format descriptor |
|
225 */ |
|
226 HBufC8* GetFormatAllocL(const TDesC8& aURI); |
|
227 |
|
228 /** |
|
229 * Gets and allocates format in DDF |
|
230 * @param aURI Target URI in command |
|
231 * @param aObject Reference to buffer where to write data |
|
232 * @return KErrNotFound if not found, otherwise KErrNone |
|
233 */ |
|
234 TInt GetMimeTypeL(const TDesC8& aURI,CBufBase& aObject); |
|
235 |
|
236 |
|
237 /** |
|
238 * Gets and allocates case sense in DDF |
|
239 * @param aURI Target URI in command |
|
240 * @param aObject Reference to buffer where to write data |
|
241 * @return KErrNotFound if not found, otherwise KErrNone |
|
242 */ |
|
243 |
|
244 TInt CNSmlDmDDF::GetCaseSenseL(const TDesC8& aURI,CBufBase& aObject); |
|
245 |
|
246 |
|
247 /** |
|
248 * Gets and allocates name in DDF |
|
249 * @param aURI Target URI in command |
|
250 * @param aObject Reference to buffer where to write data |
|
251 * @return KErrNotFound if not found, otherwise KErrNone |
|
252 */ |
|
253 TInt GetNameL(const TDesC8& aURI,CBufBase& aObject); |
|
254 |
|
255 /** |
|
256 * Checks if node is leaf or interior node |
|
257 * @param aURI Target URI in command |
|
258 * @return ENSmlDmDDFLeaf,ENSmlDmDDFNode |
|
259 * or ENSmlDmDDFNotFound |
|
260 */ |
|
261 TNSmlDmDDFFormat IsLeafL(const TDesC8& aURI); |
|
262 |
|
263 /** |
|
264 * Checks URI and access type and set the member variables point to correct |
|
265 * plug-in adapter and correct host server |
|
266 * @param aURI Target URI in command |
|
267 * @param aCmdType Command type |
|
268 * @return EOk,ENotAccess or ENotExist |
|
269 */ |
|
270 TAccess CheckURIL(const TDesC8& aURI,TNSmlDmCmdType aCmd); |
|
271 |
|
272 /** |
|
273 * Replace ACL operation in DM protocoll |
|
274 * @param aURI Target URI in command |
|
275 * @param aACL ACL data |
|
276 * @param aStatusRef Reference to status element |
|
277 */ |
|
278 void UpdateAclL(const TDesC8& aURI, const TDesC8& aACL, |
|
279 const TInt aStatusRef); |
|
280 |
|
281 /** |
|
282 * Get ACL operation in DM protocoll |
|
283 * @param aURI Target URI in command |
|
284 * @param aACL Reference to buffer where to write ACL data |
|
285 * @return Status code |
|
286 */ |
|
287 TInt GetAclL(const TDesC8& aURI, CBufBase& aACL); |
|
288 |
|
289 /** |
|
290 * Get more data in case of getting largeobject |
|
291 * @param aData Reference to buffer where to write data |
|
292 */ |
|
293 void MoreDataL(CBufBase*& aData); |
|
294 |
|
295 /** |
|
296 * "Callback" method. This is called when plug-in adapter makes new |
|
297 * new mapping, i.e. maps aLuid to aURI |
|
298 * @param aURI Uri to be mapped |
|
299 * @param aLuid Luid to be mapped |
|
300 */ |
|
301 void SetMappingL( const TDesC8& aURI, const TDesC8& aLUID ); |
|
302 |
|
303 /** |
|
304 * "Callback" method. This is called when plug-in adapter has given |
|
305 * result to get command |
|
306 * @param aResultRef Reference information to result element |
|
307 * @param aObject Result data |
|
308 * @param aType Mime type of data |
|
309 * @param aTotalSize Total size of data. In case of large object, |
|
310 * this is different from aObject size. |
|
311 * @param aSessionId Id of host session, this is given in case of |
|
312 * large object -> module keeps the information |
|
313 * until whole item is read |
|
314 */ |
|
315 void SetResultsL( TInt aResultsRef, CBufBase& aObject, |
|
316 const TDesC8& aType,TInt aTotalSize,TInt8 aSessionId=KErrNotFound); |
|
317 |
|
318 /** |
|
319 * "Callback" method. This is called when plug-in adapter has given |
|
320 * status to command |
|
321 * @param aStatusRef Reference information to status element |
|
322 * @param aErrorCode Status code from plug-in adapter |
|
323 */ |
|
324 void SetStatusL( TInt aStatusRef, CSmlDmAdapter::TError aErrorCode ); |
|
325 |
|
326 /** |
|
327 * Gets and allocs luid mapped to aURI. Allocs KNullDesC8 if not exist. |
|
328 * status to command |
|
329 * @param aURI Uri to be serched |
|
330 * @return Pointer to allocated luid |
|
331 */ |
|
332 HBufC8* GetLuidAllocL(const TDesC8& aURI); |
|
333 |
|
334 /** |
|
335 * Start atomic indication |
|
336 */ |
|
337 void StartAtomicL(); |
|
338 |
|
339 /** |
|
340 * Commit atomic indication |
|
341 */ |
|
342 void CommitAtomicL(); |
|
343 |
|
344 /** |
|
345 * Rollback atomic indication |
|
346 */ |
|
347 void RollbackAtomicL(); |
|
348 |
|
349 /** |
|
350 * Closes the connections to callback server and host servers. |
|
351 * Separate function is needed, since the disconnecting cannot |
|
352 * be made after the active scheduler of the thread is stopped. |
|
353 */ |
|
354 void DisconnectFromOtherServers(); |
|
355 |
|
356 // FOTA |
|
357 /** |
|
358 * When the generic alerts are successfully sent to the remote |
|
359 * server, the FOTA adapter needs to be informed about this. |
|
360 * This command is chained through the DM engine. |
|
361 */ |
|
362 void MarkGenAlertsSentL(); |
|
363 // FOTA end |
|
364 |
|
365 |
|
366 /* For 1.2 Any adapter can send the Generic adapter, |
|
367 Hence URI of adapter is passed |
|
368 */ |
|
369 void MarkGenAlertsSentL(const TDesC8& aURI); |
|
370 |
|
371 private: |
|
372 |
|
373 enum TUriCheck |
|
374 { |
|
375 EPassAdapter, |
|
376 EBeforeAdapter, |
|
377 EUriNotFound |
|
378 }; |
|
379 |
|
380 /** |
|
381 * Constructor |
|
382 */ |
|
383 CNSmlDmDDF(CNSmlDmModule& aDmModule); |
|
384 |
|
385 /** |
|
386 * Second phase constructor |
|
387 */ |
|
388 void ConstructL(); |
|
389 |
|
390 /** |
|
391 * Set the member variables point to correct plug-in adapter and correct |
|
392 * host server and gets the access type of node |
|
393 * @param aURI Target URI in command |
|
394 * @param aAccess Access type is written to this parameter |
|
395 * @return EPassAdapter,EBeforeAdapter or EUriNotFound |
|
396 */ |
|
397 TUriCheck CheckAdapterL(const TDesC8& aURI, TUint8 &aAccess); |
|
398 |
|
399 /** |
|
400 * Removes end and begin slashes from aObject |
|
401 * @param aObject Child list data from plug-in adapter |
|
402 */ |
|
403 void RemoveEndAndBeginSlashes(CBufBase& aObject) const; |
|
404 /** |
|
405 * Cleans array of delete elements and updates the add node |
|
406 * elements array |
|
407 * @param aStatusRef Reference information to status element |
|
408 * @param aErrorCode Status code from plug-in adapter |
|
409 */ |
|
410 void DeleteandAddStatusRefsL( TInt aStatusRef, |
|
411 MSmlDmAdapter::TError aErrorCode ); |
|
412 |
|
413 /** |
|
414 * Pointer to tree dtd |
|
415 */ |
|
416 CNSmlDmMgmtTree* iMgmtTree; |
|
417 |
|
418 /** |
|
419 * Reference to DM Module instance |
|
420 */ |
|
421 CNSmlDmModule& iDmModule; |
|
422 |
|
423 /** |
|
424 * Tree database client |
|
425 */ |
|
426 RNSmlDMCallbackSession iDbSession; |
|
427 |
|
428 |
|
429 /** |
|
430 * Array of result elements, used for cleaning the tree when result |
|
431 * is got from plug-in adapter |
|
432 */ |
|
433 RPointerArray<CNSmlCallbackElement> iResultRefs; |
|
434 |
|
435 /** |
|
436 * Array of delete elements, used for cleaning the tree when |
|
437 * succesfull delete is executed |
|
438 */ |
|
439 RPointerArray<CNSmlCallbackElement> iDeleteStatusRefs; |
|
440 |
|
441 /** |
|
442 * Array of add node elements, used for setting default acls to |
|
443 * node, if the current server does not have acces rigths to it |
|
444 */ |
|
445 RPointerArray<CNSmlCallbackElement> iAddNodeStatusRefs; |
|
446 |
|
447 /** |
|
448 * Id of current plug-in adapter |
|
449 */ |
|
450 TUint32 iAdapterId; |
|
451 |
|
452 /** |
|
453 * Id of current host session |
|
454 */ |
|
455 TUint8 iSessionId; |
|
456 |
|
457 /** |
|
458 * Id of current host session in case of getting large object |
|
459 */ |
|
460 TInt8 iResultSessionId; |
|
461 |
|
462 /** |
|
463 * Array of host sessions |
|
464 */ |
|
465 RArray<RNSmlDMDataSession> iSessionArray; |
|
466 |
|
467 /** |
|
468 * Status of host sessions |
|
469 */ |
|
470 TUint8 iOkSessions; |
|
471 |
|
472 /** |
|
473 * Reference of add commands |
|
474 * separated by commas |
|
475 */ |
|
476 HBufC8* iAddRootNodesList; |
|
477 }; |
|
478 |
|
479 |
|
480 |
|
481 // =========================================================================== |
|
482 // CNSmlDmLinkCallback |
|
483 // =========================================================================== |
|
484 /** |
|
485 * Class for overwriting the callback interface to caller. |
|
486 * In case of internal commands, the caller (agent) is not called, |
|
487 * this module is called instead |
|
488 * |
|
489 * @since |
|
490 */ |
|
491 class CNSmlDmLinkCallback : public CBase, public MNSmlDmModuleCallBack |
|
492 { |
|
493 public: |
|
494 |
|
495 /** |
|
496 * Destructor |
|
497 */ |
|
498 virtual ~CNSmlDmLinkCallback(); |
|
499 |
|
500 /** |
|
501 * Two-phased constructor. |
|
502 * @return Pointer to newly created module instance |
|
503 */ |
|
504 static CNSmlDmLinkCallback* NewL(); |
|
505 |
|
506 /** |
|
507 * The class is used in internal commands to overwrite the normal |
|
508 * callback interface. This methos overwrites the normal |
|
509 * SetResultsL function |
|
510 * @param aResultsRef Reference to result element |
|
511 * @param aObject Data |
|
512 * @param aType Mime type |
|
513 * @param aFormat Format of the object |
|
514 * @param aTotalSize Total size |
|
515 */ |
|
516 void SetResultsL( TInt aResultsRef, const CBufBase& aObject, |
|
517 const TDesC8& aType, const TDesC8& aFormat,TInt aTotalSize ); |
|
518 |
|
519 /** |
|
520 * The class is used in internal commands to overwrite the normal |
|
521 * callback interface. This methos overwrites the normal |
|
522 * SetStatuslL function |
|
523 * @param aStatusRef Reference to result element |
|
524 * @param aStatusCode Status of command |
|
525 */ |
|
526 void SetStatusL( TInt aStatusRef, TInt aStatusCode ); |
|
527 |
|
528 /** |
|
529 * Gets the result |
|
530 * @param aData Reference to the data buffer, where to |
|
531 * write result data |
|
532 * @param aStatus Reference to status info wher to write |
|
533 * the status of command execution |
|
534 */ |
|
535 void GetResultsL( CBufBase*& aData, CSmlDmAdapter::TError& aStatus ); |
|
536 |
|
537 /** |
|
538 * Gets the status |
|
539 * @return Status code |
|
540 */ |
|
541 TInt GetStatusL(); |
|
542 |
|
543 private: |
|
544 /** |
|
545 * Constructor |
|
546 */ |
|
547 CNSmlDmLinkCallback(); |
|
548 |
|
549 private: |
|
550 /** |
|
551 * Status code |
|
552 */ |
|
553 TInt iStatus; |
|
554 |
|
555 /** |
|
556 * Result |
|
557 */ |
|
558 CBufBase *iResults; |
|
559 }; |
|
560 |
|
561 #endif // __NSMLDMDDF_H |