ncdengine/provider/client/src/ncdnodedependencyinfoimpl.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:   CNcdNodeDependencyInfo
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32strm.h>
       
    20 
       
    21 #include "ncdnodedependencyinfoimpl.h"
       
    22 #include "ncddependencyinfo.h"
       
    23 #include "ncdnodeidentifier.h"
       
    24 #include "ncdnodeproxy.h"
       
    25 #include "ncdnodemanagerproxy.h"
       
    26 #include "catalogsutils.h"
       
    27 #include "catalogsdebug.h"
       
    28 
       
    29 
       
    30 CNcdNodeDependencyInfo* CNcdNodeDependencyInfo::NewL( const CNcdDependencyInfo& aInfo,
       
    31                                                       CNcdNodeManagerProxy& aNodeManager )
       
    32     {
       
    33     CNcdNodeDependencyInfo* self = 
       
    34         CNcdNodeDependencyInfo::NewLC( aInfo, aNodeManager );
       
    35     CleanupStack::Pop( self );
       
    36     return self;            
       
    37     }
       
    38     
       
    39 CNcdNodeDependencyInfo* CNcdNodeDependencyInfo::NewLC( const CNcdDependencyInfo& aInfo,
       
    40                                                        CNcdNodeManagerProxy& aNodeManager )
       
    41     {
       
    42     CNcdNodeDependencyInfo* self = 
       
    43         new( ELeave ) CNcdNodeDependencyInfo( aNodeManager );
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL( aInfo );
       
    46     return self;            
       
    47     }
       
    48 
       
    49 
       
    50 void CNcdNodeDependencyInfo::ConstructL( const CNcdDependencyInfo& aInfo  )
       
    51     {
       
    52     iUid.iUid = aInfo.Uid().iUid;
       
    53 
       
    54     const CNcdNodeIdentifier* tmpIdentifier( aInfo.Identifier() );
       
    55     if ( tmpIdentifier != NULL )
       
    56         {
       
    57         iIdentifier = CNcdNodeIdentifier::NewL( *tmpIdentifier );        
       
    58         }
       
    59 
       
    60     iName = aInfo.Name().AllocL();
       
    61     iVersion = aInfo.Version().AllocL();
       
    62     
       
    63     iDependencyState = aInfo.DependencyState();
       
    64     }
       
    65 
       
    66 
       
    67 CNcdNodeDependencyInfo::CNcdNodeDependencyInfo( CNcdNodeManagerProxy& aNodeManager ): 
       
    68     CBase(),
       
    69     iNodeManager( aNodeManager )
       
    70     {
       
    71     
       
    72     }
       
    73     
       
    74 CNcdNodeDependencyInfo::~CNcdNodeDependencyInfo()
       
    75     {
       
    76     
       
    77     delete iName;
       
    78     delete iVersion;
       
    79     delete iIdentifier;
       
    80     }
       
    81 
       
    82 
       
    83 const TDesC& CNcdNodeDependencyInfo::Name() const
       
    84     {
       
    85     return *iName;
       
    86     }    
       
    87 
       
    88 const TDesC& CNcdNodeDependencyInfo::Version() const
       
    89     {
       
    90     return *iVersion;
       
    91     }
       
    92     
       
    93 TUid CNcdNodeDependencyInfo::Uid() const
       
    94     {
       
    95     return iUid;
       
    96     }
       
    97 
       
    98 MNcdNode* CNcdNodeDependencyInfo::DependencyNodeL() const
       
    99     {
       
   100     DLTRACEIN((""));
       
   101     
       
   102     // Notice, that this class contains the information about
       
   103     // the metadata identifier that is used to create the node.
       
   104     // If the identifier is NULL, then the dependency was not
       
   105     // given as a node but as a content.
       
   106     if ( Identifier() == NULL )
       
   107         {
       
   108         return NULL;
       
   109         }
       
   110 
       
   111     // The node might have not been created yet, so create it if necessary.
       
   112     CNcdNodeProxy* node( 
       
   113         &NodeManager().
       
   114             CreateTemporaryOrSupplierNodeL(
       
   115                 *Identifier() ) );
       
   116         
       
   117     // Increase the ref count by one here. 
       
   118     node->AddRef();
       
   119 
       
   120     return node;
       
   121     }
       
   122 
       
   123 
       
   124 TNcdDependencyState CNcdNodeDependencyInfo::State() const
       
   125     {
       
   126     DLTRACEIN((""));
       
   127     return iDependencyState;
       
   128     }
       
   129     
       
   130 
       
   131 const CNcdNodeIdentifier* CNcdNodeDependencyInfo::Identifier() const
       
   132     {
       
   133     return iIdentifier;
       
   134     }
       
   135 
       
   136 
       
   137 CNcdNodeManagerProxy& CNcdNodeDependencyInfo::NodeManager() const
       
   138     {
       
   139     return iNodeManager;
       
   140     }