|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCDLOADROOTNODEOPERATIONIMPL_H |
|
20 #define C_NCDLOADROOTNODEOPERATIONIMPL_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "ncdbaseoperation.h" |
|
25 #include "ncdoperationobserver.h" |
|
26 #include "ncdparserobserver.h" |
|
27 #include "catalogshttpobserver.h" |
|
28 #include "catalogshttptypes.h" |
|
29 #include "catalogshttpsession.h" |
|
30 #include "catalogsutils.h" |
|
31 #include "ncdnodeidentifier.h" |
|
32 #include "ncdconfigurationobserver.h" |
|
33 #include "ncdproviderdefines.h" |
|
34 |
|
35 class CDesC16Array; |
|
36 class CDesC16ArrayFlat; |
|
37 class CDesC8ArrayFlat; |
|
38 class MNcdParser; |
|
39 class CNcdNodeManager; |
|
40 class MNcdProtocol; |
|
41 class CNcdNodeIdentifier; |
|
42 class CNcdLoadNodeOperationImpl; |
|
43 class CCatalogsContext; |
|
44 class MCatalogsAccessPointManager; |
|
45 class MNcdConfigurationManager; |
|
46 class MNcdOperationRemoveHandler; |
|
47 class CNcdContentSourceMap; |
|
48 class CNcdChildEntityMap; |
|
49 |
|
50 // ======== CONSTANTS ======== |
|
51 |
|
52 |
|
53 class CNcdContentSource : public CBase |
|
54 { |
|
55 public: |
|
56 |
|
57 static CNcdContentSource* NewLC( const CNcdNodeIdentifier& aParentIdentifier ) |
|
58 { |
|
59 CNcdContentSource* self = |
|
60 new( ELeave ) CNcdContentSource; |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL( aParentIdentifier ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 static CNcdContentSource* NewL( RReadStream& aStream ) |
|
67 { |
|
68 CNcdContentSource* self = new ( ELeave ) CNcdContentSource; |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL( aStream ); |
|
71 CleanupStack::Pop( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 ~CNcdContentSource() |
|
76 { |
|
77 delete iParentIdentifier; |
|
78 delete iNameSpace; |
|
79 delete iProvider; |
|
80 delete iUri; |
|
81 delete iNodeId; |
|
82 } |
|
83 |
|
84 const TDesC& NameSpace() const |
|
85 { |
|
86 return *iNameSpace; |
|
87 } |
|
88 void SetNameSpaceL( const TDesC& aNameSpace ) |
|
89 { |
|
90 AssignDesL( iNameSpace, aNameSpace ); |
|
91 } |
|
92 const TDesC& Provider() const |
|
93 { |
|
94 return *iProvider; |
|
95 } |
|
96 void SetProviderL( const TDesC& aProvider ) |
|
97 { |
|
98 AssignDesL( iProvider, aProvider ); |
|
99 } |
|
100 const TDesC& Uri() const |
|
101 { |
|
102 return *iUri; |
|
103 } |
|
104 void SetUriL( const TDesC& aUri ) |
|
105 { |
|
106 AssignDesL( iUri, aUri ); |
|
107 } |
|
108 /** |
|
109 * Getter for node id. |
|
110 * |
|
111 * @return const TDesC |
|
112 */ |
|
113 const TDesC& NodeId() const |
|
114 { |
|
115 return *iNodeId; |
|
116 } |
|
117 void SetNodeIdL( const TDesC& aNodeId ) |
|
118 { |
|
119 AssignDesL( iNodeId, aNodeId ); |
|
120 } |
|
121 |
|
122 void SetBroken( TBool aBroken ) |
|
123 { |
|
124 DLTRACEIN(("broken: %d", aBroken)); |
|
125 iBroken = aBroken; |
|
126 } |
|
127 |
|
128 TBool IsBroken() const |
|
129 { |
|
130 DLTRACEIN(("broken: %d", iBroken)); |
|
131 return iBroken; |
|
132 } |
|
133 |
|
134 void SetAlwaysVisible( TBool aValue ) |
|
135 { |
|
136 iAlwaysVisible = aValue; |
|
137 } |
|
138 |
|
139 TBool AlwaysVisible() const |
|
140 { |
|
141 return iAlwaysVisible; |
|
142 } |
|
143 |
|
144 void SetTransparent( TBool aValue ) |
|
145 { |
|
146 iTransparent = aValue; |
|
147 } |
|
148 |
|
149 TBool IsTransparent() const |
|
150 { |
|
151 return iTransparent; |
|
152 } |
|
153 |
|
154 |
|
155 CNcdNodeIdentifier& ParentIdentifier() const |
|
156 { |
|
157 return *iParentIdentifier; |
|
158 } |
|
159 |
|
160 CNcdContentSource* CopyL() const |
|
161 { |
|
162 CNcdContentSource* copy = CNcdContentSource::NewLC( *iParentIdentifier ); |
|
163 copy->SetNameSpaceL( *iNameSpace ); |
|
164 copy->SetProviderL( *iProvider ); |
|
165 copy->SetUriL( *iUri ); |
|
166 copy->SetNodeIdL( *iNodeId ); |
|
167 copy->SetBroken( iBroken ); |
|
168 copy->SetAlwaysVisible( iAlwaysVisible ); |
|
169 copy->SetTransparent( iTransparent ); |
|
170 CleanupStack::Pop( copy ); |
|
171 return copy; |
|
172 } |
|
173 |
|
174 TBool Equals( const CNcdContentSource& aContentSource ) const |
|
175 { |
|
176 if ( aContentSource.NameSpace() == NameSpace() && |
|
177 aContentSource.Provider() == Provider() && |
|
178 aContentSource.Uri() == Uri() && |
|
179 aContentSource.NodeId() == NodeId() ) |
|
180 { |
|
181 return ETrue; |
|
182 } |
|
183 else |
|
184 { |
|
185 return EFalse; |
|
186 } |
|
187 } |
|
188 |
|
189 |
|
190 |
|
191 void ExternalizeL( RWriteStream& aStream ) |
|
192 { |
|
193 iParentIdentifier->ExternalizeL( aStream ); |
|
194 ExternalizeDesL( NameSpace(), aStream ); |
|
195 ExternalizeDesL( Provider(), aStream ); |
|
196 ExternalizeDesL( Uri(), aStream ); |
|
197 ExternalizeDesL( NodeId(), aStream ); |
|
198 aStream.WriteInt8L( iBroken ); |
|
199 aStream.WriteInt8L( iAlwaysVisible ); |
|
200 aStream.WriteInt8L( iTransparent ); |
|
201 } |
|
202 |
|
203 private: |
|
204 CNcdContentSource() |
|
205 : iBroken( EFalse ), |
|
206 iAlwaysVisible( EFalse ), |
|
207 iTransparent( EFalse ) |
|
208 { |
|
209 } |
|
210 |
|
211 |
|
212 void ConstructL( const CNcdNodeIdentifier& aParentIdentifier ) |
|
213 { |
|
214 iParentIdentifier = CNcdNodeIdentifier::NewL( aParentIdentifier ); |
|
215 iNameSpace = KNullDesC().AllocL(); |
|
216 iProvider = KNullDesC().AllocL(); |
|
217 iUri = KNullDesC().AllocL(); |
|
218 iNodeId = KNullDesC().AllocL(); |
|
219 } |
|
220 |
|
221 void ConstructL( RReadStream& aStream ) |
|
222 { |
|
223 iParentIdentifier = CNcdNodeIdentifier::NewL( aStream ); |
|
224 InternalizeDesL( iNameSpace, aStream ); |
|
225 InternalizeDesL( iProvider, aStream ); |
|
226 InternalizeDesL( iUri, aStream ); |
|
227 InternalizeDesL( iNodeId, aStream ); |
|
228 iBroken = aStream.ReadInt8L(); |
|
229 iAlwaysVisible = aStream.ReadInt8L(); |
|
230 iTransparent = aStream.ReadInt8L(); |
|
231 } |
|
232 |
|
233 private: |
|
234 CNcdNodeIdentifier* iParentIdentifier; |
|
235 HBufC* iNameSpace; |
|
236 HBufC* iProvider; |
|
237 HBufC* iUri; |
|
238 HBufC* iNodeId; |
|
239 TBool iBroken; |
|
240 TBool iAlwaysVisible; |
|
241 TBool iTransparent; |
|
242 }; |
|
243 |
|
244 class CNcdNodeMap : public CBase |
|
245 { |
|
246 public: |
|
247 CNcdNodeMap( CNcdContentSource* aContentSource ) |
|
248 : iContentSource( aContentSource ) |
|
249 { |
|
250 } |
|
251 |
|
252 static CNcdNodeMap* NewL( RReadStream& aStream ) |
|
253 { |
|
254 CNcdNodeMap* self = new ( ELeave ) CNcdNodeMap; |
|
255 CleanupStack::PushL( self ); |
|
256 self->ConstructL( aStream ); |
|
257 CleanupStack::Pop( self ); |
|
258 return self; |
|
259 } |
|
260 |
|
261 virtual ~CNcdNodeMap() |
|
262 { |
|
263 delete iContentSource; |
|
264 iNodes.ResetAndDestroy(); |
|
265 } |
|
266 |
|
267 TBool ContainsNode( const CNcdNodeIdentifier& aNodeIdentifier ) |
|
268 { |
|
269 for ( TInt i = 0; i < iNodes.Count(); i++ ) |
|
270 { |
|
271 if ( iNodes[i]->Equals( aNodeIdentifier ) ) |
|
272 { |
|
273 return ETrue; |
|
274 } |
|
275 } |
|
276 return EFalse; |
|
277 } |
|
278 |
|
279 void ExternalizeL( RWriteStream& aStream ) |
|
280 { |
|
281 iContentSource->ExternalizeL( aStream ); |
|
282 aStream.WriteInt32L( iNodes.Count() ); |
|
283 for ( TInt i = 0; i < iNodes.Count(); i++ ) |
|
284 { |
|
285 iNodes[i]->ExternalizeL( aStream ); |
|
286 } |
|
287 } |
|
288 |
|
289 private: |
|
290 CNcdNodeMap() |
|
291 { |
|
292 } |
|
293 |
|
294 void ConstructL( RReadStream& aStream ) |
|
295 { |
|
296 DLTRACEIN(("")); |
|
297 iContentSource = CNcdContentSource::NewL( aStream ); |
|
298 TInt32 nodeCount = aStream.ReadInt32L(); |
|
299 for ( TInt i = 0; i < nodeCount; i++ ) |
|
300 { |
|
301 CNcdNodeIdentifier* nodeId = CNcdNodeIdentifier::NewLC( aStream ); |
|
302 iNodes.AppendL( nodeId ); |
|
303 CleanupStack::Pop( nodeId ); |
|
304 } |
|
305 } |
|
306 |
|
307 public: |
|
308 CNcdContentSource* iContentSource; |
|
309 RPointerArray<CNcdNodeIdentifier> iNodes; |
|
310 }; |
|
311 |
|
312 class CNcdFolderContent : public CBase |
|
313 { |
|
314 public: |
|
315 static CNcdFolderContent* NewL( |
|
316 CNcdNodeIdentifier* aFolderIdentifier, TInt aPositionInGrid ) |
|
317 { |
|
318 CNcdFolderContent* self = |
|
319 new ( ELeave ) CNcdFolderContent( aFolderIdentifier, aPositionInGrid ); |
|
320 return self; |
|
321 } |
|
322 |
|
323 static CNcdFolderContent* NewLC( RReadStream& aStream ) |
|
324 { |
|
325 CNcdFolderContent* self = new ( ELeave ) CNcdFolderContent; |
|
326 CleanupStack::PushL( self ); |
|
327 self->InternalizeL( aStream ); |
|
328 return self; |
|
329 } |
|
330 |
|
331 ~CNcdFolderContent() |
|
332 { |
|
333 delete iFolderIdentifier; |
|
334 iContentSources.ResetAndDestroy(); |
|
335 } |
|
336 |
|
337 TInt Find( const CNcdContentSource& aContentSource ) const |
|
338 { |
|
339 for ( TInt i = 0; i < iContentSources.Count(); i++ ) |
|
340 { |
|
341 if ( iContentSources[i]->Equals( aContentSource ) ) |
|
342 { |
|
343 return i; |
|
344 } |
|
345 } |
|
346 return KErrNotFound; |
|
347 } |
|
348 |
|
349 const CNcdNodeIdentifier& FolderIdentifier() const |
|
350 { |
|
351 DASSERT( iFolderIdentifier ); |
|
352 return *iFolderIdentifier; |
|
353 } |
|
354 |
|
355 TInt PositionInGrid() const |
|
356 { |
|
357 return iPositionInGrid; |
|
358 } |
|
359 |
|
360 CNcdContentSource& ContentSource( TInt aIndex ) const |
|
361 { |
|
362 DASSERT( aIndex >= 0 && aIndex < iContentSources.Count() ); |
|
363 return *iContentSources[aIndex]; |
|
364 } |
|
365 |
|
366 TInt ContentSourceCount() const |
|
367 { |
|
368 return iContentSources.Count(); |
|
369 } |
|
370 |
|
371 void AppendContentSourceL( CNcdContentSource* aContentSource ) |
|
372 { |
|
373 iContentSources.AppendL( aContentSource ); |
|
374 } |
|
375 |
|
376 void ClearContentSources() |
|
377 { |
|
378 iContentSources.ResetAndDestroy(); |
|
379 } |
|
380 |
|
381 void ExternalizeL( RWriteStream& aStream ) |
|
382 { |
|
383 DLTRACEIN(("")); |
|
384 aStream.WriteInt32L( iPositionInGrid ); |
|
385 iFolderIdentifier->ExternalizeL( aStream ); |
|
386 aStream.WriteInt32L( iContentSources.Count() ); |
|
387 for ( TInt i = 0; i < iContentSources.Count(); i++ ) |
|
388 { |
|
389 iContentSources[i]->ExternalizeL( aStream ); |
|
390 } |
|
391 } |
|
392 |
|
393 |
|
394 protected: |
|
395 CNcdFolderContent( CNcdNodeIdentifier* aFolderIdentifier, TInt aPositionInGrid ) : |
|
396 iPositionInGrid( aPositionInGrid ), iFolderIdentifier( aFolderIdentifier ) |
|
397 { |
|
398 } |
|
399 |
|
400 CNcdFolderContent() |
|
401 { |
|
402 } |
|
403 |
|
404 void InternalizeL( RReadStream& aStream ) |
|
405 { |
|
406 DLTRACEIN(("")); |
|
407 iPositionInGrid = aStream.ReadInt32L(); |
|
408 delete iFolderIdentifier; |
|
409 iFolderIdentifier = NULL; |
|
410 iFolderIdentifier = CNcdNodeIdentifier::NewL( aStream ); |
|
411 |
|
412 iContentSources.ResetAndDestroy(); |
|
413 TInt contentSourceCount = aStream.ReadInt32L(); |
|
414 for ( TInt i = 0; i < contentSourceCount; i++ ) |
|
415 { |
|
416 CNcdContentSource* contentSource = CNcdContentSource::NewL( aStream ); |
|
417 CleanupStack::PushL( contentSource ); |
|
418 iContentSources.AppendL( contentSource ); |
|
419 CleanupStack::Pop( contentSource ); |
|
420 } |
|
421 } |
|
422 |
|
423 |
|
424 private: |
|
425 TInt iPositionInGrid; |
|
426 CNcdNodeIdentifier* iFolderIdentifier; |
|
427 RPointerArray<CNcdContentSource> iContentSources; |
|
428 }; |
|
429 |
|
430 |
|
431 class CNcdContentSourceMap : public CBase |
|
432 { |
|
433 public: |
|
434 static CNcdContentSourceMap* NewL() |
|
435 { |
|
436 CNcdContentSourceMap* self = |
|
437 new( ELeave ) CNcdContentSourceMap; |
|
438 CleanupStack::PushL( self ); |
|
439 self->ConstructL(); |
|
440 CleanupStack::Pop( self ); |
|
441 return self; |
|
442 } |
|
443 |
|
444 static CNcdContentSourceMap* NewL( RReadStream& aStream ) |
|
445 { |
|
446 CNcdContentSourceMap* self = new ( ELeave ) CNcdContentSourceMap; |
|
447 CleanupStack::PushL( self ); |
|
448 self->ConstructL( aStream ); |
|
449 CleanupStack::Pop( self ); |
|
450 return self; |
|
451 } |
|
452 |
|
453 |
|
454 ~CNcdContentSourceMap() |
|
455 { |
|
456 iNodeMaps.ResetAndDestroy(); |
|
457 iFolderContents.ResetAndDestroy(); |
|
458 } |
|
459 |
|
460 |
|
461 TInt GetInsertIndexL( |
|
462 const CNcdContentSource& aContentSource, |
|
463 const CNcdNodeIdentifier& aParentIdentifier ) |
|
464 { |
|
465 DLTRACEIN(("")); |
|
466 TInt folderIndex = FindFolder( aParentIdentifier ); |
|
467 User::LeaveIfError( folderIndex ); |
|
468 CNcdFolderContent& folderContent = FolderContent( folderIndex ); |
|
469 |
|
470 TInt csIndex = folderContent.Find( aContentSource ); |
|
471 User::LeaveIfError( csIndex ); |
|
472 TInt insertIndex = 0; |
|
473 for ( TInt i = 0; i <= csIndex; i++ ) |
|
474 { |
|
475 CNcdContentSource& contentSource = folderContent.ContentSource( i ); |
|
476 insertIndex += NodeCount( contentSource ); |
|
477 } |
|
478 |
|
479 if ( aParentIdentifier.NodeNameSpace() == |
|
480 NcdProviderDefines::KRootNodeNameSpace ) |
|
481 { |
|
482 // There may be bundles before this content source, so the index |
|
483 // must be increased possibly. |
|
484 for ( TInt i = 0; i < iFolderContents.Count(); i++ ) |
|
485 { |
|
486 if ( iFolderContents[i]->FolderIdentifier().NodeNameSpace() != |
|
487 NcdProviderDefines::KRootNodeNameSpace && |
|
488 iFolderContents[i]->PositionInGrid() <= csIndex ) |
|
489 { |
|
490 insertIndex++; |
|
491 } |
|
492 } |
|
493 return insertIndex; |
|
494 } |
|
495 else |
|
496 { |
|
497 return insertIndex; |
|
498 } |
|
499 } |
|
500 |
|
501 void AppendContentSourceL( |
|
502 CNcdContentSource* aContentSource, |
|
503 TInt aPositionInGrid = 0 ) |
|
504 { |
|
505 DLTRACEIN(("")); |
|
506 CNcdNodeMap* map = new ( ELeave ) CNcdNodeMap( aContentSource->CopyL() ); |
|
507 CleanupStack::PushL( map ); |
|
508 iNodeMaps.AppendL( map ); |
|
509 CleanupStack::Pop( map ); |
|
510 |
|
511 TInt folderIndex = FindFolder( aContentSource->ParentIdentifier() ); |
|
512 if ( folderIndex != KErrNotFound ) |
|
513 { |
|
514 CNcdFolderContent& folderContent = FolderContent( folderIndex ); |
|
515 folderContent.AppendContentSourceL( aContentSource ); |
|
516 } |
|
517 else |
|
518 { |
|
519 CNcdNodeIdentifier* parentCopy = |
|
520 CNcdNodeIdentifier::NewLC( aContentSource->ParentIdentifier() ); |
|
521 CNcdFolderContent* folderContent = CNcdFolderContent::NewL( |
|
522 parentCopy, aPositionInGrid ); |
|
523 CleanupStack::Pop( parentCopy ); |
|
524 CleanupStack::PushL( folderContent ); |
|
525 iFolderContents.AppendL( folderContent ); |
|
526 CleanupStack::Pop( folderContent ); |
|
527 folderContent->AppendContentSourceL( aContentSource ); |
|
528 } |
|
529 } |
|
530 |
|
531 void AppendFolderL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
532 TInt aPositionInGrid = 0 ) |
|
533 { |
|
534 TInt folderIndex = FindFolder( aNodeIdentifier ); |
|
535 if ( folderIndex == KErrNotFound ) |
|
536 { |
|
537 CNcdNodeIdentifier* parentCopy = |
|
538 CNcdNodeIdentifier::NewLC( aNodeIdentifier ); |
|
539 CNcdFolderContent* folderContent = CNcdFolderContent::NewL( |
|
540 parentCopy, aPositionInGrid ); |
|
541 CleanupStack::Pop( parentCopy ); |
|
542 CleanupStack::PushL( folderContent ); |
|
543 iFolderContents.AppendL( folderContent ); |
|
544 CleanupStack::Pop( folderContent ); |
|
545 } |
|
546 } |
|
547 |
|
548 void AddNodeToContentSourceL( |
|
549 CNcdNodeIdentifier* aNodeIdentifier, |
|
550 CNcdContentSource& aContentSource ) |
|
551 { |
|
552 DLTRACEIN(("")); |
|
553 TInt index = Find( aContentSource ); |
|
554 User::LeaveIfError( index ); |
|
555 CNcdNodeMap* map = iNodeMaps[index]; |
|
556 if ( !map->ContainsNode( *aNodeIdentifier ) ) |
|
557 { |
|
558 map->iNodes.AppendL( aNodeIdentifier ); |
|
559 } |
|
560 } |
|
561 |
|
562 TInt ContentSourceCount() |
|
563 { |
|
564 return iNodeMaps.Count(); |
|
565 } |
|
566 |
|
567 CNcdContentSource& ContentSource( TInt aIndex ) |
|
568 { |
|
569 return *iNodeMaps[aIndex]->iContentSource; |
|
570 } |
|
571 |
|
572 TBool HasContentSource( const CNcdContentSource& aContentSource ) |
|
573 { |
|
574 TInt index = Find( aContentSource ); |
|
575 return index != KErrNotFound; |
|
576 } |
|
577 |
|
578 CNcdContentSource& ContentSourceL( const CNcdContentSource& aContentSource ) |
|
579 { |
|
580 TInt index = Find( aContentSource ); |
|
581 if ( index == KErrNotFound ) |
|
582 { |
|
583 User::Leave( KErrNotFound ); |
|
584 } |
|
585 |
|
586 return *iNodeMaps[index]->iContentSource; |
|
587 } |
|
588 |
|
589 RPointerArray<CNcdNodeIdentifier>& NodesL( |
|
590 const CNcdContentSource& aContentSource ) |
|
591 { |
|
592 |
|
593 TInt index = Find( aContentSource ); |
|
594 if ( index == KErrNotFound ) |
|
595 { |
|
596 User::Leave( KErrNotFound ); |
|
597 } |
|
598 return iNodeMaps[index]->iNodes; |
|
599 } |
|
600 |
|
601 TInt BundleFolderCount() const |
|
602 { |
|
603 TInt count( 0 ); |
|
604 for ( TInt i = 0; i < iFolderContents.Count(); i++ ) |
|
605 { |
|
606 if ( iFolderContents[i]->FolderIdentifier().NodeNameSpace() != |
|
607 NcdProviderDefines::KRootNodeNameSpace ) |
|
608 { |
|
609 count++; |
|
610 } |
|
611 } |
|
612 return count; |
|
613 } |
|
614 |
|
615 const CNcdNodeIdentifier& BundleFolder( TInt aIndex ) const |
|
616 { |
|
617 TInt bundleIndex( 0 ); |
|
618 for ( TInt i = 0; i < iFolderContents.Count(); i++ ) |
|
619 { |
|
620 if ( iFolderContents[i]->FolderIdentifier().NodeNameSpace() != NcdProviderDefines::KRootNodeNameSpace ) |
|
621 { |
|
622 if ( aIndex == bundleIndex ) |
|
623 { |
|
624 return iFolderContents[i]->FolderIdentifier(); |
|
625 } |
|
626 bundleIndex++; |
|
627 } |
|
628 } |
|
629 |
|
630 DASSERT( EFalse ); |
|
631 return iFolderContents[0]->FolderIdentifier(); |
|
632 } |
|
633 |
|
634 TBool HasBundleFolder( const CNcdNodeIdentifier& aNodeIdentifier ) |
|
635 { |
|
636 DLTRACEIN(("")); |
|
637 TInt index = FindFolder( aNodeIdentifier ); |
|
638 if ( index != KErrNotFound && aNodeIdentifier.NodeNameSpace() != NcdProviderDefines::KRootNodeNameSpace ) |
|
639 { |
|
640 return ETrue; |
|
641 } |
|
642 return EFalse; |
|
643 } |
|
644 |
|
645 TInt FindFolder( const CNcdNodeIdentifier& aFolderIdentifier ) const |
|
646 { |
|
647 for ( TInt i = 0; i < iFolderContents.Count(); i++ ) |
|
648 { |
|
649 if ( iFolderContents[i]->FolderIdentifier().Equals( aFolderIdentifier ) ) |
|
650 { |
|
651 return i; |
|
652 } |
|
653 } |
|
654 |
|
655 return KErrNotFound; |
|
656 } |
|
657 |
|
658 CNcdFolderContent& FolderContent( TInt aIndex ) const |
|
659 { |
|
660 DASSERT( aIndex >= 0 && aIndex < iFolderContents.Count() ); |
|
661 return *iFolderContents[aIndex]; |
|
662 } |
|
663 |
|
664 void ExternalizeL( RWriteStream& aStream ) |
|
665 { |
|
666 DLTRACEIN(( ( "Content source count=%d" ), iNodeMaps.Count() )); |
|
667 aStream.WriteInt32L( iNodeMaps.Count() ); |
|
668 for ( TInt i = 0; i < iNodeMaps.Count(); i++ ) |
|
669 { |
|
670 iNodeMaps[i]->ExternalizeL( aStream ); |
|
671 } |
|
672 DLINFO(( ( "Folder content count=%d" ), iFolderContents.Count() )); |
|
673 aStream.WriteInt32L( iFolderContents.Count() ); |
|
674 for ( TInt i = 0; i < iFolderContents.Count(); i++ ) |
|
675 { |
|
676 iFolderContents[i]->ExternalizeL( aStream ); |
|
677 } |
|
678 } |
|
679 |
|
680 private: |
|
681 CNcdContentSourceMap(){} |
|
682 void ConstructL(){} |
|
683 |
|
684 void ConstructL( RReadStream& aStream ) |
|
685 { |
|
686 DLTRACEIN(("")); |
|
687 TInt32 nodeMapCount = aStream.ReadInt32L(); |
|
688 DLINFO((("Content source count=%d"), nodeMapCount )); |
|
689 for ( TInt i = 0; i < nodeMapCount; i++ ) |
|
690 { |
|
691 CNcdNodeMap* map = CNcdNodeMap::NewL( aStream ); |
|
692 CleanupStack::PushL( map ); |
|
693 iNodeMaps.AppendL( map ); |
|
694 CleanupStack::Pop( map ); |
|
695 } |
|
696 |
|
697 TInt32 folderContentCount = aStream.ReadInt32L(); |
|
698 DLINFO((("Folder content count=%d"), folderContentCount )); |
|
699 for ( TInt i = 0; i < folderContentCount; i++ ) |
|
700 { |
|
701 CNcdFolderContent* content = CNcdFolderContent::NewLC( aStream ); |
|
702 iFolderContents.AppendL( content ); |
|
703 CleanupStack::Pop( content ); |
|
704 } |
|
705 } |
|
706 |
|
707 TInt Find( const CNcdContentSource& aContentSource ) const |
|
708 { |
|
709 for ( TInt i = 0; i < iNodeMaps.Count(); i++ ) |
|
710 { |
|
711 if ( iNodeMaps[i]->iContentSource->Equals( aContentSource ) ) |
|
712 { |
|
713 return i; |
|
714 } |
|
715 } |
|
716 return KErrNotFound; |
|
717 } |
|
718 |
|
719 |
|
720 TInt NodeCount( const CNcdContentSource& aContentSource ) const |
|
721 { |
|
722 TInt index = Find( aContentSource ); |
|
723 DASSERT( index >= 0 && index < iNodeMaps.Count() ); |
|
724 CNcdNodeMap* map = iNodeMaps[index]; |
|
725 return map->iNodes.Count(); |
|
726 } |
|
727 |
|
728 private: |
|
729 RPointerArray<CNcdNodeMap> iNodeMaps; |
|
730 RPointerArray<CNcdFolderContent> iFolderContents; |
|
731 |
|
732 }; |
|
733 |
|
734 |
|
735 /** |
|
736 * Load node operation implementation. |
|
737 * |
|
738 * Handles the "loading of root node" i.e. creates |
|
739 * a root node from a conf protocol response. |
|
740 * |
|
741 * @lib ?library |
|
742 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
743 */ |
|
744 class CNcdLoadRootNodeOperation : public CNcdBaseOperation, |
|
745 public MNcdParserObserver, |
|
746 public MCatalogsHttpObserver, |
|
747 public MNcdParserConfigurationProtocolObserver, |
|
748 public MNcdConfigurationObserver |
|
749 { |
|
750 |
|
751 public: |
|
752 |
|
753 /** Sub states of root node operation */ |
|
754 enum TRootNodeState |
|
755 { |
|
756 EConfRequest, // create and send a conf request |
|
757 EReceiveConf, // receive and parse conf data |
|
758 EConfQuery, // respond to conf query |
|
759 EBrowseRequest, // create sub-operations |
|
760 EReceiveBrowse, // wait for sub-operations to complete |
|
761 EComplete, // everything done |
|
762 EFailed // operation failed |
|
763 }; |
|
764 |
|
765 |
|
766 static CNcdLoadRootNodeOperation* NewL( |
|
767 TInt aClientUid, |
|
768 CNcdGeneralManager& aGeneralManager, |
|
769 MCatalogsHttpSession& aHttpSession, |
|
770 MNcdOperationRemoveHandler* aRemoveHandler, |
|
771 MCatalogsSession& aSession ); |
|
772 |
|
773 static CNcdLoadRootNodeOperation* NewLC( |
|
774 TInt aClientUid, |
|
775 CNcdGeneralManager& aGeneralManager, |
|
776 MCatalogsHttpSession& aHttpSession, |
|
777 MNcdOperationRemoveHandler* aRemoveHandler, |
|
778 MCatalogsSession& aSession ); |
|
779 |
|
780 virtual ~CNcdLoadRootNodeOperation(); |
|
781 |
|
782 /** |
|
783 * Returns the identifier of the parent node this operation is loading. |
|
784 * |
|
785 * @return Identifier of the parent node. |
|
786 */ |
|
787 const CNcdNodeIdentifier& NodeIdentifier() const; |
|
788 |
|
789 public: //from CNcdBaseOperation |
|
790 |
|
791 /** |
|
792 * @see CNcdBaseOperation::Cancel |
|
793 */ |
|
794 virtual void Cancel(); |
|
795 |
|
796 /** |
|
797 * @see CNcdBaseOperation::HandleCancelMessage |
|
798 */ |
|
799 virtual void HandleCancelMessage( MCatalogsBaseMessage* aMessage ); |
|
800 |
|
801 public: // from MCatalogsHttpObserver |
|
802 |
|
803 /** |
|
804 * @see MCatalogsHttpObserver::HandleHttpEventL |
|
805 */ |
|
806 virtual void HandleHttpEventL( |
|
807 MCatalogsHttpOperation& aOperation, |
|
808 TCatalogsHttpEvent aEvent ); |
|
809 |
|
810 /** |
|
811 * @see MCatalogsHttpObserver::HandleHttpError() |
|
812 */ |
|
813 TBool HandleHttpError( |
|
814 MCatalogsHttpOperation& aOperation, |
|
815 TCatalogsHttpError aError ); |
|
816 |
|
817 public: //from MNcdParserObserver |
|
818 |
|
819 /** |
|
820 * @see MNcdParserObserver |
|
821 */ |
|
822 virtual void ParseError( TInt aErrorCode ); |
|
823 |
|
824 /** |
|
825 * @see MNcdParserObserver |
|
826 */ |
|
827 virtual void ParseCompleteL( TInt aError ); |
|
828 |
|
829 public: // from MNcdParserConfigurationProtocolObserver |
|
830 |
|
831 virtual void ConfigurationBeginL( const TDesC& aVersion, |
|
832 TInt aExpirationDelta ); |
|
833 virtual void ConfigurationQueryL( MNcdConfigurationProtocolQuery* aQuery ); |
|
834 |
|
835 virtual void ClientConfigurationL( |
|
836 MNcdConfigurationProtocolClientConfiguration* aConfiguration ); |
|
837 virtual void ConfigurationDetailsL( |
|
838 CArrayPtr<MNcdConfigurationProtocolDetail>* aDetails ); |
|
839 virtual void ConfigurationActionRequestL( |
|
840 MNcdConfigurationProtocolActionRequest* aActionRequest ); |
|
841 virtual void ConfigurationErrorL( MNcdConfigurationProtocolError* aError ); |
|
842 virtual void ConfigurationServerDetailsL( MNcdConfigurationProtocolServerDetails* aServerDetails ); |
|
843 virtual void ConfigurationEndL(); |
|
844 |
|
845 public: // from MNcdOperationObserver |
|
846 |
|
847 /** |
|
848 * @see MNcdOperationObserver |
|
849 */ |
|
850 virtual void Progress( CNcdBaseOperation& aOperation ); |
|
851 |
|
852 /** |
|
853 * @see MNcdOperationObserver |
|
854 */ |
|
855 virtual void QueryReceived( CNcdBaseOperation& aOperation, |
|
856 CNcdQuery* aQuery ); |
|
857 |
|
858 /** |
|
859 * @see MNcdOperationObserver |
|
860 */ |
|
861 virtual void OperationComplete( CNcdBaseOperation* aOperation, |
|
862 TInt aError ); |
|
863 |
|
864 public: // from MNcdConfigurationObserver |
|
865 |
|
866 virtual void ConfigurationChangedL(); |
|
867 |
|
868 public: // from CCatalogsCommunicable |
|
869 |
|
870 /** |
|
871 * @see CCatalogsCommunicable |
|
872 */ |
|
873 virtual void ReceiveMessage( |
|
874 MCatalogsBaseMessage* aMessage, |
|
875 TInt aFunctionNumber ); |
|
876 |
|
877 public: // from MNcdParserErrorObserver |
|
878 |
|
879 virtual void ErrorL( MNcdPreminetProtocolError* aData ); |
|
880 |
|
881 |
|
882 protected: |
|
883 |
|
884 CNcdLoadRootNodeOperation( |
|
885 TInt aClientUid, |
|
886 CNcdGeneralManager& aGeneralManager, |
|
887 MCatalogsHttpSession& aHttpSession, |
|
888 MNcdOperationRemoveHandler* aRemoveHandler, |
|
889 MCatalogsSession& aSession ); |
|
890 |
|
891 void ConstructL(); |
|
892 |
|
893 HBufC8* CreateConfRequestLC( CNcdQuery* aQuery = NULL ); |
|
894 |
|
895 /** |
|
896 * Reverts the nodes which could not be retrieved due to broken content |
|
897 * source from NodeManager's temp cache to main RAM cache. |
|
898 */ |
|
899 void RevertNodesOfBrokenSourcesToCacheL(); |
|
900 |
|
901 /** |
|
902 * Reverts the given node belonging to given content source from |
|
903 * NodeManager's temp cache to the main cache. |
|
904 */ |
|
905 void RevertNodeL( |
|
906 const CNcdNodeIdentifier& aNodeIdentifier, |
|
907 const CNcdContentSource& aContentSource ); |
|
908 |
|
909 /** |
|
910 * Checks the content source map for nodes which belong to several parent |
|
911 * nodes and adds them as child of the different parents. |
|
912 */ |
|
913 void AddNodesToDifferentParentsL(); |
|
914 |
|
915 /** |
|
916 * Sets always visible flags to the metadata of the nodes that belong to |
|
917 * content sources defined as always visible in client configuration. |
|
918 */ |
|
919 void SetAlwaysVisibleFlagsL(); |
|
920 |
|
921 void ParseCatalogBundleL( const MNcdConfigurationProtocolDetail& aDetail ); |
|
922 |
|
923 static TBool ContainsNode( |
|
924 const RPointerArray<CNcdNodeIdentifier>& aNodes, |
|
925 const CNcdNodeIdentifier& aNode); |
|
926 |
|
927 protected: |
|
928 |
|
929 void HandleConfigurationDataRequestMessage( MCatalogsBaseMessage& aMessage ); |
|
930 |
|
931 |
|
932 protected: // from CNcdBaseOperation |
|
933 |
|
934 /** |
|
935 * @see CNcdBaseOperation::RunOperation |
|
936 */ |
|
937 virtual TInt RunOperation(); |
|
938 |
|
939 void DoRunOperationL(); |
|
940 |
|
941 /** |
|
942 * @see CNcdBaseOperation::RunOperation |
|
943 */ |
|
944 virtual void ChangeToPreviousStateL(); |
|
945 |
|
946 virtual TBool QueryCompletedL( CNcdQuery* aQuery ); |
|
947 |
|
948 private: // type declarations |
|
949 |
|
950 /** Sub states of master server redirection process */ |
|
951 enum TMasterServerRedirectionState |
|
952 { |
|
953 EBegin, // Start state. |
|
954 ERedirecting, // Redirecting. |
|
955 EReverted // Returned to use previous master server address. |
|
956 }; |
|
957 |
|
958 private: // data |
|
959 /** |
|
960 * A sub-state of this operation's execution. |
|
961 */ |
|
962 TRootNodeState iRootNodeState; |
|
963 |
|
964 /** |
|
965 * A sub-state of master server redirection. |
|
966 */ |
|
967 TMasterServerRedirectionState iMasterServerRedirectionState; |
|
968 |
|
969 /** |
|
970 * Nodes that have been loaded. This is used to store loaded |
|
971 * nodes identifiers before they can be sent to the proxy in a message. |
|
972 */ |
|
973 RPointerArray<CNcdNodeIdentifier> iLoadedNodes; |
|
974 |
|
975 /** |
|
976 * This flag is set to indicate that progress info should be sent |
|
977 * when the next message is received. |
|
978 */ |
|
979 TBool iSendProgress; |
|
980 |
|
981 CNcdNodeIdentifier* iRootNodeIdentifier; |
|
982 |
|
983 /** |
|
984 * Access point manager for creating access points. |
|
985 */ |
|
986 MCatalogsAccessPointManager& iAccessPointManager; |
|
987 |
|
988 |
|
989 /** |
|
990 * Http session for sending requests and receiving responses. |
|
991 * Not own. |
|
992 */ |
|
993 MCatalogsHttpSession& iHttpSession; |
|
994 |
|
995 MNcdProtocol& iProtocol; |
|
996 |
|
997 /** |
|
998 * Configuration manager for getting the Master Server Address |
|
999 */ |
|
1000 MNcdConfigurationManager& iConfigManager; |
|
1001 |
|
1002 /** |
|
1003 * Http operation for current transaction. |
|
1004 * Not own. |
|
1005 */ |
|
1006 MCatalogsHttpOperation* iTransaction; |
|
1007 |
|
1008 /** |
|
1009 * Sub-operations for browse requests. |
|
1010 */ |
|
1011 RPointerArray<CNcdLoadNodeOperationImpl> iSubOps; |
|
1012 RPointerArray<CNcdLoadNodeOperationImpl> iFailedSubOps; |
|
1013 RPointerArray<CNcdLoadNodeOperationImpl> iCompletedSubOps; |
|
1014 |
|
1015 TInt32 iClientUid; |
|
1016 |
|
1017 /** |
|
1018 * Content sources are stored here. |
|
1019 */ |
|
1020 CNcdContentSourceMap* iContentSourceMap; |
|
1021 |
|
1022 CNcdQuery* iConfQuery; |
|
1023 RPointerArray<CNcdQuery> iSubOpQuerys; |
|
1024 |
|
1025 |
|
1026 MNcdParserConfigurationProtocolObserver* iDefaultConfigurationProtocolObserver; |
|
1027 |
|
1028 HBufC* iServerUri; |
|
1029 |
|
1030 CBufFlat* iConfigResponseBuf; |
|
1031 |
|
1032 TInt iBundleInsertIndex; |
|
1033 |
|
1034 TBool iNodeDbLocked; |
|
1035 |
|
1036 /** |
|
1037 * Maps of current children and their children for new checking. |
|
1038 */ |
|
1039 RPointerArray<CNcdChildEntityMap> iChildEntityMaps; |
|
1040 }; |
|
1041 |
|
1042 #endif // C_NCDLOADROOTNODEOPERATIONIMPL_H |