|
1 /* |
|
2 * Copyright (c) 2006 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: Implements CNcdNodeFactory class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdnodefactory.h" |
|
20 #include "ncdnodeidentifier.h" |
|
21 #include "ncdnodeidentifiereditor.h" |
|
22 #include "ncdnodemanager.h" |
|
23 #include "ncdnodedbmanager.h" |
|
24 #include "ncdnodeimpl.h" |
|
25 #include "ncdnodeitem.h" |
|
26 #include "ncdnodefolder.h" |
|
27 #include "ncdrootnode.h" |
|
28 #include "ncdsearchrootnode.h" |
|
29 #include "ncdsearchnodeitem.h" |
|
30 #include "ncdsearchnodefolder.h" |
|
31 #include "ncdnodetransparentfolder.h" |
|
32 #include "ncdbundlefolder.h" |
|
33 #include "ncdnodesupplier.h" |
|
34 #include "ncdnodemetadataimpl.h" |
|
35 #include "ncdnodeitemmetadata.h" |
|
36 #include "ncdnodefoldermetadata.h" |
|
37 #include "catalogsdebug.h" |
|
38 #include "ncdsearchnodebundle.h" |
|
39 |
|
40 |
|
41 CNcdNodeFactory* CNcdNodeFactory::NewL( CNcdNodeManager& aNodeManager ) |
|
42 { |
|
43 CNcdNodeFactory* self = |
|
44 CNcdNodeFactory::NewLC( aNodeManager ); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 CNcdNodeFactory* CNcdNodeFactory::NewLC( CNcdNodeManager& aNodeManager ) |
|
50 { |
|
51 CNcdNodeFactory* self = |
|
52 new( ELeave ) CNcdNodeFactory( aNodeManager ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 CNcdNodeFactory::CNcdNodeFactory( CNcdNodeManager& aNodeManager ) |
|
61 : CBase(), |
|
62 iNodeManager( aNodeManager ) |
|
63 { |
|
64 } |
|
65 |
|
66 |
|
67 void CNcdNodeFactory::ConstructL() |
|
68 { |
|
69 // These values have to be set. |
|
70 } |
|
71 |
|
72 |
|
73 CNcdNodeFactory::~CNcdNodeFactory() |
|
74 { |
|
75 DLTRACEIN(("")); |
|
76 |
|
77 // Delete member variables that are owned by this class object here. |
|
78 |
|
79 DLTRACEOUT(("")); |
|
80 } |
|
81 |
|
82 |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Functions to check the node types and node purposes |
|
86 // --------------------------------------------------------------------------- |
|
87 |
|
88 CNcdNodeFactory::TNcdNodeType CNcdNodeFactory::NodeTypeL( const TDesC8& aNodeData ) |
|
89 { |
|
90 DLTRACEIN(("")); |
|
91 |
|
92 // Check the class ids and return the correct value according to that. |
|
93 |
|
94 // Reads the class id from the stream |
|
95 if ( aNodeData.Length() == 0 ) |
|
96 { |
|
97 DLINFO(("Node data was empty.")); |
|
98 DASSERT( EFalse ); |
|
99 User::Leave( KErrArgument ); |
|
100 } |
|
101 |
|
102 DLINFO(("Create stream from db data length: %d", aNodeData.Length())); |
|
103 RDesReadStream stream( aNodeData ); |
|
104 CleanupClosePushL( stream ); |
|
105 |
|
106 // Read the class id from the stream |
|
107 NcdNodeClassIds::TNcdNodeClassId classId = |
|
108 static_cast<NcdNodeClassIds::TNcdNodeClassId>( stream.ReadInt32L() ); |
|
109 |
|
110 CleanupStack::PopAndDestroy( &stream ); |
|
111 |
|
112 TNcdNodeType type( NodeTypeL( classId ) ); |
|
113 |
|
114 DLTRACEOUT(("")); |
|
115 |
|
116 return type; |
|
117 } |
|
118 |
|
119 |
|
120 CNcdNodeFactory::TNcdNodeType CNcdNodeFactory::NodeTypeL( const CNcdNode& aNode ) |
|
121 { |
|
122 DLTRACEIN(("")); |
|
123 |
|
124 TNcdNodeType type( NodeTypeL( aNode.ClassId() ) ); |
|
125 |
|
126 DLTRACEOUT(("")); |
|
127 |
|
128 return type; |
|
129 } |
|
130 |
|
131 |
|
132 CNcdNodeFactory::TNcdNodeType CNcdNodeFactory::NodeTypeL( NcdNodeClassIds::TNcdNodeClassId aClassId ) |
|
133 { |
|
134 // Check the class ids and return the correct value according to that. |
|
135 // Use switch case instead of if-else. |
|
136 |
|
137 TNcdNodeType type( ENcdNodeItem ); |
|
138 |
|
139 switch( aClassId ) |
|
140 { |
|
141 case NcdNodeClassIds::ENcdItemNodeClassId: |
|
142 DLTRACE(("Item node")); |
|
143 type = ENcdNodeItem; |
|
144 break; |
|
145 |
|
146 case NcdNodeClassIds::ENcdSearchItemNodeClassId: |
|
147 DLTRACE(("Search item")); |
|
148 type = ENcdNodeItem; |
|
149 break; |
|
150 |
|
151 case NcdNodeClassIds::ENcdFolderNodeClassId: |
|
152 DLTRACE(("Folder node")); |
|
153 type = ENcdNodeFolder; |
|
154 break; |
|
155 |
|
156 case NcdNodeClassIds::ENcdTransparentFolderNodeClassId: |
|
157 DLTRACE(("Transparent folder")); |
|
158 type = ENcdNodeFolder; |
|
159 break; |
|
160 |
|
161 case NcdNodeClassIds::ENcdSearchFolderNodeClassId: |
|
162 DLTRACE(("Search folder")); |
|
163 type = ENcdNodeFolder; |
|
164 break; |
|
165 |
|
166 case NcdNodeClassIds::ENcdBundleFolderNodeClassId: |
|
167 DLTRACE(("Bundle folder")); |
|
168 type = ENcdNodeFolder; |
|
169 break; |
|
170 |
|
171 case NcdNodeClassIds::ENcdRootNodeClassId: |
|
172 DLTRACE(("Root node")); |
|
173 type = ENcdNodeRoot; |
|
174 break; |
|
175 |
|
176 case NcdNodeClassIds::ENcdSearchRootNodeClassId: |
|
177 DLTRACE(("Search root node")); |
|
178 type = ENcdNodeRoot; |
|
179 break; |
|
180 |
|
181 case NcdNodeClassIds::ENcdSupplierNodeClassId: |
|
182 DLTRACE(("Supplier node")); |
|
183 type = ENcdNodeSupplier; |
|
184 break; |
|
185 |
|
186 case NcdNodeClassIds::ENcdSearchBundleNodeClassId: |
|
187 DLTRACE(("Search bundle folder")); |
|
188 type = ENcdNodeSearchBundle; |
|
189 break; |
|
190 |
|
191 default: |
|
192 DLERROR(("Unknown class id")); |
|
193 // For debuggin purpose |
|
194 DASSERT( EFalse ); |
|
195 User::Leave( KErrUnknown ); |
|
196 break; |
|
197 } |
|
198 |
|
199 return type; |
|
200 } |
|
201 |
|
202 |
|
203 CNcdNodeFactory::TNcdNodePurpose CNcdNodeFactory::NodePurposeL( const CNcdNode& aNode ) |
|
204 { |
|
205 DLTRACEIN(("")); |
|
206 |
|
207 TNcdNodePurpose purpose( NodePurposeL( aNode.ClassId() ) ); |
|
208 |
|
209 DLTRACEOUT(("")); |
|
210 |
|
211 return purpose; |
|
212 } |
|
213 |
|
214 |
|
215 CNcdNodeFactory::TNcdNodePurpose CNcdNodeFactory::NodePurposeL( NcdNodeClassIds::TNcdNodeClassId aClassId ) |
|
216 { |
|
217 // Check the class ids and return the correct value according to that. |
|
218 // Use switch case instead of if-else. |
|
219 |
|
220 TNcdNodePurpose purpose( ENcdNormalNode ); |
|
221 |
|
222 switch( aClassId ) |
|
223 { |
|
224 case NcdNodeClassIds::ENcdItemNodeClassId: |
|
225 DLTRACE(("Item node")); |
|
226 purpose = ENcdNormalNode; |
|
227 break; |
|
228 |
|
229 case NcdNodeClassIds::ENcdSearchItemNodeClassId: |
|
230 DLTRACE(("Search item")); |
|
231 purpose = ENcdSearchNode; |
|
232 break; |
|
233 |
|
234 case NcdNodeClassIds::ENcdFolderNodeClassId: |
|
235 DLTRACE(("Folder node")); |
|
236 purpose = ENcdNormalNode; |
|
237 break; |
|
238 |
|
239 case NcdNodeClassIds::ENcdTransparentFolderNodeClassId: |
|
240 DLTRACE(("Transparent folder")); |
|
241 purpose = ENcdTransparentNode; |
|
242 break; |
|
243 |
|
244 case NcdNodeClassIds::ENcdSearchFolderNodeClassId: |
|
245 DLTRACE(("Search folder")); |
|
246 purpose = ENcdSearchNode; |
|
247 break; |
|
248 |
|
249 case NcdNodeClassIds::ENcdBundleFolderNodeClassId: |
|
250 DLTRACE(("Bundle folder")); |
|
251 purpose = ENcdBundleNode; |
|
252 break; |
|
253 |
|
254 case NcdNodeClassIds::ENcdRootNodeClassId: |
|
255 DLTRACE(("Root node")); |
|
256 purpose = ENcdNormalNode; |
|
257 break; |
|
258 |
|
259 case NcdNodeClassIds::ENcdSearchRootNodeClassId: |
|
260 DLTRACE(("Search root node")); |
|
261 purpose = ENcdSearchNode; |
|
262 break; |
|
263 |
|
264 case NcdNodeClassIds::ENcdSupplierNodeClassId: |
|
265 DLTRACE(("Supplier node")); |
|
266 purpose = ENcdNormalNode; |
|
267 break; |
|
268 |
|
269 case NcdNodeClassIds::ENcdSearchBundleNodeClassId: |
|
270 DLTRACE(("Search bundle folder")); |
|
271 purpose = ENcdSearchNode; |
|
272 break; |
|
273 |
|
274 default: |
|
275 DLERROR(("Unknown class id")); |
|
276 // For debuggin purpose |
|
277 DASSERT( EFalse ); |
|
278 User::Leave( KErrUnknown ); |
|
279 break; |
|
280 } |
|
281 |
|
282 return purpose; |
|
283 } |
|
284 |
|
285 |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // Functions to find out the node class id |
|
289 // --------------------------------------------------------------------------- |
|
290 |
|
291 NcdNodeClassIds::TNcdNodeClassId CNcdNodeFactory::NodeClassIdL( CNcdNodeFactory::TNcdNodeType aNodeType, |
|
292 CNcdNodeFactory::TNcdNodePurpose aNodePurpose ) |
|
293 { |
|
294 |
|
295 NcdNodeClassIds::TNcdNodeClassId classId( NcdNodeClassIds::ENcdNullObjectClassId ); |
|
296 |
|
297 // Check if the node is item, folder or root |
|
298 switch( aNodeType ) |
|
299 { |
|
300 case ENcdNodeItem: |
|
301 { |
|
302 // The node is item. |
|
303 // Check what kind of item. |
|
304 switch( aNodePurpose ) |
|
305 { |
|
306 case ENcdNormalNode: |
|
307 DLTRACE(("Normal item node class id")); |
|
308 classId = NcdNodeClassIds::ENcdItemNodeClassId; |
|
309 break; |
|
310 |
|
311 case ENcdChildOfTransparentNode: |
|
312 DLTRACE(("Transparent child item class id")); |
|
313 classId = NcdNodeClassIds::ENcdItemNodeClassId; |
|
314 break; |
|
315 |
|
316 case ENcdSearchNode: |
|
317 DLTRACE(("Search item class id")); |
|
318 classId = NcdNodeClassIds::ENcdSearchItemNodeClassId; |
|
319 break; |
|
320 |
|
321 default: |
|
322 DLERROR(("Unknown node item purpose")); |
|
323 // For debuggin purpose |
|
324 DASSERT( EFalse ); |
|
325 User::Leave( KErrUnknown ); |
|
326 break; |
|
327 } |
|
328 } |
|
329 break; |
|
330 |
|
331 case ENcdNodeFolder: |
|
332 { |
|
333 // The node is folder. |
|
334 // Check what kind of folder. |
|
335 switch( aNodePurpose ) |
|
336 { |
|
337 case ENcdNormalNode: |
|
338 DLTRACE(("Normal folder class id")); |
|
339 classId = NcdNodeClassIds::ENcdFolderNodeClassId; |
|
340 break; |
|
341 |
|
342 case ENcdChildOfTransparentNode: |
|
343 DLTRACE(("Transparent child folder class id")); |
|
344 classId = NcdNodeClassIds::ENcdFolderNodeClassId; |
|
345 break; |
|
346 |
|
347 case ENcdSearchNode: |
|
348 DLTRACE(("Search folder class id")); |
|
349 classId = NcdNodeClassIds::ENcdSearchFolderNodeClassId; |
|
350 break; |
|
351 |
|
352 case ENcdBundleNode: |
|
353 DLTRACE(("Bundle folder class id")); |
|
354 classId = NcdNodeClassIds::ENcdBundleFolderNodeClassId; |
|
355 break; |
|
356 |
|
357 case ENcdTransparentNode: |
|
358 DLTRACE(("Transparent folder class id")); |
|
359 classId = NcdNodeClassIds::ENcdTransparentFolderNodeClassId; |
|
360 break; |
|
361 |
|
362 default: |
|
363 DLERROR(("Unknown node folder purpose")); |
|
364 // For debuggin purpose |
|
365 DASSERT( EFalse ); |
|
366 User::Leave( KErrUnknown ); |
|
367 break; |
|
368 } |
|
369 } |
|
370 break; |
|
371 |
|
372 case ENcdNodeRoot: |
|
373 { |
|
374 switch( aNodePurpose ) |
|
375 { |
|
376 case ENcdNormalNode: |
|
377 DLTRACE(("Root class id")); |
|
378 classId = NcdNodeClassIds::ENcdRootNodeClassId; |
|
379 break; |
|
380 |
|
381 case ENcdSearchNode: |
|
382 DLTRACE(("Search root as normal folder class id")); |
|
383 // Notice that the search root is actually normal search folder. |
|
384 // Should this be changed when the id functions properly? |
|
385 classId = NcdNodeClassIds::ENcdSearchRootNodeClassId; |
|
386 break; |
|
387 |
|
388 default: |
|
389 DLERROR(("Unknown node root purpose")); |
|
390 // For debuggin purpose |
|
391 DASSERT( EFalse ); |
|
392 User::Leave( KErrUnknown ); |
|
393 break; |
|
394 } |
|
395 } |
|
396 break; |
|
397 |
|
398 case ENcdNodeSupplier: |
|
399 { |
|
400 // The supplier class id will always be the same. |
|
401 classId = NcdNodeClassIds::ENcdSupplierNodeClassId; |
|
402 } |
|
403 break; |
|
404 |
|
405 case ENcdNodeSearchBundle: |
|
406 { |
|
407 // The search bundle class id will always be the same. |
|
408 classId = NcdNodeClassIds::ENcdSearchBundleNodeClassId; |
|
409 } |
|
410 break; |
|
411 |
|
412 default: |
|
413 DLERROR(("Unknown node type")); |
|
414 // For debuggin purpose |
|
415 DASSERT( EFalse ); |
|
416 User::Leave( KErrUnknown ); |
|
417 break; |
|
418 }; |
|
419 |
|
420 return classId; |
|
421 } |
|
422 |
|
423 |
|
424 |
|
425 // --------------------------------------------------------------------------- |
|
426 // Functions to create node objects |
|
427 // --------------------------------------------------------------------------- |
|
428 |
|
429 CNcdNodeItem* CNcdNodeFactory::CreateNodeItemL( const CNcdNodeIdentifier& aParentIdentifier, |
|
430 const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
431 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
432 { |
|
433 DLTRACEIN(("")); |
|
434 |
|
435 CNcdNodeItem* item( CreateNodeItemLC( aParentIdentifier, |
|
436 aMetaDataIdentifier, |
|
437 aClassId ) ); |
|
438 if ( item != NULL ) |
|
439 { |
|
440 CleanupStack::Pop( item ); |
|
441 } |
|
442 |
|
443 DLTRACEOUT(("")); |
|
444 |
|
445 return item; |
|
446 } |
|
447 |
|
448 |
|
449 CNcdNodeItem* CNcdNodeFactory::CreateNodeItemLC( const CNcdNodeIdentifier& aParentIdentifier, |
|
450 const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
451 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
452 { |
|
453 DLTRACEIN(("")); |
|
454 |
|
455 // Creates the node, |
|
456 // but does not internalize its data from anywhere. |
|
457 |
|
458 CNcdNodeIdentifier* identifier = |
|
459 NcdNodeIdentifierEditor::CreateNodeIdentifierLC( aParentIdentifier, aMetaDataIdentifier ); |
|
460 |
|
461 |
|
462 // First check if the node can be created as an item. |
|
463 CNcdNodeItem* item( CreateNodeItemLC( *identifier, |
|
464 aClassId ) ); |
|
465 |
|
466 CleanupStack::PopAndDestroy( identifier ); |
|
467 |
|
468 DLTRACEOUT(("")); |
|
469 |
|
470 return item; |
|
471 } |
|
472 |
|
473 |
|
474 CNcdNodeItem* CNcdNodeFactory::CreateNodeItemL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
475 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
476 { |
|
477 DLTRACEIN(("")); |
|
478 |
|
479 CNcdNodeItem* item( CreateNodeItemLC( aNodeIdentifier, |
|
480 aClassId) ); |
|
481 |
|
482 if ( item != NULL ) |
|
483 { |
|
484 CleanupStack::Pop( item ); |
|
485 } |
|
486 |
|
487 DLTRACEOUT(("")); |
|
488 |
|
489 return item; |
|
490 } |
|
491 |
|
492 |
|
493 CNcdNodeItem* CNcdNodeFactory::CreateNodeItemLC( const CNcdNodeIdentifier& aNodeIdentifier, |
|
494 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
495 { |
|
496 DLTRACEIN(("")); |
|
497 |
|
498 // Creates the node, |
|
499 // but does not internalize its data from anywhere. |
|
500 CNcdNodeItem* item( NULL ); |
|
501 |
|
502 // Create object according to the class type |
|
503 switch( aClassId ) |
|
504 { |
|
505 case NcdNodeClassIds::ENcdItemNodeClassId: |
|
506 DLINFO(("Item node")); |
|
507 item = CNcdNodeItem::NewLC( NodeManager(), aNodeIdentifier ); |
|
508 break; |
|
509 |
|
510 case NcdNodeClassIds::ENcdSearchItemNodeClassId: |
|
511 DLINFO(("Search item node")); |
|
512 item = CNcdSearchNodeItem::NewLC( NodeManager(), aNodeIdentifier ); |
|
513 break; |
|
514 |
|
515 default: |
|
516 DLERROR(("Unknown node item class id. Return NULL")); |
|
517 // Do not insert assert here because CreateNodeL(C) function uses this |
|
518 // function among other create functions to create nodes. |
|
519 item = NULL; |
|
520 break; |
|
521 } |
|
522 |
|
523 DLTRACEOUT(("")); |
|
524 |
|
525 return item; |
|
526 } |
|
527 |
|
528 |
|
529 |
|
530 CNcdNodeFolder* CNcdNodeFactory::CreateNodeFolderL( const CNcdNodeIdentifier& aParentIdentifier, |
|
531 const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
532 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
533 { |
|
534 DLTRACEIN(("")); |
|
535 |
|
536 CNcdNodeFolder* folder( CreateNodeFolderLC( aParentIdentifier, |
|
537 aMetaDataIdentifier, |
|
538 aClassId) ); |
|
539 if ( folder != NULL ) |
|
540 { |
|
541 CleanupStack::Pop( folder ); |
|
542 } |
|
543 |
|
544 DLTRACEOUT(("")); |
|
545 |
|
546 return folder; |
|
547 } |
|
548 |
|
549 |
|
550 CNcdNodeFolder* CNcdNodeFactory::CreateNodeFolderLC( const CNcdNodeIdentifier& aParentIdentifier, |
|
551 const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
552 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
553 { |
|
554 DLTRACEIN(("")); |
|
555 |
|
556 // Creates the node, |
|
557 // but does not internalize its data from anywhere. |
|
558 |
|
559 CNcdNodeIdentifier* identifier = |
|
560 NcdNodeIdentifierEditor::CreateNodeIdentifierLC( aParentIdentifier, aMetaDataIdentifier ); |
|
561 |
|
562 |
|
563 // First check if the node can be created as an item. |
|
564 CNcdNodeFolder* folder( CreateNodeFolderLC( *identifier, |
|
565 aClassId ) ); |
|
566 |
|
567 CleanupStack::PopAndDestroy( identifier ); |
|
568 |
|
569 DLTRACEOUT(("")); |
|
570 |
|
571 return folder; |
|
572 } |
|
573 |
|
574 |
|
575 CNcdNodeFolder* CNcdNodeFactory::CreateNodeFolderL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
576 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
577 { |
|
578 DLTRACEIN(("")); |
|
579 |
|
580 // Creates the node, |
|
581 // but does not internalize its data from anywhere. |
|
582 CNcdNodeFolder* folder( CreateNodeFolderLC( aNodeIdentifier, aClassId ) ); |
|
583 |
|
584 if ( folder != NULL ) |
|
585 { |
|
586 CleanupStack::Pop( folder ); |
|
587 } |
|
588 |
|
589 DLTRACEOUT(("")); |
|
590 |
|
591 return folder; |
|
592 } |
|
593 |
|
594 |
|
595 CNcdNodeFolder* CNcdNodeFactory::CreateNodeFolderLC( const CNcdNodeIdentifier& aNodeIdentifier, |
|
596 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
597 { |
|
598 DLTRACEIN(("")); |
|
599 |
|
600 // Creates the node, |
|
601 // but does not internalize its data from anywhere. |
|
602 CNcdNodeFolder* folder( NULL ); |
|
603 |
|
604 // Create object according to the class type |
|
605 switch( aClassId ) |
|
606 { |
|
607 case NcdNodeClassIds::ENcdFolderNodeClassId: |
|
608 DLINFO(("Folder node")); |
|
609 folder = CNcdNodeFolder::NewLC( NodeManager(), aNodeIdentifier ); |
|
610 break; |
|
611 |
|
612 case NcdNodeClassIds::ENcdTransparentFolderNodeClassId: |
|
613 DLINFO(("Transparent folder node")); |
|
614 folder = CNcdNodeTransparentFolder::NewLC( NodeManager(), aNodeIdentifier ); |
|
615 break; |
|
616 |
|
617 case NcdNodeClassIds::ENcdSearchFolderNodeClassId: |
|
618 DLINFO(("Search folder node")); |
|
619 folder = CNcdSearchNodeFolder::NewLC( NodeManager(), aNodeIdentifier ); |
|
620 break; |
|
621 |
|
622 case NcdNodeClassIds::ENcdRootNodeClassId: |
|
623 DLINFO(("Root node")); |
|
624 folder = CNcdRootNode::NewLC( NodeManager(), aNodeIdentifier ); |
|
625 break; |
|
626 |
|
627 case NcdNodeClassIds::ENcdBundleFolderNodeClassId: |
|
628 DLINFO(("Bundle folder")); |
|
629 folder = CNcdBundleFolder::NewLC( NodeManager(), aNodeIdentifier ); |
|
630 break; |
|
631 |
|
632 case NcdNodeClassIds::ENcdSearchRootNodeClassId: |
|
633 DLINFO(("Search root node from db")); |
|
634 folder = CNcdSearchRootNode::NewLC( NodeManager(), aNodeIdentifier ); |
|
635 break; |
|
636 |
|
637 case NcdNodeClassIds::ENcdSearchBundleNodeClassId: |
|
638 DLINFO(("Search bundle folder")); |
|
639 folder = CNcdSearchNodeBundle::NewLC( NodeManager(), aNodeIdentifier ); |
|
640 break; |
|
641 |
|
642 default: |
|
643 DLERROR(("Unknown folder node class id. Return NULL")); |
|
644 // Do not insert assert here because CreateNodeL(C) function uses this |
|
645 // function among other create function to create nodes. |
|
646 folder = NULL; |
|
647 break; |
|
648 } |
|
649 |
|
650 DLTRACEOUT(("")); |
|
651 |
|
652 return folder; |
|
653 } |
|
654 |
|
655 |
|
656 CNcdNodeSupplier* CNcdNodeFactory::CreateNodeSupplierL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
657 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
658 { |
|
659 DLTRACEIN(("")); |
|
660 |
|
661 // Creates the node, |
|
662 // but does not internalize its data from anywhere. |
|
663 CNcdNodeSupplier* node( CreateNodeSupplierLC( aNodeIdentifier, aClassId ) ); |
|
664 |
|
665 if ( node != NULL ) |
|
666 { |
|
667 CleanupStack::Pop( node ); |
|
668 } |
|
669 |
|
670 DLTRACEOUT(("")); |
|
671 |
|
672 return node; |
|
673 } |
|
674 |
|
675 |
|
676 CNcdNodeSupplier* CNcdNodeFactory::CreateNodeSupplierLC( const CNcdNodeIdentifier& aNodeIdentifier, |
|
677 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
678 { |
|
679 DLTRACEIN(("")); |
|
680 |
|
681 // Creates the node, |
|
682 // but does not internalize its data from anywhere. |
|
683 CNcdNodeSupplier* node( NULL ); |
|
684 |
|
685 // Create object according to the class type |
|
686 switch( aClassId ) |
|
687 { |
|
688 case NcdNodeClassIds::ENcdSupplierNodeClassId: |
|
689 DLINFO(("Supplier node")); |
|
690 node = CNcdNodeSupplier::NewLC( NodeManager(), aNodeIdentifier ); |
|
691 break; |
|
692 |
|
693 default: |
|
694 DLERROR(("Unknown supplier node class id. Return NULL")); |
|
695 // Do not insert assert here because CreateNodeL(C) function uses this |
|
696 // function among other create function to create nodes. |
|
697 node = NULL; |
|
698 break; |
|
699 } |
|
700 |
|
701 DLTRACEOUT(("")); |
|
702 |
|
703 return node; |
|
704 } |
|
705 |
|
706 |
|
707 CNcdNode* CNcdNodeFactory::CreateNodeL( const CNcdNodeIdentifier& aParentIdentifier, |
|
708 const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
709 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
710 { |
|
711 DLTRACEIN(("")); |
|
712 |
|
713 // Creates the node, |
|
714 // but does not internalize its data from anywhere. |
|
715 CNcdNode* node( CreateNodeLC( aParentIdentifier, aMetaDataIdentifier, aClassId ) ); |
|
716 |
|
717 if ( node != NULL ) |
|
718 { |
|
719 CleanupStack::Pop( node ); |
|
720 } |
|
721 |
|
722 DLTRACEOUT(("")); |
|
723 |
|
724 return node; |
|
725 } |
|
726 |
|
727 |
|
728 CNcdNode* CNcdNodeFactory::CreateNodeLC( const CNcdNodeIdentifier& aParentIdentifier, |
|
729 const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
730 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
731 { |
|
732 DLTRACEIN(("")); |
|
733 |
|
734 // Creates the node, |
|
735 // but does not internalize its data from anywhere. |
|
736 |
|
737 CNcdNodeIdentifier* identifier = |
|
738 NcdNodeIdentifierEditor::CreateNodeIdentifierLC( aParentIdentifier, aMetaDataIdentifier ); |
|
739 |
|
740 |
|
741 // First check if the node can be created as an item. |
|
742 CNcdNode* node( CreateNodeL( *identifier, aClassId ) ); |
|
743 |
|
744 CleanupStack::PopAndDestroy( identifier ); |
|
745 |
|
746 CleanupStack::PushL( node ); |
|
747 |
|
748 DLTRACEOUT(("")); |
|
749 |
|
750 return node; |
|
751 } |
|
752 |
|
753 |
|
754 CNcdNode* CNcdNodeFactory::CreateNodeL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
755 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
756 { |
|
757 DLTRACEIN(("")); |
|
758 |
|
759 // Creates the node, |
|
760 // but does not internalize its data from anywhere. |
|
761 CNcdNode* node( CreateNodeLC( aNodeIdentifier, aClassId ) ); |
|
762 |
|
763 if ( node != NULL ) |
|
764 { |
|
765 CleanupStack::Pop( node ); |
|
766 } |
|
767 |
|
768 DLTRACEOUT(("")); |
|
769 |
|
770 return node; |
|
771 } |
|
772 |
|
773 |
|
774 CNcdNode* CNcdNodeFactory::CreateNodeLC( const CNcdNodeIdentifier& aNodeIdentifier, |
|
775 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
776 { |
|
777 DLTRACEIN(("")); |
|
778 |
|
779 // Creates the node, |
|
780 // but does not internalize its data from anywhere. |
|
781 |
|
782 // First check if the node can be created as an item. |
|
783 CNcdNode* node( CreateNodeItemLC( aNodeIdentifier, |
|
784 aClassId ) ); |
|
785 |
|
786 |
|
787 if ( node == NULL ) |
|
788 { |
|
789 // Node was not an item. So, create a folder. |
|
790 node = CreateNodeFolderLC( aNodeIdentifier, |
|
791 aClassId ); |
|
792 } |
|
793 |
|
794 if ( node == NULL ) |
|
795 { |
|
796 // Node was none of above. So, try to create node supplier. |
|
797 node = CreateNodeSupplierLC( aNodeIdentifier, aClassId ); |
|
798 } |
|
799 |
|
800 DLINFO(("Node should have been created")); |
|
801 if ( node == NULL ) |
|
802 { |
|
803 DLERROR(("Null node")) |
|
804 DASSERT( EFalse ); |
|
805 User::Leave( KErrNotFound ); |
|
806 } |
|
807 |
|
808 DLTRACEOUT(("")); |
|
809 |
|
810 return node; |
|
811 } |
|
812 |
|
813 |
|
814 |
|
815 CNcdNode* CNcdNodeFactory::CreateNodeL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
816 RReadStream& aStream ) const |
|
817 { |
|
818 DLTRACEIN(("")); |
|
819 |
|
820 // Creates the node |
|
821 // and internalizes its data from given stream. |
|
822 CNcdNode* node( CreateNodeLC( aNodeIdentifier, aStream ) ); |
|
823 |
|
824 if ( node != NULL ) |
|
825 { |
|
826 CleanupStack::Pop( node ); |
|
827 } |
|
828 |
|
829 DLTRACEOUT(("")); |
|
830 |
|
831 return node; |
|
832 } |
|
833 |
|
834 CNcdNode* CNcdNodeFactory::CreateNodeLC( const CNcdNodeIdentifier& aNodeIdentifier, |
|
835 RReadStream& aStream ) const |
|
836 { |
|
837 DLTRACEIN(("")); |
|
838 |
|
839 // Creates the node |
|
840 // and internalizes its data from given stream. |
|
841 CNcdNode* node( NULL ); |
|
842 |
|
843 // The first four bits (TInt32) should describe the class type of the data. |
|
844 // This data type is used to create the right class and the stream data |
|
845 // after that will be used to initialize the class object. |
|
846 NcdNodeClassIds::TNcdNodeClassId classId = |
|
847 static_cast<NcdNodeClassIds::TNcdNodeClassId>( aStream.ReadInt32L() ); |
|
848 |
|
849 DLINFO(("classId: %d", classId )); |
|
850 |
|
851 // Creates the corresponding node |
|
852 node = CreateNodeLC( aNodeIdentifier, classId ); |
|
853 |
|
854 // Internalizes the node from the stream |
|
855 node->InternalizeL( aStream ); |
|
856 |
|
857 DLTRACEOUT(("")); |
|
858 |
|
859 return node; |
|
860 } |
|
861 |
|
862 |
|
863 CNcdNode* CNcdNodeFactory::CreateNodeL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
864 const TDesC8& aData ) const |
|
865 { |
|
866 DLTRACEIN(("")); |
|
867 |
|
868 CNcdNode* node( NULL ); |
|
869 |
|
870 // Reads the class id from the stream |
|
871 if ( aData.Length() == 0 ) |
|
872 { |
|
873 DLINFO(("Node data was empty.")); |
|
874 DASSERT( EFalse ); |
|
875 User::Leave( KErrArgument ); |
|
876 } |
|
877 |
|
878 DLINFO(("Create stream from data length: %d", aData.Length())); |
|
879 RDesReadStream stream( aData ); |
|
880 CleanupClosePushL( stream ); |
|
881 |
|
882 node = CreateNodeL( aNodeIdentifier, stream ); |
|
883 |
|
884 CleanupStack::PopAndDestroy( &stream ); |
|
885 |
|
886 DLTRACEOUT(("")); |
|
887 |
|
888 return node; |
|
889 } |
|
890 |
|
891 |
|
892 CNcdNode* CNcdNodeFactory::CreateNodeLC( const CNcdNodeIdentifier& aNodeIdentifier, |
|
893 const TDesC8& aData ) const |
|
894 { |
|
895 DLTRACEIN(("")); |
|
896 |
|
897 // Creates the node |
|
898 // and internalizes its data from given data. |
|
899 CNcdNode* node( CreateNodeL( aNodeIdentifier, aData ) ); |
|
900 |
|
901 if ( node != NULL ) |
|
902 { |
|
903 CleanupStack::PushL( node ); |
|
904 } |
|
905 |
|
906 DLTRACEOUT(("")); |
|
907 |
|
908 return node; |
|
909 } |
|
910 |
|
911 |
|
912 void CNcdNodeFactory::InternalizeNodeL( CNcdNode& aNode, const TDesC8& aData ) |
|
913 { |
|
914 DLTRACEIN(("")); |
|
915 |
|
916 // Reads the class id from the stream |
|
917 if ( aData.Length() == 0 ) |
|
918 { |
|
919 DLINFO(("Node data was empty.")); |
|
920 DASSERT( EFalse ); |
|
921 User::Leave( KErrArgument ); |
|
922 } |
|
923 |
|
924 DLINFO(("Create stream from data length: %d", aData.Length())); |
|
925 RDesReadStream stream( aData ); |
|
926 CleanupClosePushL( stream ); |
|
927 |
|
928 // The first four bits (TInt32) should describe the class type of the data. |
|
929 // This data type is used to create the right class and the stream data |
|
930 // after that will be used to initialize the class object. |
|
931 NcdNodeClassIds::TNcdNodeClassId classId = |
|
932 static_cast<NcdNodeClassIds::TNcdNodeClassId>( stream.ReadInt32L() ); |
|
933 if ( aNode.ClassId() != classId ) |
|
934 { |
|
935 User::Leave( KErrArgument ); |
|
936 DASSERT( EFalse ); |
|
937 } |
|
938 |
|
939 aNode.InternalizeL( stream ); |
|
940 CleanupStack::PopAndDestroy( &stream ); |
|
941 } |
|
942 |
|
943 |
|
944 // --------------------------------------------------------------------------- |
|
945 // Functions to get metadata type info |
|
946 // --------------------------------------------------------------------------- |
|
947 |
|
948 |
|
949 CNcdNodeFactory::TNcdNodeType CNcdNodeFactory::MetaDataTypeL( const CNcdNodeMetaData& aNode ) |
|
950 { |
|
951 DLTRACEIN(("")); |
|
952 |
|
953 TNcdNodeType type( MetaDataTypeL( aNode.ClassId() ) ); |
|
954 |
|
955 DLTRACEOUT(("")); |
|
956 |
|
957 return type; |
|
958 } |
|
959 |
|
960 |
|
961 CNcdNodeFactory::TNcdNodeType CNcdNodeFactory::MetaDataTypeL( NcdNodeClassIds::TNcdNodeClassId aClassId ) |
|
962 { |
|
963 DLTRACEIN(("")); |
|
964 |
|
965 // Check the class ids and return the correct value according to that. |
|
966 // Use switch case instead of if-else. |
|
967 |
|
968 TNcdNodeType type( ENcdNodeItem ); |
|
969 |
|
970 switch( aClassId ) |
|
971 { |
|
972 case NcdNodeClassIds::ENcdItemNodeMetaDataClassId: |
|
973 DLINFO(("Item metadata")); |
|
974 type = ENcdNodeItem; |
|
975 break; |
|
976 |
|
977 case NcdNodeClassIds::ENcdFolderNodeMetaDataClassId: |
|
978 DLINFO(("Folder metadata")); |
|
979 type = ENcdNodeFolder; |
|
980 break; |
|
981 |
|
982 case NcdNodeClassIds::ENcdSupplierNodeMetaDataClassId: |
|
983 DLINFO(("Folder metadata")); |
|
984 type = ENcdNodeSupplier; |
|
985 break; |
|
986 |
|
987 default: |
|
988 DLERROR(("Unknown class id")); |
|
989 // For debuggin purpose |
|
990 DASSERT( EFalse ); |
|
991 User::Leave( KErrUnknown ); |
|
992 break; |
|
993 } |
|
994 |
|
995 DLTRACEOUT(("")); |
|
996 |
|
997 return type; |
|
998 } |
|
999 |
|
1000 |
|
1001 |
|
1002 // --------------------------------------------------------------------------- |
|
1003 // Functions to find out the metadata class id |
|
1004 // --------------------------------------------------------------------------- |
|
1005 |
|
1006 NcdNodeClassIds::TNcdNodeClassId CNcdNodeFactory::MetaDataClassId( CNcdNodeFactory::TNcdNodeType aNodeType ) |
|
1007 { |
|
1008 DLTRACEIN(("")); |
|
1009 |
|
1010 NcdNodeClassIds::TNcdNodeClassId classId( NcdNodeClassIds::ENcdNullObjectClassId ); |
|
1011 |
|
1012 // Check if the node is item, folder or root |
|
1013 switch( aNodeType ) |
|
1014 { |
|
1015 case ENcdNodeItem: |
|
1016 DLINFO(("Item metadata")); |
|
1017 classId = NcdNodeClassIds::ENcdItemNodeMetaDataClassId; |
|
1018 break; |
|
1019 |
|
1020 case ENcdNodeFolder: |
|
1021 DLINFO(("Folder metadata")); |
|
1022 classId = NcdNodeClassIds::ENcdFolderNodeMetaDataClassId; |
|
1023 break; |
|
1024 |
|
1025 case ENcdNodeSupplier: |
|
1026 DLINFO(("Supplier metadata")); |
|
1027 classId = NcdNodeClassIds::ENcdSupplierNodeMetaDataClassId; |
|
1028 break; |
|
1029 |
|
1030 default: |
|
1031 DLERROR(("Unknown node type")); |
|
1032 // For debuggin purpose |
|
1033 DASSERT( EFalse ); |
|
1034 _LIT( KCategory, "Unknown node type" ); |
|
1035 User::Panic( KCategory, KErrUnknown ); |
|
1036 break; |
|
1037 }; |
|
1038 |
|
1039 DLTRACEOUT(("")); |
|
1040 |
|
1041 return classId; |
|
1042 } |
|
1043 |
|
1044 |
|
1045 |
|
1046 // --------------------------------------------------------------------------- |
|
1047 // Functions to create metadata objects |
|
1048 // --------------------------------------------------------------------------- |
|
1049 |
|
1050 CNcdNodeMetaData* CNcdNodeFactory::CreateMetaDataL( const CNcdNodeIdentifier& aIdentifier, |
|
1051 TNcdNodeType aMetaType ) const |
|
1052 { |
|
1053 DLTRACEIN(("")); |
|
1054 |
|
1055 CNcdNodeMetaData* metaData( CreateMetaDataLC( aIdentifier, aMetaType ) ); |
|
1056 |
|
1057 if ( metaData != NULL ) |
|
1058 { |
|
1059 CleanupStack::Pop( metaData ); |
|
1060 } |
|
1061 |
|
1062 DLTRACEOUT(("")); |
|
1063 |
|
1064 return metaData; |
|
1065 } |
|
1066 |
|
1067 CNcdNodeMetaData* CNcdNodeFactory::CreateMetaDataLC( const CNcdNodeIdentifier& aIdentifier, |
|
1068 TNcdNodeType aMetaType ) const |
|
1069 { |
|
1070 DLTRACEIN(("")); |
|
1071 |
|
1072 CNcdNodeMetaData* metaData( NULL ); |
|
1073 |
|
1074 switch( aMetaType ) |
|
1075 { |
|
1076 case ENcdNodeItem: |
|
1077 metaData = |
|
1078 CreateMetaDataLC( aIdentifier, |
|
1079 NcdNodeClassIds::ENcdItemNodeMetaDataClassId ); |
|
1080 break; |
|
1081 |
|
1082 case ENcdNodeFolder: |
|
1083 metaData = |
|
1084 CreateMetaDataLC( aIdentifier, |
|
1085 NcdNodeClassIds::ENcdFolderNodeMetaDataClassId ); |
|
1086 break; |
|
1087 |
|
1088 default: |
|
1089 DLERROR(("Unknown metadata class id.")); |
|
1090 DASSERT( EFalse ); |
|
1091 User::Leave( KErrArgument ); |
|
1092 break; |
|
1093 } |
|
1094 |
|
1095 DASSERT( metaData ); |
|
1096 |
|
1097 DLTRACEOUT(("")); |
|
1098 return metaData; |
|
1099 } |
|
1100 |
|
1101 |
|
1102 CNcdNodeItemMetaData* CNcdNodeFactory::CreateItemMetaDataL( const CNcdNodeIdentifier& aIdentifier, |
|
1103 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
1104 { |
|
1105 DLTRACEIN(("")); |
|
1106 |
|
1107 CNcdNodeItemMetaData* item( CreateItemMetaDataLC( aIdentifier, aClassId ) ); |
|
1108 |
|
1109 if ( item != NULL ) |
|
1110 { |
|
1111 CleanupStack::Pop( item ); |
|
1112 } |
|
1113 |
|
1114 DLTRACEOUT(("")); |
|
1115 |
|
1116 return item; |
|
1117 } |
|
1118 |
|
1119 |
|
1120 CNcdNodeItemMetaData* CNcdNodeFactory::CreateItemMetaDataLC( const CNcdNodeIdentifier& aIdentifier, |
|
1121 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
1122 { |
|
1123 DLTRACEIN(("")); |
|
1124 |
|
1125 // Creates the metadata, |
|
1126 // but does not internalize its data from anywhere. |
|
1127 CNcdNodeItemMetaData* item( NULL ); |
|
1128 |
|
1129 // Create object according to the class type |
|
1130 switch( aClassId ) |
|
1131 { |
|
1132 case NcdNodeClassIds::ENcdItemNodeMetaDataClassId: |
|
1133 DLINFO(("Item meta")); |
|
1134 item = CNcdNodeItemMetaData::NewLC( aIdentifier, NodeManager() ); |
|
1135 break; |
|
1136 |
|
1137 default: |
|
1138 DLERROR(("Unknown metadata item class id. Return NULL")); |
|
1139 // Do not insert assert here because CreateMetaDataL(C) function uses this |
|
1140 // function and CreateMetadataFolderL(C) function to create nodes. |
|
1141 item = NULL; |
|
1142 break; |
|
1143 } |
|
1144 |
|
1145 DLTRACEOUT(("")); |
|
1146 |
|
1147 return item; |
|
1148 } |
|
1149 |
|
1150 |
|
1151 CNcdNodeFolderMetaData* CNcdNodeFactory::CreateFolderMetaDataL( const CNcdNodeIdentifier& aIdentifier, |
|
1152 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
1153 { |
|
1154 DLTRACEIN(("")); |
|
1155 |
|
1156 // Creates the metadata, |
|
1157 // but does not internalize its data from anywhere. |
|
1158 CNcdNodeFolderMetaData* folder( CreateFolderMetaDataLC( aIdentifier, aClassId ) ); |
|
1159 |
|
1160 if ( folder != NULL ) |
|
1161 { |
|
1162 CleanupStack::Pop( folder ); |
|
1163 } |
|
1164 |
|
1165 DLTRACEOUT(("")); |
|
1166 |
|
1167 return folder; |
|
1168 } |
|
1169 |
|
1170 |
|
1171 CNcdNodeFolderMetaData* CNcdNodeFactory::CreateFolderMetaDataLC( const CNcdNodeIdentifier& aIdentifier, |
|
1172 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
1173 { |
|
1174 DLTRACEIN(("")); |
|
1175 |
|
1176 // Creates the metadata, |
|
1177 // but does not internalize its data from anywhere. |
|
1178 CNcdNodeFolderMetaData* folder( NULL ); |
|
1179 |
|
1180 // Create object according to the class type |
|
1181 switch( aClassId ) |
|
1182 { |
|
1183 case NcdNodeClassIds::ENcdFolderNodeMetaDataClassId: |
|
1184 DLINFO(("Folder meta")); |
|
1185 folder = CNcdNodeFolderMetaData::NewLC( aIdentifier, NodeManager() ); |
|
1186 break; |
|
1187 |
|
1188 default: |
|
1189 DLERROR(("Unknown folder metadata class id. Return NULL")); |
|
1190 // Do not insert assert here because CreateMetaDataL(C) function uses this |
|
1191 // function and CreateFolderMetaDataL(C) function to create nodes. |
|
1192 folder = NULL; |
|
1193 break; |
|
1194 } |
|
1195 |
|
1196 DLTRACEOUT(("")); |
|
1197 |
|
1198 return folder; |
|
1199 } |
|
1200 |
|
1201 |
|
1202 CNcdNodeMetaData* CNcdNodeFactory::CreateMetaDataL( const CNcdNodeIdentifier& aIdentifier, |
|
1203 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
1204 { |
|
1205 DLTRACEIN(("")); |
|
1206 |
|
1207 // Creates the metadata, |
|
1208 // but does not internalize its data from anywhere. |
|
1209 CNcdNodeMetaData* metadata( CreateMetaDataLC( aIdentifier, aClassId ) ); |
|
1210 |
|
1211 if ( metadata != NULL ) |
|
1212 { |
|
1213 CleanupStack::Pop( metadata ); |
|
1214 } |
|
1215 |
|
1216 DLTRACEOUT(("")); |
|
1217 |
|
1218 return metadata; |
|
1219 } |
|
1220 |
|
1221 |
|
1222 CNcdNodeMetaData* CNcdNodeFactory::CreateMetaDataLC( const CNcdNodeIdentifier& aIdentifier, |
|
1223 NcdNodeClassIds::TNcdNodeClassId aClassId ) const |
|
1224 { |
|
1225 DLTRACEIN(("")); |
|
1226 |
|
1227 // Creates the metadata, |
|
1228 // but does not internalize its data from anywhere. |
|
1229 |
|
1230 // First check if the metadata can be created as an item. |
|
1231 CNcdNodeMetaData* metadata( CreateItemMetaDataLC( aIdentifier, |
|
1232 aClassId ) ); |
|
1233 |
|
1234 |
|
1235 if ( metadata == NULL ) |
|
1236 { |
|
1237 // Node was not an item. So, create a folder. |
|
1238 metadata = CreateFolderMetaDataLC( aIdentifier, |
|
1239 aClassId ); |
|
1240 } |
|
1241 |
|
1242 DLTRACEOUT(("")); |
|
1243 |
|
1244 return metadata; |
|
1245 } |
|
1246 |
|
1247 |
|
1248 |
|
1249 CNcdNodeMetaData* CNcdNodeFactory::CreateMetaDataL( const CNcdNodeIdentifier& aIdentifier, |
|
1250 RReadStream& aStream ) const |
|
1251 { |
|
1252 DLTRACEIN(("")); |
|
1253 |
|
1254 // Creates the metadata |
|
1255 // and internalizes its data from given stream. |
|
1256 CNcdNodeMetaData* metadata( CreateMetaDataLC( aIdentifier, aStream ) ); |
|
1257 |
|
1258 if ( metadata != NULL ) |
|
1259 { |
|
1260 CleanupStack::Pop( metadata ); |
|
1261 } |
|
1262 |
|
1263 DLTRACEOUT(("")); |
|
1264 |
|
1265 return metadata; |
|
1266 } |
|
1267 |
|
1268 CNcdNodeMetaData* CNcdNodeFactory::CreateMetaDataLC( const CNcdNodeIdentifier& aIdentifier, |
|
1269 RReadStream& aStream ) const |
|
1270 { |
|
1271 DLTRACEIN(("")); |
|
1272 |
|
1273 // Creates the metadata |
|
1274 // and internalizes its data from given stream. |
|
1275 CNcdNodeMetaData* metadata( NULL ); |
|
1276 |
|
1277 // The first four bits (TInt32) should describe the class type of the data. |
|
1278 // This data type is used to create the right class and the stream data |
|
1279 // after that will be used to initialize the class object. |
|
1280 NcdNodeClassIds::TNcdNodeClassId classId = |
|
1281 static_cast<NcdNodeClassIds::TNcdNodeClassId>( aStream.ReadInt32L() ); |
|
1282 |
|
1283 DLINFO(("classId: %d", classId )); |
|
1284 |
|
1285 // Creates the corresponding node |
|
1286 metadata = CreateMetaDataLC( aIdentifier, classId ); |
|
1287 |
|
1288 // Internalizes the metadata from the stream |
|
1289 metadata->InternalizeL( aStream ); |
|
1290 |
|
1291 DLTRACEOUT(("")); |
|
1292 |
|
1293 return metadata; |
|
1294 } |
|
1295 |
|
1296 |
|
1297 CNcdNodeMetaData* CNcdNodeFactory::CreateMetaDataL( const CNcdNodeIdentifier& aIdentifier, |
|
1298 const TDesC8& aData ) const |
|
1299 { |
|
1300 DLTRACEIN(("")); |
|
1301 |
|
1302 CNcdNodeMetaData* metadata( NULL ); |
|
1303 |
|
1304 // Reads the class id from the stream |
|
1305 DASSERT( aData.Length() ); |
|
1306 |
|
1307 DLINFO(("Create stream from data length: %d", aData.Length())); |
|
1308 RDesReadStream stream( aData ); |
|
1309 CleanupClosePushL( stream ); |
|
1310 |
|
1311 metadata = CreateMetaDataL( aIdentifier, stream ); |
|
1312 |
|
1313 CleanupStack::PopAndDestroy( &stream ); |
|
1314 |
|
1315 DLTRACEOUT(("")); |
|
1316 |
|
1317 return metadata; |
|
1318 } |
|
1319 |
|
1320 |
|
1321 CNcdNodeMetaData* CNcdNodeFactory::CreateMetaDataLC( const CNcdNodeIdentifier& aIdentifier, |
|
1322 const TDesC8& aData ) const |
|
1323 { |
|
1324 DLTRACEIN(("")); |
|
1325 |
|
1326 // Creates the metadata |
|
1327 // and internalizes its data from given data. |
|
1328 CNcdNodeMetaData* metadata( CreateMetaDataL( aIdentifier, aData ) ); |
|
1329 |
|
1330 if ( metadata != NULL ) |
|
1331 { |
|
1332 CleanupStack::PushL( metadata ); |
|
1333 } |
|
1334 |
|
1335 DLTRACEOUT(("")); |
|
1336 |
|
1337 return metadata; |
|
1338 } |
|
1339 |
|
1340 |
|
1341 |
|
1342 // --------------------------------------------------------------------------- |
|
1343 // Protected functions |
|
1344 // --------------------------------------------------------------------------- |
|
1345 |
|
1346 CNcdNodeManager& CNcdNodeFactory::NodeManager() const |
|
1347 { |
|
1348 return iNodeManager; |
|
1349 } |
|
1350 |