ncdengine/provider/client/src/ncdnodedisclaimerproxy.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:   Contains CNcdNodeDisclaimerProxy class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdnodedisclaimerproxy.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 #include "ncderrors.h"
       
    29 
       
    30 
       
    31 CNcdNodeDisclaimerProxy::CNcdNodeDisclaimerProxy(
       
    32     MCatalogsClientServer& aSession,
       
    33     TInt aHandle,
       
    34     CNcdNodeMetadataProxy* aMetadata )
       
    35 : CNcdInterfaceBaseProxy( aSession, aHandle, aMetadata ),
       
    36   iResponse( ENoResponse ) 
       
    37     {
       
    38 
       
    39     }
       
    40 
       
    41 
       
    42 void CNcdNodeDisclaimerProxy::ConstructL()
       
    43     {
       
    44     // If the internalization fails, let this leave.    
       
    45     InternalizeL();
       
    46     }
       
    47 
       
    48 
       
    49 CNcdNodeDisclaimerProxy* CNcdNodeDisclaimerProxy::NewL(
       
    50     MCatalogsClientServer& aSession,
       
    51     TInt aHandle,
       
    52     CNcdNodeMetadataProxy* aMetadata )
       
    53     {
       
    54     CNcdNodeDisclaimerProxy* self = 
       
    55         CNcdNodeDisclaimerProxy::NewLC( aSession, aHandle, aMetadata );
       
    56     CleanupStack::Pop( self );
       
    57     return self;
       
    58     }
       
    59 
       
    60 CNcdNodeDisclaimerProxy* CNcdNodeDisclaimerProxy::NewLC(
       
    61     MCatalogsClientServer& aSession,
       
    62     TInt aHandle,
       
    63     CNcdNodeMetadataProxy* aMetadata )
       
    64     {
       
    65     CNcdNodeDisclaimerProxy* self = 
       
    66         new( ELeave ) CNcdNodeDisclaimerProxy( aSession, aHandle, aMetadata );
       
    67     // Using PushL because the object does not have any references yet
       
    68     CleanupStack::PushL( self );
       
    69     self->ConstructL();
       
    70     return self;
       
    71     }
       
    72 
       
    73 
       
    74 CNcdNodeDisclaimerProxy::~CNcdNodeDisclaimerProxy()
       
    75     {
       
    76     // Delete member variables here
       
    77     // Do not delete node and operation manager because
       
    78     // this object does not own them.
       
    79     delete iTitle;
       
    80     iTitle = 0;
       
    81     delete iBody;
       
    82     iBody = 0;
       
    83     }
       
    84 
       
    85 
       
    86 void CNcdNodeDisclaimerProxy::InternalizeL()
       
    87     {
       
    88     DLTRACEIN((""));
       
    89 
       
    90     HBufC8* data( NULL );
       
    91         
       
    92     // Because we do not know the exact size of the data, use
       
    93     // the alloc method, which creates the buffer of the right size
       
    94     // and sets the pointer to point to the created buffer.
       
    95     // Get all the data that is necessary to internalize this object
       
    96     // from the server side.
       
    97     TInt error(
       
    98         ClientServerSession().
       
    99         SendSyncAlloc( NcdNodeFunctionIds::ENcdInternalize,
       
   100                        KNullDesC8,
       
   101                        data,
       
   102                        Handle(),
       
   103                        0 ) );
       
   104 
       
   105     if ( error == KNcdErrorObsolete )
       
   106         {
       
   107         DLINFO(("Disclaimer was obsolete"));
       
   108         // Because this object does not add any interfaces to the top parent,
       
   109         // there is no need to remove then either here.
       
   110         // Just remove object from the parent
       
   111         RemoveFromParent();        
       
   112         }
       
   113 
       
   114     // If error occurred during data transfer, leave here and forward the error.
       
   115     User::LeaveIfError( error );
       
   116 
       
   117     if ( data == NULL )
       
   118         {
       
   119         DLERROR((""));
       
   120         User::Leave(  KErrNotFound );
       
   121         }
       
   122 
       
   123      CleanupStack::PushL( data );
       
   124 
       
   125      // Read the data from the stream and insert it to the memeber variables
       
   126      RDesReadStream stream( *data );
       
   127      CleanupClosePushL( stream );
       
   128     
       
   129      InternalizeDataL( stream );
       
   130     
       
   131      // Closes the stream
       
   132      CleanupStack::PopAndDestroy( &stream ); 
       
   133      CleanupStack::PopAndDestroy( data );
       
   134 
       
   135     DLTRACEOUT((""));    
       
   136     }
       
   137 
       
   138 
       
   139 // MNcdQuery functions
       
   140 
       
   141 TBool CNcdNodeDisclaimerProxy::IsOptional() const
       
   142     {
       
   143     return iOptional;
       
   144     }
       
   145 
       
   146 
       
   147 MNcdQuery::TSemantics CNcdNodeDisclaimerProxy::Semantics() const
       
   148     {
       
   149     return iSemantics;
       
   150     }
       
   151     
       
   152 const TDesC& CNcdNodeDisclaimerProxy::MessageTitle() const
       
   153     {
       
   154     if( !iTitle )
       
   155         {
       
   156         return KNullDesC;
       
   157         }
       
   158     return *iTitle;
       
   159     }
       
   160     
       
   161     
       
   162 const TDesC& CNcdNodeDisclaimerProxy::MessageBody() const
       
   163     {
       
   164     if( !iBody )
       
   165         {
       
   166         return KNullDesC;
       
   167         }
       
   168     return *iBody;
       
   169     }
       
   170     
       
   171     
       
   172 RCatalogsArray< MNcdQueryItem > CNcdNodeDisclaimerProxy::QueryItemsL()
       
   173     {
       
   174     RCatalogsArray<MNcdQueryItem> array;
       
   175     return array;
       
   176     }
       
   177 
       
   178 
       
   179 void CNcdNodeDisclaimerProxy::SetResponseL( TResponse aResponse )
       
   180     {
       
   181     iResponse = aResponse;
       
   182     }
       
   183 
       
   184 
       
   185 MNcdQuery::TResponse CNcdNodeDisclaimerProxy::Response()
       
   186     {
       
   187     return iResponse;
       
   188     }
       
   189     
       
   190     
       
   191 TBool CNcdNodeDisclaimerProxy::IsSecureConnection() const
       
   192     {
       
   193     return EFalse;
       
   194     }
       
   195     
       
   196 
       
   197 // Other functions
       
   198 
       
   199 void CNcdNodeDisclaimerProxy::InternalizeDataL( RReadStream& aStream )
       
   200     {
       
   201     DLTRACEIN((""));
       
   202 
       
   203     // Use catalogsutils.h functions to internalize
       
   204     // memebervariables according to the data received
       
   205     // from the server.
       
   206     // Make sure that the variables are set here in the same
       
   207     // order as they are externalized in the server side.
       
   208     // Small mistake here messes up everything!
       
   209 
       
   210     // First read the class id. Because, it is the first thing in the stream.
       
   211     // Actually we do not need that information here.
       
   212     aStream.ReadInt32L();
       
   213 
       
   214     InternalizeDesL( iTitle, aStream );
       
   215     InternalizeDesL( iBody, aStream );
       
   216     iOptional = aStream.ReadInt32L();
       
   217     iSemantics = 
       
   218         static_cast<MNcdQuery::TSemantics>(aStream.ReadInt32L());
       
   219         
       
   220     DLTRACEOUT((""));
       
   221     }