ncdengine/provider/server/src/ncdnodefolderlink.cpp
changeset 4 32704c33136d
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     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 CNcdNodeFolderLink class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdnodefolderlink.h"
       
    20 #include "ncd_pp_folderref.h"
       
    21 #include "catalogsdebug.h"
       
    22 
       
    23 
       
    24 CNcdNodeFolderLink* CNcdNodeFolderLink::NewL( CNcdNode& aNode )
       
    25     {
       
    26     CNcdNodeFolderLink* self = 
       
    27         CNcdNodeFolderLink::NewLC( aNode );
       
    28     CleanupStack::Pop( self );
       
    29     return self;        
       
    30     }
       
    31 
       
    32 CNcdNodeFolderLink* CNcdNodeFolderLink::NewLC( CNcdNode& aNode )
       
    33     {
       
    34     CNcdNodeFolderLink* self = new( ELeave ) CNcdNodeFolderLink( aNode );
       
    35     CleanupClosePushL( *self );
       
    36     self->ConstructL();
       
    37     return self;        
       
    38     }
       
    39 
       
    40 
       
    41 CNcdNodeFolderLink::CNcdNodeFolderLink( 
       
    42     CNcdNode& aNode,
       
    43     NcdNodeClassIds::TNcdNodeClassId aClassId )
       
    44 : CNcdNodeLink( aNode, aClassId )
       
    45     {
       
    46     }
       
    47 
       
    48 void CNcdNodeFolderLink::ConstructL()
       
    49     {
       
    50     CNcdNodeLink::ConstructL();
       
    51     }
       
    52 
       
    53 CNcdNodeFolderLink::~CNcdNodeFolderLink()
       
    54     {
       
    55     }        
       
    56     
       
    57 
       
    58 TInt CNcdNodeFolderLink::ExpectedChildrenCount() const
       
    59     {
       
    60     DLTRACEIN(( "iExpectedChildrenCount: %d", iExpectedChildrenCount ));
       
    61 
       
    62     return iExpectedChildrenCount;
       
    63     }
       
    64 
       
    65 
       
    66 void CNcdNodeFolderLink::InternalizeL( const MNcdPreminetProtocolEntityRef& aData,
       
    67                                        const CNcdNodeIdentifier& aParentIdentifier,
       
    68                                        const CNcdNodeIdentifier& aRequestParentIdentifier,
       
    69                                        const TUid& aClientUid )
       
    70     {
       
    71     DLTRACEIN((""));
       
    72 
       
    73     if( aData.Type() != MNcdPreminetProtocolEntityRef::EFolderRef )
       
    74         {
       
    75         DLERROR(("Wrong type"));
       
    76         DASSERT( EFalse );
       
    77         // The data should be for the folder
       
    78         User::Leave( KErrArgument );
       
    79         }
       
    80     
       
    81     // First internalize parent stuff
       
    82     CNcdNodeLink::InternalizeL( 
       
    83         aData, aParentIdentifier, aRequestParentIdentifier, aClientUid );
       
    84 
       
    85     // Safe to cast because the type was checked in the beginning
       
    86     // of this function.
       
    87     const MNcdPreminetProtocolFolderRef& castedData =
       
    88         static_cast<const MNcdPreminetProtocolFolderRef&>( aData );
       
    89         
       
    90     if( castedData.Count() != MNcdPreminetProtocolFolderRef::KValueNotSet )
       
    91         {
       
    92         DLTRACE(("Child count set -> change it, previous count: %d new count: %d",
       
    93             iExpectedChildrenCount, castedData.Count() ));
       
    94         iExpectedChildrenCount = castedData.Count();
       
    95         }
       
    96 
       
    97     DLTRACEOUT((""));
       
    98     }
       
    99 
       
   100     
       
   101 void CNcdNodeFolderLink::ExternalizeL( RWriteStream& aStream )
       
   102     {
       
   103     DLTRACEIN((""));
       
   104 
       
   105     // First use the parent to externalize the general data
       
   106     CNcdNodeLink::ExternalizeL( aStream );
       
   107     
       
   108     // Now externalize the data of this specific class
       
   109     aStream.WriteInt32L( iExpectedChildrenCount );
       
   110 
       
   111     DLTRACEOUT((""));
       
   112     }
       
   113     
       
   114 void CNcdNodeFolderLink::InternalizeL( RReadStream& aStream )
       
   115     {
       
   116     DLTRACEIN((""));
       
   117 
       
   118     // First use the parent to internalize the general data
       
   119     CNcdNodeLink::InternalizeL( aStream );
       
   120     
       
   121     // Now internalize the data of this specific class
       
   122     iExpectedChildrenCount = aStream.ReadInt32L();
       
   123 
       
   124     DLTRACEOUT((""));
       
   125     }
       
   126 
       
   127     
       
   128 void CNcdNodeFolderLink::ExternalizeDataForRequestL( RWriteStream& aStream ) const
       
   129     {
       
   130     // First use the parent to set the data into the stream
       
   131     CNcdNodeLink::ExternalizeDataForRequestL( aStream );
       
   132     
       
   133     // Then, insert the folder specific data.
       
   134     
       
   135     aStream.WriteInt32L( iExpectedChildrenCount );
       
   136     }