ncdengine/provider/server/src/ncdrootnode.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     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 CNcdRootNode class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdrootnode.h"
       
    20 #include "ncdchildentity.h"
       
    21 #include "catalogsutils.h"
       
    22 
       
    23 // This is for the contentsourcemap
       
    24 #include "ncdloadrootnodeoperationimpl.h"
       
    25 
       
    26 
       
    27 CNcdRootNode* CNcdRootNode::NewL( 
       
    28     CNcdNodeManager& aNodeManager,
       
    29     const CNcdNodeIdentifier& aIdentifier )
       
    30     {
       
    31     CNcdRootNode* self = 
       
    32         CNcdRootNode::NewLC( aNodeManager, aIdentifier );
       
    33     CleanupStack::Pop( self );
       
    34     return self;        
       
    35     }
       
    36 
       
    37 CNcdRootNode* CNcdRootNode::NewLC(
       
    38     CNcdNodeManager& aNodeManager,
       
    39     const CNcdNodeIdentifier& aIdentifier )
       
    40     {
       
    41     // Notice that the default value for the class id is set in
       
    42     // the header constructor definition. No need to set it here.
       
    43     CNcdRootNode* self = 
       
    44         new( ELeave ) CNcdRootNode( aNodeManager );
       
    45     CleanupClosePushL( *self );
       
    46     self->ConstructL( aIdentifier );
       
    47     return self;        
       
    48     }
       
    49 
       
    50 CNcdRootNode::CNcdRootNode( CNcdNodeManager& aNodeManager,
       
    51                             NcdNodeClassIds::TNcdNodeClassId aNodeClassId ) 
       
    52 : CNcdParentOfTransparentNode( aNodeManager, aNodeClassId ) 
       
    53     {
       
    54     }
       
    55 
       
    56 void CNcdRootNode::ConstructL( const CNcdNodeIdentifier& aIdentifier ) 
       
    57     {
       
    58     CNcdParentOfTransparentNode::ConstructL( aIdentifier );
       
    59     iContentSourceMap = CNcdContentSourceMap::NewL();
       
    60     }
       
    61     
       
    62 CNcdRootNode::~CNcdRootNode() 
       
    63     {
       
    64     delete iContentSourceMap;
       
    65     }
       
    66     
       
    67 CNcdContentSourceMap& CNcdRootNode::ContentSourceMap() 
       
    68     {
       
    69     return *iContentSourceMap;
       
    70     }
       
    71     
       
    72 void CNcdRootNode::SetContentSourceMap( CNcdContentSourceMap* aMap ) 
       
    73     {
       
    74     DLTRACEIN((""));
       
    75     delete iContentSourceMap;
       
    76     iContentSourceMap = aMap;
       
    77     }
       
    78     
       
    79     
       
    80 void CNcdRootNode::ExternalizeL( RWriteStream& aStream ) 
       
    81     {
       
    82     DLTRACEIN((""));
       
    83     CNcdParentOfTransparentNode::ExternalizeL( aStream );
       
    84     iContentSourceMap->ExternalizeL( aStream );
       
    85     }
       
    86     
       
    87 void CNcdRootNode::InternalizeL( RReadStream& aStream ) 
       
    88     {
       
    89     DLTRACEIN((""));
       
    90     CNcdParentOfTransparentNode::InternalizeL( aStream );
       
    91     delete iContentSourceMap;
       
    92     iContentSourceMap = NULL;
       
    93     iContentSourceMap = CNcdContentSourceMap::NewL( aStream );
       
    94     }
       
    95 
       
    96 TInt CNcdRootNode::ServerChildCount() const
       
    97     {
       
    98     DLTRACEIN(( "this: %X, ChildCount: %d", this, ChildArray().Count() ));
       
    99     // root node's child count is always the number of children in the child array
       
   100     // because, contrary to regular folders, root node doesn't have an expected child count
       
   101     return ChildArray().Count();
       
   102     }
       
   103 
       
   104 const CNcdNodeIdentifier& CNcdRootNode::ChildByServerIndexL( TInt aIndex ) const
       
   105     {
       
   106     DLTRACEIN((""));    
       
   107     
       
   108     if ( aIndex < 0 || aIndex >= ChildArray().Count() )
       
   109         {
       
   110         // For debugging purposes
       
   111         DLERROR(("Wrong child index"));
       
   112         DASSERT( EFalse );
       
   113         User::Leave( KErrArgument );
       
   114         }
       
   115         
       
   116     return ChildArray()[aIndex]->Identifier();
       
   117     }