ncdengine/provider/client/src/ncdnodeuricontentproxy.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:   Contains CNcdNodeuriContentProxy class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdnodeuricontentproxy.h"
       
    20 #include "ncdnodemetadataproxy.h"
       
    21 #include "catalogsclientserver.h"
       
    22 #include "ncdnodeidentifier.h"
       
    23 #include "ncdnodefunctionids.h"
       
    24 #include "ncdnodeclassids.h"
       
    25 #include "catalogsinterfaceidentifier.h"
       
    26 #include "catalogsutils.h"
       
    27 #include "catalogsdebug.h"
       
    28 
       
    29 
       
    30 // ======== PUBLIC MEMBER FUNCTIONS ========
       
    31 
       
    32 CNcdNodeUriContentProxy* CNcdNodeUriContentProxy::NewL(
       
    33     MCatalogsClientServer& aSession,
       
    34     TInt aHandle,
       
    35     CNcdNodeMetadataProxy& aMetadata )
       
    36     {
       
    37     CNcdNodeUriContentProxy* self = 
       
    38         CNcdNodeUriContentProxy::NewLC( aSession, aHandle, aMetadata );
       
    39     CleanupStack::Pop( self );
       
    40     return self;
       
    41     }
       
    42 
       
    43 CNcdNodeUriContentProxy* CNcdNodeUriContentProxy::NewLC(
       
    44     MCatalogsClientServer& aSession,
       
    45     TInt aHandle,
       
    46     CNcdNodeMetadataProxy& aMetadata )
       
    47     {
       
    48     CNcdNodeUriContentProxy* self = 
       
    49         new( ELeave ) CNcdNodeUriContentProxy( aSession, aHandle, aMetadata );
       
    50     // Using PushL because the object does not have any references yet
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     return self;
       
    54     }
       
    55 
       
    56 
       
    57 CNcdNodeUriContentProxy::CNcdNodeUriContentProxy(
       
    58     MCatalogsClientServer& aSession,
       
    59     TInt aHandle,
       
    60     CNcdNodeMetadataProxy& aMetadata )
       
    61 : CNcdInterfaceBaseProxy( aSession, aHandle, &aMetadata ),
       
    62   iValidityDelta( -1 )
       
    63     {
       
    64     }
       
    65 
       
    66 
       
    67 void CNcdNodeUriContentProxy::ConstructL()
       
    68     {
       
    69     // Register the interface
       
    70     MNcdNodeUriContent* interface( this );
       
    71     AddInterfaceL( 
       
    72         CCatalogsInterfaceIdentifier::NewL( interface, this,
       
    73             MNcdNodeUriContent::KInterfaceUid ) );
       
    74     
       
    75     // Let this leave if the internalization fails.
       
    76     InternalizeL();
       
    77     }
       
    78 
       
    79 CNcdNodeUriContentProxy::~CNcdNodeUriContentProxy()
       
    80     {
       
    81     RemoveInterface( MNcdNodeUriContent::KInterfaceUid );
       
    82     delete iContentUri;
       
    83     }
       
    84 
       
    85 
       
    86 void CNcdNodeUriContentProxy::InternalizeL()
       
    87     {
       
    88     DLTRACEIN((""));
       
    89 
       
    90     HBufC8* data( NULL );
       
    91 
       
    92     User::LeaveIfError(
       
    93         ClientServerSession().
       
    94         SendSyncAlloc( NcdNodeFunctionIds::ENcdInternalize,
       
    95                        KNullDesC8,
       
    96                        data,
       
    97                        Handle(),
       
    98                        0 ) );
       
    99 
       
   100     if ( data == NULL )
       
   101         {
       
   102         DLERROR((""));
       
   103         User::Leave(  KErrNotFound );
       
   104         }
       
   105     
       
   106     CleanupStack::PushL( data );
       
   107     
       
   108     // Read the data from the stream and insert it to the memeber variables
       
   109     RDesReadStream stream( *data );
       
   110     CleanupClosePushL( stream );
       
   111     
       
   112     InternalizeDataL( stream );
       
   113     
       
   114     // Closes the stream
       
   115     CleanupStack::PopAndDestroy( &stream ); 
       
   116     CleanupStack::PopAndDestroy( data );
       
   117     
       
   118     DLTRACEOUT((""));    
       
   119     }
       
   120 
       
   121 
       
   122 // CNcdNodeUriContentProxy functions
       
   123     
       
   124 
       
   125 
       
   126 // Other functions
       
   127 
       
   128 void CNcdNodeUriContentProxy::InternalizeDataL( RReadStream& aStream )
       
   129     {
       
   130     DLTRACEIN((""));
       
   131 
       
   132     TInt classId( aStream.ReadInt32L() );
       
   133     
       
   134     if ( classId != NcdNodeClassIds::ENcdNodeUriContentClassId )
       
   135         {
       
   136         // classId is not recognized
       
   137         DLERROR(("Class id was not recognized!"));
       
   138         // For testing purposes assert here
       
   139         DASSERT( EFalse );
       
   140         
       
   141         // Otherwise leave is adequate
       
   142         User::Leave( KErrCorrupt );
       
   143         }
       
   144 
       
   145 
       
   146     InternalizeDesL( iContentUri, aStream );
       
   147     
       
   148     iValidityDelta = aStream.ReadInt32L();
       
   149 
       
   150     DLTRACEOUT((""));
       
   151     }
       
   152 
       
   153 const TDesC& CNcdNodeUriContentProxy::ContentUri() const
       
   154     {
       
   155     return *iContentUri;
       
   156     }
       
   157 
       
   158 TInt CNcdNodeUriContentProxy::ContentValidityDelta() const
       
   159     {
       
   160     return iValidityDelta;
       
   161     }
       
   162