|
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 Utilities |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "nsmldmtreedtd.h" |
|
20 #include <nsmldmuri.h> |
|
21 #include <s32file.h> |
|
22 #include <featmgr.h> |
|
23 |
|
24 // =========================================================================== |
|
25 // CNSmlDmPcdata |
|
26 // =========================================================================== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CNSmlDmPcdata::CNSmlDmPcdata() |
|
30 // --------------------------------------------------------------------------- |
|
31 CNSmlDmPcdata::CNSmlDmPcdata() |
|
32 { |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CNSmlDmPcdata::~CNSmlDmPcdata() |
|
37 // --------------------------------------------------------------------------- |
|
38 CNSmlDmPcdata::~CNSmlDmPcdata() |
|
39 { |
|
40 FreeContent(); |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CNSmlDmPcdata::FreeContent() |
|
45 // Free the content of pcdata element |
|
46 // --------------------------------------------------------------------------- |
|
47 void CNSmlDmPcdata::FreeContent() |
|
48 { |
|
49 delete iContent; |
|
50 iContent = 0; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CNSmlDmPcdata::DataL() |
|
55 // fill the pc data element |
|
56 // --------------------------------------------------------------------------- |
|
57 void CNSmlDmPcdata::DataL( const TDesC8& aData ) |
|
58 { |
|
59 iLength = aData.Length(); |
|
60 iContent = User::AllocL(iLength); |
|
61 Mem::Copy(iContent, aData.Ptr(), iLength); |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CNSmlDmPcdata::Compare() |
|
67 // compare content of pcdata element to aStr |
|
68 // --------------------------------------------------------------------------- |
|
69 TBool CNSmlDmPcdata::Compare(const TUint8* aStr, TInt aLength) |
|
70 { |
|
71 if(iLength!=aLength) |
|
72 { |
|
73 return EFalse; |
|
74 } |
|
75 |
|
76 for(TInt i=0;i<iLength;i++) |
|
77 { |
|
78 if(((TUint8*)iContent)[i]!=aStr[i]) |
|
79 { |
|
80 return EFalse; |
|
81 } |
|
82 } |
|
83 return ETrue; |
|
84 } |
|
85 |
|
86 // =========================================================================== |
|
87 // CNSmlDmNode |
|
88 // =========================================================================== |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CNSmlDmNode::CNSmlDmNode() |
|
92 // --------------------------------------------------------------------------- |
|
93 CNSmlDmNode::CNSmlDmNode() |
|
94 { |
|
95 iDFProperties.iCaseSense=ETrue; |
|
96 } |
|
97 |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CNSmlDmNode::~CNSmlDmNode() |
|
101 // --------------------------------------------------------------------------- |
|
102 CNSmlDmNode::~CNSmlDmNode() |
|
103 { |
|
104 delete iPath; |
|
105 delete iRTProperties; |
|
106 delete iValue; |
|
107 |
|
108 CNSmlDmNodeList* ptr = iNodeListPtr; |
|
109 while(iNodeListPtr!=0) |
|
110 { |
|
111 delete iNodeListPtr->iNode; |
|
112 iNodeListPtr = iNodeListPtr->iNext; |
|
113 delete ptr; |
|
114 ptr = iNodeListPtr; |
|
115 } |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CNSmlDmNode::SetAccessTypesL( TSmlDmAccessTypes aAccessTypes ) |
|
120 // set accestypes of node to ddf |
|
121 // --------------------------------------------------------------------------- |
|
122 void CNSmlDmNode::SetAccessTypesL( TSmlDmAccessTypes aAccessTypes ) |
|
123 { |
|
124 iDFProperties.iAccessTypes = aAccessTypes.GetACL(); |
|
125 } |
|
126 |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CNSmlDmNode::SetDefaultValueL( const TDesC8& aDefaultValue ) |
|
130 // Set default value of node to ddf |
|
131 // --------------------------------------------------------------------------- |
|
132 void CNSmlDmNode::SetDefaultValueL( const TDesC8& aDefaultValue ) |
|
133 { |
|
134 if(iDFProperties.iDefaultValue!=0) |
|
135 { |
|
136 delete iDFProperties.iDefaultValue; |
|
137 iDFProperties.iDefaultValue=0; |
|
138 } |
|
139 iDFProperties.iDefaultValue = new (ELeave) CNSmlDmPcdata(); |
|
140 iDFProperties.iDefaultValue->DataL(aDefaultValue); |
|
141 } |
|
142 |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CNSmlDmNode::SetDescriptionL( const TDesC8& aDescription ) |
|
146 // Set description of node to ddf |
|
147 // --------------------------------------------------------------------------- |
|
148 void CNSmlDmNode::SetDescriptionL( const TDesC8& aDescription ) |
|
149 { |
|
150 if(iDFProperties.iDescription!=0) |
|
151 { |
|
152 delete iDFProperties.iDescription; |
|
153 iDFProperties.iDescription=0; |
|
154 } |
|
155 iDFProperties.iDescription = new (ELeave) CNSmlDmPcdata(); |
|
156 iDFProperties.iDescription->DataL(aDescription); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CNSmlDmNode::SetDFFormatL( TDFFormat aFormat ) |
|
161 // set dfformat of node to ddf |
|
162 // --------------------------------------------------------------------------- |
|
163 void CNSmlDmNode::SetDFFormatL( TDFFormat aFormat ) |
|
164 { |
|
165 iDFProperties.iDFFormat = aFormat; |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CNSmlDmNode::SetOccurenceL( TOccurence aOccurence ) |
|
170 // set occurrence of node to ddf |
|
171 // --------------------------------------------------------------------------- |
|
172 void CNSmlDmNode::SetOccurenceL( TOccurence aOccurence ) |
|
173 { |
|
174 iDFProperties.iOccurrence = aOccurence; |
|
175 } |
|
176 |
|
177 |
|
178 void CNSmlDmNode::SetCaseSenseL( TBool aCaseSense ) |
|
179 { |
|
180 iDFProperties.iCaseSense = aCaseSense; |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CNSmlDmNode::SetScopeL( TScope aScope ) |
|
185 // set scope of node to ddf |
|
186 // --------------------------------------------------------------------------- |
|
187 void CNSmlDmNode::SetScopeL( TScope aScope ) |
|
188 { |
|
189 iDFProperties.iScope = aScope; |
|
190 } |
|
191 |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CNSmlDmNode::SetDFTitleL( const TDesC8& aDescription ) |
|
195 // set dftitle of node to ddf |
|
196 // --------------------------------------------------------------------------- |
|
197 void CNSmlDmNode::SetDFTitleL( const TDesC8& /*aDescription*/ ) |
|
198 { |
|
199 } |
|
200 |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // CNSmlDmNode::AddDFTypeMimeTypeL( const TDesC8& aMimeType ) |
|
204 // set mimetype of node to ddf |
|
205 // --------------------------------------------------------------------------- |
|
206 void CNSmlDmNode::AddDFTypeMimeTypeL( const TDesC8& aMimeType ) |
|
207 { |
|
208 if(iDFProperties.iDFType!=0) |
|
209 { |
|
210 delete iDFProperties.iDFType; |
|
211 iDFProperties.iDFType=0; |
|
212 } |
|
213 iDFProperties.iDFType = new (ELeave) CNSmlDmPcdata(); |
|
214 iDFProperties.iDFType->DataL(aMimeType); |
|
215 } |
|
216 |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CNSmlDmNode::SetAsObjectGroup() |
|
220 // se as object group, adapter level is the last objectgroup level |
|
221 // --------------------------------------------------------------------------- |
|
222 void CNSmlDmNode::SetAsObjectGroup() |
|
223 { |
|
224 } |
|
225 |
|
226 |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CNSmlDmNode::AddChildObjectL( const TDesC8& aNodeName ) |
|
230 // Add child object for the node |
|
231 // --------------------------------------------------------------------------- |
|
232 MSmlDmDDFObject& CNSmlDmNode::AddChildObjectL( const TDesC8& aNodeName ) |
|
233 { |
|
234 CNSmlDmNode* newNode; |
|
235 |
|
236 if ( iNodeListPtr == 0 ) |
|
237 { |
|
238 newNode = new (ELeave) CNSmlDmNode(); |
|
239 CleanupStack::PushL(newNode); |
|
240 newNode->iParent = this; |
|
241 iNodeListPtr = new (ELeave) CNSmlDmNodeList(); |
|
242 CleanupStack::Pop(); // newNode |
|
243 iNodeListPtr->iNext = 0; |
|
244 iNodeListPtr->iNode = newNode; |
|
245 if(iStaticLevel) |
|
246 { |
|
247 newNode->iStaticLevel=ETrue; |
|
248 } |
|
249 newNode->iNodeName.DataL(aNodeName); |
|
250 } |
|
251 else |
|
252 { |
|
253 CNSmlDmNodeList* tmpNode = iNodeListPtr; |
|
254 CNSmlDmNodeList* tmpNodePrev = iNodeListPtr; |
|
255 TBool found=EFalse; |
|
256 |
|
257 //check if same nodename already exists |
|
258 while(tmpNode!=0) |
|
259 { |
|
260 if(tmpNode->iNode->iNodeName.Compare( aNodeName.Ptr(), |
|
261 aNodeName.Length() ) ) |
|
262 { |
|
263 found = ETrue; |
|
264 break; |
|
265 } |
|
266 tmpNodePrev = tmpNode; |
|
267 tmpNode = tmpNode->iNext; |
|
268 } |
|
269 |
|
270 if(found) |
|
271 { |
|
272 //nodename already exist, new node is not created and pointer |
|
273 //to existing is returned |
|
274 newNode = tmpNode->iNode; |
|
275 } |
|
276 else |
|
277 { |
|
278 tmpNodePrev->iNext = new (ELeave) CNSmlDmNodeList(); |
|
279 newNode = new (ELeave) CNSmlDmNode(); |
|
280 newNode->iParent = this; |
|
281 tmpNode = tmpNodePrev->iNext; |
|
282 tmpNode->iNext = 0; |
|
283 tmpNode->iNode = newNode; |
|
284 if(iStaticLevel) |
|
285 { |
|
286 newNode->iStaticLevel=ETrue; |
|
287 } |
|
288 newNode->iNodeName.DataL( aNodeName ); |
|
289 } |
|
290 } |
|
291 return *newNode; |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // CNSmlDmNode::AddChildObjectGroupL() |
|
296 // Adds nameless child to node |
|
297 // --------------------------------------------------------------------------- |
|
298 MSmlDmDDFObject& CNSmlDmNode::AddChildObjectGroupL() |
|
299 { |
|
300 CNSmlDmNode* newNode = 0; |
|
301 |
|
302 if(iNodeListPtr==0) |
|
303 { |
|
304 newNode = new (ELeave) CNSmlDmNode(); |
|
305 CleanupStack::PushL(newNode); |
|
306 newNode->iParent = this; |
|
307 iNodeListPtr = new (ELeave) CNSmlDmNodeList(); |
|
308 iNodeListPtr->iNext = 0; |
|
309 iNodeListPtr->iNode = newNode; |
|
310 CleanupStack::Pop(); //newNode |
|
311 |
|
312 newNode->iNodeName.DataL(KNullDesC8); |
|
313 } |
|
314 else |
|
315 { |
|
316 User::Leave(KErrAlreadyExists); |
|
317 } |
|
318 |
|
319 return *newNode; |
|
320 } |
|
321 |
|
322 // =========================================================================== |
|
323 // CNSmlDmNodeList |
|
324 // =========================================================================== |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // CNSmlDmNodeList::CNSmlDmNodeList() |
|
328 // --------------------------------------------------------------------------- |
|
329 CNSmlDmNodeList::CNSmlDmNodeList() |
|
330 { |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // CNSmlDmNodeList::GetImplUid() |
|
335 // return implementation uid of adapter |
|
336 // --------------------------------------------------------------------------- |
|
337 EXPORT_C void CNSmlDmNodeList::GetImplUid(TUint32& aImplUid, |
|
338 TUint8& aSessionId) |
|
339 { |
|
340 CNSmlDmNode* nodePtr = this->iNode; |
|
341 while(nodePtr!=0) |
|
342 { |
|
343 if(nodePtr->iImplUid!=0) |
|
344 { |
|
345 aImplUid=nodePtr->iImplUid; |
|
346 aSessionId=nodePtr->iHostServerId; |
|
347 return; |
|
348 } |
|
349 nodePtr=nodePtr->iParent; |
|
350 } |
|
351 aImplUid=0; |
|
352 aSessionId=0; |
|
353 } |
|
354 |
|
355 |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // CNSmlDmNodeList::GenerateNodeListL(CBufBase& aObject) |
|
359 // generate xml |
|
360 // --------------------------------------------------------------------------- |
|
361 void CNSmlDmNodeList::GenerateNodeListL(CBufBase& aObject) |
|
362 { |
|
363 CNSmlDmNodeList* listPtr = this; |
|
364 while(listPtr!=0) |
|
365 { |
|
366 |
|
367 CNSmlDmNode* nodePtr = listPtr->iNode; |
|
368 aObject.InsertL(aObject.Size(),KNSmlDDFNode); |
|
369 aObject.InsertL(aObject.Size(),KNSmlDDFNodeName); |
|
370 aObject.InsertL(aObject.Size(),nodePtr->iNodeName.iContent, |
|
371 nodePtr->iNodeName.iLength); |
|
372 |
|
373 aObject.InsertL(aObject.Size(),KNSmlDDFNodeNameEnd); |
|
374 |
|
375 if(nodePtr->iPath!=0) |
|
376 { |
|
377 aObject.InsertL(aObject.Size(),KNSmlDDFPath); |
|
378 aObject.InsertL(aObject.Size(),nodePtr->iPath->iContent, |
|
379 nodePtr->iPath->iLength); |
|
380 aObject.InsertL(aObject.Size(),KNSmlDDFPathEnd); |
|
381 } |
|
382 nodePtr->iDFProperties.GenerateDFPropertiesL(aObject); |
|
383 |
|
384 if(nodePtr->iNodeListPtr!=0) |
|
385 { |
|
386 nodePtr->iNodeListPtr->GenerateNodeListL(aObject); |
|
387 } |
|
388 else |
|
389 { |
|
390 if(nodePtr->iValue!=0) |
|
391 { |
|
392 aObject.InsertL(aObject.Size(),KNSmlDDFValue); |
|
393 aObject.InsertL(aObject.Size(),nodePtr->iValue->iContent, |
|
394 nodePtr->iValue->iLength); |
|
395 aObject.InsertL(aObject.Size(),KNSmlDDFValueEnd); |
|
396 } |
|
397 |
|
398 } |
|
399 aObject.InsertL(aObject.Size(),KNSmlDDFNodeEnd); |
|
400 listPtr = listPtr->iNext; |
|
401 } |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // CNSmlDmNodeList::GenerateNodeListWBXMLL(TPtr8& aObject) |
|
406 // generate wbxml |
|
407 // --------------------------------------------------------------------------- |
|
408 void CNSmlDmNodeList::GenerateNodeListWBXMLL(RWriteStream& aStream) |
|
409 { |
|
410 CNSmlDmNodeList* listPtr = this; |
|
411 while(listPtr!=0) |
|
412 { |
|
413 CNSmlDmNode* nodePtr = listPtr->iNode; |
|
414 aStream.WriteUint8L(EDDFNode); |
|
415 // Add the iObjectGroup field |
|
416 aStream.WriteUint8L(EDDFStaticLevel); |
|
417 aStream.WriteUint8L(nodePtr->iStaticLevel); |
|
418 aStream.WriteUint8L(EDDFStaticLevelEnd); |
|
419 aStream.WriteUint8L(EDDFAdapterUid); |
|
420 aStream.WriteUint32L(nodePtr->iImplUid); |
|
421 aStream.WriteUint8L(EDDFAdapterUidEnd); |
|
422 aStream.WriteUint8L(EDDFHostServerId); |
|
423 aStream.WriteUint8L(nodePtr->iHostServerId); |
|
424 aStream.WriteUint8L(EDDFHostServerIdEnd); |
|
425 aStream.WriteUint8L(EDDFNodeName); |
|
426 aStream.WriteUint8L(nodePtr->iNodeName.iLength); |
|
427 |
|
428 aStream.WriteL(static_cast<TUint8*>(nodePtr->iNodeName.iContent), |
|
429 nodePtr->iNodeName.iLength); |
|
430 |
|
431 aStream.WriteUint8L(EDDFNodeNameEnd); |
|
432 //Path is not added |
|
433 nodePtr->iDFProperties.GenerateDFPropertiesWBXMLL(aStream); |
|
434 |
|
435 if(nodePtr->iNodeListPtr!=0) |
|
436 { |
|
437 nodePtr->iNodeListPtr->GenerateNodeListWBXMLL(aStream); |
|
438 } |
|
439 else |
|
440 { |
|
441 if(nodePtr->iValue!=0) |
|
442 { |
|
443 aStream.WriteUint8L(EDDFValue); |
|
444 aStream.WriteUint8L(nodePtr->iValue->iLength); |
|
445 aStream.WriteL(static_cast<TUint8*>(nodePtr->iValue->iContent), |
|
446 nodePtr->iValue->iLength); |
|
447 aStream.WriteUint8L(TChar(EDDFValueEnd)); |
|
448 } |
|
449 } |
|
450 aStream.WriteUint8L(EDDFNodeEnd); |
|
451 listPtr = listPtr->iNext; |
|
452 } |
|
453 } |
|
454 |
|
455 |
|
456 |
|
457 // --------------------------------------------------------------------------- |
|
458 // CNSmlDmNodeList::ParseNodeListWBXMLL(TPtr8& aObject) |
|
459 // Parse nodelist from wbxml to structure |
|
460 // --------------------------------------------------------------------------- |
|
461 TUint CNSmlDmNodeList::ParseNodeListWBXMLL(RReadStream& aReader, |
|
462 CNSmlDmNodeList*& aNodeListPtr, CNSmlDmNode* aParent) |
|
463 { |
|
464 CNSmlDmNode* newNode = NULL; |
|
465 TUint tag = 0; |
|
466 CNSmlDmNodeList* lastInList = NULL; |
|
467 |
|
468 // read node tag |
|
469 tag = aReader.ReadUint8L(); |
|
470 if (tag == EDDFNode ) |
|
471 { |
|
472 newNode = new (ELeave) CNSmlDmNode(); |
|
473 newNode->iParent= aParent; |
|
474 aNodeListPtr->iNode = newNode; |
|
475 lastInList=aNodeListPtr; |
|
476 |
|
477 ParseNodeWBXMLL( aReader, newNode ); |
|
478 newNode = NULL; |
|
479 } |
|
480 else |
|
481 { |
|
482 delete aNodeListPtr; |
|
483 aNodeListPtr = NULL; |
|
484 return tag; |
|
485 } |
|
486 |
|
487 // read next tag ( EDDFNode | EDDFNodeEnd ) |
|
488 tag = aReader.ReadUint8L(); |
|
489 __ASSERT_DEBUG(((tag == EDDFNode) || (tag == EDDFNodeEnd)|| |
|
490 (tag == EDDFMgmtTreeEnd)), |
|
491 User::Panic(_L("ParseNodeListWBXMLL: unknown tag: "),tag)); |
|
492 |
|
493 while ( tag == EDDFNode) |
|
494 { |
|
495 lastInList->iNext = new (ELeave) CNSmlDmNodeList(); |
|
496 lastInList=lastInList->iNext; |
|
497 |
|
498 newNode = new (ELeave) CNSmlDmNode(); |
|
499 newNode->iParent= aParent; |
|
500 lastInList->iNode = newNode; |
|
501 |
|
502 lastInList->ParseNodeWBXMLL( aReader, newNode ); |
|
503 |
|
504 // read next tag |
|
505 tag = aReader.ReadUint8L(); |
|
506 } |
|
507 return tag; |
|
508 } |
|
509 |
|
510 |
|
511 // --------------------------------------------------------------------------- |
|
512 // CNSmlDmNodeList::ParseNodeWBXMLL(TPtr8& aObject) |
|
513 // Parse node from wbxml to structure |
|
514 // --------------------------------------------------------------------------- |
|
515 void CNSmlDmNodeList::ParseNodeWBXMLL(RReadStream& aReader,CNSmlDmNode* aNode ) |
|
516 { |
|
517 HBufC8* data; |
|
518 TUint tag = 0; |
|
519 |
|
520 //EDDFStaticLevel tag |
|
521 tag = aReader.ReadUint8L(); |
|
522 aNode->iStaticLevel = aReader.ReadUint8L(); |
|
523 tag = aReader.ReadUint8L(); |
|
524 |
|
525 //EDDFAdapterUid tag |
|
526 tag = aReader.ReadUint8L(); |
|
527 aNode->iImplUid = aReader.ReadUint32L(); |
|
528 tag = aReader.ReadUint8L(); |
|
529 |
|
530 //EDDFHostServerId tag |
|
531 tag = aReader.ReadUint8L(); |
|
532 aNode->iHostServerId = aReader.ReadUint8L(); |
|
533 tag = aReader.ReadUint8L(); |
|
534 |
|
535 // nodename tag |
|
536 tag = aReader.ReadUint8L(); |
|
537 |
|
538 // read nodename length |
|
539 TUint8 len = aReader.ReadUint8L(); |
|
540 if ( len != 0 ) |
|
541 { |
|
542 data = HBufC8::NewLC( len ); |
|
543 TPtr8 dataPtr = data->Des(); |
|
544 // ..and nodename |
|
545 aReader.ReadL(dataPtr, len); |
|
546 aNode->iNodeName.DataL(dataPtr); |
|
547 CleanupStack::PopAndDestroy(); |
|
548 } |
|
549 |
|
550 // end nodename |
|
551 tag = aReader.ReadUint8L(); |
|
552 |
|
553 // read next tag |
|
554 tag = aReader.ReadUint8L(); |
|
555 __ASSERT_DEBUG( tag == EDDFDFProperties, |
|
556 User::Panic(_L("ParseNodeWBXMLL: wrong tag: "),tag)); |
|
557 |
|
558 // Path is not added to data |
|
559 ParseDFPropertiesWBXMLL( aReader, aNode ); |
|
560 |
|
561 |
|
562 if ( aNode->iNodeListPtr == NULL ) |
|
563 { |
|
564 aNode->iNodeListPtr = new (ELeave) CNSmlDmNodeList(); |
|
565 tag = ParseNodeListWBXMLL(aReader, aNode->iNodeListPtr, aNode); |
|
566 } |
|
567 |
|
568 if (tag == EDDFValue ) |
|
569 { |
|
570 // value length |
|
571 len = aReader.ReadUint8L(); |
|
572 // value data |
|
573 data = HBufC8::NewLC( len ); |
|
574 TPtr8 dataPtr = data->Des(); |
|
575 aReader.ReadL(dataPtr, len); |
|
576 // store the data |
|
577 aNode->iValue->DataL(dataPtr); |
|
578 // end value tag |
|
579 tag = aReader.ReadUint8L(); |
|
580 CleanupStack::PopAndDestroy(); // data |
|
581 } |
|
582 } |
|
583 |
|
584 // =========================================================================== |
|
585 // CNSmlDmMgmtTree |
|
586 // =========================================================================== |
|
587 |
|
588 // --------------------------------------------------------------------------- |
|
589 // CNSmlDmMgmtTree::NewL() |
|
590 // --------------------------------------------------------------------------- |
|
591 EXPORT_C CNSmlDmMgmtTree* CNSmlDmMgmtTree::NewL() |
|
592 { |
|
593 CNSmlDmMgmtTree* self = new (ELeave) CNSmlDmMgmtTree(); |
|
594 CleanupStack::PushL(self); |
|
595 self->ConstructL(); |
|
596 CleanupStack::Pop(); |
|
597 return self; |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------------------------- |
|
601 // CNSmlDmMgmtTree::ConstructL() |
|
602 // --------------------------------------------------------------------------- |
|
603 void CNSmlDmMgmtTree::ConstructL() |
|
604 { |
|
605 iNodeListPtr = 0; |
|
606 iVerDTD.DataL ( KNSmlDmTreeDTDVersion ); |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // CNSmlDmMgmtTree::CNSmlDmMgmtTree() |
|
611 // --------------------------------------------------------------------------- |
|
612 CNSmlDmMgmtTree::CNSmlDmMgmtTree() |
|
613 { |
|
614 } |
|
615 |
|
616 |
|
617 // --------------------------------------------------------------------------- |
|
618 // CNSmlDmMgmtTree::~CNSmlDmMgmtTree() |
|
619 // --------------------------------------------------------------------------- |
|
620 CNSmlDmMgmtTree::~CNSmlDmMgmtTree() |
|
621 { |
|
622 CNSmlDmNodeList* ptr = iNodeListPtr; |
|
623 while(iNodeListPtr!=0) |
|
624 { |
|
625 delete iNodeListPtr->iNode; |
|
626 iNodeListPtr = iNodeListPtr->iNext; |
|
627 delete ptr; |
|
628 ptr = iNodeListPtr; |
|
629 } |
|
630 } |
|
631 |
|
632 |
|
633 // --------------------------------------------------------------------------- |
|
634 // CNSmlDmMgmtTree::SetAccessTypesL( TSmlDmAccessTypes aAccessTypes ) |
|
635 // set accestypes for root node |
|
636 // --------------------------------------------------------------------------- |
|
637 void CNSmlDmMgmtTree::SetAccessTypesL( TSmlDmAccessTypes /*aAccessTypes*/ ) |
|
638 { |
|
639 //root node cannot be changed |
|
640 } |
|
641 |
|
642 |
|
643 |
|
644 // --------------------------------------------------------------------------- |
|
645 // CNSmlDmMgmtTree::SetDefaultValueL( const TDesC8& aDefaultValue ) |
|
646 // --------------------------------------------------------------------------- |
|
647 void CNSmlDmMgmtTree::SetDefaultValueL( const TDesC8& /*aDefaultValue*/ ) |
|
648 { |
|
649 //root node cannot be changed |
|
650 } |
|
651 |
|
652 |
|
653 // --------------------------------------------------------------------------- |
|
654 // CNSmlDmMgmtTree::SetDescriptionL( const TDesC8& aDescription ) |
|
655 // --------------------------------------------------------------------------- |
|
656 void CNSmlDmMgmtTree::SetDescriptionL( const TDesC8& /*aDescription*/ ) |
|
657 { |
|
658 //root node cannot be changed |
|
659 } |
|
660 |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 // --------------------------------------------------------------------------- |
|
664 void CNSmlDmMgmtTree::SetDFFormatL( TDFFormat /*aFormat*/ ) |
|
665 { |
|
666 //root node cannot be changed |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // CNSmlDmMgmtTree::SetOccurenceL( TOccurence aOccurence ) |
|
671 // --------------------------------------------------------------------------- |
|
672 void CNSmlDmMgmtTree::SetOccurenceL( TOccurence /*aOccurence*/ ) |
|
673 { |
|
674 //root node cannot be changed |
|
675 } |
|
676 |
|
677 // --------------------------------------------------------------------------- |
|
678 // CNSmlDmMgmtTree::SetScopeL( TScope aScope ) |
|
679 // --------------------------------------------------------------------------- |
|
680 void CNSmlDmMgmtTree::SetScopeL( TScope /*aScope*/ ) |
|
681 { |
|
682 //root node cannot be changed |
|
683 } |
|
684 |
|
685 |
|
686 // --------------------------------------------------------------------------- |
|
687 // CNSmlDmMgmtTree::SetDFTitleL( const TDesC8& aTitle ) |
|
688 // --------------------------------------------------------------------------- |
|
689 void CNSmlDmMgmtTree::SetDFTitleL( const TDesC8& /*aTitle*/ ) |
|
690 { |
|
691 //root node cannot be changed |
|
692 } |
|
693 |
|
694 |
|
695 // --------------------------------------------------------------------------- |
|
696 // CNSmlDmMgmtTree::AddDFTypeMimeTypeL( const TDesC8& aMimeType ) |
|
697 // --------------------------------------------------------------------------- |
|
698 void CNSmlDmMgmtTree::AddDFTypeMimeTypeL( const TDesC8& /*aMimeType*/ ) |
|
699 { |
|
700 //root node cannot be changed |
|
701 } |
|
702 |
|
703 |
|
704 // --------------------------------------------------------------------------- |
|
705 // CNSmlDmMgmtTree::SetAsObjectGroup() |
|
706 // --------------------------------------------------------------------------- |
|
707 void CNSmlDmMgmtTree::SetAsObjectGroup() |
|
708 { |
|
709 //root node cannot be changed |
|
710 } |
|
711 |
|
712 |
|
713 |
|
714 // --------------------------------------------------------------------------- |
|
715 // CNSmlDmMgmtTree::AddChildObjectL(const TDesC8& aNodeName) |
|
716 // add child under root node |
|
717 // --------------------------------------------------------------------------- |
|
718 MSmlDmDDFObject& CNSmlDmMgmtTree::AddChildObjectL(const TDesC8& aNodeName) |
|
719 { |
|
720 CNSmlDmNode* newNode; |
|
721 |
|
722 if(iNodeListPtr==0) |
|
723 { |
|
724 newNode = new (ELeave) CNSmlDmNode(); |
|
725 CleanupStack::PushL(newNode); |
|
726 iNodeListPtr = new (ELeave) CNSmlDmNodeList(); |
|
727 CleanupStack::Pop(); // newNode |
|
728 iNodeListPtr->iNext = 0; |
|
729 iNodeListPtr->iNode = newNode; |
|
730 newNode->iStaticLevel=ETrue; |
|
731 newNode->iNodeName.DataL(aNodeName); |
|
732 } |
|
733 else |
|
734 { |
|
735 CNSmlDmNodeList* tmpNode = iNodeListPtr; |
|
736 CNSmlDmNodeList* tmpNodePrev = iNodeListPtr; |
|
737 TBool found=EFalse; |
|
738 |
|
739 //check if nodename already exists |
|
740 while(tmpNode!=0) |
|
741 { |
|
742 if(tmpNode->iNode->iNodeName.Compare ( aNodeName.Ptr(), |
|
743 aNodeName.Length() ) ) |
|
744 { |
|
745 found = ETrue; |
|
746 break; |
|
747 } |
|
748 tmpNodePrev = tmpNode; |
|
749 tmpNode = tmpNode->iNext; |
|
750 } |
|
751 |
|
752 if(found) |
|
753 { |
|
754 //nodename already exist, new node is not created and pointer |
|
755 //to existing is returned |
|
756 newNode = tmpNode->iNode; |
|
757 } |
|
758 else |
|
759 { |
|
760 //create new node |
|
761 tmpNodePrev->iNext = new (ELeave) CNSmlDmNodeList(); |
|
762 newNode = new (ELeave) CNSmlDmNode(); |
|
763 tmpNode = tmpNodePrev->iNext; |
|
764 tmpNode->iNext = 0; |
|
765 tmpNode->iNode = newNode; |
|
766 newNode->iStaticLevel=ETrue; |
|
767 newNode->iNodeName.DataL(aNodeName); |
|
768 } |
|
769 } |
|
770 return *newNode; |
|
771 } |
|
772 |
|
773 // --------------------------------------------------------------------------- |
|
774 // CNSmlDmMgmtTree::AddChildObjectGroupL() |
|
775 // add child under root node |
|
776 // --------------------------------------------------------------------------- |
|
777 |
|
778 MSmlDmDDFObject& CNSmlDmMgmtTree::AddChildObjectGroupL() |
|
779 { |
|
780 User::Leave(KErrAccessDenied); |
|
781 CNSmlDmNode* newNode=0; |
|
782 return *newNode; |
|
783 } |
|
784 |
|
785 // --------------------------------------------------------------------------- |
|
786 // CNSmlDmMgmtTree::GenerateXMLL(CBufBase& aObject) |
|
787 // Generate xml from ddf structure |
|
788 // --------------------------------------------------------------------------- |
|
789 EXPORT_C void CNSmlDmMgmtTree::GenerateXMLL(CBufBase& aObject) |
|
790 { |
|
791 CBufBase* man = CBufFlat::NewL(8); |
|
792 CleanupStack::PushL(man); |
|
793 CBufBase* mod = CBufFlat::NewL(8); |
|
794 CleanupStack::PushL(mod); |
|
795 |
|
796 aObject.InsertL(aObject.Size(),KNSmlDDFMgmtTree); |
|
797 aObject.InsertL(aObject.Size(),KNSmlDDFVerDTD); |
|
798 aObject.InsertL(aObject.Size(),iVerDTD.iContent, iVerDTD.iLength ); |
|
799 aObject.InsertL(aObject.Size(),KNSmlDDFVerDTDEnd); |
|
800 |
|
801 //man |
|
802 aObject.InsertL(aObject.Size(),KNSmlDDFMan); |
|
803 aObject.InsertL(aObject.Size(),man->Ptr(0)); |
|
804 aObject.InsertL(aObject.Size(),KNSmlDDFManEnd); |
|
805 |
|
806 //mod |
|
807 aObject.InsertL(aObject.Size(),KNSmlDDFMod); |
|
808 aObject.InsertL(aObject.Size(),mod->Ptr(0)); |
|
809 aObject.InsertL(aObject.Size(),KNSmlDDFModEnd); |
|
810 CleanupStack::PopAndDestroy(2); //man,mod |
|
811 |
|
812 if(iNodeListPtr!=0) |
|
813 { |
|
814 iNodeListPtr->GenerateNodeListL(aObject); |
|
815 } |
|
816 aObject.InsertL(aObject.Size(),KNSmlDDFMgmtTreeEnd); |
|
817 } |
|
818 |
|
819 // --------------------------------------------------------------------------- |
|
820 // CNSmlDmMgmtTree::GenerateWBXMLL(CBufBase& aObject) |
|
821 // Generate wbxml from ddf structure |
|
822 // --------------------------------------------------------------------------- |
|
823 EXPORT_C void CNSmlDmMgmtTree::GenerateWBXMLL(RWriteStream& aStream) |
|
824 { |
|
825 aStream.WriteUint8L(EDDFMgmtTree); |
|
826 aStream.WriteUint8L(EDDFVerDTD); |
|
827 aStream.WriteUint8L(iVerDTD.iLength); |
|
828 aStream.WriteL(static_cast<TUint8*>(iVerDTD.iContent), iVerDTD.iLength); |
|
829 aStream.WriteUint8L(EDDFVerDTDEnd); |
|
830 |
|
831 if(iNodeListPtr!=0) |
|
832 { |
|
833 iNodeListPtr->GenerateNodeListWBXMLL(aStream); |
|
834 } |
|
835 |
|
836 aStream.WriteUint8L(EDDFMgmtTreeEnd); |
|
837 } |
|
838 |
|
839 // --------------------------------------------------------------------------- |
|
840 // CNSmlDmMgmtTree::ParseWBXMLL(CBufBase& aObject) |
|
841 // Parse wbxml to ddf structure |
|
842 // --------------------------------------------------------------------------- |
|
843 EXPORT_C void CNSmlDmMgmtTree::ParseWBXMLL(RReadStream& aReader) |
|
844 { |
|
845 //Mgmttree; ignore |
|
846 aReader.ReadUint8L(); |
|
847 //VerDTD; ignore |
|
848 aReader.ReadUint8L(); |
|
849 // verDTD length |
|
850 TInt len = aReader.ReadUint8L(); |
|
851 // ..and value |
|
852 //TDes8& aDes |
|
853 HBufC8* verData = HBufC8::NewLC( len ); |
|
854 TPtr8 verDataPtr = verData->Des(); |
|
855 aReader.ReadL(verDataPtr, len); |
|
856 //Append the verDTD to new DDF |
|
857 CleanupStack::PopAndDestroy(); //verData |
|
858 // end verDTD, ignore |
|
859 aReader.ReadUint8L(); |
|
860 |
|
861 |
|
862 CNSmlDmNodeList* nodeListPtr; |
|
863 TBool first=EFalse; |
|
864 |
|
865 if(iNodeListPtr==0) |
|
866 { |
|
867 iNodeListPtr = new (ELeave) CNSmlDmNodeList(); |
|
868 nodeListPtr=iNodeListPtr; |
|
869 first=ETrue; |
|
870 } |
|
871 else |
|
872 { |
|
873 nodeListPtr=iNodeListPtr; |
|
874 while(nodeListPtr->iNext) |
|
875 { |
|
876 nodeListPtr=nodeListPtr->iNext; |
|
877 } |
|
878 nodeListPtr->iNext = new (ELeave) CNSmlDmNodeList(); |
|
879 } |
|
880 if(first) |
|
881 { |
|
882 iNodeListPtr->ParseNodeListWBXMLL(aReader,iNodeListPtr, NULL ); |
|
883 } |
|
884 else |
|
885 { |
|
886 iNodeListPtr->ParseNodeListWBXMLL(aReader,nodeListPtr->iNext, NULL ); |
|
887 } |
|
888 } |
|
889 |
|
890 |
|
891 |
|
892 // --------------------------------------------------------------------------- |
|
893 // CNSmlDmMgmtTree::SetUid(TUint32 aUid) |
|
894 // Sets adapter uid to tree |
|
895 // --------------------------------------------------------------------------- |
|
896 EXPORT_C void CNSmlDmMgmtTree::SetAdapterUid(TUint32 aUid) |
|
897 { |
|
898 SetUidToNewItems(iNodeListPtr,aUid); |
|
899 } |
|
900 |
|
901 // --------------------------------------------------------------------------- |
|
902 // CNSmlDmMgmtTree::SetServerId(TUint8 aServerId) |
|
903 // Sets host server id (host session id) to tree |
|
904 // --------------------------------------------------------------------------- |
|
905 EXPORT_C void CNSmlDmMgmtTree::SetServerId(TUint8 aServerId) |
|
906 { |
|
907 SetServerIdToNewItems(iNodeListPtr,aServerId); |
|
908 } |
|
909 |
|
910 |
|
911 |
|
912 // --------------------------------------------------------------------------- |
|
913 // TNSmlDmDDFFormatt CNSmlDmDDF::FindNameFromNodeListL() |
|
914 // Recursive function for searching certain uri segment from ddf structure. |
|
915 // --------------------------------------------------------------------------- |
|
916 EXPORT_C TNSmlDmDDFFormat CNSmlDmMgmtTree::FindNameFromNodeListL( |
|
917 const TDesC8& aURI,CNSmlDmNodeList*& aFinalPtr) |
|
918 { |
|
919 TNSmlDmDDFFormat ret = ENSmlDmDDFNotFound; |
|
920 |
|
921 CNSmlDmNodeList* nodeListPtr = iNodeListPtr; |
|
922 TInt numOfUriSegs=NSmlDmURI::NumOfURISegs(aURI); |
|
923 |
|
924 TInt level=1; |
|
925 |
|
926 |
|
927 while(nodeListPtr!=0) |
|
928 { |
|
929 TPtrC8 nodeNamePtr = |
|
930 TPtrC8((TUint8*)nodeListPtr->iNode->iNodeName.iContent, |
|
931 nodeListPtr->iNode->iNodeName.iLength); |
|
932 |
|
933 |
|
934 //check if we are in correct level |
|
935 if(level>=numOfUriSegs) |
|
936 { |
|
937 if( nodeNamePtr.Compare(NSmlDmURI::URISeg(aURI,level)) == 0 || |
|
938 nodeNamePtr.Length()==0) |
|
939 { |
|
940 if(nodeListPtr->iNode->iNodeListPtr!=0) |
|
941 { |
|
942 ret = ENSmlDmDDFNode; |
|
943 } |
|
944 else |
|
945 { |
|
946 ret = ENSmlDmDDFLeaf; |
|
947 } |
|
948 aFinalPtr = nodeListPtr; |
|
949 break; |
|
950 } |
|
951 else |
|
952 { |
|
953 nodeListPtr = nodeListPtr->iNext; |
|
954 } |
|
955 } |
|
956 else |
|
957 { |
|
958 //not yet in final level, if correct nodename found, this function is called recursively |
|
959 if( nodeNamePtr.Compare(NSmlDmURI::URISeg(aURI,level)) == 0 || |
|
960 nodeNamePtr.Length()==0) |
|
961 { |
|
962 nodeListPtr=nodeListPtr->iNode->iNodeListPtr; |
|
963 level++; |
|
964 } |
|
965 else |
|
966 { |
|
967 nodeListPtr = nodeListPtr->iNext; |
|
968 } |
|
969 } |
|
970 } // end while |
|
971 |
|
972 return ret; |
|
973 } |
|
974 |
|
975 |
|
976 // --------------------------------------------------------------------------- |
|
977 // TBool CNSmlDmDDF::FindLoadedAdaptersL() |
|
978 // Finds the uids of allready loaded adapters |
|
979 // --------------------------------------------------------------------------- |
|
980 EXPORT_C TBool CNSmlDmMgmtTree::FindLoadedAdaptersL( |
|
981 RArray<TUint32>& aLoadedAdapters, |
|
982 CNSmlDmNodeList* aNodeListPtr) |
|
983 { |
|
984 CNSmlDmNodeList* nodeListPtr; |
|
985 if(aNodeListPtr) |
|
986 { |
|
987 nodeListPtr = aNodeListPtr; |
|
988 } |
|
989 else |
|
990 { |
|
991 nodeListPtr = iNodeListPtr; |
|
992 } |
|
993 while(nodeListPtr!=0) |
|
994 { |
|
995 if(nodeListPtr->iNode) |
|
996 { |
|
997 if(nodeListPtr->iNode->iImplUid) |
|
998 { |
|
999 TBool found(EFalse); |
|
1000 for(TInt i = 0;i<aLoadedAdapters.Count();i++) |
|
1001 { |
|
1002 if(aLoadedAdapters[i]==nodeListPtr->iNode->iImplUid) |
|
1003 { |
|
1004 found = ETrue; |
|
1005 break; |
|
1006 } |
|
1007 } |
|
1008 if(!found) |
|
1009 { |
|
1010 aLoadedAdapters.AppendL(nodeListPtr->iNode->iImplUid); |
|
1011 } |
|
1012 } |
|
1013 if(nodeListPtr->iNode->iNodeListPtr) |
|
1014 { |
|
1015 FindLoadedAdaptersL(aLoadedAdapters, |
|
1016 nodeListPtr->iNode->iNodeListPtr); |
|
1017 } |
|
1018 } |
|
1019 nodeListPtr=nodeListPtr->iNext; |
|
1020 } // end while |
|
1021 return EFalse; |
|
1022 } |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 // --------------------------------------------------------------------------- |
|
1028 // CNSmlDmMgmtTree::SetUidToNewItems |
|
1029 // Set adapter id to new items in tree |
|
1030 // --------------------------------------------------------------------------- |
|
1031 TBool CNSmlDmMgmtTree::SetUidToNewItems ( CNSmlDmNodeList* aNodeListPtr, |
|
1032 TUint32 aUid) |
|
1033 { |
|
1034 CNSmlDmNodeList* nodeListPtr = aNodeListPtr; |
|
1035 while ( nodeListPtr ) |
|
1036 { |
|
1037 if ( nodeListPtr->iNode->iStaticLevel) |
|
1038 { |
|
1039 if(nodeListPtr->iNode->iParent) |
|
1040 { |
|
1041 nodeListPtr->iNode->iParent->iImplUid=0; |
|
1042 } |
|
1043 if(nodeListPtr->iNode->iImplUid==0 ) |
|
1044 { |
|
1045 nodeListPtr->iNode->iImplUid = aUid; |
|
1046 SetUidToNewItems ( nodeListPtr->iNode->iNodeListPtr, aUid ); |
|
1047 } |
|
1048 } |
|
1049 nodeListPtr =nodeListPtr->iNext; |
|
1050 } |
|
1051 return EFalse; |
|
1052 } |
|
1053 |
|
1054 // --------------------------------------------------------------------------- |
|
1055 // CNSmlDmMgmtTree::SetServerIdToNewItems |
|
1056 // Set session id to new items in tree |
|
1057 // --------------------------------------------------------------------------- |
|
1058 TBool CNSmlDmMgmtTree::SetServerIdToNewItems ( CNSmlDmNodeList* aNodeListPtr, |
|
1059 TUint8 aServerId) |
|
1060 { |
|
1061 CNSmlDmNodeList* nodeListPtr = aNodeListPtr; |
|
1062 while ( nodeListPtr ) |
|
1063 { |
|
1064 if ( nodeListPtr->iNode->iStaticLevel ) |
|
1065 { |
|
1066 if(nodeListPtr->iNode->iParent) |
|
1067 { |
|
1068 nodeListPtr->iNode->iParent->iHostServerId=0; |
|
1069 } |
|
1070 if(nodeListPtr->iNode->iHostServerId==0 ) |
|
1071 { |
|
1072 nodeListPtr->iNode->iHostServerId = aServerId; |
|
1073 SetServerIdToNewItems ( nodeListPtr->iNode->iNodeListPtr, aServerId ); |
|
1074 } |
|
1075 } |
|
1076 nodeListPtr = nodeListPtr->iNext; |
|
1077 } |
|
1078 return EFalse; |
|
1079 } |
|
1080 |
|
1081 // --------------------------------------------------------------------------- |
|
1082 // CNSmlDmMgmtTree::NodeListPtr() |
|
1083 // --------------------------------------------------------------------------- |
|
1084 EXPORT_C CNSmlDmNodeList* CNSmlDmMgmtTree::NodeListPtr() |
|
1085 { |
|
1086 return iNodeListPtr; |
|
1087 } |
|
1088 |
|
1089 |
|
1090 // =========================================================================== |
|
1091 // CNSmlDmDFProperties |
|
1092 // =========================================================================== |
|
1093 |
|
1094 // --------------------------------------------------------------------------- |
|
1095 // CNSmlDmDFProperties::CNSmlDmDFProperties() |
|
1096 // --------------------------------------------------------------------------- |
|
1097 CNSmlDmDFProperties::CNSmlDmDFProperties() |
|
1098 { |
|
1099 iOccurrence = MSmlDmDDFObject::EOne; |
|
1100 iScope = MSmlDmDDFObject::EDynamic; |
|
1101 iDFFormat = MSmlDmDDFObject::ENode; |
|
1102 iAccessTypes = 0; |
|
1103 } |
|
1104 |
|
1105 |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // CNSmlDmDFProperties::~CNSmlDmDFProperties() |
|
1108 // --------------------------------------------------------------------------- |
|
1109 CNSmlDmDFProperties::~CNSmlDmDFProperties() |
|
1110 { |
|
1111 delete iDefaultValue; |
|
1112 delete iDescription; |
|
1113 delete iDFTitle; |
|
1114 delete iDFType; |
|
1115 } |
|
1116 |
|
1117 |
|
1118 // --------------------------------------------------------------------------- |
|
1119 // CNSmlDmDFProperties::GenerateDFPropertiesL(CBufBase& aObject) |
|
1120 // generate xml from df properties |
|
1121 // --------------------------------------------------------------------------- |
|
1122 void CNSmlDmDFProperties::GenerateDFPropertiesL(CBufBase& aObject) |
|
1123 { |
|
1124 aObject.InsertL(aObject.Size(),KNSmlDDFDFProperties); |
|
1125 aObject.InsertL(aObject.Size(),KNSmlDDFAccessType); |
|
1126 for(TUint8 i = 0; i<6;i++) |
|
1127 { |
|
1128 TUint8 acl = TUint8(0x1<<i); |
|
1129 if(acl&iAccessTypes) |
|
1130 { |
|
1131 switch (acl) |
|
1132 { |
|
1133 case TSmlDmAccessTypes::EAccessType_Add: |
|
1134 { |
|
1135 aObject.InsertL(aObject.Size(),KNSmlDDFAccessTypeAdd); |
|
1136 break; |
|
1137 } |
|
1138 case TSmlDmAccessTypes::EAccessType_Copy: |
|
1139 { |
|
1140 aObject.InsertL(aObject.Size(),KNSmlDDFAccessTypeCopy); |
|
1141 break; |
|
1142 } |
|
1143 case TSmlDmAccessTypes::EAccessType_Delete: |
|
1144 { |
|
1145 aObject.InsertL(aObject.Size(),KNSmlDDFAccessTypeDelete); |
|
1146 break; |
|
1147 } |
|
1148 case TSmlDmAccessTypes::EAccessType_Exec: |
|
1149 { |
|
1150 aObject.InsertL(aObject.Size(),KNSmlDDFAccessTypeExec); |
|
1151 break; |
|
1152 } |
|
1153 case TSmlDmAccessTypes::EAccessType_Get: |
|
1154 { |
|
1155 aObject.InsertL(aObject.Size(),KNSmlDDFAccessTypeGet); |
|
1156 break; |
|
1157 } |
|
1158 case TSmlDmAccessTypes::EAccessType_Replace: |
|
1159 { |
|
1160 aObject.InsertL(aObject.Size(),KNSmlDDFAccessTypeReplace); |
|
1161 break; |
|
1162 default: |
|
1163 User::Panic(KNSmlTreeDTDPanic,KErrArgument); |
|
1164 break; |
|
1165 } |
|
1166 } //end switch |
|
1167 } //end if(acl&AccessTypes) |
|
1168 } |
|
1169 aObject.InsertL(aObject.Size(),KNSmlDDFAccessTypeEnd); |
|
1170 FeatureManager::InitializeLibL(); |
|
1171 GenerateDFPropsSubmethodL(aObject); // To reduce cyclomatic complexity |
|
1172 aObject.InsertL(aObject.Size(),KNSmlDDFOccurrence); |
|
1173 switch( iOccurrence ) |
|
1174 { |
|
1175 case MSmlDmDDFObject::EOne: |
|
1176 { |
|
1177 aObject.InsertL(aObject.Size(),KNSmlDDFOccurrenceOne); |
|
1178 break; |
|
1179 } |
|
1180 case MSmlDmDDFObject::EZeroOrOne: |
|
1181 { |
|
1182 aObject.InsertL(aObject.Size(),KNSmlDDFOccurrenceZeroOrOne); |
|
1183 break; |
|
1184 } |
|
1185 case MSmlDmDDFObject::EZeroOrMore: |
|
1186 { |
|
1187 aObject.InsertL(aObject.Size(),KNSmlDDFOccurrenceZeroOrMore); |
|
1188 break; |
|
1189 } |
|
1190 case MSmlDmDDFObject::EOneOrMore: |
|
1191 { |
|
1192 aObject.InsertL(aObject.Size(),KNSmlDDFOccurrenceOneOrMore); |
|
1193 break; |
|
1194 } |
|
1195 case MSmlDmDDFObject::EZeroOrN: |
|
1196 { |
|
1197 aObject.InsertL(aObject.Size(),KNSmlDDFOccurrenceZeroOrN); |
|
1198 break; |
|
1199 } |
|
1200 case MSmlDmDDFObject::EOneOrN: |
|
1201 { |
|
1202 aObject.InsertL(aObject.Size(),KNSmlDDFOccurrenceOneOrN); |
|
1203 break; |
|
1204 default: |
|
1205 User::Panic(KNSmlTreeDTDPanic,KErrArgument); |
|
1206 break; |
|
1207 } |
|
1208 } |
|
1209 aObject.InsertL(aObject.Size(),KNSmlDDFOccurrenceEnd); |
|
1210 aObject.InsertL(aObject.Size(),KNSmlDDFScope); |
|
1211 switch( iScope ) |
|
1212 { |
|
1213 case MSmlDmDDFObject::EPermanent: |
|
1214 { |
|
1215 aObject.InsertL(aObject.Size(),KNSmlDDFScopePermanent); |
|
1216 break; |
|
1217 } |
|
1218 case MSmlDmDDFObject::EDynamic: |
|
1219 { |
|
1220 aObject.InsertL(aObject.Size(),KNSmlDDFScopeDynamic); |
|
1221 break; |
|
1222 } |
|
1223 default: |
|
1224 User::Panic(KNSmlTreeDTDPanic,KErrArgument); |
|
1225 break; |
|
1226 } |
|
1227 aObject.InsertL(aObject.Size(),KNSmlDDFScopeEnd); |
|
1228 if(iDFTitle!=0) |
|
1229 { |
|
1230 aObject.InsertL(aObject.Size(),KNSmlDDFDFTitle); |
|
1231 aObject.InsertL(aObject.Size(),iDFTitle->iContent,iDFTitle->iLength); |
|
1232 aObject.InsertL(aObject.Size(),KNSmlDDFDFTitleEnd); |
|
1233 } |
|
1234 if(iDFType!=0) |
|
1235 { |
|
1236 aObject.InsertL(aObject.Size(),KNSmlDDFDFType); |
|
1237 aObject.InsertL(aObject.Size(),KNSmlDDFMIME); |
|
1238 aObject.InsertL(aObject.Size(),iDFType->iContent,iDFType->iLength); |
|
1239 aObject.InsertL(aObject.Size(),KNSmlDDFMIMEEnd); |
|
1240 aObject.InsertL(aObject.Size(),KNSmlDDFDFTypeEnd); |
|
1241 } |
|
1242 |
|
1243 aObject.InsertL(aObject.Size(),KNSmlDDFDFPropertiesEnd); |
|
1244 |
|
1245 FeatureManager::UnInitializeLib(); |
|
1246 } |
|
1247 |
|
1248 // --------------------------------------------------------------------------- |
|
1249 // CNSmlDmDFProperties::GenerateDFPropertiesWBXMLL(TPtr8& aObject) |
|
1250 // generate wbxml from df properties |
|
1251 // --------------------------------------------------------------------------- |
|
1252 void CNSmlDmDFProperties::GenerateDFPropertiesWBXMLL(RWriteStream& aStream) |
|
1253 { |
|
1254 aStream.WriteUint8L(EDDFDFProperties); |
|
1255 aStream.WriteUint8L(EDDFAccessType); |
|
1256 aStream.WriteUint8L(iAccessTypes); |
|
1257 aStream.WriteUint8L(EDDFAccessTypeEnd); |
|
1258 if(iDefaultValue != 0) |
|
1259 { |
|
1260 aStream.WriteUint8L(EDDFDefaultValue); |
|
1261 aStream.WriteUint16L(iDefaultValue->iLength); |
|
1262 aStream.WriteL(static_cast<TUint8*>(iDefaultValue->iContent), |
|
1263 iDefaultValue->iLength); |
|
1264 aStream.WriteUint8L(EDDFDefaultValueEnd); |
|
1265 } |
|
1266 if(iDescription != 0) |
|
1267 { |
|
1268 aStream.WriteUint8L(EDDFDescription); |
|
1269 aStream.WriteUint16L(iDescription->iLength); |
|
1270 aStream.WriteL(static_cast<TUint8*>(iDescription->iContent), |
|
1271 iDescription->iLength); |
|
1272 aStream.WriteUint8L(EDDFDescriptionEnd); |
|
1273 } |
|
1274 |
|
1275 aStream.WriteUint8L(EDDFDFFormat); |
|
1276 aStream.WriteUint8L(iDFFormat); |
|
1277 |
|
1278 aStream.WriteUint8L(EDDFDFFormatEnd); |
|
1279 aStream.WriteUint8L(EDDFOccurrence); |
|
1280 aStream.WriteUint8L( iOccurrence ); |
|
1281 |
|
1282 aStream.WriteUint8L(EDDFOccurrenceEnd); |
|
1283 aStream.WriteUint8L(EDDFScope); |
|
1284 aStream.WriteUint8L( iScope ); |
|
1285 |
|
1286 aStream.WriteUint8L(EDDFScopeEnd); |
|
1287 |
|
1288 if(iDFTitle!=0) |
|
1289 { |
|
1290 aStream.WriteUint8L(EDDFDFTitle); |
|
1291 aStream.WriteUint8L(iDFTitle->iLength); |
|
1292 aStream.WriteL(static_cast<TUint8*>(iDFTitle->iContent), |
|
1293 iDFTitle->iLength); |
|
1294 |
|
1295 aStream.WriteUint8L(EDDFDFTitleEnd); |
|
1296 } |
|
1297 if(iDFType!=0) |
|
1298 { |
|
1299 aStream.WriteUint8L(EDDFDFType); |
|
1300 aStream.WriteUint8L(EDDFMIME); |
|
1301 aStream.WriteUint8L(iDFType->iLength); |
|
1302 aStream.WriteL(static_cast<TUint8*>(iDFType->iContent), |
|
1303 iDFType->iLength); |
|
1304 aStream.WriteUint8L(EDDFMIMEEnd); |
|
1305 aStream.WriteUint8L(EDDFDFTypeEnd); |
|
1306 } |
|
1307 aStream.WriteUint8L(EDDFDFPropertiesEnd); |
|
1308 } |
|
1309 |
|
1310 |
|
1311 // --------------------------------------------------------------------------- |
|
1312 // CNSmlDmDFProperties::ParseDFPropertiesWBXMLL(RFileReadStream& reader) |
|
1313 // Parses DF properties element to structure |
|
1314 // --------------------------------------------------------------------------- |
|
1315 void CNSmlDmNodeList::ParseDFPropertiesWBXMLL(RReadStream& aReader, |
|
1316 MSmlDmDDFObject* aNodePtr ) |
|
1317 { |
|
1318 TInt len; |
|
1319 //Accesstypes |
|
1320 TUint tag = aReader.ReadUint8L(); |
|
1321 // get the Accesstypes value |
|
1322 TSmlDmAccessTypes act; |
|
1323 tag = aReader.ReadUint8L(); |
|
1324 Mem::Copy(&act, &tag, 1); |
|
1325 aNodePtr->SetAccessTypesL( act ); |
|
1326 // Accesstypes End |
|
1327 tag = aReader.ReadUint8L(); |
|
1328 |
|
1329 // next tag |
|
1330 do |
|
1331 { |
|
1332 tag = aReader.ReadUint8L(); |
|
1333 |
|
1334 if(tag==EDDFDefaultValue) |
|
1335 { |
|
1336 len = aReader.ReadUint16L(); |
|
1337 //value |
|
1338 HBufC8* data = HBufC8::NewLC( len ); |
|
1339 TPtr8 dataPtr = data->Des(); |
|
1340 aReader.ReadL(dataPtr, len); |
|
1341 aNodePtr->SetDefaultValueL(dataPtr); |
|
1342 CleanupStack::PopAndDestroy(1); //data |
|
1343 // end defaultvalue |
|
1344 tag = aReader.ReadUint8L(); |
|
1345 } |
|
1346 else if(tag==EDDFDescription) |
|
1347 { |
|
1348 len = aReader.ReadUint16L(); |
|
1349 //value |
|
1350 HBufC8* desData = HBufC8::NewLC( len ); |
|
1351 TPtr8 desDataPtr = desData->Des(); |
|
1352 aReader.ReadL(desDataPtr, len); |
|
1353 aNodePtr->SetDescriptionL(desDataPtr); |
|
1354 CleanupStack::PopAndDestroy(); //desData |
|
1355 // end description |
|
1356 tag = aReader.ReadUint8L(); |
|
1357 } |
|
1358 else if(tag==EDDFDFFormat) |
|
1359 { |
|
1360 aNodePtr->SetDFFormatL(MSmlDmDDFObject::TDFFormat(aReader.ReadUint8L())); |
|
1361 // end format |
|
1362 tag = aReader.ReadUint8L(); |
|
1363 } |
|
1364 }while ((tag == EDDFDefaultValueEnd) || (tag == EDDFDescriptionEnd)); |
|
1365 |
|
1366 //Occurrence |
|
1367 tag = aReader.ReadUint8L(); |
|
1368 __ASSERT_DEBUG(tag == EDDFOccurrence, |
|
1369 User::Panic(_L("Tag not EDDFOccurrence, tag:"),tag)); |
|
1370 |
|
1371 aNodePtr->SetOccurenceL(MSmlDmDDFObject::TOccurence(aReader.ReadUint8L())); |
|
1372 // end occurrence |
|
1373 tag = aReader.ReadUint8L(); |
|
1374 |
|
1375 //Scope |
|
1376 tag = aReader.ReadUint8L(); |
|
1377 aNodePtr->SetScopeL(MSmlDmDDFObject::TScope(aReader.ReadUint8L())); |
|
1378 // end occurrence |
|
1379 tag = aReader.ReadUint8L(); |
|
1380 |
|
1381 do |
|
1382 { |
|
1383 tag = aReader.ReadUint8L(); |
|
1384 |
|
1385 if(tag==EDDFDFTitle) |
|
1386 { |
|
1387 //length |
|
1388 len = aReader.ReadUint8L(); |
|
1389 //value |
|
1390 HBufC8* titleData = HBufC8::NewLC( len ); |
|
1391 TPtr8 titleDataPtr = titleData->Des(); |
|
1392 aReader.ReadL(titleDataPtr, len); |
|
1393 |
|
1394 aNodePtr->SetDFTitleL(titleDataPtr); |
|
1395 CleanupStack::PopAndDestroy(); //titleData, titleData16 |
|
1396 // end description |
|
1397 tag = aReader.ReadUint8L(); |
|
1398 } |
|
1399 else if(tag==EDDFDFType) |
|
1400 { |
|
1401 tag = aReader.ReadUint8L(); |
|
1402 if ( tag == EDDFMIME ) |
|
1403 { |
|
1404 //length |
|
1405 len = aReader.ReadUint8L(); |
|
1406 //value |
|
1407 HBufC8* typeData = HBufC8::NewLC( len ); |
|
1408 TPtr8 typeDataPtr = typeData->Des(); |
|
1409 aReader.ReadL(typeDataPtr, len); |
|
1410 |
|
1411 aNodePtr->AddDFTypeMimeTypeL(typeDataPtr); |
|
1412 CleanupStack::PopAndDestroy(); //data |
|
1413 //end MIMETYPE |
|
1414 tag = aReader.ReadUint8L(); |
|
1415 } |
|
1416 // end DFType |
|
1417 tag = aReader.ReadUint8L(); |
|
1418 |
|
1419 } |
|
1420 else if(tag==EDDFDFPropertiesEnd) |
|
1421 { |
|
1422 |
|
1423 } |
|
1424 }while ( tag != EDDFDFPropertiesEnd ); |
|
1425 } |
|
1426 |
|
1427 |
|
1428 // =========================================================================== |
|
1429 // CNSmlDmRTProperties |
|
1430 // =========================================================================== |
|
1431 |
|
1432 // --------------------------------------------------------------------------- |
|
1433 // CNSmlDmRTProperties::CNSmlDmRTProperties() |
|
1434 // --------------------------------------------------------------------------- |
|
1435 CNSmlDmRTProperties::CNSmlDmRTProperties() |
|
1436 { |
|
1437 } |
|
1438 |
|
1439 // --------------------------------------------------------------------------- |
|
1440 // CNSmlDmRTProperties::~CNSmlDmRTProperties() |
|
1441 // --------------------------------------------------------------------------- |
|
1442 CNSmlDmRTProperties::~CNSmlDmRTProperties() |
|
1443 { |
|
1444 delete iSize; |
|
1445 delete iTitle; |
|
1446 delete iTStamp; |
|
1447 delete iType; |
|
1448 delete iVerNo; |
|
1449 } |
|
1450 |
|
1451 // --------------------------------------------------------------------------- |
|
1452 // CNSmlDmRTProperties::GenerateDFPropsSubmethodL(CBufBase& aObject) |
|
1453 // --------------------------------------------------------------------------- |
|
1454 void CNSmlDmDFProperties::GenerateDFPropsSubmethodL(CBufBase& aObject) |
|
1455 { |
|
1456 if(iDefaultValue != 0) |
|
1457 { |
|
1458 aObject.InsertL(aObject.Size(),KNSmlDDFDefaultValue); |
|
1459 aObject.InsertL(aObject.Size(),iDefaultValue->iContent, |
|
1460 iDefaultValue->iLength); |
|
1461 |
|
1462 aObject.InsertL(aObject.Size(),KNSmlDDFDefaultValueEnd); |
|
1463 } |
|
1464 if(iDescription != 0) |
|
1465 { |
|
1466 aObject.InsertL(aObject.Size(),KNSmlDDFDescription); |
|
1467 aObject.InsertL(aObject.Size(),iDescription->iContent, |
|
1468 iDescription->iLength); |
|
1469 |
|
1470 aObject.InsertL(aObject.Size(),KNSmlDDFDescriptionEnd); |
|
1471 } |
|
1472 |
|
1473 aObject.InsertL(aObject.Size(),KNSmlDDFDFFormat); |
|
1474 switch( iDFFormat ) |
|
1475 { |
|
1476 case MSmlDmDDFObject::EB64: |
|
1477 { |
|
1478 aObject.InsertL(aObject.Size(),KNSmlDDFFormatB64); |
|
1479 break; |
|
1480 } |
|
1481 case MSmlDmDDFObject::EBool: |
|
1482 { |
|
1483 aObject.InsertL(aObject.Size(),KNSmlDDFFormatBool); |
|
1484 break; |
|
1485 } |
|
1486 case MSmlDmDDFObject::EChr: |
|
1487 { |
|
1488 aObject.InsertL(aObject.Size(),KNSmlDDFFormatChr); |
|
1489 break; |
|
1490 } |
|
1491 case MSmlDmDDFObject::EInt: |
|
1492 { |
|
1493 aObject.InsertL(aObject.Size(),KNSmlDDFFormatInt); |
|
1494 break; |
|
1495 } |
|
1496 case MSmlDmDDFObject::ENode: |
|
1497 { |
|
1498 aObject.InsertL(aObject.Size(),KNSmlDDFFormatNode); |
|
1499 break; |
|
1500 } |
|
1501 case MSmlDmDDFObject::ENull: |
|
1502 { |
|
1503 aObject.InsertL(aObject.Size(),KNSmlDDFFormatNull); |
|
1504 break; |
|
1505 } |
|
1506 case MSmlDmDDFObject::EXml: |
|
1507 { |
|
1508 aObject.InsertL(aObject.Size(),KNSmlDDFFormatXml); |
|
1509 break; |
|
1510 } |
|
1511 case MSmlDmDDFObject::EBin: |
|
1512 { |
|
1513 aObject.InsertL(aObject.Size(),KNSmlDDFFormatBin); |
|
1514 break; |
|
1515 } |
|
1516 |
|
1517 case MSmlDmDDFObject::EDate: |
|
1518 { |
|
1519 if(!FeatureManager::FeatureSupported( KFeatureIdSyncMlDm112 )) |
|
1520 { |
|
1521 aObject.InsertL(aObject.Size(),KNSmlDDFFormatDate); |
|
1522 } |
|
1523 else |
|
1524 { |
|
1525 User::Panic(KNSmlTreeDTDPanic,KErrArgument); |
|
1526 } |
|
1527 break; |
|
1528 } |
|
1529 case MSmlDmDDFObject::ETime: |
|
1530 { |
|
1531 if(!FeatureManager::FeatureSupported( KFeatureIdSyncMlDm112 )) |
|
1532 { |
|
1533 aObject.InsertL(aObject.Size(),KNSmlDDFFormatTime); |
|
1534 } |
|
1535 else |
|
1536 { |
|
1537 User::Panic(KNSmlTreeDTDPanic,KErrArgument); |
|
1538 } |
|
1539 break; |
|
1540 } |
|
1541 case MSmlDmDDFObject::EFloat: |
|
1542 { |
|
1543 if(!FeatureManager::FeatureSupported( KFeatureIdSyncMlDm112 )) |
|
1544 { |
|
1545 aObject.InsertL(aObject.Size(),KNSmlDDFFormatFloat); |
|
1546 } |
|
1547 else |
|
1548 { |
|
1549 User::Panic(KNSmlTreeDTDPanic,KErrArgument); |
|
1550 } |
|
1551 break; |
|
1552 } |
|
1553 default: |
|
1554 User::Panic(KNSmlTreeDTDPanic,KErrArgument); |
|
1555 break; |
|
1556 } |
|
1557 aObject.InsertL(aObject.Size(),KNSmlDDFDFFormatEnd); |
|
1558 } |
|
1559 // End of file |
|
1560 |