ncdengine/provider/server/src/ncdnodelink.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 CNcdNodeLink class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdnodelink.h"
       
    20 #include "ncdnodeimpl.h"
       
    21 #include "catalogssession.h"
       
    22 #include "catalogsbasemessage.h"
       
    23 #include "ncdnodefunctionids.h"
       
    24 #include "ncdnodeclassids.h"
       
    25 #include "ncdnodeidentifier.h"
       
    26 #include "ncdproviderdefines.h"
       
    27 #include "catalogsconstants.h"
       
    28 #include "ncd_pp_entityref.h"
       
    29 #include "catalogsdebug.h"
       
    30 #include "catalogsutils.h"
       
    31 
       
    32 
       
    33 CNcdNodeLink::CNcdNodeLink( CNcdNode& aNode,
       
    34                             NcdNodeClassIds::TNcdNodeClassId aClassId )
       
    35 : CCatalogsCommunicable(),
       
    36   iClassId( aClassId ),
       
    37   iNode( aNode ),
       
    38   iLinkDownloadTime( KMinTInt64 )
       
    39     {
       
    40     }
       
    41 
       
    42 void CNcdNodeLink::ConstructL()
       
    43     {
       
    44     iParentIdentifier = CNcdNodeIdentifier::NewL();
       
    45     iRequestParentIdentifier = CNcdNodeIdentifier::NewL();
       
    46     iMetaDataIdentifier = CNcdNodeIdentifier::NewL();
       
    47     iTimeStamp = KNullDesC().AllocL();
       
    48     iCatalogsSourceName = KNullDesC().AllocL();
       
    49     iServerUri = KNullDesC().AllocL();
       
    50     iRemoteUri = KNullDesC().AllocL();
       
    51     iMetadataTimeStamp = KNullDesC().AllocL();
       
    52     }
       
    53 
       
    54 CNcdNodeLink::~CNcdNodeLink()
       
    55     {
       
    56     DLTRACEIN((""));
       
    57 
       
    58     // Do not delete node here because this link does not own it.
       
    59 
       
    60     delete iParentIdentifier;
       
    61     iParentIdentifier = NULL;
       
    62     
       
    63     delete iRequestParentIdentifier;
       
    64     iRequestParentIdentifier = NULL;
       
    65     
       
    66     delete iMetaDataIdentifier;
       
    67     iMetaDataIdentifier = NULL;
       
    68 
       
    69     delete iTimeStamp;
       
    70     iTimeStamp = NULL;
       
    71 
       
    72     delete iCatalogsSourceName;
       
    73     iCatalogsSourceName = NULL;
       
    74         
       
    75     delete iServerUri;
       
    76     iServerUri = NULL;
       
    77     
       
    78     delete iRemoteUri;
       
    79     iRemoteUri = NULL;
       
    80     
       
    81     DeletePtr( iMetadataTimeStamp );
       
    82     iQueries.Close();
       
    83     DLTRACEOUT((""));
       
    84     }        
       
    85     
       
    86 
       
    87 NcdNodeClassIds::TNcdNodeClassId CNcdNodeLink::ClassId() const
       
    88     {
       
    89     return iClassId;
       
    90     }    
       
    91     
       
    92 
       
    93 const TDesC& CNcdNodeLink::Timestamp() const
       
    94     {
       
    95     return *iTimeStamp;
       
    96     }
       
    97 
       
    98 const TDesC& CNcdNodeLink::ServerUri() const
       
    99     {
       
   100     return *iServerUri;
       
   101     }
       
   102     
       
   103 void CNcdNodeLink::SetServerUriL( const TDesC& aServerUri )
       
   104     {    
       
   105     AssignDesL( iServerUri, aServerUri );
       
   106     }
       
   107 
       
   108 const TDesC& CNcdNodeLink::RemoteUri() const
       
   109     {
       
   110     return *iRemoteUri;
       
   111     }
       
   112 
       
   113 MNcdPreminetProtocolEntityRef::TDescription CNcdNodeLink::Description() const
       
   114     {
       
   115     return iDescription;
       
   116     }
       
   117 
       
   118 TInt CNcdNodeLink::ValidUntilDelta() const
       
   119     {
       
   120     return iValidUntilDelta;
       
   121     }
       
   122 
       
   123 void CNcdNodeLink::SetValidUntilDelta( TInt aValidUntilDelta )
       
   124     {
       
   125     iValidUntilDelta = aValidUntilDelta;
       
   126     iLinkDownloadTime.HomeTime();
       
   127     }
       
   128 
       
   129 TBool CNcdNodeLink::ValidUntilAutoUpdate() const
       
   130     {
       
   131     return iValidUntilAutoUpdate;
       
   132     }
       
   133 
       
   134 
       
   135 const CNcdNodeIdentifier& CNcdNodeLink::ParentIdentifier() const
       
   136     {
       
   137     // Parent identifier contains always at least the empty values.
       
   138     return *iParentIdentifier;
       
   139     }
       
   140     
       
   141 void CNcdNodeLink::SetParentIdentifierL(
       
   142     const CNcdNodeIdentifier& aParentIdentifier ) 
       
   143     {
       
   144     CNcdNodeIdentifier* newParent = 
       
   145         CNcdNodeIdentifier::NewLC( aParentIdentifier );
       
   146 
       
   147     // Also set the request parent to correspond the same new identifier.
       
   148     // Notice that if the user wants these two differ. The request parent
       
   149     // identifier has to be reset after this function has been called.
       
   150     CNcdNodeIdentifier* newRequestParent =
       
   151         CNcdNodeIdentifier::NewLC( aParentIdentifier );
       
   152 
       
   153     delete iRequestParentIdentifier;
       
   154     iRequestParentIdentifier = newRequestParent;
       
   155     CleanupStack::Pop( newRequestParent );
       
   156 
       
   157     delete iParentIdentifier;
       
   158     iParentIdentifier = newParent;
       
   159     CleanupStack::Pop( newParent );
       
   160     }
       
   161 
       
   162 
       
   163 const CNcdNodeIdentifier& CNcdNodeLink::RequestParentIdentifier() const
       
   164     {
       
   165     // Parent identifier contains always at least the empty values.
       
   166     return *iRequestParentIdentifier;
       
   167     }
       
   168     
       
   169 void CNcdNodeLink::SetRequestParentIdentifierL(
       
   170     const CNcdNodeIdentifier& aRequestParentIdentifier ) 
       
   171     {
       
   172     CNcdNodeIdentifier* newParent = 
       
   173         CNcdNodeIdentifier::NewL( aRequestParentIdentifier );
       
   174     delete iRequestParentIdentifier;
       
   175     iRequestParentIdentifier = newParent;
       
   176     }
       
   177 
       
   178 
       
   179 TTime CNcdNodeLink::LinkDownloadTime() const
       
   180     {
       
   181     return iLinkDownloadTime;
       
   182     }
       
   183 
       
   184 TTime CNcdNodeLink::ExpiredTime() const
       
   185     {
       
   186     DLTRACEIN((""));
       
   187 
       
   188     // The expired time is the min value as default.
       
   189     // Then if the node data has not actually been loaded
       
   190     // this value is returned.
       
   191     TTime expired( KMinTInt64 );
       
   192         
       
   193     if ( ValidUntilDelta() == NcdProviderDefines::KNeverExpires )
       
   194         {
       
   195         // Because the delta value is set to never expire
       
   196         // value, the expire time should be as large as
       
   197         // possible
       
   198         DLINFO(("Delta was set to never expire. Largest expire time."));
       
   199         expired = KMaxTInt64;
       
   200         }
       
   201     else if ( LinkDownloadTime() != KMinTInt64 )
       
   202         {
       
   203         // The expiration time can be calculated because
       
   204         // the link has been downloaded and the delta value
       
   205         // has been given and it is not never expire value.
       
   206         DLINFO(("Calculate the expire time."));
       
   207 
       
   208         // The valid until delta is given in minutes.
       
   209         TTimeIntervalMinutes delta( ValidUntilDelta() );
       
   210         expired = LinkDownloadTime() + delta;
       
   211         
       
   212         if ( iTimeStamp->Length() && 
       
   213              iMetadataTimeStamp->Length() &&
       
   214              *iTimeStamp != *iMetadataTimeStamp ) 
       
   215             {
       
   216             DLINFO(("Link and metadata timestamps differ, expired"));
       
   217             expired = KMinTInt64;
       
   218             }
       
   219               
       
   220         }
       
   221 
       
   222     DLTRACEOUT(( "Expired time: %d", expired.Int64() ));
       
   223         
       
   224     return expired;
       
   225     }
       
   226     
       
   227 TBool CNcdNodeLink::IsExpired() const
       
   228     {
       
   229     DLTRACEIN((""));
       
   230 
       
   231     TTime currentTime;
       
   232     currentTime.HomeTime();
       
   233     
       
   234     if ( ExpiredTime() <= currentTime )
       
   235         {
       
   236         DLTRACEOUT(( "Link is expired" ));
       
   237         return ETrue;
       
   238         }
       
   239     else
       
   240         {
       
   241         DLTRACEOUT(( "Link is not expired" ));
       
   242         return EFalse;
       
   243         } 
       
   244     }
       
   245 
       
   246 void CNcdNodeLink::SetCatalogsSourceNameL( const TDesC& aSourceName )
       
   247     {
       
   248     HBufC* tmpSourceName = aSourceName.AllocL();
       
   249     delete iCatalogsSourceName;
       
   250     iCatalogsSourceName = tmpSourceName;
       
   251     }
       
   252 
       
   253 const TDesC& CNcdNodeLink::CatalogsSourceName() const
       
   254     {
       
   255     return *iCatalogsSourceName;
       
   256     }
       
   257 
       
   258 
       
   259 void CNcdNodeLink::SetRemoteFlag( TBool aRemoteFlag )
       
   260     {
       
   261     iRemoteFlag = aRemoteFlag;
       
   262     }
       
   263 
       
   264 TBool CNcdNodeLink::RemoteFlag() const
       
   265     {
       
   266     return iRemoteFlag;
       
   267     }
       
   268 
       
   269 
       
   270 const CNcdNodeIdentifier& CNcdNodeLink::MetaDataIdentifier() const
       
   271     {    
       
   272     DLNODEID(( *iMetaDataIdentifier ));    
       
   273     return *iMetaDataIdentifier;
       
   274     }
       
   275 
       
   276 void CNcdNodeLink::SetMetaDataIdentifierL( const CNcdNodeIdentifier& aIdentifier )
       
   277     {
       
   278     DLTRACEIN((""));
       
   279     CNcdNodeIdentifier* newIdentifier =
       
   280         CNcdNodeIdentifier::NewL( aIdentifier );
       
   281     delete iMetaDataIdentifier;
       
   282     iMetaDataIdentifier = newIdentifier;
       
   283     DLTRACEOUT((""));
       
   284     }
       
   285 
       
   286 
       
   287 void CNcdNodeLink::SetMetadataTimeStampL( const TDesC& aTimeStamp )
       
   288     {
       
   289     AssignDesL( iMetadataTimeStamp, aTimeStamp );
       
   290     }
       
   291 
       
   292 
       
   293 void CNcdNodeLink::InternalizeL( const MNcdPreminetProtocolEntityRef& aData,
       
   294                                  const CNcdNodeIdentifier& aParentIdentifier,
       
   295                                  const CNcdNodeIdentifier& aRequestParentIdentifier,
       
   296                                  const TUid& aClientUid )
       
   297     {
       
   298     DLTRACEIN((""));
       
   299 
       
   300     // Notice that we do not internalize the link id and namespace here
       
   301     // because this information is contained in the node-object that
       
   302     // wraps this link.
       
   303     // Also, note that the catalogs source name is not set here. That value
       
   304     // is set separately by using the setter function.
       
   305     
       
   306     HBufC* timeStamp = aData.Timestamp().AllocLC();
       
   307     HBufC* remoteUri = aData.RemoteUri().AllocLC();
       
   308     HBufC* serverUri = aData.ServerUri().AllocLC();
       
   309     
       
   310     CNcdNodeIdentifier* parentIdentifier = 
       
   311         CNcdNodeIdentifier::NewLC( aParentIdentifier );
       
   312     CNcdNodeIdentifier* requestParentIdentifier = 
       
   313         CNcdNodeIdentifier::NewLC( aRequestParentIdentifier );
       
   314     
       
   315      CNcdNodeIdentifier* metaDataIdentifier =
       
   316         CNcdNodeIdentifier::NewLC( aData.Namespace(),
       
   317                                    aData.Id(),
       
   318                                    aData.ServerUri(),
       
   319                                    aClientUid );
       
   320     
       
   321         
       
   322     // This may be a little bit risky if the system runs out of memory.
       
   323     // Then, the array may contain only part of the actual queries.
       
   324     
       
   325     iQueries.Reset();    
       
   326     const RArray<TInt>& queries = aData.Queries();
       
   327     for ( TInt i = 0; i < queries.Count(); ++i )
       
   328         {
       
   329         DLTRACE(("Query %d: %d", i, queries[ i ]));
       
   330         iQueries.AppendL( queries[ i ] );
       
   331         }
       
   332 
       
   333     // The function will not leave after this. So, it is safe to replace
       
   334     // old info by new.
       
   335 
       
   336 
       
   337     delete iMetaDataIdentifier;
       
   338     iMetaDataIdentifier = metaDataIdentifier;
       
   339     CleanupStack::Pop( metaDataIdentifier );
       
   340     
       
   341     delete iRequestParentIdentifier;
       
   342     iRequestParentIdentifier = requestParentIdentifier;
       
   343     CleanupStack::Pop( requestParentIdentifier );     
       
   344 
       
   345     delete iParentIdentifier;
       
   346     iParentIdentifier = parentIdentifier;
       
   347     CleanupStack::Pop( parentIdentifier );
       
   348     
       
   349 
       
   350     if ( *serverUri != KNullDesC )
       
   351         {
       
   352         // Do not delete this value if it already exists. This is set
       
   353         // for the root children from the operation.
       
   354         delete iServerUri;
       
   355         iServerUri = serverUri;
       
   356         CleanupStack::Pop( serverUri );
       
   357         }
       
   358 
       
   359     delete iRemoteUri;
       
   360     iRemoteUri = remoteUri;
       
   361     CleanupStack::Pop( remoteUri );
       
   362     
       
   363     delete iTimeStamp;
       
   364     iTimeStamp = timeStamp;
       
   365     CleanupStack::Pop( timeStamp );
       
   366     DLTRACE(( _L("timestamp: %S"), iTimeStamp ));
       
   367     
       
   368     iDescription = aData.Description();
       
   369     iValidUntilDelta = aData.ValidUntilDelta();
       
   370     iValidUntilAutoUpdate = aData.ValidUntilAutoUpdate();
       
   371 
       
   372     // Set the download time to this exact moment.
       
   373     iLinkDownloadTime.HomeTime();
       
   374     DLTRACE(( "downloadTime: %d", iLinkDownloadTime.Int64() ));
       
   375 
       
   376     DLTRACEOUT(("Internalization went ok :)"));
       
   377     }
       
   378 
       
   379 
       
   380 void CNcdNodeLink::ExternalizeL( RWriteStream& aStream )
       
   381     {
       
   382     DLTRACEIN((""));
       
   383     // Set all the membervariable values to the stream. So,
       
   384     // that the stream may be used later to create a new
       
   385     // object.
       
   386 
       
   387     aStream.WriteInt32L( iClassId );
       
   388 
       
   389     // Notice that we do not externalize the link id and namespace here
       
   390     // because this information is contained in the node-object that
       
   391     // wraps this link.
       
   392 
       
   393     ExternalizeDesL( Timestamp(), aStream );
       
   394     ExternalizeDesL( CatalogsSourceName(), aStream );
       
   395     ExternalizeDesL( RemoteUri(), aStream );
       
   396     ExternalizeDesL( ServerUri(), aStream );
       
   397     
       
   398     aStream << LinkDownloadTime().Int64();
       
   399     
       
   400     aStream.WriteInt32L( iDescription );
       
   401     aStream.WriteInt32L( iValidUntilDelta );
       
   402     aStream.WriteInt32L( iValidUntilAutoUpdate );
       
   403     aStream.WriteInt32L( RemoteFlag() );
       
   404             
       
   405     ParentIdentifier().ExternalizeL( aStream );
       
   406     RequestParentIdentifier().ExternalizeL( aStream );
       
   407     MetaDataIdentifier().ExternalizeL( aStream );
       
   408     
       
   409     aStream.WriteInt32L( iQueries.Count() );
       
   410     for ( TInt i = 0; i < iQueries.Count(); ++i )
       
   411         {
       
   412         aStream.WriteInt32L( iQueries[ i ] );
       
   413         }
       
   414 
       
   415     DLTRACEOUT((""));
       
   416     }
       
   417 
       
   418 
       
   419 void CNcdNodeLink::InternalizeL( RReadStream& aStream )
       
   420     {
       
   421     DLTRACEIN((""));
       
   422 
       
   423     // Read all the membervariable values from the stream and
       
   424     // set the values for this object.
       
   425 
       
   426     // First get the data to the tmp variables. So, we can be sure
       
   427     // that there is enough memory to set the member variables.
       
   428         
       
   429     HBufC* timeStamp( NULL );
       
   430     HBufC* catalogsSourceName( NULL );
       
   431     HBufC* remoteUri( NULL );
       
   432     HBufC* serverUri( NULL );
       
   433     TInt64 linkDownloadTime( 0 );    
       
   434 
       
   435     TInt description( 0 );
       
   436     TInt validUntilDelta( 0 );
       
   437     TBool validUntilAutoUpdate( EFalse );
       
   438     TBool remoteFlag( RemoteFlag() );
       
   439 
       
   440     CNcdNodeIdentifier* parentIdentifier( NULL );
       
   441     CNcdNodeIdentifier* requestParentIdentifier( NULL );
       
   442     CNcdNodeIdentifier* metaDataIdentifier( NULL );
       
   443         
       
   444     InternalizeDesL( timeStamp, aStream );
       
   445     CleanupStack::PushL( timeStamp );
       
   446 
       
   447     InternalizeDesL( catalogsSourceName, aStream );
       
   448     CleanupStack::PushL( catalogsSourceName );
       
   449     
       
   450     InternalizeDesL( remoteUri, aStream );
       
   451     CleanupStack::PushL( remoteUri );
       
   452     
       
   453     InternalizeDesL( serverUri, aStream );
       
   454     CleanupStack::PushL( serverUri );
       
   455 
       
   456     aStream >> linkDownloadTime;
       
   457     
       
   458     description = aStream.ReadInt32L();
       
   459     validUntilDelta = aStream.ReadInt32L();
       
   460     validUntilAutoUpdate = aStream.ReadInt32L();
       
   461     remoteFlag = aStream.ReadInt32L();
       
   462     
       
   463     // The parent identifier will contain at least empty values.
       
   464     parentIdentifier = CNcdNodeIdentifier::NewLC( aStream );
       
   465     requestParentIdentifier = CNcdNodeIdentifier::NewLC( aStream );
       
   466     metaDataIdentifier = CNcdNodeIdentifier::NewLC( aStream );
       
   467 
       
   468     // Now that descriptors were succesfully created we
       
   469     // may delete old info and replaced it by new data.
       
   470 
       
   471     delete iMetaDataIdentifier;
       
   472     iMetaDataIdentifier = metaDataIdentifier;
       
   473     CleanupStack::Pop( metaDataIdentifier );
       
   474     
       
   475     delete iRequestParentIdentifier;
       
   476     iRequestParentIdentifier = requestParentIdentifier;
       
   477     CleanupStack::Pop( requestParentIdentifier );     
       
   478 
       
   479     delete iParentIdentifier;
       
   480     iParentIdentifier = parentIdentifier;
       
   481     CleanupStack::Pop( parentIdentifier );     
       
   482 
       
   483     delete iServerUri;
       
   484     iServerUri = serverUri;
       
   485     CleanupStack::Pop( serverUri );
       
   486 
       
   487     delete iRemoteUri;
       
   488     iRemoteUri = remoteUri;
       
   489     CleanupStack::Pop( remoteUri );
       
   490 
       
   491     delete iCatalogsSourceName;
       
   492     iCatalogsSourceName = catalogsSourceName;
       
   493     CleanupStack::Pop( catalogsSourceName );
       
   494         
       
   495     delete iTimeStamp;
       
   496     iTimeStamp = timeStamp;
       
   497     CleanupStack::Pop( timeStamp );
       
   498 
       
   499     iLinkDownloadTime = linkDownloadTime;
       
   500 
       
   501     // We can be sure that enumeration is same as TInt
       
   502     iDescription = 
       
   503         static_cast<MNcdPreminetProtocolEntityRef::TDescription>(description);
       
   504     iValidUntilDelta = validUntilDelta;
       
   505     iValidUntilAutoUpdate = validUntilAutoUpdate;
       
   506     iRemoteFlag = remoteFlag;
       
   507 
       
   508     // Handle the query data
       
   509     
       
   510     TInt queryCount = aStream.ReadInt32L();
       
   511     // Reset old array if it contains data
       
   512     iQueries.Reset();
       
   513     for ( TInt i = 0; i < queryCount; ++i )
       
   514         {
       
   515         // Because all the other info has been already set,
       
   516         // here we just skip insertion if it failed for some reason.
       
   517         // Insert the queries that you can.
       
   518         TRAP_IGNORE( iQueries.Append( aStream.ReadInt32L() ) );
       
   519         }
       
   520         
       
   521     DLTRACEOUT((""));
       
   522     }
       
   523 
       
   524 
       
   525 
       
   526 void CNcdNodeLink::ReceiveMessage( MCatalogsBaseMessage* aMessage,
       
   527                                    TInt aFunctionNumber )
       
   528     {
       
   529     DLTRACEIN((""));
       
   530 
       
   531     DASSERT( aMessage );
       
   532     
       
   533     // Now, we can be sure that rest of the time iMessage exists.
       
   534     // This member variable is set for the CounterPartLost function.
       
   535     iMessage = aMessage;
       
   536         
       
   537     TInt trapError( KErrNone );
       
   538     
       
   539     switch( aFunctionNumber )
       
   540         {
       
   541         case NcdNodeFunctionIds::ENcdInternalize:
       
   542             TRAP( trapError, InternalizeRequestL( *aMessage ) );
       
   543             break;
       
   544 
       
   545         case NcdNodeFunctionIds::ENcdRelease:
       
   546             ReleaseRequest( *aMessage );
       
   547             break;
       
   548 
       
   549         default:
       
   550             break;
       
   551         }
       
   552 
       
   553     if ( trapError != KErrNone )
       
   554         {
       
   555         // Because something went wrong the complete has not been
       
   556         // yet called for the message.
       
   557         // So, inform the client about the error.
       
   558         aMessage->CompleteAndRelease( trapError );
       
   559         }
       
   560         
       
   561     // Because the message should not be used after this, set it NULL.
       
   562     // So, CounterPartLost function will know that no messages are
       
   563     // waiting the response at the moment.
       
   564     iMessage = NULL;        
       
   565     
       
   566     DLTRACEOUT((""));
       
   567     }
       
   568 
       
   569 
       
   570 void CNcdNodeLink::CounterPartLost( const MCatalogsSession& aSession )
       
   571     {
       
   572     // This function may be called whenever -- when the message is waiting
       
   573     // response or when the message does not exist.
       
   574     // iMessage may be NULL here, because in the end of the
       
   575     // ReceiveMessage it is set to NULL. The life time of the message
       
   576     // ends shortly after CompleteAndRelease is called.
       
   577     if ( iMessage != NULL )
       
   578         {
       
   579         iMessage->CounterPartLost( aSession );
       
   580         }    
       
   581     }
       
   582                   
       
   583 
       
   584 void CNcdNodeLink::InternalizeRequestL( MCatalogsBaseMessage& aMessage ) const
       
   585     {
       
   586     DLTRACEIN((""));
       
   587     
       
   588     CBufBase* buf = CBufFlat::NewL( KBufExpandSize );
       
   589     CleanupStack::PushL( buf );
       
   590     
       
   591     RBufWriteStream stream( *buf );
       
   592     CleanupClosePushL( stream );
       
   593 
       
   594 
       
   595     // Include all the necessary node data to the stream
       
   596     ExternalizeDataForRequestL( stream );     
       
   597     
       
   598     
       
   599     // Commits data to the stream when closing.
       
   600     CleanupStack::PopAndDestroy( &stream );
       
   601 
       
   602     if ( buf->Size() > 0 ) 
       
   603         {
       
   604         DLTRACE(( "Completing the message, buf len: %d", buf->Ptr(0).Length() ));
       
   605         }
       
   606     // If this leaves, ReceiveMessage function will complete the message.
       
   607     aMessage.CompleteAndReleaseL( buf->Ptr( 0 ), KErrNone );
       
   608         
       
   609     
       
   610     DLTRACE(("Deleting the buf"));
       
   611     CleanupStack::PopAndDestroy( buf );
       
   612         
       
   613     DLTRACEOUT((""));
       
   614     }
       
   615 
       
   616 void CNcdNodeLink::ExternalizeDataForRequestL( RWriteStream& aStream ) const
       
   617     {
       
   618     DLTRACEIN((""));
       
   619 
       
   620     // Link existed. So, insert info that link was found.
       
   621     aStream.WriteInt32L( ClassId() );
       
   622 
       
   623     // Notice that the proxy does not require all the information contained
       
   624     // in this class. So, send only the information that proxy wants.
       
   625 
       
   626     ExternalizeDesL( Timestamp(), aStream );
       
   627     ExternalizeDesL( CatalogsSourceName(), aStream );
       
   628     aStream.WriteInt32L( RemoteFlag() );
       
   629  
       
   630     aStream << ExpiredTime().Int64();    
       
   631         
       
   632     ParentIdentifierForRequestL( aStream );
       
   633     
       
   634     // Externalize the real parent too.
       
   635     ParentIdentifier().ExternalizeL( aStream );
       
   636         
       
   637     DLTRACEOUT((""));
       
   638     }
       
   639 
       
   640 
       
   641 void CNcdNodeLink::ReleaseRequest( MCatalogsBaseMessage& aMessage ) const
       
   642     {
       
   643     DLTRACEIN((""));
       
   644 
       
   645     // Decrease the reference count for this object.
       
   646     // When the reference count reaches zero, this object will be destroyed
       
   647     // and removed from the session.
       
   648     MCatalogsSession& requestSession( aMessage.Session() );
       
   649     TInt handle( aMessage.Handle() );
       
   650     aMessage.CompleteAndRelease( KErrNone );
       
   651     requestSession.RemoveObject( handle );
       
   652         
       
   653     DLTRACEOUT((""));
       
   654     }    
       
   655 
       
   656 
       
   657 CNcdNode& CNcdNodeLink::Node() const
       
   658     {
       
   659     return iNode;
       
   660     }
       
   661 
       
   662 
       
   663 void CNcdNodeLink::ParentIdentifierForRequestL( RWriteStream& aStream ) const
       
   664     {
       
   665     DLTRACEIN((""));
       
   666 
       
   667     // There is always at least an empty identifier value.
       
   668     RequestParentIdentifier().ExternalizeL( aStream );
       
   669 
       
   670     DLTRACEOUT((""));
       
   671     }